diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c0e602c..209a5a88 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,34 @@ # Monaco Editor Change log +## [0.7.0] + - Adopted TypeScript 2.0 in all the repos (also reflected in `monaco.d.ts`). + - Added YAML colorization support. + - Brought back the ability to use `editor.addAction()` and have the action show in the context menu. + - Web workers now get a nice label next to the script name. + +### API changes: + - settings: + - new values for `lineNumbers`: `'on' | 'off' | 'relative'` + - new values for `renderWhitespace`: `'none' | 'boundary' | 'all'` + - removed `model.setMode()`, as `IMode` will soon disappear from the API. + +### Debt work + - Removed html, razor, php and handlebars from `monaco-editor-core`: + - the `monaco-editor-core` is now finally language agnostic. + - coloring for html, razor, php and handlebars is now coming in from `monaco-languages`. + - language smarts for html, razor and handlebars now comes from `monaco-html`. + - Packaging improvements: + - thanks to the removal of the old languages from `monaco-editor-core`, we could improve the bundling and reduce the number of .js files we ship. + - we are thinking about simplifying this further in the upcoming releases. + +### Thank you + * [Sandy Armstrong (@sandyarmstrong)](https://github.com/sandyarmstrong): csharp: allow styling #r/#load [PR monaco-languages#9](https://github.com/Microsoft/monaco-languages/pull/9) + * [Nico Tonozzi (@nicot)](https://github.com/nicot): Go: add raw string literal syntax [PR monaco-languages#10](https://github.com/Microsoft/monaco-languages/pull/10) + * [Jason Killian (@JKillian)](https://github.com/JKillian): Add vmin and vmax CSS units [PR monaco-languages#11](https://github.com/Microsoft/monaco-languages/pull/11) + * [Jan Pilzer (@Hirse)](https://github.com/Hirse): YAML colorization [PR monaco-languages#12](https://github.com/Microsoft/monaco-languages/pull/12) + * [Sam El-Husseini (@microsoftsam)](https://github.com/microsoftsam): Using Cmd+Scroll to zoom on a mac [PR vscode#12477](https://github.com/Microsoft/vscode/pull/12477) + + ## [0.6.1] - Fixed regression where `editor.addCommand` was no longer working. diff --git a/package.json b/package.json index 0ff6481a..638646d6 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "monaco-editor", "private": true, - "version": "0.6.1", + "version": "0.7.0", "description": "A browser based code editor", "author": "Microsoft Corporation", "license": "MIT", diff --git a/website/playground/monaco.d.ts.txt b/website/playground/monaco.d.ts.txt index d421563c..7667272b 100644 --- a/website/playground/monaco.d.ts.txt +++ b/website/playground/monaco.d.ts.txt @@ -75,17 +75,21 @@ declare module monaco { public cancel(): void; public static as(value: ValueType): Promise; - public static is(value: any): value is Promise; + public static is(value: any): value is Thenable; public static timeout(delay: number): Promise; public static join(promises: Promise[]): Promise; public static join(promises: Thenable[]): Thenable; public static join(promises: { [n: string]: Promise }): Promise<{ [n: string]: ValueType }>; public static any(promises: Promise[]): Promise<{ key: string; value: Promise; }>; + + public static wrap(value: Thenable): Promise; + public static wrap(value: ValueType): Promise; + public static wrapError(error: any): Promise; } export class CancellationTokenSource { - token: CancellationToken; + readonly token: CancellationToken; cancel(): void; dispose(): void; } @@ -112,36 +116,36 @@ declare module monaco { */ export class Uri { static isUri(thing: any): thing is Uri; - constructor(); + protected constructor(); /** * scheme is the 'http' part of 'http://www.msft.com/some/path?query#fragment'. * The part before the first colon. */ - scheme: string; + readonly scheme: string; /** * authority is the 'www.msft.com' part of 'http://www.msft.com/some/path?query#fragment'. * The part between the first double slashes and the next slash. */ - authority: string; + readonly authority: string; /** * path is the '/some/path' part of 'http://www.msft.com/some/path?query#fragment'. */ - path: string; + readonly path: string; /** * query is the 'query' part of 'http://www.msft.com/some/path?query#fragment'. */ - query: string; + readonly query: string; /** * fragment is the 'fragment' part of 'http://www.msft.com/some/path?query#fragment'. */ - fragment: string; + readonly fragment: string; /** * Returns a string representing the corresponding file system path of this Uri. * Will handle UNC paths and normalize windows drive letters to lower-case. Also * uses the platform specific path separator. Will *not* validate the path for * invalid characters and semantics. Will *not* look at the scheme of this Uri. */ - fsPath: string; + readonly fsPath: string; with(change: { scheme?: string; authority?: string; @@ -337,6 +341,7 @@ declare module monaco { NUMPAD_DIVIDE = 108, /** * Placed last to cover the length of the enum. + * Please do not depend on this value! */ MAX_VALUE = 109, } @@ -740,14 +745,14 @@ declare module monaco.editor { * `domElement` should be empty (not contain other dom nodes). * The editor will read the size of `domElement`. */ - export function create(domElement: HTMLElement, options?: IEditorConstructionOptions, services?: IEditorOverrideServices): IStandaloneCodeEditor; + export function create(domElement: HTMLElement, options?: IEditorConstructionOptions, override?: IEditorOverrideServices): IStandaloneCodeEditor; /** * Create a new diff editor under `domElement`. * `domElement` should be empty (not contain other dom nodes). * The editor will read the size of `domElement`. */ - export function createDiffEditor(domElement: HTMLElement, options?: IDiffEditorConstructionOptions, services?: IEditorOverrideServices): IStandaloneDiffEditor; + export function createDiffEditor(domElement: HTMLElement, options?: IDiffEditorConstructionOptions, override?: IEditorOverrideServices): IStandaloneDiffEditor; export interface IDiffNavigator { canNavigate(): boolean; @@ -808,6 +813,27 @@ declare module monaco.editor { oldLanguage: string; }) => void): IDisposable; + /** + * Create a new web worker that has model syncing capabilities built in. + * Specify an AMD module to load that will `create` an object that will be proxied. + */ + export function createWebWorker(opts: IWebWorkerOptions): MonacoWebWorker; + + /** + * Colorize the contents of `domNode` using attribute `data-lang`. + */ + export function colorizeElement(domNode: HTMLElement, options: IColorizerElementOptions): Promise; + + /** + * Colorize `text` using language `languageId`. + */ + export function colorize(text: string, languageId: string, options: IColorizerOptions): Promise; + + /** + * Colorize a line in a model. + */ + export function colorizeModelLine(model: IModel, lineNumber: number, tabSize?: number): string; + /** * A web worker that can provide a proxy to an arbitrary file. */ @@ -837,29 +863,12 @@ declare module monaco.editor { * The data to send over when calling create on the module. */ createData?: any; + /** + * A label to be used to identify the web worker for debugging purposes. + */ + label?: string; } - /** - * Create a new web worker that has model syncing capabilities built in. - * Specify an AMD module to load that will `create` an object that will be proxied. - */ - export function createWebWorker(opts: IWebWorkerOptions): MonacoWebWorker; - - /** - * Colorize the contents of `domNode` using attribute `data-lang`. - */ - export function colorizeElement(domNode: HTMLElement, options: IColorizerElementOptions): Promise; - - /** - * Colorize `text` using language `languageId`. - */ - export function colorize(text: string, languageId: string, options: IColorizerOptions): Promise; - - /** - * Colorize a line in a model. - */ - export function colorizeModelLine(model: IModel, lineNumber: number, tabSize?: number): string; - /** * The options to create an editor. */ @@ -1026,6 +1035,8 @@ declare module monaco.editor { Indent = 2, } + export type LineNumbersOption = 'on' | 'off' | 'relative' | ((lineNumber: number) => string); + /** * Configuration options for the editor. */ @@ -1061,7 +1072,7 @@ declare module monaco.editor { * Otherwise, line numbers will not be rendered. * Defaults to true. */ - lineNumbers?: any; + lineNumbers?: LineNumbersOption; /** * Should the corresponding line be selected when clicking on the line number? * Defaults to true. @@ -1278,10 +1289,10 @@ declare module monaco.editor { */ folding?: boolean; /** - * Enable rendering of leading whitespace. - * Defaults to false. + * Enable rendering of whitespace. + * Defaults to none. */ - renderWhitespace?: boolean; + renderWhitespace?: 'none' | 'boundary' | 'all'; /** * Enable rendering of control characters. * Defaults to false. @@ -1378,7 +1389,9 @@ declare module monaco.editor { experimentalScreenReader: boolean; rulers: number[]; ariaLabel: string; - lineNumbers: any; + renderLineNumbers: boolean; + renderCustomLineNumbers: (lineNumber: number) => string; + renderRelativeLineNumbers: boolean; selectOnLineNumbers: boolean; glyphMargin: boolean; revealHorizontalRightPadding: number; @@ -1391,7 +1404,7 @@ declare module monaco.editor { scrollBeyondLastLine: boolean; editorClassName: string; stopRenderingLineAfter: number; - renderWhitespace: boolean; + renderWhitespace: 'none' | 'boundary' | 'all'; renderControlCharacters: boolean; renderIndentGuides: boolean; renderLineHighlight: boolean; @@ -1404,7 +1417,9 @@ declare module monaco.editor { experimentalScreenReader: boolean; rulers: boolean; ariaLabel: boolean; - lineNumbers: boolean; + renderLineNumbers: boolean; + renderCustomLineNumbers: boolean; + renderRelativeLineNumbers: boolean; selectOnLineNumbers: boolean; glyphMargin: boolean; revealHorizontalRightPadding: boolean; @@ -1948,6 +1963,48 @@ declare module monaco.editor { * Returns iff the model was disposed or not. */ isDisposed(): boolean; + /** + * Search the model. + * @param searchString The string used to search. If it is a regular expression, set `isRegex` to true. + * @param searchOnlyEditableRange Limit the searching to only search inside the editable range of the model. + * @param isRegex Used to indicate that `searchString` is a regular expression. + * @param matchCase Force the matching to match lower/upper case exactly. + * @param wholeWord Force the matching to match entire words only. + * @param 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[]; + /** + * Search the model. + * @param searchString The string used to search. If it is a regular expression, set `isRegex` to true. + * @param searchScope Limit the searching to only search inside this range. + * @param isRegex Used to indicate that `searchString` is a regular expression. + * @param matchCase Force the matching to match lower/upper case exactly. + * @param wholeWord Force the matching to match entire words only. + * @param 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[]; + /** + * Search the model for the next match. Loops to the beginning of the model if needed. + * @param searchString The string used to search. If it is a regular expression, set `isRegex` to true. + * @param searchStart Start the searching at the specified position. + * @param isRegex Used to indicate that `searchString` is a regular expression. + * @param matchCase Force the matching to match lower/upper case exactly. + * @param wholeWord Force the matching to match entire words only. + * @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; + /** + * Search the model for the previous match. Loops to the end of the model if needed. + * @param searchString The string used to search. If it is a regular expression, set `isRegex` to true. + * @param searchStart Start the searching at the specified position. + * @param isRegex Used to indicate that `searchString` is a regular expression. + * @param matchCase Force the matching to match lower/upper case exactly. + * @param wholeWord Force the matching to match entire words only. + * @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; } export interface IReadOnlyModel extends ITextModel { @@ -1984,9 +2041,9 @@ declare module monaco.editor { */ getMode(): languages.IMode; /** - * Set the current language mode associated with the model. + * Get the language associated with this model. */ - setMode(newMode: languages.IMode | Promise): void; + getModeId(): string; /** * Get the word under or besides `position`. * @param position The position to look for a word. @@ -2163,48 +2220,6 @@ declare module monaco.editor { * and make all necessary clean-up to release this object to the GC. */ dispose(): void; - /** - * Search the model. - * @param searchString The string used to search. If it is a regular expression, set `isRegex` to true. - * @param searchOnlyEditableRange Limit the searching to only search inside the editable range of the model. - * @param isRegex Used to indicate that `searchString` is a regular expression. - * @param matchCase Force the matching to match lower/upper case exactly. - * @param wholeWord Force the matching to match entire words only. - * @param 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[]; - /** - * Search the model. - * @param searchString The string used to search. If it is a regular expression, set `isRegex` to true. - * @param searchScope Limit the searching to only search inside this range. - * @param isRegex Used to indicate that `searchString` is a regular expression. - * @param matchCase Force the matching to match lower/upper case exactly. - * @param wholeWord Force the matching to match entire words only. - * @param 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[]; - /** - * Search the model for the next match. Loops to the beginning of the model if needed. - * @param searchString The string used to search. If it is a regular expression, set `isRegex` to true. - * @param searchStart Start the searching at the specified position. - * @param isRegex Used to indicate that `searchString` is a regular expression. - * @param matchCase Force the matching to match lower/upper case exactly. - * @param wholeWord Force the matching to match entire words only. - * @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; - /** - * Search the model for the previous match. Loops to the end of the model if needed. - * @param searchString The string used to search. If it is a regular expression, set `isRegex` to true. - * @param searchStart Start the searching at the specified position. - * @param isRegex Used to indicate that `searchString` is a regular expression. - * @param matchCase Force the matching to match lower/upper case exactly. - * @param wholeWord Force the matching to match entire words only. - * @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; } /** @@ -2761,6 +2776,20 @@ declare module monaco.editor { * An array of keybindings for the action. */ keybindings?: number[]; + /** + * Control if the action should show up in the context menu and where. + * The context menu of the editor has these default: + * navigation - The navigation group comes first in all cases. + * 1_modification - This group comes next and contains commands that modify your code. + * 9_cutcopypaste - The last default group with the basic editing commands. + * You can also create your own group. + * Defaults to null (don't show in context menu). + */ + contextMenuGroupId?: string; + /** + * Control the order in the context menu group. + */ + contextMenuOrder?: number; /** * The keybinding rule. */ @@ -4018,8 +4047,8 @@ declare module monaco.languages { */ indentationRules?: IndentationRule; /** - * The language's rules to be evaluated when pressing Enter. - */ + * The language's rules to be evaluated when pressing Enter. + */ onEnterRules?: OnEnterRule[]; /** * The language's auto closing pairs. The 'close' character is automatically inserted with the @@ -4870,38 +4899,38 @@ declare module monaco.languages.typescript { * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ declare module monaco.languages.css { - export interface DiagnosticsOptions { - validate?: boolean; - lint?: { - compatibleVendorPrefixes?: 'ignore' | 'warning' | 'error', - vendorPrefix?: 'ignore' | 'warning' | 'error', - duplicateProperties?: 'ignore' | 'warning' | 'error', - emptyRules?: 'ignore' | 'warning' | 'error', - importStatement?: 'ignore' | 'warning' | 'error', - boxModel?: 'ignore' | 'warning' | 'error', - universalSelector?: 'ignore' | 'warning' | 'error', - zeroUnits?: 'ignore' | 'warning' | 'error', - fontFaceProperties?: 'ignore' | 'warning' | 'error', - hexColorLength?: 'ignore' | 'warning' | 'error', - argumentsInColorFunction?: 'ignore' | 'warning' | 'error', - unknownProperties?: 'ignore' | 'warning' | 'error', - ieHack?: 'ignore' | 'warning' | 'error', - unknownVendorSpecificProperties?: 'ignore' | 'warning' | 'error', - propertyIgnoredDueToDisplay?: 'ignore' | 'warning' | 'error', - important?: 'ignore' | 'warning' | 'error', - float?: 'ignore' | 'warning' | 'error', - idSelector?: 'ignore' | 'warning' | 'error' + export interface DiagnosticsOptions { + readonly validate?: boolean; + readonly lint?: { + readonly compatibleVendorPrefixes?: 'ignore' | 'warning' | 'error', + readonly vendorPrefix?: 'ignore' | 'warning' | 'error', + readonly duplicateProperties?: 'ignore' | 'warning' | 'error', + readonly emptyRules?: 'ignore' | 'warning' | 'error', + readonly importStatement?: 'ignore' | 'warning' | 'error', + readonly boxModel?: 'ignore' | 'warning' | 'error', + readonly universalSelector?: 'ignore' | 'warning' | 'error', + readonly zeroUnits?: 'ignore' | 'warning' | 'error', + readonly fontFaceProperties?: 'ignore' | 'warning' | 'error', + readonly hexColorLength?: 'ignore' | 'warning' | 'error', + readonly argumentsInColorFunction?: 'ignore' | 'warning' | 'error', + readonly unknownProperties?: 'ignore' | 'warning' | 'error', + readonly ieHack?: 'ignore' | 'warning' | 'error', + readonly unknownVendorSpecificProperties?: 'ignore' | 'warning' | 'error', + readonly propertyIgnoredDueToDisplay?: 'ignore' | 'warning' | 'error', + readonly important?: 'ignore' | 'warning' | 'error', + readonly float?: 'ignore' | 'warning' | 'error', + readonly idSelector?: 'ignore' | 'warning' | 'error' } - } + } - export interface LanguageServiceDefaults { - onDidChange: IEvent; - diagnosticsOptions: DiagnosticsOptions; - setDiagnosticsOptions(options: DiagnosticsOptions): void; - } + export interface LanguageServiceDefaults { + readonly onDidChange: IEvent; + readonly diagnosticsOptions: DiagnosticsOptions; + setDiagnosticsOptions(options: DiagnosticsOptions): void; + } - export var cssDefaults: LanguageServiceDefaults; - export var lessDefaults: LanguageServiceDefaults; + export var cssDefaults: LanguageServiceDefaults; + export var lessDefaults: LanguageServiceDefaults; export var scssDefaults: LanguageServiceDefaults; } /*--------------------------------------------------------------------------------------------- @@ -4914,35 +4943,79 @@ declare module monaco.languages.json { /** * If set, the validator will be enabled and perform syntax validation as well as schema based validation. */ - validate?: boolean; + readonly validate?: boolean; /** * If set, comments are tolerated. If set to false, syntax errors will be emmited for comments. */ - allowComments?: boolean; + readonly allowComments?: boolean; /** * A list of known schemas and/or associations of schemas to file names. */ - schemas?: { + readonly schemas?: { /** * The URI of the schema, which is also the identifier of the schema. */ - uri: string; + readonly uri: string; /** * A list of file names that are associated to the schema. The '*' wildcard can be used. For example '*.schema.json', 'package.json' */ - fileMatch?: string[]; + readonly fileMatch?: string[]; /** * The schema for the given URI. */ - schema?: any; + readonly schema?: any; }[]; } export interface LanguageServiceDefaults { - onDidChange: IEvent; - diagnosticsOptions: DiagnosticsOptions; + readonly onDidChange: IEvent; + readonly diagnosticsOptions: DiagnosticsOptions; setDiagnosticsOptions(options: DiagnosticsOptions): void; } export var jsonDefaults: LanguageServiceDefaults; +} +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +declare module monaco.languages.html { + export interface HTMLFormatConfiguration { + readonly tabSize: number; + readonly insertSpaces: boolean; + readonly wrapLineLength: number; + readonly unformatted: string; + readonly indentInnerHtml: boolean; + readonly preserveNewLines: boolean; + readonly maxPreserveNewLines: number; + readonly indentHandlebars: boolean; + readonly endWithNewline: boolean; + readonly extraLiners: string; + } + + export interface CompletionConfiguration { + [provider: string]: boolean; + } + + export interface Options { + /** + * If set, comments are tolerated. If set to false, syntax errors will be emmited for comments. + */ + readonly format?: HTMLFormatConfiguration; + /** + * A list of known schemas and/or associations of schemas to file names. + */ + readonly suggest?: CompletionConfiguration; + } + + export interface LanguageServiceDefaults { + readonly onDidChange: IEvent; + readonly options: Options; + setOptions(options: Options): void; + } + + export var htmlDefaults: LanguageServiceDefaults; + export var handlebarDefaults: LanguageServiceDefaults; + export var razorDefaults: LanguageServiceDefaults; } \ No newline at end of file