@logicflow/extension 1.2.0-alpha.0 → 1.2.0-alpha.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.
Files changed (89) hide show
  1. package/cjs/NodeResize/Control/Control.js +13 -9
  2. package/cjs/NodeResize/Node/DiamondResize.js +10 -8
  3. package/cjs/NodeResize/Node/EllipseResize.js +10 -8
  4. package/cjs/NodeResize/Node/HtmlResize.js +10 -8
  5. package/cjs/NodeResize/Node/RectResize.js +10 -8
  6. package/cjs/bpmn-adapter/index.js +1 -1
  7. package/cjs/components/control/index.js +16 -16
  8. package/cjs/components/highlight/index.js +187 -0
  9. package/cjs/components/menu/index.js +9 -9
  10. package/cjs/components/mini-map/index.js +5 -0
  11. package/cjs/components/selection-select/index.js +22 -2
  12. package/cjs/index.js +2 -0
  13. package/cjs/locale/en-locale/en.js +22 -0
  14. package/cjs/locale/en-locale/index.js +29 -0
  15. package/cjs/locale/locale.js +19 -0
  16. package/cjs/materials/group/GroupNode.js +22 -12
  17. package/cjs/tools/snapshot/index.js +47 -46
  18. package/cjs/turbo-adapter/index.js +71 -41
  19. package/es/NodeResize/Control/Control.js +13 -9
  20. package/es/NodeResize/Node/DiamondResize.d.ts +1 -1
  21. package/es/NodeResize/Node/DiamondResize.js +10 -8
  22. package/es/NodeResize/Node/EllipseResize.d.ts +1 -1
  23. package/es/NodeResize/Node/EllipseResize.js +10 -8
  24. package/es/NodeResize/Node/HtmlResize.d.ts +1 -1
  25. package/es/NodeResize/Node/HtmlResize.js +10 -8
  26. package/es/NodeResize/Node/RectResize.d.ts +1 -1
  27. package/es/NodeResize/Node/RectResize.js +10 -8
  28. package/es/bpmn-adapter/index.js +1 -1
  29. package/es/components/control/index.d.ts +2 -3
  30. package/es/components/control/index.js +16 -16
  31. package/es/components/highlight/index.d.ts +21 -0
  32. package/es/components/highlight/index.js +184 -0
  33. package/es/components/menu/index.d.ts +2 -3
  34. package/es/components/menu/index.js +9 -9
  35. package/es/components/mini-map/index.js +5 -0
  36. package/es/components/selection-select/index.d.ts +1 -0
  37. package/es/components/selection-select/index.js +22 -2
  38. package/es/index.d.ts +2 -0
  39. package/es/index.js +2 -0
  40. package/es/locale/en-locale/en.d.ts +19 -0
  41. package/es/locale/en-locale/en.js +19 -0
  42. package/es/locale/en-locale/index.d.ts +9 -0
  43. package/es/locale/en-locale/index.js +26 -0
  44. package/es/locale/locale.d.ts +6 -0
  45. package/es/locale/locale.js +16 -0
  46. package/es/materials/group/GroupNode.js +22 -12
  47. package/es/tools/snapshot/index.d.ts +15 -7
  48. package/es/tools/snapshot/index.js +47 -46
  49. package/es/turbo-adapter/index.d.ts +6 -7
  50. package/es/turbo-adapter/index.js +70 -40
  51. package/lib/AutoLayout.js +1 -1
  52. package/lib/BpmnAdapter.js +1 -1
  53. package/lib/BpmnElement.js +1 -1
  54. package/lib/ContextMenu.js +1 -1
  55. package/lib/Control.js +1 -1
  56. package/lib/CurvedEdge.js +1 -1
  57. package/lib/DndPanel.js +1 -1
  58. package/lib/EnLocale.js +1 -0
  59. package/lib/FlowPath.js +1 -1
  60. package/lib/Group.js +1 -1
  61. package/lib/Highlight.js +1 -0
  62. package/lib/InsertNodeInPolyline.js +1 -1
  63. package/lib/Menu.js +1 -1
  64. package/lib/MiniMap.js +1 -1
  65. package/lib/NodeResize.js +1 -1
  66. package/lib/RectLabelNode.js +1 -1
  67. package/lib/SelectionSelect.js +1 -1
  68. package/lib/Snapshot.js +1 -1
  69. package/lib/TurboAdapter.js +1 -1
  70. package/lib/lfJson2Xml.js +1 -1
  71. package/lib/lfXml2Json.js +1 -1
  72. package/package.json +2 -2
  73. package/types/NodeResize/Node/DiamondResize.d.ts +1 -1
  74. package/types/NodeResize/Node/EllipseResize.d.ts +1 -1
  75. package/types/NodeResize/Node/HtmlResize.d.ts +1 -1
  76. package/types/NodeResize/Node/RectResize.d.ts +1 -1
  77. package/types/components/control/index.d.ts +2 -3
  78. package/types/components/highlight/index.d.ts +21 -0
  79. package/types/components/menu/index.d.ts +2 -3
  80. package/types/components/selection-select/index.d.ts +1 -0
  81. package/types/index.d.ts +2 -0
  82. package/types/locale/en-locale/en.d.ts +19 -0
  83. package/types/locale/en-locale/index.d.ts +9 -0
  84. package/types/locale/locale.d.ts +6 -0
  85. package/types/tools/snapshot/index.d.ts +15 -7
  86. package/types/turbo-adapter/index.d.ts +6 -7
  87. package/types/NodeResize/BasicShape/Ellipse.d.ts +0 -2
  88. package/types/curved.d.ts +0 -0
  89. package/types/group-shrink/index.d.ts +0 -28
@@ -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({ lf }: {
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;
@@ -19,15 +19,16 @@ var __spread = (this && this.__spread) || function () {
19
19
  return ar;
20
20
  };
21
21
  var Control = /** @class */ (function () {
22
- function Control(_a) {
22
+ function Control(args) {
23
23
  var _this = this;
24
- var lf = _a.lf;
24
+ this.lf = args.lf;
25
+ this.LogicFlow = args.LogicFlow;
25
26
  this.controlItems = [
26
27
  {
27
28
  key: 'zoom-out',
28
29
  iconClass: 'lf-control-zoomOut',
29
- title: '缩小流程图',
30
- text: '缩小',
30
+ title: this.LogicFlow.t('缩小流程图'),
31
+ text: this.LogicFlow.t('缩小'),
31
32
  onClick: function () {
32
33
  _this.lf.zoom(false);
33
34
  },
@@ -35,8 +36,8 @@ var Control = /** @class */ (function () {
35
36
  {
36
37
  key: 'zoom-in',
37
38
  iconClass: 'lf-control-zoomIn',
38
- title: '放大流程图',
39
- text: '放大',
39
+ title: this.LogicFlow.t('放大流程图'),
40
+ text: this.LogicFlow.t('放大'),
40
41
  onClick: function () {
41
42
  _this.lf.zoom(true);
42
43
  },
@@ -44,8 +45,8 @@ var Control = /** @class */ (function () {
44
45
  {
45
46
  key: 'reset',
46
47
  iconClass: 'lf-control-fit',
47
- title: '恢复流程原有尺寸',
48
- text: '适应',
48
+ title: this.LogicFlow.t('恢复流程原有尺寸'),
49
+ text: this.LogicFlow.t('适应'),
49
50
  onClick: function () {
50
51
  _this.lf.resetZoom();
51
52
  },
@@ -53,8 +54,8 @@ var Control = /** @class */ (function () {
53
54
  {
54
55
  key: 'undo',
55
56
  iconClass: 'lf-control-undo',
56
- title: '回到上一步',
57
- text: '上一步',
57
+ title: this.LogicFlow.t('回到上一步'),
58
+ text: this.LogicFlow.t('上一步'),
58
59
  onClick: function () {
59
60
  _this.lf.undo();
60
61
  },
@@ -62,14 +63,13 @@ var Control = /** @class */ (function () {
62
63
  {
63
64
  key: 'redo',
64
65
  iconClass: 'lf-control-redo',
65
- title: '移到下一步',
66
- text: '下一步',
66
+ title: this.LogicFlow.t('移到下一步'),
67
+ text: this.LogicFlow.t('下一步'),
67
68
  onClick: function () {
68
69
  _this.lf.redo();
69
70
  },
70
71
  },
71
72
  ];
72
- this.lf = lf;
73
73
  }
74
74
  Control.prototype.render = function (lf, domContainer) {
75
75
  this.destroy();
@@ -110,14 +110,14 @@ var Control = /** @class */ (function () {
110
110
  text.title = item.title;
111
111
  text.innerText = item.text;
112
112
  itemContainer.append(icon, text);
113
- switch (item.text) {
114
- case '上一步':
113
+ switch (item.key) {
114
+ case 'undo':
115
115
  _this.lf.on('history:change', function (_a) {
116
116
  var undoAble = _a.data.undoAble;
117
117
  itemContainer.className = undoAble ? NORMAL : DISABLED;
118
118
  });
119
119
  break;
120
- case '下一步':
120
+ case 'redo':
121
121
  _this.lf.on('history:change', function (_a) {
122
122
  var redoAble = _a.data.redoAble;
123
123
  itemContainer.className = redoAble ? NORMAL : DISABLED;
@@ -0,0 +1,21 @@
1
+ import LogicFlow from '@logicflow/core';
2
+ declare type IMode = 'single' | 'path';
3
+ declare class Highlight {
4
+ lf: LogicFlow;
5
+ static pluginName: string;
6
+ mode: IMode;
7
+ manual: boolean;
8
+ tempStyles: {};
9
+ constructor({ lf }: {
10
+ lf: any;
11
+ });
12
+ setMode(mode: IMode): void;
13
+ setManual(manual: boolean): void;
14
+ private highlightSingle;
15
+ private highlightPath;
16
+ highlight(id: string, mode?: IMode): void;
17
+ restoreHighlight(): void;
18
+ render(lf: any, domContainer: any): void;
19
+ destroy(): void;
20
+ }
21
+ export { Highlight };
@@ -0,0 +1,184 @@
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
+ };
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
+ };
28
+ var __spread = (this && this.__spread) || function () {
29
+ for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
30
+ return ar;
31
+ };
32
+ // 后续并入FlowPath
33
+ var getPath = function (id, lf) {
34
+ var el = lf.getModelById(id);
35
+ return getNodePath(el.BaseType === 'node' ? el : el.targetNode, lf);
36
+ };
37
+ // dfs + 动态规划
38
+ // todo 算法优化
39
+ var getNodePath = function (node, lf) {
40
+ var incomingPaths = [];
41
+ var outgoingPaths = [];
42
+ var getIncomingPaths = function (curNode, path, prevNode) {
43
+ if (prevNode === void 0) { prevNode = null; }
44
+ if (prevNode) {
45
+ // * 上个节点和当前节点中间边
46
+ path.unshift.apply(path, __spread(lf
47
+ .getEdgeModels({
48
+ sourceNodeId: curNode.id,
49
+ targetNodeId: prevNode.id,
50
+ })
51
+ .map(function (item) { return item.id; })));
52
+ }
53
+ // * 路径中存在节点,则不再继续查找,说明出现环情况
54
+ if (path.includes(curNode.id)) {
55
+ incomingPaths.push(path);
56
+ return;
57
+ }
58
+ // * 路径中当前加入节点
59
+ path.unshift(curNode.id);
60
+ if (!curNode.incoming.nodes.length) {
61
+ incomingPaths.push(path);
62
+ return;
63
+ }
64
+ // * 往下找
65
+ curNode.incoming.nodes.forEach(function (nextNode) {
66
+ getIncomingPaths(nextNode, path.slice(), curNode);
67
+ });
68
+ };
69
+ // * 同上逻辑
70
+ var getOutgoingPaths = function (curNode, path, prevNode) {
71
+ if (prevNode === void 0) { prevNode = null; }
72
+ if (prevNode) {
73
+ path.push.apply(path, __spread(lf
74
+ .getEdgeModels({
75
+ sourceNodeId: prevNode.id,
76
+ targetNodeId: curNode.id,
77
+ })
78
+ .map(function (item) { return item.id; })));
79
+ }
80
+ if (path.includes(curNode.id)) {
81
+ outgoingPaths.push(path);
82
+ return;
83
+ }
84
+ path.push(curNode.id);
85
+ if (!curNode.outgoing.nodes.length) {
86
+ outgoingPaths.push(path);
87
+ return;
88
+ }
89
+ curNode.outgoing.nodes.forEach(function (nextNode) {
90
+ getOutgoingPaths(nextNode, path.slice(), curNode);
91
+ });
92
+ };
93
+ getIncomingPaths(node, []);
94
+ getOutgoingPaths(node, []);
95
+ return __spread(new Set(__spread(incomingPaths.flat(), outgoingPaths.flat())));
96
+ };
97
+ var Highlight = /** @class */ (function () {
98
+ function Highlight(_a) {
99
+ var lf = _a.lf;
100
+ this.mode = 'path';
101
+ this.manual = false;
102
+ this.tempStyles = {};
103
+ this.lf = lf;
104
+ }
105
+ Highlight.prototype.setMode = function (mode) {
106
+ this.mode = mode;
107
+ };
108
+ Highlight.prototype.setManual = function (manual) {
109
+ this.manual = manual;
110
+ };
111
+ Highlight.prototype.highlightSingle = function (id) {
112
+ var model = this.lf.getModelById(id);
113
+ if (model.BaseType === 'node') {
114
+ // 高亮节点
115
+ model.updateStyles(this.tempStyles[id]);
116
+ }
117
+ else if (model.BaseType === 'edge') {
118
+ // 高亮边及对应的节点
119
+ model.updateStyles(this.tempStyles[id]);
120
+ model.sourceNode.updateStyles(this.tempStyles[model.sourceNode.id]);
121
+ model.targetNode.updateStyles(this.tempStyles[model.targetNode.id]);
122
+ }
123
+ };
124
+ Highlight.prototype.highlightPath = function (id) {
125
+ var _this = this;
126
+ var path = getPath(id, this.lf);
127
+ path.forEach(function (_id) {
128
+ // 高亮路径上所有的边和节点
129
+ _this.lf.getModelById(_id).updateStyles(_this.tempStyles[_id]);
130
+ });
131
+ };
132
+ Highlight.prototype.highlight = function (id, mode) {
133
+ var _this = this;
134
+ if (mode === void 0) { mode = this.mode; }
135
+ if (this.manual)
136
+ return;
137
+ if (Object.keys(this.tempStyles).length) {
138
+ this.restoreHighlight();
139
+ }
140
+ Object.values(this.lf.graphModel.modelsMap).forEach(function (item) {
141
+ // 所有节点样式都进行备份
142
+ // eslint-disable-next-line operator-linebreak
143
+ var oStyle = item.BaseType === 'node' ? item.getNodeStyle() : item.getEdgeStyle();
144
+ _this.tempStyles[item.id] = __assign({}, oStyle);
145
+ // 所有节点都设置透明度为0.1
146
+ item.setStyles({ opacity: 0.1 });
147
+ });
148
+ var modeTrigger = {
149
+ single: this.highlightSingle.bind(this),
150
+ path: this.highlightPath.bind(this),
151
+ };
152
+ modeTrigger[mode](id);
153
+ };
154
+ Highlight.prototype.restoreHighlight = function () {
155
+ var _this = this;
156
+ // 恢复所有节点的样式
157
+ if (!Object.keys(this.tempStyles).length)
158
+ return;
159
+ Object.values(this.lf.graphModel.modelsMap).forEach(function (item) {
160
+ var _a;
161
+ var oStyle = (_a = _this.tempStyles[item.id]) !== null && _a !== void 0 ? _a : {};
162
+ item.updateStyles(__assign({}, oStyle));
163
+ });
164
+ this.tempStyles = {};
165
+ };
166
+ Highlight.prototype.render = function (lf, domContainer) {
167
+ var _this = this;
168
+ this.lf.on('node:mouseenter', function (_a) {
169
+ var data = _a.data;
170
+ return _this.highlight(data.id);
171
+ });
172
+ this.lf.on('edge:mouseenter', function (_a) {
173
+ var data = _a.data;
174
+ return _this.highlight(data.id);
175
+ });
176
+ this.lf.on('node:mouseleave', this.restoreHighlight.bind(this));
177
+ this.lf.on('edge:mouseleave', this.restoreHighlight.bind(this));
178
+ this.lf.on('history:change', this.restoreHighlight.bind(this));
179
+ };
180
+ Highlight.prototype.destroy = function () { };
181
+ Highlight.pluginName = 'highlight';
182
+ return Highlight;
183
+ }());
184
+ export { Highlight };
@@ -13,14 +13,13 @@ export declare type MenuConfig = {
13
13
  };
14
14
  declare class Menu {
15
15
  lf: LogicFlow;
16
+ LogicFlow: any;
16
17
  private __container;
17
18
  private __menuDOM;
18
19
  private menuTypeMap;
19
20
  private __currentData;
20
21
  static pluginName: string;
21
- constructor({ lf }: {
22
- lf: any;
23
- });
22
+ constructor(args: any);
24
23
  /**
25
24
  * 初始化设置默认内置菜单栏
26
25
  */
@@ -23,11 +23,11 @@ var DefaultEdgeMenuKey = 'lf:defaultEdgeMenu';
23
23
  var DefaultGraphMenuKey = 'lf:defaultGraphMenu';
24
24
  var DefaultSelectionMenuKey = 'lf:defaultSelectionMenu';
25
25
  var Menu = /** @class */ (function () {
26
- function Menu(_a) {
26
+ function Menu(args) {
27
27
  var _this = this;
28
- var lf = _a.lf;
29
28
  this.__menuDOM = document.createElement('ul');
30
- this.lf = lf;
29
+ this.lf = args.lf;
30
+ this.LogicFlow = args.LogicFlow;
31
31
  this.menuTypeMap = new Map();
32
32
  this.init();
33
33
  this.lf.setMenuConfig = function (config) {
@@ -47,19 +47,19 @@ var Menu = /** @class */ (function () {
47
47
  var _this = this;
48
48
  var defaultNodeMenu = [
49
49
  {
50
- text: '删除',
50
+ text: this.LogicFlow.t('删除'),
51
51
  callback: function (node) {
52
52
  _this.lf.deleteNode(node.id);
53
53
  },
54
54
  },
55
55
  {
56
- text: '编辑文本',
56
+ text: this.LogicFlow.t('编辑文本'),
57
57
  callback: function (node) {
58
58
  _this.lf.graphModel.editText(node.id);
59
59
  },
60
60
  },
61
61
  {
62
- text: '复制',
62
+ text: this.LogicFlow.t('复制'),
63
63
  callback: function (node) {
64
64
  _this.lf.cloneNode(node.id);
65
65
  },
@@ -68,13 +68,13 @@ var Menu = /** @class */ (function () {
68
68
  this.menuTypeMap.set(DefaultNodeMenuKey, defaultNodeMenu);
69
69
  var defaultEdgeMenu = [
70
70
  {
71
- text: '删除',
71
+ text: this.LogicFlow.t('删除'),
72
72
  callback: function (edge) {
73
73
  _this.lf.deleteEdge(edge.id);
74
74
  },
75
75
  },
76
76
  {
77
- text: '编辑文本',
77
+ text: this.LogicFlow.t('编辑文本'),
78
78
  callback: function (edge) {
79
79
  _this.lf.graphModel.editText(edge.id);
80
80
  },
@@ -84,7 +84,7 @@ var Menu = /** @class */ (function () {
84
84
  this.menuTypeMap.set(DefaultGraphMenuKey, []);
85
85
  var DefaultSelectionMenu = [
86
86
  {
87
- text: '删除',
87
+ text: this.LogicFlow.t('删除'),
88
88
  callback: function (elements) {
89
89
  _this.lf.clearSelectElements();
90
90
  elements.edges.forEach(function (edge) { return _this.lf.deleteEdge(edge.id); });
@@ -100,6 +100,11 @@ var MiniMap = /** @class */ (function () {
100
100
  _this.__setView();
101
101
  }
102
102
  });
103
+ this.__lf.on('blank:drop', function () {
104
+ if (_this.__isShow) {
105
+ _this.__setView();
106
+ }
107
+ });
103
108
  };
104
109
  MiniMap.prototype.init = function (option) {
105
110
  this.__disabledPlugins = this.__disabledPlugins.concat(option.disabledPlugins || []);
@@ -36,6 +36,7 @@ declare class SelectionSelect {
36
36
  closeSelectionSelect(): void;
37
37
  __draw: (ev: any) => void;
38
38
  __drawOff: () => void;
39
+ isSelectElement(elementModel: any): boolean;
39
40
  open(): void;
40
41
  close(): void;
41
42
  }
@@ -40,9 +40,11 @@ var SelectionSelect = /** @class */ (function () {
40
40
  }
41
41
  var lt = [Math.min(x, x1), Math.min(y, y1)];
42
42
  var rt = [Math.max(x, x1), Math.max(y, y1)];
43
- var elements = _this.lf.getAreaElement(lt, rt, _this.isWholeEdge, _this.isWholeNode);
43
+ var elements = _this.lf.graphModel.getAreaElement(lt, rt, _this.isWholeEdge, _this.isWholeNode);
44
44
  elements.forEach(function (element) {
45
- _this.lf.selectElementById(element.id, true);
45
+ if (_this.isSelectElement(element)) {
46
+ _this.lf.selectElementById(element.id, true);
47
+ }
46
48
  });
47
49
  _this.lf.emit('selection:selected', elements);
48
50
  };
@@ -115,6 +117,24 @@ var SelectionSelect = /** @class */ (function () {
115
117
  }
116
118
  this.close();
117
119
  };
120
+ SelectionSelect.prototype.isSelectElement = function (elementModel) {
121
+ // 如果不可见,则不被选中
122
+ if (!elementModel.visible)
123
+ return false;
124
+ var group = this.lf.extension.group;
125
+ // 节点在group中,则不被选中
126
+ if (group) {
127
+ if (elementModel.BaseType === 'node' && group.getNodeGroup(elementModel.id))
128
+ return false;
129
+ if (elementModel.BaseType === 'edge') {
130
+ if (group.getNodeGroup(elementModel.sourceNodeId)
131
+ || group.getNodeGroup(elementModel.targetNodeId)) {
132
+ return false;
133
+ }
134
+ }
135
+ }
136
+ return true;
137
+ };
118
138
  SelectionSelect.prototype.open = function () {
119
139
  this.__disabled = false;
120
140
  };
package/es/index.d.ts CHANGED
@@ -16,3 +16,5 @@ export * from './tools/flow-path';
16
16
  export * from './tools/auto-layout';
17
17
  export * from './bpmn-adapter/xml2json';
18
18
  export * from './bpmn-adapter/json2xml';
19
+ export * from './locale/en-locale';
20
+ export * from './components/highlight';
package/es/index.js CHANGED
@@ -17,3 +17,5 @@ export * from './tools/flow-path';
17
17
  export * from './tools/auto-layout';
18
18
  export * from './bpmn-adapter/xml2json';
19
19
  export * from './bpmn-adapter/json2xml';
20
+ export * from './locale/en-locale';
21
+ export * from './components/highlight';
@@ -0,0 +1,19 @@
1
+ declare const en: {
2
+ 文本: string;
3
+ 开始: string;
4
+ 缩小流程图: string;
5
+ 缩小: string;
6
+ 放大流程图: string;
7
+ 放大: string;
8
+ 恢复流程原有尺寸: string;
9
+ 适应: string;
10
+ 回到上一步: string;
11
+ 上一步: string;
12
+ 移到下一步: string;
13
+ 下一步: string;
14
+ 删除: string;
15
+ 编辑文本: string;
16
+ 复制: string;
17
+ };
18
+ export default en;
19
+ export { en };
@@ -0,0 +1,19 @@
1
+ var en = {
2
+ 文本: 'text',
3
+ 开始: 'start',
4
+ 缩小流程图: 'zoom in',
5
+ 缩小: 'zoom in',
6
+ 放大流程图: 'zoom out',
7
+ 放大: 'zoom out',
8
+ 恢复流程原有尺寸: 'adapt to original size',
9
+ 适应: 'adapt',
10
+ 回到上一步: 'undo',
11
+ 上一步: 'undo',
12
+ 移到下一步: 'redo',
13
+ 下一步: 'redo',
14
+ 删除: 'delete',
15
+ 编辑文本: 'edit text',
16
+ 复制: 'copy',
17
+ };
18
+ export default en;
19
+ export { en };
@@ -0,0 +1,9 @@
1
+ import { Locale } from '../locale';
2
+ declare class EnLocale extends Locale {
3
+ static pluginName: string;
4
+ constructor({ LogicFlow }: {
5
+ LogicFlow: any;
6
+ });
7
+ }
8
+ export default EnLocale;
9
+ export { EnLocale };
@@ -0,0 +1,26 @@
1
+ var __extends = (this && this.__extends) || (function () {
2
+ var extendStatics = function (d, b) {
3
+ extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
9
+ extendStatics(d, b);
10
+ function __() { this.constructor = d; }
11
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12
+ };
13
+ })();
14
+ import { Locale } from '../locale';
15
+ import en from './en';
16
+ var EnLocale = /** @class */ (function (_super) {
17
+ __extends(EnLocale, _super);
18
+ function EnLocale(_a) {
19
+ var LogicFlow = _a.LogicFlow;
20
+ return _super.call(this, LogicFlow, en) || this;
21
+ }
22
+ EnLocale.pluginName = 'enLocale';
23
+ return EnLocale;
24
+ }(Locale));
25
+ export default EnLocale;
26
+ export { EnLocale };
@@ -0,0 +1,6 @@
1
+ export declare class Locale {
2
+ constructor(LogicFlow?: any, map?: Object);
3
+ replaceTranslator(LogicFlow: any, map: Object): void;
4
+ setDefault(LogicFlow: any): void;
5
+ static defaultTranslator: (text: string) => string;
6
+ }
@@ -0,0 +1,16 @@
1
+ var Locale = /** @class */ (function () {
2
+ function Locale(LogicFlow, map) {
3
+ if (LogicFlow && map) {
4
+ this.replaceTranslator(LogicFlow, map);
5
+ }
6
+ }
7
+ Locale.prototype.replaceTranslator = function (LogicFlow, map) {
8
+ LogicFlow.t = function (text) { return (map[text] ? map[text] : text); };
9
+ };
10
+ Locale.prototype.setDefault = function (LogicFlow) {
11
+ LogicFlow.t = Locale.defaultTranslator;
12
+ };
13
+ Locale.defaultTranslator = function (text) { return text; };
14
+ return Locale;
15
+ }());
16
+ export { Locale };
@@ -105,24 +105,30 @@ var GroupNodeModel = /** @class */ (function (_super) {
105
105
  this.isFolded = isFolded;
106
106
  // step 1
107
107
  if (isFolded) {
108
- this.x = this.x - this.width / 2 + this.foldedWidth / 2;
109
- this.y = this.y - this.height / 2 + this.foldedHeight / 2;
110
108
  this.unfoldedWidth = this.width;
111
109
  this.unfoldedHight = this.height;
112
- this.width = this.foldedWidth;
113
- this.height = this.foldedHeight;
110
+ this.updateAttributes({
111
+ x: this.x - this.width / 2 + this.foldedWidth / 2,
112
+ y: this.y - this.height / 2 + this.foldedHeight / 2,
113
+ width: this.foldedWidth,
114
+ height: this.foldedHeight,
115
+ });
114
116
  }
115
117
  else {
116
- this.width = this.unfoldedWidth;
117
- this.height = this.unfoldedHight;
118
- this.x = this.x + this.width / 2 - this.foldedWidth / 2;
119
- this.y = this.y + this.height / 2 - this.foldedHeight / 2;
118
+ this.updateAttributes({
119
+ width: this.unfoldedWidth,
120
+ height: this.unfoldedHight,
121
+ x: this.x + this.unfoldedWidth / 2 - this.foldedWidth / 2,
122
+ y: this.y + this.unfoldedHight / 2 - this.foldedHeight / 2,
123
+ });
120
124
  }
121
125
  // step 2
122
126
  var allEdges = this.incoming.edges.concat(this.outgoing.edges);
123
127
  this.children.forEach(function (elementId) {
124
128
  var nodeModel = _this.graphModel.getElement(elementId);
125
- nodeModel.visible = !isFolded;
129
+ nodeModel.updateAttributes({
130
+ visible: !isFolded,
131
+ });
126
132
  allEdges = allEdges.concat(nodeModel.incoming.edges.concat(nodeModel.outgoing.edges));
127
133
  });
128
134
  // step 3
@@ -194,7 +200,9 @@ var GroupNodeModel = /** @class */ (function (_super) {
194
200
  if (targetNodeIdGroup.id !== _this.id || sourceNodeIdGroup.id !== _this.id) {
195
201
  _this.createVirtualEdge(data);
196
202
  }
197
- edgeModel.visible = false;
203
+ edgeModel.updateAttributes({
204
+ visible: false,
205
+ });
198
206
  }
199
207
  // 展开时,处理被隐藏的边的逻辑
200
208
  if (!isFolded && edgeModel.visible === false) {
@@ -210,7 +218,9 @@ var GroupNodeModel = /** @class */ (function (_super) {
210
218
  _this.createVirtualEdge(data);
211
219
  }
212
220
  else {
213
- edgeModel.visible = true;
221
+ edgeModel.updateAttributes({
222
+ visible: true,
223
+ });
214
224
  }
215
225
  }
216
226
  });
@@ -220,7 +230,7 @@ var GroupNodeModel = /** @class */ (function (_super) {
220
230
  var model = this.graphModel.addEdge(edgeData);
221
231
  model.virtual = true;
222
232
  // 强制不保存group连线数据
223
- model.getData = function () { return null; };
233
+ // model.getData = () => null;
224
234
  model.text.editable = false;
225
235
  model.isFoldedEdge = true;
226
236
  };
@@ -1,17 +1,25 @@
1
1
  /**
2
2
  * 快照插件,生成视图
3
3
  */
4
- declare const Snapshot: {
5
- pluginName: string;
6
- install(lf: any): void;
4
+ declare class Snapshot {
5
+ static pluginName: string;
6
+ lf: any;
7
+ offsetX: number;
8
+ offsetY: number;
9
+ fileName: string;
10
+ customCssRules: string;
11
+ useGlobalRules: boolean;
12
+ constructor({ lf }: {
13
+ lf: any;
14
+ });
7
15
  getSvgRootElement(lf: any): any;
8
16
  triggerDownload(imgURI: string): void;
9
17
  removeAnchor(element: any): void;
10
- downloadSvg(svg: SVGGraphicsElement, fileName: string, backgroundColor: string): void;
11
- getBase64(svg: SVGGraphicsElement, backgroundColor: string): Promise<unknown>;
12
- getBlob(svg: SVGGraphicsElement, backgroundColor: string): Promise<unknown>;
18
+ getSnapshot(fileName: string, backgroundColor: string): void;
19
+ getSnapshotBase64(backgroundColor: string): Promise<unknown>;
20
+ getSnapshotBlob(backgroundColor: string): Promise<unknown>;
13
21
  getClassRules(): string;
14
22
  getCanvasData(svg: SVGGraphicsElement, backgroundColor: string): Promise<unknown>;
15
- };
23
+ }
16
24
  export default Snapshot;
17
25
  export { Snapshot, };