This commit is contained in:
Max Leiter 2023-01-28 23:57:35 -08:00
parent f3d588c0eb
commit eda977b203
4 changed files with 12 additions and 8 deletions

View file

@ -14,7 +14,7 @@ type Props = RadixTabs.TabsProps & {
onPaste?: (e: ClipboardEvent<HTMLTextAreaElement>) => void onPaste?: (e: ClipboardEvent<HTMLTextAreaElement>) => void
title?: string title?: string
staticPreview?: string staticPreview?: string
children: string; children: string
} }
export default function DocumentTabs({ export default function DocumentTabs({
@ -83,9 +83,11 @@ export default function DocumentTabs({
</RadixTabs.Content> </RadixTabs.Content>
<RadixTabs.Content value="preview"> <RadixTabs.Content value="preview">
{isEditing ? ( {isEditing ? (
<Preview height={"100%"} title={title}>{children}</Preview> <Preview height={"100%"} title={title}>
{children}
</Preview>
) : ( ) : (
<StaticPreview height={"100%"}>{preview}</StaticPreview> <StaticPreview height={"100%"}>{preview || ""}</StaticPreview>
)} )}
</RadixTabs.Content> </RadixTabs.Content>
</RadixTabs.Root> </RadixTabs.Root>

View file

@ -106,16 +106,17 @@ const Document = ({ skeleton, ...props }: Props) => {
> >
{title} {title}
</Link> </Link>
{/* Not /api/ because of rewrites defined in next.config.mjs */}
<DownloadButtons rawLink={`/file/raw/${id}`} /> <DownloadButtons rawLink={`/file/raw/${id}`} />
</header> </header>
<div className={styles.documentContainer}> <div className={styles.documentContainer}>
{/* Not /api/ because of rewrites defined in next.config.mjs */}
<DocumentTabs <DocumentTabs
defaultTab={initialTab} defaultTab={initialTab}
staticPreview={preview} staticPreview={preview}
content={content}
isEditing={false} isEditing={false}
/> >
{content || ""}
</DocumentTabs>
</div> </div>
</div> </div>
</> </>

View file

@ -17,7 +17,7 @@ const actions = [
const handler = async (req: NextApiRequest, res: NextApiResponse) => { const handler = async (req: NextApiRequest, res: NextApiResponse) => {
const { action: requestedAction } = req.query const { action: requestedAction } = req.query
const action = parseQueryParam(requestedAction) as typeof actions[number] const action = parseQueryParam(requestedAction) as (typeof actions)[number]
if (!action || !actions.includes(action)) { if (!action || !actions.includes(action)) {
res.status(400).json({ error: "Invalid action" }) res.status(400).json({ error: "Invalid action" })

View file

@ -135,7 +135,8 @@ export default async function handler(req: NextRequest) {
), ),
{ {
width: WIDTH, width: WIDTH,
height: HEIGHT, height: HEIGHT
// debug: true // debug: true
} }
) )