doocus improvemnts

This commit is contained in:
Mariano Gabriel
2026-07-05 20:35:44 -03:00
parent 7b276e8f3d
commit 8606520ef2
22 changed files with 1328 additions and 61 deletions

View File

@@ -62,6 +62,7 @@ interface State {
loading: boolean
selected: Set<string>
collapsed: Set<string> // collapsed folder paths (folders default open)
detailCollapsed: boolean // bottom viewer collapsed to a bar
targetKey: string
error: string
}
@@ -76,6 +77,7 @@ export const store = reactive<State>({
loading: false,
selected: new Set<string>(),
collapsed: new Set<string>(),
detailCollapsed: false,
targetKey: TARGETS[0].key,
error: '',
})
@@ -163,3 +165,26 @@ export function humanBytes(n: number): string {
if (n < 1024 * 1024) return `${(n / 1024).toFixed(1)} KB`
return `${(n / 1024 / 1024).toFixed(1)} MB`
}
export type ViewerKind =
| 'pdf' | 'image' | 'html' | 'markdown' | 'code' | 'docx' | 'xlsx' | 'pptx' | 'video' | 'unhandled'
/** Single source of truth for how a file is viewed — shared by the tree (to flag
* unhandled types) and the viewer. 'unhandled' = no inline view; default action
* is to open the original file (or the Drive link once we have it). */
export function kindFor(ext: string): ViewerKind {
if (ext === 'pdf') return 'pdf'
if (['png', 'jpg', 'jpeg', 'gif', 'webp', 'svg'].includes(ext)) return 'image'
if (['html', 'htm'].includes(ext)) return 'html'
if (['md', 'markdown'].includes(ext)) return 'markdown'
if (['txt', 'json', 'yaml', 'yml', 'csv', 'log', 'ini', 'xml', 'toml'].includes(ext)) return 'code'
if (ext === 'docx') return 'docx'
if (ext === 'xlsx') return 'xlsx'
if (ext === 'pptx') return 'pptx'
if (['mp4', 'mkv', 'mov', 'm4v', 'webm', 'avi', 'wmv'].includes(ext)) return 'video'
return 'unhandled'
}
export function isUnhandled(node: FileNode): boolean {
return node.mode !== 'meeting' && kindFor(node.ext) === 'unhandled'
}