@logicflow/core 1.0.0-alpha.6 → 1.0.0
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/dist/logic-flow.js +2 -11
- package/package.json +1 -1
- package/types/LogicFlow.d.ts +1 -1
- package/types/constant/DefaultTheme.d.ts +1 -12
- package/types/model/BaseModel.d.ts +1 -1
- package/types/model/GraphModel.d.ts +26 -16
- package/types/model/edge/BaseEdgeModel.d.ts +83 -59
- package/types/model/edge/BezierEdgeModel.d.ts +1 -3
- package/types/model/edge/LineEdgeModel.d.ts +0 -1
- package/types/model/edge/PolylineEdgeModel.d.ts +1 -4
- package/types/model/node/BaseNodeModel.d.ts +59 -55
- package/types/options.d.ts +1 -9
- package/types/view/node/BaseNode.d.ts +1 -1
- package/types/view/node/HtmlNode.d.ts +1 -0
- package/types/view/text/BaseText.d.ts +0 -2
package/package.json
CHANGED
package/types/LogicFlow.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { CallbackType } from './event/eventEmitter';
|
|
|
8
8
|
import Keyboard from './keyboard';
|
|
9
9
|
import { EdgeConfig, EdgeFilter, NodeConfig, Extension, ComponentRender, FocusOnArgs, EdgeData, GraphConfigData, RegisterElementFn, RegisterConfig, ZoomParam, PointTuple } from './type';
|
|
10
10
|
import SnaplineModel from './model/SnaplineModel';
|
|
11
|
-
import { EditConfigInterface } from './model/
|
|
11
|
+
import { EditConfigInterface } from './model/EditConfigModel';
|
|
12
12
|
import { Theme } from './constant/DefaultTheme';
|
|
13
13
|
declare type GraphConfigModel = {
|
|
14
14
|
nodes: _Model.BaseNodeModel[];
|
|
@@ -147,19 +147,8 @@ export declare type EdgeTextTheme = {
|
|
|
147
147
|
hover?: EdgeTextTheme;
|
|
148
148
|
} & TextTheme;
|
|
149
149
|
export declare type EdgeTheme = CommonTheme;
|
|
150
|
-
export declare type EdgePolylineTheme =
|
|
151
|
-
/**
|
|
152
|
-
* 为了避免折线贴着节点导致折线和节点边重合
|
|
153
|
-
* 设置折线与节点产生垂线的距离。
|
|
154
|
-
* 详情见http://logic-flow.org/article/article03.html#%E7%9B%B4%E8%A7%92%E6%8A%98%E7%BA%BF
|
|
155
|
-
*/
|
|
156
|
-
offset?: number;
|
|
157
|
-
} & EdgeTheme;
|
|
150
|
+
export declare type EdgePolylineTheme = EdgeTheme;
|
|
158
151
|
export declare type EdgeBezierTheme = {
|
|
159
|
-
/**
|
|
160
|
-
* 贝塞尔曲线控制点与锚点的距离
|
|
161
|
-
*/
|
|
162
|
-
offset?: number;
|
|
163
152
|
/**
|
|
164
153
|
* 贝塞尔调整线主题
|
|
165
154
|
*/
|
|
@@ -68,7 +68,6 @@ interface IBaseModel {
|
|
|
68
68
|
* @returns string
|
|
69
69
|
*/
|
|
70
70
|
createId(): string;
|
|
71
|
-
move(deltaX: number, deltaY: number): void;
|
|
72
71
|
moveText(deltaX: number, deltaY: number): void;
|
|
73
72
|
updateText(value: string): void;
|
|
74
73
|
setSelected(flag: boolean): void;
|
|
@@ -81,5 +80,6 @@ interface IBaseModel {
|
|
|
81
80
|
getProperties(): Object;
|
|
82
81
|
setProperties(properties: Object): void;
|
|
83
82
|
updateAttributes(attributes: Object): void;
|
|
83
|
+
getTextStyle(): Record<string, any>;
|
|
84
84
|
}
|
|
85
85
|
export { IBaseModel, };
|
|
@@ -4,7 +4,7 @@ import EditConfigModel from './EditConfigModel';
|
|
|
4
4
|
import TransfromModel from './TransformModel';
|
|
5
5
|
import { IBaseModel } from './BaseModel';
|
|
6
6
|
import { OverlapMode } from '../constant/constant';
|
|
7
|
-
import { AdditionData, Point, NodeConfig, EdgeConfig, NodeMoveRule, GraphConfigData } from '../type';
|
|
7
|
+
import { AdditionData, Point, NodeConfig, EdgeConfig, PointTuple, NodeMoveRule, GraphConfigData } from '../type';
|
|
8
8
|
import EventEmitter from '../event/eventEmitter';
|
|
9
9
|
import { Theme } from '../constant/DefaultTheme';
|
|
10
10
|
import { Definition } from '../options';
|
|
@@ -124,11 +124,14 @@ declare class GraphModel {
|
|
|
124
124
|
* 当前编辑的元素,低频操作,先循环找。
|
|
125
125
|
*/
|
|
126
126
|
get textEditElement(): BaseNodeModel | BaseEdgeModel;
|
|
127
|
+
/**
|
|
128
|
+
* 当前画布所有被选中的元素
|
|
129
|
+
*/
|
|
127
130
|
get selectElements(): Map<any, any>;
|
|
128
131
|
/**
|
|
129
132
|
* 获取指定区域内的所有元素
|
|
130
133
|
*/
|
|
131
|
-
getAreaElement(leftTopPoint:
|
|
134
|
+
getAreaElement(leftTopPoint: PointTuple, rightBottomPoint: PointTuple): any[];
|
|
132
135
|
/**
|
|
133
136
|
* 获取指定类型元素对应的Model
|
|
134
137
|
*/
|
|
@@ -158,7 +161,7 @@ declare class GraphModel {
|
|
|
158
161
|
* @param lt 左上角点
|
|
159
162
|
* @param rb 右下角点
|
|
160
163
|
*/
|
|
161
|
-
isElementInArea(element: any, lt:
|
|
164
|
+
isElementInArea(element: any, lt: PointTuple, rb: PointTuple, wholeEdge?: boolean): boolean;
|
|
162
165
|
/**
|
|
163
166
|
* 使用新的数据重新设置整个画布的元素
|
|
164
167
|
* 注意:将会清除画布上所有已有的节点和边
|
|
@@ -169,6 +172,10 @@ declare class GraphModel {
|
|
|
169
172
|
* 获取画布数据
|
|
170
173
|
*/
|
|
171
174
|
modelToGraphData(): GraphConfigData;
|
|
175
|
+
modelToHistoryData(): false | {
|
|
176
|
+
nodes: any[];
|
|
177
|
+
edges: any[];
|
|
178
|
+
};
|
|
172
179
|
/**
|
|
173
180
|
* 获取边的model
|
|
174
181
|
*/
|
|
@@ -267,10 +274,10 @@ declare class GraphModel {
|
|
|
267
274
|
* @param x X轴目标位置
|
|
268
275
|
* @param y Y轴目标位置
|
|
269
276
|
*/
|
|
270
|
-
moveNode2Coordinate(nodeId: BaseNodeModelId, x: number, y: number): void;
|
|
277
|
+
moveNode2Coordinate(nodeId: BaseNodeModelId, x: number, y: number, isignoreRule?: boolean): void;
|
|
271
278
|
/**
|
|
272
|
-
*
|
|
273
|
-
* @param
|
|
279
|
+
* 显示节点、连线文本编辑框
|
|
280
|
+
* @param elementId 节点id
|
|
274
281
|
*/
|
|
275
282
|
editText(id: ElementModeId): void;
|
|
276
283
|
/**
|
|
@@ -283,7 +290,7 @@ declare class GraphModel {
|
|
|
283
290
|
*/
|
|
284
291
|
moveEdge(nodeId: BaseNodeModelId, deltaX: number, deltaY: number): void;
|
|
285
292
|
/**
|
|
286
|
-
*
|
|
293
|
+
* 删除两节点之间的边
|
|
287
294
|
* @param sourceNodeId 边的起始节点
|
|
288
295
|
* @param targetNodeId 边的目的节点
|
|
289
296
|
*/
|
|
@@ -334,21 +341,24 @@ declare class GraphModel {
|
|
|
334
341
|
* 将所有选中的元素设置为非选中
|
|
335
342
|
*/
|
|
336
343
|
clearSelectElements(): void;
|
|
337
|
-
/**
|
|
338
|
-
* 批量移动元素
|
|
339
|
-
*/
|
|
340
|
-
moveElements(elements: {
|
|
341
|
-
nodes: NodeConfig[];
|
|
342
|
-
}, deltaX: number, deltaY: number): void;
|
|
343
344
|
/**
|
|
344
345
|
* 批量移动节点,节点移动的时候,会动态计算所有节点与未移动节点的边位置
|
|
345
|
-
*
|
|
346
|
+
* 移动的节点之间的边会保持相对位置
|
|
346
347
|
*/
|
|
347
|
-
moveNodes(nodeIds:
|
|
348
|
+
moveNodes(nodeIds: string[], deltaX: number, deltaY: number, isignoreRule?: boolean): void;
|
|
348
349
|
/**
|
|
349
350
|
* 添加节点移动限制规则,在节点移动的时候触发。
|
|
350
351
|
* 如果方法返回false, 则会阻止节点移动。
|
|
351
352
|
* @param fn function
|
|
353
|
+
* @example
|
|
354
|
+
*
|
|
355
|
+
* graphModel.addNodeMoveRules((nodeModel, x, y) => {
|
|
356
|
+
* if (nodeModel.properties.disabled) {
|
|
357
|
+
* return false
|
|
358
|
+
* }
|
|
359
|
+
* return true
|
|
360
|
+
* })
|
|
361
|
+
*
|
|
352
362
|
*/
|
|
353
363
|
addNodeMoveRules(fn: NodeMoveRule): void;
|
|
354
364
|
/**
|
|
@@ -366,7 +376,7 @@ declare class GraphModel {
|
|
|
366
376
|
/**
|
|
367
377
|
* 切换边的类型
|
|
368
378
|
* @param id 边Id
|
|
369
|
-
* @param type
|
|
379
|
+
* @param type 边类型
|
|
370
380
|
*/
|
|
371
381
|
changeEdgeType(id: any, type: any): void;
|
|
372
382
|
/**
|
|
@@ -5,16 +5,11 @@ import { ModelType, ElementType } from '../../constant/constant';
|
|
|
5
5
|
import { OutlineTheme } from '../../constant/DefaultTheme';
|
|
6
6
|
declare class BaseEdgeModel implements IBaseModel {
|
|
7
7
|
id: string;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
graphModel: GraphModel;
|
|
14
|
-
menu?: MenuConfig[];
|
|
15
|
-
sourceAnchorId: string;
|
|
16
|
-
targetAnchorId: string;
|
|
17
|
-
customTextPosition: boolean;
|
|
8
|
+
type: string;
|
|
9
|
+
sourceNodeId: string;
|
|
10
|
+
targetNodeId: string;
|
|
11
|
+
startPoint: any;
|
|
12
|
+
endPoint: any;
|
|
18
13
|
text: {
|
|
19
14
|
value: string;
|
|
20
15
|
x: number;
|
|
@@ -22,87 +17,116 @@ declare class BaseEdgeModel implements IBaseModel {
|
|
|
22
17
|
draggable: boolean;
|
|
23
18
|
editable: boolean;
|
|
24
19
|
};
|
|
25
|
-
type: string;
|
|
26
20
|
properties: Record<string, any>;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
startPoint: any;
|
|
30
|
-
endPoint: any;
|
|
31
|
-
strokeWidth: number;
|
|
32
|
-
stroke: string;
|
|
33
|
-
hideOutline: boolean;
|
|
34
|
-
strokeOpacity: number;
|
|
35
|
-
zIndex: number;
|
|
21
|
+
points: string;
|
|
22
|
+
pointsList: any[];
|
|
36
23
|
isSelected: boolean;
|
|
37
24
|
isHovered: boolean;
|
|
38
25
|
isHitable: boolean;
|
|
39
|
-
points: string;
|
|
40
|
-
pointsList: any[];
|
|
41
26
|
draggable: boolean;
|
|
42
|
-
|
|
27
|
+
graphModel: GraphModel;
|
|
28
|
+
zIndex: number;
|
|
29
|
+
readonly BaseType = ElementType.EDGE;
|
|
30
|
+
modelType: ModelType;
|
|
31
|
+
state: number;
|
|
32
|
+
additionStateData: AdditionData;
|
|
33
|
+
sourceAnchorId: string;
|
|
34
|
+
targetAnchorId: string;
|
|
35
|
+
menu?: MenuConfig[];
|
|
36
|
+
customTextPosition: boolean;
|
|
37
|
+
[propName: string]: any;
|
|
38
|
+
constructor(data: EdgeConfig, graphModel: GraphModel);
|
|
39
|
+
/**
|
|
40
|
+
* @overridable 支持重写
|
|
41
|
+
* 初始化边数据
|
|
42
|
+
* initNodeData和setAttributes的区别在于
|
|
43
|
+
* initNodeData只在节点初始化的时候调用,用于初始化节点的所有属性。
|
|
44
|
+
* setAttributes除了初始化调用外,还会在properties发生变化了调用。
|
|
45
|
+
*/
|
|
43
46
|
initEdgeData(data: any): void;
|
|
44
|
-
|
|
47
|
+
/**
|
|
48
|
+
* 设置model属性,每次properties发生变化会触发
|
|
49
|
+
* @overridable 支持重写
|
|
50
|
+
*/
|
|
45
51
|
setAttributes(): void;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
52
|
+
/**
|
|
53
|
+
* @overridable 支持重写,自定义此类型节点默认生成方式
|
|
54
|
+
* @returns string
|
|
55
|
+
*/
|
|
56
|
+
createId(): any;
|
|
57
|
+
/**
|
|
58
|
+
* @overridable 支持重写
|
|
59
|
+
* 获取当前节点样式
|
|
60
|
+
* @returns 自定义边样式
|
|
61
|
+
*/
|
|
62
|
+
getEdgeStyle(): import("../../constant/DefaultTheme").CommonTheme;
|
|
63
|
+
/**
|
|
64
|
+
* @overridable 支持重写
|
|
65
|
+
* 获取当前节点文本样式
|
|
66
|
+
*/
|
|
67
|
+
getTextStyle(): import("../../constant/DefaultTheme").EdgeTextTheme;
|
|
68
|
+
/**
|
|
69
|
+
* @overridable 支持重写
|
|
70
|
+
* 获取outline样式,重写可以定义此类型边outline样式, 默认使用主题样式
|
|
71
|
+
* @returns 自定义outline样式
|
|
72
|
+
*/
|
|
73
|
+
getOutlineStyle(): OutlineTheme;
|
|
74
|
+
/**
|
|
75
|
+
* @overridable 支持重新,重新自定义文本位置
|
|
76
|
+
* @returns 文本位置
|
|
77
|
+
*/
|
|
78
|
+
getTextPosition(): Point;
|
|
70
79
|
get sourceNode(): import("..").BaseNodeModel;
|
|
71
80
|
get targetNode(): import("..").BaseNodeModel;
|
|
72
81
|
get textPosition(): Point;
|
|
73
82
|
/**
|
|
74
|
-
*
|
|
75
|
-
* @returns 文本位置
|
|
83
|
+
* 内部方法,计算两个节点相连是起点位置
|
|
76
84
|
*/
|
|
77
|
-
getTextPosition(): Point;
|
|
78
|
-
move(): void;
|
|
79
85
|
getBeginAnchor(sourceNode: any, targetNode: any): Point;
|
|
86
|
+
/**
|
|
87
|
+
* 内部方法,计算两个节点相连是终点位置
|
|
88
|
+
*/
|
|
80
89
|
getEndAnchor(targetNode: any): Point;
|
|
90
|
+
/**
|
|
91
|
+
* 获取当前边的properties
|
|
92
|
+
*/
|
|
81
93
|
getProperties(): Record<string, any>;
|
|
94
|
+
/**
|
|
95
|
+
* 获取被保存时返回的数据
|
|
96
|
+
*/
|
|
82
97
|
getData(): EdgeData;
|
|
83
98
|
setProperty(key: any, val: any): void;
|
|
84
99
|
setProperties(properties: any): void;
|
|
85
100
|
/**
|
|
86
|
-
*
|
|
87
|
-
* 获取outline样式,重写可以定义此类型节点outline样式, 默认使用主题样式
|
|
88
|
-
* @returns 自定义outline样式
|
|
101
|
+
* 内部方法,处理初始化文本格式
|
|
89
102
|
*/
|
|
90
|
-
getOutlineStyle(): OutlineTheme;
|
|
91
103
|
formatText(data: any): void;
|
|
104
|
+
/**
|
|
105
|
+
* 重置文本位置
|
|
106
|
+
*/
|
|
92
107
|
resetTextPosition(): void;
|
|
108
|
+
/**
|
|
109
|
+
* 移动边上的文本
|
|
110
|
+
*/
|
|
93
111
|
moveText(deltaX: number, deltaY: number): void;
|
|
112
|
+
/**
|
|
113
|
+
* 设置文本位置和值
|
|
114
|
+
*/
|
|
94
115
|
setText(textConfig: any): void;
|
|
116
|
+
/**
|
|
117
|
+
* 更新文本的值
|
|
118
|
+
*/
|
|
95
119
|
updateText(value: string): void;
|
|
120
|
+
/**
|
|
121
|
+
* 内部方法,计算边的起点和终点
|
|
122
|
+
*/
|
|
96
123
|
setAnchors(): void;
|
|
97
124
|
setSelected(flag?: boolean): void;
|
|
98
125
|
setHovered(flag?: boolean): void;
|
|
99
126
|
setHitable(flag?: boolean): void;
|
|
100
127
|
setElementState(state: number, additionStateData?: AdditionData): void;
|
|
101
|
-
updateStroke(color: any): void;
|
|
102
|
-
updateStrokeWidth(width: any): void;
|
|
103
128
|
updateStartPoint(anchor: any): void;
|
|
104
129
|
updateEndPoint(anchor: any): void;
|
|
105
|
-
setStyleFromTheme(type: any, graphModel: any): void;
|
|
106
130
|
setZIndex(zindex?: number): void;
|
|
107
131
|
initPoints(): void;
|
|
108
132
|
updateAttributes(attributes: any): void;
|
|
@@ -4,12 +4,10 @@ import { ModelType } from '../../constant/constant';
|
|
|
4
4
|
export { BezierEdgeModel };
|
|
5
5
|
export default class BezierEdgeModel extends BaseEdgeModel {
|
|
6
6
|
modelType: ModelType;
|
|
7
|
-
offset: number;
|
|
8
7
|
path: string;
|
|
9
|
-
|
|
8
|
+
initEdgeData(data: any): void;
|
|
10
9
|
getEdgeStyle(): {
|
|
11
10
|
[x: string]: any;
|
|
12
|
-
offset?: number;
|
|
13
11
|
adjustLine?: import("../../constant/DefaultTheme").CommonTheme;
|
|
14
12
|
adjustAnchor?: import("../../constant/DefaultTheme").CircleTheme;
|
|
15
13
|
fill?: string;
|
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
import { ModelType } from '../../constant/constant';
|
|
2
2
|
import { Point } from '../../type';
|
|
3
3
|
import BaseEdgeModel from './BaseEdgeModel';
|
|
4
|
-
import GraphModel from '../GraphModel';
|
|
5
4
|
export { PolylineEdgeModel };
|
|
6
5
|
export default class PolylineEdgeModel extends BaseEdgeModel {
|
|
7
6
|
modelType: ModelType;
|
|
8
|
-
offset: number;
|
|
9
7
|
draginngPointList: any;
|
|
10
8
|
dbClickPosition: Point;
|
|
11
|
-
|
|
9
|
+
initEdgeData(data: any): void;
|
|
12
10
|
getEdgeStyle(): {
|
|
13
11
|
[x: string]: any;
|
|
14
|
-
offset?: number;
|
|
15
12
|
fill?: string;
|
|
16
13
|
stroke?: string;
|
|
17
14
|
strokeWidth?: number;
|
|
@@ -5,7 +5,7 @@ import GraphModel from '../GraphModel';
|
|
|
5
5
|
import { IBaseModel } from '../BaseModel';
|
|
6
6
|
export declare type ConnectRule = {
|
|
7
7
|
message: string;
|
|
8
|
-
validate: (source
|
|
8
|
+
validate: (source?: BaseNodeModel, target?: BaseNodeModel, sourceAnchor?: AnchorConfig, targetAnchor?: AnchorConfig) => boolean;
|
|
9
9
|
};
|
|
10
10
|
export declare type ConnectRuleResult = {
|
|
11
11
|
isAllPass: boolean;
|
|
@@ -20,59 +20,52 @@ interface IBaseNodeModel extends IBaseModel {
|
|
|
20
20
|
export { BaseNodeModel };
|
|
21
21
|
export default class BaseNodeModel implements IBaseNodeModel {
|
|
22
22
|
id: string;
|
|
23
|
-
readonly BaseType = ElementType.NODE;
|
|
24
|
-
modelType: ModelType;
|
|
25
|
-
additionStateData: AdditionData;
|
|
26
|
-
[propName: string]: any;
|
|
27
|
-
targetRules: ConnectRule[];
|
|
28
|
-
sourceRules: ConnectRule[];
|
|
29
|
-
moveRules: NodeMoveRule[];
|
|
30
|
-
hasSetTargetRules: boolean;
|
|
31
|
-
hasSetSourceRules: boolean;
|
|
32
|
-
properties: Record<string, any>;
|
|
33
23
|
type: string;
|
|
34
24
|
x: number;
|
|
35
25
|
y: number;
|
|
26
|
+
text: {
|
|
27
|
+
value: string;
|
|
28
|
+
x: number;
|
|
29
|
+
y: number;
|
|
30
|
+
draggable: boolean;
|
|
31
|
+
editable: boolean;
|
|
32
|
+
};
|
|
33
|
+
properties: Record<string, any>;
|
|
36
34
|
private _width;
|
|
37
|
-
graphModel: GraphModel;
|
|
38
35
|
get width(): number;
|
|
39
36
|
set width(value: number);
|
|
40
37
|
private _height;
|
|
41
38
|
get height(): number;
|
|
42
39
|
set height(value: number);
|
|
40
|
+
anchorsOffset: AnchorsOffsetItem[];
|
|
43
41
|
isSelected: boolean;
|
|
44
42
|
isHovered: boolean;
|
|
43
|
+
isDragging: boolean;
|
|
45
44
|
isHitable: boolean;
|
|
45
|
+
draggable: boolean;
|
|
46
|
+
graphModel: GraphModel;
|
|
46
47
|
zIndex: number;
|
|
47
|
-
anchorsOffset: AnchorsOffsetItem[];
|
|
48
48
|
state: number;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
49
|
+
readonly BaseType = ElementType.NODE;
|
|
50
|
+
modelType: ModelType;
|
|
51
|
+
additionStateData: AdditionData;
|
|
52
|
+
targetRules: ConnectRule[];
|
|
53
|
+
sourceRules: ConnectRule[];
|
|
54
|
+
moveRules: NodeMoveRule[];
|
|
55
|
+
hasSetTargetRules: boolean;
|
|
56
|
+
hasSetSourceRules: boolean;
|
|
57
|
+
[propName: string]: any;
|
|
57
58
|
constructor(data: NodeConfig, graphModel: GraphModel);
|
|
58
59
|
/**
|
|
59
|
-
*
|
|
60
|
-
*
|
|
60
|
+
* @overridable 可以重写
|
|
61
|
+
* 初始化节点数据
|
|
61
62
|
* initNodeData和setAttributes的区别在于
|
|
62
|
-
* initNodeData
|
|
63
|
+
* initNodeData只在节点初始化的时候调用,用于初始化节点的所有属性。
|
|
64
|
+
* setAttributes除了初始化调用外,还会在properties发生变化了调用。
|
|
63
65
|
*/
|
|
64
|
-
|
|
66
|
+
initNodeData(data: any): void;
|
|
65
67
|
/**
|
|
66
|
-
*
|
|
67
|
-
* @returns string
|
|
68
|
-
*/
|
|
69
|
-
createId(): string;
|
|
70
|
-
/**
|
|
71
|
-
* 初始化文本属性,对
|
|
72
|
-
*/
|
|
73
|
-
private formatText;
|
|
74
|
-
/**
|
|
75
|
-
* 设置model初始化属性
|
|
68
|
+
* 设置model属性,每次properties发生变化会触发
|
|
76
69
|
* 例如设置节点的宽度
|
|
77
70
|
* @example
|
|
78
71
|
*
|
|
@@ -84,12 +77,23 @@ export default class BaseNodeModel implements IBaseNodeModel {
|
|
|
84
77
|
* @overridable 支持重写
|
|
85
78
|
*/
|
|
86
79
|
setAttributes(): void;
|
|
80
|
+
/**
|
|
81
|
+
* @overridable 支持重写,自定义此类型节点默认生成方式
|
|
82
|
+
* @returns string
|
|
83
|
+
*/
|
|
84
|
+
createId(): string;
|
|
85
|
+
/**
|
|
86
|
+
* 初始化文本属性
|
|
87
|
+
*/
|
|
88
|
+
private formatText;
|
|
87
89
|
/**
|
|
88
90
|
* 获取被保存时返回的数据
|
|
89
91
|
* @overridable 支持重写
|
|
90
|
-
* @returns NodeData
|
|
91
92
|
*/
|
|
92
93
|
getData(): NodeData;
|
|
94
|
+
/**
|
|
95
|
+
* 获取当前节点的properties
|
|
96
|
+
*/
|
|
93
97
|
getProperties(): Record<string, any>;
|
|
94
98
|
/**
|
|
95
99
|
* @overridable 支持重写
|
|
@@ -97,27 +101,23 @@ export default class BaseNodeModel implements IBaseNodeModel {
|
|
|
97
101
|
* @returns 自定义节点样式
|
|
98
102
|
*/
|
|
99
103
|
getNodeStyle(): ShapeStyleAttribute;
|
|
100
|
-
getTextStyle(): {
|
|
101
|
-
[x: string]: any;
|
|
102
|
-
overflowMode?: string;
|
|
103
|
-
background?: import("../../constant/DefaultTheme").RectTheme;
|
|
104
|
-
color?: string;
|
|
105
|
-
fontSize?: number;
|
|
106
|
-
fill?: string;
|
|
107
|
-
stroke?: string;
|
|
108
|
-
strokeWidth?: number;
|
|
109
|
-
};
|
|
110
104
|
/**
|
|
111
|
-
*
|
|
105
|
+
* @overridable 支持重写
|
|
106
|
+
* 获取当前节点文本样式
|
|
107
|
+
*/
|
|
108
|
+
getTextStyle(): import("../../constant/DefaultTheme").NodeTextTheme;
|
|
109
|
+
/**
|
|
110
|
+
* @overridable 支持重写
|
|
111
|
+
* 获取当前节点锚点样式
|
|
112
112
|
* @returns 自定义样式
|
|
113
113
|
*/
|
|
114
114
|
getAnchorStyle(): Record<string, any>;
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
115
|
+
/**
|
|
116
|
+
* @overridable 支持重写
|
|
117
|
+
* 获取当前节点锚点拖出连线样式
|
|
118
|
+
* @returns 自定义锚点拖出样式
|
|
119
|
+
*/
|
|
120
|
+
getAnchorLineStyle(): import("../../constant/DefaultTheme").CommonTheme;
|
|
121
121
|
/**
|
|
122
122
|
* @overridable 支持重写
|
|
123
123
|
* 获取outline样式,重写可以定义此类型节点outline样式, 默认使用主题样式
|
|
@@ -125,6 +125,7 @@ export default class BaseNodeModel implements IBaseNodeModel {
|
|
|
125
125
|
*/
|
|
126
126
|
getOutlineStyle(): OutlineTheme;
|
|
127
127
|
/**
|
|
128
|
+
* @over
|
|
128
129
|
* 在边的时候,是否允许这个节点为source节点,边到target节点。
|
|
129
130
|
*/
|
|
130
131
|
isAllowConnectedAsSource(target: BaseNodeModel, soureAnchor: AnchorConfig, targetAnchor: AnchorConfig): ConnectRuleResult | Boolean;
|
|
@@ -133,13 +134,17 @@ export default class BaseNodeModel implements IBaseNodeModel {
|
|
|
133
134
|
*/
|
|
134
135
|
getConnectedSourceRules(): ConnectRule[];
|
|
135
136
|
/**
|
|
136
|
-
*
|
|
137
|
+
* 在连线的时候,是否允许这个节点为target节点
|
|
137
138
|
*/
|
|
138
139
|
isAllowConnectedAsTarget(source: BaseNodeModel, soureAnchor: AnchorConfig, targetAnchor: AnchorConfig): ConnectRuleResult | Boolean;
|
|
139
140
|
/**
|
|
141
|
+
* 内部方法
|
|
140
142
|
* 是否允许移动节点到新的位置
|
|
141
143
|
*/
|
|
142
144
|
isAllowMoveNode(deltaX: any, deltaY: any): boolean;
|
|
145
|
+
/**
|
|
146
|
+
* 获取作为连线终点时的所有规则。
|
|
147
|
+
*/
|
|
143
148
|
getConnectedTargetRules(): ConnectRule[];
|
|
144
149
|
/**
|
|
145
150
|
* @overridable 子类重写此方法设置锚点
|
|
@@ -164,7 +169,6 @@ export default class BaseNodeModel implements IBaseNodeModel {
|
|
|
164
169
|
setHovered(flag?: boolean): void;
|
|
165
170
|
setHitable(flag?: boolean): void;
|
|
166
171
|
setElementState(state: number, additionStateData?: AdditionData): void;
|
|
167
|
-
updateStroke(color: any): void;
|
|
168
172
|
setProperty(key: any, val: any): void;
|
|
169
173
|
setProperties(properties: any): void;
|
|
170
174
|
setZIndex(zindex?: number): void;
|
package/types/options.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { GridOptions } from './view/overlay/Grid';
|
|
|
2
2
|
import { BackgroundConfig } from './view/overlay/BackgroundOverlay';
|
|
3
3
|
import { NodeData, EdgeData, GraphConfigData } from './type';
|
|
4
4
|
import { KeyboardDef } from './keyboard';
|
|
5
|
-
import { EditConfigInterface } from './model/
|
|
5
|
+
import { EditConfigInterface } from './model/EditConfigModel';
|
|
6
6
|
import { Theme } from './constant/DefaultTheme';
|
|
7
7
|
export declare type EdgeType = 'line' | 'polyline' | 'bezier' | any;
|
|
8
8
|
declare type DefaultOverlapMode = 0;
|
|
@@ -68,10 +68,6 @@ export declare type Definition = {
|
|
|
68
68
|
* todo: 目前不完善,仅支持同步
|
|
69
69
|
*/
|
|
70
70
|
guards?: GuardsTypes;
|
|
71
|
-
/**
|
|
72
|
-
* 是否不启用outline显示选中和hover效果
|
|
73
|
-
*/
|
|
74
|
-
hideOutline?: boolean;
|
|
75
71
|
/**
|
|
76
72
|
* 表示节点在上,边在下,点击元素时选择元素显示在最顶部。
|
|
77
73
|
* 表示安装元素创建顺序排序,点击元素也不会将其置顶。要置顶需要调用置顶API。
|
|
@@ -156,10 +152,6 @@ export declare function get(options: Definition): {
|
|
|
156
152
|
* todo: 目前不完善,仅支持同步
|
|
157
153
|
*/
|
|
158
154
|
guards?: GuardsTypes;
|
|
159
|
-
/**
|
|
160
|
-
* 是否不启用outline显示选中和hover效果
|
|
161
|
-
*/
|
|
162
|
-
hideOutline?: boolean;
|
|
163
155
|
/**
|
|
164
156
|
* 表示节点在上,边在下,点击元素时选择元素显示在最顶部。
|
|
165
157
|
* 表示安装元素创建顺序排序,点击元素也不会将其置顶。要置顶需要调用置顶API。
|
|
@@ -7,8 +7,8 @@ declare type IProps = {
|
|
|
7
7
|
graphModel: GraphModel;
|
|
8
8
|
};
|
|
9
9
|
declare type Istate = {
|
|
10
|
-
isDraging: boolean;
|
|
11
10
|
isHovered: boolean;
|
|
11
|
+
isDraging?: boolean;
|
|
12
12
|
};
|
|
13
13
|
export default abstract class BaseNode extends Component<IProps, Istate> {
|
|
14
14
|
static getModel(defaultModel: any): any;
|
|
@@ -2,11 +2,9 @@ import { h, Component } from 'preact';
|
|
|
2
2
|
import GraphModel from '../../model/GraphModel';
|
|
3
3
|
import { StepDrag } from '../../util/drag';
|
|
4
4
|
import { IBaseModel } from '../../model/BaseModel';
|
|
5
|
-
import { EdgeTextStyle } from '../../type';
|
|
6
5
|
declare type IProps = {
|
|
7
6
|
model: IBaseModel;
|
|
8
7
|
graphModel: GraphModel;
|
|
9
|
-
style: EdgeTextStyle;
|
|
10
8
|
draggable: boolean;
|
|
11
9
|
editable: boolean;
|
|
12
10
|
};
|