This commit is contained in:
asp_ly 2024-12-14 15:41:23 +08:00
parent fd90632e0f
commit d1908582c1

View File

@ -88,6 +88,14 @@ const WorkflowDesign: React.FC = () => {
rubberband: true, rubberband: true,
movable: true, movable: true,
showNodeSelectionBox: true, showNodeSelectionBox: true,
strict: true,
selectCellOnMoved: true,
selectNodeOnMoved: true,
selectEdgeOnMoved: true,
multipleSelectionModifiers: ['ctrl', 'meta'],
showEdgeSelectionBox: true,
showAnchorSelectionBox: true,
pointerEvents: 'auto'
}, },
snapline: true, snapline: true,
keyboard: { keyboard: {
@ -120,7 +128,25 @@ const WorkflowDesign: React.FC = () => {
}, },
}); });
graph.use(new Selection()); // 初始化Selection插件
const selection = new Selection({
enabled: true,
multiple: true,
rubberband: true,
movable: true,
showNodeSelectionBox: true,
strict: true,
selectCellOnMoved: true,
selectNodeOnMoved: true,
selectEdgeOnMoved: true,
multipleSelectionModifiers: ['ctrl', 'meta'],
showEdgeSelectionBox: true,
showAnchorSelectionBox: true,
pointerEvents: 'auto'
});
console.log('Initializing Selection plugin:', selection);
graph.use(selection);
graph.use(new MiniMap({ graph.use(new MiniMap({
container: minimapContainerRef.current!, container: minimapContainerRef.current!,
width: minimapWidth, width: minimapWidth,
@ -782,18 +808,39 @@ const WorkflowDesign: React.FC = () => {
</Tooltip> </Tooltip>
</Space.Compact> </Space.Compact>
<Space.Compact> <Space.Compact>
<Tooltip title=""> <Tooltip title="选">
<Button <Button
icon={<SelectOutlined />} icon={<SelectOutlined />}
onClick={() => { onClick={() => {
if (!graph) return; if (!graph) return;
// 添加小延时确保图形已完全初始化
setTimeout(() => {
const cells = graph.getCells(); const cells = graph.getCells();
console.log('All cells:', cells);
if (cells.length === 0) { if (cells.length === 0) {
message.info('当前没有可选择的元素'); message.info('当前没有可选择的元素');
return; return;
} }
// 打印当前选择状态
console.log('Current selection before reset:', graph.getSelectedCells());
graph.resetSelection(); graph.resetSelection();
console.log('Selection after reset:', graph.getSelectedCells());
// 尝试选择所有单元格
try {
graph.select(cells); graph.select(cells);
console.log('Selection after select all:', graph.getSelectedCells());
} catch (error) {
console.error('Error selecting cells:', error);
}
// 检查Selection插件是否正确初始化
const selection = graph.getPlugin('selection');
console.log('Selection plugin:', selection);
}, 100);
}} }}
/> />
</Tooltip> </Tooltip>