@node-projects/web-component-designer-codeview-monaco 0.1.16 → 0.1.17
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,46 @@ 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
|
+
console.log('text change');
|
|
150
|
+
if (selectionTimeout) {
|
|
151
|
+
clearTimeout(selectionTimeout);
|
|
152
|
+
selectionTimeout = null;
|
|
153
|
+
}
|
|
154
|
+
disableCursorChange = true;
|
|
155
|
+
setTimeout(() => {
|
|
156
|
+
disableCursorChange = false;
|
|
157
|
+
}, 50);
|
|
147
158
|
this.onTextChanged.emit(this._monacoEditor.getValue());
|
|
148
159
|
});
|
|
149
160
|
this._monacoEditor.onDidChangeModel(e => {
|
|
150
161
|
changeContentListener.dispose();
|
|
151
162
|
changeContentListener = this._monacoEditor.getModel().onDidChangeContent(e => {
|
|
163
|
+
console.log('text change');
|
|
164
|
+
if (selectionTimeout) {
|
|
165
|
+
clearTimeout(selectionTimeout);
|
|
166
|
+
selectionTimeout = null;
|
|
167
|
+
}
|
|
168
|
+
disableCursorChange = true;
|
|
169
|
+
setTimeout(() => {
|
|
170
|
+
disableCursorChange = false;
|
|
171
|
+
}, 50);
|
|
152
172
|
this.onTextChanged.emit(this._monacoEditor.getValue());
|
|
153
173
|
});
|
|
154
174
|
});
|
|
155
175
|
this._monacoEditor.onDidChangeCursorPosition(e => {
|
|
156
176
|
const offset = this._monacoEditor.getModel().getOffsetAt(e.position);
|
|
157
|
-
|
|
158
|
-
if (this._instanceServiceContainer && !debounce && !this._disableSelectionAfterUpd) {
|
|
159
|
-
debounce = true;
|
|
177
|
+
if (this._instanceServiceContainer && !this._disableSelectionAfterUpd && !disableCursorChange) {
|
|
160
178
|
this._disableSelection = true;
|
|
161
|
-
|
|
162
|
-
|
|
179
|
+
if (selectionTimeout)
|
|
180
|
+
clearTimeout(selectionTimeout);
|
|
181
|
+
selectionTimeout = setTimeout(() => {
|
|
182
|
+
selectionTimeout = null;
|
|
183
|
+
this._instanceServiceContainer.selectionService.setSelectionByTextRange(offset, offset);
|
|
184
|
+
this._disableSelection = false;
|
|
163
185
|
}, 50);
|
|
164
|
-
this._instanceServiceContainer.selectionService.setSelectionByTextRange(offset, offset);
|
|
165
|
-
this._disableSelection = false;
|
|
166
186
|
}
|
|
167
187
|
});
|
|
168
188
|
this._monacoEditor.focus();
|
|
@@ -185,6 +205,7 @@ export class CodeViewMonaco extends BaseCustomWebComponentLazyAppend {
|
|
|
185
205
|
this._monacoEditor.layout();
|
|
186
206
|
}
|
|
187
207
|
update(code, instanceServiceContainer) {
|
|
208
|
+
console.log('update text');
|
|
188
209
|
this.code = code;
|
|
189
210
|
this._instanceServiceContainer = instanceServiceContainer;
|
|
190
211
|
if (this._monacoEditor) {
|
|
@@ -200,6 +221,7 @@ export class CodeViewMonaco extends BaseCustomWebComponentLazyAppend {
|
|
|
200
221
|
return this._monacoEditor.getValue();
|
|
201
222
|
}
|
|
202
223
|
setSelection(position) {
|
|
224
|
+
console.log('set selection');
|
|
203
225
|
if (this._monacoEditor && !this._disableSelection) {
|
|
204
226
|
let model = this._monacoEditor.getModel();
|
|
205
227
|
let point1 = model.getPositionAt(position.start);
|
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.17",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/widgets/codeView/code-view-monaco.js",
|
|
7
7
|
"author": "jochen.kuehner@gmx.de",
|