UNPKG

monaco-editor

Version:
1,497 lines (1,419 loc) • 176 kB
/*!----------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Type definitions for monaco-editor v0.8.3 * Released under the MIT license *-----------------------------------------------------------*/ declare module monaco { interface Thenable<T> { /** * Attaches callbacks for the resolution and/or rejection of the Promise. * @param onfulfilled The callback to execute when the Promise is resolved. * @param onrejected The callback to execute when the Promise is rejected. * @returns A Promise for the completion of which ever callback is executed. */ then<TResult>(onfulfilled?: (value: T) => TResult | Thenable<TResult>, onrejected?: (reason: any) => TResult | Thenable<TResult>): Thenable<TResult>; then<TResult>(onfulfilled?: (value: T) => TResult | Thenable<TResult>, onrejected?: (reason: any) => void): Thenable<TResult>; } export interface IDisposable { dispose(): void; } export interface IEvent<T> { (listener: (e: T) => any, thisArg?: any): IDisposable; } /** * A helper that allows to emit and listen to typed events */ export class Emitter<T> { constructor(); readonly event: IEvent<T>; fire(event?: T): void; dispose(): void; } export enum Severity { Ignore = 0, Info = 1, Warning = 2, Error = 3, } /** * The value callback to complete a promise */ export interface TValueCallback<T> { (value: T): void; } export interface ProgressCallback { (progress: any): any; } /** * A Promise implementation that supports progress and cancelation. */ export class Promise<V> { constructor(init: (complete: TValueCallback<V>, error: (err: any) => void, progress: ProgressCallback) => void, oncancel?: any); public then<U>(success?: (value: V) => Promise<U>, error?: (err: any) => Promise<U>, progress?: ProgressCallback): Promise<U>; public then<U>(success?: (value: V) => Promise<U>, error?: (err: any) => Promise<U> | U, progress?: ProgressCallback): Promise<U>; public then<U>(success?: (value: V) => Promise<U>, error?: (err: any) => U, progress?: ProgressCallback): Promise<U>; public then<U>(success?: (value: V) => Promise<U>, error?: (err: any) => void, progress?: ProgressCallback): Promise<U>; public then<U>(success?: (value: V) => Promise<U> | U, error?: (err: any) => Promise<U>, progress?: ProgressCallback): Promise<U>; public then<U>(success?: (value: V) => Promise<U> | U, error?: (err: any) => Promise<U> | U, progress?: ProgressCallback): Promise<U>; public then<U>(success?: (value: V) => Promise<U> | U, error?: (err: any) => U, progress?: ProgressCallback): Promise<U>; public then<U>(success?: (value: V) => Promise<U> | U, error?: (err: any) => void, progress?: ProgressCallback): Promise<U>; public then<U>(success?: (value: V) => U, error?: (err: any) => Promise<U>, progress?: ProgressCallback): Promise<U>; public then<U>(success?: (value: V) => U, error?: (err: any) => Promise<U> | U, progress?: ProgressCallback): Promise<U>; public then<U>(success?: (value: V) => U, error?: (err: any) => U, progress?: ProgressCallback): Promise<U>; public then<U>(success?: (value: V) => U, error?: (err: any) => void, progress?: ProgressCallback): Promise<U>; public done(success?: (value: V) => void, error?: (err: any) => any, progress?: ProgressCallback): void; public cancel(): void; public static as<ValueType>(value: ValueType): Promise<ValueType>; public static is(value: any): value is Thenable<any>; public static timeout(delay: number): Promise<void>; public static join<ValueType>(promises: Promise<ValueType>[]): Promise<ValueType[]>; public static join<ValueType>(promises: Thenable<ValueType>[]): Thenable<ValueType[]>; public static join<ValueType>(promises: { [n: string]: Promise<ValueType> }): Promise<{ [n: string]: ValueType }>; public static any<ValueType>(promises: Promise<ValueType>[]): Promise<{ key: string; value: Promise<ValueType>; }>; public static wrap<ValueType>(value: Thenable<ValueType>): Promise<ValueType>; public static wrap<ValueType>(value: ValueType): Promise<ValueType>; public static wrapError<ValueType>(error: any): Promise<ValueType>; } export class CancellationTokenSource { readonly token: CancellationToken; cancel(): void; dispose(): void; } export interface CancellationToken { readonly isCancellationRequested: boolean; /** * An event emitted when cancellation is requested * @event */ readonly onCancellationRequested: IEvent<any>; } /** * Uniform Resource Identifier (Uri) http://tools.ietf.org/html/rfc3986. * This class is a simple parser which creates the basic component paths * (http://tools.ietf.org/html/rfc3986#section-3) with minimal validation * and encoding. * * foo://example.com:8042/over/there?name=ferret#nose * \_/ \______________/\_________/ \_________/ \__/ * | | | | | * scheme authority path query fragment * | _____________________|__ * / \ / \ * urn:example:animal:ferret:nose * * */ export class Uri { static isUri(thing: any): thing is Uri; protected constructor(); /** * scheme is the 'http' part of 'http://www.msft.com/some/path?query#fragment'. * The part before the first colon. */ readonly scheme: string; /** * authority is the 'www.msft.com' part of 'http://www.msft.com/some/path?query#fragment'. * The part between the first double slashes and the next slash. */ readonly authority: string; /** * path is the '/some/path' part of 'http://www.msft.com/some/path?query#fragment'. */ readonly path: string; /** * query is the 'query' part of 'http://www.msft.com/some/path?query#fragment'. */ readonly query: string; /** * fragment is the 'fragment' part of 'http://www.msft.com/some/path?query#fragment'. */ readonly fragment: string; /** * Returns a string representing the corresponding file system path of this Uri. * Will handle UNC paths and normalize windows drive letters to lower-case. Also * uses the platform specific path separator. Will *not* validate the path for * invalid characters and semantics. Will *not* look at the scheme of this Uri. */ readonly fsPath: string; with(change: { scheme?: string; authority?: string; path?: string; query?: string; fragment?: string; }): Uri; static parse(value: string): Uri; static file(path: string): Uri; static from(components: { scheme?: string; authority?: string; path?: string; query?: string; fragment?: string; }): Uri; /** * * @param skipEncoding Do not encode the result, default is `false` */ toString(skipEncoding?: boolean): string; toJSON(): any; static revive(data: any): Uri; } /** * Virtual Key Codes, the value does not hold any inherent meaning. * Inspired somewhat from https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx * But these are "more general", as they should work across browsers & OS`s. */ export enum KeyCode { /** * Placed first to cover the 0 value of the enum. */ Unknown = 0, Backspace = 1, Tab = 2, Enter = 3, Shift = 4, Ctrl = 5, Alt = 6, PauseBreak = 7, CapsLock = 8, Escape = 9, Space = 10, PageUp = 11, PageDown = 12, End = 13, Home = 14, LeftArrow = 15, UpArrow = 16, RightArrow = 17, DownArrow = 18, Insert = 19, Delete = 20, KEY_0 = 21, KEY_1 = 22, KEY_2 = 23, KEY_3 = 24, KEY_4 = 25, KEY_5 = 26, KEY_6 = 27, KEY_7 = 28, KEY_8 = 29, KEY_9 = 30, KEY_A = 31, KEY_B = 32, KEY_C = 33, KEY_D = 34, KEY_E = 35, KEY_F = 36, KEY_G = 37, KEY_H = 38, KEY_I = 39, KEY_J = 40, KEY_K = 41, KEY_L = 42, KEY_M = 43, KEY_N = 44, KEY_O = 45, KEY_P = 46, KEY_Q = 47, KEY_R = 48, KEY_S = 49, KEY_T = 50, KEY_U = 51, KEY_V = 52, KEY_W = 53, KEY_X = 54, KEY_Y = 55, KEY_Z = 56, Meta = 57, ContextMenu = 58, F1 = 59, F2 = 60, F3 = 61, F4 = 62, F5 = 63, F6 = 64, F7 = 65, F8 = 66, F9 = 67, F10 = 68, F11 = 69, F12 = 70, F13 = 71, F14 = 72, F15 = 73, F16 = 74, F17 = 75, F18 = 76, F19 = 77, NumLock = 78, ScrollLock = 79, /** * Used for miscellaneous characters; it can vary by keyboard. * For the US standard keyboard, the ';:' key */ US_SEMICOLON = 80, /** * For any country/region, the '+' key * For the US standard keyboard, the '=+' key */ US_EQUAL = 81, /** * For any country/region, the ',' key * For the US standard keyboard, the ',<' key */ US_COMMA = 82, /** * For any country/region, the '-' key * For the US standard keyboard, the '-_' key */ US_MINUS = 83, /** * For any country/region, the '.' key * For the US standard keyboard, the '.>' key */ US_DOT = 84, /** * Used for miscellaneous characters; it can vary by keyboard. * For the US standard keyboard, the '/?' key */ US_SLASH = 85, /** * Used for miscellaneous characters; it can vary by keyboard. * For the US standard keyboard, the '`~' key */ US_BACKTICK = 86, /** * Used for miscellaneous characters; it can vary by keyboard. * For the US standard keyboard, the '[{' key */ US_OPEN_SQUARE_BRACKET = 87, /** * Used for miscellaneous characters; it can vary by keyboard. * For the US standard keyboard, the '\|' key */ US_BACKSLASH = 88, /** * Used for miscellaneous characters; it can vary by keyboard. * For the US standard keyboard, the ']}' key */ US_CLOSE_SQUARE_BRACKET = 89, /** * Used for miscellaneous characters; it can vary by keyboard. * For the US standard keyboard, the ''"' key */ US_QUOTE = 90, /** * Used for miscellaneous characters; it can vary by keyboard. */ OEM_8 = 91, /** * Either the angle bracket key or the backslash key on the RT 102-key keyboard. */ OEM_102 = 92, NUMPAD_0 = 93, NUMPAD_1 = 94, NUMPAD_2 = 95, NUMPAD_3 = 96, NUMPAD_4 = 97, NUMPAD_5 = 98, NUMPAD_6 = 99, NUMPAD_7 = 100, NUMPAD_8 = 101, NUMPAD_9 = 102, NUMPAD_MULTIPLY = 103, NUMPAD_ADD = 104, NUMPAD_SEPARATOR = 105, NUMPAD_SUBTRACT = 106, NUMPAD_DECIMAL = 107, NUMPAD_DIVIDE = 108, /** * Placed last to cover the length of the enum. * Please do not depend on this value! */ MAX_VALUE = 109, } export class KeyMod { static readonly CtrlCmd: number; static readonly Shift: number; static readonly Alt: number; static readonly WinCtrl: number; static chord(firstPart: number, secondPart: number): number; } export class Keybinding { value: number; constructor(keybinding: number); equals(other: Keybinding): boolean; hasCtrlCmd(): boolean; hasShift(): boolean; hasAlt(): boolean; hasWinCtrl(): boolean; isModifierKey(): boolean; getKeyCode(): KeyCode; } /** * MarkedString can be used to render human readable text. It is either a markdown string * or a code-block that provides a language and a code snippet. Note that * markdown strings will be sanitized - that means html will be escaped. */ export type MarkedString = string | { readonly language: string; readonly value: string; }; export interface IKeyboardEvent { readonly browserEvent: KeyboardEvent; readonly target: HTMLElement; readonly ctrlKey: boolean; readonly shiftKey: boolean; readonly altKey: boolean; readonly metaKey: boolean; readonly keyCode: KeyCode; toKeybinding(): Keybinding; equals(keybinding: number): boolean; preventDefault(): void; stopPropagation(): void; } export interface IMouseEvent { readonly browserEvent: MouseEvent; readonly leftButton: boolean; readonly middleButton: boolean; readonly rightButton: boolean; readonly target: HTMLElement; readonly detail: number; readonly posx: number; readonly posy: number; readonly ctrlKey: boolean; readonly shiftKey: boolean; readonly altKey: boolean; readonly metaKey: boolean; readonly timestamp: number; preventDefault(): void; stopPropagation(): void; } export interface IScrollEvent { readonly scrollTop: number; readonly scrollLeft: number; readonly scrollWidth: number; readonly scrollHeight: number; readonly scrollTopChanged: boolean; readonly scrollLeftChanged: boolean; readonly scrollWidthChanged: boolean; readonly scrollHeightChanged: boolean; } /** * A position in the editor. This interface is suitable for serialization. */ export interface IPosition { /** * line number (starts at 1) */ readonly lineNumber: number; /** * column (the first character in a line is between column 1 and column 2) */ readonly column: number; } /** * A range in the editor. This interface is suitable for serialization. */ export interface IRange { /** * Line number on which the range starts (starts at 1). */ readonly startLineNumber: number; /** * Column on which the range starts in line `startLineNumber` (starts at 1). */ readonly startColumn: number; /** * Line number on which the range ends. */ readonly endLineNumber: number; /** * Column on which the range ends in line `endLineNumber`. */ readonly endColumn: number; } /** * A selection in the editor. * The selection is a range that has an orientation. */ export interface ISelection { /** * The line number on which the selection has started. */ readonly selectionStartLineNumber: number; /** * The column on `selectionStartLineNumber` where the selection has started. */ readonly selectionStartColumn: number; /** * The line number on which the selection has ended. */ readonly positionLineNumber: number; /** * The column on `positionLineNumber` where the selection has ended. */ readonly positionColumn: number; } /** * A position in the editor. */ export class Position { /** * line number (starts at 1) */ readonly lineNumber: number; /** * column (the first character in a line is between column 1 and column 2) */ readonly column: number; constructor(lineNumber: number, column: number); /** * Test if this position equals other position */ equals(other: IPosition): boolean; /** * Test if position `a` equals position `b` */ static equals(a: IPosition, b: IPosition): boolean; /** * Test if this position is before other position. * If the two positions are equal, the result will be false. */ isBefore(other: IPosition): boolean; /** * Test if position `a` is before position `b`. * If the two positions are equal, the result will be false. */ static isBefore(a: IPosition, b: IPosition): boolean; /** * Test if this position is before other position. * If the two positions are equal, the result will be true. */ isBeforeOrEqual(other: IPosition): boolean; /** * Test if position `a` is before position `b`. * If the two positions are equal, the result will be true. */ static isBeforeOrEqual(a: IPosition, b: IPosition): boolean; /** * A function that compares positions, useful for sorting */ static compare(a: IPosition, b: IPosition): number; /** * Clone this position. */ clone(): Position; /** * Convert to a human-readable representation. */ toString(): string; /** * Create a `Position` from an `IPosition`. */ static lift(pos: IPosition): Position; /** * Test if `obj` is an `IPosition`. */ static isIPosition(obj: any): obj is IPosition; } /** * A range in the editor. (startLineNumber,startColumn) is <= (endLineNumber,endColumn) */ export class Range { /** * Line number on which the range starts (starts at 1). */ readonly startLineNumber: number; /** * Column on which the range starts in line `startLineNumber` (starts at 1). */ readonly startColumn: number; /** * Line number on which the range ends. */ readonly endLineNumber: number; /** * Column on which the range ends in line `endLineNumber`. */ readonly endColumn: number; constructor(startLineNumber: number, startColumn: number, endLineNumber: number, endColumn: number); /** * Test if this range is empty. */ isEmpty(): boolean; /** * Test if `range` is empty. */ static isEmpty(range: IRange): boolean; /** * Test if position is in this range. If the position is at the edges, will return true. */ containsPosition(position: IPosition): boolean; /** * Test if `position` is in `range`. If the position is at the edges, will return true. */ static containsPosition(range: IRange, position: IPosition): boolean; /** * Test if range is in this range. If the range is equal to this range, will return true. */ containsRange(range: IRange): boolean; /** * Test if `otherRange` is in `range`. If the ranges are equal, will return true. */ static containsRange(range: IRange, otherRange: IRange): boolean; /** * A reunion of the two ranges. * The smallest position will be used as the start point, and the largest one as the end point. */ plusRange(range: IRange): Range; /** * A reunion of the two ranges. * The smallest position will be used as the start point, and the largest one as the end point. */ static plusRange(a: IRange, b: IRange): Range; /** * A intersection of the two ranges. */ intersectRanges(range: IRange): Range; /** * A intersection of the two ranges. */ static intersectRanges(a: IRange, b: IRange): Range; /** * Test if this range equals other. */ equalsRange(other: IRange): boolean; /** * Test if range `a` equals `b`. */ static equalsRange(a: IRange, b: IRange): boolean; /** * Return the end position (which will be after or equal to the start position) */ getEndPosition(): Position; /** * Return the start position (which will be before or equal to the end position) */ getStartPosition(): Position; /** * Clone this range. */ cloneRange(): Range; /** * Transform to a user presentable string representation. */ toString(): string; /** * Create a new range using this range's start position, and using endLineNumber and endColumn as the end position. */ setEndPosition(endLineNumber: number, endColumn: number): Range; /** * Create a new range using this range's end position, and using startLineNumber and startColumn as the start position. */ setStartPosition(startLineNumber: number, startColumn: number): Range; /** * Create a new empty range using this range's start position. */ collapseToStart(): Range; /** * Create a new empty range using this range's start position. */ static collapseToStart(range: IRange): Range; /** * Create a `Range` from an `IRange`. */ static lift(range: IRange): Range; /** * Test if `obj` is an `IRange`. */ static isIRange(obj: any): obj is IRange; /** * Test if the two ranges are touching in any way. */ static areIntersectingOrTouching(a: IRange, b: IRange): boolean; /** * A function that compares ranges, useful for sorting ranges * It will first compare ranges on the startPosition and then on the endPosition */ static compareRangesUsingStarts(a: IRange, b: IRange): number; /** * A function that compares ranges, useful for sorting ranges * It will first compare ranges on the endPosition and then on the startPosition */ static compareRangesUsingEnds(a: IRange, b: IRange): number; /** * Test if the range spans multiple lines. */ static spansMultipleLines(range: IRange): boolean; } /** * A selection in the editor. * The selection is a range that has an orientation. */ export class Selection extends Range { /** * The line number on which the selection has started. */ readonly selectionStartLineNumber: number; /** * The column on `selectionStartLineNumber` where the selection has started. */ readonly selectionStartColumn: number; /** * The line number on which the selection has ended. */ readonly positionLineNumber: number; /** * The column on `positionLineNumber` where the selection has ended. */ readonly positionColumn: number; constructor(selectionStartLineNumber: number, selectionStartColumn: number, positionLineNumber: number, positionColumn: number); /** * Clone this selection. */ clone(): Selection; /** * Transform to a human-readable representation. */ toString(): string; /** * Test if equals other selection. */ equalsSelection(other: ISelection): boolean; /** * Test if the two selections are equal. */ static selectionsEqual(a: ISelection, b: ISelection): boolean; /** * Get directions (LTR or RTL). */ getDirection(): SelectionDirection; /** * Create a new selection with a different `positionLineNumber` and `positionColumn`. */ setEndPosition(endLineNumber: number, endColumn: number): Selection; /** * Create a new selection with a different `selectionStartLineNumber` and `selectionStartColumn`. */ setStartPosition(startLineNumber: number, startColumn: number): Selection; /** * Create a `Selection` from an `ISelection`. */ static liftSelection(sel: ISelection): Selection; /** * `a` equals `b`. */ static selectionsArrEqual(a: ISelection[], b: ISelection[]): boolean; /** * Test if `obj` is an `ISelection`. */ static isISelection(obj: any): obj is ISelection; /** * Create with a direction. */ static createWithDirection(startLineNumber: number, startColumn: number, endLineNumber: number, endColumn: number, direction: SelectionDirection): Selection; } /** * The direction of a selection. */ export enum SelectionDirection { /** * The selection starts above where it ends. */ LTR = 0, /** * The selection starts below where it ends. */ RTL = 1, } export class Token { _tokenBrand: void; readonly offset: number; readonly type: string; readonly language: string; constructor(offset: number, type: string, language: string); toString(): string; } } declare module monaco.editor { /** * Create a new editor under `domElement`. * `domElement` should be empty (not contain other dom nodes). * The editor will read the size of `domElement`. */ export function create(domElement: HTMLElement, options?: IEditorConstructionOptions, override?: IEditorOverrideServices): IStandaloneCodeEditor; /** * Emitted when an editor is created. * Creating a diff editor might cause this listener to be invoked with the two editors. * @event */ export function onDidCreateEditor(listener: (codeEditor: ICodeEditor) => void): IDisposable; /** * Create a new diff editor under `domElement`. * `domElement` should be empty (not contain other dom nodes). * The editor will read the size of `domElement`. */ export function createDiffEditor(domElement: HTMLElement, options?: IDiffEditorConstructionOptions, override?: IEditorOverrideServices): IStandaloneDiffEditor; export interface IDiffNavigator { revealFirst: boolean; canNavigate(): boolean; next(): void; previous(): void; dispose(): void; } export interface IDiffNavigatorOptions { readonly followsCaret?: boolean; readonly ignoreCharChanges?: boolean; readonly alwaysRevealFirst?: boolean; } export function createDiffNavigator(diffEditor: IStandaloneDiffEditor, opts?: IDiffNavigatorOptions): IDiffNavigator; /** * Create a new editor model. * You can specify the language that should be set for this model or let the language be inferred from the `uri`. */ export function createModel(value: string, language?: string, uri?: Uri): IModel; /** * Change the language for a model. */ export function setModelLanguage(model: IModel, language: string): void; /** * Set the markers for a model. */ export function setModelMarkers(model: IModel, owner: string, markers: IMarkerData[]): void; /** * Get the model that has `uri` if it exists. */ export function getModel(uri: Uri): IModel; /** * Get all the created models. */ export function getModels(): IModel[]; /** * Emitted when a model is created. * @event */ export function onDidCreateModel(listener: (model: IModel) => void): IDisposable; /** * Emitted right before a model is disposed. * @event */ export function onWillDisposeModel(listener: (model: IModel) => void): IDisposable; /** * Emitted when a different language is set to a model. * @event */ export function onDidChangeModelLanguage(listener: (e: { readonly model: IModel; readonly oldLanguage: string; }) => void): IDisposable; /** * Create a new web worker that has model syncing capabilities built in. * Specify an AMD module to load that will `create` an object that will be proxied. */ export function createWebWorker<T>(opts: IWebWorkerOptions): MonacoWebWorker<T>; /** * Colorize the contents of `domNode` using attribute `data-lang`. */ export function colorizeElement(domNode: HTMLElement, options: IColorizerElementOptions): Promise<void>; /** * Colorize `text` using language `languageId`. */ export function colorize(text: string, languageId: string, options: IColorizerOptions): Promise<string>; /** * Colorize a line in a model. */ export function colorizeModelLine(model: IModel, lineNumber: number, tabSize?: number): string; /** * Tokenize `text` using language `languageId` */ export function tokenize(text: string, languageId: string): Token[][]; /** * Define a new theme. */ export function defineTheme(themeName: string, themeData: ITheme): void; export type BuiltinTheme = 'vs' | 'vs-dark' | 'hc-black'; export interface ITheme { base: BuiltinTheme; inherit: boolean; rules: IThemeRule[]; } export interface IThemeRule { token: string; foreground?: string; background?: string; fontStyle?: string; } /** * A web worker that can provide a proxy to an arbitrary file. */ export interface MonacoWebWorker<T> { /** * Terminate the web worker, thus invalidating the returned proxy. */ dispose(): void; /** * Get a proxy to the arbitrary loaded code. */ getProxy(): Promise<T>; /** * Synchronize (send) the models at `resources` to the web worker, * making them available in the monaco.worker.getMirrorModels(). */ withSyncedResources(resources: Uri[]): Promise<T>; } export interface IWebWorkerOptions { /** * The AMD moduleId to load. * It should export a function `create` that should return the exported proxy. */ moduleId: string; /** * The data to send over when calling create on the module. */ createData?: any; /** * A label to be used to identify the web worker for debugging purposes. */ label?: string; } /** * The options to create an editor. */ export interface IEditorConstructionOptions extends ICodeEditorWidgetCreationOptions { /** * The initial value of the auto created model in the editor. * To not create automatically a model, use `model: null`. */ value?: string; /** * The initial language of the auto created model in the editor. * To not create automatically a model, use `model: null`. */ language?: string; } /** * The options to create a diff editor. */ export interface IDiffEditorConstructionOptions extends IDiffEditorOptions { } export interface IStandaloneCodeEditor extends ICodeEditor { addCommand(keybinding: number, handler: ICommandHandler, context: string): string; createContextKey<T>(key: string, defaultValue: T): IContextKey<T>; addAction(descriptor: IActionDescriptor): IDisposable; } export interface IStandaloneDiffEditor extends IDiffEditor { addCommand(keybinding: number, handler: ICommandHandler, context: string): string; createContextKey<T>(key: string, defaultValue: T): IContextKey<T>; addAction(descriptor: IActionDescriptor): IDisposable; getOriginalEditor(): IStandaloneCodeEditor; getModifiedEditor(): IStandaloneCodeEditor; } export interface ICommandHandler { (...args: any[]): void; } export interface IContextKey<T> { set(value: T): void; reset(): void; get(): T; } export interface IEditorOverrideServices { } /** * A structure defining a problem/warning/etc. */ export interface IMarkerData { code?: string; severity: Severity; message: string; source?: string; startLineNumber: number; startColumn: number; endLineNumber: number; endColumn: number; } export interface IColorizerOptions { tabSize?: number; } export interface IColorizerElementOptions extends IColorizerOptions { theme?: string; mimeType?: string; } export enum ScrollbarVisibility { Auto = 1, Hidden = 2, Visible = 3, } /** * Configuration options for editor scrollbars */ export interface IEditorScrollbarOptions { /** * The size of arrows (if displayed). * Defaults to 11. */ arrowSize?: number; /** * Render vertical scrollbar. * Accepted values: 'auto', 'visible', 'hidden'. * Defaults to 'auto'. */ vertical?: string; /** * Render horizontal scrollbar. * Accepted values: 'auto', 'visible', 'hidden'. * Defaults to 'auto'. */ horizontal?: string; /** * Cast horizontal and vertical shadows when the content is scrolled. * Defaults to true. */ useShadows?: boolean; /** * Render arrows at the top and bottom of the vertical scrollbar. * Defaults to false. */ verticalHasArrows?: boolean; /** * Render arrows at the left and right of the horizontal scrollbar. * Defaults to false. */ horizontalHasArrows?: boolean; /** * Listen to mouse wheel events and react to them by scrolling. * Defaults to true. */ handleMouseWheel?: boolean; /** * Height in pixels for the horizontal scrollbar. * Defaults to 10 (px). */ horizontalScrollbarSize?: number; /** * Width in pixels for the vertical scrollbar. * Defaults to 10 (px). */ verticalScrollbarSize?: number; /** * Width in pixels for the vertical slider. * Defaults to `verticalScrollbarSize`. */ verticalSliderSize?: number; /** * Height in pixels for the horizontal slider. * Defaults to `horizontalScrollbarSize`. */ horizontalSliderSize?: number; } /** * Describes how to indent wrapped lines. */ export enum WrappingIndent { /** * No indentation => wrapped lines begin at column 1. */ None = 0, /** * Same => wrapped lines get the same indentation as the parent. */ Same = 1, /** * Indent => wrapped lines get +1 indentation as the parent. */ Indent = 2, } export type LineNumbersOption = 'on' | 'off' | 'relative' | ((lineNumber: number) => string); /** * Configuration options for the editor. */ export interface IEditorOptions { /** * Enable experimental screen reader support. * Defaults to `true`. */ experimentalScreenReader?: boolean; /** * The aria label for the editor's textarea (when it is focused). */ ariaLabel?: string; /** * Render vertical lines at the specified columns. * Defaults to empty array. */ rulers?: number[]; /** * A string containing the word separators used when doing word navigation. * Defaults to `~!@#$%^&*()-=+[{]}\\|;:\'",.<>/? */ wordSeparators?: string; /** * Enable Linux primary clipboard. * Defaults to true. */ selectionClipboard?: boolean; /** * Control the rendering of line numbers. * If it is a function, it will be invoked when rendering a line number and the return value will be rendered. * Otherwise, if it is a truey, line numbers will be rendered normally (equivalent of using an identity function). * Otherwise, line numbers will not be rendered. * Defaults to true. */ lineNumbers?: LineNumbersOption; /** * Should the corresponding line be selected when clicking on the line number? * Defaults to true. */ selectOnLineNumbers?: boolean; /** * Control the width of line numbers, by reserving horizontal space for rendering at least an amount of digits. * Defaults to 5. */ lineNumbersMinChars?: number; /** * Enable the rendering of the glyph margin. * Defaults to true in vscode and to false in monaco-editor. */ glyphMargin?: boolean; /** * The width reserved for line decorations (in px). * Line decorations are placed between line numbers and the editor content. * You can pass in a string in the format floating point followed by "ch". e.g. 1.3ch. * Defaults to 10. */ lineDecorationsWidth?: number | string; /** * When revealing the cursor, a virtual padding (px) is added to the cursor, turning it into a rectangle. * This virtual padding ensures that the cursor gets revealed before hitting the edge of the viewport. * Defaults to 30 (px). */ revealHorizontalRightPadding?: number; /** * Render the editor selection with rounded borders. * Defaults to true. */ roundedSelection?: boolean; /** * 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`. */ theme?: string; /** * Should the editor be read only. * Defaults to false. */ readOnly?: boolean; /** * Control the behavior and rendering of the scrollbars. */ scrollbar?: IEditorScrollbarOptions; /** * Display overflow widgets as `fixed`. * Defaults to `false`. */ fixedOverflowWidgets?: boolean; /** * The number of vertical lanes the overview ruler should render. * Defaults to 2. */ overviewRulerLanes?: number; /** * Control the cursor animation style, possible values are 'blink', 'smooth', 'phase', 'expand' and 'solid'. * Defaults to 'blink'. */ cursorBlinking?: string; /** * Zoom the font in the editor when using the mouse wheel in combination with holding Ctrl. * Defaults to false. */ mouseWheelZoom?: boolean; /** * Control the cursor style, either 'block' or 'line'. * Defaults to 'line'. */ cursorStyle?: string; /** * Enable font ligatures. * Defaults to false. */ fontLigatures?: boolean; /** * Disable the use of `translate3d`. * Defaults to false. */ disableTranslate3d?: boolean; /** * Disable the optimizations for monospace fonts. * Defaults to false. */ disableMonospaceOptimizations?: boolean; /** * Should the cursor be hidden in the overview ruler. * Defaults to false. */ hideCursorInOverviewRuler?: boolean; /** * Enable that scrolling can go one screen size after the last line. * Defaults to true. */ scrollBeyondLastLine?: boolean; /** * Enable that the editor will install an interval to check if its container dom node size has changed. * Enabling this might have a severe performance impact. * Defaults to false. */ automaticLayout?: boolean; /** * Control the wrapping strategy of the editor. * Using -1 means no wrapping whatsoever. * Using 0 means viewport width wrapping (ajusts with the resizing of the editor). * Using a positive number means wrapping after a fixed number of characters. * Defaults to 300. */ wrappingColumn?: number; /** * Control the alternate style of viewport wrapping. * When set to true viewport wrapping is used only when the window width is less than the number of columns specified in the wrappingColumn property. Has no effect if wrappingColumn is not a positive number. * Defaults to false. */ wordWrap?: boolean; /** * Control indentation of wrapped lines. Can be: 'none', 'same' or 'indent'. * Defaults to 'same' in vscode and to 'none' in monaco-editor. */ wrappingIndent?: string; /** * Configure word wrapping characters. A break will be introduced before these characters. * Defaults to '{([+'. */ wordWrapBreakBeforeCharacters?: string; /** * Configure word wrapping characters. A break will be introduced after these characters. * Defaults to ' \t})]?|&,;'. */ wordWrapBreakAfterCharacters?: string; /** * Configure word wrapping characters. A break will be introduced after these characters only if no `wordWrapBreakBeforeCharacters` or `wordWrapBreakAfterCharacters` were found. * Defaults to '.'. */ wordWrapBreakObtrusiveCharacters?: string; /** * Performance guard: Stop rendering a line after x characters. * Defaults to 10000 if wrappingColumn is -1. Defaults to -1 if wrappingColumn is >= 0. * Use -1 to never stop rendering */ stopRenderingLineAfter?: number; /** * Enable hover. * Defaults to true. */ hover?: boolean; /** * Enable custom contextmenu. * Defaults to true. */ contextmenu?: boolean; /** * A multiplier to be used on the `deltaX` and `deltaY` of mouse wheel scroll events. * Defaults to 1. */ mouseWheelScrollSensitivity?: number; /** * Enable quick suggestions (shadow suggestions) * Defaults to true. */ quickSuggestions?: boolean; /** * Quick suggestions show delay (in ms) * Defaults to 500 (ms) */ quickSuggestionsDelay?: number; /** * Enables parameter hints */ parameterHints?: boolean; /** * Render icons in suggestions box. * Defaults to true. */ iconsInSuggestions?: boolean; /** * Enable auto closing brackets. * Defaults to true. */ autoClosingBrackets?: boolean; /** * Enable format on type. * Defaults to false. */ formatOnType?: boolean; /** * Enable format on paste. * Defaults to false. */ formatOnPaste?: boolean; /** * Enable the suggestion box to pop-up on trigger characters. * Defaults to true. */ suggestOnTriggerCharacters?: boolean; /** * Accept suggestions on ENTER. * Defaults to true. */ acceptSuggestionOnEnter?: boolean; /** * Accept suggestions on provider defined characters. * Defaults to true. */ acceptSuggestionOnCommitCharacter?: boolean; /** * Enable snippet suggestions. Default to 'true'. */ snippetSuggestions?: 'top' | 'bottom' | 'inline' | 'none'; /** * Copying without a selection copies the current line. */ emptySelectionClipboard?: boolean; /** * Enable tab completion. Defaults to 'false' */ tabCompletion?: boolean; /** * Enable word based suggestions. Defaults to 'true' */ wordBasedSuggestions?: boolean; /** * The font size for the suggest widget. * Defaults to the editor font size. */ suggestFontSize?: number; /** * The line height for the suggest widget. * Defaults to the editor line height. */ suggestLineHeight?: number; /** * Enable selection highlight. * Defaults to true. */ selectionHighlight?: boolean; /** * Show code lens * Defaults to true. */ codeLens?: boolean; /** * Enable code folding * Defaults to true in vscode and to false in monaco-editor. */ folding?: boolean; /** * Enable rendering of whitespace. * Defaults to none. */ renderWhitespace?: 'none' | 'boundary' | 'all'; /** * Enable rendering of control characters. * Defaults to false. */ renderControlCharacters?: boolean; /** * Enable rendering of indent guides. * Defaults to false. */ renderIndentGuides?: boolean; /** * Enable rendering of current line highlight. * Defaults to all. */ renderLineHighlight?: 'none' | 'gutter' | 'line' | 'all'; /** * Inserting and deleting whitespace follows tab stops. */ useTabStops?: boolean; /** * The font family */ fontFamily?: string; /** * The font weight */ fontWeight?: 'normal' | 'bold' | 'bolder' | 'lighter' | 'initial' | 'inherit' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900'; /** * The font size */ fontSize?: number; /** * The line height */ lineHeight?: number; } /** * Configuration options for the diff editor. */ export interface IDiffEditorOptions extends IEditorOptions { /** * Allow the user to resize the diff editor split view. * Defaults to true. */ enableSplitViewResizing?: boolean; /** * Render the differences in two side-by-side editors. * Defaults to true. */ renderSideBySide?: boolean; /** * Compute the diff by ignoring leading/trailing whitespace * Defaults to true. */ ignoreTrimWhitespace?: boolean; /** * Render +/- indicators for added/deleted changes. * Defaults to true. */ renderIndicators?: boolean; /** * Original model should be editable? * Defaults to false. */ originalEditable?: boolean; } export class InternalEditorScrollbarOptions { readonly _internalEditorScrollbarOptionsBrand: void; readonly arrowSize: number; readonly vertical: ScrollbarVisibility; readonly horizontal: ScrollbarVisibility; readonly useShadows: boolean; readonly verticalHasArrows: boolean; readonly horizontalHasArrows: boolean; readonly handleMouseWheel: boolean; readonly horizontalScrollbarSize: number; readonly horizontalSliderSize: number; readonly verticalScrollbarSize: number; readonly verticalSliderSize: number; readonly mouseWheelScrollSensitivity: number; } export class EditorWrappingInfo { readonly _editorWrappingInfoBrand: void; readonly isViewportWrapping: boolean; readonly wrappingColumn: number; readonly wrappingIndent: WrappingIndent; readonly wordWrapBreakBeforeCharacters: string; readonly wordWrapBreakAfterCharacters: string; readonly wordWrapBreakObtrusiveCharacters: string; } export class InternalEditorViewOptions { readonly _internalEditorViewOptionsBrand: void; readonly theme: string; readonly canUseTranslate3d: boolean; readonly disableMonospaceOptimizations: boolean; readonly experimentalScreenReader: boolean; readonly rulers: number[]; readonly ariaLabel: string; readonly renderLineNumbers: boolean; readonly renderCustomLineNumbers: (lineNumber: number) => string; readonly renderRelativeLineNumbers: boolean; readonly selectOnLineNumbers: boolean;