@logicflow/core 2.0.10 → 2.0.11
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 +2 -2
- package/.turbo/turbo-build.log +7 -7
- package/CHANGELOG.md +15 -5
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/es/LogicFlow.js +7 -0
- package/es/model/edge/BezierEdgeModel.js +2 -2
- package/es/model/edge/PolylineEdgeModel.js +2 -2
- package/es/model/node/BaseNodeModel.js +4 -0
- package/es/tool/index.js +2 -2
- package/es/util/node.d.ts +1 -1
- package/es/util/node.js +32 -16
- package/es/view/node/BaseNode.js +1 -5
- package/lib/LogicFlow.js +7 -0
- package/lib/model/edge/BezierEdgeModel.js +1 -1
- package/lib/model/edge/PolylineEdgeModel.js +1 -1
- package/lib/model/node/BaseNodeModel.js +4 -0
- package/lib/tool/index.js +2 -2
- package/lib/util/node.d.ts +1 -1
- package/lib/util/node.js +32 -16
- package/lib/view/node/BaseNode.js +0 -4
- package/package.json +1 -1
- package/src/LogicFlow.tsx +6 -0
- package/src/model/edge/BezierEdgeModel.ts +2 -2
- package/src/model/edge/PolylineEdgeModel.ts +2 -2
- package/src/model/node/BaseNodeModel.ts +4 -0
- package/src/tool/index.ts +2 -2
- package/src/util/node.ts +19 -18
- package/src/view/node/BaseNode.tsx +0 -6
- package/stats.html +1 -1
package/es/LogicFlow.js
CHANGED
|
@@ -1176,12 +1176,19 @@ var LogicFlow = /** @class */ (function () {
|
|
|
1176
1176
|
};
|
|
1177
1177
|
/** 销毁当前实例 */
|
|
1178
1178
|
LogicFlow.prototype.destroy = function () {
|
|
1179
|
+
var _a;
|
|
1179
1180
|
this.clearData();
|
|
1180
1181
|
render(null, this.container);
|
|
1181
1182
|
this.keyboard.destroy();
|
|
1182
1183
|
this.graphModel.destroy();
|
|
1183
1184
|
this.tool.destroy();
|
|
1184
1185
|
this.history.destroy();
|
|
1186
|
+
for (var extensionName in this.extension) {
|
|
1187
|
+
var extensionInstance = this.extension[extensionName];
|
|
1188
|
+
if ('destroy' in extensionInstance) {
|
|
1189
|
+
(_a = extensionInstance.destroy) === null || _a === void 0 ? void 0 : _a.call(extensionInstance);
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
1185
1192
|
};
|
|
1186
1193
|
// 全局配置的插件,所有的LogicFlow示例都会使用
|
|
1187
1194
|
LogicFlow.extensions = new Map();
|
|
@@ -46,7 +46,7 @@ var __read = (this && this.__read) || function (o, n) {
|
|
|
46
46
|
}
|
|
47
47
|
return ar;
|
|
48
48
|
};
|
|
49
|
-
import { assign, cloneDeep } from 'lodash-es';
|
|
49
|
+
import { get, assign, cloneDeep } from 'lodash-es';
|
|
50
50
|
import { action, observable } from 'mobx';
|
|
51
51
|
import BaseEdgeModel from './BaseEdgeModel';
|
|
52
52
|
import { ModelType } from '../../constant';
|
|
@@ -62,7 +62,7 @@ var BezierEdgeModel = /** @class */ (function (_super) {
|
|
|
62
62
|
return _this;
|
|
63
63
|
}
|
|
64
64
|
BezierEdgeModel.prototype.initEdgeData = function (data) {
|
|
65
|
-
this.offset = 100;
|
|
65
|
+
this.offset = get(data, 'properties.offset', 100);
|
|
66
66
|
_super.prototype.initEdgeData.call(this, data);
|
|
67
67
|
};
|
|
68
68
|
BezierEdgeModel.prototype.getEdgeStyle = function () {
|
|
@@ -55,7 +55,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
55
55
|
}
|
|
56
56
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
57
57
|
};
|
|
58
|
-
import { assign, cloneDeep } from 'lodash-es';
|
|
58
|
+
import { get, assign, cloneDeep } from 'lodash-es';
|
|
59
59
|
import { observable, action } from 'mobx';
|
|
60
60
|
import { BaseEdgeModel } from '.';
|
|
61
61
|
import { ModelType, SegmentDirection } from '../../constant';
|
|
@@ -69,7 +69,7 @@ var PolylineEdgeModel = /** @class */ (function (_super) {
|
|
|
69
69
|
return _this;
|
|
70
70
|
}
|
|
71
71
|
PolylineEdgeModel.prototype.initEdgeData = function (data) {
|
|
72
|
-
this.offset = 30;
|
|
72
|
+
this.offset = get(data, 'properties.offset', 30);
|
|
73
73
|
if (data.pointsList) {
|
|
74
74
|
this.pointsList = data.pointsList;
|
|
75
75
|
}
|
|
@@ -645,6 +645,10 @@ var BaseNodeModel = /** @class */ (function () {
|
|
|
645
645
|
this.text && this.moveText(0, deltaY);
|
|
646
646
|
moveY = deltaY;
|
|
647
647
|
}
|
|
648
|
+
this.transform = new TranslateMatrix(-this.x, -this.y)
|
|
649
|
+
.rotate(this.rotate)
|
|
650
|
+
.translate(this.x, this.y)
|
|
651
|
+
.toString();
|
|
648
652
|
return [moveX, moveY];
|
|
649
653
|
};
|
|
650
654
|
BaseNodeModel.prototype.moveTo = function (x, y, isIgnoreRule) {
|
package/es/tool/index.js
CHANGED
|
@@ -50,7 +50,7 @@ var Tool = /** @class */ (function () {
|
|
|
50
50
|
this.toolMap.delete(name);
|
|
51
51
|
return true;
|
|
52
52
|
}
|
|
53
|
-
throw new Error(
|
|
53
|
+
throw new Error("\u7981\u7528\u5931\u8D25\uFF0C\u4E0D\u5B58\u5728\u540D\u4E3A ".concat(tool, " \u7684\u5DE5\u5177"));
|
|
54
54
|
};
|
|
55
55
|
Tool.prototype.enableTool = function (name) {
|
|
56
56
|
var tool = this.disabledToolMap.get(name);
|
|
@@ -59,7 +59,7 @@ var Tool = /** @class */ (function () {
|
|
|
59
59
|
this.disabledToolMap.delete(name);
|
|
60
60
|
return true;
|
|
61
61
|
}
|
|
62
|
-
throw new Error(
|
|
62
|
+
throw new Error("\u4E0D\u5B58\u5728\u540D\u4E3A ".concat(tool, " \u7684\u5DE5\u5177"));
|
|
63
63
|
};
|
|
64
64
|
Tool.prototype.getTools = function () {
|
|
65
65
|
return Array.from(this.toolMap.values());
|
package/es/util/node.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export type NodeContaint = {
|
|
|
15
15
|
export declare const targetNodeInfo: (position: Point, graphModel: GraphModel) => NodeContaint;
|
|
16
16
|
export declare const getClosestAnchor: (position: Point, node: BaseNodeModel) => AnchorInfo;
|
|
17
17
|
export declare const distance: (x1: number, y1: number, x2: number, y2: number) => number;
|
|
18
|
-
export declare const isInNode: (position: Point, node: BaseNodeModel) => boolean;
|
|
18
|
+
export declare const isInNode: (position: Point, node: BaseNodeModel, offset?: number) => boolean;
|
|
19
19
|
export declare const isInNodeBbox: (position: Point, node: BaseNodeModel) => boolean;
|
|
20
20
|
export type NodeBBox = {
|
|
21
21
|
x: number;
|
package/es/util/node.js
CHANGED
|
@@ -9,10 +9,27 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
13
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
14
|
+
if (!m) return o;
|
|
15
|
+
var i = m.call(o), r, ar = [], e;
|
|
16
|
+
try {
|
|
17
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
18
|
+
}
|
|
19
|
+
catch (error) { e = { error: error }; }
|
|
20
|
+
finally {
|
|
21
|
+
try {
|
|
22
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
23
|
+
}
|
|
24
|
+
finally { if (e) throw e.error; }
|
|
25
|
+
}
|
|
26
|
+
return ar;
|
|
27
|
+
};
|
|
12
28
|
import { pick } from 'lodash-es';
|
|
13
29
|
import { getBytesLength } from './edge';
|
|
14
30
|
import { SegmentDirection } from '../constant';
|
|
15
31
|
import { isInSegment } from '../algorithm/edge';
|
|
32
|
+
import { Matrix } from './matrix';
|
|
16
33
|
/* 获取所有锚点 */
|
|
17
34
|
export var getAnchors = function (data) {
|
|
18
35
|
var anchors = data.anchors;
|
|
@@ -72,29 +89,28 @@ export var getClosestAnchor = function (position, node) {
|
|
|
72
89
|
/* 两点之间距离 */
|
|
73
90
|
export var distance = function (x1, y1, x2, y2) { return Math.hypot(x1 - x2, y1 - y2); };
|
|
74
91
|
/* 是否在某个节点内,手否进行连接,有offset控制粒度,与outline有关,可以优化 */
|
|
75
|
-
export var isInNode = function (position, node) {
|
|
92
|
+
export var isInNode = function (position, node, offset) {
|
|
93
|
+
if (offset === void 0) { offset = 0; }
|
|
76
94
|
var inNode = false;
|
|
77
|
-
var offset = 0;
|
|
78
95
|
var bBox = getNodeBBox(node);
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
96
|
+
var _a = __read(new Matrix([position.x, position.y, 1])
|
|
97
|
+
.translate(-node.x, -node.y)
|
|
98
|
+
.rotate(-node.rotate)
|
|
99
|
+
.translate(node.x, node.y)[0], 2), x = _a[0], y = _a[1];
|
|
100
|
+
var reverseRotatedPosition = {
|
|
101
|
+
x: x,
|
|
102
|
+
y: y,
|
|
103
|
+
};
|
|
104
|
+
if (reverseRotatedPosition.x >= bBox.minX - offset &&
|
|
105
|
+
reverseRotatedPosition.x <= bBox.maxX + offset &&
|
|
106
|
+
reverseRotatedPosition.y >= bBox.minY - offset &&
|
|
107
|
+
reverseRotatedPosition.y <= bBox.maxY + offset) {
|
|
83
108
|
inNode = true;
|
|
84
109
|
}
|
|
85
110
|
return inNode;
|
|
86
111
|
};
|
|
87
112
|
export var isInNodeBbox = function (position, node) {
|
|
88
|
-
|
|
89
|
-
var offset = 5;
|
|
90
|
-
var bBox = getNodeBBox(node);
|
|
91
|
-
if (position.x >= bBox.minX - offset &&
|
|
92
|
-
position.x <= bBox.maxX + offset &&
|
|
93
|
-
position.y >= bBox.minY - offset &&
|
|
94
|
-
position.y <= bBox.maxY + offset) {
|
|
95
|
-
inNode = true;
|
|
96
|
-
}
|
|
97
|
-
return inNode;
|
|
113
|
+
return isInNode(position, node, 5);
|
|
98
114
|
};
|
|
99
115
|
/* 获取节点bbox */
|
|
100
116
|
export var getNodeBBox = function (node) {
|
package/es/view/node/BaseNode.js
CHANGED
|
@@ -58,7 +58,7 @@ import { map } from 'lodash-es';
|
|
|
58
58
|
import Anchor from '../Anchor';
|
|
59
59
|
import { BaseText } from '../text';
|
|
60
60
|
import { ElementState, EventType, TextMode } from '../../constant';
|
|
61
|
-
import { StepDrag, snapToGrid, isIe, isMultipleSelect, cancelRaf, createRaf,
|
|
61
|
+
import { StepDrag, snapToGrid, isIe, isMultipleSelect, cancelRaf, createRaf,
|
|
62
62
|
// RotateMatrix,
|
|
63
63
|
} from '../../util';
|
|
64
64
|
import RotateControlPoint from '../Rotate';
|
|
@@ -135,10 +135,6 @@ var BaseNode = /** @class */ (function (_super) {
|
|
|
135
135
|
if (_this.t) {
|
|
136
136
|
cancelRaf(_this.t);
|
|
137
137
|
}
|
|
138
|
-
model.transform = new TranslateMatrix(-x, -y)
|
|
139
|
-
.rotate(model.rotate)
|
|
140
|
-
.translate(x, y)
|
|
141
|
-
.toString();
|
|
142
138
|
var moveNodes = selectNodes.map(function (node) { return node.id; });
|
|
143
139
|
// 未被选中的节点也可以拖动
|
|
144
140
|
if (moveNodes.indexOf(model.id) === -1) {
|
package/lib/LogicFlow.js
CHANGED
|
@@ -1205,12 +1205,19 @@ var LogicFlow = /** @class */ (function () {
|
|
|
1205
1205
|
};
|
|
1206
1206
|
/** 销毁当前实例 */
|
|
1207
1207
|
LogicFlow.prototype.destroy = function () {
|
|
1208
|
+
var _a;
|
|
1208
1209
|
this.clearData();
|
|
1209
1210
|
(0, compat_1.render)(null, this.container);
|
|
1210
1211
|
this.keyboard.destroy();
|
|
1211
1212
|
this.graphModel.destroy();
|
|
1212
1213
|
this.tool.destroy();
|
|
1213
1214
|
this.history.destroy();
|
|
1215
|
+
for (var extensionName in this.extension) {
|
|
1216
|
+
var extensionInstance = this.extension[extensionName];
|
|
1217
|
+
if ('destroy' in extensionInstance) {
|
|
1218
|
+
(_a = extensionInstance.destroy) === null || _a === void 0 ? void 0 : _a.call(extensionInstance);
|
|
1219
|
+
}
|
|
1220
|
+
}
|
|
1214
1221
|
};
|
|
1215
1222
|
// 全局配置的插件,所有的LogicFlow示例都会使用
|
|
1216
1223
|
LogicFlow.extensions = new Map();
|
|
@@ -68,7 +68,7 @@ var BezierEdgeModel = /** @class */ (function (_super) {
|
|
|
68
68
|
return _this;
|
|
69
69
|
}
|
|
70
70
|
BezierEdgeModel.prototype.initEdgeData = function (data) {
|
|
71
|
-
this.offset = 100;
|
|
71
|
+
this.offset = (0, lodash_es_1.get)(data, 'properties.offset', 100);
|
|
72
72
|
_super.prototype.initEdgeData.call(this, data);
|
|
73
73
|
};
|
|
74
74
|
BezierEdgeModel.prototype.getEdgeStyle = function () {
|
|
@@ -72,7 +72,7 @@ var PolylineEdgeModel = /** @class */ (function (_super) {
|
|
|
72
72
|
return _this;
|
|
73
73
|
}
|
|
74
74
|
PolylineEdgeModel.prototype.initEdgeData = function (data) {
|
|
75
|
-
this.offset = 30;
|
|
75
|
+
this.offset = (0, lodash_es_1.get)(data, 'properties.offset', 30);
|
|
76
76
|
if (data.pointsList) {
|
|
77
77
|
this.pointsList = data.pointsList;
|
|
78
78
|
}
|
|
@@ -648,6 +648,10 @@ var BaseNodeModel = /** @class */ (function () {
|
|
|
648
648
|
this.text && this.moveText(0, deltaY);
|
|
649
649
|
moveY = deltaY;
|
|
650
650
|
}
|
|
651
|
+
this.transform = new util_1.TranslateMatrix(-this.x, -this.y)
|
|
652
|
+
.rotate(this.rotate)
|
|
653
|
+
.translate(this.x, this.y)
|
|
654
|
+
.toString();
|
|
651
655
|
return [moveX, moveY];
|
|
652
656
|
};
|
|
653
657
|
BaseNodeModel.prototype.moveTo = function (x, y, isIgnoreRule) {
|
package/lib/tool/index.js
CHANGED
|
@@ -56,7 +56,7 @@ var Tool = /** @class */ (function () {
|
|
|
56
56
|
this.toolMap.delete(name);
|
|
57
57
|
return true;
|
|
58
58
|
}
|
|
59
|
-
throw new Error(
|
|
59
|
+
throw new Error("\u7981\u7528\u5931\u8D25\uFF0C\u4E0D\u5B58\u5728\u540D\u4E3A ".concat(tool, " \u7684\u5DE5\u5177"));
|
|
60
60
|
};
|
|
61
61
|
Tool.prototype.enableTool = function (name) {
|
|
62
62
|
var tool = this.disabledToolMap.get(name);
|
|
@@ -65,7 +65,7 @@ var Tool = /** @class */ (function () {
|
|
|
65
65
|
this.disabledToolMap.delete(name);
|
|
66
66
|
return true;
|
|
67
67
|
}
|
|
68
|
-
throw new Error(
|
|
68
|
+
throw new Error("\u4E0D\u5B58\u5728\u540D\u4E3A ".concat(tool, " \u7684\u5DE5\u5177"));
|
|
69
69
|
};
|
|
70
70
|
Tool.prototype.getTools = function () {
|
|
71
71
|
return Array.from(this.toolMap.values());
|
package/lib/util/node.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export type NodeContaint = {
|
|
|
15
15
|
export declare const targetNodeInfo: (position: Point, graphModel: GraphModel) => NodeContaint;
|
|
16
16
|
export declare const getClosestAnchor: (position: Point, node: BaseNodeModel) => AnchorInfo;
|
|
17
17
|
export declare const distance: (x1: number, y1: number, x2: number, y2: number) => number;
|
|
18
|
-
export declare const isInNode: (position: Point, node: BaseNodeModel) => boolean;
|
|
18
|
+
export declare const isInNode: (position: Point, node: BaseNodeModel, offset?: number) => boolean;
|
|
19
19
|
export declare const isInNodeBbox: (position: Point, node: BaseNodeModel) => boolean;
|
|
20
20
|
export type NodeBBox = {
|
|
21
21
|
x: number;
|
package/lib/util/node.js
CHANGED
|
@@ -10,12 +10,29 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
};
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
14
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
15
|
+
if (!m) return o;
|
|
16
|
+
var i = m.call(o), r, ar = [], e;
|
|
17
|
+
try {
|
|
18
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
19
|
+
}
|
|
20
|
+
catch (error) { e = { error: error }; }
|
|
21
|
+
finally {
|
|
22
|
+
try {
|
|
23
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
24
|
+
}
|
|
25
|
+
finally { if (e) throw e.error; }
|
|
26
|
+
}
|
|
27
|
+
return ar;
|
|
28
|
+
};
|
|
13
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
30
|
exports.formatAnchorConnectValidateData = exports.getSvgTextWidthHeight = exports.getHtmlTextHeight = exports.getNodeAnchorPosition = exports.pickNodeConfig = exports.getCrossPointWithPolygon = exports.getCrossPointWithEllipse = exports.inStraightLineOfRect = exports.pointEdgeDirection = exports.getCrossPointWithCircle = exports.getClosestRadiusCenter = exports.getRectRadiusCircle = exports.getNodeBBox = exports.isInNodeBbox = exports.isInNode = exports.distance = exports.getClosestAnchor = exports.targetNodeInfo = exports.getAnchors = void 0;
|
|
15
31
|
var lodash_es_1 = require("lodash-es");
|
|
16
32
|
var edge_1 = require("./edge");
|
|
17
33
|
var constant_1 = require("../constant");
|
|
18
34
|
var edge_2 = require("../algorithm/edge");
|
|
35
|
+
var matrix_1 = require("./matrix");
|
|
19
36
|
/* 获取所有锚点 */
|
|
20
37
|
var getAnchors = function (data) {
|
|
21
38
|
var anchors = data.anchors;
|
|
@@ -79,30 +96,29 @@ exports.getClosestAnchor = getClosestAnchor;
|
|
|
79
96
|
var distance = function (x1, y1, x2, y2) { return Math.hypot(x1 - x2, y1 - y2); };
|
|
80
97
|
exports.distance = distance;
|
|
81
98
|
/* 是否在某个节点内,手否进行连接,有offset控制粒度,与outline有关,可以优化 */
|
|
82
|
-
var isInNode = function (position, node) {
|
|
99
|
+
var isInNode = function (position, node, offset) {
|
|
100
|
+
if (offset === void 0) { offset = 0; }
|
|
83
101
|
var inNode = false;
|
|
84
|
-
var offset = 0;
|
|
85
102
|
var bBox = (0, exports.getNodeBBox)(node);
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
103
|
+
var _a = __read(new matrix_1.Matrix([position.x, position.y, 1])
|
|
104
|
+
.translate(-node.x, -node.y)
|
|
105
|
+
.rotate(-node.rotate)
|
|
106
|
+
.translate(node.x, node.y)[0], 2), x = _a[0], y = _a[1];
|
|
107
|
+
var reverseRotatedPosition = {
|
|
108
|
+
x: x,
|
|
109
|
+
y: y,
|
|
110
|
+
};
|
|
111
|
+
if (reverseRotatedPosition.x >= bBox.minX - offset &&
|
|
112
|
+
reverseRotatedPosition.x <= bBox.maxX + offset &&
|
|
113
|
+
reverseRotatedPosition.y >= bBox.minY - offset &&
|
|
114
|
+
reverseRotatedPosition.y <= bBox.maxY + offset) {
|
|
90
115
|
inNode = true;
|
|
91
116
|
}
|
|
92
117
|
return inNode;
|
|
93
118
|
};
|
|
94
119
|
exports.isInNode = isInNode;
|
|
95
120
|
var isInNodeBbox = function (position, node) {
|
|
96
|
-
|
|
97
|
-
var offset = 5;
|
|
98
|
-
var bBox = (0, exports.getNodeBBox)(node);
|
|
99
|
-
if (position.x >= bBox.minX - offset &&
|
|
100
|
-
position.x <= bBox.maxX + offset &&
|
|
101
|
-
position.y >= bBox.minY - offset &&
|
|
102
|
-
position.y <= bBox.maxY + offset) {
|
|
103
|
-
inNode = true;
|
|
104
|
-
}
|
|
105
|
-
return inNode;
|
|
121
|
+
return (0, exports.isInNode)(position, node, 5);
|
|
106
122
|
};
|
|
107
123
|
exports.isInNodeBbox = isInNodeBbox;
|
|
108
124
|
/* 获取节点bbox */
|
|
@@ -139,10 +139,6 @@ var BaseNode = /** @class */ (function (_super) {
|
|
|
139
139
|
if (_this.t) {
|
|
140
140
|
(0, util_1.cancelRaf)(_this.t);
|
|
141
141
|
}
|
|
142
|
-
model.transform = new util_1.TranslateMatrix(-x, -y)
|
|
143
|
-
.rotate(model.rotate)
|
|
144
|
-
.translate(x, y)
|
|
145
|
-
.toString();
|
|
146
142
|
var moveNodes = selectNodes.map(function (node) { return node.id; });
|
|
147
143
|
// 未被选中的节点也可以拖动
|
|
148
144
|
if (moveNodes.indexOf(model.id) === -1) {
|
package/package.json
CHANGED
package/src/LogicFlow.tsx
CHANGED
|
@@ -1391,6 +1391,12 @@ export class LogicFlow {
|
|
|
1391
1391
|
this.graphModel.destroy()
|
|
1392
1392
|
this.tool.destroy()
|
|
1393
1393
|
this.history.destroy()
|
|
1394
|
+
for (const extensionName in this.extension) {
|
|
1395
|
+
const extensionInstance = this.extension[extensionName]
|
|
1396
|
+
if ('destroy' in extensionInstance) {
|
|
1397
|
+
extensionInstance.destroy?.()
|
|
1398
|
+
}
|
|
1399
|
+
}
|
|
1394
1400
|
}
|
|
1395
1401
|
}
|
|
1396
1402
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { assign, cloneDeep } from 'lodash-es'
|
|
1
|
+
import { get, assign, cloneDeep } from 'lodash-es'
|
|
2
2
|
import { action, observable } from 'mobx'
|
|
3
3
|
import BaseEdgeModel from './BaseEdgeModel'
|
|
4
4
|
import { BaseNodeModel } from '../node'
|
|
@@ -21,7 +21,7 @@ export class BezierEdgeModel extends BaseEdgeModel {
|
|
|
21
21
|
this.setAttributes()
|
|
22
22
|
}
|
|
23
23
|
initEdgeData(data: EdgeConfig): void {
|
|
24
|
-
this.offset = 100
|
|
24
|
+
this.offset = get(data, 'properties.offset', 100)
|
|
25
25
|
super.initEdgeData(data)
|
|
26
26
|
}
|
|
27
27
|
getEdgeStyle() {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { assign, cloneDeep } from 'lodash-es'
|
|
1
|
+
import { get, assign, cloneDeep } from 'lodash-es'
|
|
2
2
|
import { observable, action } from 'mobx'
|
|
3
3
|
import { BaseEdgeModel } from '.'
|
|
4
4
|
import { BaseNodeModel, RectNodeModel, CircleNodeModel, Model } from '..'
|
|
@@ -34,7 +34,7 @@ export class PolylineEdgeModel extends BaseEdgeModel {
|
|
|
34
34
|
@observable dbClickPosition?: Point
|
|
35
35
|
|
|
36
36
|
initEdgeData(data: LogicFlow.EdgeConfig): void {
|
|
37
|
-
this.offset = 30
|
|
37
|
+
this.offset = get(data, 'properties.offset', 30)
|
|
38
38
|
if (data.pointsList) {
|
|
39
39
|
this.pointsList = data.pointsList
|
|
40
40
|
}
|
|
@@ -740,6 +740,10 @@ export class BaseNodeModel<P extends PropertiesType = PropertiesType>
|
|
|
740
740
|
this.text && this.moveText(0, deltaY)
|
|
741
741
|
moveY = deltaY
|
|
742
742
|
}
|
|
743
|
+
this.transform = new TranslateMatrix(-this.x, -this.y)
|
|
744
|
+
.rotate(this.rotate)
|
|
745
|
+
.translate(this.x, this.y)
|
|
746
|
+
.toString()
|
|
743
747
|
return [moveX, moveY]
|
|
744
748
|
}
|
|
745
749
|
|
package/src/tool/index.ts
CHANGED
|
@@ -70,7 +70,7 @@ export class Tool {
|
|
|
70
70
|
this.toolMap.delete(name)
|
|
71
71
|
return true
|
|
72
72
|
}
|
|
73
|
-
throw new Error(
|
|
73
|
+
throw new Error(`禁用失败,不存在名为 ${tool} 的工具`)
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
@action
|
|
@@ -81,7 +81,7 @@ export class Tool {
|
|
|
81
81
|
this.disabledToolMap.delete(name)
|
|
82
82
|
return true
|
|
83
83
|
}
|
|
84
|
-
throw new Error(
|
|
84
|
+
throw new Error(`不存在名为 ${tool} 的工具`)
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
getTools() {
|
package/src/util/node.ts
CHANGED
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
} from '../model'
|
|
14
14
|
import { SegmentDirection } from '../constant'
|
|
15
15
|
import { isInSegment } from '../algorithm/edge'
|
|
16
|
+
import { Matrix } from './matrix'
|
|
16
17
|
|
|
17
18
|
import Point = LogicFlow.Point
|
|
18
19
|
import Direction = LogicFlow.Direction
|
|
@@ -112,33 +113,33 @@ export const distance = (
|
|
|
112
113
|
): number => Math.hypot(x1 - x2, y1 - y2)
|
|
113
114
|
|
|
114
115
|
/* 是否在某个节点内,手否进行连接,有offset控制粒度,与outline有关,可以优化 */
|
|
115
|
-
export const isInNode = (
|
|
116
|
+
export const isInNode = (
|
|
117
|
+
position: Point,
|
|
118
|
+
node: BaseNodeModel,
|
|
119
|
+
offset = 0,
|
|
120
|
+
): boolean => {
|
|
116
121
|
let inNode = false
|
|
117
|
-
const offset = 0
|
|
118
122
|
const bBox = getNodeBBox(node)
|
|
123
|
+
const [x, y] = new Matrix([position.x, position.y, 1])
|
|
124
|
+
.translate(-node.x, -node.y)
|
|
125
|
+
.rotate(-node.rotate)
|
|
126
|
+
.translate(node.x, node.y)[0]
|
|
127
|
+
const reverseRotatedPosition = {
|
|
128
|
+
x,
|
|
129
|
+
y,
|
|
130
|
+
}
|
|
119
131
|
if (
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
132
|
+
reverseRotatedPosition.x >= bBox.minX - offset &&
|
|
133
|
+
reverseRotatedPosition.x <= bBox.maxX + offset &&
|
|
134
|
+
reverseRotatedPosition.y >= bBox.minY - offset &&
|
|
135
|
+
reverseRotatedPosition.y <= bBox.maxY + offset
|
|
124
136
|
) {
|
|
125
137
|
inNode = true
|
|
126
138
|
}
|
|
127
139
|
return inNode
|
|
128
140
|
}
|
|
129
141
|
export const isInNodeBbox = (position: Point, node: BaseNodeModel): boolean => {
|
|
130
|
-
|
|
131
|
-
const offset = 5
|
|
132
|
-
const bBox = getNodeBBox(node)
|
|
133
|
-
if (
|
|
134
|
-
position.x >= bBox.minX - offset &&
|
|
135
|
-
position.x <= bBox.maxX + offset &&
|
|
136
|
-
position.y >= bBox.minY - offset &&
|
|
137
|
-
position.y <= bBox.maxY + offset
|
|
138
|
-
) {
|
|
139
|
-
inNode = true
|
|
140
|
-
}
|
|
141
|
-
return inNode
|
|
142
|
+
return isInNode(position, node, 5)
|
|
142
143
|
}
|
|
143
144
|
|
|
144
145
|
export type NodeBBox = {
|
|
@@ -13,7 +13,6 @@ import {
|
|
|
13
13
|
isMultipleSelect,
|
|
14
14
|
cancelRaf,
|
|
15
15
|
createRaf,
|
|
16
|
-
TranslateMatrix,
|
|
17
16
|
IDragParams,
|
|
18
17
|
// RotateMatrix,
|
|
19
18
|
} from '../../util'
|
|
@@ -297,11 +296,6 @@ export abstract class BaseNode<P extends IProps = IProps> extends Component<
|
|
|
297
296
|
cancelRaf(this.t)
|
|
298
297
|
}
|
|
299
298
|
|
|
300
|
-
model.transform = new TranslateMatrix(-x, -y)
|
|
301
|
-
.rotate(model.rotate)
|
|
302
|
-
.translate(x, y)
|
|
303
|
-
.toString()
|
|
304
|
-
|
|
305
299
|
let moveNodes = selectNodes.map((node) => node.id)
|
|
306
300
|
// 未被选中的节点也可以拖动
|
|
307
301
|
if (moveNodes.indexOf(model.id) === -1) {
|