@fc-components/monaco-editor 0.1.25 → 0.1.26

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.
@@ -17,6 +17,7 @@ interface PromQLEditorProps {
17
17
  onEnter?: (value: string) => void;
18
18
  onBlur?: (value: string) => void;
19
19
  editorDidMount?: (editor: monacoTypes.editor.IStandaloneCodeEditor) => void;
20
+ debugEscKey?: boolean;
20
21
  }
21
22
  export default function PromQLEditor(props: PromQLEditorProps & DataProviderParams): React.JSX.Element;
22
23
  export {};
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.1.25",
6
+ "version": "0.1.26",
7
7
  "license": "MIT",
8
8
  "main": "dist/index.js",
9
9
  "module": "dist/monaco-editor.esm.js",
@@ -30,6 +30,7 @@ interface PromQLEditorProps {
30
30
  onEnter?: (value: string) => void;
31
31
  onBlur?: (value: string) => void;
32
32
  editorDidMount?: (editor: monacoTypes.editor.IStandaloneCodeEditor) => void;
33
+ debugEscKey?: boolean;
33
34
  }
34
35
 
35
36
  const PROMQL_LANG_ID = promLanguageDefinition.id;
@@ -103,6 +104,7 @@ export default function PromQLEditor(props: PromQLEditorProps & DataProviderPara
103
104
  onEnter,
104
105
  onBlur,
105
106
  editorDidMount,
107
+ debugEscKey = false,
106
108
  } = props;
107
109
  const autocompleteDisposeFun = useRef<(() => void) | null>(null);
108
110
  const containerRef = useRef<HTMLDivElement>(null);
@@ -211,6 +213,22 @@ export default function PromQLEditor(props: PromQLEditorProps & DataProviderPara
211
213
  '!suggestWidgetVisible && isEditorFocused' + id,
212
214
  );
213
215
 
216
+ editor.addCommand(
217
+ monaco.KeyCode.Escape,
218
+ () => {
219
+ if (debugEscKey) {
220
+ const suggestWidgetVisible = (editor as any)?._contextKeyService?.getContextKeyValue?.('suggestWidgetVisible');
221
+ // eslint-disable-next-line no-console
222
+ console.log('[PromQLEditor][ESC]', {
223
+ suggestWidgetVisible,
224
+ valueLength: editor.getValue().length,
225
+ });
226
+ }
227
+ editor.trigger('keyboard', 'hideSuggestWidget', {});
228
+ },
229
+ 'suggestWidgetVisible && isEditorFocused' + id,
230
+ );
231
+
214
232
  // Initialize previous content tracking
215
233
  previousContentRef.current = editor.getValue();
216
234
  lastDeletionTriggerTimeRef.current = 0;