@logicflow/extension 1.2.0-alpha.0 → 1.2.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/components/control/index.js +16 -16
- package/cjs/components/menu/index.js +9 -9
- package/cjs/index.js +1 -0
- package/cjs/locale/en-locale/en.js +22 -0
- package/cjs/locale/en-locale/index.js +29 -0
- package/cjs/locale/locale.js +19 -0
- package/cjs/tools/snapshot/index.js +47 -46
- package/cjs/turbo-adapter/index.js +71 -41
- package/es/components/control/index.d.ts +2 -3
- package/es/components/control/index.js +16 -16
- package/es/components/menu/index.d.ts +2 -3
- package/es/components/menu/index.js +9 -9
- package/es/index.d.ts +1 -0
- package/es/index.js +1 -0
- package/es/locale/en-locale/en.d.ts +19 -0
- package/es/locale/en-locale/en.js +19 -0
- package/es/locale/en-locale/index.d.ts +9 -0
- package/es/locale/en-locale/index.js +26 -0
- package/es/locale/locale.d.ts +6 -0
- package/es/locale/locale.js +16 -0
- package/es/tools/snapshot/index.d.ts +15 -7
- package/es/tools/snapshot/index.js +47 -46
- package/es/turbo-adapter/index.d.ts +6 -7
- package/es/turbo-adapter/index.js +70 -40
- 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/EnLocale.js +1 -0
- 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/components/control/index.d.ts +2 -3
- package/types/components/menu/index.d.ts +2 -3
- package/types/index.d.ts +1 -0
- package/types/locale/en-locale/en.d.ts +19 -0
- package/types/locale/en-locale/index.d.ts +9 -0
- package/types/locale/locale.d.ts +6 -0
- package/types/tools/snapshot/index.d.ts +15 -7
- package/types/turbo-adapter/index.d.ts +6 -7
|
@@ -22,15 +22,16 @@ var __spread = (this && this.__spread) || function () {
|
|
|
22
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
23
|
exports.Control = void 0;
|
|
24
24
|
var Control = /** @class */ (function () {
|
|
25
|
-
function Control(
|
|
25
|
+
function Control(args) {
|
|
26
26
|
var _this = this;
|
|
27
|
-
|
|
27
|
+
this.lf = args.lf;
|
|
28
|
+
this.LogicFlow = args.LogicFlow;
|
|
28
29
|
this.controlItems = [
|
|
29
30
|
{
|
|
30
31
|
key: 'zoom-out',
|
|
31
32
|
iconClass: 'lf-control-zoomOut',
|
|
32
|
-
title: '缩小流程图',
|
|
33
|
-
text: '缩小',
|
|
33
|
+
title: this.LogicFlow.t('缩小流程图'),
|
|
34
|
+
text: this.LogicFlow.t('缩小'),
|
|
34
35
|
onClick: function () {
|
|
35
36
|
_this.lf.zoom(false);
|
|
36
37
|
},
|
|
@@ -38,8 +39,8 @@ var Control = /** @class */ (function () {
|
|
|
38
39
|
{
|
|
39
40
|
key: 'zoom-in',
|
|
40
41
|
iconClass: 'lf-control-zoomIn',
|
|
41
|
-
title: '放大流程图',
|
|
42
|
-
text: '放大',
|
|
42
|
+
title: this.LogicFlow.t('放大流程图'),
|
|
43
|
+
text: this.LogicFlow.t('放大'),
|
|
43
44
|
onClick: function () {
|
|
44
45
|
_this.lf.zoom(true);
|
|
45
46
|
},
|
|
@@ -47,8 +48,8 @@ var Control = /** @class */ (function () {
|
|
|
47
48
|
{
|
|
48
49
|
key: 'reset',
|
|
49
50
|
iconClass: 'lf-control-fit',
|
|
50
|
-
title: '恢复流程原有尺寸',
|
|
51
|
-
text: '适应',
|
|
51
|
+
title: this.LogicFlow.t('恢复流程原有尺寸'),
|
|
52
|
+
text: this.LogicFlow.t('适应'),
|
|
52
53
|
onClick: function () {
|
|
53
54
|
_this.lf.resetZoom();
|
|
54
55
|
},
|
|
@@ -56,8 +57,8 @@ var Control = /** @class */ (function () {
|
|
|
56
57
|
{
|
|
57
58
|
key: 'undo',
|
|
58
59
|
iconClass: 'lf-control-undo',
|
|
59
|
-
title: '回到上一步',
|
|
60
|
-
text: '上一步',
|
|
60
|
+
title: this.LogicFlow.t('回到上一步'),
|
|
61
|
+
text: this.LogicFlow.t('上一步'),
|
|
61
62
|
onClick: function () {
|
|
62
63
|
_this.lf.undo();
|
|
63
64
|
},
|
|
@@ -65,14 +66,13 @@ var Control = /** @class */ (function () {
|
|
|
65
66
|
{
|
|
66
67
|
key: 'redo',
|
|
67
68
|
iconClass: 'lf-control-redo',
|
|
68
|
-
title: '移到下一步',
|
|
69
|
-
text: '下一步',
|
|
69
|
+
title: this.LogicFlow.t('移到下一步'),
|
|
70
|
+
text: this.LogicFlow.t('下一步'),
|
|
70
71
|
onClick: function () {
|
|
71
72
|
_this.lf.redo();
|
|
72
73
|
},
|
|
73
74
|
},
|
|
74
75
|
];
|
|
75
|
-
this.lf = lf;
|
|
76
76
|
}
|
|
77
77
|
Control.prototype.render = function (lf, domContainer) {
|
|
78
78
|
this.destroy();
|
|
@@ -113,14 +113,14 @@ var Control = /** @class */ (function () {
|
|
|
113
113
|
text.title = item.title;
|
|
114
114
|
text.innerText = item.text;
|
|
115
115
|
itemContainer.append(icon, text);
|
|
116
|
-
switch (item.
|
|
117
|
-
case '
|
|
116
|
+
switch (item.key) {
|
|
117
|
+
case 'undo':
|
|
118
118
|
_this.lf.on('history:change', function (_a) {
|
|
119
119
|
var undoAble = _a.data.undoAble;
|
|
120
120
|
itemContainer.className = undoAble ? NORMAL : DISABLED;
|
|
121
121
|
});
|
|
122
122
|
break;
|
|
123
|
-
case '
|
|
123
|
+
case 'redo':
|
|
124
124
|
_this.lf.on('history:change', function (_a) {
|
|
125
125
|
var redoAble = _a.data.redoAble;
|
|
126
126
|
itemContainer.className = redoAble ? NORMAL : DISABLED;
|
|
@@ -26,11 +26,11 @@ var DefaultEdgeMenuKey = 'lf:defaultEdgeMenu';
|
|
|
26
26
|
var DefaultGraphMenuKey = 'lf:defaultGraphMenu';
|
|
27
27
|
var DefaultSelectionMenuKey = 'lf:defaultSelectionMenu';
|
|
28
28
|
var Menu = /** @class */ (function () {
|
|
29
|
-
function Menu(
|
|
29
|
+
function Menu(args) {
|
|
30
30
|
var _this = this;
|
|
31
|
-
var lf = _a.lf;
|
|
32
31
|
this.__menuDOM = document.createElement('ul');
|
|
33
|
-
this.lf = lf;
|
|
32
|
+
this.lf = args.lf;
|
|
33
|
+
this.LogicFlow = args.LogicFlow;
|
|
34
34
|
this.menuTypeMap = new Map();
|
|
35
35
|
this.init();
|
|
36
36
|
this.lf.setMenuConfig = function (config) {
|
|
@@ -50,19 +50,19 @@ var Menu = /** @class */ (function () {
|
|
|
50
50
|
var _this = this;
|
|
51
51
|
var defaultNodeMenu = [
|
|
52
52
|
{
|
|
53
|
-
text: '删除',
|
|
53
|
+
text: this.LogicFlow.t('删除'),
|
|
54
54
|
callback: function (node) {
|
|
55
55
|
_this.lf.deleteNode(node.id);
|
|
56
56
|
},
|
|
57
57
|
},
|
|
58
58
|
{
|
|
59
|
-
text: '编辑文本',
|
|
59
|
+
text: this.LogicFlow.t('编辑文本'),
|
|
60
60
|
callback: function (node) {
|
|
61
61
|
_this.lf.graphModel.editText(node.id);
|
|
62
62
|
},
|
|
63
63
|
},
|
|
64
64
|
{
|
|
65
|
-
text: '复制',
|
|
65
|
+
text: this.LogicFlow.t('复制'),
|
|
66
66
|
callback: function (node) {
|
|
67
67
|
_this.lf.cloneNode(node.id);
|
|
68
68
|
},
|
|
@@ -71,13 +71,13 @@ var Menu = /** @class */ (function () {
|
|
|
71
71
|
this.menuTypeMap.set(DefaultNodeMenuKey, defaultNodeMenu);
|
|
72
72
|
var defaultEdgeMenu = [
|
|
73
73
|
{
|
|
74
|
-
text: '删除',
|
|
74
|
+
text: this.LogicFlow.t('删除'),
|
|
75
75
|
callback: function (edge) {
|
|
76
76
|
_this.lf.deleteEdge(edge.id);
|
|
77
77
|
},
|
|
78
78
|
},
|
|
79
79
|
{
|
|
80
|
-
text: '编辑文本',
|
|
80
|
+
text: this.LogicFlow.t('编辑文本'),
|
|
81
81
|
callback: function (edge) {
|
|
82
82
|
_this.lf.graphModel.editText(edge.id);
|
|
83
83
|
},
|
|
@@ -87,7 +87,7 @@ var Menu = /** @class */ (function () {
|
|
|
87
87
|
this.menuTypeMap.set(DefaultGraphMenuKey, []);
|
|
88
88
|
var DefaultSelectionMenu = [
|
|
89
89
|
{
|
|
90
|
-
text: '删除',
|
|
90
|
+
text: this.LogicFlow.t('删除'),
|
|
91
91
|
callback: function (elements) {
|
|
92
92
|
_this.lf.clearSelectElements();
|
|
93
93
|
elements.edges.forEach(function (edge) { return _this.lf.deleteEdge(edge.id); });
|
package/cjs/index.js
CHANGED
|
@@ -29,3 +29,4 @@ __exportStar(require("./tools/flow-path"), exports);
|
|
|
29
29
|
__exportStar(require("./tools/auto-layout"), exports);
|
|
30
30
|
__exportStar(require("./bpmn-adapter/xml2json"), exports);
|
|
31
31
|
__exportStar(require("./bpmn-adapter/json2xml"), exports);
|
|
32
|
+
__exportStar(require("./locale/en-locale"), exports);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.en = void 0;
|
|
4
|
+
var en = {
|
|
5
|
+
文本: 'text',
|
|
6
|
+
开始: 'start',
|
|
7
|
+
缩小流程图: 'zoom in',
|
|
8
|
+
缩小: 'zoom in',
|
|
9
|
+
放大流程图: 'zoom out',
|
|
10
|
+
放大: 'zoom out',
|
|
11
|
+
恢复流程原有尺寸: 'adapt to original size',
|
|
12
|
+
适应: 'adapt',
|
|
13
|
+
回到上一步: 'undo',
|
|
14
|
+
上一步: 'undo',
|
|
15
|
+
移到下一步: 'redo',
|
|
16
|
+
下一步: 'redo',
|
|
17
|
+
删除: 'delete',
|
|
18
|
+
编辑文本: 'edit text',
|
|
19
|
+
复制: 'copy',
|
|
20
|
+
};
|
|
21
|
+
exports.en = en;
|
|
22
|
+
exports.default = en;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
extendStatics(d, b);
|
|
11
|
+
function __() { this.constructor = d; }
|
|
12
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.EnLocale = void 0;
|
|
17
|
+
var locale_1 = require("../locale");
|
|
18
|
+
var en_1 = require("./en");
|
|
19
|
+
var EnLocale = /** @class */ (function (_super) {
|
|
20
|
+
__extends(EnLocale, _super);
|
|
21
|
+
function EnLocale(_a) {
|
|
22
|
+
var LogicFlow = _a.LogicFlow;
|
|
23
|
+
return _super.call(this, LogicFlow, en_1.default) || this;
|
|
24
|
+
}
|
|
25
|
+
EnLocale.pluginName = 'enLocale';
|
|
26
|
+
return EnLocale;
|
|
27
|
+
}(locale_1.Locale));
|
|
28
|
+
exports.EnLocale = EnLocale;
|
|
29
|
+
exports.default = EnLocale;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Locale = void 0;
|
|
4
|
+
var Locale = /** @class */ (function () {
|
|
5
|
+
function Locale(LogicFlow, map) {
|
|
6
|
+
if (LogicFlow && map) {
|
|
7
|
+
this.replaceTranslator(LogicFlow, map);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
Locale.prototype.replaceTranslator = function (LogicFlow, map) {
|
|
11
|
+
LogicFlow.t = function (text) { return (map[text] ? map[text] : text); };
|
|
12
|
+
};
|
|
13
|
+
Locale.prototype.setDefault = function (LogicFlow) {
|
|
14
|
+
LogicFlow.t = Locale.defaultTranslator;
|
|
15
|
+
};
|
|
16
|
+
Locale.defaultTranslator = function (text) { return text; };
|
|
17
|
+
return Locale;
|
|
18
|
+
}());
|
|
19
|
+
exports.Locale = Locale;
|
|
@@ -4,37 +4,27 @@
|
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.Snapshot = void 0;
|
|
7
|
-
var Snapshot = {
|
|
8
|
-
|
|
9
|
-
install: function (lf) {
|
|
7
|
+
var Snapshot = /** @class */ (function () {
|
|
8
|
+
function Snapshot(_a) {
|
|
10
9
|
var _this = this;
|
|
10
|
+
var lf = _a.lf;
|
|
11
11
|
this.lf = lf;
|
|
12
|
+
this.customCssRules = '';
|
|
13
|
+
this.useGlobalRules = true;
|
|
12
14
|
/* 下载快照 */
|
|
13
15
|
lf.getSnapshot = function (fileName, backgroundColor) {
|
|
14
|
-
_this.
|
|
15
|
-
_this.offsetY = Number.MAX_SAFE_INTEGER;
|
|
16
|
-
_this.fileName = fileName || "logic-flow." + Date.now() + ".png";
|
|
17
|
-
var svgRootElement = _this.getSvgRootElement(lf);
|
|
18
|
-
_this.downloadSvg(svgRootElement, _this.fileName, backgroundColor);
|
|
16
|
+
_this.getSnapshot(fileName, backgroundColor);
|
|
19
17
|
};
|
|
20
18
|
/* 获取Blob对象,用户图片上传 */
|
|
21
|
-
lf.getSnapshotBlob = function (backgroundColor) {
|
|
22
|
-
_this.offsetX = Number.MAX_SAFE_INTEGER;
|
|
23
|
-
_this.offsetY = Number.MAX_SAFE_INTEGER;
|
|
24
|
-
var svgRootElement = _this.getSvgRootElement(lf);
|
|
25
|
-
return _this.getBlob(svgRootElement, backgroundColor);
|
|
26
|
-
};
|
|
19
|
+
lf.getSnapshotBlob = function (backgroundColor) { return _this.getSnapshotBlob(backgroundColor); };
|
|
27
20
|
/* 获取Base64对象,用户图片上传 */
|
|
28
|
-
lf.getSnapshotBase64 = function (backgroundColor) {
|
|
29
|
-
|
|
30
|
-
_this.offsetY = Number.MAX_SAFE_INTEGER;
|
|
31
|
-
var svgRootElement = _this.getSvgRootElement(lf);
|
|
32
|
-
return _this.getBase64(svgRootElement, backgroundColor);
|
|
33
|
-
};
|
|
34
|
-
},
|
|
21
|
+
lf.getSnapshotBase64 = function (backgroundColor) { return _this.getSnapshotBase64(backgroundColor); };
|
|
22
|
+
}
|
|
35
23
|
/* 获取svgRoot对象 */
|
|
36
|
-
getSvgRootElement
|
|
24
|
+
Snapshot.prototype.getSvgRootElement = function (lf) {
|
|
37
25
|
var _this = this;
|
|
26
|
+
this.offsetX = Number.MAX_SAFE_INTEGER;
|
|
27
|
+
this.offsetY = Number.MAX_SAFE_INTEGER;
|
|
38
28
|
lf.graphModel.nodes.forEach(function (item) {
|
|
39
29
|
var x = item.x, width = item.width, y = item.y, height = item.height;
|
|
40
30
|
var offsetX = x - width / 2;
|
|
@@ -61,8 +51,8 @@ var Snapshot = {
|
|
|
61
51
|
});
|
|
62
52
|
var svgRootElement = lf.container.querySelector('.lf-canvas-overlay');
|
|
63
53
|
return svgRootElement;
|
|
64
|
-
}
|
|
65
|
-
triggerDownload
|
|
54
|
+
};
|
|
55
|
+
Snapshot.prototype.triggerDownload = function (imgURI) {
|
|
66
56
|
var evt = new MouseEvent('click', {
|
|
67
57
|
view: window,
|
|
68
58
|
bubbles: false,
|
|
@@ -73,8 +63,8 @@ var Snapshot = {
|
|
|
73
63
|
a.setAttribute('href', imgURI);
|
|
74
64
|
a.setAttribute('target', '_blank');
|
|
75
65
|
a.dispatchEvent(evt);
|
|
76
|
-
}
|
|
77
|
-
removeAnchor
|
|
66
|
+
};
|
|
67
|
+
Snapshot.prototype.removeAnchor = function (element) {
|
|
78
68
|
var childNodes = element.childNodes;
|
|
79
69
|
var childLength = element.childNodes && element.childNodes.length;
|
|
80
70
|
for (var i = 0; i < childLength; i++) {
|
|
@@ -86,20 +76,22 @@ var Snapshot = {
|
|
|
86
76
|
i--;
|
|
87
77
|
}
|
|
88
78
|
}
|
|
89
|
-
}
|
|
79
|
+
};
|
|
90
80
|
/* 下载图片 */
|
|
91
|
-
|
|
81
|
+
Snapshot.prototype.getSnapshot = function (fileName, backgroundColor) {
|
|
92
82
|
var _this = this;
|
|
83
|
+
this.fileName = fileName || "logic-flow." + Date.now() + ".png";
|
|
84
|
+
var svg = this.getSvgRootElement(this.lf);
|
|
93
85
|
this.getCanvasData(svg, backgroundColor).then(function (canvas) {
|
|
94
|
-
var imgURI = canvas
|
|
95
|
-
.toDataURL('image/png')
|
|
86
|
+
var imgURI = canvas.toDataURL('image/png')
|
|
96
87
|
.replace('image/png', 'image/octet-stream');
|
|
97
|
-
_this.triggerDownload(imgURI
|
|
88
|
+
_this.triggerDownload(imgURI);
|
|
98
89
|
});
|
|
99
|
-
}
|
|
90
|
+
};
|
|
100
91
|
/* 获取base64对象 */
|
|
101
|
-
|
|
92
|
+
Snapshot.prototype.getSnapshotBase64 = function (backgroundColor) {
|
|
102
93
|
var _this = this;
|
|
94
|
+
var svg = this.getSvgRootElement(this.lf);
|
|
103
95
|
return new Promise(function (resolve) {
|
|
104
96
|
_this.getCanvasData(svg, backgroundColor).then(function (canvas) {
|
|
105
97
|
var base64 = canvas.toDataURL('image/png');
|
|
@@ -107,10 +99,11 @@ var Snapshot = {
|
|
|
107
99
|
resolve({ data: base64, width: canvas.width, height: canvas.height });
|
|
108
100
|
});
|
|
109
101
|
});
|
|
110
|
-
}
|
|
102
|
+
};
|
|
111
103
|
/* 获取Blob对象 */
|
|
112
|
-
|
|
104
|
+
Snapshot.prototype.getSnapshotBlob = function (backgroundColor) {
|
|
113
105
|
var _this = this;
|
|
106
|
+
var svg = this.getSvgRootElement(this.lf);
|
|
114
107
|
return new Promise(function (resolve) {
|
|
115
108
|
_this.getCanvasData(svg, backgroundColor).then(function (canvas) {
|
|
116
109
|
canvas.toBlob(function (blob) {
|
|
@@ -119,20 +112,25 @@ var Snapshot = {
|
|
|
119
112
|
}, 'image/png');
|
|
120
113
|
});
|
|
121
114
|
});
|
|
122
|
-
}
|
|
123
|
-
getClassRules
|
|
115
|
+
};
|
|
116
|
+
Snapshot.prototype.getClassRules = function () {
|
|
124
117
|
var rules = '';
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
var
|
|
128
|
-
|
|
129
|
-
|
|
118
|
+
if (this.useGlobalRules) {
|
|
119
|
+
var styleSheets = document.styleSheets;
|
|
120
|
+
for (var i = 0; i < styleSheets.length; i++) {
|
|
121
|
+
var sheet = styleSheets[i];
|
|
122
|
+
for (var j = 0; j < sheet.cssRules.length; j++) {
|
|
123
|
+
rules += sheet.cssRules[j].cssText;
|
|
124
|
+
}
|
|
130
125
|
}
|
|
131
126
|
}
|
|
127
|
+
if (this.customCssRules) {
|
|
128
|
+
rules += this.customCssRules;
|
|
129
|
+
}
|
|
132
130
|
return rules;
|
|
133
|
-
}
|
|
131
|
+
};
|
|
134
132
|
// 获取图片生成中中间产物canvas对象,用户转换为其他需要的格式
|
|
135
|
-
getCanvasData
|
|
133
|
+
Snapshot.prototype.getCanvasData = function (svg, backgroundColor) {
|
|
136
134
|
var _this = this;
|
|
137
135
|
var copy = svg.cloneNode(true);
|
|
138
136
|
var graph = copy.lastChild;
|
|
@@ -204,12 +202,15 @@ var Snapshot = {
|
|
|
204
202
|
因为svg中存在dom存放在foreignObject元素中
|
|
205
203
|
SVG图形转成img对象
|
|
206
204
|
todo: 会导致一些清晰度问题这个需要再解决
|
|
205
|
+
fixme: XMLSerializer的中的css background url不会下载图片
|
|
207
206
|
*/
|
|
208
207
|
var svg2Img = "data:image/svg+xml;charset=utf-8," + new XMLSerializer().serializeToString(copy);
|
|
209
208
|
var imgSrc = svg2Img.replace(/\n/g, '').replace(/\t/g, '').replace(/#/g, '%23');
|
|
210
209
|
img.src = imgSrc;
|
|
211
210
|
});
|
|
212
|
-
}
|
|
213
|
-
|
|
211
|
+
};
|
|
212
|
+
Snapshot.pluginName = 'snapshot';
|
|
213
|
+
return Snapshot;
|
|
214
|
+
}());
|
|
214
215
|
exports.Snapshot = Snapshot;
|
|
215
216
|
exports.default = Snapshot;
|
|
@@ -10,17 +10,39 @@ 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
|
-
exports.
|
|
15
|
-
var TurboType
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
TurboType[TurboType["USER_TASK"] = 4] = "USER_TASK";
|
|
30
|
+
exports.toLogicflowData = exports.toTurboData = void 0;
|
|
31
|
+
var TurboType = {
|
|
32
|
+
SEQUENCE_FLOW: 1,
|
|
33
|
+
START_EVENT: 2,
|
|
34
|
+
END_EVENT: 3,
|
|
35
|
+
USER_TASK: 4,
|
|
21
36
|
// SERVICE_TASK = 5, 暂不支持
|
|
22
|
-
|
|
23
|
-
}
|
|
37
|
+
EXCLUSIVE_GATEWAY: 6,
|
|
38
|
+
};
|
|
39
|
+
var TurboTypeMap = {
|
|
40
|
+
1: 'bpmn:sequenceFlow',
|
|
41
|
+
2: 'bpmn:startEvent',
|
|
42
|
+
3: 'bpmn:endEvent',
|
|
43
|
+
4: 'bpmn:userTask',
|
|
44
|
+
6: 'bpmn:exclusiveGateway',
|
|
45
|
+
};
|
|
24
46
|
// 转换Turbo识别的类型
|
|
25
47
|
function getTurboType(type) {
|
|
26
48
|
switch (type) {
|
|
@@ -50,7 +72,7 @@ function convertNodeToTurboElement(node) {
|
|
|
50
72
|
type: getTurboType(node.type),
|
|
51
73
|
properties: __assign(__assign({}, properties), { name: (text && text.value) || '', x: x,
|
|
52
74
|
y: y,
|
|
53
|
-
text: text
|
|
75
|
+
text: text }),
|
|
54
76
|
key: id,
|
|
55
77
|
};
|
|
56
78
|
}
|
|
@@ -62,10 +84,7 @@ function convertEdgeToTurboElement(edge) {
|
|
|
62
84
|
outgoing: [targetNodeId],
|
|
63
85
|
type: getTurboType(type),
|
|
64
86
|
dockers: [],
|
|
65
|
-
properties: __assign(__assign({}, properties), { name: (text && text.value) || '', text: text,
|
|
66
|
-
startPoint: startPoint,
|
|
67
|
-
endPoint: endPoint,
|
|
68
|
-
pointsList: pointsList, logicFlowType: type }),
|
|
87
|
+
properties: __assign(__assign({}, properties), { name: (text && text.value) || '', text: text, startPoint: JSON.stringify(startPoint), endPoint: JSON.stringify(endPoint), pointsList: JSON.stringify(text) }),
|
|
69
88
|
key: id,
|
|
70
89
|
};
|
|
71
90
|
}
|
|
@@ -93,21 +112,30 @@ function toTurboData(data) {
|
|
|
93
112
|
exports.toTurboData = toTurboData;
|
|
94
113
|
// 将Turbo元素数据转换为LogicFlow中的Edge数据
|
|
95
114
|
function convertFlowElementToEdge(element) {
|
|
96
|
-
var incoming = element.incoming, outgoing = element.outgoing, properties = element.properties, key = element.key;
|
|
97
|
-
var text = properties.text,
|
|
115
|
+
var incoming = element.incoming, outgoing = element.outgoing, properties = element.properties, key = element.key, type = element.type;
|
|
116
|
+
var text = properties.text, name = properties.name, startPoint = properties.startPoint, endPoint = properties.endPoint, pointsList = properties.pointsList;
|
|
98
117
|
var edge = {
|
|
99
118
|
id: key,
|
|
100
|
-
type:
|
|
119
|
+
type: TurboTypeMap[type],
|
|
101
120
|
sourceNodeId: incoming[0],
|
|
102
121
|
targetNodeId: outgoing[0],
|
|
103
|
-
text: text,
|
|
104
|
-
startPoint: startPoint,
|
|
105
|
-
endPoint: endPoint,
|
|
106
|
-
pointsList: pointsList,
|
|
122
|
+
text: text || name,
|
|
107
123
|
properties: {},
|
|
108
124
|
};
|
|
125
|
+
if (startPoint) {
|
|
126
|
+
// @ts-ignore
|
|
127
|
+
edge.startPoint = JSON.parse(startPoint);
|
|
128
|
+
}
|
|
129
|
+
if (endPoint) {
|
|
130
|
+
// @ts-ignore
|
|
131
|
+
edge.endPoint = JSON.parse(endPoint);
|
|
132
|
+
}
|
|
133
|
+
if (pointsList) {
|
|
134
|
+
// @ts-ignore
|
|
135
|
+
edge.endPoint = JSON.parse(pointsList);
|
|
136
|
+
}
|
|
109
137
|
// 这种转换方式,在自定义属性中不能与excludeProperties中的属性重名,否则将在转换过程中丢失
|
|
110
|
-
var excludeProperties = ['startPoint', 'endPoint', 'pointsList', 'text'
|
|
138
|
+
var excludeProperties = ['startPoint', 'endPoint', 'pointsList', 'text'];
|
|
111
139
|
Object.keys(element.properties).forEach(function (property) {
|
|
112
140
|
if (excludeProperties.indexOf(property) === -1) {
|
|
113
141
|
edge.properties[property] = element.properties[property];
|
|
@@ -117,18 +145,23 @@ function convertFlowElementToEdge(element) {
|
|
|
117
145
|
}
|
|
118
146
|
// 将Turbo元素数据转换为LogicFlow中的Node数据
|
|
119
147
|
function convertFlowElementToNode(element) {
|
|
120
|
-
var properties = element.properties, key = element.key;
|
|
121
|
-
var x = properties.x, y = properties.y
|
|
148
|
+
var properties = element.properties, key = element.key, type = element.type, bounds = element.bounds;
|
|
149
|
+
var x = properties.x, y = properties.y;
|
|
150
|
+
if (x === undefined) {
|
|
151
|
+
var _a = __read(bounds, 2), _b = _a[0], x1 = _b.x, y1 = _b.y, _c = _a[1], x2 = _c.x, y2 = _c.y;
|
|
152
|
+
x = (x1 + x2) / 2;
|
|
153
|
+
y = (y1 + y2) / 2;
|
|
154
|
+
}
|
|
122
155
|
var node = {
|
|
123
156
|
id: key,
|
|
124
|
-
type:
|
|
157
|
+
type: TurboTypeMap[type],
|
|
125
158
|
x: x,
|
|
126
159
|
y: y,
|
|
127
|
-
text: text,
|
|
160
|
+
text: properties.text,
|
|
128
161
|
properties: {},
|
|
129
162
|
};
|
|
130
163
|
// 这种转换方式,在自定义属性中不能与excludeProperties中的属性重名,否则将在转换过程中丢失
|
|
131
|
-
var excludeProperties = ['x', 'y', 'text'
|
|
164
|
+
var excludeProperties = ['x', 'y', 'text'];
|
|
132
165
|
Object.keys(element.properties).forEach(function (property) {
|
|
133
166
|
if (excludeProperties.indexOf(property) === -1) {
|
|
134
167
|
node.properties[property] = element.properties[property];
|
|
@@ -156,26 +189,23 @@ function toLogicflowData(data) {
|
|
|
156
189
|
return lfData;
|
|
157
190
|
}
|
|
158
191
|
exports.toLogicflowData = toLogicflowData;
|
|
159
|
-
var TurboAdapter = {
|
|
160
|
-
|
|
161
|
-
|
|
192
|
+
var TurboAdapter = /** @class */ (function () {
|
|
193
|
+
function TurboAdapter(_a) {
|
|
194
|
+
var lf = _a.lf;
|
|
162
195
|
lf.adapterIn = this.adapterIn;
|
|
163
196
|
lf.adapterOut = this.adapterOut;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
setCustomShape: function (key, val) {
|
|
167
|
-
this.shapeConfigMap.set(key, val);
|
|
168
|
-
},
|
|
169
|
-
adapterOut: function (logicflowData) {
|
|
197
|
+
}
|
|
198
|
+
TurboAdapter.prototype.adapterOut = function (logicflowData) {
|
|
170
199
|
if (logicflowData) {
|
|
171
200
|
return toTurboData(logicflowData);
|
|
172
201
|
}
|
|
173
|
-
}
|
|
174
|
-
adapterIn
|
|
202
|
+
};
|
|
203
|
+
TurboAdapter.prototype.adapterIn = function (turboData) {
|
|
175
204
|
if (turboData) {
|
|
176
205
|
return toLogicflowData(turboData);
|
|
177
206
|
}
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
|
|
207
|
+
};
|
|
208
|
+
TurboAdapter.pluginName = 'turboAdapter';
|
|
209
|
+
return TurboAdapter;
|
|
210
|
+
}());
|
|
181
211
|
exports.default = TurboAdapter;
|
|
@@ -9,13 +9,12 @@ declare type ControlItem = {
|
|
|
9
9
|
};
|
|
10
10
|
declare class Control {
|
|
11
11
|
private lf;
|
|
12
|
+
private LogicFlow;
|
|
12
13
|
static pluginName: string;
|
|
13
14
|
private controlItems;
|
|
14
15
|
private domContainer;
|
|
15
16
|
private toolEl;
|
|
16
|
-
constructor(
|
|
17
|
-
lf: any;
|
|
18
|
-
});
|
|
17
|
+
constructor(args: any);
|
|
19
18
|
render(lf: any, domContainer: any): void;
|
|
20
19
|
destroy(): void;
|
|
21
20
|
addItem(item: any): void;
|