Add drop handler

This commit is contained in:
huchenlei
2024-08-31 20:40:14 -04:00
committed by Chenlei Hu
parent 86e7c12e27
commit bc7da487e8
2 changed files with 6 additions and 0 deletions

View File

@@ -84,6 +84,7 @@ onMounted(() => {
onDrop: (event) => {
const dndData = event.source.data as TreeExplorerDragAndDropData
if (dndData.type === 'tree-explorer-node') {
props.node.handleDrop?.(props.node, dndData)
canDrop.value = false
emit('itemDropped', props.node, dndData.data)
}

View File

@@ -19,6 +19,11 @@ export interface TreeExplorerNode<T = any> {
draggable?: boolean
// Whether the node is droppable
droppable?: boolean
// Function to handle dropping a node
handleDrop?: (
node: TreeExplorerNode<T>,
data: TreeExplorerDragAndDropData
) => void
}
export interface RenderedTreeExplorerNode<T = any> extends TreeExplorerNode<T> {