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

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

@ -55,6 +55,9 @@ const registerEvents = (flowChart: Graph): void => {
args.edge.attr('line/strokeWidth', '2px'); args.edge.attr('line/strokeWidth', '2px');
} }
}); });
flowChart.on('node:dblclick', () => {
flowChart.trigger('settingBar:clickEditCode');
});
flowChart.on('blank:contextmenu', (args) => { flowChart.on('blank:contextmenu', (args) => {
const { e: { clientX, clientY } } = args; const { e: { clientX, clientY } } = args;
flowChart.cleanSelection(); 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); const [visible, setVisible] = useState<boolean>(false);
useEffect(() => { useEffect(() => {
flowChart.on('node:dblclick', () => { flowChart.on('settingBar:clickEditCode', onClickEdit);
onClickEdit(); return () => {
}); flowChart.off('settingBar:clickEditCode', onClickEdit);
};
}, []); }, []);
// events // events

Loading…
Cancel
Save