From 7f2445a6f52c20ac28392018d94b75f0f9cabb62 Mon Sep 17 00:00:00 2001 From: Syngnat Date: Sat, 20 Jun 2026 17:05:38 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(monaco-editor):=20=E7=A6=81?= =?UTF-8?q?=E7=94=A8=20EditContext=20=E4=BF=AE=E5=A4=8D=E4=B8=AD=E6=96=87?= =?UTF-8?q?=E8=BE=93=E5=85=A5=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 MonacoEditor 中统一关闭 editContext - 修复单引号场景下中文输入首次上屏异常 - 补充编辑器选项回归断言 Close #578 --- frontend/src/components/MonacoEditor.tsx | 6 +++++- frontend/src/components/MonacoEditor.typography.test.tsx | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/MonacoEditor.tsx b/frontend/src/components/MonacoEditor.tsx index ff25ce7..1153802 100644 --- a/frontend/src/components/MonacoEditor.tsx +++ b/frontend/src/components/MonacoEditor.tsx @@ -113,7 +113,10 @@ const MonacoEditor: React.FC = ({ const resolvedOptions = useMemo(() => { if (uiVersion !== 'v2') { - return options; + return { + ...options, + editContext: false, + }; } const effectiveGlobalFontSize = Math.min( @@ -129,6 +132,7 @@ const MonacoEditor: React.FC = ({ return { ...options, + editContext: false, fontFamily: options?.fontFamily ?? monoFontFamily ?? DEFAULT_MONO_FONT_FAMILY, fontSize: options?.fontSize ?? resolvedFontSize, lineHeight: options?.lineHeight ?? Math.max(18, Math.round(resolvedFontSize * 1.62)), diff --git a/frontend/src/components/MonacoEditor.typography.test.tsx b/frontend/src/components/MonacoEditor.typography.test.tsx index dc8a475..b90d625 100644 --- a/frontend/src/components/MonacoEditor.typography.test.tsx +++ b/frontend/src/components/MonacoEditor.typography.test.tsx @@ -57,6 +57,7 @@ describe('MonacoEditor typography', () => { , ); + expect(markup).toContain('"editContext":false'); expect(markup).toContain('JetBrains Mono'); expect(markup).toContain('ui-monospace'); expect(markup).toContain('"fontSize":13'); @@ -83,6 +84,7 @@ describe('MonacoEditor typography', () => { , ); + expect(markup).toContain('"editContext":false'); expect(markup).toContain('"fontFamily":"Consolas"'); expect(markup).toContain('"fontSize":18'); expect(markup).not.toContain('JetBrains Mono');