From 21879410ab3b28f046b987fefa23bb362978d424 Mon Sep 17 00:00:00 2001 From: Josh Hunt Date: Thu, 8 Apr 2021 14:02:00 +0100 Subject: [PATCH] Grafana-UI: allow pass through of monaco options (#32763) --- packages/grafana-ui/src/components/Monaco/CodeEditor.tsx | 7 +++++-- packages/grafana-ui/src/components/Monaco/types.ts | 3 +++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/grafana-ui/src/components/Monaco/CodeEditor.tsx b/packages/grafana-ui/src/components/Monaco/CodeEditor.tsx index 8306f992e8b..68cb2026dea 100644 --- a/packages/grafana-ui/src/components/Monaco/CodeEditor.tsx +++ b/packages/grafana-ui/src/components/Monaco/CodeEditor.tsx @@ -64,7 +64,7 @@ class UnthemedCodeEditor extends React.PureComponent { }; render() { - const { theme, language, width, height, showMiniMap, showLineNumbers, readOnly } = this.props; + const { theme, language, width, height, showMiniMap, showLineNumbers, readOnly, monacoOptions } = this.props; const value = this.props.value ?? ''; const longText = value.length > 100; @@ -97,7 +97,10 @@ class UnthemedCodeEditor extends React.PureComponent { language={language} theme={theme.isDark ? 'vs-dark' : 'vs-light'} value={value} - options={options} + options={{ + ...options, + ...(monacoOptions ?? {}), + }} editorWillMount={this.editorWillMount} editorDidMount={this.editorDidMount} /> diff --git a/packages/grafana-ui/src/components/Monaco/types.ts b/packages/grafana-ui/src/components/Monaco/types.ts index 33bde5e7952..982d48f0611 100644 --- a/packages/grafana-ui/src/components/Monaco/types.ts +++ b/packages/grafana-ui/src/components/Monaco/types.ts @@ -1,3 +1,5 @@ +import * as monaco from 'monaco-editor/esm/vs/editor/editor.api'; + export type CodeEditorChangeHandler = (value: string) => void; export type CodeEditorSuggestionProvider = () => CodeEditorSuggestionItem[]; @@ -10,6 +12,7 @@ export interface CodeEditorProps { readOnly?: boolean; showMiniMap?: boolean; showLineNumbers?: boolean; + monacoOptions?: monaco.editor.IEditorConstructionOptions; /** * Callback after the editor has mounted that gives you raw access to monaco