@node-projects/web-component-designer-codeview-monaco 0.1.22 → 0.1.24

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.
@@ -178,12 +178,14 @@ export class CodeViewMonaco extends BaseCustomWebComponentLazyAppend {
178
178
  if (selectionTimeout) {
179
179
  clearTimeout(selectionTimeout);
180
180
  selectionTimeout = null;
181
+ this._disableSelection = false;
181
182
  }
182
183
  disableCursorChange = true;
183
184
  setTimeout(() => {
184
185
  disableCursorChange = false;
185
186
  }, 50);
186
187
  this.onTextChanged.emit(this._monacoEditor.getValue());
188
+ this.dispatchEvent(new CustomEvent('code-changed'));
187
189
  });
188
190
  this._monacoEditor.onDidChangeModel(e => {
189
191
  changeContentListener.dispose();
@@ -191,23 +193,27 @@ export class CodeViewMonaco extends BaseCustomWebComponentLazyAppend {
191
193
  if (selectionTimeout) {
192
194
  clearTimeout(selectionTimeout);
193
195
  selectionTimeout = null;
196
+ this._disableSelection = false;
194
197
  }
195
198
  disableCursorChange = true;
196
199
  setTimeout(() => {
197
200
  disableCursorChange = false;
198
201
  }, 50);
199
202
  this.onTextChanged.emit(this._monacoEditor.getValue());
203
+ this.dispatchEvent(new CustomEvent('code-changed'));
200
204
  });
201
205
  });
202
206
  this._monacoEditor.onDidChangeCursorPosition(e => {
203
- const offset = this._monacoEditor.getModel().getOffsetAt(e.position);
207
+ const sel = this._monacoEditor.getSelection();
208
+ const offsetStart = this._monacoEditor.getModel().getOffsetAt(sel.getStartPosition());
209
+ const offsetEnd = this._monacoEditor.getModel().getOffsetAt(sel.getEndPosition());
204
210
  if (this._instanceServiceContainer && !this._disableSelectionAfterUpd && !disableCursorChange) {
205
211
  this._disableSelection = true;
206
212
  if (selectionTimeout)
207
213
  clearTimeout(selectionTimeout);
208
214
  selectionTimeout = setTimeout(() => {
209
215
  selectionTimeout = null;
210
- this._instanceServiceContainer.selectionService.setSelectionByTextRange(offset, offset);
216
+ this._instanceServiceContainer.selectionService.setSelectionByTextRange(offsetStart, offsetEnd);
211
217
  this._disableSelection = false;
212
218
  }, 50);
213
219
  }
@@ -247,7 +253,7 @@ export class CodeViewMonaco extends BaseCustomWebComponentLazyAppend {
247
253
  return this._monacoEditor.getValue();
248
254
  }
249
255
  setSelection(position) {
250
- if (this._monacoEditor && !this._disableSelection) {
256
+ if (this._monacoEditor && !this._disableSelection && position) {
251
257
  let model = this._monacoEditor.getModel();
252
258
  let point1 = model.getPositionAt(position.start);
253
259
  let point2 = model.getPositionAt(position.start + position.length);
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.22",
4
+ "version": "0.1.24",
5
5
  "type": "module",
6
6
  "main": "./dist/widgets/codeView/code-view-monaco.js",
7
7
  "author": "jochen.kuehner@gmx.de",