update: Flow instance provides update node internals func

* Rename onLoadParams to FlowInstance
* Pass update node internals to instance
This commit is contained in:
Braks
2021-10-22 12:39:55 +02:00
parent cd32f14a5a
commit babcbd0e1f
23 changed files with 149 additions and 46 deletions
+3 -3
View File
@@ -7,7 +7,7 @@ import Flow, {
Edge,
Elements,
FlowElement,
OnLoadParams,
FlowInstance,
addEdge,
isNode,
removeElements,
@@ -24,11 +24,11 @@ const elements = ref<Elements>([
{ id: 'e1-2', source: '1', target: '2', animated: true },
{ id: 'e1-3', source: '1', target: '3' },
] as Elements)
const rfInstance = ref<OnLoadParams | null>(null)
const rfInstance = ref<FlowInstance | null>(null)
const onElementsRemove = (elementsToRemove: Elements) =>
(elements.value = removeElements(elementsToRemove, elements.value as Elements))
const onConnect = (params: Edge | Connection) => (elements.value = addEdge(params, elements.value as Elements))
const onLoad = (flowInstance: OnLoadParams) => {
const onLoad = (flowInstance: FlowInstance) => {
flowInstance.fitView({ padding: 0.1 })
rfInstance.value = flowInstance
}