documentsmanager

This commit is contained in:
2025-11-19 23:36:04 +01:00
parent e1b47ed153
commit b76f1df27f
17 changed files with 564 additions and 300 deletions
+32 -9
View File
@@ -253,12 +253,35 @@ const DocumentViewerPanel: React.FC<DocumentViewerPanelProps> = ({
const [zoomOverlayOpen, setZoomOverlayOpen] = useState(false);
const fallbackDocumentLink = useMemo(() => {
if (!document) {
return null;
}
const downloadPath = document.current_version?.download_path;
if (!downloadPath) {
return null;
}
const href = resolveApiPath ? resolveApiPath(downloadPath) : downloadPath;
if (!href) {
return null;
}
const contentType = document.current_version?.version?.content_type || document.content_type || null;
const filename = document.current_version?.filename || document.filename || document.title || null;
return {
url: href,
contentType,
filename,
};
}, [document, resolveApiPath]);
const effectiveDocumentLink = documentLink?.url ? documentLink : fallbackDocumentLink;
const handleZoomOpen = useCallback(() => {
if (!documentLink?.url) {
if (!effectiveDocumentLink?.url) {
return;
}
setZoomOverlayOpen(true);
}, [documentLink?.url]);
}, [effectiveDocumentLink?.url]);
const handleZoomClose = useCallback(() => {
setZoomOverlayOpen(false);
@@ -266,7 +289,7 @@ const DocumentViewerPanel: React.FC<DocumentViewerPanelProps> = ({
useEffect(() => {
setZoomOverlayOpen(false);
}, [documentLink?.url, document?.id]);
}, [effectiveDocumentLink?.url, document?.id]);
useEffect(() => {
if (hydrateDocument && document?.id) {
@@ -355,23 +378,23 @@ const DocumentViewerPanel: React.FC<DocumentViewerPanelProps> = ({
}, [breadcrumbs, handleBreadcrumbNavigate]);
const zoomDisplay = useMemo(() => {
if (!documentLink?.url || !document) {
if (!effectiveDocumentLink?.url || !document) {
return null;
}
const docContentType = document.content_type;
const versionContentType = document.current_version?.version?.content_type;
const normalizedContentType = documentLink.contentType || docContentType || versionContentType || null;
const normalizedContentType = effectiveDocumentLink.contentType || docContentType || versionContentType || null;
return {
url: documentLink.url,
url: effectiveDocumentLink.url,
alt: document.title,
contentType: normalizedContentType || undefined,
};
}, [documentLink?.url, documentLink?.contentType, document]);
}, [effectiveDocumentLink?.url, effectiveDocumentLink?.contentType, document]);
const headerActions = createDocumentViewerHeaderActions({
document,
actionState,
documentLink,
documentLink: effectiveDocumentLink,
onZoom: zoomDisplay ? handleZoomOpen : null,
canZoom: Boolean(zoomDisplay),
});
@@ -471,7 +494,7 @@ const DocumentViewerPanel: React.FC<DocumentViewerPanelProps> = ({
<section className={viewerClassName}>
<DocumentViewerLayout
document={document}
documentLink={documentLink}
documentLink={effectiveDocumentLink}
summaryProps={summaryProps}
metadataPayload={metadataPayload}
contentTabConfig={contentTabConfig}