如何在 tiptap 文本编辑器中向用户推荐一些预加载的文本?

问题描述 投票:0回答:1

我想在用户点击 tip-tap 编辑器时向用户提供建议。该建议将是一些预加载的文本。如果用户喜欢那个建议,那么他可以通过点击回车键或键盘上的右箭头键按钮将该建议保存在他的数据库中。

reactjs next rich-text-editor tiptap prose-mirror
1个回答
0
投票

您可以像文档

中的
示例一样使用Floating Menu并使用插入内容。

{
  editor && (
    <FloatingMenu editor={editor} tippyOptions={{ duration: 100 }}>
      <button
        onClick={() => editor.chain().focus().insertContent("hello").run()}
      >
        hello
      </button>
      <button
        onClick={() => editor.chain().focus().insertContent("world").run()}
      >
        world
      </button>
    </FloatingMenu>
  );
}
<EditorContent editor={editor} />

请注意,您可能需要使用

shouldShow
prop.

© www.soinside.com 2019 - 2024. All rights reserved.