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

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

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