Skip to content

Commit dc9c77b

Browse files
committed
fix: typo
1 parent fe4b3a1 commit dc9c77b

3 files changed

Lines changed: 7 additions & 4 deletions

File tree

docs/components/pro/monaco_editor/README-zh_CN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
| original | `str\| None` | None | 原始源的值(左侧)。 |
5454
| language | `str\| None` | None | 编辑器的语言(monaco-editor [支持](https://github.com/microsoft/monaco-editor/tree/main/src/basic-languages)的所有语言)。 |
5555
| original_language | `str\| None` | None | 单独指定原始源的语言。否则,它将获取 language 属性的值。 |
56-
| modified_Language | `str\| None` | None | 单独指定修改后的源的语言。否则,它将获取 language 属性的值。 |
56+
| modified_language | `str\| None` | None | 单独指定修改后的源的语言。否则,它将获取 language 属性的值。 |
5757
| line | `number\| None` | None | 垂直滚动编辑器到指定行。 |
5858
| read_only | `bool\| None` | None | 编辑器是否只读。 |
5959
| loading | `str\| None` | 'Editor is loading...' | 编辑器初始化加载时的加载文案。 |

docs/components/pro/monaco_editor/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ If you need further customization of Monaco Editor, you can pass in JavaScript f
5353
| original | `str\| None` | None | The original source (left one) value. |
5454
| language | `str\| None` | None | The language of the editor (all languages [supported](https://github.com/microsoft/monaco-editor/tree/main/src/basic-languages) by monaco-editor). |
5555
| original_language | `str\| None` | None | Specifies the language of the original source separately. Otherwise, it will take the value of the language property. |
56-
| modified_Language | `str\| None` | None | Specifies the language of the modified source separately. Otherwise, it will take the value of the language property. |
56+
| modified_language | `str\| None` | None | Specifies the language of the modified source separately. Otherwise, it will take the value of the language property. |
5757
| line | `number\| None` | None | Vertically scroll the editor to the specified line. |
5858
| read_only | `bool\| None` | None | Whether the editor is read-only. |
5959
| loading | `str\| None` | 'Editor is loading...' | The loading text when the editor is initializing. |

frontend/pro/monaco-editor/diff-editor/monaco-editor.diff-editor.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { ReactSlot } from '@svelte-preprocess-react/react-slot';
77
import { sveltify } from '@svelte-preprocess-react/sveltify';
88
import React, { useEffect, useMemo, useRef } from 'react';
99
import { useFunction } from '@utils/hooks/useFunction';
10+
import { useMemoizedFn } from '@utils/hooks/useMemoizedFn';
1011
import { Spin } from 'antd';
1112
import { isNumber } from 'lodash-es';
1213
import type { editor, IDisposable } from 'monaco-editor';
@@ -61,6 +62,8 @@ export const MonacoDiffEditor = sveltify<MonacoDiffEditorProps, ['loading']>(
6162
onValueChange,
6263
value: valueProp,
6364
});
65+
const onChangeMemoized = useMemoizedFn(onChange);
66+
const onValidateMemoized = useMemoizedFn(onValidate);
6467
const handleEditorMount: MonacoDiffEditorProps['onMount'] = (
6568
editor,
6669
monaco
@@ -74,7 +77,7 @@ export const MonacoDiffEditor = sveltify<MonacoDiffEditorProps, ['loading']>(
7477
const mountDisposable = modifiedEditor.onDidChangeModelContent((e) => {
7578
const newValue = modifiedEditor.getValue();
7679
setValue(newValue);
77-
onChange?.(newValue, e);
80+
onChangeMemoized(newValue, e);
7881
});
7982

8083
const validateDisposable = monaco.editor.onDidChangeMarkers((uris) => {
@@ -87,7 +90,7 @@ export const MonacoDiffEditor = sveltify<MonacoDiffEditorProps, ['loading']>(
8790
const markers = monaco.editor.getModelMarkers({
8891
resource: editorUri,
8992
});
90-
onValidate?.(markers);
93+
onValidateMemoized(markers);
9194
}
9295
}
9396
});

0 commit comments

Comments
 (0)