@logicflow/extension 1.2.0-alpha.1 → 1.2.0-alpha.4

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 (52) hide show
  1. package/cjs/components/control/index.js +16 -16
  2. package/cjs/components/menu/index.js +9 -9
  3. package/cjs/index.js +1 -0
  4. package/cjs/locale/en-locale/en.js +22 -0
  5. package/cjs/locale/en-locale/index.js +29 -0
  6. package/cjs/locale/locale.js +19 -0
  7. package/cjs/turbo-adapter/index.js +71 -41
  8. package/es/components/control/index.d.ts +2 -3
  9. package/es/components/control/index.js +16 -16
  10. package/es/components/menu/index.d.ts +2 -3
  11. package/es/components/menu/index.js +9 -9
  12. package/es/index.d.ts +1 -0
  13. package/es/index.js +1 -0
  14. package/es/locale/en-locale/en.d.ts +19 -0
  15. package/es/locale/en-locale/en.js +19 -0
  16. package/es/locale/en-locale/index.d.ts +9 -0
  17. package/es/locale/en-locale/index.js +26 -0
  18. package/es/locale/locale.d.ts +6 -0
  19. package/es/locale/locale.js +16 -0
  20. package/es/turbo-adapter/index.d.ts +6 -7
  21. package/es/turbo-adapter/index.js +70 -40
  22. package/lib/AutoLayout.js +1 -1
  23. package/lib/BpmnAdapter.js +1 -1
  24. package/lib/BpmnElement.js +1 -1
  25. package/lib/ContextMenu.js +1 -1
  26. package/lib/Control.js +1 -1
  27. package/lib/CurvedEdge.js +1 -1
  28. package/lib/DndPanel.js +1 -1
  29. package/lib/EnLocale.js +1 -0
  30. package/lib/FlowPath.js +1 -1
  31. package/lib/Group.js +1 -1
  32. package/lib/InsertNodeInPolyline.js +1 -1
  33. package/lib/Menu.js +1 -1
  34. package/lib/MiniMap.js +1 -1
  35. package/lib/NodeResize.js +1 -1
  36. package/lib/RectLabelNode.js +1 -1
  37. package/lib/SelectionSelect.js +1 -1
  38. package/lib/Snapshot.js +1 -1
  39. package/lib/TurboAdapter.js +1 -1
  40. package/lib/lfJson2Xml.js +1 -1
  41. package/lib/lfXml2Json.js +1 -1
  42. package/package.json +2 -2
  43. package/types/components/control/index.d.ts +2 -3
  44. package/types/components/menu/index.d.ts +2 -3
  45. package/types/index.d.ts +1 -0
  46. package/types/locale/en-locale/en.d.ts +19 -0
  47. package/types/locale/en-locale/index.d.ts +9 -0
  48. package/types/locale/locale.d.ts +6 -0
  49. package/types/turbo-adapter/index.d.ts +6 -7
  50. package/types/NodeResize/BasicShape/Ellipse.d.ts +0 -2
  51. package/types/curved.d.ts +0 -0
  52. package/types/group-shrink/index.d.ts +0 -28
@@ -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(_a) {
25
+ function Control(args) {
26
26
  var _this = this;
27
- var lf = _a.lf;
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.text) {
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(_a) {
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;
@@ -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.TurboAdapter = exports.toLogicflowData = exports.toTurboData = void 0;
15
- var TurboType;
16
- (function (TurboType) {
17
- TurboType[TurboType["SEQUENCE_FLOW"] = 1] = "SEQUENCE_FLOW";
18
- TurboType[TurboType["START_EVENT"] = 2] = "START_EVENT";
19
- TurboType[TurboType["END_EVENT"] = 3] = "END_EVENT";
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
- TurboType[TurboType["EXCLUSIVE_GATEWAY"] = 6] = "EXCLUSIVE_GATEWAY";
23
- })(TurboType || (TurboType = {}));
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, logicFlowType: type }),
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, startPoint = properties.startPoint, endPoint = properties.endPoint, pointsList = properties.pointsList, logicFlowType = properties.logicFlowType;
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: logicFlowType,
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', 'logicFlowType'];
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, text = properties.text, logicFlowType = properties.logicFlowType;
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: logicFlowType,
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', 'logicFlowType'];
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
- pluginName: 'turboAdapter',
161
- install: function (lf) {
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
- shapeConfigMap: new Map(),
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: function (turboData) {
202
+ };
203
+ TurboAdapter.prototype.adapterIn = function (turboData) {
175
204
  if (turboData) {
176
205
  return toLogicflowData(turboData);
177
206
  }
178
- },
179
- };
180
- exports.TurboAdapter = TurboAdapter;
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({ 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;
@@ -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); });
package/es/index.d.ts CHANGED
@@ -16,3 +16,4 @@ 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';
package/es/index.js CHANGED
@@ -17,3 +17,4 @@ 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';
@@ -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 };