UNPKG

4.05 kBTypeScriptView Raw
1import * as monacoEditor from "monaco-editor/esm/vs/editor/editor.api";
2export declare type ChangeHandler = (value: string, event: monacoEditor.editor.IModelContentChangedEvent) => void;
3export declare type EditorDidMount = (editor: monacoEditor.editor.IStandaloneCodeEditor, monaco: typeof monacoEditor) => void;
4/**
5 * @remarks
6 * This will be `IStandaloneEditorConstructionOptions` in newer versions of monaco-editor, or
7 * `IEditorConstructionOptions` in versions before that was introduced.
8 */
9export declare type EditorConstructionOptions = NonNullable<Parameters<typeof monacoEditor.editor.create>[1]>;
10export declare type EditorWillMount = (monaco: typeof monacoEditor) => void | EditorConstructionOptions;
11export interface MonacoEditorBaseProps {
12 /**
13 * Width of editor. Defaults to 100%.
14 */
15 width?: string | number;
16 /**
17 * Height of editor. Defaults to 100%.
18 */
19 height?: string | number;
20 /**
21 * The initial value of the auto created model in the editor.
22 */
23 defaultValue?: string;
24 /**
25 * The initial language of the auto created model in the editor. Defaults to 'javascript'.
26 */
27 language?: string;
28 /**
29 * Theme to be used for rendering.
30 * The current out-of-the-box available themes are: 'vs' (default), 'vs-dark', 'hc-black'.
31 * You can create custom themes via `monaco.editor.defineTheme`.
32 */
33 theme?: string | null;
34 /**
35 * Optional string classname to append to the editor.
36 */
37 className?: string | null;
38}
39export interface MonacoEditorProps extends MonacoEditorBaseProps {
40 /**
41 * Value of the auto created model in the editor.
42 * If you specify `null` or `undefined` for this property, the component behaves in uncontrolled mode.
43 * Otherwise, it behaves in controlled mode.
44 */
45 value?: string | null;
46 /**
47 * Refer to Monaco interface {monaco.editor.IStandaloneEditorConstructionOptions}.
48 */
49 options?: monacoEditor.editor.IStandaloneEditorConstructionOptions;
50 /**
51 * Refer to Monaco interface {monaco.editor.IEditorOverrideServices}.
52 */
53 overrideServices?: monacoEditor.editor.IEditorOverrideServices;
54 /**
55 * An event emitted when the editor has been mounted (similar to componentDidMount of React).
56 */
57 editorDidMount?: EditorDidMount;
58 /**
59 * An event emitted before the editor mounted (similar to componentWillMount of React).
60 */
61 editorWillMount?: EditorWillMount;
62 /**
63 * An event emitted when the content of the current model has changed.
64 */
65 onChange?: ChangeHandler;
66}
67export declare type DiffEditorDidMount = (editor: monacoEditor.editor.IStandaloneDiffEditor, monaco: typeof monacoEditor) => void;
68export declare type DiffEditorWillMount = (monaco: typeof monacoEditor) => void | monacoEditor.editor.IStandaloneEditorConstructionOptions;
69export declare type DiffChangeHandler = ChangeHandler;
70export interface MonacoDiffEditorProps extends MonacoEditorBaseProps {
71 /**
72 * The original value to compare against.
73 */
74 original?: string;
75 /**
76 * Value of the auto created model in the editor.
77 * If you specify value property, the component behaves in controlled mode. Otherwise, it behaves in uncontrolled mode.
78 */
79 value?: string;
80 /**
81 * Refer to Monaco interface {monaco.editor.IDiffEditorConstructionOptions}.
82 */
83 options?: monacoEditor.editor.IDiffEditorConstructionOptions;
84 /**
85 * Refer to Monaco interface {monaco.editor.IEditorOverrideServices}.
86 */
87 overrideServices?: monacoEditor.editor.IEditorOverrideServices;
88 /**
89 * An event emitted when the editor has been mounted (similar to componentDidMount of React).
90 */
91 editorDidMount?: DiffEditorDidMount;
92 /**
93 * An event emitted before the editor mounted (similar to componentWillMount of React).
94 */
95 editorWillMount?: DiffEditorWillMount;
96 /**
97 * An event emitted when the content of the current model has changed.
98 */
99 onChange?: DiffChangeHandler;
100}