@logicflow/extension 1.2.0-next.1 → 1.2.0-next.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 (104) hide show
  1. package/cjs/NodeResize/Control/Control.js +71 -16
  2. package/cjs/NodeResize/Node/DiamondResize.js +24 -10
  3. package/cjs/NodeResize/Node/EllipseResize.js +24 -10
  4. package/cjs/NodeResize/Node/HtmlResize.js +24 -10
  5. package/cjs/NodeResize/Node/RectResize.js +24 -10
  6. package/cjs/bpmn-adapter/index.js +74 -122
  7. package/cjs/bpmn-adapter/json2xml.js +2 -4
  8. package/cjs/bpmn-adapter/xml2json.js +247 -2
  9. package/cjs/components/control/index.js +16 -16
  10. package/cjs/components/dnd-panel/index.js +21 -0
  11. package/cjs/components/highlight/index.js +0 -1
  12. package/cjs/components/menu/index.js +9 -9
  13. package/cjs/components/mini-map/index.js +223 -138
  14. package/cjs/components/selection-select/index.js +6 -19
  15. package/cjs/index.js +0 -1
  16. package/cjs/materials/curved-edge/index.js +19 -5
  17. package/cjs/materials/curved-edge/searchMiddleIndex.js +17 -0
  18. package/cjs/materials/group/GroupNode.js +34 -64
  19. package/cjs/materials/group/index.js +80 -70
  20. package/cjs/style/index.css +10 -0
  21. package/cjs/tools/auto-layout/index.js +1 -1
  22. package/es/NodeResize/Control/Control.d.ts +4 -1
  23. package/es/NodeResize/Control/Control.js +71 -16
  24. package/es/NodeResize/Node/DiamondResize.d.ts +3 -1
  25. package/es/NodeResize/Node/DiamondResize.js +24 -10
  26. package/es/NodeResize/Node/EllipseResize.d.ts +3 -1
  27. package/es/NodeResize/Node/EllipseResize.js +24 -10
  28. package/es/NodeResize/Node/HtmlResize.d.ts +3 -1
  29. package/es/NodeResize/Node/HtmlResize.js +24 -10
  30. package/es/NodeResize/Node/RectResize.d.ts +3 -1
  31. package/es/NodeResize/Node/RectResize.js +24 -10
  32. package/es/bpmn-adapter/index.d.ts +33 -41
  33. package/es/bpmn-adapter/index.js +74 -122
  34. package/es/bpmn-adapter/json2xml.js +2 -4
  35. package/es/bpmn-adapter/xml2json.js +247 -2
  36. package/es/components/control/index.d.ts +3 -2
  37. package/es/components/control/index.js +16 -16
  38. package/es/components/dnd-panel/index.js +21 -0
  39. package/es/components/highlight/index.js +0 -1
  40. package/es/components/menu/index.d.ts +3 -2
  41. package/es/components/menu/index.js +9 -9
  42. package/es/components/mini-map/index.d.ts +57 -45
  43. package/es/components/mini-map/index.js +223 -138
  44. package/es/components/selection-select/index.d.ts +0 -1
  45. package/es/components/selection-select/index.js +6 -19
  46. package/es/index.d.ts +0 -1
  47. package/es/index.js +0 -1
  48. package/es/materials/curved-edge/index.js +19 -5
  49. package/es/materials/curved-edge/searchMiddleIndex.d.ts +1 -0
  50. package/es/materials/curved-edge/searchMiddleIndex.js +14 -0
  51. package/es/materials/group/GroupNode.d.ts +5 -7
  52. package/es/materials/group/GroupNode.js +34 -64
  53. package/es/materials/group/index.d.ts +19 -1
  54. package/es/materials/group/index.js +80 -70
  55. package/es/style/index.css +10 -0
  56. package/es/tools/auto-layout/index.d.ts +1 -1
  57. package/es/tools/auto-layout/index.js +1 -1
  58. package/lib/AutoLayout.js +1 -1
  59. package/lib/BpmnAdapter.js +1 -1
  60. package/lib/BpmnElement.js +1 -1
  61. package/lib/ContextMenu.js +1 -1
  62. package/lib/Control.js +1 -1
  63. package/lib/CurvedEdge.js +1 -1
  64. package/lib/DndPanel.js +1 -1
  65. package/lib/FlowPath.js +1 -1
  66. package/lib/Group.js +1 -1
  67. package/lib/Highlight.js +1 -1
  68. package/lib/InsertNodeInPolyline.js +1 -1
  69. package/lib/Menu.js +1 -1
  70. package/lib/MiniMap.js +1 -1
  71. package/lib/NodeResize.js +1 -1
  72. package/lib/RectLabelNode.js +1 -1
  73. package/lib/SelectionSelect.js +1 -1
  74. package/lib/Snapshot.js +1 -1
  75. package/lib/TurboAdapter.js +1 -1
  76. package/lib/lfJson2Xml.js +1 -1
  77. package/lib/lfXml2Json.js +1 -1
  78. package/lib/style/index.css +10 -0
  79. package/package.json +3 -2
  80. package/types/NodeResize/Control/Control.d.ts +4 -1
  81. package/types/NodeResize/Node/DiamondResize.d.ts +3 -1
  82. package/types/NodeResize/Node/EllipseResize.d.ts +3 -1
  83. package/types/NodeResize/Node/HtmlResize.d.ts +3 -1
  84. package/types/NodeResize/Node/RectResize.d.ts +3 -1
  85. package/types/bpmn-adapter/index.d.ts +33 -41
  86. package/types/components/control/index.d.ts +3 -2
  87. package/types/components/menu/index.d.ts +3 -2
  88. package/types/components/mini-map/index.d.ts +57 -45
  89. package/types/components/selection-select/index.d.ts +0 -1
  90. package/types/index.d.ts +0 -1
  91. package/types/materials/curved-edge/searchMiddleIndex.d.ts +1 -0
  92. package/types/materials/group/GroupNode.d.ts +5 -7
  93. package/types/materials/group/index.d.ts +19 -1
  94. package/types/tools/auto-layout/index.d.ts +1 -1
  95. package/cjs/locale/en-locale/en.js +0 -22
  96. package/cjs/locale/en-locale/index.js +0 -29
  97. package/cjs/locale/locale.js +0 -19
  98. package/es/locale/en-locale/en.d.ts +0 -19
  99. package/es/locale/en-locale/en.js +0 -19
  100. package/es/locale/en-locale/index.d.ts +0 -9
  101. package/es/locale/en-locale/index.js +0 -26
  102. package/es/locale/locale.d.ts +0 -6
  103. package/es/locale/locale.js +0 -16
  104. package/lib/EnLocale.js +0 -1
@@ -27,8 +27,14 @@ import ControlGroup from '../Control/ControlGroup';
27
27
  import Polygon from '../BasicShape/Polygon';
28
28
  var DiamondResizeModel = /** @class */ (function (_super) {
29
29
  __extends(DiamondResizeModel, _super);
30
- function DiamondResizeModel() {
31
- return _super !== null && _super.apply(this, arguments) || this;
30
+ function DiamondResizeModel(data, graphModel) {
31
+ var _this = _super.call(this, data, graphModel) || this;
32
+ var nodeSize = _this.properties.nodeSize;
33
+ if (nodeSize) {
34
+ _this.rx = nodeSize.rx;
35
+ _this.ry = nodeSize.ry;
36
+ }
37
+ return _this;
32
38
  }
33
39
  DiamondResizeModel.prototype.initNodeData = function (data) {
34
40
  _super.prototype.initNodeData.call(this, data);
@@ -38,14 +44,6 @@ var DiamondResizeModel = /** @class */ (function (_super) {
38
44
  this.maxHeight = 2000;
39
45
  this.gridSize = 1;
40
46
  };
41
- DiamondResizeModel.prototype.init = function () {
42
- _super.prototype.init.call(this);
43
- var nodeSize = this.properties.nodeSize;
44
- if (nodeSize) {
45
- this.rx = nodeSize.rx;
46
- this.ry = nodeSize.ry;
47
- }
48
- };
49
47
  DiamondResizeModel.prototype.getOutlineStyle = function () {
50
48
  var style = _super.prototype.getOutlineStyle.call(this);
51
49
  var isSilentMode = this.graphModel.editConfigModel.isSilentMode;
@@ -72,6 +70,22 @@ var DiamondResizeModel = /** @class */ (function (_super) {
72
70
  stroke: '#000000',
73
71
  };
74
72
  };
73
+ // 该方法需要在重设宽高和最大、最小限制后被调用,不建议在 initNodeData() 方法中使用
74
+ DiamondResizeModel.prototype.enableProportionResize = function (turnOn) {
75
+ if (turnOn === void 0) { turnOn = true; }
76
+ if (turnOn) {
77
+ var ResizePCT = { widthPCT: 100, hightPCT: 100 };
78
+ var ResizeBasis = { basisWidth: this.rx, basisHeight: this.ry };
79
+ var ScaleLimit = {
80
+ maxScaleLimit: Math.min((this.maxWidth / (this.rx * 2)) * 100, (this.maxHeight / (this.ry * 2)) * 100),
81
+ minScaleLimit: Math.max((this.minWidth / (this.rx * 2)) * 100, (this.minHeight / (this.ry * 2)) * 100),
82
+ };
83
+ this.PCTResizeInfo = { ResizePCT: ResizePCT, ResizeBasis: ResizeBasis, ScaleLimit: ScaleLimit };
84
+ }
85
+ else {
86
+ delete this.PCTResizeInfo;
87
+ }
88
+ };
75
89
  return DiamondResizeModel;
76
90
  }(DiamondNodeModel));
77
91
  var DiamondResizeView = /** @class */ (function (_super) {
@@ -1,7 +1,8 @@
1
1
  import { h, EllipseNode, EllipseNodeModel } from '@logicflow/core';
2
2
  declare class EllipseResizeModel extends EllipseNodeModel {
3
+ private PCTResizeInfo;
4
+ constructor(data: any, graphModel: any);
3
5
  initNodeData(data: any): void;
4
- init(): void;
5
6
  getOutlineStyle(): import("@logicflow/core/types/constant/DefaultTheme").OutlineTheme;
6
7
  getResizeOutlineStyle(): {
7
8
  stroke: string;
@@ -14,6 +15,7 @@ declare class EllipseResizeModel extends EllipseNodeModel {
14
15
  fill: string;
15
16
  stroke: string;
16
17
  };
18
+ enableProportionResize(turnOn?: boolean): void;
17
19
  }
18
20
  declare class EllipseResizeView extends EllipseNode {
19
21
  getControlGroup(): h.JSX.Element;
@@ -15,8 +15,14 @@ import { h, EllipseNode, EllipseNodeModel } from '@logicflow/core';
15
15
  import ControlGroup from '../Control/ControlGroup';
16
16
  var EllipseResizeModel = /** @class */ (function (_super) {
17
17
  __extends(EllipseResizeModel, _super);
18
- function EllipseResizeModel() {
19
- return _super !== null && _super.apply(this, arguments) || this;
18
+ function EllipseResizeModel(data, graphModel) {
19
+ var _this = _super.call(this, data, graphModel) || this;
20
+ var nodeSize = _this.properties.nodeSize;
21
+ if (nodeSize) {
22
+ _this.rx = nodeSize.rx;
23
+ _this.ry = nodeSize.ry;
24
+ }
25
+ return _this;
20
26
  }
21
27
  EllipseResizeModel.prototype.initNodeData = function (data) {
22
28
  _super.prototype.initNodeData.call(this, data);
@@ -25,14 +31,6 @@ var EllipseResizeModel = /** @class */ (function (_super) {
25
31
  this.maxWidth = 2000;
26
32
  this.maxHeight = 2000;
27
33
  };
28
- EllipseResizeModel.prototype.init = function () {
29
- _super.prototype.init.call(this);
30
- var nodeSize = this.properties.nodeSize;
31
- if (nodeSize) {
32
- this.rx = nodeSize.rx;
33
- this.ry = nodeSize.ry;
34
- }
35
- };
36
34
  EllipseResizeModel.prototype.getOutlineStyle = function () {
37
35
  var style = _super.prototype.getOutlineStyle.call(this);
38
36
  var isSilentMode = this.graphModel.editConfigModel.isSilentMode;
@@ -59,6 +57,22 @@ var EllipseResizeModel = /** @class */ (function (_super) {
59
57
  stroke: '#000000',
60
58
  };
61
59
  };
60
+ // 该方法需要在重设宽高和最大、最小限制后被调用,不建议在 initNodeData() 方法中使用
61
+ EllipseResizeModel.prototype.enableProportionResize = function (turnOn) {
62
+ if (turnOn === void 0) { turnOn = true; }
63
+ if (turnOn) {
64
+ var ResizePCT = { widthPCT: 100, hightPCT: 100 };
65
+ var ResizeBasis = { basisWidth: this.rx, basisHeight: this.ry };
66
+ var ScaleLimit = {
67
+ maxScaleLimit: Math.min((this.maxWidth / (this.rx * 2)) * 100, (this.maxHeight / (this.ry * 2)) * 100),
68
+ minScaleLimit: Math.max((this.minWidth / (this.rx * 2)) * 100, (this.minHeight / (this.ry * 2)) * 100),
69
+ };
70
+ this.PCTResizeInfo = { ResizePCT: ResizePCT, ResizeBasis: ResizeBasis, ScaleLimit: ScaleLimit };
71
+ }
72
+ else {
73
+ delete this.PCTResizeInfo;
74
+ }
75
+ };
62
76
  return EllipseResizeModel;
63
77
  }(EllipseNodeModel));
64
78
  var EllipseResizeView = /** @class */ (function (_super) {
@@ -1,7 +1,8 @@
1
1
  import { h, HtmlNode, HtmlNodeModel } from '@logicflow/core';
2
2
  declare class HtmlResizeModel extends HtmlNodeModel {
3
+ private PCTResizeInfo;
4
+ constructor(data: any, graphModel: any);
3
5
  initNodeData(data: any): void;
4
- init(): void;
5
6
  getOutlineStyle(): import("@logicflow/core/types/constant/DefaultTheme").OutlineTheme;
6
7
  getResizeOutlineStyle(): {
7
8
  stroke: string;
@@ -14,6 +15,7 @@ declare class HtmlResizeModel extends HtmlNodeModel {
14
15
  fill: string;
15
16
  stroke: string;
16
17
  };
18
+ enableProportionResize(turnOn?: boolean): void;
17
19
  }
18
20
  declare class HtmlResizeView extends HtmlNode {
19
21
  getControlGroup(): h.JSX.Element;
@@ -15,8 +15,14 @@ import { h, HtmlNode, HtmlNodeModel } from '@logicflow/core';
15
15
  import ControlGroup from '../Control/ControlGroup';
16
16
  var HtmlResizeModel = /** @class */ (function (_super) {
17
17
  __extends(HtmlResizeModel, _super);
18
- function HtmlResizeModel() {
19
- return _super !== null && _super.apply(this, arguments) || this;
18
+ function HtmlResizeModel(data, graphModel) {
19
+ var _this = _super.call(this, data, graphModel) || this;
20
+ var nodeSize = _this.properties.nodeSize;
21
+ if (nodeSize) {
22
+ _this.width = nodeSize.width;
23
+ _this.height = nodeSize.height;
24
+ }
25
+ return _this;
20
26
  }
21
27
  HtmlResizeModel.prototype.initNodeData = function (data) {
22
28
  _super.prototype.initNodeData.call(this, data);
@@ -25,14 +31,6 @@ var HtmlResizeModel = /** @class */ (function (_super) {
25
31
  this.maxWidth = 2000;
26
32
  this.maxHeight = 2000;
27
33
  };
28
- HtmlResizeModel.prototype.init = function () {
29
- _super.prototype.init.call(this);
30
- var nodeSize = this.properties.nodeSize;
31
- if (nodeSize) {
32
- this.width = nodeSize.width;
33
- this.height = nodeSize.height;
34
- }
35
- };
36
34
  HtmlResizeModel.prototype.getOutlineStyle = function () {
37
35
  var style = _super.prototype.getOutlineStyle.call(this);
38
36
  var isSilentMode = this.graphModel.editConfigModel.isSilentMode;
@@ -59,6 +57,22 @@ var HtmlResizeModel = /** @class */ (function (_super) {
59
57
  stroke: '#000000',
60
58
  };
61
59
  };
60
+ // 该方法需要在重设宽高和最大、最小限制后被调用,不建议在 initNodeData() 方法中使用
61
+ HtmlResizeModel.prototype.enableProportionResize = function (turnOn) {
62
+ if (turnOn === void 0) { turnOn = true; }
63
+ if (turnOn) {
64
+ var ResizePCT = { widthPCT: 100, hightPCT: 100 };
65
+ var ResizeBasis = { basisWidth: this.width, basisHeight: this.height };
66
+ var ScaleLimit = {
67
+ maxScaleLimit: Math.min((this.maxWidth / this.width) * 100, (this.maxHeight / this.height) * 100),
68
+ minScaleLimit: Math.max((this.minWidth / this.width) * 100, (this.minHeight / this.height) * 100),
69
+ };
70
+ this.PCTResizeInfo = { ResizePCT: ResizePCT, ResizeBasis: ResizeBasis, ScaleLimit: ScaleLimit };
71
+ }
72
+ else {
73
+ delete this.PCTResizeInfo;
74
+ }
75
+ };
62
76
  return HtmlResizeModel;
63
77
  }(HtmlNodeModel));
64
78
  var HtmlResizeView = /** @class */ (function (_super) {
@@ -1,7 +1,8 @@
1
1
  import { h, RectNode, RectNodeModel } from '@logicflow/core';
2
2
  declare class RectResizeModel extends RectNodeModel {
3
+ private PCTResizeInfo;
4
+ constructor(data: any, graphModel: any);
3
5
  initNodeData(data: any): void;
4
- init(): void;
5
6
  getOutlineStyle(): import("@logicflow/core/types/constant/DefaultTheme").OutlineTheme;
6
7
  getResizeOutlineStyle(): {
7
8
  fill: string;
@@ -16,6 +17,7 @@ declare class RectResizeModel extends RectNodeModel {
16
17
  stroke: string;
17
18
  };
18
19
  resize(deltaX: any, deltaY: any): void;
20
+ enableProportionResize(turnOn?: boolean): void;
19
21
  }
20
22
  declare class RectResizeView extends RectNode {
21
23
  getControlGroup(): h.JSX.Element;
@@ -15,8 +15,14 @@ import { h, RectNode, RectNodeModel } from '@logicflow/core';
15
15
  import ControlGroup from '../Control/ControlGroup';
16
16
  var RectResizeModel = /** @class */ (function (_super) {
17
17
  __extends(RectResizeModel, _super);
18
- function RectResizeModel() {
19
- return _super !== null && _super.apply(this, arguments) || this;
18
+ function RectResizeModel(data, graphModel) {
19
+ var _this = _super.call(this, data, graphModel) || this;
20
+ var nodeSize = _this.properties.nodeSize;
21
+ if (nodeSize) {
22
+ _this.width = nodeSize.width;
23
+ _this.height = nodeSize.height;
24
+ }
25
+ return _this;
20
26
  }
21
27
  RectResizeModel.prototype.initNodeData = function (data) {
22
28
  _super.prototype.initNodeData.call(this, data);
@@ -25,14 +31,6 @@ var RectResizeModel = /** @class */ (function (_super) {
25
31
  this.maxWidth = 2000;
26
32
  this.maxHeight = 2000;
27
33
  };
28
- RectResizeModel.prototype.init = function () {
29
- _super.prototype.init.call(this);
30
- var nodeSize = this.properties.nodeSize;
31
- if (nodeSize) {
32
- this.width = nodeSize.width;
33
- this.height = nodeSize.height;
34
- }
35
- };
36
34
  RectResizeModel.prototype.getOutlineStyle = function () {
37
35
  var style = _super.prototype.getOutlineStyle.call(this);
38
36
  var isSilentMode = this.graphModel.editConfigModel.isSilentMode;
@@ -63,6 +61,22 @@ var RectResizeModel = /** @class */ (function (_super) {
63
61
  RectResizeModel.prototype.resize = function (deltaX, deltaY) {
64
62
  console.log(deltaX, deltaY);
65
63
  };
64
+ // 该方法需要在重设宽高和最大、最小限制后被调用,不建议在 initNodeData() 方法中使用
65
+ RectResizeModel.prototype.enableProportionResize = function (turnOn) {
66
+ if (turnOn === void 0) { turnOn = true; }
67
+ if (turnOn) {
68
+ var ResizePCT = { widthPCT: 100, hightPCT: 100 };
69
+ var ResizeBasis = { basisWidth: this.width, basisHeight: this.height };
70
+ var ScaleLimit = {
71
+ maxScaleLimit: Math.min((this.maxWidth / this.width) * 100, (this.maxHeight / this.height) * 100),
72
+ minScaleLimit: Math.max((this.minWidth / this.width) * 100, (this.minHeight / this.height) * 100),
73
+ };
74
+ this.PCTResizeInfo = { ResizePCT: ResizePCT, ResizeBasis: ResizeBasis, ScaleLimit: ScaleLimit };
75
+ }
76
+ else {
77
+ delete this.PCTResizeInfo;
78
+ }
79
+ };
66
80
  return RectResizeModel;
67
81
  }(RectNodeModel));
68
82
  var RectResizeView = /** @class */ (function (_super) {
@@ -1,53 +1,45 @@
1
- declare class BpmnAdapter {
2
- static pluginName: string;
3
- static shapeConfigMap: Map<any, any>;
4
- processAttributes: {
5
- ['-isExecutable']: string;
6
- ['-id']: string;
7
- };
8
- definitionAttributes: {
9
- ['-id']: string;
10
- ['-xmlns:xsi']: string;
11
- ['-xmlns:bpmn']: string;
12
- ['-xmlns:bpmndi']: string;
13
- ['-xmlns:dc']: string;
14
- ['-xmlns:di']: string;
15
- ['-targetNamespace']: string;
16
- ['-exporter']: string;
17
- ['-exporterVersion']: string;
18
- [key: string]: any;
19
- };
20
- constructor({ lf }: {
21
- lf: any;
22
- });
1
+ declare const BpmnAdapter: {
2
+ pluginName: string;
3
+ install(lf: any): void;
4
+ shapeConfigMap: Map<any, any>;
23
5
  setCustomShape(key: any, val: any): void;
24
- adapterOut: (data: any) => {
6
+ adapterOut(data: any): {
25
7
  'bpmn:definitions': {
26
- [key: string]: any;
27
- "-id": string;
28
- "-xmlns:xsi": string;
29
- "-xmlns:bpmn": string;
30
- "-xmlns:bpmndi": string;
31
- "-xmlns:dc": string;
32
- "-xmlns:di": string;
33
- "-targetNamespace": string;
34
- "-exporter": string;
35
- "-exporterVersion": string;
8
+ '-id': string;
9
+ '-xmlns:xsi': string;
10
+ '-xmlns:bpmn': string;
11
+ '-xmlns:bpmndi': string;
12
+ '-xmlns:dc': string;
13
+ '-xmlns:di': string;
14
+ '-targetNamespace': string;
15
+ '-exporter': string;
16
+ '-exporterVersion': string;
17
+ 'bpmn:process': {
18
+ '-id': string;
19
+ '-isExecutable': string;
20
+ };
21
+ 'bpmndi:BPMNDiagram': {
22
+ '-id': string;
23
+ 'bpmndi:BPMNPlane': {
24
+ '-id': string;
25
+ '-bpmnElement': string;
26
+ };
27
+ };
36
28
  };
37
29
  };
38
- adapterIn: (bpmnData: any) => {
30
+ adapterIn(bpmnData: any): {
39
31
  nodes: any[];
40
32
  edges: any[];
41
33
  };
42
- }
43
- declare class BpmnXmlAdapter extends BpmnAdapter {
44
- static pluginName: string;
45
- constructor(data: any);
46
- adapterXmlIn: (bpmnData: any) => {
34
+ };
35
+ declare const BpmnXmlAdapter: {
36
+ pluginName: string;
37
+ install(lf: any): void;
38
+ adapterXmlIn(bpmnData: any): {
47
39
  nodes: any[];
48
40
  edges: any[];
49
41
  };
50
- adapterXmlOut: (data: any) => string;
51
- }
42
+ adapterXmlOut(data: any): string;
43
+ };
52
44
  export { BpmnAdapter, BpmnXmlAdapter, };
53
45
  export default BpmnAdapter;
@@ -1,27 +1,3 @@
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
- var __assign = (this && this.__assign) || function () {
15
- __assign = Object.assign || function(t) {
16
- for (var s, i = 1, n = arguments.length; i < n; i++) {
17
- s = arguments[i];
18
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
19
- t[p] = s[p];
20
- }
21
- return t;
22
- };
23
- return __assign.apply(this, arguments);
24
- };
25
1
  var __read = (this && this.__read) || function (o, n) {
26
2
  var m = typeof Symbol === "function" && o[Symbol.iterator];
27
3
  if (!m) return o;
@@ -138,6 +114,8 @@ function convertLf2ProcessData(bpmnProcessData, data) {
138
114
  var sequenceFlow = data.edges.map(function (edge) {
139
115
  var _a, _b;
140
116
  var targetNode = nodeMap.get(edge.targetNodeId);
117
+ // @see https://github.com/didi/LogicFlow/issues/325
118
+ // 需要保证incomming在outgoing之前
141
119
  if (!targetNode['bpmn:incoming']) {
142
120
  targetNode['bpmn:incoming'] = edge.id;
143
121
  }
@@ -150,34 +128,6 @@ function convertLf2ProcessData(bpmnProcessData, data) {
150
128
  edge.id,
151
129
  ];
152
130
  }
153
- // const sourceNode = nodeMap.get(edge.sourceNodeId);
154
- // if (!sourceNode['bpmn:outgoing']) {
155
- // sourceNode['bpmn:outgoing'] = edge.id;
156
- // } else if (Array.isArray(sourceNode['bpmn:outgoing'])) {
157
- // sourceNode['bpmn:outgoing'].push(edge.id);
158
- // } else { // 字符串转数组
159
- // sourceNode['bpmn:outgoing'] = [
160
- // sourceNode['bpmn:outgoing'],
161
- // edge.id,
162
- // ];
163
- // }
164
- var edgeConfig = {
165
- '-id': edge.id,
166
- '-sourceRef': edge.sourceNodeId,
167
- '-targetRef': edge.targetNodeId,
168
- };
169
- if ((_a = edge.text) === null || _a === void 0 ? void 0 : _a.value) {
170
- edgeConfig['-name'] = (_b = edge.text) === null || _b === void 0 ? void 0 : _b.value;
171
- }
172
- if (edge.properties) {
173
- var properties = toXmlJson(edge.properties);
174
- Object.assign(edgeConfig, properties);
175
- }
176
- return edgeConfig;
177
- });
178
- // @see https://github.com/didi/LogicFlow/issues/325
179
- // 需要保证incoming在outgoing之前
180
- data.edges.forEach(function (edge) {
181
131
  var sourceNode = nodeMap.get(edge.sourceNodeId);
182
132
  if (!sourceNode['bpmn:outgoing']) {
183
133
  sourceNode['bpmn:outgoing'] = edge.id;
@@ -191,6 +141,19 @@ function convertLf2ProcessData(bpmnProcessData, data) {
191
141
  edge.id,
192
142
  ];
193
143
  }
144
+ var edgeConfig = {
145
+ '-id': edge.id,
146
+ '-sourceRef': edge.sourceNodeId,
147
+ '-targetRef': edge.targetNodeId,
148
+ };
149
+ if ((_a = edge.text) === null || _a === void 0 ? void 0 : _a.value) {
150
+ edgeConfig['-name'] = (_b = edge.text) === null || _b === void 0 ? void 0 : _b.value;
151
+ }
152
+ if (edge.properties) {
153
+ var properties = toXmlJson(edge.properties);
154
+ Object.assign(edgeConfig, properties);
155
+ }
156
+ return edgeConfig;
194
157
  });
195
158
  bpmnProcessData[BpmnElements.FLOW] = sequenceFlow;
196
159
  }
@@ -436,59 +399,53 @@ function getEdgeConfig(edgeValue, processValue) {
436
399
  }
437
400
  return edge;
438
401
  }
439
- var BpmnAdapter = /** @class */ (function () {
440
- function BpmnAdapter(_a) {
441
- var _this = this;
442
- var lf = _a.lf;
443
- this.adapterOut = function (data) {
444
- var bpmnProcessData = __assign({}, _this.processAttributes);
445
- convertLf2ProcessData(bpmnProcessData, data);
446
- var bpmnDiagramData = {
447
- '-id': 'BPMNPlane_1',
448
- '-bpmnElement': bpmnProcessData['-id'],
449
- };
450
- convertLf2DiagramData(bpmnDiagramData, data);
451
- var definitions = _this.definitionAttributes;
452
- definitions['bpmn:process'] = bpmnProcessData;
453
- definitions['bpmndi:BPMNDiagram'] = {
454
- '-id': 'BPMNDiagram_1',
455
- 'bpmndi:BPMNPlane': bpmnDiagramData,
456
- };
457
- var bpmnData = {
458
- 'bpmn:definitions': definitions,
459
- };
460
- return bpmnData;
461
- };
462
- this.adapterIn = function (bpmnData) {
463
- if (bpmnData) {
464
- return convertBpmn2LfData(bpmnData);
465
- }
466
- };
467
- lf.adapterIn = function (data) { return _this.adapterIn(data); };
468
- lf.adapterOut = function (data) { return _this.adapterOut(data); };
469
- this.processAttributes = {
470
- '-isExecutable': 'true',
402
+ var BpmnAdapter = {
403
+ pluginName: 'bpmn-adapter',
404
+ install: function (lf) {
405
+ lf.adapterIn = this.adapterIn;
406
+ lf.adapterOut = this.adapterOut;
407
+ },
408
+ shapeConfigMap: new Map(),
409
+ setCustomShape: function (key, val) {
410
+ this.shapeConfigMap.set(key, val);
411
+ },
412
+ adapterOut: function (data) {
413
+ var bpmnProcessData = {
471
414
  '-id': "Process_" + getBpmnId(),
415
+ '-isExecutable': 'false',
472
416
  };
473
- this.definitionAttributes = {
474
- '-id': "Definitions_" + getBpmnId(),
475
- '-xmlns:xsi': 'http://www.w3.org/2001/XMLSchema-instance',
476
- '-xmlns:bpmn': 'http://www.omg.org/spec/BPMN/20100524/MODEL',
477
- '-xmlns:bpmndi': 'http://www.omg.org/spec/BPMN/20100524/DI',
478
- '-xmlns:dc': 'http://www.omg.org/spec/DD/20100524/DC',
479
- '-xmlns:di': 'http://www.omg.org/spec/DD/20100524/DI',
480
- '-targetNamespace': 'http://logic-flow.org',
481
- '-exporter': 'logicflow',
482
- '-exporterVersion': '1.2.0',
417
+ convertLf2ProcessData(bpmnProcessData, data);
418
+ var bpmnDiagramData = {
419
+ '-id': 'BPMNPlane_1',
420
+ '-bpmnElement': bpmnProcessData['-id'],
483
421
  };
484
- }
485
- BpmnAdapter.prototype.setCustomShape = function (key, val) {
486
- BpmnAdapter.shapeConfigMap.set(key, val);
487
- };
488
- BpmnAdapter.pluginName = 'bpmn-adapter';
489
- BpmnAdapter.shapeConfigMap = new Map();
490
- return BpmnAdapter;
491
- }());
422
+ convertLf2DiagramData(bpmnDiagramData, data);
423
+ var bpmnData = {
424
+ 'bpmn:definitions': {
425
+ '-id': "Definitions_" + getBpmnId(),
426
+ '-xmlns:xsi': 'http://www.w3.org/2001/XMLSchema-instance',
427
+ '-xmlns:bpmn': 'http://www.omg.org/spec/BPMN/20100524/MODEL',
428
+ '-xmlns:bpmndi': 'http://www.omg.org/spec/BPMN/20100524/DI',
429
+ '-xmlns:dc': 'http://www.omg.org/spec/DD/20100524/DC',
430
+ '-xmlns:di': 'http://www.omg.org/spec/DD/20100524/DI',
431
+ '-targetNamespace': 'http://bpmn.io/schema/bpmn',
432
+ '-exporter': 'bpmn-js (https://demo.bpmn.io)',
433
+ '-exporterVersion': '7.3.0',
434
+ 'bpmn:process': bpmnProcessData,
435
+ 'bpmndi:BPMNDiagram': {
436
+ '-id': 'BPMNDiagram_1',
437
+ 'bpmndi:BPMNPlane': bpmnDiagramData,
438
+ },
439
+ },
440
+ };
441
+ return bpmnData;
442
+ },
443
+ adapterIn: function (bpmnData) {
444
+ if (bpmnData) {
445
+ return convertBpmn2LfData(bpmnData);
446
+ }
447
+ },
448
+ };
492
449
  BpmnAdapter.shapeConfigMap.set(BpmnElements.START, {
493
450
  width: StartEventConfig.width,
494
451
  height: StartEventConfig.height,
@@ -509,25 +466,20 @@ BpmnAdapter.shapeConfigMap.set(BpmnElements.USER, {
509
466
  width: UserTaskConfig.width,
510
467
  height: UserTaskConfig.height,
511
468
  });
512
- var BpmnXmlAdapter = /** @class */ (function (_super) {
513
- __extends(BpmnXmlAdapter, _super);
514
- function BpmnXmlAdapter(data) {
515
- var _this = _super.call(this, data) || this;
516
- _this.adapterXmlIn = function (bpmnData) {
517
- var json = lfXml2Json(bpmnData);
518
- return _this.adapterIn(json);
519
- };
520
- _this.adapterXmlOut = function (data) {
521
- var outData = _this.adapterOut(data);
522
- return lfJson2Xml(outData);
523
- };
524
- var lf = data.lf;
525
- lf.adapterIn = _this.adapterXmlIn;
526
- lf.adapterOut = _this.adapterXmlOut;
527
- return _this;
528
- }
529
- BpmnXmlAdapter.pluginName = 'bpmnXmlAdapter';
530
- return BpmnXmlAdapter;
531
- }(BpmnAdapter));
469
+ var BpmnXmlAdapter = {
470
+ pluginName: 'bpmnXmlAdapter',
471
+ install: function (lf) {
472
+ lf.adapterIn = this.adapterXmlIn;
473
+ lf.adapterOut = this.adapterXmlOut;
474
+ },
475
+ adapterXmlIn: function (bpmnData) {
476
+ var json = lfXml2Json(bpmnData);
477
+ return BpmnAdapter.adapterIn(json);
478
+ },
479
+ adapterXmlOut: function (data) {
480
+ var outData = BpmnAdapter.adapterOut(data);
481
+ return lfJson2Xml(outData);
482
+ },
483
+ };
532
484
  export { BpmnAdapter, BpmnXmlAdapter, };
533
485
  export default BpmnAdapter;
@@ -22,12 +22,10 @@ function toXml(v, name, ind, deep) {
22
22
  var hasChild = false;
23
23
  xml += addIndSpace(ind, deep) + "<" + name;
24
24
  for (var m in v) {
25
- if (m.charAt(0) == "-") {
25
+ if (m.charAt(0) == "-")
26
26
  xml += " " + m.substr(1) + "=\"" + v[m].toString() + "\"";
27
- }
28
- else {
27
+ else
29
28
  hasChild = true;
30
- }
31
29
  }
32
30
  xml += hasChild ? ">" : " />";
33
31
  if (hasChild) {