diff --git a/monaco.d.ts b/monaco.d.ts index 566d65e0..8b556227 100644 --- a/monaco.d.ts +++ b/monaco.d.ts @@ -3,6 +3,11 @@ * Type definitions for monaco-editor v0.8.3 * 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 module monaco { interface Thenable { @@ -79,7 +84,12 @@ declare module monaco { public done(success?: (value: V) => void, error?: (err: any) => any, progress?: ProgressCallback): void; public cancel(): void; + public static as(value: null): Promise; + public static as(value: undefined): Promise; + public static as(value: Promise): Promise; + public static as(value: Thenable): Thenable; public static as(value: ValueType): Promise; + public static is(value: any): value is Thenable; public static timeout(delay: number): Promise; public static join(promises: Promise[]): Promise; @@ -90,7 +100,7 @@ declare module monaco { public static wrap(value: Thenable): Promise; public static wrap(value: ValueType): Promise; - public static wrapError(error: any): Promise; + public static wrapError(error: Error): Promise; } export class CancellationTokenSource { @@ -348,11 +358,17 @@ declare module monaco { 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 = 109, + MAX_VALUE = 112, } export class KeyMod { @@ -362,18 +378,6 @@ declare module monaco { 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 @@ -392,7 +396,7 @@ declare module monaco { readonly altKey: boolean; readonly metaKey: boolean; readonly keyCode: KeyCode; - toKeybinding(): Keybinding; + readonly code: string; equals(keybinding: number): boolean; preventDefault(): void; stopPropagation(): void; @@ -425,7 +429,6 @@ declare module monaco { readonly scrollWidthChanged: boolean; readonly scrollHeightChanged: boolean; } - /** * A position in the editor. This interface is suitable for serialization. */ @@ -440,51 +443,6 @@ declare module monaco { 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. */ @@ -548,6 +506,28 @@ declare module monaco { 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) */ @@ -651,6 +631,7 @@ declare module monaco { * 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`. */ @@ -679,6 +660,29 @@ declare module monaco { 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. @@ -725,10 +729,18 @@ declare module monaco { * 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`. */ @@ -887,17 +899,27 @@ declare module monaco.editor { /** * Define a new theme. */ - export function defineTheme(themeName: string, themeData: ITheme): void; + export function defineTheme(themeName: string, themeData: IStandaloneThemeData): void; + + /** + * Switches to a theme. + */ + export function setTheme(themeName: string): void; export type BuiltinTheme = 'vs' | 'vs-dark' | 'hc-black'; - export interface ITheme { + export interface IStandaloneThemeData { base: BuiltinTheme; inherit: boolean; - rules: IThemeRule[]; + rules: ITokenThemeRule[]; + colors: IColors; } - export interface IThemeRule { + export type IColors = { + [colorId: string]: string; + }; + + export interface ITokenThemeRule { token: string; foreground?: string; background?: string; @@ -942,7 +964,11 @@ declare module monaco.editor { /** * The options to create an editor. */ - export interface IEditorConstructionOptions extends ICodeEditorWidgetCreationOptions { + export interface IEditorConstructionOptions extends IEditorOptions { + /** + * The initial model associated with this code editor. + */ + model?: IModel; /** * The initial value of the auto created model in the editor. * To not create automatically a model, use `model: null`. @@ -953,12 +979,33 @@ declare module monaco.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` + */ + theme?: string; + /** + * 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` + */ + theme?: string; } export interface IStandaloneCodeEditor extends ICodeEditor { @@ -985,6 +1032,7 @@ declare module monaco.editor { } export interface IEditorOverrideServices { + [index: string]: any; } /** @@ -1016,591 +1064,8 @@ declare module monaco.editor { 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; - readonly glyphMargin: boolean; - readonly revealHorizontalRightPadding: number; - readonly roundedSelection: boolean; - readonly overviewRulerLanes: number; - readonly cursorBlinking: TextEditorCursorBlinkingStyle; - readonly mouseWheelZoom: boolean; - readonly cursorStyle: TextEditorCursorStyle; - readonly hideCursorInOverviewRuler: boolean; - readonly scrollBeyondLastLine: boolean; - readonly editorClassName: string; - readonly stopRenderingLineAfter: number; - readonly renderWhitespace: 'none' | 'boundary' | 'all'; - readonly renderControlCharacters: boolean; - readonly renderIndentGuides: boolean; - readonly renderLineHighlight: 'none' | 'gutter' | 'line' | 'all'; - readonly scrollbar: InternalEditorScrollbarOptions; - readonly fixedOverflowWidgets: boolean; - } - - export interface IViewConfigurationChangedEvent { - readonly theme: boolean; - readonly canUseTranslate3d: boolean; - readonly disableMonospaceOptimizations: boolean; - readonly experimentalScreenReader: boolean; - readonly rulers: boolean; - readonly ariaLabel: boolean; - readonly renderLineNumbers: boolean; - readonly renderCustomLineNumbers: boolean; - readonly renderRelativeLineNumbers: boolean; - readonly selectOnLineNumbers: boolean; - readonly glyphMargin: boolean; - readonly revealHorizontalRightPadding: boolean; - readonly roundedSelection: boolean; - readonly overviewRulerLanes: boolean; - readonly cursorBlinking: boolean; - readonly mouseWheelZoom: boolean; - readonly cursorStyle: boolean; - readonly hideCursorInOverviewRuler: boolean; - readonly scrollBeyondLastLine: boolean; - readonly editorClassName: boolean; - readonly stopRenderingLineAfter: boolean; - readonly renderWhitespace: boolean; - readonly renderControlCharacters: boolean; - readonly renderIndentGuides: boolean; - readonly renderLineHighlight: boolean; - readonly scrollbar: boolean; - readonly fixedOverflowWidgets: boolean; - } - - export class EditorContribOptions { - readonly selectionClipboard: boolean; - readonly hover: boolean; - readonly contextmenu: boolean; - readonly quickSuggestions: boolean; - readonly quickSuggestionsDelay: number; - readonly parameterHints: boolean; - readonly iconsInSuggestions: boolean; - readonly formatOnType: boolean; - readonly formatOnPaste: boolean; - readonly suggestOnTriggerCharacters: boolean; - readonly acceptSuggestionOnEnter: boolean; - readonly acceptSuggestionOnCommitCharacter: boolean; - readonly snippetSuggestions: 'top' | 'bottom' | 'inline' | 'none'; - readonly emptySelectionClipboard: boolean; - readonly tabCompletion: boolean; - readonly wordBasedSuggestions: boolean; - readonly suggestFontSize: number; - readonly suggestLineHeight: number; - readonly selectionHighlight: boolean; - readonly codeLens: boolean; - readonly folding: boolean; - } - - /** - * Internal configuration options (transformed or computed) for the editor. - */ - export class InternalEditorOptions { - readonly _internalEditorOptionsBrand: void; - readonly lineHeight: number; - readonly readOnly: boolean; - readonly wordSeparators: string; - readonly autoClosingBrackets: boolean; - readonly useTabStops: boolean; - readonly tabFocusMode: boolean; - readonly layoutInfo: EditorLayoutInfo; - readonly fontInfo: FontInfo; - readonly viewInfo: InternalEditorViewOptions; - readonly wrappingInfo: EditorWrappingInfo; - readonly contribInfo: EditorContribOptions; - } - - /** - * An event describing that the configuration of the editor has changed. - */ - export interface IConfigurationChangedEvent { - readonly lineHeight: boolean; - readonly readOnly: boolean; - readonly wordSeparators: boolean; - readonly autoClosingBrackets: boolean; - readonly useTabStops: boolean; - readonly tabFocusMode: boolean; - readonly layoutInfo: boolean; - readonly fontInfo: boolean; - readonly viewInfo: IViewConfigurationChangedEvent; - readonly wrappingInfo: boolean; - readonly contribInfo: boolean; + export interface ThemeColor { + id: string; } /** @@ -1619,14 +1084,19 @@ declare module monaco.editor { export interface IModelDecorationOverviewRulerOptions { /** * CSS color to render in the overview ruler. - * e.g.: rgba(100, 100, 100, 0.5) + * e.g.: rgba(100, 100, 100, 0.5) or a color from the color registry */ - color: string; + color: string | ThemeColor; /** * CSS color to render in the overview ruler. - * e.g.: rgba(100, 100, 100, 0.5) + * e.g.: rgba(100, 100, 100, 0.5) or a color from the color registry */ - darkColor: string; + darkColor: string | ThemeColor; + /** + * CSS color to render in the overview ruler. + * e.g.: rgba(100, 100, 100, 0.5) or a color from the color registry + */ + hcColor?: string | ThemeColor; /** * The position in the overview ruler. */ @@ -1638,7 +1108,7 @@ declare module monaco.editor { */ export interface IModelDecorationOptions { /** - * Customize the growing behaviour of the decoration when typing at the edges of the decoration. + * Customize the growing behavior of the decoration when typing at the edges of the decoration. * Defaults to TrackedRangeStickiness.AlwaysGrowsWhenTypingAtEdges */ stickiness?: TrackedRangeStickiness; @@ -1658,10 +1128,6 @@ declare module monaco.editor { * Should the decoration expand to encompass a whole line. */ isWholeLine?: boolean; - /** - * @deprecated : Use `overviewRuler` instead - */ - showInOverviewRuler?: string; /** * If set, render this decoration in the overview ruler. */ @@ -1822,6 +1288,13 @@ declare module monaco.editor { * @param text The text to replace with. May be null to represent a simple delete. */ addEditOperation(range: Range, text: string): void; + /** + * Add a new edit operation (a replace operation). + * The inverse edits will be accessible in `ICursorStateComputerData.getInverseEditOperations()` + * @param range The range to replace (delete). May be empty to represent a simple insert. + * @param text The text to replace with. May be null to represent a simple delete. + */ + addTrackedEditOperation(range: Range, text: string): void; /** * Track `selection` when applying edit operations. * A best effort will be made to not grow/expand the selection. @@ -1941,16 +1414,13 @@ declare module monaco.editor { trimAutoWhitespace?: boolean; } - export interface IModelOptionsChangedEvent { - readonly tabSize: boolean; - readonly insertSpaces: boolean; - readonly trimAutoWhitespace: boolean; - } - /** * A textual read-only model. */ export interface ITextModel { + /** + * Get the resolved options for this model. + */ getOptions(): TextModelResolvedOptions; /** * Get the current version id of the model. @@ -2080,46 +1550,46 @@ declare module monaco.editor { * @param searchOnlyEditableRange Limit the searching to only search inside the editable range of the model. * @param isRegex Used to indicate that `searchString` is a regular expression. * @param matchCase Force the matching to match lower/upper case exactly. - * @param wholeWord Force the matching to match entire words only. + * @param wordSeparators Force the matching to match entire words only. Pass null otherwise. * @param captureMatches The result will contain the captured groups. * @param limitResultCount Limit the number of results * @return The ranges where the matches are. It is empty if not matches have been found. */ - findMatches(searchString: string, searchOnlyEditableRange: boolean, isRegex: boolean, matchCase: boolean, wholeWord: boolean, captureMatches: boolean, limitResultCount?: number): FindMatch[]; + findMatches(searchString: string, searchOnlyEditableRange: boolean, isRegex: boolean, matchCase: boolean, wordSeparators: string, captureMatches: boolean, limitResultCount?: number): FindMatch[]; /** * Search the model. * @param searchString The string used to search. If it is a regular expression, set `isRegex` to true. * @param searchScope Limit the searching to only search inside this range. * @param isRegex Used to indicate that `searchString` is a regular expression. * @param matchCase Force the matching to match lower/upper case exactly. - * @param wholeWord Force the matching to match entire words only. + * @param wordSeparators Force the matching to match entire words only. Pass null otherwise. * @param captureMatches The result will contain the captured groups. * @param limitResultCount Limit the number of results * @return The ranges where the matches are. It is empty if no matches have been found. */ - findMatches(searchString: string, searchScope: IRange, isRegex: boolean, matchCase: boolean, wholeWord: boolean, captureMatches: boolean, limitResultCount?: number): FindMatch[]; + findMatches(searchString: string, searchScope: IRange, isRegex: boolean, matchCase: boolean, wordSeparators: string, captureMatches: boolean, limitResultCount?: number): FindMatch[]; /** * Search the model for the next match. Loops to the beginning of the model if needed. * @param searchString The string used to search. If it is a regular expression, set `isRegex` to true. * @param searchStart Start the searching at the specified position. * @param isRegex Used to indicate that `searchString` is a regular expression. * @param matchCase Force the matching to match lower/upper case exactly. - * @param wholeWord Force the matching to match entire words only. + * @param wordSeparators Force the matching to match entire words only. Pass null otherwise. * @param captureMatches The result will contain the captured groups. * @return The range where the next match is. It is null if no next match has been found. */ - findNextMatch(searchString: string, searchStart: IPosition, isRegex: boolean, matchCase: boolean, wholeWord: boolean, captureMatches: boolean): FindMatch; + findNextMatch(searchString: string, searchStart: IPosition, isRegex: boolean, matchCase: boolean, wordSeparators: string, captureMatches: boolean): FindMatch; /** * Search the model for the previous match. Loops to the end of the model if needed. * @param searchString The string used to search. If it is a regular expression, set `isRegex` to true. * @param searchStart Start the searching at the specified position. * @param isRegex Used to indicate that `searchString` is a regular expression. * @param matchCase Force the matching to match lower/upper case exactly. - * @param wholeWord Force the matching to match entire words only. + * @param wordSeparators Force the matching to match entire words only. Pass null otherwise. * @param captureMatches The result will contain the captured groups. * @return The range where the previous match is. It is null if no previous match has been found. */ - findPreviousMatch(searchString: string, searchStart: IPosition, isRegex: boolean, matchCase: boolean, wholeWord: boolean, captureMatches: boolean): FindMatch; + findPreviousMatch(searchString: string, searchStart: IPosition, isRegex: boolean, matchCase: boolean, wordSeparators: string, captureMatches: boolean): FindMatch; } export class FindMatch { @@ -2184,7 +1654,8 @@ declare module monaco.editor { } /** - * Describes the behaviour of decorations when typing/editing near their edges. + * Describes the behavior of decorations when typing/editing near their edges. + * Note: Please do not edit the values, as they very carefully match `DecorationRangeBehavior` */ export enum TrackedRangeStickiness { AlwaysGrowsWhenTypingAtEdges = 0, @@ -2301,12 +1772,12 @@ declare module monaco.editor { /** * A model. */ - export interface IModel extends IReadOnlyModel, IEditableTextModel, ITextModelWithMarkers, ITokenizedModel, ITextModelWithDecorations, IEditorModel { + export interface IModel extends IReadOnlyModel, IEditableTextModel, ITextModelWithMarkers, ITokenizedModel, ITextModelWithDecorations { /** * An event emitted when the contents of the model have changed. * @event */ - onDidChangeContent(listener: (e: IModelContentChangedEvent2) => void): IDisposable; + onDidChangeContent(listener: (e: IModelContentChangedEvent) => void): IDisposable; /** * An event emitted when decorations of the model have changed. * @event @@ -2339,183 +1810,17 @@ declare module monaco.editor { } /** - * An event describing that the current mode associated with a model has changed. + * A model for the diff editor. */ - export interface IModelLanguageChangedEvent { + export interface IDiffEditorModel { /** - * Previous language + * Original model. */ - readonly oldLanguage: string; + original: IModel; /** - * New language + * Modified model. */ - readonly newLanguage: string; - } - - /** - * An event describing a change in the text of a model. - */ - export interface IModelContentChangedEvent2 { - /** - * The range that got replaced. - */ - readonly range: IRange; - /** - * The length of the range that got replaced. - */ - readonly rangeLength: number; - /** - * The new text for the range. - */ - readonly text: string; - /** - * The (new) end-of-line character. - */ - readonly eol: string; - /** - * The new version id the model has transitioned to. - */ - versionId: number; - /** - * Flag that indicates that this event was generated while undoing. - */ - readonly isUndoing: boolean; - /** - * Flag that indicates that this event was generated while redoing. - */ - readonly isRedoing: boolean; - } - - /** - * An event describing that model decorations have changed. - */ - export interface IModelDecorationsChangedEvent { - /** - * Lists of ids for added decorations. - */ - readonly addedDecorations: string[]; - /** - * Lists of ids for changed decorations. - */ - readonly changedDecorations: string[]; - /** - * List of ids for removed decorations. - */ - readonly removedDecorations: string[]; - } - - /** - * An event describing that some ranges of lines have been tokenized (their tokens have changed). - */ - export interface IModelTokensChangedEvent { - readonly ranges: { - /** - * The start of the range (inclusive) - */ - readonly fromLineNumber: number; - /** - * The end of the range (inclusive) - */ - readonly toLineNumber: number; - }[]; - } - - /** - * Describes the reason the cursor has changed its position. - */ - export enum CursorChangeReason { - /** - * Unknown or not set. - */ - NotSet = 0, - /** - * A `model.setValue()` was called. - */ - ContentFlush = 1, - /** - * The `model` has been changed outside of this cursor and the cursor recovers its position from associated markers. - */ - RecoverFromMarkers = 2, - /** - * There was an explicit user gesture. - */ - Explicit = 3, - /** - * There was a Paste. - */ - Paste = 4, - /** - * There was an Undo. - */ - Undo = 5, - /** - * There was a Redo. - */ - Redo = 6, - } - - /** - * An event describing that the cursor position has changed. - */ - export interface ICursorPositionChangedEvent { - /** - * Primary cursor's position. - */ - readonly position: Position; - /** - * Primary cursor's view position - */ - readonly viewPosition: Position; - /** - * Secondary cursors' position. - */ - readonly secondaryPositions: Position[]; - /** - * Secondary cursors' view position. - */ - readonly secondaryViewPositions: Position[]; - /** - * Reason. - */ - readonly reason: CursorChangeReason; - /** - * Source of the call that caused the event. - */ - readonly source: string; - /** - * Is the primary cursor in the editable range? - */ - readonly isInEditableRange: boolean; - } - - /** - * An event describing that the cursor selection has changed. - */ - export interface ICursorSelectionChangedEvent { - /** - * The primary selection. - */ - readonly selection: Selection; - /** - * The primary selection in view coordinates. - */ - readonly viewSelection: Selection; - /** - * The secondary selections. - */ - readonly secondarySelections: Selection[]; - /** - * The secondary selections in view coordinates. - */ - readonly secondaryViewSelections: Selection[]; - /** - * Source of the call that caused the event. - */ - readonly source: string; - /** - * Reason. - */ - readonly reason: CursorChangeReason; + modified: IModel; } /** @@ -2532,240 +1837,11 @@ declare module monaco.editor { readonly newModelUrl: Uri; } - /** - * A description for the overview ruler position. - */ - export class OverviewRulerPosition { - readonly _overviewRulerPositionBrand: void; - /** - * Width of the overview ruler - */ - readonly width: number; - /** - * Height of the overview ruler - */ - readonly height: number; - /** - * Top position for the overview ruler - */ - readonly top: number; - /** - * Right position for the overview ruler - */ - readonly right: number; - } - - /** - * The internal layout details of the editor. - */ - export class EditorLayoutInfo { - readonly _editorLayoutInfoBrand: void; - /** - * Full editor width. - */ - readonly width: number; - /** - * Full editor height. - */ - readonly height: number; - /** - * Left position for the glyph margin. - */ - readonly glyphMarginLeft: number; - /** - * The width of the glyph margin. - */ - readonly glyphMarginWidth: number; - /** - * The height of the glyph margin. - */ - readonly glyphMarginHeight: number; - /** - * Left position for the line numbers. - */ - readonly lineNumbersLeft: number; - /** - * The width of the line numbers. - */ - readonly lineNumbersWidth: number; - /** - * The height of the line numbers. - */ - readonly lineNumbersHeight: number; - /** - * Left position for the line decorations. - */ - readonly decorationsLeft: number; - /** - * The width of the line decorations. - */ - readonly decorationsWidth: number; - /** - * The height of the line decorations. - */ - readonly decorationsHeight: number; - /** - * Left position for the content (actual text) - */ - readonly contentLeft: number; - /** - * The width of the content (actual text) - */ - readonly contentWidth: number; - /** - * The height of the content (actual height) - */ - readonly contentHeight: number; - /** - * The width of the vertical scrollbar. - */ - readonly verticalScrollbarWidth: number; - /** - * The height of the horizontal scrollbar. - */ - readonly horizontalScrollbarHeight: number; - /** - * The position of the overview ruler. - */ - readonly overviewRuler: OverviewRulerPosition; - } - - /** - * Options for creating the editor. - */ - export interface ICodeEditorWidgetCreationOptions extends IEditorOptions { - /** - * The initial model associated with this code editor. - */ - model?: IModel; - } - - /** - * An editor model. - */ - export interface IEditorModel { - } - - /** - * An editor view state. - */ - export interface IEditorViewState { - } - export interface IDimension { width: number; height: number; } - /** - * A (serializable) state of the cursors. - */ - export interface ICursorState { - inSelectionMode: boolean; - selectionStart: IPosition; - position: IPosition; - } - - /** - * A (serializable) state of the view. - */ - export interface IViewState { - scrollTop: number; - scrollTopWithoutViewZones: number; - scrollLeft: number; - } - - /** - * A (serializable) state of the code editor. - */ - export interface ICodeEditorViewState extends IEditorViewState { - cursorState: ICursorState[]; - viewState: IViewState; - contributionsState: { - [id: string]: any; - }; - } - - /** - * Type of hit element with the mouse in the editor. - */ - export enum MouseTargetType { - /** - * Mouse is on top of an unknown element. - */ - UNKNOWN = 0, - /** - * Mouse is on top of the textarea used for input. - */ - TEXTAREA = 1, - /** - * Mouse is on top of the glyph margin - */ - GUTTER_GLYPH_MARGIN = 2, - /** - * Mouse is on top of the line numbers - */ - GUTTER_LINE_NUMBERS = 3, - /** - * Mouse is on top of the line decorations - */ - GUTTER_LINE_DECORATIONS = 4, - /** - * Mouse is on top of the whitespace left in the gutter by a view zone. - */ - GUTTER_VIEW_ZONE = 5, - /** - * Mouse is on top of text in the content. - */ - CONTENT_TEXT = 6, - /** - * Mouse is on top of empty space in the content (e.g. after line text or below last line) - */ - CONTENT_EMPTY = 7, - /** - * Mouse is on top of a view zone in the content. - */ - CONTENT_VIEW_ZONE = 8, - /** - * Mouse is on top of a content widget. - */ - CONTENT_WIDGET = 9, - /** - * Mouse is on top of the decorations overview ruler. - */ - OVERVIEW_RULER = 10, - /** - * Mouse is on top of a scrollbar. - */ - SCROLLBAR = 11, - /** - * Mouse is on top of an overlay widget. - */ - OVERLAY_WIDGET = 12, - } - - /** - * A model for the diff editor. - */ - export interface IDiffEditorModel extends IEditorModel { - /** - * Original model. - */ - original: IModel; - /** - * Modified model. - */ - modified: IModel; - } - - /** - * (Serializable) View state for the diff editor. - */ - export interface IDiffEditorViewState extends IEditorViewState { - original: ICodeEditorViewState; - modified: ICodeEditorViewState; - } - /** * A change */ @@ -2858,40 +1934,54 @@ declare module monaco.editor { run(): Promise; } + export type IEditorModel = IModel | IDiffEditorModel; + + /** + * A (serializable) state of the cursors. + */ + export interface ICursorState { + inSelectionMode: boolean; + selectionStart: IPosition; + position: IPosition; + } + + /** + * A (serializable) state of the view. + */ + export interface IViewState { + scrollTop: number; + scrollTopWithoutViewZones: number; + scrollLeft: number; + } + + /** + * A (serializable) state of the code editor. + */ + export interface ICodeEditorViewState { + cursorState: ICursorState[]; + viewState: IViewState; + contributionsState: { + [id: string]: any; + }; + } + + /** + * (Serializable) View state for the diff editor. + */ + export interface IDiffEditorViewState { + original: ICodeEditorViewState; + modified: ICodeEditorViewState; + } + + /** + * An editor view state. + */ + export type IEditorViewState = ICodeEditorViewState | IDiffEditorViewState; + /** * An editor. */ export interface IEditor { - /** - * An event emitted when the content of the current model has changed. - * @event - */ - onDidChangeModelContent(listener: (e: IModelContentChangedEvent2) => void): IDisposable; - /** - * An event emitted when the language of the current model has changed. - * @event - */ - onDidChangeModelLanguage(listener: (e: IModelLanguageChangedEvent) => void): IDisposable; - /** - * An event emitted when the options of the current model has changed. - * @event - */ - onDidChangeModelOptions(listener: (e: IModelOptionsChangedEvent) => void): IDisposable; - /** - * An event emitted when the configuration of the editor has changed. (e.g. `editor.updateOptions()`) - * @event - */ - onDidChangeConfiguration(listener: (e: IConfigurationChangedEvent) => void): IDisposable; - /** - * An event emitted when the cursor position has changed. - * @event - */ - onDidChangeCursorPosition(listener: (e: ICursorPositionChangedEvent) => void): IDisposable; - /** - * An event emitted when the cursor selection has changed. - * @event - */ - onDidChangeCursorSelection(listener: (e: ICursorSelectionChangedEvent) => void): IDisposable; /** * An event emitted when the editor has been disposed. * @event @@ -2971,7 +2061,7 @@ declare module monaco.editor { /** * Scroll vertically or horizontally as necessary and reveal a position. */ - revealPosition(position: IPosition): void; + revealPosition(position: IPosition, revealVerticalInCenter?: boolean, revealHorizontal?: boolean): void; /** * Scroll vertically or horizontally as necessary and reveal a position centered vertically. */ @@ -3086,6 +2176,36 @@ declare module monaco.editor { } export interface ICommonCodeEditor extends IEditor { + /** + * An event emitted when the content of the current model has changed. + * @event + */ + onDidChangeModelContent(listener: (e: IModelContentChangedEvent) => void): IDisposable; + /** + * An event emitted when the language of the current model has changed. + * @event + */ + onDidChangeModelLanguage(listener: (e: IModelLanguageChangedEvent) => void): IDisposable; + /** + * An event emitted when the options of the current model has changed. + * @event + */ + onDidChangeModelOptions(listener: (e: IModelOptionsChangedEvent) => void): IDisposable; + /** + * An event emitted when the configuration of the editor has changed. (e.g. `editor.updateOptions()`) + * @event + */ + onDidChangeConfiguration(listener: (e: IConfigurationChangedEvent) => void): IDisposable; + /** + * An event emitted when the cursor position has changed. + * @event + */ + onDidChangeCursorPosition(listener: (e: ICursorPositionChangedEvent) => void): IDisposable; + /** + * An event emitted when the cursor selection has changed. + * @event + */ + onDidChangeCursorSelection(listener: (e: ICursorSelectionChangedEvent) => void): IDisposable; /** * An event emitted when the model of this editor has changed (e.g. `editor.setModel()`). * @event @@ -3116,6 +2236,14 @@ declare module monaco.editor { * @event */ onDidBlurEditor(listener: () => void): IDisposable; + /** + * Saves current view state of the editor in a serializable object. + */ + saveViewState(): ICodeEditorViewState; + /** + * Restores the view state of the editor from a serializable object generated by `saveViewState`. + */ + restoreViewState(state: ICodeEditorViewState): void; /** * Returns true if this editor or one of its widgets has keyboard focus. */ @@ -3183,6 +2311,7 @@ declare module monaco.editor { getAction(id: string): IEditorAction; /** * Execute a command on the editor. + * The edits will land on the undo-redo stack, but no "undo stop" will be pushed. * @param source The source of the call. * @param command The command to execute */ @@ -3193,6 +2322,7 @@ declare module monaco.editor { pushUndoStop(): boolean; /** * Execute edits on the editor. + * The edits will land on the undo-redo stack, but no "undo stop" will be pushed. * @param source The source of the call. * @param edits The edits to execute. * @param endCursoState Cursor state after the edits were applied. @@ -3225,6 +2355,14 @@ declare module monaco.editor { * @event */ onDidUpdateDiff(listener: () => void): IDisposable; + /** + * Saves current view state of the editor in a serializable object. + */ + saveViewState(): IDiffEditorViewState; + /** + * Restores the view state of the editor from a serializable object generated by `saveViewState`. + */ + restoreViewState(state: IDiffEditorViewState): void; /** * Type the getModel() of IEditor. */ @@ -3269,199 +2407,725 @@ declare module monaco.editor { }; /** - * Positions in the view for cursor move command. + * An event describing that the current mode associated with a model has changed. */ - export const CursorMovePosition: { - Left: string; - Right: string; - Up: string; - Down: string; - WrappedLineStart: string; - WrappedLineFirstNonWhitespaceCharacter: string; - WrappedLineColumnCenter: string; - WrappedLineEnd: string; - WrappedLineLastNonWhitespaceCharacter: string; - ViewPortTop: string; - ViewPortCenter: string; - ViewPortBottom: string; - ViewPortIfOutside: string; - }; + export interface IModelLanguageChangedEvent { + /** + * Previous language + */ + readonly oldLanguage: string; + /** + * New language + */ + readonly newLanguage: string; + } - /** - * Units for Cursor move 'by' argument - */ - export const CursorMoveByUnit: { - Line: string; - WrappedLine: string; - Character: string; - HalfLine: string; - }; - - /** - * Arguments for Cursor move command - */ - export interface CursorMoveArguments { - to: string; - select?: boolean; - by?: string; - value?: number; + export interface IModelContentChange { + /** + * The range that got replaced. + */ + readonly range: IRange; + /** + * The length of the range that got replaced. + */ + readonly rangeLength: number; + /** + * The new text for the range. + */ + readonly text: string; } /** - * Directions in the view for editor scroll command. + * An event describing a change in the text of a model. */ - export const EditorScrollDirection: { - Up: string; - Down: string; - }; - - /** - * Units for editor scroll 'by' argument - */ - export const EditorScrollByUnit: { - Line: string; - WrappedLine: string; - Page: string; - HalfPage: string; - }; - - /** - * Arguments for editor scroll command - */ - export interface EditorScrollArguments { - to: string; - by?: string; - value?: number; - revealCursor?: boolean; + export interface IModelContentChangedEvent { + readonly changes: IModelContentChange[]; + /** + * The (new) end-of-line character. + */ + readonly eol: string; + /** + * The new version id the model has transitioned to. + */ + readonly versionId: number; + /** + * Flag that indicates that this event was generated while undoing. + */ + readonly isUndoing: boolean; + /** + * Flag that indicates that this event was generated while redoing. + */ + readonly isRedoing: boolean; + /** + * Flag that indicates that all decorations were lost with this edit. + * The model has been reset to a new value. + */ + readonly isFlush: boolean; } /** - * Arguments for reveal line command + * An event describing that model decorations have changed. */ - export interface RevealLineArguments { - lineNumber?: number; - at?: string; + export interface IModelDecorationsChangedEvent { + /** + * Lists of ids for added decorations. + */ + readonly addedDecorations: string[]; + /** + * Lists of ids for changed decorations. + */ + readonly changedDecorations: string[]; + /** + * List of ids for removed decorations. + */ + readonly removedDecorations: string[]; } /** - * Values for reveal line 'at' argument + * An event describing that some ranges of lines have been tokenized (their tokens have changed). */ - export const RevealLineAtArgument: { - Top: string; - Center: string; - Bottom: string; - }; + export interface IModelTokensChangedEvent { + readonly ranges: { + /** + * The start of the range (inclusive) + */ + readonly fromLineNumber: number; + /** + * The end of the range (inclusive) + */ + readonly toLineNumber: number; + }[]; + } + + export interface IModelOptionsChangedEvent { + readonly tabSize: boolean; + readonly insertSpaces: boolean; + readonly trimAutoWhitespace: boolean; + } /** - * Built-in commands. + * Describes the reason the cursor has changed its position. */ - export var Handler: { - ExecuteCommand: string; - ExecuteCommands: string; - CursorLeft: string; - CursorLeftSelect: string; - CursorWordLeft: string; - CursorWordStartLeft: string; - CursorWordEndLeft: string; - CursorWordLeftSelect: string; - CursorWordStartLeftSelect: string; - CursorWordEndLeftSelect: string; - CursorRight: string; - CursorRightSelect: string; - CursorWordRight: string; - CursorWordStartRight: string; - CursorWordEndRight: string; - CursorWordRightSelect: string; - CursorWordStartRightSelect: string; - CursorWordEndRightSelect: string; - CursorUp: string; - CursorUpSelect: string; - CursorDown: string; - CursorDownSelect: string; - CursorPageUp: string; - CursorPageUpSelect: string; - CursorPageDown: string; - CursorPageDownSelect: string; - CursorHome: string; - CursorHomeSelect: string; - CursorEnd: string; - CursorEndSelect: string; - ExpandLineSelection: string; - CursorTop: string; - CursorTopSelect: string; - CursorBottom: string; - CursorBottomSelect: string; - CursorColumnSelectLeft: string; - CursorColumnSelectRight: string; - CursorColumnSelectUp: string; - CursorColumnSelectPageUp: string; - CursorColumnSelectDown: string; - CursorColumnSelectPageDown: string; - CursorMove: string; - AddCursorDown: string; - AddCursorUp: string; - CursorUndo: string; - MoveTo: string; - MoveToSelect: string; - ColumnSelect: string; - CreateCursor: string; - LastCursorMoveToSelect: string; - Type: string; - ReplacePreviousChar: string; - CompositionStart: string; - CompositionEnd: string; - Paste: string; - Tab: string; - Indent: string; - Outdent: string; - DeleteLeft: string; - DeleteRight: string; - DeleteWordLeft: string; - DeleteWordStartLeft: string; - DeleteWordEndLeft: string; - DeleteWordRight: string; - DeleteWordStartRight: string; - DeleteWordEndRight: string; - RemoveSecondaryCursors: string; - CancelSelection: string; - Cut: string; - Undo: string; - Redo: string; - WordSelect: string; - WordSelectDrag: string; - LastCursorWordSelect: string; - LineSelect: string; - LineSelectDrag: string; - LastCursorLineSelect: string; - LastCursorLineSelectDrag: string; - LineInsertBefore: string; - LineInsertAfter: string; - LineBreakInsert: string; - SelectAll: string; - EditorScroll: string; - ScrollLineUp: string; - ScrollLineDown: string; - ScrollPageUp: string; - ScrollPageDown: string; - RevealLine: string; - }; + export enum CursorChangeReason { + /** + * Unknown or not set. + */ + NotSet = 0, + /** + * A `model.setValue()` was called. + */ + ContentFlush = 1, + /** + * The `model` has been changed outside of this cursor and the cursor recovers its position from associated markers. + */ + RecoverFromMarkers = 2, + /** + * There was an explicit user gesture. + */ + Explicit = 3, + /** + * There was a Paste. + */ + Paste = 4, + /** + * There was an Undo. + */ + Undo = 5, + /** + * There was a Redo. + */ + Redo = 6, + } /** - * The style in which the editor's cursor should be rendered. + * An event describing that the cursor position has changed. */ - export enum TextEditorCursorStyle { + export interface ICursorPositionChangedEvent { /** - * As a vertical line (sitting between two characters). + * Primary cursor's position. */ - Line = 1, + readonly position: Position; /** - * As a block (sitting on top of a character). + * Secondary cursors' position. */ - Block = 2, + readonly secondaryPositions: Position[]; /** - * As a horizontal line (sitting under a character). + * Reason. */ - Underline = 3, + readonly reason: CursorChangeReason; + /** + * Source of the call that caused the event. + */ + readonly source: string; + } + + /** + * An event describing that the cursor selection has changed. + */ + export interface ICursorSelectionChangedEvent { + /** + * The primary selection. + */ + readonly selection: Selection; + /** + * The secondary selections. + */ + readonly secondarySelections: Selection[]; + /** + * Source of the call that caused the event. + */ + readonly source: string; + /** + * Reason. + */ + readonly reason: CursorChangeReason; + } + + /** + * 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; + } + + /** + * Configuration options for editor find widget + */ + export interface IEditorFindOptions { + /** + * Controls if we seed search string in the Find Widget with editor selection. + */ + seedSearchStringFromSelection?: boolean; + /** + * Controls if Find in Selection flag is turned on when multiple lines of text are selected in the editor. + */ + autoFindInSelection: boolean; + } + + /** + * Configuration options for editor minimap + */ + export interface IEditorMinimapOptions { + /** + * Enable the rendering of the minimap. + * Defaults to false. + */ + enabled?: boolean; + /** + * Control the rendering of the minimap slider. + * Defaults to 'mouseover'. + */ + showSlider?: 'always' | 'mouseover'; + /** + * Render the actual text on a line (as opposed to color blocks). + * Defaults to true. + */ + renderCharacters?: boolean; + /** + * Limit the width of the minimap to render at most a certain number of columns. + * Defaults to 120. + */ + maxColumn?: number; + } + + /** + * Configuration options for the editor. + */ + export interface IEditorOptions { + /** + * 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?: 'on' | 'off' | 'relative' | ((lineNumber: number) => string); + /** + * 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; + /** + * Class name to be added to the editor. + */ + extraEditorClassName?: string; + /** + * Should the editor be read only. + * Defaults to false. + */ + readOnly?: boolean; + /** + * Control the behavior and rendering of the scrollbars. + */ + scrollbar?: IEditorScrollbarOptions; + /** + * Control the behavior and rendering of the minimap. + */ + minimap?: IEditorMinimapOptions; + /** + * Control the behavior of the find widget. + */ + find?: IEditorFindOptions; + /** + * 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; + /** + * Controls if a border should be drawn around the overview ruler. + * Defaults to `true`. + */ + overviewRulerBorder?: boolean; + /** + * 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 `will-change` for the editor margin and lines layers. + * The usage of `will-change` acts as a hint for browsers to create an extra layer. + * Defaults to false. + */ + disableLayerHinting?: 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 of the editor. + * When `wordWrap` = "off", the lines will never wrap. + * When `wordWrap` = "on", the lines will wrap at the viewport width. + * When `wordWrap` = "wordWrapColumn", the lines will wrap at `wordWrapColumn`. + * When `wordWrap` = "bounded", the lines will wrap at min(viewport width, wordWrapColumn). + * Defaults to "off". + */ + wordWrap?: 'off' | 'on' | 'wordWrapColumn' | 'bounded'; + /** + * Control the wrapping of the editor. + * When `wordWrap` = "off", the lines will never wrap. + * When `wordWrap` = "on", the lines will wrap at the viewport width. + * When `wordWrap` = "wordWrapColumn", the lines will wrap at `wordWrapColumn`. + * When `wordWrap` = "bounded", the lines will wrap at min(viewport width, wordWrapColumn). + * Defaults to 80. + */ + wordWrapColumn?: number; + /** + * Force word wrapping when the text appears to be of a minified/generated file. + * Defaults to true. + */ + wordWrapMinified?: 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. + * Use -1 to never stop rendering + */ + stopRenderingLineAfter?: number; + /** + * Enable hover. + * Defaults to true. + */ + hover?: boolean; + /** + * Enable detecting links and making them clickable. + * Defaults to true. + */ + links?: 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; + /** + * The modifier to be used to add multiple cursors with the mouse. + * Defaults to 'alt' + */ + multiCursorModifier?: 'ctrlCmd' | 'alt'; + /** + * Configure the editor's accessibility support. + * Defaults to 'auto'. It is best to leave this to 'auto'. + */ + accessibilitySupport?: 'auto' | 'off' | 'on'; + /** + * Enable quick suggestions (shadow suggestions) + * Defaults to true. + */ + quickSuggestions?: boolean | { + other: boolean; + comments: boolean; + strings: 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 auto indentation adjustment. + * Defaults to false. + */ + autoIndent?: boolean; + /** + * Enable format on type. + * Defaults to false. + */ + formatOnType?: boolean; + /** + * Enable format on paste. + * Defaults to false. + */ + formatOnPaste?: boolean; + /** + * Controls if the editor should allow to move selections via drag and drop. + * Defaults to false. + */ + dragAndDrop?: boolean; + /** + * Enable the suggestion box to pop-up on trigger characters. + * Defaults to true. + */ + suggestOnTriggerCharacters?: boolean; + /** + * Accept suggestions on ENTER. + * Defaults to 'on'. + */ + acceptSuggestionOnEnter?: 'on' | 'smart' | 'off'; + /** + * 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 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; + /** + * Enable semantic occurrences highlight. + * Defaults to true. + */ + occurrencesHighlight?: 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; + /** + * Controls whether the fold actions in the gutter stay always visible or hide unless the mouse is over the gutter. + * Defaults to 'mouseover'. + */ + showFoldingControls?: 'always' | 'mouseover'; + /** + * Enable highlighting of matching brackets. + * Defaults to true. + */ + matchBrackets?: 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; + /** + * The letter spacing + */ + letterSpacing?: 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 enum RenderMinimap { + None = 0, + Small = 1, + Large = 2, + SmallBlocks = 3, + LargeBlocks = 4, + } + + /** + * 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, } /** @@ -3494,6 +3158,294 @@ declare module monaco.editor { Solid = 5, } + /** + * The style in which the editor's cursor should be rendered. + */ + export enum TextEditorCursorStyle { + /** + * As a vertical line (sitting between two characters). + */ + Line = 1, + /** + * As a block (sitting on top of a character). + */ + Block = 2, + /** + * As a horizontal line (sitting under a character). + */ + Underline = 3, + /** + * As a thin vertical line (sitting between two characters). + */ + LineThin = 4, + /** + * As an outlined block (sitting on top of a character). + */ + BlockOutline = 5, + /** + * As a thin horizontal line (sitting under a character). + */ + UnderlineThin = 6, + } + + export interface InternalEditorScrollbarOptions { + 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 interface InternalEditorMinimapOptions { + readonly enabled: boolean; + readonly showSlider: 'always' | 'mouseover'; + readonly renderCharacters: boolean; + readonly maxColumn: number; + } + + export interface InternalEditorFindOptions { + readonly seedSearchStringFromSelection: boolean; + readonly autoFindInSelection: boolean; + } + + export interface EditorWrappingInfo { + readonly inDiffEditor: boolean; + readonly isDominatedByLongLines: boolean; + readonly isWordWrapMinified: boolean; + readonly isViewportWrapping: boolean; + readonly wrappingColumn: number; + readonly wrappingIndent: WrappingIndent; + readonly wordWrapBreakBeforeCharacters: string; + readonly wordWrapBreakAfterCharacters: string; + readonly wordWrapBreakObtrusiveCharacters: string; + } + + export interface InternalEditorViewOptions { + readonly extraEditorClassName: string; + readonly disableMonospaceOptimizations: boolean; + readonly rulers: number[]; + readonly ariaLabel: string; + readonly renderLineNumbers: boolean; + readonly renderCustomLineNumbers: (lineNumber: number) => string; + readonly renderRelativeLineNumbers: boolean; + readonly selectOnLineNumbers: boolean; + readonly glyphMargin: boolean; + readonly revealHorizontalRightPadding: number; + readonly roundedSelection: boolean; + readonly overviewRulerLanes: number; + readonly overviewRulerBorder: boolean; + readonly cursorBlinking: TextEditorCursorBlinkingStyle; + readonly mouseWheelZoom: boolean; + readonly cursorStyle: TextEditorCursorStyle; + readonly hideCursorInOverviewRuler: boolean; + readonly scrollBeyondLastLine: boolean; + readonly stopRenderingLineAfter: number; + readonly renderWhitespace: 'none' | 'boundary' | 'all'; + readonly renderControlCharacters: boolean; + readonly fontLigatures: boolean; + readonly renderIndentGuides: boolean; + readonly renderLineHighlight: 'none' | 'gutter' | 'line' | 'all'; + readonly scrollbar: InternalEditorScrollbarOptions; + readonly minimap: InternalEditorMinimapOptions; + readonly fixedOverflowWidgets: boolean; + } + + export interface EditorContribOptions { + readonly selectionClipboard: boolean; + readonly hover: boolean; + readonly links: boolean; + readonly contextmenu: boolean; + readonly quickSuggestions: boolean | { + other: boolean; + comments: boolean; + strings: boolean; + }; + readonly quickSuggestionsDelay: number; + readonly parameterHints: boolean; + readonly iconsInSuggestions: boolean; + readonly formatOnType: boolean; + readonly formatOnPaste: boolean; + readonly suggestOnTriggerCharacters: boolean; + readonly acceptSuggestionOnEnter: 'on' | 'smart' | 'off'; + readonly acceptSuggestionOnCommitCharacter: boolean; + readonly snippetSuggestions: 'top' | 'bottom' | 'inline' | 'none'; + readonly wordBasedSuggestions: boolean; + readonly suggestFontSize: number; + readonly suggestLineHeight: number; + readonly selectionHighlight: boolean; + readonly occurrencesHighlight: boolean; + readonly codeLens: boolean; + readonly folding: boolean; + readonly showFoldingControls: 'always' | 'mouseover'; + readonly matchBrackets: boolean; + readonly find: InternalEditorFindOptions; + } + + /** + * Internal configuration options (transformed or computed) for the editor. + */ + export class InternalEditorOptions { + readonly _internalEditorOptionsBrand: void; + readonly canUseLayerHinting: boolean; + readonly pixelRatio: number; + readonly editorClassName: string; + readonly lineHeight: number; + readonly readOnly: boolean; + readonly multiCursorModifier: 'altKey' | 'ctrlKey' | 'metaKey'; + readonly wordSeparators: string; + readonly autoClosingBrackets: boolean; + readonly autoIndent: boolean; + readonly useTabStops: boolean; + readonly tabFocusMode: boolean; + readonly dragAndDrop: boolean; + readonly emptySelectionClipboard: boolean; + readonly layoutInfo: EditorLayoutInfo; + readonly fontInfo: FontInfo; + readonly viewInfo: InternalEditorViewOptions; + readonly wrappingInfo: EditorWrappingInfo; + readonly contribInfo: EditorContribOptions; + } + + /** + * A description for the overview ruler position. + */ + export interface OverviewRulerPosition { + /** + * Width of the overview ruler + */ + readonly width: number; + /** + * Height of the overview ruler + */ + readonly height: number; + /** + * Top position for the overview ruler + */ + readonly top: number; + /** + * Right position for the overview ruler + */ + readonly right: number; + } + + /** + * The internal layout details of the editor. + */ + export interface EditorLayoutInfo { + /** + * Full editor width. + */ + readonly width: number; + /** + * Full editor height. + */ + readonly height: number; + /** + * Left position for the glyph margin. + */ + readonly glyphMarginLeft: number; + /** + * The width of the glyph margin. + */ + readonly glyphMarginWidth: number; + /** + * The height of the glyph margin. + */ + readonly glyphMarginHeight: number; + /** + * Left position for the line numbers. + */ + readonly lineNumbersLeft: number; + /** + * The width of the line numbers. + */ + readonly lineNumbersWidth: number; + /** + * The height of the line numbers. + */ + readonly lineNumbersHeight: number; + /** + * Left position for the line decorations. + */ + readonly decorationsLeft: number; + /** + * The width of the line decorations. + */ + readonly decorationsWidth: number; + /** + * The height of the line decorations. + */ + readonly decorationsHeight: number; + /** + * Left position for the content (actual text) + */ + readonly contentLeft: number; + /** + * The width of the content (actual text) + */ + readonly contentWidth: number; + /** + * The height of the content (actual height) + */ + readonly contentHeight: number; + /** + * The width of the minimap + */ + readonly minimapWidth: number; + /** + * Minimap render type + */ + readonly renderMinimap: RenderMinimap; + /** + * The number of columns (of typical characters) fitting on a viewport line. + */ + readonly viewportColumn: number; + /** + * The width of the vertical scrollbar. + */ + readonly verticalScrollbarWidth: number; + /** + * The height of the horizontal scrollbar. + */ + readonly horizontalScrollbarHeight: number; + /** + * The position of the overview ruler. + */ + readonly overviewRuler: OverviewRulerPosition; + } + + /** + * An event describing that the configuration of the editor has changed. + */ + export interface IConfigurationChangedEvent { + readonly canUseLayerHinting: boolean; + readonly pixelRatio: boolean; + readonly editorClassName: boolean; + readonly lineHeight: boolean; + readonly readOnly: boolean; + readonly accessibilitySupport: boolean; + readonly multiCursorModifier: boolean; + readonly wordSeparators: boolean; + readonly autoClosingBrackets: boolean; + readonly autoIndent: boolean; + readonly useTabStops: boolean; + readonly tabFocusMode: boolean; + readonly dragAndDrop: boolean; + readonly emptySelectionClipboard: boolean; + readonly layoutInfo: boolean; + readonly fontInfo: boolean; + readonly viewInfo: boolean; + readonly wrappingInfo: boolean; + readonly contribInfo: boolean; + } + /** * A view zone is a full horizontal rectangle that 'pushes' text down. * The editor reserves space for view zones when rendering. @@ -3671,6 +3623,68 @@ declare module monaco.editor { getPosition(): IOverlayWidgetPosition; } + /** + * Type of hit element with the mouse in the editor. + */ + export enum MouseTargetType { + /** + * Mouse is on top of an unknown element. + */ + UNKNOWN = 0, + /** + * Mouse is on top of the textarea used for input. + */ + TEXTAREA = 1, + /** + * Mouse is on top of the glyph margin + */ + GUTTER_GLYPH_MARGIN = 2, + /** + * Mouse is on top of the line numbers + */ + GUTTER_LINE_NUMBERS = 3, + /** + * Mouse is on top of the line decorations + */ + GUTTER_LINE_DECORATIONS = 4, + /** + * Mouse is on top of the whitespace left in the gutter by a view zone. + */ + GUTTER_VIEW_ZONE = 5, + /** + * Mouse is on top of text in the content. + */ + CONTENT_TEXT = 6, + /** + * Mouse is on top of empty space in the content (e.g. after line text or below last line) + */ + CONTENT_EMPTY = 7, + /** + * Mouse is on top of a view zone in the content. + */ + CONTENT_VIEW_ZONE = 8, + /** + * Mouse is on top of a content widget. + */ + CONTENT_WIDGET = 9, + /** + * Mouse is on top of the decorations overview ruler. + */ + OVERVIEW_RULER = 10, + /** + * Mouse is on top of a scrollbar. + */ + SCROLLBAR = 11, + /** + * Mouse is on top of an overlay widget. + */ + OVERLAY_WIDGET = 12, + /** + * Mouse is outside of the editor. + */ + OUTSIDE_EDITOR = 13, + } + /** * Target hit with the mouse in the editor. */ @@ -3851,6 +3865,7 @@ declare module monaco.editor { export class FontInfo extends BareFontInfo { readonly _editorStylingBrand: void; + readonly isTrusted: boolean; readonly isMonospace: boolean; readonly typicalHalfwidthCharacterWidth: number; readonly typicalFullwidthCharacterWidth: number; @@ -3859,10 +3874,12 @@ declare module monaco.editor { } export class BareFontInfo { readonly _bareFontInfoBrand: void; + readonly zoomLevel: number; readonly fontFamily: string; readonly fontWeight: string; readonly fontSize: number; readonly lineHeight: number; + readonly letterSpacing: number; } } @@ -3963,7 +3980,7 @@ declare module monaco.languages { export function registerDocumentSymbolProvider(languageId: string, provider: DocumentSymbolProvider): IDisposable; /** - * Register a document highlight provider (used by e.g. highlight occurences). + * Register a document highlight provider (used by e.g. highlight occurrences). */ export function registerDocumentHighlightProvider(languageId: string, provider: DocumentHighlightProvider): IDisposable; @@ -3973,10 +3990,15 @@ declare module monaco.languages { export function registerDefinitionProvider(languageId: string, provider: DefinitionProvider): IDisposable; /** - * Register a type implementation provider (used by e.g. go to implementation). + * Register a implementation provider (used by e.g. go to implementation). */ export function registerImplementationProvider(languageId: string, provider: ImplementationProvider): IDisposable; + /** + * Register a type definition provider (used by e.g. go to type definition). + */ + export function registerTypeDefinitionProvider(languageId: string, provider: TypeDefinitionProvider): IDisposable; + /** * Register a code lens provider (used by e.g. inline code lenses). */ @@ -4069,7 +4091,7 @@ declare module monaco.languages { * and `${3:foo}`. `$0` defines the final tab stop, it defaults to * the end of the snippet. Variables are defined with `$name` and * `${name:default value}`. The full snippet syntax is documented - * [here](http://code.visualstudio.com/docs/customization/userdefinedsnippets#_creating-your-own-snippets). + * [here](http://code.visualstudio.com/docs/editor/userdefinedsnippets#_creating-your-own-snippets). */ export interface SnippetString { /** @@ -4162,7 +4184,7 @@ declare module monaco.languages { /** * The completion item provider interface defines the contract between extensions and - * the [IntelliSense](https://code.visualstudio.com/docs/editor/editingevolved#_intellisense). + * the [IntelliSense](https://code.visualstudio.com/docs/editor/intellisense). * * When computing *complete* completion items is expensive, providers can optionally implement * the `resolveCompletionItem`-function. In that case it is enough to return completion @@ -4397,7 +4419,7 @@ declare module monaco.languages { /** * The hover provider interface defines the contract between extensions and - * the [hover](https://code.visualstudio.com/docs/editor/editingevolved#_hover)-feature. + * the [hover](https://code.visualstudio.com/docs/editor/intellisense)-feature. */ export interface HoverProvider { /** @@ -4477,7 +4499,7 @@ declare module monaco.languages { /** * The signature help provider interface defines the contract between extensions and - * the [parameter hints](https://code.visualstudio.com/docs/editor/editingevolved#_parameter-hints)-feature. + * the [parameter hints](https://code.visualstudio.com/docs/editor/intellisense)-feature. */ export interface SignatureHelpProvider { signatureHelpTriggerCharacters: string[]; @@ -4590,7 +4612,7 @@ declare module monaco.languages { } /** - * The type definition provider interface defines the contract between extensions and + * The implementation provider interface defines the contract between extensions and * the go to implementation feature. */ export interface ImplementationProvider { @@ -4600,6 +4622,17 @@ declare module monaco.languages { provideImplementation(model: editor.IReadOnlyModel, position: Position, token: CancellationToken): Definition | Thenable; } + /** + * The type definition provider interface defines the contract between extensions and + * the go to type definition feature. + */ + export interface TypeDefinitionProvider { + /** + * Provide the type definition of the symbol at the given position and document. + */ + provideTypeDefinition(model: editor.IReadOnlyModel, position: Position, token: CancellationToken): Definition | Thenable; + } + /** * A symbol kind. */ @@ -4625,6 +4658,11 @@ declare module monaco.languages { Object = 18, Key = 19, Null = 20, + EnumMember = 21, + Struct = 22, + Event = 23, + Operator = 24, + TypeParameter = 25, } /** @@ -4661,6 +4699,12 @@ declare module monaco.languages { provideDocumentSymbols(model: editor.IReadOnlyModel, token: CancellationToken): SymbolInformation[] | Thenable; } + export interface TextEdit { + range: IRange; + text: string; + eol?: editor.EndOfLineSequence; + } + /** * Interface used to format a model */ @@ -4683,7 +4727,7 @@ declare module monaco.languages { /** * Provide formatting edits for a whole document. */ - provideDocumentFormattingEdits(model: editor.IReadOnlyModel, options: FormattingOptions, token: CancellationToken): editor.ISingleEditOperation[] | Thenable; + provideDocumentFormattingEdits(model: editor.IReadOnlyModel, options: FormattingOptions, token: CancellationToken): TextEdit[] | Thenable; } /** @@ -4698,7 +4742,7 @@ declare module monaco.languages { * or larger range. Often this is done by adjusting the start and end * of the range to full syntax nodes. */ - provideDocumentRangeFormattingEdits(model: editor.IReadOnlyModel, range: Range, options: FormattingOptions, token: CancellationToken): editor.ISingleEditOperation[] | Thenable; + provideDocumentRangeFormattingEdits(model: editor.IReadOnlyModel, range: Range, options: FormattingOptions, token: CancellationToken): TextEdit[] | Thenable; } /** @@ -4714,7 +4758,7 @@ declare module monaco.languages { * what range the position to expand to, like find the matching `{` * when `}` has been entered. */ - provideOnTypeFormattingEdits(model: editor.IReadOnlyModel, position: Position, ch: string, options: FormattingOptions, token: CancellationToken): editor.ISingleEditOperation[] | Thenable; + provideOnTypeFormattingEdits(model: editor.IReadOnlyModel, position: Position, ch: string, options: FormattingOptions, token: CancellationToken): TextEdit[] | Thenable; } /** @@ -4751,6 +4795,7 @@ declare module monaco.languages { export interface Command { id: string; title: string; + tooltip?: string; arguments?: any[]; } @@ -4910,6 +4955,7 @@ declare module monaco.worker { } + declare module monaco.languages.typescript { enum ModuleKind { @@ -5047,6 +5093,12 @@ declare module monaco.languages.typescript { * mean never shut down. */ setMaximunWorkerIdleTime(value: number): void; + + /** + * Configure if all existing models should be eagerly sync'd + * to the worker on start or restart. + */ + setEagerModelSync(value: boolean): void; } export var typescriptDefaults: LanguageServiceDefaults; diff --git a/package.json b/package.json index 852f2ef5..d3b90c6e 100644 --- a/package.json +++ b/package.json @@ -21,12 +21,12 @@ "gulp": "^3.9.1", "gulp-typedoc": "^2.0.0", "http-server": "^0.9.0", - "monaco-css": "1.3.1", - "monaco-editor-core": "0.8.2", - "monaco-html": "1.2.1", - "monaco-json": "1.2.2", - "monaco-languages": "0.7.0", - "monaco-typescript": "2.1.2", + "monaco-css": "1.3.2", + "monaco-editor-core": "0.9.0", + "monaco-html": "1.3.0", + "monaco-json": "1.3.0", + "monaco-languages": "0.8.0", + "monaco-typescript": "2.2.0", "rimraf": "^2.5.2", "typedoc": "^0.5.0", "uncss": "^0.14.1" diff --git a/test/playground.generated/customizing-the-appearence-exposed-css-classes.html b/test/playground.generated/customizing-the-appearence-exposed-colors.html similarity index 100% rename from test/playground.generated/customizing-the-appearence-exposed-css-classes.html rename to test/playground.generated/customizing-the-appearence-exposed-colors.html diff --git a/test/playground.generated/index.html b/test/playground.generated/index.html index 98de4c68..06e5c798 100644 --- a/test/playground.generated/index.html +++ b/test/playground.generated/index.html @@ -19,7 +19,7 @@ THIS IS A GENERATED FILE VIA gulp generate-test-samples

Interacting with the editor > Customizing the line numbers
Interacting with the editor > Listening to mouse events
Interacting with the editor > Listening to key events
-Customizing the appearence > Exposed CSS classes
+Customizing the appearence > Exposed CSS classes
Customizing the appearence > Scrollbars
Customizing the appearence > Tokens and colors
Creating the DiffEditor > Hello diff world!
diff --git a/test/samples-all.generated.js b/test/samples-all.generated.js index 36f3e69d..12b9f80c 100644 --- a/test/samples-all.generated.js +++ b/test/samples-all.generated.js @@ -100,10 +100,6 @@ define([], function() { return[ "name": "sample.ini.txt", "content": "# Example of a .gitconfig file\r\n\r\n[core]\r\n\trepositoryformatversion = 0\r\n\tfilemode = false\r\n\tbare = false\r\n\tlogallrefupdates = true\r\n\tsymlinks = false\r\n\tignorecase = true\r\n\thideDotFiles = dotGitOnly\r\n\r\n# Defines the master branch\r\n[branch \"master\"]\r\n\tremote = origin\r\n\tmerge = refs/heads/master\r\n" }, - { - "name": "sample.pug.txt", - "content": "doctype 5\nhtml(lang=\"en\")\n head\n title= pageTitle\n script(type='text/javascript')\n if (foo) {\n bar()\n }\n body\n // Disclaimer: You will need to turn insertSpaces to true in order for the\n syntax highlighting to kick in properly (especially for comments)\n Enjoy :)\n h1 Pug - node template engine\n #container\n if youAreUsingPug\n p You are amazing\n else\n p Get on it!" - }, { "name": "sample.java.txt", "content": "import java.util.ArrayList;\nimport org.junit.Test;\n\npublic class Example {\n @Test \n public void method() {\n org.junit.Assert.assertTrue( \"isEmpty\", new ArrayList().isEmpty());\n }\n\t\n @Test(timeout=100) public void infinity() {\n while(true);\n }\n }\n " @@ -144,6 +140,10 @@ define([], function() { return[ "name": "sample.powershell.txt", "content": "$SelectedObjectNames=@();\n$XenCenterNodeSelected = 0;\n#the object info array contains hashmaps, each of which represent a parameter set and describe a target in the XenCenter resource list\nforeach($parameterSet in $ObjInfoArray)\n{\n\tif ($parameterSet[\"class\"] -eq \"blank\")\n\t{\n\t\t#When the XenCenter node is selected a parameter set is created for each of your connected servers with the class and objUuid keys marked as blank\n\t\tif ($XenCenterNodeSelected)\n\t\t{\n\t\t\tcontinue\n\t\t}\n\t\t$XenCenterNodeSelected = 1;\n\t\t$SelectedObjectNames += \"XenCenter\"\n\t}\n\telseif ($parameterSet[\"sessionRef\"] -eq \"null\")\n\t{\n\t\t#When a disconnected server is selected there is no session information, we get null for everything except class\n\t}\n\t\t$SelectedObjectNames += \"a disconnected server\"\n\telse\n\t{\n\t\tConnect-XenServer -url $parameterSet[\"url\"] -opaqueref $parameterSet[\"sessionRef\"]\n\t\t#Use $class to determine which server objects to get\n\t\t#-properties allows us to filter the results to just include the selected object\n\t\t$exp = \"Get-XenServer:{0} -properties @{{uuid='{1}'}}\" -f $parameterSet[\"class\"], $parameterSet[\"objUuid\"]\n\t\t$obj = Invoke-Expression $exp\n\t\t$SelectedObjectNames += $obj.name_label;\n\t} \n}" }, + { + "name": "sample.pug.txt", + "content": "doctype 5\nhtml(lang=\"en\")\n head\n title= pageTitle\n script(type='text/javascript')\n if (foo) {\n bar()\n }\n body\n // Disclaimer: You will need to turn insertSpaces to true in order for the\n syntax highlighting to kick in properly (especially for comments)\n Enjoy :)\n h1 Pug - node template engine\n #container\n if youAreUsingPug\n p You are amazing\n else\n p Get on it!" + }, { "name": "sample.python.txt", "content": "from banana import *\r\n\r\nclass Monkey:\r\n\t# Bananas the monkey can eat.\r\n\tcapacity = 10\r\n\tdef eat(self, N):\r\n\t\t'''Make the monkey eat N bananas!'''\r\n\t\tcapacity = capacity - N*banana.size\r\n\r\n\tdef feeding_frenzy(self):\r\n\t\teat(9.25)\r\n\t\treturn \"Yum yum\"" diff --git a/website/index/index.js b/website/index/index.js index 20240c9a..65180fdc 100644 --- a/website/index/index.js +++ b/website/index/index.js @@ -164,10 +164,5 @@ function loadDiffSample() { function changeTheme(theme) { var newTheme = (theme === 1 ? 'vs-dark' : ( theme === 0 ? 'vs' : 'hc-black' )); - if (editor) { - editor.updateOptions({ 'theme' : newTheme }); - } - if (diffEditor) { - diffEditor.updateOptions({ 'theme': newTheme }); - } + monaco.editor.setTheme(newTheme); } diff --git a/website/monarch/monarch.js b/website/monarch/monarch.js index fee40400..5bec9087 100644 --- a/website/monarch/monarch.js +++ b/website/monarch/monarch.js @@ -136,7 +136,7 @@ require(["vs/editor/editor.main"], function () { var currentTheme = "vs"; select.onchange = function () { currentTheme = select.options[select.selectedIndex].value; - sampleEditor.updateOptions({ theme: currentTheme }); + monaco.editor.setTheme(currentTheme); }; // on resize diff --git a/website/playground/monaco.d.ts.txt b/website/playground/monaco.d.ts.txt index 566d65e0..8b556227 100644 --- a/website/playground/monaco.d.ts.txt +++ b/website/playground/monaco.d.ts.txt @@ -3,6 +3,11 @@ * Type definitions for monaco-editor v0.8.3 * 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 module monaco { interface Thenable { @@ -79,7 +84,12 @@ declare module monaco { public done(success?: (value: V) => void, error?: (err: any) => any, progress?: ProgressCallback): void; public cancel(): void; + public static as(value: null): Promise; + public static as(value: undefined): Promise; + public static as(value: Promise): Promise; + public static as(value: Thenable): Thenable; public static as(value: ValueType): Promise; + public static is(value: any): value is Thenable; public static timeout(delay: number): Promise; public static join(promises: Promise[]): Promise; @@ -90,7 +100,7 @@ declare module monaco { public static wrap(value: Thenable): Promise; public static wrap(value: ValueType): Promise; - public static wrapError(error: any): Promise; + public static wrapError(error: Error): Promise; } export class CancellationTokenSource { @@ -348,11 +358,17 @@ declare module monaco { 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 = 109, + MAX_VALUE = 112, } export class KeyMod { @@ -362,18 +378,6 @@ declare module monaco { 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 @@ -392,7 +396,7 @@ declare module monaco { readonly altKey: boolean; readonly metaKey: boolean; readonly keyCode: KeyCode; - toKeybinding(): Keybinding; + readonly code: string; equals(keybinding: number): boolean; preventDefault(): void; stopPropagation(): void; @@ -425,7 +429,6 @@ declare module monaco { readonly scrollWidthChanged: boolean; readonly scrollHeightChanged: boolean; } - /** * A position in the editor. This interface is suitable for serialization. */ @@ -440,51 +443,6 @@ declare module monaco { 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. */ @@ -548,6 +506,28 @@ declare module monaco { 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) */ @@ -651,6 +631,7 @@ declare module monaco { * 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`. */ @@ -679,6 +660,29 @@ declare module monaco { 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. @@ -725,10 +729,18 @@ declare module monaco { * 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`. */ @@ -887,17 +899,27 @@ declare module monaco.editor { /** * Define a new theme. */ - export function defineTheme(themeName: string, themeData: ITheme): void; + export function defineTheme(themeName: string, themeData: IStandaloneThemeData): void; + + /** + * Switches to a theme. + */ + export function setTheme(themeName: string): void; export type BuiltinTheme = 'vs' | 'vs-dark' | 'hc-black'; - export interface ITheme { + export interface IStandaloneThemeData { base: BuiltinTheme; inherit: boolean; - rules: IThemeRule[]; + rules: ITokenThemeRule[]; + colors: IColors; } - export interface IThemeRule { + export type IColors = { + [colorId: string]: string; + }; + + export interface ITokenThemeRule { token: string; foreground?: string; background?: string; @@ -942,7 +964,11 @@ declare module monaco.editor { /** * The options to create an editor. */ - export interface IEditorConstructionOptions extends ICodeEditorWidgetCreationOptions { + export interface IEditorConstructionOptions extends IEditorOptions { + /** + * The initial model associated with this code editor. + */ + model?: IModel; /** * The initial value of the auto created model in the editor. * To not create automatically a model, use `model: null`. @@ -953,12 +979,33 @@ declare module monaco.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` + */ + theme?: string; + /** + * 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` + */ + theme?: string; } export interface IStandaloneCodeEditor extends ICodeEditor { @@ -985,6 +1032,7 @@ declare module monaco.editor { } export interface IEditorOverrideServices { + [index: string]: any; } /** @@ -1016,591 +1064,8 @@ declare module monaco.editor { 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; - readonly glyphMargin: boolean; - readonly revealHorizontalRightPadding: number; - readonly roundedSelection: boolean; - readonly overviewRulerLanes: number; - readonly cursorBlinking: TextEditorCursorBlinkingStyle; - readonly mouseWheelZoom: boolean; - readonly cursorStyle: TextEditorCursorStyle; - readonly hideCursorInOverviewRuler: boolean; - readonly scrollBeyondLastLine: boolean; - readonly editorClassName: string; - readonly stopRenderingLineAfter: number; - readonly renderWhitespace: 'none' | 'boundary' | 'all'; - readonly renderControlCharacters: boolean; - readonly renderIndentGuides: boolean; - readonly renderLineHighlight: 'none' | 'gutter' | 'line' | 'all'; - readonly scrollbar: InternalEditorScrollbarOptions; - readonly fixedOverflowWidgets: boolean; - } - - export interface IViewConfigurationChangedEvent { - readonly theme: boolean; - readonly canUseTranslate3d: boolean; - readonly disableMonospaceOptimizations: boolean; - readonly experimentalScreenReader: boolean; - readonly rulers: boolean; - readonly ariaLabel: boolean; - readonly renderLineNumbers: boolean; - readonly renderCustomLineNumbers: boolean; - readonly renderRelativeLineNumbers: boolean; - readonly selectOnLineNumbers: boolean; - readonly glyphMargin: boolean; - readonly revealHorizontalRightPadding: boolean; - readonly roundedSelection: boolean; - readonly overviewRulerLanes: boolean; - readonly cursorBlinking: boolean; - readonly mouseWheelZoom: boolean; - readonly cursorStyle: boolean; - readonly hideCursorInOverviewRuler: boolean; - readonly scrollBeyondLastLine: boolean; - readonly editorClassName: boolean; - readonly stopRenderingLineAfter: boolean; - readonly renderWhitespace: boolean; - readonly renderControlCharacters: boolean; - readonly renderIndentGuides: boolean; - readonly renderLineHighlight: boolean; - readonly scrollbar: boolean; - readonly fixedOverflowWidgets: boolean; - } - - export class EditorContribOptions { - readonly selectionClipboard: boolean; - readonly hover: boolean; - readonly contextmenu: boolean; - readonly quickSuggestions: boolean; - readonly quickSuggestionsDelay: number; - readonly parameterHints: boolean; - readonly iconsInSuggestions: boolean; - readonly formatOnType: boolean; - readonly formatOnPaste: boolean; - readonly suggestOnTriggerCharacters: boolean; - readonly acceptSuggestionOnEnter: boolean; - readonly acceptSuggestionOnCommitCharacter: boolean; - readonly snippetSuggestions: 'top' | 'bottom' | 'inline' | 'none'; - readonly emptySelectionClipboard: boolean; - readonly tabCompletion: boolean; - readonly wordBasedSuggestions: boolean; - readonly suggestFontSize: number; - readonly suggestLineHeight: number; - readonly selectionHighlight: boolean; - readonly codeLens: boolean; - readonly folding: boolean; - } - - /** - * Internal configuration options (transformed or computed) for the editor. - */ - export class InternalEditorOptions { - readonly _internalEditorOptionsBrand: void; - readonly lineHeight: number; - readonly readOnly: boolean; - readonly wordSeparators: string; - readonly autoClosingBrackets: boolean; - readonly useTabStops: boolean; - readonly tabFocusMode: boolean; - readonly layoutInfo: EditorLayoutInfo; - readonly fontInfo: FontInfo; - readonly viewInfo: InternalEditorViewOptions; - readonly wrappingInfo: EditorWrappingInfo; - readonly contribInfo: EditorContribOptions; - } - - /** - * An event describing that the configuration of the editor has changed. - */ - export interface IConfigurationChangedEvent { - readonly lineHeight: boolean; - readonly readOnly: boolean; - readonly wordSeparators: boolean; - readonly autoClosingBrackets: boolean; - readonly useTabStops: boolean; - readonly tabFocusMode: boolean; - readonly layoutInfo: boolean; - readonly fontInfo: boolean; - readonly viewInfo: IViewConfigurationChangedEvent; - readonly wrappingInfo: boolean; - readonly contribInfo: boolean; + export interface ThemeColor { + id: string; } /** @@ -1619,14 +1084,19 @@ declare module monaco.editor { export interface IModelDecorationOverviewRulerOptions { /** * CSS color to render in the overview ruler. - * e.g.: rgba(100, 100, 100, 0.5) + * e.g.: rgba(100, 100, 100, 0.5) or a color from the color registry */ - color: string; + color: string | ThemeColor; /** * CSS color to render in the overview ruler. - * e.g.: rgba(100, 100, 100, 0.5) + * e.g.: rgba(100, 100, 100, 0.5) or a color from the color registry */ - darkColor: string; + darkColor: string | ThemeColor; + /** + * CSS color to render in the overview ruler. + * e.g.: rgba(100, 100, 100, 0.5) or a color from the color registry + */ + hcColor?: string | ThemeColor; /** * The position in the overview ruler. */ @@ -1638,7 +1108,7 @@ declare module monaco.editor { */ export interface IModelDecorationOptions { /** - * Customize the growing behaviour of the decoration when typing at the edges of the decoration. + * Customize the growing behavior of the decoration when typing at the edges of the decoration. * Defaults to TrackedRangeStickiness.AlwaysGrowsWhenTypingAtEdges */ stickiness?: TrackedRangeStickiness; @@ -1658,10 +1128,6 @@ declare module monaco.editor { * Should the decoration expand to encompass a whole line. */ isWholeLine?: boolean; - /** - * @deprecated : Use `overviewRuler` instead - */ - showInOverviewRuler?: string; /** * If set, render this decoration in the overview ruler. */ @@ -1822,6 +1288,13 @@ declare module monaco.editor { * @param text The text to replace with. May be null to represent a simple delete. */ addEditOperation(range: Range, text: string): void; + /** + * Add a new edit operation (a replace operation). + * The inverse edits will be accessible in `ICursorStateComputerData.getInverseEditOperations()` + * @param range The range to replace (delete). May be empty to represent a simple insert. + * @param text The text to replace with. May be null to represent a simple delete. + */ + addTrackedEditOperation(range: Range, text: string): void; /** * Track `selection` when applying edit operations. * A best effort will be made to not grow/expand the selection. @@ -1941,16 +1414,13 @@ declare module monaco.editor { trimAutoWhitespace?: boolean; } - export interface IModelOptionsChangedEvent { - readonly tabSize: boolean; - readonly insertSpaces: boolean; - readonly trimAutoWhitespace: boolean; - } - /** * A textual read-only model. */ export interface ITextModel { + /** + * Get the resolved options for this model. + */ getOptions(): TextModelResolvedOptions; /** * Get the current version id of the model. @@ -2080,46 +1550,46 @@ declare module monaco.editor { * @param searchOnlyEditableRange Limit the searching to only search inside the editable range of the model. * @param isRegex Used to indicate that `searchString` is a regular expression. * @param matchCase Force the matching to match lower/upper case exactly. - * @param wholeWord Force the matching to match entire words only. + * @param wordSeparators Force the matching to match entire words only. Pass null otherwise. * @param captureMatches The result will contain the captured groups. * @param limitResultCount Limit the number of results * @return The ranges where the matches are. It is empty if not matches have been found. */ - findMatches(searchString: string, searchOnlyEditableRange: boolean, isRegex: boolean, matchCase: boolean, wholeWord: boolean, captureMatches: boolean, limitResultCount?: number): FindMatch[]; + findMatches(searchString: string, searchOnlyEditableRange: boolean, isRegex: boolean, matchCase: boolean, wordSeparators: string, captureMatches: boolean, limitResultCount?: number): FindMatch[]; /** * Search the model. * @param searchString The string used to search. If it is a regular expression, set `isRegex` to true. * @param searchScope Limit the searching to only search inside this range. * @param isRegex Used to indicate that `searchString` is a regular expression. * @param matchCase Force the matching to match lower/upper case exactly. - * @param wholeWord Force the matching to match entire words only. + * @param wordSeparators Force the matching to match entire words only. Pass null otherwise. * @param captureMatches The result will contain the captured groups. * @param limitResultCount Limit the number of results * @return The ranges where the matches are. It is empty if no matches have been found. */ - findMatches(searchString: string, searchScope: IRange, isRegex: boolean, matchCase: boolean, wholeWord: boolean, captureMatches: boolean, limitResultCount?: number): FindMatch[]; + findMatches(searchString: string, searchScope: IRange, isRegex: boolean, matchCase: boolean, wordSeparators: string, captureMatches: boolean, limitResultCount?: number): FindMatch[]; /** * Search the model for the next match. Loops to the beginning of the model if needed. * @param searchString The string used to search. If it is a regular expression, set `isRegex` to true. * @param searchStart Start the searching at the specified position. * @param isRegex Used to indicate that `searchString` is a regular expression. * @param matchCase Force the matching to match lower/upper case exactly. - * @param wholeWord Force the matching to match entire words only. + * @param wordSeparators Force the matching to match entire words only. Pass null otherwise. * @param captureMatches The result will contain the captured groups. * @return The range where the next match is. It is null if no next match has been found. */ - findNextMatch(searchString: string, searchStart: IPosition, isRegex: boolean, matchCase: boolean, wholeWord: boolean, captureMatches: boolean): FindMatch; + findNextMatch(searchString: string, searchStart: IPosition, isRegex: boolean, matchCase: boolean, wordSeparators: string, captureMatches: boolean): FindMatch; /** * Search the model for the previous match. Loops to the end of the model if needed. * @param searchString The string used to search. If it is a regular expression, set `isRegex` to true. * @param searchStart Start the searching at the specified position. * @param isRegex Used to indicate that `searchString` is a regular expression. * @param matchCase Force the matching to match lower/upper case exactly. - * @param wholeWord Force the matching to match entire words only. + * @param wordSeparators Force the matching to match entire words only. Pass null otherwise. * @param captureMatches The result will contain the captured groups. * @return The range where the previous match is. It is null if no previous match has been found. */ - findPreviousMatch(searchString: string, searchStart: IPosition, isRegex: boolean, matchCase: boolean, wholeWord: boolean, captureMatches: boolean): FindMatch; + findPreviousMatch(searchString: string, searchStart: IPosition, isRegex: boolean, matchCase: boolean, wordSeparators: string, captureMatches: boolean): FindMatch; } export class FindMatch { @@ -2184,7 +1654,8 @@ declare module monaco.editor { } /** - * Describes the behaviour of decorations when typing/editing near their edges. + * Describes the behavior of decorations when typing/editing near their edges. + * Note: Please do not edit the values, as they very carefully match `DecorationRangeBehavior` */ export enum TrackedRangeStickiness { AlwaysGrowsWhenTypingAtEdges = 0, @@ -2301,12 +1772,12 @@ declare module monaco.editor { /** * A model. */ - export interface IModel extends IReadOnlyModel, IEditableTextModel, ITextModelWithMarkers, ITokenizedModel, ITextModelWithDecorations, IEditorModel { + export interface IModel extends IReadOnlyModel, IEditableTextModel, ITextModelWithMarkers, ITokenizedModel, ITextModelWithDecorations { /** * An event emitted when the contents of the model have changed. * @event */ - onDidChangeContent(listener: (e: IModelContentChangedEvent2) => void): IDisposable; + onDidChangeContent(listener: (e: IModelContentChangedEvent) => void): IDisposable; /** * An event emitted when decorations of the model have changed. * @event @@ -2339,183 +1810,17 @@ declare module monaco.editor { } /** - * An event describing that the current mode associated with a model has changed. + * A model for the diff editor. */ - export interface IModelLanguageChangedEvent { + export interface IDiffEditorModel { /** - * Previous language + * Original model. */ - readonly oldLanguage: string; + original: IModel; /** - * New language + * Modified model. */ - readonly newLanguage: string; - } - - /** - * An event describing a change in the text of a model. - */ - export interface IModelContentChangedEvent2 { - /** - * The range that got replaced. - */ - readonly range: IRange; - /** - * The length of the range that got replaced. - */ - readonly rangeLength: number; - /** - * The new text for the range. - */ - readonly text: string; - /** - * The (new) end-of-line character. - */ - readonly eol: string; - /** - * The new version id the model has transitioned to. - */ - versionId: number; - /** - * Flag that indicates that this event was generated while undoing. - */ - readonly isUndoing: boolean; - /** - * Flag that indicates that this event was generated while redoing. - */ - readonly isRedoing: boolean; - } - - /** - * An event describing that model decorations have changed. - */ - export interface IModelDecorationsChangedEvent { - /** - * Lists of ids for added decorations. - */ - readonly addedDecorations: string[]; - /** - * Lists of ids for changed decorations. - */ - readonly changedDecorations: string[]; - /** - * List of ids for removed decorations. - */ - readonly removedDecorations: string[]; - } - - /** - * An event describing that some ranges of lines have been tokenized (their tokens have changed). - */ - export interface IModelTokensChangedEvent { - readonly ranges: { - /** - * The start of the range (inclusive) - */ - readonly fromLineNumber: number; - /** - * The end of the range (inclusive) - */ - readonly toLineNumber: number; - }[]; - } - - /** - * Describes the reason the cursor has changed its position. - */ - export enum CursorChangeReason { - /** - * Unknown or not set. - */ - NotSet = 0, - /** - * A `model.setValue()` was called. - */ - ContentFlush = 1, - /** - * The `model` has been changed outside of this cursor and the cursor recovers its position from associated markers. - */ - RecoverFromMarkers = 2, - /** - * There was an explicit user gesture. - */ - Explicit = 3, - /** - * There was a Paste. - */ - Paste = 4, - /** - * There was an Undo. - */ - Undo = 5, - /** - * There was a Redo. - */ - Redo = 6, - } - - /** - * An event describing that the cursor position has changed. - */ - export interface ICursorPositionChangedEvent { - /** - * Primary cursor's position. - */ - readonly position: Position; - /** - * Primary cursor's view position - */ - readonly viewPosition: Position; - /** - * Secondary cursors' position. - */ - readonly secondaryPositions: Position[]; - /** - * Secondary cursors' view position. - */ - readonly secondaryViewPositions: Position[]; - /** - * Reason. - */ - readonly reason: CursorChangeReason; - /** - * Source of the call that caused the event. - */ - readonly source: string; - /** - * Is the primary cursor in the editable range? - */ - readonly isInEditableRange: boolean; - } - - /** - * An event describing that the cursor selection has changed. - */ - export interface ICursorSelectionChangedEvent { - /** - * The primary selection. - */ - readonly selection: Selection; - /** - * The primary selection in view coordinates. - */ - readonly viewSelection: Selection; - /** - * The secondary selections. - */ - readonly secondarySelections: Selection[]; - /** - * The secondary selections in view coordinates. - */ - readonly secondaryViewSelections: Selection[]; - /** - * Source of the call that caused the event. - */ - readonly source: string; - /** - * Reason. - */ - readonly reason: CursorChangeReason; + modified: IModel; } /** @@ -2532,240 +1837,11 @@ declare module monaco.editor { readonly newModelUrl: Uri; } - /** - * A description for the overview ruler position. - */ - export class OverviewRulerPosition { - readonly _overviewRulerPositionBrand: void; - /** - * Width of the overview ruler - */ - readonly width: number; - /** - * Height of the overview ruler - */ - readonly height: number; - /** - * Top position for the overview ruler - */ - readonly top: number; - /** - * Right position for the overview ruler - */ - readonly right: number; - } - - /** - * The internal layout details of the editor. - */ - export class EditorLayoutInfo { - readonly _editorLayoutInfoBrand: void; - /** - * Full editor width. - */ - readonly width: number; - /** - * Full editor height. - */ - readonly height: number; - /** - * Left position for the glyph margin. - */ - readonly glyphMarginLeft: number; - /** - * The width of the glyph margin. - */ - readonly glyphMarginWidth: number; - /** - * The height of the glyph margin. - */ - readonly glyphMarginHeight: number; - /** - * Left position for the line numbers. - */ - readonly lineNumbersLeft: number; - /** - * The width of the line numbers. - */ - readonly lineNumbersWidth: number; - /** - * The height of the line numbers. - */ - readonly lineNumbersHeight: number; - /** - * Left position for the line decorations. - */ - readonly decorationsLeft: number; - /** - * The width of the line decorations. - */ - readonly decorationsWidth: number; - /** - * The height of the line decorations. - */ - readonly decorationsHeight: number; - /** - * Left position for the content (actual text) - */ - readonly contentLeft: number; - /** - * The width of the content (actual text) - */ - readonly contentWidth: number; - /** - * The height of the content (actual height) - */ - readonly contentHeight: number; - /** - * The width of the vertical scrollbar. - */ - readonly verticalScrollbarWidth: number; - /** - * The height of the horizontal scrollbar. - */ - readonly horizontalScrollbarHeight: number; - /** - * The position of the overview ruler. - */ - readonly overviewRuler: OverviewRulerPosition; - } - - /** - * Options for creating the editor. - */ - export interface ICodeEditorWidgetCreationOptions extends IEditorOptions { - /** - * The initial model associated with this code editor. - */ - model?: IModel; - } - - /** - * An editor model. - */ - export interface IEditorModel { - } - - /** - * An editor view state. - */ - export interface IEditorViewState { - } - export interface IDimension { width: number; height: number; } - /** - * A (serializable) state of the cursors. - */ - export interface ICursorState { - inSelectionMode: boolean; - selectionStart: IPosition; - position: IPosition; - } - - /** - * A (serializable) state of the view. - */ - export interface IViewState { - scrollTop: number; - scrollTopWithoutViewZones: number; - scrollLeft: number; - } - - /** - * A (serializable) state of the code editor. - */ - export interface ICodeEditorViewState extends IEditorViewState { - cursorState: ICursorState[]; - viewState: IViewState; - contributionsState: { - [id: string]: any; - }; - } - - /** - * Type of hit element with the mouse in the editor. - */ - export enum MouseTargetType { - /** - * Mouse is on top of an unknown element. - */ - UNKNOWN = 0, - /** - * Mouse is on top of the textarea used for input. - */ - TEXTAREA = 1, - /** - * Mouse is on top of the glyph margin - */ - GUTTER_GLYPH_MARGIN = 2, - /** - * Mouse is on top of the line numbers - */ - GUTTER_LINE_NUMBERS = 3, - /** - * Mouse is on top of the line decorations - */ - GUTTER_LINE_DECORATIONS = 4, - /** - * Mouse is on top of the whitespace left in the gutter by a view zone. - */ - GUTTER_VIEW_ZONE = 5, - /** - * Mouse is on top of text in the content. - */ - CONTENT_TEXT = 6, - /** - * Mouse is on top of empty space in the content (e.g. after line text or below last line) - */ - CONTENT_EMPTY = 7, - /** - * Mouse is on top of a view zone in the content. - */ - CONTENT_VIEW_ZONE = 8, - /** - * Mouse is on top of a content widget. - */ - CONTENT_WIDGET = 9, - /** - * Mouse is on top of the decorations overview ruler. - */ - OVERVIEW_RULER = 10, - /** - * Mouse is on top of a scrollbar. - */ - SCROLLBAR = 11, - /** - * Mouse is on top of an overlay widget. - */ - OVERLAY_WIDGET = 12, - } - - /** - * A model for the diff editor. - */ - export interface IDiffEditorModel extends IEditorModel { - /** - * Original model. - */ - original: IModel; - /** - * Modified model. - */ - modified: IModel; - } - - /** - * (Serializable) View state for the diff editor. - */ - export interface IDiffEditorViewState extends IEditorViewState { - original: ICodeEditorViewState; - modified: ICodeEditorViewState; - } - /** * A change */ @@ -2858,40 +1934,54 @@ declare module monaco.editor { run(): Promise; } + export type IEditorModel = IModel | IDiffEditorModel; + + /** + * A (serializable) state of the cursors. + */ + export interface ICursorState { + inSelectionMode: boolean; + selectionStart: IPosition; + position: IPosition; + } + + /** + * A (serializable) state of the view. + */ + export interface IViewState { + scrollTop: number; + scrollTopWithoutViewZones: number; + scrollLeft: number; + } + + /** + * A (serializable) state of the code editor. + */ + export interface ICodeEditorViewState { + cursorState: ICursorState[]; + viewState: IViewState; + contributionsState: { + [id: string]: any; + }; + } + + /** + * (Serializable) View state for the diff editor. + */ + export interface IDiffEditorViewState { + original: ICodeEditorViewState; + modified: ICodeEditorViewState; + } + + /** + * An editor view state. + */ + export type IEditorViewState = ICodeEditorViewState | IDiffEditorViewState; + /** * An editor. */ export interface IEditor { - /** - * An event emitted when the content of the current model has changed. - * @event - */ - onDidChangeModelContent(listener: (e: IModelContentChangedEvent2) => void): IDisposable; - /** - * An event emitted when the language of the current model has changed. - * @event - */ - onDidChangeModelLanguage(listener: (e: IModelLanguageChangedEvent) => void): IDisposable; - /** - * An event emitted when the options of the current model has changed. - * @event - */ - onDidChangeModelOptions(listener: (e: IModelOptionsChangedEvent) => void): IDisposable; - /** - * An event emitted when the configuration of the editor has changed. (e.g. `editor.updateOptions()`) - * @event - */ - onDidChangeConfiguration(listener: (e: IConfigurationChangedEvent) => void): IDisposable; - /** - * An event emitted when the cursor position has changed. - * @event - */ - onDidChangeCursorPosition(listener: (e: ICursorPositionChangedEvent) => void): IDisposable; - /** - * An event emitted when the cursor selection has changed. - * @event - */ - onDidChangeCursorSelection(listener: (e: ICursorSelectionChangedEvent) => void): IDisposable; /** * An event emitted when the editor has been disposed. * @event @@ -2971,7 +2061,7 @@ declare module monaco.editor { /** * Scroll vertically or horizontally as necessary and reveal a position. */ - revealPosition(position: IPosition): void; + revealPosition(position: IPosition, revealVerticalInCenter?: boolean, revealHorizontal?: boolean): void; /** * Scroll vertically or horizontally as necessary and reveal a position centered vertically. */ @@ -3086,6 +2176,36 @@ declare module monaco.editor { } export interface ICommonCodeEditor extends IEditor { + /** + * An event emitted when the content of the current model has changed. + * @event + */ + onDidChangeModelContent(listener: (e: IModelContentChangedEvent) => void): IDisposable; + /** + * An event emitted when the language of the current model has changed. + * @event + */ + onDidChangeModelLanguage(listener: (e: IModelLanguageChangedEvent) => void): IDisposable; + /** + * An event emitted when the options of the current model has changed. + * @event + */ + onDidChangeModelOptions(listener: (e: IModelOptionsChangedEvent) => void): IDisposable; + /** + * An event emitted when the configuration of the editor has changed. (e.g. `editor.updateOptions()`) + * @event + */ + onDidChangeConfiguration(listener: (e: IConfigurationChangedEvent) => void): IDisposable; + /** + * An event emitted when the cursor position has changed. + * @event + */ + onDidChangeCursorPosition(listener: (e: ICursorPositionChangedEvent) => void): IDisposable; + /** + * An event emitted when the cursor selection has changed. + * @event + */ + onDidChangeCursorSelection(listener: (e: ICursorSelectionChangedEvent) => void): IDisposable; /** * An event emitted when the model of this editor has changed (e.g. `editor.setModel()`). * @event @@ -3116,6 +2236,14 @@ declare module monaco.editor { * @event */ onDidBlurEditor(listener: () => void): IDisposable; + /** + * Saves current view state of the editor in a serializable object. + */ + saveViewState(): ICodeEditorViewState; + /** + * Restores the view state of the editor from a serializable object generated by `saveViewState`. + */ + restoreViewState(state: ICodeEditorViewState): void; /** * Returns true if this editor or one of its widgets has keyboard focus. */ @@ -3183,6 +2311,7 @@ declare module monaco.editor { getAction(id: string): IEditorAction; /** * Execute a command on the editor. + * The edits will land on the undo-redo stack, but no "undo stop" will be pushed. * @param source The source of the call. * @param command The command to execute */ @@ -3193,6 +2322,7 @@ declare module monaco.editor { pushUndoStop(): boolean; /** * Execute edits on the editor. + * The edits will land on the undo-redo stack, but no "undo stop" will be pushed. * @param source The source of the call. * @param edits The edits to execute. * @param endCursoState Cursor state after the edits were applied. @@ -3225,6 +2355,14 @@ declare module monaco.editor { * @event */ onDidUpdateDiff(listener: () => void): IDisposable; + /** + * Saves current view state of the editor in a serializable object. + */ + saveViewState(): IDiffEditorViewState; + /** + * Restores the view state of the editor from a serializable object generated by `saveViewState`. + */ + restoreViewState(state: IDiffEditorViewState): void; /** * Type the getModel() of IEditor. */ @@ -3269,199 +2407,725 @@ declare module monaco.editor { }; /** - * Positions in the view for cursor move command. + * An event describing that the current mode associated with a model has changed. */ - export const CursorMovePosition: { - Left: string; - Right: string; - Up: string; - Down: string; - WrappedLineStart: string; - WrappedLineFirstNonWhitespaceCharacter: string; - WrappedLineColumnCenter: string; - WrappedLineEnd: string; - WrappedLineLastNonWhitespaceCharacter: string; - ViewPortTop: string; - ViewPortCenter: string; - ViewPortBottom: string; - ViewPortIfOutside: string; - }; + export interface IModelLanguageChangedEvent { + /** + * Previous language + */ + readonly oldLanguage: string; + /** + * New language + */ + readonly newLanguage: string; + } - /** - * Units for Cursor move 'by' argument - */ - export const CursorMoveByUnit: { - Line: string; - WrappedLine: string; - Character: string; - HalfLine: string; - }; - - /** - * Arguments for Cursor move command - */ - export interface CursorMoveArguments { - to: string; - select?: boolean; - by?: string; - value?: number; + export interface IModelContentChange { + /** + * The range that got replaced. + */ + readonly range: IRange; + /** + * The length of the range that got replaced. + */ + readonly rangeLength: number; + /** + * The new text for the range. + */ + readonly text: string; } /** - * Directions in the view for editor scroll command. + * An event describing a change in the text of a model. */ - export const EditorScrollDirection: { - Up: string; - Down: string; - }; - - /** - * Units for editor scroll 'by' argument - */ - export const EditorScrollByUnit: { - Line: string; - WrappedLine: string; - Page: string; - HalfPage: string; - }; - - /** - * Arguments for editor scroll command - */ - export interface EditorScrollArguments { - to: string; - by?: string; - value?: number; - revealCursor?: boolean; + export interface IModelContentChangedEvent { + readonly changes: IModelContentChange[]; + /** + * The (new) end-of-line character. + */ + readonly eol: string; + /** + * The new version id the model has transitioned to. + */ + readonly versionId: number; + /** + * Flag that indicates that this event was generated while undoing. + */ + readonly isUndoing: boolean; + /** + * Flag that indicates that this event was generated while redoing. + */ + readonly isRedoing: boolean; + /** + * Flag that indicates that all decorations were lost with this edit. + * The model has been reset to a new value. + */ + readonly isFlush: boolean; } /** - * Arguments for reveal line command + * An event describing that model decorations have changed. */ - export interface RevealLineArguments { - lineNumber?: number; - at?: string; + export interface IModelDecorationsChangedEvent { + /** + * Lists of ids for added decorations. + */ + readonly addedDecorations: string[]; + /** + * Lists of ids for changed decorations. + */ + readonly changedDecorations: string[]; + /** + * List of ids for removed decorations. + */ + readonly removedDecorations: string[]; } /** - * Values for reveal line 'at' argument + * An event describing that some ranges of lines have been tokenized (their tokens have changed). */ - export const RevealLineAtArgument: { - Top: string; - Center: string; - Bottom: string; - }; + export interface IModelTokensChangedEvent { + readonly ranges: { + /** + * The start of the range (inclusive) + */ + readonly fromLineNumber: number; + /** + * The end of the range (inclusive) + */ + readonly toLineNumber: number; + }[]; + } + + export interface IModelOptionsChangedEvent { + readonly tabSize: boolean; + readonly insertSpaces: boolean; + readonly trimAutoWhitespace: boolean; + } /** - * Built-in commands. + * Describes the reason the cursor has changed its position. */ - export var Handler: { - ExecuteCommand: string; - ExecuteCommands: string; - CursorLeft: string; - CursorLeftSelect: string; - CursorWordLeft: string; - CursorWordStartLeft: string; - CursorWordEndLeft: string; - CursorWordLeftSelect: string; - CursorWordStartLeftSelect: string; - CursorWordEndLeftSelect: string; - CursorRight: string; - CursorRightSelect: string; - CursorWordRight: string; - CursorWordStartRight: string; - CursorWordEndRight: string; - CursorWordRightSelect: string; - CursorWordStartRightSelect: string; - CursorWordEndRightSelect: string; - CursorUp: string; - CursorUpSelect: string; - CursorDown: string; - CursorDownSelect: string; - CursorPageUp: string; - CursorPageUpSelect: string; - CursorPageDown: string; - CursorPageDownSelect: string; - CursorHome: string; - CursorHomeSelect: string; - CursorEnd: string; - CursorEndSelect: string; - ExpandLineSelection: string; - CursorTop: string; - CursorTopSelect: string; - CursorBottom: string; - CursorBottomSelect: string; - CursorColumnSelectLeft: string; - CursorColumnSelectRight: string; - CursorColumnSelectUp: string; - CursorColumnSelectPageUp: string; - CursorColumnSelectDown: string; - CursorColumnSelectPageDown: string; - CursorMove: string; - AddCursorDown: string; - AddCursorUp: string; - CursorUndo: string; - MoveTo: string; - MoveToSelect: string; - ColumnSelect: string; - CreateCursor: string; - LastCursorMoveToSelect: string; - Type: string; - ReplacePreviousChar: string; - CompositionStart: string; - CompositionEnd: string; - Paste: string; - Tab: string; - Indent: string; - Outdent: string; - DeleteLeft: string; - DeleteRight: string; - DeleteWordLeft: string; - DeleteWordStartLeft: string; - DeleteWordEndLeft: string; - DeleteWordRight: string; - DeleteWordStartRight: string; - DeleteWordEndRight: string; - RemoveSecondaryCursors: string; - CancelSelection: string; - Cut: string; - Undo: string; - Redo: string; - WordSelect: string; - WordSelectDrag: string; - LastCursorWordSelect: string; - LineSelect: string; - LineSelectDrag: string; - LastCursorLineSelect: string; - LastCursorLineSelectDrag: string; - LineInsertBefore: string; - LineInsertAfter: string; - LineBreakInsert: string; - SelectAll: string; - EditorScroll: string; - ScrollLineUp: string; - ScrollLineDown: string; - ScrollPageUp: string; - ScrollPageDown: string; - RevealLine: string; - }; + export enum CursorChangeReason { + /** + * Unknown or not set. + */ + NotSet = 0, + /** + * A `model.setValue()` was called. + */ + ContentFlush = 1, + /** + * The `model` has been changed outside of this cursor and the cursor recovers its position from associated markers. + */ + RecoverFromMarkers = 2, + /** + * There was an explicit user gesture. + */ + Explicit = 3, + /** + * There was a Paste. + */ + Paste = 4, + /** + * There was an Undo. + */ + Undo = 5, + /** + * There was a Redo. + */ + Redo = 6, + } /** - * The style in which the editor's cursor should be rendered. + * An event describing that the cursor position has changed. */ - export enum TextEditorCursorStyle { + export interface ICursorPositionChangedEvent { /** - * As a vertical line (sitting between two characters). + * Primary cursor's position. */ - Line = 1, + readonly position: Position; /** - * As a block (sitting on top of a character). + * Secondary cursors' position. */ - Block = 2, + readonly secondaryPositions: Position[]; /** - * As a horizontal line (sitting under a character). + * Reason. */ - Underline = 3, + readonly reason: CursorChangeReason; + /** + * Source of the call that caused the event. + */ + readonly source: string; + } + + /** + * An event describing that the cursor selection has changed. + */ + export interface ICursorSelectionChangedEvent { + /** + * The primary selection. + */ + readonly selection: Selection; + /** + * The secondary selections. + */ + readonly secondarySelections: Selection[]; + /** + * Source of the call that caused the event. + */ + readonly source: string; + /** + * Reason. + */ + readonly reason: CursorChangeReason; + } + + /** + * 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; + } + + /** + * Configuration options for editor find widget + */ + export interface IEditorFindOptions { + /** + * Controls if we seed search string in the Find Widget with editor selection. + */ + seedSearchStringFromSelection?: boolean; + /** + * Controls if Find in Selection flag is turned on when multiple lines of text are selected in the editor. + */ + autoFindInSelection: boolean; + } + + /** + * Configuration options for editor minimap + */ + export interface IEditorMinimapOptions { + /** + * Enable the rendering of the minimap. + * Defaults to false. + */ + enabled?: boolean; + /** + * Control the rendering of the minimap slider. + * Defaults to 'mouseover'. + */ + showSlider?: 'always' | 'mouseover'; + /** + * Render the actual text on a line (as opposed to color blocks). + * Defaults to true. + */ + renderCharacters?: boolean; + /** + * Limit the width of the minimap to render at most a certain number of columns. + * Defaults to 120. + */ + maxColumn?: number; + } + + /** + * Configuration options for the editor. + */ + export interface IEditorOptions { + /** + * 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?: 'on' | 'off' | 'relative' | ((lineNumber: number) => string); + /** + * 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; + /** + * Class name to be added to the editor. + */ + extraEditorClassName?: string; + /** + * Should the editor be read only. + * Defaults to false. + */ + readOnly?: boolean; + /** + * Control the behavior and rendering of the scrollbars. + */ + scrollbar?: IEditorScrollbarOptions; + /** + * Control the behavior and rendering of the minimap. + */ + minimap?: IEditorMinimapOptions; + /** + * Control the behavior of the find widget. + */ + find?: IEditorFindOptions; + /** + * 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; + /** + * Controls if a border should be drawn around the overview ruler. + * Defaults to `true`. + */ + overviewRulerBorder?: boolean; + /** + * 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 `will-change` for the editor margin and lines layers. + * The usage of `will-change` acts as a hint for browsers to create an extra layer. + * Defaults to false. + */ + disableLayerHinting?: 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 of the editor. + * When `wordWrap` = "off", the lines will never wrap. + * When `wordWrap` = "on", the lines will wrap at the viewport width. + * When `wordWrap` = "wordWrapColumn", the lines will wrap at `wordWrapColumn`. + * When `wordWrap` = "bounded", the lines will wrap at min(viewport width, wordWrapColumn). + * Defaults to "off". + */ + wordWrap?: 'off' | 'on' | 'wordWrapColumn' | 'bounded'; + /** + * Control the wrapping of the editor. + * When `wordWrap` = "off", the lines will never wrap. + * When `wordWrap` = "on", the lines will wrap at the viewport width. + * When `wordWrap` = "wordWrapColumn", the lines will wrap at `wordWrapColumn`. + * When `wordWrap` = "bounded", the lines will wrap at min(viewport width, wordWrapColumn). + * Defaults to 80. + */ + wordWrapColumn?: number; + /** + * Force word wrapping when the text appears to be of a minified/generated file. + * Defaults to true. + */ + wordWrapMinified?: 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. + * Use -1 to never stop rendering + */ + stopRenderingLineAfter?: number; + /** + * Enable hover. + * Defaults to true. + */ + hover?: boolean; + /** + * Enable detecting links and making them clickable. + * Defaults to true. + */ + links?: 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; + /** + * The modifier to be used to add multiple cursors with the mouse. + * Defaults to 'alt' + */ + multiCursorModifier?: 'ctrlCmd' | 'alt'; + /** + * Configure the editor's accessibility support. + * Defaults to 'auto'. It is best to leave this to 'auto'. + */ + accessibilitySupport?: 'auto' | 'off' | 'on'; + /** + * Enable quick suggestions (shadow suggestions) + * Defaults to true. + */ + quickSuggestions?: boolean | { + other: boolean; + comments: boolean; + strings: 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 auto indentation adjustment. + * Defaults to false. + */ + autoIndent?: boolean; + /** + * Enable format on type. + * Defaults to false. + */ + formatOnType?: boolean; + /** + * Enable format on paste. + * Defaults to false. + */ + formatOnPaste?: boolean; + /** + * Controls if the editor should allow to move selections via drag and drop. + * Defaults to false. + */ + dragAndDrop?: boolean; + /** + * Enable the suggestion box to pop-up on trigger characters. + * Defaults to true. + */ + suggestOnTriggerCharacters?: boolean; + /** + * Accept suggestions on ENTER. + * Defaults to 'on'. + */ + acceptSuggestionOnEnter?: 'on' | 'smart' | 'off'; + /** + * 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 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; + /** + * Enable semantic occurrences highlight. + * Defaults to true. + */ + occurrencesHighlight?: 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; + /** + * Controls whether the fold actions in the gutter stay always visible or hide unless the mouse is over the gutter. + * Defaults to 'mouseover'. + */ + showFoldingControls?: 'always' | 'mouseover'; + /** + * Enable highlighting of matching brackets. + * Defaults to true. + */ + matchBrackets?: 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; + /** + * The letter spacing + */ + letterSpacing?: 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 enum RenderMinimap { + None = 0, + Small = 1, + Large = 2, + SmallBlocks = 3, + LargeBlocks = 4, + } + + /** + * 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, } /** @@ -3494,6 +3158,294 @@ declare module monaco.editor { Solid = 5, } + /** + * The style in which the editor's cursor should be rendered. + */ + export enum TextEditorCursorStyle { + /** + * As a vertical line (sitting between two characters). + */ + Line = 1, + /** + * As a block (sitting on top of a character). + */ + Block = 2, + /** + * As a horizontal line (sitting under a character). + */ + Underline = 3, + /** + * As a thin vertical line (sitting between two characters). + */ + LineThin = 4, + /** + * As an outlined block (sitting on top of a character). + */ + BlockOutline = 5, + /** + * As a thin horizontal line (sitting under a character). + */ + UnderlineThin = 6, + } + + export interface InternalEditorScrollbarOptions { + 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 interface InternalEditorMinimapOptions { + readonly enabled: boolean; + readonly showSlider: 'always' | 'mouseover'; + readonly renderCharacters: boolean; + readonly maxColumn: number; + } + + export interface InternalEditorFindOptions { + readonly seedSearchStringFromSelection: boolean; + readonly autoFindInSelection: boolean; + } + + export interface EditorWrappingInfo { + readonly inDiffEditor: boolean; + readonly isDominatedByLongLines: boolean; + readonly isWordWrapMinified: boolean; + readonly isViewportWrapping: boolean; + readonly wrappingColumn: number; + readonly wrappingIndent: WrappingIndent; + readonly wordWrapBreakBeforeCharacters: string; + readonly wordWrapBreakAfterCharacters: string; + readonly wordWrapBreakObtrusiveCharacters: string; + } + + export interface InternalEditorViewOptions { + readonly extraEditorClassName: string; + readonly disableMonospaceOptimizations: boolean; + readonly rulers: number[]; + readonly ariaLabel: string; + readonly renderLineNumbers: boolean; + readonly renderCustomLineNumbers: (lineNumber: number) => string; + readonly renderRelativeLineNumbers: boolean; + readonly selectOnLineNumbers: boolean; + readonly glyphMargin: boolean; + readonly revealHorizontalRightPadding: number; + readonly roundedSelection: boolean; + readonly overviewRulerLanes: number; + readonly overviewRulerBorder: boolean; + readonly cursorBlinking: TextEditorCursorBlinkingStyle; + readonly mouseWheelZoom: boolean; + readonly cursorStyle: TextEditorCursorStyle; + readonly hideCursorInOverviewRuler: boolean; + readonly scrollBeyondLastLine: boolean; + readonly stopRenderingLineAfter: number; + readonly renderWhitespace: 'none' | 'boundary' | 'all'; + readonly renderControlCharacters: boolean; + readonly fontLigatures: boolean; + readonly renderIndentGuides: boolean; + readonly renderLineHighlight: 'none' | 'gutter' | 'line' | 'all'; + readonly scrollbar: InternalEditorScrollbarOptions; + readonly minimap: InternalEditorMinimapOptions; + readonly fixedOverflowWidgets: boolean; + } + + export interface EditorContribOptions { + readonly selectionClipboard: boolean; + readonly hover: boolean; + readonly links: boolean; + readonly contextmenu: boolean; + readonly quickSuggestions: boolean | { + other: boolean; + comments: boolean; + strings: boolean; + }; + readonly quickSuggestionsDelay: number; + readonly parameterHints: boolean; + readonly iconsInSuggestions: boolean; + readonly formatOnType: boolean; + readonly formatOnPaste: boolean; + readonly suggestOnTriggerCharacters: boolean; + readonly acceptSuggestionOnEnter: 'on' | 'smart' | 'off'; + readonly acceptSuggestionOnCommitCharacter: boolean; + readonly snippetSuggestions: 'top' | 'bottom' | 'inline' | 'none'; + readonly wordBasedSuggestions: boolean; + readonly suggestFontSize: number; + readonly suggestLineHeight: number; + readonly selectionHighlight: boolean; + readonly occurrencesHighlight: boolean; + readonly codeLens: boolean; + readonly folding: boolean; + readonly showFoldingControls: 'always' | 'mouseover'; + readonly matchBrackets: boolean; + readonly find: InternalEditorFindOptions; + } + + /** + * Internal configuration options (transformed or computed) for the editor. + */ + export class InternalEditorOptions { + readonly _internalEditorOptionsBrand: void; + readonly canUseLayerHinting: boolean; + readonly pixelRatio: number; + readonly editorClassName: string; + readonly lineHeight: number; + readonly readOnly: boolean; + readonly multiCursorModifier: 'altKey' | 'ctrlKey' | 'metaKey'; + readonly wordSeparators: string; + readonly autoClosingBrackets: boolean; + readonly autoIndent: boolean; + readonly useTabStops: boolean; + readonly tabFocusMode: boolean; + readonly dragAndDrop: boolean; + readonly emptySelectionClipboard: boolean; + readonly layoutInfo: EditorLayoutInfo; + readonly fontInfo: FontInfo; + readonly viewInfo: InternalEditorViewOptions; + readonly wrappingInfo: EditorWrappingInfo; + readonly contribInfo: EditorContribOptions; + } + + /** + * A description for the overview ruler position. + */ + export interface OverviewRulerPosition { + /** + * Width of the overview ruler + */ + readonly width: number; + /** + * Height of the overview ruler + */ + readonly height: number; + /** + * Top position for the overview ruler + */ + readonly top: number; + /** + * Right position for the overview ruler + */ + readonly right: number; + } + + /** + * The internal layout details of the editor. + */ + export interface EditorLayoutInfo { + /** + * Full editor width. + */ + readonly width: number; + /** + * Full editor height. + */ + readonly height: number; + /** + * Left position for the glyph margin. + */ + readonly glyphMarginLeft: number; + /** + * The width of the glyph margin. + */ + readonly glyphMarginWidth: number; + /** + * The height of the glyph margin. + */ + readonly glyphMarginHeight: number; + /** + * Left position for the line numbers. + */ + readonly lineNumbersLeft: number; + /** + * The width of the line numbers. + */ + readonly lineNumbersWidth: number; + /** + * The height of the line numbers. + */ + readonly lineNumbersHeight: number; + /** + * Left position for the line decorations. + */ + readonly decorationsLeft: number; + /** + * The width of the line decorations. + */ + readonly decorationsWidth: number; + /** + * The height of the line decorations. + */ + readonly decorationsHeight: number; + /** + * Left position for the content (actual text) + */ + readonly contentLeft: number; + /** + * The width of the content (actual text) + */ + readonly contentWidth: number; + /** + * The height of the content (actual height) + */ + readonly contentHeight: number; + /** + * The width of the minimap + */ + readonly minimapWidth: number; + /** + * Minimap render type + */ + readonly renderMinimap: RenderMinimap; + /** + * The number of columns (of typical characters) fitting on a viewport line. + */ + readonly viewportColumn: number; + /** + * The width of the vertical scrollbar. + */ + readonly verticalScrollbarWidth: number; + /** + * The height of the horizontal scrollbar. + */ + readonly horizontalScrollbarHeight: number; + /** + * The position of the overview ruler. + */ + readonly overviewRuler: OverviewRulerPosition; + } + + /** + * An event describing that the configuration of the editor has changed. + */ + export interface IConfigurationChangedEvent { + readonly canUseLayerHinting: boolean; + readonly pixelRatio: boolean; + readonly editorClassName: boolean; + readonly lineHeight: boolean; + readonly readOnly: boolean; + readonly accessibilitySupport: boolean; + readonly multiCursorModifier: boolean; + readonly wordSeparators: boolean; + readonly autoClosingBrackets: boolean; + readonly autoIndent: boolean; + readonly useTabStops: boolean; + readonly tabFocusMode: boolean; + readonly dragAndDrop: boolean; + readonly emptySelectionClipboard: boolean; + readonly layoutInfo: boolean; + readonly fontInfo: boolean; + readonly viewInfo: boolean; + readonly wrappingInfo: boolean; + readonly contribInfo: boolean; + } + /** * A view zone is a full horizontal rectangle that 'pushes' text down. * The editor reserves space for view zones when rendering. @@ -3671,6 +3623,68 @@ declare module monaco.editor { getPosition(): IOverlayWidgetPosition; } + /** + * Type of hit element with the mouse in the editor. + */ + export enum MouseTargetType { + /** + * Mouse is on top of an unknown element. + */ + UNKNOWN = 0, + /** + * Mouse is on top of the textarea used for input. + */ + TEXTAREA = 1, + /** + * Mouse is on top of the glyph margin + */ + GUTTER_GLYPH_MARGIN = 2, + /** + * Mouse is on top of the line numbers + */ + GUTTER_LINE_NUMBERS = 3, + /** + * Mouse is on top of the line decorations + */ + GUTTER_LINE_DECORATIONS = 4, + /** + * Mouse is on top of the whitespace left in the gutter by a view zone. + */ + GUTTER_VIEW_ZONE = 5, + /** + * Mouse is on top of text in the content. + */ + CONTENT_TEXT = 6, + /** + * Mouse is on top of empty space in the content (e.g. after line text or below last line) + */ + CONTENT_EMPTY = 7, + /** + * Mouse is on top of a view zone in the content. + */ + CONTENT_VIEW_ZONE = 8, + /** + * Mouse is on top of a content widget. + */ + CONTENT_WIDGET = 9, + /** + * Mouse is on top of the decorations overview ruler. + */ + OVERVIEW_RULER = 10, + /** + * Mouse is on top of a scrollbar. + */ + SCROLLBAR = 11, + /** + * Mouse is on top of an overlay widget. + */ + OVERLAY_WIDGET = 12, + /** + * Mouse is outside of the editor. + */ + OUTSIDE_EDITOR = 13, + } + /** * Target hit with the mouse in the editor. */ @@ -3851,6 +3865,7 @@ declare module monaco.editor { export class FontInfo extends BareFontInfo { readonly _editorStylingBrand: void; + readonly isTrusted: boolean; readonly isMonospace: boolean; readonly typicalHalfwidthCharacterWidth: number; readonly typicalFullwidthCharacterWidth: number; @@ -3859,10 +3874,12 @@ declare module monaco.editor { } export class BareFontInfo { readonly _bareFontInfoBrand: void; + readonly zoomLevel: number; readonly fontFamily: string; readonly fontWeight: string; readonly fontSize: number; readonly lineHeight: number; + readonly letterSpacing: number; } } @@ -3963,7 +3980,7 @@ declare module monaco.languages { export function registerDocumentSymbolProvider(languageId: string, provider: DocumentSymbolProvider): IDisposable; /** - * Register a document highlight provider (used by e.g. highlight occurences). + * Register a document highlight provider (used by e.g. highlight occurrences). */ export function registerDocumentHighlightProvider(languageId: string, provider: DocumentHighlightProvider): IDisposable; @@ -3973,10 +3990,15 @@ declare module monaco.languages { export function registerDefinitionProvider(languageId: string, provider: DefinitionProvider): IDisposable; /** - * Register a type implementation provider (used by e.g. go to implementation). + * Register a implementation provider (used by e.g. go to implementation). */ export function registerImplementationProvider(languageId: string, provider: ImplementationProvider): IDisposable; + /** + * Register a type definition provider (used by e.g. go to type definition). + */ + export function registerTypeDefinitionProvider(languageId: string, provider: TypeDefinitionProvider): IDisposable; + /** * Register a code lens provider (used by e.g. inline code lenses). */ @@ -4069,7 +4091,7 @@ declare module monaco.languages { * and `${3:foo}`. `$0` defines the final tab stop, it defaults to * the end of the snippet. Variables are defined with `$name` and * `${name:default value}`. The full snippet syntax is documented - * [here](http://code.visualstudio.com/docs/customization/userdefinedsnippets#_creating-your-own-snippets). + * [here](http://code.visualstudio.com/docs/editor/userdefinedsnippets#_creating-your-own-snippets). */ export interface SnippetString { /** @@ -4162,7 +4184,7 @@ declare module monaco.languages { /** * The completion item provider interface defines the contract between extensions and - * the [IntelliSense](https://code.visualstudio.com/docs/editor/editingevolved#_intellisense). + * the [IntelliSense](https://code.visualstudio.com/docs/editor/intellisense). * * When computing *complete* completion items is expensive, providers can optionally implement * the `resolveCompletionItem`-function. In that case it is enough to return completion @@ -4397,7 +4419,7 @@ declare module monaco.languages { /** * The hover provider interface defines the contract between extensions and - * the [hover](https://code.visualstudio.com/docs/editor/editingevolved#_hover)-feature. + * the [hover](https://code.visualstudio.com/docs/editor/intellisense)-feature. */ export interface HoverProvider { /** @@ -4477,7 +4499,7 @@ declare module monaco.languages { /** * The signature help provider interface defines the contract between extensions and - * the [parameter hints](https://code.visualstudio.com/docs/editor/editingevolved#_parameter-hints)-feature. + * the [parameter hints](https://code.visualstudio.com/docs/editor/intellisense)-feature. */ export interface SignatureHelpProvider { signatureHelpTriggerCharacters: string[]; @@ -4590,7 +4612,7 @@ declare module monaco.languages { } /** - * The type definition provider interface defines the contract between extensions and + * The implementation provider interface defines the contract between extensions and * the go to implementation feature. */ export interface ImplementationProvider { @@ -4600,6 +4622,17 @@ declare module monaco.languages { provideImplementation(model: editor.IReadOnlyModel, position: Position, token: CancellationToken): Definition | Thenable; } + /** + * The type definition provider interface defines the contract between extensions and + * the go to type definition feature. + */ + export interface TypeDefinitionProvider { + /** + * Provide the type definition of the symbol at the given position and document. + */ + provideTypeDefinition(model: editor.IReadOnlyModel, position: Position, token: CancellationToken): Definition | Thenable; + } + /** * A symbol kind. */ @@ -4625,6 +4658,11 @@ declare module monaco.languages { Object = 18, Key = 19, Null = 20, + EnumMember = 21, + Struct = 22, + Event = 23, + Operator = 24, + TypeParameter = 25, } /** @@ -4661,6 +4699,12 @@ declare module monaco.languages { provideDocumentSymbols(model: editor.IReadOnlyModel, token: CancellationToken): SymbolInformation[] | Thenable; } + export interface TextEdit { + range: IRange; + text: string; + eol?: editor.EndOfLineSequence; + } + /** * Interface used to format a model */ @@ -4683,7 +4727,7 @@ declare module monaco.languages { /** * Provide formatting edits for a whole document. */ - provideDocumentFormattingEdits(model: editor.IReadOnlyModel, options: FormattingOptions, token: CancellationToken): editor.ISingleEditOperation[] | Thenable; + provideDocumentFormattingEdits(model: editor.IReadOnlyModel, options: FormattingOptions, token: CancellationToken): TextEdit[] | Thenable; } /** @@ -4698,7 +4742,7 @@ declare module monaco.languages { * or larger range. Often this is done by adjusting the start and end * of the range to full syntax nodes. */ - provideDocumentRangeFormattingEdits(model: editor.IReadOnlyModel, range: Range, options: FormattingOptions, token: CancellationToken): editor.ISingleEditOperation[] | Thenable; + provideDocumentRangeFormattingEdits(model: editor.IReadOnlyModel, range: Range, options: FormattingOptions, token: CancellationToken): TextEdit[] | Thenable; } /** @@ -4714,7 +4758,7 @@ declare module monaco.languages { * what range the position to expand to, like find the matching `{` * when `}` has been entered. */ - provideOnTypeFormattingEdits(model: editor.IReadOnlyModel, position: Position, ch: string, options: FormattingOptions, token: CancellationToken): editor.ISingleEditOperation[] | Thenable; + provideOnTypeFormattingEdits(model: editor.IReadOnlyModel, position: Position, ch: string, options: FormattingOptions, token: CancellationToken): TextEdit[] | Thenable; } /** @@ -4751,6 +4795,7 @@ declare module monaco.languages { export interface Command { id: string; title: string; + tooltip?: string; arguments?: any[]; } @@ -4910,6 +4955,7 @@ declare module monaco.worker { } + declare module monaco.languages.typescript { enum ModuleKind { @@ -5047,6 +5093,12 @@ declare module monaco.languages.typescript { * mean never shut down. */ setMaximunWorkerIdleTime(value: number): void; + + /** + * Configure if all existing models should be eagerly sync'd + * to the worker on start or restart. + */ + setEagerModelSync(value: boolean): void; } export var typescriptDefaults: LanguageServiceDefaults; diff --git a/website/playground/new-samples/all.js b/website/playground/new-samples/all.js index 336632cb..f0eaec3b 100644 --- a/website/playground/new-samples/all.js +++ b/website/playground/new-samples/all.js @@ -75,9 +75,9 @@ var PLAY_SAMPLES = [ }, { chapter: "Customizing the appearence", - name: "Exposed CSS classes", - id: "customizing-the-appearence-exposed-css-classes", - path: "customizing-the-appearence/exposed-css-classes" + name: "Exposed colors", + id: "customizing-the-appearence-exposed-colors", + path: "customizing-the-appearence/exposed-colors" }, { chapter: "Customizing the appearence", diff --git a/website/playground/new-samples/creating-the-editor/hard-wrapping/sample.js b/website/playground/new-samples/creating-the-editor/hard-wrapping/sample.js index f92df878..c879fb1e 100644 --- a/website/playground/new-samples/creating-the-editor/hard-wrapping/sample.js +++ b/website/playground/new-samples/creating-the-editor/hard-wrapping/sample.js @@ -4,13 +4,11 @@ var editor = monaco.editor.create(document.getElementById("container"), { value: jsCode, language: "javascript", - // If `wrappingColumn` is -1, then no wrapping occurs and - // long lines are rendered on one line. However, this might - // mean that not all code is rendered (... may be used). - // If `wrappingColumn` is 0, then viewport width wrapping is set - // If `wrappingColumn` is > 0, then the lines will wrap at its value - // Defaults to 300 - wrappingColumn: 40, + wordWrap: 'wordWrapColumn', + wordWrapColumn: 40, + + // Set this to false to not auto word wrap minified files + wordWrapMinified: true, // try "same", "indent" or "none" wrappingIndent: "indent" diff --git a/website/playground/new-samples/customizing-the-appearence/exposed-colors/sample.css b/website/playground/new-samples/customizing-the-appearence/exposed-colors/sample.css new file mode 100644 index 00000000..e69de29b diff --git a/website/playground/new-samples/customizing-the-appearence/exposed-css-classes/sample.html b/website/playground/new-samples/customizing-the-appearence/exposed-colors/sample.html similarity index 100% rename from website/playground/new-samples/customizing-the-appearence/exposed-css-classes/sample.html rename to website/playground/new-samples/customizing-the-appearence/exposed-colors/sample.html diff --git a/website/playground/new-samples/customizing-the-appearence/exposed-colors/sample.js b/website/playground/new-samples/customizing-the-appearence/exposed-colors/sample.js new file mode 100644 index 00000000..a5bcc1ce --- /dev/null +++ b/website/playground/new-samples/customizing-the-appearence/exposed-colors/sample.js @@ -0,0 +1,154 @@ +// The editor colors can be customized through CSS or through JS + +monaco.editor.defineTheme('myTheme', { + base: 'vs', + inherit: true, + rules: [{ background: 'EDF9FA' }], + colors: { + 'editor.foreground': '#000000', + 'editor.background': '#EDF9FA', + 'editorCursor.foreground': '#8B0000', + 'editor.lineHighlightBackground': '#0000FF20', + 'editorLineNumber.foreground': '#008800', + 'editor.selectionBackground': '#88000030', + 'editor.inactiveSelectionBackground': '#88000015' + } +}); +monaco.editor.setTheme('myTheme'); + +monaco.editor.create(document.getElementById("container"), { + value: "My to-do list:\n* buy milk\n* buy coffee\n* write awesome code", + language: "text/plain", + fontFamily: "Arial", + fontSize: 20 +}); + +// A list of color names: +'foreground' // Overall foreground color. This color is only used if not overridden by a component. +'errorForeground' // Overall foreground color for error messages. This color is only used if not overridden by a component. +'descriptionForeground' // Foreground color for description text providing additional information, for example for a label. +'focusBorder' // Overall border color for focused elements. This color is only used if not overridden by a component. +'contrastBorder' // An extra border around elements to separate them from others for greater contrast. +'contrastActiveBorder' // An extra border around active elements to separate them from others for greater contrast. +'selection.background' // The background color of text selections in the workbench (e.g. for input fields or text areas). Note that this does not apply to selections within the editor. +'textSeparator.foreground' // Color for text separators. +'textLink.foreground' // Foreground color for links in text. +'textLink.activeForeground' // Foreground color for active links in text. +'textPreformat.foreground' // Foreground color for preformatted text segments. +'textBlockQuote.background' // Background color for block quotes in text. +'textBlockQuote.border' // Border color for block quotes in text. +'textCodeBlock.background' // Background color for code blocks in text. +'widget.shadow' // Shadow color of widgets such as find/replace inside the editor. +'input.background' // Input box background. +'input.foreground' // Input box foreground. +'input.border' // Input box border. +'inputOption.activeBorder' // Border color of activated options in input fields. +'input.placeholderForeground' // Input box foreground color for placeholder text. +'inputValidation.infoBackground' // Input validation background color for information severity. +'inputValidation.infoBorder' // Input validation border color for information severity. +'inputValidation.warningBackground' // Input validation background color for information warning. +'inputValidation.warningBorder' // Input validation border color for warning severity. +'inputValidation.errorBackground' // Input validation background color for error severity. +'inputValidation.errorBorder' // Input validation border color for error severity. +'dropdown.background' // Dropdown background. +'dropdown.foreground' // Dropdown foreground. +'dropdown.border' // Dropdown border. +'list.focusBackground' // List/Tree background color for the focused item when the list/tree is active. An active list/tree has keyboard focus, an inactive does not. +'list.focusForeground' // List/Tree foreground color for the focused item when the list/tree is active. An active list/tree has keyboard focus, an inactive does not. +'list.activeSelectionBackground' // List/Tree background color for the selected item when the list/tree is active. An active list/tree has keyboard focus, an inactive does not. +'list.activeSelectionForeground' // List/Tree foreground color for the selected item when the list/tree is active. An active list/tree has keyboard focus, an inactive does not. +'list.inactiveSelectionBackground' // List/Tree background color for the selected item when the list/tree is inactive. An active list/tree has keyboard focus, an inactive does not. +'list.inactiveSelectionForeground' // List/Tree foreground color for the selected item when the list/tree is inactive. An active list/tree has keyboard focus, an inactive does not. +'list.hoverBackground' // List/Tree background when hovering over items using the mouse. +'list.hoverForeground' // List/Tree foreground when hovering over items using the mouse. +'list.dropBackground' // List/Tree drag and drop background when moving items around using the mouse. +'list.highlightForeground' // List/Tree foreground color of the match highlights when searching inside the list/tree. +'pickerGroup.foreground' // Quick picker color for grouping labels. +'pickerGroup.border' // Quick picker color for grouping borders. +'button.foreground' // Button foreground color. +'button.background' // Button background color. +'button.hoverBackground' // Button background color when hovering. +'badge.background' // Badge background color. Badges are small information labels, e.g. for search results count. +'badge.foreground' // Badge foreground color. Badges are small information labels, e.g. for search results count. +'scrollbar.shadow' // Scrollbar shadow to indicate that the view is scrolled. +'scrollbarSlider.background' // Slider background color. +'scrollbarSlider.hoverBackground' // Slider background color when hovering. +'scrollbarSlider.activeBackground' // Slider background color when active. +'progressBar.background' // Background color of the progress bar that can show for long running operations. +'editor.background' // Editor background color. +'editor.foreground' // Editor default foreground color. +'editorWidget.background' // Background color of editor widgets, such as find/replace. +'editorWidget.border' // Border color of editor widgets. The color is only used if the widget chooses to have a border and if the color is not overridden by a widget. +'editor.selectionBackground' // Color of the editor selection. +'editor.selectionForeground' // Color of the selected text for high contrast. +'editor.inactiveSelectionBackground' // Color of the selection in an inactive editor. +'editor.selectionHighlightBackground' // Color for regions with the same content as the selection. +'editor.findMatchBackground' // Color of the current search match. +'editor.findMatchHighlightBackground' // Color of the other search matches. +'editor.findRangeHighlightBackground' // Color the range limiting the search. +'editor.hoverHighlightBackground' // Highlight below the word for which a hover is shown. +'editorHoverWidget.background' // Background color of the editor hover. +'editorHoverWidget.border' // Border color of the editor hover. +'editorLink.activeForeground' // Color of active links. +'diffEditor.insertedTextBackground' // Background color for text that got inserted. +'diffEditor.removedTextBackground' // Background color for text that got removed. +'diffEditor.insertedTextBorder' // Outline color for the text that got inserted. +'diffEditor.removedTextBorder' // Outline color for text that got removed. +'merge.currentHeaderBackground' // Current header background in inline merge-conflicts. +'merge.currentContentBackground' // Current content background in inline merge-conflicts. +'merge.incomingHeaderBackground' // Incoming header background in inline merge-conflicts. +'merge.incomingContentBackground' // Incoming content background in inline merge-conflicts. +'merge.commonHeaderBackground' // Common ancestor header background in inline merge-conflicts. +'merge.commonContentBackground' // Common ancester content background in inline merge-conflicts. +'merge.border' // Border color on headers and the splitter in inline merge-conflicts. +'editorOverviewRuler.currentContentForeground' // Current overview ruler foreground for inline merge-conflicts. +'editorOverviewRuler.incomingContentForeground' // Incoming overview ruler foreground for inline merge-conflicts. +'editorOverviewRuler.commonContentForeground' // Common ancestor overview ruler foreground for inline merge-conflicts. +'editor.lineHighlightBackground' // Background color for the highlight of line at the cursor position. +'editor.lineHighlightBorder' // Background color for the border around the line at the cursor position. +'editor.rangeHighlightBackground' // Background color of highlighted ranges, like by quick open and find features. +'editorCursor.foreground' // Color of the editor cursor. +'editorWhitespace.foreground' // Color of whitespace characters in the editor. +'editorIndentGuide.background' // Color of the editor indentation guides. +'editorLineNumber.foreground' // Color of editor line numbers. +'editorRuler.foreground' // Color of the editor rulers. +'editorCodeLens.foreground' // Foreground color of editor code lenses +'editorBracketMatch.background' // Background color behind matching brackets +'editorBracketMatch.border' // Color for matching brackets boxes +'editorOverviewRuler.border' // Color of the overview ruler border. +'editorGutter.background' // Background color of the editor gutter. The gutter contains the glyph margins and the line numbers. +'editorError.foreground' // Foreground color of error squigglies in the editor. +'editorError.border' // Border color of error squigglies in the editor. +'editorWarning.foreground' // Foreground color of warning squigglies in the editor. +'editorWarning.border' // Border color of warning squigglies in the editor. +'editorMarkerNavigationError.background' // Editor marker navigation widget error color. +'editorMarkerNavigationWarning.background' // Editor marker navigation widget warning color. +'editorMarkerNavigation.background' // Editor marker navigation widget background. +'editorSuggestWidget.background' // Background color of the suggest widget. +'editorSuggestWidget.border' // Border color of the suggest widget. +'editorSuggestWidget.foreground' // Foreground color of the suggest widget. +'editorSuggestWidget.selectedBackground' // Background color of the selected entry in the suggest widget. +'editorSuggestWidget.highlightForeground' // Color of the match highlights in the suggest widget. +'editor.wordHighlightBackground' // Background color of a symbol during read-access, like reading a variable. +'editor.wordHighlightStrongBackground' // Background color of a symbol during write-access, like writing to a variable. +'peekViewTitle.background' // Background color of the peek view title area. +'peekViewTitleLabel.foreground' // Color of the peek view title. +'peekViewTitleDescription.foreground' // Color of the peek view title info. +'peekView.border' // Color of the peek view borders and arrow. +'peekViewResult.background' // Background color of the peek view result list. +'peekViewResult.lineForeground' // Foreground color for line nodes in the peek view result list. +'peekViewResult.fileForeground' // Foreground color for file nodes in the peek view result list. +'peekViewResult.selectionBackground' // Background color of the selected entry in the peek view result list. +'peekViewResult.selectionForeground' // Foreground color of the selected entry in the peek view result list. +'peekViewEditor.background' // Background color of the peek view editor. +'peekViewEditorGutter.background' // Background color of the gutter in the peek view editor. +'peekViewResult.matchHighlightBackground' // Match highlight color in the peek view result list. +'peekViewEditor.matchHighlightBackground' // Match highlight color in the peek view editor. + +/* +var colors = require('vs/platform/registry/common/platform').Registry.data['base.contributions.colors'].colorSchema.properties +Object.keys(colors).forEach(function(key) { + var val = colors[key]; + console.log( '//' + val.description + '\n' + key); +}) +*/ \ No newline at end of file diff --git a/website/playground/new-samples/customizing-the-appearence/exposed-css-classes/sample.css b/website/playground/new-samples/customizing-the-appearence/exposed-css-classes/sample.css deleted file mode 100644 index 960a97b0..00000000 --- a/website/playground/new-samples/customizing-the-appearence/exposed-css-classes/sample.css +++ /dev/null @@ -1,32 +0,0 @@ -.monaco-editor, .monaco-editor-background { - background: #EDF9FA; -} - -/* Cursor */ -.monaco-editor .cursor { - background: darkred !important; -} - -/* Current line */ -.monaco-editor .current-line { - background: rgba(0, 0, 255, 0.1); -} - -/* Line Numbers */ -.monaco-editor .line-numbers { - background-color: #EDF9FA; - color: green; -} - -/* Line Decorations */ -.monaco-editor .lines-decorations { - background-color: #EDF9FA; -} - -/* Selection */ -.monaco-editor .view-overlays.focused .selected-text { - background: rgba(128, 0, 0, 0.2) !important; -} -.monaco-editor .view-overlays .selected-text { - background: rgba(128, 0, 0, 0.1) !important; -} diff --git a/website/playground/new-samples/customizing-the-appearence/exposed-css-classes/sample.js b/website/playground/new-samples/customizing-the-appearence/exposed-css-classes/sample.js deleted file mode 100644 index fe66f639..00000000 --- a/website/playground/new-samples/customizing-the-appearence/exposed-css-classes/sample.js +++ /dev/null @@ -1,7 +0,0 @@ -// The editor exposes a set of CSS classes that can be overwritten. -monaco.editor.create(document.getElementById("container"), { - value: "My to-do list:\n* buy milk\n* buy coffee\n* write awesome code", - language: "text/plain", - fontFamily: "Arial", - fontSize: 20 -}); diff --git a/website/playground/new-samples/interacting-with-the-editor/adding-an-action-to-an-editor-instance/sample.js b/website/playground/new-samples/interacting-with-the-editor/adding-an-action-to-an-editor-instance/sample.js index db20fe3d..2993571b 100644 --- a/website/playground/new-samples/interacting-with-the-editor/adding-an-action-to-an-editor-instance/sample.js +++ b/website/playground/new-samples/interacting-with-the-editor/adding-an-action-to-an-editor-instance/sample.js @@ -13,9 +13,6 @@ var editor = monaco.editor.create(document.getElementById("container"), { }); // Explanation: -// Try right clicking on an identifier or keyword => the action will be enabled (due to `tokensAtPosition`) -// Try right clicking on a string => the action will be disabled (due to `tokensAtPosition`) -// Try right clicking on whitespace => the action will be disabled (due to `wordAtPosition`) // Press F1 (Alt-F1 in IE) => the action will appear and run if it is enabled // Press Ctrl-F10 => the action will run if it is enabled @@ -29,6 +26,10 @@ editor.addAction({ // An optional array of keybindings for the action. keybindings: [monaco.KeyMod.CtrlCmd | monaco.KeyCode.F10], + // A precondition for this action. + precondition: null, + + // A rule to evaluate on top of the precondition in order to dispatch the keybindings. keybindingContext: null, contextMenuGroupId: 'navigation', diff --git a/website/playground/playground.js b/website/playground/playground.js index 1c291d29..e6481283 100644 --- a/website/playground/playground.js +++ b/website/playground/playground.js @@ -262,7 +262,10 @@ function load() { data.html.model = monaco.editor.createModel('html', 'html'); editor = monaco.editor.create(editorContainer, { - model: data.js.model + model: data.js.model, + minimap: { + enabled: false + } }); var currentToken = 0;