@logicflow/extension 1.0.7 → 1.1.0-alpha.3

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 (87) hide show
  1. package/cjs/NodeResize/Control/Control.js +2 -1
  2. package/cjs/NodeResize/Control/Util.js +1 -0
  3. package/cjs/NodeResize/Node/EllipseResize.js +1 -17
  4. package/cjs/NodeResize/Node/HtmlResize.js +72 -0
  5. package/cjs/NodeResize/index.js +7 -1
  6. package/cjs/bpmn/index.js +1 -1
  7. package/cjs/bpmn-adapter/index.js +1 -1
  8. package/cjs/components/context-menu/index.js +38 -23
  9. package/cjs/components/control/index.js +0 -14
  10. package/cjs/components/dnd-panel/index.js +9 -6
  11. package/cjs/components/menu/index.js +7 -7
  12. package/cjs/components/mini-map/index.js +159 -156
  13. package/cjs/components/selection-select/index.js +27 -14
  14. package/cjs/insert-node-in-polyline/index.js +1 -1
  15. package/cjs/materials/curved-edge/index.js +1 -1
  16. package/cjs/materials/group/GroupNode.js +66 -20
  17. package/cjs/materials/group/index.js +28 -9
  18. package/cjs/style/index.css +3 -2
  19. package/cjs/tools/flow-path/index.js +1 -1
  20. package/cjs/turbo-adapter/index.js +1 -1
  21. package/es/NodeResize/Control/Control.js +2 -1
  22. package/es/NodeResize/Control/Util.d.ts +1 -0
  23. package/es/NodeResize/Control/Util.js +1 -0
  24. package/es/NodeResize/Node/EllipseResize.js +1 -17
  25. package/es/NodeResize/Node/HtmlResize.d.ts +20 -0
  26. package/es/NodeResize/Node/HtmlResize.js +70 -0
  27. package/es/NodeResize/index.js +7 -1
  28. package/es/bpmn/index.js +1 -1
  29. package/es/bpmn-adapter/index.js +1 -1
  30. package/es/components/context-menu/index.d.ts +11 -1
  31. package/es/components/context-menu/index.js +38 -23
  32. package/es/components/control/index.d.ts +4 -5
  33. package/es/components/control/index.js +0 -14
  34. package/es/components/dnd-panel/index.d.ts +1 -0
  35. package/es/components/dnd-panel/index.js +9 -6
  36. package/es/components/menu/index.d.ts +2 -2
  37. package/es/components/menu/index.js +7 -7
  38. package/es/components/mini-map/index.d.ts +73 -2
  39. package/es/components/mini-map/index.js +159 -156
  40. package/es/components/selection-select/index.d.ts +8 -0
  41. package/es/components/selection-select/index.js +27 -14
  42. package/es/insert-node-in-polyline/index.js +1 -1
  43. package/es/materials/curved-edge/index.js +1 -1
  44. package/es/materials/group/GroupNode.d.ts +24 -9
  45. package/es/materials/group/GroupNode.js +67 -21
  46. package/es/materials/group/index.d.ts +3 -1
  47. package/es/materials/group/index.js +27 -9
  48. package/es/style/index.css +3 -2
  49. package/es/tools/flow-path/index.js +1 -1
  50. package/es/turbo-adapter/index.js +1 -1
  51. package/lib/AutoLayout.js +1 -1
  52. package/lib/BpmnAdapter.js +1 -1
  53. package/lib/BpmnElement.js +1 -1
  54. package/lib/ContextMenu.js +1 -1
  55. package/lib/Control.js +1 -1
  56. package/lib/CurvedEdge.js +1 -1
  57. package/lib/DndPanel.js +1 -1
  58. package/lib/FlowPath.js +1 -1
  59. package/lib/Group.js +1 -1
  60. package/lib/InsertNodeInPolyline.js +1 -1
  61. package/lib/Menu.js +1 -1
  62. package/lib/MiniMap.js +1 -1
  63. package/lib/NodeResize.js +1 -1
  64. package/lib/RectLabelNode.js +1 -1
  65. package/lib/SelectionSelect.js +1 -1
  66. package/lib/Snapshot.js +1 -1
  67. package/lib/TurboAdapter.js +1 -1
  68. package/lib/lfJson2Xml.js +1 -1
  69. package/lib/lfXml2Json.js +1 -1
  70. package/lib/style/index.css +3 -2
  71. package/package.json +2 -2
  72. package/types/NodeResize/Control/Util.d.ts +1 -0
  73. package/types/NodeResize/Node/HtmlResize.d.ts +20 -0
  74. package/types/components/context-menu/index.d.ts +11 -1
  75. package/types/components/control/index.d.ts +4 -5
  76. package/types/components/dnd-panel/index.d.ts +1 -0
  77. package/types/components/menu/index.d.ts +2 -2
  78. package/types/components/mini-map/index.d.ts +73 -2
  79. package/types/components/selection-select/index.d.ts +8 -0
  80. package/types/materials/group/GroupNode.d.ts +24 -9
  81. package/types/materials/group/index.d.ts +3 -1
  82. package/cjs/NodeResize/BasicShape/Ellipse.js +0 -21
  83. package/cjs/curved.js +0 -0
  84. package/es/NodeResize/BasicShape/Ellipse.d.ts +0 -2
  85. package/es/NodeResize/BasicShape/Ellipse.js +0 -18
  86. package/es/curved.d.ts +0 -0
  87. package/es/curved.js +0 -0
@@ -270,7 +270,8 @@ var Control = /** @class */ (function (_super) {
270
270
  _this.onDraging = function (_a) {
271
271
  var deltaX = _a.deltaX, deltaY = _a.deltaY;
272
272
  var modelType = _this.nodeModel.modelType;
273
- if (modelType === Util_1.ModelType.RECT_NODE) {
273
+ // html和矩形的计算方式是一样的,共用一个方法
274
+ if (modelType === Util_1.ModelType.RECT_NODE || modelType === Util_1.ModelType.HTML_NODE) {
274
275
  _this.updateRect({ deltaX: deltaX, deltaY: deltaY });
275
276
  }
276
277
  else if (modelType === Util_1.ModelType.ELLIPSE_NODE) {
@@ -7,6 +7,7 @@ var ModelType;
7
7
  ModelType["CIRCLE_NODE"] = "circle-node";
8
8
  ModelType["POLYGON_NODE"] = "polygon-node";
9
9
  ModelType["RECT_NODE"] = "rect-node";
10
+ ModelType["HTML_NODE"] = "html-node";
10
11
  ModelType["TEXT_NODE"] = "text-node";
11
12
  ModelType["ELLIPSE_NODE"] = "ellipse-node";
12
13
  ModelType["DIAMOND_NODE"] = "diamond-node";
@@ -12,21 +12,9 @@ var __extends = (this && this.__extends) || (function () {
12
12
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13
13
  };
14
14
  })();
15
- var __assign = (this && this.__assign) || function () {
16
- __assign = Object.assign || function(t) {
17
- for (var s, i = 1, n = arguments.length; i < n; i++) {
18
- s = arguments[i];
19
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
20
- t[p] = s[p];
21
- }
22
- return t;
23
- };
24
- return __assign.apply(this, arguments);
25
- };
26
15
  Object.defineProperty(exports, "__esModule", { value: true });
27
16
  var core_1 = require("@logicflow/core");
28
17
  var ControlGroup_1 = require("../Control/ControlGroup");
29
- var Ellipse_1 = require("../BasicShape/Ellipse");
30
18
  var EllipseResizeModel = /** @class */ (function (_super) {
31
19
  __extends(EllipseResizeModel, _super);
32
20
  function EllipseResizeModel(data, graphModel) {
@@ -68,11 +56,7 @@ var EllipseResizeView = /** @class */ (function (_super) {
68
56
  };
69
57
  // getResizeShape绘制图形,功能等同于基础椭圆的getShape功能,可以通过复写此方法,进行节点自定义
70
58
  EllipseResizeView.prototype.getResizeShape = function () {
71
- var model = this.props.model;
72
- var rx = model.rx, ry = model.ry, x = model.x, y = model.y;
73
- var style = model.getNodeStyle();
74
- return (core_1.h("g", null,
75
- core_1.h(Ellipse_1.default, __assign({}, style, { rx: rx, ry: ry, x: x, y: y }))));
59
+ return _super.prototype.getShape.call(this);
76
60
  };
77
61
  EllipseResizeView.prototype.getShape = function () {
78
62
  var model = this.props.model;
@@ -0,0 +1,72 @@
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
+ var core_1 = require("@logicflow/core");
17
+ var ControlGroup_1 = require("../Control/ControlGroup");
18
+ var HtmlResizeModel = /** @class */ (function (_super) {
19
+ __extends(HtmlResizeModel, _super);
20
+ function HtmlResizeModel() {
21
+ var _this = _super !== null && _super.apply(this, arguments) || this;
22
+ _this.minWidth = 30;
23
+ _this.minHeight = 30;
24
+ _this.maxWidth = 2000;
25
+ _this.maxHeight = 2000;
26
+ return _this;
27
+ }
28
+ HtmlResizeModel.prototype.getOutlineStyle = function () {
29
+ var style = _super.prototype.getOutlineStyle.call(this);
30
+ style.stroke = 'none';
31
+ if (style.hover) {
32
+ style.hover.stroke = 'none';
33
+ }
34
+ return style;
35
+ };
36
+ HtmlResizeModel.prototype.setAttributes = function () {
37
+ // @ts-ignore
38
+ var nodeSize = this.properties.nodeSize;
39
+ if (nodeSize) {
40
+ this.width = nodeSize.width;
41
+ this.height = nodeSize.height;
42
+ }
43
+ };
44
+ return HtmlResizeModel;
45
+ }(core_1.HtmlNodeModel));
46
+ var HtmlResizeView = /** @class */ (function (_super) {
47
+ __extends(HtmlResizeView, _super);
48
+ function HtmlResizeView() {
49
+ return _super !== null && _super.apply(this, arguments) || this;
50
+ }
51
+ HtmlResizeView.prototype.getControlGroup = function () {
52
+ var _a = this.props, model = _a.model, graphModel = _a.graphModel;
53
+ return (core_1.h(ControlGroup_1.default, { model: model, graphModel: graphModel }));
54
+ };
55
+ // getResizeShape绘制图形,功能等同于基础矩形的getShape功能,可以通过复写此方法,进行节点自定义
56
+ HtmlResizeView.prototype.getResizeShape = function () {
57
+ return _super.prototype.getShape.call(this);
58
+ };
59
+ HtmlResizeView.prototype.getShape = function () {
60
+ var isSelected = this.props.model.isSelected;
61
+ return (core_1.h("g", null,
62
+ this.getResizeShape(),
63
+ isSelected ? this.getControlGroup() : ''));
64
+ };
65
+ return HtmlResizeView;
66
+ }(core_1.HtmlNode));
67
+ var HtmlResize = {
68
+ type: 'html',
69
+ view: HtmlResizeView,
70
+ model: HtmlResizeModel,
71
+ };
72
+ exports.default = HtmlResize;
@@ -7,8 +7,9 @@ var EllipseResize_1 = require("./Node/EllipseResize");
7
7
  exports.EllipseResize = EllipseResize_1.default;
8
8
  var DiamondResize_1 = require("./Node/DiamondResize");
9
9
  exports.DiamondResize = DiamondResize_1.default;
10
+ var HtmlResize_1 = require("./Node/HtmlResize");
10
11
  var NodeResize = {
11
- pluginName: 'node-resize',
12
+ pluginName: 'nodeResize',
12
13
  // 拖动step
13
14
  step: 0,
14
15
  // 边框和contol拖动点样式的设置
@@ -62,6 +63,11 @@ var NodeResize = {
62
63
  view: DiamondResize_1.default.view,
63
64
  model: DiamondResize_1.default.model,
64
65
  });
66
+ lf.register({
67
+ type: HtmlResize_1.default.type,
68
+ view: HtmlResize_1.default.view,
69
+ model: HtmlResize_1.default.model,
70
+ });
65
71
  },
66
72
  };
67
73
  exports.NodeResize = NodeResize;
package/cjs/bpmn/index.js CHANGED
@@ -37,7 +37,7 @@ var BpmnElement = /** @class */ (function () {
37
37
  lf.setDefaultEdgeType('bpmn:sequenceFlow');
38
38
  }
39
39
  }
40
- BpmnElement.pluginName = 'BpmnElement';
40
+ BpmnElement.pluginName = 'bpmnElement';
41
41
  return BpmnElement;
42
42
  }());
43
43
  exports.BpmnElement = BpmnElement;
@@ -471,7 +471,7 @@ BpmnAdapter.shapeConfigMap.set(BpmnElements.USER, {
471
471
  height: constant_1.UserTaskConfig.height,
472
472
  });
473
473
  var BpmnXmlAdapter = {
474
- pluginName: 'bpmn-xml-adapter',
474
+ pluginName: 'bpmnXmlAdapter',
475
475
  install: function (lf) {
476
476
  lf.adapterIn = this.adapterXmlIn;
477
477
  lf.adapterOut = this.adapterXmlOut;
@@ -26,29 +26,23 @@ var ContextMenu = /** @class */ (function () {
26
26
  var lf = _a.lf;
27
27
  this.menuTypeMap = new Map();
28
28
  this.listenDelete = function () {
29
- _this.hideMenu();
29
+ _this.hideContextMenu();
30
30
  };
31
31
  this.lf = lf;
32
32
  this.__menuDOM = document.createElement('div');
33
33
  this.__menuDOM.className = 'lf-inner-context';
34
- // const commonMenu = [];
35
34
  this.menuTypeMap.set(COMMON_TYPE_KEY, []);
36
35
  this.lf.setContextMenuByType = function (type, menus) {
37
- _this.menuTypeMap.set(type, menus);
36
+ _this.setContextMenuByType(type, menus);
38
37
  };
39
38
  this.lf.setContextMenuItems = function (menus) {
40
- _this.menuTypeMap.set(COMMON_TYPE_KEY, menus);
39
+ _this.setContextMenuItems(menus);
41
40
  };
42
41
  this.lf.showContextMenu = function (data) {
43
- if (!data || !data.id) {
44
- console.warn('请检查传入的参数');
45
- return;
46
- }
47
- _this._activeData = data;
48
- _this.createContextMenu();
42
+ _this.showContextMenu(data);
49
43
  };
50
44
  this.lf.hideContextMenu = function () {
51
- _this.hideMenu();
45
+ _this.hideContextMenu();
52
46
  };
53
47
  }
54
48
  ContextMenu.prototype.render = function (lf, container) {
@@ -66,9 +60,39 @@ var ContextMenu = /** @class */ (function () {
66
60
  _this.createContextMenu();
67
61
  });
68
62
  lf.on('blank:click', function () {
69
- _this.hideMenu();
63
+ _this.hideContextMenu();
70
64
  });
71
65
  };
66
+ ContextMenu.prototype.setContextMenuByType = function (type, menus) {
67
+ this.menuTypeMap.set(type, menus);
68
+ };
69
+ /**
70
+ * 隐藏菜单
71
+ */
72
+ ContextMenu.prototype.hideContextMenu = function () {
73
+ this.__menuDOM.innerHTML = '';
74
+ this.__menuDOM.style.display = 'none';
75
+ if (this.isShow) {
76
+ this.container.removeChild(this.__menuDOM);
77
+ }
78
+ this.lf.off('node:delete,edge:delete,node:drag,graph:transform', this.listenDelete);
79
+ this.isShow = false;
80
+ };
81
+ /**
82
+ * 显示指定元素菜单
83
+ * @param data 节点id、节点类型、菜单位置
84
+ */
85
+ ContextMenu.prototype.showContextMenu = function (data) {
86
+ if (!data || !data.id) {
87
+ console.warn('请检查传入的参数');
88
+ return;
89
+ }
90
+ this._activeData = data;
91
+ this.createContextMenu();
92
+ };
93
+ ContextMenu.prototype.setContextMenuItems = function (menus) {
94
+ this.menuTypeMap.set(COMMON_TYPE_KEY, menus);
95
+ };
72
96
  /**
73
97
  * 获取新菜单位置
74
98
  */
@@ -122,7 +146,7 @@ var ContextMenu = /** @class */ (function () {
122
146
  menuItem.className = menuItem.className + " " + item.className;
123
147
  }
124
148
  img.addEventListener('click', function () {
125
- _this.hideMenu();
149
+ _this.hideContextMenu();
126
150
  if (item.callback) {
127
151
  item.callback(_this._activeData);
128
152
  }
@@ -194,16 +218,7 @@ var ContextMenu = /** @class */ (function () {
194
218
  !this.isShow && this.lf.on('node:delete,edge:delete,node:drag,graph:transform', this.listenDelete);
195
219
  this.isShow = true;
196
220
  };
197
- ContextMenu.prototype.hideMenu = function () {
198
- this.__menuDOM.innerHTML = '';
199
- this.__menuDOM.style.display = 'none';
200
- if (this.isShow) {
201
- this.container.removeChild(this.__menuDOM);
202
- }
203
- this.lf.off('node:delete,edge:delete,node:drag,graph:transform', this.listenDelete);
204
- this.isShow = false;
205
- };
206
- ContextMenu.pluginName = 'ContextMenu';
221
+ ContextMenu.pluginName = 'contextMenu';
207
222
  return ContextMenu;
208
223
  }());
209
224
  exports.ContextMenu = ContextMenu;
@@ -1,15 +1,4 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
2
  var __read = (this && this.__read) || function (o, n) {
14
3
  var m = typeof Symbol === "function" && o[Symbol.iterator];
15
4
  if (!m) return o;
@@ -34,10 +23,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
34
23
  exports.Control = void 0;
35
24
  var Control = /** @class */ (function () {
36
25
  function Control(_a) {
37
- var _b;
38
26
  var _this = this;
39
27
  var lf = _a.lf;
40
- var _c;
41
28
  this.controlItems = [
42
29
  {
43
30
  key: 'zoom-out',
@@ -86,7 +73,6 @@ var Control = /** @class */ (function () {
86
73
  },
87
74
  ];
88
75
  this.lf = lf;
89
- this.lf.extension = __assign(__assign({}, ((_c = this.lf.extension) !== null && _c !== void 0 ? _c : {})), (_b = {}, _b[Control.pluginName] = this, _b));
90
76
  }
91
77
  Control.prototype.render = function (lf, domContainer) {
92
78
  this.destroy();
@@ -7,11 +7,7 @@ var DndPanel = /** @class */ (function () {
7
7
  var lf = _a.lf;
8
8
  this.lf = lf;
9
9
  this.lf.setPatternItems = function (shapeList) {
10
- _this.shapeList = shapeList;
11
- // 支持渲染后重新设置拖拽面板
12
- if (_this.domContainer) {
13
- _this.render(_this.lf, _this.domContainer);
14
- }
10
+ _this.setPatternItems(shapeList);
15
11
  };
16
12
  }
17
13
  DndPanel.prototype.render = function (lf, domContainer) {
@@ -35,6 +31,13 @@ var DndPanel = /** @class */ (function () {
35
31
  this.domContainer.removeChild(this.panelEl);
36
32
  }
37
33
  };
34
+ DndPanel.prototype.setPatternItems = function (shapeList) {
35
+ this.shapeList = shapeList;
36
+ // 支持渲染后重新设置拖拽面板
37
+ if (this.domContainer) {
38
+ this.render(this.lf, this.domContainer);
39
+ }
40
+ };
38
41
  DndPanel.prototype.createDndItem = function (shapeItem) {
39
42
  var _this = this;
40
43
  var el = document.createElement('div');
@@ -65,7 +68,7 @@ var DndPanel = /** @class */ (function () {
65
68
  };
66
69
  return el;
67
70
  };
68
- DndPanel.pluginName = 'DndPanel';
71
+ DndPanel.pluginName = 'dndPanel';
69
72
  return DndPanel;
70
73
  }());
71
74
  exports.DndPanel = DndPanel;
@@ -34,10 +34,10 @@ var Menu = /** @class */ (function () {
34
34
  this.menuTypeMap = new Map();
35
35
  this.init();
36
36
  this.lf.setMenuConfig = function (config) {
37
- _this.resetMenuItem(config);
37
+ _this.setMenuConfig(config);
38
38
  };
39
39
  this.lf.addMenuConfig = function (config) {
40
- _this.addMenuItem(config);
40
+ _this.addMenuConfig(config);
41
41
  };
42
42
  this.lf.setMenuByType = function (config) {
43
43
  _this.setMenuByType(config);
@@ -250,7 +250,7 @@ var Menu = /** @class */ (function () {
250
250
  return menuList;
251
251
  };
252
252
  // 复写菜单
253
- Menu.prototype.resetMenuItem = function (config) {
253
+ Menu.prototype.setMenuConfig = function (config) {
254
254
  if (!config) {
255
255
  return;
256
256
  }
@@ -265,7 +265,7 @@ var Menu = /** @class */ (function () {
265
265
  && this.menuTypeMap.set(DefalutGraphMenuKey, config.graphMenu ? config.graphMenu : []);
266
266
  };
267
267
  // 在默认菜单后面追加菜单项
268
- Menu.prototype.addMenuItem = function (config) {
268
+ Menu.prototype.addMenuConfig = function (config) {
269
269
  if (!config) {
270
270
  return;
271
271
  }
@@ -289,14 +289,14 @@ var Menu = /** @class */ (function () {
289
289
  */
290
290
  Menu.prototype.changeMenuItem = function (type, config) {
291
291
  if (type === 'add')
292
- this.addMenuItem(config);
292
+ this.addMenuConfig(config);
293
293
  else if (type === 'reset')
294
- this.resetMenuItem(config);
294
+ this.setMenuConfig(config);
295
295
  else {
296
296
  throw new Error('The first parameter of changeMenuConfig should be \'add\' or \'reset\'');
297
297
  }
298
298
  };
299
- Menu.pluginName = 'Menu';
299
+ Menu.pluginName = 'menu';
300
300
  return Menu;
301
301
  }());
302
302
  exports.Menu = Menu;