Skip to content
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
2 changes: 1 addition & 1 deletion packages/super-editor/src/editors/v1/core/DocxZipper.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { reconcileDocumentRelationships, MANAGED_DOCUMENT_PARTS } from './opc/re
const IMAGE_EXTS = new Set(['png', 'jpg', 'jpeg', 'gif', 'bmp', 'tiff', 'tif', 'emf', 'wmf', 'svg', 'webp']);

/** Map file extensions to correct MIME sub-types where they differ. */
const MIME_TYPE_FOR_EXT = { tif: 'tiff', jpg: 'jpeg' };
const MIME_TYPE_FOR_EXT = { tif: 'tiff', jpg: 'jpeg', svg: 'svg+xml' };
const CUSTOM_XML_ITEM_PROPS_CONTENT_TYPE = 'application/vnd.openxmlformats-officedocument.customXmlProperties+xml';

/** OOXML content types for embedded font file extensions. */
Expand Down
Binary file not shown.
32 changes: 32 additions & 0 deletions tests/behavior/tests/importing/load-doc-with-svg.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { test, expect } from '../../fixtures/superdoc.js';
import { assertDocumentApiReady } from '../../helpers/document-api.js';

const __dirname = path.dirname(fileURLToPath(import.meta.url));
const DOC_PATH = path.resolve(__dirname, 'fixtures/svg-image.docx');

test.use({ config: { toolbar: 'full', comments: 'off' } });

test('loads DOCX with SVG image and renders it with the correct MIME type', async ({ superdoc }) => {
await superdoc.loadDocument(DOC_PATH);
await superdoc.waitForStable();
await assertDocumentApiReady(superdoc.page);

await expect(superdoc.page.locator('.superdoc-page').first()).toBeVisible();

const mediaEntry = await superdoc.page.evaluate(() => {
const editor = (window as any).editor;
const media = editor?.storage?.image?.media ?? {};
const svgKey = Object.keys(media).find((k) => k.toLowerCase().endsWith('.svg'));
return svgKey ? { key: svgKey, value: media[svgKey] } : null;
});

expect(mediaEntry, 'imported SVG should be registered in editor.storage.image.media').not.toBeNull();
expect(mediaEntry!.value, 'SVG data URI must use the image/svg+xml MIME type').toMatch(
/^data:image\/svg\+xml;base64,/,
);

const imgSrc = await superdoc.page.locator('img').first().getAttribute('src');
expect(imgSrc, 'rendered <img> should resolve to the SVG data URI').toMatch(/^data:image\/svg\+xml;base64,/);
});
Loading