import { AbstractWraplet, Constructable } from "wraplet"; import { KeyValueStorage } from "wraplet/storage"; import type * as monaco from "monaco-editor"; import { DocumentAltererProviderWraplet } from "./types/DocumentAltererProviderWraplet"; import { DocumentAlterer } from "./types/DocumentAlterer"; export type EditorCreator = (options: monaco.editor.IStandaloneEditorConstructionOptions, node: HTMLElement, monaco: MonacoInstance) => Promise; export type ExhibitionMonacoEditorOptions = { /** * Monaco instance. */ monaco: MonacoInstance; /** * Instead of depending on this class for editor instantiation, you can provide your own editor instance here. */ monacoEditorCreator?: EditorCreator; /** * Monaco options for the editor. */ monacoEditorOptions?: monaco.editor.IStandaloneEditorConstructionOptions; /** * Location where the editor should be inserted. */ location?: "head" | "body"; /** * Priority of the editor's document alterer. Higher priority means it will be executed first. */ priority?: number; /** * Trim the default value of the editor. */ trimDefaultValue?: boolean; /** * This option applies to single tag languages only (typescript, javascript and css). It * determines the attributes that will be added to the generated tag. */ tagAttributes?: Record; }; export type MonacoInstance = typeof monaco; export declare class ExhibitionMonacoEditor extends AbstractWraplet implements DocumentAltererProviderWraplet { private monaco; private editor; private options; private priority; private monacoEditorOptions; constructor(node: HTMLElement, options: ExhibitionMonacoEditorOptions, optionsStorage?: KeyValueStorage>); protected supportedNodeTypes(): readonly Constructable[]; initialize(): Promise; destroy(): Promise; protected onInitialize(): Promise; getPriority(): number; private getMonacoInstance; /** * Returns the current value of the editor. */ private getValue; private alterDocument; getDocumentAlterer(): DocumentAlterer; /** * Additional validation. */ private validateOptions; private getEditor; private getTSValueAsJS; private getLanguage; static trimDefaultValue(content: string): string; protected onDestroy(): Promise; /** * Helper method creating a new monaco editor instance. */ static createMonacoEditor(editorOptions: monaco.editor.IStandaloneEditorConstructionOptions | undefined, node: HTMLElement, monaco: MonacoInstance): monaco.editor.IStandaloneCodeEditor; /** * Helper method creating a new monaco model instance. */ static createMonacoModel(monaco: MonacoInstance, language: string, value: string): monaco.editor.ITextModel; /** * Create a single ExhibitionMonacoEditor instance wrapping a given element. */ static create(element: HTMLElement, options: ExhibitionMonacoEditorOptions): ExhibitionMonacoEditor; }