@logicflow/extension 1.1.0-alpha.2 → 1.1.0-alpha.3
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/materials/group/GroupNode.js +66 -20
- package/cjs/materials/group/index.js +28 -9
- package/cjs/style/index.css +3 -2
- package/es/materials/group/GroupNode.d.ts +24 -9
- package/es/materials/group/GroupNode.js +67 -21
- package/es/materials/group/index.d.ts +3 -1
- package/es/materials/group/index.js +27 -9
- package/es/style/index.css +3 -2
- 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/lib/style/index.css +3 -2
- package/package.json +1 -1
- package/types/materials/group/GroupNode.d.ts +24 -9
- package/types/materials/group/index.d.ts +3 -1
|
@@ -12,6 +12,17 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
12
12
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
13
13
|
};
|
|
14
14
|
})();
|
|
15
|
+
var __assign = (this && this.__assign) || function () {
|
|
16
|
+
__assign = Object.assign || function(t) {
|
|
17
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
18
|
+
s = arguments[i];
|
|
19
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
20
|
+
t[p] = s[p];
|
|
21
|
+
}
|
|
22
|
+
return t;
|
|
23
|
+
};
|
|
24
|
+
return __assign.apply(this, arguments);
|
|
25
|
+
};
|
|
15
26
|
var __read = (this && this.__read) || function (o, n) {
|
|
16
27
|
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
17
28
|
if (!m) return o;
|
|
@@ -34,27 +45,31 @@ var __spread = (this && this.__spread) || function () {
|
|
|
34
45
|
};
|
|
35
46
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
47
|
var core_1 = require("@logicflow/core");
|
|
48
|
+
var NodeResize_1 = require("../../NodeResize");
|
|
37
49
|
var GroupNodeModel = /** @class */ (function (_super) {
|
|
38
50
|
__extends(GroupNodeModel, _super);
|
|
39
51
|
function GroupNodeModel() {
|
|
40
52
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
41
53
|
_this.isGroup = true;
|
|
42
|
-
_this.children = new Set();
|
|
43
|
-
_this.isRestrict = true; // 其子节点是否被禁止通过拖拽移出分组。 默认false,允许拖拽移除分组。
|
|
44
54
|
return _this;
|
|
45
55
|
}
|
|
46
|
-
GroupNodeModel.prototype.
|
|
56
|
+
GroupNodeModel.prototype.initNodeData = function (data) {
|
|
57
|
+
_super.prototype.initNodeData.call(this, data);
|
|
58
|
+
var children = [];
|
|
59
|
+
if (Array.isArray(data.children)) {
|
|
60
|
+
children = data.children;
|
|
61
|
+
}
|
|
62
|
+
// 初始化组的子节点
|
|
63
|
+
this.children = new Set(children);
|
|
47
64
|
this.width = 500;
|
|
48
65
|
this.height = 200;
|
|
49
|
-
|
|
50
|
-
this.zIndex =
|
|
66
|
+
// todo: 参考bpmn.js, 分组和未加入分组的节点重合时,未加入分组的节点在分组之下。方便标识。
|
|
67
|
+
this.zIndex = -1;
|
|
51
68
|
this.radius = 0;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
GroupNodeModel.prototype.setIsRestrict = function (isRestrict) {
|
|
57
|
-
this.isRestrict = isRestrict;
|
|
69
|
+
this.text.editable = false;
|
|
70
|
+
this.text.draggable = false;
|
|
71
|
+
this.isRestrict = false;
|
|
72
|
+
this.resizable = false;
|
|
58
73
|
};
|
|
59
74
|
GroupNodeModel.prototype.isInRange = function (_a) {
|
|
60
75
|
var x1 = _a.x1, y1 = _a.y1, x2 = _a.x2, y2 = _a.y2;
|
|
@@ -63,28 +78,40 @@ var GroupNodeModel = /** @class */ (function (_super) {
|
|
|
63
78
|
&& y1 >= (this.y - this.height / 2)
|
|
64
79
|
&& y2 <= (this.y + this.height / 2);
|
|
65
80
|
};
|
|
66
|
-
// todo: 更好的方式定义分组的样式
|
|
67
81
|
GroupNodeModel.prototype.setAllowAppendChild = function (isAllow) {
|
|
68
|
-
|
|
69
|
-
this.stroke = 'red';
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
this.stroke = 'rgb(24, 125, 255)';
|
|
73
|
-
}
|
|
82
|
+
this.setProperty('groupAddable', isAllow);
|
|
74
83
|
};
|
|
84
|
+
/**
|
|
85
|
+
* 添加分组子节点
|
|
86
|
+
* @param id 节点id
|
|
87
|
+
*/
|
|
75
88
|
GroupNodeModel.prototype.addChild = function (id) {
|
|
76
89
|
this.children.add(id);
|
|
77
90
|
};
|
|
91
|
+
/**
|
|
92
|
+
* 删除分组子节点
|
|
93
|
+
* @param id 节点id
|
|
94
|
+
*/
|
|
78
95
|
GroupNodeModel.prototype.removeChild = function (id) {
|
|
79
96
|
this.children.delete(id);
|
|
80
97
|
};
|
|
98
|
+
GroupNodeModel.prototype.getAddableOutlineStyle = function () {
|
|
99
|
+
return {
|
|
100
|
+
stroke: '#FEB663',
|
|
101
|
+
strokeWidth: 2,
|
|
102
|
+
strokeDasharray: '4 4',
|
|
103
|
+
fill: 'transparent',
|
|
104
|
+
};
|
|
105
|
+
};
|
|
81
106
|
GroupNodeModel.prototype.getData = function () {
|
|
82
107
|
var data = _super.prototype.getData.call(this);
|
|
83
108
|
data.children = __spread(this.children);
|
|
109
|
+
var properties = data.properties;
|
|
110
|
+
delete properties.groupAddable;
|
|
84
111
|
return data;
|
|
85
112
|
};
|
|
86
113
|
return GroupNodeModel;
|
|
87
|
-
}(
|
|
114
|
+
}(NodeResize_1.RectResize.model));
|
|
88
115
|
var GroupNode = /** @class */ (function (_super) {
|
|
89
116
|
__extends(GroupNode, _super);
|
|
90
117
|
function GroupNode() {
|
|
@@ -94,8 +121,27 @@ var GroupNode = /** @class */ (function (_super) {
|
|
|
94
121
|
* 重新toFront,阻止其置顶
|
|
95
122
|
*/
|
|
96
123
|
GroupNode.prototype.toFront = function () { };
|
|
124
|
+
GroupNode.prototype.getControlGroup = function () {
|
|
125
|
+
return this.props.model.resizable ? _super.prototype.getControlGroup.call(this) : null;
|
|
126
|
+
};
|
|
127
|
+
GroupNode.prototype.getAddedableShape = function () {
|
|
128
|
+
var _a = this.props.model, width = _a.width, height = _a.height, x = _a.x, y = _a.y, radius = _a.radius, properties = _a.properties;
|
|
129
|
+
if (!properties.groupAddable)
|
|
130
|
+
return null;
|
|
131
|
+
var strokeWidth = this.props.model.getNodeStyle().strokeWidth;
|
|
132
|
+
var style = this.props.model.getAddableOutlineStyle();
|
|
133
|
+
var newWidth = width + strokeWidth + 8;
|
|
134
|
+
var newHeight = height + strokeWidth + 8;
|
|
135
|
+
return core_1.h('rect', __assign(__assign({}, style), { width: newWidth, height: newHeight, x: x - newWidth / 2, y: y - newHeight / 2, rx: radius, ry: radius }));
|
|
136
|
+
};
|
|
137
|
+
GroupNode.prototype.getResizeShape = function () {
|
|
138
|
+
return core_1.h('g', {}, [
|
|
139
|
+
this.getAddedableShape(),
|
|
140
|
+
_super.prototype.getResizeShape.call(this),
|
|
141
|
+
]);
|
|
142
|
+
};
|
|
97
143
|
return GroupNode;
|
|
98
|
-
}(
|
|
144
|
+
}(NodeResize_1.RectResize.view));
|
|
99
145
|
exports.default = {
|
|
100
146
|
type: 'group',
|
|
101
147
|
view: GroupNode,
|
|
@@ -20,13 +20,26 @@ var __spread = (this && this.__spread) || function () {
|
|
|
20
20
|
return ar;
|
|
21
21
|
};
|
|
22
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
-
exports.Group = void 0;
|
|
23
|
+
exports.GroupNode = exports.Group = void 0;
|
|
24
24
|
var GroupNode_1 = require("./GroupNode");
|
|
25
|
+
exports.GroupNode = GroupNode_1.default;
|
|
25
26
|
var Group = /** @class */ (function () {
|
|
26
27
|
function Group(_a) {
|
|
27
28
|
var _this = this;
|
|
28
29
|
var lf = _a.lf;
|
|
29
30
|
this.nodeGroupMap = new Map();
|
|
31
|
+
this.graphRendered = function (data) {
|
|
32
|
+
// 如果节点
|
|
33
|
+
if (data && data.nodes) {
|
|
34
|
+
data.nodes.forEach(function (node) {
|
|
35
|
+
if (node.children) {
|
|
36
|
+
node.children.forEach(function (nodeId) {
|
|
37
|
+
_this.nodeGroupMap.set(nodeId, node.id);
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
};
|
|
30
43
|
this.appendNodeToGrop = function (_a) {
|
|
31
44
|
var data = _a.data;
|
|
32
45
|
// 如果这个节点之前已经在group中了,则将其从之前的group中移除
|
|
@@ -48,14 +61,19 @@ var Group = /** @class */ (function () {
|
|
|
48
61
|
};
|
|
49
62
|
this.setActiveGroup = function (_a) {
|
|
50
63
|
var data = _a.data;
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
var
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
64
|
+
var nodeModel = _this.lf.getNodeModelById(data.id);
|
|
65
|
+
if (nodeModel.isGroup)
|
|
66
|
+
return;
|
|
67
|
+
var bounds = nodeModel.getBounds();
|
|
68
|
+
var newGroup = _this.getGroup(bounds);
|
|
69
|
+
if (newGroup || newGroup !== _this.activeGroup) {
|
|
70
|
+
if (_this.activeGroup) {
|
|
71
|
+
_this.activeGroup.setAllowAppendChild(false);
|
|
72
|
+
}
|
|
73
|
+
if (newGroup) {
|
|
74
|
+
_this.activeGroup = newGroup;
|
|
75
|
+
_this.activeGroup.setAllowAppendChild(true);
|
|
76
|
+
}
|
|
59
77
|
}
|
|
60
78
|
};
|
|
61
79
|
lf.register(GroupNode_1.default);
|
|
@@ -82,6 +100,7 @@ var Group = /** @class */ (function () {
|
|
|
82
100
|
lf.on('node:drop', this.appendNodeToGrop);
|
|
83
101
|
lf.on('node:dnd-move', this.setActiveGroup);
|
|
84
102
|
lf.on('node:drag', this.setActiveGroup);
|
|
103
|
+
lf.on('graph:rendered', this.graphRendered);
|
|
85
104
|
}
|
|
86
105
|
Group.prototype.getGroups = function () {
|
|
87
106
|
var groups = [];
|
package/cjs/style/index.css
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { h } from '@logicflow/core';
|
|
2
|
+
import { RectResize } from '../../NodeResize';
|
|
3
|
+
declare class GroupNodeModel extends RectResize.model {
|
|
3
4
|
readonly isGroup = true;
|
|
4
|
-
children: Set<
|
|
5
|
+
children: Set<string>;
|
|
5
6
|
isRestrict: boolean;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
* 设置是否允许子节点被拖动移除分组
|
|
9
|
-
*/
|
|
10
|
-
setIsRestrict(isRestrict: any): void;
|
|
7
|
+
resizable: boolean;
|
|
8
|
+
initNodeData(data: any): void;
|
|
11
9
|
isInRange({ x1, y1, x2, y2 }: {
|
|
12
10
|
x1: any;
|
|
13
11
|
y1: any;
|
|
@@ -15,15 +13,32 @@ declare class GroupNodeModel extends RectNodeModel {
|
|
|
15
13
|
y2: any;
|
|
16
14
|
}): boolean;
|
|
17
15
|
setAllowAppendChild(isAllow: any): void;
|
|
16
|
+
/**
|
|
17
|
+
* 添加分组子节点
|
|
18
|
+
* @param id 节点id
|
|
19
|
+
*/
|
|
18
20
|
addChild(id: any): void;
|
|
21
|
+
/**
|
|
22
|
+
* 删除分组子节点
|
|
23
|
+
* @param id 节点id
|
|
24
|
+
*/
|
|
19
25
|
removeChild(id: any): void;
|
|
26
|
+
getAddableOutlineStyle(): {
|
|
27
|
+
stroke: string;
|
|
28
|
+
strokeWidth: number;
|
|
29
|
+
strokeDasharray: string;
|
|
30
|
+
fill: string;
|
|
31
|
+
};
|
|
20
32
|
getData(): import("@logicflow/core").NodeData;
|
|
21
33
|
}
|
|
22
|
-
declare class GroupNode extends
|
|
34
|
+
declare class GroupNode extends RectResize.view {
|
|
23
35
|
/**
|
|
24
36
|
* 重新toFront,阻止其置顶
|
|
25
37
|
*/
|
|
26
38
|
toFront(): void;
|
|
39
|
+
getControlGroup(): h.JSX.Element;
|
|
40
|
+
getAddedableShape(): import("preact").VNode<any>;
|
|
41
|
+
getResizeShape(): import("preact").VNode<any>;
|
|
27
42
|
}
|
|
28
43
|
declare const _default: {
|
|
29
44
|
type: string;
|
|
@@ -11,6 +11,17 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
11
11
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
12
12
|
};
|
|
13
13
|
})();
|
|
14
|
+
var __assign = (this && this.__assign) || function () {
|
|
15
|
+
__assign = Object.assign || function(t) {
|
|
16
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
17
|
+
s = arguments[i];
|
|
18
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
19
|
+
t[p] = s[p];
|
|
20
|
+
}
|
|
21
|
+
return t;
|
|
22
|
+
};
|
|
23
|
+
return __assign.apply(this, arguments);
|
|
24
|
+
};
|
|
14
25
|
var __read = (this && this.__read) || function (o, n) {
|
|
15
26
|
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
16
27
|
if (!m) return o;
|
|
@@ -31,28 +42,32 @@ var __spread = (this && this.__spread) || function () {
|
|
|
31
42
|
for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
|
|
32
43
|
return ar;
|
|
33
44
|
};
|
|
34
|
-
import {
|
|
45
|
+
import { h } from '@logicflow/core';
|
|
46
|
+
import { RectResize } from '../../NodeResize';
|
|
35
47
|
var GroupNodeModel = /** @class */ (function (_super) {
|
|
36
48
|
__extends(GroupNodeModel, _super);
|
|
37
49
|
function GroupNodeModel() {
|
|
38
50
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
39
51
|
_this.isGroup = true;
|
|
40
|
-
_this.children = new Set();
|
|
41
|
-
_this.isRestrict = true; // 其子节点是否被禁止通过拖拽移出分组。 默认false,允许拖拽移除分组。
|
|
42
52
|
return _this;
|
|
43
53
|
}
|
|
44
|
-
GroupNodeModel.prototype.
|
|
54
|
+
GroupNodeModel.prototype.initNodeData = function (data) {
|
|
55
|
+
_super.prototype.initNodeData.call(this, data);
|
|
56
|
+
var children = [];
|
|
57
|
+
if (Array.isArray(data.children)) {
|
|
58
|
+
children = data.children;
|
|
59
|
+
}
|
|
60
|
+
// 初始化组的子节点
|
|
61
|
+
this.children = new Set(children);
|
|
45
62
|
this.width = 500;
|
|
46
63
|
this.height = 200;
|
|
47
|
-
|
|
48
|
-
this.zIndex =
|
|
64
|
+
// todo: 参考bpmn.js, 分组和未加入分组的节点重合时,未加入分组的节点在分组之下。方便标识。
|
|
65
|
+
this.zIndex = -1;
|
|
49
66
|
this.radius = 0;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
GroupNodeModel.prototype.setIsRestrict = function (isRestrict) {
|
|
55
|
-
this.isRestrict = isRestrict;
|
|
67
|
+
this.text.editable = false;
|
|
68
|
+
this.text.draggable = false;
|
|
69
|
+
this.isRestrict = false;
|
|
70
|
+
this.resizable = false;
|
|
56
71
|
};
|
|
57
72
|
GroupNodeModel.prototype.isInRange = function (_a) {
|
|
58
73
|
var x1 = _a.x1, y1 = _a.y1, x2 = _a.x2, y2 = _a.y2;
|
|
@@ -61,28 +76,40 @@ var GroupNodeModel = /** @class */ (function (_super) {
|
|
|
61
76
|
&& y1 >= (this.y - this.height / 2)
|
|
62
77
|
&& y2 <= (this.y + this.height / 2);
|
|
63
78
|
};
|
|
64
|
-
// todo: 更好的方式定义分组的样式
|
|
65
79
|
GroupNodeModel.prototype.setAllowAppendChild = function (isAllow) {
|
|
66
|
-
|
|
67
|
-
this.stroke = 'red';
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
this.stroke = 'rgb(24, 125, 255)';
|
|
71
|
-
}
|
|
80
|
+
this.setProperty('groupAddable', isAllow);
|
|
72
81
|
};
|
|
82
|
+
/**
|
|
83
|
+
* 添加分组子节点
|
|
84
|
+
* @param id 节点id
|
|
85
|
+
*/
|
|
73
86
|
GroupNodeModel.prototype.addChild = function (id) {
|
|
74
87
|
this.children.add(id);
|
|
75
88
|
};
|
|
89
|
+
/**
|
|
90
|
+
* 删除分组子节点
|
|
91
|
+
* @param id 节点id
|
|
92
|
+
*/
|
|
76
93
|
GroupNodeModel.prototype.removeChild = function (id) {
|
|
77
94
|
this.children.delete(id);
|
|
78
95
|
};
|
|
96
|
+
GroupNodeModel.prototype.getAddableOutlineStyle = function () {
|
|
97
|
+
return {
|
|
98
|
+
stroke: '#FEB663',
|
|
99
|
+
strokeWidth: 2,
|
|
100
|
+
strokeDasharray: '4 4',
|
|
101
|
+
fill: 'transparent',
|
|
102
|
+
};
|
|
103
|
+
};
|
|
79
104
|
GroupNodeModel.prototype.getData = function () {
|
|
80
105
|
var data = _super.prototype.getData.call(this);
|
|
81
106
|
data.children = __spread(this.children);
|
|
107
|
+
var properties = data.properties;
|
|
108
|
+
delete properties.groupAddable;
|
|
82
109
|
return data;
|
|
83
110
|
};
|
|
84
111
|
return GroupNodeModel;
|
|
85
|
-
}(
|
|
112
|
+
}(RectResize.model));
|
|
86
113
|
var GroupNode = /** @class */ (function (_super) {
|
|
87
114
|
__extends(GroupNode, _super);
|
|
88
115
|
function GroupNode() {
|
|
@@ -92,8 +119,27 @@ var GroupNode = /** @class */ (function (_super) {
|
|
|
92
119
|
* 重新toFront,阻止其置顶
|
|
93
120
|
*/
|
|
94
121
|
GroupNode.prototype.toFront = function () { };
|
|
122
|
+
GroupNode.prototype.getControlGroup = function () {
|
|
123
|
+
return this.props.model.resizable ? _super.prototype.getControlGroup.call(this) : null;
|
|
124
|
+
};
|
|
125
|
+
GroupNode.prototype.getAddedableShape = function () {
|
|
126
|
+
var _a = this.props.model, width = _a.width, height = _a.height, x = _a.x, y = _a.y, radius = _a.radius, properties = _a.properties;
|
|
127
|
+
if (!properties.groupAddable)
|
|
128
|
+
return null;
|
|
129
|
+
var strokeWidth = this.props.model.getNodeStyle().strokeWidth;
|
|
130
|
+
var style = this.props.model.getAddableOutlineStyle();
|
|
131
|
+
var newWidth = width + strokeWidth + 8;
|
|
132
|
+
var newHeight = height + strokeWidth + 8;
|
|
133
|
+
return h('rect', __assign(__assign({}, style), { width: newWidth, height: newHeight, x: x - newWidth / 2, y: y - newHeight / 2, rx: radius, ry: radius }));
|
|
134
|
+
};
|
|
135
|
+
GroupNode.prototype.getResizeShape = function () {
|
|
136
|
+
return h('g', {}, [
|
|
137
|
+
this.getAddedableShape(),
|
|
138
|
+
_super.prototype.getResizeShape.call(this),
|
|
139
|
+
]);
|
|
140
|
+
};
|
|
95
141
|
return GroupNode;
|
|
96
|
-
}(
|
|
142
|
+
}(RectResize.view));
|
|
97
143
|
export default {
|
|
98
144
|
type: 'group',
|
|
99
145
|
view: GroupNode,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import LogicFlow, { BaseNodeModel } from '@logicflow/core';
|
|
2
|
+
import GroupNode from './GroupNode';
|
|
2
3
|
declare type BaseNodeId = string;
|
|
3
4
|
declare type GroupId = string;
|
|
4
5
|
declare type Bounds = {
|
|
@@ -15,6 +16,7 @@ declare class Group {
|
|
|
15
16
|
constructor({ lf }: {
|
|
16
17
|
lf: any;
|
|
17
18
|
});
|
|
19
|
+
graphRendered: (data: any) => void;
|
|
18
20
|
appendNodeToGrop: ({ data }: {
|
|
19
21
|
data: any;
|
|
20
22
|
}) => void;
|
|
@@ -27,4 +29,4 @@ declare class Group {
|
|
|
27
29
|
*/
|
|
28
30
|
getGroup(bounds: Bounds): BaseNodeModel | undefined;
|
|
29
31
|
}
|
|
30
|
-
export { Group };
|
|
32
|
+
export { Group, GroupNode, };
|
|
@@ -24,6 +24,18 @@ var Group = /** @class */ (function () {
|
|
|
24
24
|
var _this = this;
|
|
25
25
|
var lf = _a.lf;
|
|
26
26
|
this.nodeGroupMap = new Map();
|
|
27
|
+
this.graphRendered = function (data) {
|
|
28
|
+
// 如果节点
|
|
29
|
+
if (data && data.nodes) {
|
|
30
|
+
data.nodes.forEach(function (node) {
|
|
31
|
+
if (node.children) {
|
|
32
|
+
node.children.forEach(function (nodeId) {
|
|
33
|
+
_this.nodeGroupMap.set(nodeId, node.id);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
};
|
|
27
39
|
this.appendNodeToGrop = function (_a) {
|
|
28
40
|
var data = _a.data;
|
|
29
41
|
// 如果这个节点之前已经在group中了,则将其从之前的group中移除
|
|
@@ -45,14 +57,19 @@ var Group = /** @class */ (function () {
|
|
|
45
57
|
};
|
|
46
58
|
this.setActiveGroup = function (_a) {
|
|
47
59
|
var data = _a.data;
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
var
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
60
|
+
var nodeModel = _this.lf.getNodeModelById(data.id);
|
|
61
|
+
if (nodeModel.isGroup)
|
|
62
|
+
return;
|
|
63
|
+
var bounds = nodeModel.getBounds();
|
|
64
|
+
var newGroup = _this.getGroup(bounds);
|
|
65
|
+
if (newGroup || newGroup !== _this.activeGroup) {
|
|
66
|
+
if (_this.activeGroup) {
|
|
67
|
+
_this.activeGroup.setAllowAppendChild(false);
|
|
68
|
+
}
|
|
69
|
+
if (newGroup) {
|
|
70
|
+
_this.activeGroup = newGroup;
|
|
71
|
+
_this.activeGroup.setAllowAppendChild(true);
|
|
72
|
+
}
|
|
56
73
|
}
|
|
57
74
|
};
|
|
58
75
|
lf.register(GroupNode);
|
|
@@ -79,6 +96,7 @@ var Group = /** @class */ (function () {
|
|
|
79
96
|
lf.on('node:drop', this.appendNodeToGrop);
|
|
80
97
|
lf.on('node:dnd-move', this.setActiveGroup);
|
|
81
98
|
lf.on('node:drag', this.setActiveGroup);
|
|
99
|
+
lf.on('graph:rendered', this.graphRendered);
|
|
82
100
|
}
|
|
83
101
|
Group.prototype.getGroups = function () {
|
|
84
102
|
var groups = [];
|
|
@@ -103,4 +121,4 @@ var Group = /** @class */ (function () {
|
|
|
103
121
|
Group.pluginName = 'group';
|
|
104
122
|
return Group;
|
|
105
123
|
}());
|
|
106
|
-
export { Group };
|
|
124
|
+
export { Group, GroupNode, };
|
package/es/style/index.css
CHANGED