From 65bbabe69b3fe84bd6fd90e3cfc8b1f2a59d4a44 Mon Sep 17 00:00:00 2001 From: kric_jspark Date: Tue, 28 Jul 2026 14:42:46 +0900 Subject: [PATCH] =?UTF-8?q?260728=5F04=5FENH:=20Wysiwyg=20=EC=97=90?= =?UTF-8?q?=EB=94=94=ED=84=B0=20=EB=B2=84=EA=B7=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/kri-editor/KriEditorWysiwyg.tsx | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/components/kri-editor/KriEditorWysiwyg.tsx b/src/components/kri-editor/KriEditorWysiwyg.tsx index 4149555..40c3d90 100644 --- a/src/components/kri-editor/KriEditorWysiwyg.tsx +++ b/src/components/kri-editor/KriEditorWysiwyg.tsx @@ -103,7 +103,6 @@ export function KriEditorWysiwyg(props: KriEditorProps) { const htmlTi = useTextareaInsert(htmlTextareaRef); const [view, setView] = useState("wysiwyg"); - const [wysiwygKey, setWysiwygKey] = useState(0); const [previewSource, setPreviewSource] = useState(value ?? ""); const viewRef = useRef("wysiwyg"); @@ -252,7 +251,7 @@ export function KriEditorWysiwyg(props: KriEditorProps) { }, }, }, - },[wysiwygKey]); + }, []); const restoreSelection = useCallback(() => { if (!editor) return; @@ -482,21 +481,20 @@ export function KriEditorWysiwyg(props: KriEditorProps) { const current = editor.getHTML(); if (normalizedValue !== current && normalizedValue !== optimisticHtmlRef.current) { - // 이미지가 포함된 HTML 업데이트면, 아예 editor를 새로 생성 + // 외부에서 본문이 변경된 경우에만 기존 editor 문서를 갱신한다. editor.commands.setContent(normalizedValue, { emitUpdate: false, parseOptions: {preserveWhitespace: "full"}, }); + + // resize가 활성화된 TipTap 이미지 NodeView는 노드의 src 변경을 기존 DOM에 반영하지 않는다. + // editor 전체 대신 NodeView만 다시 생성해 이미지를 갱신하고 편집 포커스는 유지한다. + if (normalizedValue.includes(" { - if (value.includes(" k + 1); - return; - } - }, [value]); - useEffect(() => { if (!editor) return;