feat: implement common file preview component
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
+26
-3
@@ -129,11 +129,27 @@ function entityToViewerItem(entity: EntityObject): ViewerItem {
|
||||
}
|
||||
|
||||
function resolveViewerSource(item: ViewerItem): string {
|
||||
return documentManager.getEntityUrl(item.id, (item.meta?.collection as string | null) ?? null)
|
||||
return documentManager.getEntityPreviewUrl(
|
||||
item.id,
|
||||
(item.meta?.collection as string | null) ?? null,
|
||||
'fullscreen',
|
||||
)
|
||||
}
|
||||
|
||||
function resolvePreviewSource(item: ViewerItem): string {
|
||||
return documentManager.getEntityPreviewUrl(item.id, (item.meta?.collection as string | null) ?? null)
|
||||
return documentManager.getEntityPreviewUrl(
|
||||
item.id,
|
||||
(item.meta?.collection as string | null) ?? null,
|
||||
'inline',
|
||||
)
|
||||
}
|
||||
|
||||
function resolveThumbnailSource(item: ViewerItem): string {
|
||||
return documentManager.getEntityPreviewUrl(
|
||||
item.id,
|
||||
(item.meta?.collection as string | null) ?? null,
|
||||
'thumbnail',
|
||||
)
|
||||
}
|
||||
|
||||
// Preview shown in the info panel sidebar for the current single selection
|
||||
@@ -142,7 +158,11 @@ const infoPanelPreviewUrl = computed<string | null>(() => {
|
||||
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)
|
||||
return documentManager.getEntityPreviewUrl(
|
||||
nodeId(item),
|
||||
item.collection ? String(item.collection) : null,
|
||||
'inline',
|
||||
)
|
||||
})
|
||||
|
||||
function downloadViewerItem(item: ViewerItem): void {
|
||||
@@ -796,6 +816,7 @@ onMounted(async () => {
|
||||
:entities="sortedItems.entities"
|
||||
:selected-ids="selectedIds"
|
||||
:preview-source="resolvePreviewSource"
|
||||
:thumbnail-source="resolveThumbnailSource"
|
||||
@item-click="handleItemClick"
|
||||
@open="handleOpenItem"
|
||||
@edit="handleEditItem"
|
||||
@@ -812,6 +833,7 @@ onMounted(async () => {
|
||||
:entities="sortedItems.entities"
|
||||
:selected-ids="selectedIds"
|
||||
:preview-source="resolvePreviewSource"
|
||||
:thumbnail-source="resolveThumbnailSource"
|
||||
@item-click="handleItemClick"
|
||||
@open="handleOpenItem"
|
||||
@edit="handleEditItem"
|
||||
@@ -828,6 +850,7 @@ onMounted(async () => {
|
||||
:entities="sortedItems.entities"
|
||||
:selected-ids="selectedIds"
|
||||
:preview-source="resolvePreviewSource"
|
||||
:thumbnail-source="resolveThumbnailSource"
|
||||
@item-click="handleItemClick"
|
||||
@open="handleOpenItem"
|
||||
@edit="handleEditItem"
|
||||
|
||||
Reference in New Issue
Block a user