@firestitch/text-editor 12.4.7 → 15.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/app/components/text-editor/text-editor.component.d.ts +33 -33
  2. package/app/fs-text-editor.module.d.ts +13 -13
  3. package/app/interfaces/config.interface.d.ts +7 -7
  4. package/app/modules/ngx-monaco-editor/base-editor.d.ts +19 -19
  5. package/app/modules/ngx-monaco-editor/config.d.ts +9 -9
  6. package/app/modules/ngx-monaco-editor/diff-editor.component.d.ts +17 -17
  7. package/app/modules/ngx-monaco-editor/editor.component.d.ts +23 -23
  8. package/app/modules/ngx-monaco-editor/editor.module.d.ts +12 -12
  9. package/app/modules/ngx-monaco-editor/types.d.ts +9 -9
  10. package/esm2020/app/components/text-editor/text-editor.component.mjs +146 -0
  11. package/esm2020/app/fs-text-editor.module.mjs +40 -0
  12. package/{esm2015/app/interfaces/config.interface.js → esm2020/app/interfaces/config.interface.mjs} +1 -1
  13. package/{esm2015/app/modules/ngx-monaco-editor/base-editor.js → esm2020/app/modules/ngx-monaco-editor/base-editor.mjs} +76 -76
  14. package/{esm2015/app/modules/ngx-monaco-editor/config.js → esm2020/app/modules/ngx-monaco-editor/config.mjs} +2 -2
  15. package/esm2020/app/modules/ngx-monaco-editor/diff-editor.component.mjs +77 -0
  16. package/esm2020/app/modules/ngx-monaco-editor/editor.component.mjs +106 -0
  17. package/{esm2015/app/modules/ngx-monaco-editor/editor.module.js → esm2020/app/modules/ngx-monaco-editor/editor.module.mjs} +38 -40
  18. package/{esm2015/app/modules/ngx-monaco-editor/types.js → esm2020/app/modules/ngx-monaco-editor/types.mjs} +1 -1
  19. package/{esm2015/firestitch-text-editor.js → esm2020/firestitch-text-editor.mjs} +4 -4
  20. package/{esm2015/public_api.js → esm2020/public_api.mjs} +5 -5
  21. package/fesm2015/firestitch-text-editor.mjs +471 -0
  22. package/fesm2015/firestitch-text-editor.mjs.map +1 -0
  23. package/{fesm2015/firestitch-text-editor.js → fesm2020/firestitch-text-editor.mjs} +444 -472
  24. package/fesm2020/firestitch-text-editor.mjs.map +1 -0
  25. package/{firestitch-text-editor.d.ts → index.d.ts} +5 -5
  26. package/package.json +21 -8
  27. package/public_api.d.ts +3 -3
  28. package/bundles/firestitch-text-editor.umd.js +0 -1028
  29. package/bundles/firestitch-text-editor.umd.js.map +0 -1
  30. package/esm2015/app/components/text-editor/text-editor.component.js +0 -143
  31. package/esm2015/app/fs-text-editor.module.js +0 -43
  32. package/esm2015/app/modules/ngx-monaco-editor/diff-editor.component.js +0 -91
  33. package/esm2015/app/modules/ngx-monaco-editor/editor.component.js +0 -118
  34. package/fesm2015/firestitch-text-editor.js.map +0 -1
@@ -7,493 +7,465 @@ import { fromEvent } from 'rxjs';
7
7
 
8
8
  const NGX_MONACO_EDITOR_CONFIG = new InjectionToken('NGX_MONACO_EDITOR_CONFIG');
9
9
 
10
- let loadedMonaco = false;
11
- let loadPromise;
12
- class BaseEditor {
13
- constructor(config) {
14
- this.config = config;
15
- this.onInit = new EventEmitter();
16
- }
17
- ngAfterViewInit() {
18
- if (loadedMonaco) {
19
- // Wait until monaco editor is available
20
- loadPromise.then(() => {
21
- this.initMonaco(this._options);
22
- });
23
- }
24
- else {
25
- loadedMonaco = true;
26
- loadPromise = new Promise((resolve) => {
27
- const baseUrl = `${this.config.baseUrl || './assets'}/monaco-editor/min/vs`;
28
- if (typeof (window.monaco) === 'object') {
29
- resolve();
30
- return;
31
- }
32
- const onGotAmdLoader = () => {
33
- // Load monaco
34
- window.require.config({ paths: { vs: `${baseUrl}` } });
35
- window.require(['vs/editor/editor.main'], () => {
36
- if (typeof this.config.onMonacoLoad === 'function') {
37
- this.config.onMonacoLoad();
38
- }
39
- this.initMonaco(this._options);
40
- resolve();
41
- });
42
- };
43
- // Load AMD loader if necessary
44
- if (!window.require) {
45
- const loaderScript = document.createElement('script');
46
- loaderScript.type = 'text/javascript';
47
- loaderScript.src = `${baseUrl}/loader.js`;
48
- loaderScript.addEventListener('load', onGotAmdLoader);
49
- document.body.appendChild(loaderScript);
50
- }
51
- else {
52
- onGotAmdLoader();
53
- }
54
- });
55
- }
56
- }
57
- ngOnDestroy() {
58
- if (this._windowResizeSubscription) {
59
- this._windowResizeSubscription.unsubscribe();
60
- }
61
- if (this._editor) {
62
- this._editor.dispose();
63
- this._editor = undefined;
64
- }
65
- }
66
- }
67
- BaseEditor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: BaseEditor, deps: [{ token: NGX_MONACO_EDITOR_CONFIG }], target: i0.ɵɵFactoryTarget.Component });
68
- BaseEditor.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: BaseEditor, selector: "ng-component", outputs: { onInit: "onInit" }, viewQueries: [{ propertyName: "_editorContainer", first: true, predicate: ["editorContainer"], descendants: true, static: true }], ngImport: i0, template: '', isInline: true });
69
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: BaseEditor, decorators: [{
70
- type: Component,
71
- args: [{
72
- template: '',
73
- }]
74
- }], ctorParameters: function () { return [{ type: undefined, decorators: [{
75
- type: Inject,
76
- args: [NGX_MONACO_EDITOR_CONFIG]
77
- }] }]; }, propDecorators: { _editorContainer: [{
78
- type: ViewChild,
79
- args: ['editorContainer', { static: true }]
80
- }], onInit: [{
81
- type: Output
10
+ let loadedMonaco = false;
11
+ let loadPromise;
12
+ class BaseEditor {
13
+ constructor(config) {
14
+ this.config = config;
15
+ this.onInit = new EventEmitter();
16
+ }
17
+ ngAfterViewInit() {
18
+ if (loadedMonaco) {
19
+ // Wait until monaco editor is available
20
+ loadPromise.then(() => {
21
+ this.initMonaco(this._options);
22
+ });
23
+ }
24
+ else {
25
+ loadedMonaco = true;
26
+ loadPromise = new Promise((resolve) => {
27
+ const baseUrl = `${this.config.baseUrl || './assets'}/monaco-editor/min/vs`;
28
+ if (typeof (window.monaco) === 'object') {
29
+ resolve();
30
+ return;
31
+ }
32
+ const onGotAmdLoader = () => {
33
+ // Load monaco
34
+ window.require.config({ paths: { vs: `${baseUrl}` } });
35
+ window.require(['vs/editor/editor.main'], () => {
36
+ if (typeof this.config.onMonacoLoad === 'function') {
37
+ this.config.onMonacoLoad();
38
+ }
39
+ this.initMonaco(this._options);
40
+ resolve();
41
+ });
42
+ };
43
+ // Load AMD loader if necessary
44
+ if (!window.require) {
45
+ const loaderScript = document.createElement('script');
46
+ loaderScript.type = 'text/javascript';
47
+ loaderScript.src = `${baseUrl}/loader.js`;
48
+ loaderScript.addEventListener('load', onGotAmdLoader);
49
+ document.body.appendChild(loaderScript);
50
+ }
51
+ else {
52
+ onGotAmdLoader();
53
+ }
54
+ });
55
+ }
56
+ }
57
+ ngOnDestroy() {
58
+ if (this._windowResizeSubscription) {
59
+ this._windowResizeSubscription.unsubscribe();
60
+ }
61
+ if (this._editor) {
62
+ this._editor.dispose();
63
+ this._editor = undefined;
64
+ }
65
+ }
66
+ }
67
+ BaseEditor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: BaseEditor, deps: [{ token: NGX_MONACO_EDITOR_CONFIG }], target: i0.ɵɵFactoryTarget.Component });
68
+ BaseEditor.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: BaseEditor, selector: "ng-component", outputs: { onInit: "onInit" }, viewQueries: [{ propertyName: "_editorContainer", first: true, predicate: ["editorContainer"], descendants: true, static: true }], ngImport: i0, template: '', isInline: true });
69
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: BaseEditor, decorators: [{
70
+ type: Component,
71
+ args: [{
72
+ template: '',
73
+ }]
74
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
75
+ type: Inject,
76
+ args: [NGX_MONACO_EDITOR_CONFIG]
77
+ }] }]; }, propDecorators: { _editorContainer: [{
78
+ type: ViewChild,
79
+ args: ['editorContainer', { static: true }]
80
+ }], onInit: [{
81
+ type: Output
82
82
  }] } });
83
83
 
84
- class EditorComponent extends BaseEditor {
85
- constructor(zone, editorConfig) {
86
- super(editorConfig);
87
- this.zone = zone;
88
- this.editorConfig = editorConfig;
89
- this._value = '';
90
- this.propagateChange = (_) => { };
91
- this.onTouched = () => { };
92
- }
93
- set options(options) {
94
- this._options = Object.assign(Object.assign({}, this.config.defaultOptions), options);
95
- if (this._editor) {
96
- this._editor.dispose();
97
- this.initMonaco(options);
98
- }
99
- }
100
- get options() {
101
- return this._options;
102
- }
103
- set model(model) {
104
- this.options.model = model;
105
- if (this._editor) {
106
- this._editor.dispose();
107
- this.initMonaco(this.options);
108
- }
109
- }
110
- writeValue(value) {
111
- this._value = value || '';
112
- // Fix for value change while dispose in process.
113
- setTimeout(() => {
114
- if (this._editor && !this.options.model) {
115
- this._editor.setValue(this._value);
116
- }
117
- });
118
- }
119
- registerOnChange(fn) {
120
- this.propagateChange = fn;
121
- }
122
- registerOnTouched(fn) {
123
- this.onTouched = fn;
124
- }
125
- initMonaco(options) {
126
- const hasModel = !!options.model;
127
- if (hasModel) {
128
- const model = monaco.editor.getModel(options.model.uri || '');
129
- if (model) {
130
- options.model = model;
131
- options.model.setValue(this._value);
132
- }
133
- else {
134
- options.model = monaco.editor.createModel(options.model.value, options.model.language, options.model.uri);
135
- }
136
- }
137
- this._editor = monaco.editor.create(this._editorContainer.nativeElement, options);
138
- if (!hasModel) {
139
- this._editor.setValue(this._value);
140
- }
141
- this._editor.onDidChangeModelContent((e) => {
142
- const value = this._editor.getValue();
143
- // value is not propagated to parent when executing outside zone.
144
- this.zone.run(() => {
145
- this.propagateChange(value);
146
- this._value = value;
147
- });
148
- });
149
- this._editor.onDidBlurEditorWidget(() => {
150
- this.onTouched();
151
- });
152
- // refresh layout on resize event.
153
- if (this._windowResizeSubscription) {
154
- this._windowResizeSubscription.unsubscribe();
155
- }
156
- this._windowResizeSubscription = fromEvent(window, 'resize').subscribe(() => this._editor.layout());
157
- this.onInit.emit(this._editor);
158
- }
159
- }
160
- EditorComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: EditorComponent, deps: [{ token: i0.NgZone }, { token: NGX_MONACO_EDITOR_CONFIG }], target: i0.ɵɵFactoryTarget.Component });
161
- EditorComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: EditorComponent, selector: "ngx-monaco-editor", inputs: { options: "options", model: "model" }, providers: [{
162
- provide: NG_VALUE_ACCESSOR,
163
- useExisting: forwardRef(() => EditorComponent),
164
- multi: true,
165
- }], usesInheritance: true, ngImport: i0, template: '<div class="editor-container" #editorContainer></div>', isInline: true, styles: ["\n\n\n .editor-container {\n width: 100%;\n height: 100%;\n }\n "] });
166
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: EditorComponent, decorators: [{
167
- type: Component,
168
- args: [{
169
- selector: 'ngx-monaco-editor',
170
- template: '<div class="editor-container" #editorContainer></div>',
171
- styles: [`
172
-
173
-
174
- .editor-container {
175
- width: 100%;
176
- height: 100%;
177
- }
178
- `],
179
- providers: [{
180
- provide: NG_VALUE_ACCESSOR,
181
- useExisting: forwardRef(() => EditorComponent),
182
- multi: true,
183
- }],
184
- }]
185
- }], ctorParameters: function () { return [{ type: i0.NgZone }, { type: undefined, decorators: [{
186
- type: Inject,
187
- args: [NGX_MONACO_EDITOR_CONFIG]
188
- }] }]; }, propDecorators: { options: [{
189
- type: Input,
190
- args: ['options']
191
- }], model: [{
192
- type: Input,
193
- args: ['model']
84
+ class EditorComponent extends BaseEditor {
85
+ set options(options) {
86
+ this._options = { ...this.config.defaultOptions, ...options };
87
+ if (this._editor) {
88
+ this._editor.dispose();
89
+ this.initMonaco(options);
90
+ }
91
+ }
92
+ get options() {
93
+ return this._options;
94
+ }
95
+ set model(model) {
96
+ this.options.model = model;
97
+ if (this._editor) {
98
+ this._editor.dispose();
99
+ this.initMonaco(this.options);
100
+ }
101
+ }
102
+ constructor(zone, editorConfig) {
103
+ super(editorConfig);
104
+ this.zone = zone;
105
+ this.editorConfig = editorConfig;
106
+ this._value = '';
107
+ this.propagateChange = (_) => { };
108
+ this.onTouched = () => { };
109
+ }
110
+ writeValue(value) {
111
+ this._value = value || '';
112
+ // Fix for value change while dispose in process.
113
+ setTimeout(() => {
114
+ if (this._editor && !this.options.model) {
115
+ this._editor.setValue(this._value);
116
+ }
117
+ });
118
+ }
119
+ registerOnChange(fn) {
120
+ this.propagateChange = fn;
121
+ }
122
+ registerOnTouched(fn) {
123
+ this.onTouched = fn;
124
+ }
125
+ initMonaco(options) {
126
+ const hasModel = !!options.model;
127
+ if (hasModel) {
128
+ const model = monaco.editor.getModel(options.model.uri || '');
129
+ if (model) {
130
+ options.model = model;
131
+ options.model.setValue(this._value);
132
+ }
133
+ else {
134
+ options.model = monaco.editor.createModel(options.model.value, options.model.language, options.model.uri);
135
+ }
136
+ }
137
+ this._editor = monaco.editor.create(this._editorContainer.nativeElement, options);
138
+ if (!hasModel) {
139
+ this._editor.setValue(this._value);
140
+ }
141
+ this._editor.onDidChangeModelContent((e) => {
142
+ const value = this._editor.getValue();
143
+ // value is not propagated to parent when executing outside zone.
144
+ this.zone.run(() => {
145
+ this.propagateChange(value);
146
+ this._value = value;
147
+ });
148
+ });
149
+ this._editor.onDidBlurEditorWidget(() => {
150
+ this.onTouched();
151
+ });
152
+ // refresh layout on resize event.
153
+ if (this._windowResizeSubscription) {
154
+ this._windowResizeSubscription.unsubscribe();
155
+ }
156
+ this._windowResizeSubscription = fromEvent(window, 'resize').subscribe(() => this._editor.layout());
157
+ this.onInit.emit(this._editor);
158
+ }
159
+ }
160
+ EditorComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: EditorComponent, deps: [{ token: i0.NgZone }, { token: NGX_MONACO_EDITOR_CONFIG }], target: i0.ɵɵFactoryTarget.Component });
161
+ EditorComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: EditorComponent, selector: "ngx-monaco-editor", inputs: { options: "options", model: "model" }, providers: [{
162
+ provide: NG_VALUE_ACCESSOR,
163
+ useExisting: forwardRef(() => EditorComponent),
164
+ multi: true,
165
+ }], usesInheritance: true, ngImport: i0, template: '<div class="editor-container" #editorContainer></div>', isInline: true, styles: [".editor-container{width:100%;height:100%}\n"] });
166
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: EditorComponent, decorators: [{
167
+ type: Component,
168
+ args: [{ selector: 'ngx-monaco-editor', template: '<div class="editor-container" #editorContainer></div>', providers: [{
169
+ provide: NG_VALUE_ACCESSOR,
170
+ useExisting: forwardRef(() => EditorComponent),
171
+ multi: true,
172
+ }], styles: [".editor-container{width:100%;height:100%}\n"] }]
173
+ }], ctorParameters: function () { return [{ type: i0.NgZone }, { type: undefined, decorators: [{
174
+ type: Inject,
175
+ args: [NGX_MONACO_EDITOR_CONFIG]
176
+ }] }]; }, propDecorators: { options: [{
177
+ type: Input,
178
+ args: ['options']
179
+ }], model: [{
180
+ type: Input,
181
+ args: ['model']
194
182
  }] } });
195
183
 
196
- class FsTextEditorComponent {
197
- constructor(_document) {
198
- this._document = _document;
199
- this.LINE_HEIGHT = 18;
200
- this.config = {};
201
- this.scrollable = false;
202
- this.ready = new EventEmitter();
203
- this.blur = new EventEmitter();
204
- this._value = '';
205
- this._window = this._document.defaultView;
206
- }
207
- get monaco() {
208
- return this._window.monaco;
209
- }
210
- ngOnInit() {
211
- if (this.config) {
212
- this.config = Object.assign({ minimap: {
213
- enabled: false,
214
- }, theme: 'vs-dark', automaticLayout: !!this.config.height, scrollBeyondLastLine: false, scrollbar: {
215
- vertical: this.config.height ? 'auto' : 'hidden',
216
- }, hideCursorInOverviewRuler: true }, this.config);
217
- }
218
- }
219
- ngOnDestroy() {
220
- // must be there to cleanup https://github.com/microsoft/monaco-editor/issues/827
221
- this._window.define = null;
222
- }
223
- get value() {
224
- return this._value;
225
- }
226
- onEditorInit(event) {
227
- // Timeout allows the content to fully load to and calculate height
228
- setTimeout(() => {
229
- this._editorRef = event;
230
- this._initEditor();
231
- this.ready.next(event);
232
- if (!this.scrollable && !this.config.height) {
233
- this._disableScroll();
234
- }
235
- if (this.config.ready) {
236
- this.config.ready(this._editorRef);
237
- }
238
- });
239
- }
240
- writeValue(value) {
241
- this._value = value || '';
242
- }
243
- changed(e) {
244
- if (this._value !== e) {
245
- this._value = e;
246
- this.onChange(e);
247
- }
248
- }
249
- updateLayout() {
250
- this._editorRef.layout();
251
- }
252
- registerOnChange(fn) {
253
- this.onChange = fn;
254
- }
255
- registerOnTouched(fn) {
256
- this.onTouched = fn;
257
- }
258
- _initEditor() {
259
- if (this._editorRef && !this.config.height) {
260
- this._updateEditorHeight();
261
- this._editorRef.onDidChangeModelContent((e) => {
262
- this._updateEditorHeight();
263
- });
264
- }
265
- this._editorRef.onDidBlurEditorText(() => {
266
- this.blur.next();
267
- if (this.config.blur) {
268
- this.config.blur();
269
- }
270
- });
271
- this._editorRef.onDidFocusEditorText(() => {
272
- if (this.config.focus) {
273
- this.config.focus();
274
- }
275
- });
276
- }
277
- _updateEditorHeight() {
278
- const editorDomNode = this._editorRef.getDomNode();
279
- if (!editorDomNode) {
280
- return;
281
- }
282
- const container = editorDomNode.getElementsByClassName('view-lines')[0];
283
- const lineHeight = container.firstChild
284
- ? container.firstChild.offsetHeight
285
- : this.LINE_HEIGHT;
286
- const editorModel = this._editorRef.getModel();
287
- if (!editorModel) {
288
- return;
289
- }
290
- const nextHeight = this._editorRef.getModel().getLineCount() * lineHeight;
291
- // set the height and redo layout
292
- editorDomNode.style.height = `${nextHeight}px`;
293
- this.updateLayout();
294
- }
295
- _disableScroll() {
296
- const node = this._editorRef.getDomNode();
297
- node.addEventListener('wheel', (e) => {
298
- e.stopPropagation();
299
- }, true);
300
- }
301
- }
302
- FsTextEditorComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: FsTextEditorComponent, deps: [{ token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Component });
303
- FsTextEditorComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: FsTextEditorComponent, selector: "fs-text-editor", inputs: { config: "config", scrollable: "scrollable" }, outputs: { ready: "ready", blur: "blur" }, providers: [{
304
- provide: NG_VALUE_ACCESSOR,
305
- useExisting: forwardRef(() => FsTextEditorComponent),
306
- multi: true,
307
- }], ngImport: i0, template: "<ngx-monaco-editor\n [style.height]=\"config.height\"\n [ngModel]=\"value\"\n (ngModelChange)=\"changed($event)\"\n [options]=\"config\"\n (onInit)=\"onEditorInit($event)\">\n</ngx-monaco-editor>\n", styles: ["ngx-monaco-editor{display:block}\n"], components: [{ type: EditorComponent, selector: "ngx-monaco-editor", inputs: ["options", "model"] }], directives: [{ type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i2.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }] });
308
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: FsTextEditorComponent, decorators: [{
309
- type: Component,
310
- args: [{
311
- selector: 'fs-text-editor',
312
- templateUrl: './text-editor.component.html',
313
- styleUrls: ['./text-editor.component.scss'],
314
- providers: [{
315
- provide: NG_VALUE_ACCESSOR,
316
- useExisting: forwardRef(() => FsTextEditorComponent),
317
- multi: true,
318
- }],
319
- }]
320
- }], ctorParameters: function () { return [{ type: Document, decorators: [{
321
- type: Inject,
322
- args: [DOCUMENT]
323
- }] }]; }, propDecorators: { config: [{
324
- type: Input
325
- }], scrollable: [{
326
- type: Input
327
- }], ready: [{
328
- type: Output
329
- }], blur: [{
330
- type: Output
184
+ class FsTextEditorComponent {
185
+ constructor(_document) {
186
+ this._document = _document;
187
+ this.LINE_HEIGHT = 18;
188
+ this.config = {};
189
+ this.scrollable = false;
190
+ this.ready = new EventEmitter();
191
+ this.blur = new EventEmitter();
192
+ this._value = '';
193
+ this._window = this._document.defaultView;
194
+ }
195
+ get monaco() {
196
+ return this._window.monaco;
197
+ }
198
+ ngOnInit() {
199
+ if (this.config) {
200
+ this.config = {
201
+ minimap: {
202
+ enabled: false,
203
+ },
204
+ theme: 'vs-dark',
205
+ automaticLayout: !!this.config.height,
206
+ scrollBeyondLastLine: false,
207
+ scrollbar: {
208
+ vertical: this.config.height ? 'auto' : 'hidden',
209
+ },
210
+ hideCursorInOverviewRuler: true,
211
+ ...this.config,
212
+ };
213
+ }
214
+ }
215
+ ngOnDestroy() {
216
+ // must be there to cleanup https://github.com/microsoft/monaco-editor/issues/827
217
+ this._window.define = null;
218
+ }
219
+ get value() {
220
+ return this._value;
221
+ }
222
+ onEditorInit(event) {
223
+ // Timeout allows the content to fully load to and calculate height
224
+ setTimeout(() => {
225
+ this._editorRef = event;
226
+ this._initEditor();
227
+ this.ready.next(event);
228
+ if (!this.scrollable && !this.config.height) {
229
+ this._disableScroll();
230
+ }
231
+ if (this.config.ready) {
232
+ this.config.ready(this._editorRef);
233
+ }
234
+ });
235
+ }
236
+ writeValue(value) {
237
+ this._value = value || '';
238
+ }
239
+ changed(e) {
240
+ if (this._value !== e) {
241
+ this._value = e;
242
+ this.onChange(e);
243
+ }
244
+ }
245
+ updateLayout() {
246
+ this._editorRef.layout();
247
+ }
248
+ registerOnChange(fn) {
249
+ this.onChange = fn;
250
+ }
251
+ registerOnTouched(fn) {
252
+ this.onTouched = fn;
253
+ }
254
+ _initEditor() {
255
+ if (this._editorRef && !this.config.height) {
256
+ this._updateEditorHeight();
257
+ this._editorRef.onDidChangeModelContent((e) => {
258
+ this._updateEditorHeight();
259
+ });
260
+ }
261
+ this._editorRef.onDidBlurEditorText(() => {
262
+ this.blur.next();
263
+ if (this.config.blur) {
264
+ this.config.blur();
265
+ }
266
+ });
267
+ this._editorRef.onDidFocusEditorText(() => {
268
+ if (this.config.focus) {
269
+ this.config.focus();
270
+ }
271
+ });
272
+ }
273
+ _updateEditorHeight() {
274
+ const editorDomNode = this._editorRef.getDomNode();
275
+ if (!editorDomNode) {
276
+ return;
277
+ }
278
+ const container = editorDomNode.getElementsByClassName('view-lines')[0];
279
+ const lineHeight = container.firstChild
280
+ ? container.firstChild.offsetHeight
281
+ : this.LINE_HEIGHT;
282
+ const editorModel = this._editorRef.getModel();
283
+ if (!editorModel) {
284
+ return;
285
+ }
286
+ const nextHeight = this._editorRef.getModel().getLineCount() * lineHeight;
287
+ // set the height and redo layout
288
+ editorDomNode.style.height = `${nextHeight}px`;
289
+ this.updateLayout();
290
+ }
291
+ _disableScroll() {
292
+ const node = this._editorRef.getDomNode();
293
+ node.addEventListener('wheel', (e) => {
294
+ e.stopPropagation();
295
+ }, true);
296
+ }
297
+ }
298
+ FsTextEditorComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: FsTextEditorComponent, deps: [{ token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Component });
299
+ FsTextEditorComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: FsTextEditorComponent, selector: "fs-text-editor", inputs: { config: "config", scrollable: "scrollable" }, outputs: { ready: "ready", blur: "blur" }, providers: [{
300
+ provide: NG_VALUE_ACCESSOR,
301
+ useExisting: forwardRef(() => FsTextEditorComponent),
302
+ multi: true,
303
+ }], ngImport: i0, template: "<ngx-monaco-editor\n [style.height]=\"config.height\"\n [ngModel]=\"value\"\n (ngModelChange)=\"changed($event)\"\n [options]=\"config\"\n (onInit)=\"onEditorInit($event)\">\n</ngx-monaco-editor>\n", styles: ["ngx-monaco-editor{display:block}\n"], dependencies: [{ kind: "component", type: EditorComponent, selector: "ngx-monaco-editor", inputs: ["options", "model"] }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }] });
304
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: FsTextEditorComponent, decorators: [{
305
+ type: Component,
306
+ args: [{ selector: 'fs-text-editor', providers: [{
307
+ provide: NG_VALUE_ACCESSOR,
308
+ useExisting: forwardRef(() => FsTextEditorComponent),
309
+ multi: true,
310
+ }], template: "<ngx-monaco-editor\n [style.height]=\"config.height\"\n [ngModel]=\"value\"\n (ngModelChange)=\"changed($event)\"\n [options]=\"config\"\n (onInit)=\"onEditorInit($event)\">\n</ngx-monaco-editor>\n", styles: ["ngx-monaco-editor{display:block}\n"] }]
311
+ }], ctorParameters: function () { return [{ type: Document, decorators: [{
312
+ type: Inject,
313
+ args: [DOCUMENT]
314
+ }] }]; }, propDecorators: { config: [{
315
+ type: Input
316
+ }], scrollable: [{
317
+ type: Input
318
+ }], ready: [{
319
+ type: Output
320
+ }], blur: [{
321
+ type: Output
331
322
  }] } });
332
323
 
333
- class DiffEditorComponent extends BaseEditor {
334
- constructor(editorConfig) {
335
- super(editorConfig);
336
- this.editorConfig = editorConfig;
337
- }
338
- set options(options) {
339
- this._options = Object.assign(Object.assign({}, this.config.defaultOptions), options);
340
- if (this._editor) {
341
- this._editor.dispose();
342
- this.initMonaco(options);
343
- }
344
- }
345
- get options() {
346
- return this._options;
347
- }
348
- set originalModel(model) {
349
- this._originalModel = model;
350
- if (this._editor) {
351
- this._editor.dispose();
352
- this.initMonaco(this.options);
353
- }
354
- }
355
- set modifiedModel(model) {
356
- this._modifiedModel = model;
357
- if (this._editor) {
358
- this._editor.dispose();
359
- this.initMonaco(this.options);
360
- }
361
- }
362
- initMonaco(options) {
363
- if (!this._originalModel || !this._modifiedModel) {
364
- throw new Error('originalModel or modifiedModel not found for ngx-monaco-diff-editor');
365
- }
366
- this._originalModel.language = this._originalModel.language || options.language;
367
- this._modifiedModel.language = this._modifiedModel.language || options.language;
368
- const originalModel = monaco.editor.createModel(this._originalModel.code, this._originalModel.language);
369
- const modifiedModel = monaco.editor.createModel(this._modifiedModel.code, this._modifiedModel.language);
370
- this._editorContainer.nativeElement.innerHTML = '';
371
- const theme = options.theme;
372
- this._editor = monaco.editor.createDiffEditor(this._editorContainer.nativeElement, options);
373
- options.theme = theme;
374
- this._editor.setModel({
375
- original: originalModel,
376
- modified: modifiedModel,
377
- });
378
- // refresh layout on resize event.
379
- if (this._windowResizeSubscription) {
380
- this._windowResizeSubscription.unsubscribe();
381
- }
382
- this._windowResizeSubscription = fromEvent(window, 'resize').subscribe(() => this._editor.layout());
383
- this.onInit.emit(this._editor);
384
- }
385
- }
386
- DiffEditorComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: DiffEditorComponent, deps: [{ token: NGX_MONACO_EDITOR_CONFIG }], target: i0.ɵɵFactoryTarget.Component });
387
- DiffEditorComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: DiffEditorComponent, selector: "ngx-monaco-diff-editor", inputs: { options: "options", originalModel: "originalModel", modifiedModel: "modifiedModel" }, usesInheritance: true, ngImport: i0, template: '<div class="editor-container" #editorContainer></div>', isInline: true, styles: ["\n :host {\n display: block;\n height: 200px;\n }\n\n .editor-container {\n width: 100%;\n height: 100%;\n }\n "] });
388
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: DiffEditorComponent, decorators: [{
389
- type: Component,
390
- args: [{
391
- selector: 'ngx-monaco-diff-editor',
392
- template: '<div class="editor-container" #editorContainer></div>',
393
- styles: [`
394
- :host {
395
- display: block;
396
- height: 200px;
324
+ class DiffEditorComponent extends BaseEditor {
325
+ set options(options) {
326
+ this._options = { ...this.config.defaultOptions, ...options };
327
+ if (this._editor) {
328
+ this._editor.dispose();
329
+ this.initMonaco(options);
330
+ }
397
331
  }
398
-
399
- .editor-container {
400
- width: 100%;
401
- height: 100%;
402
- }
403
- `],
404
- }]
405
- }], ctorParameters: function () { return [{ type: undefined, decorators: [{
406
- type: Inject,
407
- args: [NGX_MONACO_EDITOR_CONFIG]
408
- }] }]; }, propDecorators: { options: [{
409
- type: Input,
410
- args: ['options']
411
- }], originalModel: [{
412
- type: Input,
413
- args: ['originalModel']
414
- }], modifiedModel: [{
415
- type: Input,
416
- args: ['modifiedModel']
332
+ get options() {
333
+ return this._options;
334
+ }
335
+ set originalModel(model) {
336
+ this._originalModel = model;
337
+ if (this._editor) {
338
+ this._editor.dispose();
339
+ this.initMonaco(this.options);
340
+ }
341
+ }
342
+ set modifiedModel(model) {
343
+ this._modifiedModel = model;
344
+ if (this._editor) {
345
+ this._editor.dispose();
346
+ this.initMonaco(this.options);
347
+ }
348
+ }
349
+ constructor(editorConfig) {
350
+ super(editorConfig);
351
+ this.editorConfig = editorConfig;
352
+ }
353
+ initMonaco(options) {
354
+ if (!this._originalModel || !this._modifiedModel) {
355
+ throw new Error('originalModel or modifiedModel not found for ngx-monaco-diff-editor');
356
+ }
357
+ this._originalModel.language = this._originalModel.language || options.language;
358
+ this._modifiedModel.language = this._modifiedModel.language || options.language;
359
+ const originalModel = monaco.editor.createModel(this._originalModel.code, this._originalModel.language);
360
+ const modifiedModel = monaco.editor.createModel(this._modifiedModel.code, this._modifiedModel.language);
361
+ this._editorContainer.nativeElement.innerHTML = '';
362
+ const theme = options.theme;
363
+ this._editor = monaco.editor.createDiffEditor(this._editorContainer.nativeElement, options);
364
+ options.theme = theme;
365
+ this._editor.setModel({
366
+ original: originalModel,
367
+ modified: modifiedModel,
368
+ });
369
+ // refresh layout on resize event.
370
+ if (this._windowResizeSubscription) {
371
+ this._windowResizeSubscription.unsubscribe();
372
+ }
373
+ this._windowResizeSubscription = fromEvent(window, 'resize').subscribe(() => this._editor.layout());
374
+ this.onInit.emit(this._editor);
375
+ }
376
+ }
377
+ DiffEditorComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: DiffEditorComponent, deps: [{ token: NGX_MONACO_EDITOR_CONFIG }], target: i0.ɵɵFactoryTarget.Component });
378
+ DiffEditorComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: DiffEditorComponent, selector: "ngx-monaco-diff-editor", inputs: { options: "options", originalModel: "originalModel", modifiedModel: "modifiedModel" }, usesInheritance: true, ngImport: i0, template: '<div class="editor-container" #editorContainer></div>', isInline: true, styles: [":host{display:block;height:200px}.editor-container{width:100%;height:100%}\n"] });
379
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: DiffEditorComponent, decorators: [{
380
+ type: Component,
381
+ args: [{ selector: 'ngx-monaco-diff-editor', template: '<div class="editor-container" #editorContainer></div>', styles: [":host{display:block;height:200px}.editor-container{width:100%;height:100%}\n"] }]
382
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
383
+ type: Inject,
384
+ args: [NGX_MONACO_EDITOR_CONFIG]
385
+ }] }]; }, propDecorators: { options: [{
386
+ type: Input,
387
+ args: ['options']
388
+ }], originalModel: [{
389
+ type: Input,
390
+ args: ['originalModel']
391
+ }], modifiedModel: [{
392
+ type: Input,
393
+ args: ['modifiedModel']
417
394
  }] } });
418
395
 
419
- class MonacoEditorModule {
420
- static forRoot(config = {}) {
421
- return {
422
- ngModule: MonacoEditorModule,
423
- providers: [
424
- { provide: NGX_MONACO_EDITOR_CONFIG, useValue: config }
425
- ]
426
- };
427
- }
428
- }
429
- MonacoEditorModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MonacoEditorModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
430
- MonacoEditorModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MonacoEditorModule, declarations: [EditorComponent,
431
- DiffEditorComponent], imports: [CommonModule], exports: [EditorComponent,
432
- DiffEditorComponent] });
433
- MonacoEditorModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MonacoEditorModule, imports: [[
434
- CommonModule
435
- ]] });
436
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MonacoEditorModule, decorators: [{
437
- type: NgModule,
438
- args: [{
439
- imports: [
440
- CommonModule
441
- ],
442
- declarations: [
443
- EditorComponent,
444
- DiffEditorComponent
445
- ],
446
- exports: [
447
- EditorComponent,
448
- DiffEditorComponent
449
- ]
450
- }]
396
+ class MonacoEditorModule {
397
+ static forRoot(config = {}) {
398
+ return {
399
+ ngModule: MonacoEditorModule,
400
+ providers: [
401
+ { provide: NGX_MONACO_EDITOR_CONFIG, useValue: config }
402
+ ]
403
+ };
404
+ }
405
+ }
406
+ MonacoEditorModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MonacoEditorModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
407
+ MonacoEditorModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.10", ngImport: i0, type: MonacoEditorModule, declarations: [EditorComponent,
408
+ DiffEditorComponent], imports: [CommonModule], exports: [EditorComponent,
409
+ DiffEditorComponent] });
410
+ MonacoEditorModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MonacoEditorModule, imports: [CommonModule] });
411
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MonacoEditorModule, decorators: [{
412
+ type: NgModule,
413
+ args: [{
414
+ imports: [
415
+ CommonModule
416
+ ],
417
+ declarations: [
418
+ EditorComponent,
419
+ DiffEditorComponent
420
+ ],
421
+ exports: [
422
+ EditorComponent,
423
+ DiffEditorComponent
424
+ ]
425
+ }]
451
426
  }] });
452
427
 
453
- class FsTextEditorModule {
454
- static forRoot(config) {
455
- return {
456
- ngModule: FsTextEditorModule,
457
- providers: [
458
- MonacoEditorModule.forRoot(config).providers,
459
- ],
460
- };
461
- }
462
- }
463
- FsTextEditorModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: FsTextEditorModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
464
- FsTextEditorModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: FsTextEditorModule, declarations: [FsTextEditorComponent], imports: [CommonModule,
465
- MonacoEditorModule,
466
- FormsModule], exports: [FsTextEditorComponent] });
467
- FsTextEditorModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: FsTextEditorModule, imports: [[
468
- CommonModule,
469
- MonacoEditorModule,
470
- FormsModule,
471
- ]] });
472
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: FsTextEditorModule, decorators: [{
473
- type: NgModule,
474
- args: [{
475
- imports: [
476
- CommonModule,
477
- MonacoEditorModule,
478
- FormsModule,
479
- ],
480
- exports: [
481
- FsTextEditorComponent,
482
- ],
483
- entryComponents: [],
484
- declarations: [
485
- FsTextEditorComponent,
486
- ]
487
- }]
428
+ class FsTextEditorModule {
429
+ static forRoot(config) {
430
+ return {
431
+ ngModule: FsTextEditorModule,
432
+ providers: [
433
+ MonacoEditorModule.forRoot(config).providers,
434
+ ],
435
+ };
436
+ }
437
+ }
438
+ FsTextEditorModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: FsTextEditorModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
439
+ FsTextEditorModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.10", ngImport: i0, type: FsTextEditorModule, declarations: [FsTextEditorComponent], imports: [CommonModule,
440
+ MonacoEditorModule,
441
+ FormsModule], exports: [FsTextEditorComponent] });
442
+ FsTextEditorModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: FsTextEditorModule, imports: [CommonModule,
443
+ MonacoEditorModule,
444
+ FormsModule] });
445
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: FsTextEditorModule, decorators: [{
446
+ type: NgModule,
447
+ args: [{
448
+ imports: [
449
+ CommonModule,
450
+ MonacoEditorModule,
451
+ FormsModule,
452
+ ],
453
+ exports: [
454
+ FsTextEditorComponent,
455
+ ],
456
+ declarations: [
457
+ FsTextEditorComponent,
458
+ ]
459
+ }]
488
460
  }] });
489
461
 
490
- /*
491
- * Public API Surface of fs-menu
462
+ /*
463
+ * Public API Surface of fs-menu
492
464
  */
493
465
 
494
- /**
495
- * Generated bundle index. Do not edit.
466
+ /**
467
+ * Generated bundle index. Do not edit.
496
468
  */
497
469
 
498
470
  export { FsTextEditorComponent, FsTextEditorModule };
499
- //# sourceMappingURL=firestitch-text-editor.js.map
471
+ //# sourceMappingURL=firestitch-text-editor.mjs.map