build(deps): 添加 Tiptap 富文本编辑器依赖

This commit is contained in:
yelan
2026-09-11 16:13:05 +08:00
parent 7035c6f378
commit 1b576c6095
5 changed files with 1083 additions and 9 deletions
@@ -1,9 +1,11 @@
<script setup lang="ts">
import { reactive, ref, watch } from 'vue'
import { ElMessage } from 'element-plus'
import type { CampusRecord, DepartmentRecord } from '@/api/management/types'
import EditorCkPane from './editors/EditorCkPane.vue'
import EditorTipTapPane from './editors/EditorTipTapPane.vue'
import EditorTinyPane from './editors/EditorTinyPane.vue'
import EditorWangPane from './editors/EditorWangPane.vue'
import type { DocumentTemplate, TemplateEditorForm } from '../types'
@@ -24,7 +26,7 @@ const emit = defineEmits<{
// Word 自维护方案:科室把文书从 Word/WPS 直接粘贴进来(保留表格与基本格式),
// 或上传 .docx 由 mammoth 转换;签署时由交互管线识别"勾选"表并转为签署域。
// 富文本引擎做成可切换的三套(对比 Word 粘贴保真度),存储统一为编辑器产出的 HTML。
type EditorEngine = 'wangeditor' | 'ckeditor5' | 'tinymce'
type EditorEngine = 'wangeditor' | 'ckeditor5' | 'tinymce' | 'tiptap'
interface EditorPaneHandle {
getText: () => string
@@ -35,6 +37,7 @@ const engineComponents = {
wangeditor: EditorWangPane,
ckeditor5: EditorCkPane,
tinymce: EditorTinyPane,
tiptap: EditorTipTapPane,
}
const engineOptions: Array<{ key: EditorEngine; label: string; note: string }> = [
@@ -53,6 +56,11 @@ const engineOptions: Array<{ key: EditorEngine; label: string; note: string }> =
label: 'TinyMCE',
note: '均衡之选(MIT)',
},
{
key: 'tiptap',
label: 'TipTap',
note: 'ProseMirror 架构,可自定义签署域节点;粘贴走 schema,样式有损(MIT)',
},
]
const engine = ref<EditorEngine>('wangeditor')
@@ -162,15 +170,23 @@ async function handleDocxChange(event: Event) {
}
function save() {
const text = paneRef.value?.getText() ?? ''
// 引擎面板句柄可能因初始化时序暂不可用,此时用 valueHtml 兜底判空,避免误报"内容为空"。
const handleText = paneRef.value?.getText() ?? ''
const fallbackText = valueHtml.value
.replace(/<[^>]*>/g, ' ')
.replace(/&nbsp;/g, ' ')
.trim()
const text = handleText || fallbackText
if (!form.name.trim()) {
importMessage.value = '请填写文书名称'
ElMessage.error('请填写文书名称')
return
}
if (!text) {
importMessage.value = '文书内容为空,请粘贴 Word 内容或导入 .docx'
ElMessage.error('文书内容为空,请粘贴 Word 内容或导入 .docx')
return
}