@covalent/code-editor 4.0.0 → 4.1.0-develop.10

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.
@@ -0,0 +1,384 @@
1
+ import * as i0 from '@angular/core';
2
+ import { EventEmitter, forwardRef, Component, ViewChild, Output, Input, NgModule } from '@angular/core';
3
+ import { NG_VALUE_ACCESSOR } from '@angular/forms';
4
+ import { Subject, of, merge, fromEvent, timer } from 'rxjs';
5
+ import { debounceTime, distinctUntilChanged, takeUntil } from 'rxjs/operators';
6
+ import * as monaco from 'monaco-editor/esm/vs/editor/editor.api';
7
+ import { mixinControlValueAccessor, mixinDisabled } from '@covalent/core/common';
8
+ import { CommonModule } from '@angular/common';
9
+
10
+ const noop = () => {
11
+ // empty method
12
+ };
13
+ // counter for ids to allow for multiple editors on one page
14
+ let uniqueCounter = 0;
15
+ class TdCodeEditorBase {
16
+ constructor(_changeDetectorRef) {
17
+ this._changeDetectorRef = _changeDetectorRef;
18
+ }
19
+ }
20
+ const _TdCodeEditorMixinBase = mixinControlValueAccessor(mixinDisabled(TdCodeEditorBase), []);
21
+ class TdCodeEditorComponent extends _TdCodeEditorMixinBase {
22
+ // tslint:disable-next-line:member-ordering
23
+ constructor(_changeDetectorRef, _elementRef) {
24
+ super(_changeDetectorRef);
25
+ this._elementRef = _elementRef;
26
+ this._destroy = new Subject();
27
+ this._widthSubject = new Subject();
28
+ this._heightSubject = new Subject();
29
+ this._editorStyle = 'width:100%;height:100%;border:1px solid grey;';
30
+ this._value = '';
31
+ this._theme = 'vs';
32
+ this._language = 'javascript';
33
+ this._subject = new Subject();
34
+ this._editorInnerContainer = 'editorInnerContainer' + uniqueCounter++;
35
+ this._fromEditor = false;
36
+ this._componentInitialized = false;
37
+ this._editorOptions = {};
38
+ this._isFullScreen = false;
39
+ this._registeredLanguagesStyles = [];
40
+ /**
41
+ * editorInitialized: function($event)
42
+ * Event emitted when editor is first initialized
43
+ */
44
+ this.editorInitialized = new EventEmitter();
45
+ /**
46
+ * editorConfigurationChanged: function($event)
47
+ * Event emitted when editor's configuration changes
48
+ */
49
+ this.editorConfigurationChanged = new EventEmitter();
50
+ /**
51
+ * editorLanguageChanged: function($event)
52
+ * Event emitted when editor's Language changes
53
+ */
54
+ this.editorLanguageChanged = new EventEmitter();
55
+ /**
56
+ * editorValueChange: function($event)
57
+ * Event emitted any time something changes the editor value
58
+ */
59
+ this.editorValueChange = new EventEmitter();
60
+ this.propagateChange = (_) => noop;
61
+ }
62
+ /**
63
+ * value?: string
64
+ */
65
+ set value(value) {
66
+ this._value = value;
67
+ if (this._componentInitialized) {
68
+ this.applyValue();
69
+ }
70
+ }
71
+ get value() {
72
+ return this._value;
73
+ }
74
+ applyValue() {
75
+ if (!this._fromEditor) {
76
+ this._editor.setValue(this._value);
77
+ }
78
+ this._fromEditor = false;
79
+ this.propagateChange(this._value);
80
+ this.editorValueChange.emit();
81
+ }
82
+ registerOnChange(fn) {
83
+ this.propagateChange = fn;
84
+ }
85
+ registerOnTouched(fn) {
86
+ this.onTouched = fn;
87
+ }
88
+ /**
89
+ * getEditorContent?: function
90
+ * Returns the content within the editor
91
+ */
92
+ getValue() {
93
+ if (!this._componentInitialized) {
94
+ return of('');
95
+ }
96
+ setTimeout(() => {
97
+ this._subject.next(this._value);
98
+ this._subject.complete();
99
+ this._subject = new Subject();
100
+ });
101
+ return this._subject.asObservable();
102
+ }
103
+ /**
104
+ * language?: string
105
+ * language used in editor
106
+ */
107
+ set language(language) {
108
+ this._language = language;
109
+ if (this._componentInitialized) {
110
+ this.applyLanguage();
111
+ }
112
+ }
113
+ get language() {
114
+ return this._language;
115
+ }
116
+ applyLanguage() {
117
+ if (this._language) {
118
+ monaco.editor.setModelLanguage(this._editor.getModel(), this._language);
119
+ this.editorLanguageChanged.emit();
120
+ }
121
+ }
122
+ /**
123
+ * registerLanguage?: function
124
+ * Registers a custom Language within the editor
125
+ */
126
+ registerLanguage(language) {
127
+ if (this._componentInitialized) {
128
+ monaco.languages.register({ id: language.id });
129
+ monaco.languages.setMonarchTokensProvider(language.id, {
130
+ tokenizer: {
131
+ root: language.monarchTokensProvider,
132
+ },
133
+ });
134
+ // Define a new theme that constains only rules that match this language
135
+ monaco.editor.defineTheme(language.customTheme.id, language.customTheme.theme);
136
+ this._theme = language.customTheme.id;
137
+ monaco.languages.registerCompletionItemProvider(language.id, {
138
+ provideCompletionItems: () => {
139
+ return language.completionItemProvider;
140
+ },
141
+ });
142
+ const css = document.createElement('style');
143
+ css.type = 'text/css';
144
+ css.innerHTML = language.monarchTokensProviderCSS;
145
+ document.body.appendChild(css);
146
+ this.editorConfigurationChanged.emit();
147
+ this._registeredLanguagesStyles = [
148
+ ...this._registeredLanguagesStyles,
149
+ css,
150
+ ];
151
+ }
152
+ }
153
+ /**
154
+ * style?: string
155
+ * css style of the editor on the page
156
+ */
157
+ set editorStyle(editorStyle) {
158
+ this._editorStyle = editorStyle;
159
+ if (this._componentInitialized) {
160
+ this.applyStyle();
161
+ }
162
+ }
163
+ get editorStyle() {
164
+ return this._editorStyle;
165
+ }
166
+ applyStyle() {
167
+ if (this._editorStyle) {
168
+ const containerDiv = this._editorContainer.nativeElement;
169
+ containerDiv.setAttribute('style', this._editorStyle);
170
+ }
171
+ }
172
+ /**
173
+ * theme?: string
174
+ * Theme to be applied to editor
175
+ */
176
+ set theme(theme) {
177
+ this._theme = theme;
178
+ if (this._componentInitialized) {
179
+ this._editor.updateOptions({ theme });
180
+ this.editorConfigurationChanged.emit();
181
+ }
182
+ }
183
+ get theme() {
184
+ return this._theme;
185
+ }
186
+ /**
187
+ * fullScreenKeyBinding?: number
188
+ * See here for key bindings https://microsoft.github.io/monaco-editor/api/enums/monaco.keycode.html
189
+ * Sets the KeyCode for shortcutting to Fullscreen mode
190
+ */
191
+ set fullScreenKeyBinding(keycode) {
192
+ this._keycode = keycode;
193
+ }
194
+ get fullScreenKeyBinding() {
195
+ return this._keycode;
196
+ }
197
+ /**
198
+ * editorOptions?: object
199
+ * Options used on editor instantiation. Available options listed here:
200
+ * https://microsoft.github.io/monaco-editor/api/interfaces/editor.ieditoroptions.html
201
+ */
202
+ set editorOptions(editorOptions) {
203
+ this._editorOptions = editorOptions;
204
+ if (this._componentInitialized) {
205
+ this._editor.updateOptions(editorOptions);
206
+ this.editorConfigurationChanged.emit();
207
+ }
208
+ }
209
+ get editorOptions() {
210
+ return this._editorOptions;
211
+ }
212
+ /**
213
+ * layout method that calls layout method of editor and instructs the editor to remeasure its container
214
+ */
215
+ layout() {
216
+ if (this._componentInitialized) {
217
+ this._editor.layout();
218
+ }
219
+ }
220
+ /**
221
+ * Returns if in Full Screen Mode or not
222
+ */
223
+ get isFullScreen() {
224
+ return this._isFullScreen;
225
+ }
226
+ ngOnInit() {
227
+ const containerDiv = this._editorContainer.nativeElement;
228
+ containerDiv.id = this._editorInnerContainer;
229
+ this._editor = monaco.editor.create(containerDiv, Object.assign({
230
+ value: this._value,
231
+ language: this.language,
232
+ theme: this._theme,
233
+ }, this.editorOptions));
234
+ this._componentInitialized = true;
235
+ setTimeout(() => {
236
+ this.applyLanguage();
237
+ this._fromEditor = true;
238
+ this.applyValue();
239
+ this.applyStyle();
240
+ this.editorInitialized.emit(this._editor);
241
+ this.editorConfigurationChanged.emit();
242
+ });
243
+ // The `onDidChangeContent` returns a disposable object (an object with `dispose()` method) which will cleanup
244
+ // the listener. The callback, that we pass to `onDidChangeContent`, captures `this`. This leads to a circular reference
245
+ // (`td-code-editor -> monaco -> td-code-editor`) and prevents the `td-code-editor` from being GC'd.
246
+ this._onDidChangeContentDisposable = this._editor
247
+ .getModel()
248
+ ?.onDidChangeContent(() => {
249
+ this._fromEditor = true;
250
+ this.writeValue(this._editor.getValue());
251
+ this.layout();
252
+ });
253
+ this.addFullScreenModeCommand();
254
+ merge(fromEvent(window, 'resize').pipe(debounceTime(100)), this._widthSubject.asObservable().pipe(distinctUntilChanged()), this._heightSubject.asObservable().pipe(distinctUntilChanged()))
255
+ .pipe(takeUntil(this._destroy), debounceTime(100))
256
+ .subscribe(() => {
257
+ this.layout();
258
+ this._changeDetectorRef.markForCheck();
259
+ });
260
+ timer(500, 250)
261
+ .pipe(takeUntil(this._destroy))
262
+ .subscribe(() => {
263
+ if (this._elementRef && this._elementRef.nativeElement) {
264
+ this._widthSubject.next((this._elementRef.nativeElement).getBoundingClientRect().width);
265
+ this._heightSubject.next((this._elementRef.nativeElement).getBoundingClientRect().height);
266
+ }
267
+ });
268
+ }
269
+ ngOnDestroy() {
270
+ this._changeDetectorRef.detach();
271
+ this._registeredLanguagesStyles.forEach((style) => style.remove());
272
+ if (this._onDidChangeContentDisposable) {
273
+ this._onDidChangeContentDisposable.dispose();
274
+ this._onDidChangeContentDisposable = undefined;
275
+ }
276
+ if (this._editor) {
277
+ this._editor.dispose();
278
+ }
279
+ this._destroy.next(true);
280
+ this._destroy.unsubscribe();
281
+ }
282
+ /**
283
+ * showFullScreenEditor request for full screen of Code Editor based on its browser type.
284
+ */
285
+ showFullScreenEditor() {
286
+ if (this._componentInitialized) {
287
+ const codeEditorElement = this._editorContainer
288
+ .nativeElement;
289
+ codeEditorElement.requestFullscreen();
290
+ }
291
+ this._isFullScreen = true;
292
+ }
293
+ /**
294
+ * exitFullScreenEditor request to exit full screen of Code Editor based on its browser type.
295
+ */
296
+ exitFullScreenEditor() {
297
+ if (this._componentInitialized) {
298
+ document.exitFullscreen();
299
+ }
300
+ this._isFullScreen = false;
301
+ }
302
+ /**
303
+ * addFullScreenModeCommand used to add the fullscreen option to the context menu
304
+ */
305
+ addFullScreenModeCommand() {
306
+ this._editor.addAction({
307
+ // An unique identifier of the contributed action.
308
+ id: 'fullScreen',
309
+ // A label of the action that will be presented to the user.
310
+ label: 'Full Screen',
311
+ // An optional array of keybindings for the action.
312
+ contextMenuGroupId: 'navigation',
313
+ keybindings: this._keycode,
314
+ contextMenuOrder: 1.5,
315
+ // Method that will be executed when the action is triggered.
316
+ run: () => {
317
+ this.showFullScreenEditor();
318
+ },
319
+ });
320
+ }
321
+ }
322
+ TdCodeEditorComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: TdCodeEditorComponent, deps: [{ token: i0.ChangeDetectorRef }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
323
+ TdCodeEditorComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.2", type: TdCodeEditorComponent, selector: "td-code-editor", inputs: { value: "value", language: "language", editorStyle: "editorStyle", theme: "theme", fullScreenKeyBinding: "fullScreenKeyBinding", editorOptions: "editorOptions" }, outputs: { editorInitialized: "editorInitialized", editorConfigurationChanged: "editorConfigurationChanged", editorLanguageChanged: "editorLanguageChanged", editorValueChange: "editorValueChange" }, providers: [
324
+ {
325
+ provide: NG_VALUE_ACCESSOR,
326
+ useExisting: forwardRef(() => TdCodeEditorComponent),
327
+ multi: true,
328
+ },
329
+ ], viewQueries: [{ propertyName: "_editorContainer", first: true, predicate: ["editorContainer"], descendants: true, static: true }], usesInheritance: true, ngImport: i0, template: "<div class=\"editor-container\" #editorContainer></div>\n", styles: [":host{display:block;position:relative}:host .editor-container{position:absolute;top:0;bottom:0;left:0;right:0}::ng-deep .monaco-aria-container{display:none}\n"] });
330
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: TdCodeEditorComponent, decorators: [{
331
+ type: Component,
332
+ args: [{ selector: 'td-code-editor', providers: [
333
+ {
334
+ provide: NG_VALUE_ACCESSOR,
335
+ useExisting: forwardRef(() => TdCodeEditorComponent),
336
+ multi: true,
337
+ },
338
+ ], template: "<div class=\"editor-container\" #editorContainer></div>\n", styles: [":host{display:block;position:relative}:host .editor-container{position:absolute;top:0;bottom:0;left:0;right:0}::ng-deep .monaco-aria-container{display:none}\n"] }]
339
+ }], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }, { type: i0.ElementRef }]; }, propDecorators: { _editorContainer: [{
340
+ type: ViewChild,
341
+ args: ['editorContainer', { static: true }]
342
+ }], editorInitialized: [{
343
+ type: Output
344
+ }], editorConfigurationChanged: [{
345
+ type: Output
346
+ }], editorLanguageChanged: [{
347
+ type: Output
348
+ }], editorValueChange: [{
349
+ type: Output
350
+ }], value: [{
351
+ type: Input
352
+ }], language: [{
353
+ type: Input
354
+ }], editorStyle: [{
355
+ type: Input
356
+ }], theme: [{
357
+ type: Input
358
+ }], fullScreenKeyBinding: [{
359
+ type: Input
360
+ }], editorOptions: [{
361
+ type: Input
362
+ }] } });
363
+
364
+ class CovalentCodeEditorModule {
365
+ }
366
+ CovalentCodeEditorModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: CovalentCodeEditorModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
367
+ CovalentCodeEditorModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: CovalentCodeEditorModule, bootstrap: [TdCodeEditorComponent], declarations: [TdCodeEditorComponent], imports: [CommonModule], exports: [TdCodeEditorComponent] });
368
+ CovalentCodeEditorModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: CovalentCodeEditorModule, imports: [[CommonModule]] });
369
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: CovalentCodeEditorModule, decorators: [{
370
+ type: NgModule,
371
+ args: [{
372
+ imports: [CommonModule],
373
+ declarations: [TdCodeEditorComponent],
374
+ exports: [TdCodeEditorComponent],
375
+ bootstrap: [TdCodeEditorComponent],
376
+ }]
377
+ }] });
378
+
379
+ /**
380
+ * Generated bundle index. Do not edit.
381
+ */
382
+
383
+ export { CovalentCodeEditorModule, TdCodeEditorComponent };
384
+ //# sourceMappingURL=covalent-code-editor.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"covalent-code-editor.mjs","sources":["../../../../libs/angular-code-editor/src/lib/code-editor.component.ts","../../../../libs/angular-code-editor/src/lib/code-editor.component.html","../../../../libs/angular-code-editor/src/lib/code-editor.module.ts","../../../../libs/angular-code-editor/src/covalent-code-editor.ts"],"sourcesContent":["import {\n Component,\n Input,\n Output,\n EventEmitter,\n OnInit,\n ViewChild,\n ElementRef,\n forwardRef,\n ChangeDetectorRef,\n OnDestroy,\n} from '@angular/core';\nimport { NG_VALUE_ACCESSOR, ControlValueAccessor } from '@angular/forms';\nimport { Observable, of, Subject } from 'rxjs';\nimport { fromEvent, merge, timer } from 'rxjs';\nimport { debounceTime, distinctUntilChanged, takeUntil } from 'rxjs/operators';\n\n// Use esm version to support shipping subset of languages and features\nimport * as monaco from 'monaco-editor/esm/vs/editor/editor.api';\nimport {\n mixinControlValueAccessor,\n mixinDisabled,\n} from '@covalent/core/common';\n\nconst noop = () => {\n // empty method\n};\n\n// counter for ids to allow for multiple editors on one page\nlet uniqueCounter = 0;\n\nexport class TdCodeEditorBase {\n constructor(public _changeDetectorRef: ChangeDetectorRef) {}\n}\n\nexport const _TdCodeEditorMixinBase = mixinControlValueAccessor(\n mixinDisabled(TdCodeEditorBase),\n []\n);\n\n@Component({\n selector: 'td-code-editor',\n templateUrl: './code-editor.component.html',\n styleUrls: ['./code-editor.component.scss'],\n providers: [\n {\n provide: NG_VALUE_ACCESSOR,\n useExisting: forwardRef(() => TdCodeEditorComponent),\n multi: true,\n },\n ],\n})\nexport class TdCodeEditorComponent\n extends _TdCodeEditorMixinBase\n implements OnInit, ControlValueAccessor, OnDestroy\n{\n private _destroy: Subject<boolean> = new Subject<boolean>();\n private _widthSubject: Subject<number> = new Subject<number>();\n private _heightSubject: Subject<number> = new Subject<number>();\n\n private _editorStyle = 'width:100%;height:100%;border:1px solid grey;';\n private _value = '';\n private _theme = 'vs';\n private _language = 'javascript';\n private _subject: Subject<string> = new Subject();\n private _editorInnerContainer: string =\n 'editorInnerContainer' + uniqueCounter++;\n private _editor!: monaco.editor.IStandaloneCodeEditor;\n private _fromEditor = false;\n private _componentInitialized = false;\n private _editorOptions: any = {};\n private _isFullScreen = false;\n private _keycode: any;\n private _registeredLanguagesStyles: HTMLStyleElement[] = [];\n private _onDidChangeContentDisposable?: monaco.IDisposable;\n\n @ViewChild('editorContainer', { static: true }) _editorContainer!: ElementRef;\n\n /**\n * editorInitialized: function($event)\n * Event emitted when editor is first initialized\n */\n @Output()\n editorInitialized: EventEmitter<monaco.editor.IStandaloneCodeEditor> = new EventEmitter<monaco.editor.IStandaloneCodeEditor>();\n\n /**\n * editorConfigurationChanged: function($event)\n * Event emitted when editor's configuration changes\n */\n @Output() editorConfigurationChanged: EventEmitter<void> =\n new EventEmitter<void>();\n\n /**\n * editorLanguageChanged: function($event)\n * Event emitted when editor's Language changes\n */\n @Output() editorLanguageChanged: EventEmitter<void> =\n new EventEmitter<void>();\n\n /**\n * editorValueChange: function($event)\n * Event emitted any time something changes the editor value\n */\n @Output() editorValueChange: EventEmitter<void> = new EventEmitter<void>();\n\n propagateChange = (_: any) => noop;\n\n /**\n * value?: string\n */\n @Input()\n override set value(value: string) {\n this._value = value;\n\n if (this._componentInitialized) {\n this.applyValue();\n }\n }\n override get value(): string {\n return this._value;\n }\n\n applyValue(): void {\n if (!this._fromEditor) {\n this._editor.setValue(this._value);\n }\n this._fromEditor = false;\n this.propagateChange(this._value);\n this.editorValueChange.emit();\n }\n\n override registerOnChange(fn: any): void {\n this.propagateChange = fn;\n }\n override registerOnTouched(fn: any): void {\n this.onTouched = fn;\n }\n\n /**\n * getEditorContent?: function\n * Returns the content within the editor\n */\n getValue(): Observable<string> {\n if (!this._componentInitialized) {\n return of('');\n }\n setTimeout(() => {\n this._subject.next(this._value);\n this._subject.complete();\n this._subject = new Subject();\n });\n return this._subject.asObservable();\n }\n\n /**\n * language?: string\n * language used in editor\n */\n @Input()\n set language(language: string) {\n this._language = language;\n if (this._componentInitialized) {\n this.applyLanguage();\n }\n }\n\n get language(): string {\n return this._language;\n }\n\n applyLanguage(): void {\n if (this._language) {\n monaco.editor.setModelLanguage(\n this._editor.getModel() as monaco.editor.ITextModel,\n this._language\n );\n this.editorLanguageChanged.emit();\n }\n }\n\n /**\n * registerLanguage?: function\n * Registers a custom Language within the editor\n */\n registerLanguage(language: any): void {\n if (this._componentInitialized) {\n monaco.languages.register({ id: language.id });\n\n monaco.languages.setMonarchTokensProvider(language.id, {\n tokenizer: {\n root: language.monarchTokensProvider,\n },\n });\n\n // Define a new theme that constains only rules that match this language\n monaco.editor.defineTheme(\n language.customTheme.id,\n language.customTheme.theme\n );\n this._theme = language.customTheme.id;\n\n monaco.languages.registerCompletionItemProvider(language.id, {\n provideCompletionItems: () => {\n return language.completionItemProvider;\n },\n });\n\n const css: HTMLStyleElement = document.createElement('style');\n css.type = 'text/css';\n css.innerHTML = language.monarchTokensProviderCSS;\n document.body.appendChild(css);\n this.editorConfigurationChanged.emit();\n this._registeredLanguagesStyles = [\n ...this._registeredLanguagesStyles,\n css,\n ];\n }\n }\n\n /**\n * style?: string\n * css style of the editor on the page\n */\n @Input()\n set editorStyle(editorStyle: string) {\n this._editorStyle = editorStyle;\n if (this._componentInitialized) {\n this.applyStyle();\n }\n }\n\n get editorStyle(): string {\n return this._editorStyle;\n }\n\n applyStyle(): void {\n if (this._editorStyle) {\n const containerDiv: HTMLDivElement = this._editorContainer.nativeElement;\n containerDiv.setAttribute('style', this._editorStyle);\n }\n }\n\n /**\n * theme?: string\n * Theme to be applied to editor\n */\n @Input()\n set theme(theme: string) {\n this._theme = theme;\n if (this._componentInitialized) {\n this._editor.updateOptions({ theme });\n this.editorConfigurationChanged.emit();\n }\n }\n get theme(): string {\n return this._theme;\n }\n\n /**\n * fullScreenKeyBinding?: number\n * See here for key bindings https://microsoft.github.io/monaco-editor/api/enums/monaco.keycode.html\n * Sets the KeyCode for shortcutting to Fullscreen mode\n */\n @Input()\n set fullScreenKeyBinding(keycode: number[]) {\n this._keycode = keycode;\n }\n get fullScreenKeyBinding(): number[] {\n return this._keycode;\n }\n\n /**\n * editorOptions?: object\n * Options used on editor instantiation. Available options listed here:\n * https://microsoft.github.io/monaco-editor/api/interfaces/editor.ieditoroptions.html\n */\n @Input()\n set editorOptions(editorOptions: any) {\n this._editorOptions = editorOptions;\n if (this._componentInitialized) {\n this._editor.updateOptions(editorOptions);\n this.editorConfigurationChanged.emit();\n }\n }\n get editorOptions(): any {\n return this._editorOptions;\n }\n\n /**\n * layout method that calls layout method of editor and instructs the editor to remeasure its container\n */\n layout(): void {\n if (this._componentInitialized) {\n this._editor.layout();\n }\n }\n\n /**\n * Returns if in Full Screen Mode or not\n */\n get isFullScreen(): boolean {\n return this._isFullScreen;\n }\n\n // tslint:disable-next-line:member-ordering\n constructor(\n _changeDetectorRef: ChangeDetectorRef,\n private _elementRef: ElementRef\n ) {\n super(_changeDetectorRef);\n }\n\n ngOnInit(): void {\n const containerDiv: HTMLDivElement = this._editorContainer.nativeElement;\n containerDiv.id = this._editorInnerContainer;\n\n this._editor = monaco.editor.create(\n containerDiv,\n Object.assign(\n {\n value: this._value,\n language: this.language,\n theme: this._theme,\n },\n this.editorOptions\n )\n );\n this._componentInitialized = true;\n setTimeout(() => {\n this.applyLanguage();\n this._fromEditor = true;\n this.applyValue();\n this.applyStyle();\n this.editorInitialized.emit(this._editor);\n this.editorConfigurationChanged.emit();\n });\n // The `onDidChangeContent` returns a disposable object (an object with `dispose()` method) which will cleanup\n // the listener. The callback, that we pass to `onDidChangeContent`, captures `this`. This leads to a circular reference\n // (`td-code-editor -> monaco -> td-code-editor`) and prevents the `td-code-editor` from being GC'd.\n this._onDidChangeContentDisposable = this._editor\n .getModel()\n ?.onDidChangeContent(() => {\n this._fromEditor = true;\n this.writeValue(this._editor.getValue());\n this.layout();\n });\n this.addFullScreenModeCommand();\n\n merge(\n fromEvent(window, 'resize').pipe(debounceTime(100)),\n this._widthSubject.asObservable().pipe(distinctUntilChanged()),\n this._heightSubject.asObservable().pipe(distinctUntilChanged())\n )\n .pipe(takeUntil(this._destroy), debounceTime(100))\n .subscribe(() => {\n this.layout();\n this._changeDetectorRef.markForCheck();\n });\n timer(500, 250)\n .pipe(takeUntil(this._destroy))\n .subscribe(() => {\n if (this._elementRef && this._elementRef.nativeElement) {\n this._widthSubject.next(\n (<HTMLElement>(\n this._elementRef.nativeElement\n )).getBoundingClientRect().width\n );\n this._heightSubject.next(\n (<HTMLElement>(\n this._elementRef.nativeElement\n )).getBoundingClientRect().height\n );\n }\n });\n }\n\n ngOnDestroy(): void {\n this._changeDetectorRef.detach();\n this._registeredLanguagesStyles.forEach((style: HTMLStyleElement) =>\n style.remove()\n );\n if (this._onDidChangeContentDisposable) {\n this._onDidChangeContentDisposable.dispose();\n this._onDidChangeContentDisposable = undefined;\n }\n if (this._editor) {\n this._editor.dispose();\n }\n this._destroy.next(true);\n this._destroy.unsubscribe();\n }\n\n /**\n * showFullScreenEditor request for full screen of Code Editor based on its browser type.\n */\n public showFullScreenEditor(): void {\n if (this._componentInitialized) {\n const codeEditorElement: HTMLDivElement = this._editorContainer\n .nativeElement as HTMLDivElement;\n codeEditorElement.requestFullscreen();\n }\n this._isFullScreen = true;\n }\n\n /**\n * exitFullScreenEditor request to exit full screen of Code Editor based on its browser type.\n */\n public exitFullScreenEditor(): void {\n if (this._componentInitialized) {\n document.exitFullscreen();\n }\n this._isFullScreen = false;\n }\n\n /**\n * addFullScreenModeCommand used to add the fullscreen option to the context menu\n */\n private addFullScreenModeCommand(): void {\n this._editor.addAction({\n // An unique identifier of the contributed action.\n id: 'fullScreen',\n // A label of the action that will be presented to the user.\n label: 'Full Screen',\n // An optional array of keybindings for the action.\n contextMenuGroupId: 'navigation',\n keybindings: this._keycode,\n contextMenuOrder: 1.5,\n // Method that will be executed when the action is triggered.\n run: () => {\n this.showFullScreenEditor();\n },\n });\n }\n}\n","<div class=\"editor-container\" #editorContainer></div>\n","import { NgModule } from '@angular/core';\n\nimport { CommonModule } from '@angular/common';\n\nimport { TdCodeEditorComponent } from './code-editor.component';\n\n@NgModule({\n imports: [CommonModule],\n declarations: [TdCodeEditorComponent],\n exports: [TdCodeEditorComponent],\n bootstrap: [TdCodeEditorComponent],\n})\nexport class CovalentCodeEditorModule {}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;;;;;;;AAwBA,MAAM,IAAI,GAAG;;AAEb,CAAC,CAAC;AAEF;AACA,IAAI,aAAa,GAAG,CAAC,CAAC;MAET,gBAAgB;IAC3B,YAAmB,kBAAqC;QAArC,uBAAkB,GAAlB,kBAAkB,CAAmB;KAAI;CAC7D;AAEM,MAAM,sBAAsB,GAAG,yBAAyB,CAC7D,aAAa,CAAC,gBAAgB,CAAC,EAC/B,EAAE,CACH,CAAC;MAcW,qBACX,SAAQ,sBAAsB;;IA4P9B,YACE,kBAAqC,EAC7B,WAAuB;QAE/B,KAAK,CAAC,kBAAkB,CAAC,CAAC;QAFlB,gBAAW,GAAX,WAAW,CAAY;QA3PzB,aAAQ,GAAqB,IAAI,OAAO,EAAW,CAAC;QACpD,kBAAa,GAAoB,IAAI,OAAO,EAAU,CAAC;QACvD,mBAAc,GAAoB,IAAI,OAAO,EAAU,CAAC;QAExD,iBAAY,GAAG,+CAA+C,CAAC;QAC/D,WAAM,GAAG,EAAE,CAAC;QACZ,WAAM,GAAG,IAAI,CAAC;QACd,cAAS,GAAG,YAAY,CAAC;QACzB,aAAQ,GAAoB,IAAI,OAAO,EAAE,CAAC;QAC1C,0BAAqB,GAC3B,sBAAsB,GAAG,aAAa,EAAE,CAAC;QAEnC,gBAAW,GAAG,KAAK,CAAC;QACpB,0BAAqB,GAAG,KAAK,CAAC;QAC9B,mBAAc,GAAQ,EAAE,CAAC;QACzB,kBAAa,GAAG,KAAK,CAAC;QAEtB,+BAA0B,GAAuB,EAAE,CAAC;;;;;QAU5D,sBAAiB,GAAsD,IAAI,YAAY,EAAuC,CAAC;;;;;QAMrH,+BAA0B,GAClC,IAAI,YAAY,EAAQ,CAAC;;;;;QAMjB,0BAAqB,GA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DACA;2FDmDa,qBAAqB;kBAZjC,SAAS;+BACE,gBAAgB,aAGf;wBACT;4BACE,OAAO,EAAE,iBAAiB;4BAC1B,WAAW,EAAE,UAAU,CAAC,2BAA2B,CAAC;4BACpD,KAAK,EAAE,IAAI;yBACZ;qBACF;iIA0B+C,gBAAgB;sBAA/D,SAAS;uBAAC,iBAAiB,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE;gBAO9C,iBAAiB;sBADhB,MAAM;gBAOG,0BAA0B;sBAAnC,MAAM;gBAOG,qBAAqB;sBAA9B,MAAM;gBAOG,iBAAiB;sBAA1B,MAAM;gBAQM,KAAK;sBADjB,KAAK;gBAiDF,QAAQ;sBADX,KAAK;gBAkEF,WAAW;sBADd,KAAK;gBAwBF,KAAK;sBADR,KAAK;gBAkBF,oBAAoB;sBADvB,KAAK;gBAcF,aAAa;sBADhB,KAAK;;;MExQK,wBAAwB;;qHAAxB,wBAAwB;sHAAxB,wBAAwB,cAFvB,qBAAqB,kBAFlB,qBAAqB,aAD1B,YAAY,aAEZ,qBAAqB;sHAGpB,wBAAwB,YAL1B,CAAC,YAAY,CAAC;2FAKZ,wBAAwB;kBANpC,QAAQ;mBAAC;oBACR,OAAO,EAAE,CAAC,YAAY,CAAC;oBACvB,YAAY,EAAE,CAAC,qBAAqB,CAAC;oBACrC,OAAO,EAAE,CAAC,qBAAqB,CAAC;oBAChC,SAAS,EAAE,CAAC,qBAAqB,CAAC;iBACnC;;;ACXD;;;;;;"}
@@ -1,9 +1,14 @@
1
- import { EventEmitter, OnInit, ElementRef, NgZone, ChangeDetectorRef, OnDestroy } from '@angular/core';
1
+ import { EventEmitter, OnInit, ElementRef, ChangeDetectorRef, OnDestroy } from '@angular/core';
2
2
  import { ControlValueAccessor } from '@angular/forms';
3
3
  import { Observable } from 'rxjs';
4
- export declare class TdCodeEditorComponent implements OnInit, ControlValueAccessor, OnDestroy {
5
- private zone;
6
- private _changeDetectorRef;
4
+ import * as monaco from 'monaco-editor/esm/vs/editor/editor.api';
5
+ import * as i0 from "@angular/core";
6
+ export declare class TdCodeEditorBase {
7
+ _changeDetectorRef: ChangeDetectorRef;
8
+ constructor(_changeDetectorRef: ChangeDetectorRef);
9
+ }
10
+ export declare const _TdCodeEditorMixinBase: (new (...args: any[]) => import("@covalent/core/common").IControlValueAccessor) & (new (...args: any[]) => import("@covalent/core/common").ICanDisable) & typeof TdCodeEditorBase;
11
+ export declare class TdCodeEditorComponent extends _TdCodeEditorMixinBase implements OnInit, ControlValueAccessor, OnDestroy {
7
12
  private _elementRef;
8
13
  private _destroy;
9
14
  private _widthSubject;
@@ -21,12 +26,13 @@ export declare class TdCodeEditorComponent implements OnInit, ControlValueAccess
21
26
  private _isFullScreen;
22
27
  private _keycode;
23
28
  private _registeredLanguagesStyles;
29
+ private _onDidChangeContentDisposable?;
24
30
  _editorContainer: ElementRef;
25
31
  /**
26
32
  * editorInitialized: function($event)
27
33
  * Event emitted when editor is first initialized
28
34
  */
29
- editorInitialized: EventEmitter<void>;
35
+ editorInitialized: EventEmitter<monaco.editor.IStandaloneCodeEditor>;
30
36
  /**
31
37
  * editorConfigurationChanged: function($event)
32
38
  * Event emitted when editor's configuration changes
@@ -42,23 +48,13 @@ export declare class TdCodeEditorComponent implements OnInit, ControlValueAccess
42
48
  * Event emitted any time something changes the editor value
43
49
  */
44
50
  editorValueChange: EventEmitter<void>;
45
- /**
46
- * The change event notifies you about a change happening in an input field.
47
- * Since the component is not a native Angular component have to specifiy the event emitter ourself
48
- */
49
- change: EventEmitter<void>;
50
- propagateChange: (_: any) => void;
51
- onTouched: () => any;
51
+ propagateChange: (_: any) => () => void;
52
52
  /**
53
53
  * value?: string
54
54
  */
55
55
  set value(value: string);
56
56
  get value(): string;
57
57
  applyValue(): void;
58
- /**
59
- * Implemented as part of ControlValueAccessor.
60
- */
61
- writeValue(value: any): void;
62
58
  registerOnChange(fn: any): void;
63
59
  registerOnTouched(fn: any): void;
64
60
  /**
@@ -101,7 +97,7 @@ export declare class TdCodeEditorComponent implements OnInit, ControlValueAccess
101
97
  /**
102
98
  * editorOptions?: object
103
99
  * Options used on editor instantiation. Available options listed here:
104
- * https://microsoft.github.io/monaco-editor/api/interfaces/monaco.editor.ieditoroptions.html
100
+ * https://microsoft.github.io/monaco-editor/api/interfaces/editor.ieditoroptions.html
105
101
  */
106
102
  set editorOptions(editorOptions: any);
107
103
  get editorOptions(): any;
@@ -113,7 +109,7 @@ export declare class TdCodeEditorComponent implements OnInit, ControlValueAccess
113
109
  * Returns if in Full Screen Mode or not
114
110
  */
115
111
  get isFullScreen(): boolean;
116
- constructor(zone: NgZone, _changeDetectorRef: ChangeDetectorRef, _elementRef: ElementRef);
112
+ constructor(_changeDetectorRef: ChangeDetectorRef, _elementRef: ElementRef);
117
113
  ngOnInit(): void;
118
114
  ngOnDestroy(): void;
119
115
  /**
@@ -128,4 +124,6 @@ export declare class TdCodeEditorComponent implements OnInit, ControlValueAccess
128
124
  * addFullScreenModeCommand used to add the fullscreen option to the context menu
129
125
  */
130
126
  private addFullScreenModeCommand;
127
+ static ɵfac: i0.ɵɵFactoryDeclaration<TdCodeEditorComponent, never>;
128
+ static ɵcmp: i0.ɵɵComponentDeclaration<TdCodeEditorComponent, "td-code-editor", never, { "value": "value"; "language": "language"; "editorStyle": "editorStyle"; "theme": "theme"; "fullScreenKeyBinding": "fullScreenKeyBinding"; "editorOptions": "editorOptions"; }, { "editorInitialized": "editorInitialized"; "editorConfigurationChanged": "editorConfigurationChanged"; "editorLanguageChanged": "editorLanguageChanged"; "editorValueChange": "editorValueChange"; }, never, never>;
131
129
  }
@@ -0,0 +1,8 @@
1
+ import * as i0 from "@angular/core";
2
+ import * as i1 from "./code-editor.component";
3
+ import * as i2 from "@angular/common";
4
+ export declare class CovalentCodeEditorModule {
5
+ static ɵfac: i0.ɵɵFactoryDeclaration<CovalentCodeEditorModule, never>;
6
+ static ɵmod: i0.ɵɵNgModuleDeclaration<CovalentCodeEditorModule, [typeof i1.TdCodeEditorComponent], [typeof i2.CommonModule], [typeof i1.TdCodeEditorComponent]>;
7
+ static ɵinj: i0.ɵɵInjectorDeclaration<CovalentCodeEditorModule>;
8
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@covalent/code-editor",
3
- "version": "4.0.0",
3
+ "version": "4.1.0-develop.10",
4
4
  "description": "Teradata UI Platform Code Editor Module",
5
5
  "keywords": [
6
6
  "angular",
@@ -17,33 +17,46 @@
17
17
  "url": "https://github.com/teradata/covalent.git"
18
18
  },
19
19
  "bugs": {
20
- "url": "https://github.com/Teradata/covalent/issues"
20
+ "url": "https://github.com/teradata/covalent/issues"
21
21
  },
22
22
  "license": "MIT",
23
23
  "author": "Teradata UX",
24
- "contributors": [
25
- "Kyle Ledbetter <kyle.ledbetter@teradata.com>",
26
- "Richa Vyas <richa.vyas@teradata.com>",
27
- "Ed Morales <eduardo.morales@teradata.com>",
28
- "Jason Weaver <jason.weaver@teradata.com>",
29
- "Jeremy Wilken <jeremy.wilken@teradata.com>",
30
- "Jeremy Smartt <jeremy.smartt@teradata.com>",
31
- "Steven Ov <steven.ov@teradata.com>"
32
- ],
24
+ "peerDependencies": {
25
+ "@angular/common": "^13.2.0",
26
+ "@angular/core": "^13.2.0",
27
+ "monaco-editor": "^0.32.1",
28
+ "@angular/forms": "^13.2.0",
29
+ "rxjs": "~7.4.0",
30
+ "@covalent/core": "4.1.0-develop.10",
31
+ "@angular/router": "^13.2.0",
32
+ "@angular/platform-browser": "^13.2.0",
33
+ "@angular/material": "^13.2.1",
34
+ "@angular/animations": "^13.2.0",
35
+ "@angular/cdk": "^13.2.1",
36
+ "@angular/platform-browser-dynamic": "^13.2.0",
37
+ "zone.js": "~0.11.4"
38
+ },
33
39
  "dependencies": {
34
- "monaco-editor": "^0.22.0",
35
40
  "tslib": "^2.0.0"
36
41
  },
37
- "peerDependencies": {
38
- "@angular/common": "^9.0.0 || ^10.0.0-0 || ^11.0.0-0",
39
- "@angular/core": "^9.0.0 || ^10.0.0-0 || ^11.0.0-0"
40
- },
41
- "main": "bundles/covalent-code-editor.umd.js",
42
- "module": "fesm2015/covalent-code-editor.js",
43
- "es2015": "fesm2015/covalent-code-editor.js",
44
- "esm2015": "esm2015/covalent-code-editor.js",
45
- "fesm2015": "fesm2015/covalent-code-editor.js",
42
+ "module": "fesm2015/covalent-code-editor.mjs",
43
+ "es2020": "fesm2020/covalent-code-editor.mjs",
44
+ "esm2020": "esm2020/covalent-code-editor.mjs",
45
+ "fesm2020": "fesm2020/covalent-code-editor.mjs",
46
+ "fesm2015": "fesm2015/covalent-code-editor.mjs",
46
47
  "typings": "covalent-code-editor.d.ts",
47
- "metadata": "covalent-code-editor.metadata.json",
48
+ "exports": {
49
+ "./package.json": {
50
+ "default": "./package.json"
51
+ },
52
+ ".": {
53
+ "types": "./covalent-code-editor.d.ts",
54
+ "esm2020": "./esm2020/covalent-code-editor.mjs",
55
+ "es2020": "./fesm2020/covalent-code-editor.mjs",
56
+ "es2015": "./fesm2015/covalent-code-editor.mjs",
57
+ "node": "./fesm2015/covalent-code-editor.mjs",
58
+ "default": "./fesm2020/covalent-code-editor.mjs"
59
+ }
60
+ },
48
61
  "sideEffects": false
49
62
  }
@@ -0,0 +1,2 @@
1
+ export { TdCodeEditorComponent } from './lib/code-editor.component';
2
+ export { CovalentCodeEditorModule } from './lib/code-editor.module';