({
tabPath,
vaultRoot
}: {
tabPath: string
vaultRoot: string | null
})
| 3484 | } |
| 3485 | |
| 3486 | function AssetTabView({ |
| 3487 | tabPath, |
| 3488 | vaultRoot |
| 3489 | }: { |
| 3490 | tabPath: string |
| 3491 | vaultRoot: string | null |
| 3492 | }): JSX.Element { |
| 3493 | const assetPath = assetPathFromTab(tabPath) |
| 3494 | const title = assetTitleFromPath(assetPath) |
| 3495 | const assetUrl = |
| 3496 | assetPath && vaultRoot ? window.zen.resolveVaultAssetUrl(vaultRoot, assetPath) : null |
| 3497 | const assetKind = assetPath ? classifyLocalAssetHref(assetPath) ?? 'file' : 'file' |
| 3498 | const canReveal = |
| 3499 | !!assetPath && |
| 3500 | window.zen.getAppInfo().runtime === 'desktop' && |
| 3501 | useStore.getState().workspaceMode !== 'remote' |
| 3502 | |
| 3503 | const body = !assetPath || !assetUrl ? ( |
| 3504 | <div className="flex min-h-0 flex-1 items-center justify-center text-sm text-ink-400"> |
| 3505 | Couldn't resolve asset path. |
| 3506 | </div> |
| 3507 | ) : assetKind === 'image' ? ( |
| 3508 | <div className="flex min-h-0 min-w-0 flex-1 items-center justify-center overflow-auto bg-black/5 p-6"> |
| 3509 | <img |
| 3510 | src={assetUrl} |
| 3511 | alt={title} |
| 3512 | className="max-h-full max-w-full rounded-lg object-contain shadow-sm" |
| 3513 | /> |
| 3514 | </div> |
| 3515 | ) : assetKind === 'video' ? ( |
| 3516 | <div className="flex min-h-0 min-w-0 flex-1 items-center justify-center bg-black"> |
| 3517 | <video src={assetUrl} controls className="max-h-full max-w-full" /> |
| 3518 | </div> |
| 3519 | ) : assetKind === 'audio' ? ( |
| 3520 | <div className="flex min-h-0 min-w-0 flex-1 items-center justify-center bg-paper-100/35 p-6"> |
| 3521 | <div className="w-full max-w-md rounded-lg border border-paper-300/70 bg-paper-50/80 p-4 shadow-sm"> |
| 3522 | <div className="mb-3 truncate text-sm font-medium text-ink-900">{title}</div> |
| 3523 | <audio src={assetUrl} controls className="w-full" /> |
| 3524 | </div> |
| 3525 | </div> |
| 3526 | ) : ( |
| 3527 | <iframe |
| 3528 | src={assetUrl} |
| 3529 | title={title} |
| 3530 | className="min-h-0 min-w-0 flex-1 border-0 bg-paper-50" |
| 3531 | /> |
| 3532 | ) |
| 3533 | |
| 3534 | return ( |
| 3535 | <div className="flex min-h-0 min-w-0 flex-1 flex-col"> |
| 3536 | <header className="glass-header flex h-12 shrink-0 items-center justify-between gap-3 border-b border-paper-300/70 px-4"> |
| 3537 | <div className="flex min-w-0 items-center gap-2 text-sm font-semibold text-ink-900"> |
| 3538 | <DocumentIcon width={15} height={15} className="shrink-0 text-accent" /> |
| 3539 | <span className="truncate">{title}</span> |
| 3540 | </div> |
| 3541 | {canReveal && assetPath && ( |
| 3542 | <button |
| 3543 | type="button" |
nothing calls this directly
no test coverage detected