fix(@vben/plugins): 修复 tiptap 重复注册扩展警告 (#7917)

StarterKit v3.22.0 已默认包含 Document、Link、Underline 扩展,
与单独导入产生重复注册,导致控制台警告:
[tiptap warn]: Duplicate extension names found: ['link', 'doc', 'underline']

- 移除 Document 单独导入和使用,StarterKit 已内置
- 移除 Underline 单独导入和使用,StarterKit 已内置
- StarterKit 配置中添加 link: false,禁用内置 Link,
  保留自定义配置的 Link.configure({...})
pull/348/MERGE
JyQAQ 2026-05-16 10:45:30 +08:00 committed by GitHub
parent 42d82875ce
commit b5f79db321
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 34 additions and 37 deletions

View File

@ -9,14 +9,12 @@ import { $t } from '@vben/locales';
import { alert } from '@vben-core/popup-ui'; import { alert } from '@vben-core/popup-ui';
import Document from '@tiptap/extension-document';
import Highlight from '@tiptap/extension-highlight'; import Highlight from '@tiptap/extension-highlight';
import Image from '@tiptap/extension-image'; import Image from '@tiptap/extension-image';
import Link from '@tiptap/extension-link'; import Link from '@tiptap/extension-link';
import Placeholder from '@tiptap/extension-placeholder'; import Placeholder from '@tiptap/extension-placeholder';
import TextAlign from '@tiptap/extension-text-align'; import TextAlign from '@tiptap/extension-text-align';
import { Color, TextStyle } from '@tiptap/extension-text-style'; import { Color, TextStyle } from '@tiptap/extension-text-style';
import Underline from '@tiptap/extension-underline';
import { Plugin, PluginKey } from '@tiptap/pm/state'; import { Plugin, PluginKey } from '@tiptap/pm/state';
import StarterKit from '@tiptap/starter-kit'; import StarterKit from '@tiptap/starter-kit';
@ -405,13 +403,12 @@ export function createDefaultTiptapExtensions(
options: VbenTiptapExtensionOptions = {}, options: VbenTiptapExtensionOptions = {},
): Extensions { ): Extensions {
return [ return [
Document,
StarterKit.configure({ StarterKit.configure({
heading: { heading: {
levels: [1, 2, 3, 4], levels: [1, 2, 3, 4],
}, },
link: false,
}), }),
Underline,
TextAlign.configure({ TextAlign.configure({
types: ['heading', 'paragraph'], types: ['heading', 'paragraph'],
}), }),