diff --git a/frontend/src/pages/Workflow/Definition/Design/index.tsx b/frontend/src/pages/Workflow/Definition/Design/index.tsx index 42e9a2a7..30e6701a 100644 --- a/frontend/src/pages/Workflow/Definition/Design/index.tsx +++ b/frontend/src/pages/Workflow/Definition/Design/index.tsx @@ -1,9 +1,22 @@ import React, {useEffect, useState, useRef} from 'react'; import {useParams, useNavigate} from 'react-router-dom'; import {Button, Space, Card, Row, Col, message, Modal} from 'antd'; -import {ArrowLeftOutlined, SaveOutlined, PlayCircleOutlined} from '@ant-design/icons'; +import { + ArrowLeftOutlined, + SaveOutlined, + PlayCircleOutlined, + CopyOutlined, + DeleteOutlined, + UndoOutlined, + RedoOutlined, + ScissorOutlined, + SnippetsOutlined, +} from '@ant-design/icons'; import {Graph, Cell} from '@antv/x6'; import '@antv/x6-plugin-snapline'; +import '@antv/x6-plugin-clipboard'; +import '@antv/x6-plugin-history'; +import { Selection } from '@antv/x6-plugin-selection'; import {getDefinitionDetail, saveDefinition} from '../service'; import {getNodeDefinitionList} from './service'; import NodePanel from './components/NodePanel'; @@ -61,25 +74,47 @@ const WorkflowDesign: React.FC = () => { snapline: true, history: true, clipboard: true, - selecting: true, keyboard: true, background: { color: '#f5f5f5', }, - mousewheel: { - enabled: true, - modifiers: ['ctrl', 'meta'], - factor: 1.1, - maxScale: 1.5, - minScale: 0.5, - }, - panning: { - enabled: true, - eventTypes: ['rightMouseDown'], - }, - preventDefaultContextMenu: true, }); + // 注册选择插件 + graph.use( + new Selection({ + enabled: true, + multiple: true, + rubberband: true, + showNodeSelectionBox: true, + showEdgeSelectionBox: true, + className: 'node-selected', + pointerEvents: 'none', + }) + ); + + // 添加选择样式 + const style = document.createElement('style'); + style.textContent = ` + .node-selected > rect { + stroke: #1890ff; + stroke-width: 2px; + } + .node-selected > path { + stroke: #1890ff; + stroke-width: 2px; + } + .x6-node-selected rect { + stroke: #1890ff; + stroke-width: 2px; + } + .x6-edge-selected path { + stroke: #1890ff; + stroke-width: 2px !important; + } + `; + document.head.appendChild(style); + // 显示/隐藏连接桩 graph.on('node:mouseenter', ({node}) => { const ports = document.querySelectorAll(`[data-cell-id="${node.id}"] .x6-port-body`); @@ -307,6 +342,94 @@ const WorkflowDesign: React.FC = () => { }} extra={ + +