From 4b28cfb9718e70537baf670c06f2a8b281c30be1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=B8=85?= Date: Wed, 22 May 2019 16:01:11 +0800 Subject: [PATCH] add EditorFlow --- .../components/PageHeaderWrapper/index.tsx | 2 +- EditorFlow/.gitignore | 7 + EditorFlow/README.md | 13 ++ EditorFlow/package.json | 36 +++++ EditorFlow/src/common/IconFont/index.js | 7 + .../EditorContextMenu/FlowContextMenu.js | 36 +++++ .../EditorContextMenu/KoniContextMenu.js | 3 + .../components/EditorContextMenu/MenuItem.js | 20 +++ .../EditorContextMenu/MindContextMenu.js | 24 ++++ .../src/components/EditorContextMenu/index.js | 5 + .../components/EditorContextMenu/index.less | 39 ++++++ .../EditorDetailPanel/DetailForm.js | 129 ++++++++++++++++++ .../EditorDetailPanel/FlowDetailPanel.js | 29 ++++ .../EditorDetailPanel/KoniDetailPanel.js | 3 + .../EditorDetailPanel/MindDetailPanel.js | 20 +++ .../src/components/EditorDetailPanel/index.js | 5 + .../components/EditorDetailPanel/index.less | 10 ++ .../EditorItemPanel/FlowItemPanel.js | 55 ++++++++ .../EditorItemPanel/KoniItemPanel.js | 54 ++++++++ .../src/components/EditorItemPanel/index.js | 4 + .../src/components/EditorItemPanel/index.less | 20 +++ .../src/components/EditorMinimap/index.js | 13 ++ .../components/EditorToolbar/FlowToolbar.js | 32 +++++ .../components/EditorToolbar/KoniToolbar.js | 3 + .../components/EditorToolbar/MindToolbar.js | 27 ++++ .../components/EditorToolbar/ToolbarButton.js | 24 ++++ .../src/components/EditorToolbar/index.js | 5 + .../src/components/EditorToolbar/index.less | 39 ++++++ .../components/PageHeaderWrapper/index.less | 86 ++++++++++++ .../components/PageHeaderWrapper/index.tsx | 96 +++++++++++++ EditorFlow/src/index.less | 41 ++++++ EditorFlow/src/index.tsx | 42 ++++++ EditorKoni/.gitignore | 7 + EditorKoni/README.md | 13 ++ EditorKoni/package.json | 36 +++++ EditorKoni/src/common/IconFont/index.js | 7 + .../EditorContextMenu/FlowContextMenu.js | 36 +++++ .../EditorContextMenu/KoniContextMenu.js | 3 + .../components/EditorContextMenu/MenuItem.js | 20 +++ .../EditorContextMenu/MindContextMenu.js | 24 ++++ .../src/components/EditorContextMenu/index.js | 5 + .../components/EditorContextMenu/index.less | 39 ++++++ .../EditorDetailPanel/DetailForm.js | 129 ++++++++++++++++++ .../EditorDetailPanel/FlowDetailPanel.js | 29 ++++ .../EditorDetailPanel/KoniDetailPanel.js | 3 + .../EditorDetailPanel/MindDetailPanel.js | 20 +++ .../src/components/EditorDetailPanel/index.js | 5 + .../components/EditorDetailPanel/index.less | 10 ++ .../EditorItemPanel/FlowItemPanel.js | 55 ++++++++ .../EditorItemPanel/KoniItemPanel.js | 54 ++++++++ .../src/components/EditorItemPanel/index.js | 4 + .../src/components/EditorItemPanel/index.less | 20 +++ .../src/components/EditorMinimap/index.js | 13 ++ .../components/EditorToolbar/FlowToolbar.js | 32 +++++ .../components/EditorToolbar/KoniToolbar.js | 3 + .../components/EditorToolbar/MindToolbar.js | 27 ++++ .../components/EditorToolbar/ToolbarButton.js | 24 ++++ .../src/components/EditorToolbar/index.js | 5 + .../src/components/EditorToolbar/index.less | 39 ++++++ .../components/PageHeaderWrapper/index.less | 86 ++++++++++++ .../components/PageHeaderWrapper/index.tsx | 96 +++++++++++++ .../components/shape/nodes/KoniCustomNode.js | 33 +++++ EditorKoni/src/index.less | 41 ++++++ EditorKoni/src/index.tsx | 44 ++++++ EditorMind/.gitignore | 7 + EditorMind/README.md | 13 ++ EditorMind/package.json | 36 +++++ EditorMind/src/common/IconFont/index.js | 7 + .../EditorContextMenu/FlowContextMenu.js | 36 +++++ .../EditorContextMenu/KoniContextMenu.js | 3 + .../components/EditorContextMenu/MenuItem.js | 20 +++ .../EditorContextMenu/MindContextMenu.js | 24 ++++ .../src/components/EditorContextMenu/index.js | 5 + .../components/EditorContextMenu/index.less | 39 ++++++ .../EditorDetailPanel/DetailForm.js | 129 ++++++++++++++++++ .../EditorDetailPanel/FlowDetailPanel.js | 29 ++++ .../EditorDetailPanel/KoniDetailPanel.js | 3 + .../EditorDetailPanel/MindDetailPanel.js | 20 +++ .../src/components/EditorDetailPanel/index.js | 5 + .../components/EditorDetailPanel/index.less | 10 ++ .../EditorItemPanel/FlowItemPanel.js | 55 ++++++++ .../EditorItemPanel/KoniItemPanel.js | 54 ++++++++ .../src/components/EditorItemPanel/index.js | 4 + .../src/components/EditorItemPanel/index.less | 20 +++ .../src/components/EditorMinimap/index.js | 13 ++ .../components/EditorToolbar/FlowToolbar.js | 32 +++++ .../components/EditorToolbar/KoniToolbar.js | 3 + .../components/EditorToolbar/MindToolbar.js | 27 ++++ .../components/EditorToolbar/ToolbarButton.js | 24 ++++ .../src/components/EditorToolbar/index.js | 5 + .../src/components/EditorToolbar/index.less | 39 ++++++ .../components/PageHeaderWrapper/index.less | 86 ++++++++++++ .../components/PageHeaderWrapper/index.tsx | 96 +++++++++++++ EditorMind/src/index.less | 41 ++++++ EditorMind/src/index.tsx | 39 ++++++ EditorMind/src/worldCup2018.json | 129 ++++++++++++++++++ .../components/PageHeaderWrapper/index.tsx | 4 +- .../components/PageHeaderWrapper/index.tsx | 4 +- .../components/PageHeaderWrapper/index.tsx | 4 +- .../components/PageHeaderWrapper/index.tsx | 4 +- .../components/PageHeaderWrapper/index.tsx | 4 +- .../components/PageHeaderWrapper/index.tsx | 4 +- package.json | 2 +- 103 files changed, 2956 insertions(+), 14 deletions(-) create mode 100644 EditorFlow/.gitignore create mode 100644 EditorFlow/README.md create mode 100644 EditorFlow/package.json create mode 100644 EditorFlow/src/common/IconFont/index.js create mode 100644 EditorFlow/src/components/EditorContextMenu/FlowContextMenu.js create mode 100644 EditorFlow/src/components/EditorContextMenu/KoniContextMenu.js create mode 100644 EditorFlow/src/components/EditorContextMenu/MenuItem.js create mode 100644 EditorFlow/src/components/EditorContextMenu/MindContextMenu.js create mode 100644 EditorFlow/src/components/EditorContextMenu/index.js create mode 100644 EditorFlow/src/components/EditorContextMenu/index.less create mode 100644 EditorFlow/src/components/EditorDetailPanel/DetailForm.js create mode 100644 EditorFlow/src/components/EditorDetailPanel/FlowDetailPanel.js create mode 100644 EditorFlow/src/components/EditorDetailPanel/KoniDetailPanel.js create mode 100644 EditorFlow/src/components/EditorDetailPanel/MindDetailPanel.js create mode 100644 EditorFlow/src/components/EditorDetailPanel/index.js create mode 100644 EditorFlow/src/components/EditorDetailPanel/index.less create mode 100644 EditorFlow/src/components/EditorItemPanel/FlowItemPanel.js create mode 100644 EditorFlow/src/components/EditorItemPanel/KoniItemPanel.js create mode 100644 EditorFlow/src/components/EditorItemPanel/index.js create mode 100644 EditorFlow/src/components/EditorItemPanel/index.less create mode 100644 EditorFlow/src/components/EditorMinimap/index.js create mode 100644 EditorFlow/src/components/EditorToolbar/FlowToolbar.js create mode 100644 EditorFlow/src/components/EditorToolbar/KoniToolbar.js create mode 100644 EditorFlow/src/components/EditorToolbar/MindToolbar.js create mode 100644 EditorFlow/src/components/EditorToolbar/ToolbarButton.js create mode 100644 EditorFlow/src/components/EditorToolbar/index.js create mode 100644 EditorFlow/src/components/EditorToolbar/index.less create mode 100644 EditorFlow/src/components/PageHeaderWrapper/index.less create mode 100644 EditorFlow/src/components/PageHeaderWrapper/index.tsx create mode 100644 EditorFlow/src/index.less create mode 100644 EditorFlow/src/index.tsx create mode 100644 EditorKoni/.gitignore create mode 100644 EditorKoni/README.md create mode 100644 EditorKoni/package.json create mode 100644 EditorKoni/src/common/IconFont/index.js create mode 100644 EditorKoni/src/components/EditorContextMenu/FlowContextMenu.js create mode 100644 EditorKoni/src/components/EditorContextMenu/KoniContextMenu.js create mode 100644 EditorKoni/src/components/EditorContextMenu/MenuItem.js create mode 100644 EditorKoni/src/components/EditorContextMenu/MindContextMenu.js create mode 100644 EditorKoni/src/components/EditorContextMenu/index.js create mode 100644 EditorKoni/src/components/EditorContextMenu/index.less create mode 100644 EditorKoni/src/components/EditorDetailPanel/DetailForm.js create mode 100644 EditorKoni/src/components/EditorDetailPanel/FlowDetailPanel.js create mode 100644 EditorKoni/src/components/EditorDetailPanel/KoniDetailPanel.js create mode 100644 EditorKoni/src/components/EditorDetailPanel/MindDetailPanel.js create mode 100644 EditorKoni/src/components/EditorDetailPanel/index.js create mode 100644 EditorKoni/src/components/EditorDetailPanel/index.less create mode 100644 EditorKoni/src/components/EditorItemPanel/FlowItemPanel.js create mode 100644 EditorKoni/src/components/EditorItemPanel/KoniItemPanel.js create mode 100644 EditorKoni/src/components/EditorItemPanel/index.js create mode 100644 EditorKoni/src/components/EditorItemPanel/index.less create mode 100644 EditorKoni/src/components/EditorMinimap/index.js create mode 100644 EditorKoni/src/components/EditorToolbar/FlowToolbar.js create mode 100644 EditorKoni/src/components/EditorToolbar/KoniToolbar.js create mode 100644 EditorKoni/src/components/EditorToolbar/MindToolbar.js create mode 100644 EditorKoni/src/components/EditorToolbar/ToolbarButton.js create mode 100644 EditorKoni/src/components/EditorToolbar/index.js create mode 100644 EditorKoni/src/components/EditorToolbar/index.less create mode 100644 EditorKoni/src/components/PageHeaderWrapper/index.less create mode 100644 EditorKoni/src/components/PageHeaderWrapper/index.tsx create mode 100644 EditorKoni/src/components/shape/nodes/KoniCustomNode.js create mode 100644 EditorKoni/src/index.less create mode 100644 EditorKoni/src/index.tsx create mode 100644 EditorMind/.gitignore create mode 100644 EditorMind/README.md create mode 100644 EditorMind/package.json create mode 100644 EditorMind/src/common/IconFont/index.js create mode 100644 EditorMind/src/components/EditorContextMenu/FlowContextMenu.js create mode 100644 EditorMind/src/components/EditorContextMenu/KoniContextMenu.js create mode 100644 EditorMind/src/components/EditorContextMenu/MenuItem.js create mode 100644 EditorMind/src/components/EditorContextMenu/MindContextMenu.js create mode 100644 EditorMind/src/components/EditorContextMenu/index.js create mode 100644 EditorMind/src/components/EditorContextMenu/index.less create mode 100644 EditorMind/src/components/EditorDetailPanel/DetailForm.js create mode 100644 EditorMind/src/components/EditorDetailPanel/FlowDetailPanel.js create mode 100644 EditorMind/src/components/EditorDetailPanel/KoniDetailPanel.js create mode 100644 EditorMind/src/components/EditorDetailPanel/MindDetailPanel.js create mode 100644 EditorMind/src/components/EditorDetailPanel/index.js create mode 100644 EditorMind/src/components/EditorDetailPanel/index.less create mode 100644 EditorMind/src/components/EditorItemPanel/FlowItemPanel.js create mode 100644 EditorMind/src/components/EditorItemPanel/KoniItemPanel.js create mode 100644 EditorMind/src/components/EditorItemPanel/index.js create mode 100644 EditorMind/src/components/EditorItemPanel/index.less create mode 100644 EditorMind/src/components/EditorMinimap/index.js create mode 100644 EditorMind/src/components/EditorToolbar/FlowToolbar.js create mode 100644 EditorMind/src/components/EditorToolbar/KoniToolbar.js create mode 100644 EditorMind/src/components/EditorToolbar/MindToolbar.js create mode 100644 EditorMind/src/components/EditorToolbar/ToolbarButton.js create mode 100644 EditorMind/src/components/EditorToolbar/index.js create mode 100644 EditorMind/src/components/EditorToolbar/index.less create mode 100644 EditorMind/src/components/PageHeaderWrapper/index.less create mode 100644 EditorMind/src/components/PageHeaderWrapper/index.tsx create mode 100644 EditorMind/src/index.less create mode 100644 EditorMind/src/index.tsx create mode 100644 EditorMind/src/worldCup2018.json diff --git a/DashboardWorkplace/src/components/PageHeaderWrapper/index.tsx b/DashboardWorkplace/src/components/PageHeaderWrapper/index.tsx index dc5ee01b..f8f54550 100644 --- a/DashboardWorkplace/src/components/PageHeaderWrapper/index.tsx +++ b/DashboardWorkplace/src/components/PageHeaderWrapper/index.tsx @@ -20,7 +20,7 @@ const PageHeaderWrapper: React.SFC = ({ {value => (
- +
diff --git a/EditorFlow/.gitignore b/EditorFlow/.gitignore new file mode 100644 index 00000000..8ce76bc4 --- /dev/null +++ b/EditorFlow/.gitignore @@ -0,0 +1,7 @@ +/yarn.lock +/package-lock.json +/dist +/node_modules + +.umi +.umi-production diff --git a/EditorFlow/README.md b/EditorFlow/README.md new file mode 100644 index 00000000..bfcf96e8 --- /dev/null +++ b/EditorFlow/README.md @@ -0,0 +1,13 @@ +# @umi-blocks/ant-design-pro/flow + +flow + +## Usage + +```sh +umi block add ant-design-pro/flow +``` + +## LICENSE + +MIT diff --git a/EditorFlow/package.json b/EditorFlow/package.json new file mode 100644 index 00000000..045a5998 --- /dev/null +++ b/EditorFlow/package.json @@ -0,0 +1,36 @@ +{ + "name": "@umi-block/flow", + "version": "0.0.1", + "description": "flow", + "repository": { + "type": "git", + "url": "https://github.com/umijs/umi-blocks/ant-design-pro/flow" + }, + "license": "ISC", + "main": "src/index.js", + "scripts": { + "dev": "umi dev" + }, + "dependencies": { + "@antv/data-set": "^0.10.2", + "antd": "^3.16.3", + "bizcharts": "^3.5.2", + "bizcharts-plugin-slider": "^2.1.1-beta.1", + "dva": "^2.4.0", + "gg-editor": "^2.0.2", + "moment": "^2.22.2", + "numeral": "^2.0.6", + "react": "^16.6.3", + "react-fittext": "^1.0.0", + "umi-request": "^1.0.0" + }, + "devDependencies": { + "umi": "^2.6.9", + "umi-plugin-block-dev": "^1.1.0", + "umi-plugin-react": "^1.7.2", + "@types/numeral": "^0.0.25" + }, + "blockConfig": { + "specVersion": "0.1" + } +} diff --git a/EditorFlow/src/common/IconFont/index.js b/EditorFlow/src/common/IconFont/index.js new file mode 100644 index 00000000..3bba8d2e --- /dev/null +++ b/EditorFlow/src/common/IconFont/index.js @@ -0,0 +1,7 @@ +import { Icon } from 'antd'; + +const IconFont = Icon.createFromIconfontCN({ + scriptUrl: 'https://at.alicdn.com/t/font_1101588_01zniftxm9yp.js', +}); + +export default IconFont; diff --git a/EditorFlow/src/components/EditorContextMenu/FlowContextMenu.js b/EditorFlow/src/components/EditorContextMenu/FlowContextMenu.js new file mode 100644 index 00000000..cbb7041f --- /dev/null +++ b/EditorFlow/src/components/EditorContextMenu/FlowContextMenu.js @@ -0,0 +1,36 @@ +import React from 'react'; +import { NodeMenu, EdgeMenu, GroupMenu, MultiMenu, CanvasMenu, ContextMenu } from 'gg-editor'; +import MenuItem from './MenuItem'; +import styles from './index.less'; + +const FlowContextMenu = () => { + return ( + + + + + + + + + + + + + + + + + + + + + + + + + + ); +}; + +export default FlowContextMenu; diff --git a/EditorFlow/src/components/EditorContextMenu/KoniContextMenu.js b/EditorFlow/src/components/EditorContextMenu/KoniContextMenu.js new file mode 100644 index 00000000..8b049a5e --- /dev/null +++ b/EditorFlow/src/components/EditorContextMenu/KoniContextMenu.js @@ -0,0 +1,3 @@ +import FlowContextMenu from './FlowContextMenu'; + +export default FlowContextMenu; diff --git a/EditorFlow/src/components/EditorContextMenu/MenuItem.js b/EditorFlow/src/components/EditorContextMenu/MenuItem.js new file mode 100644 index 00000000..4cbde89e --- /dev/null +++ b/EditorFlow/src/components/EditorContextMenu/MenuItem.js @@ -0,0 +1,20 @@ +import React from 'react'; +import { Command } from 'gg-editor'; +import upperFirst from 'lodash/upperFirst'; +import IconFont from '../../common/IconFont'; +import styles from './index.less'; + +const MenuItem = props => { + const { command, icon, text } = props; + + return ( + +
+ + {text || upperFirst(command)} +
+
+ ); +}; + +export default MenuItem; diff --git a/EditorFlow/src/components/EditorContextMenu/MindContextMenu.js b/EditorFlow/src/components/EditorContextMenu/MindContextMenu.js new file mode 100644 index 00000000..2a9d43cd --- /dev/null +++ b/EditorFlow/src/components/EditorContextMenu/MindContextMenu.js @@ -0,0 +1,24 @@ +import React from 'react'; +import { NodeMenu, CanvasMenu, ContextMenu } from 'gg-editor'; +import MenuItem from './MenuItem'; +import styles from './index.less'; + +const MindContextMenu = () => { + return ( + + + + + + + + + + + + + + ); +}; + +export default MindContextMenu; diff --git a/EditorFlow/src/components/EditorContextMenu/index.js b/EditorFlow/src/components/EditorContextMenu/index.js new file mode 100644 index 00000000..16fcde01 --- /dev/null +++ b/EditorFlow/src/components/EditorContextMenu/index.js @@ -0,0 +1,5 @@ +import FlowContextMenu from './FlowContextMenu'; +import MindContextMenu from './MindContextMenu'; +import KoniContextMenu from './KoniContextMenu'; + +export { FlowContextMenu, MindContextMenu, KoniContextMenu }; diff --git a/EditorFlow/src/components/EditorContextMenu/index.less b/EditorFlow/src/components/EditorContextMenu/index.less new file mode 100644 index 00000000..8a2cdae3 --- /dev/null +++ b/EditorFlow/src/components/EditorContextMenu/index.less @@ -0,0 +1,39 @@ +.contextMenu { + display: none; + overflow: hidden; + background: #fff; + border-radius: 4px; + box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15); + + .item { + display: flex; + align-items: center; + padding: 5px 12px; + cursor: pointer; + transition: all 0.3s; + user-select: none; + + &:hover { + background: #e6f7ff; + } + + i { + margin-right: 8px; + } + } + + :global { + .disable { + :local { + .item { + color: rgba(0, 0, 0, 0.25); + cursor: auto; + + &:hover { + background: #fff; + } + } + } + } + } +} diff --git a/EditorFlow/src/components/EditorDetailPanel/DetailForm.js b/EditorFlow/src/components/EditorDetailPanel/DetailForm.js new file mode 100644 index 00000000..3d680115 --- /dev/null +++ b/EditorFlow/src/components/EditorDetailPanel/DetailForm.js @@ -0,0 +1,129 @@ +import React, { Fragment } from 'react'; +import { Card, Form, Input, Select } from 'antd'; +import { withPropsAPI } from 'gg-editor'; +import upperFirst from 'lodash/upperFirst'; + +const { Item } = Form; +const { Option } = Select; + +const inlineFormItemLayout = { + labelCol: { + sm: { span: 8 }, + }, + wrapperCol: { + sm: { span: 16 }, + }, +}; + +class DetailForm extends React.Component { + get item() { + const { propsAPI } = this.props; + + return propsAPI.getSelected()[0]; + } + + handleSubmit = e => { + if (e && e.preventDefault) { + e.preventDefault(); + } + + const { form, propsAPI } = this.props; + const { getSelected, executeCommand, update } = propsAPI; + + setTimeout(() => { + form.validateFieldsAndScroll((err, values) => { + if (err) { + return; + } + + const item = getSelected()[0]; + + if (!item) { + return; + } + + executeCommand(() => { + update(item, { + ...values, + }); + }); + }); + }, 0); + }; + + renderEdgeShapeSelect = () => { + return ( + + ); + }; + + renderNodeDetail = () => { + const { form } = this.props; + const { label } = this.item.getModel(); + + return ( + + {form.getFieldDecorator('label', { + initialValue: label, + })()} + + ); + }; + + renderEdgeDetail = () => { + const { form } = this.props; + const { label = '', shape = 'flow-smooth' } = this.item.getModel(); + + return ( + + + {form.getFieldDecorator('label', { + initialValue: label, + })()} + + + {form.getFieldDecorator('shape', { + initialValue: shape, + })(this.renderEdgeShapeSelect())} + + + ); + }; + + renderGroupDetail = () => { + const { form } = this.props; + const { label = '新建分组' } = this.item.getModel(); + + return ( + + {form.getFieldDecorator('label', { + initialValue: label, + })()} + + ); + }; + + render() { + const { type } = this.props; + + if (!this.item) { + return null; + } + + return ( + +
+ {type === 'node' && this.renderNodeDetail()} + {type === 'edge' && this.renderEdgeDetail()} + {type === 'group' && this.renderGroupDetail()} +
+
+ ); + } +} + +export default Form.create()(withPropsAPI(DetailForm)); diff --git a/EditorFlow/src/components/EditorDetailPanel/FlowDetailPanel.js b/EditorFlow/src/components/EditorDetailPanel/FlowDetailPanel.js new file mode 100644 index 00000000..8d681618 --- /dev/null +++ b/EditorFlow/src/components/EditorDetailPanel/FlowDetailPanel.js @@ -0,0 +1,29 @@ +import React from 'react'; +import { Card } from 'antd'; +import { NodePanel, EdgePanel, GroupPanel, MultiPanel, CanvasPanel, DetailPanel } from 'gg-editor'; +import DetailForm from './DetailForm'; +import styles from './index.less'; + +const FlowDetailPanel = () => { + return ( + + + + + + + + + + + + + + + + + + ); +}; + +export default FlowDetailPanel; diff --git a/EditorFlow/src/components/EditorDetailPanel/KoniDetailPanel.js b/EditorFlow/src/components/EditorDetailPanel/KoniDetailPanel.js new file mode 100644 index 00000000..18aea9a4 --- /dev/null +++ b/EditorFlow/src/components/EditorDetailPanel/KoniDetailPanel.js @@ -0,0 +1,3 @@ +import FlowDetailPanel from './FlowDetailPanel'; + +export default FlowDetailPanel; diff --git a/EditorFlow/src/components/EditorDetailPanel/MindDetailPanel.js b/EditorFlow/src/components/EditorDetailPanel/MindDetailPanel.js new file mode 100644 index 00000000..6b4d5c9e --- /dev/null +++ b/EditorFlow/src/components/EditorDetailPanel/MindDetailPanel.js @@ -0,0 +1,20 @@ +import React from 'react'; +import { Card } from 'antd'; +import { NodePanel, CanvasPanel, DetailPanel } from 'gg-editor'; +import DetailForm from './DetailForm'; +import styles from './index.less'; + +const MindDetailPanel = () => { + return ( + + + + + + + + + ); +}; + +export default MindDetailPanel; diff --git a/EditorFlow/src/components/EditorDetailPanel/index.js b/EditorFlow/src/components/EditorDetailPanel/index.js new file mode 100644 index 00000000..8df063ef --- /dev/null +++ b/EditorFlow/src/components/EditorDetailPanel/index.js @@ -0,0 +1,5 @@ +import FlowDetailPanel from './FlowDetailPanel'; +import MindDetailPanel from './MindDetailPanel'; +import KoniDetailPanel from './KoniDetailPanel'; + +export { FlowDetailPanel, MindDetailPanel, KoniDetailPanel }; diff --git a/EditorFlow/src/components/EditorDetailPanel/index.less b/EditorFlow/src/components/EditorDetailPanel/index.less new file mode 100644 index 00000000..081945be --- /dev/null +++ b/EditorFlow/src/components/EditorDetailPanel/index.less @@ -0,0 +1,10 @@ +.detailPanel { + flex: 1; + background: #fafafa; + + :global { + .ant-card { + background: #fafafa; + } + } +} diff --git a/EditorFlow/src/components/EditorItemPanel/FlowItemPanel.js b/EditorFlow/src/components/EditorItemPanel/FlowItemPanel.js new file mode 100644 index 00000000..e6912793 --- /dev/null +++ b/EditorFlow/src/components/EditorItemPanel/FlowItemPanel.js @@ -0,0 +1,55 @@ +import React from 'react'; +import { Card } from 'antd'; +import { ItemPanel, Item } from 'gg-editor'; +import styles from './index.less'; + +const FlowItemPanel = () => { + return ( + + + + + + + + + ); +}; + +export default FlowItemPanel; diff --git a/EditorFlow/src/components/EditorItemPanel/KoniItemPanel.js b/EditorFlow/src/components/EditorItemPanel/KoniItemPanel.js new file mode 100644 index 00000000..9df51f98 --- /dev/null +++ b/EditorFlow/src/components/EditorItemPanel/KoniItemPanel.js @@ -0,0 +1,54 @@ +import React from 'react'; +import { Card } from 'antd'; +import { ItemPanel, Item } from 'gg-editor'; +import styles from './index.less'; + +const KoniItemPanel = () => { + return ( + + + + + + + + ); +}; + +export default KoniItemPanel; diff --git a/EditorFlow/src/components/EditorItemPanel/index.js b/EditorFlow/src/components/EditorItemPanel/index.js new file mode 100644 index 00000000..2ba03fbb --- /dev/null +++ b/EditorFlow/src/components/EditorItemPanel/index.js @@ -0,0 +1,4 @@ +import FlowItemPanel from './FlowItemPanel'; +import KoniItemPanel from './KoniItemPanel'; + +export { FlowItemPanel, KoniItemPanel }; diff --git a/EditorFlow/src/components/EditorItemPanel/index.less b/EditorFlow/src/components/EditorItemPanel/index.less new file mode 100644 index 00000000..a7acc366 --- /dev/null +++ b/EditorFlow/src/components/EditorItemPanel/index.less @@ -0,0 +1,20 @@ +.itemPanel { + flex: 1; + background: #fafafa; + + :global { + .ant-card { + background: #fafafa; + } + + .ant-card-body { + display: flex; + flex-direction: column; + align-items: center; + + > div { + margin-bottom: 16px; + } + } + } +} diff --git a/EditorFlow/src/components/EditorMinimap/index.js b/EditorFlow/src/components/EditorMinimap/index.js new file mode 100644 index 00000000..8c86b242 --- /dev/null +++ b/EditorFlow/src/components/EditorMinimap/index.js @@ -0,0 +1,13 @@ +import React from 'react'; +import { Card } from 'antd'; +import { Minimap } from 'gg-editor'; + +const EditorMinimap = () => { + return ( + + + + ); +}; + +export default EditorMinimap; diff --git a/EditorFlow/src/components/EditorToolbar/FlowToolbar.js b/EditorFlow/src/components/EditorToolbar/FlowToolbar.js new file mode 100644 index 00000000..374c1858 --- /dev/null +++ b/EditorFlow/src/components/EditorToolbar/FlowToolbar.js @@ -0,0 +1,32 @@ +import React from 'react'; +import { Divider } from 'antd'; +import { Toolbar } from 'gg-editor'; +import ToolbarButton from './ToolbarButton'; +import styles from './index.less'; + +const FlowToolbar = () => { + return ( + + + + + + + + + + + + + + + + + + + + + ); +}; + +export default FlowToolbar; diff --git a/EditorFlow/src/components/EditorToolbar/KoniToolbar.js b/EditorFlow/src/components/EditorToolbar/KoniToolbar.js new file mode 100644 index 00000000..f222007a --- /dev/null +++ b/EditorFlow/src/components/EditorToolbar/KoniToolbar.js @@ -0,0 +1,3 @@ +import FlowToolbar from './FlowToolbar'; + +export default FlowToolbar; diff --git a/EditorFlow/src/components/EditorToolbar/MindToolbar.js b/EditorFlow/src/components/EditorToolbar/MindToolbar.js new file mode 100644 index 00000000..1c83286a --- /dev/null +++ b/EditorFlow/src/components/EditorToolbar/MindToolbar.js @@ -0,0 +1,27 @@ +import React from 'react'; +import { Divider } from 'antd'; +import { Toolbar } from 'gg-editor'; +import ToolbarButton from './ToolbarButton'; +import styles from './index.less'; + +const FlowToolbar = () => { + return ( + + + + + + + + + + + + + + + + ); +}; + +export default FlowToolbar; diff --git a/EditorFlow/src/components/EditorToolbar/ToolbarButton.js b/EditorFlow/src/components/EditorToolbar/ToolbarButton.js new file mode 100644 index 00000000..eb5b4ffa --- /dev/null +++ b/EditorFlow/src/components/EditorToolbar/ToolbarButton.js @@ -0,0 +1,24 @@ +import React from 'react'; +import { Tooltip } from 'antd'; +import { Command } from 'gg-editor'; +import upperFirst from 'lodash/upperFirst'; +import IconFont from '../../common/IconFont'; +import styles from './index.less'; + +const ToolbarButton = props => { + const { command, icon, text } = props; + + return ( + + + + + + ); +}; + +export default ToolbarButton; diff --git a/EditorFlow/src/components/EditorToolbar/index.js b/EditorFlow/src/components/EditorToolbar/index.js new file mode 100644 index 00000000..ac08e3dc --- /dev/null +++ b/EditorFlow/src/components/EditorToolbar/index.js @@ -0,0 +1,5 @@ +import FlowToolbar from './FlowToolbar'; +import MindToolbar from './MindToolbar'; +import KoniToolbar from './KoniToolbar'; + +export { FlowToolbar, MindToolbar, KoniToolbar }; diff --git a/EditorFlow/src/components/EditorToolbar/index.less b/EditorFlow/src/components/EditorToolbar/index.less new file mode 100644 index 00000000..a5cca37c --- /dev/null +++ b/EditorFlow/src/components/EditorToolbar/index.less @@ -0,0 +1,39 @@ +.toolbar { + display: flex; + align-items: center; + + :global { + .command i { + display: inline-block; + width: 27px; + height: 27px; + margin: 0 6px; + padding-top: 6px; + text-align: center; + border: 1px solid #fff; + cursor: pointer; + + &:hover { + border: 1px solid #e6e9ed; + } + } + + .disable i { + color: rgba(0, 0, 0, 0.25); + cursor: auto; + + &:hover { + border: 1px solid #fff; + } + } + } +} + +.tooltip { + :global { + .ant-tooltip-inner { + font-size: 12px; + border-radius: 0; + } + } +} diff --git a/EditorFlow/src/components/PageHeaderWrapper/index.less b/EditorFlow/src/components/PageHeaderWrapper/index.less new file mode 100644 index 00000000..908db575 --- /dev/null +++ b/EditorFlow/src/components/PageHeaderWrapper/index.less @@ -0,0 +1,86 @@ +@import '~antd/lib/style/themes/default.less'; + +.children-content { + margin: 24px 24px 0; +} + +.main { + .detail { + display: flex; + } + + .row { + display: flex; + width: 100%; + } + + .title-content { + margin-bottom: 16px; + } + + @media screen and (max-width: @screen-sm) { + .content { + margin: 24px 0 0; + } + } + + .title, + .content { + flex: auto; + } + + .extraContent, + .main { + flex: 0 1 auto; + } + + .main { + width: 100%; + } + + .title { + margin-bottom: 16px; + } + + .logo, + .content, + .extraContent { + margin-bottom: 16px; + } + + .extraContent { + min-width: 242px; + margin-left: 88px; + text-align: right; + } +} + +@media screen and (max-width: @screen-xl) { + .extraContent { + margin-left: 44px; + } +} + +@media screen and (max-width: @screen-lg) { + .extraContent { + margin-left: 20px; + } +} + +@media screen and (max-width: @screen-md) { + .row { + display: block; + } + + .action, + .extraContent { + margin-left: 0; + text-align: left; + } +} + +@media screen and (max-width: @screen-sm) { + .detail { + display: block; + } +} diff --git a/EditorFlow/src/components/PageHeaderWrapper/index.tsx b/EditorFlow/src/components/PageHeaderWrapper/index.tsx new file mode 100644 index 00000000..bb565a04 --- /dev/null +++ b/EditorFlow/src/components/PageHeaderWrapper/index.tsx @@ -0,0 +1,96 @@ +import React from 'react'; +import { RouteContext } from '@ant-design/pro-layout'; +import { PageHeader, Tabs, Typography } from 'antd'; +import styles from './index.less'; +import { GridContent } from '@ant-design/pro-layout'; +import { TabsProps } from 'antd/lib/tabs'; +interface IPageHeaderTabConfig { + tabList?: Array<{ + key: string; + tab: string; + }>; + tabActiveKey?: TabsProps['activeKey']; + onTabChange?: TabsProps['onChange']; + tabBarExtraContent?: TabsProps['tabBarExtraContent']; +} + +interface IPageHeaderWrapperProps extends IPageHeaderTabConfig { + content?: React.ReactNode; + title: React.ReactNode; + extraContent?: React.ReactNode; +} + +/** + * render Footer tabList + * In order to be compatible with the old version of the PageHeader + * basically all the functions are implemented. + */ +const renderFooter = ({ + tabList, + tabActiveKey, + onTabChange, + tabBarExtraContent, +}: IPageHeaderTabConfig) => { + return tabList && tabList.length ? ( + { + if (onTabChange) { + onTabChange(key); + } + }} + tabBarExtraContent={tabBarExtraContent} + > + {tabList.map(item => ( + + ))} + + ) : null; +}; + +const PageHeaderWrapper: React.SFC = ({ + children, + title, + content, + extraContent, + ...restProps +}) => ( + + {value => ( +
+ + {title || value.title} + + } + footer={renderFooter(restProps)} + > +
+
+
+ {content &&
{content}
} + {extraContent &&
{extraContent}
} +
+
+
+
+ {children ? ( + +
{children}
+
+ ) : null} +
+ )} +
+); + +export default PageHeaderWrapper; diff --git a/EditorFlow/src/index.less b/EditorFlow/src/index.less new file mode 100644 index 00000000..aeffa829 --- /dev/null +++ b/EditorFlow/src/index.less @@ -0,0 +1,41 @@ +.editor { + display: flex; + flex: 1; + flex-direction: column; + width: 100%; + height: calc(100vh - 250px); + background: #fff; +} + +.editorHd { + padding: 8px; + border: 1px solid #e6e9ed; +} + +.editorBd { + flex: 1; +} + +.editorSidebar, +.editorContent { + display: flex; + flex-direction: column; +} + +.editorSidebar { + background: #fafafa; + + &:first-child { + border-right: 1px solid #e6e9ed; + } + + &:last-child { + border-left: 1px solid #e6e9ed; + } +} + +.flow, +.mind, +.koni { + flex: 1; +} diff --git a/EditorFlow/src/index.tsx b/EditorFlow/src/index.tsx new file mode 100644 index 00000000..d8dec88a --- /dev/null +++ b/EditorFlow/src/index.tsx @@ -0,0 +1,42 @@ +import React from 'react'; +import { Row, Col } from 'antd'; +import GGEditor, { Flow } from 'gg-editor'; +import EditorMinimap from './components/EditorMinimap'; +import { FlowContextMenu } from './components/EditorContextMenu'; +import { FlowToolbar } from './components/EditorToolbar'; +import { FlowItemPanel } from './components/EditorItemPanel'; +import { FlowDetailPanel } from './components/EditorDetailPanel'; +import styles from './index.less'; +import PageHeaderWrapper from './components/PageHeaderWrapper'; + +GGEditor.setTrackable(false); + +export default () => { + return ( + + + + + + + + + + + + + + + + + + + + + + + ); +}; diff --git a/EditorKoni/.gitignore b/EditorKoni/.gitignore new file mode 100644 index 00000000..8ce76bc4 --- /dev/null +++ b/EditorKoni/.gitignore @@ -0,0 +1,7 @@ +/yarn.lock +/package-lock.json +/dist +/node_modules + +.umi +.umi-production diff --git a/EditorKoni/README.md b/EditorKoni/README.md new file mode 100644 index 00000000..bfcf96e8 --- /dev/null +++ b/EditorKoni/README.md @@ -0,0 +1,13 @@ +# @umi-blocks/ant-design-pro/flow + +flow + +## Usage + +```sh +umi block add ant-design-pro/flow +``` + +## LICENSE + +MIT diff --git a/EditorKoni/package.json b/EditorKoni/package.json new file mode 100644 index 00000000..045a5998 --- /dev/null +++ b/EditorKoni/package.json @@ -0,0 +1,36 @@ +{ + "name": "@umi-block/flow", + "version": "0.0.1", + "description": "flow", + "repository": { + "type": "git", + "url": "https://github.com/umijs/umi-blocks/ant-design-pro/flow" + }, + "license": "ISC", + "main": "src/index.js", + "scripts": { + "dev": "umi dev" + }, + "dependencies": { + "@antv/data-set": "^0.10.2", + "antd": "^3.16.3", + "bizcharts": "^3.5.2", + "bizcharts-plugin-slider": "^2.1.1-beta.1", + "dva": "^2.4.0", + "gg-editor": "^2.0.2", + "moment": "^2.22.2", + "numeral": "^2.0.6", + "react": "^16.6.3", + "react-fittext": "^1.0.0", + "umi-request": "^1.0.0" + }, + "devDependencies": { + "umi": "^2.6.9", + "umi-plugin-block-dev": "^1.1.0", + "umi-plugin-react": "^1.7.2", + "@types/numeral": "^0.0.25" + }, + "blockConfig": { + "specVersion": "0.1" + } +} diff --git a/EditorKoni/src/common/IconFont/index.js b/EditorKoni/src/common/IconFont/index.js new file mode 100644 index 00000000..3bba8d2e --- /dev/null +++ b/EditorKoni/src/common/IconFont/index.js @@ -0,0 +1,7 @@ +import { Icon } from 'antd'; + +const IconFont = Icon.createFromIconfontCN({ + scriptUrl: 'https://at.alicdn.com/t/font_1101588_01zniftxm9yp.js', +}); + +export default IconFont; diff --git a/EditorKoni/src/components/EditorContextMenu/FlowContextMenu.js b/EditorKoni/src/components/EditorContextMenu/FlowContextMenu.js new file mode 100644 index 00000000..cbb7041f --- /dev/null +++ b/EditorKoni/src/components/EditorContextMenu/FlowContextMenu.js @@ -0,0 +1,36 @@ +import React from 'react'; +import { NodeMenu, EdgeMenu, GroupMenu, MultiMenu, CanvasMenu, ContextMenu } from 'gg-editor'; +import MenuItem from './MenuItem'; +import styles from './index.less'; + +const FlowContextMenu = () => { + return ( + + + + + + + + + + + + + + + + + + + + + + + + + + ); +}; + +export default FlowContextMenu; diff --git a/EditorKoni/src/components/EditorContextMenu/KoniContextMenu.js b/EditorKoni/src/components/EditorContextMenu/KoniContextMenu.js new file mode 100644 index 00000000..8b049a5e --- /dev/null +++ b/EditorKoni/src/components/EditorContextMenu/KoniContextMenu.js @@ -0,0 +1,3 @@ +import FlowContextMenu from './FlowContextMenu'; + +export default FlowContextMenu; diff --git a/EditorKoni/src/components/EditorContextMenu/MenuItem.js b/EditorKoni/src/components/EditorContextMenu/MenuItem.js new file mode 100644 index 00000000..4cbde89e --- /dev/null +++ b/EditorKoni/src/components/EditorContextMenu/MenuItem.js @@ -0,0 +1,20 @@ +import React from 'react'; +import { Command } from 'gg-editor'; +import upperFirst from 'lodash/upperFirst'; +import IconFont from '../../common/IconFont'; +import styles from './index.less'; + +const MenuItem = props => { + const { command, icon, text } = props; + + return ( + +
+ + {text || upperFirst(command)} +
+
+ ); +}; + +export default MenuItem; diff --git a/EditorKoni/src/components/EditorContextMenu/MindContextMenu.js b/EditorKoni/src/components/EditorContextMenu/MindContextMenu.js new file mode 100644 index 00000000..2a9d43cd --- /dev/null +++ b/EditorKoni/src/components/EditorContextMenu/MindContextMenu.js @@ -0,0 +1,24 @@ +import React from 'react'; +import { NodeMenu, CanvasMenu, ContextMenu } from 'gg-editor'; +import MenuItem from './MenuItem'; +import styles from './index.less'; + +const MindContextMenu = () => { + return ( + + + + + + + + + + + + + + ); +}; + +export default MindContextMenu; diff --git a/EditorKoni/src/components/EditorContextMenu/index.js b/EditorKoni/src/components/EditorContextMenu/index.js new file mode 100644 index 00000000..16fcde01 --- /dev/null +++ b/EditorKoni/src/components/EditorContextMenu/index.js @@ -0,0 +1,5 @@ +import FlowContextMenu from './FlowContextMenu'; +import MindContextMenu from './MindContextMenu'; +import KoniContextMenu from './KoniContextMenu'; + +export { FlowContextMenu, MindContextMenu, KoniContextMenu }; diff --git a/EditorKoni/src/components/EditorContextMenu/index.less b/EditorKoni/src/components/EditorContextMenu/index.less new file mode 100644 index 00000000..8a2cdae3 --- /dev/null +++ b/EditorKoni/src/components/EditorContextMenu/index.less @@ -0,0 +1,39 @@ +.contextMenu { + display: none; + overflow: hidden; + background: #fff; + border-radius: 4px; + box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15); + + .item { + display: flex; + align-items: center; + padding: 5px 12px; + cursor: pointer; + transition: all 0.3s; + user-select: none; + + &:hover { + background: #e6f7ff; + } + + i { + margin-right: 8px; + } + } + + :global { + .disable { + :local { + .item { + color: rgba(0, 0, 0, 0.25); + cursor: auto; + + &:hover { + background: #fff; + } + } + } + } + } +} diff --git a/EditorKoni/src/components/EditorDetailPanel/DetailForm.js b/EditorKoni/src/components/EditorDetailPanel/DetailForm.js new file mode 100644 index 00000000..3d680115 --- /dev/null +++ b/EditorKoni/src/components/EditorDetailPanel/DetailForm.js @@ -0,0 +1,129 @@ +import React, { Fragment } from 'react'; +import { Card, Form, Input, Select } from 'antd'; +import { withPropsAPI } from 'gg-editor'; +import upperFirst from 'lodash/upperFirst'; + +const { Item } = Form; +const { Option } = Select; + +const inlineFormItemLayout = { + labelCol: { + sm: { span: 8 }, + }, + wrapperCol: { + sm: { span: 16 }, + }, +}; + +class DetailForm extends React.Component { + get item() { + const { propsAPI } = this.props; + + return propsAPI.getSelected()[0]; + } + + handleSubmit = e => { + if (e && e.preventDefault) { + e.preventDefault(); + } + + const { form, propsAPI } = this.props; + const { getSelected, executeCommand, update } = propsAPI; + + setTimeout(() => { + form.validateFieldsAndScroll((err, values) => { + if (err) { + return; + } + + const item = getSelected()[0]; + + if (!item) { + return; + } + + executeCommand(() => { + update(item, { + ...values, + }); + }); + }); + }, 0); + }; + + renderEdgeShapeSelect = () => { + return ( + + ); + }; + + renderNodeDetail = () => { + const { form } = this.props; + const { label } = this.item.getModel(); + + return ( + + {form.getFieldDecorator('label', { + initialValue: label, + })()} + + ); + }; + + renderEdgeDetail = () => { + const { form } = this.props; + const { label = '', shape = 'flow-smooth' } = this.item.getModel(); + + return ( + + + {form.getFieldDecorator('label', { + initialValue: label, + })()} + + + {form.getFieldDecorator('shape', { + initialValue: shape, + })(this.renderEdgeShapeSelect())} + + + ); + }; + + renderGroupDetail = () => { + const { form } = this.props; + const { label = '新建分组' } = this.item.getModel(); + + return ( + + {form.getFieldDecorator('label', { + initialValue: label, + })()} + + ); + }; + + render() { + const { type } = this.props; + + if (!this.item) { + return null; + } + + return ( + +
+ {type === 'node' && this.renderNodeDetail()} + {type === 'edge' && this.renderEdgeDetail()} + {type === 'group' && this.renderGroupDetail()} +
+
+ ); + } +} + +export default Form.create()(withPropsAPI(DetailForm)); diff --git a/EditorKoni/src/components/EditorDetailPanel/FlowDetailPanel.js b/EditorKoni/src/components/EditorDetailPanel/FlowDetailPanel.js new file mode 100644 index 00000000..8d681618 --- /dev/null +++ b/EditorKoni/src/components/EditorDetailPanel/FlowDetailPanel.js @@ -0,0 +1,29 @@ +import React from 'react'; +import { Card } from 'antd'; +import { NodePanel, EdgePanel, GroupPanel, MultiPanel, CanvasPanel, DetailPanel } from 'gg-editor'; +import DetailForm from './DetailForm'; +import styles from './index.less'; + +const FlowDetailPanel = () => { + return ( + + + + + + + + + + + + + + + + + + ); +}; + +export default FlowDetailPanel; diff --git a/EditorKoni/src/components/EditorDetailPanel/KoniDetailPanel.js b/EditorKoni/src/components/EditorDetailPanel/KoniDetailPanel.js new file mode 100644 index 00000000..18aea9a4 --- /dev/null +++ b/EditorKoni/src/components/EditorDetailPanel/KoniDetailPanel.js @@ -0,0 +1,3 @@ +import FlowDetailPanel from './FlowDetailPanel'; + +export default FlowDetailPanel; diff --git a/EditorKoni/src/components/EditorDetailPanel/MindDetailPanel.js b/EditorKoni/src/components/EditorDetailPanel/MindDetailPanel.js new file mode 100644 index 00000000..6b4d5c9e --- /dev/null +++ b/EditorKoni/src/components/EditorDetailPanel/MindDetailPanel.js @@ -0,0 +1,20 @@ +import React from 'react'; +import { Card } from 'antd'; +import { NodePanel, CanvasPanel, DetailPanel } from 'gg-editor'; +import DetailForm from './DetailForm'; +import styles from './index.less'; + +const MindDetailPanel = () => { + return ( + + + + + + + + + ); +}; + +export default MindDetailPanel; diff --git a/EditorKoni/src/components/EditorDetailPanel/index.js b/EditorKoni/src/components/EditorDetailPanel/index.js new file mode 100644 index 00000000..8df063ef --- /dev/null +++ b/EditorKoni/src/components/EditorDetailPanel/index.js @@ -0,0 +1,5 @@ +import FlowDetailPanel from './FlowDetailPanel'; +import MindDetailPanel from './MindDetailPanel'; +import KoniDetailPanel from './KoniDetailPanel'; + +export { FlowDetailPanel, MindDetailPanel, KoniDetailPanel }; diff --git a/EditorKoni/src/components/EditorDetailPanel/index.less b/EditorKoni/src/components/EditorDetailPanel/index.less new file mode 100644 index 00000000..081945be --- /dev/null +++ b/EditorKoni/src/components/EditorDetailPanel/index.less @@ -0,0 +1,10 @@ +.detailPanel { + flex: 1; + background: #fafafa; + + :global { + .ant-card { + background: #fafafa; + } + } +} diff --git a/EditorKoni/src/components/EditorItemPanel/FlowItemPanel.js b/EditorKoni/src/components/EditorItemPanel/FlowItemPanel.js new file mode 100644 index 00000000..e6912793 --- /dev/null +++ b/EditorKoni/src/components/EditorItemPanel/FlowItemPanel.js @@ -0,0 +1,55 @@ +import React from 'react'; +import { Card } from 'antd'; +import { ItemPanel, Item } from 'gg-editor'; +import styles from './index.less'; + +const FlowItemPanel = () => { + return ( + + + + + + + + + ); +}; + +export default FlowItemPanel; diff --git a/EditorKoni/src/components/EditorItemPanel/KoniItemPanel.js b/EditorKoni/src/components/EditorItemPanel/KoniItemPanel.js new file mode 100644 index 00000000..9df51f98 --- /dev/null +++ b/EditorKoni/src/components/EditorItemPanel/KoniItemPanel.js @@ -0,0 +1,54 @@ +import React from 'react'; +import { Card } from 'antd'; +import { ItemPanel, Item } from 'gg-editor'; +import styles from './index.less'; + +const KoniItemPanel = () => { + return ( + + + + + + + + ); +}; + +export default KoniItemPanel; diff --git a/EditorKoni/src/components/EditorItemPanel/index.js b/EditorKoni/src/components/EditorItemPanel/index.js new file mode 100644 index 00000000..2ba03fbb --- /dev/null +++ b/EditorKoni/src/components/EditorItemPanel/index.js @@ -0,0 +1,4 @@ +import FlowItemPanel from './FlowItemPanel'; +import KoniItemPanel from './KoniItemPanel'; + +export { FlowItemPanel, KoniItemPanel }; diff --git a/EditorKoni/src/components/EditorItemPanel/index.less b/EditorKoni/src/components/EditorItemPanel/index.less new file mode 100644 index 00000000..a7acc366 --- /dev/null +++ b/EditorKoni/src/components/EditorItemPanel/index.less @@ -0,0 +1,20 @@ +.itemPanel { + flex: 1; + background: #fafafa; + + :global { + .ant-card { + background: #fafafa; + } + + .ant-card-body { + display: flex; + flex-direction: column; + align-items: center; + + > div { + margin-bottom: 16px; + } + } + } +} diff --git a/EditorKoni/src/components/EditorMinimap/index.js b/EditorKoni/src/components/EditorMinimap/index.js new file mode 100644 index 00000000..8c86b242 --- /dev/null +++ b/EditorKoni/src/components/EditorMinimap/index.js @@ -0,0 +1,13 @@ +import React from 'react'; +import { Card } from 'antd'; +import { Minimap } from 'gg-editor'; + +const EditorMinimap = () => { + return ( + + + + ); +}; + +export default EditorMinimap; diff --git a/EditorKoni/src/components/EditorToolbar/FlowToolbar.js b/EditorKoni/src/components/EditorToolbar/FlowToolbar.js new file mode 100644 index 00000000..374c1858 --- /dev/null +++ b/EditorKoni/src/components/EditorToolbar/FlowToolbar.js @@ -0,0 +1,32 @@ +import React from 'react'; +import { Divider } from 'antd'; +import { Toolbar } from 'gg-editor'; +import ToolbarButton from './ToolbarButton'; +import styles from './index.less'; + +const FlowToolbar = () => { + return ( + + + + + + + + + + + + + + + + + + + + + ); +}; + +export default FlowToolbar; diff --git a/EditorKoni/src/components/EditorToolbar/KoniToolbar.js b/EditorKoni/src/components/EditorToolbar/KoniToolbar.js new file mode 100644 index 00000000..f222007a --- /dev/null +++ b/EditorKoni/src/components/EditorToolbar/KoniToolbar.js @@ -0,0 +1,3 @@ +import FlowToolbar from './FlowToolbar'; + +export default FlowToolbar; diff --git a/EditorKoni/src/components/EditorToolbar/MindToolbar.js b/EditorKoni/src/components/EditorToolbar/MindToolbar.js new file mode 100644 index 00000000..1c83286a --- /dev/null +++ b/EditorKoni/src/components/EditorToolbar/MindToolbar.js @@ -0,0 +1,27 @@ +import React from 'react'; +import { Divider } from 'antd'; +import { Toolbar } from 'gg-editor'; +import ToolbarButton from './ToolbarButton'; +import styles from './index.less'; + +const FlowToolbar = () => { + return ( + + + + + + + + + + + + + + + + ); +}; + +export default FlowToolbar; diff --git a/EditorKoni/src/components/EditorToolbar/ToolbarButton.js b/EditorKoni/src/components/EditorToolbar/ToolbarButton.js new file mode 100644 index 00000000..eb5b4ffa --- /dev/null +++ b/EditorKoni/src/components/EditorToolbar/ToolbarButton.js @@ -0,0 +1,24 @@ +import React from 'react'; +import { Tooltip } from 'antd'; +import { Command } from 'gg-editor'; +import upperFirst from 'lodash/upperFirst'; +import IconFont from '../../common/IconFont'; +import styles from './index.less'; + +const ToolbarButton = props => { + const { command, icon, text } = props; + + return ( + + + + + + ); +}; + +export default ToolbarButton; diff --git a/EditorKoni/src/components/EditorToolbar/index.js b/EditorKoni/src/components/EditorToolbar/index.js new file mode 100644 index 00000000..ac08e3dc --- /dev/null +++ b/EditorKoni/src/components/EditorToolbar/index.js @@ -0,0 +1,5 @@ +import FlowToolbar from './FlowToolbar'; +import MindToolbar from './MindToolbar'; +import KoniToolbar from './KoniToolbar'; + +export { FlowToolbar, MindToolbar, KoniToolbar }; diff --git a/EditorKoni/src/components/EditorToolbar/index.less b/EditorKoni/src/components/EditorToolbar/index.less new file mode 100644 index 00000000..a5cca37c --- /dev/null +++ b/EditorKoni/src/components/EditorToolbar/index.less @@ -0,0 +1,39 @@ +.toolbar { + display: flex; + align-items: center; + + :global { + .command i { + display: inline-block; + width: 27px; + height: 27px; + margin: 0 6px; + padding-top: 6px; + text-align: center; + border: 1px solid #fff; + cursor: pointer; + + &:hover { + border: 1px solid #e6e9ed; + } + } + + .disable i { + color: rgba(0, 0, 0, 0.25); + cursor: auto; + + &:hover { + border: 1px solid #fff; + } + } + } +} + +.tooltip { + :global { + .ant-tooltip-inner { + font-size: 12px; + border-radius: 0; + } + } +} diff --git a/EditorKoni/src/components/PageHeaderWrapper/index.less b/EditorKoni/src/components/PageHeaderWrapper/index.less new file mode 100644 index 00000000..908db575 --- /dev/null +++ b/EditorKoni/src/components/PageHeaderWrapper/index.less @@ -0,0 +1,86 @@ +@import '~antd/lib/style/themes/default.less'; + +.children-content { + margin: 24px 24px 0; +} + +.main { + .detail { + display: flex; + } + + .row { + display: flex; + width: 100%; + } + + .title-content { + margin-bottom: 16px; + } + + @media screen and (max-width: @screen-sm) { + .content { + margin: 24px 0 0; + } + } + + .title, + .content { + flex: auto; + } + + .extraContent, + .main { + flex: 0 1 auto; + } + + .main { + width: 100%; + } + + .title { + margin-bottom: 16px; + } + + .logo, + .content, + .extraContent { + margin-bottom: 16px; + } + + .extraContent { + min-width: 242px; + margin-left: 88px; + text-align: right; + } +} + +@media screen and (max-width: @screen-xl) { + .extraContent { + margin-left: 44px; + } +} + +@media screen and (max-width: @screen-lg) { + .extraContent { + margin-left: 20px; + } +} + +@media screen and (max-width: @screen-md) { + .row { + display: block; + } + + .action, + .extraContent { + margin-left: 0; + text-align: left; + } +} + +@media screen and (max-width: @screen-sm) { + .detail { + display: block; + } +} diff --git a/EditorKoni/src/components/PageHeaderWrapper/index.tsx b/EditorKoni/src/components/PageHeaderWrapper/index.tsx new file mode 100644 index 00000000..bb565a04 --- /dev/null +++ b/EditorKoni/src/components/PageHeaderWrapper/index.tsx @@ -0,0 +1,96 @@ +import React from 'react'; +import { RouteContext } from '@ant-design/pro-layout'; +import { PageHeader, Tabs, Typography } from 'antd'; +import styles from './index.less'; +import { GridContent } from '@ant-design/pro-layout'; +import { TabsProps } from 'antd/lib/tabs'; +interface IPageHeaderTabConfig { + tabList?: Array<{ + key: string; + tab: string; + }>; + tabActiveKey?: TabsProps['activeKey']; + onTabChange?: TabsProps['onChange']; + tabBarExtraContent?: TabsProps['tabBarExtraContent']; +} + +interface IPageHeaderWrapperProps extends IPageHeaderTabConfig { + content?: React.ReactNode; + title: React.ReactNode; + extraContent?: React.ReactNode; +} + +/** + * render Footer tabList + * In order to be compatible with the old version of the PageHeader + * basically all the functions are implemented. + */ +const renderFooter = ({ + tabList, + tabActiveKey, + onTabChange, + tabBarExtraContent, +}: IPageHeaderTabConfig) => { + return tabList && tabList.length ? ( + { + if (onTabChange) { + onTabChange(key); + } + }} + tabBarExtraContent={tabBarExtraContent} + > + {tabList.map(item => ( + + ))} + + ) : null; +}; + +const PageHeaderWrapper: React.SFC = ({ + children, + title, + content, + extraContent, + ...restProps +}) => ( + + {value => ( +
+ + {title || value.title} + + } + footer={renderFooter(restProps)} + > +
+
+
+ {content &&
{content}
} + {extraContent &&
{extraContent}
} +
+
+
+
+ {children ? ( + +
{children}
+
+ ) : null} +
+ )} +
+); + +export default PageHeaderWrapper; diff --git a/EditorKoni/src/components/shape/nodes/KoniCustomNode.js b/EditorKoni/src/components/shape/nodes/KoniCustomNode.js new file mode 100644 index 00000000..4c13bb4f --- /dev/null +++ b/EditorKoni/src/components/shape/nodes/KoniCustomNode.js @@ -0,0 +1,33 @@ +import React from 'react'; +import { RegisterNode } from 'gg-editor'; + +class KoniCustomNode extends React.Component { + render() { + const config = { + draw(item) { + const keyShape = this.drawKeyShape(item); + + // draw label + this.drawLabel(item); + + // draw image + const group = item.getGraphicGroup(); + const model = item.getModel(); + + group.addShape('image', { + attrs: { + x: -7, + y: -7, + img: model.icon, + }, + }); + + return keyShape; + }, + }; + + return ; + } +} + +export default KoniCustomNode; diff --git a/EditorKoni/src/index.less b/EditorKoni/src/index.less new file mode 100644 index 00000000..aeffa829 --- /dev/null +++ b/EditorKoni/src/index.less @@ -0,0 +1,41 @@ +.editor { + display: flex; + flex: 1; + flex-direction: column; + width: 100%; + height: calc(100vh - 250px); + background: #fff; +} + +.editorHd { + padding: 8px; + border: 1px solid #e6e9ed; +} + +.editorBd { + flex: 1; +} + +.editorSidebar, +.editorContent { + display: flex; + flex-direction: column; +} + +.editorSidebar { + background: #fafafa; + + &:first-child { + border-right: 1px solid #e6e9ed; + } + + &:last-child { + border-left: 1px solid #e6e9ed; + } +} + +.flow, +.mind, +.koni { + flex: 1; +} diff --git a/EditorKoni/src/index.tsx b/EditorKoni/src/index.tsx new file mode 100644 index 00000000..f2ee717c --- /dev/null +++ b/EditorKoni/src/index.tsx @@ -0,0 +1,44 @@ +import React from 'react'; +import { Row, Col } from 'antd'; +import GGEditor, { Koni } from 'gg-editor'; +import EditorMinimap from './components/EditorMinimap'; +import { KoniContextMenu } from './components/EditorContextMenu'; +import { KoniToolbar } from './components/EditorToolbar'; +import { KoniItemPanel } from './components/EditorItemPanel'; +import { KoniDetailPanel } from './components/EditorDetailPanel'; +import KoniCustomNode from './components/shape/nodes/KoniCustomNode'; +import styles from './index.less'; +import PageHeaderWrapper from './components/PageHeaderWrapper'; + +GGEditor.setTrackable(false); + +export default () => { + return ( + + + + + + + + + + + + + + + + + + + + + + + + ); +}; diff --git a/EditorMind/.gitignore b/EditorMind/.gitignore new file mode 100644 index 00000000..8ce76bc4 --- /dev/null +++ b/EditorMind/.gitignore @@ -0,0 +1,7 @@ +/yarn.lock +/package-lock.json +/dist +/node_modules + +.umi +.umi-production diff --git a/EditorMind/README.md b/EditorMind/README.md new file mode 100644 index 00000000..bfcf96e8 --- /dev/null +++ b/EditorMind/README.md @@ -0,0 +1,13 @@ +# @umi-blocks/ant-design-pro/flow + +flow + +## Usage + +```sh +umi block add ant-design-pro/flow +``` + +## LICENSE + +MIT diff --git a/EditorMind/package.json b/EditorMind/package.json new file mode 100644 index 00000000..045a5998 --- /dev/null +++ b/EditorMind/package.json @@ -0,0 +1,36 @@ +{ + "name": "@umi-block/flow", + "version": "0.0.1", + "description": "flow", + "repository": { + "type": "git", + "url": "https://github.com/umijs/umi-blocks/ant-design-pro/flow" + }, + "license": "ISC", + "main": "src/index.js", + "scripts": { + "dev": "umi dev" + }, + "dependencies": { + "@antv/data-set": "^0.10.2", + "antd": "^3.16.3", + "bizcharts": "^3.5.2", + "bizcharts-plugin-slider": "^2.1.1-beta.1", + "dva": "^2.4.0", + "gg-editor": "^2.0.2", + "moment": "^2.22.2", + "numeral": "^2.0.6", + "react": "^16.6.3", + "react-fittext": "^1.0.0", + "umi-request": "^1.0.0" + }, + "devDependencies": { + "umi": "^2.6.9", + "umi-plugin-block-dev": "^1.1.0", + "umi-plugin-react": "^1.7.2", + "@types/numeral": "^0.0.25" + }, + "blockConfig": { + "specVersion": "0.1" + } +} diff --git a/EditorMind/src/common/IconFont/index.js b/EditorMind/src/common/IconFont/index.js new file mode 100644 index 00000000..3bba8d2e --- /dev/null +++ b/EditorMind/src/common/IconFont/index.js @@ -0,0 +1,7 @@ +import { Icon } from 'antd'; + +const IconFont = Icon.createFromIconfontCN({ + scriptUrl: 'https://at.alicdn.com/t/font_1101588_01zniftxm9yp.js', +}); + +export default IconFont; diff --git a/EditorMind/src/components/EditorContextMenu/FlowContextMenu.js b/EditorMind/src/components/EditorContextMenu/FlowContextMenu.js new file mode 100644 index 00000000..cbb7041f --- /dev/null +++ b/EditorMind/src/components/EditorContextMenu/FlowContextMenu.js @@ -0,0 +1,36 @@ +import React from 'react'; +import { NodeMenu, EdgeMenu, GroupMenu, MultiMenu, CanvasMenu, ContextMenu } from 'gg-editor'; +import MenuItem from './MenuItem'; +import styles from './index.less'; + +const FlowContextMenu = () => { + return ( + + + + + + + + + + + + + + + + + + + + + + + + + + ); +}; + +export default FlowContextMenu; diff --git a/EditorMind/src/components/EditorContextMenu/KoniContextMenu.js b/EditorMind/src/components/EditorContextMenu/KoniContextMenu.js new file mode 100644 index 00000000..8b049a5e --- /dev/null +++ b/EditorMind/src/components/EditorContextMenu/KoniContextMenu.js @@ -0,0 +1,3 @@ +import FlowContextMenu from './FlowContextMenu'; + +export default FlowContextMenu; diff --git a/EditorMind/src/components/EditorContextMenu/MenuItem.js b/EditorMind/src/components/EditorContextMenu/MenuItem.js new file mode 100644 index 00000000..4cbde89e --- /dev/null +++ b/EditorMind/src/components/EditorContextMenu/MenuItem.js @@ -0,0 +1,20 @@ +import React from 'react'; +import { Command } from 'gg-editor'; +import upperFirst from 'lodash/upperFirst'; +import IconFont from '../../common/IconFont'; +import styles from './index.less'; + +const MenuItem = props => { + const { command, icon, text } = props; + + return ( + +
+ + {text || upperFirst(command)} +
+
+ ); +}; + +export default MenuItem; diff --git a/EditorMind/src/components/EditorContextMenu/MindContextMenu.js b/EditorMind/src/components/EditorContextMenu/MindContextMenu.js new file mode 100644 index 00000000..2a9d43cd --- /dev/null +++ b/EditorMind/src/components/EditorContextMenu/MindContextMenu.js @@ -0,0 +1,24 @@ +import React from 'react'; +import { NodeMenu, CanvasMenu, ContextMenu } from 'gg-editor'; +import MenuItem from './MenuItem'; +import styles from './index.less'; + +const MindContextMenu = () => { + return ( + + + + + + + + + + + + + + ); +}; + +export default MindContextMenu; diff --git a/EditorMind/src/components/EditorContextMenu/index.js b/EditorMind/src/components/EditorContextMenu/index.js new file mode 100644 index 00000000..16fcde01 --- /dev/null +++ b/EditorMind/src/components/EditorContextMenu/index.js @@ -0,0 +1,5 @@ +import FlowContextMenu from './FlowContextMenu'; +import MindContextMenu from './MindContextMenu'; +import KoniContextMenu from './KoniContextMenu'; + +export { FlowContextMenu, MindContextMenu, KoniContextMenu }; diff --git a/EditorMind/src/components/EditorContextMenu/index.less b/EditorMind/src/components/EditorContextMenu/index.less new file mode 100644 index 00000000..8a2cdae3 --- /dev/null +++ b/EditorMind/src/components/EditorContextMenu/index.less @@ -0,0 +1,39 @@ +.contextMenu { + display: none; + overflow: hidden; + background: #fff; + border-radius: 4px; + box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15); + + .item { + display: flex; + align-items: center; + padding: 5px 12px; + cursor: pointer; + transition: all 0.3s; + user-select: none; + + &:hover { + background: #e6f7ff; + } + + i { + margin-right: 8px; + } + } + + :global { + .disable { + :local { + .item { + color: rgba(0, 0, 0, 0.25); + cursor: auto; + + &:hover { + background: #fff; + } + } + } + } + } +} diff --git a/EditorMind/src/components/EditorDetailPanel/DetailForm.js b/EditorMind/src/components/EditorDetailPanel/DetailForm.js new file mode 100644 index 00000000..3d680115 --- /dev/null +++ b/EditorMind/src/components/EditorDetailPanel/DetailForm.js @@ -0,0 +1,129 @@ +import React, { Fragment } from 'react'; +import { Card, Form, Input, Select } from 'antd'; +import { withPropsAPI } from 'gg-editor'; +import upperFirst from 'lodash/upperFirst'; + +const { Item } = Form; +const { Option } = Select; + +const inlineFormItemLayout = { + labelCol: { + sm: { span: 8 }, + }, + wrapperCol: { + sm: { span: 16 }, + }, +}; + +class DetailForm extends React.Component { + get item() { + const { propsAPI } = this.props; + + return propsAPI.getSelected()[0]; + } + + handleSubmit = e => { + if (e && e.preventDefault) { + e.preventDefault(); + } + + const { form, propsAPI } = this.props; + const { getSelected, executeCommand, update } = propsAPI; + + setTimeout(() => { + form.validateFieldsAndScroll((err, values) => { + if (err) { + return; + } + + const item = getSelected()[0]; + + if (!item) { + return; + } + + executeCommand(() => { + update(item, { + ...values, + }); + }); + }); + }, 0); + }; + + renderEdgeShapeSelect = () => { + return ( + + ); + }; + + renderNodeDetail = () => { + const { form } = this.props; + const { label } = this.item.getModel(); + + return ( + + {form.getFieldDecorator('label', { + initialValue: label, + })()} + + ); + }; + + renderEdgeDetail = () => { + const { form } = this.props; + const { label = '', shape = 'flow-smooth' } = this.item.getModel(); + + return ( + + + {form.getFieldDecorator('label', { + initialValue: label, + })()} + + + {form.getFieldDecorator('shape', { + initialValue: shape, + })(this.renderEdgeShapeSelect())} + + + ); + }; + + renderGroupDetail = () => { + const { form } = this.props; + const { label = '新建分组' } = this.item.getModel(); + + return ( + + {form.getFieldDecorator('label', { + initialValue: label, + })()} + + ); + }; + + render() { + const { type } = this.props; + + if (!this.item) { + return null; + } + + return ( + +
+ {type === 'node' && this.renderNodeDetail()} + {type === 'edge' && this.renderEdgeDetail()} + {type === 'group' && this.renderGroupDetail()} +
+
+ ); + } +} + +export default Form.create()(withPropsAPI(DetailForm)); diff --git a/EditorMind/src/components/EditorDetailPanel/FlowDetailPanel.js b/EditorMind/src/components/EditorDetailPanel/FlowDetailPanel.js new file mode 100644 index 00000000..8d681618 --- /dev/null +++ b/EditorMind/src/components/EditorDetailPanel/FlowDetailPanel.js @@ -0,0 +1,29 @@ +import React from 'react'; +import { Card } from 'antd'; +import { NodePanel, EdgePanel, GroupPanel, MultiPanel, CanvasPanel, DetailPanel } from 'gg-editor'; +import DetailForm from './DetailForm'; +import styles from './index.less'; + +const FlowDetailPanel = () => { + return ( + + + + + + + + + + + + + + + + + + ); +}; + +export default FlowDetailPanel; diff --git a/EditorMind/src/components/EditorDetailPanel/KoniDetailPanel.js b/EditorMind/src/components/EditorDetailPanel/KoniDetailPanel.js new file mode 100644 index 00000000..18aea9a4 --- /dev/null +++ b/EditorMind/src/components/EditorDetailPanel/KoniDetailPanel.js @@ -0,0 +1,3 @@ +import FlowDetailPanel from './FlowDetailPanel'; + +export default FlowDetailPanel; diff --git a/EditorMind/src/components/EditorDetailPanel/MindDetailPanel.js b/EditorMind/src/components/EditorDetailPanel/MindDetailPanel.js new file mode 100644 index 00000000..6b4d5c9e --- /dev/null +++ b/EditorMind/src/components/EditorDetailPanel/MindDetailPanel.js @@ -0,0 +1,20 @@ +import React from 'react'; +import { Card } from 'antd'; +import { NodePanel, CanvasPanel, DetailPanel } from 'gg-editor'; +import DetailForm from './DetailForm'; +import styles from './index.less'; + +const MindDetailPanel = () => { + return ( + + + + + + + + + ); +}; + +export default MindDetailPanel; diff --git a/EditorMind/src/components/EditorDetailPanel/index.js b/EditorMind/src/components/EditorDetailPanel/index.js new file mode 100644 index 00000000..8df063ef --- /dev/null +++ b/EditorMind/src/components/EditorDetailPanel/index.js @@ -0,0 +1,5 @@ +import FlowDetailPanel from './FlowDetailPanel'; +import MindDetailPanel from './MindDetailPanel'; +import KoniDetailPanel from './KoniDetailPanel'; + +export { FlowDetailPanel, MindDetailPanel, KoniDetailPanel }; diff --git a/EditorMind/src/components/EditorDetailPanel/index.less b/EditorMind/src/components/EditorDetailPanel/index.less new file mode 100644 index 00000000..081945be --- /dev/null +++ b/EditorMind/src/components/EditorDetailPanel/index.less @@ -0,0 +1,10 @@ +.detailPanel { + flex: 1; + background: #fafafa; + + :global { + .ant-card { + background: #fafafa; + } + } +} diff --git a/EditorMind/src/components/EditorItemPanel/FlowItemPanel.js b/EditorMind/src/components/EditorItemPanel/FlowItemPanel.js new file mode 100644 index 00000000..e6912793 --- /dev/null +++ b/EditorMind/src/components/EditorItemPanel/FlowItemPanel.js @@ -0,0 +1,55 @@ +import React from 'react'; +import { Card } from 'antd'; +import { ItemPanel, Item } from 'gg-editor'; +import styles from './index.less'; + +const FlowItemPanel = () => { + return ( + + + + + + + + + ); +}; + +export default FlowItemPanel; diff --git a/EditorMind/src/components/EditorItemPanel/KoniItemPanel.js b/EditorMind/src/components/EditorItemPanel/KoniItemPanel.js new file mode 100644 index 00000000..9df51f98 --- /dev/null +++ b/EditorMind/src/components/EditorItemPanel/KoniItemPanel.js @@ -0,0 +1,54 @@ +import React from 'react'; +import { Card } from 'antd'; +import { ItemPanel, Item } from 'gg-editor'; +import styles from './index.less'; + +const KoniItemPanel = () => { + return ( + + + + + + + + ); +}; + +export default KoniItemPanel; diff --git a/EditorMind/src/components/EditorItemPanel/index.js b/EditorMind/src/components/EditorItemPanel/index.js new file mode 100644 index 00000000..2ba03fbb --- /dev/null +++ b/EditorMind/src/components/EditorItemPanel/index.js @@ -0,0 +1,4 @@ +import FlowItemPanel from './FlowItemPanel'; +import KoniItemPanel from './KoniItemPanel'; + +export { FlowItemPanel, KoniItemPanel }; diff --git a/EditorMind/src/components/EditorItemPanel/index.less b/EditorMind/src/components/EditorItemPanel/index.less new file mode 100644 index 00000000..a7acc366 --- /dev/null +++ b/EditorMind/src/components/EditorItemPanel/index.less @@ -0,0 +1,20 @@ +.itemPanel { + flex: 1; + background: #fafafa; + + :global { + .ant-card { + background: #fafafa; + } + + .ant-card-body { + display: flex; + flex-direction: column; + align-items: center; + + > div { + margin-bottom: 16px; + } + } + } +} diff --git a/EditorMind/src/components/EditorMinimap/index.js b/EditorMind/src/components/EditorMinimap/index.js new file mode 100644 index 00000000..8c86b242 --- /dev/null +++ b/EditorMind/src/components/EditorMinimap/index.js @@ -0,0 +1,13 @@ +import React from 'react'; +import { Card } from 'antd'; +import { Minimap } from 'gg-editor'; + +const EditorMinimap = () => { + return ( + + + + ); +}; + +export default EditorMinimap; diff --git a/EditorMind/src/components/EditorToolbar/FlowToolbar.js b/EditorMind/src/components/EditorToolbar/FlowToolbar.js new file mode 100644 index 00000000..374c1858 --- /dev/null +++ b/EditorMind/src/components/EditorToolbar/FlowToolbar.js @@ -0,0 +1,32 @@ +import React from 'react'; +import { Divider } from 'antd'; +import { Toolbar } from 'gg-editor'; +import ToolbarButton from './ToolbarButton'; +import styles from './index.less'; + +const FlowToolbar = () => { + return ( + + + + + + + + + + + + + + + + + + + + + ); +}; + +export default FlowToolbar; diff --git a/EditorMind/src/components/EditorToolbar/KoniToolbar.js b/EditorMind/src/components/EditorToolbar/KoniToolbar.js new file mode 100644 index 00000000..f222007a --- /dev/null +++ b/EditorMind/src/components/EditorToolbar/KoniToolbar.js @@ -0,0 +1,3 @@ +import FlowToolbar from './FlowToolbar'; + +export default FlowToolbar; diff --git a/EditorMind/src/components/EditorToolbar/MindToolbar.js b/EditorMind/src/components/EditorToolbar/MindToolbar.js new file mode 100644 index 00000000..1c83286a --- /dev/null +++ b/EditorMind/src/components/EditorToolbar/MindToolbar.js @@ -0,0 +1,27 @@ +import React from 'react'; +import { Divider } from 'antd'; +import { Toolbar } from 'gg-editor'; +import ToolbarButton from './ToolbarButton'; +import styles from './index.less'; + +const FlowToolbar = () => { + return ( + + + + + + + + + + + + + + + + ); +}; + +export default FlowToolbar; diff --git a/EditorMind/src/components/EditorToolbar/ToolbarButton.js b/EditorMind/src/components/EditorToolbar/ToolbarButton.js new file mode 100644 index 00000000..eb5b4ffa --- /dev/null +++ b/EditorMind/src/components/EditorToolbar/ToolbarButton.js @@ -0,0 +1,24 @@ +import React from 'react'; +import { Tooltip } from 'antd'; +import { Command } from 'gg-editor'; +import upperFirst from 'lodash/upperFirst'; +import IconFont from '../../common/IconFont'; +import styles from './index.less'; + +const ToolbarButton = props => { + const { command, icon, text } = props; + + return ( + + + + + + ); +}; + +export default ToolbarButton; diff --git a/EditorMind/src/components/EditorToolbar/index.js b/EditorMind/src/components/EditorToolbar/index.js new file mode 100644 index 00000000..ac08e3dc --- /dev/null +++ b/EditorMind/src/components/EditorToolbar/index.js @@ -0,0 +1,5 @@ +import FlowToolbar from './FlowToolbar'; +import MindToolbar from './MindToolbar'; +import KoniToolbar from './KoniToolbar'; + +export { FlowToolbar, MindToolbar, KoniToolbar }; diff --git a/EditorMind/src/components/EditorToolbar/index.less b/EditorMind/src/components/EditorToolbar/index.less new file mode 100644 index 00000000..a5cca37c --- /dev/null +++ b/EditorMind/src/components/EditorToolbar/index.less @@ -0,0 +1,39 @@ +.toolbar { + display: flex; + align-items: center; + + :global { + .command i { + display: inline-block; + width: 27px; + height: 27px; + margin: 0 6px; + padding-top: 6px; + text-align: center; + border: 1px solid #fff; + cursor: pointer; + + &:hover { + border: 1px solid #e6e9ed; + } + } + + .disable i { + color: rgba(0, 0, 0, 0.25); + cursor: auto; + + &:hover { + border: 1px solid #fff; + } + } + } +} + +.tooltip { + :global { + .ant-tooltip-inner { + font-size: 12px; + border-radius: 0; + } + } +} diff --git a/EditorMind/src/components/PageHeaderWrapper/index.less b/EditorMind/src/components/PageHeaderWrapper/index.less new file mode 100644 index 00000000..908db575 --- /dev/null +++ b/EditorMind/src/components/PageHeaderWrapper/index.less @@ -0,0 +1,86 @@ +@import '~antd/lib/style/themes/default.less'; + +.children-content { + margin: 24px 24px 0; +} + +.main { + .detail { + display: flex; + } + + .row { + display: flex; + width: 100%; + } + + .title-content { + margin-bottom: 16px; + } + + @media screen and (max-width: @screen-sm) { + .content { + margin: 24px 0 0; + } + } + + .title, + .content { + flex: auto; + } + + .extraContent, + .main { + flex: 0 1 auto; + } + + .main { + width: 100%; + } + + .title { + margin-bottom: 16px; + } + + .logo, + .content, + .extraContent { + margin-bottom: 16px; + } + + .extraContent { + min-width: 242px; + margin-left: 88px; + text-align: right; + } +} + +@media screen and (max-width: @screen-xl) { + .extraContent { + margin-left: 44px; + } +} + +@media screen and (max-width: @screen-lg) { + .extraContent { + margin-left: 20px; + } +} + +@media screen and (max-width: @screen-md) { + .row { + display: block; + } + + .action, + .extraContent { + margin-left: 0; + text-align: left; + } +} + +@media screen and (max-width: @screen-sm) { + .detail { + display: block; + } +} diff --git a/EditorMind/src/components/PageHeaderWrapper/index.tsx b/EditorMind/src/components/PageHeaderWrapper/index.tsx new file mode 100644 index 00000000..bb565a04 --- /dev/null +++ b/EditorMind/src/components/PageHeaderWrapper/index.tsx @@ -0,0 +1,96 @@ +import React from 'react'; +import { RouteContext } from '@ant-design/pro-layout'; +import { PageHeader, Tabs, Typography } from 'antd'; +import styles from './index.less'; +import { GridContent } from '@ant-design/pro-layout'; +import { TabsProps } from 'antd/lib/tabs'; +interface IPageHeaderTabConfig { + tabList?: Array<{ + key: string; + tab: string; + }>; + tabActiveKey?: TabsProps['activeKey']; + onTabChange?: TabsProps['onChange']; + tabBarExtraContent?: TabsProps['tabBarExtraContent']; +} + +interface IPageHeaderWrapperProps extends IPageHeaderTabConfig { + content?: React.ReactNode; + title: React.ReactNode; + extraContent?: React.ReactNode; +} + +/** + * render Footer tabList + * In order to be compatible with the old version of the PageHeader + * basically all the functions are implemented. + */ +const renderFooter = ({ + tabList, + tabActiveKey, + onTabChange, + tabBarExtraContent, +}: IPageHeaderTabConfig) => { + return tabList && tabList.length ? ( + { + if (onTabChange) { + onTabChange(key); + } + }} + tabBarExtraContent={tabBarExtraContent} + > + {tabList.map(item => ( + + ))} + + ) : null; +}; + +const PageHeaderWrapper: React.SFC = ({ + children, + title, + content, + extraContent, + ...restProps +}) => ( + + {value => ( +
+ + {title || value.title} + + } + footer={renderFooter(restProps)} + > +
+
+
+ {content &&
{content}
} + {extraContent &&
{extraContent}
} +
+
+
+
+ {children ? ( + +
{children}
+
+ ) : null} +
+ )} +
+); + +export default PageHeaderWrapper; diff --git a/EditorMind/src/index.less b/EditorMind/src/index.less new file mode 100644 index 00000000..aeffa829 --- /dev/null +++ b/EditorMind/src/index.less @@ -0,0 +1,41 @@ +.editor { + display: flex; + flex: 1; + flex-direction: column; + width: 100%; + height: calc(100vh - 250px); + background: #fff; +} + +.editorHd { + padding: 8px; + border: 1px solid #e6e9ed; +} + +.editorBd { + flex: 1; +} + +.editorSidebar, +.editorContent { + display: flex; + flex-direction: column; +} + +.editorSidebar { + background: #fafafa; + + &:first-child { + border-right: 1px solid #e6e9ed; + } + + &:last-child { + border-left: 1px solid #e6e9ed; + } +} + +.flow, +.mind, +.koni { + flex: 1; +} diff --git a/EditorMind/src/index.tsx b/EditorMind/src/index.tsx new file mode 100644 index 00000000..62c954da --- /dev/null +++ b/EditorMind/src/index.tsx @@ -0,0 +1,39 @@ +import React from 'react'; +import { Row, Col } from 'antd'; +import GGEditor, { Mind } from 'gg-editor'; +import EditorMinimap from './components/EditorMinimap'; +import { MindContextMenu } from './components/EditorContextMenu'; +import { MindToolbar } from './components/EditorToolbar'; +import { MindDetailPanel } from './components/EditorDetailPanel'; +import data from './worldCup2018.json'; +import styles from './index.less'; +import PageHeaderWrapper from './components/PageHeaderWrapper'; + +GGEditor.setTrackable(false); + +export default () => { + return ( + + + + + + + + + + + + + + + + + + + + ); +}; diff --git a/EditorMind/src/worldCup2018.json b/EditorMind/src/worldCup2018.json new file mode 100644 index 00000000..44f3e63f --- /dev/null +++ b/EditorMind/src/worldCup2018.json @@ -0,0 +1,129 @@ +{ + "roots": [ + { + "label": "法国", + "children": [ + { + "label": "克罗地亚", + "side": "left", + "children": [ + { + "label": "克罗地亚", + "children": [ + { + "label": "克罗地亚", + "children": [ + { + "label": "克罗地亚" + }, + { + "label": "丹麦" + } + ] + }, + { + "label": "俄罗斯", + "children": [ + { + "label": "俄罗斯" + }, + { + "label": "西班牙" + } + ] + } + ] + }, + { + "label": "英格兰", + "children": [ + { + "label": "英格兰", + "children": [ + { + "label": "英格兰" + }, + { + "label": "哥伦比亚" + } + ] + }, + { + "label": "瑞典", + "children": [ + { + "label": "瑞士" + }, + { + "label": "瑞典" + } + ] + } + ] + } + ] + }, + { + "label": "法国", + "side": "right", + "children": [ + { + "label": "法国", + "children": [ + { + "label": "法国", + "children": [ + { + "label": "法国" + }, + { + "label": "阿根廷" + } + ] + }, + { + "label": "乌拉圭", + "children": [ + { + "label": "乌拉圭" + }, + { + "label": "葡萄牙" + } + ] + } + ] + }, + { + "label": "比利时", + "children": [ + { + "label": "比利时", + "children": [ + { + "label": "比利时" + }, + { + "label": "日本" + } + ] + }, + { + "label": "巴西", + "children": [ + { + "label": "巴西" + }, + { + "label": "墨西哥" + } + ] + } + ] + } + ] + } + ] + } + ] +} diff --git a/FormBasicForm/src/components/PageHeaderWrapper/index.tsx b/FormBasicForm/src/components/PageHeaderWrapper/index.tsx index 2776ca83..93a13146 100644 --- a/FormBasicForm/src/components/PageHeaderWrapper/index.tsx +++ b/FormBasicForm/src/components/PageHeaderWrapper/index.tsx @@ -18,6 +18,7 @@ const PageHeaderWrapper: React.SFC = ({ {value => (
= ({ margin: 0, }} > - {title} + {title || value.title} } {...restProps} - {...value} > {content} diff --git a/FormStepForm/src/components/PageHeaderWrapper/index.tsx b/FormStepForm/src/components/PageHeaderWrapper/index.tsx index fe1a33b8..7186520a 100644 --- a/FormStepForm/src/components/PageHeaderWrapper/index.tsx +++ b/FormStepForm/src/components/PageHeaderWrapper/index.tsx @@ -21,6 +21,7 @@ const PageHeaderWrapper: React.SFC = ({ {value => (
= ({ margin: 0, }} > - {title} + {title || value.title} } {...restProps} - {...value} >
diff --git a/ListCardList/src/components/PageHeaderWrapper/index.tsx b/ListCardList/src/components/PageHeaderWrapper/index.tsx index fe1a33b8..7186520a 100644 --- a/ListCardList/src/components/PageHeaderWrapper/index.tsx +++ b/ListCardList/src/components/PageHeaderWrapper/index.tsx @@ -21,6 +21,7 @@ const PageHeaderWrapper: React.SFC = ({ {value => (
= ({ margin: 0, }} > - {title} + {title || value.title} } {...restProps} - {...value} >
diff --git a/ListSearch/src/components/PageHeaderWrapper/index.tsx b/ListSearch/src/components/PageHeaderWrapper/index.tsx index 6ed06a55..622a42b3 100644 --- a/ListSearch/src/components/PageHeaderWrapper/index.tsx +++ b/ListSearch/src/components/PageHeaderWrapper/index.tsx @@ -60,6 +60,7 @@ const PageHeaderWrapper: React.SFC = ({ {value => (
= ({ margin: 0, }} > - {title} + {title || value.title} } {...restProps} - {...value} footer={renderFooter(restProps)} >
diff --git a/ListSearchApplications/src/components/PageHeaderWrapper/index.tsx b/ListSearchApplications/src/components/PageHeaderWrapper/index.tsx index fe1a33b8..7186520a 100644 --- a/ListSearchApplications/src/components/PageHeaderWrapper/index.tsx +++ b/ListSearchApplications/src/components/PageHeaderWrapper/index.tsx @@ -21,6 +21,7 @@ const PageHeaderWrapper: React.SFC = ({ {value => (
= ({ margin: 0, }} > - {title} + {title || value.title} } {...restProps} - {...value} >
diff --git a/ProfileBasic/src/components/PageHeaderWrapper/index.tsx b/ProfileBasic/src/components/PageHeaderWrapper/index.tsx index d92c875e..0f20f43a 100644 --- a/ProfileBasic/src/components/PageHeaderWrapper/index.tsx +++ b/ProfileBasic/src/components/PageHeaderWrapper/index.tsx @@ -13,6 +13,7 @@ const PageHeaderWrapper: React.SFC = ({ children, conte {value => (
= ({ children, conte margin: 0, }} > - {title} + {title || value.title} } - {...value} > {content} diff --git a/package.json b/package.json index 146328a8..c5904c3d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "private": true, "scripts": { - "dev": "cross-env PAGES_PATH='SearchList/src' umi dev", + "dev": "cross-env PAGES_PATH='EditorKoni/src' umi dev", "lint": "npm run lint:ts && npm run lint:style && npm run lint:prettier", "lint-staged": "lint-staged", "lint-staged:ts": "tslint", -- GitLab