mirror of
https://github.com/langgenius/dify.git
synced 2026-05-06 02:18:08 +08:00
Switch from native HTML5 drag to react-arborist's built-in drag system for internal node drag-and-drop. The HTML5Backend used by react-arborist was intercepting dragstart events, preventing native drag from working. - Add onMove callback and disableDrop validation to Tree component - Sync react-arborist drag state (isDragging, willReceiveDrop) to Zustand - Simplify use-node-move to only handle API execution - Update use-unified-drag to only handle external file uploads - External file drops continue to work via native HTML5 events
41 lines
1.1 KiB
TypeScript
41 lines
1.1 KiB
TypeScript
'use client'
|
|
|
|
// Unified drag handler for external file uploads
|
|
// Internal node drag-move is now handled by react-arborist's built-in drag system
|
|
|
|
import { useCallback } from 'react'
|
|
import { isFileDrag } from '../utils/drag-utils'
|
|
import { useFileDrop } from './use-file-drop'
|
|
|
|
type DragTarget = {
|
|
folderId: string | null
|
|
isFolder: boolean
|
|
}
|
|
|
|
export function useUnifiedDrag() {
|
|
const fileDrop = useFileDrop()
|
|
|
|
// Only handle external file drags - internal node drags are handled by react-arborist
|
|
const handleDragOver = useCallback((e: React.DragEvent, target: DragTarget) => {
|
|
if (isFileDrag(e))
|
|
fileDrop.handleDragOver(e, target)
|
|
}, [fileDrop])
|
|
|
|
const handleDragLeave = useCallback((e: React.DragEvent) => {
|
|
if (isFileDrag(e))
|
|
fileDrop.handleDragLeave(e)
|
|
}, [fileDrop])
|
|
|
|
const handleDrop = useCallback((e: React.DragEvent, targetFolderId: string | null) => {
|
|
if (isFileDrag(e))
|
|
return fileDrop.handleDrop(e, targetFolderId)
|
|
}, [fileDrop])
|
|
|
|
return {
|
|
handleDragOver,
|
|
handleDragLeave,
|
|
handleDrop,
|
|
isUploading: fileDrop.isUploading,
|
|
}
|
|
}
|