@logicflow/core 0.4.1-alpha.1 → 0.4.1-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +171 -0
- package/dist/logic-flow-cjs.js +2 -0
- package/dist/logic-flow-cjs.js.LICENSE.txt +23 -0
- package/dist/logic-flow.js +2 -2
- package/dist/logic-flow.js.LICENSE.txt +23 -0
- package/dist/style/index.css +124 -8
- package/es/index.js +69 -0
- package/package.json +20 -5
- package/types/LogicFlow.d.ts +63 -19
- package/types/constant/DefaultTheme.d.ts +12 -0
- package/types/constant/constant.d.ts +13 -2
- package/types/event/eventEmitter.d.ts +8 -8
- package/types/model/BaseModel.d.ts +60 -1
- package/types/model/EditConfigModel.d.ts +74 -2
- package/types/model/GraphModel.d.ts +34 -6
- package/types/model/TransformModel.d.ts +16 -3
- package/types/model/edge/BaseEdgeModel.d.ts +19 -1
- package/types/model/edge/BezierEdgeModel.d.ts +11 -1
- package/types/model/edge/LineEdgeModel.d.ts +1 -1
- package/types/model/edge/PolylineEdgeModel.d.ts +19 -1
- package/types/model/node/BaseNodeModel.d.ts +71 -23
- package/types/model/node/CircleNodeModel.d.ts +5 -2
- package/types/model/node/HtmlNodeModel.d.ts +11 -0
- package/types/model/node/PolygonNodeModel.d.ts +5 -0
- package/types/model/node/index.d.ts +1 -0
- package/types/options.d.ts +79 -9
- package/types/tool/MultipleSelectTool.d.ts +2 -2
- package/types/tool/TextEditTool.d.ts +3 -4
- package/types/tool/index.d.ts +1 -0
- package/types/type/index.d.ts +74 -5
- package/types/util/drag.d.ts +2 -0
- package/types/util/edge.d.ts +2 -1
- package/types/util/graph.d.ts +4 -0
- package/types/util/node.d.ts +20 -2
- package/types/util/theme.d.ts +12 -0
- package/types/util/uuid.d.ts +5 -0
- package/types/util/zIndex.d.ts +2 -0
- package/types/view/Anchor.d.ts +6 -4
- package/types/view/Graph.d.ts +0 -4
- package/types/view/basic-shape/LinearGradient.d.ts +1 -0
- package/types/view/basic-shape/Polygon.d.ts +1 -9
- package/types/view/behavior/DnD.d.ts +1 -1
- package/types/view/edge/AdjustPoint.d.ts +43 -0
- package/types/view/edge/BaseEdge.d.ts +3 -1
- package/types/view/edge/PolylineEdge.d.ts +1 -0
- package/types/view/node/BaseNode.d.ts +11 -7
- package/types/view/node/CircleNode.d.ts +3 -1
- package/types/view/node/DiamondNode.d.ts +3 -1
- package/types/view/node/EllipseNode.d.ts +3 -1
- package/types/view/node/HtmlNode.d.ts +11 -0
- package/types/view/node/PolygonNode.d.ts +3 -1
- package/types/view/node/RectNode.d.ts +3 -1
- package/types/view/node/TextNode.d.ts +1 -0
- package/types/view/node/index.d.ts +2 -1
- package/types/view/overlay/CanvasOverlay.d.ts +30 -2
- package/types/view/overlay/Grid.d.ts +10 -0
- package/types/view/overlay/HtmlOverlay.d.ts +5 -46
- package/types/view/overlay/ModificationOverlay.d.ts +9 -0
- package/CHANGELOG.md +0 -415
- package/LICENSE +0 -433
- package/dist/style/background.css +0 -8
- package/dist/style/html-overlay.css +0 -33
- package/dist/style/tool.css +0 -29
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/*! *****************************************************************************
|
|
2
|
+
Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
4
|
+
this file except in compliance with the License. You may obtain a copy of the
|
|
5
|
+
License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
|
|
7
|
+
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
8
|
+
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
|
9
|
+
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
|
10
|
+
MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
11
|
+
|
|
12
|
+
See the Apache Version 2.0 License for specific language governing permissions
|
|
13
|
+
and limitations under the License.
|
|
14
|
+
***************************************************************************** */
|
|
15
|
+
|
|
16
|
+
/** @license mobx-react v5.4.4
|
|
17
|
+
* index.module.js
|
|
18
|
+
*
|
|
19
|
+
* Copyright (c) 2015 Michel Weststrate.
|
|
20
|
+
*
|
|
21
|
+
* This source code is licensed under the MIT license found in the
|
|
22
|
+
* LICENSE file in the root directory of this source tree.
|
|
23
|
+
*/
|
package/dist/style/index.css
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
@import 'background.css';
|
|
2
|
-
@import 'html-overlay.css';
|
|
3
|
-
@import 'tool.css';
|
|
4
|
-
|
|
5
1
|
.lf-graph {
|
|
6
2
|
position: relative;
|
|
7
3
|
width: 100%;
|
|
8
4
|
height: 100%;
|
|
9
5
|
z-index: 0;
|
|
10
|
-
background: #
|
|
6
|
+
background: #ffffff;
|
|
11
7
|
user-select: none;
|
|
12
8
|
}
|
|
13
9
|
.lf-element-text {
|
|
@@ -19,7 +15,7 @@
|
|
|
19
15
|
.lf-node-anchor-hover {
|
|
20
16
|
visibility: hidden;
|
|
21
17
|
}
|
|
22
|
-
.lf-anchor:hover
|
|
18
|
+
.lf-anchor:hover .lf-node-anchor-hover {
|
|
23
19
|
visibility: visible;
|
|
24
20
|
}
|
|
25
21
|
.lf-edge-append {
|
|
@@ -43,8 +39,128 @@
|
|
|
43
39
|
cursor: grabbing;
|
|
44
40
|
}
|
|
45
41
|
.lf-drag-able {
|
|
46
|
-
cursor:default;
|
|
42
|
+
cursor: default;
|
|
47
43
|
}
|
|
48
|
-
.lf-bezier-adjust-anchor{
|
|
44
|
+
.lf-bezier-adjust-anchor {
|
|
49
45
|
cursor: pointer;
|
|
50
46
|
}
|
|
47
|
+
/* background */
|
|
48
|
+
.lf-background,
|
|
49
|
+
.lf-grid {
|
|
50
|
+
position: absolute;
|
|
51
|
+
left: 0px;
|
|
52
|
+
top: 0px;
|
|
53
|
+
right: 0;
|
|
54
|
+
bottom: 0;
|
|
55
|
+
z-index: -1;
|
|
56
|
+
}
|
|
57
|
+
.lf-background-area {
|
|
58
|
+
width: 100%;
|
|
59
|
+
height: 100%;
|
|
60
|
+
}
|
|
61
|
+
/* html-overlay */
|
|
62
|
+
.lf-html-overlay {
|
|
63
|
+
position: absolute;
|
|
64
|
+
top: 0;
|
|
65
|
+
left: 0;
|
|
66
|
+
right: 0;
|
|
67
|
+
bottom: 0;
|
|
68
|
+
z-index: 1;
|
|
69
|
+
pointer-events: none;
|
|
70
|
+
overflow: hidden;
|
|
71
|
+
user-select: none;
|
|
72
|
+
}
|
|
73
|
+
.lf-html-overlay__transform > * {
|
|
74
|
+
pointer-events: all;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.lf-text-editable {
|
|
78
|
+
pointer-events: all;
|
|
79
|
+
}
|
|
80
|
+
.lf-text-input {
|
|
81
|
+
text-align: center;
|
|
82
|
+
outline: none;
|
|
83
|
+
position: absolute;
|
|
84
|
+
border: 1px solid #edefed;
|
|
85
|
+
box-sizing: border-box;
|
|
86
|
+
line-height: 1.2;
|
|
87
|
+
border-radius: 3px;
|
|
88
|
+
resize: none;
|
|
89
|
+
padding: 5px;
|
|
90
|
+
min-height: 20px;
|
|
91
|
+
min-width: 100px;
|
|
92
|
+
white-space: pre;
|
|
93
|
+
background: #fff;
|
|
94
|
+
transform: translate(-50%, -50%);
|
|
95
|
+
}
|
|
96
|
+
.lf-get-text-height {
|
|
97
|
+
display: inline-block;
|
|
98
|
+
word-break: break-all;
|
|
99
|
+
/* 为了跟输入效果保持一致,设置透明边框占位 */
|
|
100
|
+
border: 1px solid transparent;
|
|
101
|
+
box-sizing: border-box;
|
|
102
|
+
}
|
|
103
|
+
.lf-node-text-auto-wrap {
|
|
104
|
+
box-sizing: border-box;
|
|
105
|
+
display: flex;
|
|
106
|
+
justify-content: center;
|
|
107
|
+
align-items: center;
|
|
108
|
+
border: 1px solid transparent;
|
|
109
|
+
}
|
|
110
|
+
.lf-node-text-auto-wrap-content {
|
|
111
|
+
line-height: 1.2;
|
|
112
|
+
background: transparent;
|
|
113
|
+
text-align: center;
|
|
114
|
+
word-break: break-all;
|
|
115
|
+
}
|
|
116
|
+
/* tool-overlay */
|
|
117
|
+
.lf-tool-overlay {
|
|
118
|
+
position: absolute;
|
|
119
|
+
top: 0;
|
|
120
|
+
left: 0;
|
|
121
|
+
right: 0;
|
|
122
|
+
bottom: 0;
|
|
123
|
+
z-index: 2;
|
|
124
|
+
pointer-events: none;
|
|
125
|
+
overflow: hidden;
|
|
126
|
+
}
|
|
127
|
+
.lf-tool-overlay > * {
|
|
128
|
+
pointer-events: all;
|
|
129
|
+
}
|
|
130
|
+
/* modification-overlay */
|
|
131
|
+
|
|
132
|
+
.modification-overlay {
|
|
133
|
+
position: absolute;
|
|
134
|
+
top: 0;
|
|
135
|
+
left: 0;
|
|
136
|
+
right: 0;
|
|
137
|
+
bottom: 0;
|
|
138
|
+
z-index: 1;
|
|
139
|
+
pointer-events: none;
|
|
140
|
+
overflow: hidden;
|
|
141
|
+
}
|
|
142
|
+
.modification-overlay > * {
|
|
143
|
+
pointer-events: all;
|
|
144
|
+
}
|
|
145
|
+
.lf-outline,.lf-snapline {
|
|
146
|
+
pointer-events: none;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.lf-keyboard-tips {
|
|
150
|
+
float: right;
|
|
151
|
+
}
|
|
152
|
+
.lf-node-select-decorate {
|
|
153
|
+
transform: translate(-50%, -50%);
|
|
154
|
+
pointer-events: none;
|
|
155
|
+
border: 1px dashed #343435;
|
|
156
|
+
position: absolute;
|
|
157
|
+
}
|
|
158
|
+
.lf-multiple-select {
|
|
159
|
+
position: absolute;
|
|
160
|
+
border: 2px dashed rgba(24, 125, 255, 0.8);
|
|
161
|
+
box-shadow: 0px 0px 3px 0px rgba(24, 125, 255, 0.5);
|
|
162
|
+
cursor: move;
|
|
163
|
+
}
|
|
164
|
+
.lf-edge-adjust-point {
|
|
165
|
+
cursor: move;
|
|
166
|
+
}
|
package/es/index.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
|
|
2
|
+
import {
|
|
3
|
+
LogicFlow,
|
|
4
|
+
LogicFlowUtil,
|
|
5
|
+
h,
|
|
6
|
+
observer,
|
|
7
|
+
BaseNode,
|
|
8
|
+
RectNode,
|
|
9
|
+
CircleNode,
|
|
10
|
+
PolygonNode,
|
|
11
|
+
DiamondNode,
|
|
12
|
+
EllipseNode,
|
|
13
|
+
TextNode,
|
|
14
|
+
HtmlNode,
|
|
15
|
+
BaseEdge,
|
|
16
|
+
LineEdge,
|
|
17
|
+
PolylineEdge,
|
|
18
|
+
BezierEdge,
|
|
19
|
+
BaseEdgeModel,
|
|
20
|
+
BezierEdgeModel,
|
|
21
|
+
LineEdgeModel,
|
|
22
|
+
PolylineEdgeModel,
|
|
23
|
+
BaseNodeModel,
|
|
24
|
+
CircleNodeModel,
|
|
25
|
+
DiamondNodeModel,
|
|
26
|
+
EllipseNodeModel,
|
|
27
|
+
PolygonNodeModel,
|
|
28
|
+
RectNodeModel,
|
|
29
|
+
TextNodeModel,
|
|
30
|
+
HtmlNodeModel,
|
|
31
|
+
GraphModel,
|
|
32
|
+
Arrow,
|
|
33
|
+
Keyboard,
|
|
34
|
+
} from '../dist/logic-flow';
|
|
35
|
+
|
|
36
|
+
export {
|
|
37
|
+
LogicFlow,
|
|
38
|
+
LogicFlowUtil,
|
|
39
|
+
h,
|
|
40
|
+
observer,
|
|
41
|
+
BaseNode,
|
|
42
|
+
RectNode,
|
|
43
|
+
CircleNode,
|
|
44
|
+
PolygonNode,
|
|
45
|
+
DiamondNode,
|
|
46
|
+
EllipseNode,
|
|
47
|
+
TextNode,
|
|
48
|
+
HtmlNode,
|
|
49
|
+
BaseEdge,
|
|
50
|
+
LineEdge,
|
|
51
|
+
PolylineEdge,
|
|
52
|
+
BezierEdge,
|
|
53
|
+
BaseEdgeModel,
|
|
54
|
+
BezierEdgeModel,
|
|
55
|
+
LineEdgeModel,
|
|
56
|
+
PolylineEdgeModel,
|
|
57
|
+
BaseNodeModel,
|
|
58
|
+
CircleNodeModel,
|
|
59
|
+
DiamondNodeModel,
|
|
60
|
+
EllipseNodeModel,
|
|
61
|
+
PolygonNodeModel,
|
|
62
|
+
RectNodeModel,
|
|
63
|
+
TextNodeModel,
|
|
64
|
+
HtmlNodeModel,
|
|
65
|
+
GraphModel,
|
|
66
|
+
Arrow,
|
|
67
|
+
Keyboard,
|
|
68
|
+
}
|
|
69
|
+
export default LogicFlow;
|
package/package.json
CHANGED
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@logicflow/core",
|
|
3
|
-
"version": "0.4.1-alpha.
|
|
3
|
+
"version": "0.4.1-alpha.2",
|
|
4
4
|
"description": "LogicFlow core, to quickly build flowchart editor",
|
|
5
5
|
"main": "dist/logic-flow.js",
|
|
6
|
-
"
|
|
6
|
+
"unpkg": "dist/logic-flow.js",
|
|
7
|
+
"jsdelivr": "dist/logic-flow.js",
|
|
8
|
+
"module": "es/index.js",
|
|
9
|
+
"license": "Apache-2.0",
|
|
10
|
+
"homepage": "http://logic-flow.org/",
|
|
7
11
|
"types": "types/index.d.ts",
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "https://github.com/didi/LogicFlow",
|
|
15
|
+
"directory": "packages/core"
|
|
16
|
+
},
|
|
8
17
|
"scripts": {
|
|
9
|
-
"dev": "cross-env NODE_ENV=development
|
|
18
|
+
"dev": "cross-env NODE_ENV=development webpack-dev-server --client-log-level warning --config scripts/webpack.config.dev.js",
|
|
10
19
|
"clean": "rimraf dist lib esm cjs",
|
|
11
20
|
"build": "npm run build:umd",
|
|
12
21
|
"build:umd": "cross-env NODE_ENV=production webpack --config scripts/webpack.config.build.js && cp -r src/style/ dist/style",
|
|
@@ -18,13 +27,19 @@
|
|
|
18
27
|
},
|
|
19
28
|
"files": [
|
|
20
29
|
"dist",
|
|
21
|
-
"
|
|
30
|
+
"es",
|
|
31
|
+
"types",
|
|
32
|
+
"README.md"
|
|
22
33
|
],
|
|
23
34
|
"dependencies": {
|
|
24
35
|
"@types/mousetrap": "^1.6.4",
|
|
25
36
|
"mousetrap": "^1.6.5",
|
|
26
37
|
"preact": "^10.4.8"
|
|
27
38
|
},
|
|
39
|
+
"keywords": [
|
|
40
|
+
"flowchart",
|
|
41
|
+
"diagram"
|
|
42
|
+
],
|
|
28
43
|
"devDependencies": {
|
|
29
44
|
"@babel/core": "^7.9.0",
|
|
30
45
|
"@babel/plugin-proposal-class-properties": "^7.8.3",
|
|
@@ -81,5 +96,5 @@
|
|
|
81
96
|
"last 2 versions",
|
|
82
97
|
"not ie <= 11"
|
|
83
98
|
],
|
|
84
|
-
"gitHead": "
|
|
99
|
+
"gitHead": "ab8cc6126e9dfa5c4fb18037538a374d3a0b0521"
|
|
85
100
|
}
|
package/types/LogicFlow.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import History from './history/History';
|
|
|
6
6
|
import Tool from './tool';
|
|
7
7
|
import EventEmitter, { CallbackType } from './event/eventEmitter';
|
|
8
8
|
import Keyboard from './keyboard';
|
|
9
|
-
import { EdgeConfig, EdgeFilter, NodeConfig, NodeAttribute, Extension, ComponentRender, FocusOnArgs, EdgeAttribute, EdgeData, GraphConfigData, RegisterElementFn, RegisterConfig } from './type';
|
|
9
|
+
import { EdgeConfig, EdgeFilter, NodeConfig, NodeAttribute, Extension, ComponentRender, FocusOnArgs, EdgeAttribute, EdgeData, GraphConfigData, RegisterElementFn, RegisterConfig, ZoomParam, PointTuple } from './type';
|
|
10
10
|
import SnaplineModel from './model/SnaplineModel';
|
|
11
11
|
import { EditConfigInterface } from './model/EditConfigModel';
|
|
12
12
|
declare type GraphConfigModel = {
|
|
@@ -35,7 +35,8 @@ export default class LogicFlow {
|
|
|
35
35
|
constructor(options: Options.Definition);
|
|
36
36
|
on(evt: string, callback: CallbackType): void;
|
|
37
37
|
off(evt: string, callback: CallbackType): void;
|
|
38
|
-
|
|
38
|
+
once(evt: string, callback: CallbackType): void;
|
|
39
|
+
emit(evt: string, arg: any): void;
|
|
39
40
|
/**
|
|
40
41
|
* 添加扩展, 待讨论,这里是不是静态方法好一些?
|
|
41
42
|
* 重复添加插件的时候,把上一次添加的插件的销毁。
|
|
@@ -51,10 +52,11 @@ export default class LogicFlow {
|
|
|
51
52
|
redo(): void;
|
|
52
53
|
/**
|
|
53
54
|
* 放大缩小图形
|
|
54
|
-
*
|
|
55
|
+
* @param zoomSize 放大缩小的值,支持传入0-n之间的数字。小于1表示缩小,大于1表示放大。也支持传入true和false按照内置的刻度放大缩小
|
|
56
|
+
* @param point 缩放的原点
|
|
55
57
|
* @returns {string} -放大缩小的比例
|
|
56
58
|
*/
|
|
57
|
-
zoom(
|
|
59
|
+
zoom(zoomSize?: ZoomParam, point?: PointTuple): string;
|
|
58
60
|
/**
|
|
59
61
|
* 还原图形
|
|
60
62
|
*/
|
|
@@ -111,6 +113,11 @@ export default class LogicFlow {
|
|
|
111
113
|
* @param value 文案内容
|
|
112
114
|
*/
|
|
113
115
|
updateText(id: string, value: string): void;
|
|
116
|
+
/**
|
|
117
|
+
* 删除元素,在不确定当前id是节点还是连线时使用
|
|
118
|
+
* @param id 元素id
|
|
119
|
+
*/
|
|
120
|
+
deleteElement(id: any): boolean;
|
|
114
121
|
/**
|
|
115
122
|
* 修改指定节点类型
|
|
116
123
|
* @param id 节点id
|
|
@@ -132,7 +139,7 @@ export default class LogicFlow {
|
|
|
132
139
|
* 删除节点
|
|
133
140
|
* @param {string} nodeId 节点Id
|
|
134
141
|
*/
|
|
135
|
-
deleteNode(nodeId: string):
|
|
142
|
+
deleteNode(nodeId: string): boolean;
|
|
136
143
|
/**
|
|
137
144
|
* 显示节点文本编辑框
|
|
138
145
|
* @param nodeId 节点id
|
|
@@ -148,20 +155,44 @@ export default class LogicFlow {
|
|
|
148
155
|
* 删除边
|
|
149
156
|
* @param {string} edgeId 边Id
|
|
150
157
|
*/
|
|
151
|
-
deleteEdge(edgeId: string):
|
|
158
|
+
deleteEdge(edgeId: string): boolean;
|
|
159
|
+
/**
|
|
160
|
+
* 删除指定类型的边
|
|
161
|
+
* todo: API一致
|
|
162
|
+
* @param config.sourceNodeId 边的起点节点ID
|
|
163
|
+
* @param config.targetNodeId 边的终点节点ID
|
|
164
|
+
*/
|
|
152
165
|
removeEdge(config: {
|
|
153
166
|
sourceNodeId: string;
|
|
154
167
|
targetNodeId: string;
|
|
155
168
|
}): void;
|
|
156
|
-
getEdge(config: EdgeFilter): _Model.BaseEdgeModel[];
|
|
157
169
|
/**
|
|
158
170
|
* 获取节点对象
|
|
159
171
|
* @param nodeId 节点Id
|
|
160
172
|
*/
|
|
161
173
|
getNodeModel(nodeId: string): _Model.BaseNodeModel;
|
|
162
174
|
getNodeData(nodeId: string): NodeAttribute;
|
|
175
|
+
/**
|
|
176
|
+
* 设置节点数据
|
|
177
|
+
* @deprecated 不建议直接设置节点数据,更新文本请用updateText, 修改数据请用setProperties
|
|
178
|
+
*/
|
|
163
179
|
setNodeData(nodeAttribute: NodeAttribute): void;
|
|
180
|
+
getEdgeModel(config: EdgeFilter): _Model.BaseEdgeModel[];
|
|
181
|
+
/**
|
|
182
|
+
* 获取边的model
|
|
183
|
+
* @param edgeId 边的Id
|
|
184
|
+
*/
|
|
185
|
+
getEdgeModelById(edgeId: string): _Model.BaseEdgeModel;
|
|
186
|
+
/**
|
|
187
|
+
* 获取边Model
|
|
188
|
+
* @deprecated 不建议使用getEdge, 建议使用getEdgeModel
|
|
189
|
+
*/
|
|
190
|
+
getEdge(config: EdgeFilter): _Model.BaseEdgeModel[];
|
|
164
191
|
getEdgeData(edgeId: string): EdgeData;
|
|
192
|
+
/**
|
|
193
|
+
* 设置边数据
|
|
194
|
+
* @deprecated 不建议直接设置边数据,更新文本请用updateText, 修改数据请用setProperties
|
|
195
|
+
*/
|
|
165
196
|
setEdgeData(edgeAttribute: EdgeAttribute): void;
|
|
166
197
|
/**
|
|
167
198
|
* 获取流程绘图数据
|
|
@@ -171,10 +202,7 @@ export default class LogicFlow {
|
|
|
171
202
|
* 获取流程绘图原始数据
|
|
172
203
|
* 在存在adapter时,可以使用getGraphRawData获取图原始数据
|
|
173
204
|
*/
|
|
174
|
-
getGraphRawData():
|
|
175
|
-
nodes: import("./type").NodeData[];
|
|
176
|
-
edges: EdgeData[];
|
|
177
|
-
};
|
|
205
|
+
getGraphRawData(): GraphConfigData;
|
|
178
206
|
/**
|
|
179
207
|
* 设置元素的自定义属性
|
|
180
208
|
* @param id 元素的id
|
|
@@ -187,6 +215,20 @@ export default class LogicFlow {
|
|
|
187
215
|
* @returns 自定义属性
|
|
188
216
|
*/
|
|
189
217
|
getProperties(id: string): Object;
|
|
218
|
+
/**
|
|
219
|
+
* 修改节点的id, 如果不传新的id,会内部自动创建一个。
|
|
220
|
+
* @param { string } oldId 将要被修改的id
|
|
221
|
+
* @param { string } newId 可选,修改后的id
|
|
222
|
+
* @returns 修改后的节点id
|
|
223
|
+
*/
|
|
224
|
+
changeNodeId<T extends string>(oldId: string, newId?: T): false | T | string;
|
|
225
|
+
/**
|
|
226
|
+
* 修改连线的id, 如果不传新的id,会内部自动创建一个。
|
|
227
|
+
* @param { string } oldId 将要被修改的id
|
|
228
|
+
* @param { string } newId 可选,修改后的id
|
|
229
|
+
* @returns 修改后的节点id
|
|
230
|
+
*/
|
|
231
|
+
changeEdgeId<T extends string>(oldId: string, newId?: T): false | T | string;
|
|
190
232
|
/**
|
|
191
233
|
* 更新流程图编辑相关设置
|
|
192
234
|
*/
|
|
@@ -218,13 +260,21 @@ export default class LogicFlow {
|
|
|
218
260
|
* @param isIgnoreCheck 是否包括sourceNode和targetNode没有被选中的连线,默认包括。
|
|
219
261
|
* 复制的时候不能包括此类连线, 因为复制的时候不允许悬空的连线。
|
|
220
262
|
*/
|
|
221
|
-
getSelectElements(isIgnoreCheck?: boolean):
|
|
263
|
+
getSelectElements(isIgnoreCheck?: boolean): GraphConfigData;
|
|
222
264
|
/**
|
|
223
265
|
* 动态修改 id 对应元素 model 中的属性
|
|
224
266
|
* @param {string} id 元素id
|
|
225
267
|
* @param {object} attributes 需要更新的属性
|
|
226
268
|
*/
|
|
227
269
|
updateAttributes(id: string, attributes: object): void;
|
|
270
|
+
/**
|
|
271
|
+
* 清空画布
|
|
272
|
+
*/
|
|
273
|
+
clearData(): void;
|
|
274
|
+
/**
|
|
275
|
+
* 设置元素的层级高度,在元素重叠的时候大的在前面
|
|
276
|
+
*/
|
|
277
|
+
setElementZIndex(id: any, zIndex: number | 'top' | 'bottom'): void;
|
|
228
278
|
/**
|
|
229
279
|
* 添加多个元素, 包括连线和节点。
|
|
230
280
|
*/
|
|
@@ -238,14 +288,8 @@ export default class LogicFlow {
|
|
|
238
288
|
* @param leftTopPoint 区域左上角坐标, dom层坐标
|
|
239
289
|
* @param rightBottomPoint 区域右下角坐标,dom层坐标
|
|
240
290
|
*/
|
|
241
|
-
getAreaElement(leftTopPoint:
|
|
291
|
+
getAreaElement(leftTopPoint: PointTuple, rightBottomPoint: PointTuple): any[];
|
|
242
292
|
removeNodeSnapLine(): void;
|
|
243
|
-
clearData(): void;
|
|
244
|
-
/**
|
|
245
|
-
* 获取边的model
|
|
246
|
-
* @param edgeId 边的Id
|
|
247
|
-
*/
|
|
248
|
-
getEdgeModelById(edgeId: string): _Model.BaseEdgeModel;
|
|
249
293
|
setView(type: string, component: any): void;
|
|
250
294
|
getView: (type: string) => any;
|
|
251
295
|
render(graphData?: {}): void;
|
|
@@ -87,6 +87,9 @@ export declare const defaultTheme: {
|
|
|
87
87
|
fontFamily: string;
|
|
88
88
|
};
|
|
89
89
|
nodeText: {
|
|
90
|
+
autoWrap: boolean;
|
|
91
|
+
lineHeight: number;
|
|
92
|
+
wrapPadding: string;
|
|
90
93
|
color: string;
|
|
91
94
|
fontSize: number;
|
|
92
95
|
fontWeight: string;
|
|
@@ -104,6 +107,9 @@ export declare const defaultTheme: {
|
|
|
104
107
|
radius: number;
|
|
105
108
|
};
|
|
106
109
|
hoverBackground: any;
|
|
110
|
+
autoWrap: boolean;
|
|
111
|
+
lineHeight: number;
|
|
112
|
+
wrapPadding: string;
|
|
107
113
|
};
|
|
108
114
|
line: {
|
|
109
115
|
stroke: string;
|
|
@@ -158,4 +164,10 @@ export declare const defaultTheme: {
|
|
|
158
164
|
stroke: string;
|
|
159
165
|
strokeWidth: number;
|
|
160
166
|
};
|
|
167
|
+
edgeAdjust: {
|
|
168
|
+
r: number;
|
|
169
|
+
fill: string;
|
|
170
|
+
stroke: string;
|
|
171
|
+
strokeWidth: string;
|
|
172
|
+
};
|
|
161
173
|
};
|
|
@@ -18,6 +18,7 @@ export declare enum ModelType {
|
|
|
18
18
|
TEXT_NODE = "text-node",
|
|
19
19
|
ELLIPSE_NODE = "ellipse-node",
|
|
20
20
|
DIAMOND_NODE = "diamond-node",
|
|
21
|
+
HTML_NODE = "html-node",
|
|
21
22
|
EDGE = "edge",
|
|
22
23
|
LINE_EDGE = "line-edge",
|
|
23
24
|
POLYLINE_EDGE = "polyline-edge",
|
|
@@ -36,6 +37,7 @@ export declare enum EventType {
|
|
|
36
37
|
NODE_DELETE = "node:delete",
|
|
37
38
|
NODE_ADD = "node:add",
|
|
38
39
|
NODE_DND_ADD = "node:dnd-add",
|
|
40
|
+
NODE_DND_DRAG = "node:dnd-drag",
|
|
39
41
|
NODE_MOUSEDOWN = "node:mousedown",
|
|
40
42
|
NODE_DRAGSTART = "node:dragstart",
|
|
41
43
|
NODE_DRAG = "node:drag",
|
|
@@ -52,6 +54,9 @@ export declare enum EventType {
|
|
|
52
54
|
EDGE_MOUSEENTER = "edge:mouseenter",
|
|
53
55
|
EDGE_MOUSELEAVE = "edge:mouseleave",
|
|
54
56
|
EDGE_CONTEXTMENU = "edge:contextmenu",
|
|
57
|
+
EDGE_ADJUST = "edge:adjust",
|
|
58
|
+
EDGE_EXCHANGE_NODE = "edge:exchange-node",
|
|
59
|
+
SELECTION_CONTEXTMENU = "selection:contextmenu",
|
|
55
60
|
BLANK_MOUSEDOWN = "blank:mousedown",
|
|
56
61
|
BLANK_DRAGSTART = "blank:dragstart",
|
|
57
62
|
BLANK_DRAG = "blank:drag",
|
|
@@ -61,10 +66,16 @@ export declare enum EventType {
|
|
|
61
66
|
BLANK_CLICK = "blank:click",
|
|
62
67
|
BLANK_CONTEXTMENU = "blank:contextmenu",
|
|
63
68
|
CONNECTION_NOT_ALLOWED = "connection:not-allowed",
|
|
64
|
-
HISTORY_CHANGE = "history:change"
|
|
69
|
+
HISTORY_CHANGE = "history:change",
|
|
70
|
+
TEXT_UPDATE = "text:update",
|
|
71
|
+
GRAPH_TRANSFORM = "graph:transform"
|
|
65
72
|
}
|
|
66
73
|
export declare enum SegmentDirection {
|
|
67
74
|
HORIZONTAL = "horizontal",
|
|
68
75
|
VERTICAL = "vertical"
|
|
69
76
|
}
|
|
70
|
-
export declare const ElementMaxzIndex =
|
|
77
|
+
export declare const ElementMaxzIndex = 9999;
|
|
78
|
+
export declare enum OverlapMode {
|
|
79
|
+
DEFAULT = 0,
|
|
80
|
+
INCREASE = 1
|
|
81
|
+
}
|
|
@@ -9,28 +9,28 @@ export default class EventEmitter {
|
|
|
9
9
|
private _events;
|
|
10
10
|
/**
|
|
11
11
|
* 监听一个事件
|
|
12
|
-
* @param evt
|
|
12
|
+
* @param evt 事件名称
|
|
13
13
|
* @param callback
|
|
14
14
|
* @param once
|
|
15
15
|
*/
|
|
16
16
|
on(evt: string, callback: CallbackType, once?: boolean): this;
|
|
17
17
|
/**
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
once(evt: string, callback: CallbackType):
|
|
18
|
+
* 监听一个事件一次
|
|
19
|
+
* @param evt
|
|
20
|
+
* @param callback
|
|
21
|
+
*/
|
|
22
|
+
once(evt: string, callback: CallbackType): void;
|
|
23
23
|
/**
|
|
24
24
|
* 触发一个事件
|
|
25
25
|
* @param evt
|
|
26
26
|
* @param args
|
|
27
27
|
*/
|
|
28
|
-
emit(
|
|
28
|
+
emit(evts: string, eventArgs: EventArgs): void;
|
|
29
29
|
/**
|
|
30
30
|
* 取消监听一个事件,或者一个channel
|
|
31
31
|
* @param evt
|
|
32
32
|
* @param callback
|
|
33
33
|
*/
|
|
34
|
-
off(
|
|
34
|
+
off(evts?: string, callback?: CallbackType): this;
|
|
35
35
|
getEvents(): Record<string, EventType[]>;
|
|
36
36
|
}
|
|
@@ -1,14 +1,73 @@
|
|
|
1
1
|
import { ElementState } from '../constant/constant';
|
|
2
2
|
import { TextConfig, AdditionData } from '../type';
|
|
3
3
|
interface IBaseModel {
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* 节点或者连线的id.
|
|
6
|
+
* 默认情况下,使用uuidv4生成。
|
|
7
|
+
* 如果想要自定义,可以重写createId生成。
|
|
8
|
+
*/
|
|
9
|
+
id: string;
|
|
10
|
+
/**
|
|
11
|
+
* 不可自定义
|
|
12
|
+
* model对应的图形外观类型(eg: 圆形、矩形、多边形等)
|
|
13
|
+
* 用于logicflow内部计算使用。
|
|
14
|
+
*/
|
|
5
15
|
modelType: string;
|
|
16
|
+
/**
|
|
17
|
+
* 请勿直接修改属性,如果想要将一个节点类型修改为另一个类型。请使用
|
|
18
|
+
* `lf.graphModel.changeEdgeType`和`lf.graphModel.changeNodeType`
|
|
19
|
+
*
|
|
20
|
+
* 流程图元素类型,自定义元素时对应的标识。
|
|
21
|
+
* 在logicflow/core中对应着rect、circle、polyline这种。
|
|
22
|
+
* 在实际项目中,我们会基于业务类型进行自定义type.
|
|
23
|
+
* 例如BPMN应用场景,我们会定义开始节点的类型为bpmn:start-event
|
|
24
|
+
*
|
|
25
|
+
* 和modelType的区别是,type更多的是业务上的类型,而modelType则是外观上的类型。
|
|
26
|
+
* 例如bpmnjs的开始节点和结束节点type分别为'bpmn:start-event'和'bpmn:end-event'。
|
|
27
|
+
* 但是他们的modelType都是circle-node, 因为他们外观都是基于圆形自定义而来。
|
|
28
|
+
*/
|
|
6
29
|
type: string;
|
|
30
|
+
/**
|
|
31
|
+
* 元素状态
|
|
32
|
+
* 不同的状态对应着元素显示效果。
|
|
33
|
+
* 请勿直接修改。
|
|
34
|
+
* logicflow内部将元素状态分为5种:
|
|
35
|
+
* DEFAULT = 1 默认显示
|
|
36
|
+
* TEXT_EDIT = 2 此元素正在进行文本编辑
|
|
37
|
+
* SHOW_MENU = 3, 显示菜单,废弃请使用菜单插件
|
|
38
|
+
* ALLOW_CONNECT = 4, 此元素允许作为当前连线的目标节点
|
|
39
|
+
* NOT_ALLOW_CONNECT = 5, 此元素不允许作为当前连线的目标节点
|
|
40
|
+
*/
|
|
7
41
|
state: ElementState;
|
|
8
42
|
additionStateData: AdditionData;
|
|
43
|
+
/**
|
|
44
|
+
* 元素上的文本
|
|
45
|
+
* logicflow中存在两种文本
|
|
46
|
+
* 一种是脱离连线和节点单独存在的文本
|
|
47
|
+
* 一种是必须和连线、节点关联的文本。
|
|
48
|
+
* 此属性控制的是第二种。
|
|
49
|
+
* 节点和连线删除、调整的时候,其关联的文本也会对应删除、调整。
|
|
50
|
+
*/
|
|
9
51
|
text: TextConfig;
|
|
52
|
+
/**
|
|
53
|
+
* 元素是否被选中
|
|
54
|
+
*/
|
|
10
55
|
isSelected: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* 元素堆叠是层级,默认情况下节点zIndex值为1,连线zIndex为0。
|
|
58
|
+
* todo:写完善
|
|
59
|
+
*/
|
|
11
60
|
zIndex: number;
|
|
61
|
+
/**
|
|
62
|
+
* 创建节点ID
|
|
63
|
+
* 默认情况下,logicflow内部使用uuidv4生成id。
|
|
64
|
+
* 在自定义节点的时候,可以重写此方法基于自己的规则生成id。
|
|
65
|
+
* 注意,此方法必须是同步的。
|
|
66
|
+
* 如果想要异步修改Id,建议删除此节点后再同一位置创建一个新的节点。
|
|
67
|
+
* @overridable 可以重写
|
|
68
|
+
* @returns string
|
|
69
|
+
*/
|
|
70
|
+
createId(): string;
|
|
12
71
|
move(deltaX: number, deltaY: number): void;
|
|
13
72
|
moveText(deltaX: number, deltaY: number): void;
|
|
14
73
|
updateText(value: string): void;
|