Skip to content
Source
Sign inSign up

attachmentDocumentPresentation.ts

20 lines542 Bytes

1import type { FilePreviewKind } from "@t3tools/shared/filePreview";
2​
3export function attachmentDocumentPresentation(input: {
4 kind: FilePreviewKind;
5 hasTable: boolean;
6 hasEnvironment: boolean;
7 rendered: boolean;
8}) {
9 const renderedMode = input.hasTable
10 ? "table"
11 : input.kind === "markdown" && input.hasEnvironment
12 ? "markdown"
13 : input.kind === "html"
14 ? "html"
15 : null;
16 return {
17 renderedMode,
18 activeMode: input.rendered && renderedMode !== null ? renderedMode : "source",
19 } as const;