From e965e44c992dc1219720fc084d67ea6957e66370 Mon Sep 17 00:00:00 2001 From: Kelvin Amoaba <97001695+AmoabaKelvin@users.noreply.github.com> Date: Tue, 10 Nov 2026 18:21:16 +0000 Subject: [PATCH] fix(editor): show SVGs without a fixed width in the rich markdown editor The image wrapper was inline-block, so it sized itself from the image's natural width. An SVG with a viewBox but no absolute width has none, so the wrapper and the image collapsed to 0x0. Keep the wrapper inline so the image sizes against the paragraph, as it does in the preview. --- .../rich-markdown/schema/rich-markdown-extensions.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/renderer/src/components/editor/rich-markdown/schema/rich-markdown-extensions.ts b/src/renderer/src/components/editor/rich-markdown/schema/rich-markdown-extensions.ts index 6deada4d943..653b47c2f71 100644 --- a/src/renderer/src/components/editor/rich-markdown/schema/rich-markdown-extensions.ts +++ b/src/renderer/src/components/editor/rich-markdown/schema/rich-markdown-extensions.ts @@ -125,13 +125,15 @@ export function createRichMarkdownExtensions({ return ({ node, HTMLAttributes, editor }) => { // A wrapper prevents native image-byte dragging from conflicting with ProseMirror’s schema-node relocation. const dom = document.createElement('span') - // Keep the image wrapper inline so it cannot break surrounding text onto separate lines. - dom.style.display = 'inline-block' + // Inline, not inline-block: a shrink-to-fit wrapper collapses an SVG that has a viewBox but no width to 0×0. + dom.style.display = 'inline' dom.style.lineHeight = '0' - dom.style.maxWidth = '100%' const img = document.createElement('img') img.draggable = false + // Undo preflight's block, middle-aligned images so text keeps flowing around them as before. + img.style.display = 'inline-block' + img.style.verticalAlign = 'baseline' let renderedAttributeNames = new Set() const syncImageAttributes = (attributes: Record): void => { const nextNames = new Set()