diff --git a/src/components/viewer/CadBlob.tsx b/src/components/viewer/CadBlob.tsx index 5338a7e..c3fa51e 100644 --- a/src/components/viewer/CadBlob.tsx +++ b/src/components/viewer/CadBlob.tsx @@ -36,7 +36,7 @@ export function CadBlob({ blob }: FileBlob): React.ReactElement { <> {geometry && ( - + 2 // Preview, Code, Blame + if (isPreviewAlreadyEnabled) { + const existingPreview = element.querySelector('iframe') + blob = existingPreview?.parentElement + if (blob && blob.parentElement) { + setBlobContainer(blob.parentElement) + blob.style.display = 'none' + } + // No toolbar, no sourceElements. Only a replacement of the existing (STL) preview + return + } + if (toolbar != null) { setToolbarContainer(toolbar) if (existingToggle) { @@ -110,7 +123,12 @@ function CadBlobPortal({ )} {blobContainer && createPortal( - + {richBlob ? ( ) : ( diff --git a/tests/extension.spec.ts b/tests/extension.spec.ts index f73b44a..bd382bd 100644 --- a/tests/extension.spec.ts +++ b/tests/extension.spec.ts @@ -99,3 +99,13 @@ test('blob preview with an .obj file', async ({ const screenshot = await getBlobPreviewScreenshot(page, url) expect(screenshot).toMatchSnapshot() }) + +test('blob preview with an .stl file', async ({ + page, + authorizedBackground, +}) => { + const url = + 'https://github.com/KittyCAD/diff-samples/blob/fd9eec79f0464833686ea6b5b34ea07145e32734/models/box.stl' + const screenshot = await getBlobPreviewScreenshot(page, url) + expect(screenshot).toMatchSnapshot() +}) diff --git a/tests/extension.spec.ts-snapshots/blob-preview-with-an-obj-file-1-chromium-linux.png b/tests/extension.spec.ts-snapshots/blob-preview-with-an-obj-file-1-chromium-linux.png index d0b5179..f8138a3 100644 Binary files a/tests/extension.spec.ts-snapshots/blob-preview-with-an-obj-file-1-chromium-linux.png and b/tests/extension.spec.ts-snapshots/blob-preview-with-an-obj-file-1-chromium-linux.png differ diff --git a/tests/extension.spec.ts-snapshots/blob-preview-with-an-stl-file-1-chromium-linux.png b/tests/extension.spec.ts-snapshots/blob-preview-with-an-stl-file-1-chromium-linux.png new file mode 100644 index 0000000..c413910 Binary files /dev/null and b/tests/extension.spec.ts-snapshots/blob-preview-with-an-stl-file-1-chromium-linux.png differ