diff --git a/packages/CodeEditor/Editor.vue b/packages/CodeEditor/Editor.vue index 3fceae9..bedd5dd 100644 --- a/packages/CodeEditor/Editor.vue +++ b/packages/CodeEditor/Editor.vue @@ -160,6 +160,8 @@ export default { data() { return { id: newId(), + cursorLocation: null, + updatingValue: false, editorHasFocus: false, autosave: true, messageIds: [], @@ -241,6 +243,14 @@ export default { }); editor.getModel().onDidChangeContent((event) => { this.update(); + if (this.updatingValue && this.cursorLocation) { + this.$refs.editor.pinstance.setPosition(this.cursorLocation); + } + }); + editor.onDidChangeCursorPosition(e => { + if (!this.updatingValue) { + this.cursorLocation = this.$refs.editor.pinstance.getPosition(); + } }); // HACK: if editor is attached to "this" it will freeze the system this.$refs.editor.pinstance = editor; @@ -447,7 +457,9 @@ export default { if (!this.$refs.editor || !this.$refs.editor.pinstance) { return; } - this.$refs.editor.pinstance.setValue(val, monaco.editor.StableMarker); + this.updatingValue = true; + this.$refs.editor.pinstance.setValue(val); + this.updatingValue = false; }, getValue() { return this.$refs.editor.pinstance.getValue(); @@ -507,10 +519,9 @@ export default { this.loadFromCache(); }, value() { - console.log('watch value update'); this.localValue = this.value; if (this.$refs.editor) { - this.$refs.editor.pinstance.value = this.localValue; + this.setValue(this.localValue); } }, navWidth() { diff --git a/packages/CompileTemplate/importVue.ts b/packages/CompileTemplate/importVue.ts index 17aeec5..146c3ec 100644 --- a/packages/CompileTemplate/importVue.ts +++ b/packages/CompileTemplate/importVue.ts @@ -26,6 +26,8 @@ const _createElementBlock = self.dependencies.vue.createElementBlock; const _resolveComponent = self.dependencies.vue.resolveComponent; const _withCtx = self.dependencies.vue.withCtx; const _createBlock = self.dependencies.vue.createBlock; +const _withDirectives = self.dependencies.vue.withDirectives; +const _vModelText = self.dependencies.vue.vModelText; `); const script = compiler.compileScript(blocks.descriptor, { diff --git a/packages/Node/Node.vue b/packages/Node/Node.vue index ccdd391..ba3610b 100644 --- a/packages/Node/Node.vue +++ b/packages/Node/Node.vue @@ -5,7 +5,7 @@ :nodeId="node.id" :hovered="localHoveredNode"/>
{{errorMessage}}