@covalent/code-editor 4.0.0 → 4.1.1-beta.3

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.
@@ -1,1067 +0,0 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/forms'), require('rxjs'), require('rxjs/operators'), require('monaco-editor/esm/vs/editor/editor.api'), require('@angular/common')) :
3
- typeof define === 'function' && define.amd ? define('@covalent/code-editor', ['exports', '@angular/core', '@angular/forms', 'rxjs', 'rxjs/operators', 'monaco-editor/esm/vs/editor/editor.api', '@angular/common'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.covalent = global.covalent || {}, global.covalent['code-editor'] = {}), global.ng.core, global.ng.forms, global.rxjs, global.rxjs.operators, global.monaco, global.ng.common));
5
- }(this, (function (exports, core, forms, rxjs, operators, monaco, common) { 'use strict';
6
-
7
- /*! *****************************************************************************
8
- Copyright (c) Microsoft Corporation.
9
-
10
- Permission to use, copy, modify, and/or distribute this software for any
11
- purpose with or without fee is hereby granted.
12
-
13
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
14
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
15
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
16
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
17
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
18
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19
- PERFORMANCE OF THIS SOFTWARE.
20
- ***************************************************************************** */
21
- /* global Reflect, Promise */
22
- var extendStatics = function (d, b) {
23
- extendStatics = Object.setPrototypeOf ||
24
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
25
- function (d, b) { for (var p in b)
26
- if (Object.prototype.hasOwnProperty.call(b, p))
27
- d[p] = b[p]; };
28
- return extendStatics(d, b);
29
- };
30
- function __extends(d, b) {
31
- extendStatics(d, b);
32
- function __() { this.constructor = d; }
33
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
34
- }
35
- var __assign = function () {
36
- __assign = Object.assign || function __assign(t) {
37
- for (var s, i = 1, n = arguments.length; i < n; i++) {
38
- s = arguments[i];
39
- for (var p in s)
40
- if (Object.prototype.hasOwnProperty.call(s, p))
41
- t[p] = s[p];
42
- }
43
- return t;
44
- };
45
- return __assign.apply(this, arguments);
46
- };
47
- function __rest(s, e) {
48
- var t = {};
49
- for (var p in s)
50
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
51
- t[p] = s[p];
52
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
53
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
54
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
55
- t[p[i]] = s[p[i]];
56
- }
57
- return t;
58
- }
59
- function __decorate(decorators, target, key, desc) {
60
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
61
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
62
- r = Reflect.decorate(decorators, target, key, desc);
63
- else
64
- for (var i = decorators.length - 1; i >= 0; i--)
65
- if (d = decorators[i])
66
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
67
- return c > 3 && r && Object.defineProperty(target, key, r), r;
68
- }
69
- function __param(paramIndex, decorator) {
70
- return function (target, key) { decorator(target, key, paramIndex); };
71
- }
72
- function __metadata(metadataKey, metadataValue) {
73
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
74
- return Reflect.metadata(metadataKey, metadataValue);
75
- }
76
- function __awaiter(thisArg, _arguments, P, generator) {
77
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
78
- return new (P || (P = Promise))(function (resolve, reject) {
79
- function fulfilled(value) { try {
80
- step(generator.next(value));
81
- }
82
- catch (e) {
83
- reject(e);
84
- } }
85
- function rejected(value) { try {
86
- step(generator["throw"](value));
87
- }
88
- catch (e) {
89
- reject(e);
90
- } }
91
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
92
- step((generator = generator.apply(thisArg, _arguments || [])).next());
93
- });
94
- }
95
- function __generator(thisArg, body) {
96
- var _ = { label: 0, sent: function () { if (t[0] & 1)
97
- throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
98
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
99
- function verb(n) { return function (v) { return step([n, v]); }; }
100
- function step(op) {
101
- if (f)
102
- throw new TypeError("Generator is already executing.");
103
- while (_)
104
- try {
105
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
106
- return t;
107
- if (y = 0, t)
108
- op = [op[0] & 2, t.value];
109
- switch (op[0]) {
110
- case 0:
111
- case 1:
112
- t = op;
113
- break;
114
- case 4:
115
- _.label++;
116
- return { value: op[1], done: false };
117
- case 5:
118
- _.label++;
119
- y = op[1];
120
- op = [0];
121
- continue;
122
- case 7:
123
- op = _.ops.pop();
124
- _.trys.pop();
125
- continue;
126
- default:
127
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
128
- _ = 0;
129
- continue;
130
- }
131
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
132
- _.label = op[1];
133
- break;
134
- }
135
- if (op[0] === 6 && _.label < t[1]) {
136
- _.label = t[1];
137
- t = op;
138
- break;
139
- }
140
- if (t && _.label < t[2]) {
141
- _.label = t[2];
142
- _.ops.push(op);
143
- break;
144
- }
145
- if (t[2])
146
- _.ops.pop();
147
- _.trys.pop();
148
- continue;
149
- }
150
- op = body.call(thisArg, _);
151
- }
152
- catch (e) {
153
- op = [6, e];
154
- y = 0;
155
- }
156
- finally {
157
- f = t = 0;
158
- }
159
- if (op[0] & 5)
160
- throw op[1];
161
- return { value: op[0] ? op[1] : void 0, done: true };
162
- }
163
- }
164
- var __createBinding = Object.create ? (function (o, m, k, k2) {
165
- if (k2 === undefined)
166
- k2 = k;
167
- Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
168
- }) : (function (o, m, k, k2) {
169
- if (k2 === undefined)
170
- k2 = k;
171
- o[k2] = m[k];
172
- });
173
- function __exportStar(m, o) {
174
- for (var p in m)
175
- if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
176
- __createBinding(o, m, p);
177
- }
178
- function __values(o) {
179
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
180
- if (m)
181
- return m.call(o);
182
- if (o && typeof o.length === "number")
183
- return {
184
- next: function () {
185
- if (o && i >= o.length)
186
- o = void 0;
187
- return { value: o && o[i++], done: !o };
188
- }
189
- };
190
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
191
- }
192
- function __read(o, n) {
193
- var m = typeof Symbol === "function" && o[Symbol.iterator];
194
- if (!m)
195
- return o;
196
- var i = m.call(o), r, ar = [], e;
197
- try {
198
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
199
- ar.push(r.value);
200
- }
201
- catch (error) {
202
- e = { error: error };
203
- }
204
- finally {
205
- try {
206
- if (r && !r.done && (m = i["return"]))
207
- m.call(i);
208
- }
209
- finally {
210
- if (e)
211
- throw e.error;
212
- }
213
- }
214
- return ar;
215
- }
216
- function __spread() {
217
- for (var ar = [], i = 0; i < arguments.length; i++)
218
- ar = ar.concat(__read(arguments[i]));
219
- return ar;
220
- }
221
- function __spreadArrays() {
222
- for (var s = 0, i = 0, il = arguments.length; i < il; i++)
223
- s += arguments[i].length;
224
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
225
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
226
- r[k] = a[j];
227
- return r;
228
- }
229
- ;
230
- function __await(v) {
231
- return this instanceof __await ? (this.v = v, this) : new __await(v);
232
- }
233
- function __asyncGenerator(thisArg, _arguments, generator) {
234
- if (!Symbol.asyncIterator)
235
- throw new TypeError("Symbol.asyncIterator is not defined.");
236
- var g = generator.apply(thisArg, _arguments || []), i, q = [];
237
- return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
238
- function verb(n) { if (g[n])
239
- i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
240
- function resume(n, v) { try {
241
- step(g[n](v));
242
- }
243
- catch (e) {
244
- settle(q[0][3], e);
245
- } }
246
- function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
247
- function fulfill(value) { resume("next", value); }
248
- function reject(value) { resume("throw", value); }
249
- function settle(f, v) { if (f(v), q.shift(), q.length)
250
- resume(q[0][0], q[0][1]); }
251
- }
252
- function __asyncDelegator(o) {
253
- var i, p;
254
- return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
255
- function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
256
- }
257
- function __asyncValues(o) {
258
- if (!Symbol.asyncIterator)
259
- throw new TypeError("Symbol.asyncIterator is not defined.");
260
- var m = o[Symbol.asyncIterator], i;
261
- return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
262
- function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
263
- function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
264
- }
265
- function __makeTemplateObject(cooked, raw) {
266
- if (Object.defineProperty) {
267
- Object.defineProperty(cooked, "raw", { value: raw });
268
- }
269
- else {
270
- cooked.raw = raw;
271
- }
272
- return cooked;
273
- }
274
- ;
275
- var __setModuleDefault = Object.create ? (function (o, v) {
276
- Object.defineProperty(o, "default", { enumerable: true, value: v });
277
- }) : function (o, v) {
278
- o["default"] = v;
279
- };
280
- function __importStar(mod) {
281
- if (mod && mod.__esModule)
282
- return mod;
283
- var result = {};
284
- if (mod != null)
285
- for (var k in mod)
286
- if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
287
- __createBinding(result, mod, k);
288
- __setModuleDefault(result, mod);
289
- return result;
290
- }
291
- function __importDefault(mod) {
292
- return (mod && mod.__esModule) ? mod : { default: mod };
293
- }
294
- function __classPrivateFieldGet(receiver, privateMap) {
295
- if (!privateMap.has(receiver)) {
296
- throw new TypeError("attempted to get private field on non-instance");
297
- }
298
- return privateMap.get(receiver);
299
- }
300
- function __classPrivateFieldSet(receiver, privateMap, value) {
301
- if (!privateMap.has(receiver)) {
302
- throw new TypeError("attempted to set private field on non-instance");
303
- }
304
- privateMap.set(receiver, value);
305
- return value;
306
- }
307
-
308
- /** @type {?} */
309
- var noop = ( /**
310
- * @return {?}
311
- */function () {
312
- // empty method
313
- });
314
- var ɵ0 = noop;
315
- // counter for ids to allow for multiple editors on one page
316
- /** @type {?} */
317
- var uniqueCounter = 0;
318
- var TdCodeEditorComponent = /** @class */ (function () {
319
- // tslint:disable-next-line:member-ordering
320
- /**
321
- * @param {?} zone
322
- * @param {?} _changeDetectorRef
323
- * @param {?} _elementRef
324
- */
325
- function TdCodeEditorComponent(zone, _changeDetectorRef, _elementRef) {
326
- this.zone = zone;
327
- this._changeDetectorRef = _changeDetectorRef;
328
- this._elementRef = _elementRef;
329
- this._destroy = new rxjs.Subject();
330
- this._widthSubject = new rxjs.Subject();
331
- this._heightSubject = new rxjs.Subject();
332
- this._editorStyle = 'width:100%;height:100%;border:1px solid grey;';
333
- this._value = '';
334
- this._theme = 'vs';
335
- this._language = 'javascript';
336
- this._subject = new rxjs.Subject();
337
- this._editorInnerContainer = 'editorInnerContainer' + uniqueCounter++;
338
- this._fromEditor = false;
339
- this._componentInitialized = false;
340
- this._editorOptions = {};
341
- this._isFullScreen = false;
342
- this._registeredLanguagesStyles = [];
343
- /**
344
- * editorInitialized: function($event)
345
- * Event emitted when editor is first initialized
346
- */
347
- this.editorInitialized = new core.EventEmitter();
348
- /**
349
- * editorConfigurationChanged: function($event)
350
- * Event emitted when editor's configuration changes
351
- */
352
- this.editorConfigurationChanged = new core.EventEmitter();
353
- /**
354
- * editorLanguageChanged: function($event)
355
- * Event emitted when editor's Language changes
356
- */
357
- this.editorLanguageChanged = new core.EventEmitter();
358
- /**
359
- * editorValueChange: function($event)
360
- * Event emitted any time something changes the editor value
361
- */
362
- this.editorValueChange = new core.EventEmitter();
363
- /**
364
- * The change event notifies you about a change happening in an input field.
365
- * Since the component is not a native Angular component have to specifiy the event emitter ourself
366
- */
367
- this.change = new core.EventEmitter();
368
- /* tslint:disable-next-line */
369
- this.propagateChange = ( /**
370
- * @param {?} _
371
- * @return {?}
372
- */function (_) { });
373
- this.onTouched = ( /**
374
- * @return {?}
375
- */function () { return noop; });
376
- }
377
- Object.defineProperty(TdCodeEditorComponent.prototype, "value", {
378
- /**
379
- * @return {?}
380
- */
381
- get: function () {
382
- return this._value;
383
- },
384
- /**
385
- * value?: string
386
- * @param {?} value
387
- * @return {?}
388
- */
389
- set: function (value) {
390
- if (value === this._value) {
391
- return;
392
- }
393
- this._value = value;
394
- if (this._componentInitialized) {
395
- this.applyValue();
396
- }
397
- },
398
- enumerable: false,
399
- configurable: true
400
- });
401
- /**
402
- * @return {?}
403
- */
404
- TdCodeEditorComponent.prototype.applyValue = function () {
405
- if (!this._fromEditor) {
406
- this._editor.setValue(this._value);
407
- }
408
- this._fromEditor = false;
409
- this.propagateChange(this._value);
410
- this.change.emit();
411
- this.editorValueChange.emit();
412
- };
413
- /**
414
- * Implemented as part of ControlValueAccessor.
415
- * @param {?} value
416
- * @return {?}
417
- */
418
- TdCodeEditorComponent.prototype.writeValue = function (value) {
419
- // do not write if null or undefined
420
- // tslint:disable-next-line
421
- if (value != undefined) {
422
- this.value = value;
423
- }
424
- };
425
- /**
426
- * @param {?} fn
427
- * @return {?}
428
- */
429
- TdCodeEditorComponent.prototype.registerOnChange = function (fn) {
430
- this.propagateChange = fn;
431
- };
432
- /**
433
- * @param {?} fn
434
- * @return {?}
435
- */
436
- TdCodeEditorComponent.prototype.registerOnTouched = function (fn) {
437
- this.onTouched = fn;
438
- };
439
- /**
440
- * getEditorContent?: function
441
- * Returns the content within the editor
442
- * @return {?}
443
- */
444
- TdCodeEditorComponent.prototype.getValue = function () {
445
- var _this = this;
446
- if (this._componentInitialized) {
447
- setTimeout(( /**
448
- * @return {?}
449
- */function () {
450
- _this._subject.next(_this._value);
451
- _this._subject.complete();
452
- _this._subject = new rxjs.Subject();
453
- }));
454
- return this._subject.asObservable();
455
- }
456
- };
457
- Object.defineProperty(TdCodeEditorComponent.prototype, "language", {
458
- /**
459
- * @return {?}
460
- */
461
- get: function () {
462
- return this._language;
463
- },
464
- /**
465
- * language?: string
466
- * language used in editor
467
- * @param {?} language
468
- * @return {?}
469
- */
470
- set: function (language) {
471
- this._language = language;
472
- if (this._componentInitialized) {
473
- this.applyLanguage();
474
- }
475
- },
476
- enumerable: false,
477
- configurable: true
478
- });
479
- /**
480
- * @return {?}
481
- */
482
- TdCodeEditorComponent.prototype.applyLanguage = function () {
483
- if (this._language) {
484
- monaco.editor.setModelLanguage(this._editor.getModel(), this._language);
485
- this.editorLanguageChanged.emit();
486
- }
487
- };
488
- /**
489
- * registerLanguage?: function
490
- * Registers a custom Language within the editor
491
- * @param {?} language
492
- * @return {?}
493
- */
494
- TdCodeEditorComponent.prototype.registerLanguage = function (language) {
495
- var e_1, _a, e_2, _b;
496
- if (this._componentInitialized) {
497
- try {
498
- for (var _c = __values(language.completionItemProvider), _d = _c.next(); !_d.done; _d = _c.next()) {
499
- var provider = _d.value;
500
- /* tslint:disable-next-line */
501
- provider.kind = eval(provider.kind);
502
- }
503
- }
504
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
505
- finally {
506
- try {
507
- if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
508
- }
509
- finally { if (e_1) throw e_1.error; }
510
- }
511
- try {
512
- for (var _e = __values(language.monarchTokensProvider), _f = _e.next(); !_f.done; _f = _e.next()) {
513
- var monarchTokens = _f.value;
514
- /* tslint:disable-next-line */
515
- monarchTokens[0] = eval(monarchTokens[0]);
516
- }
517
- }
518
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
519
- finally {
520
- try {
521
- if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
522
- }
523
- finally { if (e_2) throw e_2.error; }
524
- }
525
- monaco.languages.register({ id: language.id });
526
- monaco.languages.setMonarchTokensProvider(language.id, {
527
- tokenizer: {
528
- root: language.monarchTokensProvider,
529
- },
530
- });
531
- // Define a new theme that constains only rules that match this language
532
- monaco.editor.defineTheme(language.customTheme.id, language.customTheme.theme);
533
- this._theme = language.customTheme.id;
534
- monaco.languages.registerCompletionItemProvider(language.id, {
535
- provideCompletionItems: ( /**
536
- * @return {?}
537
- */function () {
538
- return language.completionItemProvider;
539
- }),
540
- });
541
- /** @type {?} */
542
- var css = document.createElement('style');
543
- css.type = 'text/css';
544
- css.innerHTML = language.monarchTokensProviderCSS;
545
- document.body.appendChild(css);
546
- this.editorConfigurationChanged.emit();
547
- this._registeredLanguagesStyles = __spread(this._registeredLanguagesStyles, [css]);
548
- }
549
- };
550
- Object.defineProperty(TdCodeEditorComponent.prototype, "editorStyle", {
551
- /**
552
- * @return {?}
553
- */
554
- get: function () {
555
- return this._editorStyle;
556
- },
557
- /**
558
- * style?: string
559
- * css style of the editor on the page
560
- * @param {?} editorStyle
561
- * @return {?}
562
- */
563
- set: function (editorStyle) {
564
- this._editorStyle = editorStyle;
565
- if (this._componentInitialized) {
566
- this.applyStyle();
567
- }
568
- },
569
- enumerable: false,
570
- configurable: true
571
- });
572
- /**
573
- * @return {?}
574
- */
575
- TdCodeEditorComponent.prototype.applyStyle = function () {
576
- if (this._editorStyle) {
577
- /** @type {?} */
578
- var containerDiv = this._editorContainer.nativeElement;
579
- containerDiv.setAttribute('style', this._editorStyle);
580
- }
581
- };
582
- Object.defineProperty(TdCodeEditorComponent.prototype, "theme", {
583
- /**
584
- * @return {?}
585
- */
586
- get: function () {
587
- return this._theme;
588
- },
589
- /**
590
- * theme?: string
591
- * Theme to be applied to editor
592
- * @param {?} theme
593
- * @return {?}
594
- */
595
- set: function (theme) {
596
- this._theme = theme;
597
- if (this._componentInitialized) {
598
- this._editor.updateOptions({ theme: theme });
599
- this.editorConfigurationChanged.emit();
600
- }
601
- },
602
- enumerable: false,
603
- configurable: true
604
- });
605
- Object.defineProperty(TdCodeEditorComponent.prototype, "fullScreenKeyBinding", {
606
- /**
607
- * @return {?}
608
- */
609
- get: function () {
610
- return this._keycode;
611
- },
612
- /**
613
- * fullScreenKeyBinding?: number
614
- * See here for key bindings https://microsoft.github.io/monaco-editor/api/enums/monaco.keycode.html
615
- * Sets the KeyCode for shortcutting to Fullscreen mode
616
- * @param {?} keycode
617
- * @return {?}
618
- */
619
- set: function (keycode) {
620
- this._keycode = keycode;
621
- },
622
- enumerable: false,
623
- configurable: true
624
- });
625
- Object.defineProperty(TdCodeEditorComponent.prototype, "editorOptions", {
626
- /**
627
- * @return {?}
628
- */
629
- get: function () {
630
- return this._editorOptions;
631
- },
632
- /**
633
- * editorOptions?: object
634
- * Options used on editor instantiation. Available options listed here:
635
- * https://microsoft.github.io/monaco-editor/api/interfaces/monaco.editor.ieditoroptions.html
636
- * @param {?} editorOptions
637
- * @return {?}
638
- */
639
- set: function (editorOptions) {
640
- this._editorOptions = editorOptions;
641
- if (this._componentInitialized) {
642
- this._editor.updateOptions(editorOptions);
643
- this.editorConfigurationChanged.emit();
644
- }
645
- },
646
- enumerable: false,
647
- configurable: true
648
- });
649
- /**
650
- * layout method that calls layout method of editor and instructs the editor to remeasure its container
651
- * @return {?}
652
- */
653
- TdCodeEditorComponent.prototype.layout = function () {
654
- if (this._componentInitialized) {
655
- this._editor.layout();
656
- }
657
- };
658
- Object.defineProperty(TdCodeEditorComponent.prototype, "isFullScreen", {
659
- /**
660
- * Returns if in Full Screen Mode or not
661
- * @return {?}
662
- */
663
- get: function () {
664
- return this._isFullScreen;
665
- },
666
- enumerable: false,
667
- configurable: true
668
- });
669
- /**
670
- * @return {?}
671
- */
672
- TdCodeEditorComponent.prototype.ngOnInit = function () {
673
- var _this = this;
674
- /** @type {?} */
675
- var containerDiv = this._editorContainer.nativeElement;
676
- containerDiv.id = this._editorInnerContainer;
677
- this._editor = monaco.editor.create(containerDiv, Object.assign({
678
- value: this._value,
679
- language: this.language,
680
- theme: this._theme,
681
- }, this.editorOptions));
682
- this._componentInitialized = true;
683
- setTimeout(( /**
684
- * @return {?}
685
- */function () {
686
- _this.applyLanguage();
687
- _this._fromEditor = true;
688
- _this.applyValue();
689
- _this.applyStyle();
690
- _this.editorInitialized.emit(_this._editor);
691
- _this.editorConfigurationChanged.emit();
692
- }));
693
- this._editor.getModel().onDidChangeContent(( /**
694
- * @param {?} e
695
- * @return {?}
696
- */function (e) {
697
- _this._fromEditor = true;
698
- _this.writeValue(_this._editor.getValue());
699
- _this.layout();
700
- }));
701
- this.addFullScreenModeCommand();
702
- rxjs.merge(rxjs.fromEvent(window, 'resize').pipe(operators.debounceTime(100)), this._widthSubject.asObservable().pipe(operators.distinctUntilChanged()), this._heightSubject.asObservable().pipe(operators.distinctUntilChanged()))
703
- .pipe(operators.takeUntil(this._destroy), operators.debounceTime(100))
704
- .subscribe(( /**
705
- * @return {?}
706
- */function () {
707
- _this.layout();
708
- _this._changeDetectorRef.markForCheck();
709
- }));
710
- rxjs.timer(500, 250)
711
- .pipe(operators.takeUntil(this._destroy))
712
- .subscribe(( /**
713
- * @return {?}
714
- */function () {
715
- if (_this._elementRef && _this._elementRef.nativeElement) {
716
- _this._widthSubject.next((( /** @type {?} */(_this._elementRef.nativeElement))).getBoundingClientRect().width);
717
- _this._heightSubject.next((( /** @type {?} */(_this._elementRef.nativeElement))).getBoundingClientRect().height);
718
- }
719
- }));
720
- };
721
- /**
722
- * @return {?}
723
- */
724
- TdCodeEditorComponent.prototype.ngOnDestroy = function () {
725
- this._changeDetectorRef.detach();
726
- this._registeredLanguagesStyles.forEach(( /**
727
- * @param {?} style
728
- * @return {?}
729
- */function (style) { return style.remove(); }));
730
- if (this._editor) {
731
- this._editor.dispose();
732
- }
733
- this._destroy.next(true);
734
- this._destroy.unsubscribe();
735
- };
736
- /**
737
- * showFullScreenEditor request for full screen of Code Editor based on its browser type.
738
- * @return {?}
739
- */
740
- TdCodeEditorComponent.prototype.showFullScreenEditor = function () {
741
- var e_3, _a;
742
- if (this._componentInitialized) {
743
- /** @type {?} */
744
- var codeEditorElement_1 = ( /** @type {?} */(this._editorContainer.nativeElement));
745
- /** @type {?} */
746
- var fullScreenMap = {
747
- // Chrome
748
- requestFullscreen: ( /**
749
- * @return {?}
750
- */function () { return codeEditorElement_1.requestFullscreen(); }),
751
- // Safari
752
- webkitRequestFullscreen: ( /**
753
- * @return {?}
754
- */function () { return (( /** @type {?} */(codeEditorElement_1))).webkitRequestFullscreen(); }),
755
- // IE
756
- msRequestFullscreen: ( /**
757
- * @return {?}
758
- */function () { return (( /** @type {?} */(codeEditorElement_1))).msRequestFullscreen(); }),
759
- // Firefox
760
- mozRequestFullScreen: ( /**
761
- * @return {?}
762
- */function () { return (( /** @type {?} */(codeEditorElement_1))).mozRequestFullScreen(); }),
763
- };
764
- try {
765
- for (var _b = __values(Object.keys(fullScreenMap)), _c = _b.next(); !_c.done; _c = _b.next()) {
766
- var handler = _c.value;
767
- if (codeEditorElement_1[handler]) {
768
- fullScreenMap[handler]();
769
- }
770
- }
771
- }
772
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
773
- finally {
774
- try {
775
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
776
- }
777
- finally { if (e_3) throw e_3.error; }
778
- }
779
- }
780
- this._isFullScreen = true;
781
- };
782
- /**
783
- * exitFullScreenEditor request to exit full screen of Code Editor based on its browser type.
784
- * @return {?}
785
- */
786
- TdCodeEditorComponent.prototype.exitFullScreenEditor = function () {
787
- var e_4, _a;
788
- if (this._componentInitialized) {
789
- /** @type {?} */
790
- var exitFullScreenMap = {
791
- // Chrome
792
- exitFullscreen: ( /**
793
- * @return {?}
794
- */function () { return document.exitFullscreen(); }),
795
- // Safari
796
- webkitExitFullscreen: ( /**
797
- * @return {?}
798
- */function () { return (( /** @type {?} */(document))).webkitExitFullscreen(); }),
799
- // Firefox
800
- mozCancelFullScreen: ( /**
801
- * @return {?}
802
- */function () { return (( /** @type {?} */(document))).mozCancelFullScreen(); }),
803
- // IE
804
- msExitFullscreen: ( /**
805
- * @return {?}
806
- */function () { return (( /** @type {?} */(document))).msExitFullscreen(); }),
807
- };
808
- try {
809
- for (var _b = __values(Object.keys(exitFullScreenMap)), _c = _b.next(); !_c.done; _c = _b.next()) {
810
- var handler = _c.value;
811
- if (document[handler]) {
812
- exitFullScreenMap[handler]();
813
- }
814
- }
815
- }
816
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
817
- finally {
818
- try {
819
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
820
- }
821
- finally { if (e_4) throw e_4.error; }
822
- }
823
- }
824
- this._isFullScreen = false;
825
- };
826
- /**
827
- * addFullScreenModeCommand used to add the fullscreen option to the context menu
828
- * @private
829
- * @return {?}
830
- */
831
- TdCodeEditorComponent.prototype.addFullScreenModeCommand = function () {
832
- var _this = this;
833
- this._editor.addAction({
834
- // An unique identifier of the contributed action.
835
- id: 'fullScreen',
836
- // A label of the action that will be presented to the user.
837
- label: 'Full Screen',
838
- // An optional array of keybindings for the action.
839
- contextMenuGroupId: 'navigation',
840
- keybindings: this._keycode,
841
- contextMenuOrder: 1.5,
842
- // Method that will be executed when the action is triggered.
843
- // @param editor The editor instance is passed in as a convinience
844
- run: ( /**
845
- * @param {?} ed
846
- * @return {?}
847
- */function (ed) {
848
- _this.showFullScreenEditor();
849
- }),
850
- });
851
- };
852
- return TdCodeEditorComponent;
853
- }());
854
- TdCodeEditorComponent.decorators = [
855
- { type: core.Component, args: [{
856
- selector: 'td-code-editor',
857
- template: "<div class=\"editorContainer\" #editorContainer></div>\n",
858
- providers: [
859
- {
860
- provide: forms.NG_VALUE_ACCESSOR,
861
- useExisting: core.forwardRef(( /**
862
- * @return {?}
863
- */function () { return TdCodeEditorComponent; })),
864
- multi: true,
865
- },
866
- ],
867
- styles: [":host{display:block;position:relative}:host .editorContainer{bottom:0;left:0;position:absolute;right:0;top:0}::ng-deep .monaco-aria-container{display:none}"]
868
- }] }
869
- ];
870
- /** @nocollapse */
871
- TdCodeEditorComponent.ctorParameters = function () { return [
872
- { type: core.NgZone },
873
- { type: core.ChangeDetectorRef },
874
- { type: core.ElementRef }
875
- ]; };
876
- TdCodeEditorComponent.propDecorators = {
877
- _editorContainer: [{ type: core.ViewChild, args: ['editorContainer', { static: true },] }],
878
- editorInitialized: [{ type: core.Output }],
879
- editorConfigurationChanged: [{ type: core.Output }],
880
- editorLanguageChanged: [{ type: core.Output }],
881
- editorValueChange: [{ type: core.Output }],
882
- change: [{ type: core.Output }],
883
- value: [{ type: core.Input, args: ['value',] }],
884
- language: [{ type: core.Input, args: ['language',] }],
885
- editorStyle: [{ type: core.Input, args: ['editorStyle',] }],
886
- theme: [{ type: core.Input, args: ['theme',] }],
887
- fullScreenKeyBinding: [{ type: core.Input, args: ['fullScreenKeyBinding',] }],
888
- editorOptions: [{ type: core.Input, args: ['editorOptions',] }]
889
- };
890
- if (false) {
891
- /**
892
- * @type {?}
893
- * @private
894
- */
895
- TdCodeEditorComponent.prototype._destroy;
896
- /**
897
- * @type {?}
898
- * @private
899
- */
900
- TdCodeEditorComponent.prototype._widthSubject;
901
- /**
902
- * @type {?}
903
- * @private
904
- */
905
- TdCodeEditorComponent.prototype._heightSubject;
906
- /**
907
- * @type {?}
908
- * @private
909
- */
910
- TdCodeEditorComponent.prototype._editorStyle;
911
- /**
912
- * @type {?}
913
- * @private
914
- */
915
- TdCodeEditorComponent.prototype._value;
916
- /**
917
- * @type {?}
918
- * @private
919
- */
920
- TdCodeEditorComponent.prototype._theme;
921
- /**
922
- * @type {?}
923
- * @private
924
- */
925
- TdCodeEditorComponent.prototype._language;
926
- /**
927
- * @type {?}
928
- * @private
929
- */
930
- TdCodeEditorComponent.prototype._subject;
931
- /**
932
- * @type {?}
933
- * @private
934
- */
935
- TdCodeEditorComponent.prototype._editorInnerContainer;
936
- /**
937
- * @type {?}
938
- * @private
939
- */
940
- TdCodeEditorComponent.prototype._editor;
941
- /**
942
- * @type {?}
943
- * @private
944
- */
945
- TdCodeEditorComponent.prototype._fromEditor;
946
- /**
947
- * @type {?}
948
- * @private
949
- */
950
- TdCodeEditorComponent.prototype._componentInitialized;
951
- /**
952
- * @type {?}
953
- * @private
954
- */
955
- TdCodeEditorComponent.prototype._editorOptions;
956
- /**
957
- * @type {?}
958
- * @private
959
- */
960
- TdCodeEditorComponent.prototype._isFullScreen;
961
- /**
962
- * @type {?}
963
- * @private
964
- */
965
- TdCodeEditorComponent.prototype._keycode;
966
- /**
967
- * @type {?}
968
- * @private
969
- */
970
- TdCodeEditorComponent.prototype._registeredLanguagesStyles;
971
- /** @type {?} */
972
- TdCodeEditorComponent.prototype._editorContainer;
973
- /**
974
- * editorInitialized: function($event)
975
- * Event emitted when editor is first initialized
976
- * @type {?}
977
- */
978
- TdCodeEditorComponent.prototype.editorInitialized;
979
- /**
980
- * editorConfigurationChanged: function($event)
981
- * Event emitted when editor's configuration changes
982
- * @type {?}
983
- */
984
- TdCodeEditorComponent.prototype.editorConfigurationChanged;
985
- /**
986
- * editorLanguageChanged: function($event)
987
- * Event emitted when editor's Language changes
988
- * @type {?}
989
- */
990
- TdCodeEditorComponent.prototype.editorLanguageChanged;
991
- /**
992
- * editorValueChange: function($event)
993
- * Event emitted any time something changes the editor value
994
- * @type {?}
995
- */
996
- TdCodeEditorComponent.prototype.editorValueChange;
997
- /**
998
- * The change event notifies you about a change happening in an input field.
999
- * Since the component is not a native Angular component have to specifiy the event emitter ourself
1000
- * @type {?}
1001
- */
1002
- TdCodeEditorComponent.prototype.change;
1003
- /** @type {?} */
1004
- TdCodeEditorComponent.prototype.propagateChange;
1005
- /** @type {?} */
1006
- TdCodeEditorComponent.prototype.onTouched;
1007
- /**
1008
- * @type {?}
1009
- * @private
1010
- */
1011
- TdCodeEditorComponent.prototype.zone;
1012
- /**
1013
- * @type {?}
1014
- * @private
1015
- */
1016
- TdCodeEditorComponent.prototype._changeDetectorRef;
1017
- /**
1018
- * @type {?}
1019
- * @private
1020
- */
1021
- TdCodeEditorComponent.prototype._elementRef;
1022
- }
1023
-
1024
- /**
1025
- * @fileoverview added by tsickle
1026
- * Generated from: code-editor.module.ts
1027
- * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1028
- */
1029
- var CovalentCodeEditorModule = /** @class */ (function () {
1030
- function CovalentCodeEditorModule() {
1031
- }
1032
- return CovalentCodeEditorModule;
1033
- }());
1034
- CovalentCodeEditorModule.decorators = [
1035
- { type: core.NgModule, args: [{
1036
- imports: [common.CommonModule],
1037
- declarations: [TdCodeEditorComponent],
1038
- exports: [TdCodeEditorComponent],
1039
- bootstrap: [TdCodeEditorComponent],
1040
- },] }
1041
- ];
1042
-
1043
- /**
1044
- * @fileoverview added by tsickle
1045
- * Generated from: public-api.ts
1046
- * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1047
- */
1048
-
1049
- /**
1050
- * @fileoverview added by tsickle
1051
- * Generated from: index.ts
1052
- * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1053
- */
1054
-
1055
- /**
1056
- * @fileoverview added by tsickle
1057
- * Generated from: covalent-code-editor.ts
1058
- * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1059
- */
1060
-
1061
- exports.CovalentCodeEditorModule = CovalentCodeEditorModule;
1062
- exports.TdCodeEditorComponent = TdCodeEditorComponent;
1063
-
1064
- Object.defineProperty(exports, '__esModule', { value: true });
1065
-
1066
- })));
1067
- //# sourceMappingURL=covalent-code-editor.umd.js.map