From ae204deba2313f2b6b4182e23234420f23f17c40 Mon Sep 17 00:00:00 2001 From: fantasticit Date: Tue, 10 May 2022 10:26:11 +0800 Subject: [PATCH] tiptap: fix update link --- packages/client/src/tiptap/editor/menus/link/modal.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/client/src/tiptap/editor/menus/link/modal.tsx b/packages/client/src/tiptap/editor/menus/link/modal.tsx index a08425e..b5e3735 100644 --- a/packages/client/src/tiptap/editor/menus/link/modal.tsx +++ b/packages/client/src/tiptap/editor/menus/link/modal.tsx @@ -25,7 +25,9 @@ export const LinkSettingModal: React.FC = ({ editor }) => { const { view } = editor; const schema = view.state.schema; const node = schema.text(values.text, [schema.marks.link.create({ href: values.href })]); - view.dispatch(view.state.tr.replaceRangeWith(from, to, node)); + + view.dispatch(view.state.tr.deleteRange(from, to)); + view.dispatch(view.state.tr.insert(from, node)); view.dispatch(view.state.tr.scrollIntoView()); toggleVisible(false); });