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

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 (45) hide show
  1. package/cjs/components/control/index.js +13 -13
  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/es/components/control/index.d.ts +2 -3
  8. package/es/components/control/index.js +13 -13
  9. package/es/components/menu/index.d.ts +2 -3
  10. package/es/components/menu/index.js +9 -9
  11. package/es/index.d.ts +1 -0
  12. package/es/index.js +1 -0
  13. package/es/locale/en-locale/en.d.ts +19 -0
  14. package/es/locale/en-locale/en.js +19 -0
  15. package/es/locale/en-locale/index.d.ts +9 -0
  16. package/es/locale/en-locale/index.js +26 -0
  17. package/es/locale/locale.d.ts +6 -0
  18. package/es/locale/locale.js +16 -0
  19. package/lib/AutoLayout.js +1 -1
  20. package/lib/BpmnAdapter.js +1 -1
  21. package/lib/BpmnElement.js +1 -1
  22. package/lib/ContextMenu.js +1 -1
  23. package/lib/Control.js +1 -1
  24. package/lib/CurvedEdge.js +1 -1
  25. package/lib/DndPanel.js +1 -1
  26. package/lib/EnLocale.js +1 -0
  27. package/lib/FlowPath.js +1 -1
  28. package/lib/Group.js +1 -1
  29. package/lib/InsertNodeInPolyline.js +1 -1
  30. package/lib/Menu.js +1 -1
  31. package/lib/MiniMap.js +1 -1
  32. package/lib/NodeResize.js +1 -1
  33. package/lib/RectLabelNode.js +1 -1
  34. package/lib/SelectionSelect.js +1 -1
  35. package/lib/Snapshot.js +1 -1
  36. package/lib/TurboAdapter.js +1 -1
  37. package/lib/lfJson2Xml.js +1 -1
  38. package/lib/lfXml2Json.js +1 -1
  39. package/package.json +2 -2
  40. package/types/components/control/index.d.ts +2 -3
  41. package/types/components/menu/index.d.ts +2 -3
  42. package/types/index.d.ts +1 -0
  43. package/types/locale/en-locale/en.d.ts +19 -0
  44. package/types/locale/en-locale/index.d.ts +9 -0
  45. package/types/locale/locale.d.ts +6 -0
@@ -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();
@@ -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;
@@ -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();
@@ -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 };
@@ -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 };