From e86fe0767d63956abfb732d754a0ec10401c5bd1 Mon Sep 17 00:00:00 2001 From: xfy Date: Mon, 6 Jul 2026 15:48:02 +0800 Subject: [PATCH] =?UTF-8?q?feat(editor):=20=E7=94=A8=20CodeBlockLowlight?= =?UTF-8?q?=20=E6=9B=BF=E6=8D=A2=20StarterKit=20=E8=87=AA=E5=B8=A6=20CodeB?= =?UTF-8?q?lock?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 禁用 StarterKit codeBlock,引入 CodeBlockLowlight + lowlight 实例。 代码块现在有实时语法高亮(ProseMirror decoration),language 属性 仍承载完整 info string(markdown 往返不变)。 --- libs/tiptap-editor/src/index.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libs/tiptap-editor/src/index.ts b/libs/tiptap-editor/src/index.ts index f4fcc65..483e8c0 100644 --- a/libs/tiptap-editor/src/index.ts +++ b/libs/tiptap-editor/src/index.ts @@ -3,7 +3,9 @@ import { FileHandler } from '@tiptap/extension-file-handler'; import { TaskItem, TaskList } from '@tiptap/extension-list'; import { TableKit } from '@tiptap/extension-table'; import { Markdown } from '@tiptap/markdown'; +import CodeBlockLowlight from '@tiptap/extension-code-block-lowlight'; import StarterKit from '@tiptap/starter-kit'; +import { lowlight } from './highlight'; import { SlashCommand } from './slash-command'; import { TaskInputRule } from './task-input-rule'; import { @@ -98,8 +100,10 @@ class TiptapEditorInstance { linkOnPaste: true, HTMLAttributes: { rel: 'noopener noreferrer', target: '_blank' }, }, + codeBlock: false, }), Markdown, + CodeBlockLowlight.configure({ lowlight }), TableKit, UploadImage, TaskList,