@ng-util/monaco-editor 11.2.0 → 12.1.2
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/bundles/ng-util-monaco-editor.umd.js +104 -338
- package/bundles/ng-util-monaco-editor.umd.js.map +1 -1
- package/esm2015/monaco-editor-base.component.js +46 -199
- package/esm2015/monaco-editor-diff.component.js +8 -28
- package/esm2015/monaco-editor.component.js +19 -89
- package/esm2015/monaco-editor.config.js +1 -30
- package/esm2015/monaco-editor.module.js +2 -11
- package/esm2015/monaco-editor.types.js +2 -46
- package/esm2015/ng-util-monaco-editor.js +2 -7
- package/esm2015/public-api.js +6 -11
- package/fesm2015/ng-util-monaco-editor.js +72 -407
- package/fesm2015/ng-util-monaco-editor.js.map +1 -1
- package/monaco-editor-base.component.d.ts +2 -2
- package/monaco-editor.component.d.ts +1 -1
- package/monaco-editor.config.d.ts +5 -1
- package/monaco.d.ts +868 -333
- package/package.json +3 -3
- package/bundles/ng-util-monaco-editor.umd.min.js +0 -21
- package/bundles/ng-util-monaco-editor.umd.min.js.map +0 -1
|
@@ -4,185 +4,52 @@ import { DOCUMENT, CommonModule } from '@angular/common';
|
|
|
4
4
|
import { fromEvent } from 'rxjs';
|
|
5
5
|
import { debounceTime } from 'rxjs/operators';
|
|
6
6
|
|
|
7
|
-
/**
|
|
8
|
-
* @fileoverview added by tsickle
|
|
9
|
-
* Generated from: monaco-editor.types.ts
|
|
10
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
11
|
-
*/
|
|
12
|
-
/// <reference path="./monaco.d.ts" />
|
|
13
7
|
// tslint:disable-next-line: no-reference
|
|
14
|
-
/// <reference path="./monaco.d.ts" />
|
|
15
|
-
/**
|
|
16
|
-
* @record
|
|
17
|
-
*/
|
|
18
|
-
function NuMonacoEditorModel() { }
|
|
19
|
-
if (false) {
|
|
20
|
-
/** @type {?|undefined} */
|
|
21
|
-
NuMonacoEditorModel.prototype.value;
|
|
22
|
-
/** @type {?|undefined} */
|
|
23
|
-
NuMonacoEditorModel.prototype.language;
|
|
24
|
-
/** @type {?|undefined} */
|
|
25
|
-
NuMonacoEditorModel.prototype.uri;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* @record
|
|
29
|
-
*/
|
|
30
|
-
function NuMonacoEditorDiffModel() { }
|
|
31
|
-
if (false) {
|
|
32
|
-
/** @type {?} */
|
|
33
|
-
NuMonacoEditorDiffModel.prototype.code;
|
|
34
|
-
/** @type {?|undefined} */
|
|
35
|
-
NuMonacoEditorDiffModel.prototype.language;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* @record
|
|
39
|
-
*/
|
|
40
|
-
function NuMonacoEditorEvent() { }
|
|
41
|
-
if (false) {
|
|
42
|
-
/** @type {?|undefined} */
|
|
43
|
-
NuMonacoEditorEvent.prototype.type;
|
|
44
|
-
/** @type {?|undefined} */
|
|
45
|
-
NuMonacoEditorEvent.prototype.editor;
|
|
46
|
-
/** @type {?|undefined} */
|
|
47
|
-
NuMonacoEditorEvent.prototype.error;
|
|
48
|
-
/**
|
|
49
|
-
* Just only `nu-monaco-editor-diff` component
|
|
50
|
-
* @type {?|undefined}
|
|
51
|
-
*/
|
|
52
|
-
NuMonacoEditorEvent.prototype.diffValue;
|
|
53
|
-
}
|
|
54
8
|
|
|
55
|
-
/**
|
|
56
|
-
* @fileoverview added by tsickle
|
|
57
|
-
* Generated from: monaco-editor.config.ts
|
|
58
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
59
|
-
*/
|
|
60
|
-
/** @type {?} */
|
|
61
9
|
const NU_MONACO_EDITOR_CONFIG = new InjectionToken('NU_MONACO_EDITOR_CONFIG');
|
|
62
|
-
/**
|
|
63
|
-
* @record
|
|
64
|
-
*/
|
|
65
|
-
function NuMonacoEditorConfig() { }
|
|
66
|
-
if (false) {
|
|
67
|
-
/**
|
|
68
|
-
* The base URL to monaco editor library assets via AMD (RequireJS), Default: `https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.20.0/min`
|
|
69
|
-
* You can using local path, e.g.: `assets/monaco-editor/min`.
|
|
70
|
-
* @type {?|undefined}
|
|
71
|
-
*/
|
|
72
|
-
NuMonacoEditorConfig.prototype.baseUrl;
|
|
73
|
-
/**
|
|
74
|
-
* Default options when creating editors
|
|
75
|
-
* @type {?|undefined}
|
|
76
|
-
*/
|
|
77
|
-
NuMonacoEditorConfig.prototype.defaultOptions;
|
|
78
|
-
/**
|
|
79
|
-
* The event after the first loading of the monaco editor library is completed, use this function to extend monaco editor functionalities.
|
|
80
|
-
* - \@param `_monaco` equar to `window.monaco`
|
|
81
|
-
* @type {?|undefined}
|
|
82
|
-
*/
|
|
83
|
-
NuMonacoEditorConfig.prototype.monacoLoad;
|
|
84
|
-
}
|
|
85
10
|
|
|
86
|
-
/**
|
|
87
|
-
* @fileoverview added by tsickle
|
|
88
|
-
* Generated from: monaco-editor-base.component.ts
|
|
89
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
90
|
-
*/
|
|
91
|
-
/** @type {?} */
|
|
92
11
|
let loadedMonaco = false;
|
|
93
|
-
/** @type {?} */
|
|
94
12
|
let loadPromise;
|
|
95
|
-
//
|
|
13
|
+
// eslint-disable-next-line @angular-eslint/component-class-suffix
|
|
96
14
|
class NuMonacoEditorBase {
|
|
97
|
-
/**
|
|
98
|
-
* @param {?} el
|
|
99
|
-
* @param {?} config
|
|
100
|
-
* @param {?} doc
|
|
101
|
-
* @param {?} ngZone
|
|
102
|
-
*/
|
|
103
15
|
constructor(el, config, doc, ngZone) {
|
|
104
16
|
this.el = el;
|
|
105
17
|
this.doc = doc;
|
|
106
18
|
this.ngZone = ngZone;
|
|
107
|
-
this.
|
|
19
|
+
this._resize$ = null;
|
|
108
20
|
this.height = `200px`;
|
|
109
21
|
this.delay = 0;
|
|
110
22
|
this.event = new EventEmitter();
|
|
111
|
-
this._config = Object.assign({ baseUrl: 'https://
|
|
112
|
-
this.options =
|
|
23
|
+
this._config = Object.assign({ baseUrl: 'https://cdn.jsdelivr.net/npm/monaco-editor/min' }, config);
|
|
24
|
+
this.options = this._config.defaultOptions;
|
|
113
25
|
}
|
|
114
|
-
/**
|
|
115
|
-
* @param {?} val
|
|
116
|
-
* @return {?}
|
|
117
|
-
*/
|
|
118
26
|
set disabled(val) {
|
|
119
27
|
this._disabled = typeof val === 'string' ? true : val;
|
|
120
28
|
this.setDisabled();
|
|
121
29
|
}
|
|
122
|
-
/**
|
|
123
|
-
* @param {?} val
|
|
124
|
-
* @return {?}
|
|
125
|
-
*/
|
|
126
30
|
set options(val) {
|
|
127
31
|
this._options = Object.assign(Object.assign({}, this._config.defaultOptions), val);
|
|
128
32
|
}
|
|
129
|
-
/**
|
|
130
|
-
* @return {?}
|
|
131
|
-
*/
|
|
132
33
|
get options() {
|
|
133
34
|
return this._options;
|
|
134
35
|
}
|
|
135
|
-
/**
|
|
136
|
-
* @protected
|
|
137
|
-
* @param {?} _options
|
|
138
|
-
* @param {?} _initEvent
|
|
139
|
-
* @return {?}
|
|
140
|
-
*/
|
|
141
36
|
initMonaco(_options, _initEvent) { }
|
|
142
|
-
/**
|
|
143
|
-
* @protected
|
|
144
|
-
* @param {?} type
|
|
145
|
-
* @param {?=} other
|
|
146
|
-
* @return {?}
|
|
147
|
-
*/
|
|
148
37
|
notifyEvent(type, other) {
|
|
149
|
-
this.ngZone.run((
|
|
150
|
-
* @return {?}
|
|
151
|
-
*/
|
|
152
|
-
() => this.event.emit(Object.assign({ type, editor: (/** @type {?} */ (this._editor)) }, other))));
|
|
38
|
+
this.ngZone.run(() => this.event.emit(Object.assign({ type, editor: this._editor }, other)));
|
|
153
39
|
}
|
|
154
|
-
/**
|
|
155
|
-
* @protected
|
|
156
|
-
* @template THIS
|
|
157
|
-
* @this {THIS}
|
|
158
|
-
* @return {THIS}
|
|
159
|
-
*/
|
|
160
40
|
setDisabled() {
|
|
161
|
-
if (
|
|
162
|
-
|
|
41
|
+
if (this._editor) {
|
|
42
|
+
this._editor.updateOptions({ readOnly: this._disabled });
|
|
163
43
|
}
|
|
164
|
-
return
|
|
44
|
+
return this;
|
|
165
45
|
}
|
|
166
|
-
/**
|
|
167
|
-
* @private
|
|
168
|
-
* @return {?}
|
|
169
|
-
*/
|
|
170
46
|
init() {
|
|
171
47
|
if (loadedMonaco) {
|
|
172
|
-
loadPromise.then((
|
|
173
|
-
* @return {?}
|
|
174
|
-
*/
|
|
175
|
-
() => this.initMonaco(this.options, true)));
|
|
48
|
+
loadPromise.then(() => this.initMonaco(this.options, true));
|
|
176
49
|
return;
|
|
177
50
|
}
|
|
178
51
|
loadedMonaco = true;
|
|
179
|
-
loadPromise = new Promise((
|
|
180
|
-
* @param {?} resolve
|
|
181
|
-
* @param {?} reject
|
|
182
|
-
* @return {?}
|
|
183
|
-
*/
|
|
184
|
-
(resolve, reject) => {
|
|
185
|
-
/** @type {?} */
|
|
52
|
+
loadPromise = new Promise((resolve, reject) => {
|
|
186
53
|
const win = window;
|
|
187
54
|
if (win == null) {
|
|
188
55
|
resolve();
|
|
@@ -192,123 +59,68 @@ class NuMonacoEditorBase {
|
|
|
192
59
|
resolve();
|
|
193
60
|
return;
|
|
194
61
|
}
|
|
195
|
-
/** @type {?} */
|
|
196
62
|
const baseUrl = this._config.baseUrl;
|
|
197
|
-
|
|
198
|
-
const amdLoader = (/**
|
|
199
|
-
* @return {?}
|
|
200
|
-
*/
|
|
201
|
-
() => {
|
|
63
|
+
const amdLoader = () => {
|
|
202
64
|
win.require.config({ paths: { vs: `${baseUrl}/vs` } });
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
() => {
|
|
65
|
+
if (typeof this._config.monacoPreLoad === 'function') {
|
|
66
|
+
this._config.monacoPreLoad();
|
|
67
|
+
}
|
|
68
|
+
win.require(['vs/editor/editor.main'], () => {
|
|
207
69
|
if (typeof this._config.monacoLoad === 'function') {
|
|
208
70
|
this._config.monacoLoad(win.monaco);
|
|
209
71
|
}
|
|
210
72
|
this.initMonaco(this.options, true);
|
|
211
73
|
resolve();
|
|
212
|
-
}
|
|
213
|
-
* @return {?}
|
|
214
|
-
*/
|
|
215
|
-
() => {
|
|
74
|
+
}, () => {
|
|
216
75
|
reject(`Unable to load editor/editor.main module, please check your network environment.`);
|
|
217
|
-
})
|
|
218
|
-
}
|
|
76
|
+
});
|
|
77
|
+
};
|
|
219
78
|
if (!win.require) {
|
|
220
|
-
|
|
221
|
-
const loaderScript = (/** @type {?} */ (this.doc.createElement('script')));
|
|
79
|
+
const loaderScript = this.doc.createElement('script');
|
|
222
80
|
loaderScript.type = 'text/javascript';
|
|
223
81
|
loaderScript.src = `${baseUrl}/vs/loader.js`;
|
|
224
82
|
loaderScript.onload = amdLoader;
|
|
225
|
-
loaderScript.onerror = (
|
|
226
|
-
* @return {?}
|
|
227
|
-
*/
|
|
228
|
-
() => reject(`Unable to load ${loaderScript.src}, please check your network environment.`));
|
|
83
|
+
loaderScript.onerror = () => reject(`Unable to load ${loaderScript.src}, please check your network environment.`);
|
|
229
84
|
this.doc.getElementsByTagName('head')[0].appendChild(loaderScript);
|
|
230
85
|
}
|
|
231
86
|
else {
|
|
232
87
|
amdLoader();
|
|
233
88
|
}
|
|
234
|
-
})
|
|
235
|
-
* @param {?} error
|
|
236
|
-
* @return {?}
|
|
237
|
-
*/
|
|
238
|
-
error => this.notifyEvent('load-error', { error })));
|
|
89
|
+
}).catch(error => this.notifyEvent('load-error', { error }));
|
|
239
90
|
}
|
|
240
|
-
/**
|
|
241
|
-
* @protected
|
|
242
|
-
* @template THIS
|
|
243
|
-
* @this {THIS}
|
|
244
|
-
* @return {THIS}
|
|
245
|
-
*/
|
|
246
91
|
cleanResize() {
|
|
247
|
-
if (
|
|
248
|
-
|
|
92
|
+
if (this._resize$) {
|
|
93
|
+
this._resize$.unsubscribe();
|
|
249
94
|
}
|
|
250
|
-
return
|
|
95
|
+
return this;
|
|
251
96
|
}
|
|
252
|
-
/**
|
|
253
|
-
* @protected
|
|
254
|
-
* @template THIS
|
|
255
|
-
* @this {THIS}
|
|
256
|
-
* @return {THIS}
|
|
257
|
-
*/
|
|
258
97
|
registerResize() {
|
|
259
|
-
|
|
260
|
-
|
|
98
|
+
this.cleanResize();
|
|
99
|
+
this._resize$ = fromEvent(window, 'resize')
|
|
261
100
|
.pipe(debounceTime(100))
|
|
262
|
-
.subscribe((
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
(/** @type {?} */ (this)).notifyEvent('resize');
|
|
268
|
-
}));
|
|
269
|
-
return (/** @type {?} */ (this));
|
|
101
|
+
.subscribe(() => {
|
|
102
|
+
this._editor.layout();
|
|
103
|
+
this.notifyEvent('resize');
|
|
104
|
+
});
|
|
105
|
+
return this;
|
|
270
106
|
}
|
|
271
|
-
/**
|
|
272
|
-
* @protected
|
|
273
|
-
* @return {?}
|
|
274
|
-
*/
|
|
275
107
|
updateOptions() {
|
|
276
108
|
if (!this._editor)
|
|
277
109
|
return;
|
|
278
|
-
this.ngZone.runOutsideAngular((
|
|
279
|
-
|
|
280
|
-
*/
|
|
281
|
-
() => {
|
|
282
|
-
(/** @type {?} */ (this._editor)).dispose();
|
|
110
|
+
this.ngZone.runOutsideAngular(() => {
|
|
111
|
+
this._editor.dispose();
|
|
283
112
|
this.initMonaco(this._options, false);
|
|
284
|
-
})
|
|
113
|
+
});
|
|
285
114
|
}
|
|
286
|
-
/**
|
|
287
|
-
* @return {?}
|
|
288
|
-
*/
|
|
289
115
|
ngAfterViewInit() {
|
|
290
|
-
this.ngZone.runOutsideAngular((
|
|
291
|
-
* @return {?}
|
|
292
|
-
*/
|
|
293
|
-
() => setTimeout((/**
|
|
294
|
-
* @return {?}
|
|
295
|
-
*/
|
|
296
|
-
() => this.init()), +this.delay)));
|
|
116
|
+
this.ngZone.runOutsideAngular(() => setTimeout(() => this.init(), +this.delay));
|
|
297
117
|
}
|
|
298
|
-
/**
|
|
299
|
-
* @param {?} changes
|
|
300
|
-
* @return {?}
|
|
301
|
-
*/
|
|
302
118
|
ngOnChanges(changes) {
|
|
303
|
-
/** @type {?} */
|
|
304
119
|
const allKeys = Object.keys(changes);
|
|
305
120
|
if (allKeys.length === 1 && allKeys[0] === 'disabled')
|
|
306
121
|
return;
|
|
307
122
|
this.updateOptions();
|
|
308
123
|
}
|
|
309
|
-
/**
|
|
310
|
-
* @return {?}
|
|
311
|
-
*/
|
|
312
124
|
ngOnDestroy() {
|
|
313
125
|
this.cleanResize();
|
|
314
126
|
if (this._editor) {
|
|
@@ -317,19 +129,27 @@ class NuMonacoEditorBase {
|
|
|
317
129
|
}
|
|
318
130
|
}
|
|
319
131
|
}
|
|
132
|
+
/** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */
|
|
320
133
|
NuMonacoEditorBase.decorators = [
|
|
321
134
|
{ type: Component, args: [{
|
|
322
135
|
selector: 'nu-monaco-base',
|
|
323
136
|
template: ``
|
|
324
|
-
}] }
|
|
137
|
+
},] }
|
|
325
138
|
];
|
|
326
|
-
/**
|
|
139
|
+
/**
|
|
140
|
+
* @type {function(): !Array<(null|{
|
|
141
|
+
* type: ?,
|
|
142
|
+
* decorators: (undefined|!Array<{type: !Function, args: (undefined|!Array<?>)}>),
|
|
143
|
+
* })>}
|
|
144
|
+
* @nocollapse
|
|
145
|
+
*/
|
|
327
146
|
NuMonacoEditorBase.ctorParameters = () => [
|
|
328
147
|
{ type: ElementRef },
|
|
329
148
|
{ type: undefined, decorators: [{ type: Inject, args: [NU_MONACO_EDITOR_CONFIG,] }] },
|
|
330
149
|
{ type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] },
|
|
331
150
|
{ type: NgZone }
|
|
332
151
|
];
|
|
152
|
+
/** @type {!Object<string, !Array<{type: !Function, args: (undefined|!Array<?>)}>>} */
|
|
333
153
|
NuMonacoEditorBase.propDecorators = {
|
|
334
154
|
height: [{ type: Input }],
|
|
335
155
|
delay: [{ type: Input }],
|
|
@@ -337,165 +157,68 @@ NuMonacoEditorBase.propDecorators = {
|
|
|
337
157
|
options: [{ type: Input }],
|
|
338
158
|
event: [{ type: Output }]
|
|
339
159
|
};
|
|
340
|
-
if (false) {
|
|
341
|
-
/**
|
|
342
|
-
* @type {?}
|
|
343
|
-
* @protected
|
|
344
|
-
*/
|
|
345
|
-
NuMonacoEditorBase.prototype._editor;
|
|
346
|
-
/**
|
|
347
|
-
* @type {?}
|
|
348
|
-
* @protected
|
|
349
|
-
*/
|
|
350
|
-
NuMonacoEditorBase.prototype._options;
|
|
351
|
-
/**
|
|
352
|
-
* @type {?}
|
|
353
|
-
* @protected
|
|
354
|
-
*/
|
|
355
|
-
NuMonacoEditorBase.prototype._resize$;
|
|
356
|
-
/**
|
|
357
|
-
* @type {?}
|
|
358
|
-
* @protected
|
|
359
|
-
*/
|
|
360
|
-
NuMonacoEditorBase.prototype._config;
|
|
361
|
-
/**
|
|
362
|
-
* @type {?}
|
|
363
|
-
* @protected
|
|
364
|
-
*/
|
|
365
|
-
NuMonacoEditorBase.prototype._disabled;
|
|
366
|
-
/** @type {?} */
|
|
367
|
-
NuMonacoEditorBase.prototype.height;
|
|
368
|
-
/** @type {?} */
|
|
369
|
-
NuMonacoEditorBase.prototype.delay;
|
|
370
|
-
/** @type {?} */
|
|
371
|
-
NuMonacoEditorBase.prototype.event;
|
|
372
|
-
/**
|
|
373
|
-
* @type {?}
|
|
374
|
-
* @protected
|
|
375
|
-
*/
|
|
376
|
-
NuMonacoEditorBase.prototype.el;
|
|
377
|
-
/**
|
|
378
|
-
* @type {?}
|
|
379
|
-
* @protected
|
|
380
|
-
*/
|
|
381
|
-
NuMonacoEditorBase.prototype.doc;
|
|
382
|
-
/**
|
|
383
|
-
* @type {?}
|
|
384
|
-
* @protected
|
|
385
|
-
*/
|
|
386
|
-
NuMonacoEditorBase.prototype.ngZone;
|
|
387
|
-
}
|
|
388
160
|
|
|
389
|
-
/**
|
|
390
|
-
* @fileoverview added by tsickle
|
|
391
|
-
* Generated from: monaco-editor.component.ts
|
|
392
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
393
|
-
*/
|
|
394
161
|
class NuMonacoEditorComponent extends NuMonacoEditorBase {
|
|
395
162
|
constructor() {
|
|
396
163
|
super(...arguments);
|
|
397
164
|
this._value = '';
|
|
398
|
-
this.onChange = (
|
|
399
|
-
|
|
400
|
-
* @return {?}
|
|
401
|
-
*/
|
|
402
|
-
(_) => { });
|
|
403
|
-
this.onTouched = (/**
|
|
404
|
-
* @return {?}
|
|
405
|
-
*/
|
|
406
|
-
() => { });
|
|
165
|
+
this.onChange = (_) => { };
|
|
166
|
+
this.onTouched = () => { };
|
|
407
167
|
}
|
|
408
|
-
/**
|
|
409
|
-
* @return {?}
|
|
410
|
-
*/
|
|
411
168
|
get editor() {
|
|
412
|
-
return
|
|
169
|
+
return this._editor;
|
|
413
170
|
}
|
|
414
|
-
/**
|
|
415
|
-
* @param {?} options
|
|
416
|
-
* @param {?} initEvent
|
|
417
|
-
* @return {?}
|
|
418
|
-
*/
|
|
419
171
|
initMonaco(options, initEvent) {
|
|
420
|
-
/** @type {?} */
|
|
421
172
|
const hasModel = !!this.model;
|
|
422
173
|
if (hasModel) {
|
|
423
|
-
|
|
424
|
-
const model = monaco.editor.getModel((/** @type {?} */ (this.model.uri)) || '');
|
|
174
|
+
const model = monaco.editor.getModel(this.model.uri || '');
|
|
425
175
|
if (model) {
|
|
426
176
|
options.model = model;
|
|
427
177
|
options.model.setValue(this._value);
|
|
428
178
|
}
|
|
429
179
|
else {
|
|
430
|
-
const { value, language, uri } =
|
|
180
|
+
const { value, language, uri } = this.model;
|
|
431
181
|
options.model = monaco.editor.createModel(value || this._value, language, uri);
|
|
432
182
|
}
|
|
433
183
|
}
|
|
434
|
-
|
|
184
|
+
if (this._disabled != null)
|
|
185
|
+
options.readOnly = this._disabled;
|
|
435
186
|
const editor = (this._editor = monaco.editor.create(this.el.nativeElement, options));
|
|
436
187
|
if (!hasModel) {
|
|
437
188
|
editor.setValue(this._value);
|
|
438
189
|
}
|
|
439
|
-
editor.onDidChangeModelContent((
|
|
440
|
-
* @return {?}
|
|
441
|
-
*/
|
|
442
|
-
() => {
|
|
443
|
-
/** @type {?} */
|
|
190
|
+
editor.onDidChangeModelContent(() => {
|
|
444
191
|
const value = editor.getValue();
|
|
445
|
-
this.ngZone.run((
|
|
446
|
-
* @return {?}
|
|
447
|
-
*/
|
|
448
|
-
() => {
|
|
192
|
+
this.ngZone.run(() => {
|
|
449
193
|
this._value = value;
|
|
450
194
|
this.onChange(value);
|
|
451
|
-
})
|
|
452
|
-
})
|
|
453
|
-
editor.onDidBlurEditorWidget((
|
|
454
|
-
* @return {?}
|
|
455
|
-
*/
|
|
456
|
-
() => this.onTouched()));
|
|
195
|
+
});
|
|
196
|
+
});
|
|
197
|
+
editor.onDidBlurEditorWidget(() => this.onTouched());
|
|
457
198
|
this.registerResize();
|
|
458
199
|
editor
|
|
459
200
|
.getAction('editor.action.formatDocument')
|
|
460
201
|
.run()
|
|
461
|
-
.then((
|
|
462
|
-
* @return {?}
|
|
463
|
-
*/
|
|
464
|
-
() => this.notifyEvent(initEvent ? 'init' : 're-init')));
|
|
202
|
+
.then(() => this.notifyEvent(initEvent ? 'init' : 're-init'));
|
|
465
203
|
}
|
|
466
|
-
/**
|
|
467
|
-
* @param {?} value
|
|
468
|
-
* @return {?}
|
|
469
|
-
*/
|
|
470
204
|
writeValue(value) {
|
|
471
205
|
this._value = value || '';
|
|
472
206
|
if (this._editor) {
|
|
473
|
-
|
|
207
|
+
this._editor.setValue(this._value);
|
|
474
208
|
}
|
|
475
209
|
}
|
|
476
|
-
/**
|
|
477
|
-
* @param {?} fn
|
|
478
|
-
* @return {?}
|
|
479
|
-
*/
|
|
480
210
|
registerOnChange(fn) {
|
|
481
211
|
this.onChange = fn;
|
|
482
212
|
}
|
|
483
|
-
/**
|
|
484
|
-
* @param {?} fn
|
|
485
|
-
* @return {?}
|
|
486
|
-
*/
|
|
487
213
|
registerOnTouched(fn) {
|
|
488
214
|
this.onTouched = fn;
|
|
489
215
|
}
|
|
490
|
-
/**
|
|
491
|
-
* @param {?} _isDisabled
|
|
492
|
-
* @return {?}
|
|
493
|
-
*/
|
|
494
216
|
setDisabledState(_isDisabled) {
|
|
495
217
|
this.disabled = _isDisabled;
|
|
496
218
|
this.setDisabled();
|
|
497
219
|
}
|
|
498
220
|
}
|
|
221
|
+
/** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */
|
|
499
222
|
NuMonacoEditorComponent.decorators = [
|
|
500
223
|
{ type: Component, args: [{
|
|
501
224
|
selector: 'nu-monaco-editor',
|
|
@@ -508,63 +231,29 @@ NuMonacoEditorComponent.decorators = [
|
|
|
508
231
|
providers: [
|
|
509
232
|
{
|
|
510
233
|
provide: NG_VALUE_ACCESSOR,
|
|
511
|
-
useExisting: forwardRef((
|
|
512
|
-
* @return {?}
|
|
513
|
-
*/
|
|
514
|
-
() => NuMonacoEditorComponent)),
|
|
234
|
+
useExisting: forwardRef(() => NuMonacoEditorComponent),
|
|
515
235
|
multi: true,
|
|
516
236
|
},
|
|
517
237
|
],
|
|
518
238
|
changeDetection: ChangeDetectionStrategy.OnPush
|
|
519
|
-
}] }
|
|
239
|
+
},] }
|
|
520
240
|
];
|
|
241
|
+
/** @type {!Object<string, !Array<{type: !Function, args: (undefined|!Array<?>)}>>} */
|
|
521
242
|
NuMonacoEditorComponent.propDecorators = {
|
|
522
243
|
model: [{ type: Input }]
|
|
523
244
|
};
|
|
524
|
-
if (false) {
|
|
525
|
-
/**
|
|
526
|
-
* @type {?}
|
|
527
|
-
* @private
|
|
528
|
-
*/
|
|
529
|
-
NuMonacoEditorComponent.prototype._value;
|
|
530
|
-
/** @type {?} */
|
|
531
|
-
NuMonacoEditorComponent.prototype.model;
|
|
532
|
-
/**
|
|
533
|
-
* @type {?}
|
|
534
|
-
* @private
|
|
535
|
-
*/
|
|
536
|
-
NuMonacoEditorComponent.prototype.onChange;
|
|
537
|
-
/**
|
|
538
|
-
* @type {?}
|
|
539
|
-
* @private
|
|
540
|
-
*/
|
|
541
|
-
NuMonacoEditorComponent.prototype.onTouched;
|
|
542
|
-
}
|
|
543
245
|
|
|
544
|
-
/**
|
|
545
|
-
* @fileoverview added by tsickle
|
|
546
|
-
* Generated from: monaco-editor-diff.component.ts
|
|
547
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
548
|
-
*/
|
|
549
246
|
class NuMonacoEditorDiffComponent extends NuMonacoEditorBase {
|
|
550
|
-
/**
|
|
551
|
-
* @return {?}
|
|
552
|
-
*/
|
|
553
247
|
get editor() {
|
|
554
|
-
return
|
|
248
|
+
return this._editor;
|
|
555
249
|
}
|
|
556
|
-
/**
|
|
557
|
-
* @param {?} options
|
|
558
|
-
* @param {?} initEvent
|
|
559
|
-
* @return {?}
|
|
560
|
-
*/
|
|
561
250
|
initMonaco(options, initEvent) {
|
|
562
251
|
if (!this.old || !this.new) {
|
|
563
252
|
throw new Error('old or new not found for nu-monaco-diff-editor');
|
|
564
253
|
}
|
|
565
|
-
/** @type {?} */
|
|
566
254
|
const theme = options.theme;
|
|
567
|
-
|
|
255
|
+
if (this._disabled != null)
|
|
256
|
+
options.readOnly = this._disabled;
|
|
568
257
|
const editor = (this._editor = monaco.editor.createDiffEditor(this.el.nativeElement, options));
|
|
569
258
|
options.theme = theme;
|
|
570
259
|
editor.setModel({
|
|
@@ -572,15 +261,13 @@ class NuMonacoEditorDiffComponent extends NuMonacoEditorBase {
|
|
|
572
261
|
modified: monaco.editor.createModel(this.new.code, this.new.language || options.language),
|
|
573
262
|
});
|
|
574
263
|
// this.setDisabled();
|
|
575
|
-
editor.onDidUpdateDiff((
|
|
576
|
-
* @return {?}
|
|
577
|
-
*/
|
|
578
|
-
() => this.notifyEvent('update-diff', { diffValue: editor.getModifiedEditor().getValue() })));
|
|
264
|
+
editor.onDidUpdateDiff(() => this.notifyEvent('update-diff', { diffValue: editor.getModifiedEditor().getValue() }));
|
|
579
265
|
this.registerResize();
|
|
580
266
|
if (initEvent)
|
|
581
267
|
this.notifyEvent('init');
|
|
582
268
|
}
|
|
583
269
|
}
|
|
270
|
+
/** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */
|
|
584
271
|
NuMonacoEditorDiffComponent.decorators = [
|
|
585
272
|
{ type: Component, args: [{
|
|
586
273
|
selector: 'nu-monaco-diff-editor',
|
|
@@ -591,31 +278,16 @@ NuMonacoEditorDiffComponent.decorators = [
|
|
|
591
278
|
'[style.height]': 'height',
|
|
592
279
|
},
|
|
593
280
|
changeDetection: ChangeDetectionStrategy.OnPush
|
|
594
|
-
}] }
|
|
281
|
+
},] }
|
|
595
282
|
];
|
|
283
|
+
/** @type {!Object<string, !Array<{type: !Function, args: (undefined|!Array<?>)}>>} */
|
|
596
284
|
NuMonacoEditorDiffComponent.propDecorators = {
|
|
597
285
|
old: [{ type: Input }],
|
|
598
286
|
new: [{ type: Input }]
|
|
599
287
|
};
|
|
600
|
-
if (false) {
|
|
601
|
-
/** @type {?} */
|
|
602
|
-
NuMonacoEditorDiffComponent.prototype.old;
|
|
603
|
-
/** @type {?} */
|
|
604
|
-
NuMonacoEditorDiffComponent.prototype.new;
|
|
605
|
-
}
|
|
606
288
|
|
|
607
|
-
/**
|
|
608
|
-
* @fileoverview added by tsickle
|
|
609
|
-
* Generated from: monaco-editor.module.ts
|
|
610
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
611
|
-
*/
|
|
612
|
-
/** @type {?} */
|
|
613
289
|
const COMPONENTS = [NuMonacoEditorComponent, NuMonacoEditorDiffComponent];
|
|
614
290
|
class NuMonacoEditorModule {
|
|
615
|
-
/**
|
|
616
|
-
* @param {?=} config
|
|
617
|
-
* @return {?}
|
|
618
|
-
*/
|
|
619
291
|
static forRoot(config) {
|
|
620
292
|
return {
|
|
621
293
|
ngModule: NuMonacoEditorModule,
|
|
@@ -623,6 +295,7 @@ class NuMonacoEditorModule {
|
|
|
623
295
|
};
|
|
624
296
|
}
|
|
625
297
|
}
|
|
298
|
+
/** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */
|
|
626
299
|
NuMonacoEditorModule.decorators = [
|
|
627
300
|
{ type: NgModule, args: [{
|
|
628
301
|
imports: [CommonModule],
|
|
@@ -632,15 +305,7 @@ NuMonacoEditorModule.decorators = [
|
|
|
632
305
|
];
|
|
633
306
|
|
|
634
307
|
/**
|
|
635
|
-
*
|
|
636
|
-
* Generated from: public-api.ts
|
|
637
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
638
|
-
*/
|
|
639
|
-
|
|
640
|
-
/**
|
|
641
|
-
* @fileoverview added by tsickle
|
|
642
|
-
* Generated from: ng-util-monaco-editor.ts
|
|
643
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
308
|
+
* Generated bundle index. Do not edit.
|
|
644
309
|
*/
|
|
645
310
|
|
|
646
311
|
export { NU_MONACO_EDITOR_CONFIG, NuMonacoEditorComponent, NuMonacoEditorDiffComponent, NuMonacoEditorModule, NuMonacoEditorBase as ɵa };
|