- 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.
41 lines
1.5 KiB
TypeScript
41 lines
1.5 KiB
TypeScript
import type { DriveView } from "@/lib/drive/drive-url"
|
|
import { decodePathSegment, encodePathSegments, folderPathFromSegments } from "@/lib/drive/drive-url"
|
|
|
|
export function normalizeDriveFolderPath(path: string): string {
|
|
if (!path || path === "/") return "/"
|
|
return "/" + path.replace(/^\/+/, "").replace(/\/+$/, "")
|
|
}
|
|
|
|
export function driveFolderHref(view: DriveView, folderPath: string): string {
|
|
const normalized = normalizeDriveFolderPath(folderPath)
|
|
if (normalized === "/") {
|
|
return view === "shared" ? "/drive/shared" : "/drive"
|
|
}
|
|
const segments = normalized
|
|
.slice(1)
|
|
.split("/")
|
|
.map(decodePathSegment)
|
|
const encoded = encodePathSegments(segments)
|
|
return view === "shared" ? `/drive/shared/folders/${encoded}` : `/drive/folders/${encoded}`
|
|
}
|
|
|
|
export function ancestorFolderPaths(folderPath: string): string[] {
|
|
const normalized = normalizeDriveFolderPath(folderPath)
|
|
if (normalized === "/") return ["/"]
|
|
const parts = normalized.slice(1).split("/")
|
|
const out: string[] = ["/"]
|
|
for (let i = 0; i < parts.length; i++) {
|
|
out.push("/" + parts.slice(0, i + 1).join("/"))
|
|
}
|
|
return out
|
|
}
|
|
|
|
export function selectedFolderPath(view: DriveView, pathSegments: string[]): string {
|
|
if (view === "shared" && pathSegments.length === 0) return "/__shared_root__"
|
|
return folderPathFromSegments(pathSegments)
|
|
}
|
|
|
|
export function isSharedRootSelected(view: DriveView, pathSegments: string[]): boolean {
|
|
return view === "shared" && pathSegments.length === 0
|
|
}
|