ultisuite-client/lib/drive/public-share-url.ts
R3D347HR4Y 6ec95262af Add OnlyOffice integration and update project configurations
- 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.
2026-06-07 15:49:21 +02:00

39 lines
1.2 KiB
TypeScript

export function buildPublicShareEditHref(
token: string,
filePath: string,
returnTo?: string,
mode: "edit" | "view" = "edit"
): string {
const trimmed = filePath.replace(/^\/+|\/+$/g, "")
const base = `/drive/s/${encodeURIComponent(token)}/edit/${trimmed.split("/").map(encodeURIComponent).join("/")}`
const params = new URLSearchParams()
if (returnTo && returnTo.startsWith("/drive/s/")) {
params.set("returnTo", returnTo)
}
if (mode === "view") {
params.set("mode", "view")
}
const qs = params.toString()
return qs ? `${base}?${qs}` : base
}
export function resolvePublicShareEditReturnTo(
token: string,
returnTo: string | null | undefined,
filePath: string
): string {
if (returnTo && returnTo.startsWith("/drive/s/")) return returnTo
const parent = filePath.replace(/\/[^/]+$/, "") || "/"
const trimmed = parent.replace(/^\/+|\/+$/g, "")
if (!trimmed) return `/drive/s/${encodeURIComponent(token)}`
return `/drive/s/${encodeURIComponent(token)}/${trimmed.split("/").map(encodeURIComponent).join("/")}`
}
export function filePathFromPublicEditSegments(
token: string,
segments: string[] | undefined
): string {
if (!segments?.length) return "/"
return "/" + segments.map((s) => decodeURIComponent(s)).join("/")
}