@node-projects/web-component-designer-codeview-monaco 0.1.16 → 0.1.18
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.
|
@@ -143,26 +143,44 @@ export class CodeViewMonaco extends BaseCustomWebComponentLazyAppend {
|
|
|
143
143
|
}
|
|
144
144
|
});
|
|
145
145
|
CodeViewMonaco.initMonacoEditor(CodeViewMonaco.monacoLib);
|
|
146
|
+
let selectionTimeout;
|
|
147
|
+
let disableCursorChange;
|
|
146
148
|
let changeContentListener = this._monacoEditor.getModel().onDidChangeContent(e => {
|
|
149
|
+
if (selectionTimeout) {
|
|
150
|
+
clearTimeout(selectionTimeout);
|
|
151
|
+
selectionTimeout = null;
|
|
152
|
+
}
|
|
153
|
+
disableCursorChange = true;
|
|
154
|
+
setTimeout(() => {
|
|
155
|
+
disableCursorChange = false;
|
|
156
|
+
}, 50);
|
|
147
157
|
this.onTextChanged.emit(this._monacoEditor.getValue());
|
|
148
158
|
});
|
|
149
159
|
this._monacoEditor.onDidChangeModel(e => {
|
|
150
160
|
changeContentListener.dispose();
|
|
151
161
|
changeContentListener = this._monacoEditor.getModel().onDidChangeContent(e => {
|
|
162
|
+
if (selectionTimeout) {
|
|
163
|
+
clearTimeout(selectionTimeout);
|
|
164
|
+
selectionTimeout = null;
|
|
165
|
+
}
|
|
166
|
+
disableCursorChange = true;
|
|
167
|
+
setTimeout(() => {
|
|
168
|
+
disableCursorChange = false;
|
|
169
|
+
}, 50);
|
|
152
170
|
this.onTextChanged.emit(this._monacoEditor.getValue());
|
|
153
171
|
});
|
|
154
172
|
});
|
|
155
173
|
this._monacoEditor.onDidChangeCursorPosition(e => {
|
|
156
174
|
const offset = this._monacoEditor.getModel().getOffsetAt(e.position);
|
|
157
|
-
|
|
158
|
-
if (this._instanceServiceContainer && !debounce && !this._disableSelectionAfterUpd) {
|
|
159
|
-
debounce = true;
|
|
175
|
+
if (this._instanceServiceContainer && !this._disableSelectionAfterUpd && !disableCursorChange) {
|
|
160
176
|
this._disableSelection = true;
|
|
161
|
-
|
|
162
|
-
|
|
177
|
+
if (selectionTimeout)
|
|
178
|
+
clearTimeout(selectionTimeout);
|
|
179
|
+
selectionTimeout = setTimeout(() => {
|
|
180
|
+
selectionTimeout = null;
|
|
181
|
+
this._instanceServiceContainer.selectionService.setSelectionByTextRange(offset, offset);
|
|
182
|
+
this._disableSelection = false;
|
|
163
183
|
}, 50);
|
|
164
|
-
this._instanceServiceContainer.selectionService.setSelectionByTextRange(offset, offset);
|
|
165
|
-
this._disableSelection = false;
|
|
166
184
|
}
|
|
167
185
|
});
|
|
168
186
|
this._monacoEditor.focus();
|
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.
|
|
4
|
+
"version": "0.1.18",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/widgets/codeView/code-view-monaco.js",
|
|
7
7
|
"author": "jochen.kuehner@gmx.de",
|