@theia/monaco 1.48.3 → 1.49.0
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/lib/browser/monaco-diff-editor.d.ts +4 -3
- package/lib/browser/monaco-diff-editor.d.ts.map +1 -1
- package/lib/browser/monaco-diff-editor.js +30 -4
- package/lib/browser/monaco-diff-editor.js.map +1 -1
- package/lib/browser/monaco-diff-navigator-factory.d.ts +2 -2
- package/lib/browser/monaco-diff-navigator-factory.d.ts.map +1 -1
- package/lib/browser/monaco-diff-navigator-factory.js.map +1 -1
- package/lib/browser/monaco-editor-peek-view-widget.d.ts +68 -0
- package/lib/browser/monaco-editor-peek-view-widget.d.ts.map +1 -0
- package/lib/browser/monaco-editor-peek-view-widget.js +155 -0
- package/lib/browser/monaco-editor-peek-view-widget.js.map +1 -0
- package/lib/browser/monaco-editor-provider.d.ts +1 -0
- package/lib/browser/monaco-editor-provider.d.ts.map +1 -1
- package/lib/browser/monaco-editor-provider.js +24 -0
- package/lib/browser/monaco-editor-provider.js.map +1 -1
- package/lib/browser/monaco-editor.d.ts +3 -1
- package/lib/browser/monaco-editor.d.ts.map +1 -1
- package/lib/browser/monaco-editor.js +54 -2
- package/lib/browser/monaco-editor.js.map +1 -1
- package/lib/browser/monaco-frontend-module.d.ts.map +1 -1
- package/lib/browser/monaco-frontend-module.js +0 -14
- package/lib/browser/monaco-frontend-module.js.map +1 -1
- package/lib/browser/monaco-init.d.ts.map +1 -1
- package/lib/browser/monaco-init.js +15 -0
- package/lib/browser/monaco-init.js.map +1 -1
- package/lib/browser/monaco-menu.d.ts +2 -2
- package/lib/browser/monaco-menu.d.ts.map +1 -1
- package/lib/browser/monaco-menu.js +9 -4
- package/lib/browser/monaco-menu.js.map +1 -1
- package/package.json +9 -9
- package/src/browser/monaco-diff-editor.ts +48 -7
- package/src/browser/monaco-diff-navigator-factory.ts +2 -2
- package/src/browser/monaco-editor-peek-view-widget.ts +233 -0
- package/src/browser/monaco-editor-provider.ts +38 -1
- package/src/browser/monaco-editor.ts +69 -3
- package/src/browser/monaco-frontend-module.ts +0 -16
- package/src/browser/monaco-init.ts +17 -0
- package/src/browser/monaco-menu.ts +11 -6
- package/src/browser/style/index.css +0 -1
|
@@ -0,0 +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
|
+
}
|
|
@@ -211,7 +211,7 @@ export class MonacoEditorProvider {
|
|
|
211
211
|
return editor;
|
|
212
212
|
}
|
|
213
213
|
|
|
214
|
-
protected updateReadOnlyMessage(options: MonacoEditor.IOptions, readOnly: boolean | MarkdownString
|
|
214
|
+
protected updateReadOnlyMessage(options: MonacoEditor.IOptions, readOnly: boolean | MarkdownString): void {
|
|
215
215
|
options.readOnlyMessage = MarkdownString.is(readOnly) ? readOnly : undefined;
|
|
216
216
|
}
|
|
217
217
|
|
|
@@ -415,4 +415,41 @@ export class MonacoEditorProvider {
|
|
|
415
415
|
}
|
|
416
416
|
};
|
|
417
417
|
|
|
418
|
+
async createEmbeddedDiffEditor(parentEditor: MonacoEditor, node: HTMLElement, originalUri: URI, modifiedUri: URI = parentEditor.uri,
|
|
419
|
+
options?: MonacoDiffEditor.IOptions): Promise<MonacoDiffEditor> {
|
|
420
|
+
options = {
|
|
421
|
+
scrollBeyondLastLine: true,
|
|
422
|
+
overviewRulerLanes: 2,
|
|
423
|
+
fixedOverflowWidgets: true,
|
|
424
|
+
minimap: { enabled: false },
|
|
425
|
+
renderSideBySide: false,
|
|
426
|
+
readOnly: true,
|
|
427
|
+
renderIndicators: false,
|
|
428
|
+
diffAlgorithm: 'advanced',
|
|
429
|
+
stickyScroll: { enabled: false },
|
|
430
|
+
...options,
|
|
431
|
+
scrollbar: {
|
|
432
|
+
verticalScrollbarSize: 14,
|
|
433
|
+
horizontal: 'auto',
|
|
434
|
+
useShadows: true,
|
|
435
|
+
verticalHasArrows: false,
|
|
436
|
+
horizontalHasArrows: false,
|
|
437
|
+
...options?.scrollbar
|
|
438
|
+
}
|
|
439
|
+
};
|
|
440
|
+
const uri = DiffUris.encode(originalUri, modifiedUri);
|
|
441
|
+
return await this.doCreateEditor(uri, async (override, toDispose) =>
|
|
442
|
+
new MonacoDiffEditor(
|
|
443
|
+
uri,
|
|
444
|
+
node,
|
|
445
|
+
await this.getModel(originalUri, toDispose),
|
|
446
|
+
await this.getModel(modifiedUri, toDispose),
|
|
447
|
+
this.services,
|
|
448
|
+
this.diffNavigatorFactory,
|
|
449
|
+
options,
|
|
450
|
+
override,
|
|
451
|
+
parentEditor
|
|
452
|
+
)
|
|
453
|
+
) as MonacoDiffEditor;
|
|
454
|
+
}
|
|
418
455
|
}
|
|
@@ -48,9 +48,20 @@ import { StandaloneServices } from '@theia/monaco-editor-core/esm/vs/editor/stan
|
|
|
48
48
|
import { ILanguageService } from '@theia/monaco-editor-core/esm/vs/editor/common/languages/language';
|
|
49
49
|
import { IInstantiationService, ServiceIdentifier } from '@theia/monaco-editor-core/esm/vs/platform/instantiation/common/instantiation';
|
|
50
50
|
import { ICodeEditor, IMouseTargetMargin } from '@theia/monaco-editor-core/esm/vs/editor/browser/editorBrowser';
|
|
51
|
-
import { IStandaloneEditorConstructionOptions, StandaloneEditor } from '@theia/monaco-editor-core/esm/vs/editor/standalone/browser/standaloneCodeEditor';
|
|
51
|
+
import { IStandaloneEditorConstructionOptions, StandaloneCodeEditor, StandaloneEditor } from '@theia/monaco-editor-core/esm/vs/editor/standalone/browser/standaloneCodeEditor';
|
|
52
52
|
import { ServiceCollection } from '@theia/monaco-editor-core/esm/vs/platform/instantiation/common/serviceCollection';
|
|
53
53
|
import { MarkdownString } from '@theia/core/lib/common/markdown-rendering';
|
|
54
|
+
import { ConfigurationChangedEvent, IEditorOptions } from '@theia/monaco-editor-core/esm/vs/editor/common/config/editorOptions';
|
|
55
|
+
import { ICodeEditorService } from '@theia/monaco-editor-core/esm/vs/editor/browser/services/codeEditorService';
|
|
56
|
+
import { ICommandService } from '@theia/monaco-editor-core/esm/vs/platform/commands/common/commands';
|
|
57
|
+
import { IContextKeyService } from '@theia/monaco-editor-core/esm/vs/platform/contextkey/common/contextkey';
|
|
58
|
+
import { IKeybindingService } from '@theia/monaco-editor-core/esm/vs/platform/keybinding/common/keybinding';
|
|
59
|
+
import { IThemeService } from '@theia/monaco-editor-core/esm/vs/platform/theme/common/themeService';
|
|
60
|
+
import { INotificationService } from '@theia/monaco-editor-core/esm/vs/platform/notification/common/notification';
|
|
61
|
+
import { IAccessibilityService } from '@theia/monaco-editor-core/esm/vs/platform/accessibility/common/accessibility';
|
|
62
|
+
import { ILanguageConfigurationService } from '@theia/monaco-editor-core/esm/vs/editor/common/languages/languageConfigurationRegistry';
|
|
63
|
+
import { ILanguageFeaturesService } from '@theia/monaco-editor-core/esm/vs/editor/common/services/languageFeatures';
|
|
64
|
+
import * as objects from '@theia/monaco-editor-core/esm/vs/base/common/objects';
|
|
54
65
|
|
|
55
66
|
export type ServicePair<T> = [ServiceIdentifier<T>, T];
|
|
56
67
|
|
|
@@ -103,7 +114,8 @@ export class MonacoEditor extends MonacoEditorServices implements TextEditor {
|
|
|
103
114
|
readonly node: HTMLElement,
|
|
104
115
|
services: MonacoEditorServices,
|
|
105
116
|
options?: MonacoEditor.IOptions,
|
|
106
|
-
override?: EditorServiceOverrides
|
|
117
|
+
override?: EditorServiceOverrides,
|
|
118
|
+
readonly parentEditor?: MonacoEditor
|
|
107
119
|
) {
|
|
108
120
|
super(services);
|
|
109
121
|
this.toDispose.pushAll([
|
|
@@ -153,7 +165,9 @@ export class MonacoEditor extends MonacoEditorServices implements TextEditor {
|
|
|
153
165
|
* @monaco-uplift. Should be guaranteed to work.
|
|
154
166
|
* Incomparable enums prevent TypeScript from believing that public IStandaloneCodeEditor is satisfied by private StandaloneCodeEditor
|
|
155
167
|
*/
|
|
156
|
-
return this.editor =
|
|
168
|
+
return this.editor = (this.parentEditor ?
|
|
169
|
+
instantiator.createInstance(EmbeddedCodeEditor, this.node, combinedOptions, this.parentEditor.getControl() as unknown as ICodeEditor) :
|
|
170
|
+
instantiator.createInstance(StandaloneEditor, this.node, combinedOptions)) as unknown as monaco.editor.IStandaloneCodeEditor;
|
|
157
171
|
}
|
|
158
172
|
|
|
159
173
|
protected getInstantiatorWithOverrides(override?: EditorServiceOverrides): IInstantiationService {
|
|
@@ -589,6 +603,9 @@ export class MonacoEditor extends MonacoEditorServices implements TextEditor {
|
|
|
589
603
|
return this.uri.withPath(resourceUri.path);
|
|
590
604
|
}
|
|
591
605
|
|
|
606
|
+
shouldDisplayDirtyDiff(): boolean {
|
|
607
|
+
return true;
|
|
608
|
+
}
|
|
592
609
|
}
|
|
593
610
|
|
|
594
611
|
export namespace MonacoEditor {
|
|
@@ -661,3 +678,52 @@ export namespace MonacoEditor {
|
|
|
661
678
|
return {};
|
|
662
679
|
}
|
|
663
680
|
}
|
|
681
|
+
|
|
682
|
+
// adapted from https://github.com/microsoft/vscode/blob/0bd70d48ad8b3e2fb1922aa54f87c786ff2b4bd8/src/vs/editor/browser/widget/codeEditor/embeddedCodeEditorWidget.ts
|
|
683
|
+
// This class reproduces the logic in EmbeddedCodeEditorWidget but extends StandaloneCodeEditor rather than CodeEditorWidget.
|
|
684
|
+
class EmbeddedCodeEditor extends StandaloneCodeEditor {
|
|
685
|
+
|
|
686
|
+
private readonly _parentEditor: ICodeEditor;
|
|
687
|
+
private readonly _overwriteOptions: IEditorOptions;
|
|
688
|
+
|
|
689
|
+
constructor(
|
|
690
|
+
domElement: HTMLElement,
|
|
691
|
+
options: Readonly<IStandaloneEditorConstructionOptions>,
|
|
692
|
+
parentEditor: ICodeEditor,
|
|
693
|
+
@IInstantiationService instantiationService: IInstantiationService,
|
|
694
|
+
@ICodeEditorService codeEditorService: ICodeEditorService,
|
|
695
|
+
@ICommandService commandService: ICommandService,
|
|
696
|
+
@IContextKeyService contextKeyService: IContextKeyService,
|
|
697
|
+
@IKeybindingService keybindingService: IKeybindingService,
|
|
698
|
+
@IThemeService themeService: IThemeService,
|
|
699
|
+
@INotificationService notificationService: INotificationService,
|
|
700
|
+
@IAccessibilityService accessibilityService: IAccessibilityService,
|
|
701
|
+
@ILanguageConfigurationService languageConfigurationService: ILanguageConfigurationService,
|
|
702
|
+
@ILanguageFeaturesService languageFeaturesService: ILanguageFeaturesService,
|
|
703
|
+
) {
|
|
704
|
+
super(domElement, { ...parentEditor.getRawOptions(), overflowWidgetsDomNode: parentEditor.getOverflowWidgetsDomNode() }, instantiationService, codeEditorService,
|
|
705
|
+
commandService, contextKeyService, keybindingService, themeService, notificationService, accessibilityService, languageConfigurationService, languageFeaturesService);
|
|
706
|
+
|
|
707
|
+
this._parentEditor = parentEditor;
|
|
708
|
+
this._overwriteOptions = options;
|
|
709
|
+
|
|
710
|
+
// Overwrite parent's options
|
|
711
|
+
super.updateOptions(this._overwriteOptions);
|
|
712
|
+
|
|
713
|
+
this._register(parentEditor.onDidChangeConfiguration((e: ConfigurationChangedEvent) => this._onParentConfigurationChanged(e)));
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
getParentEditor(): ICodeEditor {
|
|
717
|
+
return this._parentEditor;
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
private _onParentConfigurationChanged(e: ConfigurationChangedEvent): void {
|
|
721
|
+
super.updateOptions(this._parentEditor.getRawOptions());
|
|
722
|
+
super.updateOptions(this._overwriteOptions);
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
override updateOptions(newOptions: IEditorOptions): void {
|
|
726
|
+
objects.mixin(this._overwriteOptions, newOptions, true);
|
|
727
|
+
super.updateOptions(this._overwriteOptions);
|
|
728
|
+
}
|
|
729
|
+
}
|
|
@@ -14,22 +14,6 @@
|
|
|
14
14
|
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
|
-
import * as MonacoNls from '@theia/monaco-editor-core/esm/vs/nls';
|
|
18
|
-
import { nls } from '@theia/core/lib/common/nls';
|
|
19
|
-
import { FormatType, Localization } from '@theia/core/lib/common/i18n/localization';
|
|
20
|
-
|
|
21
|
-
Object.assign(MonacoNls, {
|
|
22
|
-
localize(_key: string, label: string, ...args: FormatType[]): string {
|
|
23
|
-
if (nls.locale) {
|
|
24
|
-
const defaultKey = nls.getDefaultKey(label);
|
|
25
|
-
if (defaultKey) {
|
|
26
|
-
return nls.localize(defaultKey, label, ...args);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
return Localization.format(label, args);
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
|
|
33
17
|
import '../../src/browser/style/index.css';
|
|
34
18
|
import { ContainerModule, interfaces } from '@theia/core/shared/inversify';
|
|
35
19
|
import { MenuContribution, CommandContribution, quickInputServicePath } from '@theia/core/lib/common';
|
|
@@ -27,6 +27,23 @@
|
|
|
27
27
|
* is allowed.
|
|
28
28
|
*/
|
|
29
29
|
|
|
30
|
+
// Before importing anything from monaco we need to override its localization function
|
|
31
|
+
import * as MonacoNls from '@theia/monaco-editor-core/esm/vs/nls';
|
|
32
|
+
import { nls } from '@theia/core/lib/common/nls';
|
|
33
|
+
import { FormatType, Localization } from '@theia/core/lib/common/i18n/localization';
|
|
34
|
+
|
|
35
|
+
Object.assign(MonacoNls, {
|
|
36
|
+
localize(_key: string, label: string, ...args: FormatType[]): string {
|
|
37
|
+
if (nls.locale) {
|
|
38
|
+
const defaultKey = nls.getDefaultKey(label);
|
|
39
|
+
if (defaultKey) {
|
|
40
|
+
return nls.localize(defaultKey, label, ...args);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return Localization.format(label, args);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
|
|
30
47
|
import { Container } from '@theia/core/shared/inversify';
|
|
31
48
|
import { ICodeEditorService } from '@theia/monaco-editor-core/esm/vs/editor/browser/services/codeEditorService';
|
|
32
49
|
import { StandaloneServices } from '@theia/monaco-editor-core/esm/vs/editor/standalone/browser/standaloneServices';
|
|
@@ -14,12 +14,13 @@
|
|
|
14
14
|
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
|
-
import {
|
|
18
|
-
import { MenuContribution, MenuModelRegistry, MAIN_MENU_BAR, MenuPath, MenuAction } from '@theia/core/lib/common';
|
|
19
|
-
import { EditorMainMenu, EDITOR_CONTEXT_MENU } from '@theia/editor/lib/browser';
|
|
20
|
-
import { MonacoCommandRegistry } from './monaco-command-registry';
|
|
17
|
+
import { MAIN_MENU_BAR, MenuAction, MenuContribution, MenuModelRegistry, MenuPath } from '@theia/core/lib/common';
|
|
21
18
|
import { nls } from '@theia/core/lib/common/nls';
|
|
22
|
-
import {
|
|
19
|
+
import { inject, injectable } from '@theia/core/shared/inversify';
|
|
20
|
+
import { EDITOR_CONTEXT_MENU, EditorMainMenu } from '@theia/editor/lib/browser';
|
|
21
|
+
import { IMenuItem, MenuId, MenuRegistry, isIMenuItem } from '@theia/monaco-editor-core/esm/vs/platform/actions/common/actions';
|
|
22
|
+
import { MonacoCommands } from './monaco-command';
|
|
23
|
+
import { MonacoCommandRegistry } from './monaco-command-registry';
|
|
23
24
|
|
|
24
25
|
export interface MonacoActionGroup {
|
|
25
26
|
id: string;
|
|
@@ -46,7 +47,11 @@ export class MonacoEditorMenuContribution implements MenuContribution {
|
|
|
46
47
|
const commandId = this.commands.validate(item.command.id);
|
|
47
48
|
if (commandId) {
|
|
48
49
|
const menuPath = [...EDITOR_CONTEXT_MENU, (item.group || '')];
|
|
49
|
-
|
|
50
|
+
const coreId = MonacoCommands.COMMON_ACTIONS.get(commandId);
|
|
51
|
+
if (!(coreId && registry.getMenu(menuPath).children.some(it => it.id === coreId))) {
|
|
52
|
+
// Don't add additional actions if the item is already registered with a core ID.
|
|
53
|
+
registry.registerMenuAction(menuPath, this.buildMenuAction(commandId, item));
|
|
54
|
+
}
|
|
50
55
|
}
|
|
51
56
|
}
|
|
52
57
|
|