@nethru/ui 2.1.40 → 2.1.42
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 +12 -5
- package/package.json +1 -1
package/base/editor/Editor.js
CHANGED
|
@@ -46,7 +46,7 @@ export default function Editor({
|
|
|
46
46
|
const highlight = useMemo(() => makeHighlight(), []);
|
|
47
47
|
// eslint-disable-next-line
|
|
48
48
|
const styles = useMemo(() => makeStyle(restrictWidth, ref.current), [restrictWidth, ref.current]);
|
|
49
|
-
const eslintLinter = useMemo(() => makeEslinter(format, eslintRules, onEslintUpdate, customVariables), [format, eslintRules, onEslintUpdate, customVariables]);
|
|
49
|
+
const eslintLinter = useMemo(() => makeEslinter(format, eslintRules, onEslintUpdate, customVariables, readOnly), [format, eslintRules, onEslintUpdate, customVariables, readOnly]);
|
|
50
50
|
const languageExtension = useMemo(() => getLanguageExtension(format), [format]);
|
|
51
51
|
const keymapExtension = useMemo(() => getKeymapExtension(keymap), [keymap]);
|
|
52
52
|
const extensionList = useMemo(() => makeExtensions(languageExtension, eslintLinter, highlight.extension, keymapExtension, extensions, onScroll), [languageExtension, eslintLinter, highlight.extension, keymapExtension, extensions, onScroll]);
|
|
@@ -64,9 +64,15 @@ export default function Editor({
|
|
|
64
64
|
while (true) {
|
|
65
65
|
cursor.next();
|
|
66
66
|
if (cursor.done) break;
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
const {
|
|
68
|
+
from,
|
|
69
|
+
to
|
|
70
|
+
} = cursor.value;
|
|
71
|
+
if (from !== to) {
|
|
72
|
+
view.dispatch({
|
|
73
|
+
effects: effect.of([decoration.range(from, to)])
|
|
74
|
+
});
|
|
75
|
+
}
|
|
70
76
|
}
|
|
71
77
|
}, [view, highlight, keyword, isRegExp]);
|
|
72
78
|
const scrollToBottom = useCallback(() => {
|
|
@@ -203,7 +209,8 @@ function makeHighlight() {
|
|
|
203
209
|
extension: extension
|
|
204
210
|
};
|
|
205
211
|
}
|
|
206
|
-
function makeEslinter(format, eslintRules, onEslintUpdate, customVariables) {
|
|
212
|
+
function makeEslinter(format, eslintRules, onEslintUpdate, customVariables, readOnly) {
|
|
213
|
+
if (readOnly) return;
|
|
207
214
|
const regex = /\{\{([^}]+)\}\}/g;
|
|
208
215
|
if (format === 'javascript') {
|
|
209
216
|
return linter(view => {
|