chore(docs): cleanup examples
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
<script lang="ts" setup>
|
||||
import { VueFlow } from '@vue-flow/core'
|
||||
import { ref } from 'vue'
|
||||
import { VueFlow } from '@vue-flow/core'
|
||||
import SaveRestoreControls from './Controls.vue'
|
||||
|
||||
const elements = ref([{ id: '1', label: 'Node 1', position: { x: 100, y: 100 } }])
|
||||
const nodes = ref([{ id: '1', label: 'Node 1', position: { x: 100, y: 100 } }])
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<VueFlow v-model="elements">
|
||||
<VueFlow :nodes="nodes">
|
||||
<SaveRestoreControls />
|
||||
</VueFlow>
|
||||
</template>
|
||||
|
||||
@@ -3,7 +3,7 @@ import { Panel, useVueFlow } from '@vue-flow/core'
|
||||
|
||||
const flowKey = 'example-flow'
|
||||
|
||||
const { nodes, addNodes, setNodes, setEdges, dimensions, setTransform, toObject } = useVueFlow()
|
||||
const { nodes, addNodes, dimensions, toObject, fromObject } = useVueFlow()
|
||||
|
||||
function onSave() {
|
||||
localStorage.setItem(flowKey, JSON.stringify(toObject()))
|
||||
@@ -13,10 +13,7 @@ function onRestore() {
|
||||
const flow = JSON.parse(localStorage.getItem(flowKey))
|
||||
|
||||
if (flow) {
|
||||
const [x = 0, y = 0] = flow.position
|
||||
setNodes(flow.nodes)
|
||||
setEdges(flow.edges)
|
||||
setTransform({ x, y, zoom: flow.zoom || 0 })
|
||||
fromObject(flow)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user