From 5c830709416de04e669fb50b2e2845be757ef322 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Tue, 11 Jul 2023 21:28:38 -0400 Subject: [PATCH] fix: Pasting rich text into image caption inherits styling --- shared/editor/nodes/Image.tsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/shared/editor/nodes/Image.tsx b/shared/editor/nodes/Image.tsx index c2186a95c..5b825b3b2 100644 --- a/shared/editor/nodes/Image.tsx +++ b/shared/editor/nodes/Image.tsx @@ -215,6 +215,14 @@ export default class Image extends SimpleImage { void downloadImageNode(node); }; + // Ensure only plain text can be pasted into input when pasting from another + // rich text source. + handlePaste = (event: React.ClipboardEvent) => { + event.preventDefault(); + const text = event.clipboardData.getData("text/plain"); + window.document.execCommand("insertText", false, text); + }; + component = (props: ComponentProps) => (