chore(core): cleanup
This commit is contained in:
@@ -3,3 +3,17 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
Add `updateNode` action
|
Add `updateNode` action
|
||||||
|
|
||||||
|
## 🧙 Example
|
||||||
|
|
||||||
|
```ts
|
||||||
|
const { updateNode } = useVueFlow()
|
||||||
|
|
||||||
|
updateNode('1', { position: { x: 100, y: 100 } })
|
||||||
|
|
||||||
|
// or using a function to update the node
|
||||||
|
updateNode('1', (node) => ({ ...node, position: { x: 100, y: 100 } }))
|
||||||
|
|
||||||
|
// passing options - `replace` will replace the node instead of merging it
|
||||||
|
updateNode('1', { id: '1', label: 'Node 1', position: { x: 100, y: 100 } }, { replace: true })
|
||||||
|
```
|
||||||
|
|||||||
@@ -3,3 +3,17 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
Add `updateNodeData` action
|
Add `updateNodeData` action
|
||||||
|
|
||||||
|
## 🧙 Example
|
||||||
|
|
||||||
|
```ts
|
||||||
|
const { updateNodeData } = useVueFlow()
|
||||||
|
|
||||||
|
updateNodeData('1', { foo: 'bar' })
|
||||||
|
|
||||||
|
// or using a function to update the data
|
||||||
|
updateNodeData('1', (data) => ({ ...data, foo: 'bar' }))
|
||||||
|
|
||||||
|
// passing options - `replace` will replace the data instead of merging it
|
||||||
|
updateNodeData('1', { foo: 'bar' }, { replace: true })
|
||||||
|
```
|
||||||
|
|||||||
@@ -601,7 +601,7 @@ export function useActions(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// todo: maybe we should use a more immutable approach, this is a bit too much mutation and hard to maintain
|
// todo: maybe we should use a more immutable approach, this is a bit too much mutation and hard to maintain
|
||||||
const updateNode: Actions['updateNode'] = (id, nodeUpdate, options = { replace: true }) => {
|
const updateNode: Actions['updateNode'] = (id, nodeUpdate, options = { replace: false }) => {
|
||||||
const node = findNode(id)
|
const node = findNode(id)
|
||||||
|
|
||||||
if (!node) {
|
if (!node) {
|
||||||
|
|||||||
Reference in New Issue
Block a user