import { create } from "@bufbuild/protobuf"; import { FileIcon } from "lucide-react"; import { extractMemoIdFromName } from "@/helpers/resource-names"; import { cn } from "@/lib/utils"; import type { Attachment } from "@/types/proto/api/v1/attachment_service_pb"; import { MemoSchema } from "@/types/proto/api/v1/memo_service_pb"; import type { User } from "@/types/proto/api/v1/user_service_pb"; import { getAttachmentType, getAttachmentUrl } from "@/utils/attachment"; import MemoContent from "../MemoContent"; import { MemoViewContext, type MemoViewContextValue } from "../MemoView/MemoViewContext"; interface MemoPreviewProps { content: string; attachments: Attachment[]; name?: string; compact?: boolean; className?: string; creator?: User; showCreator?: boolean; showMemoId?: boolean; truncate?: boolean; } const STUB_CONTEXT: MemoViewContextValue = { memo: create(MemoSchema), creator: undefined, currentUser: undefined, parentPage: "/", isArchived: false, readonly: true, showBlurredContent: false, blurred: false, openEditor: () => {}, toggleBlurVisibility: () => {}, openPreview: () => {}, }; const AttachmentThumbnails = ({ attachments }: { attachments: Attachment[] }) => { const images: Attachment[] = []; const others: Attachment[] = []; for (const a of attachments) { if (getAttachmentType(a) === "image/*") images.push(a); else others.push(a); } return (