From 3c875c4ac9df3a4111a9c34e803b515892c0f80d Mon Sep 17 00:00:00 2001 From: Alex Dima Date: Wed, 18 Jan 2017 18:29:26 +0100 Subject: [PATCH] Prep for 0.8.0 --- CHANGELOG.md | 53 ++ gulpfile.js | 20 +- metadata.js | 3 + monaco.d.ts | 1151 +++++++++++++++------------- package.json | 12 +- website/playground/monaco.d.ts.txt | 1151 +++++++++++++++------------- 6 files changed, 1274 insertions(+), 1116 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dce0db35..39e6659e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,58 @@ # Monaco Editor Change log +## [0.8.0] + - This release has been brewing for a while and comes with quite a number of important changes. + +### No longer supporting IE9 and IE10 + - we have not made the editor fail on purpose in these browsers, but we have removed IE9/IE10 targeted workarounds from our codebase; + - now using **Typed Arrays** in a number of key places resulting in considerable speed boosts and lower memory consumption. + +### Monarch Tokenizer + - Monarch states are now memoized up to a depth of 5. This results in considerable memory improvements for files with many lines. + - Speed improvements to Monarch tokenizer that resulted in one breaking change: + - when entering an embedded mode (i.e. `nextEmbedded`), the state ending up in must immediately contain a `nextEmbedded: "@pop"` rule. This helps in quickly figuring out where the embedded mode should be left. The editor will throw an error if the Monarch grammar does not respect this condition. + +### Tokens are styled in JS (not in CSS anymore) + - This is a breaking change + - Before, token types would be rendered on the `span` node of text, and CSS rules would match token types and assign styling to them (i.e. color, boldness, etc.to style tokens) + - To enable us to build something like a minimap, we need to know the text color in JavaScript, and we have therefore moved the token style matching all to JavaScript. In the future, we foresee that even decorations will have to define their color in JavaScript. + - It is possible to create a custom theme via a new API method `monaco.editor.defineTheme()` and the playground contains a sample showing how that works. + - Token types can be inspected via `F1` > `Developer: Inspect tokens`. This will bring up a widget showing the token type and the applied styles. + +### API changes: + +#### Namespaces + - added `monaco.editor.onDidCreateEditor` that will be fired whenever an editor is created (will fire even for a diff editor, with the two editors that a diff editor consists of). + - added `monaco.editor.tokenize` that returns logical tokens (before theme matching, as opposed to `monaco.editor.colorize`). + - added `monaco.languages.registerTypeDefinitionProvider` + +#### Models + - removed `IModel.getMode()`. + - structural changes in the events `IModelLanguageChangedEvent`, `IModelDecorationsChangedEvent` and `IModelTokensChangedEvent`; + - changed `IModel.findMatches`, `IModel.findNextMatch` and `IModel.findPreviousMatch` to be able to capture matches while searching. + +#### Editors + - `ICodeEditor.addAction` and `IDiffEditor.addAction` now return an `IDisposable` to be able to remove a previously added action. + - renamed `ICodeEditor.onDidChangeModelMode ` to `ICodeEditor.onDidChangeModelLanguage`; + - `ICodeEditor.executeEdits` can now take resulting selection for better undo/redo stack management; + - added `ICodeEditor.getTargetAtClientPoint(clientX, clientY)` to be able to do hit testing. + - added `IViewZone.marginDomNode` to be able to insert a dom node in the margin side of a view zone. + - settings: + - `lineDecorationsWidth` can now take a value in the form of `"1.2ch"` besides the previous accepted number (in px) + - `renderLineHighlight` can now take a value in the set `'none' | 'gutter' | 'line' | 'all'`. + - added `fixedOverflowWidgets` to render overflowing content widgets as `'fixed'` (defaults to false) + - added `acceptSuggestionOnCommitCharacter` to accept suggestions on provider defined characters (defaults to true) + - added `emptySelectionClipboard` - copying without a selection copies the current line (defaults to true) + - added `suggestFontSize` - the font size for the suggest widget + - added `suggestLineHeight` - the line height for the suggest widget + - diff editor settings: + - added `renderIndicators` - Render +/- indicators for added/deleted changes. (defaults to true) + +### Thank you + * [Nico Tonozzi (@nicot)](https://github.com/nicot): Register React file extensions [PR monaco-typescript#12](https://github.com/Microsoft/monaco-typescript/pull/12) + * [Jeong Woo Chang (@inspiredjw)](https://github.com/inspiredjw): Cannot read property 'uri' of null fix [PR vscode#13263](https://github.com/Microsoft/vscode/pull/13263) + * [Jan Pilzer(@Hirse)](https://github.com/Hirse): Add YAML samples [PR monaco-editor#242](https://github.com/Microsoft/monaco-editor/pull/242) + ## [0.7.1] - Bugfixes in monaco-html, including fixing formatting. diff --git a/gulpfile.js b/gulpfile.js index a0083ca8..f3e54219 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -178,14 +178,6 @@ function addPluginDTS() { // Ensure consistent indentation and line endings contents = cleanFile(contents); - // Mark events in doc!! - contents = contents.replace(/( \*\/\n\s+)on(.*IDisposable)/gm, function(_, m0, m1) { - var m = m0.match(/( +)$/); - var indentation = m[1]; - return ' * @event\n' + indentation + ' */\n' + indentation + 'on' + m1; - }); - - data.contents = new Buffer(contents); fs.writeFileSync('website/playground/monaco.d.ts.txt', contents); @@ -226,14 +218,14 @@ function addPluginThirdPartyNotices() { var extraContent = []; metadata.METADATA.PLUGINS.forEach(function(plugin) { - var thirdPartyNoticePath = path.join(path.dirname(plugin.paths.npm), 'ThirdPartyNotices.txt'); - try { - var thirdPartyNoticeContent = fs.readFileSync(thirdPartyNoticePath).toString(); - thirdPartyNoticeContent = thirdPartyNoticeContent.split('\n').slice(8).join('\n'); - extraContent.push(thirdPartyNoticeContent); - } catch (err) { + if (!plugin.thirdPartyNotices) { return; } + + console.log('ADDING ThirdPartyNotices from ' + plugin.thirdPartyNotices); + var thirdPartyNoticeContent = fs.readFileSync(plugin.thirdPartyNotices).toString(); + thirdPartyNoticeContent = thirdPartyNoticeContent.split('\n').slice(8).join('\n'); + extraContent.push(thirdPartyNoticeContent); }); contents += '\n' + extraContent.join('\n'); diff --git a/metadata.js b/metadata.js index a6eba6c5..1ad84211 100644 --- a/metadata.js +++ b/metadata.js @@ -15,6 +15,7 @@ name: 'monaco-typescript', contrib: 'vs/language/typescript/src/monaco.contribution', modulePrefix: 'vs/language/typescript', + thirdPartyNotices: 'node_modules/monaco-typescript/ThirdPartyNotices.txt', paths: { npm: 'node_modules/monaco-typescript/release', dev: '/monaco-typescript/out' @@ -39,6 +40,7 @@ name: 'monaco-html', contrib: 'vs/language/html/monaco.contribution', modulePrefix: 'vs/language/html', + thirdPartyNotices: 'node_modules/monaco-html/ThirdPartyNotices.txt', paths: { npm: 'node_modules/monaco-html/release/min', dev: '/monaco-html/release/dev' @@ -47,6 +49,7 @@ name: 'monaco-languages', contrib: 'vs/basic-languages/src/monaco.contribution', modulePrefix: 'vs/basic-languages', + thirdPartyNotices: 'node_modules/monaco-languages/ThirdPartyNotices.txt', paths: { npm: 'node_modules/monaco-languages/release', dev: '/monaco-languages/out' diff --git a/monaco.d.ts b/monaco.d.ts index 880c51e8..dba76168 100644 --- a/monaco.d.ts +++ b/monaco.d.ts @@ -5,15 +5,15 @@ *-----------------------------------------------------------*/ declare module monaco { - interface Thenable { + interface Thenable { /** * Attaches callbacks for the resolution and/or rejection of the Promise. * @param onfulfilled The callback to execute when the Promise is resolved. * @param onrejected The callback to execute when the Promise is rejected. * @returns A Promise for the completion of which ever callback is executed. */ - then(onfulfilled?: (value: R) => TResult | Thenable, onrejected?: (reason: any) => TResult | Thenable): Thenable; - then(onfulfilled?: (value: R) => TResult | Thenable, onrejected?: (reason: any) => void): Thenable; + then(onfulfilled?: (value: T) => TResult | Thenable, onrejected?: (reason: any) => TResult | Thenable): Thenable; + then(onfulfilled?: (value: T) => TResult | Thenable, onrejected?: (reason: any) => void): Thenable; } export interface IDisposable { @@ -29,7 +29,7 @@ declare module monaco { */ export class Emitter { constructor(); - event: IEvent; + readonly event: IEvent; fire(event?: T): void; dispose(): void; } @@ -100,8 +100,12 @@ declare module monaco { } export interface CancellationToken { - isCancellationRequested: boolean; - onCancellationRequested: IEvent; + readonly isCancellationRequested: boolean; + /** + * An event emitted when cancellation is requested + * @event + */ + readonly onCancellationRequested: IEvent; } /** * Uniform Resource Identifier (Uri) http://tools.ietf.org/html/rfc3986. @@ -352,62 +356,74 @@ declare module monaco { } export class KeyMod { - static CtrlCmd: number; - static Shift: number; - static Alt: number; - static WinCtrl: number; + static readonly CtrlCmd: number; + static readonly Shift: number; + static readonly Alt: number; + static readonly WinCtrl: number; static chord(firstPart: number, secondPart: number): number; } + + export class Keybinding { + value: number; + constructor(keybinding: number); + equals(other: Keybinding): boolean; + hasCtrlCmd(): boolean; + hasShift(): boolean; + hasAlt(): boolean; + hasWinCtrl(): boolean; + isModifierKey(): boolean; + getKeyCode(): KeyCode; + } /** * MarkedString can be used to render human readable text. It is either a markdown string * or a code-block that provides a language and a code snippet. Note that * markdown strings will be sanitized - that means html will be escaped. */ export type MarkedString = string | { - language: string; - value: string; + readonly language: string; + readonly value: string; }; export interface IKeyboardEvent { - browserEvent: KeyboardEvent; - target: HTMLElement; - ctrlKey: boolean; - shiftKey: boolean; - altKey: boolean; - metaKey: boolean; - keyCode: KeyCode; - asKeybinding(): number; + readonly browserEvent: KeyboardEvent; + readonly target: HTMLElement; + readonly ctrlKey: boolean; + readonly shiftKey: boolean; + readonly altKey: boolean; + readonly metaKey: boolean; + readonly keyCode: KeyCode; + toKeybinding(): Keybinding; equals(keybinding: number): boolean; preventDefault(): void; stopPropagation(): void; } export interface IMouseEvent { - browserEvent: MouseEvent; - leftButton: boolean; - middleButton: boolean; - rightButton: boolean; - target: HTMLElement; - detail: number; - posx: number; - posy: number; - ctrlKey: boolean; - shiftKey: boolean; - altKey: boolean; - metaKey: boolean; - timestamp: number; + readonly browserEvent: MouseEvent; + readonly leftButton: boolean; + readonly middleButton: boolean; + readonly rightButton: boolean; + readonly target: HTMLElement; + readonly detail: number; + readonly posx: number; + readonly posy: number; + readonly ctrlKey: boolean; + readonly shiftKey: boolean; + readonly altKey: boolean; + readonly metaKey: boolean; + readonly timestamp: number; preventDefault(): void; stopPropagation(): void; } export interface IScrollEvent { - scrollTop: number; - scrollLeft: number; - scrollWidth: number; - scrollHeight: number; - scrollTopChanged: boolean; - scrollLeftChanged: boolean; - scrollWidthChanged: boolean; - scrollHeightChanged: boolean; + readonly scrollTop: number; + readonly scrollLeft: number; + readonly scrollWidth: number; + readonly scrollHeight: number; + readonly scrollTopChanged: boolean; + readonly scrollLeftChanged: boolean; + readonly scrollWidthChanged: boolean; + readonly scrollHeightChanged: boolean; } /** @@ -417,11 +433,11 @@ declare module monaco { /** * line number (starts at 1) */ - lineNumber: number; + readonly lineNumber: number; /** * column (the first character in a line is between column 1 and column 2) */ - column: number; + readonly column: number; } /** @@ -431,19 +447,19 @@ declare module monaco { /** * Line number on which the range starts (starts at 1). */ - startLineNumber: number; + readonly startLineNumber: number; /** * Column on which the range starts in line `startLineNumber` (starts at 1). */ - startColumn: number; + readonly startColumn: number; /** * Line number on which the range ends. */ - endLineNumber: number; + readonly endLineNumber: number; /** * Column on which the range ends in line `endLineNumber`. */ - endColumn: number; + readonly endColumn: number; } /** @@ -454,19 +470,19 @@ declare module monaco { /** * The line number on which the selection has started. */ - selectionStartLineNumber: number; + readonly selectionStartLineNumber: number; /** * The column on `selectionStartLineNumber` where the selection has started. */ - selectionStartColumn: number; + readonly selectionStartColumn: number; /** * The line number on which the selection has ended. */ - positionLineNumber: number; + readonly positionLineNumber: number; /** * The column on `positionLineNumber` where the selection has ended. */ - positionColumn: number; + readonly positionColumn: number; } /** @@ -476,11 +492,11 @@ declare module monaco { /** * line number (starts at 1) */ - lineNumber: number; + readonly lineNumber: number; /** * column (the first character in a line is between column 1 and column 2) */ - column: number; + readonly column: number; constructor(lineNumber: number, column: number); /** * Test if this position equals other position @@ -510,6 +526,10 @@ declare module monaco { * If the two positions are equal, the result will be true. */ static isBeforeOrEqual(a: IPosition, b: IPosition): boolean; + /** + * A function that compares positions, useful for sorting + */ + static compare(a: IPosition, b: IPosition): number; /** * Clone this position. */ @@ -535,19 +555,19 @@ declare module monaco { /** * Line number on which the range starts (starts at 1). */ - startLineNumber: number; + readonly startLineNumber: number; /** * Column on which the range starts in line `startLineNumber` (starts at 1). */ - startColumn: number; + readonly startColumn: number; /** * Line number on which the range ends. */ - endLineNumber: number; + readonly endLineNumber: number; /** * Column on which the range ends in line `endLineNumber`. */ - endColumn: number; + readonly endColumn: number; constructor(startLineNumber: number, startColumn: number, endLineNumber: number, endColumn: number); /** * Test if this range is empty. @@ -667,19 +687,19 @@ declare module monaco { /** * The line number on which the selection has started. */ - selectionStartLineNumber: number; + readonly selectionStartLineNumber: number; /** * The column on `selectionStartLineNumber` where the selection has started. */ - selectionStartColumn: number; + readonly selectionStartColumn: number; /** * The line number on which the selection has ended. */ - positionLineNumber: number; + readonly positionLineNumber: number; /** * The column on `positionLineNumber` where the selection has ended. */ - positionColumn: number; + readonly positionColumn: number; constructor(selectionStartLineNumber: number, selectionStartColumn: number, positionLineNumber: number, positionColumn: number); /** * Clone this selection. @@ -740,6 +760,15 @@ declare module monaco { */ RTL = 1, } + + export class Token { + _tokenBrand: void; + readonly offset: number; + readonly type: string; + readonly language: string; + constructor(offset: number, type: string, language: string); + toString(): string; + } } declare module monaco.editor { @@ -752,6 +781,13 @@ declare module monaco.editor { */ export function create(domElement: HTMLElement, options?: IEditorConstructionOptions, override?: IEditorOverrideServices): IStandaloneCodeEditor; + /** + * Emitted when an editor is created. + * Creating a diff editor might cause this listener to be invoked with the two editors. + * @event + */ + export function onDidCreateEditor(listener: (codeEditor: ICodeEditor) => void): IDisposable; + /** * Create a new diff editor under `domElement`. * `domElement` should be empty (not contain other dom nodes). @@ -767,9 +803,9 @@ declare module monaco.editor { } export interface IDiffNavigatorOptions { - followsCaret?: boolean; - ignoreCharChanges?: boolean; - alwaysRevealFirst?: boolean; + readonly followsCaret?: boolean; + readonly ignoreCharChanges?: boolean; + readonly alwaysRevealFirst?: boolean; } export function createDiffNavigator(diffEditor: IStandaloneDiffEditor, opts?: IDiffNavigatorOptions): IDiffNavigator; @@ -802,20 +838,23 @@ declare module monaco.editor { /** * Emitted when a model is created. + * @event */ export function onDidCreateModel(listener: (model: IModel) => void): IDisposable; /** * Emitted right before a model is disposed. + * @event */ export function onWillDisposeModel(listener: (model: IModel) => void): IDisposable; /** * Emitted when a different language is set to a model. + * @event */ export function onDidChangeModelLanguage(listener: (e: { - model: IModel; - oldLanguage: string; + readonly model: IModel; + readonly oldLanguage: string; }) => void): IDisposable; /** @@ -839,6 +878,31 @@ declare module monaco.editor { */ export function colorizeModelLine(model: IModel, lineNumber: number, tabSize?: number): string; + /** + * Tokenize `text` using language `languageId` + */ + export function tokenize(text: string, languageId: string): Token[][]; + + /** + * Define a new theme. + */ + export function defineTheme(themeName: string, themeData: ITheme): void; + + export type BuiltinTheme = 'vs' | 'vs-dark' | 'hc-black'; + + export interface ITheme { + base: BuiltinTheme; + inherit: boolean; + rules: IThemeRule[]; + } + + export interface IThemeRule { + token: string; + foreground?: string; + background?: string; + fontStyle?: string; + } + /** * A web worker that can provide a proxy to an arbitrary file. */ @@ -899,13 +963,13 @@ declare module monaco.editor { export interface IStandaloneCodeEditor extends ICodeEditor { addCommand(keybinding: number, handler: ICommandHandler, context: string): string; createContextKey(key: string, defaultValue: T): IContextKey; - addAction(descriptor: IActionDescriptor): void; + addAction(descriptor: IActionDescriptor): IDisposable; } export interface IStandaloneDiffEditor extends IDiffEditor { addCommand(keybinding: number, handler: ICommandHandler, context: string): string; createContextKey(key: string, defaultValue: T): IContextKey; - addAction(descriptor: IActionDescriptor): void; + addAction(descriptor: IActionDescriptor): IDisposable; } export interface ICommandHandler { (...args: any[]): void; @@ -949,16 +1013,6 @@ declare module monaco.editor { Visible = 3, } - export interface IAction extends IDisposable { - id: string; - label: string; - tooltip: string; - class: string; - enabled: boolean; - checked: boolean; - run(event?: any): Promise; - } - /** * Configuration options for editor scrollbars */ @@ -1090,15 +1144,16 @@ declare module monaco.editor { lineNumbersMinChars?: number; /** * Enable the rendering of the glyph margin. - * Defaults to false. + * 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; + 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. @@ -1111,10 +1166,9 @@ declare module monaco.editor { */ roundedSelection?: boolean; /** - * Theme to be used for rendering. Consists of two parts, the UI theme and the syntax theme, - * separated by a space. - * The current available UI themes are: 'vs' (default), 'vs-dark', 'hc-black' - * The syntax themes are contributed. The default is 'default-theme' + * 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; /** @@ -1126,6 +1180,11 @@ declare module monaco.editor { * 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. @@ -1188,7 +1247,7 @@ declare module monaco.editor { wordWrap?: boolean; /** * Control indentation of wrapped lines. Can be: 'none', 'same' or 'indent'. - * Defaults to 'none'. + * Defaults to 'same' in vscode and to 'none' in monaco-editor. */ wrappingIndent?: string; /** @@ -1266,10 +1325,19 @@ declare module monaco.editor { * 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' */ @@ -1278,6 +1346,16 @@ declare module monaco.editor { * 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. @@ -1290,7 +1368,7 @@ declare module monaco.editor { codeLens?: boolean; /** * Enable code folding - * Defaults to true. + * Defaults to true in vscode and to false in monaco-editor. */ folding?: boolean; /** @@ -1310,9 +1388,9 @@ declare module monaco.editor { renderIndentGuides?: boolean; /** * Enable rendering of current line highlight. - * Defaults to true. + * Defaults to all. */ - renderLineHighlight?: boolean; + renderLineHighlight?: 'none' | 'gutter' | 'line' | 'all'; /** * Inserting and deleting whitespace follows tab stops. */ @@ -1354,6 +1432,11 @@ declare module monaco.editor { * Defaults to true. */ ignoreTrimWhitespace?: boolean; + /** + * Render +/- indicators for added/deleted changes. + * Defaults to true. + */ + renderIndicators?: boolean; /** * Original model should be editable? * Defaults to false. @@ -1362,140 +1445,146 @@ declare module monaco.editor { } export class InternalEditorScrollbarOptions { - _internalEditorScrollbarOptionsBrand: void; - arrowSize: number; - vertical: ScrollbarVisibility; - horizontal: ScrollbarVisibility; - useShadows: boolean; - verticalHasArrows: boolean; - horizontalHasArrows: boolean; - handleMouseWheel: boolean; - horizontalScrollbarSize: number; - horizontalSliderSize: number; - verticalScrollbarSize: number; - verticalSliderSize: number; - mouseWheelScrollSensitivity: number; + 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 { - _editorWrappingInfoBrand: void; - isViewportWrapping: boolean; - wrappingColumn: number; - wrappingIndent: WrappingIndent; - wordWrapBreakBeforeCharacters: string; - wordWrapBreakAfterCharacters: string; - wordWrapBreakObtrusiveCharacters: string; + readonly _editorWrappingInfoBrand: void; + readonly isViewportWrapping: boolean; + readonly wrappingColumn: number; + readonly wrappingIndent: WrappingIndent; + readonly wordWrapBreakBeforeCharacters: string; + readonly wordWrapBreakAfterCharacters: string; + readonly wordWrapBreakObtrusiveCharacters: string; } export class InternalEditorViewOptions { - _internalEditorViewOptionsBrand: void; - theme: string; - canUseTranslate3d: boolean; - experimentalScreenReader: boolean; - rulers: number[]; - ariaLabel: string; - renderLineNumbers: boolean; - renderCustomLineNumbers: (lineNumber: number) => string; - renderRelativeLineNumbers: boolean; - selectOnLineNumbers: boolean; - glyphMargin: boolean; - revealHorizontalRightPadding: number; - roundedSelection: boolean; - overviewRulerLanes: number; - cursorBlinking: TextEditorCursorBlinkingStyle; - mouseWheelZoom: boolean; - cursorStyle: TextEditorCursorStyle; - hideCursorInOverviewRuler: boolean; - scrollBeyondLastLine: boolean; - editorClassName: string; - stopRenderingLineAfter: number; - renderWhitespace: 'none' | 'boundary' | 'all'; - renderControlCharacters: boolean; - renderIndentGuides: boolean; - renderLineHighlight: boolean; - scrollbar: InternalEditorScrollbarOptions; + readonly _internalEditorViewOptionsBrand: void; + readonly theme: string; + readonly canUseTranslate3d: 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 { - theme: boolean; - canUseTranslate3d: boolean; - experimentalScreenReader: boolean; - rulers: boolean; - ariaLabel: boolean; - renderLineNumbers: boolean; - renderCustomLineNumbers: boolean; - renderRelativeLineNumbers: boolean; - selectOnLineNumbers: boolean; - glyphMargin: boolean; - revealHorizontalRightPadding: boolean; - roundedSelection: boolean; - overviewRulerLanes: boolean; - cursorBlinking: boolean; - mouseWheelZoom: boolean; - cursorStyle: boolean; - hideCursorInOverviewRuler: boolean; - scrollBeyondLastLine: boolean; - editorClassName: boolean; - stopRenderingLineAfter: boolean; - renderWhitespace: boolean; - renderControlCharacters: boolean; - renderIndentGuides: boolean; - renderLineHighlight: boolean; - scrollbar: boolean; + readonly theme: boolean; + readonly canUseTranslate3d: 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 { - selectionClipboard: boolean; - hover: boolean; - contextmenu: boolean; - quickSuggestions: boolean; - quickSuggestionsDelay: number; - parameterHints: boolean; - iconsInSuggestions: boolean; - formatOnType: boolean; - suggestOnTriggerCharacters: boolean; - acceptSuggestionOnEnter: boolean; - snippetSuggestions: 'top' | 'bottom' | 'inline' | 'none'; - tabCompletion: boolean; - wordBasedSuggestions: boolean; - selectionHighlight: boolean; - codeLens: boolean; - folding: boolean; + 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 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 { - _internalEditorOptionsBrand: void; - lineHeight: number; - readOnly: boolean; - wordSeparators: string; - autoClosingBrackets: boolean; - useTabStops: boolean; - tabFocusMode: boolean; - layoutInfo: EditorLayoutInfo; - fontInfo: FontInfo; - viewInfo: InternalEditorViewOptions; - wrappingInfo: EditorWrappingInfo; - contribInfo: EditorContribOptions; + 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 { - lineHeight: boolean; - readOnly: boolean; - wordSeparators: boolean; - autoClosingBrackets: boolean; - useTabStops: boolean; - tabFocusMode: boolean; - layoutInfo: boolean; - fontInfo: boolean; - viewInfo: IViewConfigurationChangedEvent; - wrappingInfo: boolean; - contribInfo: boolean; + 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; } /** @@ -1541,6 +1630,10 @@ declare module monaco.editor { * CSS class name describing the decoration. */ className?: string; + /** + * Message to be rendered when hovering over the glyph margin decoration. + */ + glyphMarginHoverMessage?: MarkedString | MarkedString[]; /** * Array of MarkedString to render as the decoration message. */ @@ -1565,6 +1658,10 @@ declare module monaco.editor { * If set, the decoration will be rendered in the lines decorations with this CSS class name. */ linesDecorationsClassName?: string; + /** + * If set, the decoration will be rendered in the margin (covering its full width) with this CSS class name. + */ + marginClassName?: string; /** * If set, the decoration will be rendered inline with the text with this CSS class name. * Please use this only for CSS rules that must impact the text. For example, use `className` @@ -1602,19 +1699,23 @@ declare module monaco.editor { /** * Identifier for a decoration. */ - id: string; + readonly id: string; /** * Identifier for a decoration's owener. */ - ownerId: number; + readonly ownerId: number; /** * Range that this decoration covers. */ - range: Range; + readonly range: Range; /** * Options associated with this decoration. */ - options: IModelDecorationOptions; + readonly options: IModelDecorationOptions; + /** + * A flag describing if this is a problem decoration (e.g. warning/error). + */ + readonly isForValidation: boolean; } /** @@ -1624,15 +1725,15 @@ declare module monaco.editor { /** * The word. */ - word: string; + readonly word: string; /** * The column where the word starts. */ - startColumn: number; + readonly startColumn: number; /** * The column where the word ends. */ - endColumn: number; + readonly endColumn: number; } /** @@ -1682,7 +1783,7 @@ declare module monaco.editor { } /** - * And identifier for a single edit operation. + * An identifier for a single edit operation. */ export interface ISingleEditOperationIdentifier { /** @@ -1810,11 +1911,12 @@ declare module monaco.editor { (inverseEditOperations: IIdentifiedSingleEditOperation[]): Selection[]; } - export interface ITextModelResolvedOptions { - tabSize: number; - insertSpaces: boolean; - defaultEOL: DefaultEndOfLine; - trimAutoWhitespace: boolean; + export class TextModelResolvedOptions { + _textModelResolvedOptionsBrand: void; + readonly tabSize: number; + readonly insertSpaces: boolean; + readonly defaultEOL: DefaultEndOfLine; + readonly trimAutoWhitespace: boolean; } export interface ITextModelUpdateOptions { @@ -1824,16 +1926,16 @@ declare module monaco.editor { } export interface IModelOptionsChangedEvent { - tabSize: boolean; - insertSpaces: boolean; - trimAutoWhitespace: boolean; + readonly tabSize: boolean; + readonly insertSpaces: boolean; + readonly trimAutoWhitespace: boolean; } /** * A textual read-only model. */ export interface ITextModel { - getOptions(): ITextModelResolvedOptions; + getOptions(): TextModelResolvedOptions; /** * Get the current version id of the model. * Anytime a change happens to the model (even undo/redo), @@ -1850,10 +1952,6 @@ declare module monaco.editor { * Replace the entire text buffer value contained in this model. */ setValue(newValue: string): void; - /** - * Replace the entire text buffer value contained in this model. - */ - setValueFromRawText(newValue: IRawText): void; /** * Get the text stored in this model. * @param eol The end of line character preference. Defaults to `EndOfLinePreference.TextDefined`. @@ -1865,14 +1963,6 @@ declare module monaco.editor { * Get the length of the text stored in this model. */ getValueLength(eol?: EndOfLinePreference, preserveBOM?: boolean): number; - /** - * Get the raw text stored in this model. - */ - toRawText(): IRawText; - /** - * Check if the raw text stored in this model equals another raw text. - */ - equals(other: IRawText): boolean; /** * Get the text in a certain range. * @param range The range describing what text to get. @@ -1975,10 +2065,11 @@ declare module monaco.editor { * @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 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, limitResultCount?: number): Range[]; + findMatches(searchString: string, searchOnlyEditableRange: boolean, isRegex: boolean, matchCase: boolean, wholeWord: boolean, 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. @@ -1986,10 +2077,11 @@ declare module monaco.editor { * @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 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, limitResultCount?: number): Range[]; + findMatches(searchString: string, searchScope: IRange, isRegex: boolean, matchCase: boolean, wholeWord: boolean, 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. @@ -1997,9 +2089,10 @@ declare module monaco.editor { * @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 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): Range; + findNextMatch(searchString: string, searchStart: IPosition, isRegex: boolean, matchCase: boolean, wholeWord: boolean, 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. @@ -2007,16 +2100,23 @@ declare module monaco.editor { * @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 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): Range; + findPreviousMatch(searchString: string, searchStart: IPosition, isRegex: boolean, matchCase: boolean, wholeWord: boolean, captureMatches: boolean): FindMatch; + } + + export class FindMatch { + _findMatchBrand: void; + readonly range: Range; + readonly matches: string[]; } export interface IReadOnlyModel extends ITextModel { /** * Gets the resource associated with this editor model. */ - uri: Uri; + readonly uri: Uri; /** * Get the language associated with this model. */ @@ -2041,10 +2141,6 @@ declare module monaco.editor { * A model that is tokenized. */ export interface ITokenizedModel extends ITextModel { - /** - * Get the current language mode associated with the model. - */ - getMode(): languages.IMode; /** * Get the language associated with this model. */ @@ -2081,12 +2177,6 @@ declare module monaco.editor { GrowsOnlyWhenTypingAfter = 3, } - /** - * A model that can track ranges. - */ - export interface ITextModelWithTrackedRanges extends ITextModel { - } - /** * A model that can have decorations. */ @@ -2195,7 +2285,7 @@ declare module monaco.editor { /** * A model. */ - export interface IModel extends IReadOnlyModel, IEditableTextModel, ITextModelWithMarkers, ITokenizedModel, ITextModelWithTrackedRanges, ITextModelWithDecorations, IEditorModel { + export interface IModel extends IReadOnlyModel, IEditableTextModel, ITextModelWithMarkers, ITokenizedModel, ITextModelWithDecorations, IEditorModel { /** * An event emitted when the contents of the model have changed. * @event @@ -2215,7 +2305,7 @@ declare module monaco.editor { * An event emitted when the language associated with the model has changed. * @event */ - onDidChangeMode(listener: (e: IModelModeChangedEvent) => void): IDisposable; + onDidChangeLanguage(listener: (e: IModelLanguageChangedEvent) => void): IDisposable; /** * An event emitted right before disposing the model. * @event @@ -2224,7 +2314,7 @@ declare module monaco.editor { /** * A unique identifier associated with this model. */ - id: string; + readonly id: string; /** * Destroy this model. This will unbind the model from the mode * and make all necessary clean-up to release this object to the GC. @@ -2235,15 +2325,15 @@ declare module monaco.editor { /** * An event describing that the current mode associated with a model has changed. */ - export interface IModelModeChangedEvent { + export interface IModelLanguageChangedEvent { /** - * Previous mode + * Previous language */ - oldMode: languages.IMode; + readonly oldLanguage: string; /** - * New mode + * New language */ - newMode: languages.IMode; + readonly newLanguage: string; } /** @@ -2253,19 +2343,19 @@ declare module monaco.editor { /** * The range that got replaced. */ - range: IRange; + readonly range: IRange; /** * The length of the range that got replaced. */ - rangeLength: number; + readonly rangeLength: number; /** * The new text for the range. */ - text: string; + readonly text: string; /** * The (new) end-of-line character. */ - eol: string; + readonly eol: string; /** * The new version id the model has transitioned to. */ @@ -2273,63 +2363,11 @@ declare module monaco.editor { /** * Flag that indicates that this event was generated while undoing. */ - isUndoing: boolean; + readonly isUndoing: boolean; /** * Flag that indicates that this event was generated while redoing. */ - isRedoing: boolean; - } - - /** - * The raw text backing a model. - */ - export interface IRawText { - /** - * The entire text length. - */ - length: number; - /** - * The text split into lines. - */ - lines: string[]; - /** - * The BOM (leading character sequence of the file). - */ - BOM: string; - /** - * The end of line sequence. - */ - EOL: string; - /** - * The options associated with this text. - */ - options: ITextModelResolvedOptions; - } - - /** - * Decoration data associated with a model decorations changed event. - */ - export interface IModelDecorationsChangedEventDecorationData { - /** - * The id of the decoration. - */ - id: string; - /** - * The owner id of the decoration. - */ - ownerId: number; - /** - * The range of the decoration. - */ - range: IRange; - /** - * A flag describing if this is a problem decoration (e.g. warning/error). - */ - isForValidation: boolean; - /** - * The options for this decoration. - */ - options: IModelDecorationOptions; + readonly isRedoing: boolean; } /** @@ -2337,43 +2375,33 @@ declare module monaco.editor { */ export interface IModelDecorationsChangedEvent { /** - * A summary with ids of decorations that have changed. + * Lists of ids for added decorations. */ - ids: string[]; + readonly addedDecorations: string[]; /** - * Lists of details for added or changed decorations. + * Lists of ids for changed decorations. */ - addedOrChangedDecorations: IModelDecorationsChangedEventDecorationData[]; + readonly changedDecorations: string[]; /** * List of ids for removed decorations. */ - removedDecorations: string[]; - /** - * Details regarding old options. - */ - oldOptions: { - [decorationId: string]: IModelDecorationOptions; - }; - /** - * Details regarding old ranges. - */ - oldRanges: { - [decorationId: string]: IRange; - }; + readonly removedDecorations: string[]; } /** - * An event describing that a range of lines has been tokenized + * An event describing that some ranges of lines have been tokenized (their tokens have changed). */ export interface IModelTokensChangedEvent { - /** - * The start of the range (inclusive) - */ - fromLineNumber: number; - /** - * The end of the range (inclusive) - */ - toLineNumber: number; + readonly ranges: { + /** + * The start of the range (inclusive) + */ + readonly fromLineNumber: number; + /** + * The end of the range (inclusive) + */ + readonly toLineNumber: number; + }[]; } /** @@ -2417,31 +2445,31 @@ declare module monaco.editor { /** * Primary cursor's position. */ - position: Position; + readonly position: Position; /** * Primary cursor's view position */ - viewPosition: Position; + readonly viewPosition: Position; /** * Secondary cursors' position. */ - secondaryPositions: Position[]; + readonly secondaryPositions: Position[]; /** * Secondary cursors' view position. */ - secondaryViewPositions: Position[]; + readonly secondaryViewPositions: Position[]; /** * Reason. */ - reason: CursorChangeReason; + readonly reason: CursorChangeReason; /** * Source of the call that caused the event. */ - source: string; + readonly source: string; /** * Is the primary cursor in the editable range? */ - isInEditableRange: boolean; + readonly isInEditableRange: boolean; } /** @@ -2451,27 +2479,27 @@ declare module monaco.editor { /** * The primary selection. */ - selection: Selection; + readonly selection: Selection; /** * The primary selection in view coordinates. */ - viewSelection: Selection; + readonly viewSelection: Selection; /** * The secondary selections. */ - secondarySelections: Selection[]; + readonly secondarySelections: Selection[]; /** * The secondary selections in view coordinates. */ - secondaryViewSelections: Selection[]; + readonly secondaryViewSelections: Selection[]; /** * Source of the call that caused the event. */ - source: string; + readonly source: string; /** * Reason. */ - reason: CursorChangeReason; + readonly reason: CursorChangeReason; } /** @@ -2481,109 +2509,109 @@ declare module monaco.editor { /** * The `uri` of the previous model or null. */ - oldModelUrl: Uri; + readonly oldModelUrl: Uri; /** * The `uri` of the new model or null. */ - newModelUrl: Uri; + readonly newModelUrl: Uri; } /** * A description for the overview ruler position. */ export class OverviewRulerPosition { - _overviewRulerPositionBrand: void; + readonly _overviewRulerPositionBrand: void; /** * Width of the overview ruler */ - width: number; + readonly width: number; /** * Height of the overview ruler */ - height: number; + readonly height: number; /** * Top position for the overview ruler */ - top: number; + readonly top: number; /** * Right position for the overview ruler */ - right: number; + readonly right: number; } /** * The internal layout details of the editor. */ export class EditorLayoutInfo { - _editorLayoutInfoBrand: void; + readonly _editorLayoutInfoBrand: void; /** * Full editor width. */ - width: number; + readonly width: number; /** * Full editor height. */ - height: number; + readonly height: number; /** * Left position for the glyph margin. */ - glyphMarginLeft: number; + readonly glyphMarginLeft: number; /** * The width of the glyph margin. */ - glyphMarginWidth: number; + readonly glyphMarginWidth: number; /** * The height of the glyph margin. */ - glyphMarginHeight: number; + readonly glyphMarginHeight: number; /** * Left position for the line numbers. */ - lineNumbersLeft: number; + readonly lineNumbersLeft: number; /** * The width of the line numbers. */ - lineNumbersWidth: number; + readonly lineNumbersWidth: number; /** * The height of the line numbers. */ - lineNumbersHeight: number; + readonly lineNumbersHeight: number; /** * Left position for the line decorations. */ - decorationsLeft: number; + readonly decorationsLeft: number; /** * The width of the line decorations. */ - decorationsWidth: number; + readonly decorationsWidth: number; /** * The height of the line decorations. */ - decorationsHeight: number; + readonly decorationsHeight: number; /** * Left position for the content (actual text) */ - contentLeft: number; + readonly contentLeft: number; /** * The width of the content (actual text) */ - contentWidth: number; + readonly contentWidth: number; /** * The height of the content (actual height) */ - contentHeight: number; + readonly contentHeight: number; /** * The width of the vertical scrollbar. */ - verticalScrollbarWidth: number; + readonly verticalScrollbarWidth: number; /** * The height of the horizontal scrollbar. */ - horizontalScrollbarHeight: number; + readonly horizontalScrollbarHeight: number; /** * The position of the overview ruler. */ - overviewRuler: OverviewRulerPosition; + readonly overviewRuler: OverviewRulerPosition; } /** @@ -2726,43 +2754,27 @@ declare module monaco.editor { * A change */ export interface IChange { - originalStartLineNumber: number; - originalEndLineNumber: number; - modifiedStartLineNumber: number; - modifiedEndLineNumber: number; + readonly originalStartLineNumber: number; + readonly originalEndLineNumber: number; + readonly modifiedStartLineNumber: number; + readonly modifiedEndLineNumber: number; } /** * A character level change. */ export interface ICharChange extends IChange { - originalStartColumn: number; - originalEndColumn: number; - modifiedStartColumn: number; - modifiedEndColumn: number; + readonly originalStartColumn: number; + readonly originalEndColumn: number; + readonly modifiedStartColumn: number; + readonly modifiedEndColumn: number; } /** * A line change */ export interface ILineChange extends IChange { - charChanges: ICharChange[]; - } - - export class BareFontInfo { - _bareFontInfoBrand: void; - fontFamily: string; - fontWeight: string; - fontSize: number; - lineHeight: number; - } - - export class FontInfo extends BareFontInfo { - _editorStylingBrand: void; - typicalHalfwidthCharacterWidth: number; - typicalFullwidthCharacterWidth: number; - spaceWidth: number; - maxDigitWidth: number; + readonly charChanges: ICharChange[]; } export interface INewScrollPosition { @@ -2808,13 +2820,13 @@ declare module monaco.editor { * Method that will be executed when the action is triggered. * @param editor The editor instance is passed in as a convinience */ - run: (editor: ICommonCodeEditor) => Promise; + run(editor: ICommonCodeEditor): void | Promise; } export interface IEditorAction { - id: string; - label: string; - alias: string; + readonly id: string; + readonly label: string; + readonly alias: string; isSupported(): boolean; run(): Promise; } @@ -2832,7 +2844,7 @@ declare module monaco.editor { * An event emitted when the language of the current model has changed. * @event */ - onDidChangeModelMode(listener: (e: IModelModeChangedEvent) => void): IDisposable; + onDidChangeModelLanguage(listener: (e: IModelLanguageChangedEvent) => void): IDisposable; /** * An event emitted when the options of the current model has changed. * @event @@ -2888,10 +2900,6 @@ declare module monaco.editor { * Returns true if this editor has keyboard focus (e.g. cursor is blinking). */ isFocused(): boolean; - /** - * Add a new action to this editor. - */ - addAction(descriptor: IActionDescriptor): void; /** * Returns all actions associated with this editor. */ @@ -3153,11 +3161,12 @@ declare module monaco.editor { */ pushUndoStop(): boolean; /** - * Execute a command on the editor. + * Execute edits on the editor. * @param source The source of the call. - * @param command The command to execute + * @param edits The edits to execute. + * @param endCursoState Cursor state after the edits were applied. */ - executeEdits(source: string, edits: IIdentifiedSingleEditOperation[]): boolean; + executeEdits(source: string, edits: IIdentifiedSingleEditOperation[], endCursoState?: Selection[]): boolean; /** * Execute multiple (concommitent) commands on the editor. * @param source The source of the call. @@ -3356,7 +3365,6 @@ declare module monaco.editor { ColumnSelect: string; CreateCursor: string; LastCursorMoveToSelect: string; - JumpToBracket: string; Type: string; ReplacePreviousChar: string; CompositionStart: string; @@ -3373,8 +3381,6 @@ declare module monaco.editor { DeleteWordRight: string; DeleteWordStartRight: string; DeleteWordEndRight: string; - DeleteAllLeft: string; - DeleteAllRight: string; RemoveSecondaryCursors: string; CancelSelection: string; Cut: string; @@ -3484,6 +3490,10 @@ declare module monaco.editor { * The dom node of the view zone */ domNode: HTMLElement; + /** + * An optional dom node for the view zone that will be placed in the margin area. + */ + marginDomNode?: HTMLElement; /** * Callback which gives the relative top of the view zone as it appears (taking scrolling into account). */ @@ -3627,35 +3637,35 @@ declare module monaco.editor { /** * The target element */ - element: Element; + readonly element: Element; /** * The target type */ - type: MouseTargetType; + readonly type: MouseTargetType; /** * The 'approximate' editor position */ - position: Position; + readonly position: Position; /** * Desired mouse column (e.g. when position.column gets clamped to text length -- clicking after text on a line). */ - mouseColumn: number; + readonly mouseColumn: number; /** * The 'approximate' editor range */ - range: Range; + readonly range: Range; /** * Some extra detail. */ - detail: any; + readonly detail: any; } /** * A mouse event originating from the editor. */ export interface IEditorMouseEvent { - event: IMouseEvent; - target: IMouseTarget; + readonly event: IMouseEvent; + readonly target: IMouseTarget; } /** @@ -3763,6 +3773,13 @@ declare module monaco.editor { * Get the vertical position (top offset) for the position w.r.t. to the first line. */ getTopForPosition(lineNumber: number, column: number): number; + /** + * Get the hit test target at coordinates `clientX` and `clientY`. + * The coordinates are relative to the top-left of the viewport. + * + * @returns Hit test target or null if the coordinates fall outside the editor or the editor has no model. + */ + getTargetAtClientPoint(clientX: number, clientY: number): IMouseTarget; /** * Get the visible position for `position`. * The result position takes scrolling into account and is relative to the top left corner of the editor. @@ -3790,6 +3807,22 @@ declare module monaco.editor { */ getDomNode(): HTMLElement; } + + export class FontInfo extends BareFontInfo { + readonly _editorStylingBrand: void; + readonly isMonospace: boolean; + readonly typicalHalfwidthCharacterWidth: number; + readonly typicalFullwidthCharacterWidth: number; + readonly spaceWidth: number; + readonly maxDigitWidth: number; + } + export class BareFontInfo { + readonly _bareFontInfoBrand: void; + readonly fontFamily: string; + readonly fontWeight: string; + readonly fontSize: number; + readonly lineHeight: number; + } } declare module monaco.languages { @@ -3807,6 +3840,7 @@ declare module monaco.languages { /** * An event emitted when a language is first time needed (e.g. a model has it set). + * @event */ export function onLanguage(languageId: string, callback: () => void): IDisposable; @@ -3815,6 +3849,43 @@ declare module monaco.languages { */ export function setLanguageConfiguration(languageId: string, configuration: LanguageConfiguration): IDisposable; + /** + * A token. + */ + export interface IToken { + startIndex: number; + scopes: string; + } + + /** + * The result of a line tokenization. + */ + export interface ILineTokens { + /** + * The list of tokens on the line. + */ + tokens: IToken[]; + /** + * The tokenization end state. + * A pointer will be held to this and the object should not be modified by the tokenizer after the pointer is returned. + */ + endState: IState; + } + + /** + * A "manual" provider of tokens. + */ + export interface TokensProvider { + /** + * The initial state of a language. Will be the state passed in to tokenize the first line. + */ + getInitialState(): IState; + /** + * Tokenize a line given the state at the beginning of the line. + */ + tokenize(line: string, state: IState): ILineTokens; + } + /** * Set the tokens provider for a language (manual implementation). */ @@ -3860,6 +3931,11 @@ declare module monaco.languages { */ export function registerDefinitionProvider(languageId: string, provider: DefinitionProvider): IDisposable; + /** + * Register a type definition provider (used by e.g. go to implementation). + */ + export function registerTypeDefinitionProvider(languageId: string, provider: TypeDefinitionProvider): IDisposable; + /** * Register a code lens provider (used by e.g. inline code lenses). */ @@ -3905,7 +3981,7 @@ declare module monaco.languages { * * @readonly */ - markers: editor.IMarkerData[]; + readonly markers: editor.IMarkerData[]; } /** @@ -3941,6 +4017,7 @@ declare module monaco.languages { Color = 15, File = 16, Reference = 17, + Folder = 18, } /** @@ -4144,51 +4221,77 @@ declare module monaco.languages { export interface IBracketElectricCharacterContribution { docComment?: IDocComment; - embeddedElectricCharacters?: string[]; } /** * Definition of documentation comments (e.g. Javadoc/JSdoc) */ export interface IDocComment { - scope: string; + /** + * The string that starts a doc comment (e.g. '/**') + */ open: string; - lineStart: string; - close?: string; + /** + * The string that appears on the last line and closes the doc comment (e.g. ' * /'). + */ + close: string; } /** - * A mode. Will soon be obsolete. + * A tuple of two characters, like a pair of + * opening and closing brackets. */ - export interface IMode { - getId(): string; + export type CharacterPair = [string, string]; + + export interface IAutoClosingPair { + open: string; + close: string; + } + + export interface IAutoClosingPairConditional extends IAutoClosingPair { + notIn?: string[]; } /** - * A token. Only supports a single scope, but will soon support a scope array. + * Describes what to do with the indentation when pressing Enter. */ - export interface IToken { - startIndex: number; - scopes: string | string[]; + export enum IndentAction { + /** + * Insert new line and copy the previous line's indentation. + */ + None = 0, + /** + * Insert new line and indent once (relative to the previous line's indentation). + */ + Indent = 1, + /** + * Insert two new lines: + * - the first one indented which will hold the cursor + * - the second one at the same indentation level + */ + IndentOutdent = 2, + /** + * Insert new line and outdent once (relative to the previous line's indentation). + */ + Outdent = 3, } /** - * The result of a line tokenization. + * Describes what to do when pressing Enter. */ - export interface ILineTokens { + export interface EnterAction { /** - * The list of tokens on the line. + * Describe what to do with the indentation. */ - tokens: IToken[]; + indentAction: IndentAction; /** - * The tokenization end state. - * A pointer will be held to this and the object should not be modified by the tokenizer after the pointer is returned. + * Describes text to be appended after the new line and after the indentation. */ - endState: IState; + appendText?: string; /** - * An optional promise to force the model to retokenize this line (e.g. missing information at the point of tokenization) + * Describes the number of characters to remove from the new line's indentation. */ - retokenize?: Promise; + removeText?: number; } /** @@ -4201,20 +4304,6 @@ declare module monaco.languages { equals(other: IState): boolean; } - /** - * A "manual" provider of tokens. - */ - export interface TokensProvider { - /** - * The initial state of a language. Will be the state passed in to tokenize the first line. - */ - getInitialState(): IState; - /** - * Tokenize a line given the state at the beginning of the line. - */ - tokenize(line: string, state: IState): ILineTokens; - } - /** * A hover represents additional information for a symbol or word. Hovers are * rendered in a tooltip-like widget. @@ -4267,7 +4356,7 @@ declare module monaco.languages { * The human-readable doc-comment of this signature. Will be shown * in the UI but can be omitted. */ - documentation: string; + documentation?: string; } /** @@ -4285,7 +4374,7 @@ declare module monaco.languages { * The human-readable doc-comment of this signature. Will be shown * in the UI but can be omitted. */ - documentation: string; + documentation?: string; /** * The parameters of this signature. */ @@ -4426,6 +4515,17 @@ declare module monaco.languages { provideDefinition(model: editor.IReadOnlyModel, position: Position, token: CancellationToken): Definition | Thenable; } + /** + * The type definition provider interface defines the contract between extensions and + * the go to implementation feature. + */ + export interface TypeDefinitionProvider { + /** + * Provide the implementation of the symbol at the given position and document. + */ + provideTypeDefinition(model: editor.IReadOnlyModel, position: Position, token: CancellationToken): Definition | Thenable; + } + /** * A symbol kind. */ @@ -4587,67 +4687,11 @@ declare module monaco.languages { } export interface CodeLensProvider { + onDidChange?: IEvent; provideCodeLenses(model: editor.IReadOnlyModel, token: CancellationToken): ICodeLensSymbol[] | Thenable; resolveCodeLens?(model: editor.IReadOnlyModel, codeLens: ICodeLensSymbol, token: CancellationToken): ICodeLensSymbol | Thenable; } - /** - * A tuple of two characters, like a pair of - * opening and closing brackets. - */ - export type CharacterPair = [string, string]; - - export interface IAutoClosingPairConditional extends IAutoClosingPair { - notIn?: string[]; - } - - /** - * Describes what to do with the indentation when pressing Enter. - */ - export enum IndentAction { - /** - * Insert new line and copy the previous line's indentation. - */ - None = 0, - /** - * Insert new line and indent once (relative to the previous line's indentation). - */ - Indent = 1, - /** - * Insert two new lines: - * - the first one indented which will hold the cursor - * - the second one at the same indentation level - */ - IndentOutdent = 2, - /** - * Insert new line and outdent once (relative to the previous line's indentation). - */ - Outdent = 3, - } - - /** - * Describes what to do when pressing Enter. - */ - export interface EnterAction { - /** - * Describe what to do with the indentation. - */ - indentAction: IndentAction; - /** - * Describes text to be appended after the new line and after the indentation. - */ - appendText?: string; - /** - * Describes the number of characters to remove from the new line's indentation. - */ - removeText?: number; - } - - export interface IAutoClosingPair { - open: string; - close: string; - } - export interface ILanguageExtensionPoint { id: string; extensions?: string[]; @@ -4778,8 +4822,8 @@ declare module monaco.worker { export interface IMirrorModel { - uri: Uri; - version: number; + readonly uri: Uri; + readonly version: number; getValue(): string; } @@ -4794,33 +4838,32 @@ declare module monaco.worker { declare module monaco.languages.typescript { - export enum ModuleKind { + enum ModuleKind { None = 0, CommonJS = 1, AMD = 2, UMD = 3, System = 4, - ES6 = 5, ES2015 = 5, } - - export enum JsxEmit { + enum JsxEmit { None = 0, Preserve = 1, React = 2, } - - export enum NewLineKind { + enum NewLineKind { CarriageReturnLineFeed = 0, LineFeed = 1, } - export enum ScriptTarget { + enum ScriptTarget { ES3 = 0, ES5 = 1, - ES6 = 2, ES2015 = 2, - Latest = 2, + ES2016 = 3, + ES2017 = 4, + ESNext = 5, + Latest = 5, } export enum ModuleResolutionKind { @@ -4828,58 +4871,70 @@ declare module monaco.languages.typescript { NodeJs = 2, } + type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[]; interface CompilerOptions { - allowNonTsExtensions?: boolean; + allowJs?: boolean; + allowSyntheticDefaultImports?: boolean; + allowUnreachableCode?: boolean; + allowUnusedLabels?: boolean; + alwaysStrict?: boolean; + baseUrl?: string; charset?: string; declaration?: boolean; - diagnostics?: boolean; + declarationDir?: string; + disableSizeLimit?: boolean; emitBOM?: boolean; - help?: boolean; - init?: boolean; + emitDecoratorMetadata?: boolean; + experimentalDecorators?: boolean; + forceConsistentCasingInFileNames?: boolean; + importHelpers?: boolean; inlineSourceMap?: boolean; inlineSources?: boolean; + isolatedModules?: boolean; jsx?: JsxEmit; - reactNamespace?: string; - listFiles?: boolean; + lib?: string[]; locale?: string; mapRoot?: string; + maxNodeModuleJsDepth?: number; module?: ModuleKind; + moduleResolution?: ModuleResolutionKind; newLine?: NewLineKind; noEmit?: boolean; noEmitHelpers?: boolean; noEmitOnError?: boolean; noErrorTruncation?: boolean; + noFallthroughCasesInSwitch?: boolean; noImplicitAny?: boolean; + noImplicitReturns?: boolean; + noImplicitThis?: boolean; + noUnusedLocals?: boolean; + noUnusedParameters?: boolean; + noImplicitUseStrict?: boolean; noLib?: boolean; noResolve?: boolean; out?: string; - outFile?: string; outDir?: string; + outFile?: string; preserveConstEnums?: boolean; project?: string; + reactNamespace?: string; + jsxFactory?: string; removeComments?: boolean; rootDir?: string; + rootDirs?: string[]; + skipLibCheck?: boolean; + skipDefaultLibCheck?: boolean; sourceMap?: boolean; sourceRoot?: string; + strictNullChecks?: boolean; suppressExcessPropertyErrors?: boolean; suppressImplicitAnyIndexErrors?: boolean; target?: ScriptTarget; - version?: boolean; - watch?: boolean; - isolatedModules?: boolean; - experimentalDecorators?: boolean; - emitDecoratorMetadata?: boolean; - moduleResolution?: ModuleResolutionKind; - allowUnusedLabels?: boolean; - allowUnreachableCode?: boolean; - noImplicitReturns?: boolean; - noFallthroughCasesInSwitch?: boolean; - forceConsistentCasingInFileNames?: boolean; - allowSyntheticDefaultImports?: boolean; - allowJs?: boolean; - noImplicitUseStrict?: boolean; - disableSizeLimit?: boolean; - [option: string]: string | number | boolean; + traceResolution?: boolean; + types?: string[]; + /** Paths used to compute primary types search locations */ + typeRoots?: string[]; + [option: string]: CompilerOptionsValue | undefined; } export interface DiagnosticsOptions { diff --git a/package.json b/package.json index 0720e81e..8988e162 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.2.1", - "monaco-editor-core": "0.7.3", - "monaco-html": "1.1.0", - "monaco-json": "1.1.1", - "monaco-languages": "0.6.0", - "monaco-typescript": "2.0.1", + "monaco-css": "1.3.0", + "monaco-editor-core": "0.8.0", + "monaco-html": "1.2.0", + "monaco-json": "1.2.0", + "monaco-languages": "0.7.0", + "monaco-typescript": "2.1.1", "rimraf": "^2.5.2", "typedoc": "^0.5.0", "uncss": "^0.14.1" diff --git a/website/playground/monaco.d.ts.txt b/website/playground/monaco.d.ts.txt index 880c51e8..dba76168 100644 --- a/website/playground/monaco.d.ts.txt +++ b/website/playground/monaco.d.ts.txt @@ -5,15 +5,15 @@ *-----------------------------------------------------------*/ declare module monaco { - interface Thenable { + interface Thenable { /** * Attaches callbacks for the resolution and/or rejection of the Promise. * @param onfulfilled The callback to execute when the Promise is resolved. * @param onrejected The callback to execute when the Promise is rejected. * @returns A Promise for the completion of which ever callback is executed. */ - then(onfulfilled?: (value: R) => TResult | Thenable, onrejected?: (reason: any) => TResult | Thenable): Thenable; - then(onfulfilled?: (value: R) => TResult | Thenable, onrejected?: (reason: any) => void): Thenable; + then(onfulfilled?: (value: T) => TResult | Thenable, onrejected?: (reason: any) => TResult | Thenable): Thenable; + then(onfulfilled?: (value: T) => TResult | Thenable, onrejected?: (reason: any) => void): Thenable; } export interface IDisposable { @@ -29,7 +29,7 @@ declare module monaco { */ export class Emitter { constructor(); - event: IEvent; + readonly event: IEvent; fire(event?: T): void; dispose(): void; } @@ -100,8 +100,12 @@ declare module monaco { } export interface CancellationToken { - isCancellationRequested: boolean; - onCancellationRequested: IEvent; + readonly isCancellationRequested: boolean; + /** + * An event emitted when cancellation is requested + * @event + */ + readonly onCancellationRequested: IEvent; } /** * Uniform Resource Identifier (Uri) http://tools.ietf.org/html/rfc3986. @@ -352,62 +356,74 @@ declare module monaco { } export class KeyMod { - static CtrlCmd: number; - static Shift: number; - static Alt: number; - static WinCtrl: number; + static readonly CtrlCmd: number; + static readonly Shift: number; + static readonly Alt: number; + static readonly WinCtrl: number; static chord(firstPart: number, secondPart: number): number; } + + export class Keybinding { + value: number; + constructor(keybinding: number); + equals(other: Keybinding): boolean; + hasCtrlCmd(): boolean; + hasShift(): boolean; + hasAlt(): boolean; + hasWinCtrl(): boolean; + isModifierKey(): boolean; + getKeyCode(): KeyCode; + } /** * MarkedString can be used to render human readable text. It is either a markdown string * or a code-block that provides a language and a code snippet. Note that * markdown strings will be sanitized - that means html will be escaped. */ export type MarkedString = string | { - language: string; - value: string; + readonly language: string; + readonly value: string; }; export interface IKeyboardEvent { - browserEvent: KeyboardEvent; - target: HTMLElement; - ctrlKey: boolean; - shiftKey: boolean; - altKey: boolean; - metaKey: boolean; - keyCode: KeyCode; - asKeybinding(): number; + readonly browserEvent: KeyboardEvent; + readonly target: HTMLElement; + readonly ctrlKey: boolean; + readonly shiftKey: boolean; + readonly altKey: boolean; + readonly metaKey: boolean; + readonly keyCode: KeyCode; + toKeybinding(): Keybinding; equals(keybinding: number): boolean; preventDefault(): void; stopPropagation(): void; } export interface IMouseEvent { - browserEvent: MouseEvent; - leftButton: boolean; - middleButton: boolean; - rightButton: boolean; - target: HTMLElement; - detail: number; - posx: number; - posy: number; - ctrlKey: boolean; - shiftKey: boolean; - altKey: boolean; - metaKey: boolean; - timestamp: number; + readonly browserEvent: MouseEvent; + readonly leftButton: boolean; + readonly middleButton: boolean; + readonly rightButton: boolean; + readonly target: HTMLElement; + readonly detail: number; + readonly posx: number; + readonly posy: number; + readonly ctrlKey: boolean; + readonly shiftKey: boolean; + readonly altKey: boolean; + readonly metaKey: boolean; + readonly timestamp: number; preventDefault(): void; stopPropagation(): void; } export interface IScrollEvent { - scrollTop: number; - scrollLeft: number; - scrollWidth: number; - scrollHeight: number; - scrollTopChanged: boolean; - scrollLeftChanged: boolean; - scrollWidthChanged: boolean; - scrollHeightChanged: boolean; + readonly scrollTop: number; + readonly scrollLeft: number; + readonly scrollWidth: number; + readonly scrollHeight: number; + readonly scrollTopChanged: boolean; + readonly scrollLeftChanged: boolean; + readonly scrollWidthChanged: boolean; + readonly scrollHeightChanged: boolean; } /** @@ -417,11 +433,11 @@ declare module monaco { /** * line number (starts at 1) */ - lineNumber: number; + readonly lineNumber: number; /** * column (the first character in a line is between column 1 and column 2) */ - column: number; + readonly column: number; } /** @@ -431,19 +447,19 @@ declare module monaco { /** * Line number on which the range starts (starts at 1). */ - startLineNumber: number; + readonly startLineNumber: number; /** * Column on which the range starts in line `startLineNumber` (starts at 1). */ - startColumn: number; + readonly startColumn: number; /** * Line number on which the range ends. */ - endLineNumber: number; + readonly endLineNumber: number; /** * Column on which the range ends in line `endLineNumber`. */ - endColumn: number; + readonly endColumn: number; } /** @@ -454,19 +470,19 @@ declare module monaco { /** * The line number on which the selection has started. */ - selectionStartLineNumber: number; + readonly selectionStartLineNumber: number; /** * The column on `selectionStartLineNumber` where the selection has started. */ - selectionStartColumn: number; + readonly selectionStartColumn: number; /** * The line number on which the selection has ended. */ - positionLineNumber: number; + readonly positionLineNumber: number; /** * The column on `positionLineNumber` where the selection has ended. */ - positionColumn: number; + readonly positionColumn: number; } /** @@ -476,11 +492,11 @@ declare module monaco { /** * line number (starts at 1) */ - lineNumber: number; + readonly lineNumber: number; /** * column (the first character in a line is between column 1 and column 2) */ - column: number; + readonly column: number; constructor(lineNumber: number, column: number); /** * Test if this position equals other position @@ -510,6 +526,10 @@ declare module monaco { * If the two positions are equal, the result will be true. */ static isBeforeOrEqual(a: IPosition, b: IPosition): boolean; + /** + * A function that compares positions, useful for sorting + */ + static compare(a: IPosition, b: IPosition): number; /** * Clone this position. */ @@ -535,19 +555,19 @@ declare module monaco { /** * Line number on which the range starts (starts at 1). */ - startLineNumber: number; + readonly startLineNumber: number; /** * Column on which the range starts in line `startLineNumber` (starts at 1). */ - startColumn: number; + readonly startColumn: number; /** * Line number on which the range ends. */ - endLineNumber: number; + readonly endLineNumber: number; /** * Column on which the range ends in line `endLineNumber`. */ - endColumn: number; + readonly endColumn: number; constructor(startLineNumber: number, startColumn: number, endLineNumber: number, endColumn: number); /** * Test if this range is empty. @@ -667,19 +687,19 @@ declare module monaco { /** * The line number on which the selection has started. */ - selectionStartLineNumber: number; + readonly selectionStartLineNumber: number; /** * The column on `selectionStartLineNumber` where the selection has started. */ - selectionStartColumn: number; + readonly selectionStartColumn: number; /** * The line number on which the selection has ended. */ - positionLineNumber: number; + readonly positionLineNumber: number; /** * The column on `positionLineNumber` where the selection has ended. */ - positionColumn: number; + readonly positionColumn: number; constructor(selectionStartLineNumber: number, selectionStartColumn: number, positionLineNumber: number, positionColumn: number); /** * Clone this selection. @@ -740,6 +760,15 @@ declare module monaco { */ RTL = 1, } + + export class Token { + _tokenBrand: void; + readonly offset: number; + readonly type: string; + readonly language: string; + constructor(offset: number, type: string, language: string); + toString(): string; + } } declare module monaco.editor { @@ -752,6 +781,13 @@ declare module monaco.editor { */ export function create(domElement: HTMLElement, options?: IEditorConstructionOptions, override?: IEditorOverrideServices): IStandaloneCodeEditor; + /** + * Emitted when an editor is created. + * Creating a diff editor might cause this listener to be invoked with the two editors. + * @event + */ + export function onDidCreateEditor(listener: (codeEditor: ICodeEditor) => void): IDisposable; + /** * Create a new diff editor under `domElement`. * `domElement` should be empty (not contain other dom nodes). @@ -767,9 +803,9 @@ declare module monaco.editor { } export interface IDiffNavigatorOptions { - followsCaret?: boolean; - ignoreCharChanges?: boolean; - alwaysRevealFirst?: boolean; + readonly followsCaret?: boolean; + readonly ignoreCharChanges?: boolean; + readonly alwaysRevealFirst?: boolean; } export function createDiffNavigator(diffEditor: IStandaloneDiffEditor, opts?: IDiffNavigatorOptions): IDiffNavigator; @@ -802,20 +838,23 @@ declare module monaco.editor { /** * Emitted when a model is created. + * @event */ export function onDidCreateModel(listener: (model: IModel) => void): IDisposable; /** * Emitted right before a model is disposed. + * @event */ export function onWillDisposeModel(listener: (model: IModel) => void): IDisposable; /** * Emitted when a different language is set to a model. + * @event */ export function onDidChangeModelLanguage(listener: (e: { - model: IModel; - oldLanguage: string; + readonly model: IModel; + readonly oldLanguage: string; }) => void): IDisposable; /** @@ -839,6 +878,31 @@ declare module monaco.editor { */ export function colorizeModelLine(model: IModel, lineNumber: number, tabSize?: number): string; + /** + * Tokenize `text` using language `languageId` + */ + export function tokenize(text: string, languageId: string): Token[][]; + + /** + * Define a new theme. + */ + export function defineTheme(themeName: string, themeData: ITheme): void; + + export type BuiltinTheme = 'vs' | 'vs-dark' | 'hc-black'; + + export interface ITheme { + base: BuiltinTheme; + inherit: boolean; + rules: IThemeRule[]; + } + + export interface IThemeRule { + token: string; + foreground?: string; + background?: string; + fontStyle?: string; + } + /** * A web worker that can provide a proxy to an arbitrary file. */ @@ -899,13 +963,13 @@ declare module monaco.editor { export interface IStandaloneCodeEditor extends ICodeEditor { addCommand(keybinding: number, handler: ICommandHandler, context: string): string; createContextKey(key: string, defaultValue: T): IContextKey; - addAction(descriptor: IActionDescriptor): void; + addAction(descriptor: IActionDescriptor): IDisposable; } export interface IStandaloneDiffEditor extends IDiffEditor { addCommand(keybinding: number, handler: ICommandHandler, context: string): string; createContextKey(key: string, defaultValue: T): IContextKey; - addAction(descriptor: IActionDescriptor): void; + addAction(descriptor: IActionDescriptor): IDisposable; } export interface ICommandHandler { (...args: any[]): void; @@ -949,16 +1013,6 @@ declare module monaco.editor { Visible = 3, } - export interface IAction extends IDisposable { - id: string; - label: string; - tooltip: string; - class: string; - enabled: boolean; - checked: boolean; - run(event?: any): Promise; - } - /** * Configuration options for editor scrollbars */ @@ -1090,15 +1144,16 @@ declare module monaco.editor { lineNumbersMinChars?: number; /** * Enable the rendering of the glyph margin. - * Defaults to false. + * 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; + 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. @@ -1111,10 +1166,9 @@ declare module monaco.editor { */ roundedSelection?: boolean; /** - * Theme to be used for rendering. Consists of two parts, the UI theme and the syntax theme, - * separated by a space. - * The current available UI themes are: 'vs' (default), 'vs-dark', 'hc-black' - * The syntax themes are contributed. The default is 'default-theme' + * 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; /** @@ -1126,6 +1180,11 @@ declare module monaco.editor { * 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. @@ -1188,7 +1247,7 @@ declare module monaco.editor { wordWrap?: boolean; /** * Control indentation of wrapped lines. Can be: 'none', 'same' or 'indent'. - * Defaults to 'none'. + * Defaults to 'same' in vscode and to 'none' in monaco-editor. */ wrappingIndent?: string; /** @@ -1266,10 +1325,19 @@ declare module monaco.editor { * 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' */ @@ -1278,6 +1346,16 @@ declare module monaco.editor { * 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. @@ -1290,7 +1368,7 @@ declare module monaco.editor { codeLens?: boolean; /** * Enable code folding - * Defaults to true. + * Defaults to true in vscode and to false in monaco-editor. */ folding?: boolean; /** @@ -1310,9 +1388,9 @@ declare module monaco.editor { renderIndentGuides?: boolean; /** * Enable rendering of current line highlight. - * Defaults to true. + * Defaults to all. */ - renderLineHighlight?: boolean; + renderLineHighlight?: 'none' | 'gutter' | 'line' | 'all'; /** * Inserting and deleting whitespace follows tab stops. */ @@ -1354,6 +1432,11 @@ declare module monaco.editor { * Defaults to true. */ ignoreTrimWhitespace?: boolean; + /** + * Render +/- indicators for added/deleted changes. + * Defaults to true. + */ + renderIndicators?: boolean; /** * Original model should be editable? * Defaults to false. @@ -1362,140 +1445,146 @@ declare module monaco.editor { } export class InternalEditorScrollbarOptions { - _internalEditorScrollbarOptionsBrand: void; - arrowSize: number; - vertical: ScrollbarVisibility; - horizontal: ScrollbarVisibility; - useShadows: boolean; - verticalHasArrows: boolean; - horizontalHasArrows: boolean; - handleMouseWheel: boolean; - horizontalScrollbarSize: number; - horizontalSliderSize: number; - verticalScrollbarSize: number; - verticalSliderSize: number; - mouseWheelScrollSensitivity: number; + 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 { - _editorWrappingInfoBrand: void; - isViewportWrapping: boolean; - wrappingColumn: number; - wrappingIndent: WrappingIndent; - wordWrapBreakBeforeCharacters: string; - wordWrapBreakAfterCharacters: string; - wordWrapBreakObtrusiveCharacters: string; + readonly _editorWrappingInfoBrand: void; + readonly isViewportWrapping: boolean; + readonly wrappingColumn: number; + readonly wrappingIndent: WrappingIndent; + readonly wordWrapBreakBeforeCharacters: string; + readonly wordWrapBreakAfterCharacters: string; + readonly wordWrapBreakObtrusiveCharacters: string; } export class InternalEditorViewOptions { - _internalEditorViewOptionsBrand: void; - theme: string; - canUseTranslate3d: boolean; - experimentalScreenReader: boolean; - rulers: number[]; - ariaLabel: string; - renderLineNumbers: boolean; - renderCustomLineNumbers: (lineNumber: number) => string; - renderRelativeLineNumbers: boolean; - selectOnLineNumbers: boolean; - glyphMargin: boolean; - revealHorizontalRightPadding: number; - roundedSelection: boolean; - overviewRulerLanes: number; - cursorBlinking: TextEditorCursorBlinkingStyle; - mouseWheelZoom: boolean; - cursorStyle: TextEditorCursorStyle; - hideCursorInOverviewRuler: boolean; - scrollBeyondLastLine: boolean; - editorClassName: string; - stopRenderingLineAfter: number; - renderWhitespace: 'none' | 'boundary' | 'all'; - renderControlCharacters: boolean; - renderIndentGuides: boolean; - renderLineHighlight: boolean; - scrollbar: InternalEditorScrollbarOptions; + readonly _internalEditorViewOptionsBrand: void; + readonly theme: string; + readonly canUseTranslate3d: 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 { - theme: boolean; - canUseTranslate3d: boolean; - experimentalScreenReader: boolean; - rulers: boolean; - ariaLabel: boolean; - renderLineNumbers: boolean; - renderCustomLineNumbers: boolean; - renderRelativeLineNumbers: boolean; - selectOnLineNumbers: boolean; - glyphMargin: boolean; - revealHorizontalRightPadding: boolean; - roundedSelection: boolean; - overviewRulerLanes: boolean; - cursorBlinking: boolean; - mouseWheelZoom: boolean; - cursorStyle: boolean; - hideCursorInOverviewRuler: boolean; - scrollBeyondLastLine: boolean; - editorClassName: boolean; - stopRenderingLineAfter: boolean; - renderWhitespace: boolean; - renderControlCharacters: boolean; - renderIndentGuides: boolean; - renderLineHighlight: boolean; - scrollbar: boolean; + readonly theme: boolean; + readonly canUseTranslate3d: 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 { - selectionClipboard: boolean; - hover: boolean; - contextmenu: boolean; - quickSuggestions: boolean; - quickSuggestionsDelay: number; - parameterHints: boolean; - iconsInSuggestions: boolean; - formatOnType: boolean; - suggestOnTriggerCharacters: boolean; - acceptSuggestionOnEnter: boolean; - snippetSuggestions: 'top' | 'bottom' | 'inline' | 'none'; - tabCompletion: boolean; - wordBasedSuggestions: boolean; - selectionHighlight: boolean; - codeLens: boolean; - folding: boolean; + 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 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 { - _internalEditorOptionsBrand: void; - lineHeight: number; - readOnly: boolean; - wordSeparators: string; - autoClosingBrackets: boolean; - useTabStops: boolean; - tabFocusMode: boolean; - layoutInfo: EditorLayoutInfo; - fontInfo: FontInfo; - viewInfo: InternalEditorViewOptions; - wrappingInfo: EditorWrappingInfo; - contribInfo: EditorContribOptions; + 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 { - lineHeight: boolean; - readOnly: boolean; - wordSeparators: boolean; - autoClosingBrackets: boolean; - useTabStops: boolean; - tabFocusMode: boolean; - layoutInfo: boolean; - fontInfo: boolean; - viewInfo: IViewConfigurationChangedEvent; - wrappingInfo: boolean; - contribInfo: boolean; + 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; } /** @@ -1541,6 +1630,10 @@ declare module monaco.editor { * CSS class name describing the decoration. */ className?: string; + /** + * Message to be rendered when hovering over the glyph margin decoration. + */ + glyphMarginHoverMessage?: MarkedString | MarkedString[]; /** * Array of MarkedString to render as the decoration message. */ @@ -1565,6 +1658,10 @@ declare module monaco.editor { * If set, the decoration will be rendered in the lines decorations with this CSS class name. */ linesDecorationsClassName?: string; + /** + * If set, the decoration will be rendered in the margin (covering its full width) with this CSS class name. + */ + marginClassName?: string; /** * If set, the decoration will be rendered inline with the text with this CSS class name. * Please use this only for CSS rules that must impact the text. For example, use `className` @@ -1602,19 +1699,23 @@ declare module monaco.editor { /** * Identifier for a decoration. */ - id: string; + readonly id: string; /** * Identifier for a decoration's owener. */ - ownerId: number; + readonly ownerId: number; /** * Range that this decoration covers. */ - range: Range; + readonly range: Range; /** * Options associated with this decoration. */ - options: IModelDecorationOptions; + readonly options: IModelDecorationOptions; + /** + * A flag describing if this is a problem decoration (e.g. warning/error). + */ + readonly isForValidation: boolean; } /** @@ -1624,15 +1725,15 @@ declare module monaco.editor { /** * The word. */ - word: string; + readonly word: string; /** * The column where the word starts. */ - startColumn: number; + readonly startColumn: number; /** * The column where the word ends. */ - endColumn: number; + readonly endColumn: number; } /** @@ -1682,7 +1783,7 @@ declare module monaco.editor { } /** - * And identifier for a single edit operation. + * An identifier for a single edit operation. */ export interface ISingleEditOperationIdentifier { /** @@ -1810,11 +1911,12 @@ declare module monaco.editor { (inverseEditOperations: IIdentifiedSingleEditOperation[]): Selection[]; } - export interface ITextModelResolvedOptions { - tabSize: number; - insertSpaces: boolean; - defaultEOL: DefaultEndOfLine; - trimAutoWhitespace: boolean; + export class TextModelResolvedOptions { + _textModelResolvedOptionsBrand: void; + readonly tabSize: number; + readonly insertSpaces: boolean; + readonly defaultEOL: DefaultEndOfLine; + readonly trimAutoWhitespace: boolean; } export interface ITextModelUpdateOptions { @@ -1824,16 +1926,16 @@ declare module monaco.editor { } export interface IModelOptionsChangedEvent { - tabSize: boolean; - insertSpaces: boolean; - trimAutoWhitespace: boolean; + readonly tabSize: boolean; + readonly insertSpaces: boolean; + readonly trimAutoWhitespace: boolean; } /** * A textual read-only model. */ export interface ITextModel { - getOptions(): ITextModelResolvedOptions; + getOptions(): TextModelResolvedOptions; /** * Get the current version id of the model. * Anytime a change happens to the model (even undo/redo), @@ -1850,10 +1952,6 @@ declare module monaco.editor { * Replace the entire text buffer value contained in this model. */ setValue(newValue: string): void; - /** - * Replace the entire text buffer value contained in this model. - */ - setValueFromRawText(newValue: IRawText): void; /** * Get the text stored in this model. * @param eol The end of line character preference. Defaults to `EndOfLinePreference.TextDefined`. @@ -1865,14 +1963,6 @@ declare module monaco.editor { * Get the length of the text stored in this model. */ getValueLength(eol?: EndOfLinePreference, preserveBOM?: boolean): number; - /** - * Get the raw text stored in this model. - */ - toRawText(): IRawText; - /** - * Check if the raw text stored in this model equals another raw text. - */ - equals(other: IRawText): boolean; /** * Get the text in a certain range. * @param range The range describing what text to get. @@ -1975,10 +2065,11 @@ declare module monaco.editor { * @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 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, limitResultCount?: number): Range[]; + findMatches(searchString: string, searchOnlyEditableRange: boolean, isRegex: boolean, matchCase: boolean, wholeWord: boolean, 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. @@ -1986,10 +2077,11 @@ declare module monaco.editor { * @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 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, limitResultCount?: number): Range[]; + findMatches(searchString: string, searchScope: IRange, isRegex: boolean, matchCase: boolean, wholeWord: boolean, 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. @@ -1997,9 +2089,10 @@ declare module monaco.editor { * @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 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): Range; + findNextMatch(searchString: string, searchStart: IPosition, isRegex: boolean, matchCase: boolean, wholeWord: boolean, 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. @@ -2007,16 +2100,23 @@ declare module monaco.editor { * @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 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): Range; + findPreviousMatch(searchString: string, searchStart: IPosition, isRegex: boolean, matchCase: boolean, wholeWord: boolean, captureMatches: boolean): FindMatch; + } + + export class FindMatch { + _findMatchBrand: void; + readonly range: Range; + readonly matches: string[]; } export interface IReadOnlyModel extends ITextModel { /** * Gets the resource associated with this editor model. */ - uri: Uri; + readonly uri: Uri; /** * Get the language associated with this model. */ @@ -2041,10 +2141,6 @@ declare module monaco.editor { * A model that is tokenized. */ export interface ITokenizedModel extends ITextModel { - /** - * Get the current language mode associated with the model. - */ - getMode(): languages.IMode; /** * Get the language associated with this model. */ @@ -2081,12 +2177,6 @@ declare module monaco.editor { GrowsOnlyWhenTypingAfter = 3, } - /** - * A model that can track ranges. - */ - export interface ITextModelWithTrackedRanges extends ITextModel { - } - /** * A model that can have decorations. */ @@ -2195,7 +2285,7 @@ declare module monaco.editor { /** * A model. */ - export interface IModel extends IReadOnlyModel, IEditableTextModel, ITextModelWithMarkers, ITokenizedModel, ITextModelWithTrackedRanges, ITextModelWithDecorations, IEditorModel { + export interface IModel extends IReadOnlyModel, IEditableTextModel, ITextModelWithMarkers, ITokenizedModel, ITextModelWithDecorations, IEditorModel { /** * An event emitted when the contents of the model have changed. * @event @@ -2215,7 +2305,7 @@ declare module monaco.editor { * An event emitted when the language associated with the model has changed. * @event */ - onDidChangeMode(listener: (e: IModelModeChangedEvent) => void): IDisposable; + onDidChangeLanguage(listener: (e: IModelLanguageChangedEvent) => void): IDisposable; /** * An event emitted right before disposing the model. * @event @@ -2224,7 +2314,7 @@ declare module monaco.editor { /** * A unique identifier associated with this model. */ - id: string; + readonly id: string; /** * Destroy this model. This will unbind the model from the mode * and make all necessary clean-up to release this object to the GC. @@ -2235,15 +2325,15 @@ declare module monaco.editor { /** * An event describing that the current mode associated with a model has changed. */ - export interface IModelModeChangedEvent { + export interface IModelLanguageChangedEvent { /** - * Previous mode + * Previous language */ - oldMode: languages.IMode; + readonly oldLanguage: string; /** - * New mode + * New language */ - newMode: languages.IMode; + readonly newLanguage: string; } /** @@ -2253,19 +2343,19 @@ declare module monaco.editor { /** * The range that got replaced. */ - range: IRange; + readonly range: IRange; /** * The length of the range that got replaced. */ - rangeLength: number; + readonly rangeLength: number; /** * The new text for the range. */ - text: string; + readonly text: string; /** * The (new) end-of-line character. */ - eol: string; + readonly eol: string; /** * The new version id the model has transitioned to. */ @@ -2273,63 +2363,11 @@ declare module monaco.editor { /** * Flag that indicates that this event was generated while undoing. */ - isUndoing: boolean; + readonly isUndoing: boolean; /** * Flag that indicates that this event was generated while redoing. */ - isRedoing: boolean; - } - - /** - * The raw text backing a model. - */ - export interface IRawText { - /** - * The entire text length. - */ - length: number; - /** - * The text split into lines. - */ - lines: string[]; - /** - * The BOM (leading character sequence of the file). - */ - BOM: string; - /** - * The end of line sequence. - */ - EOL: string; - /** - * The options associated with this text. - */ - options: ITextModelResolvedOptions; - } - - /** - * Decoration data associated with a model decorations changed event. - */ - export interface IModelDecorationsChangedEventDecorationData { - /** - * The id of the decoration. - */ - id: string; - /** - * The owner id of the decoration. - */ - ownerId: number; - /** - * The range of the decoration. - */ - range: IRange; - /** - * A flag describing if this is a problem decoration (e.g. warning/error). - */ - isForValidation: boolean; - /** - * The options for this decoration. - */ - options: IModelDecorationOptions; + readonly isRedoing: boolean; } /** @@ -2337,43 +2375,33 @@ declare module monaco.editor { */ export interface IModelDecorationsChangedEvent { /** - * A summary with ids of decorations that have changed. + * Lists of ids for added decorations. */ - ids: string[]; + readonly addedDecorations: string[]; /** - * Lists of details for added or changed decorations. + * Lists of ids for changed decorations. */ - addedOrChangedDecorations: IModelDecorationsChangedEventDecorationData[]; + readonly changedDecorations: string[]; /** * List of ids for removed decorations. */ - removedDecorations: string[]; - /** - * Details regarding old options. - */ - oldOptions: { - [decorationId: string]: IModelDecorationOptions; - }; - /** - * Details regarding old ranges. - */ - oldRanges: { - [decorationId: string]: IRange; - }; + readonly removedDecorations: string[]; } /** - * An event describing that a range of lines has been tokenized + * An event describing that some ranges of lines have been tokenized (their tokens have changed). */ export interface IModelTokensChangedEvent { - /** - * The start of the range (inclusive) - */ - fromLineNumber: number; - /** - * The end of the range (inclusive) - */ - toLineNumber: number; + readonly ranges: { + /** + * The start of the range (inclusive) + */ + readonly fromLineNumber: number; + /** + * The end of the range (inclusive) + */ + readonly toLineNumber: number; + }[]; } /** @@ -2417,31 +2445,31 @@ declare module monaco.editor { /** * Primary cursor's position. */ - position: Position; + readonly position: Position; /** * Primary cursor's view position */ - viewPosition: Position; + readonly viewPosition: Position; /** * Secondary cursors' position. */ - secondaryPositions: Position[]; + readonly secondaryPositions: Position[]; /** * Secondary cursors' view position. */ - secondaryViewPositions: Position[]; + readonly secondaryViewPositions: Position[]; /** * Reason. */ - reason: CursorChangeReason; + readonly reason: CursorChangeReason; /** * Source of the call that caused the event. */ - source: string; + readonly source: string; /** * Is the primary cursor in the editable range? */ - isInEditableRange: boolean; + readonly isInEditableRange: boolean; } /** @@ -2451,27 +2479,27 @@ declare module monaco.editor { /** * The primary selection. */ - selection: Selection; + readonly selection: Selection; /** * The primary selection in view coordinates. */ - viewSelection: Selection; + readonly viewSelection: Selection; /** * The secondary selections. */ - secondarySelections: Selection[]; + readonly secondarySelections: Selection[]; /** * The secondary selections in view coordinates. */ - secondaryViewSelections: Selection[]; + readonly secondaryViewSelections: Selection[]; /** * Source of the call that caused the event. */ - source: string; + readonly source: string; /** * Reason. */ - reason: CursorChangeReason; + readonly reason: CursorChangeReason; } /** @@ -2481,109 +2509,109 @@ declare module monaco.editor { /** * The `uri` of the previous model or null. */ - oldModelUrl: Uri; + readonly oldModelUrl: Uri; /** * The `uri` of the new model or null. */ - newModelUrl: Uri; + readonly newModelUrl: Uri; } /** * A description for the overview ruler position. */ export class OverviewRulerPosition { - _overviewRulerPositionBrand: void; + readonly _overviewRulerPositionBrand: void; /** * Width of the overview ruler */ - width: number; + readonly width: number; /** * Height of the overview ruler */ - height: number; + readonly height: number; /** * Top position for the overview ruler */ - top: number; + readonly top: number; /** * Right position for the overview ruler */ - right: number; + readonly right: number; } /** * The internal layout details of the editor. */ export class EditorLayoutInfo { - _editorLayoutInfoBrand: void; + readonly _editorLayoutInfoBrand: void; /** * Full editor width. */ - width: number; + readonly width: number; /** * Full editor height. */ - height: number; + readonly height: number; /** * Left position for the glyph margin. */ - glyphMarginLeft: number; + readonly glyphMarginLeft: number; /** * The width of the glyph margin. */ - glyphMarginWidth: number; + readonly glyphMarginWidth: number; /** * The height of the glyph margin. */ - glyphMarginHeight: number; + readonly glyphMarginHeight: number; /** * Left position for the line numbers. */ - lineNumbersLeft: number; + readonly lineNumbersLeft: number; /** * The width of the line numbers. */ - lineNumbersWidth: number; + readonly lineNumbersWidth: number; /** * The height of the line numbers. */ - lineNumbersHeight: number; + readonly lineNumbersHeight: number; /** * Left position for the line decorations. */ - decorationsLeft: number; + readonly decorationsLeft: number; /** * The width of the line decorations. */ - decorationsWidth: number; + readonly decorationsWidth: number; /** * The height of the line decorations. */ - decorationsHeight: number; + readonly decorationsHeight: number; /** * Left position for the content (actual text) */ - contentLeft: number; + readonly contentLeft: number; /** * The width of the content (actual text) */ - contentWidth: number; + readonly contentWidth: number; /** * The height of the content (actual height) */ - contentHeight: number; + readonly contentHeight: number; /** * The width of the vertical scrollbar. */ - verticalScrollbarWidth: number; + readonly verticalScrollbarWidth: number; /** * The height of the horizontal scrollbar. */ - horizontalScrollbarHeight: number; + readonly horizontalScrollbarHeight: number; /** * The position of the overview ruler. */ - overviewRuler: OverviewRulerPosition; + readonly overviewRuler: OverviewRulerPosition; } /** @@ -2726,43 +2754,27 @@ declare module monaco.editor { * A change */ export interface IChange { - originalStartLineNumber: number; - originalEndLineNumber: number; - modifiedStartLineNumber: number; - modifiedEndLineNumber: number; + readonly originalStartLineNumber: number; + readonly originalEndLineNumber: number; + readonly modifiedStartLineNumber: number; + readonly modifiedEndLineNumber: number; } /** * A character level change. */ export interface ICharChange extends IChange { - originalStartColumn: number; - originalEndColumn: number; - modifiedStartColumn: number; - modifiedEndColumn: number; + readonly originalStartColumn: number; + readonly originalEndColumn: number; + readonly modifiedStartColumn: number; + readonly modifiedEndColumn: number; } /** * A line change */ export interface ILineChange extends IChange { - charChanges: ICharChange[]; - } - - export class BareFontInfo { - _bareFontInfoBrand: void; - fontFamily: string; - fontWeight: string; - fontSize: number; - lineHeight: number; - } - - export class FontInfo extends BareFontInfo { - _editorStylingBrand: void; - typicalHalfwidthCharacterWidth: number; - typicalFullwidthCharacterWidth: number; - spaceWidth: number; - maxDigitWidth: number; + readonly charChanges: ICharChange[]; } export interface INewScrollPosition { @@ -2808,13 +2820,13 @@ declare module monaco.editor { * Method that will be executed when the action is triggered. * @param editor The editor instance is passed in as a convinience */ - run: (editor: ICommonCodeEditor) => Promise; + run(editor: ICommonCodeEditor): void | Promise; } export interface IEditorAction { - id: string; - label: string; - alias: string; + readonly id: string; + readonly label: string; + readonly alias: string; isSupported(): boolean; run(): Promise; } @@ -2832,7 +2844,7 @@ declare module monaco.editor { * An event emitted when the language of the current model has changed. * @event */ - onDidChangeModelMode(listener: (e: IModelModeChangedEvent) => void): IDisposable; + onDidChangeModelLanguage(listener: (e: IModelLanguageChangedEvent) => void): IDisposable; /** * An event emitted when the options of the current model has changed. * @event @@ -2888,10 +2900,6 @@ declare module monaco.editor { * Returns true if this editor has keyboard focus (e.g. cursor is blinking). */ isFocused(): boolean; - /** - * Add a new action to this editor. - */ - addAction(descriptor: IActionDescriptor): void; /** * Returns all actions associated with this editor. */ @@ -3153,11 +3161,12 @@ declare module monaco.editor { */ pushUndoStop(): boolean; /** - * Execute a command on the editor. + * Execute edits on the editor. * @param source The source of the call. - * @param command The command to execute + * @param edits The edits to execute. + * @param endCursoState Cursor state after the edits were applied. */ - executeEdits(source: string, edits: IIdentifiedSingleEditOperation[]): boolean; + executeEdits(source: string, edits: IIdentifiedSingleEditOperation[], endCursoState?: Selection[]): boolean; /** * Execute multiple (concommitent) commands on the editor. * @param source The source of the call. @@ -3356,7 +3365,6 @@ declare module monaco.editor { ColumnSelect: string; CreateCursor: string; LastCursorMoveToSelect: string; - JumpToBracket: string; Type: string; ReplacePreviousChar: string; CompositionStart: string; @@ -3373,8 +3381,6 @@ declare module monaco.editor { DeleteWordRight: string; DeleteWordStartRight: string; DeleteWordEndRight: string; - DeleteAllLeft: string; - DeleteAllRight: string; RemoveSecondaryCursors: string; CancelSelection: string; Cut: string; @@ -3484,6 +3490,10 @@ declare module monaco.editor { * The dom node of the view zone */ domNode: HTMLElement; + /** + * An optional dom node for the view zone that will be placed in the margin area. + */ + marginDomNode?: HTMLElement; /** * Callback which gives the relative top of the view zone as it appears (taking scrolling into account). */ @@ -3627,35 +3637,35 @@ declare module monaco.editor { /** * The target element */ - element: Element; + readonly element: Element; /** * The target type */ - type: MouseTargetType; + readonly type: MouseTargetType; /** * The 'approximate' editor position */ - position: Position; + readonly position: Position; /** * Desired mouse column (e.g. when position.column gets clamped to text length -- clicking after text on a line). */ - mouseColumn: number; + readonly mouseColumn: number; /** * The 'approximate' editor range */ - range: Range; + readonly range: Range; /** * Some extra detail. */ - detail: any; + readonly detail: any; } /** * A mouse event originating from the editor. */ export interface IEditorMouseEvent { - event: IMouseEvent; - target: IMouseTarget; + readonly event: IMouseEvent; + readonly target: IMouseTarget; } /** @@ -3763,6 +3773,13 @@ declare module monaco.editor { * Get the vertical position (top offset) for the position w.r.t. to the first line. */ getTopForPosition(lineNumber: number, column: number): number; + /** + * Get the hit test target at coordinates `clientX` and `clientY`. + * The coordinates are relative to the top-left of the viewport. + * + * @returns Hit test target or null if the coordinates fall outside the editor or the editor has no model. + */ + getTargetAtClientPoint(clientX: number, clientY: number): IMouseTarget; /** * Get the visible position for `position`. * The result position takes scrolling into account and is relative to the top left corner of the editor. @@ -3790,6 +3807,22 @@ declare module monaco.editor { */ getDomNode(): HTMLElement; } + + export class FontInfo extends BareFontInfo { + readonly _editorStylingBrand: void; + readonly isMonospace: boolean; + readonly typicalHalfwidthCharacterWidth: number; + readonly typicalFullwidthCharacterWidth: number; + readonly spaceWidth: number; + readonly maxDigitWidth: number; + } + export class BareFontInfo { + readonly _bareFontInfoBrand: void; + readonly fontFamily: string; + readonly fontWeight: string; + readonly fontSize: number; + readonly lineHeight: number; + } } declare module monaco.languages { @@ -3807,6 +3840,7 @@ declare module monaco.languages { /** * An event emitted when a language is first time needed (e.g. a model has it set). + * @event */ export function onLanguage(languageId: string, callback: () => void): IDisposable; @@ -3815,6 +3849,43 @@ declare module monaco.languages { */ export function setLanguageConfiguration(languageId: string, configuration: LanguageConfiguration): IDisposable; + /** + * A token. + */ + export interface IToken { + startIndex: number; + scopes: string; + } + + /** + * The result of a line tokenization. + */ + export interface ILineTokens { + /** + * The list of tokens on the line. + */ + tokens: IToken[]; + /** + * The tokenization end state. + * A pointer will be held to this and the object should not be modified by the tokenizer after the pointer is returned. + */ + endState: IState; + } + + /** + * A "manual" provider of tokens. + */ + export interface TokensProvider { + /** + * The initial state of a language. Will be the state passed in to tokenize the first line. + */ + getInitialState(): IState; + /** + * Tokenize a line given the state at the beginning of the line. + */ + tokenize(line: string, state: IState): ILineTokens; + } + /** * Set the tokens provider for a language (manual implementation). */ @@ -3860,6 +3931,11 @@ declare module monaco.languages { */ export function registerDefinitionProvider(languageId: string, provider: DefinitionProvider): IDisposable; + /** + * Register a type definition provider (used by e.g. go to implementation). + */ + export function registerTypeDefinitionProvider(languageId: string, provider: TypeDefinitionProvider): IDisposable; + /** * Register a code lens provider (used by e.g. inline code lenses). */ @@ -3905,7 +3981,7 @@ declare module monaco.languages { * * @readonly */ - markers: editor.IMarkerData[]; + readonly markers: editor.IMarkerData[]; } /** @@ -3941,6 +4017,7 @@ declare module monaco.languages { Color = 15, File = 16, Reference = 17, + Folder = 18, } /** @@ -4144,51 +4221,77 @@ declare module monaco.languages { export interface IBracketElectricCharacterContribution { docComment?: IDocComment; - embeddedElectricCharacters?: string[]; } /** * Definition of documentation comments (e.g. Javadoc/JSdoc) */ export interface IDocComment { - scope: string; + /** + * The string that starts a doc comment (e.g. '/**') + */ open: string; - lineStart: string; - close?: string; + /** + * The string that appears on the last line and closes the doc comment (e.g. ' * /'). + */ + close: string; } /** - * A mode. Will soon be obsolete. + * A tuple of two characters, like a pair of + * opening and closing brackets. */ - export interface IMode { - getId(): string; + export type CharacterPair = [string, string]; + + export interface IAutoClosingPair { + open: string; + close: string; + } + + export interface IAutoClosingPairConditional extends IAutoClosingPair { + notIn?: string[]; } /** - * A token. Only supports a single scope, but will soon support a scope array. + * Describes what to do with the indentation when pressing Enter. */ - export interface IToken { - startIndex: number; - scopes: string | string[]; + export enum IndentAction { + /** + * Insert new line and copy the previous line's indentation. + */ + None = 0, + /** + * Insert new line and indent once (relative to the previous line's indentation). + */ + Indent = 1, + /** + * Insert two new lines: + * - the first one indented which will hold the cursor + * - the second one at the same indentation level + */ + IndentOutdent = 2, + /** + * Insert new line and outdent once (relative to the previous line's indentation). + */ + Outdent = 3, } /** - * The result of a line tokenization. + * Describes what to do when pressing Enter. */ - export interface ILineTokens { + export interface EnterAction { /** - * The list of tokens on the line. + * Describe what to do with the indentation. */ - tokens: IToken[]; + indentAction: IndentAction; /** - * The tokenization end state. - * A pointer will be held to this and the object should not be modified by the tokenizer after the pointer is returned. + * Describes text to be appended after the new line and after the indentation. */ - endState: IState; + appendText?: string; /** - * An optional promise to force the model to retokenize this line (e.g. missing information at the point of tokenization) + * Describes the number of characters to remove from the new line's indentation. */ - retokenize?: Promise; + removeText?: number; } /** @@ -4201,20 +4304,6 @@ declare module monaco.languages { equals(other: IState): boolean; } - /** - * A "manual" provider of tokens. - */ - export interface TokensProvider { - /** - * The initial state of a language. Will be the state passed in to tokenize the first line. - */ - getInitialState(): IState; - /** - * Tokenize a line given the state at the beginning of the line. - */ - tokenize(line: string, state: IState): ILineTokens; - } - /** * A hover represents additional information for a symbol or word. Hovers are * rendered in a tooltip-like widget. @@ -4267,7 +4356,7 @@ declare module monaco.languages { * The human-readable doc-comment of this signature. Will be shown * in the UI but can be omitted. */ - documentation: string; + documentation?: string; } /** @@ -4285,7 +4374,7 @@ declare module monaco.languages { * The human-readable doc-comment of this signature. Will be shown * in the UI but can be omitted. */ - documentation: string; + documentation?: string; /** * The parameters of this signature. */ @@ -4426,6 +4515,17 @@ declare module monaco.languages { provideDefinition(model: editor.IReadOnlyModel, position: Position, token: CancellationToken): Definition | Thenable; } + /** + * The type definition provider interface defines the contract between extensions and + * the go to implementation feature. + */ + export interface TypeDefinitionProvider { + /** + * Provide the implementation of the symbol at the given position and document. + */ + provideTypeDefinition(model: editor.IReadOnlyModel, position: Position, token: CancellationToken): Definition | Thenable; + } + /** * A symbol kind. */ @@ -4587,67 +4687,11 @@ declare module monaco.languages { } export interface CodeLensProvider { + onDidChange?: IEvent; provideCodeLenses(model: editor.IReadOnlyModel, token: CancellationToken): ICodeLensSymbol[] | Thenable; resolveCodeLens?(model: editor.IReadOnlyModel, codeLens: ICodeLensSymbol, token: CancellationToken): ICodeLensSymbol | Thenable; } - /** - * A tuple of two characters, like a pair of - * opening and closing brackets. - */ - export type CharacterPair = [string, string]; - - export interface IAutoClosingPairConditional extends IAutoClosingPair { - notIn?: string[]; - } - - /** - * Describes what to do with the indentation when pressing Enter. - */ - export enum IndentAction { - /** - * Insert new line and copy the previous line's indentation. - */ - None = 0, - /** - * Insert new line and indent once (relative to the previous line's indentation). - */ - Indent = 1, - /** - * Insert two new lines: - * - the first one indented which will hold the cursor - * - the second one at the same indentation level - */ - IndentOutdent = 2, - /** - * Insert new line and outdent once (relative to the previous line's indentation). - */ - Outdent = 3, - } - - /** - * Describes what to do when pressing Enter. - */ - export interface EnterAction { - /** - * Describe what to do with the indentation. - */ - indentAction: IndentAction; - /** - * Describes text to be appended after the new line and after the indentation. - */ - appendText?: string; - /** - * Describes the number of characters to remove from the new line's indentation. - */ - removeText?: number; - } - - export interface IAutoClosingPair { - open: string; - close: string; - } - export interface ILanguageExtensionPoint { id: string; extensions?: string[]; @@ -4778,8 +4822,8 @@ declare module monaco.worker { export interface IMirrorModel { - uri: Uri; - version: number; + readonly uri: Uri; + readonly version: number; getValue(): string; } @@ -4794,33 +4838,32 @@ declare module monaco.worker { declare module monaco.languages.typescript { - export enum ModuleKind { + enum ModuleKind { None = 0, CommonJS = 1, AMD = 2, UMD = 3, System = 4, - ES6 = 5, ES2015 = 5, } - - export enum JsxEmit { + enum JsxEmit { None = 0, Preserve = 1, React = 2, } - - export enum NewLineKind { + enum NewLineKind { CarriageReturnLineFeed = 0, LineFeed = 1, } - export enum ScriptTarget { + enum ScriptTarget { ES3 = 0, ES5 = 1, - ES6 = 2, ES2015 = 2, - Latest = 2, + ES2016 = 3, + ES2017 = 4, + ESNext = 5, + Latest = 5, } export enum ModuleResolutionKind { @@ -4828,58 +4871,70 @@ declare module monaco.languages.typescript { NodeJs = 2, } + type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[]; interface CompilerOptions { - allowNonTsExtensions?: boolean; + allowJs?: boolean; + allowSyntheticDefaultImports?: boolean; + allowUnreachableCode?: boolean; + allowUnusedLabels?: boolean; + alwaysStrict?: boolean; + baseUrl?: string; charset?: string; declaration?: boolean; - diagnostics?: boolean; + declarationDir?: string; + disableSizeLimit?: boolean; emitBOM?: boolean; - help?: boolean; - init?: boolean; + emitDecoratorMetadata?: boolean; + experimentalDecorators?: boolean; + forceConsistentCasingInFileNames?: boolean; + importHelpers?: boolean; inlineSourceMap?: boolean; inlineSources?: boolean; + isolatedModules?: boolean; jsx?: JsxEmit; - reactNamespace?: string; - listFiles?: boolean; + lib?: string[]; locale?: string; mapRoot?: string; + maxNodeModuleJsDepth?: number; module?: ModuleKind; + moduleResolution?: ModuleResolutionKind; newLine?: NewLineKind; noEmit?: boolean; noEmitHelpers?: boolean; noEmitOnError?: boolean; noErrorTruncation?: boolean; + noFallthroughCasesInSwitch?: boolean; noImplicitAny?: boolean; + noImplicitReturns?: boolean; + noImplicitThis?: boolean; + noUnusedLocals?: boolean; + noUnusedParameters?: boolean; + noImplicitUseStrict?: boolean; noLib?: boolean; noResolve?: boolean; out?: string; - outFile?: string; outDir?: string; + outFile?: string; preserveConstEnums?: boolean; project?: string; + reactNamespace?: string; + jsxFactory?: string; removeComments?: boolean; rootDir?: string; + rootDirs?: string[]; + skipLibCheck?: boolean; + skipDefaultLibCheck?: boolean; sourceMap?: boolean; sourceRoot?: string; + strictNullChecks?: boolean; suppressExcessPropertyErrors?: boolean; suppressImplicitAnyIndexErrors?: boolean; target?: ScriptTarget; - version?: boolean; - watch?: boolean; - isolatedModules?: boolean; - experimentalDecorators?: boolean; - emitDecoratorMetadata?: boolean; - moduleResolution?: ModuleResolutionKind; - allowUnusedLabels?: boolean; - allowUnreachableCode?: boolean; - noImplicitReturns?: boolean; - noFallthroughCasesInSwitch?: boolean; - forceConsistentCasingInFileNames?: boolean; - allowSyntheticDefaultImports?: boolean; - allowJs?: boolean; - noImplicitUseStrict?: boolean; - disableSizeLimit?: boolean; - [option: string]: string | number | boolean; + traceResolution?: boolean; + types?: string[]; + /** Paths used to compute primary types search locations */ + typeRoots?: string[]; + [option: string]: CompilerOptionsValue | undefined; } export interface DiagnosticsOptions {