StarterKit 扩展

版本下载量

StarterKit 是一个集合了最受欢迎的 Tiptap 扩展的工具。如果你刚开始,这个扩展非常适合你。

安装

npm install @tiptap/starter-kit

包含的扩展

节点

标记

扩展功能

源代码

packages/starter-kit/

使用 StarterKit 扩展

StarterKit 传递给编辑器,以一次加载所有包含的扩展。

import { Editor } from '@tiptap/core'
import StarterKit from '@tiptap/starter-kit'

const editor = new Editor({
  content: '<p>示例文本</p>',
  extensions: [StarterKit],
})

你可以配置包含的扩展,甚至禁用其中的一些,如下所示。

import { Editor } from '@tiptap/core'
import StarterKit from '@tiptap/starter-kit'

const editor = new Editor({
  content: '<p>示例文本</p>',
  extensions: [
    StarterKit.configure({
      // 禁用一个包含的扩展
      undoRedo: false,

      // 配置一个包含的扩展
      heading: {
        levels: [1, 2],
      },
    }),
  ],
})

Tiptap 不允许存在两个具有相同 name 属性的扩展。如果自定义扩展与 StarterKit 中包含的某个扩展同名,请将其禁用:

import { Editor, Mark } from '@tiptap/core'
import StarterKit from '@tiptap/starter-kit'
import Link from '@tiptap/extension-link'

const CustomLinkExtension = Mark.create({
  name: 'link',
})

const editor = new Editor({
  extensions: [
    StarterKit.configure({
      // 禁用 Link 扩展
      // 以免它与 CustomLinkExtension 冲突
      link: false,
    }),
    CustomLinkExtension,
  ],
})