@theia/monaco 1.45.0 → 1.46.0-next.72
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/index.d.ts +1 -1
- package/lib/browser/index.js +28 -28
- package/lib/browser/markdown-renderer/monaco-markdown-renderer.d.ts +20 -24
- package/lib/browser/markdown-renderer/monaco-markdown-renderer.d.ts.map +1 -1
- package/lib/browser/markdown-renderer/monaco-markdown-renderer.js +122 -137
- package/lib/browser/markdown-renderer/monaco-markdown-renderer.js.map +1 -1
- package/lib/browser/monaco-bulk-edit-service.d.ts +12 -14
- package/lib/browser/monaco-bulk-edit-service.d.ts.map +1 -1
- package/lib/browser/monaco-bulk-edit-service.js +66 -66
- package/lib/browser/monaco-bulk-edit-service.js.map +1 -1
- package/lib/browser/monaco-color-registry.d.ts +16 -16
- package/lib/browser/monaco-color-registry.js +82 -82
- package/lib/browser/monaco-command-registry.d.ts +19 -19
- package/lib/browser/monaco-command-registry.d.ts.map +1 -1
- package/lib/browser/monaco-command-registry.js +88 -85
- package/lib/browser/monaco-command-registry.js.map +1 -1
- package/lib/browser/monaco-command-service.d.ts +21 -26
- package/lib/browser/monaco-command-service.d.ts.map +1 -1
- package/lib/browser/monaco-command-service.js +93 -92
- package/lib/browser/monaco-command-service.js.map +1 -1
- package/lib/browser/monaco-command.d.ts +88 -94
- package/lib/browser/monaco-command.d.ts.map +1 -1
- package/lib/browser/monaco-command.js +294 -307
- package/lib/browser/monaco-command.js.map +1 -1
- package/lib/browser/monaco-context-key-service.d.ts +22 -22
- package/lib/browser/monaco-context-key-service.d.ts.map +1 -1
- package/lib/browser/monaco-context-key-service.js +146 -147
- package/lib/browser/monaco-context-key-service.js.map +1 -1
- package/lib/browser/monaco-context-menu.d.ts +17 -16
- package/lib/browser/monaco-context-menu.d.ts.map +1 -1
- package/lib/browser/monaco-context-menu.js +112 -102
- package/lib/browser/monaco-context-menu.js.map +1 -1
- package/lib/browser/monaco-diff-editor.d.ts +29 -29
- package/lib/browser/monaco-diff-editor.d.ts.map +1 -1
- package/lib/browser/monaco-diff-editor.js +74 -74
- package/lib/browser/monaco-diff-editor.js.map +1 -1
- package/lib/browser/monaco-diff-navigator-factory.d.ts +6 -7
- package/lib/browser/monaco-diff-navigator-factory.d.ts.map +1 -1
- package/lib/browser/monaco-diff-navigator-factory.js +45 -66
- package/lib/browser/monaco-diff-navigator-factory.js.map +1 -1
- package/lib/browser/monaco-editor-model.d.ts +158 -156
- package/lib/browser/monaco-editor-model.d.ts.map +1 -1
- package/lib/browser/monaco-editor-model.js +562 -559
- package/lib/browser/monaco-editor-model.js.map +1 -1
- package/lib/browser/monaco-editor-provider.d.ts +70 -89
- package/lib/browser/monaco-editor-provider.d.ts.map +1 -1
- package/lib/browser/monaco-editor-provider.js +386 -440
- package/lib/browser/monaco-editor-provider.js.map +1 -1
- package/lib/browser/monaco-editor-service.d.ts +32 -27
- package/lib/browser/monaco-editor-service.d.ts.map +1 -1
- package/lib/browser/monaco-editor-service.js +158 -155
- package/lib/browser/monaco-editor-service.js.map +1 -1
- package/lib/browser/monaco-editor-zone-widget.d.ts +43 -43
- package/lib/browser/monaco-editor-zone-widget.js +194 -194
- package/lib/browser/monaco-editor.d.ts +154 -151
- package/lib/browser/monaco-editor.d.ts.map +1 -1
- package/lib/browser/monaco-editor.js +542 -524
- package/lib/browser/monaco-editor.js.map +1 -1
- package/lib/browser/monaco-formatting-conflicts.d.ts +13 -13
- package/lib/browser/monaco-formatting-conflicts.js +111 -111
- package/lib/browser/monaco-formatting-conflicts.js.map +1 -1
- package/lib/browser/monaco-frontend-application-contribution.d.ts +22 -28
- package/lib/browser/monaco-frontend-application-contribution.d.ts.map +1 -1
- package/lib/browser/monaco-frontend-application-contribution.js +178 -215
- package/lib/browser/monaco-frontend-application-contribution.js.map +1 -1
- package/lib/browser/monaco-frontend-module.d.ts +7 -7
- package/lib/browser/monaco-frontend-module.d.ts.map +1 -1
- package/lib/browser/monaco-frontend-module.js +280 -271
- package/lib/browser/monaco-frontend-module.js.map +1 -1
- package/lib/browser/monaco-gotoline-quick-access.d.ts +11 -11
- package/lib/browser/monaco-gotoline-quick-access.js +64 -64
- package/lib/browser/monaco-gotosymbol-quick-access.d.ts +16 -16
- package/lib/browser/monaco-gotosymbol-quick-access.js +70 -70
- package/lib/browser/monaco-icon-registry.d.ts +10 -11
- package/lib/browser/monaco-icon-registry.d.ts.map +1 -1
- package/lib/browser/monaco-icon-registry.js +52 -50
- package/lib/browser/monaco-icon-registry.js.map +1 -1
- package/lib/browser/monaco-indexed-db.d.ts +28 -28
- package/lib/browser/monaco-indexed-db.js +131 -131
- package/lib/browser/monaco-init.d.ts +5 -0
- package/lib/browser/monaco-init.d.ts.map +1 -0
- package/lib/browser/monaco-init.js +125 -0
- package/lib/browser/monaco-init.js.map +1 -0
- package/lib/browser/monaco-keybinding.d.ts +16 -16
- package/lib/browser/monaco-keybinding.js +134 -134
- package/lib/browser/monaco-keybinding.js.map +1 -1
- package/lib/browser/monaco-keycode-map.d.ts +2 -2
- package/lib/browser/monaco-keycode-map.js +163 -163
- package/lib/browser/monaco-keycode-map.js.map +1 -1
- package/lib/browser/monaco-languages.d.ts +35 -35
- package/lib/browser/monaco-languages.js +180 -180
- package/lib/browser/monaco-marker-collection.d.ts +18 -18
- package/lib/browser/monaco-marker-collection.js +70 -70
- package/lib/browser/monaco-menu.d.ts +20 -20
- package/lib/browser/monaco-menu.js +145 -145
- package/lib/browser/monaco-mime-service.d.ts +10 -10
- package/lib/browser/monaco-mime-service.js +78 -78
- package/lib/browser/monaco-outline-contribution.d.ts +78 -78
- package/lib/browser/monaco-outline-contribution.js +384 -384
- package/lib/browser/monaco-outline-decorator.d.ts +12 -12
- package/lib/browser/monaco-outline-decorator.js +67 -67
- package/lib/browser/monaco-quick-access-registry.d.ts +11 -11
- package/lib/browser/monaco-quick-access-registry.js +99 -99
- package/lib/browser/monaco-quick-input-service.d.ts +99 -101
- package/lib/browser/monaco-quick-input-service.d.ts.map +1 -1
- package/lib/browser/monaco-quick-input-service.js +529 -568
- package/lib/browser/monaco-quick-input-service.js.map +1 -1
- package/lib/browser/monaco-resolved-keybinding.d.ts +23 -23
- package/lib/browser/monaco-resolved-keybinding.d.ts.map +1 -1
- package/lib/browser/monaco-resolved-keybinding.js +131 -131
- package/lib/browser/monaco-resolved-keybinding.js.map +1 -1
- package/lib/browser/monaco-snippet-suggest-provider.d.ts +66 -66
- package/lib/browser/monaco-snippet-suggest-provider.js +273 -273
- package/lib/browser/monaco-status-bar-contribution.d.ts +17 -17
- package/lib/browser/monaco-status-bar-contribution.js +121 -121
- package/lib/browser/monaco-text-model-service.d.ts +51 -51
- package/lib/browser/monaco-text-model-service.js +189 -189
- package/lib/browser/monaco-text-model-service.js.map +1 -1
- package/lib/browser/monaco-theming-service.d.ts +67 -67
- package/lib/browser/monaco-theming-service.js +171 -171
- package/lib/browser/monaco-to-protocol-converter.d.ts +26 -26
- package/lib/browser/monaco-to-protocol-converter.js +61 -61
- package/lib/browser/monaco-workspace.d.ts +83 -85
- package/lib/browser/monaco-workspace.d.ts.map +1 -1
- package/lib/browser/monaco-workspace.js +384 -384
- package/lib/browser/monaco-workspace.js.map +1 -1
- package/lib/browser/protocol-to-monaco-converter.d.ts +31 -31
- package/lib/browser/protocol-to-monaco-converter.js +133 -133
- package/lib/browser/simple-monaco-editor.d.ts +45 -44
- package/lib/browser/simple-monaco-editor.d.ts.map +1 -1
- package/lib/browser/simple-monaco-editor.js +184 -176
- package/lib/browser/simple-monaco-editor.js.map +1 -1
- package/lib/browser/textmate/index.d.ts +4 -4
- package/lib/browser/textmate/index.js +31 -31
- package/lib/browser/textmate/monaco-textmate-frontend-bindings.d.ts +11 -11
- package/lib/browser/textmate/monaco-textmate-frontend-bindings.js +91 -91
- package/lib/browser/textmate/monaco-textmate-service.d.ts +30 -30
- package/lib/browser/textmate/monaco-textmate-service.js +185 -185
- package/lib/browser/textmate/monaco-textmate-service.js.map +1 -1
- package/lib/browser/textmate/monaco-theme-registry.d.ts +27 -27
- package/lib/browser/textmate/monaco-theme-registry.js +173 -173
- package/lib/browser/textmate/monaco-theme-types.d.ts +20 -20
- package/lib/browser/textmate/monaco-theme-types.js +21 -21
- package/lib/browser/textmate/textmate-contribution.d.ts +9 -9
- package/lib/browser/textmate/textmate-contribution.js +27 -27
- package/lib/browser/textmate/textmate-registry.d.ts +31 -31
- package/lib/browser/textmate/textmate-registry.js +109 -109
- package/lib/browser/textmate/textmate-snippet-completion-provider.d.ts +26 -26
- package/lib/browser/textmate/textmate-snippet-completion-provider.js +53 -53
- package/lib/browser/textmate/textmate-tokenizer.d.ts +22 -22
- package/lib/browser/textmate/textmate-tokenizer.js +65 -65
- package/lib/browser/workspace-symbol-command.d.ts +55 -55
- package/lib/browser/workspace-symbol-command.js +215 -215
- package/lib/package.spec.js +25 -25
- package/package.json +10 -10
- package/src/browser/index.ts +17 -17
- package/src/browser/markdown-renderer/monaco-markdown-renderer.ts +109 -117
- 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 -82
- package/src/browser/monaco-command-service.ts +90 -99
- package/src/browser/monaco-command.ts +303 -313
- package/src/browser/monaco-context-key-service.ts +144 -143
- package/src/browser/monaco-context-menu.ts +100 -90
- package/src/browser/monaco-diff-editor.ts +100 -101
- package/src/browser/monaco-diff-navigator-factory.ts +39 -61
- package/src/browser/monaco-editor-model.ts +684 -681
- package/src/browser/monaco-editor-provider.ts +409 -452
- package/src/browser/monaco-editor-service.ts +149 -144
- package/src/browser/monaco-editor-zone-widget.ts +250 -250
- package/src/browser/monaco-editor.ts +663 -644
- package/src/browser/monaco-formatting-conflicts.ts +116 -116
- package/src/browser/monaco-frontend-application-contribution.ts +165 -200
- package/src/browser/monaco-frontend-module.ts +328 -320
- 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 -47
- package/src/browser/monaco-indexed-db.ts +130 -130
- package/src/browser/monaco-init.ts +114 -0
- 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 +142 -142
- 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 +647 -676
- package/src/browser/monaco-resolved-keybinding.ts +162 -162
- package/src/browser/monaco-snippet-suggest-provider.ts +306 -306
- package/src/browser/monaco-status-bar-contribution.ts +110 -110
- package/src/browser/monaco-text-model-service.ts +199 -199
- package/src/browser/monaco-theming-service.ts +204 -204
- package/src/browser/monaco-to-protocol-converter.ts +71 -71
- package/src/browser/monaco-workspace.ts +412 -412
- package/src/browser/protocol-to-monaco-converter.ts +158 -158
- package/src/browser/simple-monaco-editor.ts +217 -210
- package/src/browser/style/index.css +263 -263
- 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,525 +1,543 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// *****************************************************************************
|
|
3
|
-
// Copyright (C) 2018 TypeFox and others.
|
|
4
|
-
//
|
|
5
|
-
// This program and the accompanying materials are made available under the
|
|
6
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
-
//
|
|
9
|
-
// This Source Code may also be made available under the following Secondary
|
|
10
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
-
// with the GNU Classpath Exception which is available at
|
|
13
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
-
//
|
|
15
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
|
-
// *****************************************************************************
|
|
17
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
18
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
19
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
20
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
21
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
22
|
-
};
|
|
23
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
24
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
25
|
-
};
|
|
26
|
-
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
27
|
-
return function (target, key) { decorator(target, key, paramIndex); }
|
|
28
|
-
};
|
|
29
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
-
exports.MonacoEditor = exports.MonacoEditorServices = void 0;
|
|
31
|
-
const inversify_1 = require("@theia/core/shared/inversify");
|
|
32
|
-
const domutils_1 = require("@theia/core/shared/@phosphor/domutils");
|
|
33
|
-
const context_key_service_1 = require("@theia/core/lib/browser/context-key-service");
|
|
34
|
-
const common_1 = require("@theia/core/lib/common");
|
|
35
|
-
const monaco_to_protocol_converter_1 = require("./monaco-to-protocol-converter");
|
|
36
|
-
const protocol_to_monaco_converter_1 = require("./protocol-to-monaco-converter");
|
|
37
|
-
const encodings_1 = require("@theia/core/lib/common/encodings");
|
|
38
|
-
const monaco = require("@theia/monaco-editor-core");
|
|
39
|
-
const standaloneServices_1 = require("@theia/monaco-editor-core/esm/vs/editor/standalone/browser/standaloneServices");
|
|
40
|
-
const language_1 = require("@theia/monaco-editor-core/esm/vs/editor/common/languages/language");
|
|
41
|
-
const
|
|
42
|
-
const standaloneCodeEditor_1 = require("@theia/monaco-editor-core/esm/vs/editor/standalone/browser/standaloneCodeEditor");
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
MonacoEditorServices
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
this.
|
|
71
|
-
this.
|
|
72
|
-
this.
|
|
73
|
-
this.
|
|
74
|
-
this.
|
|
75
|
-
this.
|
|
76
|
-
this.
|
|
77
|
-
this.
|
|
78
|
-
this.
|
|
79
|
-
this.
|
|
80
|
-
this.
|
|
81
|
-
this.
|
|
82
|
-
this.
|
|
83
|
-
this.
|
|
84
|
-
this.
|
|
85
|
-
|
|
86
|
-
this.
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
this.
|
|
91
|
-
this.
|
|
92
|
-
this.
|
|
93
|
-
this.
|
|
94
|
-
this.
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
this.
|
|
99
|
-
this.
|
|
100
|
-
this.
|
|
101
|
-
this.
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
this.toDispose.push(codeEditor.
|
|
147
|
-
this.toDispose.push(codeEditor.
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
this.
|
|
194
|
-
}
|
|
195
|
-
get
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
case '
|
|
229
|
-
this.editor.
|
|
230
|
-
break;
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
textarea.
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
this.
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
this.
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
dimension
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
if (this.
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
return {
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
const
|
|
423
|
-
const
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
this._languageAutoDetected
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
this._languageAutoDetected =
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
(
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
function
|
|
500
|
-
return get(
|
|
501
|
-
}
|
|
502
|
-
MonacoEditor.
|
|
503
|
-
function
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2018 TypeFox and others.
|
|
4
|
+
//
|
|
5
|
+
// This program and the accompanying materials are made available under the
|
|
6
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
+
//
|
|
9
|
+
// This Source Code may also be made available under the following Secondary
|
|
10
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
+
// with the GNU Classpath Exception which is available at
|
|
13
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
+
//
|
|
15
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
|
+
// *****************************************************************************
|
|
17
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
18
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
19
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
20
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
21
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
22
|
+
};
|
|
23
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
24
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
25
|
+
};
|
|
26
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
27
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
28
|
+
};
|
|
29
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
+
exports.MonacoEditor = exports.MonacoEditorServices = void 0;
|
|
31
|
+
const inversify_1 = require("@theia/core/shared/inversify");
|
|
32
|
+
const domutils_1 = require("@theia/core/shared/@phosphor/domutils");
|
|
33
|
+
const context_key_service_1 = require("@theia/core/lib/browser/context-key-service");
|
|
34
|
+
const common_1 = require("@theia/core/lib/common");
|
|
35
|
+
const monaco_to_protocol_converter_1 = require("./monaco-to-protocol-converter");
|
|
36
|
+
const protocol_to_monaco_converter_1 = require("./protocol-to-monaco-converter");
|
|
37
|
+
const encodings_1 = require("@theia/core/lib/common/encodings");
|
|
38
|
+
const monaco = require("@theia/monaco-editor-core");
|
|
39
|
+
const standaloneServices_1 = require("@theia/monaco-editor-core/esm/vs/editor/standalone/browser/standaloneServices");
|
|
40
|
+
const language_1 = require("@theia/monaco-editor-core/esm/vs/editor/common/languages/language");
|
|
41
|
+
const instantiation_1 = require("@theia/monaco-editor-core/esm/vs/platform/instantiation/common/instantiation");
|
|
42
|
+
const standaloneCodeEditor_1 = require("@theia/monaco-editor-core/esm/vs/editor/standalone/browser/standaloneCodeEditor");
|
|
43
|
+
const serviceCollection_1 = require("@theia/monaco-editor-core/esm/vs/platform/instantiation/common/serviceCollection");
|
|
44
|
+
let MonacoEditorServices = class MonacoEditorServices {
|
|
45
|
+
constructor(services) {
|
|
46
|
+
Object.assign(this, services);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
__decorate([
|
|
50
|
+
(0, inversify_1.inject)(monaco_to_protocol_converter_1.MonacoToProtocolConverter),
|
|
51
|
+
__metadata("design:type", monaco_to_protocol_converter_1.MonacoToProtocolConverter)
|
|
52
|
+
], MonacoEditorServices.prototype, "m2p", void 0);
|
|
53
|
+
__decorate([
|
|
54
|
+
(0, inversify_1.inject)(protocol_to_monaco_converter_1.ProtocolToMonacoConverter),
|
|
55
|
+
__metadata("design:type", protocol_to_monaco_converter_1.ProtocolToMonacoConverter)
|
|
56
|
+
], MonacoEditorServices.prototype, "p2m", void 0);
|
|
57
|
+
__decorate([
|
|
58
|
+
(0, inversify_1.inject)(context_key_service_1.ContextKeyService),
|
|
59
|
+
__metadata("design:type", Object)
|
|
60
|
+
], MonacoEditorServices.prototype, "contextKeyService", void 0);
|
|
61
|
+
MonacoEditorServices = __decorate([
|
|
62
|
+
(0, inversify_1.injectable)(),
|
|
63
|
+
__param(0, (0, inversify_1.unmanaged)()),
|
|
64
|
+
__metadata("design:paramtypes", [MonacoEditorServices])
|
|
65
|
+
], MonacoEditorServices);
|
|
66
|
+
exports.MonacoEditorServices = MonacoEditorServices;
|
|
67
|
+
class MonacoEditor extends MonacoEditorServices {
|
|
68
|
+
constructor(uri, document, node, services, options, override) {
|
|
69
|
+
super(services);
|
|
70
|
+
this.uri = uri;
|
|
71
|
+
this.document = document;
|
|
72
|
+
this.node = node;
|
|
73
|
+
this.toDispose = new common_1.DisposableCollection();
|
|
74
|
+
this.onCursorPositionChangedEmitter = new common_1.Emitter();
|
|
75
|
+
this.onSelectionChangedEmitter = new common_1.Emitter();
|
|
76
|
+
this.onFocusChangedEmitter = new common_1.Emitter();
|
|
77
|
+
this.onDocumentContentChangedEmitter = new common_1.Emitter();
|
|
78
|
+
this.onMouseDownEmitter = new common_1.Emitter();
|
|
79
|
+
this.onDidChangeReadOnly = this.document.onDidChangeReadOnly;
|
|
80
|
+
this.onLanguageChangedEmitter = new common_1.Emitter();
|
|
81
|
+
this.onLanguageChanged = this.onLanguageChangedEmitter.event;
|
|
82
|
+
this.onScrollChangedEmitter = new common_1.Emitter();
|
|
83
|
+
this.onEncodingChanged = this.document.onDidChangeEncoding;
|
|
84
|
+
this.onResizeEmitter = new common_1.Emitter();
|
|
85
|
+
this.onDidResize = this.onResizeEmitter.event;
|
|
86
|
+
this.documents = new Set();
|
|
87
|
+
/* `true` because it is derived from an URI during the instantiation */
|
|
88
|
+
this._languageAutoDetected = true;
|
|
89
|
+
this.toDispose.pushAll([
|
|
90
|
+
this.onCursorPositionChangedEmitter,
|
|
91
|
+
this.onSelectionChangedEmitter,
|
|
92
|
+
this.onFocusChangedEmitter,
|
|
93
|
+
this.onDocumentContentChangedEmitter,
|
|
94
|
+
this.onMouseDownEmitter,
|
|
95
|
+
this.onLanguageChangedEmitter,
|
|
96
|
+
this.onScrollChangedEmitter
|
|
97
|
+
]);
|
|
98
|
+
this.documents.add(document);
|
|
99
|
+
this.autoSizing = options && options.autoSizing !== undefined ? options.autoSizing : false;
|
|
100
|
+
this.minHeight = options && options.minHeight !== undefined ? options.minHeight : -1;
|
|
101
|
+
this.maxHeight = options && options.maxHeight !== undefined ? options.maxHeight : -1;
|
|
102
|
+
this.toDispose.push(this.create({
|
|
103
|
+
...MonacoEditor.createReadOnlyOptions(document.readOnly),
|
|
104
|
+
...options
|
|
105
|
+
}, override));
|
|
106
|
+
this.addHandlers(this.editor);
|
|
107
|
+
}
|
|
108
|
+
getEncoding() {
|
|
109
|
+
return this.document.getEncoding() || encodings_1.UTF8;
|
|
110
|
+
}
|
|
111
|
+
setEncoding(encoding, mode) {
|
|
112
|
+
return this.document.setEncoding(encoding, mode);
|
|
113
|
+
}
|
|
114
|
+
create(options, override) {
|
|
115
|
+
const combinedOptions = {
|
|
116
|
+
...options,
|
|
117
|
+
lightbulb: { enabled: true },
|
|
118
|
+
fixedOverflowWidgets: true,
|
|
119
|
+
scrollbar: {
|
|
120
|
+
useShadows: false,
|
|
121
|
+
verticalHasArrows: false,
|
|
122
|
+
horizontalHasArrows: false,
|
|
123
|
+
verticalScrollbarSize: 10,
|
|
124
|
+
horizontalScrollbarSize: 10,
|
|
125
|
+
...options === null || options === void 0 ? void 0 : options.scrollbar,
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
const instantiator = this.getInstantiatorWithOverrides(override);
|
|
129
|
+
/**
|
|
130
|
+
* @monaco-uplift. Should be guaranteed to work.
|
|
131
|
+
* Incomparable enums prevent TypeScript from believing that public IStandaloneCodeEditor is satisfied by private StandaloneCodeEditor
|
|
132
|
+
*/
|
|
133
|
+
return this.editor = instantiator.createInstance(standaloneCodeEditor_1.StandaloneEditor, this.node, combinedOptions);
|
|
134
|
+
}
|
|
135
|
+
getInstantiatorWithOverrides(override) {
|
|
136
|
+
const instantiator = standaloneServices_1.StandaloneServices.get(instantiation_1.IInstantiationService);
|
|
137
|
+
if (override) {
|
|
138
|
+
const overrideServices = new serviceCollection_1.ServiceCollection(...override);
|
|
139
|
+
return instantiator.createChild(overrideServices);
|
|
140
|
+
}
|
|
141
|
+
return instantiator;
|
|
142
|
+
}
|
|
143
|
+
addHandlers(codeEditor) {
|
|
144
|
+
this.toDispose.push(codeEditor.onDidChangeModelLanguage(e => this.fireLanguageChanged(e.newLanguage)));
|
|
145
|
+
this.toDispose.push(codeEditor.onDidChangeConfiguration(() => this.refresh()));
|
|
146
|
+
this.toDispose.push(codeEditor.onDidChangeModel(() => this.refresh()));
|
|
147
|
+
this.toDispose.push(codeEditor.onDidChangeModelContent(e => {
|
|
148
|
+
this.refresh();
|
|
149
|
+
this.onDocumentContentChangedEmitter.fire({ document: this.document, contentChanges: e.changes.map(this.mapModelContentChange.bind(this)) });
|
|
150
|
+
}));
|
|
151
|
+
this.toDispose.push(codeEditor.onDidChangeCursorPosition(() => this.onCursorPositionChangedEmitter.fire(this.cursor)));
|
|
152
|
+
this.toDispose.push(codeEditor.onDidChangeCursorSelection(() => this.onSelectionChangedEmitter.fire(this.selection)));
|
|
153
|
+
this.toDispose.push(codeEditor.onDidFocusEditorText(() => this.onFocusChangedEmitter.fire(this.isFocused())));
|
|
154
|
+
this.toDispose.push(codeEditor.onDidBlurEditorText(() => this.onFocusChangedEmitter.fire(this.isFocused())));
|
|
155
|
+
this.toDispose.push(codeEditor.onMouseDown(e => {
|
|
156
|
+
const { element, position, range } = e.target;
|
|
157
|
+
this.onMouseDownEmitter.fire({
|
|
158
|
+
target: {
|
|
159
|
+
type: e.target.type,
|
|
160
|
+
element: element || undefined,
|
|
161
|
+
mouseColumn: this.m2p.asPosition(undefined, e.target.mouseColumn).character,
|
|
162
|
+
range: range && this.m2p.asRange(range) || undefined,
|
|
163
|
+
position: position && this.m2p.asPosition(position.lineNumber, position.column) || undefined,
|
|
164
|
+
detail: e.target.detail || {},
|
|
165
|
+
},
|
|
166
|
+
event: e.event.browserEvent
|
|
167
|
+
});
|
|
168
|
+
}));
|
|
169
|
+
this.toDispose.push(codeEditor.onDidScrollChange(e => {
|
|
170
|
+
this.onScrollChangedEmitter.fire(undefined);
|
|
171
|
+
}));
|
|
172
|
+
this.toDispose.push(this.onDidChangeReadOnly(readOnly => {
|
|
173
|
+
codeEditor.updateOptions(MonacoEditor.createReadOnlyOptions(readOnly));
|
|
174
|
+
}));
|
|
175
|
+
}
|
|
176
|
+
getVisibleRanges() {
|
|
177
|
+
return this.editor.getVisibleRanges().map(range => this.m2p.asRange(range));
|
|
178
|
+
}
|
|
179
|
+
mapModelContentChange(change) {
|
|
180
|
+
return {
|
|
181
|
+
range: this.m2p.asRange(change.range),
|
|
182
|
+
rangeLength: change.rangeLength,
|
|
183
|
+
text: change.text
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
get onDispose() {
|
|
187
|
+
return this.toDispose.onDispose;
|
|
188
|
+
}
|
|
189
|
+
get onDocumentContentChanged() {
|
|
190
|
+
return this.onDocumentContentChangedEmitter.event;
|
|
191
|
+
}
|
|
192
|
+
get isReadonly() {
|
|
193
|
+
return this.document.readOnly;
|
|
194
|
+
}
|
|
195
|
+
get cursor() {
|
|
196
|
+
const { lineNumber, column } = this.editor.getPosition();
|
|
197
|
+
return this.m2p.asPosition(lineNumber, column);
|
|
198
|
+
}
|
|
199
|
+
set cursor(cursor) {
|
|
200
|
+
const position = this.p2m.asPosition(cursor);
|
|
201
|
+
this.editor.setPosition(position);
|
|
202
|
+
}
|
|
203
|
+
get onCursorPositionChanged() {
|
|
204
|
+
return this.onCursorPositionChangedEmitter.event;
|
|
205
|
+
}
|
|
206
|
+
get selection() {
|
|
207
|
+
return this.m2p.asRange(this.editor.getSelection());
|
|
208
|
+
}
|
|
209
|
+
set selection(selection) {
|
|
210
|
+
const range = this.p2m.asRange(selection);
|
|
211
|
+
this.editor.setSelection(range);
|
|
212
|
+
}
|
|
213
|
+
get onSelectionChanged() {
|
|
214
|
+
return this.onSelectionChangedEmitter.event;
|
|
215
|
+
}
|
|
216
|
+
get onScrollChanged() {
|
|
217
|
+
return this.onScrollChangedEmitter.event;
|
|
218
|
+
}
|
|
219
|
+
revealPosition(raw, options = { vertical: 'center' }) {
|
|
220
|
+
const position = this.p2m.asPosition(raw);
|
|
221
|
+
switch (options.vertical) {
|
|
222
|
+
case 'auto':
|
|
223
|
+
this.editor.revealPosition(position);
|
|
224
|
+
break;
|
|
225
|
+
case 'center':
|
|
226
|
+
this.editor.revealPositionInCenter(position);
|
|
227
|
+
break;
|
|
228
|
+
case 'centerIfOutsideViewport':
|
|
229
|
+
this.editor.revealPositionInCenterIfOutsideViewport(position);
|
|
230
|
+
break;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
revealRange(raw, options = { at: 'center' }) {
|
|
234
|
+
const range = this.p2m.asRange(raw);
|
|
235
|
+
switch (options.at) {
|
|
236
|
+
case 'top':
|
|
237
|
+
this.editor.revealRangeAtTop(range);
|
|
238
|
+
break;
|
|
239
|
+
case 'center':
|
|
240
|
+
this.editor.revealRangeInCenter(range);
|
|
241
|
+
break;
|
|
242
|
+
case 'centerIfOutsideViewport':
|
|
243
|
+
this.editor.revealRangeInCenterIfOutsideViewport(range);
|
|
244
|
+
break;
|
|
245
|
+
case 'auto':
|
|
246
|
+
this.editor.revealRange(range);
|
|
247
|
+
break;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
focus() {
|
|
251
|
+
/**
|
|
252
|
+
* `this.editor.focus` forcefully changes the focus editor state,
|
|
253
|
+
* regardless whether the textarea actually received the focus.
|
|
254
|
+
* It could lead to issues like https://github.com/eclipse-theia/theia/issues/7902
|
|
255
|
+
* Instead we focus the underlying textarea.
|
|
256
|
+
*/
|
|
257
|
+
const node = this.editor.getDomNode();
|
|
258
|
+
if (node) {
|
|
259
|
+
const textarea = node.querySelector('textarea');
|
|
260
|
+
textarea.focus();
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
blur() {
|
|
264
|
+
const node = this.editor.getDomNode();
|
|
265
|
+
if (node) {
|
|
266
|
+
const textarea = node.querySelector('textarea');
|
|
267
|
+
textarea.blur();
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
isFocused({ strict } = { strict: false }) {
|
|
271
|
+
if (!this.editor.hasTextFocus()) {
|
|
272
|
+
return false;
|
|
273
|
+
}
|
|
274
|
+
if (strict) {
|
|
275
|
+
return !this.isSuggestWidgetVisible() && !this.isFindWidgetVisible() && !this.isRenameInputVisible();
|
|
276
|
+
}
|
|
277
|
+
return true;
|
|
278
|
+
}
|
|
279
|
+
get onFocusChanged() {
|
|
280
|
+
return this.onFocusChangedEmitter.event;
|
|
281
|
+
}
|
|
282
|
+
get onMouseDown() {
|
|
283
|
+
return this.onMouseDownEmitter.event;
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* `true` if the suggest widget is visible in the editor. Otherwise, `false`.
|
|
287
|
+
*/
|
|
288
|
+
isSuggestWidgetVisible() {
|
|
289
|
+
return this.contextKeyService.match('suggestWidgetVisible', this.editor.getDomNode() || this.node);
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* `true` if the find (and replace) widget is visible in the editor. Otherwise, `false`.
|
|
293
|
+
*/
|
|
294
|
+
isFindWidgetVisible() {
|
|
295
|
+
return this.contextKeyService.match('findWidgetVisible', this.editor.getDomNode() || this.node);
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* `true` if the name rename refactoring input HTML element is visible. Otherwise, `false`.
|
|
299
|
+
*/
|
|
300
|
+
isRenameInputVisible() {
|
|
301
|
+
return this.contextKeyService.match('renameInputVisible', this.editor.getDomNode() || this.node);
|
|
302
|
+
}
|
|
303
|
+
dispose() {
|
|
304
|
+
this.toDispose.dispose();
|
|
305
|
+
}
|
|
306
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
307
|
+
trigger(source, handlerId, payload) {
|
|
308
|
+
this.editor.trigger(source, handlerId, payload);
|
|
309
|
+
}
|
|
310
|
+
getControl() {
|
|
311
|
+
return this.editor;
|
|
312
|
+
}
|
|
313
|
+
refresh() {
|
|
314
|
+
this.autoresize();
|
|
315
|
+
}
|
|
316
|
+
resizeToFit() {
|
|
317
|
+
this.autoresize();
|
|
318
|
+
// eslint-disable-next-line no-null/no-null
|
|
319
|
+
this.onResizeEmitter.fire(null);
|
|
320
|
+
}
|
|
321
|
+
setSize(dimension) {
|
|
322
|
+
this.resize(dimension);
|
|
323
|
+
this.onResizeEmitter.fire(dimension);
|
|
324
|
+
}
|
|
325
|
+
autoresize() {
|
|
326
|
+
if (this.autoSizing) {
|
|
327
|
+
// eslint-disable-next-line no-null/no-null
|
|
328
|
+
this.resize(null);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
resize(dimension) {
|
|
332
|
+
if (this.node) {
|
|
333
|
+
const layoutSize = this.computeLayoutSize(this.node, dimension);
|
|
334
|
+
this.editor.layout(layoutSize);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
computeLayoutSize(hostNode, dimension) {
|
|
338
|
+
if (dimension && dimension.width >= 0 && dimension.height >= 0) {
|
|
339
|
+
return dimension;
|
|
340
|
+
}
|
|
341
|
+
const boxSizing = domutils_1.ElementExt.boxSizing(hostNode);
|
|
342
|
+
const width = (!dimension || dimension.width < 0) ?
|
|
343
|
+
this.getWidth(hostNode, boxSizing) :
|
|
344
|
+
dimension.width;
|
|
345
|
+
const height = (!dimension || dimension.height < 0) ?
|
|
346
|
+
this.getHeight(hostNode, boxSizing) :
|
|
347
|
+
dimension.height;
|
|
348
|
+
return { width, height };
|
|
349
|
+
}
|
|
350
|
+
getWidth(hostNode, boxSizing) {
|
|
351
|
+
return hostNode.offsetWidth - boxSizing.horizontalSum;
|
|
352
|
+
}
|
|
353
|
+
getHeight(hostNode, boxSizing) {
|
|
354
|
+
if (!this.autoSizing) {
|
|
355
|
+
return hostNode.offsetHeight - boxSizing.verticalSum;
|
|
356
|
+
}
|
|
357
|
+
const lineHeight = this.editor.getOption(monaco.editor.EditorOption.lineHeight);
|
|
358
|
+
const lineCount = this.editor.getModel().getLineCount();
|
|
359
|
+
const contentHeight = lineHeight * lineCount;
|
|
360
|
+
const horizontalScrollbarHeight = this.editor.getLayoutInfo().horizontalScrollbarHeight;
|
|
361
|
+
const editorHeight = contentHeight + horizontalScrollbarHeight;
|
|
362
|
+
if (this.minHeight >= 0) {
|
|
363
|
+
const minHeight = lineHeight * this.minHeight + horizontalScrollbarHeight;
|
|
364
|
+
if (editorHeight < minHeight) {
|
|
365
|
+
return minHeight;
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
if (this.maxHeight >= 0) {
|
|
369
|
+
const maxHeight = lineHeight * this.maxHeight + horizontalScrollbarHeight;
|
|
370
|
+
return Math.min(maxHeight, editorHeight);
|
|
371
|
+
}
|
|
372
|
+
return editorHeight;
|
|
373
|
+
}
|
|
374
|
+
isActionSupported(id) {
|
|
375
|
+
const action = this.editor.getAction(id);
|
|
376
|
+
return !!action && action.isSupported();
|
|
377
|
+
}
|
|
378
|
+
async runAction(id) {
|
|
379
|
+
const action = this.editor.getAction(id);
|
|
380
|
+
if (action && action.isSupported()) {
|
|
381
|
+
await action.run();
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
deltaDecorations(params) {
|
|
385
|
+
const oldDecorations = params.oldDecorations;
|
|
386
|
+
const newDecorations = this.toDeltaDecorations(params);
|
|
387
|
+
return this.editor.deltaDecorations(oldDecorations, newDecorations);
|
|
388
|
+
}
|
|
389
|
+
toDeltaDecorations(params) {
|
|
390
|
+
return params.newDecorations.map(({ options: theiaOptions, range }) => {
|
|
391
|
+
const options = {
|
|
392
|
+
...theiaOptions,
|
|
393
|
+
hoverMessage: this.fromStringToMarkdownString(theiaOptions.hoverMessage),
|
|
394
|
+
glyphMarginHoverMessage: this.fromStringToMarkdownString(theiaOptions.glyphMarginHoverMessage)
|
|
395
|
+
};
|
|
396
|
+
return {
|
|
397
|
+
options,
|
|
398
|
+
range: this.p2m.asRange(range),
|
|
399
|
+
};
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
fromStringToMarkdownString(hoverMessage) {
|
|
403
|
+
if (typeof hoverMessage === 'string') {
|
|
404
|
+
return { value: hoverMessage };
|
|
405
|
+
}
|
|
406
|
+
return hoverMessage;
|
|
407
|
+
}
|
|
408
|
+
fromMarkdownToString(maybeMarkdown) {
|
|
409
|
+
if (!maybeMarkdown) {
|
|
410
|
+
return undefined;
|
|
411
|
+
}
|
|
412
|
+
if (typeof maybeMarkdown === 'string') {
|
|
413
|
+
return maybeMarkdown;
|
|
414
|
+
}
|
|
415
|
+
if (Array.isArray(maybeMarkdown)) {
|
|
416
|
+
return maybeMarkdown.map(({ value }) => value).join('\n');
|
|
417
|
+
}
|
|
418
|
+
return maybeMarkdown.value;
|
|
419
|
+
}
|
|
420
|
+
getLinesDecorations(startLineNumber, endLineNumber) {
|
|
421
|
+
const toPosition = (line) => this.p2m.asPosition({ line, character: 0 });
|
|
422
|
+
const start = toPosition(startLineNumber).lineNumber;
|
|
423
|
+
const end = toPosition(endLineNumber).lineNumber;
|
|
424
|
+
return this.editor
|
|
425
|
+
.getModel()
|
|
426
|
+
.getLinesDecorations(start, end)
|
|
427
|
+
.map(this.toEditorDecoration.bind(this));
|
|
428
|
+
}
|
|
429
|
+
toEditorDecoration(decoration) {
|
|
430
|
+
const range = this.m2p.asRange(decoration.range);
|
|
431
|
+
const { id, options: monacoOptions } = decoration;
|
|
432
|
+
const options = {
|
|
433
|
+
...monacoOptions,
|
|
434
|
+
hoverMessage: this.fromMarkdownToString(monacoOptions.hoverMessage),
|
|
435
|
+
glyphMarginHoverMessage: this.fromMarkdownToString(monacoOptions.hoverMessage),
|
|
436
|
+
};
|
|
437
|
+
return {
|
|
438
|
+
options: (0, common_1.nullToUndefined)(options),
|
|
439
|
+
range,
|
|
440
|
+
id
|
|
441
|
+
};
|
|
442
|
+
}
|
|
443
|
+
getVisibleColumn(position) {
|
|
444
|
+
return this.editor.getVisibleColumnFromPosition(this.p2m.asPosition(position));
|
|
445
|
+
}
|
|
446
|
+
async replaceText(params) {
|
|
447
|
+
const edits = params.replaceOperations.map(param => {
|
|
448
|
+
const range = monaco.Range.fromPositions(this.p2m.asPosition(param.range.start), this.p2m.asPosition(param.range.end));
|
|
449
|
+
return {
|
|
450
|
+
forceMoveMarkers: true,
|
|
451
|
+
identifier: {
|
|
452
|
+
major: range.startLineNumber,
|
|
453
|
+
minor: range.startColumn
|
|
454
|
+
},
|
|
455
|
+
range,
|
|
456
|
+
text: param.text
|
|
457
|
+
};
|
|
458
|
+
});
|
|
459
|
+
return this.editor.executeEdits(params.source, edits);
|
|
460
|
+
}
|
|
461
|
+
executeEdits(edits) {
|
|
462
|
+
return this.editor.executeEdits('MonacoEditor', this.p2m.asTextEdits(edits));
|
|
463
|
+
}
|
|
464
|
+
storeViewState() {
|
|
465
|
+
return this.editor.saveViewState();
|
|
466
|
+
}
|
|
467
|
+
restoreViewState(state) {
|
|
468
|
+
this.editor.restoreViewState(state);
|
|
469
|
+
}
|
|
470
|
+
get languageAutoDetected() {
|
|
471
|
+
return this._languageAutoDetected;
|
|
472
|
+
}
|
|
473
|
+
async detectLanguage() {
|
|
474
|
+
const languageService = standaloneServices_1.StandaloneServices.get(language_1.ILanguageService);
|
|
475
|
+
const firstLine = this.document.textEditorModel.getLineContent(1);
|
|
476
|
+
const model = this.getControl().getModel();
|
|
477
|
+
const language = languageService.createByFilepathOrFirstLine(model && model.uri, firstLine);
|
|
478
|
+
this.setLanguage(language.languageId);
|
|
479
|
+
this._languageAutoDetected = true;
|
|
480
|
+
}
|
|
481
|
+
setLanguage(languageId) {
|
|
482
|
+
for (const document of this.documents) {
|
|
483
|
+
monaco.editor.setModelLanguage(document.textEditorModel, languageId);
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
fireLanguageChanged(languageId) {
|
|
487
|
+
this._languageAutoDetected = false;
|
|
488
|
+
this.onLanguageChangedEmitter.fire(languageId);
|
|
489
|
+
}
|
|
490
|
+
getResourceUri() {
|
|
491
|
+
return this.uri;
|
|
492
|
+
}
|
|
493
|
+
createMoveToUri(resourceUri) {
|
|
494
|
+
return this.uri.withPath(resourceUri.path);
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
exports.MonacoEditor = MonacoEditor;
|
|
498
|
+
(function (MonacoEditor) {
|
|
499
|
+
function getAll(manager) {
|
|
500
|
+
return manager.all.map(e => get(e)).filter(e => !!e);
|
|
501
|
+
}
|
|
502
|
+
MonacoEditor.getAll = getAll;
|
|
503
|
+
function getCurrent(manager) {
|
|
504
|
+
return get(manager.currentEditor);
|
|
505
|
+
}
|
|
506
|
+
MonacoEditor.getCurrent = getCurrent;
|
|
507
|
+
function getActive(manager) {
|
|
508
|
+
return get(manager.activeEditor);
|
|
509
|
+
}
|
|
510
|
+
MonacoEditor.getActive = getActive;
|
|
511
|
+
function get(editorWidget) {
|
|
512
|
+
if (editorWidget && editorWidget.editor instanceof MonacoEditor) {
|
|
513
|
+
return editorWidget.editor;
|
|
514
|
+
}
|
|
515
|
+
return undefined;
|
|
516
|
+
}
|
|
517
|
+
MonacoEditor.get = get;
|
|
518
|
+
function findByDocument(manager, document) {
|
|
519
|
+
return getAll(manager).filter(candidate => candidate.documents.has(document));
|
|
520
|
+
}
|
|
521
|
+
MonacoEditor.findByDocument = findByDocument;
|
|
522
|
+
function getWidgetFor(manager, control) {
|
|
523
|
+
if (!control) {
|
|
524
|
+
return undefined;
|
|
525
|
+
}
|
|
526
|
+
return manager.all.find(widget => {
|
|
527
|
+
const candidate = get(widget);
|
|
528
|
+
return candidate && candidate.getControl() === control;
|
|
529
|
+
});
|
|
530
|
+
}
|
|
531
|
+
MonacoEditor.getWidgetFor = getWidgetFor;
|
|
532
|
+
function createReadOnlyOptions(readOnly) {
|
|
533
|
+
if (typeof readOnly === 'boolean') {
|
|
534
|
+
return { readOnly };
|
|
535
|
+
}
|
|
536
|
+
if (readOnly) {
|
|
537
|
+
return { readOnly: true, readOnlyMessage: readOnly };
|
|
538
|
+
}
|
|
539
|
+
return {};
|
|
540
|
+
}
|
|
541
|
+
MonacoEditor.createReadOnlyOptions = createReadOnlyOptions;
|
|
542
|
+
})(MonacoEditor = exports.MonacoEditor || (exports.MonacoEditor = {}));
|
|
525
543
|
//# sourceMappingURL=monaco-editor.js.map
|