@logicflow/extension 1.0.6 → 1.0.7-alpha.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/cjs/components/control/index.js +97 -71
- package/cjs/components/dnd-panel/index.js +11 -5
- package/es/components/control/index.d.ts +16 -12
- package/es/components/control/index.js +98 -72
- package/es/components/dnd-panel/index.d.ts +3 -1
- package/es/components/dnd-panel/index.js +11 -5
- 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/package.json +2 -2
- package/types/components/control/index.d.ts +16 -12
- package/types/components/dnd-panel/index.d.ts +3 -1
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
2
13
|
var __read = (this && this.__read) || function (o, n) {
|
|
3
14
|
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
4
15
|
if (!m) return o;
|
|
@@ -21,83 +32,96 @@ var __spread = (this && this.__spread) || function () {
|
|
|
21
32
|
};
|
|
22
33
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
34
|
exports.Control = void 0;
|
|
24
|
-
var Control = {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
35
|
+
var Control = /** @class */ (function () {
|
|
36
|
+
function Control(_a) {
|
|
37
|
+
var _b;
|
|
38
|
+
var _this = this;
|
|
39
|
+
var lf = _a.lf;
|
|
40
|
+
var _c;
|
|
41
|
+
this.controlItems = [
|
|
42
|
+
{
|
|
43
|
+
key: 'zoom-out',
|
|
44
|
+
iconClass: 'lf-control-zoomOut',
|
|
45
|
+
title: '缩小流程图',
|
|
46
|
+
text: '缩小',
|
|
47
|
+
onClick: function () {
|
|
48
|
+
_this.lf.zoom(false);
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
key: 'zoom-in',
|
|
53
|
+
iconClass: 'lf-control-zoomIn',
|
|
54
|
+
title: '放大流程图',
|
|
55
|
+
text: '放大',
|
|
56
|
+
onClick: function () {
|
|
57
|
+
_this.lf.zoom(true);
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
key: 'reset',
|
|
62
|
+
iconClass: 'lf-control-fit',
|
|
63
|
+
title: '恢复流程原有尺寸',
|
|
64
|
+
text: '适应',
|
|
65
|
+
onClick: function () {
|
|
66
|
+
_this.lf.resetZoom();
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
key: 'undo',
|
|
71
|
+
iconClass: 'lf-control-undo',
|
|
72
|
+
title: '回到上一步',
|
|
73
|
+
text: '上一步',
|
|
74
|
+
onClick: function () {
|
|
75
|
+
_this.lf.undo();
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
key: 'redo',
|
|
80
|
+
iconClass: 'lf-control-redo',
|
|
81
|
+
title: '移到下一步',
|
|
82
|
+
text: '下一步',
|
|
83
|
+
onClick: function () {
|
|
84
|
+
_this.lf.redo();
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
];
|
|
88
|
+
this.lf = lf;
|
|
89
|
+
this.lf.extension = __assign(__assign({}, ((_c = this.lf.extension) !== null && _c !== void 0 ? _c : {})), (_b = {}, _b[Control.pluginName] = this, _b));
|
|
90
|
+
}
|
|
91
|
+
Control.prototype.render = function (lf, domContainer) {
|
|
92
|
+
this.destroy();
|
|
93
|
+
var toolEl = this.getControlTool();
|
|
94
|
+
this.toolEl = toolEl;
|
|
95
|
+
domContainer.appendChild(toolEl);
|
|
96
|
+
this.domContainer = domContainer;
|
|
97
|
+
};
|
|
98
|
+
Control.prototype.destroy = function () {
|
|
99
|
+
if (this.domContainer && this.toolEl && this.domContainer.contains(this.toolEl)) {
|
|
100
|
+
this.domContainer.removeChild(this.toolEl);
|
|
82
101
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
|
|
102
|
+
};
|
|
103
|
+
Control.prototype.addItem = function (item) {
|
|
104
|
+
this.controlItems.push(item);
|
|
105
|
+
};
|
|
106
|
+
Control.prototype.removeItem = function (key) {
|
|
107
|
+
var index = this.controlItems.findIndex(function (item) { return item.key === key; });
|
|
108
|
+
return this.controlItems.splice(index, 1)[0];
|
|
109
|
+
};
|
|
110
|
+
Control.prototype.getControlTool = function () {
|
|
111
|
+
var _this = this;
|
|
88
112
|
var NORMAL = 'lf-control-item';
|
|
89
113
|
var DISABLED = 'lf-control-item disabled';
|
|
90
114
|
var controlTool = document.createElement('div');
|
|
91
115
|
var controlElements = [];
|
|
92
116
|
controlTool.className = 'lf-control';
|
|
93
|
-
|
|
117
|
+
this.controlItems.forEach(function (item) {
|
|
94
118
|
var itemContainer = document.createElement('div');
|
|
95
119
|
var icon = document.createElement('i');
|
|
96
120
|
var text = document.createElement('span');
|
|
97
121
|
itemContainer.className = DISABLED;
|
|
98
|
-
item.onClick && (itemContainer.onclick = item.onClick.bind(null,
|
|
99
|
-
item.onMouseEnter && (itemContainer.onmouseenter = item.onMouseEnter.bind(null,
|
|
100
|
-
item.onMouseLeave && (itemContainer.onmouseleave = item.onMouseLeave.bind(null,
|
|
122
|
+
item.onClick && (itemContainer.onclick = item.onClick.bind(null, _this.lf));
|
|
123
|
+
item.onMouseEnter && (itemContainer.onmouseenter = item.onMouseEnter.bind(null, _this.lf));
|
|
124
|
+
item.onMouseLeave && (itemContainer.onmouseleave = item.onMouseLeave.bind(null, _this.lf));
|
|
101
125
|
icon.className = item.iconClass;
|
|
102
126
|
text.className = 'lf-control-text';
|
|
103
127
|
text.title = item.title;
|
|
@@ -105,13 +129,13 @@ var Control = {
|
|
|
105
129
|
itemContainer.append(icon, text);
|
|
106
130
|
switch (item.text) {
|
|
107
131
|
case '上一步':
|
|
108
|
-
|
|
132
|
+
_this.lf.on('history:change', function (_a) {
|
|
109
133
|
var undoAble = _a.data.undoAble;
|
|
110
134
|
itemContainer.className = undoAble ? NORMAL : DISABLED;
|
|
111
135
|
});
|
|
112
136
|
break;
|
|
113
137
|
case '下一步':
|
|
114
|
-
|
|
138
|
+
_this.lf.on('history:change', function (_a) {
|
|
115
139
|
var redoAble = _a.data.redoAble;
|
|
116
140
|
itemContainer.className = redoAble ? NORMAL : DISABLED;
|
|
117
141
|
});
|
|
@@ -124,7 +148,9 @@ var Control = {
|
|
|
124
148
|
});
|
|
125
149
|
controlTool.append.apply(controlTool, __spread(controlElements));
|
|
126
150
|
return controlTool;
|
|
127
|
-
}
|
|
128
|
-
|
|
151
|
+
};
|
|
152
|
+
Control.pluginName = 'control';
|
|
153
|
+
return Control;
|
|
154
|
+
}());
|
|
129
155
|
exports.Control = Control;
|
|
130
156
|
exports.default = Control;
|
|
@@ -16,11 +16,12 @@ var DndPanel = /** @class */ (function () {
|
|
|
16
16
|
}
|
|
17
17
|
DndPanel.prototype.render = function (lf, domContainer) {
|
|
18
18
|
var _this = this;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
this.destroy();
|
|
20
|
+
if (!this.shapeList || this.shapeList.length === 0) {
|
|
21
|
+
// 首次render后失败后,后续调用setPatternItems支持渲染
|
|
22
|
+
this.domContainer = domContainer;
|
|
23
23
|
return;
|
|
24
|
+
}
|
|
24
25
|
this.panelEl = document.createElement('div');
|
|
25
26
|
this.panelEl.className = 'lf-dndpanel';
|
|
26
27
|
this.shapeList.forEach(function (shapeItem) {
|
|
@@ -29,6 +30,11 @@ var DndPanel = /** @class */ (function () {
|
|
|
29
30
|
domContainer.appendChild(this.panelEl);
|
|
30
31
|
this.domContainer = domContainer;
|
|
31
32
|
};
|
|
33
|
+
DndPanel.prototype.destroy = function () {
|
|
34
|
+
if (this.domContainer && this.panelEl && this.domContainer.contains(this.panelEl)) {
|
|
35
|
+
this.domContainer.removeChild(this.panelEl);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
32
38
|
DndPanel.prototype.createDndItem = function (shapeItem) {
|
|
33
39
|
var _this = this;
|
|
34
40
|
var el = document.createElement('div');
|
|
@@ -54,7 +60,7 @@ var DndPanel = /** @class */ (function () {
|
|
|
54
60
|
});
|
|
55
61
|
}
|
|
56
62
|
if (shapeItem.callback) {
|
|
57
|
-
shapeItem.callback();
|
|
63
|
+
shapeItem.callback(_this.lf, _this.domContainer);
|
|
58
64
|
}
|
|
59
65
|
};
|
|
60
66
|
return el;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import LogicFlow
|
|
1
|
+
import LogicFlow from '@logicflow/core';
|
|
2
2
|
declare type ControlItem = {
|
|
3
3
|
key: string;
|
|
4
4
|
iconClass: string;
|
|
@@ -8,16 +8,20 @@ declare type ControlItem = {
|
|
|
8
8
|
onMouseEnter?: Function;
|
|
9
9
|
onMouseLeave?: Function;
|
|
10
10
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
11
|
+
declare class Control {
|
|
12
|
+
lf: LogicFlow;
|
|
13
|
+
static pluginName: string;
|
|
14
|
+
controlItems: ControlItem[];
|
|
15
|
+
domContainer: HTMLElement;
|
|
16
|
+
toolEl: HTMLElement;
|
|
17
|
+
constructor({ lf }: {
|
|
18
|
+
lf: any;
|
|
19
|
+
});
|
|
20
|
+
render(lf: any, domContainer: any): void;
|
|
21
|
+
destroy(): void;
|
|
22
|
+
addItem(item: any): void;
|
|
23
|
+
removeItem(key: any): ControlItem;
|
|
24
|
+
private getControlTool;
|
|
20
25
|
}
|
|
21
|
-
declare const Control: ControlPlugin;
|
|
22
26
|
export default Control;
|
|
23
|
-
export { Control
|
|
27
|
+
export { Control };
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
1
12
|
var __read = (this && this.__read) || function (o, n) {
|
|
2
13
|
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
3
14
|
if (!m) return o;
|
|
@@ -18,83 +29,96 @@ var __spread = (this && this.__spread) || function () {
|
|
|
18
29
|
for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
|
|
19
30
|
return ar;
|
|
20
31
|
};
|
|
21
|
-
var Control = {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
32
|
+
var Control = /** @class */ (function () {
|
|
33
|
+
function Control(_a) {
|
|
34
|
+
var _b;
|
|
35
|
+
var _this = this;
|
|
36
|
+
var lf = _a.lf;
|
|
37
|
+
var _c;
|
|
38
|
+
this.controlItems = [
|
|
39
|
+
{
|
|
40
|
+
key: 'zoom-out',
|
|
41
|
+
iconClass: 'lf-control-zoomOut',
|
|
42
|
+
title: '缩小流程图',
|
|
43
|
+
text: '缩小',
|
|
44
|
+
onClick: function () {
|
|
45
|
+
_this.lf.zoom(false);
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
key: 'zoom-in',
|
|
50
|
+
iconClass: 'lf-control-zoomIn',
|
|
51
|
+
title: '放大流程图',
|
|
52
|
+
text: '放大',
|
|
53
|
+
onClick: function () {
|
|
54
|
+
_this.lf.zoom(true);
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
key: 'reset',
|
|
59
|
+
iconClass: 'lf-control-fit',
|
|
60
|
+
title: '恢复流程原有尺寸',
|
|
61
|
+
text: '适应',
|
|
62
|
+
onClick: function () {
|
|
63
|
+
_this.lf.resetZoom();
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
key: 'undo',
|
|
68
|
+
iconClass: 'lf-control-undo',
|
|
69
|
+
title: '回到上一步',
|
|
70
|
+
text: '上一步',
|
|
71
|
+
onClick: function () {
|
|
72
|
+
_this.lf.undo();
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
key: 'redo',
|
|
77
|
+
iconClass: 'lf-control-redo',
|
|
78
|
+
title: '移到下一步',
|
|
79
|
+
text: '下一步',
|
|
80
|
+
onClick: function () {
|
|
81
|
+
_this.lf.redo();
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
];
|
|
85
|
+
this.lf = lf;
|
|
86
|
+
this.lf.extension = __assign(__assign({}, ((_c = this.lf.extension) !== null && _c !== void 0 ? _c : {})), (_b = {}, _b[Control.pluginName] = this, _b));
|
|
87
|
+
}
|
|
88
|
+
Control.prototype.render = function (lf, domContainer) {
|
|
89
|
+
this.destroy();
|
|
90
|
+
var toolEl = this.getControlTool();
|
|
91
|
+
this.toolEl = toolEl;
|
|
92
|
+
domContainer.appendChild(toolEl);
|
|
93
|
+
this.domContainer = domContainer;
|
|
94
|
+
};
|
|
95
|
+
Control.prototype.destroy = function () {
|
|
96
|
+
if (this.domContainer && this.toolEl && this.domContainer.contains(this.toolEl)) {
|
|
97
|
+
this.domContainer.removeChild(this.toolEl);
|
|
79
98
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
|
|
99
|
+
};
|
|
100
|
+
Control.prototype.addItem = function (item) {
|
|
101
|
+
this.controlItems.push(item);
|
|
102
|
+
};
|
|
103
|
+
Control.prototype.removeItem = function (key) {
|
|
104
|
+
var index = this.controlItems.findIndex(function (item) { return item.key === key; });
|
|
105
|
+
return this.controlItems.splice(index, 1)[0];
|
|
106
|
+
};
|
|
107
|
+
Control.prototype.getControlTool = function () {
|
|
108
|
+
var _this = this;
|
|
85
109
|
var NORMAL = 'lf-control-item';
|
|
86
110
|
var DISABLED = 'lf-control-item disabled';
|
|
87
111
|
var controlTool = document.createElement('div');
|
|
88
112
|
var controlElements = [];
|
|
89
113
|
controlTool.className = 'lf-control';
|
|
90
|
-
|
|
114
|
+
this.controlItems.forEach(function (item) {
|
|
91
115
|
var itemContainer = document.createElement('div');
|
|
92
116
|
var icon = document.createElement('i');
|
|
93
117
|
var text = document.createElement('span');
|
|
94
118
|
itemContainer.className = DISABLED;
|
|
95
|
-
item.onClick && (itemContainer.onclick = item.onClick.bind(null,
|
|
96
|
-
item.onMouseEnter && (itemContainer.onmouseenter = item.onMouseEnter.bind(null,
|
|
97
|
-
item.onMouseLeave && (itemContainer.onmouseleave = item.onMouseLeave.bind(null,
|
|
119
|
+
item.onClick && (itemContainer.onclick = item.onClick.bind(null, _this.lf));
|
|
120
|
+
item.onMouseEnter && (itemContainer.onmouseenter = item.onMouseEnter.bind(null, _this.lf));
|
|
121
|
+
item.onMouseLeave && (itemContainer.onmouseleave = item.onMouseLeave.bind(null, _this.lf));
|
|
98
122
|
icon.className = item.iconClass;
|
|
99
123
|
text.className = 'lf-control-text';
|
|
100
124
|
text.title = item.title;
|
|
@@ -102,13 +126,13 @@ var Control = {
|
|
|
102
126
|
itemContainer.append(icon, text);
|
|
103
127
|
switch (item.text) {
|
|
104
128
|
case '上一步':
|
|
105
|
-
|
|
129
|
+
_this.lf.on('history:change', function (_a) {
|
|
106
130
|
var undoAble = _a.data.undoAble;
|
|
107
131
|
itemContainer.className = undoAble ? NORMAL : DISABLED;
|
|
108
132
|
});
|
|
109
133
|
break;
|
|
110
134
|
case '下一步':
|
|
111
|
-
|
|
135
|
+
_this.lf.on('history:change', function (_a) {
|
|
112
136
|
var redoAble = _a.data.redoAble;
|
|
113
137
|
itemContainer.className = redoAble ? NORMAL : DISABLED;
|
|
114
138
|
});
|
|
@@ -121,7 +145,9 @@ var Control = {
|
|
|
121
145
|
});
|
|
122
146
|
controlTool.append.apply(controlTool, __spread(controlElements));
|
|
123
147
|
return controlTool;
|
|
124
|
-
}
|
|
125
|
-
|
|
148
|
+
};
|
|
149
|
+
Control.pluginName = 'control';
|
|
150
|
+
return Control;
|
|
151
|
+
}());
|
|
126
152
|
export default Control;
|
|
127
|
-
export { Control
|
|
153
|
+
export { Control };
|
|
@@ -3,9 +3,10 @@ declare type ShapeItem = {
|
|
|
3
3
|
type?: string;
|
|
4
4
|
text?: string;
|
|
5
5
|
icon?: string;
|
|
6
|
+
label?: string;
|
|
6
7
|
className?: string;
|
|
7
8
|
properties?: Record<string, any>;
|
|
8
|
-
callback?: () => void;
|
|
9
|
+
callback?: (lf: LogicFlow, container: HTMLElement) => void;
|
|
9
10
|
};
|
|
10
11
|
declare class DndPanel {
|
|
11
12
|
lf: LogicFlow;
|
|
@@ -17,6 +18,7 @@ declare class DndPanel {
|
|
|
17
18
|
lf: any;
|
|
18
19
|
});
|
|
19
20
|
render(lf: any, domContainer: any): void;
|
|
21
|
+
destroy(): void;
|
|
20
22
|
private createDndItem;
|
|
21
23
|
}
|
|
22
24
|
export { DndPanel, };
|
|
@@ -13,11 +13,12 @@ var DndPanel = /** @class */ (function () {
|
|
|
13
13
|
}
|
|
14
14
|
DndPanel.prototype.render = function (lf, domContainer) {
|
|
15
15
|
var _this = this;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
this.destroy();
|
|
17
|
+
if (!this.shapeList || this.shapeList.length === 0) {
|
|
18
|
+
// 首次render后失败后,后续调用setPatternItems支持渲染
|
|
19
|
+
this.domContainer = domContainer;
|
|
20
20
|
return;
|
|
21
|
+
}
|
|
21
22
|
this.panelEl = document.createElement('div');
|
|
22
23
|
this.panelEl.className = 'lf-dndpanel';
|
|
23
24
|
this.shapeList.forEach(function (shapeItem) {
|
|
@@ -26,6 +27,11 @@ var DndPanel = /** @class */ (function () {
|
|
|
26
27
|
domContainer.appendChild(this.panelEl);
|
|
27
28
|
this.domContainer = domContainer;
|
|
28
29
|
};
|
|
30
|
+
DndPanel.prototype.destroy = function () {
|
|
31
|
+
if (this.domContainer && this.panelEl && this.domContainer.contains(this.panelEl)) {
|
|
32
|
+
this.domContainer.removeChild(this.panelEl);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
29
35
|
DndPanel.prototype.createDndItem = function (shapeItem) {
|
|
30
36
|
var _this = this;
|
|
31
37
|
var el = document.createElement('div');
|
|
@@ -51,7 +57,7 @@ var DndPanel = /** @class */ (function () {
|
|
|
51
57
|
});
|
|
52
58
|
}
|
|
53
59
|
if (shapeItem.callback) {
|
|
54
|
-
shapeItem.callback();
|
|
60
|
+
shapeItem.callback(_this.lf, _this.domContainer);
|
|
55
61
|
}
|
|
56
62
|
};
|
|
57
63
|
return el;
|