-
-
Notifications
You must be signed in to change notification settings - Fork 261
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
13fed0a
commit e1c28a2
Showing
1 changed file
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
--- | ||
'@vue-flow/core': patch | ||
--- | ||
|
||
# What's changed? | ||
|
||
- Simplify `useHandle` usage | ||
- Pass props to the composable as possible refs | ||
- Still returns onClick & onMouseDown handlers but only expects mouse event now | ||
|
||
Before: | ||
```vue | ||
<script lang="ts" setup> | ||
import { useHandle, NodeId } from '@vue-flow/core' | ||
const nodeId = inject(NodeId) | ||
const handleId = 'my-handle' | ||
const type = 'source' | ||
const isValidConnection = () => true | ||
const { onMouseDown } = useHandle() | ||
const onMouseDownHandler = (event: MouseEvent) => { | ||
onMouseDown(event, handleId, nodeId, type === 'target', isValidConnection, undefined) | ||
} | ||
</script> | ||
<template> | ||
<div @mousedown="onMouseDownHandler" /> | ||
</template> | ||
``` | ||
|
||
After: | ||
```vue | ||
<script lang="ts" setup> | ||
import { useHandle, useNode } from '@vue-flow/core' | ||
const { nodeId } = useNode() | ||
const handleId = 'my-handle' | ||
const type = 'source' | ||
const isValidConnection = () => true | ||
const { onMouseDown } = useHandle({ | ||
nodeId, | ||
handleId, | ||
isValidConnection, | ||
type, | ||
}) | ||
</script> | ||
<template> | ||
<div @mousedown="onMouseDown" /> | ||
</template> | ||
``` |