@logicflow/core 2.0.5 → 2.0.7
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/.turbo/turbo-build$colon$dev.log +10 -10
- package/.turbo/turbo-build.log +33 -33
- package/CHANGELOG.md +29 -0
- package/__tests__/algorithm/egde.test.ts +36 -23
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/es/algorithm/rotate.d.ts +31 -0
- package/es/algorithm/rotate.js +43 -0
- package/es/event/eventArgs.d.ts +23 -29
- package/es/model/BaseModel.d.ts +9 -0
- package/es/model/GraphModel.d.ts +17 -1
- package/es/model/GraphModel.js +37 -2
- package/es/model/edge/BaseEdgeModel.d.ts +1 -0
- package/es/model/node/BaseNodeModel.d.ts +7 -0
- package/es/model/node/BaseNodeModel.js +55 -2
- package/es/util/drag.d.ts +1 -0
- package/es/util/drag.js +11 -0
- package/es/util/graph.d.ts +1 -1
- package/es/util/resize.d.ts +23 -9
- package/es/util/resize.js +139 -16
- package/es/view/Anchor.js +6 -8
- package/es/view/Control.d.ts +1 -0
- package/es/view/Control.js +6 -1
- package/es/view/Graph.js +3 -15
- package/es/view/behavior/dnd.js +1 -0
- package/es/view/edge/BaseEdge.d.ts +3 -1
- package/es/view/edge/BaseEdge.js +8 -5
- package/es/view/overlay/BackgroundOverlay.d.ts +4 -14
- package/es/view/overlay/BackgroundOverlay.js +11 -1
- package/es/view/overlay/Grid.d.ts +4 -3
- package/es/view/overlay/Grid.js +8 -31
- package/es/view/text/BaseText.js +1 -1
- package/lib/algorithm/rotate.d.ts +31 -0
- package/lib/algorithm/rotate.js +50 -0
- package/lib/event/eventArgs.d.ts +23 -29
- package/lib/model/BaseModel.d.ts +9 -0
- package/lib/model/GraphModel.d.ts +17 -1
- package/lib/model/GraphModel.js +36 -1
- package/lib/model/edge/BaseEdgeModel.d.ts +1 -0
- package/lib/model/node/BaseNodeModel.d.ts +7 -0
- package/lib/model/node/BaseNodeModel.js +55 -2
- package/lib/util/drag.d.ts +1 -0
- package/lib/util/drag.js +11 -0
- package/lib/util/graph.d.ts +1 -1
- package/lib/util/resize.d.ts +23 -9
- package/lib/util/resize.js +141 -17
- package/lib/view/Anchor.js +6 -8
- package/lib/view/Control.d.ts +1 -0
- package/lib/view/Control.js +6 -1
- package/lib/view/Graph.js +3 -15
- package/lib/view/behavior/dnd.js +1 -0
- package/lib/view/edge/BaseEdge.d.ts +3 -1
- package/lib/view/edge/BaseEdge.js +8 -5
- package/lib/view/overlay/BackgroundOverlay.d.ts +4 -14
- package/lib/view/overlay/BackgroundOverlay.js +11 -1
- package/lib/view/overlay/Grid.d.ts +4 -3
- package/lib/view/overlay/Grid.js +8 -31
- package/lib/view/text/BaseText.js +1 -1
- package/package.json +1 -1
- package/src/algorithm/edge.ts +2 -4
- package/src/event/eventArgs.ts +23 -29
- package/src/model/BaseModel.ts +16 -0
- package/src/model/GraphModel.ts +25 -3
- package/src/model/edge/BaseEdgeModel.ts +1 -0
- package/src/model/node/BaseNodeModel.ts +33 -1
- package/src/model/node/HtmlNodeModel.ts +1 -1
- package/src/util/drag.ts +12 -0
- package/src/util/resize.ts +7 -1
- package/src/view/Anchor.tsx +7 -8
- package/src/view/Control.tsx +1 -1
- package/src/view/Graph.tsx +2 -3
- package/src/view/behavior/dnd.ts +1 -0
- package/src/view/edge/BaseEdge.tsx +8 -3
- package/src/view/overlay/Grid.tsx +13 -9
- package/src/view/text/BaseText.tsx +1 -1
- package/stats.html +1 -1
package/lib/event/eventArgs.d.ts
CHANGED
|
@@ -105,7 +105,7 @@ interface NodeEventArgs {
|
|
|
105
105
|
/**
|
|
106
106
|
* 拖拽外部拖入节点
|
|
107
107
|
*/
|
|
108
|
-
'node:dnd-drag': NodeEventArgsPick<'data'>;
|
|
108
|
+
'node:dnd-drag': NodeEventArgsPick<'data' | 'e'>;
|
|
109
109
|
/**
|
|
110
110
|
* 开始拖拽节点
|
|
111
111
|
*/
|
|
@@ -130,6 +130,27 @@ interface NodeEventArgs {
|
|
|
130
130
|
* 节点缩放
|
|
131
131
|
*/
|
|
132
132
|
'node:resize': NodeEventArgsPick<'preData' | 'data' | 'model' | 'deltaX' | 'deltaY' | 'index'>;
|
|
133
|
+
/**
|
|
134
|
+
* 元素的 properties 发生改变
|
|
135
|
+
*/
|
|
136
|
+
'node:properties-change': {
|
|
137
|
+
/**
|
|
138
|
+
* 元素的 id
|
|
139
|
+
*/
|
|
140
|
+
id: string;
|
|
141
|
+
/**
|
|
142
|
+
* 改变的 properties 的 key
|
|
143
|
+
*/
|
|
144
|
+
keys: string[];
|
|
145
|
+
/**
|
|
146
|
+
* 改变前的 properties
|
|
147
|
+
*/
|
|
148
|
+
preProperties: Record<string, any>;
|
|
149
|
+
/**
|
|
150
|
+
* 改变后的 properties
|
|
151
|
+
*/
|
|
152
|
+
properties: Record<string, any>;
|
|
153
|
+
};
|
|
133
154
|
}
|
|
134
155
|
type EdgeEventArgsPick<T extends 'data' | 'e' | 'position'> = Pick<{
|
|
135
156
|
/**
|
|
@@ -275,33 +296,6 @@ interface CommonEventArgs {
|
|
|
275
296
|
*/
|
|
276
297
|
position: ClientPosition;
|
|
277
298
|
};
|
|
278
|
-
/**
|
|
279
|
-
* 元素的 properties 发生改变
|
|
280
|
-
*/
|
|
281
|
-
'properties:change': {
|
|
282
|
-
data: {
|
|
283
|
-
/**
|
|
284
|
-
* 元素的 id
|
|
285
|
-
*/
|
|
286
|
-
id: string;
|
|
287
|
-
/**
|
|
288
|
-
* 元素的类型
|
|
289
|
-
*/
|
|
290
|
-
type: string;
|
|
291
|
-
/**
|
|
292
|
-
* 改变的 properties 的 key
|
|
293
|
-
*/
|
|
294
|
-
keys: string[];
|
|
295
|
-
/**
|
|
296
|
-
* 改变前的 properties
|
|
297
|
-
*/
|
|
298
|
-
preProperties: Record<string, any>;
|
|
299
|
-
/**
|
|
300
|
-
* 改变后的 properties
|
|
301
|
-
*/
|
|
302
|
-
properties: Record<string, any>;
|
|
303
|
-
};
|
|
304
|
-
};
|
|
305
299
|
/**
|
|
306
300
|
* 进行画布平移或缩放等变化操作时触发
|
|
307
301
|
*/
|
|
@@ -356,7 +350,7 @@ type AnchorEventArgsPick<T extends 'data' | 'e' | 'nodeModel' | 'edgeModel'> = P
|
|
|
356
350
|
/**
|
|
357
351
|
* 通过拖动锚点连线添加的边的数据
|
|
358
352
|
*/
|
|
359
|
-
edgeModel
|
|
353
|
+
edgeModel?: BaseEdgeModel;
|
|
360
354
|
}, T>;
|
|
361
355
|
/**
|
|
362
356
|
* 锚点事件
|
package/lib/model/BaseModel.d.ts
CHANGED
|
@@ -42,6 +42,15 @@ export declare namespace Model {
|
|
|
42
42
|
* deltaY: 移动的 Y 轴距离
|
|
43
43
|
*/
|
|
44
44
|
type NodeMoveRule = (model: BaseNodeModel, deltaX: number, deltaY: number) => boolean | IsAllowMove;
|
|
45
|
+
/**
|
|
46
|
+
* 限制节点resize规则
|
|
47
|
+
* model: 移动节点的 model
|
|
48
|
+
* deltaX: 中心点移动的 X 轴距离
|
|
49
|
+
* deltaY: 中心点移动的 Y 轴距离
|
|
50
|
+
* width: 中心点新的width
|
|
51
|
+
* height: 中心点新的height
|
|
52
|
+
*/
|
|
53
|
+
type NodeResizeRule = (model: BaseNodeModel, deltaX: number, deltaY: number, width: number, height: number) => boolean;
|
|
45
54
|
type AdjustEdgeStartAndEndParams = {
|
|
46
55
|
startPoint: LogicFlow.Point;
|
|
47
56
|
endPoint: LogicFlow.Point;
|
|
@@ -3,6 +3,7 @@ import { ElementState, EventType, OverlapMode, TextMode } from '../constant';
|
|
|
3
3
|
import LogicFlow from '../LogicFlow';
|
|
4
4
|
import { Options as LFOptions } from '../options';
|
|
5
5
|
import EventEmitter from '../event/eventEmitter';
|
|
6
|
+
import { Grid } from '../view/overlay';
|
|
6
7
|
import PointTuple = LogicFlow.PointTuple;
|
|
7
8
|
import GraphData = LogicFlow.GraphData;
|
|
8
9
|
import NodeConfig = LogicFlow.NodeConfig;
|
|
@@ -16,6 +17,7 @@ export declare class GraphModel {
|
|
|
16
17
|
width: number;
|
|
17
18
|
height: number;
|
|
18
19
|
theme: LogicFlow.Theme;
|
|
20
|
+
grid: Grid.GridOptions;
|
|
19
21
|
readonly eventCenter: EventEmitter;
|
|
20
22
|
readonly modelMap: Map<string, LogicFlow.GraphElementCtor>;
|
|
21
23
|
/**
|
|
@@ -32,9 +34,14 @@ export declare class GraphModel {
|
|
|
32
34
|
elementsModelMap: Map<string, BaseNodeModel | BaseEdgeModel>;
|
|
33
35
|
/**
|
|
34
36
|
* 节点移动规则判断
|
|
35
|
-
*
|
|
37
|
+
* 在节点移动的时候,会触发此数组中的所有规则判断
|
|
36
38
|
*/
|
|
37
39
|
nodeMoveRules: Model.NodeMoveRule[];
|
|
40
|
+
/**
|
|
41
|
+
* 节点resize规则判断
|
|
42
|
+
* 在节点resize的时候,会触发此数组中的所有规则判断
|
|
43
|
+
*/
|
|
44
|
+
nodeResizeRules: Model.NodeResizeRule[];
|
|
38
45
|
/**
|
|
39
46
|
* 获取自定义连线轨迹
|
|
40
47
|
*/
|
|
@@ -330,6 +337,7 @@ export declare class GraphModel {
|
|
|
330
337
|
*
|
|
331
338
|
*/
|
|
332
339
|
addNodeMoveRules(fn: Model.NodeMoveRule): void;
|
|
340
|
+
addNodeResizeRules(fn: Model.NodeResizeRule): void;
|
|
333
341
|
/**
|
|
334
342
|
* 设置默认的边类型
|
|
335
343
|
* 也就是设置在节点直接有用户手动绘制的连线类型。
|
|
@@ -377,6 +385,14 @@ export declare class GraphModel {
|
|
|
377
385
|
* todo docs link
|
|
378
386
|
*/
|
|
379
387
|
setTheme(style: Partial<LogicFlow.Theme>): void;
|
|
388
|
+
/**
|
|
389
|
+
* 更新网格配置
|
|
390
|
+
*/
|
|
391
|
+
updateGridOptions(options: Partial<Grid.GridOptions>): void;
|
|
392
|
+
/**
|
|
393
|
+
* 更新网格配置
|
|
394
|
+
*/
|
|
395
|
+
updateBackgroundOptions(options: boolean | Partial<LFOptions.BackgroundConfig>): void;
|
|
380
396
|
/**
|
|
381
397
|
* 重新设置画布的宽高
|
|
382
398
|
*/
|
package/lib/model/GraphModel.js
CHANGED
|
@@ -52,6 +52,7 @@ var _1 = require(".");
|
|
|
52
52
|
var constant_1 = require("../constant");
|
|
53
53
|
var util_1 = require("../util");
|
|
54
54
|
var eventEmitter_1 = __importDefault(require("../event/eventEmitter"));
|
|
55
|
+
var overlay_1 = require("../view/overlay");
|
|
55
56
|
var GraphModel = /** @class */ (function () {
|
|
56
57
|
function GraphModel(options) {
|
|
57
58
|
// 维护所有节点和边类型对应的 model
|
|
@@ -64,9 +65,14 @@ var GraphModel = /** @class */ (function () {
|
|
|
64
65
|
this.elementsModelMap = new Map();
|
|
65
66
|
/**
|
|
66
67
|
* 节点移动规则判断
|
|
67
|
-
*
|
|
68
|
+
* 在节点移动的时候,会触发此数组中的所有规则判断
|
|
68
69
|
*/
|
|
69
70
|
this.nodeMoveRules = [];
|
|
71
|
+
/**
|
|
72
|
+
* 节点resize规则判断
|
|
73
|
+
* 在节点resize的时候,会触发此数组中的所有规则判断
|
|
74
|
+
*/
|
|
75
|
+
this.nodeResizeRules = [];
|
|
70
76
|
// 当前图上所有节点的model
|
|
71
77
|
this.nodes = [];
|
|
72
78
|
// 当前图上所有边的model
|
|
@@ -89,6 +95,7 @@ var GraphModel = /** @class */ (function () {
|
|
|
89
95
|
this.gridSize = grid.size || 1; // 默认 gridSize 设置为 1
|
|
90
96
|
}
|
|
91
97
|
this.theme = (0, util_1.setupTheme)(options.style);
|
|
98
|
+
this.grid = overlay_1.Grid.getGridOptions(grid !== null && grid !== void 0 ? grid : false);
|
|
92
99
|
this.edgeType = options.edgeType || 'polyline';
|
|
93
100
|
this.animation = (0, util_1.setupAnimation)(animation);
|
|
94
101
|
this.overlapMode = options.overlapMode || constant_1.OverlapMode.DEFAULT;
|
|
@@ -1087,6 +1094,11 @@ var GraphModel = /** @class */ (function () {
|
|
|
1087
1094
|
this.nodeMoveRules.push(fn);
|
|
1088
1095
|
}
|
|
1089
1096
|
};
|
|
1097
|
+
GraphModel.prototype.addNodeResizeRules = function (fn) {
|
|
1098
|
+
if (!this.nodeResizeRules.includes(fn)) {
|
|
1099
|
+
this.nodeResizeRules.push(fn);
|
|
1100
|
+
}
|
|
1101
|
+
};
|
|
1090
1102
|
/**
|
|
1091
1103
|
* 设置默认的边类型
|
|
1092
1104
|
* 也就是设置在节点直接有用户手动绘制的连线类型。
|
|
@@ -1234,6 +1246,26 @@ var GraphModel = /** @class */ (function () {
|
|
|
1234
1246
|
GraphModel.prototype.setTheme = function (style) {
|
|
1235
1247
|
this.theme = (0, util_1.updateTheme)(__assign(__assign({}, this.theme), style));
|
|
1236
1248
|
};
|
|
1249
|
+
/**
|
|
1250
|
+
* 更新网格配置
|
|
1251
|
+
*/
|
|
1252
|
+
GraphModel.prototype.updateGridOptions = function (options) {
|
|
1253
|
+
(0, lodash_es_1.merge)(this.grid, options);
|
|
1254
|
+
};
|
|
1255
|
+
/**
|
|
1256
|
+
* 更新网格配置
|
|
1257
|
+
*/
|
|
1258
|
+
GraphModel.prototype.updateBackgroundOptions = function (options) {
|
|
1259
|
+
if (typeof options === 'boolean') {
|
|
1260
|
+
this.background = options;
|
|
1261
|
+
}
|
|
1262
|
+
else if (typeof this.background === 'boolean') {
|
|
1263
|
+
this.background = options;
|
|
1264
|
+
}
|
|
1265
|
+
else {
|
|
1266
|
+
this.background = __assign(__assign({}, this.background), options);
|
|
1267
|
+
}
|
|
1268
|
+
};
|
|
1237
1269
|
/**
|
|
1238
1270
|
* 重新设置画布的宽高
|
|
1239
1271
|
*/
|
|
@@ -1361,6 +1393,9 @@ var GraphModel = /** @class */ (function () {
|
|
|
1361
1393
|
__decorate([
|
|
1362
1394
|
mobx_1.observable
|
|
1363
1395
|
], GraphModel.prototype, "height", void 0);
|
|
1396
|
+
__decorate([
|
|
1397
|
+
mobx_1.observable
|
|
1398
|
+
], GraphModel.prototype, "grid", void 0);
|
|
1364
1399
|
__decorate([
|
|
1365
1400
|
mobx_1.observable
|
|
1366
1401
|
], GraphModel.prototype, "edgeType", void 0);
|
|
@@ -72,6 +72,7 @@ export declare class BaseNodeModel<P extends PropertiesType = PropertiesType> im
|
|
|
72
72
|
targetRules: Model.ConnectRule[];
|
|
73
73
|
sourceRules: Model.ConnectRule[];
|
|
74
74
|
moveRules: Model.NodeMoveRule[];
|
|
75
|
+
resizeRules: Model.NodeResizeRule[];
|
|
75
76
|
hasSetTargetRules: boolean;
|
|
76
77
|
hasSetSourceRules: boolean;
|
|
77
78
|
[propName: string]: any;
|
|
@@ -264,6 +265,12 @@ export declare class BaseNodeModel<P extends PropertiesType = PropertiesType> im
|
|
|
264
265
|
moveTo(x: number, y: number, isIgnoreRule?: boolean): boolean;
|
|
265
266
|
moveText(deltaX: number, deltaY: number): void;
|
|
266
267
|
updateText(value: string): void;
|
|
268
|
+
addNodeResizeRules(fn: Model.NodeResizeRule): void;
|
|
269
|
+
/**
|
|
270
|
+
* 内部方法
|
|
271
|
+
* 是否允许resize节点到新的位置
|
|
272
|
+
*/
|
|
273
|
+
isAllowResizeNode(deltaX: number, deltaY: number, width: number, height: number): boolean;
|
|
267
274
|
setSelected(flag?: boolean): void;
|
|
268
275
|
setHovered(flag?: boolean): void;
|
|
269
276
|
setIsShowAnchor(flag?: boolean): void;
|
|
@@ -98,6 +98,7 @@ var BaseNodeModel = /** @class */ (function () {
|
|
|
98
98
|
this.targetRules = [];
|
|
99
99
|
this.sourceRules = [];
|
|
100
100
|
this.moveRules = []; // 节点移动之前的hook
|
|
101
|
+
this.resizeRules = []; // 节点resize之前的hook
|
|
101
102
|
this.hasSetTargetRules = false; // 用来限制rules的重复值
|
|
102
103
|
this.hasSetSourceRules = false; // 用来限制rules的重复值
|
|
103
104
|
this.graphModel = graphModel;
|
|
@@ -243,7 +244,7 @@ var BaseNodeModel = /** @class */ (function () {
|
|
|
243
244
|
textConfig.draggable = text.draggable;
|
|
244
245
|
}
|
|
245
246
|
if (!(0, lodash_es_1.isUndefined)(text.editable)) {
|
|
246
|
-
textConfig.
|
|
247
|
+
textConfig.editable = text.editable;
|
|
247
248
|
}
|
|
248
249
|
}
|
|
249
250
|
}
|
|
@@ -255,6 +256,10 @@ var BaseNodeModel = /** @class */ (function () {
|
|
|
255
256
|
*/
|
|
256
257
|
BaseNodeModel.prototype.resize = function (resizeInfo) {
|
|
257
258
|
var width = resizeInfo.width, height = resizeInfo.height, deltaX = resizeInfo.deltaX, deltaY = resizeInfo.deltaY;
|
|
259
|
+
var isAllowResize = this.isAllowResizeNode(deltaX, deltaY, width, height);
|
|
260
|
+
if (!isAllowResize) {
|
|
261
|
+
return this.getData();
|
|
262
|
+
}
|
|
258
263
|
// 移动节点以及文本内容
|
|
259
264
|
this.move(deltaX / 2, deltaY / 2);
|
|
260
265
|
this.width = width;
|
|
@@ -277,6 +282,18 @@ var BaseNodeModel = /** @class */ (function () {
|
|
|
277
282
|
if ((0, mobx_1.isObservable)(properties)) {
|
|
278
283
|
properties = (0, mobx_1.toJS)(properties);
|
|
279
284
|
}
|
|
285
|
+
if ((0, lodash_es_1.isNil)(properties.width)) {
|
|
286
|
+
// resize()的时候会触发this.setProperties({width,height})
|
|
287
|
+
// 然后返回getData(),可以从properties拿到width
|
|
288
|
+
// 但是初始化如果没有在properties传入width,那么getData()就一直无法从properties拿到width
|
|
289
|
+
properties.width = this.width;
|
|
290
|
+
}
|
|
291
|
+
if ((0, lodash_es_1.isNil)(properties.height)) {
|
|
292
|
+
// resize()的时候会触发this.setProperties({width,height})
|
|
293
|
+
// 然后返回getData(),可以从properties拿到height
|
|
294
|
+
// 但是初始化如果没有在properties传入height,那么getData()就一直无法从properties拿到width
|
|
295
|
+
properties.height = this.height;
|
|
296
|
+
}
|
|
280
297
|
var data = {
|
|
281
298
|
id: this.id,
|
|
282
299
|
type: this.type,
|
|
@@ -609,6 +626,10 @@ var BaseNodeModel = /** @class */ (function () {
|
|
|
609
626
|
this.y = this.y + deltaY;
|
|
610
627
|
this.text && this.moveText(0, deltaY);
|
|
611
628
|
}
|
|
629
|
+
if (isAllowMoveX || isAllowMoveY) {
|
|
630
|
+
// 更新x和y的同时也要更新对应的transform旋转矩阵(依赖x、y)
|
|
631
|
+
this.rotate = this._rotate;
|
|
632
|
+
}
|
|
612
633
|
return isAllowMoveX || isAllowMoveY;
|
|
613
634
|
};
|
|
614
635
|
BaseNodeModel.prototype.getMoveDistance = function (deltaX, deltaY, isIgnoreRule) {
|
|
@@ -652,6 +673,35 @@ var BaseNodeModel = /** @class */ (function () {
|
|
|
652
673
|
BaseNodeModel.prototype.updateText = function (value) {
|
|
653
674
|
this.text = __assign(__assign({}, (0, mobx_1.toJS)(this.text)), { value: value });
|
|
654
675
|
};
|
|
676
|
+
BaseNodeModel.prototype.addNodeResizeRules = function (fn) {
|
|
677
|
+
if (!this.resizeRules.includes(fn)) {
|
|
678
|
+
this.resizeRules.push(fn);
|
|
679
|
+
}
|
|
680
|
+
};
|
|
681
|
+
/**
|
|
682
|
+
* 内部方法
|
|
683
|
+
* 是否允许resize节点到新的位置
|
|
684
|
+
*/
|
|
685
|
+
BaseNodeModel.prototype.isAllowResizeNode = function (deltaX, deltaY, width, height) {
|
|
686
|
+
var e_2, _a;
|
|
687
|
+
var rules = this.resizeRules.concat(this.graphModel.nodeResizeRules);
|
|
688
|
+
try {
|
|
689
|
+
for (var rules_2 = __values(rules), rules_2_1 = rules_2.next(); !rules_2_1.done; rules_2_1 = rules_2.next()) {
|
|
690
|
+
var rule = rules_2_1.value;
|
|
691
|
+
var r = rule(this, deltaX, deltaY, width, height);
|
|
692
|
+
if (!r)
|
|
693
|
+
return false;
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
697
|
+
finally {
|
|
698
|
+
try {
|
|
699
|
+
if (rules_2_1 && !rules_2_1.done && (_a = rules_2.return)) _a.call(rules_2);
|
|
700
|
+
}
|
|
701
|
+
finally { if (e_2) throw e_2.error; }
|
|
702
|
+
}
|
|
703
|
+
return true;
|
|
704
|
+
};
|
|
655
705
|
BaseNodeModel.prototype.setSelected = function (flag) {
|
|
656
706
|
if (flag === void 0) { flag = true; }
|
|
657
707
|
this.isSelected = flag;
|
|
@@ -689,7 +739,7 @@ var BaseNodeModel = /** @class */ (function () {
|
|
|
689
739
|
var preProperties = (0, mobx_1.toJS)(this.properties);
|
|
690
740
|
this.properties = nextProperties;
|
|
691
741
|
this.setAttributes();
|
|
692
|
-
// 触发更新节点 properties
|
|
742
|
+
// 触发更新节点 node:properties-change 的事件
|
|
693
743
|
this.graphModel.eventCenter.emit(constant_1.EventType.NODE_PROPERTIES_CHANGE, {
|
|
694
744
|
id: this.id,
|
|
695
745
|
keys: updateKeys,
|
|
@@ -842,6 +892,9 @@ var BaseNodeModel = /** @class */ (function () {
|
|
|
842
892
|
__decorate([
|
|
843
893
|
mobx_1.action
|
|
844
894
|
], BaseNodeModel.prototype, "updateText", null);
|
|
895
|
+
__decorate([
|
|
896
|
+
mobx_1.action
|
|
897
|
+
], BaseNodeModel.prototype, "addNodeResizeRules", null);
|
|
845
898
|
__decorate([
|
|
846
899
|
mobx_1.action
|
|
847
900
|
], BaseNodeModel.prototype, "setSelected", null);
|
package/lib/util/drag.d.ts
CHANGED
package/lib/util/drag.js
CHANGED
|
@@ -124,6 +124,17 @@ var StepDrag = /** @class */ (function () {
|
|
|
124
124
|
_this.onDragEnd({ event: undefined });
|
|
125
125
|
_this.isDragging = false;
|
|
126
126
|
};
|
|
127
|
+
this.destroy = function () {
|
|
128
|
+
if (_this.isStartDragging) {
|
|
129
|
+
// https://github.com/didi/LogicFlow/issues/1934
|
|
130
|
+
// https://github.com/didi/LogicFlow/issues/1926
|
|
131
|
+
// cancelDrag()->onDragEnd()->updateEdgePointByAnchors()触发线的重新计算
|
|
132
|
+
// 我们的本意是为了防止mousemove和mouseup没有及时被移除
|
|
133
|
+
// 因此这里增加if(this.isStartDragging)的判断,isStartDragging=true代表没有触发handleMouseUp(),此时监听还没被移除
|
|
134
|
+
// 在拖拽情况下(isStartDragging=true),此时注册了监听,在组件突然销毁时,强制触发cancelDrag进行监听事件的移除
|
|
135
|
+
_this.cancelDrag();
|
|
136
|
+
}
|
|
137
|
+
};
|
|
127
138
|
this.onDragStart = onDragStart;
|
|
128
139
|
this.onDragging = onDragging;
|
|
129
140
|
this.onDragEnd = onDragEnd;
|
package/lib/util/graph.d.ts
CHANGED
package/lib/util/resize.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { ResizeControl, ResizeControlIndex } from '../view/Control';
|
|
|
2
2
|
import { BaseNodeModel, GraphModel } from '../model';
|
|
3
3
|
import ResizeInfo = ResizeControl.ResizeInfo;
|
|
4
4
|
import ResizeNodeData = ResizeControl.ResizeNodeData;
|
|
5
|
+
import type { SimplePoint } from '../algorithm/rotate';
|
|
5
6
|
/**
|
|
6
7
|
* 计算 Control 拖动后,节点的高度信息
|
|
7
8
|
* @param index
|
|
@@ -10,11 +11,23 @@ import ResizeNodeData = ResizeControl.ResizeNodeData;
|
|
|
10
11
|
* @param freezeWidth
|
|
11
12
|
* @param freezeHeight
|
|
12
13
|
*/
|
|
13
|
-
export declare const recalcResizeInfo: (index: ResizeControlIndex, resizeInfo: ResizeInfo, pct
|
|
14
|
+
export declare const recalcResizeInfo: (index: ResizeControlIndex, resizeInfo: ResizeInfo, pct: number | undefined, freezeWidth: boolean | undefined, freezeHeight: boolean | undefined, rotate: number | undefined, controlX: number | undefined, controlY: number | undefined, oldCenterX: number, oldCenterY: number) => ResizeInfo;
|
|
14
15
|
export declare const updateEdgePointByAnchors: (nodeModel: BaseNodeModel, graphModel: GraphModel) => void;
|
|
15
16
|
export declare const triggerResizeEvent: (preNodeData: ResizeNodeData, curNodeData: ResizeNodeData, deltaX: number, deltaY: number, index: number, nodeModel: BaseNodeModel, graphModel: GraphModel) => void;
|
|
17
|
+
export type IHandleResizeParams = {
|
|
18
|
+
x?: number;
|
|
19
|
+
y?: number;
|
|
20
|
+
deltaX: number;
|
|
21
|
+
deltaY: number;
|
|
22
|
+
index: ResizeControlIndex;
|
|
23
|
+
nodeModel: BaseNodeModel;
|
|
24
|
+
graphModel: GraphModel;
|
|
25
|
+
cancelCallback?: () => void;
|
|
26
|
+
};
|
|
16
27
|
/**
|
|
17
28
|
* 处理节点的 resize 事件,提出来放到 utils 中,方便在外面(extension)中使用
|
|
29
|
+
* @param x
|
|
30
|
+
* @param y
|
|
18
31
|
* @param deltaX
|
|
19
32
|
* @param deltaY
|
|
20
33
|
* @param index
|
|
@@ -22,11 +35,12 @@ export declare const triggerResizeEvent: (preNodeData: ResizeNodeData, curNodeDa
|
|
|
22
35
|
* @param graphModel
|
|
23
36
|
* @param cancelCallback
|
|
24
37
|
*/
|
|
25
|
-
export declare const handleResize: ({ deltaX, deltaY, index, nodeModel, graphModel, cancelCallback, }:
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
38
|
+
export declare const handleResize: ({ x, y, deltaX, deltaY, index, nodeModel, graphModel, cancelCallback, }: IHandleResizeParams) => void;
|
|
39
|
+
export declare function calculateWidthAndHeight(startRotatedTouchControlPoint: SimplePoint, endRotatedTouchControlPoint: SimplePoint, oldCenter: SimplePoint, angle: number, freezeWidth: boolean | undefined, freezeHeight: boolean | undefined, oldWidth: number, oldHeight: number): {
|
|
40
|
+
width: number;
|
|
41
|
+
height: number;
|
|
42
|
+
center: {
|
|
43
|
+
x: number;
|
|
44
|
+
y: number;
|
|
45
|
+
};
|
|
46
|
+
};
|