Browse Source

feat: completes editint code item of node's context menu

master
smallstonesk 4 years ago
parent
commit
b2bf6a3755
  1. 12
      packages/core/src/mods/flowChart/contextMenu/menuConfig/node.tsx
  2. 3
      packages/core/src/mods/flowChart/createFlowChart.ts
  3. 7
      packages/core/src/mods/settingBar/components/code/index.tsx

12
packages/core/src/mods/flowChart/contextMenu/menuConfig/node.tsx

@ -9,6 +9,8 @@ import {
} from '@ant-design/icons';
import XIcon from '../../../../components/xIcon';
import shortcuts from '../../../../common/shortcuts';
import { Graph } from '@antv/x6';
import { getSelectedNodes } from '../../../../utils/flowChartUtils';
const nodeMenuConfig = [
{
@ -49,14 +51,20 @@ const nodeMenuConfig = [
key: 'editCode',
title: '编辑代码',
icon: <FormOutlined />,
handler() {
// TODO
disabled(flowChart: Graph) {
return getSelectedNodes(flowChart).length !== 1;
},
handler(flowChart: Graph) {
flowChart.trigger('settingBar:clickEditCode');
}
},
{
key: 'executeCode',
title: '执行代码',
icon: <CodeOutlined />,
disabled(flowChart: Graph) {
return getSelectedNodes(flowChart).length !== 1;
},
handler() {
// TODO
}

3
packages/core/src/mods/flowChart/createFlowChart.ts

@ -55,6 +55,9 @@ const registerEvents = (flowChart: Graph): void => {
args.edge.attr('line/strokeWidth', '2px');
}
});
flowChart.on('node:dblclick', () => {
flowChart.trigger('settingBar:clickEditCode');
});
flowChart.on('blank:contextmenu', (args) => {
const { e: { clientX, clientY } } = args;
flowChart.cleanSelection();

7
packages/core/src/mods/settingBar/components/code/index.tsx

@ -21,9 +21,10 @@ const Code: React.FC<IProps> = (props) => {
const [visible, setVisible] = useState<boolean>(false);
useEffect(() => {
flowChart.on('node:dblclick', () => {
onClickEdit();
});
flowChart.on('settingBar:clickEditCode', onClickEdit);
return () => {
flowChart.off('settingBar:clickEditCode', onClickEdit);
};
}, []);
// events

Loading…
Cancel
Save