@fc-components/monaco-editor 0.1.8 → 0.1.10
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/dist/monaco-editor.cjs.development.js +11 -1
- package/dist/monaco-editor.cjs.development.js.map +1 -1
- package/dist/monaco-editor.cjs.production.min.js +1 -1
- package/dist/monaco-editor.cjs.production.min.js.map +1 -1
- package/dist/monaco-editor.esm.js +12 -2
- package/dist/monaco-editor.esm.js.map +1 -1
- package/dist/promql/index.d.ts +1 -0
- package/package.json +1 -1
- package/src/promql/index.tsx +23 -1
package/dist/promql/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ interface PromQLEditorProps {
|
|
|
8
8
|
placeholder?: string;
|
|
9
9
|
enableAutocomplete?: boolean;
|
|
10
10
|
durationVariablesCompletion?: boolean;
|
|
11
|
+
readOnly?: boolean;
|
|
11
12
|
interpolateString?: (query: string) => string;
|
|
12
13
|
onChange?: (value: string) => void;
|
|
13
14
|
onShiftEnter?: (value: string) => void;
|
package/package.json
CHANGED
package/src/promql/index.tsx
CHANGED
|
@@ -20,6 +20,7 @@ interface PromQLEditorProps {
|
|
|
20
20
|
placeholder?: string;
|
|
21
21
|
enableAutocomplete?: boolean;
|
|
22
22
|
durationVariablesCompletion?: boolean;
|
|
23
|
+
readOnly?: boolean;
|
|
23
24
|
interpolateString?: (query: string) => string;
|
|
24
25
|
onChange?: (value: string) => void;
|
|
25
26
|
onShiftEnter?: (value: string) => void;
|
|
@@ -70,7 +71,19 @@ const getStyles = (placeholder?: string) => {
|
|
|
70
71
|
|
|
71
72
|
export default function PromQLEditor(props: PromQLEditorProps & DataProviderParams) {
|
|
72
73
|
const id = uuidv4();
|
|
73
|
-
const {
|
|
74
|
+
const {
|
|
75
|
+
size = 'middle',
|
|
76
|
+
theme = 'light',
|
|
77
|
+
value,
|
|
78
|
+
placeholder,
|
|
79
|
+
interpolateString,
|
|
80
|
+
enableAutocomplete = true,
|
|
81
|
+
readOnly = false,
|
|
82
|
+
onChange,
|
|
83
|
+
onShiftEnter,
|
|
84
|
+
onBlur,
|
|
85
|
+
editorDidMount,
|
|
86
|
+
} = props;
|
|
74
87
|
const autocompleteDisposeFun = useRef<(() => void) | null>(null);
|
|
75
88
|
const containerRef = useRef<HTMLDivElement>(null);
|
|
76
89
|
const dataProviderRef = useRef<DataProvider | null>(null);
|
|
@@ -94,7 +107,14 @@ export default function PromQLEditor(props: PromQLEditorProps & DataProviderPara
|
|
|
94
107
|
editor.onDidBlurEditorWidget(() => {
|
|
95
108
|
isEditorFocused.set(false);
|
|
96
109
|
onBlur?.(editor.getValue());
|
|
110
|
+
// reset the selection to the current position
|
|
111
|
+
const position = editor.getPosition();
|
|
112
|
+
if (position) {
|
|
113
|
+
const newSelection = new monaco.Selection(position.lineNumber, position.column, position.lineNumber, position.column);
|
|
114
|
+
editor.setSelection(newSelection);
|
|
115
|
+
}
|
|
97
116
|
});
|
|
117
|
+
|
|
98
118
|
editor.onDidFocusEditorText(() => {
|
|
99
119
|
isEditorFocused.set(true);
|
|
100
120
|
});
|
|
@@ -270,6 +290,7 @@ export default function PromQLEditor(props: PromQLEditorProps & DataProviderPara
|
|
|
270
290
|
onChange={onChange}
|
|
271
291
|
editorDidMount={handleEditorDidMount}
|
|
272
292
|
options={{
|
|
293
|
+
readOnly,
|
|
273
294
|
codeLens: false,
|
|
274
295
|
contextmenu: false,
|
|
275
296
|
fixedOverflowWidgets: true,
|
|
@@ -299,6 +320,7 @@ export default function PromQLEditor(props: PromQLEditorProps & DataProviderPara
|
|
|
299
320
|
suggestFontSize: 12,
|
|
300
321
|
wordWrap: 'on',
|
|
301
322
|
automaticLayout: true,
|
|
323
|
+
occurrencesHighlight: 'off', // Disable word highlighting
|
|
302
324
|
}}
|
|
303
325
|
/>
|
|
304
326
|
</div>
|