- Updated .env.example to include configuration for OnlyOffice Document Server. - Modified the workspace configuration to remove the drive-suite path. - Adjusted TypeScript environment imports for consistency. - Enhanced Next.js configuration to disable canvas in Webpack. - Updated package.json to include new dependencies for OnlyOffice and PDF.js. - Added global styles for OnlyOffice theme integration in the CSS. - Created new layout and page components for the Drive feature, including public sharing and editing functionalities. - Updated metadata handling across various layouts to reflect the new app structure.
60 lines
1.7 KiB
TypeScript
60 lines
1.7 KiB
TypeScript
"use client"
|
|
|
|
import { useCallback } from "react"
|
|
import type { DriveFileInfo } from "@/lib/api/types"
|
|
import { applyDriveDragPreview, removeDriveDragPreview } from "@/lib/drive/drive-drag-preview"
|
|
import { resolveDragSources, setDriveDragData } from "@/lib/drive/drive-dnd"
|
|
import { isFromDriveMenu } from "@/lib/drive/drive-menu-guard"
|
|
import { useDriveUIStore } from "@/lib/stores/drive-ui-store"
|
|
|
|
export function useDriveDragSource({
|
|
file,
|
|
allItems,
|
|
disabled,
|
|
}: {
|
|
file: DriveFileInfo
|
|
allItems: DriveFileInfo[]
|
|
disabled?: boolean
|
|
}) {
|
|
const selectedPaths = useDriveUIStore((s) => s.selectedPaths)
|
|
const setDraggingItems = useDriveUIStore((s) => s.setDraggingItems)
|
|
|
|
const onDragStart = useCallback(
|
|
(event: React.DragEvent) => {
|
|
if (disabled || isFromDriveMenu(event.target)) {
|
|
event.preventDefault()
|
|
return
|
|
}
|
|
const sources = resolveDragSources(file, selectedPaths, allItems)
|
|
const previewFiles = sources
|
|
.map((s) => allItems.find((i) => i.path === s.path))
|
|
.filter((f): f is DriveFileInfo => Boolean(f))
|
|
setDriveDragData(event.dataTransfer, sources)
|
|
applyDriveDragPreview(
|
|
event.dataTransfer,
|
|
previewFiles.length > 0 ? previewFiles : [file],
|
|
event.currentTarget as HTMLElement
|
|
)
|
|
setDraggingItems(sources)
|
|
},
|
|
[allItems, disabled, file, selectedPaths, setDraggingItems]
|
|
)
|
|
|
|
const onDragEnd = useCallback(() => {
|
|
removeDriveDragPreview()
|
|
setDraggingItems(null)
|
|
}, [setDraggingItems])
|
|
|
|
if (disabled) {
|
|
return { dragProps: {} as const }
|
|
}
|
|
|
|
return {
|
|
dragProps: {
|
|
draggable: true,
|
|
onDragStart,
|
|
onDragEnd,
|
|
} as const,
|
|
}
|
|
}
|