UNPKG

@theia/monaco

Version:
99 lines 7.35 kB
import URI from '@theia/core/lib/common/uri'; import { EditorPreferenceChange, EditorPreferences, TextEditor, DiffNavigator } from '@theia/editor/lib/browser'; import { DisposableCollection, Disposable, CancellationToken } from '@theia/core/lib/common'; import { MonacoDiffEditor } from './monaco-diff-editor'; import { MonacoDiffNavigatorFactory } from './monaco-diff-navigator-factory'; import { EditorServiceOverrides, MonacoEditor, MonacoEditorServices } from './monaco-editor'; import { MonacoEditorModel } from './monaco-editor-model'; import { MonacoWorkspace } from './monaco-workspace'; import { ContributionProvider } from '@theia/core'; import { KeybindingRegistry, OpenerService, SaveOptions } from '@theia/core/lib/browser'; import { MonacoToProtocolConverter } from './monaco-to-protocol-converter'; import { ProtocolToMonacoConverter } from './protocol-to-monaco-converter'; import * as monaco from '@theia/monaco-editor-core'; import { OpenExternalOptions, OpenInternalOptions } from '@theia/monaco-editor-core/esm/vs/platform/opener/common/opener'; import { MarkdownString } from '@theia/core/lib/common/markdown-rendering'; import { SimpleMonacoEditor } from './simple-monaco-editor'; import { ICodeEditorWidgetOptions } from '@theia/monaco-editor-core/esm/vs/editor/browser/widget/codeEditor/codeEditorWidget'; import { FileSystemPreferences } from '@theia/filesystem/lib/browser'; export declare const MonacoEditorFactory: unique symbol; export interface MonacoEditorFactory { readonly scheme: string; create(model: MonacoEditorModel, defaultOptions: MonacoEditor.IOptions, defaultOverrides: EditorServiceOverrides): Promise<MonacoEditor>; } export declare const SaveParticipant: unique symbol; export interface SaveParticipant { readonly order: number; applyChangesOnSave(editor: MonacoEditor, cancellationToken: CancellationToken, options?: SaveOptions): Promise<void>; } export declare const SAVE_PARTICIPANT_DEFAULT_ORDER = 0; export declare class MonacoEditorProvider { protected readonly m2p: MonacoToProtocolConverter; protected readonly p2m: ProtocolToMonacoConverter; protected readonly workspace: MonacoWorkspace; protected readonly editorPreferences: EditorPreferences; protected readonly diffNavigatorFactory: MonacoDiffNavigatorFactory; protected readonly factories: ContributionProvider<MonacoEditorFactory>; protected readonly services: MonacoEditorServices; protected readonly keybindingRegistry: KeybindingRegistry; protected readonly openerService: OpenerService; protected readonly saveProviderContributions: ContributionProvider<SaveParticipant>; protected readonly filePreferences: FileSystemPreferences; protected saveParticipants: SaveParticipant[]; protected _current: MonacoEditor | undefined; /** * Returns the last focused MonacoEditor. * It takes into account inline editors as well. * If you are interested only in standalone editors then use `MonacoEditor.getCurrent(EditorManager)` */ get current(): MonacoEditor | undefined; constructor(m2p: MonacoToProtocolConverter, p2m: ProtocolToMonacoConverter, workspace: MonacoWorkspace, editorPreferences: EditorPreferences, diffNavigatorFactory: MonacoDiffNavigatorFactory); protected getModel(uri: URI, toDispose: DisposableCollection): Promise<MonacoEditorModel>; get(uri: URI): Promise<MonacoEditor>; protected doCreateEditor<T>(uri: URI, factory: (override: EditorServiceOverrides, toDispose: DisposableCollection) => Promise<T>): Promise<T>; /** * Intercept internal Monaco open calls and delegate to OpenerService. */ protected interceptOpen(monacoUri: monaco.Uri | string, monacoOptions?: OpenInternalOptions | OpenExternalOptions): Promise<boolean>; protected injectKeybindingResolver(editor: MonacoEditor): void; protected createEditor(uri: URI, override: EditorServiceOverrides, toDispose: DisposableCollection): Promise<MonacoEditor>; protected get preferencePrefixes(): string[]; createMonacoEditor(uri: URI, override: EditorServiceOverrides, toDispose: DisposableCollection): Promise<MonacoEditor>; protected updateReadOnlyMessage(options: MonacoEditor.IOptions, readOnly: boolean | MarkdownString): void; protected createMonacoEditorOptions(model: MonacoEditorModel): MonacoEditor.IOptions; protected updateMonacoEditorOptions(editor: MonacoEditor, event?: EditorPreferenceChange): void; protected get diffPreferencePrefixes(): string[]; protected createMonacoDiffEditor(uri: URI, override: EditorServiceOverrides, toDispose: DisposableCollection): Promise<MonacoDiffEditor>; protected createMonacoDiffEditorOptions(original: MonacoEditorModel, modified: MonacoEditorModel): MonacoDiffEditor.IOptions; protected updateMonacoDiffEditorOptions(editor: MonacoDiffEditor, event?: EditorPreferenceChange, resourceUri?: string): void; /** @deprecated always pass a language as an overrideIdentifier */ protected createOptions(prefixes: string[], uri: string): Record<string, any>; protected createOptions(prefixes: string[], uri: string, overrideIdentifier: string): Record<string, any>; protected setOption(preferenceName: string, value: any, prefixes: string[], options?: Record<string, any>): { [name: string]: any; }; protected toOptionName(preferenceName: string, prefixes: string[]): string; protected doSetOption(obj: Record<string, any>, value: any, names: string[]): void; getDiffNavigator(editor: TextEditor): DiffNavigator; /** * Creates an instance of the standard MonacoEditor with a StandaloneCodeEditor as its Monaco delegate. * Among other differences, these editors execute basic actions like typing or deletion via commands that may be overridden by extensions. * @deprecated Most use cases for inline editors should be served by `createSimpleInline` instead. */ createInline(uri: URI, node: HTMLElement, options?: MonacoEditor.IOptions): Promise<MonacoEditor>; /** * Creates an instance of the standard MonacoEditor with a CodeEditorWidget as its Monaco delegate. * In addition to the service customizability of the StandaloneCodeEditor,This editor allows greater customization the editor contributions active in the widget. * See {@link ICodeEditorWidgetOptions.contributions}. */ createSimpleInline(uri: URI, node: HTMLElement, options?: MonacoEditor.IOptions, widgetOptions?: ICodeEditorWidgetOptions): Promise<SimpleMonacoEditor>; static inlineOptions: monaco.editor.IEditorConstructionOptions; createEmbeddedDiffEditor(parentEditor: MonacoEditor, node: HTMLElement, originalUri: URI, modifiedUri?: URI, options?: MonacoDiffEditor.IOptions): Promise<MonacoDiffEditor>; init(): void; registerSaveParticipant(saveParticipant: SaveParticipant): Disposable; protected shouldFormat(model: MonacoEditorModel, options: SaveOptions): boolean; runSaveParticipants(editor: MonacoEditor, cancellationToken: CancellationToken, options?: SaveOptions): Promise<void>; protected formatOnSave(editor: MonacoEditor, model: MonacoEditorModel, cancellationToken: CancellationToken, options: SaveOptions): Promise<void>; protected insertFinalNewline(editorModel: MonacoEditorModel): void; } //# sourceMappingURL=monaco-editor-provider.d.ts.map