@logicflow/core 0.7.4 → 0.7.8
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/CHANGELOG.md +42 -0
- package/README.md +171 -0
- package/dist/logic-flow.js +2 -2
- package/dist/style/index.css +19 -1
- package/package.json +14 -3
- package/types/LogicFlow.d.ts +25 -16
- package/types/event/eventEmitter.d.ts +7 -7
- package/types/model/GraphModel.d.ts +4 -3
- package/types/model/TransformModel.d.ts +12 -3
- package/types/model/node/BaseNodeModel.d.ts +1 -1
- package/types/type/index.d.ts +2 -1
- package/types/view/overlay/CanvasOverlay.d.ts +30 -2
- package/types/view/overlay/HtmlOverlay.d.ts +5 -46
- package/types/view/overlay/ModificationOverlay.d.ts +9 -0
package/dist/style/index.css
CHANGED
|
@@ -120,13 +120,31 @@
|
|
|
120
120
|
left: 0;
|
|
121
121
|
right: 0;
|
|
122
122
|
bottom: 0;
|
|
123
|
-
z-index:
|
|
123
|
+
z-index: 2;
|
|
124
124
|
pointer-events: none;
|
|
125
125
|
overflow: hidden;
|
|
126
126
|
}
|
|
127
127
|
.lf-tool-overlay > * {
|
|
128
128
|
pointer-events: all;
|
|
129
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
|
+
}
|
|
130
148
|
|
|
131
149
|
.lf-keyboard-tips {
|
|
132
150
|
float: right;
|
package/package.json
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@logicflow/core",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.8",
|
|
4
4
|
"description": "LogicFlow core, to quickly build flowchart editor",
|
|
5
5
|
"main": "dist/logic-flow.js",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
|
+
"homepage": "http://logic-flow.org/",
|
|
7
8
|
"types": "types/index.d.ts",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/didi/LogicFlow",
|
|
12
|
+
"directory": "packages/core"
|
|
13
|
+
},
|
|
8
14
|
"scripts": {
|
|
9
15
|
"dev": "cross-env NODE_ENV=development webpack-dev-server --client-log-level warning --config scripts/webpack.config.dev.js",
|
|
10
16
|
"clean": "rimraf dist lib esm cjs",
|
|
@@ -18,13 +24,18 @@
|
|
|
18
24
|
},
|
|
19
25
|
"files": [
|
|
20
26
|
"dist",
|
|
21
|
-
"types"
|
|
27
|
+
"types",
|
|
28
|
+
"README.md"
|
|
22
29
|
],
|
|
23
30
|
"dependencies": {
|
|
24
31
|
"@types/mousetrap": "^1.6.4",
|
|
25
32
|
"mousetrap": "^1.6.5",
|
|
26
33
|
"preact": "^10.4.8"
|
|
27
34
|
},
|
|
35
|
+
"keywords": [
|
|
36
|
+
"flowchart",
|
|
37
|
+
"diagram"
|
|
38
|
+
],
|
|
28
39
|
"devDependencies": {
|
|
29
40
|
"@babel/core": "^7.9.0",
|
|
30
41
|
"@babel/plugin-proposal-class-properties": "^7.8.3",
|
|
@@ -81,5 +92,5 @@
|
|
|
81
92
|
"last 2 versions",
|
|
82
93
|
"not ie <= 11"
|
|
83
94
|
],
|
|
84
|
-
"gitHead": "
|
|
95
|
+
"gitHead": "4740088e9abbb943a8046c4030f21a5751050833"
|
|
85
96
|
}
|
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 = {
|
|
@@ -52,10 +52,11 @@ export default class LogicFlow {
|
|
|
52
52
|
redo(): void;
|
|
53
53
|
/**
|
|
54
54
|
* 放大缩小图形
|
|
55
|
-
*
|
|
55
|
+
* @param zoomSize 放大缩小的值,支持传入0-n之间的数字。小于1表示缩小,大于1表示放大。也支持传入true和false按照内置的刻度放大缩小
|
|
56
|
+
* @param point 缩放的原点
|
|
56
57
|
* @returns {string} -放大缩小的比例
|
|
57
58
|
*/
|
|
58
|
-
zoom(
|
|
59
|
+
zoom(zoomSize?: ZoomParam, point?: PointTuple): string;
|
|
59
60
|
/**
|
|
60
61
|
* 还原图形
|
|
61
62
|
*/
|
|
@@ -74,10 +75,10 @@ export default class LogicFlow {
|
|
|
74
75
|
* 获取缩放的值和平移的值。
|
|
75
76
|
*/
|
|
76
77
|
getTransform(): {
|
|
77
|
-
SCALE_X:
|
|
78
|
-
SCALE_Y:
|
|
79
|
-
TRANSLATE_X:
|
|
80
|
-
TRANSLATE_Y:
|
|
78
|
+
SCALE_X: number;
|
|
79
|
+
SCALE_Y: number;
|
|
80
|
+
TRANSLATE_X: number;
|
|
81
|
+
TRANSLATE_Y: number;
|
|
81
82
|
};
|
|
82
83
|
/**
|
|
83
84
|
* 平移图形
|
|
@@ -112,6 +113,11 @@ export default class LogicFlow {
|
|
|
112
113
|
* @param value 文案内容
|
|
113
114
|
*/
|
|
114
115
|
updateText(id: string, value: string): void;
|
|
116
|
+
/**
|
|
117
|
+
* 删除元素,在不确定当前id是节点还是连线时使用
|
|
118
|
+
* @param id 元素id
|
|
119
|
+
*/
|
|
120
|
+
deleteElement(id: any): boolean;
|
|
115
121
|
/**
|
|
116
122
|
* 修改指定节点类型
|
|
117
123
|
* @param id 节点id
|
|
@@ -133,7 +139,7 @@ export default class LogicFlow {
|
|
|
133
139
|
* 删除节点
|
|
134
140
|
* @param {string} nodeId 节点Id
|
|
135
141
|
*/
|
|
136
|
-
deleteNode(nodeId: string):
|
|
142
|
+
deleteNode(nodeId: string): boolean;
|
|
137
143
|
/**
|
|
138
144
|
* 显示节点文本编辑框
|
|
139
145
|
* @param nodeId 节点id
|
|
@@ -149,7 +155,13 @@ export default class LogicFlow {
|
|
|
149
155
|
* 删除边
|
|
150
156
|
* @param {string} edgeId 边Id
|
|
151
157
|
*/
|
|
152
|
-
deleteEdge(edgeId: string):
|
|
158
|
+
deleteEdge(edgeId: string): boolean;
|
|
159
|
+
/**
|
|
160
|
+
* 删除指定类型的边
|
|
161
|
+
* todo: API一致
|
|
162
|
+
* @param config.sourceNodeId 边的起点节点ID
|
|
163
|
+
* @param config.targetNodeId 边的终点节点ID
|
|
164
|
+
*/
|
|
153
165
|
removeEdge(config: {
|
|
154
166
|
sourceNodeId: string;
|
|
155
167
|
targetNodeId: string;
|
|
@@ -239,8 +251,8 @@ export default class LogicFlow {
|
|
|
239
251
|
y: number;
|
|
240
252
|
};
|
|
241
253
|
canvasOverlayPosition: {
|
|
242
|
-
x:
|
|
243
|
-
y:
|
|
254
|
+
x: number;
|
|
255
|
+
y: number;
|
|
244
256
|
};
|
|
245
257
|
};
|
|
246
258
|
/**
|
|
@@ -248,10 +260,7 @@ export default class LogicFlow {
|
|
|
248
260
|
* @param isIgnoreCheck 是否包括sourceNode和targetNode没有被选中的连线,默认包括。
|
|
249
261
|
* 复制的时候不能包括此类连线, 因为复制的时候不允许悬空的连线。
|
|
250
262
|
*/
|
|
251
|
-
getSelectElements(isIgnoreCheck?: boolean):
|
|
252
|
-
nodes: any[];
|
|
253
|
-
edges: any[];
|
|
254
|
-
};
|
|
263
|
+
getSelectElements(isIgnoreCheck?: boolean): GraphConfigData;
|
|
255
264
|
/**
|
|
256
265
|
* 动态修改 id 对应元素 model 中的属性
|
|
257
266
|
* @param {string} id 元素id
|
|
@@ -279,7 +288,7 @@ export default class LogicFlow {
|
|
|
279
288
|
* @param leftTopPoint 区域左上角坐标, dom层坐标
|
|
280
289
|
* @param rightBottomPoint 区域右下角坐标,dom层坐标
|
|
281
290
|
*/
|
|
282
|
-
getAreaElement(leftTopPoint:
|
|
291
|
+
getAreaElement(leftTopPoint: PointTuple, rightBottomPoint: PointTuple): any[];
|
|
283
292
|
removeNodeSnapLine(): void;
|
|
284
293
|
setView(type: string, component: any): void;
|
|
285
294
|
getView: (type: string) => any;
|
|
@@ -15,22 +15,22 @@ export default class EventEmitter {
|
|
|
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,6 +1,7 @@
|
|
|
1
1
|
import BaseNodeModel from './node/BaseNodeModel';
|
|
2
2
|
import BaseEdgeModel from './edge/BaseEdgeModel';
|
|
3
3
|
import EditConfigModel from './EditConfigModel';
|
|
4
|
+
import TransfromModel from './TransformModel';
|
|
4
5
|
import { IBaseModel } from './BaseModel';
|
|
5
6
|
import { ElementState, ModelType, ElementType } from '../constant/constant';
|
|
6
7
|
import { AdditionData, Point, NodeConfig, EdgeConfig, Style, NodeMoveRule } from '../type';
|
|
@@ -32,7 +33,7 @@ declare class GraphModel {
|
|
|
32
33
|
plugins: any[];
|
|
33
34
|
tools: any[];
|
|
34
35
|
background: any;
|
|
35
|
-
transformMatrix:
|
|
36
|
+
transformMatrix: TransfromModel;
|
|
36
37
|
editConfig: EditConfigModel;
|
|
37
38
|
gridSize: number;
|
|
38
39
|
partial: boolean;
|
|
@@ -73,8 +74,8 @@ declare class GraphModel {
|
|
|
73
74
|
y: number;
|
|
74
75
|
};
|
|
75
76
|
canvasOverlayPosition: {
|
|
76
|
-
x:
|
|
77
|
-
y:
|
|
77
|
+
x: number;
|
|
78
|
+
y: number;
|
|
78
79
|
};
|
|
79
80
|
};
|
|
80
81
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import EventEmitter from '../event/eventEmitter';
|
|
2
|
-
import { PointTuple } from '../type';
|
|
2
|
+
import { PointTuple, ZoomParam } from '../type';
|
|
3
3
|
export interface TransfromInterface {
|
|
4
4
|
SCALE_X: number;
|
|
5
5
|
SKEW_Y: number;
|
|
@@ -10,10 +10,13 @@ export interface TransfromInterface {
|
|
|
10
10
|
ZOOM_SIZE: number;
|
|
11
11
|
MINI_SCALE_SIZE: number;
|
|
12
12
|
MAX_SCALE_SIZE: number;
|
|
13
|
-
zoom: (isZoomout:
|
|
13
|
+
zoom: (isZoomout: ZoomParam) => boolean;
|
|
14
14
|
HtmlPointToCanvasPoint: (point: PointTuple) => PointTuple;
|
|
15
15
|
CanvasPointToHtmlPoint: (point: PointTuple) => PointTuple;
|
|
16
16
|
moveCanvasPointByHtml: (point: PointTuple, x: number, y: number) => PointTuple;
|
|
17
|
+
getTransformStyle: () => {
|
|
18
|
+
transform: string;
|
|
19
|
+
};
|
|
17
20
|
}
|
|
18
21
|
export default class TransfromModel implements TransfromInterface {
|
|
19
22
|
MINI_SCALE_SIZE: number;
|
|
@@ -53,7 +56,13 @@ export default class TransfromModel implements TransfromInterface {
|
|
|
53
56
|
* @param deltaY y轴距离变化
|
|
54
57
|
*/
|
|
55
58
|
fixDeltaXY(deltaX: number, deltaY: number): PointTuple;
|
|
56
|
-
|
|
59
|
+
/**
|
|
60
|
+
* 基于当前的缩放,获取画布渲染样式transform值
|
|
61
|
+
*/
|
|
62
|
+
getTransformStyle(): {
|
|
63
|
+
transform: string;
|
|
64
|
+
};
|
|
65
|
+
zoom(zoomSize?: ZoomParam, point?: PointTuple): boolean;
|
|
57
66
|
private emitGraphTransform;
|
|
58
67
|
resetZoom(): void;
|
|
59
68
|
translate(x: number, y: number): void;
|
|
@@ -59,7 +59,7 @@ export default class BaseNodeModel implements IBaseModel {
|
|
|
59
59
|
draggable: boolean;
|
|
60
60
|
constructor(data: NodeConfig, graphModel: GraphModel, type: any);
|
|
61
61
|
initNodeData(data: any): void;
|
|
62
|
-
createId():
|
|
62
|
+
createId(): any;
|
|
63
63
|
formatText(data: any): void;
|
|
64
64
|
setAttributes(): void;
|
|
65
65
|
/**
|
package/types/type/index.d.ts
CHANGED
|
@@ -120,7 +120,7 @@ export declare type EdgeConfig = {
|
|
|
120
120
|
x: number;
|
|
121
121
|
y: number;
|
|
122
122
|
value: string;
|
|
123
|
-
};
|
|
123
|
+
} | string;
|
|
124
124
|
pointsList?: Point[];
|
|
125
125
|
zIndex?: number;
|
|
126
126
|
properties?: Record<string, unknown>;
|
|
@@ -352,4 +352,5 @@ export declare type AnchorConfig = {
|
|
|
352
352
|
* deltaY: 移动的y轴距离
|
|
353
353
|
*/
|
|
354
354
|
export declare type NodeMoveRule = (model: BaseNodeModel, deltaX: number, deltaY: number) => Boolean;
|
|
355
|
+
export declare type ZoomParam = boolean | number;
|
|
355
356
|
export {};
|
|
@@ -1,2 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { h, Component } from 'preact';
|
|
2
|
+
import GraphModel from '../../model/GraphModel';
|
|
3
|
+
import { StepDrag } from '../../util/drag';
|
|
4
|
+
import EventEmitter from '../../event/eventEmitter';
|
|
5
|
+
import Dnd from '../behavior/DnD';
|
|
6
|
+
declare type IProps = {
|
|
7
|
+
graphModel: GraphModel;
|
|
8
|
+
eventCenter: EventEmitter;
|
|
9
|
+
dnd: Dnd;
|
|
10
|
+
};
|
|
11
|
+
declare type Istate = {
|
|
12
|
+
isDraging: boolean;
|
|
13
|
+
};
|
|
14
|
+
declare class CanvasOverlay extends Component<IProps, Istate> {
|
|
15
|
+
stepDrag: StepDrag;
|
|
16
|
+
stepScrollX: number;
|
|
17
|
+
stepScrollY: number;
|
|
18
|
+
constructor(props: IProps);
|
|
19
|
+
onDraging: ({ deltaX, deltaY }: {
|
|
20
|
+
deltaX: any;
|
|
21
|
+
deltaY: any;
|
|
22
|
+
}) => void;
|
|
23
|
+
onDragEnd: () => void;
|
|
24
|
+
zoomHandler: (ev: WheelEvent) => void;
|
|
25
|
+
clickHandler: (ev: MouseEvent) => void;
|
|
26
|
+
handleContextMenu: (ev: MouseEvent) => void;
|
|
27
|
+
mouseDownHandler: (ev: MouseEvent) => void;
|
|
28
|
+
render(): h.JSX.Element;
|
|
29
|
+
}
|
|
30
|
+
export default CanvasOverlay;
|
|
@@ -4,53 +4,12 @@
|
|
|
4
4
|
* 目前这里可以放文本。
|
|
5
5
|
* 之后可以考虑放图片,范围框等。
|
|
6
6
|
*/
|
|
7
|
-
import { h } from 'preact';
|
|
7
|
+
import { h, Component } from 'preact';
|
|
8
8
|
import GraphModel from '../../model/GraphModel';
|
|
9
|
-
import { GraphTransform } from '../../type';
|
|
10
9
|
declare type IProps = {
|
|
11
10
|
graphModel: GraphModel;
|
|
12
11
|
};
|
|
13
|
-
declare
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
getMatrixString(): GraphTransform;
|
|
18
|
-
render(): h.JSX.Element;
|
|
19
|
-
componentWillMount?(): void;
|
|
20
|
-
componentDidMount?(): void;
|
|
21
|
-
componentWillUnmount?(): void;
|
|
22
|
-
getChildContext?(): object;
|
|
23
|
-
componentWillReceiveProps?(nextProps: Readonly<{
|
|
24
|
-
graphModel: GraphModel;
|
|
25
|
-
} & IProps>, nextContext: any): void;
|
|
26
|
-
shouldComponentUpdate?(nextProps: Readonly<{
|
|
27
|
-
graphModel: GraphModel;
|
|
28
|
-
} & IProps>, nextState: Readonly<{}>, nextContext: any): boolean;
|
|
29
|
-
componentWillUpdate?(nextProps: Readonly<{
|
|
30
|
-
graphModel: GraphModel;
|
|
31
|
-
} & IProps>, nextState: Readonly<{}>, nextContext: any): void;
|
|
32
|
-
getSnapshotBeforeUpdate?(oldProps: Readonly<{
|
|
33
|
-
graphModel: GraphModel;
|
|
34
|
-
} & IProps>, oldState: Readonly<{}>): any;
|
|
35
|
-
componentDidUpdate?(previousProps: Readonly<{
|
|
36
|
-
graphModel: GraphModel;
|
|
37
|
-
} & IProps>, previousState: Readonly<{}>, snapshot: any): void;
|
|
38
|
-
componentDidCatch?(error: any, errorInfo: any): void;
|
|
39
|
-
state: Readonly<{}>;
|
|
40
|
-
props: import("preact").RenderableProps<{
|
|
41
|
-
graphModel: GraphModel;
|
|
42
|
-
} & IProps, any>;
|
|
43
|
-
context: any;
|
|
44
|
-
base?: Element | Text;
|
|
45
|
-
setState<K extends never>(state: Partial<{}> | ((prevState: Readonly<{}>, props: Readonly<{
|
|
46
|
-
graphModel: GraphModel;
|
|
47
|
-
} & IProps>) => Partial<{}> | Pick<{}, K>) | Pick<{}, K>, callback?: () => void): void;
|
|
48
|
-
forceUpdate(callback?: () => void): void;
|
|
49
|
-
};
|
|
50
|
-
displayName?: string;
|
|
51
|
-
defaultProps?: any;
|
|
52
|
-
contextType?: import("preact").Context<any>;
|
|
53
|
-
getDerivedStateFromProps?(props: object, state: object): object;
|
|
54
|
-
getDerivedStateFromError?(error: any): object;
|
|
55
|
-
};
|
|
56
|
-
export default _default;
|
|
12
|
+
declare class HtmlOverlay extends Component<IProps> {
|
|
13
|
+
render(): h.JSX.Element;
|
|
14
|
+
}
|
|
15
|
+
export default HtmlOverlay;
|