From ed42857e779a8d410a725f5e4bb84a5e2573a394 Mon Sep 17 00:00:00 2001 From: hanchayi Date: Tue, 20 Jan 2026 12:34:12 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=96=87=E6=9C=AC=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E5=99=A8):=20=E6=94=AF=E6=8C=81SVG=E6=96=87=E4=BB=B6=E8=AF=AD?= =?UTF-8?q?=E6=B3=95=E9=AB=98=E4=BA=AE=E5=B9=B6=E4=BC=98=E5=8C=96=E8=B7=AF?= =?UTF-8?q?=E5=BE=84=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加SVG文件扩展名到HTML语言支持列表,使其能够进行语法高亮 修改路径处理逻辑,允许可选路径参数并提供默认值 --- .../feat-svg-highlight_2026-01-20-04-34.json | 11 +++++++++++ .../text-editor/dev/src/pages/highlight/examples.tsx | 8 ++++++++ .../preset-code-languages/src/languages.ts | 2 +- .../text-editor/preset-code-languages/src/preset.ts | 2 +- 4 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 common/changes/@coze-editor/preset-code-languages/feat-svg-highlight_2026-01-20-04-34.json diff --git a/common/changes/@coze-editor/preset-code-languages/feat-svg-highlight_2026-01-20-04-34.json b/common/changes/@coze-editor/preset-code-languages/feat-svg-highlight_2026-01-20-04-34.json new file mode 100644 index 00000000..544caac6 --- /dev/null +++ b/common/changes/@coze-editor/preset-code-languages/feat-svg-highlight_2026-01-20-04-34.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "packageName": "@coze-editor/preset-code-languages", + "comment": "支持SVG文件语法高亮并优化路径处理", + "type": "minor" + } + ], + "packageName": "@coze-editor/preset-code-languages", + "email": "hanchayi@163.com" +} diff --git a/packages/text-editor/dev/src/pages/highlight/examples.tsx b/packages/text-editor/dev/src/pages/highlight/examples.tsx index e251221c..c1fcfc1f 100644 --- a/packages/text-editor/dev/src/pages/highlight/examples.tsx +++ b/packages/text-editor/dev/src/pages/highlight/examples.tsx @@ -61,6 +61,14 @@ export default App; }, { code: ` + + + +`, + path: 'a.svg', + }, + { + code: ` body { background-color: #f0f0f0; } diff --git a/packages/text-editor/preset-code-languages/src/languages.ts b/packages/text-editor/preset-code-languages/src/languages.ts index ddd4c801..e4a86750 100644 --- a/packages/text-editor/preset-code-languages/src/languages.ts +++ b/packages/text-editor/preset-code-languages/src/languages.ts @@ -50,7 +50,7 @@ export const supportedLanguages = [ }), LanguageDescription.of({ name: 'HTML', - extensions: ['html'], + extensions: ['html', 'svg'], async load() { return import('@codemirror/lang-html').then(module => module.html()); }, diff --git a/packages/text-editor/preset-code-languages/src/preset.ts b/packages/text-editor/preset-code-languages/src/preset.ts index 8240582c..ed7d6c91 100644 --- a/packages/text-editor/preset-code-languages/src/preset.ts +++ b/packages/text-editor/preset-code-languages/src/preset.ts @@ -3,7 +3,7 @@ import { asyncOption } from '@coze-editor/core'; import { getLanguage } from './languages'; export const preset = [ - ...asyncOption('path', (path: string) => getLanguage(path), { + ...asyncOption('path', (path?: string) => getLanguage(path ?? ''), { reset: true, }), ];