refactor: begin spatial workspace architecture refactor with design document and updated pointer event handling for document activation.

This commit is contained in:
2025-11-27 01:57:38 +01:00
parent 82243b4170
commit 68ed888172
7 changed files with 31 additions and 35 deletions
@@ -42,8 +42,6 @@ interface DocumentsPanelProps extends DocumentsPanelInnerProps {
selectionValue: WorkspaceSelectionValue;
}
const defaultGetDocumentAsset = (_doc?: unknown, _type?: string) => null;
export type DocumentLinkLike = { url?: string | null; mimeType?: string | null };
export interface DocumentsViewProps {
@@ -60,8 +58,7 @@ export interface DocumentsViewProps {
onFolderDragStart?: (event: DragEvent<HTMLElement>, folderId: Identifier | 'root') => void;
onFolderDragEnd?: (event: DragEvent<HTMLElement>) => void;
onFolderRename?: (folderId: Identifier | 'root', nextName: string) => Promise<boolean> | boolean;
onDocumentClick?: DocumentEventHandler;
onDocumentActivate?: DocumentEventHandler;
onDocumentOpen?: DocumentEventHandler;
onDocumentDragStart?: (event: DragEvent<HTMLElement>, document: Document) => void;
onDocumentDragEnd?: (event: DragEvent<HTMLElement>) => void;
onDocumentTagDragOver?: (event: DragEvent<HTMLElement>) => void;
@@ -105,7 +102,7 @@ const DocumentsPanelInner: React.FC<DocumentsPanelInnerProps> = ({
tagLookupById,
activeCorrespondentIds = [],
ensureAssetUrl = null,
getDocumentAsset = defaultGetDocumentAsset,
getDocumentAsset,
isSearchLoading = false,
viewMode = 'list',
onViewModeChange,
@@ -345,29 +342,19 @@ const DocumentsPanelInner: React.FC<DocumentsPanelInnerProps> = ({
[isTagDragEvent],
);
const handleDocumentClick = useCallback(
(doc, event) => {
if (!doc || suppressDocumentClickRef.current || !onEntryPointer) {
return;
}
onEntryPointer(
{ type: EntryType.document, id: doc.id, key: `document:${doc.id}`, document: doc },
event,
);
},
[onEntryPointer],
);
const handleDocumentActivate = useCallback(
(doc, event?: React.MouseEvent | KeyboardEvent | null) => {
if (!doc) {
return;
}
if (event && (event.altKey || (event.button === 1))) {
// Handle Preview (Alt+Click or Middle Click)
if (event && (event.altKey || ((event as React.MouseEvent).button === 1))) {
openPreview(doc);
return;
}
// Handle Activation (Double Click, Enter, or explicit call)
if (onDocumentActivate) {
onDocumentActivate(doc);
}
@@ -435,7 +422,7 @@ const DocumentsPanelInner: React.FC<DocumentsPanelInnerProps> = ({
onFolderDragStart,
onFolderDragEnd,
onFolderRename,
onDocumentClick: handleDocumentClick,
onDocumentActivate: handleDocumentActivate,
onDocumentDragStart: handleDocumentDragStartLocal,
onDocumentDragEnd: handleDocumentDragEndLocal,