4-26 树rust-2
This commit is contained in:
@@ -5,31 +5,62 @@ import {
|
||||
TreeShellIframeHost,
|
||||
type TreeShellPickerItem,
|
||||
} from "@/components/sidebar/tree-shell-iframe-host";
|
||||
import type { FileTreeRow } from "@/lib/file-tree/types";
|
||||
import type { KernelFileTreeProjectionItem } from "@/lib/kernel-file-tree";
|
||||
import type { PageTreeProjectionItem } from "@/lib/tree-projection";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
export type TreeRendererFamily = "react" | "rust_family";
|
||||
|
||||
export type TreeShellHostMode = "page" | "filetree" | "picker";
|
||||
|
||||
export type TreeShellPickerCommand = {
|
||||
kind: "next" | "previous" | "home" | "end" | "pick";
|
||||
seq: number;
|
||||
};
|
||||
|
||||
export type FileTreeShellInternalDropPayload = {
|
||||
targetDocumentId: string | null;
|
||||
targetRowId: string | null;
|
||||
targetRowKind: string | null;
|
||||
targetAssetId: string | null;
|
||||
rowIds: string[];
|
||||
copy: boolean;
|
||||
};
|
||||
|
||||
export type FileTreeShellExternalDropPayload = {
|
||||
targetDocumentId: string | null;
|
||||
targetRowId: string | null;
|
||||
targetRowKind: string | null;
|
||||
targetAssetId: string | null;
|
||||
files: FileList | File[];
|
||||
};
|
||||
|
||||
type TreeShellHostProps = {
|
||||
mode: TreeShellHostMode;
|
||||
surfaceTestId: string;
|
||||
rendererFamily?: TreeRendererFamily;
|
||||
className?: string;
|
||||
treeShellEnabled?: boolean;
|
||||
fallbackImplementation?: string;
|
||||
workspaceId?: string | null;
|
||||
rootNodeId?: string | null;
|
||||
activeDocumentId?: string | null;
|
||||
focusedDocumentId?: string | null;
|
||||
activePickerItemKey?: string | null;
|
||||
allowRootPick?: boolean;
|
||||
excludeIds?: string[];
|
||||
pickerCommand?: TreeShellPickerCommand | null;
|
||||
pickerItems?: TreeShellPickerItem[];
|
||||
fileTreeRows?: FileTreeRow[];
|
||||
pageTreeItems?: PageTreeProjectionItem[];
|
||||
inlineFileTreeItems?: KernelFileTreeProjectionItem[];
|
||||
channel?: string;
|
||||
host?: string;
|
||||
onNavigate?: (documentId: string) => void;
|
||||
onPick?: (targetId: string | null) => void;
|
||||
onPickerFocusChange?: (payload: { itemKey: string | null; documentId: string | null }) => void;
|
||||
onPageContextMenu?: (payload: { documentId: string; x: number; y: number }) => void;
|
||||
onPageExpandChange?: (payload: { documentId: string | null; expanded: boolean }) => void;
|
||||
onPageFocusChange?: (payload: { documentId: string | null }) => void;
|
||||
onFileTreeContextMenu?: (payload: {
|
||||
documentId: string | null;
|
||||
assetId: string | null;
|
||||
@@ -43,8 +74,8 @@ type TreeShellHostProps = {
|
||||
anchorRowId: string | null;
|
||||
focusedRowId: string | null;
|
||||
}) => void;
|
||||
onInternalDrop?: (args: { targetRow: FileTreeRow; rowIds: string[]; copy: boolean }) => void;
|
||||
onDropFiles?: (docId: string, files: FileList | File[], targetRow?: FileTreeRow) => void;
|
||||
onInternalDrop?: (payload: FileTreeShellInternalDropPayload) => void;
|
||||
onDropFiles?: (payload: FileTreeShellExternalDropPayload) => void;
|
||||
onAssetOpen?: (payload: { assetId: string; documentId: string | null }) => void;
|
||||
onTreeMutation?: (payload: { type: string; documentId: string | null }) => void;
|
||||
children: ReactNode;
|
||||
@@ -56,18 +87,26 @@ export function TreeShellHost({
|
||||
rendererFamily = "react",
|
||||
className,
|
||||
treeShellEnabled = true,
|
||||
fallbackImplementation,
|
||||
workspaceId = null,
|
||||
rootNodeId = null,
|
||||
activeDocumentId = null,
|
||||
focusedDocumentId = null,
|
||||
activePickerItemKey = null,
|
||||
allowRootPick = false,
|
||||
excludeIds = [],
|
||||
pickerItems = [],
|
||||
fileTreeRows = [],
|
||||
pickerCommand = null,
|
||||
pickerItems,
|
||||
pageTreeItems,
|
||||
inlineFileTreeItems,
|
||||
channel,
|
||||
host,
|
||||
onNavigate,
|
||||
onPick,
|
||||
onPickerFocusChange,
|
||||
onPageContextMenu,
|
||||
onPageExpandChange,
|
||||
onPageFocusChange,
|
||||
onFileTreeContextMenu,
|
||||
onFileTreeSelectionChange,
|
||||
onInternalDrop,
|
||||
@@ -77,13 +116,12 @@ export function TreeShellHost({
|
||||
children,
|
||||
}: TreeShellHostProps) {
|
||||
const useRustHost = rendererFamily === "rust_family";
|
||||
const useIframeHost = useRustHost && treeShellEnabled && Boolean(workspaceId?.trim());
|
||||
const useIframeHost = useRustHost && Boolean(workspaceId?.trim());
|
||||
const hostKind = rendererFamily === "rust_family" ? "rust_family" : "react";
|
||||
const implementation = useIframeHost
|
||||
? "mnote_web_iframe_proxy"
|
||||
: rendererFamily === "rust_family"
|
||||
? "react_fallback"
|
||||
: "react_primary";
|
||||
: fallbackImplementation ??
|
||||
(rendererFamily === "rust_family" ? "react_fallback" : "react_primary");
|
||||
|
||||
return (
|
||||
<div
|
||||
@@ -92,6 +130,7 @@ export function TreeShellHost({
|
||||
data-renderer-family={rendererFamily}
|
||||
data-tree-host-kind={hostKind}
|
||||
data-tree-host-implementation={implementation}
|
||||
data-page-tree-focused-id={mode === "page" ? (focusedDocumentId ?? "") : undefined}
|
||||
className={cn(className)}
|
||||
>
|
||||
{useRustHost ? (
|
||||
@@ -109,15 +148,22 @@ export function TreeShellHost({
|
||||
workspaceId={workspaceId}
|
||||
rootNodeId={rootNodeId}
|
||||
activeDocumentId={activeDocumentId}
|
||||
focusedDocumentId={focusedDocumentId}
|
||||
activePickerItemKey={activePickerItemKey}
|
||||
allowRootPick={allowRootPick}
|
||||
excludeIds={excludeIds}
|
||||
pickerCommand={pickerCommand}
|
||||
pickerItems={pickerItems}
|
||||
fileTreeRows={fileTreeRows}
|
||||
pageTreeItems={pageTreeItems}
|
||||
inlineFileTreeItems={inlineFileTreeItems}
|
||||
channel={channel}
|
||||
host={host}
|
||||
onNavigate={onNavigate}
|
||||
onPick={onPick}
|
||||
onPickerFocusChange={onPickerFocusChange}
|
||||
onPageContextMenu={onPageContextMenu}
|
||||
onPageExpandChange={onPageExpandChange}
|
||||
onPageFocusChange={onPageFocusChange}
|
||||
onFileTreeContextMenu={onFileTreeContextMenu}
|
||||
onFileTreeSelectionChange={onFileTreeSelectionChange}
|
||||
onInternalDrop={onInternalDrop}
|
||||
|
||||
Reference in New Issue
Block a user