react引入ggEditor流程图
<h2>遇到的问题</h2><p>1.propsAPI获取不到内容:withPropsAPI包裹的组件必须是GGEditor的子组件。</p>
<p>2.自定义组件如何使用:正确的办法是通过config配置,参照上面的代码(之前我在在内部RegisterCommand以后,在onAfterExecuteCommand中截获命令,通过函数控制图例操作。这中间需要下钻到内部组件调用propsAPI,我就通过setState去设置状态传递到子组件。)</p>
<p>3.如何设置拖拽组件:太羞耻了,居然不晓得在Item双标签内放名称。</p>
<p>4.操作流程图后获取数据延迟:如果获取数据有延迟,尝试使用setTimeout,时间间隔设为0后再调propsAPI属性的方法操作。</p>
<p> </p>
<p><span style="font-size: 18pt"><strong>1. 两种不同颜色的线</strong></span></p>
<p><span style="font-size: 16px">用onAfterChange监听,然后用先的更新设置不同的颜色即可。</span></p>
<p><span style="font-size: 18pt"><strong>2. 节点和线的更新</strong></span></p>
<div class="cnblogs_code">
<pre>import React, { Fragment } from 'react'<span style="color: rgba(0, 0, 0, 1)">;
import { Card, Form, Input, Select } from </span>'antd'<span style="color: rgba(0, 0, 0, 1)">;
import { withPropsAPI } from </span>'gg-editor'<span style="color: rgba(0, 0, 0, 1)">;
import upperFirst from </span>'lodash/upperFirst'<span style="color: rgba(0, 0, 0, 1)">;
const { Item } </span>=<span style="color: rgba(0, 0, 0, 1)"> Form;
const { Option } </span>=<span style="color: rgba(0, 0, 0, 1)"> Select;
const inlineFormItemLayout </span>=<span style="color: rgba(0, 0, 0, 1)"> {
labelCol: {
sm: { span: </span>8<span style="color: rgba(0, 0, 0, 1)"> },
},
wrapperCol: {
sm: { span: </span>16<span style="color: rgba(0, 0, 0, 1)"> },
},
};
class DetailForm extends React.Component {
get item() {
const { propsAPI } </span>= <span style="color: rgba(0, 0, 255, 1)">this</span><span style="color: rgba(0, 0, 0, 1)">.props;
</span><span style="color: rgba(0, 0, 255, 1)">return</span> propsAPI.getSelected();
}
handleSubmit </span>= (e) =><span style="color: rgba(0, 0, 0, 1)"> {
</span><span style="color: rgba(0, 0, 255, 1)">if</span> (e &&<span style="color: rgba(0, 0, 0, 1)"> e.preventDefault) {
e.preventDefault();
}
const { form, propsAPI } </span>= <span style="color: rgba(0, 0, 255, 1)">this</span><span style="color: rgba(0, 0, 0, 1)">.props;
const { getSelected, executeCommand, update } </span>=<span style="color: rgba(0, 0, 0, 1)"> propsAPI;
setTimeout(() </span>=><span style="color: rgba(0, 0, 0, 1)"> {
form.validateFieldsAndScroll((err, values) </span>=><span style="color: rgba(0, 0, 0, 1)"> {
</span><span style="color: rgba(0, 0, 255, 1)">if</span><span style="color: rgba(0, 0, 0, 1)"> (err) {
</span><span style="color: rgba(0, 0, 255, 1)">return</span><span style="color: rgba(0, 0, 0, 1)">;
}
const item </span>= getSelected();
</span><span style="color: rgba(0, 0, 255, 1)">if</span> (!<span style="color: rgba(0, 0, 0, 1)">item) {
</span><span style="color: rgba(0, 0, 255, 1)">return</span><span style="color: rgba(0, 0, 0, 1)">;
}
console.log(item,values,</span>'values'<span style="color: rgba(0, 0, 0, 1)">)
executeCommand(() </span>=><span style="color: rgba(0, 0, 0, 1)"> {
update(item, {
...values,
});
});
});
}, </span>0<span style="color: rgba(0, 0, 0, 1)">);
};
renderEdgeShapeSelect </span>= () =><span style="color: rgba(0, 0, 0, 1)"> {
</span><span style="color: rgba(0, 0, 255, 1)">return</span><span style="color: rgba(0, 0, 0, 1)"> (
</span><Select onChange={<span style="color: rgba(0, 0, 255, 1)">this</span>.handleSubmit}>
<Option value="flow-smooth">Smooth</Option>
<Option value="flow-polyline">Polyline</Option>
<Option value="flow-polyline-round">Polyline Round</Option>
</Select>
<span style="color: rgba(0, 0, 0, 1)"> );
};
renderNodeDetail </span>= () =><span style="color: rgba(0, 0, 0, 1)"> {
const { form } </span>= <span style="color: rgba(0, 0, 255, 1)">this</span><span style="color: rgba(0, 0, 0, 1)">.props;
const { label } </span>= <span style="color: rgba(0, 0, 255, 1)">this</span><span style="color: rgba(0, 0, 0, 1)">.item.getModel();
</span><span style="color: rgba(0, 0, 255, 1)">return</span><span style="color: rgba(0, 0, 0, 1)"> (
</span><Item label="Label" {...inlineFormItemLayout}><span style="color: rgba(0, 0, 0, 1)">
{form.getFieldDecorator(</span>'label'<span style="color: rgba(0, 0, 0, 1)">, {
initialValue: label.text </span>?<span style="color: rgba(0, 0, 0, 1)"> label.text : label,
})(</span><Input onBlur={<span style="color: rgba(0, 0, 255, 1)">this</span>.handleSubmit} />)}
</Item>
<span style="color: rgba(0, 0, 0, 1)"> );
};
renderEdgeDetail </span>= () =><span style="color: rgba(0, 0, 0, 1)"> {
const { form } </span>= <span style="color: rgba(0, 0, 255, 1)">this</span><span style="color: rgba(0, 0, 0, 1)">.props;
const { label </span>= '', shape = 'flow-smooth' } = <span style="color: rgba(0, 0, 255, 1)">this</span><span style="color: rgba(0, 0, 0, 1)">.item.getModel();
</span><span style="color: rgba(0, 0, 255, 1)">return</span><span style="color: rgba(0, 0, 0, 1)"> (
</span><Fragment>
<Item label="Label" {...inlineFormItemLayout}><span style="color: rgba(0, 0, 0, 1)">
{form.getFieldDecorator(</span>'label'<span style="color: rgba(0, 0, 0, 1)">, {
initialValue: label,
})(</span><Input onBlur={<span style="color: rgba(0, 0, 255, 1)">this</span>.handleSubmit} />)}
</Item>
<Item label="Shape" {...inlineFormItemLayout}><span style="color: rgba(0, 0, 0, 1)">
{form.getFieldDecorator(</span>'shape'<span style="color: rgba(0, 0, 0, 1)">, {
initialValue: shape,
})(</span><span style="color: rgba(0, 0, 255, 1)">this</span><span style="color: rgba(0, 0, 0, 1)">.renderEdgeShapeSelect())}
</span></Item>
</Fragment>
<span style="color: rgba(0, 0, 0, 1)"> );
};
renderGroupDetail </span>= () =><span style="color: rgba(0, 0, 0, 1)"> {
const { form } </span>= <span style="color: rgba(0, 0, 255, 1)">this</span><span style="color: rgba(0, 0, 0, 1)">.props;
const { label </span>= '新建分组' } = <span style="color: rgba(0, 0, 255, 1)">this</span><span style="color: rgba(0, 0, 0, 1)">.item.getModel();
</span><span style="color: rgba(0, 0, 255, 1)">return</span><span style="color: rgba(0, 0, 0, 1)"> (
</span><Item label="Label" {...inlineFormItemLayout}><span style="color: rgba(0, 0, 0, 1)">
{form.getFieldDecorator(</span>'label'<span style="color: rgba(0, 0, 0, 1)">, {
initialValue: label,
})(</span><Input onBlur={<span style="color: rgba(0, 0, 255, 1)">this</span>.handleSubmit} />)}
</Item>
<span style="color: rgba(0, 0, 0, 1)"> );
};
render() {
const { type } </span>= <span style="color: rgba(0, 0, 255, 1)">this</span><span style="color: rgba(0, 0, 0, 1)">.props;
</span><span style="color: rgba(0, 0, 255, 1)">if</span> (!<span style="color: rgba(0, 0, 255, 1)">this</span><span style="color: rgba(0, 0, 0, 1)">.item) {
</span><span style="color: rgba(0, 0, 255, 1)">return</span> <span style="color: rgba(0, 0, 255, 1)">null</span><span style="color: rgba(0, 0, 0, 1)">;
}
</span><span style="color: rgba(0, 0, 255, 1)">return</span><span style="color: rgba(0, 0, 0, 1)"> (
</span><Card type="inner" size="small" title={upperFirst(type)} bordered={<span style="color: rgba(0, 0, 255, 1)">false</span>}>
<Form onSubmit={<span style="color: rgba(0, 0, 255, 1)">this</span>.handleSubmit}><span style="color: rgba(0, 0, 0, 1)">
{type </span>=== 'node' && <span style="color: rgba(0, 0, 255, 1)">this</span><span style="color: rgba(0, 0, 0, 1)">.renderNodeDetail()}
{type </span>=== 'edge' && <span style="color: rgba(0, 0, 255, 1)">this</span><span style="color: rgba(0, 0, 0, 1)">.renderEdgeDetail()}
{type </span>=== 'group' && <span style="color: rgba(0, 0, 255, 1)">this</span><span style="color: rgba(0, 0, 0, 1)">.renderGroupDetail()}
</span></Form>
</Card>
<span style="color: rgba(0, 0, 0, 1)"> );
}
}
export </span><span style="color: rgba(0, 0, 255, 1)">default</span> Form.create()(withPropsAPI(DetailForm));</pre>
</div>
<p> </p>
<p><span style="font-size: 18pt"><strong>3. 提交数据</strong></span></p>
<p><span style="font-size: 18pt"><strong>4. 自定义节点,注册节点</strong></span></p>
<p><strong><span style="font-size: 18px">EditorCustomFlowMap组件</span></strong></p>
<div class="cnblogs_code">
<pre>import React from 'react'<span style="color: rgba(0, 0, 0, 1)">;
import { Col } from </span>'antd'<span style="color: rgba(0, 0, 0, 1)">;
import { Flow } from </span>'gg-editor'<span style="color: rgba(0, 0, 0, 1)">;
import { withPropsAPI } from </span>'gg-editor'<span style="color: rgba(0, 0, 0, 1)">;
import CustomNode from </span>'../EditorCustomNode'<span style="color: rgba(0, 0, 0, 1)">;</span><span style="color: rgba(0, 0, 0, 1)">
const FlowMap </span>= (props) =><span style="color: rgba(0, 0, 0, 1)"> {</span><span style="color: rgba(0, 0, 255, 1)">return</span><span style="color: rgba(0, 0, 0, 1)"> (
</span><Col span={21} className='editorContent'>
<<span style="color: rgba(0, 0, 0, 1)">Flow
className</span>='flow'<span style="color: rgba(0, 0, 0, 1)">
data</span>=<span style="color: rgba(0, 0, 0, 1)">{props.data} // 已有节点那数据结构
noEndEdge</span>={<span style="color: rgba(0, 0, 255, 1)">false</span><span style="color: rgba(0, 0, 0, 1)">}</span>/>
<CustomNode />
</Col>
<span style="color: rgba(0, 0, 0, 1)"> );
};
export </span><span style="color: rgba(0, 0, 255, 1)">default</span> withPropsAPI(FlowMap);</pre>
</div>
<pre><strong><span style="font-size: 18px">CustomNode 组件,注册节点</span></strong></pre>
<div class="cnblogs_code">
<pre>import React from "react"<span style="color: rgba(0, 0, 0, 1)">;
import { RegisterNode } from </span>"gg-editor"<span style="color: rgba(0, 0, 0, 1)">;
class CustomNode extends React.Component {
render() {
const config </span>=<span style="color: rgba(0, 0, 0, 1)"> {
draw(item) {
const keyShape </span>= <span style="color: rgba(0, 0, 255, 1)">this</span><span style="color: rgba(0, 0, 0, 1)">.drawKeyShape(item);
</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> 绘制图标</span>
const group =<span style="color: rgba(0, 0, 0, 1)"> item.getGraphicGroup();
const model </span>=<span style="color: rgba(0, 0, 0, 1)"> item.getModel();
group.addShape(</span>"image"<span style="color: rgba(0, 0, 0, 1)">, {
attrs: {
x: </span>-35<span style="color: rgba(0, 0, 0, 1)">,
y: </span>-10<span style="color: rgba(0, 0, 0, 1)">,
width: </span>20<span style="color: rgba(0, 0, 0, 1)">,
height: </span>20<span style="color: rgba(0, 0, 0, 1)">,
img: model.icon
}
});
</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> 绘制标签</span>
<span style="color: rgba(0, 0, 255, 1)">this</span><span style="color: rgba(0, 0, 0, 1)">.drawLabel(item);
</span><span style="color: rgba(0, 0, 255, 1)">return</span><span style="color: rgba(0, 0, 0, 1)"> keyShape;
},
anchor: [
[</span>0.5, 0], <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> 上边中点</span>
, <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> 右边中点</span>
, <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> 底边中点</span>
<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> 左边中点</span>
<span style="color: rgba(0, 0, 0, 1)"> ]
};
</span><span style="color: rgba(0, 0, 255, 1)">return</span><span style="color: rgba(0, 0, 0, 1)"> (
</span><RegisterNode name="custom-node" config={config} extend={"flow-circle"} />
<span style="color: rgba(0, 0, 0, 1)"> );
}
}
export </span><span style="color: rgba(0, 0, 255, 1)">default</span> CustomNode;</pre>
</div>
<p> </p>
<p><span style="font-size: 18pt"><strong>5.已有节点的数据结构</strong></span></p>
<div class="cnblogs_Highlighter">
<pre class="brush:javascript;gutter:true;">{
"nodes": [
{
"id": "1",
"flowType":"flow-circle", // 节点使用的形状
"label":"开始",
"x": 100, // 节点X轴坐标位置
"y": 50,// 节点Y轴坐标位置
"color":"blue", // 节点的颜色
"size ": "80*48", // 节点的宽度和高度
"shape ": "flow-rect"
}
],
"edges": [
{
"source":"1",
"sourceAnchor": 1,
"target":"2",
"targetAnchor": 3,
"id": "d1",<br> "color":"red" // 连线的颜色
}
]
}
</pre>
</div>
<p><strong><span style="font-family: "Microsoft YaHei"; font-size: 18pt">6.左侧待拖动的节点</span></strong></p>
<p>这里的节点和flow图里面的节点样式控制不一样,这里的节点样式是靠css来控制。</p>
<p>flow图里面的节点样式,1,已有节点,靠的是已有节点的数据来控制,2,即将拖拽到flow区域的节点,是靠这里的Item属性来控制样式。</p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 128, 128, 1)"> 1</span> import React from 'react'<span style="color: rgba(0, 0, 0, 1)">;
</span><span style="color: rgba(0, 128, 128, 1)"> 2</span> import { Card } from 'antd'<span style="color: rgba(0, 0, 0, 1)">;
</span><span style="color: rgba(0, 128, 128, 1)"> 3</span> import { ItemPanel, Item } from 'gg-editor'<span style="color: rgba(0, 0, 0, 1)">;
</span><span style="color: rgba(0, 128, 128, 1)"> 4</span> import './index.less'<span style="color: rgba(0, 0, 0, 1)">;</span><span style="color: rgba(0, 128, 128, 1)"> 6</span>
<span style="color: rgba(0, 128, 128, 1)"> 7</span> const FlowItemPanel = () =><span style="color: rgba(0, 0, 0, 1)"> {
</span><span style="color: rgba(0, 128, 128, 1)"> 8</span> <span style="color: rgba(0, 0, 255, 1)">return</span><span style="color: rgba(0, 0, 0, 1)"> (</span>
<span style="color: rgba(0, 128, 128, 1)">10</span> <ItemPanel className='itemPanel'>
<span style="color: rgba(0, 128, 128, 1)">11</span> <Card bordered={<span style="color: rgba(0, 0, 255, 1)">false</span>}>
<span style="color: rgba(0, 128, 128, 1)">12</span> <<span style="color: rgba(0, 0, 0, 1)">Item
</span><span style="color: rgba(0, 128, 128, 1)">13</span> type="node"
<span style="color: rgba(0, 128, 128, 1)">14</span> size="72*72"<span style="color: rgba(0, 128, 128, 1)">15</span> shape="custom-node" // 自定义注册节点名称
<span style="color: rgba(0, 128, 128, 1)">16</span> model=<span style="color: rgba(0, 0, 0, 1)">{{
</span><span style="color: rgba(0, 128, 128, 1)">17</span> icon:'//img.alicdn.com/tfs/TB1OzAmyyLaK1RjSZFxXXamPFXa-200-200.svg'<span style="color: rgba(0, 0, 0, 1)">,
</span><span style="color: rgba(0, 128, 128, 1)">18</span> color: '#FA8C16'<span style="color: rgba(0, 0, 0, 1)">,
</span><span style="color: rgba(0, 128, 128, 1)">19</span> <span style="color: rgba(0, 0, 0, 1)"> label:{
</span><span style="color: rgba(0, 128, 128, 1)">20</span> text:'流程'<span style="color: rgba(0, 0, 0, 1)">,
</span><span style="color: rgba(0, 128, 128, 1)">21</span> fill: 'green'
<span style="color: rgba(0, 128, 128, 1)">22</span> <span style="color: rgba(0, 0, 0, 1)"> },
</span><span style="color: rgba(0, 128, 128, 1)">23</span> <span style="color: rgba(0, 0, 0, 1)"> }}
</span><span style="color: rgba(0, 128, 128, 1)">24</span> >
<span style="color: rgba(0, 128, 128, 1)">25</span> <div className="flow-node">流程</div>
<span style="color: rgba(0, 128, 128, 1)">26</span> </Item>
<span style="color: rgba(0, 128, 128, 1)">27</span>
<span style="color: rgba(0, 128, 128, 1)">28</span> <<span style="color: rgba(0, 0, 0, 1)">Item
</span><span style="color: rgba(0, 128, 128, 1)">29</span> type="node"
<span style="color: rgba(0, 128, 128, 1)">30</span> size="80*48"<span style="color: rgba(0, 128, 128, 1)">31</span> shape="flow-rect"
<span style="color: rgba(0, 128, 128, 1)">32</span> model=<span style="color: rgba(0, 0, 0, 1)">{{
</span><span style="color: rgba(0, 128, 128, 1)">33</span> color: '#1890FF'<span style="color: rgba(0, 0, 0, 1)">,
</span><span style="color: rgba(0, 128, 128, 1)">34</span> <span style="color: rgba(0, 0, 0, 1)"> label:{
</span><span style="color: rgba(0, 128, 128, 1)">35</span> text:'文档'<span style="color: rgba(0, 0, 0, 1)">,
</span><span style="color: rgba(0, 128, 128, 1)">36</span> fill: '#000'
<span style="color: rgba(0, 128, 128, 1)">37</span> <span style="color: rgba(0, 0, 0, 1)"> },
</span><span style="color: rgba(0, 128, 128, 1)">38</span> <span style="color: rgba(0, 0, 0, 1)"> }}
</span><span style="color: rgba(0, 128, 128, 1)">39</span> >
<span style="color: rgba(0, 128, 128, 1)">40</span> <div className="document-node">文档</div>
<span style="color: rgba(0, 128, 128, 1)">41</span> </Item>
<span style="color: rgba(0, 128, 128, 1)">42</span> </Card>
<span style="color: rgba(0, 128, 128, 1)">43</span> </ItemPanel>
<span style="color: rgba(0, 128, 128, 1)">44</span> <span style="color: rgba(0, 0, 0, 1)">);
</span><span style="color: rgba(0, 128, 128, 1)">45</span> <span style="color: rgba(0, 0, 0, 1)">};
</span><span style="color: rgba(0, 128, 128, 1)">46</span>
<span style="color: rgba(0, 128, 128, 1)">47</span> export <span style="color: rgba(0, 0, 255, 1)">default</span> FlowItemPanel;</pre>
</div>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 128, 128, 1)"> 1</span> .flow-<span style="color: rgba(0, 0, 0, 1)">node{
</span><span style="color: rgba(0, 128, 128, 1)"> 2</span> <span style="color: rgba(0, 0, 0, 1)">border: 1px solid #fed49a;
</span><span style="color: rgba(0, 128, 128, 1)"> 3</span> background-<span style="color: rgba(0, 0, 0, 1)">color: #fef6e7;
</span><span style="color: rgba(0, 128, 128, 1)"> 4</span> border-radius: 50%<span style="color: rgba(0, 0, 0, 1)">;
</span><span style="color: rgba(0, 128, 128, 1)"> 5</span> <span style="color: rgba(0, 0, 0, 1)">padding: 20px;
</span><span style="color: rgba(0, 128, 128, 1)"> 6</span> <span style="color: rgba(0, 0, 0, 1)">color: green;
</span><span style="color: rgba(0, 128, 128, 1)"> 7</span> -webkit-user-<span style="color: rgba(0, 0, 0, 1)">select: none;
</span><span style="color: rgba(0, 128, 128, 1)"> 8</span> -ms-user-select: none; <span style="color: rgba(0, 128, 0, 1)">/*</span><span style="color: rgba(0, 128, 0, 1)"> Internet Explorer/Edge </span><span style="color: rgba(0, 128, 0, 1)">*/</span>
<span style="color: rgba(0, 128, 128, 1)"> 9</span> <span style="color: rgba(0, 0, 0, 1)">}
</span><span style="color: rgba(0, 128, 128, 1)">10</span>
<span style="color: rgba(0, 128, 128, 1)">11</span> .document-<span style="color: rgba(0, 0, 0, 1)">node{
</span><span style="color: rgba(0, 128, 128, 1)">12</span> border-radius: 10%<span style="color: rgba(0, 0, 0, 1)">;
</span><span style="color: rgba(0, 128, 128, 1)">13</span> <span style="color: rgba(0, 0, 0, 1)">border: 1px solid #a7dafe;
</span><span style="color: rgba(0, 128, 128, 1)">14</span> background-<span style="color: rgba(0, 0, 0, 1)">color: #e7f6fe;
</span><span style="color: rgba(0, 128, 128, 1)">15</span> <span style="color: rgba(0, 0, 0, 1)">padding: 15px 20px;
</span><span style="color: rgba(0, 128, 128, 1)">16</span> -webkit-user-<span style="color: rgba(0, 0, 0, 1)">select: none;
</span><span style="color: rgba(0, 128, 128, 1)">17</span> -ms-user-select: none; <span style="color: rgba(0, 128, 0, 1)">/*</span><span style="color: rgba(0, 128, 0, 1)"> Internet Explorer/Edge </span><span style="color: rgba(0, 128, 0, 1)">*/</span>
<span style="color: rgba(0, 128, 128, 1)">18</span> }</pre>
</div>
<p><span style="font-size: 18pt; font-family: "Microsoft YaHei""><strong>7.操作栏的设置</strong></span></p>
<div class="cnblogs_code">
<pre>import React from 'react'<span style="color: rgba(0, 0, 0, 1)">;
import { Divider } from </span>'antd'<span style="color: rgba(0, 0, 0, 1)">;
import { Toolbar } from </span>'gg-editor'<span style="color: rgba(0, 0, 0, 1)">;
import ToolbarButton from </span>'./ToolbarButton'<span style="color: rgba(0, 0, 0, 1)">;
import </span>'./index.less'<span style="color: rgba(0, 0, 0, 1)">;
const FlowToolbar </span>= () =><span style="color: rgba(0, 0, 0, 1)"> {
</span><span style="color: rgba(0, 0, 255, 1)">return</span><span style="color: rgba(0, 0, 0, 1)"> (
</span><Toolbar className='toolbar'>
<ToolbarButton command="undo" text="回退一步" />
<ToolbarButton command="redo" text="前进一步" />
<Divider type="vertical" />
<ToolbarButton command="copy" text="复制" />
<ToolbarButton command="paste" text="粘贴" />
<ToolbarButton command="delete" text="删除" />
<Divider type="vertical" />
<ToolbarButton command="zoomIn" icon="zoom-in" text="Zoom In" />
<ToolbarButton command="zoomOut" icon="zoom-out" text="Zoom Out" />
<ToolbarButton command="autoZoom" icon="fit-map" text="Fit Map" />
<ToolbarButton command="resetZoom" icon="actual-size" text="Actual Size" />
<Divider type="vertical" />
<ToolbarButton command="toBack" icon="to-back" text="To Back" />
<ToolbarButton command="toFront" icon="to-front" text="To Front" />
<Divider type="vertical" />
<ToolbarButton command="multiSelect" icon="multi-select" text="Multi Select" />
<ToolbarButton command="addGroup" icon="group" text="Add Group" />
<ToolbarButton command="unGroup" icon="ungroup" text="Ungroup" />
</Toolbar>
<span style="color: rgba(0, 0, 0, 1)">);
};
export </span><span style="color: rgba(0, 0, 255, 1)">default</span> FlowToolbar;</pre>
</div>
<p> </p>
<p>8. 总</p>
<div class="cnblogs_code">
<pre>import React from 'react'<span style="color: rgba(0, 0, 0, 1)">;
import { Row, Col } from </span>'antd'<span style="color: rgba(0, 0, 0, 1)">;
import GGEditor from </span>'gg-editor'<span style="color: rgba(0, 0, 0, 1)">;
</span><span style="color: rgba(0, 128, 0, 1)">import EditorMinimap from '../components/EditorMinimap';</span>
import { FlowContextMenu } from '../components/EditorContextMenu'<span style="color: rgba(0, 0, 0, 1)">;
import { FlowToolbar } from </span>'../components/EditorToolbar'<span style="color: rgba(0, 0, 0, 1)">;
import { FlowItemPanel } from </span>'../components/EditorItemPanel'<span style="color: rgba(0, 0, 0, 1)">;
</span><span style="color: rgba(0, 128, 0, 1)">import { FlowDetailPanel } from '../components/EditorDetailPanel';</span>
import './index.less'<span style="color: rgba(0, 0, 0, 1)">;
import EditorCustomDetailPanel from </span>'../components/EditorCustomDetailPanel'<span style="color: rgba(0, 0, 0, 1)">;
import EditorCustomFlowMap from </span>'../components/EditorCustomFlowMap'<span style="color: rgba(0, 0, 0, 1)">;</span><span style="color: rgba(0, 0, 0, 1)">
const flowData </span>=<span style="color: rgba(0, 0, 0, 1)"> {nodes:[],edges:[]};
const FlowPage </span>= (props) =><span style="color: rgba(0, 0, 0, 1)"> {</span><span style="color: rgba(0, 0, 255, 1)">return</span><span style="color: rgba(0, 0, 0, 1)"> (
</span><GGEditorclassName='editor' style={{height:props.height}}>
<Row type="flex" className='editorHd'>
<Col span={24}>
<FlowToolbar />
</Col>
</Row>
<Row type="flex" className='editorBd'>
<Col span={3} className='editorSidebar'>
<FlowItemPanel />
</Col>
<<span style="color: rgba(0, 0, 0, 1)">EditorCustomFlowMap
data</span>=<span style="color: rgba(0, 0, 0, 1)">{flowData}
onNodeClick</span>=<span style="color: rgba(0, 0, 0, 1)">{props.handleNodeClick}
onNodeDragEnd </span>=<span style="color: rgba(0, 0, 0, 1)">{props.handleNodeDragEnd}
handleAfterChange</span>=<span style="color: rgba(0, 0, 0, 1)">{props.handleAfterChange}
</span>/>
<span style="color: rgba(0, 128, 0, 1)"><Col span={4} className='editorSidebar'>
<FlowDetailPanel />
<EditorMinimap />
</Col></span></Row>
<FlowContextMenu />
<<span style="color: rgba(0, 0, 0, 1)">EditorCustomDetailPanel
visibleDetailPanel</span>=<span style="color: rgba(0, 0, 0, 1)">{props.visibleDetailPanel}
hideVisibleDetailPanel</span>=<span style="color: rgba(0, 0, 0, 1)">{props.hideVisibleDetailPanel}
detailPanel</span>=<span style="color: rgba(0, 0, 0, 1)">{props.detailPanel}
currentNode</span>=<span style="color: rgba(0, 0, 0, 1)">{props.currentNode}
changeDetailPanel</span>=<span style="color: rgba(0, 0, 0, 1)">{props.changeDetailPanel}
submitCurrentNode</span>=<span style="color: rgba(0, 0, 0, 1)">{props.submitCurrentNode}
</span>/>
</GGEditor>
<span style="color: rgba(0, 0, 0, 1)"> );
};
export </span><span style="color: rgba(0, 0, 255, 1)">default</span> FlowPage;</pre>
</div>
<p> </p>
</div>
<div id="MySignature" role="contentinfo">
快乐学习,积累在于一点一滴。
希望能够帮到你,如果有问题,请多多指教,谢谢!<br><br>
来源:https://www.cnblogs.com/hibiscus-ben/p/12360401.html
頁:
[1]