feat: add right-click and keyboard delete for batch table reference thumbnails

- Right-click on reference thumbnail shows context menu with 删除素材
- Delete/Backspace key removes the hovered reference cell
- Both actions only work within the batch table, on the specific thumbnail
This commit is contained in:
Codex committed 2026-09-19 14:36:20 +08:00
1 parent 5b9abfcc97
commit 67da7af88c
6 files changed
+267 -4

No files matched your search

+20
View File
@@ -0,0 +1,20 @@
path = r"D:\yingce\open-ai-canvas-main\web\src\pages\canvas\project.tsx"
with open(path, "r", encoding="utf-8") as f:
content = f.read()
old_upload = ' onUploadReference={(rowId, columnIndex, file) => { void handleUploadBatchReference(contentNode.id, rowId, columnIndex, file); }}'
new_upload = ''' onUploadReference={(rowId, columnIndex, file) => { void handleUploadBatchReference(contentNode.id, rowId, columnIndex, file); }}
onRemoveReference={(rowId, columnIndex) => {
const table = nodesRef.current.find((n) => n.id === contentNode.id)?.metadata?.batchTable;
if (!table) return;
const row = table.rows.find((r) => r.id === rowId);
if (!row) return;
const newInputNodeIds = [...row.inputNodeIds];
newInputNodeIds[columnIndex] = "";
updateBatchRow(contentNode.id, rowId, { inputNodeIds: newInputNodeIds });
}}'''
content = content.replace(old_upload, new_upload, 1)
with open(path, "w", encoding="utf-8") as f:
f.write(content)
print("done")
+10
View File
@@ -0,0 +1,10 @@
path = r"D:\yingce\open-ai-canvas-main\web\src\pages\canvas\shared.tsx"
with open(path, "r", encoding="utf-8") as f:
content = f.read()
content = content.replace(
'onUploadReference={() => {}} onConnectStart={() => {}}',
'onUploadReference={() => {}} onRemoveReference={() => {}} onConnectStart={() => {}}'
)
with open(path, "w", encoding="utf-8") as f:
f.write(content)
print("done")
+168
View File
@@ -0,0 +1,168 @@
path = r"D:\yingce\open-ai-canvas-main\web\src\components\canvas\canvas-batch-table-node.tsx"
with open(path, "r", encoding="utf-8") as f:
content = f.read()
# 1. Add onRemoveReference to Props
old_props = " onUploadReference: (rowId: string, columnIndex: number, file: File) => void;\n onConnectStart: (event: ReactPointerEvent, handleId: string) => void;"
new_props = " onUploadReference: (rowId: string, columnIndex: number, file: File) => void;\n onRemoveReference: (rowId: string, columnIndex: number) => void;\n onConnectStart: (event: ReactPointerEvent, handleId: string) => void;"
content = content.replace(old_props, new_props, 1)
# 2. Add hoveredCell ref and context menu state after existing refs
old_refs = " const dragStartRef = useRef<{ x: number; y: number; pointerId: number; cell: ReferenceCell } | null>(null);\n const lastPointerRef = useRef({ x: 0, y: 0 });"
new_refs = """ const dragStartRef = useRef<{ x: number; y: number; pointerId: number; cell: ReferenceCell } | null>(null);
const lastPointerRef = useRef({ x: 0, y: 0 });
const hoveredCellRef = useRef<ReferenceCell | null>(null);
const [contextMenu, setContextMenu] = useState<{ x: number; y: number; cell: ReferenceCell } | null>(null);"""
content = content.replace(old_refs, new_refs, 1)
# 3. Add keyboard delete handler effect after existing useEffect block
old_effect_end = " }, [cancelReferenceDrag, finishReferenceDrag, updateReferenceDrag]);"
new_effect_end = """ }, [cancelReferenceDrag, finishReferenceDrag, updateReferenceDrag]);
// Delete / Backspace to remove hovered reference
useEffect(() => {
const handleKeyDown = (event: KeyboardEvent) => {
if (event.key !== "Delete" && event.key !== "Backspace") return;
const target = event.target as HTMLElement;
if (target && (target.tagName === "INPUT" || target.tagName === "TEXTAREA" || target.isContentEditable)) return;
const cell = hoveredCellRef.current;
if (!cell || readOnly) return;
event.preventDefault();
event.stopPropagation();
onRemoveReference(cell.rowId, cell.columnIndex);
};
window.addEventListener("keydown", handleKeyDown, true);
return () => window.removeEventListener("keydown", handleKeyDown, true);
}, [readOnly, onRemoveReference]);
// Hide context menu on outside click
useEffect(() => {
if (!contextMenu) return;
const hide = () => setContextMenu(null);
window.addEventListener("pointerdown", hide);
return () => window.removeEventListener("pointerdown", hide);
}, [contextMenu]);"""
content = content.replace(old_effect_end, new_effect_end, 1)
# 4. Destructure onRemoveReference
old_destructure = "onReplaceReference, onUploadReference, onConnectStart, onConnectDrop, readOnly = false"
new_destructure = "onReplaceReference, onUploadReference, onRemoveReference, onConnectStart, onConnectDrop, readOnly = false"
content = content.replace(old_destructure, new_destructure, 1)
# 5. Pass hover tracking and onRemove to ReferenceThumbnail in the rows
old_thumb = """ <ReferenceThumbnail
key={column.id}
node={nodeById.get(row.inputNodeIds[columnIndex])}
theme={theme}
readOnly={readOnly}
rowId={row.id}
columnIndex={columnIndex}
columnId={column.id}
draggingColumnId={draggingColumnId}
isDraggingCell={draggingCell?.rowId === row.id && draggingCell.columnIndex === columnIndex}
isDropTarget={dropCell?.rowId === row.id && dropCell.columnIndex === columnIndex}
suppressClickRef={suppressClickRef}
onReplace={onReplaceReference}
onUpload={() => { uploadTargetRef.current = { rowId: row.id, columnIndex }; uploadInputRef.current?.click(); }}
onPointerDown={handleReferencePointerDown}
onPointerMove={handleReferencePointerMove}
onPointerUp={handleReferencePointerUp}
onPointerCancel={handleReferencePointerCancel}
onLostPointerCapture={handleReferencePointerCancel}
/>"""
new_thumb = """ <ReferenceThumbnail
key={column.id}
node={nodeById.get(row.inputNodeIds[columnIndex])}
theme={theme}
readOnly={readOnly}
rowId={row.id}
columnIndex={columnIndex}
columnId={column.id}
draggingColumnId={draggingColumnId}
isDraggingCell={draggingCell?.rowId === row.id && draggingCell.columnIndex === columnIndex}
isDropTarget={dropCell?.rowId === row.id && dropCell.columnIndex === columnIndex}
suppressClickRef={suppressClickRef}
hoveredCellRef={hoveredCellRef}
onReplace={onReplaceReference}
onRemove={() => onRemoveReference(row.id, columnIndex)}
onContextMenu={(event) => { event.preventDefault(); event.stopPropagation(); setContextMenu({ x: event.clientX, y: event.clientY, cell: { rowId: row.id, columnIndex } }); }}
onUpload={() => { uploadTargetRef.current = { rowId: row.id, columnIndex }; uploadInputRef.current?.click(); }}
onPointerDown={handleReferencePointerDown}
onPointerMove={handleReferencePointerMove}
onPointerUp={handleReferencePointerUp}
onPointerCancel={handleReferencePointerCancel}
onLostPointerCapture={handleReferencePointerCancel}
/>"""
content = content.replace(old_thumb, new_thumb, 1)
# 6. Add context menu overlay before closing div
old_close = """ </div>
</div>
);
}
function ReferenceColumnHeader"""
new_close = """ </div>
{contextMenu ? (
<div
className="fixed z-50 min-w-[120px] rounded-lg border py-1 shadow-lg"
style={{ left: contextMenu.x, top: contextMenu.y, background: theme.node.panel, borderColor: theme.node.stroke }}
onPointerDown={(e) => e.stopPropagation()}
>
<button
type="button"
className="flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs hover:opacity-70"
style={{ color: "#ef4444" }}
onClick={() => { onRemoveReference(contextMenu.cell.rowId, contextMenu.cell.columnIndex); setContextMenu(null); }}
>
<Trash2 className="size-3.5" />
删除素材
</button>
</div>
) : null}
</div>
);
}
function ReferenceColumnHeader"""
content = content.replace(old_close, new_close, 1)
# 7. Update ReferenceThumbnail props type
old_thumb_props = " suppressClickRef: MutableRefObject<boolean>;\n onReplace: (node: CanvasNodeData) => void;\n onUpload: () => void;"
new_thumb_props = " suppressClickRef: MutableRefObject<boolean>;\n hoveredCellRef: MutableRefObject<ReferenceCell | null>;\n onReplace: (node: CanvasNodeData) => void;\n onRemove: () => void;\n onContextMenu: (event: ReactMouseEvent) => void;\n onUpload: () => void;"
content = content.replace(old_thumb_props, new_thumb_props, 1)
# 8. Update ReferenceThumbnail function signature
old_thumb_sig = "function ReferenceThumbnail({ node, theme, readOnly, rowId, columnIndex, columnId, draggingColumnId, isDraggingCell, isDropTarget, suppressClickRef, onReplace, onUpload, onPointerDown, onPointerMove, onPointerUp, onPointerCancel, onLostPointerCapture }: {"
new_thumb_sig = "function ReferenceThumbnail({ node, theme, readOnly, rowId, columnIndex, columnId, draggingColumnId, isDraggingCell, isDropTarget, suppressClickRef, hoveredCellRef, onReplace, onRemove, onContextMenu, onUpload, onPointerDown, onPointerMove, onPointerUp, onPointerCancel, onLostPointerCapture }: {"
content = content.replace(old_thumb_sig, new_thumb_sig, 1)
# 9. Add hover tracking to both thumbnail buttons (empty and filled)
# For empty button - add onMouseEnter/Leave and onContextMenu
old_empty_btn = ''' onClick={(event) => { event.stopPropagation(); if (!suppressClickRef.current) onUpload(); }}
aria-label={`${columnId},点击上传图片`}'''
new_empty_btn = ''' onClick={(event) => { event.stopPropagation(); if (!suppressClickRef.current) onUpload(); }}
onMouseEnter={() => { hoveredCellRef.current = { rowId, columnIndex }; }}
onMouseLeave={() => { if (hoveredCellRef.current?.rowId === rowId && hoveredCellRef.current?.columnIndex === columnIndex) hoveredCellRef.current = null; }}
onContextMenu={onContextMenu}
aria-label={`${columnId},点击上传图片`}'''
content = content.replace(old_empty_btn, new_empty_btn, 1)
# For filled button - add onMouseEnter/Leave and onContextMenu
old_filled_btn = ''' onClick={(event) => { event.stopPropagation(); if (!readOnly && !draggingColumnId && !suppressClickRef.current) onReplace(node); }}
{...cellData}'''
new_filled_btn = ''' onClick={(event) => { event.stopPropagation(); if (!readOnly && !draggingColumnId && !suppressClickRef.current) onReplace(node); }}
onMouseEnter={() => { hoveredCellRef.current = { rowId, columnIndex }; }}
onMouseLeave={() => { if (hoveredCellRef.current?.rowId === rowId && hoveredCellRef.current?.columnIndex === columnIndex) hoveredCellRef.current = null; }}
onContextMenu={onContextMenu}
{...cellData}'''
content = content.replace(old_filled_btn, new_filled_btn, 1)
# 10. Need to import ReactMouseEvent type
old_import = 'import { useCallback, useEffect, useMemo, useRef, useState, type MutableRefObject, type PointerEvent as ReactPointerEvent, type ReactNode } from "react";'
new_import = 'import { useCallback, useEffect, useMemo, useRef, useState, type MutableRefObject, type MouseEvent as ReactMouseEvent, type PointerEvent as ReactPointerEvent, type ReactNode } from "react";'
content = content.replace(old_import, new_import, 1)
with open(path, "w", encoding="utf-8") as f:
f.write(content)
print("done")
@@ -1,4 +1,4 @@
import { useCallback, useEffect, useMemo, useRef, useState, type MutableRefObject, type PointerEvent as ReactPointerEvent, type ReactNode } from "react"; import { useCallback, useEffect, useMemo, useRef, useState, type MutableRefObject, type MouseEvent as ReactMouseEvent, type PointerEvent as ReactPointerEvent, type ReactNode } from "react";
import { Button, Input, Select, Switch, Tooltip } from "antd"; import { Button, Input, Select, Switch, Tooltip } from "antd";
import { GripVertical, Image as ImageIcon, LoaderCircle, Play, Plus, RefreshCw, Rows3, Trash2, Upload } from "lucide-react"; import { GripVertical, Image as ImageIcon, LoaderCircle, Play, Plus, RefreshCw, Rows3, Trash2, Upload } from "lucide-react";
@@ -26,6 +26,7 @@ type Props = {
onMoveReferenceCell: (sourceRowId: string, sourceColumnIndex: number, targetRowId: string, targetColumnIndex: number) => void; onMoveReferenceCell: (sourceRowId: string, sourceColumnIndex: number, targetRowId: string, targetColumnIndex: number) => void;
onReplaceReference: (node: CanvasNodeData) => void; onReplaceReference: (node: CanvasNodeData) => void;
onUploadReference: (rowId: string, columnIndex: number, file: File) => void; onUploadReference: (rowId: string, columnIndex: number, file: File) => void;
onRemoveReference: (rowId: string, columnIndex: number) => void;
onConnectStart: (event: ReactPointerEvent, handleId: string) => void; onConnectStart: (event: ReactPointerEvent, handleId: string) => void;
onConnectDrop?: (event: ReactPointerEvent, handleId: string) => void; onConnectDrop?: (event: ReactPointerEvent, handleId: string) => void;
readOnly?: boolean; readOnly?: boolean;
@@ -38,7 +39,7 @@ const OPERATION_OPTIONS = [
type ReferenceCell = { rowId: string; columnIndex: number }; type ReferenceCell = { rowId: string; columnIndex: number };
export function CanvasBatchTableNodeContent({ node, nodes, connections, batch, theme, onPatchTable, onAddRow, onRemoveRow, onUpdateRow, onFillRows, onGenerate, onRetryItem, onAddReferenceColumn, onAddTextColumn, onReorderReferenceColumns, onMoveReferenceCell, onReplaceReference, onUploadReference, onConnectStart, onConnectDrop, readOnly = false }: Props) { export function CanvasBatchTableNodeContent({ node, nodes, connections, batch, theme, onPatchTable, onAddRow, onRemoveRow, onUpdateRow, onFillRows, onGenerate, onRetryItem, onAddReferenceColumn, onAddTextColumn, onReorderReferenceColumns, onMoveReferenceCell, onReplaceReference, onUploadReference, onRemoveReference, onConnectStart, onConnectDrop, readOnly = false }: Props) {
const table = node.metadata?.batchTable || { operation: "try_on" as const, concurrency: 10, rows: [] }; const table = node.metadata?.batchTable || { operation: "try_on" as const, concurrency: 10, rows: [] };
const referenceColumns = batchReferenceColumns(table); const referenceColumns = batchReferenceColumns(table);
const textColumns = batchTextColumns(table); const textColumns = batchTextColumns(table);
@@ -57,6 +58,8 @@ export function CanvasBatchTableNodeContent({ node, nodes, connections, batch, t
const dropCellRef = useRef<ReferenceCell | null>(null); const dropCellRef = useRef<ReferenceCell | null>(null);
const dragStartRef = useRef<{ x: number; y: number; pointerId: number; cell: ReferenceCell } | null>(null); const dragStartRef = useRef<{ x: number; y: number; pointerId: number; cell: ReferenceCell } | null>(null);
const lastPointerRef = useRef({ x: 0, y: 0 }); const lastPointerRef = useRef({ x: 0, y: 0 });
const hoveredCellRef = useRef<ReferenceCell | null>(null);
const [contextMenu, setContextMenu] = useState<{ x: number; y: number; cell: ReferenceCell } | null>(null);
const suppressClickRef = useRef(false); const suppressClickRef = useRef(false);
const uploadTargetRef = useRef<{ rowId: string; columnIndex: number } | null>(null); const uploadTargetRef = useRef<{ rowId: string; columnIndex: number } | null>(null);
const uploadInputRef = useRef<HTMLInputElement>(null); const uploadInputRef = useRef<HTMLInputElement>(null);
@@ -149,6 +152,30 @@ export function CanvasBatchTableNodeContent({ node, nodes, connections, batch, t
}; };
}, [cancelReferenceDrag, finishReferenceDrag, updateReferenceDrag]); }, [cancelReferenceDrag, finishReferenceDrag, updateReferenceDrag]);
// Delete / Backspace to remove hovered reference
useEffect(() => {
const handleKeyDown = (event: KeyboardEvent) => {
if (event.key !== "Delete" && event.key !== "Backspace") return;
const target = event.target as HTMLElement;
if (target && (target.tagName === "INPUT" || target.tagName === "TEXTAREA" || target.isContentEditable)) return;
const cell = hoveredCellRef.current;
if (!cell || readOnly) return;
event.preventDefault();
event.stopPropagation();
onRemoveReference(cell.rowId, cell.columnIndex);
};
window.addEventListener("keydown", handleKeyDown, true);
return () => window.removeEventListener("keydown", handleKeyDown, true);
}, [readOnly, onRemoveReference]);
// Hide context menu on outside click
useEffect(() => {
if (!contextMenu) return;
const hide = () => setContextMenu(null);
window.addEventListener("pointerdown", hide);
return () => window.removeEventListener("pointerdown", hide);
}, [contextMenu]);
const handleReferencePointerDown = useCallback((event: ReactPointerEvent<HTMLButtonElement>, rowId: string, columnIndex: number, hasMaterial: boolean) => { const handleReferencePointerDown = useCallback((event: ReactPointerEvent<HTMLButtonElement>, rowId: string, columnIndex: number, hasMaterial: boolean) => {
if (readOnly || !hasMaterial) return; if (readOnly || !hasMaterial) return;
event.preventDefault(); event.preventDefault();
@@ -293,7 +320,10 @@ export function CanvasBatchTableNodeContent({ node, nodes, connections, batch, t
isDraggingCell={draggingCell?.rowId === row.id && draggingCell.columnIndex === columnIndex} isDraggingCell={draggingCell?.rowId === row.id && draggingCell.columnIndex === columnIndex}
isDropTarget={dropCell?.rowId === row.id && dropCell.columnIndex === columnIndex} isDropTarget={dropCell?.rowId === row.id && dropCell.columnIndex === columnIndex}
suppressClickRef={suppressClickRef} suppressClickRef={suppressClickRef}
hoveredCellRef={hoveredCellRef}
onReplace={onReplaceReference} onReplace={onReplaceReference}
onRemove={() => onRemoveReference(row.id, columnIndex)}
onContextMenu={(event) => { event.preventDefault(); event.stopPropagation(); setContextMenu({ x: event.clientX, y: event.clientY, cell: { rowId: row.id, columnIndex } }); }}
onUpload={() => { uploadTargetRef.current = { rowId: row.id, columnIndex }; uploadInputRef.current?.click(); }} onUpload={() => { uploadTargetRef.current = { rowId: row.id, columnIndex }; uploadInputRef.current?.click(); }}
onPointerDown={handleReferencePointerDown} onPointerDown={handleReferencePointerDown}
onPointerMove={handleReferencePointerMove} onPointerMove={handleReferencePointerMove}
@@ -351,6 +381,23 @@ export function CanvasBatchTableNodeContent({ node, nodes, connections, batch, t
<div className="grid h-40 place-items-center px-5 text-center" style={{ color: theme.node.muted }}>连接图片后会自动生成任务;点击缩略图可替换素材,拖动参考图列可调整顺序。</div> <div className="grid h-40 place-items-center px-5 text-center" style={{ color: theme.node.muted }}>连接图片后会自动生成任务;点击缩略图可替换素材,拖动参考图列可调整顺序。</div>
)} )}
</div> </div>
{contextMenu ? (
<div
className="fixed z-50 min-w-[120px] rounded-lg border py-1 shadow-lg"
style={{ left: contextMenu.x, top: contextMenu.y, background: theme.node.panel, borderColor: theme.node.stroke }}
onPointerDown={(e) => e.stopPropagation()}
>
<button
type="button"
className="flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs hover:opacity-70"
style={{ color: "#ef4444" }}
onClick={() => { onRemoveReference(contextMenu.cell.rowId, contextMenu.cell.columnIndex); setContextMenu(null); }}
>
<Trash2 className="size-3.5" />
删除素材
</button>
</div>
) : null}
</div> </div>
); );
} }
@@ -497,7 +544,7 @@ function TextNodeCell({ node, theme }: { node?: CanvasNodeData; theme: CanvasThe
return <div className="min-h-12 max-w-full overflow-hidden rounded border px-2 py-1.5 text-[11px] leading-4" style={{ borderColor: theme.node.stroke, color: content ? theme.node.text : theme.node.placeholder }} title={content || "未连接文字节点"}>{content || "未连接文字"}</div>; return <div className="min-h-12 max-w-full overflow-hidden rounded border px-2 py-1.5 text-[11px] leading-4" style={{ borderColor: theme.node.stroke, color: content ? theme.node.text : theme.node.placeholder }} title={content || "未连接文字节点"}>{content || "未连接文字"}</div>;
} }
function ReferenceThumbnail({ node, theme, readOnly, rowId, columnIndex, columnId, draggingColumnId, isDraggingCell, isDropTarget, suppressClickRef, onReplace, onUpload, onPointerDown, onPointerMove, onPointerUp, onPointerCancel, onLostPointerCapture }: { function ReferenceThumbnail({ node, theme, readOnly, rowId, columnIndex, columnId, draggingColumnId, isDraggingCell, isDropTarget, suppressClickRef, hoveredCellRef, onReplace, onRemove, onContextMenu, onUpload, onPointerDown, onPointerMove, onPointerUp, onPointerCancel, onLostPointerCapture }: {
node?: CanvasNodeData; node?: CanvasNodeData;
theme: CanvasTheme; theme: CanvasTheme;
readOnly: boolean; readOnly: boolean;
@@ -508,7 +555,10 @@ function ReferenceThumbnail({ node, theme, readOnly, rowId, columnIndex, columnI
isDraggingCell: boolean; isDraggingCell: boolean;
isDropTarget: boolean; isDropTarget: boolean;
suppressClickRef: MutableRefObject<boolean>; suppressClickRef: MutableRefObject<boolean>;
hoveredCellRef: MutableRefObject<ReferenceCell | null>;
onReplace: (node: CanvasNodeData) => void; onReplace: (node: CanvasNodeData) => void;
onRemove: () => void;
onContextMenu: (event: ReactMouseEvent) => void;
onUpload: () => void; onUpload: () => void;
onPointerDown: (event: ReactPointerEvent<HTMLButtonElement>, rowId: string, columnIndex: number, hasMaterial: boolean) => void; onPointerDown: (event: ReactPointerEvent<HTMLButtonElement>, rowId: string, columnIndex: number, hasMaterial: boolean) => void;
onPointerMove: (event: ReactPointerEvent<HTMLButtonElement>) => void; onPointerMove: (event: ReactPointerEvent<HTMLButtonElement>) => void;
@@ -528,6 +578,9 @@ function ReferenceThumbnail({ node, theme, readOnly, rowId, columnIndex, columnI
style={{ borderColor: isDropTarget ? theme.accent.primary : theme.node.stroke, background: `${theme.node.panel}88`, ...dropStyle }} style={{ borderColor: isDropTarget ? theme.accent.primary : theme.node.stroke, background: `${theme.node.panel}88`, ...dropStyle }}
disabled={readOnly} disabled={readOnly}
onClick={(event) => { event.stopPropagation(); if (!suppressClickRef.current) onUpload(); }} onClick={(event) => { event.stopPropagation(); if (!suppressClickRef.current) onUpload(); }}
onMouseEnter={() => { hoveredCellRef.current = { rowId, columnIndex }; }}
onMouseLeave={() => { if (hoveredCellRef.current?.rowId === rowId && hoveredCellRef.current?.columnIndex === columnIndex) hoveredCellRef.current = null; }}
onContextMenu={onContextMenu}
aria-label={`${columnId},点击上传图片`} aria-label={`${columnId},点击上传图片`}
{...cellData} {...cellData}
onPointerDown={(event) => onPointerDown(event, rowId, columnIndex, false)} onPointerDown={(event) => onPointerDown(event, rowId, columnIndex, false)}
@@ -553,6 +606,9 @@ function ReferenceThumbnail({ node, theme, readOnly, rowId, columnIndex, columnI
style={{ borderColor: isDropTarget || draggingColumnId === columnId ? theme.accent.primary : theme.node.stroke, opacity: isDraggingCell || draggingColumnId === columnId ? 0.55 : 1, ...dropStyle }} style={{ borderColor: isDropTarget || draggingColumnId === columnId ? theme.accent.primary : theme.node.stroke, opacity: isDraggingCell || draggingColumnId === columnId ? 0.55 : 1, ...dropStyle }}
aria-label={readOnly ? node.title || "参考图" : `${node.title || "参考图"},点击替换素材`} aria-label={readOnly ? node.title || "参考图" : `${node.title || "参考图"},点击替换素材`}
onClick={(event) => { event.stopPropagation(); if (!readOnly && !draggingColumnId && !suppressClickRef.current) onReplace(node); }} onClick={(event) => { event.stopPropagation(); if (!readOnly && !draggingColumnId && !suppressClickRef.current) onReplace(node); }}
onMouseEnter={() => { hoveredCellRef.current = { rowId, columnIndex }; }}
onMouseLeave={() => { if (hoveredCellRef.current?.rowId === rowId && hoveredCellRef.current?.columnIndex === columnIndex) hoveredCellRef.current = null; }}
onContextMenu={onContextMenu}
{...cellData} {...cellData}
onPointerDown={(event) => onPointerDown(event, rowId, columnIndex, true)} onPointerDown={(event) => onPointerDown(event, rowId, columnIndex, true)}
onPointerMove={onPointerMove} onPointerMove={onPointerMove}
+9
View File
@@ -2174,6 +2174,15 @@ function InfiniteCanvasPage() {
onMoveReferenceCell={(sourceRowId, sourceColumnIndex, targetRowId, targetColumnIndex) => moveBatchReferenceCell(contentNode.id, sourceRowId, sourceColumnIndex, targetRowId, targetColumnIndex)} onMoveReferenceCell={(sourceRowId, sourceColumnIndex, targetRowId, targetColumnIndex) => moveBatchReferenceCell(contentNode.id, sourceRowId, sourceColumnIndex, targetRowId, targetColumnIndex)}
onReplaceReference={replaceCanvasNodeMedia} onReplaceReference={replaceCanvasNodeMedia}
onUploadReference={(rowId, columnIndex, file) => { void handleUploadBatchReference(contentNode.id, rowId, columnIndex, file); }} onUploadReference={(rowId, columnIndex, file) => { void handleUploadBatchReference(contentNode.id, rowId, columnIndex, file); }}
onRemoveReference={(rowId, columnIndex) => {
const table = nodesRef.current.find((n) => n.id === contentNode.id)?.metadata?.batchTable;
if (!table) return;
const row = table.rows.find((r) => r.id === rowId);
if (!row) return;
const newInputNodeIds = [...row.inputNodeIds];
newInputNodeIds[columnIndex] = "";
updateBatchRow(contentNode.id, rowId, { inputNodeIds: newInputNodeIds });
}}
onConnectStart={(event, handleId) => handleConnectStart(event, contentNode.id, "target", handleId)} onConnectStart={(event, handleId) => handleConnectStart(event, contentNode.id, "target", handleId)}
onConnectDrop={(event, handleId) => handleConnectDrop(event, contentNode.id, handleId)} onConnectDrop={(event, handleId) => handleConnectDrop(event, contentNode.id, handleId)}
/> />
+1 -1
View File
@@ -238,7 +238,7 @@ export default function SharedCanvasPage() {
})); }));
const renderSharedNode = useCallback((node: CanvasNodeData): ReactNode => { const renderSharedNode = useCallback((node: CanvasNodeData): ReactNode => {
if (node.type === CanvasNodeType.Script) return <SharedScriptNode node={node} onUnauthorized={unauthorized} />; if (node.type === CanvasNodeType.Script) return <SharedScriptNode node={node} onUnauthorized={unauthorized} />;
if (node.type === CanvasNodeType.BatchTable) return <CanvasBatchTableNodeContent node={node} nodes={nodes} connections={connections} batch={node.metadata?.generationBatches?.at(-1)} theme={theme} readOnly onPatchTable={() => {}} onAddRow={() => {}} onRemoveRow={() => {}} onUpdateRow={() => {}} onFillRows={() => {}} onGenerate={() => {}} onRetryItem={() => {}} onAddReferenceColumn={() => {}} onAddTextColumn={() => {}} onReorderReferenceColumns={() => {}} onMoveReferenceCell={() => {}} onReplaceReference={() => {}} onUploadReference={() => {}} onConnectStart={() => {}} />; if (node.type === CanvasNodeType.BatchTable) return <CanvasBatchTableNodeContent node={node} nodes={nodes} connections={connections} batch={node.metadata?.generationBatches?.at(-1)} theme={theme} readOnly onPatchTable={() => {}} onAddRow={() => {}} onRemoveRow={() => {}} onUpdateRow={() => {}} onFillRows={() => {}} onGenerate={() => {}} onRetryItem={() => {}} onAddReferenceColumn={() => {}} onAddTextColumn={() => {}} onReorderReferenceColumns={() => {}} onMoveReferenceCell={() => {}} onReplaceReference={() => {}} onUploadReference={() => {}} onRemoveReference={() => {}} onConnectStart={() => {}} />;
return <SharedConfigNode node={node} onUnauthorized={unauthorized} />; return <SharedConfigNode node={node} onUnauthorized={unauthorized} />;
}, [connections, nodes, theme, unauthorized]); }, [connections, nodes, theme, unauthorized]);
const toolbarNodeKey = selectedNodeId; const toolbarNodeKey = selectedNodeId;