@nethru/ui 2.1.1 → 2.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/base/editor/Editor.js +8 -2
- package/package.json +1 -1
package/base/editor/Editor.js
CHANGED
|
@@ -7,6 +7,8 @@ import { nScript } from './nScript';
|
|
|
7
7
|
import { Decoration, EditorView } from "@codemirror/view";
|
|
8
8
|
import { RegExpCursor, SearchCursor } from '@codemirror/search';
|
|
9
9
|
import { StateEffect, StateField } from "@codemirror/state";
|
|
10
|
+
import { keymap as keyMapper } from '@codemirror/view';
|
|
11
|
+
import { defaultKeymap } from '@codemirror/commands';
|
|
10
12
|
import borderRadius from "../styles/borderRadius";
|
|
11
13
|
import { blue, grey, red, yellow } from "../colors";
|
|
12
14
|
import typography from "../styles/typography";
|
|
@@ -19,6 +21,7 @@ export default function Editor({
|
|
|
19
21
|
error = false,
|
|
20
22
|
helperText,
|
|
21
23
|
basicSetup,
|
|
24
|
+
keymap = [],
|
|
22
25
|
extensions = [],
|
|
23
26
|
format = 'javascript',
|
|
24
27
|
keyword,
|
|
@@ -139,8 +142,11 @@ export default function Editor({
|
|
|
139
142
|
});
|
|
140
143
|
}
|
|
141
144
|
}, [format]);
|
|
145
|
+
const keymapExtension = useMemo(() => {
|
|
146
|
+
return [keyMapper.of(keymap), keyMapper.of(defaultKeymap)];
|
|
147
|
+
}, [keymap]);
|
|
142
148
|
const extensionList = useMemo(() => {
|
|
143
|
-
const result = [languageExtension, EditorView.lineWrapping, highlight.extension];
|
|
149
|
+
const result = [languageExtension, EditorView.lineWrapping, highlight.extension, ...keymapExtension];
|
|
144
150
|
if (onScroll) {
|
|
145
151
|
result.push(EditorView.domEventHandlers({
|
|
146
152
|
scroll(event, view) {
|
|
@@ -151,7 +157,7 @@ export default function Editor({
|
|
|
151
157
|
}
|
|
152
158
|
result.push(...extensions);
|
|
153
159
|
return result;
|
|
154
|
-
}, [languageExtension, highlight.extension, extensions, onScroll]);
|
|
160
|
+
}, [languageExtension, highlight.extension, keymapExtension, extensions, onScroll]);
|
|
155
161
|
const handleUpdate = viewUpdate => {
|
|
156
162
|
setFocused(viewUpdate.view.hasFocus);
|
|
157
163
|
if (onUpdate) onUpdate(viewUpdate);
|