@ng-util/monaco-editor 21.0.0 → 21.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 CHANGED
@@ -14,7 +14,6 @@ Monaco Code Editor for Angular.
14
14
  ## Demo
15
15
 
16
16
  - [Stackblitz](https://stackblitz.com/edit/ng-util-monaco-editor?file=src/app/app.component.ts)
17
- - [Codesandbox](https://codesandbox.io/s/ng-util-monaco-editor-0m474?file=/src/app/app.component.ts)
18
17
 
19
18
  ## Usage
20
19
 
@@ -26,73 +25,30 @@ Install from npm repository:
26
25
  npm install @ng-util/monaco-editor --save
27
26
  ```
28
27
 
29
- **Configure monaco-editor library**
30
-
31
- Currently this library only supports load monaco-editor with AMD mode. The default is to use cdn (`https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.20.0/min`) lazy loading。
32
-
33
- If you are using local monaco editor library, you could add the following:
34
-
35
- ```
36
- "assets": [
37
- {
38
- "glob": "**/*",
39
- "input": "node_modules/monaco-editor/min/vs",
40
- "output": "/lib/vs"
41
- }
42
- ],
43
- ```
44
-
45
- And configure `baseUrl` via `NuMonacoEditorModule.forRoot`.
46
-
47
- ```ts
48
- NuMonacoEditorModule.forRoot({
49
- baseUrl: `lib`,
50
- }),
51
- ```
52
-
53
28
  ### Sample
54
29
 
55
- Include `NuMonacoEditorModule` in Main Module and Feature Modules where you want to use the editor component.(eg: app.module.ts):
56
-
57
- ```ts
58
- import { NgModule } from '@angular/core';
59
- import { NuMonacoEditorModule } from '@ng-util/monaco-editor';
60
-
61
- @NgModule({
62
- imports: [
63
- NuMonacoEditorModule // And use `provideNuMonacoEditorConfig` to modify the global configuration
64
- ],
65
- })
66
- export class AppModule { }
67
- ```
68
-
69
- Create Editor options in component.
70
-
71
30
  ```ts
72
31
  import { Component } from '@angular/core';
32
+ import {
33
+ NuMonacoEditorComponent,
34
+ NuMonacoEditorDiffComponent,
35
+ NuMonacoEditorDiffModel,
36
+ NuMonacoEditorEvent,
37
+ NuMonacoEditorModel
38
+ } from '@ng-util/monaco-editor';
73
39
 
74
40
  @Component({
75
41
  selector: 'app-root',
76
- template: `<nu-monaco-editor [(ngModel)]="value" [options]="editorOptions"></nu-monaco-editor>`,
42
+ template: `
43
+ <nu-monaco-editor [(ngModel)]="value" [options]="editorOptions" />
44
+ <h2>Diff</h2>
45
+ <nu-monaco-diff-editor [options]="editorOptions" [old]="old" [new]="new" />
46
+ `,
47
+ imports: [NuMonacoEditorComponent, NuMonacoEditorDiffComponent]
77
48
  })
78
49
  export class DemoComponent {
79
50
  value: string = 'const a = 1;';
80
51
  editorOptions = { theme: 'vs-dark', language: 'typescript' };
81
- }
82
- ```
83
-
84
- Or monaco diff editor:
85
-
86
- ```ts
87
- import { Component } from '@angular/core';
88
- import { NuMonacoEditorDiffModel } from '@ng-util/monaco-editor';
89
-
90
- @Component({
91
- selector: 'app-root',
92
- template: `<nu-monaco-diff-editor [options]="editorOptions" [old]="old" [new]="new"></nu-monaco-diff-editor>`,
93
- })
94
- export class DemoComponent {
95
- editorOptions = { theme: 'vs-dark', language: 'javascript' };
96
52
  old: NuMonacoEditorDiffModel = { code: `<p>1</p>` };
97
53
  new: NuMonacoEditorDiffModel = { code: `<p>2</p>` };
98
54
  }
@@ -124,10 +80,10 @@ export class DemoComponent {
124
80
 
125
81
  ### Configurations
126
82
 
127
- `forRoot()` method of `NuMonacoEditorModule` accepts config of type `NuMonacoEditorConfig`.
83
+ `provideNuMonacoEditorConfig` accepts config of type `NuMonacoEditorConfig`.
128
84
 
129
85
  ```ts
130
- NuMonacoEditorModule.forRoot({
86
+ provideNuMonacoEditorConfig({
131
87
  baseUrl: ``, // The base URL to monaco editor library assets via AMD (RequireJS), Default: `https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.20.0/min`
132
88
  defaultOptions: {}, // Default options when creating editors
133
89
  monacoLoad: (m) => {} // The event after the first loading of the monaco editor library is completed, use this function to extend monaco editor functionalities.
@@ -139,11 +95,11 @@ NuMonacoEditorModule.forRoot({
139
95
  `monacoLoad` property of `NuMonacoEditorConfig` can be used to configure JSON default.
140
96
 
141
97
  ```ts
142
- NuMonacoEditorModule.forRoot({
98
+ provideNuMonacoEditorConfig({
143
99
  defaultOptions: { scrollBeyondLastLine: false },
144
100
  monacoLoad: () => {
145
101
  const uri = monaco.Uri.parse('a://b/foo.json');
146
- monaco.languages.json.jsonDefaults.setDiagnosticsOptions({
102
+ monaco.json.jsonDefaults.setDiagnosticsOptions({
147
103
  validate: true,
148
104
  schemas: [
149
105
  {
@@ -179,7 +135,7 @@ NuMonacoEditorModule.forRoot({
179
135
  }),
180
136
  ```
181
137
 
182
- Now pass `model` config of type `NuMonacoEditorModule` to Editor Component.
138
+ Now pass `model` config of type `NuMonacoEditorModel` to Editor Component.
183
139
 
184
140
  ```ts
185
141
  import { Component } from '@angular/core';
@@ -188,7 +144,7 @@ import { NuMonacoEditorEvent, NuMonacoEditorModel } from '@ng-util/monaco-editor
188
144
  @Component({
189
145
  selector: 'app-demo',
190
146
  template: `
191
- <nu-monaco-editor #a [(ngModel)]="value" [model]="model" (event)="showEvent($event)"></nu-monaco-editor>
147
+ <nu-monaco-editor #a [(ngModel)]="value" [model]="model" (event)="showEvent($event)" />
192
148
  <button (click)="a.editor.getAction('editor.action.formatDocument').run()">Format document</button>
193
149
  `,
194
150
  })
@@ -215,7 +171,8 @@ export class DemoComponent {
215
171
  | Property | Description | Type | Default |
216
172
  |----------|-------------|------|---------|
217
173
  | `[placeholder]` | Placeholder of monaco editor, Can change the style via defining the `.monaco-editor-placeholder` CSS. | `string` | - |
218
- | `[height]` | Height of monaco editor | `string` | `200px` |
174
+ | `[height]` | Height of monaco editor, can be set `auto` | `string` | `200px` |
175
+ | `[maxHeight]` | Max-height of monaco editor, when `height` set `auto` | `string` | `1000px` |
219
176
  | `[disabled]` | Disabled of monaco editor | `boolean` | `false` |
220
177
  | `[autoFormat]` | Whether to automatically format the document | `boolean` | `true` |
221
178
  | `[options]` | Default options when creating editors | `monaco.editor.IStandaloneEditorConstructionOptions` | - |
@@ -1,8 +1,8 @@
1
1
  import * as i0 from '@angular/core';
2
- import { InjectionToken, makeEnvironmentProviders, inject, ElementRef, DestroyRef, input, numberAttribute, booleanAttribute, output, effect, Component, untracked, forwardRef, ChangeDetectionStrategy } from '@angular/core';
2
+ import { InjectionToken, makeEnvironmentProviders, inject, ElementRef, DestroyRef, input, numberAttribute, booleanAttribute, output, effect, afterNextRender, Component, untracked, forwardRef, ChangeDetectionStrategy } from '@angular/core';
3
3
  import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
4
4
  import { NG_VALUE_ACCESSOR } from '@angular/forms';
5
- import { fromEvent, timer, take } from 'rxjs';
5
+ import { timer, fromEvent, take } from 'rxjs';
6
6
  import { DOCUMENT } from '@angular/common';
7
7
  import { debounceTime } from 'rxjs/operators';
8
8
 
@@ -37,8 +37,14 @@ class NuMonacoEditorBase {
37
37
  });
38
38
  effect(() => {
39
39
  const options = this.options();
40
+ const _ = this.height();
40
41
  this.updateOptions(options);
41
42
  });
43
+ afterNextRender(() => {
44
+ timer(this.delay())
45
+ .pipe(takeUntilDestroyed(this.destroy$))
46
+ .subscribe(() => this.init());
47
+ });
42
48
  }
43
49
  notifyEvent(type, other) {
44
50
  this.event.emit({ type, editor: this._editor, ...other });
@@ -120,9 +126,6 @@ class NuMonacoEditorBase {
120
126
  this._editor.dispose();
121
127
  this.initMonaco(v, false);
122
128
  }
123
- ngAfterViewInit() {
124
- setTimeout(() => this.init(), +this.delay());
125
- }
126
129
  ngOnDestroy() {
127
130
  this.cleanResize();
128
131
  this._editor?.dispose();
@@ -184,6 +187,7 @@ class NuMonacoEditorComponent extends NuMonacoEditorBase {
184
187
  placeholder = input(...(ngDevMode ? [undefined, { debugName: "placeholder" }] : []));
185
188
  model = input(...(ngDevMode ? [undefined, { debugName: "model" }] : []));
186
189
  autoFormat = input(true, ...(ngDevMode ? [{ debugName: "autoFormat", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
190
+ maxHeight = input(1000, ...(ngDevMode ? [{ debugName: "maxHeight", transform: numberAttribute }] : [{ transform: numberAttribute }]));
187
191
  get editor() {
188
192
  return this._editor;
189
193
  }
@@ -219,6 +223,11 @@ class NuMonacoEditorComponent extends NuMonacoEditorBase {
219
223
  initMonaco(options, initEvent) {
220
224
  const hasModel = !!this.model();
221
225
  options = { ...this.config?.defaultOptions, ...options };
226
+ const heightAuto = this.height() === 'auto';
227
+ if (heightAuto) {
228
+ options.scrollBeyondLastLine = false;
229
+ options.overviewRulerLanes = 0;
230
+ }
222
231
  if (hasModel) {
223
232
  const model = monaco.editor.getModel(this.model().uri || '');
224
233
  if (model) {
@@ -246,6 +255,10 @@ class NuMonacoEditorComponent extends NuMonacoEditorBase {
246
255
  editor.onDidBlurEditorWidget(() => this.onTouched());
247
256
  this.togglePlaceholder();
248
257
  this.registerResize();
258
+ if (heightAuto) {
259
+ editor.onDidContentSizeChange(() => this.updateHeight());
260
+ this.updateHeight();
261
+ }
249
262
  const eventName = initEvent ? 'init' : 're-init';
250
263
  if (this.autoFormat()) {
251
264
  timer(this._config.autoFormatTime)
@@ -257,6 +270,13 @@ class NuMonacoEditorComponent extends NuMonacoEditorBase {
257
270
  }
258
271
  this.notifyEvent(eventName);
259
272
  }
273
+ updateHeight() {
274
+ const editor = this.editor;
275
+ if (editor == null)
276
+ return;
277
+ const contentHeight = Math.min(this.maxHeight(), editor.getContentHeight());
278
+ editor.layout({ width: editor.getLayoutInfo().width, height: contentHeight });
279
+ }
260
280
  format() {
261
281
  const action = this.editor?.getAction('editor.action.formatDocument');
262
282
  if (action == null)
@@ -280,7 +300,7 @@ class NuMonacoEditorComponent extends NuMonacoEditorBase {
280
300
  this.setDisabled(v);
281
301
  }
282
302
  /** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.0", ngImport: i0, type: NuMonacoEditorComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
283
- /** @nocollapse */ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.0.0", type: NuMonacoEditorComponent, isStandalone: true, selector: "nu-monaco-editor", inputs: { placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, model: { classPropertyName: "model", publicName: "model", isSignal: true, isRequired: false, transformFunction: null }, autoFormat: { classPropertyName: "autoFormat", publicName: "autoFormat", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "style.display": "'block'", "style.height": "height()" } }, providers: [
303
+ /** @nocollapse */ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.0.0", type: NuMonacoEditorComponent, isStandalone: true, selector: "nu-monaco-editor", inputs: { placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, model: { classPropertyName: "model", publicName: "model", isSignal: true, isRequired: false, transformFunction: null }, autoFormat: { classPropertyName: "autoFormat", publicName: "autoFormat", isSignal: true, isRequired: false, transformFunction: null }, maxHeight: { classPropertyName: "maxHeight", publicName: "maxHeight", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "style.display": "'block'", "style.height": "height()" } }, providers: [
284
304
  {
285
305
  provide: NG_VALUE_ACCESSOR,
286
306
  useExisting: forwardRef((() => NuMonacoEditorComponent)),
@@ -307,7 +327,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.0", ngImpor
307
327
  ],
308
328
  changeDetection: ChangeDetectionStrategy.OnPush
309
329
  }]
310
- }], ctorParameters: () => [], propDecorators: { placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], model: [{ type: i0.Input, args: [{ isSignal: true, alias: "model", required: false }] }], autoFormat: [{ type: i0.Input, args: [{ isSignal: true, alias: "autoFormat", required: false }] }] } });
330
+ }], ctorParameters: () => [], propDecorators: { placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], model: [{ type: i0.Input, args: [{ isSignal: true, alias: "model", required: false }] }], autoFormat: [{ type: i0.Input, args: [{ isSignal: true, alias: "autoFormat", required: false }] }], maxHeight: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxHeight", required: false }] }] } });
311
331
 
312
332
  class NuMonacoEditorDiffComponent extends NuMonacoEditorBase {
313
333
  old = input(...(ngDevMode ? [undefined, { debugName: "old" }] : []));
@@ -1 +1 @@
1
- {"version":3,"file":"ng-util-monaco-editor.mjs","sources":["../../../../packages/monaco-editor/monaco-editor.types.ts","../../../../packages/monaco-editor/monaco-editor.config.ts","../../../../packages/monaco-editor/monaco-editor-base.component.ts","../../../../packages/monaco-editor/placholder.ts","../../../../packages/monaco-editor/monaco-editor.component.ts","../../../../packages/monaco-editor/monaco-editor-diff.component.ts","../../../../packages/monaco-editor/ng-util-monaco-editor.ts"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/triple-slash-reference\n/// <reference path=\"./monaco.d.ts\" preserve=\"true\" />\n\nexport interface NuMonacoEditorModel {\n value?: string;\n language?: string;\n uri?: monaco.Uri;\n}\n\nexport interface NuMonacoEditorDiffModel {\n code: string;\n language?: string;\n}\n\nexport type NuMonacoEditorEventType = 'load-error' | 'init' | 're-init' | 'resize' | 'update-diff' | 'error';\n\nexport interface NuMonacoEditorEvent {\n type?: NuMonacoEditorEventType;\n editor?: monaco.editor.IStandaloneCodeEditor | monaco.editor.IStandaloneDiffEditor;\n error?: string;\n /** Just only `nu-monaco-editor-diff` component */\n diffValue?: string;\n}\n","import { EnvironmentProviders, InjectionToken, makeEnvironmentProviders } from '@angular/core';\n\nexport const NU_MONACO_EDITOR_CONFIG = new InjectionToken<NuMonacoEditorConfig>('NU_MONACO_EDITOR_CONFIG');\n\nexport function provideNuMonacoEditorConfig(config?: NuMonacoEditorConfig): EnvironmentProviders {\n return makeEnvironmentProviders([{ provide: NU_MONACO_EDITOR_CONFIG, useValue: config }]);\n}\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 * Trigger automatic format delay time, default: `100`\n */\n autoFormatTime?: number;\n}\n","import { DOCUMENT } from '@angular/common';\nimport {\n AfterViewInit,\n booleanAttribute,\n Component,\n DestroyRef,\n effect,\n ElementRef,\n inject,\n input,\n numberAttribute,\n OnDestroy,\n output\n} from '@angular/core';\nimport { fromEvent, Subscription } from 'rxjs';\nimport { debounceTime } from 'rxjs/operators';\n\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})\nexport abstract class NuMonacoEditorBase implements AfterViewInit, OnDestroy {\n protected el = inject<ElementRef<HTMLElement>>(ElementRef);\n protected config = inject(NU_MONACO_EDITOR_CONFIG, { optional: true });\n protected doc = inject(DOCUMENT);\n protected destroy$ = inject(DestroyRef);\n\n protected _editor?: monaco.editor.IStandaloneCodeEditor | monaco.editor.IStandaloneDiffEditor;\n protected _resize$: Subscription | null = null;\n protected _config: NuMonacoEditorConfig;\n protected _disabled?: boolean;\n\n height = input(`200px`);\n delay = input(0, { transform: numberAttribute });\n disabled = input(false, { transform: booleanAttribute });\n options = input<monaco.editor.IStandaloneEditorConstructionOptions>();\n readonly event = output<NuMonacoEditorEvent>();\n\n constructor() {\n this._config = { baseUrl: 'https://cdn.jsdelivr.net/npm/monaco-editor/min', autoFormatTime: 100, ...this.config };\n\n effect(() => {\n this.setDisabled(this.disabled());\n });\n\n effect(() => {\n const options = this.options();\n this.updateOptions(options);\n });\n }\n\n protected abstract initMonaco(\n _options: monaco.editor.IStandaloneEditorConstructionOptions | undefined,\n _initEvent: boolean\n ): void;\n\n protected notifyEvent(type: NuMonacoEditorEventType, other?: NuMonacoEditorEvent): void {\n this.event.emit({ type, editor: this._editor!, ...other });\n }\n\n protected setDisabled(v: boolean): this {\n (this._editor as monaco.editor.IStandaloneCodeEditor)?.updateOptions({ readOnly: v });\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 let baseUrl = `${this._config.baseUrl}/vs`;\n // fix: https://github.com/microsoft/monaco-editor/issues/4778\n if (!/^https?:\\/\\//g.test(baseUrl)) {\n baseUrl = `${window.location.origin}/${baseUrl.startsWith('/') ? baseUrl.substring(1) : baseUrl}`;\n }\n const amdLoader = () => {\n win.require.config({\n paths: {\n vs: baseUrl\n }\n });\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}/loader.js`;\n loaderScript.onload = amdLoader;\n loaderScript.onerror = () =>\n 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 this._resize$?.unsubscribe();\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 updateOptions(v: monaco.editor.IStandaloneEditorConstructionOptions | undefined): void {\n if (!this._editor) return;\n this._editor!.dispose();\n this.initMonaco(v, false);\n }\n\n ngAfterViewInit(): void {\n setTimeout(() => this.init(), +this.delay());\n }\n\n ngOnDestroy(): void {\n this.cleanResize();\n this._editor?.dispose();\n }\n}\n","export class PlaceholderWidget implements monaco.editor.IContentWidget {\n private readonly ID = 'editor.widget.placeholderHint';\n private placeholder?: string;\n private editor: monaco.editor.IStandaloneCodeEditor;\n private node?: HTMLElement;\n\n constructor(editor: monaco.editor.IStandaloneCodeEditor, placeholder?: string) {\n this.placeholder = placeholder;\n this.editor = editor;\n }\n\n update(text?: string | null | undefined) {\n if (this.node == null) return;\n\n this.node.innerHTML = text ?? this.placeholder ?? '';\n }\n\n getId(): string {\n return this.ID;\n }\n getDomNode(): HTMLElement {\n if (this.node == null) {\n const node = (this.node = document.createElement('div'));\n node.classList.add('monaco-editor-placeholder');\n node.style.width = 'max-content';\n node.style.color = 'gray';\n node.innerHTML = this.placeholder!;\n node.style.fontStyle = 'italic';\n this.editor.applyFontInfo(node);\n }\n return this.node;\n }\n getPosition(): monaco.editor.IContentWidgetPosition | null {\n return {\n position: { lineNumber: 1, column: 1 },\n preference: [monaco.editor.ContentWidgetPositionPreference.EXACT]\n };\n }\n\n dispose() {\n this.editor.removeContentWidget(this);\n }\n}\n","import {\n booleanAttribute,\n ChangeDetectionStrategy,\n Component,\n effect,\n forwardRef,\n input,\n untracked\n} from '@angular/core';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\nimport { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';\nimport { take, timer } from 'rxjs';\n\nimport { NuMonacoEditorBase } from './monaco-editor-base.component';\nimport { NuMonacoEditorModel } from './monaco-editor.types';\nimport { PlaceholderWidget } from './placholder';\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 private _placeholderWidget?: PlaceholderWidget;\n placeholder = input<string>();\n model = input<NuMonacoEditorModel | null>();\n autoFormat = input(true, { transform: booleanAttribute });\n\n get editor(): monaco.editor.IStandaloneCodeEditor | null | undefined {\n return this._editor as monaco.editor.IStandaloneCodeEditor;\n }\n\n constructor() {\n super();\n effect(() => {\n const ph = this.placeholder();\n this._placeholderWidget?.update(ph);\n });\n effect(() => {\n const model = this.model();\n if (model == null) return;\n this.updateOptions(untracked(() => this.options()));\n });\n }\n\n private togglePlaceholder() {\n const text = this.placeholder();\n if (text == null || text.length <= 0 || this.editor == null) return;\n\n if (this._placeholderWidget == null) {\n this._placeholderWidget = new PlaceholderWidget(this.editor, text);\n }\n\n if (this._value.length > 0) {\n this.editor.removeContentWidget(this._placeholderWidget);\n } else {\n this.editor.addContentWidget(this._placeholderWidget);\n }\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 options = { ...this.config?.defaultOptions, ...options };\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 this._value = options.model.getValue();\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 this._value = value;\n\n this.onChange(value);\n\n this.togglePlaceholder();\n });\n editor.onDidBlurEditorWidget(() => this.onTouched());\n\n this.togglePlaceholder();\n this.registerResize();\n\n const eventName = initEvent ? 'init' : 're-init';\n if (this.autoFormat()) {\n timer(this._config.autoFormatTime!)\n .pipe(takeUntilDestroyed(this.destroy$), take(1))\n .subscribe(() => {\n this.format()?.then(() => this.notifyEvent(eventName));\n });\n return;\n }\n this.notifyEvent(eventName);\n }\n\n format(): Promise<void> | undefined {\n const action = this.editor?.getAction('editor.action.formatDocument');\n if (action == null) return;\n return action.run();\n }\n\n writeValue(value: string): void {\n this._value = value || '';\n (this._editor as monaco.editor.IStandaloneCodeEditor)?.setValue(this._value);\n if (this.autoFormat()) {\n this.format();\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(v: boolean): void {\n this.setDisabled(v);\n }\n}\n","import { ChangeDetectionStrategy, Component, input } from '@angular/core';\n\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 old = input<NuMonacoEditorDiffModel>();\n new = input<NuMonacoEditorDiffModel>();\n\n get editor(): monaco.editor.IStandaloneDiffEditor | null | undefined {\n return this._editor as monaco.editor.IStandaloneDiffEditor;\n }\n\n initMonaco(options: monaco.editor.IStandaloneEditorConstructionOptions, initEvent: boolean): void {\n const oldModel = this.old();\n const newModel = this.new();\n if (!oldModel || !newModel) {\n this.notifyEvent('error', { error: 'old or new not found for nu-monaco-diff-editor' });\n return;\n }\n\n options = { ...this.config?.defaultOptions, ...options };\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(oldModel.code, oldModel.language || options.language),\n modified: monaco.editor.createModel(newModel.code, newModel.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","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;AAAA;AACA;;MCCa,uBAAuB,GAAG,IAAI,cAAc,CAAuB,yBAAyB;AAEnG,SAAU,2BAA2B,CAAC,MAA6B,EAAA;AACvE,IAAA,OAAO,wBAAwB,CAAC,CAAC,EAAE,OAAO,EAAE,uBAAuB,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;AAC3F;;ACcA,IAAI,YAAY,GAAG,KAAK;AACxB,IAAI,WAA0B;MAMR,kBAAkB,CAAA;AAC5B,IAAA,EAAE,GAAG,MAAM,CAA0B,UAAU,CAAC;IAChD,MAAM,GAAG,MAAM,CAAC,uBAAuB,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;AAC5D,IAAA,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC;AACtB,IAAA,QAAQ,GAAG,MAAM,CAAC,UAAU,CAAC;AAE7B,IAAA,OAAO;IACP,QAAQ,GAAwB,IAAI;AACpC,IAAA,OAAO;AACP,IAAA,SAAS;AAEnB,IAAA,MAAM,GAAG,KAAK,CAAC,CAAA,KAAA,CAAO,kDAAC;AACvB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,EAAE,EAAE,CAAC,CAAC;QAEnH,IAAI,CAAC,cAAc,EAAE;AACrB,QAAA,IAAI,SAAS;AAAE,YAAA,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC;IACzC;0HA/BW,2BAA2B,EAAA,IAAA,EAAA,IAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;AAA3B,uBAAA,OAAA,IAAA,GAAA,EAAA,CAAA,oBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,IAAA,EAAA,2BAA2B,4cAR5B,CAAA,CAAE,EAAA,QAAA,EAAA,IAAA,EAAA,eAAA,EAAA,EAAA,CAAA,uBAAA,CAAA,MAAA,EAAA,CAAA;;2FAQD,2BAA2B,EAAA,UAAA,EAAA,CAAA;kBAVvC,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,uBAAuB;AACjC,oBAAA,QAAQ,EAAE,CAAA,CAAE;AACZ,oBAAA,QAAQ,EAAE,oBAAoB;AAC9B,oBAAA,IAAI,EAAE;AACJ,wBAAA,iBAAiB,EAAE,CAAA,OAAA,CAAS;AAC5B,wBAAA,gBAAgB,EAAE;AACnB,qBAAA;oBACD,eAAe,EAAE,uBAAuB,CAAC;AAC1C,iBAAA;;;ACdD;;AAEG;;;;"}
1
+ {"version":3,"file":"ng-util-monaco-editor.mjs","sources":["../../../../packages/monaco-editor/monaco-editor.types.ts","../../../../packages/monaco-editor/monaco-editor.config.ts","../../../../packages/monaco-editor/monaco-editor-base.component.ts","../../../../packages/monaco-editor/placholder.ts","../../../../packages/monaco-editor/monaco-editor.component.ts","../../../../packages/monaco-editor/monaco-editor-diff.component.ts","../../../../packages/monaco-editor/ng-util-monaco-editor.ts"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/triple-slash-reference\n/// <reference path=\"./monaco.d.ts\" preserve=\"true\" />\n\nexport interface NuMonacoEditorModel {\n value?: string;\n language?: string;\n uri?: monaco.Uri;\n}\n\nexport interface NuMonacoEditorDiffModel {\n code: string;\n language?: string;\n}\n\nexport type NuMonacoEditorEventType = 'load-error' | 'init' | 're-init' | 'resize' | 'update-diff' | 'error';\n\nexport interface NuMonacoEditorEvent {\n type?: NuMonacoEditorEventType;\n editor?: monaco.editor.IStandaloneCodeEditor | monaco.editor.IStandaloneDiffEditor;\n error?: string;\n /** Just only `nu-monaco-editor-diff` component */\n diffValue?: string;\n}\n","import { EnvironmentProviders, InjectionToken, makeEnvironmentProviders } from '@angular/core';\n\nexport const NU_MONACO_EDITOR_CONFIG = new InjectionToken<NuMonacoEditorConfig>('NU_MONACO_EDITOR_CONFIG');\n\nexport function provideNuMonacoEditorConfig(config?: NuMonacoEditorConfig): EnvironmentProviders {\n return makeEnvironmentProviders([{ provide: NU_MONACO_EDITOR_CONFIG, useValue: config }]);\n}\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 * Trigger automatic format delay time, default: `100`\n */\n autoFormatTime?: number;\n}\n","import { DOCUMENT } from '@angular/common';\nimport {\n afterNextRender,\n booleanAttribute,\n Component,\n DestroyRef,\n effect,\n ElementRef,\n inject,\n input,\n numberAttribute,\n OnDestroy,\n output\n} from '@angular/core';\nimport { fromEvent, Subscription, timer } from 'rxjs';\nimport { debounceTime } from 'rxjs/operators';\n\nimport { NuMonacoEditorConfig, NU_MONACO_EDITOR_CONFIG } from './monaco-editor.config';\nimport { NuMonacoEditorEvent, NuMonacoEditorEventType } from './monaco-editor.types';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\n\nlet loadedMonaco = false;\nlet loadPromise: Promise<void>;\n\n@Component({\n selector: 'nu-monaco-base',\n template: ``\n})\nexport abstract class NuMonacoEditorBase implements OnDestroy {\n protected el = inject<ElementRef<HTMLElement>>(ElementRef);\n protected config = inject(NU_MONACO_EDITOR_CONFIG, { optional: true });\n protected doc = inject(DOCUMENT);\n protected destroy$ = inject(DestroyRef);\n\n protected _editor?: monaco.editor.IStandaloneCodeEditor | monaco.editor.IStandaloneDiffEditor;\n protected _resize$: Subscription | null = null;\n protected _config: NuMonacoEditorConfig;\n protected _disabled?: boolean;\n\n height = input(`200px`);\n delay = input(0, { transform: numberAttribute });\n disabled = input(false, { transform: booleanAttribute });\n options = input<monaco.editor.IStandaloneEditorConstructionOptions>();\n readonly event = output<NuMonacoEditorEvent>();\n\n constructor() {\n this._config = { baseUrl: 'https://cdn.jsdelivr.net/npm/monaco-editor/min', autoFormatTime: 100, ...this.config };\n\n effect(() => {\n this.setDisabled(this.disabled());\n });\n\n effect(() => {\n const options = this.options();\n const _ = this.height();\n this.updateOptions(options);\n });\n\n afterNextRender(() => {\n timer(this.delay())\n .pipe(takeUntilDestroyed(this.destroy$))\n .subscribe(() => this.init());\n });\n }\n\n protected abstract initMonaco(\n _options: monaco.editor.IStandaloneEditorConstructionOptions | undefined,\n _initEvent: boolean\n ): void;\n\n protected notifyEvent(type: NuMonacoEditorEventType, other?: NuMonacoEditorEvent): void {\n this.event.emit({ type, editor: this._editor!, ...other });\n }\n\n protected setDisabled(v: boolean): this {\n (this._editor as monaco.editor.IStandaloneCodeEditor)?.updateOptions({ readOnly: v });\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 let baseUrl = `${this._config.baseUrl}/vs`;\n // fix: https://github.com/microsoft/monaco-editor/issues/4778\n if (!/^https?:\\/\\//g.test(baseUrl)) {\n baseUrl = `${window.location.origin}/${baseUrl.startsWith('/') ? baseUrl.substring(1) : baseUrl}`;\n }\n const amdLoader = () => {\n win.require.config({\n paths: {\n vs: baseUrl\n }\n });\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}/loader.js`;\n loaderScript.onload = amdLoader;\n loaderScript.onerror = () =>\n 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 this._resize$?.unsubscribe();\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 updateOptions(v: monaco.editor.IStandaloneEditorConstructionOptions | undefined): void {\n if (!this._editor) return;\n this._editor!.dispose();\n this.initMonaco(v, false);\n }\n\n ngOnDestroy(): void {\n this.cleanResize();\n this._editor?.dispose();\n }\n}\n","export class PlaceholderWidget implements monaco.editor.IContentWidget {\n private readonly ID = 'editor.widget.placeholderHint';\n private placeholder?: string;\n private editor: monaco.editor.IStandaloneCodeEditor;\n private node?: HTMLElement;\n\n constructor(editor: monaco.editor.IStandaloneCodeEditor, placeholder?: string) {\n this.placeholder = placeholder;\n this.editor = editor;\n }\n\n update(text?: string | null | undefined) {\n if (this.node == null) return;\n\n this.node.innerHTML = text ?? this.placeholder ?? '';\n }\n\n getId(): string {\n return this.ID;\n }\n getDomNode(): HTMLElement {\n if (this.node == null) {\n const node = (this.node = document.createElement('div'));\n node.classList.add('monaco-editor-placeholder');\n node.style.width = 'max-content';\n node.style.color = 'gray';\n node.innerHTML = this.placeholder!;\n node.style.fontStyle = 'italic';\n this.editor.applyFontInfo(node);\n }\n return this.node;\n }\n getPosition(): monaco.editor.IContentWidgetPosition | null {\n return {\n position: { lineNumber: 1, column: 1 },\n preference: [monaco.editor.ContentWidgetPositionPreference.EXACT]\n };\n }\n\n dispose() {\n this.editor.removeContentWidget(this);\n }\n}\n","import {\n booleanAttribute,\n ChangeDetectionStrategy,\n Component,\n effect,\n forwardRef,\n input,\n numberAttribute,\n untracked\n} from '@angular/core';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\nimport { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';\nimport { take, timer } from 'rxjs';\n\nimport { NuMonacoEditorBase } from './monaco-editor-base.component';\nimport { NuMonacoEditorModel } from './monaco-editor.types';\nimport { PlaceholderWidget } from './placholder';\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 private _placeholderWidget?: PlaceholderWidget;\n placeholder = input<string>();\n model = input<NuMonacoEditorModel | null>();\n autoFormat = input(true, { transform: booleanAttribute });\n maxHeight = input(1000, { transform: numberAttribute });\n\n get editor(): monaco.editor.IStandaloneCodeEditor | null | undefined {\n return this._editor as monaco.editor.IStandaloneCodeEditor;\n }\n\n constructor() {\n super();\n effect(() => {\n const ph = this.placeholder();\n this._placeholderWidget?.update(ph);\n });\n effect(() => {\n const model = this.model();\n if (model == null) return;\n this.updateOptions(untracked(() => this.options()));\n });\n }\n\n private togglePlaceholder() {\n const text = this.placeholder();\n if (text == null || text.length <= 0 || this.editor == null) return;\n\n if (this._placeholderWidget == null) {\n this._placeholderWidget = new PlaceholderWidget(this.editor, text);\n }\n\n if (this._value.length > 0) {\n this.editor.removeContentWidget(this._placeholderWidget);\n } else {\n this.editor.addContentWidget(this._placeholderWidget);\n }\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 options = { ...this.config?.defaultOptions, ...options };\n const heightAuto = this.height() === 'auto';\n if (heightAuto) {\n options.scrollBeyondLastLine = false;\n options.overviewRulerLanes = 0;\n }\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 this._value = options.model.getValue();\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 this._value = value;\n\n this.onChange(value);\n\n this.togglePlaceholder();\n });\n editor.onDidBlurEditorWidget(() => this.onTouched());\n\n this.togglePlaceholder();\n this.registerResize();\n if (heightAuto) {\n editor.onDidContentSizeChange(() => this.updateHeight());\n this.updateHeight();\n }\n\n const eventName = initEvent ? 'init' : 're-init';\n if (this.autoFormat()) {\n timer(this._config.autoFormatTime!)\n .pipe(takeUntilDestroyed(this.destroy$), take(1))\n .subscribe(() => {\n this.format()?.then(() => this.notifyEvent(eventName));\n });\n return;\n }\n this.notifyEvent(eventName);\n }\n\n private updateHeight() {\n const editor = this.editor;\n if (editor == null) return;\n\n const contentHeight = Math.min(this.maxHeight(), editor.getContentHeight());\n editor.layout({ width: editor.getLayoutInfo().width, height: contentHeight });\n }\n\n format(): Promise<void> | undefined {\n const action = this.editor?.getAction('editor.action.formatDocument');\n if (action == null) return;\n return action.run();\n }\n\n writeValue(value: string): void {\n this._value = value || '';\n (this._editor as monaco.editor.IStandaloneCodeEditor)?.setValue(this._value);\n if (this.autoFormat()) {\n this.format();\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(v: boolean): void {\n this.setDisabled(v);\n }\n}\n","import { ChangeDetectionStrategy, Component, input } from '@angular/core';\n\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 old = input<NuMonacoEditorDiffModel>();\n new = input<NuMonacoEditorDiffModel>();\n\n get editor(): monaco.editor.IStandaloneDiffEditor | null | undefined {\n return this._editor as monaco.editor.IStandaloneDiffEditor;\n }\n\n initMonaco(options: monaco.editor.IStandaloneEditorConstructionOptions, initEvent: boolean): void {\n const oldModel = this.old();\n const newModel = this.new();\n if (!oldModel || !newModel) {\n this.notifyEvent('error', { error: 'old or new not found for nu-monaco-diff-editor' });\n return;\n }\n\n options = { ...this.config?.defaultOptions, ...options };\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(oldModel.code, oldModel.language || options.language),\n modified: monaco.editor.createModel(newModel.code, newModel.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","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;AAAA;AACA;;MCCa,uBAAuB,GAAG,IAAI,cAAc,CAAuB,yBAAyB;AAEnG,SAAU,2BAA2B,CAAC,MAA6B,EAAA;AACvE,IAAA,OAAO,wBAAwB,CAAC,CAAC,EAAE,OAAO,EAAE,uBAAuB,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;AAC3F;;ACeA,IAAI,YAAY,GAAG,KAAK;AACxB,IAAI,WAA0B;MAMR,kBAAkB,CAAA;AAC5B,IAAA,EAAE,GAAG,MAAM,CAA0B,UAAU,CAAC;IAChD,MAAM,GAAG,MAAM,CAAC,uBAAuB,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;AAC5D,IAAA,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC;AACtB,IAAA,QAAQ,GAAG,MAAM,CAAC,UAAU,CAAC;AAE7B,IAAA,OAAO;IACP,QAAQ,GAAwB,IAAI;AACpC,IAAA,OAAO;AACP,IAAA,SAAS;AAEnB,IAAA,MAAM,GAAG,KAAK,CAAC,CAAA,KAAA,CAAO,kDAAC;AACvB,IAAA,KAAK,GAAG,KAAK,CAAC,CAAC,yCAAI,SAAS,EAAE,eAAe,EAAA,CAAA,GAAA,CAA5B,EAAE,SAAS,EAAE,eAAe,EAAE,GAAC;AAChD,IAAA,QAAQ,GAAG,KAAK,CAAC,KAAK,4CAAI,SAAS,EAAE,gBAAgB,EAAA,CAAA,GAAA,CAA7B,EAAE,SAAS,EAAE,gBAAgB,EAAE,GAAC;IAC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AA,IAAA,EAAA,eAAA,EAAA,EAAA,CAAA,uBAAA,CAAA,MAAA,EAAA,CAAA;;2FAQD,2BAA2B,EAAA,UAAA,EAAA,CAAA;kBAVvC,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,uBAAuB;AACjC,oBAAA,QAAQ,EAAE,CAAA,CAAE;AACZ,oBAAA,QAAQ,EAAE,oBAAoB;AAC9B,oBAAA,IAAI,EAAE;AACJ,wBAAA,iBAAiB,EAAE,CAAA,OAAA,CAAS;AAC5B,wBAAA,gBAAgB,EAAE;AACnB,qBAAA;oBACD,eAAe,EAAE,uBAAuB,CAAC;AAC1C,iBAAA;;;ACdD;;AAEG;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ng-util/monaco-editor",
3
- "version": "21.0.0",
3
+ "version": "21.1.0",
4
4
  "author": "cipchk<cipchk@qq.com>",
5
5
  "description": "Monaco Code Editor for Angular",
6
6
  "license": "MIT",
@@ -1,6 +1,6 @@
1
- /// <reference path="../../../../packages/monaco-editor/monaco.d.ts" />
1
+ /// <reference path="../monaco.d.ts" />
2
2
  import * as _angular_core from '@angular/core';
3
- import { InjectionToken, EnvironmentProviders, AfterViewInit, OnDestroy, ElementRef, DestroyRef } from '@angular/core';
3
+ import { InjectionToken, EnvironmentProviders, OnDestroy, ElementRef, DestroyRef } from '@angular/core';
4
4
  import { ControlValueAccessor } from '@angular/forms';
5
5
  import { Subscription } from 'rxjs';
6
6
 
@@ -49,7 +49,7 @@ interface NuMonacoEditorConfig {
49
49
  autoFormatTime?: number;
50
50
  }
51
51
 
52
- declare abstract class NuMonacoEditorBase implements AfterViewInit, OnDestroy {
52
+ declare abstract class NuMonacoEditorBase implements OnDestroy {
53
53
  protected el: ElementRef<HTMLElement>;
54
54
  protected config: NuMonacoEditorConfig | null;
55
55
  protected doc: Document;
@@ -71,7 +71,6 @@ declare abstract class NuMonacoEditorBase implements AfterViewInit, OnDestroy {
71
71
  protected cleanResize(): this;
72
72
  protected registerResize(): this;
73
73
  updateOptions(v: monaco.editor.IStandaloneEditorConstructionOptions | undefined): void;
74
- ngAfterViewInit(): void;
75
74
  ngOnDestroy(): void;
76
75
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<NuMonacoEditorBase, never>;
77
76
  static ɵcmp: _angular_core.ɵɵComponentDeclaration<NuMonacoEditorBase, "nu-monaco-base", never, { "height": { "alias": "height"; "required": false; "isSignal": true; }; "delay": { "alias": "delay"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "options": { "alias": "options"; "required": false; "isSignal": true; }; }, { "event": "event"; }, never, never, true, never>;
@@ -83,19 +82,21 @@ declare class NuMonacoEditorComponent extends NuMonacoEditorBase implements Cont
83
82
  placeholder: _angular_core.InputSignal<string | undefined>;
84
83
  model: _angular_core.InputSignal<NuMonacoEditorModel | null | undefined>;
85
84
  autoFormat: _angular_core.InputSignalWithTransform<boolean, unknown>;
85
+ maxHeight: _angular_core.InputSignalWithTransform<number, unknown>;
86
86
  get editor(): monaco.editor.IStandaloneCodeEditor | null | undefined;
87
87
  constructor();
88
88
  private togglePlaceholder;
89
89
  private onChange;
90
90
  private onTouched;
91
91
  initMonaco(options: monaco.editor.IStandaloneEditorConstructionOptions, initEvent: boolean): void;
92
+ private updateHeight;
92
93
  format(): Promise<void> | undefined;
93
94
  writeValue(value: string): void;
94
95
  registerOnChange(fn: (_: string) => void): void;
95
96
  registerOnTouched(fn: any): void;
96
97
  setDisabledState(v: boolean): void;
97
98
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<NuMonacoEditorComponent, never>;
98
- static ɵcmp: _angular_core.ɵɵComponentDeclaration<NuMonacoEditorComponent, "nu-monaco-editor", ["nuMonacoEditor"], { "placeholder": { "alias": "placeholder"; "required": false; "isSignal": true; }; "model": { "alias": "model"; "required": false; "isSignal": true; }; "autoFormat": { "alias": "autoFormat"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
99
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<NuMonacoEditorComponent, "nu-monaco-editor", ["nuMonacoEditor"], { "placeholder": { "alias": "placeholder"; "required": false; "isSignal": true; }; "model": { "alias": "model"; "required": false; "isSignal": true; }; "autoFormat": { "alias": "autoFormat"; "required": false; "isSignal": true; }; "maxHeight": { "alias": "maxHeight"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
99
100
  }
100
101
 
101
102
  declare class NuMonacoEditorDiffComponent extends NuMonacoEditorBase {