@logicflow/extension 1.1.5 → 1.1.7-alpha.1
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/cjs/NodeResize/Node/DiamondResize.js +7 -10
- package/cjs/NodeResize/Node/EllipseResize.js +5 -10
- package/cjs/NodeResize/Node/HtmlResize.js +7 -10
- package/cjs/NodeResize/Node/RectResize.js +7 -10
- package/cjs/components/mini-map/index.js +4 -14
- package/cjs/tools/auto-layout/index.js +28 -3
- package/es/NodeResize/Node/DiamondResize.d.ts +1 -1
- package/es/NodeResize/Node/DiamondResize.js +7 -10
- package/es/NodeResize/Node/EllipseResize.d.ts +0 -1
- package/es/NodeResize/Node/EllipseResize.js +5 -10
- package/es/NodeResize/Node/HtmlResize.d.ts +1 -1
- package/es/NodeResize/Node/HtmlResize.js +7 -10
- package/es/NodeResize/Node/RectResize.d.ts +1 -1
- package/es/NodeResize/Node/RectResize.js +7 -10
- package/es/components/mini-map/index.js +4 -14
- package/es/tools/auto-layout/index.d.ts +2 -1
- package/es/tools/auto-layout/index.js +29 -4
- package/lib/AutoLayout.js +1 -1
- package/lib/BpmnAdapter.js +1 -1
- package/lib/BpmnElement.js +1 -1
- package/lib/ContextMenu.js +1 -1
- package/lib/Control.js +1 -1
- package/lib/CurvedEdge.js +1 -1
- package/lib/DndPanel.js +1 -1
- package/lib/FlowPath.js +1 -1
- package/lib/Group.js +1 -1
- package/lib/InsertNodeInPolyline.js +1 -1
- package/lib/Menu.js +1 -1
- package/lib/MiniMap.js +1 -1
- package/lib/NodeResize.js +1 -1
- package/lib/RectLabelNode.js +1 -1
- package/lib/SelectionSelect.js +1 -1
- package/lib/Snapshot.js +1 -1
- package/lib/TurboAdapter.js +1 -1
- package/lib/lfJson2Xml.js +1 -1
- package/lib/lfXml2Json.js +1 -1
- package/package.json +2 -2
- package/types/NodeResize/Node/DiamondResize.d.ts +1 -1
- package/types/NodeResize/Node/EllipseResize.d.ts +0 -1
- package/types/NodeResize/Node/HtmlResize.d.ts +1 -1
- package/types/NodeResize/Node/RectResize.d.ts +1 -1
- package/types/tools/auto-layout/index.d.ts +2 -1
|
@@ -29,12 +29,17 @@ var ControlGroup_1 = require("../Control/ControlGroup");
|
|
|
29
29
|
var Polygon_1 = require("../BasicShape/Polygon");
|
|
30
30
|
var DiamondResizeModel = /** @class */ (function (_super) {
|
|
31
31
|
__extends(DiamondResizeModel, _super);
|
|
32
|
-
function DiamondResizeModel() {
|
|
33
|
-
var _this = _super
|
|
32
|
+
function DiamondResizeModel(data, graphModel) {
|
|
33
|
+
var _this = _super.call(this, data, graphModel) || this;
|
|
34
34
|
_this.minWidth = 30;
|
|
35
35
|
_this.minHeight = 30;
|
|
36
36
|
_this.maxWidth = 2000;
|
|
37
37
|
_this.maxHeight = 2000;
|
|
38
|
+
var nodeSize = _this.properties.nodeSize;
|
|
39
|
+
if (nodeSize) {
|
|
40
|
+
_this.rx = nodeSize.rx;
|
|
41
|
+
_this.ry = nodeSize.ry;
|
|
42
|
+
}
|
|
38
43
|
return _this;
|
|
39
44
|
}
|
|
40
45
|
DiamondResizeModel.prototype.getOutlineStyle = function () {
|
|
@@ -60,14 +65,6 @@ var DiamondResizeModel = /** @class */ (function (_super) {
|
|
|
60
65
|
stroke: '#000000',
|
|
61
66
|
};
|
|
62
67
|
};
|
|
63
|
-
DiamondResizeModel.prototype.setAttributes = function () {
|
|
64
|
-
// @ts-ignore
|
|
65
|
-
var nodeSize = this.properties.nodeSize;
|
|
66
|
-
if (nodeSize) {
|
|
67
|
-
this.rx = nodeSize.rx;
|
|
68
|
-
this.ry = nodeSize.ry;
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
68
|
return DiamondResizeModel;
|
|
72
69
|
}(core_1.DiamondNodeModel));
|
|
73
70
|
var DiamondResizeView = /** @class */ (function (_super) {
|
|
@@ -23,8 +23,11 @@ var EllipseResizeModel = /** @class */ (function (_super) {
|
|
|
23
23
|
_this.minHeight = 30;
|
|
24
24
|
_this.maxWidth = 2000;
|
|
25
25
|
_this.maxHeight = 2000;
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
var nodeSize = _this.properties.nodeSize;
|
|
27
|
+
if (nodeSize) {
|
|
28
|
+
_this.rx = nodeSize.rx;
|
|
29
|
+
_this.ry = nodeSize.ry;
|
|
30
|
+
}
|
|
28
31
|
return _this;
|
|
29
32
|
}
|
|
30
33
|
EllipseResizeModel.prototype.getOutlineStyle = function () {
|
|
@@ -50,14 +53,6 @@ var EllipseResizeModel = /** @class */ (function (_super) {
|
|
|
50
53
|
stroke: '#000000',
|
|
51
54
|
};
|
|
52
55
|
};
|
|
53
|
-
EllipseResizeModel.prototype.setAttributes = function () {
|
|
54
|
-
// @ts-ignore
|
|
55
|
-
var nodeSize = this.properties.nodeSize;
|
|
56
|
-
if (nodeSize) {
|
|
57
|
-
this.rx = nodeSize.rx;
|
|
58
|
-
this.ry = nodeSize.ry;
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
56
|
return EllipseResizeModel;
|
|
62
57
|
}(core_1.EllipseNodeModel));
|
|
63
58
|
var EllipseResizeView = /** @class */ (function (_super) {
|
|
@@ -17,12 +17,17 @@ var core_1 = require("@logicflow/core");
|
|
|
17
17
|
var ControlGroup_1 = require("../Control/ControlGroup");
|
|
18
18
|
var HtmlResizeModel = /** @class */ (function (_super) {
|
|
19
19
|
__extends(HtmlResizeModel, _super);
|
|
20
|
-
function HtmlResizeModel() {
|
|
21
|
-
var _this = _super
|
|
20
|
+
function HtmlResizeModel(data, graphModel) {
|
|
21
|
+
var _this = _super.call(this, data, graphModel) || this;
|
|
22
22
|
_this.minWidth = 30;
|
|
23
23
|
_this.minHeight = 30;
|
|
24
24
|
_this.maxWidth = 2000;
|
|
25
25
|
_this.maxHeight = 2000;
|
|
26
|
+
var nodeSize = _this.properties.nodeSize;
|
|
27
|
+
if (nodeSize) {
|
|
28
|
+
_this.width = nodeSize.width;
|
|
29
|
+
_this.height = nodeSize.height;
|
|
30
|
+
}
|
|
26
31
|
return _this;
|
|
27
32
|
}
|
|
28
33
|
HtmlResizeModel.prototype.getOutlineStyle = function () {
|
|
@@ -48,14 +53,6 @@ var HtmlResizeModel = /** @class */ (function (_super) {
|
|
|
48
53
|
stroke: '#000000',
|
|
49
54
|
};
|
|
50
55
|
};
|
|
51
|
-
HtmlResizeModel.prototype.setAttributes = function () {
|
|
52
|
-
// @ts-ignore
|
|
53
|
-
var nodeSize = this.properties.nodeSize;
|
|
54
|
-
if (nodeSize) {
|
|
55
|
-
this.width = nodeSize.width;
|
|
56
|
-
this.height = nodeSize.height;
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
56
|
return HtmlResizeModel;
|
|
60
57
|
}(core_1.HtmlNodeModel));
|
|
61
58
|
var HtmlResizeView = /** @class */ (function (_super) {
|
|
@@ -17,12 +17,17 @@ var core_1 = require("@logicflow/core");
|
|
|
17
17
|
var ControlGroup_1 = require("../Control/ControlGroup");
|
|
18
18
|
var RectResizeModel = /** @class */ (function (_super) {
|
|
19
19
|
__extends(RectResizeModel, _super);
|
|
20
|
-
function RectResizeModel() {
|
|
21
|
-
var _this = _super
|
|
20
|
+
function RectResizeModel(data, graphModel) {
|
|
21
|
+
var _this = _super.call(this, data, graphModel) || this;
|
|
22
22
|
_this.minWidth = 30;
|
|
23
23
|
_this.minHeight = 30;
|
|
24
24
|
_this.maxWidth = 2000;
|
|
25
25
|
_this.maxHeight = 2000;
|
|
26
|
+
var nodeSize = _this.properties.nodeSize;
|
|
27
|
+
if (nodeSize) {
|
|
28
|
+
_this.width = nodeSize.width;
|
|
29
|
+
_this.height = nodeSize.height;
|
|
30
|
+
}
|
|
26
31
|
return _this;
|
|
27
32
|
}
|
|
28
33
|
RectResizeModel.prototype.getOutlineStyle = function () {
|
|
@@ -49,14 +54,6 @@ var RectResizeModel = /** @class */ (function (_super) {
|
|
|
49
54
|
stroke: '#000000',
|
|
50
55
|
};
|
|
51
56
|
};
|
|
52
|
-
RectResizeModel.prototype.setAttributes = function () {
|
|
53
|
-
// @ts-ignore
|
|
54
|
-
var nodeSize = this.properties.nodeSize;
|
|
55
|
-
if (nodeSize) {
|
|
56
|
-
this.width = nodeSize.width;
|
|
57
|
-
this.height = nodeSize.height;
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
57
|
RectResizeModel.prototype.resize = function (deltaX, deltaY) {
|
|
61
58
|
console.log(deltaX, deltaY);
|
|
62
59
|
};
|
|
@@ -98,20 +98,10 @@ var MiniMap = /** @class */ (function () {
|
|
|
98
98
|
MiniMap.prototype.render = function (lf, container) {
|
|
99
99
|
var _this = this;
|
|
100
100
|
this.__container = container;
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
'edge:delete',
|
|
106
|
-
'node:drop',
|
|
107
|
-
'blank:drop',
|
|
108
|
-
];
|
|
109
|
-
events.forEach(function (eventName) {
|
|
110
|
-
_this.__lf.on(eventName, function () {
|
|
111
|
-
if (_this.__isShow) {
|
|
112
|
-
_this.__setView();
|
|
113
|
-
}
|
|
114
|
-
});
|
|
101
|
+
this.__lf.on('history:change', function () {
|
|
102
|
+
if (_this.__isShow) {
|
|
103
|
+
_this.__setView();
|
|
104
|
+
}
|
|
115
105
|
});
|
|
116
106
|
};
|
|
117
107
|
MiniMap.prototype.init = function (option) {
|
|
@@ -27,6 +27,20 @@ var AutoLayout = /** @class */ (function () {
|
|
|
27
27
|
var _this = this;
|
|
28
28
|
var lf = _a.lf;
|
|
29
29
|
this.lf = lf;
|
|
30
|
+
/**
|
|
31
|
+
* 用于记录上一次调用layout时计算出的trunk
|
|
32
|
+
* 当旧trunk和新trunk长度一致时,用于选择旧trunk,
|
|
33
|
+
* a->b->c->d
|
|
34
|
+
* |->e
|
|
35
|
+
* e后面新增f节点时候,旧逻辑会返回新trunk[a,b,e,f]
|
|
36
|
+
* 界面布局变成
|
|
37
|
+
* a->b->e->f
|
|
38
|
+
* |->c->d
|
|
39
|
+
* 其实只想要这样 尽量少变化
|
|
40
|
+
* a->b->c->d
|
|
41
|
+
* |->e->f
|
|
42
|
+
* */
|
|
43
|
+
this.trunk = [];
|
|
30
44
|
// 给lf添加方法
|
|
31
45
|
lf.layout = function (startNodeType) {
|
|
32
46
|
var data = _this.lf.getGraphRawData();
|
|
@@ -43,12 +57,22 @@ var AutoLayout = /** @class */ (function () {
|
|
|
43
57
|
// 拿到最长的路径。
|
|
44
58
|
// nodes: [], edges: [],
|
|
45
59
|
AutoLayout.prototype.layout = function (data, path) {
|
|
60
|
+
var _this = this;
|
|
46
61
|
var trunk = [];
|
|
47
62
|
path.forEach(function (p) {
|
|
48
|
-
|
|
49
|
-
|
|
63
|
+
var elements = p.elements;
|
|
64
|
+
if (elements.length > trunk.length) {
|
|
65
|
+
trunk = elements;
|
|
66
|
+
}
|
|
67
|
+
else if (elements.length === trunk.length) {
|
|
68
|
+
// 考虑是否替换为旧的trunk
|
|
69
|
+
if (JSON.stringify(elements) === JSON.stringify(_this.trunk)) {
|
|
70
|
+
trunk = _this.trunk;
|
|
71
|
+
}
|
|
50
72
|
}
|
|
51
73
|
});
|
|
74
|
+
// 记录上一次trunk
|
|
75
|
+
this.trunk = trunk;
|
|
52
76
|
var nodeMap = this.formatData(data);
|
|
53
77
|
var newGraphData = {
|
|
54
78
|
nodes: [],
|
|
@@ -182,7 +206,8 @@ var AutoLayout = /** @class */ (function () {
|
|
|
182
206
|
AutoLayout.prototype.formatData = function (data) {
|
|
183
207
|
var nodeMap = data.nodes.reduce(function (nMap, node) {
|
|
184
208
|
var type = node.type, properties = node.properties, text = node.text, x = node.x, y = node.y;
|
|
185
|
-
if (text && typeof text === 'object') {
|
|
209
|
+
if (text && typeof text === 'object') {
|
|
210
|
+
// 坐标转换为偏移量
|
|
186
211
|
text.x = text.x - x;
|
|
187
212
|
text.y = text.y - y;
|
|
188
213
|
}
|
|
@@ -4,6 +4,7 @@ declare class DiamondResizeModel extends DiamondNodeModel {
|
|
|
4
4
|
minHeight: number;
|
|
5
5
|
maxWidth: number;
|
|
6
6
|
maxHeight: number;
|
|
7
|
+
constructor(data: any, graphModel: any);
|
|
7
8
|
getOutlineStyle(): import("@logicflow/core/types/constant/DefaultTheme").OutlineTheme;
|
|
8
9
|
getResizeOutlineStyle(): {
|
|
9
10
|
stroke: string;
|
|
@@ -16,7 +17,6 @@ declare class DiamondResizeModel extends DiamondNodeModel {
|
|
|
16
17
|
fill: string;
|
|
17
18
|
stroke: string;
|
|
18
19
|
};
|
|
19
|
-
setAttributes(): void;
|
|
20
20
|
}
|
|
21
21
|
declare class DiamondResizeView extends DiamondNode {
|
|
22
22
|
getControlGroup(): h.JSX.Element;
|
|
@@ -27,12 +27,17 @@ import ControlGroup from '../Control/ControlGroup';
|
|
|
27
27
|
import Polygon from '../BasicShape/Polygon';
|
|
28
28
|
var DiamondResizeModel = /** @class */ (function (_super) {
|
|
29
29
|
__extends(DiamondResizeModel, _super);
|
|
30
|
-
function DiamondResizeModel() {
|
|
31
|
-
var _this = _super
|
|
30
|
+
function DiamondResizeModel(data, graphModel) {
|
|
31
|
+
var _this = _super.call(this, data, graphModel) || this;
|
|
32
32
|
_this.minWidth = 30;
|
|
33
33
|
_this.minHeight = 30;
|
|
34
34
|
_this.maxWidth = 2000;
|
|
35
35
|
_this.maxHeight = 2000;
|
|
36
|
+
var nodeSize = _this.properties.nodeSize;
|
|
37
|
+
if (nodeSize) {
|
|
38
|
+
_this.rx = nodeSize.rx;
|
|
39
|
+
_this.ry = nodeSize.ry;
|
|
40
|
+
}
|
|
36
41
|
return _this;
|
|
37
42
|
}
|
|
38
43
|
DiamondResizeModel.prototype.getOutlineStyle = function () {
|
|
@@ -58,14 +63,6 @@ var DiamondResizeModel = /** @class */ (function (_super) {
|
|
|
58
63
|
stroke: '#000000',
|
|
59
64
|
};
|
|
60
65
|
};
|
|
61
|
-
DiamondResizeModel.prototype.setAttributes = function () {
|
|
62
|
-
// @ts-ignore
|
|
63
|
-
var nodeSize = this.properties.nodeSize;
|
|
64
|
-
if (nodeSize) {
|
|
65
|
-
this.rx = nodeSize.rx;
|
|
66
|
-
this.ry = nodeSize.ry;
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
66
|
return DiamondResizeModel;
|
|
70
67
|
}(DiamondNodeModel));
|
|
71
68
|
var DiamondResizeView = /** @class */ (function (_super) {
|
|
@@ -21,8 +21,11 @@ var EllipseResizeModel = /** @class */ (function (_super) {
|
|
|
21
21
|
_this.minHeight = 30;
|
|
22
22
|
_this.maxWidth = 2000;
|
|
23
23
|
_this.maxHeight = 2000;
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
var nodeSize = _this.properties.nodeSize;
|
|
25
|
+
if (nodeSize) {
|
|
26
|
+
_this.rx = nodeSize.rx;
|
|
27
|
+
_this.ry = nodeSize.ry;
|
|
28
|
+
}
|
|
26
29
|
return _this;
|
|
27
30
|
}
|
|
28
31
|
EllipseResizeModel.prototype.getOutlineStyle = function () {
|
|
@@ -48,14 +51,6 @@ var EllipseResizeModel = /** @class */ (function (_super) {
|
|
|
48
51
|
stroke: '#000000',
|
|
49
52
|
};
|
|
50
53
|
};
|
|
51
|
-
EllipseResizeModel.prototype.setAttributes = function () {
|
|
52
|
-
// @ts-ignore
|
|
53
|
-
var nodeSize = this.properties.nodeSize;
|
|
54
|
-
if (nodeSize) {
|
|
55
|
-
this.rx = nodeSize.rx;
|
|
56
|
-
this.ry = nodeSize.ry;
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
54
|
return EllipseResizeModel;
|
|
60
55
|
}(EllipseNodeModel));
|
|
61
56
|
var EllipseResizeView = /** @class */ (function (_super) {
|
|
@@ -4,6 +4,7 @@ declare class HtmlResizeModel extends HtmlNodeModel {
|
|
|
4
4
|
minHeight: number;
|
|
5
5
|
maxWidth: number;
|
|
6
6
|
maxHeight: number;
|
|
7
|
+
constructor(data: any, graphModel: any);
|
|
7
8
|
getOutlineStyle(): import("@logicflow/core/types/constant/DefaultTheme").OutlineTheme;
|
|
8
9
|
getResizeOutlineStyle(): {
|
|
9
10
|
stroke: string;
|
|
@@ -16,7 +17,6 @@ declare class HtmlResizeModel extends HtmlNodeModel {
|
|
|
16
17
|
fill: string;
|
|
17
18
|
stroke: string;
|
|
18
19
|
};
|
|
19
|
-
setAttributes(): void;
|
|
20
20
|
}
|
|
21
21
|
declare class HtmlResizeView extends HtmlNode {
|
|
22
22
|
getControlGroup(): h.JSX.Element;
|
|
@@ -15,12 +15,17 @@ import { h, HtmlNode, HtmlNodeModel } from '@logicflow/core';
|
|
|
15
15
|
import ControlGroup from '../Control/ControlGroup';
|
|
16
16
|
var HtmlResizeModel = /** @class */ (function (_super) {
|
|
17
17
|
__extends(HtmlResizeModel, _super);
|
|
18
|
-
function HtmlResizeModel() {
|
|
19
|
-
var _this = _super
|
|
18
|
+
function HtmlResizeModel(data, graphModel) {
|
|
19
|
+
var _this = _super.call(this, data, graphModel) || this;
|
|
20
20
|
_this.minWidth = 30;
|
|
21
21
|
_this.minHeight = 30;
|
|
22
22
|
_this.maxWidth = 2000;
|
|
23
23
|
_this.maxHeight = 2000;
|
|
24
|
+
var nodeSize = _this.properties.nodeSize;
|
|
25
|
+
if (nodeSize) {
|
|
26
|
+
_this.width = nodeSize.width;
|
|
27
|
+
_this.height = nodeSize.height;
|
|
28
|
+
}
|
|
24
29
|
return _this;
|
|
25
30
|
}
|
|
26
31
|
HtmlResizeModel.prototype.getOutlineStyle = function () {
|
|
@@ -46,14 +51,6 @@ var HtmlResizeModel = /** @class */ (function (_super) {
|
|
|
46
51
|
stroke: '#000000',
|
|
47
52
|
};
|
|
48
53
|
};
|
|
49
|
-
HtmlResizeModel.prototype.setAttributes = function () {
|
|
50
|
-
// @ts-ignore
|
|
51
|
-
var nodeSize = this.properties.nodeSize;
|
|
52
|
-
if (nodeSize) {
|
|
53
|
-
this.width = nodeSize.width;
|
|
54
|
-
this.height = nodeSize.height;
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
54
|
return HtmlResizeModel;
|
|
58
55
|
}(HtmlNodeModel));
|
|
59
56
|
var HtmlResizeView = /** @class */ (function (_super) {
|
|
@@ -4,6 +4,7 @@ declare class RectResizeModel extends RectNodeModel {
|
|
|
4
4
|
minHeight: number;
|
|
5
5
|
maxWidth: number;
|
|
6
6
|
maxHeight: number;
|
|
7
|
+
constructor(data: any, graphModel: any);
|
|
7
8
|
getOutlineStyle(): import("@logicflow/core/types/constant/DefaultTheme").OutlineTheme;
|
|
8
9
|
getResizeOutlineStyle(): {
|
|
9
10
|
fill: string;
|
|
@@ -17,7 +18,6 @@ declare class RectResizeModel extends RectNodeModel {
|
|
|
17
18
|
fill: string;
|
|
18
19
|
stroke: string;
|
|
19
20
|
};
|
|
20
|
-
setAttributes(): void;
|
|
21
21
|
resize(deltaX: any, deltaY: any): void;
|
|
22
22
|
}
|
|
23
23
|
declare class RectResizeView extends RectNode {
|
|
@@ -15,12 +15,17 @@ import { h, RectNode, RectNodeModel } from '@logicflow/core';
|
|
|
15
15
|
import ControlGroup from '../Control/ControlGroup';
|
|
16
16
|
var RectResizeModel = /** @class */ (function (_super) {
|
|
17
17
|
__extends(RectResizeModel, _super);
|
|
18
|
-
function RectResizeModel() {
|
|
19
|
-
var _this = _super
|
|
18
|
+
function RectResizeModel(data, graphModel) {
|
|
19
|
+
var _this = _super.call(this, data, graphModel) || this;
|
|
20
20
|
_this.minWidth = 30;
|
|
21
21
|
_this.minHeight = 30;
|
|
22
22
|
_this.maxWidth = 2000;
|
|
23
23
|
_this.maxHeight = 2000;
|
|
24
|
+
var nodeSize = _this.properties.nodeSize;
|
|
25
|
+
if (nodeSize) {
|
|
26
|
+
_this.width = nodeSize.width;
|
|
27
|
+
_this.height = nodeSize.height;
|
|
28
|
+
}
|
|
24
29
|
return _this;
|
|
25
30
|
}
|
|
26
31
|
RectResizeModel.prototype.getOutlineStyle = function () {
|
|
@@ -47,14 +52,6 @@ var RectResizeModel = /** @class */ (function (_super) {
|
|
|
47
52
|
stroke: '#000000',
|
|
48
53
|
};
|
|
49
54
|
};
|
|
50
|
-
RectResizeModel.prototype.setAttributes = function () {
|
|
51
|
-
// @ts-ignore
|
|
52
|
-
var nodeSize = this.properties.nodeSize;
|
|
53
|
-
if (nodeSize) {
|
|
54
|
-
this.width = nodeSize.width;
|
|
55
|
-
this.height = nodeSize.height;
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
55
|
RectResizeModel.prototype.resize = function (deltaX, deltaY) {
|
|
59
56
|
console.log(deltaX, deltaY);
|
|
60
57
|
};
|
|
@@ -95,20 +95,10 @@ var MiniMap = /** @class */ (function () {
|
|
|
95
95
|
MiniMap.prototype.render = function (lf, container) {
|
|
96
96
|
var _this = this;
|
|
97
97
|
this.__container = container;
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
'edge:delete',
|
|
103
|
-
'node:drop',
|
|
104
|
-
'blank:drop',
|
|
105
|
-
];
|
|
106
|
-
events.forEach(function (eventName) {
|
|
107
|
-
_this.__lf.on(eventName, function () {
|
|
108
|
-
if (_this.__isShow) {
|
|
109
|
-
_this.__setView();
|
|
110
|
-
}
|
|
111
|
-
});
|
|
98
|
+
this.__lf.on('history:change', function () {
|
|
99
|
+
if (_this.__isShow) {
|
|
100
|
+
_this.__setView();
|
|
101
|
+
}
|
|
112
102
|
});
|
|
113
103
|
};
|
|
114
104
|
MiniMap.prototype.init = function (option) {
|
|
@@ -8,6 +8,7 @@ declare class AutoLayout {
|
|
|
8
8
|
lf: LogicFlow;
|
|
9
9
|
levelHeight: any[];
|
|
10
10
|
newNodeMap: Map<string, any>;
|
|
11
|
+
trunk: any[];
|
|
11
12
|
static pluginName: string;
|
|
12
13
|
constructor({ lf }: {
|
|
13
14
|
lf: any;
|
|
@@ -36,4 +37,4 @@ declare class AutoLayout {
|
|
|
36
37
|
addLevelHeight(level: any, height?: number, isNegative?: boolean): void;
|
|
37
38
|
getLevelHeight(level: any, isNegative?: boolean): any;
|
|
38
39
|
}
|
|
39
|
-
export { AutoLayout
|
|
40
|
+
export { AutoLayout };
|
|
@@ -24,6 +24,20 @@ var AutoLayout = /** @class */ (function () {
|
|
|
24
24
|
var _this = this;
|
|
25
25
|
var lf = _a.lf;
|
|
26
26
|
this.lf = lf;
|
|
27
|
+
/**
|
|
28
|
+
* 用于记录上一次调用layout时计算出的trunk
|
|
29
|
+
* 当旧trunk和新trunk长度一致时,用于选择旧trunk,
|
|
30
|
+
* a->b->c->d
|
|
31
|
+
* |->e
|
|
32
|
+
* e后面新增f节点时候,旧逻辑会返回新trunk[a,b,e,f]
|
|
33
|
+
* 界面布局变成
|
|
34
|
+
* a->b->e->f
|
|
35
|
+
* |->c->d
|
|
36
|
+
* 其实只想要这样 尽量少变化
|
|
37
|
+
* a->b->c->d
|
|
38
|
+
* |->e->f
|
|
39
|
+
* */
|
|
40
|
+
this.trunk = [];
|
|
27
41
|
// 给lf添加方法
|
|
28
42
|
lf.layout = function (startNodeType) {
|
|
29
43
|
var data = _this.lf.getGraphRawData();
|
|
@@ -40,12 +54,22 @@ var AutoLayout = /** @class */ (function () {
|
|
|
40
54
|
// 拿到最长的路径。
|
|
41
55
|
// nodes: [], edges: [],
|
|
42
56
|
AutoLayout.prototype.layout = function (data, path) {
|
|
57
|
+
var _this = this;
|
|
43
58
|
var trunk = [];
|
|
44
59
|
path.forEach(function (p) {
|
|
45
|
-
|
|
46
|
-
|
|
60
|
+
var elements = p.elements;
|
|
61
|
+
if (elements.length > trunk.length) {
|
|
62
|
+
trunk = elements;
|
|
63
|
+
}
|
|
64
|
+
else if (elements.length === trunk.length) {
|
|
65
|
+
// 考虑是否替换为旧的trunk
|
|
66
|
+
if (JSON.stringify(elements) === JSON.stringify(_this.trunk)) {
|
|
67
|
+
trunk = _this.trunk;
|
|
68
|
+
}
|
|
47
69
|
}
|
|
48
70
|
});
|
|
71
|
+
// 记录上一次trunk
|
|
72
|
+
this.trunk = trunk;
|
|
49
73
|
var nodeMap = this.formatData(data);
|
|
50
74
|
var newGraphData = {
|
|
51
75
|
nodes: [],
|
|
@@ -179,7 +203,8 @@ var AutoLayout = /** @class */ (function () {
|
|
|
179
203
|
AutoLayout.prototype.formatData = function (data) {
|
|
180
204
|
var nodeMap = data.nodes.reduce(function (nMap, node) {
|
|
181
205
|
var type = node.type, properties = node.properties, text = node.text, x = node.x, y = node.y;
|
|
182
|
-
if (text && typeof text === 'object') {
|
|
206
|
+
if (text && typeof text === 'object') {
|
|
207
|
+
// 坐标转换为偏移量
|
|
183
208
|
text.x = text.x - x;
|
|
184
209
|
text.y = text.y - y;
|
|
185
210
|
}
|
|
@@ -238,4 +263,4 @@ var AutoLayout = /** @class */ (function () {
|
|
|
238
263
|
AutoLayout.pluginName = 'AutoLayout';
|
|
239
264
|
return AutoLayout;
|
|
240
265
|
}());
|
|
241
|
-
export { AutoLayout
|
|
266
|
+
export { AutoLayout };
|