cleanup
This commit is contained in:
@@ -379,14 +379,17 @@ const PdfViewer = ({ src, title, className, viewportRef }: PdfViewerProps): JSX.
|
||||
const stackStyle = useMemo<CSSProperties>(() => ({
|
||||
'--pdf-viewer-viewport-width': `${viewportWidth}px`,
|
||||
'--pdf-viewer-viewport-height': `${viewportHeight}px`,
|
||||
cursor: viewMode === 'fit-width' ? 'zoom-out' : 'zoom-in',
|
||||
}), [viewportHeight, viewportWidth, viewMode]);
|
||||
}), [viewportHeight, viewportWidth]);
|
||||
|
||||
const toggleViewMode = useCallback(() => {
|
||||
setViewMode((prev) => (prev === 'fit-width' ? 'contain' : 'fit-width'));
|
||||
}, []);
|
||||
|
||||
const handlePageClick = useCallback((event: React.MouseEvent<HTMLDivElement>) => {
|
||||
if (!(event.target as HTMLElement).closest('.pdf-viewer__page-wrapper')) {
|
||||
return;
|
||||
}
|
||||
|
||||
const stack = containerRef.current;
|
||||
const viewportElement = viewportRef?.current || stack?.closest('.document-viewer__viewport');
|
||||
if (stack && viewportElement) {
|
||||
|
||||
@@ -45,6 +45,7 @@ const UnifiedDocumentViewer: React.FC<UnifiedDocumentViewerProps> = ({
|
||||
mimeType={normalizedMimeType}
|
||||
filename={normalizedFilename}
|
||||
alt={document.title}
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
/>
|
||||
);
|
||||
}, [
|
||||
|
||||
@@ -24,6 +24,7 @@ const PreviewZoomOverlay: React.FC<PreviewZoomOverlayProps> = ({
|
||||
const [isBackdropVisible, setBackdropVisible] = useState(false);
|
||||
const lastDocumentRef = useRef<Document | null>(null);
|
||||
const scrollRef = useRef<HTMLDivElement | null>(null);
|
||||
const stageRef = useRef<HTMLDivElement | null>(null);
|
||||
const timerRef = useRef<number | null>(null);
|
||||
|
||||
if (inputDocument) {
|
||||
@@ -104,45 +105,43 @@ const PreviewZoomOverlay: React.FC<PreviewZoomOverlayProps> = ({
|
||||
onClick={onClose}
|
||||
onKeyDown={handleKeyDown}
|
||||
>
|
||||
<PanelHeader
|
||||
className="panel-header--dark"
|
||||
title={documentTitle}
|
||||
leading={
|
||||
<>
|
||||
<button
|
||||
onClick={onClose}
|
||||
className="icon-button"
|
||||
aria-label="Close preview"
|
||||
type="button"
|
||||
>
|
||||
<IconX />
|
||||
</button>
|
||||
{onMaximize && (
|
||||
<div onClick={(e) => e.stopPropagation()}>
|
||||
<PanelHeader
|
||||
className="panel-header--dark"
|
||||
title={documentTitle}
|
||||
leading={
|
||||
<>
|
||||
<button
|
||||
onClick={onMaximize}
|
||||
onClick={onClose}
|
||||
className="icon-button"
|
||||
aria-label="Open document info"
|
||||
title="Open document info"
|
||||
aria-label="Close preview"
|
||||
type="button"
|
||||
>
|
||||
<FileInfoIcon />
|
||||
<IconX />
|
||||
</button>
|
||||
)}
|
||||
</>
|
||||
}
|
||||
actions={
|
||||
<>
|
||||
<DocumentDownloadLink document={lastDocumentRef.current} />
|
||||
</>
|
||||
}
|
||||
/>
|
||||
{onMaximize && (
|
||||
<button
|
||||
onClick={onMaximize}
|
||||
className="icon-button"
|
||||
aria-label="Open document info"
|
||||
title="Open document info"
|
||||
type="button"
|
||||
>
|
||||
<FileInfoIcon />
|
||||
</button>
|
||||
)}
|
||||
</>
|
||||
}
|
||||
actions={
|
||||
<>
|
||||
<DocumentDownloadLink document={lastDocumentRef.current} />
|
||||
</>
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
className={stageClassName}
|
||||
onClick={(event) => {
|
||||
if (event.target === event.currentTarget) {
|
||||
onClose();
|
||||
}
|
||||
}}
|
||||
ref={stageRef}
|
||||
>
|
||||
<div
|
||||
className={containerClassName}
|
||||
|
||||
@@ -4,7 +4,7 @@ import { resolveDocumentAssetUrl } from '../../lib/assets/AssetManager';
|
||||
import { useDetailPanel } from '../../app/useDetailPanel';
|
||||
import { DEFAULT_FOLDER_NAME } from '../../app/workspaceUtils';
|
||||
import type { DocumentInfoPanelProps } from '../components/DocumentInfoPanel';
|
||||
import type { EnsureAssetUrl, GetDocumentAsset } from '../../utils/ocr';
|
||||
import type { EnsureAssetUrl, GetAsset } from '../../lib/assets/AssetManager';
|
||||
import type { Identifier } from '../../types/identifiers';
|
||||
import type { Document } from '../../types/documents';
|
||||
|
||||
@@ -29,7 +29,7 @@ interface UseDetailWorkspaceArgs {
|
||||
handleDocumentTagAdd?: (doc: Document, value: string, context?: { option?: unknown }) => void;
|
||||
handleTagRemove?: (...args: unknown[]) => void;
|
||||
ensureAssetUrl?: EnsureAssetUrl;
|
||||
getDocumentAsset?: GetDocumentAsset;
|
||||
getAsset?: GetAsset;
|
||||
correspondents?: unknown[];
|
||||
handleCorrespondentAdd?: (...args: unknown[]) => void;
|
||||
handleCorrespondentRemove?: (...args: unknown[]) => void;
|
||||
@@ -66,7 +66,7 @@ const useDetailWorkspace = ({
|
||||
handleDocumentTagAdd,
|
||||
handleTagRemove,
|
||||
ensureAssetUrl,
|
||||
getDocumentAsset,
|
||||
getAsset,
|
||||
correspondents,
|
||||
handleCorrespondentAdd,
|
||||
handleCorrespondentRemove,
|
||||
@@ -191,9 +191,9 @@ const useDetailWorkspace = ({
|
||||
(doc) =>
|
||||
resolveDocumentAssetUrl(doc, 'thumbnail', {
|
||||
ensureAssetUrl,
|
||||
getAsset: getDocumentAsset,
|
||||
getAsset,
|
||||
}),
|
||||
[ensureAssetUrl, getDocumentAsset],
|
||||
[ensureAssetUrl, getAsset],
|
||||
);
|
||||
|
||||
const inspectDocument = useCallback(
|
||||
@@ -222,7 +222,7 @@ const useDetailWorkspace = ({
|
||||
onUpdateTitle: handleDocumentTitleUpdate,
|
||||
onUpdateIssued: handleDocumentIssuedUpdate,
|
||||
ensureAssetUrl,
|
||||
getDocumentAsset,
|
||||
getDocumentAsset: getAsset,
|
||||
correspondents,
|
||||
onCorrespondentAdd: handleCorrespondentAdd,
|
||||
onCorrespondentRemove: handleCorrespondentRemove,
|
||||
@@ -237,7 +237,7 @@ const useDetailWorkspace = ({
|
||||
correspondents,
|
||||
detailPanelDocument,
|
||||
ensureAssetUrl,
|
||||
getDocumentAsset,
|
||||
getAsset,
|
||||
handleCorrespondentAdd,
|
||||
handleCorrespondentRemove,
|
||||
handleDetailPanelClose,
|
||||
|
||||
@@ -631,4 +631,12 @@
|
||||
.pdf-viewer__password-error {
|
||||
color: var(--danger);
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.pdf-viewer__canvas-stack--fit-width .pdf-viewer__page-wrapper {
|
||||
cursor: zoom-out;
|
||||
}
|
||||
|
||||
.pdf-viewer__canvas-stack--contain .pdf-viewer__page-wrapper {
|
||||
cursor: zoom-in;
|
||||
}
|
||||
Reference in New Issue
Block a user