@ng-util/monaco-editor 12.1.1 → 13.1.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.
- package/README.md +1 -0
- package/esm2020/monaco-editor-base.component.mjs +152 -0
- package/esm2020/monaco-editor-diff.component.mjs +47 -0
- package/esm2020/monaco-editor.component.mjs +102 -0
- package/esm2020/monaco-editor.config.mjs +3 -0
- package/esm2020/monaco-editor.module.mjs +27 -0
- package/{esm2015/monaco-editor.types.js → esm2020/monaco-editor.types.mjs} +0 -0
- package/esm2020/ng-util-monaco-editor.mjs +5 -0
- package/{esm2015/public-api.js → esm2020/public-api.mjs} +0 -0
- package/fesm2015/{ng-util-monaco-editor.js → ng-util-monaco-editor.mjs} +106 -78
- package/fesm2015/ng-util-monaco-editor.mjs.map +1 -0
- package/fesm2020/ng-util-monaco-editor.mjs +326 -0
- package/fesm2020/ng-util-monaco-editor.mjs.map +1 -0
- package/monaco-editor-base.component.d.ts +6 -3
- package/monaco-editor-diff.component.d.ts +5 -2
- package/monaco-editor.component.d.ts +5 -1
- package/monaco-editor.config.d.ts +1 -1
- package/monaco-editor.module.d.ts +7 -0
- package/monaco.d.ts +1603 -997
- package/ng-util-monaco-editor.d.ts +1 -1
- package/package.json +20 -8
- package/bundles/ng-util-monaco-editor.umd.js +0 -656
- package/bundles/ng-util-monaco-editor.umd.js.map +0 -1
- package/esm2015/monaco-editor-base.component.js +0 -148
- package/esm2015/monaco-editor-diff.component.js +0 -42
- package/esm2015/monaco-editor.component.js +0 -85
- package/esm2015/monaco-editor.config.js +0 -3
- package/esm2015/monaco-editor.module.js +0 -23
- package/esm2015/ng-util-monaco-editor.js +0 -6
- package/fesm2015/ng-util-monaco-editor.js.map +0 -1
- package/ng-util-monaco-editor.metadata.json +0 -1
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { InjectionToken, EventEmitter, Component, Inject, Input, Output, forwardRef, ChangeDetectionStrategy, NgModule } from '@angular/core';
|
|
2
3
|
import { NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
3
4
|
import { DOCUMENT, CommonModule } from '@angular/common';
|
|
4
5
|
import { fromEvent } from 'rxjs';
|
|
5
6
|
import { debounceTime } from 'rxjs/operators';
|
|
6
7
|
|
|
7
|
-
// tslint:disable-next-line: no-reference
|
|
8
|
-
|
|
9
8
|
const NU_MONACO_EDITOR_CONFIG = new InjectionToken('NU_MONACO_EDITOR_CONFIG');
|
|
10
9
|
|
|
11
10
|
let loadedMonaco = false;
|
|
@@ -17,11 +16,10 @@ class NuMonacoEditorBase {
|
|
|
17
16
|
this.doc = doc;
|
|
18
17
|
this.ngZone = ngZone;
|
|
19
18
|
this._resize$ = null;
|
|
20
|
-
this._disabled = false;
|
|
21
19
|
this.height = `200px`;
|
|
22
20
|
this.delay = 0;
|
|
23
21
|
this.event = new EventEmitter();
|
|
24
|
-
this._config = Object.assign({ baseUrl: 'https://
|
|
22
|
+
this._config = Object.assign({ baseUrl: 'https://cdn.jsdelivr.net/npm/monaco-editor/min' }, config);
|
|
25
23
|
this.options = this._config.defaultOptions;
|
|
26
24
|
}
|
|
27
25
|
set disabled(val) {
|
|
@@ -34,7 +32,6 @@ class NuMonacoEditorBase {
|
|
|
34
32
|
get options() {
|
|
35
33
|
return this._options;
|
|
36
34
|
}
|
|
37
|
-
initMonaco(_options, _initEvent) { }
|
|
38
35
|
notifyEvent(type, other) {
|
|
39
36
|
this.ngZone.run(() => this.event.emit(Object.assign({ type, editor: this._editor }, other)));
|
|
40
37
|
}
|
|
@@ -130,31 +127,39 @@ class NuMonacoEditorBase {
|
|
|
130
127
|
}
|
|
131
128
|
}
|
|
132
129
|
}
|
|
133
|
-
NuMonacoEditorBase
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
]
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
130
|
+
/** @nocollapse */ NuMonacoEditorBase.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NuMonacoEditorBase, deps: [{ token: i0.ElementRef }, { token: NU_MONACO_EDITOR_CONFIG }, { token: DOCUMENT }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component });
|
|
131
|
+
/** @nocollapse */ NuMonacoEditorBase.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: NuMonacoEditorBase, selector: "nu-monaco-base", inputs: { height: "height", delay: "delay", disabled: "disabled", options: "options" }, outputs: { event: "event" }, usesOnChanges: true, ngImport: i0, template: ``, isInline: true });
|
|
132
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NuMonacoEditorBase, decorators: [{
|
|
133
|
+
type: Component,
|
|
134
|
+
args: [{
|
|
135
|
+
selector: 'nu-monaco-base',
|
|
136
|
+
template: ``,
|
|
137
|
+
}]
|
|
138
|
+
}], ctorParameters: function () {
|
|
139
|
+
return [{ type: i0.ElementRef }, { type: undefined, decorators: [{
|
|
140
|
+
type: Inject,
|
|
141
|
+
args: [NU_MONACO_EDITOR_CONFIG]
|
|
142
|
+
}] }, { type: undefined, decorators: [{
|
|
143
|
+
type: Inject,
|
|
144
|
+
args: [DOCUMENT]
|
|
145
|
+
}] }, { type: i0.NgZone }];
|
|
146
|
+
}, propDecorators: { height: [{
|
|
147
|
+
type: Input
|
|
148
|
+
}], delay: [{
|
|
149
|
+
type: Input
|
|
150
|
+
}], disabled: [{
|
|
151
|
+
type: Input
|
|
152
|
+
}], options: [{
|
|
153
|
+
type: Input
|
|
154
|
+
}], event: [{
|
|
155
|
+
type: Output
|
|
156
|
+
}] } });
|
|
153
157
|
|
|
154
158
|
class NuMonacoEditorComponent extends NuMonacoEditorBase {
|
|
155
159
|
constructor() {
|
|
156
160
|
super(...arguments);
|
|
157
161
|
this._value = '';
|
|
162
|
+
this.autoFormat = true;
|
|
158
163
|
this.onChange = (_) => { };
|
|
159
164
|
this.onTouched = () => { };
|
|
160
165
|
}
|
|
@@ -174,7 +179,8 @@ class NuMonacoEditorComponent extends NuMonacoEditorBase {
|
|
|
174
179
|
options.model = monaco.editor.createModel(value || this._value, language, uri);
|
|
175
180
|
}
|
|
176
181
|
}
|
|
177
|
-
|
|
182
|
+
if (this._disabled != null)
|
|
183
|
+
options.readOnly = this._disabled;
|
|
178
184
|
const editor = (this._editor = monaco.editor.create(this.el.nativeElement, options));
|
|
179
185
|
if (!hasModel) {
|
|
180
186
|
editor.setValue(this._value);
|
|
@@ -188,10 +194,14 @@ class NuMonacoEditorComponent extends NuMonacoEditorBase {
|
|
|
188
194
|
});
|
|
189
195
|
editor.onDidBlurEditorWidget(() => this.onTouched());
|
|
190
196
|
this.registerResize();
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
197
|
+
if (this.autoFormat) {
|
|
198
|
+
editor
|
|
199
|
+
.getAction('editor.action.formatDocument')
|
|
200
|
+
.run()
|
|
201
|
+
.then(() => this.notifyEvent(initEvent ? 'init' : 're-init'));
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
this.notifyEvent(initEvent ? 'init' : 're-init');
|
|
195
205
|
}
|
|
196
206
|
writeValue(value) {
|
|
197
207
|
this._value = value || '';
|
|
@@ -210,28 +220,38 @@ class NuMonacoEditorComponent extends NuMonacoEditorBase {
|
|
|
210
220
|
this.setDisabled();
|
|
211
221
|
}
|
|
212
222
|
}
|
|
213
|
-
NuMonacoEditorComponent
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
223
|
+
/** @nocollapse */ NuMonacoEditorComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NuMonacoEditorComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
224
|
+
/** @nocollapse */ NuMonacoEditorComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: NuMonacoEditorComponent, selector: "nu-monaco-editor", inputs: { model: "model", autoFormat: "autoFormat" }, host: { properties: { "style.display": "'block'", "style.height": "height" } }, providers: [
|
|
225
|
+
{
|
|
226
|
+
provide: NG_VALUE_ACCESSOR,
|
|
227
|
+
useExisting: forwardRef((() => NuMonacoEditorComponent)),
|
|
228
|
+
multi: true,
|
|
229
|
+
},
|
|
230
|
+
], exportAs: ["nuMonacoEditor"], usesInheritance: true, ngImport: i0, template: ``, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
231
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NuMonacoEditorComponent, decorators: [{
|
|
232
|
+
type: Component,
|
|
233
|
+
args: [{
|
|
234
|
+
selector: 'nu-monaco-editor',
|
|
235
|
+
template: ``,
|
|
236
|
+
exportAs: 'nuMonacoEditor',
|
|
237
|
+
host: {
|
|
238
|
+
'[style.display]': `'block'`,
|
|
239
|
+
'[style.height]': 'height',
|
|
227
240
|
},
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
241
|
+
providers: [
|
|
242
|
+
{
|
|
243
|
+
provide: NG_VALUE_ACCESSOR,
|
|
244
|
+
useExisting: forwardRef((() => NuMonacoEditorComponent)),
|
|
245
|
+
multi: true,
|
|
246
|
+
},
|
|
247
|
+
],
|
|
248
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
249
|
+
}]
|
|
250
|
+
}], propDecorators: { model: [{
|
|
251
|
+
type: Input
|
|
252
|
+
}], autoFormat: [{
|
|
253
|
+
type: Input
|
|
254
|
+
}] } });
|
|
235
255
|
|
|
236
256
|
class NuMonacoEditorDiffComponent extends NuMonacoEditorBase {
|
|
237
257
|
get editor() {
|
|
@@ -242,7 +262,8 @@ class NuMonacoEditorDiffComponent extends NuMonacoEditorBase {
|
|
|
242
262
|
throw new Error('old or new not found for nu-monaco-diff-editor');
|
|
243
263
|
}
|
|
244
264
|
const theme = options.theme;
|
|
245
|
-
|
|
265
|
+
if (this._disabled != null)
|
|
266
|
+
options.readOnly = this._disabled;
|
|
246
267
|
const editor = (this._editor = monaco.editor.createDiffEditor(this.el.nativeElement, options));
|
|
247
268
|
options.theme = theme;
|
|
248
269
|
editor.setModel({
|
|
@@ -256,22 +277,25 @@ class NuMonacoEditorDiffComponent extends NuMonacoEditorBase {
|
|
|
256
277
|
this.notifyEvent('init');
|
|
257
278
|
}
|
|
258
279
|
}
|
|
259
|
-
NuMonacoEditorDiffComponent
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
280
|
+
/** @nocollapse */ NuMonacoEditorDiffComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NuMonacoEditorDiffComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
281
|
+
/** @nocollapse */ NuMonacoEditorDiffComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: NuMonacoEditorDiffComponent, selector: "nu-monaco-diff-editor", inputs: { old: "old", new: "new" }, host: { properties: { "style.display": "'block'", "style.height": "height" } }, exportAs: ["nuMonacoDiffEditor"], usesInheritance: true, ngImport: i0, template: ``, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
282
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NuMonacoEditorDiffComponent, decorators: [{
|
|
283
|
+
type: Component,
|
|
284
|
+
args: [{
|
|
285
|
+
selector: 'nu-monaco-diff-editor',
|
|
286
|
+
template: ``,
|
|
287
|
+
exportAs: 'nuMonacoDiffEditor',
|
|
288
|
+
host: {
|
|
289
|
+
'[style.display]': `'block'`,
|
|
290
|
+
'[style.height]': 'height',
|
|
291
|
+
},
|
|
292
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
293
|
+
}]
|
|
294
|
+
}], propDecorators: { old: [{
|
|
295
|
+
type: Input
|
|
296
|
+
}], new: [{
|
|
297
|
+
type: Input
|
|
298
|
+
}] } });
|
|
275
299
|
|
|
276
300
|
const COMPONENTS = [NuMonacoEditorComponent, NuMonacoEditorDiffComponent];
|
|
277
301
|
class NuMonacoEditorModule {
|
|
@@ -282,17 +306,21 @@ class NuMonacoEditorModule {
|
|
|
282
306
|
};
|
|
283
307
|
}
|
|
284
308
|
}
|
|
285
|
-
NuMonacoEditorModule
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
]
|
|
309
|
+
/** @nocollapse */ NuMonacoEditorModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NuMonacoEditorModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
310
|
+
/** @nocollapse */ NuMonacoEditorModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NuMonacoEditorModule, declarations: [NuMonacoEditorComponent, NuMonacoEditorDiffComponent], imports: [CommonModule], exports: [NuMonacoEditorComponent, NuMonacoEditorDiffComponent] });
|
|
311
|
+
/** @nocollapse */ NuMonacoEditorModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NuMonacoEditorModule, imports: [[CommonModule]] });
|
|
312
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NuMonacoEditorModule, decorators: [{
|
|
313
|
+
type: NgModule,
|
|
314
|
+
args: [{
|
|
315
|
+
imports: [CommonModule],
|
|
316
|
+
declarations: COMPONENTS,
|
|
317
|
+
exports: COMPONENTS,
|
|
318
|
+
}]
|
|
319
|
+
}] });
|
|
292
320
|
|
|
293
321
|
/**
|
|
294
322
|
* Generated bundle index. Do not edit.
|
|
295
323
|
*/
|
|
296
324
|
|
|
297
|
-
export { NU_MONACO_EDITOR_CONFIG, NuMonacoEditorComponent, NuMonacoEditorDiffComponent, NuMonacoEditorModule
|
|
298
|
-
//# sourceMappingURL=ng-util-monaco-editor.
|
|
325
|
+
export { NU_MONACO_EDITOR_CONFIG, NuMonacoEditorComponent, NuMonacoEditorDiffComponent, NuMonacoEditorModule };
|
|
326
|
+
//# sourceMappingURL=ng-util-monaco-editor.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ng-util-monaco-editor.mjs","sources":["../../../../packages/monaco-editor/monaco-editor.config.ts","../../../../packages/monaco-editor/monaco-editor-base.component.ts","../../../../packages/monaco-editor/monaco-editor.component.ts","../../../../packages/monaco-editor/monaco-editor-diff.component.ts","../../../../packages/monaco-editor/monaco-editor.module.ts","../../../../packages/monaco-editor/ng-util-monaco-editor.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\n\nexport const NU_MONACO_EDITOR_CONFIG = new InjectionToken('NU_MONACO_EDITOR_CONFIG');\n\nexport interface NuMonacoEditorConfig {\n /**\n * The base URL to monaco editor library assets via AMD (RequireJS), Default: `https://cdn.jsdelivr.net/npm/monaco-editor/min`\n * You can using local path, e.g.: `assets/monaco-editor/min`.\n */\n baseUrl?: string;\n /**\n * Default options when creating editors\n */\n defaultOptions?: monaco.editor.IStandaloneEditorConstructionOptions;\n /**\n * The event after the first loading of the monaco editor library is completed, use this function to extend monaco editor functionalities.\n * - @param `_monaco` equar to `window.monaco`\n */\n monacoLoad?: (_monaco: any) => void;\n /**\n * The event before the first preload of the monaco editor library is completed, use this function to set nls availableLanguages.\n */\n monacoPreLoad?: () => void;\n}\n","import { DOCUMENT } from '@angular/common';\nimport {\n AfterViewInit,\n Component,\n ElementRef,\n EventEmitter,\n Inject,\n Input,\n NgZone,\n OnChanges,\n OnDestroy,\n Output,\n SimpleChange,\n SimpleChanges,\n} from '@angular/core';\nimport { fromEvent, Subscription } from 'rxjs';\nimport { debounceTime } from 'rxjs/operators';\nimport { NuMonacoEditorConfig, NU_MONACO_EDITOR_CONFIG } from './monaco-editor.config';\nimport { NuMonacoEditorEvent, NuMonacoEditorEventType } from './monaco-editor.types';\n\nlet loadedMonaco = false;\nlet loadPromise: Promise<void>;\n\n@Component({\n selector: 'nu-monaco-base',\n template: ``,\n})\n// eslint-disable-next-line @angular-eslint/component-class-suffix\nexport abstract class NuMonacoEditorBase implements AfterViewInit, OnChanges, OnDestroy {\n protected _editor?: monaco.editor.IStandaloneCodeEditor | monaco.editor.IStandaloneDiffEditor;\n protected _options!: monaco.editor.IStandaloneEditorConstructionOptions;\n protected _resize$: Subscription | null = null;\n protected _config: NuMonacoEditorConfig;\n protected _disabled?: boolean;\n\n @Input() height = `200px`;\n @Input() delay = 0;\n @Input()\n set disabled(val: boolean | string) {\n this._disabled = typeof val === 'string' ? true : val;\n this.setDisabled();\n }\n @Input()\n set options(val: monaco.editor.IStandaloneEditorConstructionOptions) {\n this._options = { ...this._config.defaultOptions, ...val };\n }\n get options() {\n return this._options;\n }\n @Output() event = new EventEmitter<NuMonacoEditorEvent>();\n\n constructor(\n protected el: ElementRef<HTMLElement>,\n @Inject(NU_MONACO_EDITOR_CONFIG) config: NuMonacoEditorConfig,\n @Inject(DOCUMENT) protected doc: any,\n protected ngZone: NgZone,\n ) {\n this._config = { baseUrl: 'https://cdn.jsdelivr.net/npm/monaco-editor/min', ...config };\n this.options = this._config.defaultOptions!;\n }\n\n protected abstract initMonaco(_options: monaco.editor.IStandaloneEditorConstructionOptions, _initEvent: boolean): void;\n\n protected notifyEvent(type: NuMonacoEditorEventType, other?: NuMonacoEditorEvent): void {\n this.ngZone.run(() => this.event.emit({ type, editor: this._editor!, ...other }));\n }\n\n protected setDisabled(): this {\n if (this._editor) {\n (this._editor as monaco.editor.IStandaloneCodeEditor).updateOptions({ readOnly: this._disabled });\n }\n return this;\n }\n\n private init(): void {\n if (loadedMonaco) {\n loadPromise.then(() => this.initMonaco(this.options, true));\n return;\n }\n\n loadedMonaco = true;\n loadPromise = new Promise<void>((resolve: () => void, reject: (err: string) => void) => {\n const win: any = window;\n if (win == null) {\n resolve();\n return;\n }\n\n if (win.monaco) {\n resolve();\n return;\n }\n\n const baseUrl = this._config.baseUrl;\n const amdLoader = () => {\n win.require.config({ paths: { vs: `${baseUrl}/vs` } });\n if (typeof this._config.monacoPreLoad === 'function') {\n this._config.monacoPreLoad();\n }\n win.require(\n ['vs/editor/editor.main'],\n () => {\n if (typeof this._config.monacoLoad === 'function') {\n this._config.monacoLoad(win.monaco);\n }\n this.initMonaco(this.options, true);\n resolve();\n },\n () => {\n reject(`Unable to load editor/editor.main module, please check your network environment.`);\n },\n );\n };\n\n if (!win.require) {\n const loaderScript = this.doc.createElement('script') as HTMLScriptElement;\n loaderScript.type = 'text/javascript';\n loaderScript.src = `${baseUrl}/vs/loader.js`;\n loaderScript.onload = amdLoader;\n loaderScript.onerror = () => reject(`Unable to load ${loaderScript.src}, please check your network environment.`);\n this.doc.getElementsByTagName('head')[0].appendChild(loaderScript);\n } else {\n amdLoader();\n }\n }).catch(error => this.notifyEvent('load-error', { error }));\n }\n\n protected cleanResize(): this {\n if (this._resize$) {\n this._resize$.unsubscribe();\n }\n return this;\n }\n\n protected registerResize(): this {\n this.cleanResize();\n this._resize$ = fromEvent(window, 'resize')\n .pipe(debounceTime(100))\n .subscribe(() => {\n this._editor!.layout();\n this.notifyEvent('resize');\n });\n return this;\n }\n\n protected updateOptions(): void {\n if (!this._editor) return;\n this.ngZone.runOutsideAngular(() => {\n this._editor!.dispose();\n this.initMonaco(this._options, false);\n });\n }\n\n ngAfterViewInit(): void {\n this.ngZone.runOutsideAngular(() => setTimeout(() => this.init(), +this.delay));\n }\n\n ngOnChanges(changes: { [P in keyof this]?: SimpleChange } & SimpleChanges): void {\n const allKeys = Object.keys(changes);\n if (allKeys.length === 1 && allKeys[0] === 'disabled') return;\n this.updateOptions();\n }\n\n ngOnDestroy(): void {\n this.cleanResize();\n if (this._editor) {\n this._editor.dispose();\n this._editor = undefined;\n }\n }\n}\n","import { ChangeDetectionStrategy, Component, forwardRef, Input } from '@angular/core';\nimport { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';\nimport { NuMonacoEditorBase } from './monaco-editor-base.component';\nimport { NuMonacoEditorModel } from './monaco-editor.types';\n\n@Component({\n selector: 'nu-monaco-editor',\n template: ``,\n exportAs: 'nuMonacoEditor',\n host: {\n '[style.display]': `'block'`,\n '[style.height]': 'height',\n },\n providers: [\n {\n provide: NG_VALUE_ACCESSOR,\n useExisting: forwardRef(() => NuMonacoEditorComponent),\n multi: true,\n },\n ],\n changeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class NuMonacoEditorComponent extends NuMonacoEditorBase implements ControlValueAccessor {\n private _value = '';\n\n @Input() model?: NuMonacoEditorModel | null;\n @Input() autoFormat = true;\n\n get editor(): monaco.editor.IStandaloneCodeEditor {\n return this._editor as monaco.editor.IStandaloneCodeEditor;\n }\n\n private onChange = (_: string) => {};\n private onTouched = () => {};\n\n initMonaco(options: monaco.editor.IStandaloneEditorConstructionOptions, initEvent: boolean): void {\n const hasModel = !!this.model;\n\n if (hasModel) {\n const model = monaco.editor.getModel(this.model!.uri! || '');\n if (model) {\n options.model = model;\n options.model.setValue(this._value);\n } else {\n const { value, language, uri } = this.model!;\n options.model = monaco.editor.createModel(value || this._value, language, uri);\n }\n }\n\n if (this._disabled != null) options.readOnly = this._disabled;\n const editor = (this._editor = monaco.editor.create(this.el.nativeElement, options));\n\n if (!hasModel) {\n editor.setValue(this._value);\n }\n\n editor.onDidChangeModelContent(() => {\n const value = editor.getValue();\n\n this.ngZone.run(() => {\n this._value = value;\n this.onChange(value);\n });\n });\n editor.onDidBlurEditorWidget(() => this.onTouched());\n\n this.registerResize();\n\n if (this.autoFormat) {\n editor\n .getAction('editor.action.formatDocument')\n .run()\n .then(() => this.notifyEvent(initEvent ? 'init' : 're-init'));\n return;\n }\n this.notifyEvent(initEvent ? 'init' : 're-init');\n }\n\n writeValue(value: string): void {\n this._value = value || '';\n if (this._editor) {\n (this._editor as monaco.editor.IStandaloneCodeEditor).setValue(this._value);\n }\n }\n\n registerOnChange(fn: (_: string) => void): void {\n this.onChange = fn;\n }\n\n registerOnTouched(fn: any): void {\n this.onTouched = fn;\n }\n\n setDisabledState(_isDisabled: boolean): void {\n this.disabled = _isDisabled;\n this.setDisabled();\n }\n}\n","import { ChangeDetectionStrategy, Component, Input } from '@angular/core';\nimport { NuMonacoEditorBase } from './monaco-editor-base.component';\nimport { NuMonacoEditorDiffModel } from './monaco-editor.types';\n\n@Component({\n selector: 'nu-monaco-diff-editor',\n template: ``,\n exportAs: 'nuMonacoDiffEditor',\n host: {\n '[style.display]': `'block'`,\n '[style.height]': 'height',\n },\n changeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class NuMonacoEditorDiffComponent extends NuMonacoEditorBase {\n @Input() old!: NuMonacoEditorDiffModel | null;\n @Input() new!: NuMonacoEditorDiffModel | null;\n\n get editor(): monaco.editor.IStandaloneDiffEditor {\n return this._editor as monaco.editor.IStandaloneDiffEditor;\n }\n\n initMonaco(options: monaco.editor.IStandaloneEditorConstructionOptions, initEvent: boolean): void {\n if (!this.old || !this.new) {\n throw new Error('old or new not found for nu-monaco-diff-editor');\n }\n\n const theme = options.theme;\n if (this._disabled != null) options.readOnly = this._disabled;\n const editor = (this._editor = monaco.editor.createDiffEditor(this.el.nativeElement, options));\n options.theme = theme;\n editor.setModel({\n original: monaco.editor.createModel(this.old.code, this.old.language || options.language),\n modified: monaco.editor.createModel(this.new.code, this.new.language || options.language),\n });\n\n // this.setDisabled();\n editor.onDidUpdateDiff(() => this.notifyEvent('update-diff', { diffValue: editor.getModifiedEditor().getValue() }));\n\n this.registerResize();\n if (initEvent) this.notifyEvent('init');\n }\n}\n","import { CommonModule } from '@angular/common';\nimport { ModuleWithProviders, NgModule } from '@angular/core';\nimport { NuMonacoEditorDiffComponent } from './monaco-editor-diff.component';\nimport { NuMonacoEditorComponent } from './monaco-editor.component';\nimport { NuMonacoEditorConfig, NU_MONACO_EDITOR_CONFIG } from './monaco-editor.config';\n\nconst COMPONENTS = [NuMonacoEditorComponent, NuMonacoEditorDiffComponent];\n\n@NgModule({\n imports: [CommonModule],\n declarations: COMPONENTS,\n exports: COMPONENTS,\n})\nexport class NuMonacoEditorModule {\n static forRoot(config?: NuMonacoEditorConfig): ModuleWithProviders<NuMonacoEditorModule> {\n return {\n ngModule: NuMonacoEditorModule,\n providers: [{ provide: NU_MONACO_EDITOR_CONFIG, useValue: config }],\n };\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;MAEa,uBAAuB,GAAG,IAAI,cAAc,CAAC,yBAAyB;;ACkBnF,IAAI,YAAY,GAAG,KAAK,CAAC;AACzB,IAAI,WAA0B,CAAC;AAM/B;MACsB,kBAAkB;IAuBtC,YACY,EAA2B,EACJ,MAA4B,EACjC,GAAQ,EAC1B,MAAc;QAHd,OAAE,GAAF,EAAE,CAAyB;QAET,QAAG,GAAH,GAAG,CAAK;QAC1B,WAAM,GAAN,MAAM,CAAQ;QAxBhB,aAAQ,GAAwB,IAAI,CAAC;QAItC,WAAM,GAAG,OAAO,CAAC;QACjB,UAAK,GAAG,CAAC,CAAC;QAaT,UAAK,GAAG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EAAE,uBAAuB;oBACjC,QAAQ,EAAE,EAAE;oBACZ,QAAQ,EAAE,oBAAoB;oBAC9B,IAAI,EAAE;wBACJ,iBAAiB,EAAE,SAAS;wBAC5B,gBAAgB,EAAE,QAAQ;qBAC3B;oBACD,eAAe,EAAE,uBAAuB,CAAC,MAAM;iBAChD;8BAEU,GAAG;sBAAX,KAAK;gBACG,GAAG;sBAAX,KAAK;;;ACVR,MAAM,UAAU,GAAG,CAAC,uBAAuB,EAAE,2BAA2B,CAAC,CAAC;MAO7D,oBAAoB;IAC/B,OAAO,OAAO,CAAC,MAA6B;QAC1C,OAAO;YACL,QAAQ,EAAE,oBAAoB;YAC9B,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,uBAAuB,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;SACpE,CAAC;KACH;;qIANU,oBAAoB;sIAApB,oBAAoB,iBAPb,uBAAuB,EAAE,2BAA2B,aAG5D,YAAY,aAHJ,uBAAuB,EAAE,2BAA2B;sIAO3D,oBAAoB,YAJtB,CAAC,YAAY,CAAC;4FAIZ,oBAAoB;kBALhC,QAAQ;mBAAC;oBACR,OAAO,EAAE,CAAC,YAAY,CAAC;oBACvB,YAAY,EAAE,UAAU;oBACxB,OAAO,EAAE,UAAU;iBACpB;;;ACZD;;;;;;"}
|
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { InjectionToken, EventEmitter, Component, Inject, Input, Output, forwardRef, ChangeDetectionStrategy, NgModule } from '@angular/core';
|
|
3
|
+
import { NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
4
|
+
import { DOCUMENT, CommonModule } from '@angular/common';
|
|
5
|
+
import { fromEvent } from 'rxjs';
|
|
6
|
+
import { debounceTime } from 'rxjs/operators';
|
|
7
|
+
|
|
8
|
+
// tslint:disable-next-line: no-reference
|
|
9
|
+
|
|
10
|
+
const NU_MONACO_EDITOR_CONFIG = new InjectionToken('NU_MONACO_EDITOR_CONFIG');
|
|
11
|
+
|
|
12
|
+
let loadedMonaco = false;
|
|
13
|
+
let loadPromise;
|
|
14
|
+
// eslint-disable-next-line @angular-eslint/component-class-suffix
|
|
15
|
+
class NuMonacoEditorBase {
|
|
16
|
+
constructor(el, config, doc, ngZone) {
|
|
17
|
+
this.el = el;
|
|
18
|
+
this.doc = doc;
|
|
19
|
+
this.ngZone = ngZone;
|
|
20
|
+
this._resize$ = null;
|
|
21
|
+
this.height = `200px`;
|
|
22
|
+
this.delay = 0;
|
|
23
|
+
this.event = new EventEmitter();
|
|
24
|
+
this._config = { baseUrl: 'https://cdn.jsdelivr.net/npm/monaco-editor/min', ...config };
|
|
25
|
+
this.options = this._config.defaultOptions;
|
|
26
|
+
}
|
|
27
|
+
set disabled(val) {
|
|
28
|
+
this._disabled = typeof val === 'string' ? true : val;
|
|
29
|
+
this.setDisabled();
|
|
30
|
+
}
|
|
31
|
+
set options(val) {
|
|
32
|
+
this._options = { ...this._config.defaultOptions, ...val };
|
|
33
|
+
}
|
|
34
|
+
get options() {
|
|
35
|
+
return this._options;
|
|
36
|
+
}
|
|
37
|
+
notifyEvent(type, other) {
|
|
38
|
+
this.ngZone.run(() => this.event.emit({ type, editor: this._editor, ...other }));
|
|
39
|
+
}
|
|
40
|
+
setDisabled() {
|
|
41
|
+
if (this._editor) {
|
|
42
|
+
this._editor.updateOptions({ readOnly: this._disabled });
|
|
43
|
+
}
|
|
44
|
+
return this;
|
|
45
|
+
}
|
|
46
|
+
init() {
|
|
47
|
+
if (loadedMonaco) {
|
|
48
|
+
loadPromise.then(() => this.initMonaco(this.options, true));
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
loadedMonaco = true;
|
|
52
|
+
loadPromise = new Promise((resolve, reject) => {
|
|
53
|
+
const win = window;
|
|
54
|
+
if (win == null) {
|
|
55
|
+
resolve();
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (win.monaco) {
|
|
59
|
+
resolve();
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const baseUrl = this._config.baseUrl;
|
|
63
|
+
const amdLoader = () => {
|
|
64
|
+
win.require.config({ paths: { vs: `${baseUrl}/vs` } });
|
|
65
|
+
if (typeof this._config.monacoPreLoad === 'function') {
|
|
66
|
+
this._config.monacoPreLoad();
|
|
67
|
+
}
|
|
68
|
+
win.require(['vs/editor/editor.main'], () => {
|
|
69
|
+
if (typeof this._config.monacoLoad === 'function') {
|
|
70
|
+
this._config.monacoLoad(win.monaco);
|
|
71
|
+
}
|
|
72
|
+
this.initMonaco(this.options, true);
|
|
73
|
+
resolve();
|
|
74
|
+
}, () => {
|
|
75
|
+
reject(`Unable to load editor/editor.main module, please check your network environment.`);
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
if (!win.require) {
|
|
79
|
+
const loaderScript = this.doc.createElement('script');
|
|
80
|
+
loaderScript.type = 'text/javascript';
|
|
81
|
+
loaderScript.src = `${baseUrl}/vs/loader.js`;
|
|
82
|
+
loaderScript.onload = amdLoader;
|
|
83
|
+
loaderScript.onerror = () => reject(`Unable to load ${loaderScript.src}, please check your network environment.`);
|
|
84
|
+
this.doc.getElementsByTagName('head')[0].appendChild(loaderScript);
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
amdLoader();
|
|
88
|
+
}
|
|
89
|
+
}).catch(error => this.notifyEvent('load-error', { error }));
|
|
90
|
+
}
|
|
91
|
+
cleanResize() {
|
|
92
|
+
if (this._resize$) {
|
|
93
|
+
this._resize$.unsubscribe();
|
|
94
|
+
}
|
|
95
|
+
return this;
|
|
96
|
+
}
|
|
97
|
+
registerResize() {
|
|
98
|
+
this.cleanResize();
|
|
99
|
+
this._resize$ = fromEvent(window, 'resize')
|
|
100
|
+
.pipe(debounceTime(100))
|
|
101
|
+
.subscribe(() => {
|
|
102
|
+
this._editor.layout();
|
|
103
|
+
this.notifyEvent('resize');
|
|
104
|
+
});
|
|
105
|
+
return this;
|
|
106
|
+
}
|
|
107
|
+
updateOptions() {
|
|
108
|
+
if (!this._editor)
|
|
109
|
+
return;
|
|
110
|
+
this.ngZone.runOutsideAngular(() => {
|
|
111
|
+
this._editor.dispose();
|
|
112
|
+
this.initMonaco(this._options, false);
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
ngAfterViewInit() {
|
|
116
|
+
this.ngZone.runOutsideAngular(() => setTimeout(() => this.init(), +this.delay));
|
|
117
|
+
}
|
|
118
|
+
ngOnChanges(changes) {
|
|
119
|
+
const allKeys = Object.keys(changes);
|
|
120
|
+
if (allKeys.length === 1 && allKeys[0] === 'disabled')
|
|
121
|
+
return;
|
|
122
|
+
this.updateOptions();
|
|
123
|
+
}
|
|
124
|
+
ngOnDestroy() {
|
|
125
|
+
this.cleanResize();
|
|
126
|
+
if (this._editor) {
|
|
127
|
+
this._editor.dispose();
|
|
128
|
+
this._editor = undefined;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
/** @nocollapse */ NuMonacoEditorBase.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NuMonacoEditorBase, deps: [{ token: i0.ElementRef }, { token: NU_MONACO_EDITOR_CONFIG }, { token: DOCUMENT }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component });
|
|
133
|
+
/** @nocollapse */ NuMonacoEditorBase.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: NuMonacoEditorBase, selector: "nu-monaco-base", inputs: { height: "height", delay: "delay", disabled: "disabled", options: "options" }, outputs: { event: "event" }, usesOnChanges: true, ngImport: i0, template: ``, isInline: true });
|
|
134
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NuMonacoEditorBase, decorators: [{
|
|
135
|
+
type: Component,
|
|
136
|
+
args: [{
|
|
137
|
+
selector: 'nu-monaco-base',
|
|
138
|
+
template: ``,
|
|
139
|
+
}]
|
|
140
|
+
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: undefined, decorators: [{
|
|
141
|
+
type: Inject,
|
|
142
|
+
args: [NU_MONACO_EDITOR_CONFIG]
|
|
143
|
+
}] }, { type: undefined, decorators: [{
|
|
144
|
+
type: Inject,
|
|
145
|
+
args: [DOCUMENT]
|
|
146
|
+
}] }, { type: i0.NgZone }]; }, propDecorators: { height: [{
|
|
147
|
+
type: Input
|
|
148
|
+
}], delay: [{
|
|
149
|
+
type: Input
|
|
150
|
+
}], disabled: [{
|
|
151
|
+
type: Input
|
|
152
|
+
}], options: [{
|
|
153
|
+
type: Input
|
|
154
|
+
}], event: [{
|
|
155
|
+
type: Output
|
|
156
|
+
}] } });
|
|
157
|
+
|
|
158
|
+
class NuMonacoEditorComponent extends NuMonacoEditorBase {
|
|
159
|
+
constructor() {
|
|
160
|
+
super(...arguments);
|
|
161
|
+
this._value = '';
|
|
162
|
+
this.autoFormat = true;
|
|
163
|
+
this.onChange = (_) => { };
|
|
164
|
+
this.onTouched = () => { };
|
|
165
|
+
}
|
|
166
|
+
get editor() {
|
|
167
|
+
return this._editor;
|
|
168
|
+
}
|
|
169
|
+
initMonaco(options, initEvent) {
|
|
170
|
+
const hasModel = !!this.model;
|
|
171
|
+
if (hasModel) {
|
|
172
|
+
const model = monaco.editor.getModel(this.model.uri || '');
|
|
173
|
+
if (model) {
|
|
174
|
+
options.model = model;
|
|
175
|
+
options.model.setValue(this._value);
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
const { value, language, uri } = this.model;
|
|
179
|
+
options.model = monaco.editor.createModel(value || this._value, language, uri);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
if (this._disabled != null)
|
|
183
|
+
options.readOnly = this._disabled;
|
|
184
|
+
const editor = (this._editor = monaco.editor.create(this.el.nativeElement, options));
|
|
185
|
+
if (!hasModel) {
|
|
186
|
+
editor.setValue(this._value);
|
|
187
|
+
}
|
|
188
|
+
editor.onDidChangeModelContent(() => {
|
|
189
|
+
const value = editor.getValue();
|
|
190
|
+
this.ngZone.run(() => {
|
|
191
|
+
this._value = value;
|
|
192
|
+
this.onChange(value);
|
|
193
|
+
});
|
|
194
|
+
});
|
|
195
|
+
editor.onDidBlurEditorWidget(() => this.onTouched());
|
|
196
|
+
this.registerResize();
|
|
197
|
+
if (this.autoFormat) {
|
|
198
|
+
editor
|
|
199
|
+
.getAction('editor.action.formatDocument')
|
|
200
|
+
.run()
|
|
201
|
+
.then(() => this.notifyEvent(initEvent ? 'init' : 're-init'));
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
this.notifyEvent(initEvent ? 'init' : 're-init');
|
|
205
|
+
}
|
|
206
|
+
writeValue(value) {
|
|
207
|
+
this._value = value || '';
|
|
208
|
+
if (this._editor) {
|
|
209
|
+
this._editor.setValue(this._value);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
registerOnChange(fn) {
|
|
213
|
+
this.onChange = fn;
|
|
214
|
+
}
|
|
215
|
+
registerOnTouched(fn) {
|
|
216
|
+
this.onTouched = fn;
|
|
217
|
+
}
|
|
218
|
+
setDisabledState(_isDisabled) {
|
|
219
|
+
this.disabled = _isDisabled;
|
|
220
|
+
this.setDisabled();
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
/** @nocollapse */ NuMonacoEditorComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NuMonacoEditorComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
224
|
+
/** @nocollapse */ NuMonacoEditorComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: NuMonacoEditorComponent, selector: "nu-monaco-editor", inputs: { model: "model", autoFormat: "autoFormat" }, host: { properties: { "style.display": "'block'", "style.height": "height" } }, providers: [
|
|
225
|
+
{
|
|
226
|
+
provide: NG_VALUE_ACCESSOR,
|
|
227
|
+
useExisting: forwardRef((() => NuMonacoEditorComponent)),
|
|
228
|
+
multi: true,
|
|
229
|
+
},
|
|
230
|
+
], exportAs: ["nuMonacoEditor"], usesInheritance: true, ngImport: i0, template: ``, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
231
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NuMonacoEditorComponent, decorators: [{
|
|
232
|
+
type: Component,
|
|
233
|
+
args: [{
|
|
234
|
+
selector: 'nu-monaco-editor',
|
|
235
|
+
template: ``,
|
|
236
|
+
exportAs: 'nuMonacoEditor',
|
|
237
|
+
host: {
|
|
238
|
+
'[style.display]': `'block'`,
|
|
239
|
+
'[style.height]': 'height',
|
|
240
|
+
},
|
|
241
|
+
providers: [
|
|
242
|
+
{
|
|
243
|
+
provide: NG_VALUE_ACCESSOR,
|
|
244
|
+
useExisting: forwardRef((() => NuMonacoEditorComponent)),
|
|
245
|
+
multi: true,
|
|
246
|
+
},
|
|
247
|
+
],
|
|
248
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
249
|
+
}]
|
|
250
|
+
}], propDecorators: { model: [{
|
|
251
|
+
type: Input
|
|
252
|
+
}], autoFormat: [{
|
|
253
|
+
type: Input
|
|
254
|
+
}] } });
|
|
255
|
+
|
|
256
|
+
class NuMonacoEditorDiffComponent extends NuMonacoEditorBase {
|
|
257
|
+
get editor() {
|
|
258
|
+
return this._editor;
|
|
259
|
+
}
|
|
260
|
+
initMonaco(options, initEvent) {
|
|
261
|
+
if (!this.old || !this.new) {
|
|
262
|
+
throw new Error('old or new not found for nu-monaco-diff-editor');
|
|
263
|
+
}
|
|
264
|
+
const theme = options.theme;
|
|
265
|
+
if (this._disabled != null)
|
|
266
|
+
options.readOnly = this._disabled;
|
|
267
|
+
const editor = (this._editor = monaco.editor.createDiffEditor(this.el.nativeElement, options));
|
|
268
|
+
options.theme = theme;
|
|
269
|
+
editor.setModel({
|
|
270
|
+
original: monaco.editor.createModel(this.old.code, this.old.language || options.language),
|
|
271
|
+
modified: monaco.editor.createModel(this.new.code, this.new.language || options.language),
|
|
272
|
+
});
|
|
273
|
+
// this.setDisabled();
|
|
274
|
+
editor.onDidUpdateDiff(() => this.notifyEvent('update-diff', { diffValue: editor.getModifiedEditor().getValue() }));
|
|
275
|
+
this.registerResize();
|
|
276
|
+
if (initEvent)
|
|
277
|
+
this.notifyEvent('init');
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
/** @nocollapse */ NuMonacoEditorDiffComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NuMonacoEditorDiffComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
281
|
+
/** @nocollapse */ NuMonacoEditorDiffComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: NuMonacoEditorDiffComponent, selector: "nu-monaco-diff-editor", inputs: { old: "old", new: "new" }, host: { properties: { "style.display": "'block'", "style.height": "height" } }, exportAs: ["nuMonacoDiffEditor"], usesInheritance: true, ngImport: i0, template: ``, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
282
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NuMonacoEditorDiffComponent, decorators: [{
|
|
283
|
+
type: Component,
|
|
284
|
+
args: [{
|
|
285
|
+
selector: 'nu-monaco-diff-editor',
|
|
286
|
+
template: ``,
|
|
287
|
+
exportAs: 'nuMonacoDiffEditor',
|
|
288
|
+
host: {
|
|
289
|
+
'[style.display]': `'block'`,
|
|
290
|
+
'[style.height]': 'height',
|
|
291
|
+
},
|
|
292
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
293
|
+
}]
|
|
294
|
+
}], propDecorators: { old: [{
|
|
295
|
+
type: Input
|
|
296
|
+
}], new: [{
|
|
297
|
+
type: Input
|
|
298
|
+
}] } });
|
|
299
|
+
|
|
300
|
+
const COMPONENTS = [NuMonacoEditorComponent, NuMonacoEditorDiffComponent];
|
|
301
|
+
class NuMonacoEditorModule {
|
|
302
|
+
static forRoot(config) {
|
|
303
|
+
return {
|
|
304
|
+
ngModule: NuMonacoEditorModule,
|
|
305
|
+
providers: [{ provide: NU_MONACO_EDITOR_CONFIG, useValue: config }],
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
/** @nocollapse */ NuMonacoEditorModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NuMonacoEditorModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
310
|
+
/** @nocollapse */ NuMonacoEditorModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NuMonacoEditorModule, declarations: [NuMonacoEditorComponent, NuMonacoEditorDiffComponent], imports: [CommonModule], exports: [NuMonacoEditorComponent, NuMonacoEditorDiffComponent] });
|
|
311
|
+
/** @nocollapse */ NuMonacoEditorModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NuMonacoEditorModule, imports: [[CommonModule]] });
|
|
312
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NuMonacoEditorModule, decorators: [{
|
|
313
|
+
type: NgModule,
|
|
314
|
+
args: [{
|
|
315
|
+
imports: [CommonModule],
|
|
316
|
+
declarations: COMPONENTS,
|
|
317
|
+
exports: COMPONENTS,
|
|
318
|
+
}]
|
|
319
|
+
}] });
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* Generated bundle index. Do not edit.
|
|
323
|
+
*/
|
|
324
|
+
|
|
325
|
+
export { NU_MONACO_EDITOR_CONFIG, NuMonacoEditorComponent, NuMonacoEditorDiffComponent, NuMonacoEditorModule };
|
|
326
|
+
//# sourceMappingURL=ng-util-monaco-editor.mjs.map
|