From d805d94a0c82ac57ab7909e791e9f3c8696ae062 Mon Sep 17 00:00:00 2001 From: umaranis Date: Tue, 26 Mar 2024 21:51:01 +1100 Subject: [PATCH] bug: Prevent file:/// img conversion --- .../src/core/plugins/Image/ImageNode.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/svelte-lexical/src/core/plugins/Image/ImageNode.ts b/packages/svelte-lexical/src/core/plugins/Image/ImageNode.ts index a5d957b7..904aa819 100644 --- a/packages/svelte-lexical/src/core/plugins/Image/ImageNode.ts +++ b/packages/svelte-lexical/src/core/plugins/Image/ImageNode.ts @@ -35,12 +35,13 @@ export interface ImagePayload { } function convertImageElement(domNode: Node): null | DOMConversionOutput { - if (domNode instanceof HTMLImageElement) { - const {alt: altText, src, width, height} = domNode; - const node = $createImageNode({altText, height, src, width}); - return {node}; + const img = domNode as HTMLImageElement; + if (img.src.startsWith('file:///')) { + return null; } - return null; + const {alt: altText, src, width, height} = img; + const node = $createImageNode({altText, height, src, width}); + return {node}; } export type SerializedImageNode = Spread<