@node-projects/web-component-designer-codeview-monaco 0.1.20 → 0.1.23

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.
@@ -11,13 +11,14 @@ export declare class CodeViewMonaco extends BaseCustomWebComponentLazyAppend imp
11
11
  dispose(): void;
12
12
  canvasElement: HTMLElement;
13
13
  elementsToPackages: Map<string, string>;
14
- code: string;
15
14
  onTextChanged: TypedEvent<string>;
16
15
  language: string;
17
16
  singleRow: boolean;
18
17
  private _theme;
19
18
  get theme(): string;
20
19
  set theme(value: string);
20
+ get code(): string;
21
+ set code(v: string);
21
22
  get readOnly(): boolean;
22
23
  set readOnly(v: boolean);
23
24
  static readonly properties: {
@@ -8,7 +8,6 @@ export class CodeViewMonaco extends BaseCustomWebComponentLazyAppend {
8
8
  }
9
9
  canvasElement;
10
10
  elementsToPackages;
11
- code;
12
11
  onTextChanged = new TypedEvent();
13
12
  language = 'html';
14
13
  singleRow = false;
@@ -22,6 +21,17 @@ export class CodeViewMonaco extends BaseCustomWebComponentLazyAppend {
22
21
  CodeViewMonaco.monacoLib ??= window.monaco;
23
22
  CodeViewMonaco.monacoLib.editor.setTheme(value);
24
23
  }
24
+ #code = null;
25
+ get code() {
26
+ if (this._monacoEditor)
27
+ return this._monacoEditor.getModel().getValue();
28
+ return null;
29
+ }
30
+ set code(v) {
31
+ this.#code = v;
32
+ if (this._monacoEditor)
33
+ this._monacoEditor.getModel().setValue(v);
34
+ }
25
35
  #readOnly = false;
26
36
  get readOnly() {
27
37
  return this.#readOnly;
@@ -138,7 +148,7 @@ export class CodeViewMonaco extends BaseCustomWebComponentLazyAppend {
138
148
  let options = {
139
149
  automaticLayout: true,
140
150
  language: this.language,
141
- value: this.code,
151
+ value: this.#code,
142
152
  fixedOverflowWidgets: true,
143
153
  minimap: {
144
154
  size: 'fill'
@@ -174,6 +184,7 @@ export class CodeViewMonaco extends BaseCustomWebComponentLazyAppend {
174
184
  disableCursorChange = false;
175
185
  }, 50);
176
186
  this.onTextChanged.emit(this._monacoEditor.getValue());
187
+ this.dispatchEvent(new CustomEvent('code-changed'));
177
188
  });
178
189
  this._monacoEditor.onDidChangeModel(e => {
179
190
  changeContentListener.dispose();
@@ -187,6 +198,7 @@ export class CodeViewMonaco extends BaseCustomWebComponentLazyAppend {
187
198
  disableCursorChange = false;
188
199
  }, 50);
189
200
  this.onTextChanged.emit(this._monacoEditor.getValue());
201
+ this.dispatchEvent(new CustomEvent('code-changed'));
190
202
  });
191
203
  });
192
204
  this._monacoEditor.onDidChangeCursorPosition(e => {
@@ -222,7 +234,7 @@ export class CodeViewMonaco extends BaseCustomWebComponentLazyAppend {
222
234
  this._monacoEditor.layout();
223
235
  }
224
236
  update(code, instanceServiceContainer) {
225
- this.code = code;
237
+ this.#code = code;
226
238
  this._instanceServiceContainer = instanceServiceContainer;
227
239
  if (this._monacoEditor) {
228
240
  this._disableSelectionAfterUpd = true;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "description": "web-component-designer addon: Code Editor using Monaco",
3
3
  "name": "@node-projects/web-component-designer-codeview-monaco",
4
- "version": "0.1.20",
4
+ "version": "0.1.23",
5
5
  "type": "module",
6
6
  "main": "./dist/widgets/codeView/code-view-monaco.js",
7
7
  "author": "jochen.kuehner@gmx.de",