import * as React from 'react'; import * as monaco from '@vscode-alt/monaco-editor/esm/vs/editor/editor.api'; import { IMonacoEditorTextProps, EditorWillMount, EditorDidMount, IMonacoEditorTextExtensionProps } from '../interfaces'; import { IThemeState } from '../../themes'; import { URI } from '@vscode-alt/monaco-editor/esm/vs/base/common/uri'; type IMonacoEditorTextComponentProps = IMonacoEditorTextProps & { uri: URI; }; export interface DefaultMonacoEditorProps extends Exclude, IMonacoEditorTextExtensionProps { width: string | number; height: string | number; value: string; defaultValue: string; language: string; theme: IThemeState; options: monaco.editor.IEditorOptions; editorDidMount: EditorDidMount; editorWillMount: EditorWillMount; onChange: (event: any) => void; doUpdateValue: boolean; updateEditorState: (resource: URI, state: monaco.editor.ICodeEditorViewState) => void; } /** * React wrapper for monaco.editor. * * If the saved editor was updated from backend asynchronously and the editor not viewing the corresponding model, * then we update the model after it was opened. Until then the updated content stays outside the monaco. * If the saved editor was updated from backend asynchronously and the editor currently viewing the corresponding model, * then we update the model by saving its current viewState and we restore the state. * * In above both scenarios after setting the value, the undo/redo state might be lost. * * Switching tabs: * ----- * When switching tabs, the URI changes and the component will be forced to update with `value` provided. But we can check * `doUpdateValue` flag to verify whether we need to update the `value` of the model or not. That way we don't have to * accidently set the value. * * This component will handle siwtching the models based on the URI value is provided. * * * v0.3.1.1 */ declare class MonacoEditorComponent extends React.Component { /** * Dom component that holds the editor. * * @private * @type {*} * @memberof MonacoEditorComponent */ private containerElement; context: any; /** * Editor Model that have methods of ModelService as well. * * @private * @type {monaco.editor.IStandaloneCodeEditor} * @memberof MonacoEditorComponent */ private editor; private __prevent_trigger_change_event; /** * Providers that are used for extension * * @private * @type {*} * @memberof MonacoEditorComponent */ private registeredProviders; /** * Explicit ModelService to manage models. * * @private * @type {(typeof monaco.editor | any)} * @memberof MonacoEditorComponent */ private modelService; private disposables; static contextType: React.Context<{ controller: any; }>; private subscriptions; constructor(props: IMonacoEditorTextComponentProps); static defaultProps: DefaultMonacoEditorProps; componentDidMount(): void; shouldComponentUpdate(nextProps: Readonly): boolean; componentDidUpdate(prevProps: IMonacoEditorTextComponentProps, prevState: any, snapshot: any): void; componentWillUnmount(): void; editorWillMount(): Partial; editorDidMount(): void; /** * Additional method to add default options. * @param options * @param override */ protected create(options: monaco.editor.IEditorConstructionOptions & { value: string; } & { language?: any; }, override?: monaco.editor.IEditorOverrideServices): monaco.editor.IStandaloneCodeEditor; private createOrGetModel; initMonaco(): void; destroyMonaco(): void; assignRef: (component: any) => void; render(): React.JSX.Element; } export default MonacoEditorComponent;