@theia/monaco 1.53.0-next.5 → 1.53.0-next.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +100 -100
- package/data/monaco-nls.json +1379 -1379
- package/data/monaco-themes/vscode/dark_plus.json +201 -201
- package/data/monaco-themes/vscode/dark_theia.json +5 -5
- package/data/monaco-themes/vscode/dark_vs.json +393 -393
- package/data/monaco-themes/vscode/hc_black.json +457 -457
- package/data/monaco-themes/vscode/hc_light.json +590 -590
- package/data/monaco-themes/vscode/hc_theia.json +5 -5
- package/data/monaco-themes/vscode/hc_theia_light.json +5 -5
- package/data/monaco-themes/vscode/light_plus.json +202 -202
- package/data/monaco-themes/vscode/light_theia.json +10 -10
- package/data/monaco-themes/vscode/light_vs.json +421 -421
- package/lib/browser/monaco-context-key-service.js +1 -1
- package/lib/browser/monaco-context-key-service.js.map +1 -1
- package/lib/browser/monaco-editor-model.d.ts +11 -5
- package/lib/browser/monaco-editor-model.d.ts.map +1 -1
- package/lib/browser/monaco-editor-model.js +2 -1
- package/lib/browser/monaco-editor-model.js.map +1 -1
- package/lib/browser/monaco-editor-service.js +1 -1
- package/lib/browser/monaco-editor-service.js.map +1 -1
- package/lib/browser/monaco-editor-zone-widget.js +1 -1
- package/lib/browser/monaco-editor.d.ts +5 -4
- package/lib/browser/monaco-editor.d.ts.map +1 -1
- package/lib/browser/monaco-editor.js +5 -2
- package/lib/browser/monaco-editor.js.map +1 -1
- package/lib/browser/monaco-frontend-application-contribution.js +25 -25
- package/lib/browser/monaco-quick-input-service.d.ts.map +1 -1
- package/lib/browser/monaco-quick-input-service.js +15 -15
- package/lib/browser/monaco-quick-input-service.js.map +1 -1
- package/lib/browser/monaco-text-model-service.d.ts +0 -10
- package/lib/browser/monaco-text-model-service.d.ts.map +1 -1
- package/lib/browser/monaco-text-model-service.js +0 -36
- package/lib/browser/monaco-text-model-service.js.map +1 -1
- package/lib/browser/monaco-to-protocol-converter.d.ts +2 -0
- package/lib/browser/monaco-to-protocol-converter.d.ts.map +1 -1
- package/lib/browser/monaco-to-protocol-converter.js +10 -0
- package/lib/browser/monaco-to-protocol-converter.js.map +1 -1
- package/package.json +9 -9
- package/src/browser/index.ts +17 -17
- package/src/browser/markdown-renderer/monaco-markdown-renderer.ts +109 -109
- package/src/browser/monaco-bulk-edit-service.ts +64 -64
- package/src/browser/monaco-color-registry.ts +73 -73
- package/src/browser/monaco-command-registry.ts +85 -85
- package/src/browser/monaco-command-service.ts +90 -90
- package/src/browser/monaco-command.ts +303 -303
- package/src/browser/monaco-context-key-service.ts +144 -144
- package/src/browser/monaco-context-menu.ts +112 -112
- package/src/browser/monaco-diff-editor.ts +141 -141
- package/src/browser/monaco-diff-navigator-factory.ts +39 -39
- package/src/browser/monaco-editor-model.ts +693 -685
- package/src/browser/monaco-editor-peek-view-widget.ts +233 -233
- package/src/browser/monaco-editor-provider.ts +455 -455
- package/src/browser/monaco-editor-service.ts +152 -152
- package/src/browser/monaco-editor-zone-widget.ts +250 -250
- package/src/browser/monaco-editor.ts +733 -729
- package/src/browser/monaco-formatting-conflicts.ts +116 -116
- package/src/browser/monaco-frontend-application-contribution.ts +182 -182
- package/src/browser/monaco-frontend-module.ts +319 -319
- package/src/browser/monaco-gotoline-quick-access.ts +47 -47
- package/src/browser/monaco-gotosymbol-quick-access.ts +53 -53
- package/src/browser/monaco-icon-registry.ts +49 -49
- package/src/browser/monaco-indexed-db.ts +130 -130
- package/src/browser/monaco-init.ts +134 -134
- package/src/browser/monaco-keybinding.ts +111 -111
- package/src/browser/monaco-keycode-map.ts +171 -171
- package/src/browser/monaco-languages.ts +177 -177
- package/src/browser/monaco-marker-collection.ts +83 -83
- package/src/browser/monaco-menu.ts +147 -147
- package/src/browser/monaco-mime-service.ts +71 -71
- package/src/browser/monaco-outline-contribution.ts +404 -404
- package/src/browser/monaco-outline-decorator.ts +66 -66
- package/src/browser/monaco-quick-access-registry.ts +112 -112
- package/src/browser/monaco-quick-input-service.ts +701 -702
- package/src/browser/monaco-resolved-keybinding.ts +162 -162
- package/src/browser/monaco-snippet-suggest-provider.ts +306 -306
- package/src/browser/monaco-standalone-theme-service.ts +51 -51
- package/src/browser/monaco-status-bar-contribution.ts +110 -110
- package/src/browser/monaco-text-model-service.ts +157 -199
- package/src/browser/monaco-theming-service.ts +204 -204
- package/src/browser/monaco-to-protocol-converter.ts +82 -71
- package/src/browser/monaco-undo-redo-handler.ts +64 -64
- package/src/browser/monaco-workspace.ts +416 -416
- package/src/browser/protocol-to-monaco-converter.ts +158 -158
- package/src/browser/simple-monaco-editor.ts +216 -216
- package/src/browser/style/index.css +266 -266
- package/src/browser/textmate/index.ts +20 -20
- package/src/browser/textmate/monaco-textmate-frontend-bindings.ts +90 -90
- package/src/browser/textmate/monaco-textmate-service.ts +187 -187
- package/src/browser/textmate/monaco-theme-registry.ts +176 -176
- package/src/browser/textmate/monaco-theme-types.ts +37 -37
- package/src/browser/textmate/textmate-contribution.ts +29 -29
- package/src/browser/textmate/textmate-registry.ts +129 -129
- package/src/browser/textmate/textmate-snippet-completion-provider.ts +73 -73
- package/src/browser/textmate/textmate-tokenizer.ts +84 -84
- package/src/browser/workspace-symbol-command.ts +196 -196
- package/src/package.spec.ts +28 -28
|
@@ -1,233 +1,233 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2024 1C-Soft LLC and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
import { Position, Range } from '@theia/core/shared/vscode-languageserver-protocol';
|
|
18
|
-
import { DisposableCollection } from '@theia/core';
|
|
19
|
-
import { MonacoEditor } from './monaco-editor';
|
|
20
|
-
import * as monaco from '@theia/monaco-editor-core';
|
|
21
|
-
import { PeekViewWidget, IPeekViewOptions, IPeekViewStyles } from '@theia/monaco-editor-core/esm/vs/editor/contrib/peekView/browser/peekView';
|
|
22
|
-
import { ICodeEditor } from '@theia/monaco-editor-core/esm/vs/editor/browser/editorBrowser';
|
|
23
|
-
import { ActionBar } from '@theia/monaco-editor-core/esm/vs/base/browser/ui/actionbar/actionbar';
|
|
24
|
-
import { Action } from '@theia/monaco-editor-core/esm/vs/base/common/actions';
|
|
25
|
-
import { StandaloneServices } from '@theia/monaco-editor-core/esm/vs/editor/standalone/browser/standaloneServices';
|
|
26
|
-
import { IInstantiationService } from '@theia/monaco-editor-core/esm/vs/platform/instantiation/common/instantiation';
|
|
27
|
-
import { IThemeService } from '@theia/monaco-editor-core/esm/vs/platform/theme/common/themeService';
|
|
28
|
-
import { Color } from '@theia/monaco-editor-core/esm/vs/base/common/color';
|
|
29
|
-
|
|
30
|
-
export { peekViewBorder, peekViewTitleBackground, peekViewTitleForeground, peekViewTitleInfoForeground }
|
|
31
|
-
from '@theia/monaco-editor-core/esm/vs/editor/contrib/peekView/browser/peekView';
|
|
32
|
-
|
|
33
|
-
export namespace MonacoEditorPeekViewWidget {
|
|
34
|
-
export interface Styles {
|
|
35
|
-
frameColor?: string;
|
|
36
|
-
arrowColor?: string;
|
|
37
|
-
headerBackgroundColor?: string;
|
|
38
|
-
primaryHeadingColor?: string;
|
|
39
|
-
secondaryHeadingColor?: string;
|
|
40
|
-
}
|
|
41
|
-
export interface Options {
|
|
42
|
-
showFrame?: boolean;
|
|
43
|
-
showArrow?: boolean;
|
|
44
|
-
frameWidth?: number;
|
|
45
|
-
className?: string;
|
|
46
|
-
isAccessible?: boolean;
|
|
47
|
-
isResizeable?: boolean;
|
|
48
|
-
keepEditorSelection?: boolean;
|
|
49
|
-
allowUnlimitedHeight?: boolean;
|
|
50
|
-
ordinal?: number;
|
|
51
|
-
showInHiddenAreas?: boolean;
|
|
52
|
-
supportOnTitleClick?: boolean;
|
|
53
|
-
}
|
|
54
|
-
export interface Action {
|
|
55
|
-
readonly id: string;
|
|
56
|
-
label: string;
|
|
57
|
-
tooltip: string;
|
|
58
|
-
class: string | undefined;
|
|
59
|
-
enabled: boolean;
|
|
60
|
-
checked?: boolean;
|
|
61
|
-
run(...args: unknown[]): unknown;
|
|
62
|
-
}
|
|
63
|
-
export interface ActionOptions {
|
|
64
|
-
icon?: boolean;
|
|
65
|
-
label?: boolean;
|
|
66
|
-
keybinding?: string;
|
|
67
|
-
index?: number;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export class MonacoEditorPeekViewWidget {
|
|
72
|
-
|
|
73
|
-
protected readonly toDispose = new DisposableCollection();
|
|
74
|
-
|
|
75
|
-
readonly onDidClose = this.toDispose.onDispose;
|
|
76
|
-
|
|
77
|
-
private readonly themeService = StandaloneServices.get(IThemeService);
|
|
78
|
-
|
|
79
|
-
private readonly delegate;
|
|
80
|
-
|
|
81
|
-
constructor(
|
|
82
|
-
readonly editor: MonacoEditor,
|
|
83
|
-
options: MonacoEditorPeekViewWidget.Options = {},
|
|
84
|
-
protected styles: MonacoEditorPeekViewWidget.Styles = {}
|
|
85
|
-
) {
|
|
86
|
-
const that = this;
|
|
87
|
-
this.toDispose.push(this.delegate = new class extends PeekViewWidget {
|
|
88
|
-
|
|
89
|
-
get actionBar(): ActionBar | undefined {
|
|
90
|
-
return this._actionbarWidget;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
fillHead(container: HTMLElement, noCloseAction?: boolean): void {
|
|
94
|
-
super._fillHead(container, noCloseAction);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
protected override _fillHead(container: HTMLElement, noCloseAction?: boolean): void {
|
|
98
|
-
that.fillHead(container, noCloseAction);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
fillBody(container: HTMLElement): void {
|
|
102
|
-
// super._fillBody is an abstract method
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
protected override _fillBody(container: HTMLElement): void {
|
|
106
|
-
that.fillBody(container);
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
doLayoutHead(heightInPixel: number, widthInPixel: number): void {
|
|
110
|
-
super._doLayoutHead(heightInPixel, widthInPixel);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
protected override _doLayoutHead(heightInPixel: number, widthInPixel: number): void {
|
|
114
|
-
that.doLayoutHead(heightInPixel, widthInPixel);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
doLayoutBody(heightInPixel: number, widthInPixel: number): void {
|
|
118
|
-
super._doLayoutBody(heightInPixel, widthInPixel);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
protected override _doLayoutBody(heightInPixel: number, widthInPixel: number): void {
|
|
122
|
-
that.doLayoutBody(heightInPixel, widthInPixel);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
onWidth(widthInPixel: number): void {
|
|
126
|
-
super._onWidth(widthInPixel);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
protected override _onWidth(widthInPixel: number): void {
|
|
130
|
-
that.onWidth(widthInPixel);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
doRevealRange(range: monaco.Range, isLastLine: boolean): void {
|
|
134
|
-
super.revealRange(range, isLastLine);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
protected override revealRange(range: monaco.Range, isLastLine: boolean): void {
|
|
138
|
-
that.doRevealRange(that.editor['m2p'].asRange(range), isLastLine);
|
|
139
|
-
}
|
|
140
|
-
}(
|
|
141
|
-
editor.getControl() as unknown as ICodeEditor,
|
|
142
|
-
Object.assign(<IPeekViewOptions>{}, options, this.convertStyles(styles)),
|
|
143
|
-
StandaloneServices.get(IInstantiationService)
|
|
144
|
-
));
|
|
145
|
-
this.toDispose.push(this.themeService.onDidColorThemeChange(() => this.style(this.styles)));
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
dispose(): void {
|
|
149
|
-
this.toDispose.dispose();
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
create(): void {
|
|
153
|
-
this.delegate.create();
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
setTitle(primaryHeading: string, secondaryHeading?: string): void {
|
|
157
|
-
this.delegate.setTitle(primaryHeading, secondaryHeading);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
style(styles: MonacoEditorPeekViewWidget.Styles): void {
|
|
161
|
-
this.delegate.style(this.convertStyles(this.styles = styles));
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
show(rangeOrPos: Range | Position, heightInLines: number): void {
|
|
165
|
-
this.delegate.show(this.convertRangeOrPosition(rangeOrPos), heightInLines);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
hide(): void {
|
|
169
|
-
this.delegate.hide();
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
clearActions(): void {
|
|
173
|
-
this.delegate.actionBar?.clear();
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
addAction(id: string, label: string, cssClass: string | undefined, enabled: boolean, actionCallback: (arg: unknown) => unknown,
|
|
177
|
-
options?: MonacoEditorPeekViewWidget.ActionOptions): MonacoEditorPeekViewWidget.Action {
|
|
178
|
-
options = cssClass ? { icon: true, label: false, ...options } : { icon: false, label: true, ...options };
|
|
179
|
-
const { actionBar } = this.delegate;
|
|
180
|
-
if (!actionBar) {
|
|
181
|
-
throw new Error('Action bar has not been created.');
|
|
182
|
-
}
|
|
183
|
-
const action = new Action(id, label, cssClass, enabled, actionCallback);
|
|
184
|
-
actionBar.push(action, options);
|
|
185
|
-
return action;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
protected fillHead(container: HTMLElement, noCloseAction?: boolean): void {
|
|
189
|
-
this.delegate.fillHead(container, noCloseAction);
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
protected fillBody(container: HTMLElement): void {
|
|
193
|
-
this.delegate.fillBody(container);
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
protected doLayoutHead(heightInPixel: number, widthInPixel: number): void {
|
|
197
|
-
this.delegate.doLayoutHead(heightInPixel, widthInPixel);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
protected doLayoutBody(heightInPixel: number, widthInPixel: number): void {
|
|
201
|
-
this.delegate.doLayoutBody(heightInPixel, widthInPixel);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
protected onWidth(widthInPixel: number): void {
|
|
205
|
-
this.delegate.onWidth(widthInPixel);
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
protected doRevealRange(range: Range, isLastLine: boolean): void {
|
|
209
|
-
this.delegate.doRevealRange(this.editor['p2m'].asRange(range), isLastLine);
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
private convertStyles(styles: MonacoEditorPeekViewWidget.Styles): IPeekViewStyles {
|
|
213
|
-
return {
|
|
214
|
-
frameColor: this.convertColor(styles.frameColor),
|
|
215
|
-
arrowColor: this.convertColor(styles.arrowColor),
|
|
216
|
-
headerBackgroundColor: this.convertColor(styles.headerBackgroundColor),
|
|
217
|
-
primaryHeadingColor: this.convertColor(styles.primaryHeadingColor),
|
|
218
|
-
secondaryHeadingColor: this.convertColor(styles.secondaryHeadingColor),
|
|
219
|
-
};
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
private convertColor(color?: string): Color | undefined {
|
|
223
|
-
if (color === undefined) {
|
|
224
|
-
return undefined;
|
|
225
|
-
}
|
|
226
|
-
return this.themeService.getColorTheme().getColor(color) || Color.fromHex(color);
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
private convertRangeOrPosition(arg: Range | Position): monaco.Range | monaco.Position {
|
|
230
|
-
const p2m = this.editor['p2m'];
|
|
231
|
-
return Range.is(arg) ? p2m.asRange(arg) : p2m.asPosition(arg);
|
|
232
|
-
}
|
|
233
|
-
}
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2024 1C-Soft LLC and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { Position, Range } from '@theia/core/shared/vscode-languageserver-protocol';
|
|
18
|
+
import { DisposableCollection } from '@theia/core';
|
|
19
|
+
import { MonacoEditor } from './monaco-editor';
|
|
20
|
+
import * as monaco from '@theia/monaco-editor-core';
|
|
21
|
+
import { PeekViewWidget, IPeekViewOptions, IPeekViewStyles } from '@theia/monaco-editor-core/esm/vs/editor/contrib/peekView/browser/peekView';
|
|
22
|
+
import { ICodeEditor } from '@theia/monaco-editor-core/esm/vs/editor/browser/editorBrowser';
|
|
23
|
+
import { ActionBar } from '@theia/monaco-editor-core/esm/vs/base/browser/ui/actionbar/actionbar';
|
|
24
|
+
import { Action } from '@theia/monaco-editor-core/esm/vs/base/common/actions';
|
|
25
|
+
import { StandaloneServices } from '@theia/monaco-editor-core/esm/vs/editor/standalone/browser/standaloneServices';
|
|
26
|
+
import { IInstantiationService } from '@theia/monaco-editor-core/esm/vs/platform/instantiation/common/instantiation';
|
|
27
|
+
import { IThemeService } from '@theia/monaco-editor-core/esm/vs/platform/theme/common/themeService';
|
|
28
|
+
import { Color } from '@theia/monaco-editor-core/esm/vs/base/common/color';
|
|
29
|
+
|
|
30
|
+
export { peekViewBorder, peekViewTitleBackground, peekViewTitleForeground, peekViewTitleInfoForeground }
|
|
31
|
+
from '@theia/monaco-editor-core/esm/vs/editor/contrib/peekView/browser/peekView';
|
|
32
|
+
|
|
33
|
+
export namespace MonacoEditorPeekViewWidget {
|
|
34
|
+
export interface Styles {
|
|
35
|
+
frameColor?: string;
|
|
36
|
+
arrowColor?: string;
|
|
37
|
+
headerBackgroundColor?: string;
|
|
38
|
+
primaryHeadingColor?: string;
|
|
39
|
+
secondaryHeadingColor?: string;
|
|
40
|
+
}
|
|
41
|
+
export interface Options {
|
|
42
|
+
showFrame?: boolean;
|
|
43
|
+
showArrow?: boolean;
|
|
44
|
+
frameWidth?: number;
|
|
45
|
+
className?: string;
|
|
46
|
+
isAccessible?: boolean;
|
|
47
|
+
isResizeable?: boolean;
|
|
48
|
+
keepEditorSelection?: boolean;
|
|
49
|
+
allowUnlimitedHeight?: boolean;
|
|
50
|
+
ordinal?: number;
|
|
51
|
+
showInHiddenAreas?: boolean;
|
|
52
|
+
supportOnTitleClick?: boolean;
|
|
53
|
+
}
|
|
54
|
+
export interface Action {
|
|
55
|
+
readonly id: string;
|
|
56
|
+
label: string;
|
|
57
|
+
tooltip: string;
|
|
58
|
+
class: string | undefined;
|
|
59
|
+
enabled: boolean;
|
|
60
|
+
checked?: boolean;
|
|
61
|
+
run(...args: unknown[]): unknown;
|
|
62
|
+
}
|
|
63
|
+
export interface ActionOptions {
|
|
64
|
+
icon?: boolean;
|
|
65
|
+
label?: boolean;
|
|
66
|
+
keybinding?: string;
|
|
67
|
+
index?: number;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export class MonacoEditorPeekViewWidget {
|
|
72
|
+
|
|
73
|
+
protected readonly toDispose = new DisposableCollection();
|
|
74
|
+
|
|
75
|
+
readonly onDidClose = this.toDispose.onDispose;
|
|
76
|
+
|
|
77
|
+
private readonly themeService = StandaloneServices.get(IThemeService);
|
|
78
|
+
|
|
79
|
+
private readonly delegate;
|
|
80
|
+
|
|
81
|
+
constructor(
|
|
82
|
+
readonly editor: MonacoEditor,
|
|
83
|
+
options: MonacoEditorPeekViewWidget.Options = {},
|
|
84
|
+
protected styles: MonacoEditorPeekViewWidget.Styles = {}
|
|
85
|
+
) {
|
|
86
|
+
const that = this;
|
|
87
|
+
this.toDispose.push(this.delegate = new class extends PeekViewWidget {
|
|
88
|
+
|
|
89
|
+
get actionBar(): ActionBar | undefined {
|
|
90
|
+
return this._actionbarWidget;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
fillHead(container: HTMLElement, noCloseAction?: boolean): void {
|
|
94
|
+
super._fillHead(container, noCloseAction);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
protected override _fillHead(container: HTMLElement, noCloseAction?: boolean): void {
|
|
98
|
+
that.fillHead(container, noCloseAction);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
fillBody(container: HTMLElement): void {
|
|
102
|
+
// super._fillBody is an abstract method
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
protected override _fillBody(container: HTMLElement): void {
|
|
106
|
+
that.fillBody(container);
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
doLayoutHead(heightInPixel: number, widthInPixel: number): void {
|
|
110
|
+
super._doLayoutHead(heightInPixel, widthInPixel);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
protected override _doLayoutHead(heightInPixel: number, widthInPixel: number): void {
|
|
114
|
+
that.doLayoutHead(heightInPixel, widthInPixel);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
doLayoutBody(heightInPixel: number, widthInPixel: number): void {
|
|
118
|
+
super._doLayoutBody(heightInPixel, widthInPixel);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
protected override _doLayoutBody(heightInPixel: number, widthInPixel: number): void {
|
|
122
|
+
that.doLayoutBody(heightInPixel, widthInPixel);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
onWidth(widthInPixel: number): void {
|
|
126
|
+
super._onWidth(widthInPixel);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
protected override _onWidth(widthInPixel: number): void {
|
|
130
|
+
that.onWidth(widthInPixel);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
doRevealRange(range: monaco.Range, isLastLine: boolean): void {
|
|
134
|
+
super.revealRange(range, isLastLine);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
protected override revealRange(range: monaco.Range, isLastLine: boolean): void {
|
|
138
|
+
that.doRevealRange(that.editor['m2p'].asRange(range), isLastLine);
|
|
139
|
+
}
|
|
140
|
+
}(
|
|
141
|
+
editor.getControl() as unknown as ICodeEditor,
|
|
142
|
+
Object.assign(<IPeekViewOptions>{}, options, this.convertStyles(styles)),
|
|
143
|
+
StandaloneServices.get(IInstantiationService)
|
|
144
|
+
));
|
|
145
|
+
this.toDispose.push(this.themeService.onDidColorThemeChange(() => this.style(this.styles)));
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
dispose(): void {
|
|
149
|
+
this.toDispose.dispose();
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
create(): void {
|
|
153
|
+
this.delegate.create();
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
setTitle(primaryHeading: string, secondaryHeading?: string): void {
|
|
157
|
+
this.delegate.setTitle(primaryHeading, secondaryHeading);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
style(styles: MonacoEditorPeekViewWidget.Styles): void {
|
|
161
|
+
this.delegate.style(this.convertStyles(this.styles = styles));
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
show(rangeOrPos: Range | Position, heightInLines: number): void {
|
|
165
|
+
this.delegate.show(this.convertRangeOrPosition(rangeOrPos), heightInLines);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
hide(): void {
|
|
169
|
+
this.delegate.hide();
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
clearActions(): void {
|
|
173
|
+
this.delegate.actionBar?.clear();
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
addAction(id: string, label: string, cssClass: string | undefined, enabled: boolean, actionCallback: (arg: unknown) => unknown,
|
|
177
|
+
options?: MonacoEditorPeekViewWidget.ActionOptions): MonacoEditorPeekViewWidget.Action {
|
|
178
|
+
options = cssClass ? { icon: true, label: false, ...options } : { icon: false, label: true, ...options };
|
|
179
|
+
const { actionBar } = this.delegate;
|
|
180
|
+
if (!actionBar) {
|
|
181
|
+
throw new Error('Action bar has not been created.');
|
|
182
|
+
}
|
|
183
|
+
const action = new Action(id, label, cssClass, enabled, actionCallback);
|
|
184
|
+
actionBar.push(action, options);
|
|
185
|
+
return action;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
protected fillHead(container: HTMLElement, noCloseAction?: boolean): void {
|
|
189
|
+
this.delegate.fillHead(container, noCloseAction);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
protected fillBody(container: HTMLElement): void {
|
|
193
|
+
this.delegate.fillBody(container);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
protected doLayoutHead(heightInPixel: number, widthInPixel: number): void {
|
|
197
|
+
this.delegate.doLayoutHead(heightInPixel, widthInPixel);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
protected doLayoutBody(heightInPixel: number, widthInPixel: number): void {
|
|
201
|
+
this.delegate.doLayoutBody(heightInPixel, widthInPixel);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
protected onWidth(widthInPixel: number): void {
|
|
205
|
+
this.delegate.onWidth(widthInPixel);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
protected doRevealRange(range: Range, isLastLine: boolean): void {
|
|
209
|
+
this.delegate.doRevealRange(this.editor['p2m'].asRange(range), isLastLine);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
private convertStyles(styles: MonacoEditorPeekViewWidget.Styles): IPeekViewStyles {
|
|
213
|
+
return {
|
|
214
|
+
frameColor: this.convertColor(styles.frameColor),
|
|
215
|
+
arrowColor: this.convertColor(styles.arrowColor),
|
|
216
|
+
headerBackgroundColor: this.convertColor(styles.headerBackgroundColor),
|
|
217
|
+
primaryHeadingColor: this.convertColor(styles.primaryHeadingColor),
|
|
218
|
+
secondaryHeadingColor: this.convertColor(styles.secondaryHeadingColor),
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
private convertColor(color?: string): Color | undefined {
|
|
223
|
+
if (color === undefined) {
|
|
224
|
+
return undefined;
|
|
225
|
+
}
|
|
226
|
+
return this.themeService.getColorTheme().getColor(color) || Color.fromHex(color);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
private convertRangeOrPosition(arg: Range | Position): monaco.Range | monaco.Position {
|
|
230
|
+
const p2m = this.editor['p2m'];
|
|
231
|
+
return Range.is(arg) ? p2m.asRange(arg) : p2m.asPosition(arg);
|
|
232
|
+
}
|
|
233
|
+
}
|