@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.
@@ -1,7 +1,7 @@
1
1
  import React, { useRef, useEffect } from 'react';
2
2
  import MonacoEditor from 'react-monaco-editor';
3
3
  import * as monaco from 'monaco-editor';
4
- import { languages, Range, editor, KeyMod, KeyCode, MarkerSeverity } from 'monaco-editor';
4
+ import { languages, Range, editor, Selection, KeyMod, KeyCode, MarkerSeverity } from 'monaco-editor';
5
5
  import { promLanguageDefinition } from 'monaco-promql';
6
6
  import { parser, LabelMatchers, VectorSelector, PromQL, FunctionCallBody, StringLiteral, UnquotedLabelMatcher, BinaryExpr, NumberDurationLiteralInDurationContext, MatrixSelector, GroupingLabels, AggregateModifier, AggregateExpr, Identifier, LabelName, MatchOp, EqlSingle, EqlRegex, Neq, NeqRegex } from '@fc-components/lezer-metricsql';
7
7
  import { v4 } from 'uuid';
@@ -1995,6 +1995,8 @@ function PromQLEditor(props) {
1995
1995
  interpolateString = props.interpolateString,
1996
1996
  _props$enableAutocomp = props.enableAutocomplete,
1997
1997
  enableAutocomplete = _props$enableAutocomp === void 0 ? true : _props$enableAutocomp,
1998
+ _props$readOnly = props.readOnly,
1999
+ readOnly = _props$readOnly === void 0 ? false : _props$readOnly,
1998
2000
  onChange = props.onChange,
1999
2001
  onShiftEnter = props.onShiftEnter,
2000
2002
  onBlur = props.onBlur,
@@ -2020,6 +2022,12 @@ function PromQLEditor(props) {
2020
2022
  editor$1.onDidBlurEditorWidget(function () {
2021
2023
  isEditorFocused.set(false);
2022
2024
  onBlur == null || onBlur(editor$1.getValue());
2025
+ // reset the selection to the current position
2026
+ var position = editor$1.getPosition();
2027
+ if (position) {
2028
+ var newSelection = new Selection(position.lineNumber, position.column, position.lineNumber, position.column);
2029
+ editor$1.setSelection(newSelection);
2030
+ }
2023
2031
  });
2024
2032
  editor$1.onDidFocusEditorText(function () {
2025
2033
  isEditorFocused.set(true);
@@ -2167,6 +2175,7 @@ function PromQLEditor(props) {
2167
2175
  onChange: onChange,
2168
2176
  editorDidMount: handleEditorDidMount,
2169
2177
  options: {
2178
+ readOnly: readOnly,
2170
2179
  codeLens: false,
2171
2180
  contextmenu: false,
2172
2181
  fixedOverflowWidgets: true,
@@ -2197,7 +2206,8 @@ function PromQLEditor(props) {
2197
2206
  },
2198
2207
  suggestFontSize: 12,
2199
2208
  wordWrap: 'on',
2200
- automaticLayout: true
2209
+ automaticLayout: true,
2210
+ occurrencesHighlight: 'off'
2201
2211
  }
2202
2212
  })));
2203
2213
  }