feat: implement image preview

Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
2026-08-29 12:22:13 -04:00
parent c32906bc12
commit 0ceb6808c4
3 changed files with 104 additions and 8 deletions
+18 -3
View File
@@ -132,6 +132,19 @@ function resolveViewerSource(item: ViewerItem): string {
return documentManager.getEntityUrl(item.id, (item.meta?.collection as string | null) ?? null)
}
function resolvePreviewSource(item: ViewerItem): string {
return documentManager.getEntityPreviewUrl(item.id, (item.meta?.collection as string | null) ?? null)
}
// Preview shown in the info panel sidebar for the current single selection
const infoPanelPreviewUrl = computed<string | null>(() => {
const items = selection.selectedNodeArray.value
if (items.length !== 1) return null
const item = items[0]
if (!(item instanceof EntityObject)) return null
return documentManager.getEntityPreviewUrl(nodeId(item), item.collection ? String(item.collection) : null)
})
function downloadViewerItem(item: ViewerItem): void {
documentManager.downloadEntity(item.id, (item.meta?.collection as string | null) ?? null)
}
@@ -782,7 +795,7 @@ onMounted(async () => {
:collections="sortedItems.collections"
:entities="sortedItems.entities"
:selected-ids="selectedIds"
:preview-source="resolveViewerSource"
:preview-source="resolvePreviewSource"
@item-click="handleItemClick"
@open="handleOpenItem"
@edit="handleEditItem"
@@ -798,7 +811,7 @@ onMounted(async () => {
:collections="sortedItems.collections"
:entities="sortedItems.entities"
:selected-ids="selectedIds"
:preview-source="resolveViewerSource"
:preview-source="resolvePreviewSource"
@item-click="handleItemClick"
@open="handleOpenItem"
@edit="handleEditItem"
@@ -814,7 +827,7 @@ onMounted(async () => {
:collections="sortedItems.collections"
:entities="sortedItems.entities"
:selected-ids="selectedIds"
:preview-source="resolveViewerSource"
:preview-source="resolvePreviewSource"
@item-click="handleItemClick"
@open="handleOpenItem"
@edit="handleEditItem"
@@ -830,6 +843,7 @@ onMounted(async () => {
v-if="hasSelection && !isMobile"
embedded
:selected-items="selection.selectedNodeArray.value"
:preview-url="infoPanelPreviewUrl"
@close="selection.clear()"
/>
</div>
@@ -838,6 +852,7 @@ onMounted(async () => {
<FilesInfoPanel
v-if="isMobile"
:selected-items="selection.selectedNodeArray.value"
:preview-url="infoPanelPreviewUrl"
@close="selection.clear()"
/>
</div>