|
@@ -1,7 +1,7 @@
|
|
|
<script setup lang="ts">
|
|
|
import { useStore, type IMappingValue } from '@/util/store'
|
|
|
const store = useStore()
|
|
|
-import { ref, shallowRef } from 'vue'
|
|
|
+import { computed, shallowRef } from 'vue'
|
|
|
|
|
|
//see https://github.com/imguolao/monaco-vue#vite
|
|
|
import { loader } from "@guolao/vue-monaco-editor"
|
|
@@ -29,17 +29,32 @@ self.MonacoEnvironment = {
|
|
|
}
|
|
|
}
|
|
|
loader.config({ monaco })
|
|
|
-
|
|
|
-
|
|
|
const MONACO_EDITOR_OPTIONS = {
|
|
|
automaticLayout: true,
|
|
|
formatOnType: true,
|
|
|
formatOnPaste: true,
|
|
|
}
|
|
|
|
|
|
-const code = ref('')
|
|
|
+const node = computed(() => {
|
|
|
+ return store.selectedNode;
|
|
|
+});
|
|
|
+
|
|
|
+const code = computed(():string => {
|
|
|
+ if(!node.value)
|
|
|
+ return "";
|
|
|
+ if(!node.value.nodeId.value)
|
|
|
+ return "";
|
|
|
+ const m=store.mapping.get(node.value.nodeId.value.toString());
|
|
|
+ if(m)
|
|
|
+ return m.read;
|
|
|
+ return "";
|
|
|
+});
|
|
|
+
|
|
|
const editorRef = shallowRef()
|
|
|
-const handleMount = (editor: any) => (editorRef.value = editor)
|
|
|
+const handleMount = (editor: any) => {
|
|
|
+ editorRef.value = editor
|
|
|
+
|
|
|
+}
|
|
|
|
|
|
const onChange = (value: string | undefined, event: monaco.editor.IModelContentChangedEvent) => {
|
|
|
if(!store.selectedNode)
|