- 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.
42 lines
1.3 KiB
TypeScript
42 lines
1.3 KiB
TypeScript
import type { DriveMoveSource } from "@/lib/drive/drive-move-items"
|
|
|
|
export const DRIVE_DND_TYPE = "application/x-ultimail-drive-items"
|
|
|
|
export type DriveDragItem = Pick<DriveMoveSource, "path" | "name" | "type">
|
|
|
|
export function setDriveDragData(dataTransfer: DataTransfer, items: DriveDragItem[]): void {
|
|
dataTransfer.setData(DRIVE_DND_TYPE, JSON.stringify(items))
|
|
dataTransfer.setData("text/plain", items.map((item) => item.path).join("\n"))
|
|
dataTransfer.effectAllowed = "move"
|
|
}
|
|
|
|
export function getDriveDragData(dataTransfer: DataTransfer): DriveDragItem[] | null {
|
|
const raw = dataTransfer.getData(DRIVE_DND_TYPE)
|
|
if (!raw) return null
|
|
try {
|
|
const parsed = JSON.parse(raw) as DriveDragItem[]
|
|
if (!Array.isArray(parsed) || parsed.length === 0) return null
|
|
return parsed.filter(
|
|
(item) =>
|
|
item &&
|
|
typeof item.path === "string" &&
|
|
typeof item.name === "string" &&
|
|
(item.type === "file" || item.type === "directory")
|
|
)
|
|
} catch {
|
|
return null
|
|
}
|
|
}
|
|
|
|
export function resolveDragSources(
|
|
file: DriveDragItem,
|
|
selectedPaths: Set<string>,
|
|
allItems: DriveDragItem[]
|
|
): DriveDragItem[] {
|
|
if (selectedPaths.has(file.path) && selectedPaths.size > 1) {
|
|
const selected = allItems.filter((item) => selectedPaths.has(item.path))
|
|
if (selected.length > 0) return selected
|
|
}
|
|
return [file]
|
|
}
|