UNPKG

monaco-editor

Version:
1,478 lines (1,399 loc) • 272 kB
/*!----------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Type definitions for monaco-editor * Released under the MIT license *-----------------------------------------------------------*/ /*--------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ declare let MonacoEnvironment: monaco.Environment | undefined; declare namespace monaco { export type Thenable<T> = PromiseLike<T>; export interface Environment { globalAPI?: boolean; baseUrl?: string; getWorker?(workerId: string, label: string): Worker; getWorkerUrl?(workerId: string, label: string): string; } 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 MarkerTag { Unnecessary = 1, Deprecated = 2 } export enum MarkerSeverity { Hint = 1, Info = 2, Warning = 4, Error = 8 } export class CancellationTokenSource { constructor(parent?: CancellationToken); get token(): CancellationToken; cancel(): void; dispose(cancel?: boolean): void; } export interface CancellationToken { /** * A flag signalling is cancellation has been requested. */ readonly isCancellationRequested: boolean; /** * An event which fires when cancellation is requested. This event * only ever fires `once` as cancellation can only happen once. Listeners * that are registered after cancellation will be called (next event loop run), * but also only once. * * @event */ readonly onCancellationRequested: (listener: (e: any) => any, thisArgs?: any, disposables?: IDisposable[]) => IDisposable; } /** * Uniform Resource Identifier (Uri) http://tools.ietf.org/html/rfc3986. * This class is a simple parser which creates the basic component parts * (http://tools.ietf.org/html/rfc3986#section-3) with minimal validation * and encoding. * * ```txt * foo://example.com:8042/over/there?name=ferret#nose * \_/ \______________/\_________/ \_________/ \__/ * | | | | | * scheme authority path query fragment * | _____________________|__ * / \ / \ * urn:example:animal:ferret:nose * ``` */ export class Uri implements UriComponents { static isUri(thing: any): thing is Uri; /** * 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, normalizes windows drive letters to lower-case, and 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. * * The result shall *not* be used for display purposes but for accessing a file on disk. * * * The *difference* to `Uri#path` is the use of the platform specific separator and the handling * of UNC paths. See the below sample of a file-uri with an authority (UNC path). * * ```ts const u = Uri.parse('file://server/c$/folder/file.txt') u.authority === 'server' u.path === '/shares/c$/file.txt' u.fsPath === '\\server\c$\folder\file.txt' ``` * * Using `Uri#path` to read a file (using fs-apis) would not be enough because parts of the path, * namely the server name, would be missing. Therefore `Uri#fsPath` exists - it's sugar to ease working * with URIs that represent files on disk (`file` scheme). */ get fsPath(): string; with(change: { scheme?: string; authority?: string | null; path?: string | null; query?: string | null; fragment?: string | null; }): Uri; /** * Creates a new Uri from a string, e.g. `http://www.msft.com/some/path`, * `file:///usr/home`, or `scheme:with/path`. * * @param value A string which represents an Uri (see `Uri#toString`). */ static parse(value: string, _strict?: boolean): Uri; /** * Creates a new Uri from a file system path, e.g. `c:\my\files`, * `/usr/home`, or `\\server\share\some\path`. * * The *difference* between `Uri#parse` and `Uri#file` is that the latter treats the argument * as path, not as stringified-uri. E.g. `Uri.file(path)` is **not the same as** * `Uri.parse('file://' + path)` because the path might contain characters that are * interpreted (# and ?). See the following sample: * ```ts const good = Uri.file('/coding/c#/project1'); good.scheme === 'file'; good.path === '/coding/c#/project1'; good.fragment === ''; const bad = Uri.parse('file://' + '/coding/c#/project1'); bad.scheme === 'file'; bad.path === '/coding/c'; // path is now broken bad.fragment === '/project1'; ``` * * @param path A file system path (see `Uri#fsPath`) */ static file(path: string): Uri; static from(components: { scheme: string; authority?: string; path?: string; query?: string; fragment?: string; }): Uri; /** * Join a Uri path with path fragments and normalizes the resulting path. * * @param uri The input Uri. * @param pathFragment The path fragment to add to the Uri path. * @returns The resulting Uri. */ static joinPath(uri: Uri, ...pathFragment: string[]): Uri; /** * Creates a string representation for this Uri. It's guaranteed that calling * `Uri.parse` with the result of this function creates an Uri which is equal * to this Uri. * * * The result shall *not* be used for display purposes but for externalization or transport. * * The result will be encoded using the percentage encoding and encoding happens mostly * ignore the scheme-specific encoding rules. * * @param skipEncoding Do not encode the result, default is `false` */ toString(skipEncoding?: boolean): string; toJSON(): UriComponents; static revive(data: UriComponents | Uri): Uri; static revive(data: UriComponents | Uri | undefined): Uri | undefined; static revive(data: UriComponents | Uri | null): Uri | null; static revive(data: UriComponents | Uri | undefined | null): Uri | undefined | null; } export interface UriComponents { scheme: string; authority: string; path: string; query: string; fragment: string; } /** * 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 { DependsOnKbLayout = -1, /** * 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, /** * Cover all key codes when IME is processing input. */ KEY_IN_COMPOSITION = 109, ABNT_C1 = 110, ABNT_C2 = 111, /** * Placed last to cover the length of the enum. * Please do not depend on this value! */ MAX_VALUE = 112 } 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 interface IMarkdownString { readonly value: string; readonly isTrusted?: boolean; readonly supportThemeIcons?: boolean; uris?: { [href: string]: UriComponents; }; } export interface IKeyboardEvent { readonly _standardKeyboardEventBrand: true; readonly browserEvent: KeyboardEvent; readonly target: HTMLElement; readonly ctrlKey: boolean; readonly shiftKey: boolean; readonly altKey: boolean; readonly metaKey: boolean; readonly keyCode: KeyCode; readonly code: string; equals(keybinding: number): boolean; preventDefault(): void; stopPropagation(): void; } export interface IMouseEvent { readonly browserEvent: MouseEvent; readonly leftButton: boolean; readonly middleButton: boolean; readonly rightButton: boolean; readonly buttons: number; 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 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); /** * Create a new position from this position. * * @param newLineNumber new line number * @param newColumn new column */ with(newLineNumber?: number, newColumn?: number): Position; /** * Derive a new position from this position. * * @param deltaLineNumber line number delta * @param deltaColumn column delta */ delta(deltaLineNumber?: number, deltaColumn?: number): Position; /** * Test if this position equals other position */ equals(other: IPosition): boolean; /** * Test if position `a` equals position `b` */ static equals(a: IPosition | null, b: IPosition | null): 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. 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 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; /** * Test if `range` is strictly in this range. `range` must start after and end before this range for the result to be true. */ strictContainsRange(range: IRange): boolean; /** * Test if `otherRange` is strinctly in `range` (must start after, and end before). If the ranges are equal, will return false. */ static strictContainsRange(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 | null; /** * A intersection of the two ranges. */ static intersectRanges(a: IRange, b: IRange): Range | null; /** * Test if this range equals other. */ equalsRange(other: IRange | null): boolean; /** * Test if range `a` equals `b`. */ static equalsRange(a: IRange | null, b: IRange | null): boolean; /** * Return the end position (which will be after or equal to the start position) */ getEndPosition(): Position; /** * Return the end position (which will be after or equal to the start position) */ static getEndPosition(range: IRange): Position; /** * Return the start position (which will be before or equal to the end position) */ getStartPosition(): Position; /** * Return the start position (which will be before or equal to the end position) */ static getStartPosition(range: IRange): Position; /** * 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; static fromPositions(start: IPosition, end?: IPosition): Range; /** * Create a `Range` from an `IRange`. */ static lift(range: undefined | null): null; 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; /** * Test if the two ranges are intersecting. If the ranges are touching it returns true. */ static areIntersecting(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 | null | undefined, b: IRange | null | undefined): 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 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 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); /** * 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; /** * Get the position at `positionLineNumber` and `positionColumn`. */ getPosition(): Position; /** * Create a new selection with a different `selectionStartLineNumber` and `selectionStartColumn`. */ setStartPosition(startLineNumber: number, startColumn: number): Selection; /** * Create a `Selection` from one or two positions */ static fromPositions(start: IPosition, end?: IPosition): 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 namespace monaco.editor { export interface IDiffNavigator { canNavigate(): boolean; next(): void; previous(): void; dispose(): void; } /** * 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?: IStandaloneEditorConstructionOptions, 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 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): ITextModel; /** * Change the language for a model. */ export function setModelLanguage(model: ITextModel, languageId: string): void; /** * Set the markers for a model. */ export function setModelMarkers(model: ITextModel, owner: string, markers: IMarkerData[]): void; /** * Get markers for owner and/or resource * * @returns list of markers */ export function getModelMarkers(filter: { owner?: string; resource?: Uri; take?: number; }): IMarker[]; /** * Emitted when markers change for a model. * @event */ export function onDidChangeMarkers(listener: (e: readonly Uri[]) => void): IDisposable; /** * Get the model that has `uri` if it exists. */ export function getModel(uri: Uri): ITextModel | null; /** * Get all the created models. */ export function getModels(): ITextModel[]; /** * Emitted when a model is created. * @event */ export function onDidCreateModel(listener: (model: ITextModel) => void): IDisposable; /** * Emitted right before a model is disposed. * @event */ export function onWillDisposeModel(listener: (model: ITextModel) => void): IDisposable; /** * Emitted when a different language is set to a model. * @event */ export function onDidChangeModelLanguage(listener: (e: { readonly model: ITextModel; 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: ITextModel, lineNumber: number, tabSize?: number): string; /** * Tokenize `text` using language `languageId` */ export function tokenize(text: string, languageId: string): Token[][]; /** * Define a new theme or update an existing theme. */ export function defineTheme(themeName: string, themeData: IStandaloneThemeData): void; /** * Switches to a theme. */ export function setTheme(themeName: string): void; /** * Clears all cached font measurements and triggers re-measurement. */ export function remeasureFonts(): void; /** * Register a command. */ export function registerCommand(id: string, handler: (accessor: any, ...args: any[]) => void): IDisposable; export type BuiltinTheme = 'vs' | 'vs-dark' | 'hc-black'; export interface IStandaloneThemeData { base: BuiltinTheme; inherit: boolean; rules: ITokenThemeRule[]; encodedTokensColors?: string[]; colors: IColors; } export type IColors = { [colorId: string]: string; }; export interface ITokenThemeRule { 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; /** * An object that can be used by the web worker to make calls back to the main thread. */ host?: any; /** * Keep idle models. * Defaults to false, which means that idle models will stop syncing after a while. */ keepIdleModels?: boolean; } /** * Description of an action contribution */ export interface IActionDescriptor { /** * An unique identifier of the contributed action. */ id: string; /** * A label of the action that will be presented to the user. */ label: string; /** * Precondition rule. */ precondition?: string; /** * An array of keybindings for the action. */ keybindings?: number[]; /** * The keybinding rule (condition on top of precondition). */ keybindingContext?: string; /** * Control if the action should show up in the context menu and where. * The context menu of the editor has these default: * navigation - The navigation group comes first in all cases. * 1_modification - This group comes next and contains commands that modify your code. * 9_cutcopypaste - The last default group with the basic editing commands. * You can also create your own group. * Defaults to null (don't show in context menu). */ contextMenuGroupId?: string; /** * Control the order in the context menu group. */ contextMenuOrder?: number; /** * Method that will be executed when the action is triggered. * @param editor The editor instance is passed in as a convenience */ run(editor: ICodeEditor, ...args: any[]): void | Promise<void>; } /** * Options which apply for all editors. */ export interface IGlobalEditorOptions { /** * The number of spaces a tab is equal to. * This setting is overridden based on the file contents when `detectIndentation` is on. * Defaults to 4. */ tabSize?: number; /** * Insert spaces when pressing `Tab`. * This setting is overridden based on the file contents when `detectIndentation` is on. * Defaults to true. */ insertSpaces?: boolean; /** * Controls whether `tabSize` and `insertSpaces` will be automatically detected when a file is opened based on the file contents. * Defaults to true. */ detectIndentation?: boolean; /** * Remove trailing auto inserted whitespace. * Defaults to true. */ trimAutoWhitespace?: boolean; /** * Special handling for large files to disable certain memory intensive features. * Defaults to true. */ largeFileOptimizations?: boolean; /** * Controls whether completions should be computed based on words in the document. * Defaults to true. */ wordBasedSuggestions?: boolean; /** * Controls whether word based completions should be included from opened documents of the same language or any language. */ wordBasedSuggestionsOnlySameLanguage?: boolean; /** * Controls whether the semanticHighlighting is shown for the languages that support it. * true: semanticHighlighting is enabled for all themes * false: semanticHighlighting is disabled for all themes * 'configuredByTheme': semanticHighlighting is controlled by the current color theme's semanticHighlighting setting. * Defaults to 'byTheme'. */ 'semanticHighlighting.enabled'?: true | false | 'configuredByTheme'; /** * Keep peek editors open even when double clicking their content or when hitting `Escape`. * Defaults to false. */ stablePeek?: boolean; /** * Lines above this length will not be tokenized for performance reasons. * Defaults to 20000. */ maxTokenizationLineLength?: number; /** * 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`. * **NOTE**: The theme might be overwritten if the OS is in high contrast mode, unless `autoDetectHighContrast` is set to false. */ theme?: string; /** * If enabled, will automatically change to high contrast theme if the OS is using a high contrast theme. * Defaults to true. */ autoDetectHighContrast?: boolean; } /** * The options to create an editor. */ export interface IStandaloneEditorConstructionOptions extends IEditorConstructionOptions, IGlobalEditorOptions { /** * The initial model associated with this code editor. */ model?: ITextModel | null; /** * 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; /** * 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`. * **NOTE**: The theme might be overwritten if the OS is in high contrast mode, unless `autoDetectHighContrast` is set to false. */ theme?: string; /** * If enabled, will automatically change to high contrast theme if the OS is using a high contrast theme. * Defaults to true. */ autoDetectHighContrast?: boolean; /** * An URL to open when Ctrl+H (Windows and Linux) or Cmd+H (OSX) is pressed in * the accessibility help dialog in the editor. * * Defaults to "https://go.microsoft.com/fwlink/?linkid=852450" */ accessibilityHelpUrl?: string; } /** * The options to create a diff editor. */ export interface IDiffEditorConstructionOptions extends IDiffEditorOptions { /** * 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`. * **NOTE**: The theme might be overwritten if the OS is in high contrast mode, unless `autoDetectHighContrast` is set to false. */ theme?: string; /** * If enabled, will automatically change to high contrast theme if the OS is using a high contrast theme. * Defaults to true. */ autoDetectHighContrast?: boolean; } export interface IStandaloneCodeEditor extends ICodeEditor { updateOptions(newOptions: IEditorOptions & IGlobalEditorOptions): void; addCommand(keybinding: number, handler: ICommandHandler, context?: string): string | null; 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 | null; 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 | undefined; } export interface IEditorOverrideServices { [index: string]: any; } export interface IMarker { owner: string; resource: Uri; severity: MarkerSeverity; code?: string | { value: string; target: Uri; }; message: string; source?: string; startLineNumber: number; startColumn: number; endLineNumber: number; endColumn: number; relatedInformation?: IRelatedInformation[]; tags?: MarkerTag[]; } /** * A structure defining a problem/warning/etc. */ export interface IMarkerData { code?: string | { value: string; target: Uri; }; severity: MarkerSeverity; message: string; source?: string; startLineNumber: number; startColumn: number; endLineNumber: number; endColumn: number; relatedInformation?: IRelatedInformation[]; tags?: MarkerTag[]; } /** * */ export interface IRelatedInformation { resource: Uri; message: 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 } export interface ThemeColor { id: string; } /** * Vertical Lane in the overview ruler of the editor. */ export enum OverviewRulerLane { Left = 1, Center = 2, Right = 4, Full = 7 } /** * Position in the minimap to render the decoration. */ export enum MinimapPosition { Inline = 1, Gutter = 2 } export interface IDecorationOptions { /** * CSS color to render. * e.g.: rgba(100, 100, 100, 0.5) or a color from the color registry */ color: string | ThemeColor | undefined; /** * CSS color to render. * e.g.: rgba(100, 100, 100, 0.5) or a color from the color registry */ darkColor?: string | ThemeColor; } /** * Options for rendering a model decoration in the overview ruler. */ export interface IModelDecorationOverviewRulerOptions extends IDecorationOptions { /** * The position in the overview ruler. */ position: OverviewRulerLane; } /** * Options for rendering a model decoration in the overview ruler. */ export interface IModelDecorationMinimapOptions extends IDecorationOptions { /** * The position in the overview ruler. */ position: MinimapPosition; } /** * Options for a model decoration. */ export interface IModelDecorationOptions { /** * Customize the growing behavior of the decoration when typing at the edges of the decoration. * Defaults to TrackedRangeStickiness.AlwaysGrowsWhenTypingAtEdges */ stickiness?: TrackedRangeStickiness; /** * CSS class name describing the decoration. */ className?: string | null; /** * Message to be rendered when hovering over the glyph margin decoration. */ glyphMarginHoverMessage?: IMarkdownString | IMarkdownString[] | null; /** * Array of MarkdownString to render as the decoration message. */ hoverMessage?: IMarkdownString | IMarkdownString[] | null; /** * Should the decoration expand to encompass a whole line. */ isWholeLine?: boolean; /** * Specifies the stack order of a decoration. * A decoration with greater stack order is always in front of a decoration with a lower stack order. */ zIndex?: number; /** * If set, render this decoration in the overview ruler. */ overviewRuler?: IModelDecorationOverviewRulerOptions | null; /** * If set, render this decoration in the minimap. */ minimap?: IModelDecorationMinimapOptions | null; /** * If set, the decoration will be rendered in the glyph margin with this CSS class name. */ glyphMarginClassName?: string | null; /** * If set, the decoration will be rendered in the lines decorations with this CSS class name. */ linesDecorationsClassName?: string | null; /** * If set, the decoration will be rendered in the lines decorations with this CSS class name, but only for the first line in case of line wrapping. */ firstLineDecorationClassName?: string | null; /** * If set, the decoration will be rendered in the margin (covering its full width) with this CSS class name. */ marginClassName?: string | null; /** * If set, the decoration will be rendered inline with the text with this CSS class name. * Please use this only for CSS rules that must impact the text. For example, use `className` * to have a background color decoration. */ inlineClassName?: string | null; /** * If there is an `inlineClassName` which affects letter spacing. */ inlineClassNameAffectsLetterSpacing?: boolean; /** * If set, the decoration will be rendered before the text with this CSS class name. */ beforeContentClassName?: string | null; /** * If set, the decoration will be rendered after the text with this CSS class name. */ afterContentClassName?: string | null; } /** * New model decorations. */ export interface IModelDeltaDecoration { /** * Range that this decoration covers. */ range: IRange; /** * Options associated with this decoration. */ options: IModelDecorationOptions; } /** * A decoration in the model. */ export interface IModelDecoration { /** * Identifier for a decoration. */ readonly id: string; /** * Identifier for a decoration's owner. */ readonly ownerId: n