插入后如何阻止 tiptap 链接传播?

How to stop tiptap Link from propagating after insertion?

提问人:BingeCode 提问时间:9/13/2023 更新时间:9/13/2023 访问量:63

问:

在编辑器中使用 tiptap 将链接插入到选定的文本上后,当我键入更多文本时,链接传播会继续。如何停止传播?

提示点

评论


答:

0赞 BingeCode 9/13/2023 #1

修复非常简单。 在代码中设置编辑器时,可以扩展链接标记,如下所示:

this.editor = new Editor({
  element: this.editorRef,
  extensions: [
    //...
    Link.extend({
      inclusive: false,
    })
    //...
  ]
});

inclusive: false确保链接不包含光标的最终位置。