- 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.1 KiB
TypeScript
42 lines
1.1 KiB
TypeScript
import { displayFileName } from "@/lib/drive/display-file-name"
|
|
|
|
/** Next "Type sans titre" / "Type sans titre N" label for a folder listing. */
|
|
export function nextUntitledName(
|
|
siblingNames: string[],
|
|
typeLabel: string,
|
|
ext = ""
|
|
): string {
|
|
const base = `${typeLabel} sans titre`
|
|
const normalized = siblingNames.map((n) => displayFileName(n))
|
|
const hasExact = (candidate: string) =>
|
|
normalized.some((n) => n === candidate || n === candidate + ext)
|
|
|
|
if (!hasExact(base)) {
|
|
return ext ? `${base}${ext}` : base
|
|
}
|
|
|
|
let n = 2
|
|
while (hasExact(`${base} ${n}`)) {
|
|
n += 1
|
|
}
|
|
return ext ? `${base} ${n}${ext}` : `${base} ${n}`
|
|
}
|
|
|
|
export function resolveRenameName(file: { name: string; type: string }, input: string): string {
|
|
const trimmed = input.trim()
|
|
if (!trimmed) {
|
|
throw new Error("Nom vide")
|
|
}
|
|
const safe = trimmed.replace(/\//g, "")
|
|
if (file.type === "directory") {
|
|
return safe
|
|
}
|
|
const rawName = displayFileName(file.name)
|
|
const dot = rawName.lastIndexOf(".")
|
|
const ext = dot > 0 ? rawName.slice(dot) : ""
|
|
if (ext && !safe.endsWith(ext)) {
|
|
return safe + ext
|
|
}
|
|
return safe
|
|
}
|