@node-projects/web-component-designer-codeview-monaco 1.1.6 → 1.1.8

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.
@@ -12,6 +12,7 @@ export declare class CodeViewMonaco extends BaseCustomWebComponentLazyAppend imp
12
12
  private _disableSelectionAfterSel;
13
13
  private _setSelectionTimeout;
14
14
  private _pendingSelectionKey;
15
+ private _initialSelection?;
15
16
  private _disposed;
16
17
  private _cleanup;
17
18
  private _enableSelectionTimeout;
@@ -16,6 +16,7 @@ export class CodeViewMonaco extends BaseCustomWebComponentLazyAppend {
16
16
  _disableSelectionAfterSel;
17
17
  _setSelectionTimeout;
18
18
  _pendingSelectionKey;
19
+ _initialSelection;
19
20
  _disposed = false;
20
21
  _cleanup = [];
21
22
  _enableSelectionTimeout;
@@ -24,6 +25,7 @@ export class CodeViewMonaco extends BaseCustomWebComponentLazyAppend {
24
25
  if (this._disposed)
25
26
  return;
26
27
  this._disposed = true;
28
+ this._initialSelection = undefined;
27
29
  this.clearPendingSetSelection();
28
30
  clearTimeout(this._enableSelectionTimeout);
29
31
  cancelAnimationFrame(this._focusFrame);
@@ -220,6 +222,10 @@ export class CodeViewMonaco extends BaseCustomWebComponentLazyAppend {
220
222
  });
221
223
  this._monacoEditor.focus();
222
224
  resizeObserver.disconnect();
225
+ const selection = this._initialSelection;
226
+ this._initialSelection = undefined;
227
+ if (selection)
228
+ this.setSelection(selection);
223
229
  }
224
230
  ;
225
231
  });
@@ -244,6 +250,8 @@ export class CodeViewMonaco extends BaseCustomWebComponentLazyAppend {
244
250
  update(code, instanceServiceContainer) {
245
251
  if (this._disposed)
246
252
  return;
253
+ if (this.#code !== code)
254
+ this._initialSelection = undefined;
247
255
  this.#code = code;
248
256
  this._instanceServiceContainer = instanceServiceContainer;
249
257
  if (this._monacoEditor) {
@@ -283,6 +291,12 @@ export class CodeViewMonaco extends BaseCustomWebComponentLazyAppend {
283
291
  return this._monacoEditor?.getValue() ?? this.#code ?? '';
284
292
  }
285
293
  setSelection(position) {
294
+ if (this._disposed || !position)
295
+ return;
296
+ if (!this._monacoEditor) {
297
+ this._initialSelection = { ...position };
298
+ return;
299
+ }
286
300
  if (this._monacoEditor && !this._disableSelection && !this._disableSelectionAfterSel && position) {
287
301
  const selectionKey = `${position.start}:${position.length}`;
288
302
  if (this._pendingSelectionKey === selectionKey)
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": "1.1.6",
4
+ "version": "1.1.8",
5
5
  "type": "module",
6
6
  "main": "./dist/widgets/codeView/code-view-monaco.js",
7
7
  "author": "jochen.kuehner@gmx.de",
@@ -15,7 +15,7 @@
15
15
  "dependencies": {
16
16
  "monaco-editor": ">=0.50.0",
17
17
  "@node-projects/base-custom-webcomponent": ">=0.19.0",
18
- "@node-projects/web-component-designer": "1.1.6"
18
+ "@node-projects/web-component-designer": "1.1.8"
19
19
  },
20
20
  "repository": {
21
21
  "type": "git",