@node-projects/web-component-designer-codeview-monaco 0.3.0 → 1.0.0
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.
|
@@ -82,12 +82,12 @@ export class CodeViewMonaco extends BaseCustomWebComponentLazyAppend {
|
|
|
82
82
|
_instanceServiceContainer;
|
|
83
83
|
_disableSelection;
|
|
84
84
|
_disableSelectionAfterUpd;
|
|
85
|
-
static style = css `
|
|
86
|
-
:host {
|
|
87
|
-
display: block;
|
|
88
|
-
height: 100%;
|
|
89
|
-
width: 100%;
|
|
90
|
-
}
|
|
85
|
+
static style = css `
|
|
86
|
+
:host {
|
|
87
|
+
display: block;
|
|
88
|
+
height: 100%;
|
|
89
|
+
width: 100%;
|
|
90
|
+
}
|
|
91
91
|
`;
|
|
92
92
|
static template = html `<div id="container" style="overflow: hidden; width: 100%; height: 100%; position: absolute;"></div>`;
|
|
93
93
|
executeCommand(command) {
|
|
@@ -249,8 +249,27 @@ export class CodeViewMonaco extends BaseCustomWebComponentLazyAppend {
|
|
|
249
249
|
if (this._monacoEditor) {
|
|
250
250
|
this.clearPendingSetSelection();
|
|
251
251
|
this._disableSelectionAfterUpd = true;
|
|
252
|
-
|
|
253
|
-
|
|
252
|
+
const model = this._monacoEditor.getModel();
|
|
253
|
+
const old = model.getValue();
|
|
254
|
+
if (old !== code) {
|
|
255
|
+
let start = 0;
|
|
256
|
+
const max = Math.min(old.length, code.length);
|
|
257
|
+
while (start < max && old.charCodeAt(start) === code.charCodeAt(start))
|
|
258
|
+
start++;
|
|
259
|
+
let endOld = old.length, endNew = code.length;
|
|
260
|
+
while (endOld > start && endNew > start && old.charCodeAt(endOld - 1) === code.charCodeAt(endNew - 1)) {
|
|
261
|
+
endOld--;
|
|
262
|
+
endNew--;
|
|
263
|
+
}
|
|
264
|
+
const a = model.getPositionAt(start);
|
|
265
|
+
const b = model.getPositionAt(endOld);
|
|
266
|
+
//minimal edit keeps the caret position (setValue would reset it)
|
|
267
|
+
this._monacoEditor.executeEdits('update', [{
|
|
268
|
+
range: { startLineNumber: a.lineNumber, startColumn: a.column, endLineNumber: b.lineNumber, endColumn: b.column },
|
|
269
|
+
text: code.substring(start, endNew),
|
|
270
|
+
forceMoveMarkers: false
|
|
271
|
+
}]);
|
|
272
|
+
}
|
|
254
273
|
this._disableSelectionAfterUpd = false;
|
|
255
274
|
CodeViewMonaco.getMonacoLib().then(monaco => {
|
|
256
275
|
if (this._disposed)
|
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.
|
|
4
|
+
"version": "1.0.0",
|
|
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": "
|
|
18
|
+
"@node-projects/web-component-designer": "1.0.0"
|
|
19
19
|
},
|
|
20
20
|
"repository": {
|
|
21
21
|
"type": "git",
|