@logicflow/extension 1.1.20 → 1.2.0-alpha.10

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 (101) hide show
  1. package/cjs/NodeResize/Control/Control.js +21 -17
  2. package/cjs/NodeResize/Control/Util.js +11 -11
  3. package/cjs/NodeResize/Node/DiamondResize.js +10 -8
  4. package/cjs/NodeResize/Node/EllipseResize.js +10 -8
  5. package/cjs/NodeResize/Node/HtmlResize.js +10 -8
  6. package/cjs/NodeResize/Node/RectResize.js +10 -8
  7. package/cjs/bpmn-adapter/index.js +124 -76
  8. package/cjs/bpmn-adapter/json2xml.js +5 -2
  9. package/cjs/bpmn-adapter/xml2json.js +38 -284
  10. package/cjs/components/context-menu/index.js +2 -2
  11. package/cjs/components/control/index.js +16 -16
  12. package/cjs/components/menu/index.js +32 -32
  13. package/cjs/components/mini-map/index.js +2 -2
  14. package/cjs/components/selection-select/index.js +27 -7
  15. package/cjs/index.js +1 -0
  16. package/cjs/insert-node-in-polyline/edge.js +4 -4
  17. package/cjs/insert-node-in-polyline/index.js +1 -1
  18. package/cjs/locale/en-locale/en.js +22 -0
  19. package/cjs/locale/en-locale/index.js +29 -0
  20. package/cjs/locale/locale.js +19 -0
  21. package/cjs/materials/group/GroupNode.js +24 -14
  22. package/cjs/materials/group/index.js +3 -3
  23. package/cjs/tools/auto-layout/index.js +9 -9
  24. package/es/NodeResize/Control/Control.d.ts +1 -1
  25. package/es/NodeResize/Control/Control.js +22 -18
  26. package/es/NodeResize/Control/Util.d.ts +3 -3
  27. package/es/NodeResize/Control/Util.js +7 -7
  28. package/es/NodeResize/Node/DiamondResize.d.ts +1 -1
  29. package/es/NodeResize/Node/DiamondResize.js +10 -8
  30. package/es/NodeResize/Node/EllipseResize.d.ts +1 -1
  31. package/es/NodeResize/Node/EllipseResize.js +10 -8
  32. package/es/NodeResize/Node/HtmlResize.d.ts +1 -1
  33. package/es/NodeResize/Node/HtmlResize.js +10 -8
  34. package/es/NodeResize/Node/RectResize.d.ts +1 -1
  35. package/es/NodeResize/Node/RectResize.js +10 -8
  36. package/es/bpmn-adapter/index.d.ts +41 -33
  37. package/es/bpmn-adapter/index.js +124 -76
  38. package/es/bpmn-adapter/json2xml.js +5 -2
  39. package/es/bpmn-adapter/xml2json.js +38 -284
  40. package/es/components/context-menu/index.js +2 -2
  41. package/es/components/control/index.d.ts +2 -3
  42. package/es/components/control/index.js +16 -16
  43. package/es/components/menu/index.d.ts +2 -3
  44. package/es/components/menu/index.js +32 -32
  45. package/es/components/mini-map/index.js +2 -2
  46. package/es/components/selection-select/index.d.ts +2 -1
  47. package/es/components/selection-select/index.js +27 -7
  48. package/es/index.d.ts +1 -0
  49. package/es/index.js +1 -0
  50. package/es/insert-node-in-polyline/edge.d.ts +3 -3
  51. package/es/insert-node-in-polyline/edge.js +3 -3
  52. package/es/insert-node-in-polyline/index.js +2 -2
  53. package/es/locale/en-locale/en.d.ts +19 -0
  54. package/es/locale/en-locale/en.js +19 -0
  55. package/es/locale/en-locale/index.d.ts +9 -0
  56. package/es/locale/en-locale/index.js +26 -0
  57. package/es/locale/locale.d.ts +6 -0
  58. package/es/locale/locale.js +16 -0
  59. package/es/materials/group/GroupNode.d.ts +1 -1
  60. package/es/materials/group/GroupNode.js +24 -14
  61. package/es/materials/group/index.d.ts +1 -1
  62. package/es/materials/group/index.js +3 -3
  63. package/es/tools/auto-layout/index.d.ts +2 -2
  64. package/es/tools/auto-layout/index.js +9 -9
  65. package/lib/AutoLayout.js +1 -1
  66. package/lib/BpmnAdapter.js +1 -1
  67. package/lib/BpmnElement.js +1 -1
  68. package/lib/ContextMenu.js +1 -1
  69. package/lib/Control.js +1 -1
  70. package/lib/CurvedEdge.js +1 -1
  71. package/lib/DndPanel.js +1 -1
  72. package/lib/EnLocale.js +1 -0
  73. package/lib/FlowPath.js +1 -1
  74. package/lib/Group.js +1 -1
  75. package/lib/Highlight.js +1 -1
  76. package/lib/InsertNodeInPolyline.js +1 -1
  77. package/lib/Menu.js +1 -1
  78. package/lib/MiniMap.js +1 -1
  79. package/lib/NodeResize.js +1 -1
  80. package/lib/RectLabelNode.js +1 -1
  81. package/lib/SelectionSelect.js +1 -1
  82. package/lib/Snapshot.js +1 -1
  83. package/lib/TurboAdapter.js +1 -1
  84. package/lib/lfJson2Xml.js +1 -1
  85. package/lib/lfXml2Json.js +1 -1
  86. package/package.json +2 -2
  87. package/types/NodeResize/Control/Control.d.ts +1 -1
  88. package/types/NodeResize/Control/Util.d.ts +3 -3
  89. package/types/NodeResize/Node/DiamondResize.d.ts +1 -1
  90. package/types/NodeResize/Node/EllipseResize.d.ts +1 -1
  91. package/types/NodeResize/Node/HtmlResize.d.ts +1 -1
  92. package/types/NodeResize/Node/RectResize.d.ts +1 -1
  93. package/types/bpmn-adapter/index.d.ts +41 -33
  94. package/types/components/control/index.d.ts +2 -3
  95. package/types/components/menu/index.d.ts +2 -3
  96. package/types/components/selection-select/index.d.ts +2 -1
  97. package/types/index.d.ts +1 -0
  98. package/types/insert-node-in-polyline/edge.d.ts +3 -3
  99. package/types/materials/group/GroupNode.d.ts +1 -1
  100. package/types/materials/group/index.d.ts +1 -1
  101. package/types/tools/auto-layout/index.d.ts +2 -2
@@ -18,16 +18,16 @@ var __spread = (this && this.__spread) || function () {
18
18
  for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
19
19
  return ar;
20
20
  };
21
- var DefalutNodeMenuKey = 'lf:defaultNodeMenu';
22
- var DefalutEdgeMenuKey = 'lf:defaultEdgeMenu';
23
- var DefalutGraphMenuKey = 'lf:defaultGraphMenu';
24
- var DefalutSelectionMenuKey = 'lf:defaultSelectionMenu';
21
+ var DefaultNodeMenuKey = 'lf:defaultNodeMenu';
22
+ var DefaultEdgeMenuKey = 'lf:defaultEdgeMenu';
23
+ var DefaultGraphMenuKey = 'lf:defaultGraphMenu';
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) {
@@ -45,46 +45,46 @@ var Menu = /** @class */ (function () {
45
45
  */
46
46
  Menu.prototype.init = function () {
47
47
  var _this = this;
48
- var defalutNodeMenu = [
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
  },
66
66
  },
67
67
  ];
68
- this.menuTypeMap.set(DefalutNodeMenuKey, defalutNodeMenu);
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
  },
81
81
  },
82
82
  ];
83
- this.menuTypeMap.set(DefalutEdgeMenuKey, defaultEdgeMenu);
84
- this.menuTypeMap.set(DefalutGraphMenuKey, []);
85
- var DefalutSelectionMenu = [
83
+ this.menuTypeMap.set(DefaultEdgeMenuKey, defaultEdgeMenu);
84
+ this.menuTypeMap.set(DefaultGraphMenuKey, []);
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); });
@@ -92,7 +92,7 @@ var Menu = /** @class */ (function () {
92
92
  },
93
93
  },
94
94
  ];
95
- this.menuTypeMap.set(DefalutSelectionMenuKey, DefalutSelectionMenu);
95
+ this.menuTypeMap.set(DefaultSelectionMenuKey, DefaultSelectionMenu);
96
96
  };
97
97
  Menu.prototype.render = function (lf, container) {
98
98
  var _this = this;
@@ -139,7 +139,7 @@ var Menu = /** @class */ (function () {
139
139
  menuList = typeMenus;
140
140
  }
141
141
  else { // 最后取全局默认
142
- menuList = _this.menuTypeMap.get(DefalutNodeMenuKey);
142
+ menuList = _this.menuTypeMap.get(DefaultNodeMenuKey);
143
143
  }
144
144
  _this.__currentData = data;
145
145
  _this.showMenu(x, y, menuList);
@@ -159,20 +159,20 @@ var Menu = /** @class */ (function () {
159
159
  menuList = typeMenus;
160
160
  }
161
161
  else { // 最后取全局默认
162
- menuList = _this.menuTypeMap.get(DefalutEdgeMenuKey);
162
+ menuList = _this.menuTypeMap.get(DefaultEdgeMenuKey);
163
163
  }
164
164
  _this.__currentData = data;
165
165
  _this.showMenu(x, y, menuList);
166
166
  });
167
167
  this.lf.on('blank:contextmenu', function (_a) {
168
168
  var position = _a.position;
169
- var menuList = _this.menuTypeMap.get(DefalutGraphMenuKey);
169
+ var menuList = _this.menuTypeMap.get(DefaultGraphMenuKey);
170
170
  var _b = position.domOverlayPosition, x = _b.x, y = _b.y;
171
171
  _this.showMenu(x, y, menuList);
172
172
  });
173
173
  this.lf.on('selection:contextmenu', function (_a) {
174
174
  var data = _a.data, position = _a.position;
175
- var menuList = _this.menuTypeMap.get(DefalutSelectionMenuKey);
175
+ var menuList = _this.menuTypeMap.get(DefaultSelectionMenuKey);
176
176
  var _b = position.domOverlayPosition, x = _b.x, y = _b.y;
177
177
  _this.__currentData = data;
178
178
  _this.showMenu(x, y, menuList);
@@ -253,13 +253,13 @@ var Menu = /** @class */ (function () {
253
253
  }
254
254
  // node
255
255
  config.nodeMenu !== undefined
256
- && this.menuTypeMap.set(DefalutNodeMenuKey, config.nodeMenu ? config.nodeMenu : []);
256
+ && this.menuTypeMap.set(DefaultNodeMenuKey, config.nodeMenu ? config.nodeMenu : []);
257
257
  // edge
258
258
  config.edgeMenu !== undefined
259
- && this.menuTypeMap.set(DefalutEdgeMenuKey, config.edgeMenu ? config.edgeMenu : []);
259
+ && this.menuTypeMap.set(DefaultEdgeMenuKey, config.edgeMenu ? config.edgeMenu : []);
260
260
  // graph
261
261
  config.graphMenu !== undefined
262
- && this.menuTypeMap.set(DefalutGraphMenuKey, config.graphMenu ? config.graphMenu : []);
262
+ && this.menuTypeMap.set(DefaultGraphMenuKey, config.graphMenu ? config.graphMenu : []);
263
263
  };
264
264
  // 在默认菜单后面追加菜单项
265
265
  Menu.prototype.addMenuConfig = function (config) {
@@ -268,16 +268,16 @@ var Menu = /** @class */ (function () {
268
268
  }
269
269
  // 追加项时,只支持数组类型,对false不做操作
270
270
  if (Array.isArray(config.nodeMenu)) {
271
- var menuList = this.menuTypeMap.get(DefalutNodeMenuKey);
272
- this.menuTypeMap.set(DefalutNodeMenuKey, menuList.concat(config.nodeMenu));
271
+ var menuList = this.menuTypeMap.get(DefaultNodeMenuKey);
272
+ this.menuTypeMap.set(DefaultNodeMenuKey, menuList.concat(config.nodeMenu));
273
273
  }
274
274
  if (Array.isArray(config.edgeMenu)) {
275
- var menuList = this.menuTypeMap.get(DefalutEdgeMenuKey);
276
- this.menuTypeMap.set(DefalutEdgeMenuKey, menuList.concat(config.edgeMenu));
275
+ var menuList = this.menuTypeMap.get(DefaultEdgeMenuKey);
276
+ this.menuTypeMap.set(DefaultEdgeMenuKey, menuList.concat(config.edgeMenu));
277
277
  }
278
278
  if (Array.isArray(config.graphMenu)) {
279
- var menuList = this.menuTypeMap.get(DefalutGraphMenuKey);
280
- this.menuTypeMap.set(DefalutGraphMenuKey, menuList.concat(config.graphMenu));
279
+ var menuList = this.menuTypeMap.get(DefaultGraphMenuKey);
280
+ this.menuTypeMap.set(DefaultGraphMenuKey, menuList.concat(config.graphMenu));
281
281
  }
282
282
  };
283
283
  /**
@@ -172,11 +172,11 @@ var MiniMap = /** @class */ (function () {
172
172
  nodes.forEach(function (_a) {
173
173
  var x = _a.x, y = _a.y, _b = _a.width, width = _b === void 0 ? 200 : _b, _c = _a.height, height = _c === void 0 ? 200 : _c;
174
174
  var nodeLeft = x - width / 2;
175
- var noderight = x + width / 2;
175
+ var nodeRight = x + width / 2;
176
176
  var nodeTop = y - height / 2;
177
177
  var nodeBottom = y + height / 2;
178
178
  left = nodeLeft < left ? nodeLeft : left;
179
- right = noderight > right ? noderight : right;
179
+ right = nodeRight > right ? nodeRight : right;
180
180
  top = nodeTop < top ? nodeTop : top;
181
181
  bottom = nodeBottom > bottom ? nodeBottom : bottom;
182
182
  });
@@ -12,7 +12,7 @@ declare class SelectionSelect {
12
12
  y: number;
13
13
  };
14
14
  __disabled: boolean;
15
- isDefalutStopMoveGraph: boolean;
15
+ isDefaultStopMoveGraph: boolean;
16
16
  isWholeNode: boolean;
17
17
  isWholeEdge: boolean;
18
18
  static pluginName: string;
@@ -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
  }
@@ -3,7 +3,7 @@ var SelectionSelect = /** @class */ (function () {
3
3
  var _this = this;
4
4
  var lf = _a.lf;
5
5
  this.__disabled = false;
6
- this.isDefalutStopMoveGraph = false;
6
+ this.isDefaultStopMoveGraph = false;
7
7
  this.isWholeNode = true;
8
8
  this.isWholeEdge = true;
9
9
  this.__draw = function (ev) {
@@ -40,16 +40,18 @@ 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
  };
49
51
  this.lf = lf;
50
- // 初始化isDefalutStopMoveGraph取值
52
+ // 初始化isDefaultStopMoveGraph取值
51
53
  var stopMoveGraph = lf.getEditConfig().stopMoveGraph;
52
- this.isDefalutStopMoveGraph = stopMoveGraph;
54
+ this.isDefaultStopMoveGraph = stopMoveGraph;
53
55
  lf.openSelectionSelect = function () {
54
56
  _this.openSelectionSelect();
55
57
  };
@@ -97,7 +99,7 @@ var SelectionSelect = /** @class */ (function () {
97
99
  SelectionSelect.prototype.openSelectionSelect = function () {
98
100
  var stopMoveGraph = this.lf.getEditConfig().stopMoveGraph;
99
101
  if (!stopMoveGraph) {
100
- this.isDefalutStopMoveGraph = false;
102
+ this.isDefaultStopMoveGraph = false;
101
103
  this.lf.updateEditConfig({
102
104
  stopMoveGraph: true,
103
105
  });
@@ -108,13 +110,31 @@ var SelectionSelect = /** @class */ (function () {
108
110
  * 关闭选区
109
111
  */
110
112
  SelectionSelect.prototype.closeSelectionSelect = function () {
111
- if (!this.isDefalutStopMoveGraph) {
113
+ if (!this.isDefaultStopMoveGraph) {
112
114
  this.lf.updateEditConfig({
113
115
  stopMoveGraph: false,
114
116
  });
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,4 +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';
19
20
  export * from './components/highlight';
package/es/index.js CHANGED
@@ -17,4 +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';
20
21
  export * from './components/highlight';
@@ -1,6 +1,6 @@
1
1
  import { Point, PolylineEdgeModel, BaseNodeModel } from '@logicflow/core';
2
2
  export declare const isInSegment: (point: any, start: any, end: any) => boolean;
3
- export declare const corssPointInSegement: (node: BaseNodeModel, start: Point, end: Point) => {
3
+ export declare const crossPointInSegment: (node: BaseNodeModel, start: Point, end: Point) => {
4
4
  startCrossPoint: {
5
5
  x: number;
6
6
  y: number;
@@ -10,12 +10,12 @@ export declare const corssPointInSegement: (node: BaseNodeModel, start: Point, e
10
10
  y: number;
11
11
  };
12
12
  };
13
- interface SegementCross {
13
+ interface SegmentCross {
14
14
  crossIndex: number;
15
15
  crossPoints: {
16
16
  startCrossPoint: Point;
17
17
  endCrossPoint: Point;
18
18
  };
19
19
  }
20
- export declare const isNodeInSegement: (node: BaseNodeModel, polyline: PolylineEdgeModel) => SegementCross;
20
+ export declare const isNodeInSegment: (node: BaseNodeModel, polyline: PolylineEdgeModel) => SegmentCross;
21
21
  export {};
@@ -42,7 +42,7 @@ var segmentDirection = function (start, end) {
42
42
  return direction;
43
43
  };
44
44
  // 节点是够在线段内,求出节点与线段的交点
45
- export var corssPointInSegement = function (node, start, end) {
45
+ export var crossPointInSegment = function (node, start, end) {
46
46
  var bBox = getNodeBBox(node);
47
47
  var direction = segmentDirection(start, end);
48
48
  var maxX = Math.max(start.x, end.x);
@@ -83,12 +83,12 @@ export var corssPointInSegement = function (node, start, end) {
83
83
  };
84
84
  // 节点是否在线段内
85
85
  // eslint-disable-next-line max-len
86
- export var isNodeInSegement = function (node, polyline) {
86
+ export var isNodeInSegment = function (node, polyline) {
87
87
  var x = node.x, y = node.y;
88
88
  var pointsList = polyline.pointsList;
89
89
  for (var i = 0; i < pointsList.length - 1; i++) {
90
90
  if (isInSegment({ x: x, y: y }, pointsList[i], pointsList[i + 1])) {
91
- var bBoxCross = corssPointInSegement(node, pointsList[i], pointsList[i + 1]);
91
+ var bBoxCross = crossPointInSegment(node, pointsList[i], pointsList[i + 1]);
92
92
  if (bBoxCross) {
93
93
  return {
94
94
  crossIndex: i + 1,
@@ -18,7 +18,7 @@ var __spread = (this && this.__spread) || function () {
18
18
  for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
19
19
  return ar;
20
20
  };
21
- import { isNodeInSegement } from './edge';
21
+ import { isNodeInSegment } from './edge';
22
22
  var InsertNodeInPolyline = /** @class */ (function () {
23
23
  function InsertNodeInPolyline(_a) {
24
24
  var lf = _a.lf;
@@ -59,7 +59,7 @@ var InsertNodeInPolyline = /** @class */ (function () {
59
59
  var nodeModel = this._lf.getNodeModelById(nodeData.id);
60
60
  for (var i = 0; i < edges.length; i++) {
61
61
  // eslint-disable-next-line max-len
62
- var _a = isNodeInSegement(nodeModel, edges[i]), crossIndex = _a.crossIndex, crossPoints = _a.crossPoints;
62
+ var _a = isNodeInSegment(nodeModel, edges[i]), crossIndex = _a.crossIndex, crossPoints = _a.crossPoints;
63
63
  if (crossIndex >= 0) {
64
64
  var _b = edges[i], sourceNodeId = _b.sourceNodeId, targetNodeId = _b.targetNodeId, id = _b.id, type = _b.type, pointsList = _b.pointsList;
65
65
  this._lf.addEdge({
@@ -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 };
@@ -101,7 +101,7 @@ declare class GroupNodeModel extends RectResize.model {
101
101
  }
102
102
  declare class GroupNode extends RectResize.view {
103
103
  getControlGroup(): h.JSX.Element;
104
- getAddedableShape(): import("preact").VNode<any>;
104
+ getAddAbleShape(): import("preact").VNode<any>;
105
105
  getFoldIcon(): import("preact").VNode<any>;
106
106
  getResizeShape(): import("preact").VNode<any>;
107
107
  }
@@ -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
  };
@@ -293,7 +303,7 @@ var GroupNode = /** @class */ (function (_super) {
293
303
  var _a = this.props.model, resizable = _a.resizable, properties = _a.properties;
294
304
  return resizable && !properties.isFolded ? _super.prototype.getControlGroup.call(this) : null;
295
305
  };
296
- GroupNode.prototype.getAddedableShape = function () {
306
+ GroupNode.prototype.getAddAbleShape = function () {
297
307
  var _a = this.props.model, width = _a.width, height = _a.height, x = _a.x, y = _a.y, radius = _a.radius, properties = _a.properties;
298
308
  if (!properties.groupAddable)
299
309
  return null;
@@ -339,7 +349,7 @@ var GroupNode = /** @class */ (function (_super) {
339
349
  };
340
350
  GroupNode.prototype.getResizeShape = function () {
341
351
  return h('g', {}, [
342
- this.getAddedableShape(),
352
+ this.getAddAbleShape(),
343
353
  _super.prototype.getResizeShape.call(this),
344
354
  this.getFoldIcon(),
345
355
  ]);
@@ -17,7 +17,7 @@ declare class Group {
17
17
  lf: any;
18
18
  });
19
19
  graphRendered: (data: any) => void;
20
- appendNodeToGrop: ({ data }: {
20
+ appendNodeToGroup: ({ data }: {
21
21
  data: any;
22
22
  }) => void;
23
23
  deleteGroupChild: ({ data }: {
@@ -36,7 +36,7 @@ var Group = /** @class */ (function () {
36
36
  });
37
37
  }
38
38
  };
39
- this.appendNodeToGrop = function (_a) {
39
+ this.appendNodeToGroup = function (_a) {
40
40
  var data = _a.data;
41
41
  // 如果这个节点之前已经在group中了,则将其从之前的group中移除
42
42
  var preGroupId = _this.nodeGroupMap.get(data.id);
@@ -110,9 +110,9 @@ var Group = /** @class */ (function () {
110
110
  return true;
111
111
  });
112
112
  lf.graphModel.group = this;
113
- lf.on('node:add', this.appendNodeToGrop);
113
+ lf.on('node:add', this.appendNodeToGroup);
114
114
  lf.on('node:delete', this.deleteGroupChild);
115
- lf.on('node:drop', this.appendNodeToGrop);
115
+ lf.on('node:drop', this.appendNodeToGroup);
116
116
  lf.on('node:dnd-drag', this.setActiveGroup);
117
117
  lf.on('node:drag', this.setActiveGroup);
118
118
  lf.on('graph:rendered', this.graphRendered);
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * 自动布局插件
3
- * 依赖flowpath插件
3
+ * 依赖flow-path插件
4
4
  * 未完善
5
5
  */
6
6
  import LogicFlow from '@logicflow/core';
@@ -26,7 +26,7 @@ declare class AutoLayout {
26
26
  * source一定在target左边。
27
27
  * 1. 如果source和target在同一x, y坐标内容。
28
28
  * 2. 如果source在target左上方。
29
- * 3. 如果souce在target左下方。
29
+ * 3. 如果source在target左下方。
30
30
  */
31
31
  private getRelativePosition;
32
32
  /**
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * 自动布局插件
3
- * 依赖flowpath插件
3
+ * 依赖flow-path插件
4
4
  * 未完善
5
5
  */
6
6
  var __assign = (this && this.__assign) || function () {
@@ -138,7 +138,7 @@ var AutoLayout = /** @class */ (function () {
138
138
  var target = this.newNodeMap.get(targetNodeId);
139
139
  var _a = this.getShape(sourceNodeId), width = _a.width, height = _a.height;
140
140
  var _b = this.getShape(targetNodeId), targetWidth = _b.width, targetHeight = _b.height;
141
- var postionType = this.getRelativePosition(source, target);
141
+ var positionType = this.getRelativePosition(source, target);
142
142
  var startPoint = {
143
143
  x: source.x,
144
144
  y: source.y,
@@ -147,7 +147,7 @@ var AutoLayout = /** @class */ (function () {
147
147
  x: target.x,
148
148
  y: target.y,
149
149
  };
150
- switch (postionType) {
150
+ switch (positionType) {
151
151
  case POSITION_TYPE.LEFT:
152
152
  startPoint.x = source.x + width / 2;
153
153
  endPoint.x = target.x - targetWidth / 2;
@@ -173,22 +173,22 @@ var AutoLayout = /** @class */ (function () {
173
173
  * source一定在target左边。
174
174
  * 1. 如果source和target在同一x, y坐标内容。
175
175
  * 2. 如果source在target左上方。
176
- * 3. 如果souce在target左下方。
176
+ * 3. 如果source在target左下方。
177
177
  */
178
178
  AutoLayout.prototype.getRelativePosition = function (source, target) {
179
179
  var y = source.y;
180
180
  var y1 = target.y;
181
- var postionType;
181
+ var positionType;
182
182
  if (y < y1) {
183
- postionType = -1;
183
+ positionType = -1;
184
184
  }
185
185
  else if (y === y1) {
186
- postionType = 0;
186
+ positionType = 0;
187
187
  }
188
188
  else {
189
- postionType = 1;
189
+ positionType = 1;
190
190
  }
191
- return postionType;
191
+ return positionType;
192
192
  };
193
193
  /**
194
194
  * 获取边节点图形的宽高。