feat: add keyboard navigation for document views, externalize document preview handling, and include physics model documentation.

This commit is contained in:
2025-11-27 01:06:31 +01:00
parent 3588fde3a2
commit 9ba581f64e
6 changed files with 306 additions and 392 deletions
+18 -15
View File
@@ -6,7 +6,6 @@ import React, {
useState,
} from 'react';
import { LayoutStore, LayoutCard } from './LayoutSystem';
import PreviewZoomOverlay from '../detail/PreviewZoomOverlay';
import DesktopDocumentCard from './DesktopDocumentCard';
import usePreviewMetadata from './hooks/usePreviewMetadata';
import useDeskTagInteractions from './tags/useDeskTagInteractions';
@@ -31,12 +30,6 @@ export interface DeskDocument {
[key: string]: unknown;
}
interface OverlayDisplay {
url: string;
alt?: string | null;
mimeType?: string | null;
}
interface DocumentSizeInfo {
width: number;
height: number;
@@ -57,6 +50,7 @@ export interface DesktopWorkspaceProps {
onDocumentTagDrop?: (docId: Identifier, tag: any) => void;
tenantId?: Identifier | null;
viewId?: string | null;
onPreview?: (doc: DeskDocument) => void;
}
// Wrapper to handle hooks per card
@@ -90,6 +84,7 @@ const DesktopWorkspaceContent: React.FC<DesktopWorkspaceProps> = ({
onDocumentTagDrop,
tenantId,
viewId,
onPreview,
}) => {
const { addPointer, removePointer } = usePointerTracking();
const containerRef = useRef<HTMLDivElement>(null);
@@ -206,9 +201,22 @@ const DesktopWorkspaceContent: React.FC<DesktopWorkspaceProps> = ({
requestCanvasFocus: focusShell,
});
// Overlay State
const [overlayDisplay, setOverlayDisplay] = useState<OverlayDisplay | null>(null);
const closeOverlay = useCallback(() => setOverlayDisplay(null), []);
useEffect(() => {
const handleWindowKeyDown = (e: KeyboardEvent) => {
if (e.code === 'Space' && selectedDocumentIds.length > 0) {
// Preview the last selected document
const lastId = selectedDocumentIds[selectedDocumentIds.length - 1];
const doc = items.find(i => String(i.id) === lastId);
if (doc && onPreview) {
e.preventDefault();
onPreview(doc);
}
}
};
window.addEventListener('keydown', handleWindowKeyDown);
return () => window.removeEventListener('keydown', handleWindowKeyDown);
}, [selectedDocumentIds, items, onPreview]);
return (
<>
@@ -305,11 +313,6 @@ const DesktopWorkspaceContent: React.FC<DesktopWorkspaceProps> = ({
})}
</div>
</div>
<PreviewZoomOverlay
open={Boolean(overlayDisplay?.url)}
onClose={closeOverlay}
document={null}
/>
</>
);
};