UNPKG

@uiw/react-monacoeditor

Version:
62 lines (61 loc) 2.32 kB
import React from 'react'; import * as monaco from 'monaco-editor'; import { editor, languages } from 'monaco-editor'; import type { Position } from 'monaco-editor'; export type IMonacoEditor = typeof monaco; export interface MonacoEditorProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'> { /** * width of editor. * Defaults to `100%` */ width?: number | string; /** * height of editor. * Defaults to `100%`. */ height?: number | string; /** * value of the auto created model in the editor. */ value?: string; /** * the initial value of the auto created model in the editor. */ defaultValue?: string; /** * The initial language of the auto created model in the editor. * To not create automatically a model, use `model: null`. */ language?: editor.IStandaloneEditorConstructionOptions['language']; /** * User provided extension function provider for auto-complete. */ autoComplete?: (model: editor.ITextModel, position: Position) => languages.CompletionItem[]; /** * Initial theme to be used for rendering. * The current out-of-the-box available themes are: 'vs' (default), 'vs-dark', 'hc-black'. * You can create custom themes via `monaco.editor.defineTheme`. * To switch a theme, use `monaco.editor.setTheme` */ theme?: editor.IStandaloneEditorConstructionOptions['theme']; /** * The options to create an editor. */ options?: editor.IStandaloneEditorConstructionOptions; /** * an event emitted when the editor has been mounted (similar to `componentDidMount` of React) */ editorDidMount?: (editor: editor.IStandaloneCodeEditor, monaco: IMonacoEditor) => void; /** * an event emitted when the content of the current model has changed. */ onChange?: (value: string, event: editor.IModelContentChangedEvent) => void; } export declare function loadFont(fontFamily: string, url: string): Promise<void>; export interface RefEditorInstance { container: HTMLDivElement | null; editor?: editor.IStandaloneCodeEditor; monaco: IMonacoEditor; } declare const _default: React.ForwardRefExoticComponent<MonacoEditorProps & React.RefAttributes<RefEditorInstance>>; export default _default;