Appearance
起步套件 StartKit
StartKit 是编辑器全部扩展的聚合扩展,通过 addExtensions() 一次性注册官方基础节点 / 标记、自定义节点、自定义标记与功能扩展,并嵌套复用 TableKit 与 QuestionKit,将 30+ 项扩展的手写注册收敛为单个入口。
用法
最小可用配置(全部成员走默认配置注册):
ts
import { StartKit } from '@qingpai/core'
import { Editor } from '@tiptap/core'
const editor = new Editor({
extensions: [
StartKit,
],
})按需配置与关闭成员:
ts
StartKit.configure({
// 传对象:作为该扩展的 configure 配置透传
image: {
allowBase64: true,
},
heading: {
levels: [1, 2, 3],
},
tableKit: {
table: {
resizable: true,
},
},
// 传 false:关闭该成员
pinyin: false,
})Settings
StartKitOptions 全部成员均可省略——省略时按各扩展的默认配置注册(gapClick 例外,省略时不注册,见功能扩展表)。
官方基础扩展
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
bold | Partial<BoldOptions> | false | 注册 | 加粗 |
document | false | 注册 | 文档根节点(无配置项,仅可传 false 关闭) |
hardBreak | Partial<HardBreakOptions> | false | 注册 | 硬换行 |
heading | Partial<HeadingOptions> | false | 注册 | 标题 |
history | Partial<HistoryOptions> | false | 注册 | 撤销 / 重做 |
italic | Partial<ItalicOptions> | false | 注册 | 斜体 |
paragraph | Partial<ParagraphOptions> | false | 注册 | 段落 |
strike | Partial<StrikeOptions> | false | 注册 | 删除线 |
subscript | Partial<SubscriptExtensionOptions> | false | 注册 | 下标 |
superscript | Partial<SuperscriptExtensionOptions> | false | 注册 | 上标 |
text | false | 注册 | 文本(无配置项,仅可传 false 关闭) |
textAlign | Partial<TextAlignOptions> | false | 注册 | 文本对齐 |
textStyleKit | Partial<TextStyleKitOptions> | false | 注册 | 文本样式容器(font-size、font-family、color 等属性的载体) |
uniqueId | Partial<UniqueIDOptions> | false | 注册 | 块级唯一 ID |
自定义节点
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
image | Partial<ImageOptions> | false | 注册 | 图片(缩放手柄) |
math | Partial<MathOptions> | false | 注册 | 数学公式 |
pinyin | Partial<PinyinOptions> | false | 注册 | 拼音 |
typedContainer | Partial<TypedContainerOptions> | false | 注册 | 类型化容器 |
聚合套件
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
tableKit | Partial<TableKitOptions> | false | 注册 | 表格套件(Table / TableRow / TableHeader / TableCell 聚合) |
questionKit | Partial<QuestionKitOptions> | false | 注册 | 试题套件(全部题目节点聚合) |
自定义标记
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
emphasis | Partial<EmphasisOptions> | false | 注册 | 着重号 |
textBox | Partial<TextBoxOptions> | false | 注册 | 文本框 |
underline | Partial<UnderlineOptions> | false | 注册 | 下划线 |
功能扩展
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
clipboard | Partial<ClipboardOptions> | false | 注册 | 剪贴板 |
clearFormatting | Partial<ClearFormattingOptions> | false | 注册 | 清除格式 |
convert | Partial<ConvertOptions> | false | 注册 | 选区转试题 |
dragHandle | Partial<DragHandleOptions> | false | 注册 | 拖拽手柄 |
dropcursor | Partial<DropcursorOptions> | false | 注册 | 放置光标 |
fixGapCursor | Partial<FixGapCursorOptions> | false | 注册 | 缝隙修复(默认修复 question 三处边界) |
gapClick | Partial<GapClickOptions> | false | 不注册 | 间隙点击(点击顶层块间空隙插入段落;默认禁用,传配置对象开启) |
indent | Partial<IndentOptions> | false | 注册 | 缩进 |
keepEmptyParagraph | false | 注册 | 末尾空段落 |
loading | Partial<LoadingOptions> | false | 注册 | 加载遮罩 |
move | Partial<MoveOptions> | false | 注册 | 块移动 |
paste | Partial<PasteOptions> | false | 注册 | 粘贴 |
placeholder | Partial<PlaceholderOptions> | false | 注册 | 占位提示 |
wordImport | Partial<WordImportOptions> | false | 注册 | Word 导入 |
founderImport | Partial<FounderImportOptions> | false | 注册 | 方正书版导入 |
resourceExplorer | Partial<ResourceExplorerOptions> | false | 注册 | 资源浏览器 |
不包含 context-menu / popover
Popover 与 ContextMenu 是 ProseMirror 插件工厂而非 TipTap 扩展,由 @qingpai/vue 的组件在内部消费,不在 StartKit 注册范围内。
Source code
packages/core/src/start-kit/