Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: re-enable preview for interactive objkts #354

Merged
merged 5 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/components/media-types/html/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export const HTMLComponent = (props) => {
const unpackZipFiles = async () => {
unpacking.current = true

const buffer = dataRUIToBuffer(previewUri)
const buffer = await dataRUIToBuffer(previewUri)

try {
const filesArr = await prepareFilesFromZIP(buffer)
Expand Down Expand Up @@ -122,7 +122,7 @@ export const HTMLComponent = (props) => {
<iframe
ref={iframeRef}
title={`interactive object ${nft.token_id}`}
src={`https://iframe.teia.art/html?uid=${uid}&creator=${_creator_}&viewer=${_viewer_}&objkt=${_objectId_}`}
src={`https://iframe.teia.art/html/?uid=${uid}&creator=${_creator_}&viewer=${_viewer_}&objkt=${_objectId_}`}
sandbox={sandbox_features}
allow={allowed_features}
/>
Expand Down
2 changes: 2 additions & 0 deletions src/components/media-types/html/index.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

&.interactive {
pointer-events: all;
width: 100%;
height: 100%;
}

.preview {
Expand Down
2 changes: 1 addition & 1 deletion src/components/media-types/vector/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,6 @@ export const VectorComponent = ({
)
}
// svg version: src={`${src}?author=${_creator_}&viewer=${_viewer_}`}
// iframe version: src={`https://iframe.teia.art/svg?src=${src}&creator=${_creator_}&viewer=${_viewer_}`}
// iframe version: src={`https://iframe.teia.art/svg/?src=${src}&creator=${_creator_}&viewer=${_viewer_}`}

export default VectorComponent
13 changes: 4 additions & 9 deletions src/utils/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,14 +288,9 @@ export async function validateFiles(files) {
}
}

export function dataRUIToBuffer(dataURI) {
const parts = dataURI.split(',')
const base64 = parts[1]
const binaryStr = atob(base64)
const len = binaryStr.length
const bytes = new Uint8Array(len)
for (let i = 0; i < len; i++) {
bytes[i] = binaryStr.charCodeAt(i)
}
export async function dataRUIToBuffer(dataURI) {
const blob = await fetch(dataURI).then((r) => r.blob())
const binaryStr = await new Response(blob).arrayBuffer()
const bytes = new Uint8Array(binaryStr)
return bytes
}
Loading