feat: Introduce DocumentOpenContext for document activation in the frontend
This commit is contained in:
@@ -15,7 +15,6 @@ import type {
|
||||
} from '../../types/documents';
|
||||
import DesktopWorkspace from '../../desktop/DesktopWorkspace';
|
||||
import { isTagTransferEvent } from '../tagTransfer';
|
||||
import { usePreviewContext } from '../../preview/PreviewContext';
|
||||
import { isPointerModifierEvent, isPrimaryPointerEvent } from '../useEntryPointer';
|
||||
import {
|
||||
WorkspaceSelectionProvider,
|
||||
@@ -65,7 +64,6 @@ 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;
|
||||
onDocumentActivate?: (doc: Document, event?: unknown) => void;
|
||||
onDocumentDragStart?: (event: DragEvent<HTMLElement>, document: Document) => void;
|
||||
onDocumentDragEnd?: (event: DragEvent<HTMLElement>) => void;
|
||||
onDocumentTagDragStart?: (event: DragEvent<HTMLElement>, docId: Identifier, tagId: Identifier) => void;
|
||||
@@ -106,7 +104,6 @@ const DocumentsPanelInner: React.FC<DocumentsPanelInnerProps> = ({
|
||||
onDocumentDragEnd,
|
||||
onDocumentRename,
|
||||
onEntryPointer = null,
|
||||
onDocumentActivate = null,
|
||||
tagLookupById,
|
||||
activeCorrespondentIds = [],
|
||||
ensureAssetUrl = null,
|
||||
@@ -317,8 +314,6 @@ const DocumentsPanelInner: React.FC<DocumentsPanelInnerProps> = ({
|
||||
const isGridView = viewMode === 'grid';
|
||||
const isDeskView = viewMode === 'desk';
|
||||
|
||||
const { openPreview } = usePreviewContext();
|
||||
|
||||
const isTagDragEvent = useCallback((event) => isTagTransferEvent(event), []);
|
||||
|
||||
const draggingTagRef = useRef<{ docId: Identifier; tagId: Identifier } | null>(null);
|
||||
@@ -365,26 +360,6 @@ const DocumentsPanelInner: React.FC<DocumentsPanelInnerProps> = ({
|
||||
[isTagDragEvent],
|
||||
);
|
||||
|
||||
const handleDocumentActivate = useCallback(
|
||||
(doc, event?: React.MouseEvent | KeyboardEvent | null) => {
|
||||
if (!doc) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 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);
|
||||
}
|
||||
},
|
||||
[onDocumentActivate, openPreview],
|
||||
);
|
||||
|
||||
const handleFolderClick = useCallback(
|
||||
(folder, event) => {
|
||||
if (!folder) {
|
||||
@@ -445,7 +420,6 @@ const DocumentsPanelInner: React.FC<DocumentsPanelInnerProps> = ({
|
||||
onFolderDragStart,
|
||||
onFolderDragEnd,
|
||||
onFolderRename,
|
||||
onDocumentActivate: handleDocumentActivate,
|
||||
onDocumentDragStart: handleDocumentDragStartLocal,
|
||||
onDocumentDragEnd: handleDocumentDragEndLocal,
|
||||
onDocumentTagDragStart: handleDocumentTagDragStart,
|
||||
|
||||
Reference in New Issue
Block a user