mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-06-25 16:04:02 +08:00
🐛 fix(monaco-editor): 禁用 EditContext 修复中文输入异常
- 在 MonacoEditor 中统一关闭 editContext - 修复单引号场景下中文输入首次上屏异常 - 补充编辑器选项回归断言 Close #578
This commit is contained in:
@@ -113,7 +113,10 @@ const MonacoEditor: React.FC<MonacoEditorProps> = ({
|
||||
|
||||
const resolvedOptions = useMemo(() => {
|
||||
if (uiVersion !== 'v2') {
|
||||
return options;
|
||||
return {
|
||||
...options,
|
||||
editContext: false,
|
||||
};
|
||||
}
|
||||
|
||||
const effectiveGlobalFontSize = Math.min(
|
||||
@@ -129,6 +132,7 @@ const MonacoEditor: React.FC<MonacoEditorProps> = ({
|
||||
|
||||
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)),
|
||||
|
||||
@@ -57,6 +57,7 @@ describe('MonacoEditor typography', () => {
|
||||
<MonacoEditor options={{ minimap: { enabled: false } }} />,
|
||||
);
|
||||
|
||||
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', () => {
|
||||
<MonacoEditor options={{ fontFamily: 'Consolas', fontSize: 18 }} />,
|
||||
);
|
||||
|
||||
expect(markup).toContain('"editContext":false');
|
||||
expect(markup).toContain('"fontFamily":"Consolas"');
|
||||
expect(markup).toContain('"fontSize":18');
|
||||
expect(markup).not.toContain('JetBrains Mono');
|
||||
|
||||
Reference in New Issue
Block a user