feat: Introduce DocumentOpenContext for document activation in the frontend
This commit is contained in:
@@ -5,6 +5,7 @@ import {
|
|||||||
DocumentsFilterProvider,
|
DocumentsFilterProvider,
|
||||||
} from '../documents/context/DocumentsFilterContext';
|
} from '../documents/context/DocumentsFilterContext';
|
||||||
import { PreviewProvider } from '../preview/PreviewContext';
|
import { PreviewProvider } from '../preview/PreviewContext';
|
||||||
|
import { DocumentOpenProvider } from '../context/DocumentOpenContext';
|
||||||
import { useWorkspaceSurface } from './useWorkspaceSurface';
|
import { useWorkspaceSurface } from './useWorkspaceSurface';
|
||||||
import { DocumentsHeaderBreadcrumb } from '../documents/panel/DocumentsPanelHeader';
|
import { DocumentsHeaderBreadcrumb } from '../documents/panel/DocumentsPanelHeader';
|
||||||
import { SidebarProvider, useSidebarContext } from '../sidebar/SidebarContext';
|
import { SidebarProvider, useSidebarContext } from '../sidebar/SidebarContext';
|
||||||
@@ -83,7 +84,9 @@ const DocumentsRouteContent: React.FC = () => {
|
|||||||
<PreviewProvider
|
<PreviewProvider
|
||||||
onNavigate={handleDocumentNavigate}
|
onNavigate={handleDocumentNavigate}
|
||||||
>
|
>
|
||||||
{content}
|
<DocumentOpenProvider onOpenViewer={handleDocumentNavigate}>
|
||||||
|
{content}
|
||||||
|
</DocumentOpenProvider>
|
||||||
</PreviewProvider>
|
</PreviewProvider>
|
||||||
</DocumentsFilterProvider>
|
</DocumentsFilterProvider>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -0,0 +1,57 @@
|
|||||||
|
import React, { createContext, useContext, useCallback } from 'react';
|
||||||
|
import { usePreviewContext } from '../preview/PreviewContext';
|
||||||
|
import { useAppShell } from '../appShellContext';
|
||||||
|
import type { Document } from '../types/documents';
|
||||||
|
import type { Identifier } from '../types/identifiers';
|
||||||
|
|
||||||
|
export type DocumentOpenTarget = 'preview' | 'sidepanel' | 'viewer';
|
||||||
|
|
||||||
|
export interface DocumentOpenContextValue {
|
||||||
|
openDocument: (doc: Document, target?: DocumentOpenTarget) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
const DocumentOpenContext = createContext<DocumentOpenContextValue | null>(null);
|
||||||
|
|
||||||
|
export const useDocumentOpen = () => {
|
||||||
|
const context = useContext(DocumentOpenContext);
|
||||||
|
if (!context) {
|
||||||
|
throw new Error('useDocumentOpen must be used within a DocumentOpenProvider');
|
||||||
|
}
|
||||||
|
return context;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const DocumentOpenProvider: React.FC<{ children: React.ReactNode; onOpenViewer?: (docId: Identifier) => void }> = ({ children, onOpenViewer }) => {
|
||||||
|
const { openPreview } = usePreviewContext();
|
||||||
|
const appShell = useAppShell();
|
||||||
|
|
||||||
|
// We cast appShell.openDetailPanel because AppShellContext is loosely typed
|
||||||
|
const openDetailPanel = appShell.openDetailPanel as ((args: { documentIds: Identifier[] }) => void) | undefined;
|
||||||
|
|
||||||
|
const openDocument = useCallback((doc: Document, target: DocumentOpenTarget = 'preview') => {
|
||||||
|
if (!doc) return;
|
||||||
|
|
||||||
|
switch (target) {
|
||||||
|
case 'preview':
|
||||||
|
openPreview(doc);
|
||||||
|
break;
|
||||||
|
case 'sidepanel':
|
||||||
|
if (openDetailPanel) {
|
||||||
|
openDetailPanel({ documentIds: [doc.id] });
|
||||||
|
} else {
|
||||||
|
console.warn('openDetailPanel is not available in AppShellContext');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'viewer':
|
||||||
|
if (onOpenViewer) {
|
||||||
|
onOpenViewer(doc.id);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}, [openPreview, openDetailPanel, onOpenViewer]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<DocumentOpenContext.Provider value={{ openDocument }}>
|
||||||
|
{children}
|
||||||
|
</DocumentOpenContext.Provider>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -18,8 +18,8 @@ import { createDocumentEntryKey } from '../app/entryKey';
|
|||||||
import { PointerTrackingProvider, usePointerTracking } from './PointerTrackingContext';
|
import { PointerTrackingProvider, usePointerTracking } from './PointerTrackingContext';
|
||||||
import type { Identifier } from '../types/identifiers';
|
import type { Identifier } from '../types/identifiers';
|
||||||
import type { DocumentsListEntry, Document } from '../types/documents';
|
import type { DocumentsListEntry, Document } from '../types/documents';
|
||||||
import { usePreviewContext } from '../preview/PreviewContext';
|
|
||||||
import { useAppState } from '../app/appState';
|
import { useAppState } from '../app/appState';
|
||||||
|
import { useDocumentOpen } from '../context/DocumentOpenContext';
|
||||||
|
|
||||||
type TagLike = { id?: Identifier | null; label?: string; color?: string | null } | null;
|
type TagLike = { id?: Identifier | null; label?: string; color?: string | null } | null;
|
||||||
type OverlaySource = { url: string; alt?: string | null; mimeType?: string | null; };
|
type OverlaySource = { url: string; alt?: string | null; mimeType?: string | null; };
|
||||||
@@ -48,7 +48,6 @@ export interface DesktopWorkspaceProps {
|
|||||||
entries: DocumentsListEntry[];
|
entries: DocumentsListEntry[];
|
||||||
ensureAssetUrl?: (...args: any[]) => Promise<unknown>;
|
ensureAssetUrl?: (...args: any[]) => Promise<unknown>;
|
||||||
getDocumentAsset?: (...args: any[]) => unknown;
|
getDocumentAsset?: (...args: any[]) => unknown;
|
||||||
onDocumentActivate?: (doc: DeskDocument, event?: unknown) => void;
|
|
||||||
onSelectionChange?: (selectedIds: Identifier[]) => void;
|
onSelectionChange?: (selectedIds: Identifier[]) => void;
|
||||||
onDocumentTagAttach?: (docId: Identifier, tagId: Identifier) => void;
|
onDocumentTagAttach?: (docId: Identifier, tagId: Identifier) => void;
|
||||||
onDocumentTagDetach?: (docId: Identifier, tagId: Identifier) => void;
|
onDocumentTagDetach?: (docId: Identifier, tagId: Identifier) => void;
|
||||||
@@ -83,14 +82,13 @@ const DesktopWorkspaceContent: React.FC<DesktopWorkspaceProps> = ({
|
|||||||
entries,
|
entries,
|
||||||
ensureAssetUrl,
|
ensureAssetUrl,
|
||||||
getDocumentAsset,
|
getDocumentAsset,
|
||||||
onDocumentActivate,
|
|
||||||
onSelectionChange,
|
onSelectionChange,
|
||||||
onDocumentTagAttach,
|
onDocumentTagAttach,
|
||||||
onDocumentTagDetach,
|
onDocumentTagDetach,
|
||||||
viewId,
|
viewId,
|
||||||
defaultCardSize = 200,
|
defaultCardSize = 200,
|
||||||
}) => {
|
}) => {
|
||||||
const { openPreview } = usePreviewContext();
|
const { openDocument } = useDocumentOpen();
|
||||||
const { tenant } = useAppState();
|
const { tenant } = useAppState();
|
||||||
const tenantId = tenant?.id as Identifier;
|
const tenantId = tenant?.id as Identifier;
|
||||||
const { addPointer, removePointer } = usePointerTracking();
|
const { addPointer, removePointer } = usePointerTracking();
|
||||||
@@ -240,7 +238,7 @@ const DesktopWorkspaceContent: React.FC<DesktopWorkspaceProps> = ({
|
|||||||
const doc = items.find(i => String(i.id) === lastId);
|
const doc = items.find(i => String(i.id) === lastId);
|
||||||
if (doc) {
|
if (doc) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
openPreview(doc);
|
openDocument(doc, 'preview');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -352,7 +350,7 @@ const DesktopWorkspaceContent: React.FC<DesktopWorkspaceProps> = ({
|
|||||||
|
|
||||||
window.addEventListener('keydown', handleWindowKeyDown);
|
window.addEventListener('keydown', handleWindowKeyDown);
|
||||||
return () => window.removeEventListener('keydown', handleWindowKeyDown);
|
return () => window.removeEventListener('keydown', handleWindowKeyDown);
|
||||||
}, [selectedDocumentIds, items, openPreview, layoutStore, handleSelectionChange]);
|
}, [selectedDocumentIds, items, openDocument, layoutStore, handleSelectionChange]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -424,7 +422,10 @@ const DesktopWorkspaceContent: React.FC<DesktopWorkspaceProps> = ({
|
|||||||
ensureAssetUrl={ensureAssetUrl}
|
ensureAssetUrl={ensureAssetUrl}
|
||||||
getDocumentAsset={getDocumentAsset}
|
getDocumentAsset={getDocumentAsset}
|
||||||
handleNavigatorSnapshot={() => { }}
|
handleNavigatorSnapshot={() => { }}
|
||||||
onDocumentActivate={(_id, event) => { onDocumentActivate?.(doc, event) }}
|
onDocumentActivate={(_id, event) => {
|
||||||
|
const isPreview = event && ((event as any).altKey || (event as any).button === 1);
|
||||||
|
openDocument(doc, isPreview ? 'preview' : 'sidepanel');
|
||||||
|
}}
|
||||||
layoutCard={layoutCard}
|
layoutCard={layoutCard}
|
||||||
onTagDragEnter={tagInteractions.handleTagDragEnterDoc}
|
onTagDragEnter={tagInteractions.handleTagDragEnterDoc}
|
||||||
onTagDragOver={tagInteractions.handleTagDragOverDoc}
|
onTagDragOver={tagInteractions.handleTagDragOverDoc}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import { useDocumentViewLogic, DocumentViewLogic } from './hooks/useDocumentView
|
|||||||
import { useDocumentsNavigation } from './hooks/useDocumentsNavigation';
|
import { useDocumentsNavigation } from './hooks/useDocumentsNavigation';
|
||||||
import { useWorkspaceSelectionContext } from '../app/WorkspaceSelectionContext';
|
import { useWorkspaceSelectionContext } from '../app/WorkspaceSelectionContext';
|
||||||
import { usePanelManager } from '../app/PanelManagerContext';
|
import { usePanelManager } from '../app/PanelManagerContext';
|
||||||
import { usePreviewContext } from '../preview/PreviewContext';
|
|
||||||
import DocumentsListRow from './components/DocumentsListRow';
|
import DocumentsListRow from './components/DocumentsListRow';
|
||||||
import DocumentsGridCard from './components/DocumentsGridCard';
|
import DocumentsGridCard from './components/DocumentsGridCard';
|
||||||
import DocumentsListContainer from './components/DocumentsListContainer';
|
import DocumentsListContainer from './components/DocumentsListContainer';
|
||||||
@@ -24,7 +23,6 @@ const AbstractDocumentsView = <CProps extends { clearSelection: () => void; chil
|
|||||||
...props
|
...props
|
||||||
}: AbstractDocumentsViewProps<CProps>) => {
|
}: AbstractDocumentsViewProps<CProps>) => {
|
||||||
const { entries, onDocumentRename, onFolderRename, onFolderSelect, scrollRef, viewId } = props;
|
const { entries, onDocumentRename, onFolderRename, onFolderSelect, scrollRef, viewId } = props;
|
||||||
const { openPreview } = usePreviewContext();
|
|
||||||
const viewLogic = useDocumentViewLogic({
|
const viewLogic = useDocumentViewLogic({
|
||||||
onDocumentRename,
|
onDocumentRename,
|
||||||
onFolderRename,
|
onFolderRename,
|
||||||
@@ -32,7 +30,6 @@ const AbstractDocumentsView = <CProps extends { clearSelection: () => void; chil
|
|||||||
const { handleKeyDown, handleFocus } = useDocumentsNavigation({
|
const { handleKeyDown, handleFocus } = useDocumentsNavigation({
|
||||||
entries,
|
entries,
|
||||||
onFolderSelect,
|
onFolderSelect,
|
||||||
onPreview: openPreview,
|
|
||||||
viewMode: props.viewMode,
|
viewMode: props.viewMode,
|
||||||
scrollRef: props.scrollRef,
|
scrollRef: props.scrollRef,
|
||||||
});
|
});
|
||||||
@@ -105,7 +102,6 @@ const AbstractDocumentsView = <CProps extends { clearSelection: () => void; chil
|
|||||||
entry={entry}
|
entry={entry}
|
||||||
viewLogic={viewLogic}
|
viewLogic={viewLogic}
|
||||||
{...props}
|
{...props}
|
||||||
onPreview={openPreview}
|
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</ContainerComponent>
|
</ContainerComponent>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import React, { type DragEvent } from 'react';
|
import React, { type DragEvent } from 'react';
|
||||||
import { parseTagTransferPayload } from '../tagTransfer';
|
import { parseTagTransferPayload } from '../tagTransfer';
|
||||||
import { createDocumentEntryKey } from '../../app/entryKey';
|
import { createDocumentEntryKey } from '../../app/entryKey';
|
||||||
|
import { useDocumentOpen } from '../../context/DocumentOpenContext';
|
||||||
import type { Document } from '../../types/documents';
|
import type { Document } from '../../types/documents';
|
||||||
import type { DocumentsViewProps } from '../panel/DocumentsPanel';
|
import type { DocumentsViewProps } from '../panel/DocumentsPanel';
|
||||||
import type { DocumentViewLogic } from './useDocumentViewLogic';
|
import type { DocumentViewLogic } from './useDocumentViewLogic';
|
||||||
@@ -17,7 +18,6 @@ export const useDocumentItemLogic = (props: UseDocumentItemLogicProps) => {
|
|||||||
doc,
|
doc,
|
||||||
viewLogic,
|
viewLogic,
|
||||||
draggingDocumentIdsSet,
|
draggingDocumentIdsSet,
|
||||||
onDocumentActivate,
|
|
||||||
onDocumentDragStart,
|
onDocumentDragStart,
|
||||||
onDocumentDragEnd,
|
onDocumentDragEnd,
|
||||||
onDocumentTagDragStart,
|
onDocumentTagDragStart,
|
||||||
@@ -54,6 +54,8 @@ export const useDocumentItemLogic = (props: UseDocumentItemLogicProps) => {
|
|||||||
isEditingDoc && trimmedDocumentDraft.length > 0 && trimmedDocumentDraft !== doc.title;
|
isEditingDoc && trimmedDocumentDraft.length > 0 && trimmedDocumentDraft !== doc.title;
|
||||||
const allowInlineDocumentEdit = onDocumentRename && isSelected && totalSelectionCount === 1;
|
const allowInlineDocumentEdit = onDocumentRename && isSelected && totalSelectionCount === 1;
|
||||||
|
|
||||||
|
const { openDocument } = useDocumentOpen();
|
||||||
|
|
||||||
const handlers = {
|
const handlers = {
|
||||||
onClick: (event: React.MouseEvent) => {
|
onClick: (event: React.MouseEvent) => {
|
||||||
if (props.onEntryPointer) {
|
if (props.onEntryPointer) {
|
||||||
@@ -63,7 +65,10 @@ export const useDocumentItemLogic = (props: UseDocumentItemLogicProps) => {
|
|||||||
handleEntrySelection(key, event);
|
handleEntrySelection(key, event);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onDoubleClick: (event: React.MouseEvent) => onDocumentActivate?.(doc, event),
|
onDoubleClick: (event: React.MouseEvent) => {
|
||||||
|
const isPreview = event && (event.altKey || event.button === 1);
|
||||||
|
openDocument(doc, isPreview ? 'preview' : 'sidepanel');
|
||||||
|
},
|
||||||
onDragStart: (event: DragEvent<HTMLElement>) => onDocumentDragStart?.(event, doc),
|
onDragStart: (event: DragEvent<HTMLElement>) => onDocumentDragStart?.(event, doc),
|
||||||
onDragEnd: (event: DragEvent<HTMLElement>) => onDocumentDragEnd?.(event),
|
onDragEnd: (event: DragEvent<HTMLElement>) => onDocumentDragEnd?.(event),
|
||||||
onDragOver: (event: DragEvent<HTMLElement>) => onDocumentTagDragOver?.(event, doc.id),
|
onDragOver: (event: DragEvent<HTMLElement>) => onDocumentTagDragOver?.(event, doc.id),
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import React, { useCallback, useMemo } from 'react';
|
import React, { useCallback, useMemo } from 'react';
|
||||||
import type { DocumentsListEntry } from '../../types/documents';
|
import type { DocumentsListEntry } from '../../types/documents';
|
||||||
import { useWorkspaceSelectionContext } from '../../app/WorkspaceSelectionContext';
|
import { useWorkspaceSelectionContext } from '../../app/WorkspaceSelectionContext';
|
||||||
|
import { useDocumentOpen } from '../../context/DocumentOpenContext';
|
||||||
|
|
||||||
interface UseDocumentsNavigationProps {
|
interface UseDocumentsNavigationProps {
|
||||||
entries: DocumentsListEntry[];
|
entries: DocumentsListEntry[];
|
||||||
onFolderSelect?: (folderId: string) => void;
|
onFolderSelect?: (folderId: string) => void;
|
||||||
onPreview?: (doc: any) => void;
|
|
||||||
viewMode?: string;
|
viewMode?: string;
|
||||||
scrollRef?: React.RefObject<HTMLElement | null>;
|
scrollRef?: React.RefObject<HTMLElement | null>;
|
||||||
}
|
}
|
||||||
@@ -13,7 +13,6 @@ interface UseDocumentsNavigationProps {
|
|||||||
export const useDocumentsNavigation = ({
|
export const useDocumentsNavigation = ({
|
||||||
entries,
|
entries,
|
||||||
onFolderSelect,
|
onFolderSelect,
|
||||||
onPreview,
|
|
||||||
viewMode,
|
viewMode,
|
||||||
scrollRef,
|
scrollRef,
|
||||||
}: UseDocumentsNavigationProps) => {
|
}: UseDocumentsNavigationProps) => {
|
||||||
@@ -25,6 +24,8 @@ export const useDocumentsNavigation = ({
|
|||||||
applySelection,
|
applySelection,
|
||||||
} = useWorkspaceSelectionContext();
|
} = useWorkspaceSelectionContext();
|
||||||
|
|
||||||
|
const { openDocument } = useDocumentOpen();
|
||||||
|
|
||||||
const navigableRows = useMemo(
|
const navigableRows = useMemo(
|
||||||
() => entries.map((entry) => ({ key: entry.key, type: entry.type, id: entry.id })),
|
() => entries.map((entry) => ({ key: entry.key, type: entry.type, id: entry.id })),
|
||||||
[entries],
|
[entries],
|
||||||
@@ -109,7 +110,8 @@ export const useDocumentsNavigation = ({
|
|||||||
} else {
|
} else {
|
||||||
const entry = getEntryByKey(activeRow.key);
|
const entry = getEntryByKey(activeRow.key);
|
||||||
if (entry && entry.type === 'document') {
|
if (entry && entry.type === 'document') {
|
||||||
onPreview?.(entry.document);
|
const isPreview = key === ' ' || key === 'Space' || key === 'Spacebar';
|
||||||
|
openDocument(entry.document, isPreview ? 'preview' : 'sidepanel');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -175,7 +177,7 @@ export const useDocumentsNavigation = ({
|
|||||||
navigableRows,
|
navigableRows,
|
||||||
onFolderSelect,
|
onFolderSelect,
|
||||||
selectedEntries,
|
selectedEntries,
|
||||||
onPreview,
|
openDocument,
|
||||||
handleEntrySelection,
|
handleEntrySelection,
|
||||||
setFocusedEntryKey,
|
setFocusedEntryKey,
|
||||||
viewMode,
|
viewMode,
|
||||||
|
|||||||
@@ -52,7 +52,6 @@ export interface UseDocumentsPanelPropsArgs {
|
|||||||
clearDocumentSelection?: () => void;
|
clearDocumentSelection?: () => void;
|
||||||
handleDeleteSelection?: () => void;
|
handleDeleteSelection?: () => void;
|
||||||
handleEntryPointerCore?: (...args: unknown[]) => void;
|
handleEntryPointerCore?: (...args: unknown[]) => void;
|
||||||
onDocumentActivate?: (docId: Identifier | null, metadata?: unknown) => void;
|
|
||||||
tags?: unknown[];
|
tags?: unknown[];
|
||||||
correspondents?: unknown[];
|
correspondents?: unknown[];
|
||||||
documentLookup?: unknown;
|
documentLookup?: unknown;
|
||||||
@@ -105,7 +104,6 @@ const useDocumentsPanelProps = (props: UseDocumentsPanelPropsArgs) => {
|
|||||||
handleDocumentsViewModeChange,
|
handleDocumentsViewModeChange,
|
||||||
handleDeleteSelection,
|
handleDeleteSelection,
|
||||||
handleEntryPointerCore,
|
handleEntryPointerCore,
|
||||||
onDocumentActivate,
|
|
||||||
tags,
|
tags,
|
||||||
correspondents,
|
correspondents,
|
||||||
documentLookup,
|
documentLookup,
|
||||||
@@ -159,7 +157,6 @@ const useDocumentsPanelProps = (props: UseDocumentsPanelPropsArgs) => {
|
|||||||
onViewModeChange: handleDocumentsViewModeChange,
|
onViewModeChange: handleDocumentsViewModeChange,
|
||||||
onDeleteSelection: handleDeleteSelection,
|
onDeleteSelection: handleDeleteSelection,
|
||||||
onEntryPointer: handleEntryPointerCore,
|
onEntryPointer: handleEntryPointerCore,
|
||||||
onDocumentActivate,
|
|
||||||
tags,
|
tags,
|
||||||
correspondents,
|
correspondents,
|
||||||
documentLookup,
|
documentLookup,
|
||||||
@@ -206,7 +203,6 @@ const useDocumentsPanelProps = (props: UseDocumentsPanelPropsArgs) => {
|
|||||||
handleFolderDragEnd,
|
handleFolderDragEnd,
|
||||||
handleFolderDragStart,
|
handleFolderDragStart,
|
||||||
handleFolderRename,
|
handleFolderRename,
|
||||||
onDocumentActivate,
|
|
||||||
moveDocumentsToFolder,
|
moveDocumentsToFolder,
|
||||||
refreshCurrentFolder,
|
refreshCurrentFolder,
|
||||||
searchLoading,
|
searchLoading,
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ import type {
|
|||||||
} from '../../types/documents';
|
} from '../../types/documents';
|
||||||
import DesktopWorkspace from '../../desktop/DesktopWorkspace';
|
import DesktopWorkspace from '../../desktop/DesktopWorkspace';
|
||||||
import { isTagTransferEvent } from '../tagTransfer';
|
import { isTagTransferEvent } from '../tagTransfer';
|
||||||
import { usePreviewContext } from '../../preview/PreviewContext';
|
|
||||||
import { isPointerModifierEvent, isPrimaryPointerEvent } from '../useEntryPointer';
|
import { isPointerModifierEvent, isPrimaryPointerEvent } from '../useEntryPointer';
|
||||||
import {
|
import {
|
||||||
WorkspaceSelectionProvider,
|
WorkspaceSelectionProvider,
|
||||||
@@ -65,7 +64,6 @@ export interface DocumentsViewProps {
|
|||||||
onFolderDragStart?: (event: DragEvent<HTMLElement>, folderId: Identifier | 'root') => void;
|
onFolderDragStart?: (event: DragEvent<HTMLElement>, folderId: Identifier | 'root') => void;
|
||||||
onFolderDragEnd?: (event: DragEvent<HTMLElement>) => void;
|
onFolderDragEnd?: (event: DragEvent<HTMLElement>) => void;
|
||||||
onFolderRename?: (folderId: Identifier | 'root', nextName: string) => Promise<boolean> | boolean;
|
onFolderRename?: (folderId: Identifier | 'root', nextName: string) => Promise<boolean> | boolean;
|
||||||
onDocumentActivate?: (doc: Document, event?: unknown) => void;
|
|
||||||
onDocumentDragStart?: (event: DragEvent<HTMLElement>, document: Document) => void;
|
onDocumentDragStart?: (event: DragEvent<HTMLElement>, document: Document) => void;
|
||||||
onDocumentDragEnd?: (event: DragEvent<HTMLElement>) => void;
|
onDocumentDragEnd?: (event: DragEvent<HTMLElement>) => void;
|
||||||
onDocumentTagDragStart?: (event: DragEvent<HTMLElement>, docId: Identifier, tagId: Identifier) => void;
|
onDocumentTagDragStart?: (event: DragEvent<HTMLElement>, docId: Identifier, tagId: Identifier) => void;
|
||||||
@@ -106,7 +104,6 @@ const DocumentsPanelInner: React.FC<DocumentsPanelInnerProps> = ({
|
|||||||
onDocumentDragEnd,
|
onDocumentDragEnd,
|
||||||
onDocumentRename,
|
onDocumentRename,
|
||||||
onEntryPointer = null,
|
onEntryPointer = null,
|
||||||
onDocumentActivate = null,
|
|
||||||
tagLookupById,
|
tagLookupById,
|
||||||
activeCorrespondentIds = [],
|
activeCorrespondentIds = [],
|
||||||
ensureAssetUrl = null,
|
ensureAssetUrl = null,
|
||||||
@@ -317,8 +314,6 @@ const DocumentsPanelInner: React.FC<DocumentsPanelInnerProps> = ({
|
|||||||
const isGridView = viewMode === 'grid';
|
const isGridView = viewMode === 'grid';
|
||||||
const isDeskView = viewMode === 'desk';
|
const isDeskView = viewMode === 'desk';
|
||||||
|
|
||||||
const { openPreview } = usePreviewContext();
|
|
||||||
|
|
||||||
const isTagDragEvent = useCallback((event) => isTagTransferEvent(event), []);
|
const isTagDragEvent = useCallback((event) => isTagTransferEvent(event), []);
|
||||||
|
|
||||||
const draggingTagRef = useRef<{ docId: Identifier; tagId: Identifier } | null>(null);
|
const draggingTagRef = useRef<{ docId: Identifier; tagId: Identifier } | null>(null);
|
||||||
@@ -365,26 +360,6 @@ const DocumentsPanelInner: React.FC<DocumentsPanelInnerProps> = ({
|
|||||||
[isTagDragEvent],
|
[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(
|
const handleFolderClick = useCallback(
|
||||||
(folder, event) => {
|
(folder, event) => {
|
||||||
if (!folder) {
|
if (!folder) {
|
||||||
@@ -445,7 +420,6 @@ const DocumentsPanelInner: React.FC<DocumentsPanelInnerProps> = ({
|
|||||||
onFolderDragStart,
|
onFolderDragStart,
|
||||||
onFolderDragEnd,
|
onFolderDragEnd,
|
||||||
onFolderRename,
|
onFolderRename,
|
||||||
onDocumentActivate: handleDocumentActivate,
|
|
||||||
onDocumentDragStart: handleDocumentDragStartLocal,
|
onDocumentDragStart: handleDocumentDragStartLocal,
|
||||||
onDocumentDragEnd: handleDocumentDragEndLocal,
|
onDocumentDragEnd: handleDocumentDragEndLocal,
|
||||||
onDocumentTagDragStart: handleDocumentTagDragStart,
|
onDocumentTagDragStart: handleDocumentTagDragStart,
|
||||||
|
|||||||
@@ -1069,7 +1069,6 @@ const useDocumentsWorkspace = ({
|
|||||||
detailPanelProps,
|
detailPanelProps,
|
||||||
detailPanelOpen,
|
detailPanelOpen,
|
||||||
openDetailPanel,
|
openDetailPanel,
|
||||||
inspectDocument,
|
|
||||||
previewActive,
|
previewActive,
|
||||||
previewWorkspaceDocument,
|
previewWorkspaceDocument,
|
||||||
resolveFolderPath,
|
resolveFolderPath,
|
||||||
@@ -1178,7 +1177,6 @@ const useDocumentsWorkspace = ({
|
|||||||
clearDocumentSelection,
|
clearDocumentSelection,
|
||||||
handleDeleteSelection,
|
handleDeleteSelection,
|
||||||
handleEntryPointerCore,
|
handleEntryPointerCore,
|
||||||
onDocumentActivate: inspectDocument,
|
|
||||||
tags,
|
tags,
|
||||||
correspondents,
|
correspondents,
|
||||||
documentLookup,
|
documentLookup,
|
||||||
|
|||||||
Reference in New Issue
Block a user