From b35a8e6d5ef11223a10e585be059cb9e9010e2de Mon Sep 17 00:00:00 2001 From: umaranis Date: Sat, 31 Aug 2024 12:45:44 +1000 Subject: [PATCH] bug: support pasting google doc checklist --- .../src/lib/core/plugins/Image/ImageNode.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/svelte-lexical/src/lib/core/plugins/Image/ImageNode.ts b/packages/svelte-lexical/src/lib/core/plugins/Image/ImageNode.ts index 904aa81..45163cb 100644 --- a/packages/svelte-lexical/src/lib/core/plugins/Image/ImageNode.ts +++ b/packages/svelte-lexical/src/lib/core/plugins/Image/ImageNode.ts @@ -34,9 +34,18 @@ export interface ImagePayload { captionsEnabled?: boolean; } +function isGoogleDocCheckboxImg(img: HTMLImageElement): boolean { + return ( + img.parentElement != null && + img.parentElement.tagName === 'LI' && + img.previousSibling === null && + img.getAttribute('aria-roledescription') === 'checkbox' + ); +} + function convertImageElement(domNode: Node): null | DOMConversionOutput { const img = domNode as HTMLImageElement; - if (img.src.startsWith('file:///')) { + if (img.src.startsWith('file:///') || isGoogleDocCheckboxImg(img)) { return null; } const {alt: altText, src, width, height} = img;