@logicflow/core 1.1.20 → 1.1.21

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.
@@ -20392,7 +20392,7 @@ var pick = _flatRest(function(object, paths) {
20392
20392
 
20393
20393
 
20394
20394
 
20395
- var _class, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6, _descriptor7, _descriptor8, _descriptor9, _descriptor10, _descriptor11, _descriptor12, _descriptor13, _descriptor14, _descriptor15, _descriptor16;
20395
+ var _class, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6, _descriptor7, _descriptor8, _descriptor9, _descriptor10, _descriptor11, _descriptor12, _descriptor13, _descriptor14, _descriptor15, _descriptor16, _descriptor17;
20396
20396
 
20397
20397
 
20398
20398
 
@@ -20426,7 +20426,7 @@ var SilentConfig = {
20426
20426
  nodeTextDraggable: false,
20427
20427
  edgeTextDraggable: false
20428
20428
  };
20429
- var EditConfigModel_keys = ['isSilentMode', 'stopZoomGraph', 'stopScrollGraph', 'stopMoveGraph', 'adjustEdge', 'adjustEdgeMiddle', 'adjustEdgeStartAndEnd', 'adjustNodePosition', 'hideAnchors', 'hoverOutline', 'nodeSelectedOutline', 'edgeSelectedOutline', 'nodeTextEdit', 'edgeTextEdit', 'nodeTextDraggable', 'edgeTextDraggable', 'multipleSelectKey'];
20429
+ var EditConfigModel_keys = ['isSilentMode', 'stopZoomGraph', 'stopScrollGraph', 'stopMoveGraph', 'adjustEdge', 'adjustEdgeMiddle', 'adjustEdgeStartAndEnd', 'adjustNodePosition', 'hideAnchors', 'hoverOutline', 'nodeSelectedOutline', 'edgeSelectedOutline', 'nodeTextEdit', 'edgeTextEdit', 'nodeTextDraggable', 'edgeTextDraggable', 'multipleSelectKey', 'autoExpand'];
20430
20430
  /**
20431
20431
  * 页面编辑配置
20432
20432
  */
@@ -20468,6 +20468,8 @@ var EditConfigModel_EditConfigModel = (_class = /*#__PURE__*/function () {
20468
20468
 
20469
20469
  _initializerDefineProperty(this, "edgeTextDraggable", _descriptor16, this);
20470
20470
 
20471
+ _initializerDefineProperty(this, "autoExpand", _descriptor17, this);
20472
+
20471
20473
  EditConfigModel_defineProperty(this, "multipleSelectKey", '');
20472
20474
 
20473
20475
  EditConfigModel_defineProperty(this, "defaultConfig", {});
@@ -20511,7 +20513,8 @@ var EditConfigModel_EditConfigModel = (_class = /*#__PURE__*/function () {
20511
20513
  nodeTextEdit: this.nodeTextEdit,
20512
20514
  edgeTextEdit: this.edgeTextEdit,
20513
20515
  nodeTextDraggable: this.nodeTextDraggable,
20514
- edgeTextDraggable: this.edgeTextDraggable
20516
+ edgeTextDraggable: this.edgeTextDraggable,
20517
+ autoExpand: this.autoExpand
20515
20518
  };
20516
20519
  lodash_es_assign(conf, silentConfig);
20517
20520
  } // 如果不传,默认undefined表示允许文本编辑
@@ -20647,6 +20650,13 @@ var EditConfigModel_EditConfigModel = (_class = /*#__PURE__*/function () {
20647
20650
  initializer: function initializer() {
20648
20651
  return false;
20649
20652
  }
20653
+ }), _descriptor17 = _applyDecoratedDescriptor(_class.prototype, "autoExpand", [mobx_module["C" /* observable */]], {
20654
+ configurable: true,
20655
+ enumerable: true,
20656
+ writable: true,
20657
+ initializer: function initializer() {
20658
+ return true;
20659
+ }
20650
20660
  }), _applyDecoratedDescriptor(_class.prototype, "updateEditConfig", [mobx_module["k" /* action */]], Object.getOwnPropertyDescriptor(_class.prototype, "updateEditConfig"), _class.prototype)), _class);
20651
20661
 
20652
20662
 
@@ -23399,7 +23409,7 @@ var getMinIndex = function getMinIndex() {
23399
23409
 
23400
23410
 
23401
23411
 
23402
- var BaseEdgeModel_class, BaseEdgeModel_descriptor, BaseEdgeModel_descriptor2, BaseEdgeModel_descriptor3, BaseEdgeModel_descriptor4, BaseEdgeModel_descriptor5, BaseEdgeModel_descriptor6, BaseEdgeModel_descriptor7, BaseEdgeModel_descriptor8, BaseEdgeModel_descriptor9, BaseEdgeModel_descriptor10, BaseEdgeModel_descriptor11, BaseEdgeModel_descriptor12, BaseEdgeModel_descriptor13, BaseEdgeModel_descriptor14, BaseEdgeModel_descriptor15, BaseEdgeModel_descriptor16, _descriptor17, _descriptor18, _descriptor19;
23412
+ var BaseEdgeModel_class, BaseEdgeModel_descriptor, BaseEdgeModel_descriptor2, BaseEdgeModel_descriptor3, BaseEdgeModel_descriptor4, BaseEdgeModel_descriptor5, BaseEdgeModel_descriptor6, BaseEdgeModel_descriptor7, BaseEdgeModel_descriptor8, BaseEdgeModel_descriptor9, BaseEdgeModel_descriptor10, BaseEdgeModel_descriptor11, BaseEdgeModel_descriptor12, BaseEdgeModel_descriptor13, BaseEdgeModel_descriptor14, BaseEdgeModel_descriptor15, BaseEdgeModel_descriptor16, BaseEdgeModel_descriptor17, _descriptor18, _descriptor19;
23403
23413
 
23404
23414
 
23405
23415
 
@@ -23478,7 +23488,7 @@ var BaseEdgeModel_BaseEdgeModel = (BaseEdgeModel_class = /*#__PURE__*/function (
23478
23488
 
23479
23489
  BaseEdgeModel_defineProperty(this, "modelType", ModelType.EDGE);
23480
23490
 
23481
- BaseEdgeModel_initializerDefineProperty(this, "state", _descriptor17, this);
23491
+ BaseEdgeModel_initializerDefineProperty(this, "state", BaseEdgeModel_descriptor17, this);
23482
23492
 
23483
23493
  BaseEdgeModel_defineProperty(this, "additionStateData", void 0);
23484
23494
 
@@ -24126,7 +24136,7 @@ var BaseEdgeModel_BaseEdgeModel = (BaseEdgeModel_class = /*#__PURE__*/function (
24126
24136
  initializer: function initializer() {
24127
24137
  return 0;
24128
24138
  }
24129
- }), _descriptor17 = BaseEdgeModel_applyDecoratedDescriptor(BaseEdgeModel_class.prototype, "state", [mobx_module["C" /* observable */]], {
24139
+ }), BaseEdgeModel_descriptor17 = BaseEdgeModel_applyDecoratedDescriptor(BaseEdgeModel_class.prototype, "state", [mobx_module["C" /* observable */]], {
24130
24140
  configurable: true,
24131
24141
  enumerable: true,
24132
24142
  writable: true,
@@ -26385,21 +26395,14 @@ var GraphModel_GraphModel = (GraphModel_class = /*#__PURE__*/function () {
26385
26395
  this.transformModel = new TransformModel_TransfromModel(this.eventCenter);
26386
26396
  this.theme = theme_updateTheme(options.style);
26387
26397
  this.edgeType = options.edgeType || 'polyline';
26388
-
26389
- if (!options.width) {
26390
- options.width = container.getBoundingClientRect().width;
26391
- }
26392
-
26393
- if (!options.height) {
26394
- options.height = container.getBoundingClientRect().height;
26395
- }
26396
-
26397
26398
  this.width = options.width;
26398
26399
  this.height = options.height;
26399
26400
  this.animation = animation_updateAnimation(animation);
26400
26401
  this.partial = options.partial;
26401
26402
  this.overlapMode = options.overlapMode || 0;
26402
26403
  this.idGenerator = idGenerator;
26404
+ this.width = options.width || this.rootEl.getBoundingClientRect().width;
26405
+ this.height = options.height || this.rootEl.getBoundingClientRect().height;
26403
26406
  }
26404
26407
 
26405
26408
  GraphModel_createClass(GraphModel, [{
@@ -26683,6 +26686,12 @@ var GraphModel_GraphModel = (GraphModel_class = /*#__PURE__*/function () {
26683
26686
  value: function graphDataToModel(graphData) {
26684
26687
  var _this = this;
26685
26688
 
26689
+ console.log(5555, this.width, this.height);
26690
+
26691
+ if (!this.width || !this.height) {
26692
+ this.resize();
26693
+ }
26694
+
26686
26695
  this.nodes = lodash_es_map(graphData.nodes, function (node) {
26687
26696
  var Model = _this.getModel(node.type);
26688
26697
 
@@ -27648,8 +27657,12 @@ var GraphModel_GraphModel = (GraphModel_class = /*#__PURE__*/function () {
27648
27657
  }, {
27649
27658
  key: "resize",
27650
27659
  value: function resize(width, height) {
27651
- this.width = width !== null && width !== void 0 ? width : this.width;
27652
- this.height = height !== null && height !== void 0 ? height : this.height;
27660
+ this.width = width || this.rootEl.getBoundingClientRect().width;
27661
+ this.height = height || this.rootEl.getBoundingClientRect().height;
27662
+
27663
+ if (!this.width || !this.height) {
27664
+ console.warn('渲染画布的时候无法获取画布宽高,请确认在container已挂载到DOM。@see https://github.com/didi/LogicFlow/issues/675');
27665
+ }
27653
27666
  }
27654
27667
  /**
27655
27668
  * 清空画布
@@ -32227,6 +32240,39 @@ var SnaplineModel_SnaplineModel = (SnaplineModel_class = /*#__PURE__*/function (
32227
32240
 
32228
32241
 
32229
32242
 
32243
+ // CONCATENATED MODULE: ./src/util/raf.ts
32244
+
32245
+
32246
+
32247
+
32248
+
32249
+
32250
+ var rafIdMap = new Map();
32251
+ var raf_createRaf = function createRaf(callback) {
32252
+ var rafId = uuid_createUuid();
32253
+
32254
+ function run() {
32255
+ callback();
32256
+ var eId = rafIdMap.get(rafId);
32257
+
32258
+ if (eId) {
32259
+ var nId = window.requestAnimationFrame(run);
32260
+ rafIdMap.set(rafId, nId);
32261
+ }
32262
+ }
32263
+
32264
+ var id = window.requestAnimationFrame(run);
32265
+ rafIdMap.set(rafId, id);
32266
+ return rafId;
32267
+ };
32268
+ var cancelRaf = function cancelRaf(rafId) {
32269
+ var eId = rafIdMap.get(rafId);
32270
+
32271
+ if (eId) {
32272
+ window.cancelAnimationFrame(eId);
32273
+ rafIdMap.delete(rafId);
32274
+ }
32275
+ };
32230
32276
  // CONCATENATED MODULE: ./src/view/Anchor.tsx
32231
32277
  function Anchor_typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { Anchor_typeof = function _typeof(obj) { return typeof obj; }; } else { Anchor_typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return Anchor_typeof(obj); }
32232
32278
 
@@ -32301,6 +32347,7 @@ function Anchor_defineProperty(obj, key, value) { if (key in obj) { Object.defin
32301
32347
 
32302
32348
 
32303
32349
 
32350
+
32304
32351
  var Anchor_Anchor = /*#__PURE__*/function (_Component) {
32305
32352
  Anchor_inherits(Anchor, _Component);
32306
32353
 
@@ -32363,7 +32410,9 @@ var Anchor_Anchor = /*#__PURE__*/function (_Component) {
32363
32410
  eventCenter = graphModel.eventCenter,
32364
32411
  width = graphModel.width,
32365
32412
  height = graphModel.height,
32366
- editConfigModel = graphModel.editConfigModel;
32413
+ _graphModel$editConfi = graphModel.editConfigModel,
32414
+ autoExpand = _graphModel$editConfi.autoExpand,
32415
+ stopMoveGraph = _graphModel$editConfi.stopMoveGraph;
32367
32416
  var clientX = event.clientX,
32368
32417
  clientY = event.clientY;
32369
32418
 
@@ -32379,7 +32428,7 @@ var Anchor_Anchor = /*#__PURE__*/function (_Component) {
32379
32428
  y1 = _graphModel$getPointB3.y;
32380
32429
 
32381
32430
  if (_this.t) {
32382
- clearInterval(_this.t);
32431
+ cancelRaf(_this.t);
32383
32432
  }
32384
32433
 
32385
32434
  var nearBoundary = [];
@@ -32403,8 +32452,8 @@ var Anchor_Anchor = /*#__PURE__*/function (_Component) {
32403
32452
 
32404
32453
  _this.moveAnchorEnd(x1, y1);
32405
32454
 
32406
- if (nearBoundary.length > 0 && !editConfigModel.stopMoveGraph) {
32407
- _this.t = setInterval(function () {
32455
+ if (nearBoundary.length > 0 && !stopMoveGraph && autoExpand) {
32456
+ _this.t = raf_createRaf(function () {
32408
32457
  var _nearBoundary = nearBoundary,
32409
32458
  _nearBoundary2 = Anchor_slicedToArray(_nearBoundary, 2),
32410
32459
  translateX = _nearBoundary2[0],
@@ -32421,7 +32470,7 @@ var Anchor_Anchor = /*#__PURE__*/function (_Component) {
32421
32470
  });
32422
32471
 
32423
32472
  _this.moveAnchorEnd(endX - translateX, endY - translateY);
32424
- }, 50);
32473
+ });
32425
32474
  }
32426
32475
 
32427
32476
  eventCenter.emit(EventType.ANCHOR_DRAG, {
@@ -33026,39 +33075,6 @@ var BaseText_BaseText = /*#__PURE__*/function (_Component) {
33026
33075
 
33027
33076
 
33028
33077
  var isIe = window.navigator.userAgent.match(/MSIE|Trident/) !== null;
33029
- // CONCATENATED MODULE: ./src/util/raf.ts
33030
-
33031
-
33032
-
33033
-
33034
-
33035
-
33036
- var rafIdMap = new Map();
33037
- var raf_createRaf = function createRaf(callback) {
33038
- var rafId = uuid_createUuid();
33039
-
33040
- function run() {
33041
- callback();
33042
- var eId = rafIdMap.get(rafId);
33043
-
33044
- if (eId) {
33045
- var nId = window.requestAnimationFrame(run);
33046
- rafIdMap.set(rafId, nId);
33047
- }
33048
- }
33049
-
33050
- var id = window.requestAnimationFrame(run);
33051
- rafIdMap.set(rafId, id);
33052
- return rafId;
33053
- };
33054
- var cancelRaf = function cancelRaf(rafId) {
33055
- var eId = rafIdMap.get(rafId);
33056
-
33057
- if (eId) {
33058
- window.cancelAnimationFrame(eId);
33059
- rafIdMap.delete(rafId);
33060
- }
33061
- };
33062
33078
  // CONCATENATED MODULE: ./src/view/node/BaseNode.tsx
33063
33079
  function BaseNode_typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { BaseNode_typeof = function _typeof(obj) { return typeof obj; }; } else { BaseNode_typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return BaseNode_typeof(obj); }
33064
33080
 
@@ -33174,7 +33190,9 @@ var BaseNode_BaseNode = /*#__PURE__*/function (_Component) {
33174
33190
  model = _this$props2.model,
33175
33191
  graphModel = _this$props2.graphModel; // const { isDragging } = model;
33176
33192
 
33177
- var editConfigModel = graphModel.editConfigModel,
33193
+ var _graphModel$editConfi = graphModel.editConfigModel,
33194
+ stopMoveGraph = _graphModel$editConfi.stopMoveGraph,
33195
+ autoExpand = _graphModel$editConfi.autoExpand,
33178
33196
  transformModel = graphModel.transformModel,
33179
33197
  width = graphModel.width,
33180
33198
  height = graphModel.height,
@@ -33194,12 +33212,7 @@ var BaseNode_BaseNode = /*#__PURE__*/function (_Component) {
33194
33212
  var _transformModel$Canva = transformModel.CanvasPointToHtmlPoint([x, y]),
33195
33213
  _transformModel$Canva2 = BaseNode_slicedToArray(_transformModel$Canva, 2),
33196
33214
  x1 = _transformModel$Canva2[0],
33197
- y1 = _transformModel$Canva2[1];
33198
-
33199
- if (x1 < 0 || y1 < 0 || x1 > width || y1 > height) {
33200
- // 鼠标超出画布后的拖动,不处理,而是让上一次setInterval持续滚动画布
33201
- return;
33202
- } // 1. 考虑画布被缩放
33215
+ y1 = _transformModel$Canva2[1]; // 1. 考虑画布被缩放
33203
33216
  // 2. 考虑鼠标位置不再节点中心
33204
33217
 
33205
33218
 
@@ -33207,7 +33220,20 @@ var BaseNode_BaseNode = /*#__PURE__*/function (_Component) {
33207
33220
  y = y + _this.moveOffset.y; // 将x, y移动到grid上
33208
33221
 
33209
33222
  x = snapToGrid(x, gridSize);
33210
- y = snapToGrid(y, gridSize); // 取节点左上角和右下角,计算节点移动是否超出范围
33223
+ y = snapToGrid(y, gridSize);
33224
+
33225
+ if (!width || !height) {
33226
+ graphModel.moveNode2Coordinate(model.id, x, y);
33227
+ return;
33228
+ }
33229
+
33230
+ var isOutCanvas = x1 < 0 || y1 < 0 || x1 > width || y1 > height;
33231
+
33232
+ if (autoExpand && !stopMoveGraph && isOutCanvas) {
33233
+ // 鼠标超出画布后的拖动,不处理,而是让上一次setInterval持续滚动画布
33234
+ return;
33235
+ } // 取节点左上角和右下角,计算节点移动是否超出范围
33236
+
33211
33237
 
33212
33238
  var _transformModel$Canva3 = transformModel.CanvasPointToHtmlPoint([x - model.width / 2, y - model.height / 2]),
33213
33239
  _transformModel$Canva4 = BaseNode_slicedToArray(_transformModel$Canva3, 2),
@@ -33236,7 +33262,7 @@ var BaseNode_BaseNode = /*#__PURE__*/function (_Component) {
33236
33262
  cancelRaf(_this.t);
33237
33263
  }
33238
33264
 
33239
- if (nearBoundary.length > 0 && !editConfigModel.stopMoveGraph) {
33265
+ if (nearBoundary.length > 0 && !stopMoveGraph && autoExpand) {
33240
33266
  _this.t = raf_createRaf(function () {
33241
33267
  var _nearBoundary = nearBoundary,
33242
33268
  _nearBoundary2 = BaseNode_slicedToArray(_nearBoundary, 2),
@@ -33525,9 +33551,9 @@ var BaseNode_BaseNode = /*#__PURE__*/function (_Component) {
33525
33551
  var _this$props11 = this.props,
33526
33552
  model = _this$props11.model,
33527
33553
  graphModel = _this$props11.graphModel;
33528
- var _graphModel$editConfi = graphModel.editConfigModel,
33529
- hideAnchors = _graphModel$editConfi.hideAnchors,
33530
- adjustNodePosition = _graphModel$editConfi.adjustNodePosition,
33554
+ var _graphModel$editConfi2 = graphModel.editConfigModel,
33555
+ hideAnchors = _graphModel$editConfi2.hideAnchors,
33556
+ adjustNodePosition = _graphModel$editConfi2.adjustNodePosition,
33531
33557
  gridSize = graphModel.gridSize,
33532
33558
  SCALE_X = graphModel.transformModel.SCALE_X;
33533
33559
  var isHitable = model.isHitable,
@@ -38108,14 +38134,15 @@ var LogicFlow_LogicFlow = /*#__PURE__*/function () {
38108
38134
  }
38109
38135
  /**
38110
38136
  * 重新设置画布的宽高
38137
+ * 不传会自动计算画布宽高
38111
38138
  */
38112
38139
 
38113
38140
  }, {
38114
38141
  key: "resize",
38115
38142
  value: function resize(width, height) {
38116
- this.options.width = width !== null && width !== void 0 ? width : this.options.width;
38117
- this.options.height = height !== null && height !== void 0 ? height : this.options.height;
38118
38143
  this.graphModel.resize(width, height);
38144
+ this.options.width = this.graphModel.width;
38145
+ this.options.height = this.graphModel.height;
38119
38146
  }
38120
38147
  /**
38121
38148
  * 设置默认的边类型。