@logicflow/extension 0.7.16 → 1.0.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 (82) hide show
  1. package/cjs/NodeResize/Control/Control.js +4 -4
  2. package/cjs/NodeResize/Control/ControlGroup.js +4 -3
  3. package/cjs/NodeResize/Node/DiamondResize.js +18 -9
  4. package/cjs/NodeResize/Node/EllipseResize.js +23 -12
  5. package/cjs/NodeResize/Node/RectResize.js +11 -16
  6. package/cjs/bpmn/events/EndEvent.js +19 -10
  7. package/cjs/bpmn/events/StartEvent.js +4 -16
  8. package/cjs/bpmn/gateways/ExclusiveGateway.js +16 -14
  9. package/cjs/bpmn/index.js +1 -1
  10. package/cjs/bpmn/tasks/ServiceTask.js +20 -17
  11. package/cjs/bpmn/tasks/UserTask.js +20 -16
  12. package/cjs/bpmn-adapter/index.js +1 -1
  13. package/cjs/components/context-menu/index.js +3 -3
  14. package/cjs/components/menu/index.js +6 -6
  15. package/cjs/components/mini-map/index.js +2 -2
  16. package/cjs/components/selection-select/index.js +1 -1
  17. package/cjs/index.js +1 -0
  18. package/cjs/insert-node-in-polyline/index.js +3 -3
  19. package/cjs/materials/curved-edge/index.js +2 -1
  20. package/cjs/materials/group/GroupNode.js +1 -5
  21. package/cjs/materials/group/index.js +4 -4
  22. package/cjs/tools/auto-layout/index.js +8 -8
  23. package/cjs/tools/snapshot/index.js +3 -3
  24. package/es/NodeResize/Control/Control.d.ts +1 -3
  25. package/es/NodeResize/Control/Control.js +4 -4
  26. package/es/NodeResize/Control/ControlGroup.d.ts +1 -8
  27. package/es/NodeResize/Control/ControlGroup.js +4 -3
  28. package/es/NodeResize/Node/DiamondResize.d.ts +3 -2
  29. package/es/NodeResize/Node/DiamondResize.js +18 -9
  30. package/es/NodeResize/Node/EllipseResize.d.ts +4 -2
  31. package/es/NodeResize/Node/EllipseResize.js +23 -12
  32. package/es/NodeResize/Node/RectResize.d.ts +2 -1
  33. package/es/NodeResize/Node/RectResize.js +11 -16
  34. package/es/bpmn/events/EndEvent.d.ts +1 -0
  35. package/es/bpmn/events/EndEvent.js +19 -10
  36. package/es/bpmn/events/StartEvent.d.ts +1 -25
  37. package/es/bpmn/events/StartEvent.js +4 -16
  38. package/es/bpmn/gateways/ExclusiveGateway.js +16 -14
  39. package/es/bpmn/index.js +1 -1
  40. package/es/bpmn/tasks/ServiceTask.js +20 -17
  41. package/es/bpmn/tasks/UserTask.js +20 -16
  42. package/es/bpmn-adapter/index.js +1 -1
  43. package/es/components/context-menu/index.js +3 -3
  44. package/es/components/menu/index.js +6 -6
  45. package/es/components/mini-map/index.js +2 -2
  46. package/es/components/selection-select/index.js +1 -1
  47. package/es/index.js +1 -0
  48. package/es/insert-node-in-polyline/index.js +3 -3
  49. package/es/materials/curved-edge/index.js +2 -1
  50. package/es/materials/group/GroupNode.d.ts +0 -12
  51. package/es/materials/group/GroupNode.js +1 -5
  52. package/es/materials/group/index.js +4 -4
  53. package/es/tools/auto-layout/index.d.ts +4 -4
  54. package/es/tools/auto-layout/index.js +8 -8
  55. package/es/tools/snapshot/index.js +3 -3
  56. package/lib/AutoLayout.js +1 -1
  57. package/lib/BpmnAdapter.js +1 -1
  58. package/lib/BpmnElement.js +1 -1
  59. package/lib/ContextMenu.js +1 -1
  60. package/lib/Control.js +1 -1
  61. package/lib/CurvedEdge.js +1 -1
  62. package/lib/DndPanel.js +1 -1
  63. package/lib/FlowPath.js +1 -1
  64. package/lib/Group.js +1 -1
  65. package/lib/InsertNodeInPolyline.js +1 -1
  66. package/lib/Menu.js +1 -1
  67. package/lib/MiniMap.js +1 -1
  68. package/lib/NodeResize.js +1 -1
  69. package/lib/RectLabelNode.js +1 -1
  70. package/lib/SelectionSelect.js +1 -1
  71. package/lib/Snapshot.js +1 -1
  72. package/lib/TurboAdapter.js +1 -1
  73. package/package.json +2 -2
  74. package/types/NodeResize/Control/Control.d.ts +1 -3
  75. package/types/NodeResize/Control/ControlGroup.d.ts +1 -8
  76. package/types/NodeResize/Node/DiamondResize.d.ts +3 -2
  77. package/types/NodeResize/Node/EllipseResize.d.ts +4 -2
  78. package/types/NodeResize/Node/RectResize.d.ts +2 -1
  79. package/types/bpmn/events/EndEvent.d.ts +1 -0
  80. package/types/bpmn/events/StartEvent.d.ts +1 -25
  81. package/types/materials/group/GroupNode.d.ts +0 -12
  82. package/types/tools/auto-layout/index.d.ts +4 -4
@@ -11,6 +11,17 @@ var __extends = (this && this.__extends) || (function () {
11
11
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12
12
  };
13
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
+ };
14
25
  import { h, PolygonNode, PolygonNodeModel } from '@logicflow/core';
15
26
  import { getBpmnId } from '../getBpmnId';
16
27
  var ExclusiveGatewayModel = /** @class */ (function (_super) {
@@ -48,23 +59,14 @@ var ExclusiveGatewayView = /** @class */ (function (_super) {
48
59
  return _super !== null && _super.apply(this, arguments) || this;
49
60
  }
50
61
  ExclusiveGatewayView.prototype.getShape = function () {
51
- var attributes = _super.prototype.getAttributes.call(this);
52
- var x = attributes.x, y = attributes.y, fill = attributes.fill, stroke = attributes.stroke, strokeWidth = attributes.strokeWidth, width = attributes.width, height = attributes.height, points = attributes.points;
62
+ var model = this.props.model;
63
+ var x = model.x, y = model.y, width = model.width, height = model.height, points = model.points;
64
+ var style = model.getNodeStyle();
53
65
  return h('g', {
54
66
  transform: "matrix(1 0 0 1 " + (x - width / 2) + " " + (y - height / 2) + ")",
55
- }, h('polygon', {
56
- fill: fill,
57
- x: x,
67
+ }, h('polygon', __assign(__assign({}, style), { x: x,
58
68
  y: y,
59
- stroke: stroke,
60
- strokeWidth: strokeWidth,
61
- points: points,
62
- }), h('path', {
63
- fill: fill,
64
- stroke: stroke,
65
- strokeWidth: strokeWidth,
66
- d: 'm 16,15 7.42857142857143,9.714285714285715 -7.42857142857143,9.714285714285715 3.428571428571429,0 5.714285714285715,-7.464228571428572 5.714285714285715,7.464228571428572 3.428571428571429,0 -7.42857142857143,-9.714285714285715 7.42857142857143,-9.714285714285715 -3.428571428571429,0 -5.714285714285715,7.464228571428572 -5.714285714285715,-7.464228571428572 -3.428571428571429,0 z',
67
- }));
69
+ points: points })), h('path', __assign({ d: 'm 16,15 7.42857142857143,9.714285714285715 -7.42857142857143,9.714285714285715 3.428571428571429,0 5.714285714285715,-7.464228571428572 5.714285714285715,7.464228571428572 3.428571428571429,0 -7.42857142857143,-9.714285714285715 7.42857142857143,-9.714285714285715 -3.428571428571429,0 -5.714285714285715,7.464228571428572 -5.714285714285715,-7.464228571428572 -3.428571428571429,0 z' }, style)));
68
70
  };
69
71
  ExclusiveGatewayView.extendKey = 'ExclusiveGatewayNode';
70
72
  return ExclusiveGatewayView;
package/es/bpmn/index.js CHANGED
@@ -16,7 +16,7 @@ var BpmnElement = /** @class */ (function () {
16
16
  lf.register(ExclusiveGateway);
17
17
  lf.register(UserTask);
18
18
  lf.register(ServiceTask);
19
- // 支持自定义bpmn元素的连线
19
+ // 支持自定义bpmn元素的边
20
20
  if (!lf.options.customBpmnEdge) {
21
21
  lf.register(SequenceFlow);
22
22
  lf.setDefaultEdgeType('bpmn:sequenceFlow');
@@ -11,6 +11,17 @@ var __extends = (this && this.__extends) || (function () {
11
11
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12
12
  };
13
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
+ };
14
25
  import { h, RectNodeModel, RectNode } from '@logicflow/core';
15
26
  import { getBpmnId } from '../getBpmnId';
16
27
  var ServiceTaskModel = /** @class */ (function (_super) {
@@ -32,8 +43,9 @@ var ServiceTaskView = /** @class */ (function (_super) {
32
43
  return _super !== null && _super.apply(this, arguments) || this;
33
44
  }
34
45
  ServiceTaskView.prototype.getLabelShape = function () {
35
- var attributes = _super.prototype.getAttributes.call(this);
36
- var x = attributes.x, y = attributes.y, width = attributes.width, height = attributes.height, stroke = attributes.stroke;
46
+ var model = this.props.model;
47
+ var x = model.x, y = model.y, width = model.width, height = model.height;
48
+ var style = model.getNodeStyle();
37
49
  return h('svg', {
38
50
  x: x - width / 2 + 5,
39
51
  y: y - height / 2 + 5,
@@ -41,26 +53,17 @@ var ServiceTaskView = /** @class */ (function (_super) {
41
53
  height: 30,
42
54
  viewBox: '0 0 1274 1024',
43
55
  }, h('path', {
44
- fill: stroke,
56
+ fill: style.stroke,
45
57
  d: 'M882.527918 434.149934c-2.234901-5.303796-7.311523-8.853645-13.059434-9.138124l-61.390185-3.009544c-6.635117-20.973684-15.521508-41.175795-26.513864-60.282968l42.051745-47.743374c4.308119-4.889357 4.955872-12.004405 1.602498-17.59268-46.384423-77.30362-103.969956-101.422947-106.400309-102.410438-5.332449-2.170432-11.432377-1.090844-15.693424 2.77009L654.674467 240.664222c-17.004279-8.654101-35.092239-15.756869-53.995775-21.210068l-3.26537-66.490344c-0.280386-5.747911-3.833305-10.824533-9.134031-13.059434-1.683339-0.709151-30.193673-12.391215-76.866668-12.051477-46.672996-0.339738-75.18333 11.342326-76.866668 12.051477-5.300726 2.234901-8.853645 7.311523-9.134031 13.059434l-3.26537 66.490344c-18.903535 5.453199-36.991496 12.555967-53.995775 21.210068l-48.450479-43.922349c-4.261047-3.860934-10.360975-4.940522-15.693424-2.77009-2.430352 0.98749-60.015885 25.106818-106.400309 102.410438-3.353374 5.588275-2.705622 12.703323 1.602498 17.59268l42.051745 47.743374c-10.992355 19.107173-19.878746 39.309284-26.513864 60.282968l-61.390185 3.009544c-5.747911 0.284479-10.824533 3.834328-13.059434 9.138124-1.01512 2.415003-24.687262 60.190871-2.822278 147.651828 1.583055 6.324032 7.072069 10.893094 13.57518 11.308557 5.892197 0.37146 11.751648 0.523933 17.419741 0.667196 14.498202 0.372483 28.193109 0.723477 40.908712 4.63353 4.212952 1.294482 6.435573 8.270361 9.349949 18.763342 1.287319 4.640694 2.617617 9.43693 4.484128 14.010085 1.794879 4.393054 3.75758 8.570189 5.66093 12.607132 1.302669 2.765997 2.529613 5.380544 3.689019 8.018627 2.986007 6.803963 2.682086 9.773598 2.578732 10.349719-3.061732 3.672646-6.391571 7.238868-9.91379 11.015891-1.810229 1.943258-3.680832 3.949962-5.523807 5.980201l-22.560832 24.8909c-3.865028 4.261047-4.940522 10.365068-2.774183 15.693424 0.991584 2.426259 25.102724 60.011792 102.414531 106.400309 5.588275 3.353374 12.703323 2.701528 17.591657-1.603521l23.476691-20.682042c2.346441-2.061962 4.64888-4.336772 6.875594-6.534833 9.05319-8.93858 14.018272-12.95608 17.73185-11.576663 3.305279 1.222851 6.907317 3.166109 10.720156 5.228071 3.325745 1.794879 6.764054 3.650133 10.465352 5.288446 6.016017 2.662643 12.120039 4.688789 18.019399 6.65149 6.827499 2.266623 13.279445 4.409426 18.819624 7.275707 1.518586 0.782829 1.926886 0.994654 2.358721 7.830339 0.726547 11.496845 1.25048 23.276123 1.753947 34.672684 0.264013 5.900384 0.528026 11.803837 0.815575 17.700127 0.284479 5.743818 3.833305 10.82044 9.138124 13.05534 1.654686 0.698918 29.371958 12.063757 74.869175 12.063757 0.328481 0 3.65832 0 3.986801 0 45.497217 0 73.214489-11.364839 74.869175-12.063757 5.304819-2.234901 8.853645-7.311523 9.138124-13.05534 0.287549-5.89629 0.551562-11.799744 0.815575-17.700127 0.503467-11.396561 1.027399-23.175839 1.753947-34.672684 0.431835-6.835685 0.840134-7.04751 2.358721-7.830339 5.54018-2.866281 11.992125-5.009084 18.819624-7.275707 5.89936-1.962701 12.003382-3.988848 18.019399-6.65149 3.701299-1.638313 7.139607-3.493567 10.465352-5.288446 3.812839-2.061962 7.414877-4.00522 10.720156-5.228071 3.713578-1.379417 8.67866 2.638083 17.73185 11.576663 2.226714 2.198062 4.529153 4.472871 6.875594 6.534833l23.476691 20.682042c4.888334 4.305049 12.003382 4.956895 17.591657 1.603521 77.311807-46.388517 101.422947-103.97405 102.414531-106.400309 2.166339-5.328355 1.090844-11.432377-2.774183-15.693424l-22.560832-24.8909c-1.842974-2.030239-3.713578-4.036943-5.523807-5.980201-3.52222-3.777023-6.852058-7.343245-9.91379-11.015891-0.103354-0.576121-0.407276-3.545756 2.578732-10.349719 1.159406-2.638083 2.38635-5.252631 3.689019-8.018627 1.90335-4.036943 3.866051-8.214079 5.66093-12.607132 1.866511-4.573155 3.196809-9.369392 4.484128-14.010085 2.914376-10.492982 5.136997-17.46886 9.349949-18.763342 12.715603-3.910053 26.41051-4.261047 40.908712-4.63353 5.668093-0.143263 11.527544-0.295735 17.419741-0.667196 6.503111-0.415462 11.992125-4.984524 13.57518-11.308557C907.21518 494.340805 883.543038 436.564937 882.527918 434.149934zM643.49894 643.761929c-35.280528 35.280528-82.191954 54.711066-132.086317 54.711066s-96.806813-19.430538-132.086317-54.711066c-35.280528-35.279504-54.711066-82.191954-54.711066-132.086317 0-49.894364 19.430538-96.80272 54.711066-132.082224 35.283598-35.284621 82.191954-54.711066 132.086317-54.711066s96.80579 19.426445 132.086317 54.711066c35.279504 35.279504 54.711066 82.187861 54.711066 132.082224C698.210006 561.569976 678.782537 608.482425 643.49894 643.761929z',
46
58
  }));
47
59
  };
48
60
  ServiceTaskView.prototype.getShape = function () {
49
- var attributes = _super.prototype.getAttributes.call(this);
50
- var x = attributes.x, y = attributes.y, width = attributes.width, height = attributes.height, fill = attributes.fill, stroke = attributes.stroke, strokeWidth = attributes.strokeWidth, radius = attributes.radius;
51
- // todo: 将basic-shape对外暴露,在这里可以直接用。现在纯手写有点麻烦。
61
+ var model = this.props.model;
62
+ var x = model.x, y = model.y, width = model.width, height = model.height, radius = model.radius;
63
+ var style = model.getNodeStyle();
52
64
  return h('g', {}, [
53
- h('rect', {
54
- x: x - width / 2,
55
- y: y - height / 2,
56
- rx: radius,
57
- ry: radius,
58
- fill: fill,
59
- stroke: stroke,
60
- strokeWidth: strokeWidth,
61
- width: width,
62
- height: height,
63
- }),
65
+ h('rect', __assign({ x: x - width / 2, y: y - height / 2, rx: radius, ry: radius, width: width,
66
+ height: height }, style)),
64
67
  this.getLabelShape(),
65
68
  ]);
66
69
  };
@@ -11,6 +11,17 @@ var __extends = (this && this.__extends) || (function () {
11
11
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12
12
  };
13
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
+ };
14
25
  import { h, RectNode, RectNodeModel } from '@logicflow/core';
15
26
  import { getBpmnId } from '../getBpmnId';
16
27
  var UserTaskModel = /** @class */ (function (_super) {
@@ -32,8 +43,9 @@ var UserTaskView = /** @class */ (function (_super) {
32
43
  return _super !== null && _super.apply(this, arguments) || this;
33
44
  }
34
45
  UserTaskView.prototype.getLabelShape = function () {
35
- var attributes = _super.prototype.getAttributes.call(this);
36
- var x = attributes.x, y = attributes.y, width = attributes.width, height = attributes.height, stroke = attributes.stroke;
46
+ var model = this.props.model;
47
+ var x = model.x, y = model.y, width = model.width, height = model.height;
48
+ var style = model.getNodeStyle();
37
49
  return h('svg', {
38
50
  x: x - width / 2 + 5,
39
51
  y: y - height / 2 + 5,
@@ -41,26 +53,18 @@ var UserTaskView = /** @class */ (function (_super) {
41
53
  height: 25,
42
54
  viewBox: '0 0 1274 1024',
43
55
  }, h('path', {
44
- fill: stroke,
56
+ fill: style.stroke,
45
57
  d: 'M655.807326 287.35973m-223.989415 0a218.879 218.879 0 1 0 447.978829 0 218.879 218.879 0 1 0-447.978829 0ZM1039.955839 895.482975c-0.490184-212.177424-172.287821-384.030443-384.148513-384.030443-211.862739 0-383.660376 171.85302-384.15056 384.030443L1039.955839 895.482975z',
46
58
  }));
47
59
  };
48
60
  UserTaskView.prototype.getShape = function () {
49
- var attributes = _super.prototype.getAttributes.call(this);
50
- var x = attributes.x, y = attributes.y, width = attributes.width, height = attributes.height, fill = attributes.fill, stroke = attributes.stroke, strokeWidth = attributes.strokeWidth, radius = attributes.radius;
61
+ var model = this.props.model;
62
+ var x = model.x, y = model.y, width = model.width, height = model.height, radius = model.radius;
63
+ var style = model.getNodeStyle();
51
64
  // todo: 将basic-shape对外暴露,在这里可以直接用。现在纯手写有点麻烦。
52
65
  return h('g', {}, [
53
- h('rect', {
54
- x: x - width / 2,
55
- y: y - height / 2,
56
- rx: radius,
57
- ry: radius,
58
- fill: fill,
59
- stroke: stroke,
60
- strokeWidth: strokeWidth,
61
- width: width,
62
- height: height,
63
- }),
66
+ h('rect', __assign(__assign({}, style), { x: x - width / 2, y: y - height / 2, rx: radius, ry: radius, width: width,
67
+ height: height })),
64
68
  this.getLabelShape(),
65
69
  ]);
66
70
  };
@@ -357,7 +357,7 @@ function getEdgeConfig(edgeValue, processValue) {
357
357
  var textVal = processValue['-name'];
358
358
  if (textVal) {
359
359
  var textBounds = edgeValue['bpmndi:BPMNLabel']['dc:Bounds'];
360
- // 如果连线文本换行,则其偏移量应该是最长一行的位置
360
+ // 如果边文本换行,则其偏移量应该是最长一行的位置
361
361
  var textLength_1 = 0;
362
362
  textVal.split('\n').forEach(function (textSpan) {
363
363
  if (textLength_1 < textSpan.length) {
@@ -97,7 +97,7 @@ var ContextMenu = /** @class */ (function () {
97
97
  x = data.x + Model.width / 2;
98
98
  y = data.y - Model.height / 2;
99
99
  }
100
- return this.lf.graphModel.transformMatrix.CanvasPointToHtmlPoint([x, y]);
100
+ return this.lf.graphModel.transformModel.CanvasPointToHtmlPoint([x, y]);
101
101
  };
102
102
  ContextMenu.prototype.createContextMenu = function () {
103
103
  var _this = this;
@@ -145,7 +145,7 @@ var ContextMenu = /** @class */ (function () {
145
145
  if (y === undefined) {
146
146
  y = node.y;
147
147
  }
148
- var nodeModel = this.lf.getNodeModel(node.sourceId);
148
+ var nodeModel = this.lf.getNodeModelById(node.sourceId);
149
149
  var leftTopX = node.x - nodeModel.width + NEXT_X_DISTANCE;
150
150
  var leftTopY = y - node.y / 2 - 20;
151
151
  var rightBottomX = node.x + nodeModel.width + NEXT_X_DISTANCE;
@@ -174,7 +174,7 @@ var ContextMenu = /** @class */ (function () {
174
174
  y: newNode.y,
175
175
  };
176
176
  }
177
- this.lf.createEdge({
177
+ this.lf.addEdge({
178
178
  sourceNodeId: node.sourceId,
179
179
  targetNodeId: newNode.id,
180
180
  startPoint: startPoint,
@@ -55,7 +55,7 @@ var Menu = /** @class */ (function () {
55
55
  {
56
56
  text: '编辑文本',
57
57
  callback: function (node) {
58
- _this.lf.graphModel.setTextEditable(node.id);
58
+ _this.lf.graphModel.editText(node.id);
59
59
  },
60
60
  },
61
61
  {
@@ -76,7 +76,7 @@ var Menu = /** @class */ (function () {
76
76
  {
77
77
  text: '编辑文本',
78
78
  callback: function (edge) {
79
- _this.lf.graphModel.setTextEditable(edge.id);
79
+ _this.lf.graphModel.editText(edge.id);
80
80
  },
81
81
  },
82
82
  ];
@@ -128,7 +128,7 @@ var Menu = /** @class */ (function () {
128
128
  var data = _a.data, position = _a.position;
129
129
  var _b = position.domOverlayPosition, x = _b.x, y = _b.y;
130
130
  var id = data.id;
131
- var model = _this.lf.graphModel.getNodeModel(id);
131
+ var model = _this.lf.graphModel.getNodeModelById(id);
132
132
  var menuList = [];
133
133
  var typeMenus = _this.menuTypeMap.get(model.type);
134
134
  // 如果单个节点自定义了节点,以单个节点自定义为准
@@ -148,14 +148,14 @@ var Menu = /** @class */ (function () {
148
148
  var data = _a.data, position = _a.position;
149
149
  var _b = position.domOverlayPosition, x = _b.x, y = _b.y;
150
150
  var id = data.id;
151
- var model = _this.lf.graphModel.getEdgeModel(id);
151
+ var model = _this.lf.graphModel.getEdgeModelById(id);
152
152
  var menuList = [];
153
153
  var typeMenus = _this.menuTypeMap.get(model.type);
154
- // 如果单个节点自定义了连线
154
+ // 如果单个节点自定义了边
155
155
  if (model && model.menu && Array.isArray(model.menu)) {
156
156
  menuList = model.menu;
157
157
  }
158
- else if (typeMenus) { // 如果定义当前连线类型的元素
158
+ else if (typeMenus) { // 如果定义当前边类型的元素
159
159
  menuList = typeMenus;
160
160
  }
161
161
  else { // 最后取全局默认
@@ -39,8 +39,8 @@ var MiniMap = {
39
39
  __disabledPlugins: ['minimap', 'control', 'selection-select'],
40
40
  install: function (lf, LogicFlow) {
41
41
  MiniMap.__lf = lf;
42
- MiniMap.__miniMapWidth = lf.width;
43
- MiniMap.__miniMapHeight = (lf.width * 220) / 150;
42
+ MiniMap.__miniMapWidth = lf.graphModel.width;
43
+ MiniMap.__miniMapHeight = (lf.graphModel.width * 220) / 150;
44
44
  MiniMap.__LogicFlow = LogicFlow;
45
45
  this.__init();
46
46
  // 避免多次install的时候, _isShow状态被修改了
@@ -36,7 +36,7 @@ var SelectionSelect = /** @class */ (function () {
36
36
  var rt = [Math.max(x, x1), Math.max(y, y1)];
37
37
  var elements = _this.lf.getAreaElement(lt, rt);
38
38
  elements.forEach(function (element) {
39
- _this.lf.select(element.id, true);
39
+ _this.lf.selectElementById(element.id, true);
40
40
  });
41
41
  _this.lf.emit('selection:selected', elements);
42
42
  };
package/es/index.js CHANGED
@@ -15,3 +15,4 @@ export * from './materials/group';
15
15
  export * from './NodeResize';
16
16
  export * from './tools/flow-path';
17
17
  export * from './tools/auto-layout';
18
+ // export * from './materials/node-selection';
@@ -57,19 +57,19 @@ var InsertNodeInPolyline = {
57
57
  },
58
58
  insetNode: function (nodeData) {
59
59
  var edges = this._lf.graphModel.edges;
60
- var nodeModel = this._lf.getNodeModel(nodeData.id);
60
+ var nodeModel = this._lf.getNodeModelById(nodeData.id);
61
61
  for (var i = 0; i < edges.length; i++) {
62
62
  // eslint-disable-next-line max-len
63
63
  var _a = isNodeInSegement(nodeModel, edges[i]), crossIndex = _a.crossIndex, crossPoints = _a.crossPoints;
64
64
  if (crossIndex >= 0) {
65
65
  var _b = edges[i], sourceNodeId = _b.sourceNodeId, targetNodeId = _b.targetNodeId, id = _b.id, type = _b.type, pointsList = _b.pointsList;
66
- this._lf.createEdge({
66
+ this._lf.addEdge({
67
67
  type: type,
68
68
  sourceNodeId: sourceNodeId,
69
69
  targetNodeId: nodeData.id,
70
70
  pointsList: __spread(pointsList.slice(0, crossIndex), [crossPoints.startCrossPoint]),
71
71
  });
72
- this._lf.createEdge({
72
+ this._lf.addEdge({
73
73
  type: type,
74
74
  sourceNodeId: nodeData.id,
75
75
  targetNodeId: targetNodeId,
@@ -34,7 +34,8 @@ var CurvedEdgeView = /** @class */ (function (_super) {
34
34
  return _super !== null && _super.apply(this, arguments) || this;
35
35
  }
36
36
  CurvedEdgeView.prototype.getEdge = function () {
37
- var _a = this.getAttributes(), points = _a.points, strokeWidth = _a.strokeWidth, stroke = _a.stroke, strokeDashArray = _a.strokeDashArray;
37
+ var _a = this.props.model.getEdgeStyle(), strokeWidth = _a.strokeWidth, stroke = _a.stroke, strokeDashArray = _a.strokeDashArray;
38
+ var points = this.props.model.points;
38
39
  var points2 = points.split(' ').map(function (p) { return p.split(',').map(function (a) { return Number(a); }); });
39
40
  var _b = __read(points2[0], 2), startX = _b[0], startY = _b[1];
40
41
  var d = "M" + startX + " " + startY;
@@ -24,18 +24,6 @@ declare class GroupNode extends RectNode {
24
24
  * 重新toFront,阻止其置顶
25
25
  */
26
26
  toFront(): void;
27
- getShapeStyle(): {
28
- radius: number;
29
- width: number;
30
- height: number;
31
- fill: string;
32
- fillOpacity?: number;
33
- strokeWidth?: number;
34
- stroke: string;
35
- strokeOpacity?: number;
36
- opacity?: number;
37
- outlineColor?: string;
38
- };
39
27
  }
40
28
  declare const _default: {
41
29
  type: string;
@@ -46,6 +46,7 @@ var GroupNodeModel = /** @class */ (function (_super) {
46
46
  this.height = 200;
47
47
  this.strokeWidth = 1;
48
48
  this.zIndex = 0;
49
+ this.radius = 0;
49
50
  };
50
51
  /**
51
52
  * 设置是否允许子节点被拖动移除分组
@@ -91,11 +92,6 @@ var GroupNode = /** @class */ (function (_super) {
91
92
  * 重新toFront,阻止其置顶
92
93
  */
93
94
  GroupNode.prototype.toFront = function () { };
94
- GroupNode.prototype.getShapeStyle = function () {
95
- var shape = _super.prototype.getShapeStyle.call(this);
96
- shape.radius = 0;
97
- return shape;
98
- };
99
95
  return GroupNode;
100
96
  }(RectNode));
101
97
  export default {
@@ -29,13 +29,13 @@ var Group = /** @class */ (function () {
29
29
  // 如果这个节点之前已经在group中了,则将其从之前的group中移除
30
30
  var preGroupId = _this.nodeGroupMap.get(data.id);
31
31
  if (preGroupId) {
32
- var preGroup = _this.lf.getNodeModel(preGroupId);
32
+ var preGroup = _this.lf.getNodeModelById(preGroupId);
33
33
  preGroup.removeChild(data.id);
34
34
  _this.nodeGroupMap.delete(data.id);
35
35
  preGroup.setAllowAppendChild(false);
36
36
  }
37
37
  // 然后再判断这个节点是否在某个group中,如果在,则将其添加到对应的group中
38
- var bounds = _this.lf.getNodeModel(data.id).getBounds();
38
+ var bounds = _this.lf.getNodeModelById(data.id).getBounds();
39
39
  var group = _this.getGroup(bounds);
40
40
  if (group && data.id !== group.id) {
41
41
  group.addChild(data.id);
@@ -49,7 +49,7 @@ var Group = /** @class */ (function () {
49
49
  _this.activeGroup.setAllowAppendChild(false);
50
50
  _this.activeGroup = undefined;
51
51
  }
52
- var bounds = _this.lf.getNodeModel(data.id).getBounds();
52
+ var bounds = _this.lf.getNodeModelById(data.id).getBounds();
53
53
  _this.activeGroup = _this.getGroup(bounds);
54
54
  if (_this.activeGroup && _this.activeGroup.id !== data.id) {
55
55
  _this.activeGroup.setAllowAppendChild(true);
@@ -62,7 +62,7 @@ var Group = /** @class */ (function () {
62
62
  lf.graphModel.moveNodes(__spread(model.children), deltaX, deltaY, true);
63
63
  return true;
64
64
  }
65
- var groupModel = lf.getNodeModel(_this.nodeGroupMap.get(model.id));
65
+ var groupModel = lf.getNodeModelById(_this.nodeGroupMap.get(model.id));
66
66
  if (groupModel && groupModel.isRestrict) { // 如果移动的节点存在分组中,且这个分组禁止子节点移出去。
67
67
  var _a = model.getBounds(), x1 = _a.x1, y1 = _a.y1, x2 = _a.x2, y2 = _a.y2;
68
68
  var r = groupModel.isInRange({
@@ -15,13 +15,13 @@ declare class AutoLayout {
15
15
  layout(data: any, path: any): void;
16
16
  private setNodePosition;
17
17
  /**
18
- * 1. 处理连线上的文本
19
- * 2. 主干节点之间直接的连线
18
+ * 1. 处理边上的文本
19
+ * 2. 主干节点之间直接的边
20
20
  * 3. 一个节点被多个连接作为目标节点,合理分配锚点位置。
21
21
  */
22
22
  private getEdgeDataPoints;
23
23
  /**
24
- * 获取连线的连接节点相对位置。
24
+ * 获取边的连接节点相对位置。
25
25
  * source一定在target左边。
26
26
  * 1. 如果source和target在同一x, y坐标内容。
27
27
  * 2. 如果source在target左上方。
@@ -29,7 +29,7 @@ declare class AutoLayout {
29
29
  */
30
30
  private getRelativePosition;
31
31
  /**
32
- * 获取连线节点图形的宽高。
32
+ * 获取边节点图形的宽高。
33
33
  */
34
34
  private getShape;
35
35
  private formatData;
@@ -34,7 +34,7 @@ var AutoLayout = /** @class */ (function () {
34
34
  return _this.layout(data, path);
35
35
  };
36
36
  }
37
- // 1) 将所有节点和连线的坐标删除。节点上的文本改成偏移量。
37
+ // 1) 将所有节点和边的坐标删除。节点上的文本改成偏移量。
38
38
  // 2) 找到长度最长的路径,作为基准路径。
39
39
  // 3) 依次计算
40
40
  // 拿到最长的路径。
@@ -94,9 +94,9 @@ var AutoLayout = /** @class */ (function () {
94
94
  _this.setNodePosition(nextInfo.nodeId, nodeMap, newGraphData, xLevel + 1, nextYLevel + 1);
95
95
  }
96
96
  else {
97
- // todo: 如果下一个节点是已经定位的,则需要考虑连线的规避
97
+ // todo: 如果下一个节点是已经定位的,则需要考虑边的规避
98
98
  }
99
- // 设置连接到下一个节点的连线
99
+ // 设置连接到下一个节点的边
100
100
  // 1) 起始位置为source节点的下方,结束位置为target节点左边。
101
101
  // 2) 计算折线
102
102
  newGraphData.edges.push(__assign({ id: nextInfo.edgeId, type: nextInfo.edgeType, sourceNodeId: nodeId, targetNodeId: nextInfo.nodeId, properties: nextInfo.properties, text: nextInfo.text }, _this.getEdgeDataPoints(nodeId, nextInfo.nodeId)));
@@ -105,8 +105,8 @@ var AutoLayout = /** @class */ (function () {
105
105
  return nodeData;
106
106
  };
107
107
  /**
108
- * 1. 处理连线上的文本
109
- * 2. 主干节点之间直接的连线
108
+ * 1. 处理边上的文本
109
+ * 2. 主干节点之间直接的边
110
110
  * 3. 一个节点被多个连接作为目标节点,合理分配锚点位置。
111
111
  */
112
112
  AutoLayout.prototype.getEdgeDataPoints = function (sourceNodeId, targetNodeId) {
@@ -145,7 +145,7 @@ var AutoLayout = /** @class */ (function () {
145
145
  };
146
146
  };
147
147
  /**
148
- * 获取连线的连接节点相对位置。
148
+ * 获取边的连接节点相对位置。
149
149
  * source一定在target左边。
150
150
  * 1. 如果source和target在同一x, y坐标内容。
151
151
  * 2. 如果source在target左上方。
@@ -167,10 +167,10 @@ var AutoLayout = /** @class */ (function () {
167
167
  return postionType;
168
168
  };
169
169
  /**
170
- * 获取连线节点图形的宽高。
170
+ * 获取边节点图形的宽高。
171
171
  */
172
172
  AutoLayout.prototype.getShape = function (nodeId) {
173
- var nodeModel = this.lf.getNodeModel(nodeId);
173
+ var nodeModel = this.lf.getNodeModelById(nodeId);
174
174
  return {
175
175
  height: nodeModel.height,
176
176
  width: nodeModel.width,
@@ -122,7 +122,7 @@ var Snapshot = {
122
122
  if (childLength) {
123
123
  for (var i = 0; i < childLength; i++) {
124
124
  var lfLayer = graph.childNodes[i];
125
- // 只保留包含节点和连线的基础图层进行下载,其他图层删除
125
+ // 只保留包含节点和边的基础图层进行下载,其他图层删除
126
126
  var layerClassList = lfLayer.classList && Array.from(lfLayer.classList);
127
127
  if (layerClassList && layerClassList.indexOf('lf-base') < 0) {
128
128
  graph.removeChild(graph.childNodes[i]);
@@ -151,8 +151,8 @@ var Snapshot = {
151
151
  var base = document.getElementsByClassName('lf-base')[0];
152
152
  var bbox = base.getBoundingClientRect();
153
153
  var graphModel = this.lf.graphModel;
154
- var transformMatrix = graphModel.transformMatrix;
155
- var SCALE_X = transformMatrix.SCALE_X, SCALE_Y = transformMatrix.SCALE_Y;
154
+ var transformModel = graphModel.transformModel;
155
+ var SCALE_X = transformModel.SCALE_X, SCALE_Y = transformModel.SCALE_Y;
156
156
  var bboxWidth = Math.ceil(bbox.width / SCALE_X);
157
157
  var bboxHeight = Math.ceil(bbox.height / SCALE_Y);
158
158
  // width,height 值加40,保证图形不会紧贴着下载图片的右边和下边