Browse Source

feat: add runCode button in CodeEditorModal's footer

master
smallstonesk 4 years ago
parent
commit
b1782551bd
  1. 15
      packages/core/src/mods/flowChart/codeEditorModel/index.tsx
  2. 2
      packages/core/src/mods/flowChart/codeRunModal/index.module.less

15
packages/core/src/mods/flowChart/codeEditorModel/index.tsx

@ -7,7 +7,7 @@ import 'antd/es/modal/style';
import styles from './index.module.less';
import { Graph } from '@antv/x6';
import { Modal, message } from 'antd';
import { Button, Modal, message } from 'antd';
import JsonView from 'react-json-view';
import { safeParse } from '../../../utils';
import analyzeDeps from '../../../utils/analyzeDeps';
@ -85,7 +85,10 @@ const CodeEditModal: React.FC<IProps> = (props) => {
};
const onCancel = (): void => {
setVisible(false);
}
};
const onRunCode = (): void => {
flowChart.trigger('graph:runCode');
};
const onChangeCode = (ev: any, newCode: string | undefined = ''): void => {
setCode(newCode);
};
@ -98,11 +101,13 @@ const CodeEditModal: React.FC<IProps> = (props) => {
className={styles.modal}
width={1000}
title={title}
okText={'保存'}
visible={visible}
cancelText={'取消'}
onOk={onOk}
onCancel={onCancel}
footer={[
<Button key={'cancel'} onClick={onCancel}></Button>,
<Button key={'runCode'} type={'primary'} ghost onClick={onRunCode}></Button>,
<Button key={'saveCode'} type={'primary'} onClick={onOk}></Button>,
]}
>
<CodeEditor
value={code}

2
packages/core/src/mods/flowChart/codeRunModal/index.module.less

@ -2,7 +2,7 @@
:global {
.ant-modal-body {
padding: 0;
height: 650px;
height: 653px;
}
}
}
Loading…
Cancel
Save