fix: editor layout and SceneGraph refinements
This commit is contained in:
@@ -7,7 +7,7 @@ import '@vue-flow/core/dist/style.css'
|
||||
import '@vue-flow/controls/dist/style.css'
|
||||
import '@vue-flow/core/dist/theme-default.css'
|
||||
import type { Connection } from '@vue-flow/core'
|
||||
import { computePositions } from '../composables/useLayout'
|
||||
import { computePositions, savePosition } from '../composables/useLayout'
|
||||
|
||||
const props = defineProps<{
|
||||
sceneNodes: { id: string; label: string }[]
|
||||
@@ -24,7 +24,7 @@ const emit = defineEmits<{
|
||||
|
||||
const nodes = ref<any[]>([])
|
||||
const edges = ref<any[]>([])
|
||||
const { onNodeClick, onConnect, onNodeContextMenu, fitView } = useVueFlow()
|
||||
const { onNodeClick, onConnect, onNodeContextMenu, onNodeDragStop, fitView } = useVueFlow()
|
||||
const ctxMenuVisible = ref(false)
|
||||
const ctxMenuX = ref(0)
|
||||
const ctxMenuY = ref(0)
|
||||
@@ -130,6 +130,11 @@ function closeMenu() {
|
||||
ctxMenuVisible.value = false
|
||||
}
|
||||
|
||||
onNodeDragStop((ev) => {
|
||||
const pos = ev.node.position
|
||||
savePosition(ev.node.id, Math.round(pos.x), Math.round(pos.y))
|
||||
})
|
||||
|
||||
onConnect((conn: Connection) => {
|
||||
if (conn.source && conn.target) emit('addEdge', conn.source, conn.target)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user