Adopt latest `monaco-editor-core`

pull/2894/head
Alex Dima 3 years ago
parent a385674a34
commit 3159d3d6c9
No known key found for this signature in database
GPG Key ID: 39563C1504FDD0C9

@ -5,6 +5,8 @@
### Breaking Changes ### Breaking Changes
- The binary format for `IEncodedLineTokens` has changed to support strikethrough text. - The binary format for `IEncodedLineTokens` has changed to support strikethrough text.
- `IDiffEditor.getDomNode()` has been renamed to `IDiffEditor.getContainerDomNode()`.
- `InlayHint.text` has been replaced by `InlayHint.label` and `InlayHintsProvider.provideInlayHints` now returns an `InlayHintList`.
## [0.31.1] (14.12.2021) ## [0.31.1] (14.12.2021)

6
package-lock.json generated

@ -1159,9 +1159,9 @@
} }
}, },
"monaco-editor-core": { "monaco-editor-core": {
"version": "0.32.0-dev.20211228", "version": "0.32.0-dev.20220110",
"resolved": "https://registry.npmjs.org/monaco-editor-core/-/monaco-editor-core-0.32.0-dev.20211228.tgz", "resolved": "https://registry.npmjs.org/monaco-editor-core/-/monaco-editor-core-0.32.0-dev.20220110.tgz",
"integrity": "sha512-7Cup6hu+EkpjW5Er6nSlSCQEJziJKiddd8vUJ+12Sgloo9KtnirzuoI69KeTYsFRVay8sUgeaZS0Bii0caTqSA==", "integrity": "sha512-XF6xIUAmziM57p+lorG3IXHg0jCuxIL6mqv0WhXcSmtg4oEJFAQy/aT9+3fDbDIyJ+b0oSJga2e38K5PH5ajJQ==",
"dev": true "dev": true
}, },
"mri": { "mri": {

@ -41,7 +41,7 @@
"jsdom": "^18.1.0", "jsdom": "^18.1.0",
"jsonc-parser": "^3.0.0", "jsonc-parser": "^3.0.0",
"mocha": "^9.1.3", "mocha": "^9.1.3",
"monaco-editor-core": "0.32.0-dev.20211228", "monaco-editor-core": "0.32.0-dev.20220110",
"playwright": "^1.16.3", "playwright": "^1.16.3",
"prettier": "^2.4.1", "prettier": "^2.4.1",
"pretty-quick": "^3.1.1", "pretty-quick": "^3.1.1",

@ -1224,7 +1224,7 @@ export class InlayHintsAdapter extends Adapter implements languages.InlayHintsPr
model: editor.ITextModel, model: editor.ITextModel,
range: Range, range: Range,
token: CancellationToken token: CancellationToken
): Promise<languages.InlayHint[]> { ): Promise<languages.InlayHintList | null> {
const resource = model.uri; const resource = model.uri;
const fileName = resource.toString(); const fileName = resource.toString();
const start = model.getOffsetAt({ const start = model.getOffsetAt({
@ -1237,18 +1237,19 @@ export class InlayHintsAdapter extends Adapter implements languages.InlayHintsPr
}); });
const worker = await this._worker(resource); const worker = await this._worker(resource);
if (model.isDisposed()) { if (model.isDisposed()) {
return []; return null;
} }
const hints = await worker.provideInlayHints(fileName, start, end); const tsHints = await worker.provideInlayHints(fileName, start, end);
const hints: languages.InlayHint[] = tsHints.map((hint) => {
return hints.map((hint) => {
return { return {
...hint, ...hint,
label: hint.text,
position: model.getPositionAt(hint.position), position: model.getPositionAt(hint.position),
kind: this._convertHintKind(hint.kind) kind: this._convertHintKind(hint.kind)
}; };
}); });
return { hints, dispose: () => {} };
} }
private _convertHintKind(kind?: ts.InlayHintKind) { private _convertHintKind(kind?: ts.InlayHintKind) {

@ -1506,6 +1506,11 @@ declare namespace monaco.editor {
* If there is an `inlineClassName` which affects letter spacing. * If there is an `inlineClassName` which affects letter spacing.
*/ */
readonly inlineClassNameAffectsLetterSpacing?: boolean; readonly inlineClassNameAffectsLetterSpacing?: boolean;
/**
* This field allows to attach data to this injected text.
* The data can be read when injected texts at a given position are queried.
*/
readonly attachedData?: unknown;
} }
/** /**
@ -3305,6 +3310,7 @@ declare namespace monaco.editor {
*/ */
guides?: IGuidesOptions; guides?: IGuidesOptions;
unicodeHighlight?: IUnicodeHighlightOptions; unicodeHighlight?: IUnicodeHighlightOptions;
bracketPairColorization?: IBracketPairColorizationOptions;
} }
export interface IDiffEditorBaseOptions { export interface IDiffEditorBaseOptions {
@ -3379,8 +3385,8 @@ declare namespace monaco.editor {
get<T extends EditorOption>(id: T): FindComputedEditorOptionValueById<T>; get<T extends EditorOption>(id: T): FindComputedEditorOptionValueById<T>;
} }
export interface IEditorOption<K1 extends EditorOption, V> { export interface IEditorOption<K extends EditorOption, V> {
readonly id: K1; readonly id: K;
readonly name: string; readonly name: string;
defaultValue: V; defaultValue: V;
/** /**
@ -4541,6 +4547,9 @@ declare namespace monaco.editor {
* Render this content widget in a location where it could overflow the editor's view dom node. * Render this content widget in a location where it could overflow the editor's view dom node.
*/ */
allowEditorOverflow?: boolean; allowEditorOverflow?: boolean;
/**
* Call preventDefault() on mousedown events that target the content widget.
*/
suppressMouseDown?: boolean; suppressMouseDown?: boolean;
/** /**
* Get a unique identifier of the content widget. * Get a unique identifier of the content widget.
@ -4678,18 +4687,11 @@ declare namespace monaco.editor {
OUTSIDE_EDITOR = 13 OUTSIDE_EDITOR = 13
} }
/** export interface IBaseMouseTarget {
* Target hit with the mouse in the editor.
*/
export interface IMouseTarget {
/** /**
* The target element * The target element
*/ */
readonly element: Element | null; readonly element: Element | null;
/**
* The target type
*/
readonly type: MouseTargetType;
/** /**
* The 'approximate' editor position * The 'approximate' editor position
*/ */
@ -4702,11 +4704,103 @@ declare namespace monaco.editor {
* The 'approximate' editor range * The 'approximate' editor range
*/ */
readonly range: Range | null; readonly range: Range | null;
}
export interface IMouseTargetUnknown extends IBaseMouseTarget {
readonly type: MouseTargetType.UNKNOWN;
}
export interface IMouseTargetTextarea extends IBaseMouseTarget {
readonly type: MouseTargetType.TEXTAREA;
readonly position: null;
readonly range: null;
}
export interface IMouseTargetMarginData {
readonly isAfterLines: boolean;
readonly glyphMarginLeft: number;
readonly glyphMarginWidth: number;
readonly lineNumbersWidth: number;
readonly offsetX: number;
}
export interface IMouseTargetMargin extends IBaseMouseTarget {
readonly type: MouseTargetType.GUTTER_GLYPH_MARGIN | MouseTargetType.GUTTER_LINE_NUMBERS | MouseTargetType.GUTTER_LINE_DECORATIONS;
readonly position: Position;
readonly range: Range;
readonly detail: IMouseTargetMarginData;
}
export interface IMouseTargetViewZoneData {
readonly viewZoneId: string;
readonly positionBefore: Position | null;
readonly positionAfter: Position | null;
readonly position: Position;
readonly afterLineNumber: number;
}
export interface IMouseTargetViewZone extends IBaseMouseTarget {
readonly type: MouseTargetType.GUTTER_VIEW_ZONE | MouseTargetType.CONTENT_VIEW_ZONE;
readonly position: Position;
readonly range: Range;
readonly detail: IMouseTargetViewZoneData;
}
export interface IMouseTargetContentTextData {
readonly mightBeForeignElement: boolean;
}
export interface IMouseTargetContentText extends IBaseMouseTarget {
readonly type: MouseTargetType.CONTENT_TEXT;
readonly position: Position;
readonly range: Range;
readonly detail: IMouseTargetContentTextData;
}
export interface IMouseTargetContentEmptyData {
readonly isAfterLines: boolean;
readonly horizontalDistanceToText?: number;
}
export interface IMouseTargetContentEmpty extends IBaseMouseTarget {
readonly type: MouseTargetType.CONTENT_EMPTY;
readonly position: Position;
readonly range: Range;
readonly detail: IMouseTargetContentEmptyData;
}
export interface IMouseTargetContentWidget extends IBaseMouseTarget {
readonly type: MouseTargetType.CONTENT_WIDGET;
readonly position: null;
readonly range: null;
readonly detail: string;
}
export interface IMouseTargetOverlayWidget extends IBaseMouseTarget {
readonly type: MouseTargetType.OVERLAY_WIDGET;
readonly position: null;
readonly range: null;
readonly detail: string;
}
export interface IMouseTargetScrollbar extends IBaseMouseTarget {
readonly type: MouseTargetType.SCROLLBAR;
readonly position: Position;
readonly range: Range;
}
export interface IMouseTargetOverviewRuler extends IBaseMouseTarget {
readonly type: MouseTargetType.OVERVIEW_RULER;
}
export interface IMouseTargetOutsideEditor extends IBaseMouseTarget {
readonly type: MouseTargetType.OUTSIDE_EDITOR;
}
/** /**
* Some extra detail. * Target hit with the mouse in the editor.
*/ */
readonly detail: any; export type IMouseTarget = (IMouseTargetUnknown | IMouseTargetTextarea | IMouseTargetMargin | IMouseTargetViewZone | IMouseTargetContentText | IMouseTargetContentEmpty | IMouseTargetContentWidget | IMouseTargetOverlayWidget | IMouseTargetScrollbar | IMouseTargetOverviewRuler | IMouseTargetOutsideEditor);
}
/** /**
* A mouse event originating from the editor. * A mouse event originating from the editor.
@ -5041,6 +5135,10 @@ declare namespace monaco.editor {
* Get all the decorations on a line (filtering out decorations from other editors). * Get all the decorations on a line (filtering out decorations from other editors).
*/ */
getLineDecorations(lineNumber: number): IModelDecoration[] | null; getLineDecorations(lineNumber: number): IModelDecoration[] | null;
/**
* Get all the decorations for a range (filtering out decorations from other editors).
*/
getDecorationsInRange(range: Range): IModelDecoration[] | null;
/** /**
* All decorations added through this call will get the ownerId of this editor. * All decorations added through this call will get the ownerId of this editor.
* @see {@link ITextModel.deltaDecorations} * @see {@link ITextModel.deltaDecorations}
@ -5149,9 +5247,9 @@ declare namespace monaco.editor {
*/ */
export interface IDiffEditor extends IEditor { export interface IDiffEditor extends IEditor {
/** /**
* @see {@link ICodeEditor.getDomNode} * @see {@link ICodeEditor.getContainerDomNode}
*/ */
getDomNode(): HTMLElement; getContainerDomNode(): HTMLElement;
/** /**
* An event emitted when the diff information computed by this diff editor has been updated. * An event emitted when the diff information computed by this diff editor has been updated.
* @event * @event
@ -5253,7 +5351,7 @@ declare namespace monaco.languages {
export function getEncodedLanguageId(languageId: string): number; export function getEncodedLanguageId(languageId: string): number;
/** /**
* An event emitted when a language is first time needed (e.g. a model has it set). * An event emitted when a language is needed for the first time (e.g. a model has it set).
* @event * @event
*/ */
export function onLanguage(languageId: string, callback: () => void): IDisposable; export function onLanguage(languageId: string, callback: () => void): IDisposable;
@ -6751,17 +6849,30 @@ declare namespace monaco.languages {
Parameter = 2 Parameter = 2
} }
export interface InlayHintLabelPart {
label: string;
collapsible?: boolean;
action?: Command | Location;
}
export interface InlayHint { export interface InlayHint {
text: string; label: string | InlayHintLabelPart[];
tooltip?: string | IMarkdownString;
position: IPosition; position: IPosition;
kind: InlayHintKind; kind: InlayHintKind;
whitespaceBefore?: boolean; whitespaceBefore?: boolean;
whitespaceAfter?: boolean; whitespaceAfter?: boolean;
} }
export interface InlayHintList {
hints: InlayHint[];
dispose(): void;
}
export interface InlayHintsProvider { export interface InlayHintsProvider {
onDidChangeInlayHints?: IEvent<void>; onDidChangeInlayHints?: IEvent<void>;
provideInlayHints(model: editor.ITextModel, range: Range, token: CancellationToken): ProviderResult<InlayHint[]>; provideInlayHints(model: editor.ITextModel, range: Range, token: CancellationToken): ProviderResult<InlayHintList>;
resolveInlayHint?(hint: InlayHint, token: CancellationToken): ProviderResult<InlayHint>;
} }
export interface SemanticTokensLegend { export interface SemanticTokensLegend {

@ -1506,6 +1506,11 @@ declare namespace monaco.editor {
* If there is an `inlineClassName` which affects letter spacing. * If there is an `inlineClassName` which affects letter spacing.
*/ */
readonly inlineClassNameAffectsLetterSpacing?: boolean; readonly inlineClassNameAffectsLetterSpacing?: boolean;
/**
* This field allows to attach data to this injected text.
* The data can be read when injected texts at a given position are queried.
*/
readonly attachedData?: unknown;
} }
/** /**
@ -3305,6 +3310,7 @@ declare namespace monaco.editor {
*/ */
guides?: IGuidesOptions; guides?: IGuidesOptions;
unicodeHighlight?: IUnicodeHighlightOptions; unicodeHighlight?: IUnicodeHighlightOptions;
bracketPairColorization?: IBracketPairColorizationOptions;
} }
export interface IDiffEditorBaseOptions { export interface IDiffEditorBaseOptions {
@ -3379,8 +3385,8 @@ declare namespace monaco.editor {
get<T extends EditorOption>(id: T): FindComputedEditorOptionValueById<T>; get<T extends EditorOption>(id: T): FindComputedEditorOptionValueById<T>;
} }
export interface IEditorOption<K1 extends EditorOption, V> { export interface IEditorOption<K extends EditorOption, V> {
readonly id: K1; readonly id: K;
readonly name: string; readonly name: string;
defaultValue: V; defaultValue: V;
/** /**
@ -4541,6 +4547,9 @@ declare namespace monaco.editor {
* Render this content widget in a location where it could overflow the editor's view dom node. * Render this content widget in a location where it could overflow the editor's view dom node.
*/ */
allowEditorOverflow?: boolean; allowEditorOverflow?: boolean;
/**
* Call preventDefault() on mousedown events that target the content widget.
*/
suppressMouseDown?: boolean; suppressMouseDown?: boolean;
/** /**
* Get a unique identifier of the content widget. * Get a unique identifier of the content widget.
@ -4678,18 +4687,11 @@ declare namespace monaco.editor {
OUTSIDE_EDITOR = 13 OUTSIDE_EDITOR = 13
} }
/** export interface IBaseMouseTarget {
* Target hit with the mouse in the editor.
*/
export interface IMouseTarget {
/** /**
* The target element * The target element
*/ */
readonly element: Element | null; readonly element: Element | null;
/**
* The target type
*/
readonly type: MouseTargetType;
/** /**
* The 'approximate' editor position * The 'approximate' editor position
*/ */
@ -4702,11 +4704,103 @@ declare namespace monaco.editor {
* The 'approximate' editor range * The 'approximate' editor range
*/ */
readonly range: Range | null; readonly range: Range | null;
}
export interface IMouseTargetUnknown extends IBaseMouseTarget {
readonly type: MouseTargetType.UNKNOWN;
}
export interface IMouseTargetTextarea extends IBaseMouseTarget {
readonly type: MouseTargetType.TEXTAREA;
readonly position: null;
readonly range: null;
}
export interface IMouseTargetMarginData {
readonly isAfterLines: boolean;
readonly glyphMarginLeft: number;
readonly glyphMarginWidth: number;
readonly lineNumbersWidth: number;
readonly offsetX: number;
}
export interface IMouseTargetMargin extends IBaseMouseTarget {
readonly type: MouseTargetType.GUTTER_GLYPH_MARGIN | MouseTargetType.GUTTER_LINE_NUMBERS | MouseTargetType.GUTTER_LINE_DECORATIONS;
readonly position: Position;
readonly range: Range;
readonly detail: IMouseTargetMarginData;
}
export interface IMouseTargetViewZoneData {
readonly viewZoneId: string;
readonly positionBefore: Position | null;
readonly positionAfter: Position | null;
readonly position: Position;
readonly afterLineNumber: number;
}
export interface IMouseTargetViewZone extends IBaseMouseTarget {
readonly type: MouseTargetType.GUTTER_VIEW_ZONE | MouseTargetType.CONTENT_VIEW_ZONE;
readonly position: Position;
readonly range: Range;
readonly detail: IMouseTargetViewZoneData;
}
export interface IMouseTargetContentTextData {
readonly mightBeForeignElement: boolean;
}
export interface IMouseTargetContentText extends IBaseMouseTarget {
readonly type: MouseTargetType.CONTENT_TEXT;
readonly position: Position;
readonly range: Range;
readonly detail: IMouseTargetContentTextData;
}
export interface IMouseTargetContentEmptyData {
readonly isAfterLines: boolean;
readonly horizontalDistanceToText?: number;
}
export interface IMouseTargetContentEmpty extends IBaseMouseTarget {
readonly type: MouseTargetType.CONTENT_EMPTY;
readonly position: Position;
readonly range: Range;
readonly detail: IMouseTargetContentEmptyData;
}
export interface IMouseTargetContentWidget extends IBaseMouseTarget {
readonly type: MouseTargetType.CONTENT_WIDGET;
readonly position: null;
readonly range: null;
readonly detail: string;
}
export interface IMouseTargetOverlayWidget extends IBaseMouseTarget {
readonly type: MouseTargetType.OVERLAY_WIDGET;
readonly position: null;
readonly range: null;
readonly detail: string;
}
export interface IMouseTargetScrollbar extends IBaseMouseTarget {
readonly type: MouseTargetType.SCROLLBAR;
readonly position: Position;
readonly range: Range;
}
export interface IMouseTargetOverviewRuler extends IBaseMouseTarget {
readonly type: MouseTargetType.OVERVIEW_RULER;
}
export interface IMouseTargetOutsideEditor extends IBaseMouseTarget {
readonly type: MouseTargetType.OUTSIDE_EDITOR;
}
/** /**
* Some extra detail. * Target hit with the mouse in the editor.
*/ */
readonly detail: any; export type IMouseTarget = (IMouseTargetUnknown | IMouseTargetTextarea | IMouseTargetMargin | IMouseTargetViewZone | IMouseTargetContentText | IMouseTargetContentEmpty | IMouseTargetContentWidget | IMouseTargetOverlayWidget | IMouseTargetScrollbar | IMouseTargetOverviewRuler | IMouseTargetOutsideEditor);
}
/** /**
* A mouse event originating from the editor. * A mouse event originating from the editor.
@ -5041,6 +5135,10 @@ declare namespace monaco.editor {
* Get all the decorations on a line (filtering out decorations from other editors). * Get all the decorations on a line (filtering out decorations from other editors).
*/ */
getLineDecorations(lineNumber: number): IModelDecoration[] | null; getLineDecorations(lineNumber: number): IModelDecoration[] | null;
/**
* Get all the decorations for a range (filtering out decorations from other editors).
*/
getDecorationsInRange(range: Range): IModelDecoration[] | null;
/** /**
* All decorations added through this call will get the ownerId of this editor. * All decorations added through this call will get the ownerId of this editor.
* @see {@link ITextModel.deltaDecorations} * @see {@link ITextModel.deltaDecorations}
@ -5149,9 +5247,9 @@ declare namespace monaco.editor {
*/ */
export interface IDiffEditor extends IEditor { export interface IDiffEditor extends IEditor {
/** /**
* @see {@link ICodeEditor.getDomNode} * @see {@link ICodeEditor.getContainerDomNode}
*/ */
getDomNode(): HTMLElement; getContainerDomNode(): HTMLElement;
/** /**
* An event emitted when the diff information computed by this diff editor has been updated. * An event emitted when the diff information computed by this diff editor has been updated.
* @event * @event
@ -5253,7 +5351,7 @@ declare namespace monaco.languages {
export function getEncodedLanguageId(languageId: string): number; export function getEncodedLanguageId(languageId: string): number;
/** /**
* An event emitted when a language is first time needed (e.g. a model has it set). * An event emitted when a language is needed for the first time (e.g. a model has it set).
* @event * @event
*/ */
export function onLanguage(languageId: string, callback: () => void): IDisposable; export function onLanguage(languageId: string, callback: () => void): IDisposable;
@ -6751,17 +6849,30 @@ declare namespace monaco.languages {
Parameter = 2 Parameter = 2
} }
export interface InlayHintLabelPart {
label: string;
collapsible?: boolean;
action?: Command | Location;
}
export interface InlayHint { export interface InlayHint {
text: string; label: string | InlayHintLabelPart[];
tooltip?: string | IMarkdownString;
position: IPosition; position: IPosition;
kind: InlayHintKind; kind: InlayHintKind;
whitespaceBefore?: boolean; whitespaceBefore?: boolean;
whitespaceAfter?: boolean; whitespaceAfter?: boolean;
} }
export interface InlayHintList {
hints: InlayHint[];
dispose(): void;
}
export interface InlayHintsProvider { export interface InlayHintsProvider {
onDidChangeInlayHints?: IEvent<void>; onDidChangeInlayHints?: IEvent<void>;
provideInlayHints(model: editor.ITextModel, range: Range, token: CancellationToken): ProviderResult<InlayHint[]>; provideInlayHints(model: editor.ITextModel, range: Range, token: CancellationToken): ProviderResult<InlayHintList>;
resolveInlayHint?(hint: InlayHint, token: CancellationToken): ProviderResult<InlayHint>;
} }
export interface SemanticTokensLegend { export interface SemanticTokensLegend {

Loading…
Cancel
Save