tiptap: fix update link

This commit is contained in:
fantasticit 2022-05-10 10:26:11 +08:00
parent 776db2bc7f
commit ae204deba2
1 changed files with 3 additions and 1 deletions

View File

@ -25,7 +25,9 @@ export const LinkSettingModal: React.FC<IProps> = ({ 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);
});