Appearance
EditorContent
编辑器宿主聚合组件:底层渲染 TipTap EditorContent 并透传其全部原生 props / emits / 插槽,同时按开关挂载编辑器的配套功能——公式对话框、拼音对话框、气泡菜单套件、拖拽手柄、题号浮层与右键菜单,一个组件替代七个手动挂载。
用法
vue
<script setup lang="ts">
import { EditorContent, Toolbar } from '@qingpai/vue'
import { Editor } from '@tiptap/vue-3'
const editor = shallowRef<Editor>()
onMounted(() => {
editor.value = new Editor({ extensions: [StartKit] })
})
</script>
<template>
<Toolbar :editor="editor" />
<EditorContent :editor="editor" />
</template>六个功能开关默认全部开启;不需要的显式关闭:
vue
<template>
<EditorContent
:editor="editor"
:drag-handle="false"
:context-menu="false"
/>
</template>TipTap EditorContent 的原生 props、emits、插槽(当前原生面仅 editor prop)经 $attrs 直接透传,未来 TipTap 新增原生能力无需改动本组件。
Props
| Prop | 类型 | 默认值 | 必填 | 说明 |
|---|---|---|---|---|
editor | Editor | — | 是 | 编辑器实例 |
mathDialog | boolean | true | 否 | 挂载 MathDialog(公式对话框) |
pinyinDialog | boolean | true | 否 | 挂载 PinyinDialog(拼音对话框) |
bubbleMenuKit | boolean | true | 否 | 挂载 BubbleMenuKit(气泡菜单套件) |
dragHandle | boolean | true | 否 | 挂载 DragHandle(拖拽手柄) |
questionNumberPopover | boolean | true | 否 | 挂载 QuestionNumberPopover(题号设置浮层) |
contextMenu | boolean | true | 否 | 挂载 ContextMenu(题目右键菜单) |
六个功能组件均显式接收 editor,不受编辑器上下文影响;其余 TipTap EditorContent 原生 props 经 $attrs 透传。
插槽
| 名称 | 参数 | 说明 |
|---|---|---|
| (任意) | 随 TipTap EditorContent 插槽 | 动态透传:消费方传入的插槽原样转发给底层组件 |