24 lines
876 B
TypeScript
24 lines
876 B
TypeScript
"use client"
|
|
|
|
import { useParams, useSearchParams } from "next/navigation"
|
|
import { OfficeEditor } from "@/components/drive/office-editor"
|
|
import { RichTextEditor } from "@/components/drive/richtext-editor"
|
|
import { shouldOpenInRichTextEditor } from "@/lib/drive/drive-preview"
|
|
|
|
export default function DriveEditPage() {
|
|
const params = useParams()
|
|
const searchParams = useSearchParams()
|
|
const filePath = decodeURIComponent(params.fileId as string)
|
|
const returnTo = searchParams.get("returnTo")
|
|
const editorParam = searchParams.get("editor")
|
|
const fileName = filePath.split("/").pop() ?? filePath
|
|
const useRichText =
|
|
editorParam === "richtext" || shouldOpenInRichTextEditor({ name: fileName })
|
|
|
|
if (useRichText) {
|
|
return <RichTextEditor filePath={filePath} returnTo={returnTo} />
|
|
}
|
|
|
|
return <OfficeEditor filePath={filePath} returnTo={returnTo} />
|
|
}
|