Skip to content

Commit

Permalink
Grafana-UI: allow pass through of monaco options (grafana#32763)
Browse files Browse the repository at this point in the history
  • Loading branch information
joshhunt authored Apr 8, 2021
1 parent e9a27ca commit 2187941
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/grafana-ui/src/components/Monaco/CodeEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class UnthemedCodeEditor extends React.PureComponent<Props> {
};

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;

Expand Down Expand Up @@ -97,7 +97,10 @@ class UnthemedCodeEditor extends React.PureComponent<Props> {
language={language}
theme={theme.isDark ? 'vs-dark' : 'vs-light'}
value={value}
options={options}
options={{
...options,
...(monacoOptions ?? {}),
}}
editorWillMount={this.editorWillMount}
editorDidMount={this.editorDidMount}
/>
Expand Down
3 changes: 3 additions & 0 deletions packages/grafana-ui/src/components/Monaco/types.ts
Original file line number Diff line number Diff line change
@@ -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[];

Expand All @@ -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
Expand Down

0 comments on commit 2187941

Please sign in to comment.