@logicflow/core 0.3.6 → 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 +22 -7
- package/types/LogicFlow.d.ts +74 -47
- 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/index.d.ts +5 -1
- 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 +23 -13
- 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 +80 -10
- 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 +87 -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/index.d.ts +2 -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 +3 -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 +13 -8
- 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/types/view/overlay/OutlineOverlay.d.ts +1 -1
- package/CHANGELOG.md +0 -366
- 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.
|
|
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",
|
|
@@ -59,8 +74,8 @@
|
|
|
59
74
|
"ids": "^1.0.0",
|
|
60
75
|
"less-loader": "^6.0.0",
|
|
61
76
|
"lodash-es": "^4.17.15",
|
|
62
|
-
"mobx": "^
|
|
63
|
-
"mobx-react": "^
|
|
77
|
+
"mobx": "^4.15.7",
|
|
78
|
+
"mobx-react": "^5.4.4",
|
|
64
79
|
"mobx-utils": "^5.6.1",
|
|
65
80
|
"prettier": "^2.2.1",
|
|
66
81
|
"rimraf": "^3.0.2",
|
|
@@ -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
|
@@ -1,35 +1,17 @@
|
|
|
1
|
-
import { h } from 'preact';
|
|
2
1
|
import GraphModel from './model/GraphModel';
|
|
3
|
-
import BaseNodeModel from './model/node/BaseNodeModel';
|
|
4
|
-
import BaseNode from './view/node/BaseNode';
|
|
5
|
-
import RectNodeModel from './model/node/RectNodeModel';
|
|
6
|
-
import RectNode from './view/node/RectNode';
|
|
7
|
-
import CircleNodeModel from './model/node/CircleNodeModel';
|
|
8
|
-
import CircleNode from './view/node/CircleNode';
|
|
9
|
-
import PolygonNodeModel from './model/node/PolygonNodeModel';
|
|
10
|
-
import PolygonNode from './view/node/PolygonNode';
|
|
11
|
-
import TextNodeModel from './model/node/TextNodeModel';
|
|
12
|
-
import TextNode from './view/node/TextNode';
|
|
13
|
-
import BaseEdgeModel from './model/edge/BaseEdgeModel';
|
|
14
|
-
import BaseEdge from './view/edge/BaseEdge';
|
|
15
|
-
import LineEdgeModel from './model/edge/LineEdgeModel';
|
|
16
|
-
import LineEdge from './view/edge/LineEdge';
|
|
17
|
-
import PolylineEdgeModel from './model/edge/PolylineEdgeModel';
|
|
18
|
-
import PolylineEdge from './view/edge/PolylineEdge';
|
|
19
2
|
import Dnd from './view/behavior/DnD';
|
|
20
|
-
import EllipseNode from './view/node/EllipseNode';
|
|
21
|
-
import EllipseNodeModel from './model/node/EllipseNodeModel';
|
|
22
3
|
import * as Options from './options';
|
|
4
|
+
import * as _Model from './model';
|
|
23
5
|
import History from './history/History';
|
|
24
6
|
import Tool from './tool';
|
|
25
7
|
import EventEmitter, { CallbackType } from './event/eventEmitter';
|
|
26
8
|
import Keyboard from './keyboard';
|
|
27
|
-
import { EdgeConfig, EdgeFilter, NodeConfig, NodeAttribute, Extension, ComponentRender, FocusOnArgs,
|
|
9
|
+
import { EdgeConfig, EdgeFilter, NodeConfig, NodeAttribute, Extension, ComponentRender, FocusOnArgs, EdgeAttribute, EdgeData, GraphConfigData, RegisterElementFn, RegisterConfig, ZoomParam, PointTuple } from './type';
|
|
28
10
|
import SnaplineModel from './model/SnaplineModel';
|
|
29
11
|
import { EditConfigInterface } from './model/EditConfigModel';
|
|
30
12
|
declare type GraphConfigModel = {
|
|
31
|
-
nodes: BaseNodeModel[];
|
|
32
|
-
edges: BaseEdgeModel[];
|
|
13
|
+
nodes: _Model.BaseNodeModel[];
|
|
14
|
+
edges: _Model.BaseEdgeModel[];
|
|
33
15
|
};
|
|
34
16
|
export default class LogicFlow {
|
|
35
17
|
container: HTMLElement;
|
|
@@ -53,7 +35,8 @@ export default class LogicFlow {
|
|
|
53
35
|
constructor(options: Options.Definition);
|
|
54
36
|
on(evt: string, callback: CallbackType): void;
|
|
55
37
|
off(evt: string, callback: CallbackType): void;
|
|
56
|
-
|
|
38
|
+
once(evt: string, callback: CallbackType): void;
|
|
39
|
+
emit(evt: string, arg: any): void;
|
|
57
40
|
/**
|
|
58
41
|
* 添加扩展, 待讨论,这里是不是静态方法好一些?
|
|
59
42
|
* 重复添加插件的时候,把上一次添加的插件的销毁。
|
|
@@ -62,16 +45,18 @@ export default class LogicFlow {
|
|
|
62
45
|
static use(extension: Extension): void;
|
|
63
46
|
installPlugins(disabledPlugins?: any[]): void;
|
|
64
47
|
__installPlugin(extension: any): void;
|
|
65
|
-
register(type: string, fn
|
|
48
|
+
register(type: string | RegisterConfig, fn?: RegisterElementFn, isObserverView?: boolean): void;
|
|
49
|
+
_registerElement(config: any): void;
|
|
66
50
|
defaultRegister(): void;
|
|
67
51
|
undo(): void;
|
|
68
52
|
redo(): void;
|
|
69
53
|
/**
|
|
70
54
|
* 放大缩小图形
|
|
71
|
-
*
|
|
55
|
+
* @param zoomSize 放大缩小的值,支持传入0-n之间的数字。小于1表示缩小,大于1表示放大。也支持传入true和false按照内置的刻度放大缩小
|
|
56
|
+
* @param point 缩放的原点
|
|
72
57
|
* @returns {string} -放大缩小的比例
|
|
73
58
|
*/
|
|
74
|
-
zoom(
|
|
59
|
+
zoom(zoomSize?: ZoomParam, point?: PointTuple): string;
|
|
75
60
|
/**
|
|
76
61
|
* 还原图形
|
|
77
62
|
*/
|
|
@@ -128,6 +113,11 @@ export default class LogicFlow {
|
|
|
128
113
|
* @param value 文案内容
|
|
129
114
|
*/
|
|
130
115
|
updateText(id: string, value: string): void;
|
|
116
|
+
/**
|
|
117
|
+
* 删除元素,在不确定当前id是节点还是连线时使用
|
|
118
|
+
* @param id 元素id
|
|
119
|
+
*/
|
|
120
|
+
deleteElement(id: any): boolean;
|
|
131
121
|
/**
|
|
132
122
|
* 修改指定节点类型
|
|
133
123
|
* @param id 节点id
|
|
@@ -139,17 +129,17 @@ export default class LogicFlow {
|
|
|
139
129
|
* @param nodeId 节点ID
|
|
140
130
|
* @returns model数组
|
|
141
131
|
*/
|
|
142
|
-
getNodeEdges(nodeId: any): BaseEdgeModel[];
|
|
132
|
+
getNodeEdges(nodeId: any): _Model.BaseEdgeModel[];
|
|
143
133
|
/**
|
|
144
134
|
* 添加节点
|
|
145
135
|
* @param nodeConfig 节点配置
|
|
146
136
|
*/
|
|
147
|
-
addNode(nodeConfig: NodeConfig): BaseNodeModel;
|
|
137
|
+
addNode(nodeConfig: NodeConfig): _Model.BaseNodeModel;
|
|
148
138
|
/**
|
|
149
139
|
* 删除节点
|
|
150
140
|
* @param {string} nodeId 节点Id
|
|
151
141
|
*/
|
|
152
|
-
deleteNode(nodeId: string):
|
|
142
|
+
deleteNode(nodeId: string): boolean;
|
|
153
143
|
/**
|
|
154
144
|
* 显示节点文本编辑框
|
|
155
145
|
* @param nodeId 节点id
|
|
@@ -159,26 +149,50 @@ export default class LogicFlow {
|
|
|
159
149
|
* 克隆节点
|
|
160
150
|
* @param nodeId 节点Id
|
|
161
151
|
*/
|
|
162
|
-
cloneNode(nodeId: string): BaseNodeModel;
|
|
152
|
+
cloneNode(nodeId: string): _Model.BaseNodeModel;
|
|
163
153
|
createEdge(edgeConfig: EdgeConfig): void;
|
|
164
154
|
/**
|
|
165
155
|
* 删除边
|
|
166
156
|
* @param {string} edgeId 边Id
|
|
167
157
|
*/
|
|
168
|
-
deleteEdge(edgeId: string):
|
|
158
|
+
deleteEdge(edgeId: string): boolean;
|
|
159
|
+
/**
|
|
160
|
+
* 删除指定类型的边
|
|
161
|
+
* todo: API一致
|
|
162
|
+
* @param config.sourceNodeId 边的起点节点ID
|
|
163
|
+
* @param config.targetNodeId 边的终点节点ID
|
|
164
|
+
*/
|
|
169
165
|
removeEdge(config: {
|
|
170
166
|
sourceNodeId: string;
|
|
171
167
|
targetNodeId: string;
|
|
172
168
|
}): void;
|
|
173
|
-
getEdge(config: EdgeFilter): BaseEdgeModel[];
|
|
174
169
|
/**
|
|
175
170
|
* 获取节点对象
|
|
176
171
|
* @param nodeId 节点Id
|
|
177
172
|
*/
|
|
178
|
-
getNodeModel(nodeId: string): BaseNodeModel;
|
|
173
|
+
getNodeModel(nodeId: string): _Model.BaseNodeModel;
|
|
179
174
|
getNodeData(nodeId: string): NodeAttribute;
|
|
175
|
+
/**
|
|
176
|
+
* 设置节点数据
|
|
177
|
+
* @deprecated 不建议直接设置节点数据,更新文本请用updateText, 修改数据请用setProperties
|
|
178
|
+
*/
|
|
180
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[];
|
|
181
191
|
getEdgeData(edgeId: string): EdgeData;
|
|
192
|
+
/**
|
|
193
|
+
* 设置边数据
|
|
194
|
+
* @deprecated 不建议直接设置边数据,更新文本请用updateText, 修改数据请用setProperties
|
|
195
|
+
*/
|
|
182
196
|
setEdgeData(edgeAttribute: EdgeAttribute): void;
|
|
183
197
|
/**
|
|
184
198
|
* 获取流程绘图数据
|
|
@@ -188,10 +202,7 @@ export default class LogicFlow {
|
|
|
188
202
|
* 获取流程绘图原始数据
|
|
189
203
|
* 在存在adapter时,可以使用getGraphRawData获取图原始数据
|
|
190
204
|
*/
|
|
191
|
-
getGraphRawData():
|
|
192
|
-
nodes: import("./type").NodeData[];
|
|
193
|
-
edges: EdgeData[];
|
|
194
|
-
};
|
|
205
|
+
getGraphRawData(): GraphConfigData;
|
|
195
206
|
/**
|
|
196
207
|
* 设置元素的自定义属性
|
|
197
208
|
* @param id 元素的id
|
|
@@ -204,6 +215,20 @@ export default class LogicFlow {
|
|
|
204
215
|
* @returns 自定义属性
|
|
205
216
|
*/
|
|
206
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;
|
|
207
232
|
/**
|
|
208
233
|
* 更新流程图编辑相关设置
|
|
209
234
|
*/
|
|
@@ -211,7 +236,7 @@ export default class LogicFlow {
|
|
|
211
236
|
/**
|
|
212
237
|
* 获取流程图编辑相关设置
|
|
213
238
|
*/
|
|
214
|
-
getEditConfig(): Partial<
|
|
239
|
+
getEditConfig(): Partial<_Model.EditConfigModel>;
|
|
215
240
|
/**
|
|
216
241
|
* 获取事件位置相对于画布左上角的坐标
|
|
217
242
|
* @param {number} x 事件x坐标
|
|
@@ -235,13 +260,21 @@ export default class LogicFlow {
|
|
|
235
260
|
* @param isIgnoreCheck 是否包括sourceNode和targetNode没有被选中的连线,默认包括。
|
|
236
261
|
* 复制的时候不能包括此类连线, 因为复制的时候不允许悬空的连线。
|
|
237
262
|
*/
|
|
238
|
-
getSelectElements(isIgnoreCheck?: boolean):
|
|
263
|
+
getSelectElements(isIgnoreCheck?: boolean): GraphConfigData;
|
|
239
264
|
/**
|
|
240
265
|
* 动态修改 id 对应元素 model 中的属性
|
|
241
266
|
* @param {string} id 元素id
|
|
242
267
|
* @param {object} attributes 需要更新的属性
|
|
243
268
|
*/
|
|
244
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;
|
|
245
278
|
/**
|
|
246
279
|
* 添加多个元素, 包括连线和节点。
|
|
247
280
|
*/
|
|
@@ -255,16 +288,10 @@ export default class LogicFlow {
|
|
|
255
288
|
* @param leftTopPoint 区域左上角坐标, dom层坐标
|
|
256
289
|
* @param rightBottomPoint 区域右下角坐标,dom层坐标
|
|
257
290
|
*/
|
|
258
|
-
getAreaElement(leftTopPoint:
|
|
291
|
+
getAreaElement(leftTopPoint: PointTuple, rightBottomPoint: PointTuple): any[];
|
|
259
292
|
removeNodeSnapLine(): void;
|
|
260
|
-
clearData(): void;
|
|
261
|
-
/**
|
|
262
|
-
* 获取边的model
|
|
263
|
-
* @param edgeId 边的Id
|
|
264
|
-
*/
|
|
265
|
-
getEdgeModelById(edgeId: string): BaseEdgeModel;
|
|
266
293
|
setView(type: string, component: any): void;
|
|
267
294
|
getView: (type: string) => any;
|
|
268
295
|
render(graphData?: {}): void;
|
|
269
296
|
}
|
|
270
|
-
export {
|
|
297
|
+
export {};
|
|
@@ -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
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
import { h } from 'preact';
|
|
1
2
|
import LogicFlow from './LogicFlow';
|
|
3
|
+
import * as LogicFlowUtil from './util';
|
|
2
4
|
export declare function observer<P>(props: P): any;
|
|
3
|
-
export { LogicFlow, };
|
|
5
|
+
export { LogicFlow, h };
|
|
6
|
+
export { LogicFlowUtil };
|
|
4
7
|
export * from './type/index';
|
|
8
|
+
export * from './view';
|
|
5
9
|
export * from './model';
|
|
6
10
|
export * from './keyboard';
|
|
7
11
|
export * from './options';
|