feat: Introduce PreviewContext and document a new spatial workspace architecture.

This commit is contained in:
2025-11-27 01:14:18 +01:00
parent 9ba581f64e
commit 82243b4170
6 changed files with 131 additions and 144 deletions
+5 -5
View File
@@ -18,6 +18,7 @@ import { createDocumentEntryKey } from '../app/entryKey';
import { PointerTrackingProvider, usePointerTracking } from './PointerTrackingContext';
import type { Identifier } from '../types/identifiers';
import type { DocumentsListEntry, Document } from '../types/documents';
import { usePreviewContext } from '../preview/PreviewContext';
type TagLike = { id?: Identifier | null; label?: string; color?: string | null } | null;
type OverlaySource = { url: string; alt?: string | null; mimeType?: string | null; };
@@ -50,7 +51,6 @@ 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
@@ -84,8 +84,8 @@ const DesktopWorkspaceContent: React.FC<DesktopWorkspaceProps> = ({
onDocumentTagDrop,
tenantId,
viewId,
onPreview,
}) => {
const { openPreview } = usePreviewContext();
const { addPointer, removePointer } = usePointerTracking();
const containerRef = useRef<HTMLDivElement>(null);
const [isLayoutReady, setIsLayoutReady] = useState(false);
@@ -207,16 +207,16 @@ const DesktopWorkspaceContent: React.FC<DesktopWorkspaceProps> = ({
// Preview the last selected document
const lastId = selectedDocumentIds[selectedDocumentIds.length - 1];
const doc = items.find(i => String(i.id) === lastId);
if (doc && onPreview) {
if (doc) {
e.preventDefault();
onPreview(doc);
openPreview(doc);
}
}
};
window.addEventListener('keydown', handleWindowKeyDown);
return () => window.removeEventListener('keydown', handleWindowKeyDown);
}, [selectedDocumentIds, items, onPreview]);
}, [selectedDocumentIds, items, openPreview]);
return (
<>