From f1bafe3b37b4ddfe354a05beac08654b7e5dd005 Mon Sep 17 00:00:00 2001 From: Aleksandr Vasiuro Date: Sat, 27 Jul 2024 18:35:27 +0200 Subject: [PATCH] fix: editor focus --- components/lib/editor/Editor.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/components/lib/editor/Editor.js b/components/lib/editor/Editor.js index 04ab291fdb..ef74b7c990 100644 --- a/components/lib/editor/Editor.js +++ b/components/lib/editor/Editor.js @@ -123,7 +123,12 @@ export const Editor = React.memo( quill.current = quillInstance; if (props.value) { - quill.current.clipboard.dangerouslyPasteHTML(props.value); + quillInstance.setContents( + quillInstance.clipboard.convert({ + html: props.value, + text: '' + }) + ); } setQuillCreated(true); @@ -151,7 +156,16 @@ export const Editor = React.memo( useUpdateEffect(() => { if (quill.current && !quill.current.hasFocus()) { - props.value ? quill.current.clipboard.dangerouslyPasteHTML(props.value) : quill.current.setText(''); + if (props.value) { + quill.current.setContents( + quill.current.clipboard.convert({ + html: props.value, + text: '' + }) + ); + } else { + quill.current.setText(''); + } } }, [props.value]);