@logicflow/core 1.2.0-alpha.9 → 1.2.0-next.1

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.
@@ -7043,7 +7043,7 @@ $({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES, sham: !CORRECT_PR
7043
7043
  var $ = __webpack_require__(14);
7044
7044
  var getBuiltIn = __webpack_require__(43);
7045
7045
  var apply = __webpack_require__(73);
7046
- var bind = __webpack_require__(194);
7046
+ var bind = __webpack_require__(195);
7047
7047
  var aConstructor = __webpack_require__(153);
7048
7048
  var anObject = __webpack_require__(30);
7049
7049
  var isObject = __webpack_require__(31);
@@ -7455,7 +7455,7 @@ module.exports = function (argument) {
7455
7455
  /***/ (function(module, exports, __webpack_require__) {
7456
7456
 
7457
7457
  var $ = __webpack_require__(14);
7458
- var assign = __webpack_require__(196);
7458
+ var assign = __webpack_require__(194);
7459
7459
 
7460
7460
  // `Object.assign` method
7461
7461
  // https://tc39.es/ecma262/#sec-object.assign
@@ -7820,7 +7820,7 @@ var $ = __webpack_require__(14);
7820
7820
  var call = __webpack_require__(33);
7821
7821
  var isObject = __webpack_require__(31);
7822
7822
  var anObject = __webpack_require__(30);
7823
- var isDataDescriptor = __webpack_require__(195);
7823
+ var isDataDescriptor = __webpack_require__(196);
7824
7824
  var getOwnPropertyDescriptorModule = __webpack_require__(48);
7825
7825
  var getPrototypeOf = __webpack_require__(92);
7826
7826
 
@@ -11337,7 +11337,7 @@ module.exports.f = function (C) {
11337
11337
  /* 161 */
11338
11338
  /***/ (function(module) {
11339
11339
 
11340
- module.exports = JSON.parse("{\"a\":\"1.2.0-alpha.8\"}");
11340
+ module.exports = JSON.parse("{\"a\":\"1.2.0-next.0\"}");
11341
11341
 
11342
11342
  /***/ }),
11343
11343
  /* 162 */
@@ -13447,57 +13447,6 @@ module.exports = function (matched, str, position, captures, namedCaptures, repl
13447
13447
 
13448
13448
  "use strict";
13449
13449
 
13450
- var global = __webpack_require__(5);
13451
- var uncurryThis = __webpack_require__(13);
13452
- var aCallable = __webpack_require__(52);
13453
- var isObject = __webpack_require__(31);
13454
- var hasOwn = __webpack_require__(32);
13455
- var arraySlice = __webpack_require__(97);
13456
-
13457
- var Function = global.Function;
13458
- var concat = uncurryThis([].concat);
13459
- var join = uncurryThis([].join);
13460
- var factories = {};
13461
-
13462
- var construct = function (C, argsLength, args) {
13463
- if (!hasOwn(factories, argsLength)) {
13464
- for (var list = [], i = 0; i < argsLength; i++) list[i] = 'a[' + i + ']';
13465
- factories[argsLength] = Function('C,a', 'return new C(' + join(list, ',') + ')');
13466
- } return factories[argsLength](C, args);
13467
- };
13468
-
13469
- // `Function.prototype.bind` method implementation
13470
- // https://tc39.es/ecma262/#sec-function.prototype.bind
13471
- module.exports = Function.bind || function bind(that /* , ...args */) {
13472
- var F = aCallable(this);
13473
- var Prototype = F.prototype;
13474
- var partArgs = arraySlice(arguments, 1);
13475
- var boundFunction = function bound(/* args... */) {
13476
- var args = concat(partArgs, arraySlice(arguments));
13477
- return this instanceof boundFunction ? construct(F, args.length, args) : F.apply(that, args);
13478
- };
13479
- if (isObject(Prototype)) boundFunction.prototype = Prototype;
13480
- return boundFunction;
13481
- };
13482
-
13483
-
13484
- /***/ }),
13485
- /* 195 */
13486
- /***/ (function(module, exports, __webpack_require__) {
13487
-
13488
- var hasOwn = __webpack_require__(32);
13489
-
13490
- module.exports = function (descriptor) {
13491
- return descriptor !== undefined && (hasOwn(descriptor, 'value') || hasOwn(descriptor, 'writable'));
13492
- };
13493
-
13494
-
13495
- /***/ }),
13496
- /* 196 */
13497
- /***/ (function(module, exports, __webpack_require__) {
13498
-
13499
- "use strict";
13500
-
13501
13450
  var DESCRIPTORS = __webpack_require__(34);
13502
13451
  var uncurryThis = __webpack_require__(13);
13503
13452
  var call = __webpack_require__(33);
@@ -13556,6 +13505,57 @@ module.exports = !$assign || fails(function () {
13556
13505
  } : $assign;
13557
13506
 
13558
13507
 
13508
+ /***/ }),
13509
+ /* 195 */
13510
+ /***/ (function(module, exports, __webpack_require__) {
13511
+
13512
+ "use strict";
13513
+
13514
+ var global = __webpack_require__(5);
13515
+ var uncurryThis = __webpack_require__(13);
13516
+ var aCallable = __webpack_require__(52);
13517
+ var isObject = __webpack_require__(31);
13518
+ var hasOwn = __webpack_require__(32);
13519
+ var arraySlice = __webpack_require__(97);
13520
+
13521
+ var Function = global.Function;
13522
+ var concat = uncurryThis([].concat);
13523
+ var join = uncurryThis([].join);
13524
+ var factories = {};
13525
+
13526
+ var construct = function (C, argsLength, args) {
13527
+ if (!hasOwn(factories, argsLength)) {
13528
+ for (var list = [], i = 0; i < argsLength; i++) list[i] = 'a[' + i + ']';
13529
+ factories[argsLength] = Function('C,a', 'return new C(' + join(list, ',') + ')');
13530
+ } return factories[argsLength](C, args);
13531
+ };
13532
+
13533
+ // `Function.prototype.bind` method implementation
13534
+ // https://tc39.es/ecma262/#sec-function.prototype.bind
13535
+ module.exports = Function.bind || function bind(that /* , ...args */) {
13536
+ var F = aCallable(this);
13537
+ var Prototype = F.prototype;
13538
+ var partArgs = arraySlice(arguments, 1);
13539
+ var boundFunction = function bound(/* args... */) {
13540
+ var args = concat(partArgs, arraySlice(arguments));
13541
+ return this instanceof boundFunction ? construct(F, args.length, args) : F.apply(that, args);
13542
+ };
13543
+ if (isObject(Prototype)) boundFunction.prototype = Prototype;
13544
+ return boundFunction;
13545
+ };
13546
+
13547
+
13548
+ /***/ }),
13549
+ /* 196 */
13550
+ /***/ (function(module, exports, __webpack_require__) {
13551
+
13552
+ var hasOwn = __webpack_require__(32);
13553
+
13554
+ module.exports = function (descriptor) {
13555
+ return descriptor !== undefined && (hasOwn(descriptor, 'value') || hasOwn(descriptor, 'writable'));
13556
+ };
13557
+
13558
+
13559
13559
  /***/ }),
13560
13560
  /* 197 */
13561
13561
  /***/ (function(module, exports, __webpack_require__) {
@@ -20004,6 +20004,7 @@ var EventType;
20004
20004
  EventType["ANCHOR_DRAGSTART"] = "anchor:dragstart";
20005
20005
  EventType["ANCHOR_DRAG"] = "anchor:drag";
20006
20006
  EventType["ANCHOR_DROP"] = "anchor:drop";
20007
+ EventType["ANCHOR_DRAGEND"] = "anchor:dragend";
20007
20008
  EventType["BLANK_MOUSEDOWN"] = "blank:mousedown";
20008
20009
  EventType["BLANK_DRAGSTART"] = "blank:dragstart";
20009
20010
  EventType["BLANK_DRAG"] = "blank:drag";
@@ -21633,7 +21634,7 @@ var defaultTheme = {
21633
21634
  stroke: 'red',
21634
21635
  strokeDasharray: '10 10',
21635
21636
  strokeDashoffset: '100%',
21636
- animationName: 'dash',
21637
+ animationName: 'lf-dash',
21637
21638
  animationDuration: '20s',
21638
21639
  animationIterationCount: 'infinite',
21639
21640
  animationTimingFunction: 'linear',
@@ -21951,6 +21952,9 @@ var es_string_replace = __webpack_require__(122);
21951
21952
  // EXTERNAL MODULE: /Users/didi/niu-workspace/LogicFlow/node_modules/core-js/modules/es.number.max-safe-integer.js
21952
21953
  var es_number_max_safe_integer = __webpack_require__(77);
21953
21954
 
21955
+ // EXTERNAL MODULE: /Users/didi/niu-workspace/LogicFlow/node_modules/core-js/modules/es.object.assign.js
21956
+ var es_object_assign = __webpack_require__(27);
21957
+
21954
21958
  // EXTERNAL MODULE: /Users/didi/niu-workspace/LogicFlow/node_modules/core-js/modules/es.object.set-prototype-of.js
21955
21959
  var es_object_set_prototype_of = __webpack_require__(10);
21956
21960
 
@@ -21963,9 +21967,6 @@ var es_reflect_construct = __webpack_require__(12);
21963
21967
  // EXTERNAL MODULE: /Users/didi/niu-workspace/LogicFlow/node_modules/core-js/modules/es.reflect.get.js
21964
21968
  var es_reflect_get = __webpack_require__(44);
21965
21969
 
21966
- // EXTERNAL MODULE: /Users/didi/niu-workspace/LogicFlow/node_modules/core-js/modules/es.object.assign.js
21967
- var es_object_assign = __webpack_require__(27);
21968
-
21969
21970
  // CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/rng.js
21970
21971
  // Unique ID creation requires a high quality random # generator. In the browser we therefore
21971
21972
  // require the crypto API and do not support built-in fallback to lower quality random number
@@ -22497,7 +22498,8 @@ var node_getCrossPointWithPolygon = function getCrossPointWithPolygon(point, dir
22497
22498
  }; // 规范节点初始化数据
22498
22499
 
22499
22500
  var node_pickNodeConfig = function pickNodeConfig(data) {
22500
- var nodeData = lodash_es_pick(data, ['id', 'type', 'x', 'y', 'text', 'properties']);
22501
+ var nodeData = lodash_es_pick(data, ['id', 'type', 'x', 'y', 'text', 'properties', 'virtual' // 区域节点是否为dnd添加的虚拟节点
22502
+ ]);
22501
22503
  return nodeData;
22502
22504
  };
22503
22505
  /**
@@ -22824,6 +22826,15 @@ var BaseEdgeModel_BaseEdgeModel = /*#__PURE__*/function () {
22824
22826
  if (overlapMode === OverlapMode.INCREASE) {
22825
22827
  this.zIndex = data.zIndex || getZIndex();
22826
22828
  }
22829
+
22830
+ this.arrowConfig.markerEnd = "url(#marker-end-".concat(this.id, ")"); // 设置边的 anchors,也就是边的两个端点
22831
+ // 端点依赖于 edgeData 的 sourceNode 和 targetNode
22832
+
22833
+ this.setAnchors(); // 边的拐点依赖于两个端点
22834
+
22835
+ this.initPoints(); // 文本位置依赖于边上的所有拐点
22836
+
22837
+ this.formatText(data);
22827
22838
  }
22828
22839
  /**
22829
22840
  * 设置model属性,每次properties发生变化会触发
@@ -23048,6 +23059,12 @@ var BaseEdgeModel_BaseEdgeModel = /*#__PURE__*/function () {
23048
23059
  });
23049
23060
  this.setAttributes();
23050
23061
  }
23062
+ }, {
23063
+ key: "deleteProperty",
23064
+ value: function deleteProperty(key) {
23065
+ delete this.properties[key];
23066
+ this.setAttributes();
23067
+ }
23051
23068
  }, {
23052
23069
  key: "setProperties",
23053
23070
  value: function setProperties(properties) {
@@ -23057,6 +23074,23 @@ var BaseEdgeModel_BaseEdgeModel = /*#__PURE__*/function () {
23057
23074
  data: properties
23058
23075
  });
23059
23076
  this.setAttributes();
23077
+ }
23078
+ }, {
23079
+ key: "changeEdgeId",
23080
+ value: function changeEdgeId(id) {
23081
+ var _this$arrowConfig = this.arrowConfig,
23082
+ markerEnd = _this$arrowConfig.markerEnd,
23083
+ markerStart = _this$arrowConfig.markerStart;
23084
+
23085
+ if (markerStart && markerStart === "url(#marker-start-".concat(this.id, ")")) {
23086
+ this.arrowConfig.markerStart = "url(#marker-start-".concat(id, ")");
23087
+ }
23088
+
23089
+ if (markerEnd && markerEnd === "url(#marker-end-".concat(this.id, ")")) {
23090
+ this.arrowConfig.markerEnd = "url(#marker-end-".concat(id, ")");
23091
+ }
23092
+
23093
+ this.id = id;
23060
23094
  } // 设置样式
23061
23095
 
23062
23096
  }, {
@@ -24000,7 +24034,6 @@ var PolylineEdgeModel_PolylineEdgeModel = /*#__PURE__*/function (_BaseEdgeModel)
24000
24034
  }
24001
24035
  }
24002
24036
 
24003
- draggingPointList = pointFilter(draggingPointList);
24004
24037
  this.updatePointsAfterDrag(draggingPointList); // step3: 调整到对应外框的位置后,执行updatePointsAfterDrag,找到当前线段和图形的准确交点
24005
24038
 
24006
24039
  this.draggingPointList = draggingPointList;
@@ -24029,7 +24062,7 @@ var PolylineEdgeModel_PolylineEdgeModel = /*#__PURE__*/function (_BaseEdgeModel)
24029
24062
  var _inNode2 = isInNode(_startPosition, this.sourceNode);
24030
24063
 
24031
24064
  if (!_inNode2) {
24032
- // FIXME: 如果某一条边上没有任何锚点,会有问题
24065
+ // FIXME: 如果某一节点上没有任何锚点,会有问题
24033
24066
  var _anchorList3 = this.sourceNode.anchors;
24034
24067
  _draggingPointList = this.getDraggingPoints(direction, 'start', _startPosition, _anchorList3, _draggingPointList);
24035
24068
  }
@@ -24049,7 +24082,6 @@ var PolylineEdgeModel_PolylineEdgeModel = /*#__PURE__*/function (_BaseEdgeModel)
24049
24082
  }
24050
24083
  }
24051
24084
 
24052
- _draggingPointList = pointFilter(_draggingPointList);
24053
24085
  this.updatePointsAfterDrag(_draggingPointList);
24054
24086
  this.draggingPointList = _draggingPointList;
24055
24087
  }
@@ -24067,7 +24099,7 @@ var PolylineEdgeModel_PolylineEdgeModel = /*#__PURE__*/function (_BaseEdgeModel)
24067
24099
  key: "dragAppendEnd",
24068
24100
  value: function dragAppendEnd() {
24069
24101
  if (this.draggingPointList) {
24070
- var pointsList = points2PointsList(this.points); // draggingPointList清空
24102
+ var pointsList = pointFilter(points2PointsList(this.points)); // draggingPointList清空
24071
24103
 
24072
24104
  this.draggingPointList = []; // 更新起终点
24073
24105
 
@@ -24194,6 +24226,27 @@ var getVerticalPointOfLine = function getVerticalPointOfLine(config) {
24194
24226
 
24195
24227
  return pointPosition;
24196
24228
  };
24229
+ // CONCATENATED MODULE: ./src/util/vector.ts
24230
+ var getDirectionVector = function getDirectionVector(point1, point2) {
24231
+ var a = point2.x - point1.x;
24232
+ var b = point2.y - point1.y;
24233
+
24234
+ if (a !== 0) {
24235
+ a = a / Math.abs(a);
24236
+ }
24237
+
24238
+ if (b !== 0) {
24239
+ b = b / Math.abs(b);
24240
+ }
24241
+
24242
+ return [a, b];
24243
+ };
24244
+ var isSameDirection = function isSameDirection(v1, v2) {
24245
+ return v1[0] === v2[0] && v1[1] === v2[1];
24246
+ };
24247
+ var isContraryDirection = function isContraryDirection(v1, v2) {
24248
+ return !(v1[0] + v2[0] || v1[1] + v2[1]);
24249
+ };
24197
24250
  // CONCATENATED MODULE: ./src/util/edge.ts
24198
24251
  function edge_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
24199
24252
 
@@ -24250,6 +24303,8 @@ function edge_arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
24250
24303
 
24251
24304
 
24252
24305
 
24306
+
24307
+
24253
24308
 
24254
24309
 
24255
24310
 
@@ -24990,14 +25045,58 @@ var edge_getBezierControlPoints = function getBezierControlPoints(_ref) {
24990
25045
  sourceNode = _ref.sourceNode,
24991
25046
  targetNode = _ref.targetNode,
24992
25047
  offset = _ref.offset;
25048
+ var nodeDistance = Math.max(Math.abs(sourceNode.x - targetNode.x), Math.abs(sourceNode.y - targetNode.y));
25049
+ offset = offset || nodeDistance / 4;
24993
25050
  var sBBox = getNodeBBox(sourceNode);
24994
25051
  var tBBox = getNodeBBox(targetNode);
24995
25052
  var sExpendBBox = getExpandedBBox(sBBox, offset);
24996
25053
  var tExpendBBox = getExpandedBBox(tBBox, offset);
24997
25054
  var sDirection = edge_pointDirection(start, sourceNode);
25055
+ var tDirection = edge_pointDirection(end, targetNode); // 1. 避免两个节点连出的多个连线重合。
25056
+ // 2. 避免开始节点和结束节点方向相同时成为一个穿过节点的直线。
25057
+
24998
25058
  var sNext = edge_getExpandedBBoxPoint(sExpendBBox, start, sDirection);
24999
- var tDirection = edge_pointDirection(end, targetNode);
25000
- var ePre = edge_getExpandedBBoxPoint(tExpendBBox, end, tDirection);
25059
+ var ePre = edge_getExpandedBBoxPoint(tExpendBBox, end, tDirection); // 如果两个节点水平或垂直并且连线在两个节点最近的锚点之间,则不产生偏移,保证连线看起来像是直线
25060
+
25061
+ var vector1 = getDirectionVector(sourceNode, start);
25062
+ var vector2 = getDirectionVector(targetNode, end);
25063
+ var vector3 = getDirectionVector(sourceNode, targetNode); // 当开始节点控制连线的方向和连线方向相同,并且结束节点控制连线相反的时候,则意味这两个节点直接相连。此时不需要对控制点进行偏移调整
25064
+
25065
+ if (isSameDirection(vector1, vector3) && isContraryDirection(vector2, vector3)) {
25066
+ return {
25067
+ sNext: sNext,
25068
+ ePre: ePre
25069
+ };
25070
+ } // 当开始节点控制连线方向和连线方向相反的时候或者结束节点控制连线形同的时候,增大偏移量,实现更美观的效果。
25071
+
25072
+
25073
+ if (isSameDirection(vector2, vector3) || isContraryDirection(vector1, vector3)) {
25074
+ offset = offset * 2;
25075
+ } // 计算起点的调整点是否需要偏移
25076
+ // 如果起点的调整点方向和连线方向相反,则添加偏移量
25077
+ // 如果终点的调整点方向与连线方向
25078
+
25079
+
25080
+ var randomNumberX = Math.ceil((Math.random() + 0.5) * offset);
25081
+ var randomNumberY = Math.ceil((Math.random() + 0.5) * offset); // 如果是调整点在节点水平方向,那么调整的点Y需要向着另一个节点的方向进行一定随机量的偏移。
25082
+ // 如果是调整点在节点垂直方向,那么调整的点X需要向着另一个节点的方向进行一定随机量的偏移。
25083
+
25084
+ if (sDirection === SegmentDirection.HORIZONTAL) {
25085
+ sNext.y += sourceNode.y >= targetNode.y ? randomNumberY : -randomNumberY;
25086
+ }
25087
+
25088
+ if (sDirection === SegmentDirection.VERTICAL) {
25089
+ sNext.x += sourceNode.x >= targetNode.x ? randomNumberX : -randomNumberX;
25090
+ }
25091
+
25092
+ if (tDirection === SegmentDirection.HORIZONTAL) {
25093
+ ePre.y += sourceNode.y > targetNode.y ? randomNumberY : -randomNumberY;
25094
+ }
25095
+
25096
+ if (tDirection === SegmentDirection.VERTICAL) {
25097
+ ePre.x += sourceNode.x > targetNode.x ? randomNumberX : -randomNumberX;
25098
+ }
25099
+
25001
25100
  return {
25002
25101
  sNext: sNext,
25003
25102
  ePre: ePre
@@ -25118,6 +25217,39 @@ var twoPointDistance = function twoPointDistance(source, target) {
25118
25217
  // };
25119
25218
  return Math.sqrt(Math.pow(source.x - target.x, 2) + Math.pow(source.y - target.y, 2));
25120
25219
  };
25220
+ /**
25221
+ * 包装边生成函数
25222
+ * @param graphModel graph model
25223
+ * @param generator 用户自定义的边生成函数
25224
+ */
25225
+
25226
+ function createEdgeGenerator(graphModel, generator) {
25227
+ if (typeof generator !== 'function') {
25228
+ return function (sourceNode, targetNode, currentEdge) {
25229
+ return Object.assign({
25230
+ type: graphModel.edgeType
25231
+ }, currentEdge);
25232
+ };
25233
+ }
25234
+
25235
+ return function (sourceNode, targetNode, currentEdge) {
25236
+ var result = generator(sourceNode, targetNode, currentEdge); // 无结果使用默认类型
25237
+
25238
+ if (!result) return {
25239
+ type: graphModel.edgeType
25240
+ };
25241
+
25242
+ if (typeof result === 'string') {
25243
+ return Object.assign({}, currentEdge, {
25244
+ type: result
25245
+ });
25246
+ }
25247
+
25248
+ return Object.assign({
25249
+ type: result
25250
+ }, currentEdge);
25251
+ };
25252
+ }
25121
25253
  // EXTERNAL MODULE: /Users/didi/niu-workspace/LogicFlow/node_modules/core-js/modules/es.promise.js
25122
25254
  var es_promise = __webpack_require__(200);
25123
25255
 
@@ -25391,6 +25523,10 @@ var drag_StepDrag = /*#__PURE__*/function () {
25391
25523
  DOC.removeEventListener('mousemove', _this.handleMouseMove, false);
25392
25524
  DOC.removeEventListener('mouseup', _this.handleMouseUp, false);
25393
25525
  _this.isDragging = false;
25526
+
25527
+ _this.onDragEnd({
25528
+ event: null
25529
+ });
25394
25530
  });
25395
25531
 
25396
25532
  this.onDragStart = onDragStart;
@@ -25531,6 +25667,8 @@ var GraphModel_GraphModel = /*#__PURE__*/function () {
25531
25667
 
25532
25668
  GraphModel_defineProperty(this, "idGenerator", void 0);
25533
25669
 
25670
+ GraphModel_defineProperty(this, "edgeGenerator", void 0);
25671
+
25534
25672
  GraphModel_defineProperty(this, "nodeMoveRules", []);
25535
25673
 
25536
25674
  GraphModel_defineProperty(this, "edgeType", void 0);
@@ -25615,6 +25753,7 @@ var GraphModel_GraphModel = /*#__PURE__*/function () {
25615
25753
  background = _options$background === void 0 ? {} : _options$background,
25616
25754
  grid = options.grid,
25617
25755
  idGenerator = options.idGenerator,
25756
+ edgeGenerator = options.edgeGenerator,
25618
25757
  animation = options.animation;
25619
25758
  this.background = background;
25620
25759
 
@@ -25637,8 +25776,8 @@ var GraphModel_GraphModel = /*#__PURE__*/function () {
25637
25776
  options.height = container.getBoundingClientRect().height;
25638
25777
  }
25639
25778
 
25640
- if (!options.width || !options.height) {
25641
- console.warn('画布初始化确实宽高');
25779
+ if ((!options.width || !options.height) && options.autoExpand) {
25780
+ console.warn('画布初始化缺少宽高,可能会出现节点无法拖动的情况');
25642
25781
  }
25643
25782
 
25644
25783
  this.width = options.width;
@@ -25647,6 +25786,9 @@ var GraphModel_GraphModel = /*#__PURE__*/function () {
25647
25786
  this.partial = options.partial;
25648
25787
  this.overlapMode = options.overlapMode || 0;
25649
25788
  this.idGenerator = idGenerator;
25789
+ this.edgeGenerator = createEdgeGenerator(this, edgeGenerator);
25790
+ this.width = options.width || this.rootEl.getBoundingClientRect().width;
25791
+ this.height = options.height || this.rootEl.getBoundingClientRect().height;
25650
25792
  }
25651
25793
 
25652
25794
  GraphModel_createClass(GraphModel, [{
@@ -25698,8 +25840,7 @@ var GraphModel_GraphModel = /*#__PURE__*/function () {
25698
25840
  return a.zIndex - b.zIndex;
25699
25841
  }); // 只显示可见区域的节点和边
25700
25842
 
25701
- var showElements = [];
25702
- var topElementIdx = -1; // todo: 缓存, 优化计算效率
25843
+ var showElements = []; // todo: 缓存, 优化计算效率
25703
25844
 
25704
25845
  var visibleLt = [-VisibleMoreSpace, -VisibleMoreSpace];
25705
25846
  var visibleRb = [this.width + VisibleMoreSpace, this.height + VisibleMoreSpace];
@@ -25708,20 +25849,10 @@ var GraphModel_GraphModel = /*#__PURE__*/function () {
25708
25849
  var currentItem = elements[i]; // 如果节点不在可见区域,且不是全元素显示模式,则隐藏节点。
25709
25850
 
25710
25851
  if (currentItem.visible && (!this.partial || currentItem.isSelected || this.isElementInArea(currentItem, visibleLt, visibleRb, false, false))) {
25711
- if (currentItem.zIndex === ElementMaxZIndex) {
25712
- topElementIdx = showElements.length;
25713
- }
25714
-
25715
25852
  showElements.push(currentItem);
25716
25853
  }
25717
25854
  }
25718
25855
 
25719
- if (topElementIdx !== -1) {
25720
- var lastElement = showElements[showElements.length - 1];
25721
- showElements[showElements.length - 1] = showElements[topElementIdx];
25722
- showElements[topElementIdx] = lastElement;
25723
- }
25724
-
25725
25856
  return showElements;
25726
25857
  }
25727
25858
  /**
@@ -25765,6 +25896,7 @@ var GraphModel_GraphModel = /*#__PURE__*/function () {
25765
25896
  * @param rightBottomPoint 表示区域右下角的点
25766
25897
  * @param wholeEdge 是否要整个边都在区域内部
25767
25898
  * @param wholeNode 是否要整个节点都在区域内部
25899
+ * @param ignoreHideElement 是否忽略隐藏的节点
25768
25900
  */
25769
25901
 
25770
25902
  }, {
@@ -25772,6 +25904,7 @@ var GraphModel_GraphModel = /*#__PURE__*/function () {
25772
25904
  value: function getAreaElement(leftTopPoint, rightBottomPoint) {
25773
25905
  var wholeEdge = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
25774
25906
  var wholeNode = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
25907
+ var ignoreHideElement = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
25775
25908
  var areaElements = [];
25776
25909
  var elements = [];
25777
25910
  this.nodes.forEach(function (node) {
@@ -25784,7 +25917,7 @@ var GraphModel_GraphModel = /*#__PURE__*/function () {
25784
25917
  for (var i = 0; i < elements.length; i++) {
25785
25918
  var currentItem = elements[i];
25786
25919
 
25787
- if (this.isElementInArea(currentItem, leftTopPoint, rightBottomPoint, wholeEdge, wholeNode)) {
25920
+ if ((!ignoreHideElement || currentItem.visible) && this.isElementInArea(currentItem, leftTopPoint, rightBottomPoint, wholeEdge, wholeNode)) {
25788
25921
  areaElements.push(currentItem);
25789
25922
  }
25790
25923
  }
@@ -25930,6 +26063,10 @@ var GraphModel_GraphModel = /*#__PURE__*/function () {
25930
26063
  value: function graphDataToModel(graphData) {
25931
26064
  var _this = this;
25932
26065
 
26066
+ if (!this.width || !this.height) {
26067
+ this.resize();
26068
+ }
26069
+
25933
26070
  this.nodes = lodash_es_map(graphData.nodes, function (node) {
25934
26071
  var Model = _this.getModel(node.type);
25935
26072
 
@@ -26184,7 +26321,8 @@ var GraphModel_GraphModel = /*#__PURE__*/function () {
26184
26321
 
26185
26322
  this.edges.forEach(function (edge) {
26186
26323
  if (edge.id === oldId) {
26187
- edge.id = newId;
26324
+ // edge.id = newId;
26325
+ edge.changeEdgeId(newId);
26188
26326
  }
26189
26327
  });
26190
26328
  return newId;
@@ -26312,9 +26450,10 @@ var GraphModel_GraphModel = /*#__PURE__*/function () {
26312
26450
 
26313
26451
  if (!Model) {
26314
26452
  throw new Error("\u627E\u4E0D\u5230".concat(nodeOriginData.type, "\u5BF9\u5E94\u7684\u8282\u70B9\uFF0C\u8BF7\u786E\u8BA4\u662F\u5426\u5DF2\u6CE8\u518C\u6B64\u7C7B\u578B\u8282\u70B9\u3002"));
26315
- } // TODO 元素的 model 不应该直接可以操作 graphModel 的属性,但可以调方法
26316
-
26453
+ }
26317
26454
 
26455
+ nodeOriginData.x = snapToGrid(nodeOriginData.x, this.gridSize);
26456
+ nodeOriginData.y = snapToGrid(nodeOriginData.y, this.gridSize);
26318
26457
  var nodeModel = new Model(nodeOriginData, this);
26319
26458
  nodeModel.init();
26320
26459
  this.nodes.push(nodeModel);
@@ -26369,9 +26508,15 @@ var GraphModel_GraphModel = /*#__PURE__*/function () {
26369
26508
  }
26370
26509
 
26371
26510
  var nodeModel = node.model;
26372
- var r = nodeModel.move(deltaX, deltaY, isIgnoreRule); // 2) 移动边
26373
26511
 
26374
- r && this.moveEdge(nodeId, deltaX, deltaY);
26512
+ var _nodeModel$getMoveDis = nodeModel.getMoveDistance(deltaX, deltaY, isIgnoreRule);
26513
+
26514
+ var _nodeModel$getMoveDis2 = GraphModel_slicedToArray(_nodeModel$getMoveDis, 2);
26515
+
26516
+ deltaX = _nodeModel$getMoveDis2[0];
26517
+ deltaY = _nodeModel$getMoveDis2[1];
26518
+ // 2) 移动边
26519
+ this.moveEdge(nodeId, deltaX, deltaY);
26375
26520
  }
26376
26521
  /**
26377
26522
  * 移动节点-绝对位置
@@ -26904,8 +27049,12 @@ var GraphModel_GraphModel = /*#__PURE__*/function () {
26904
27049
  }, {
26905
27050
  key: "resize",
26906
27051
  value: function resize(width, height) {
26907
- this.width = width !== null && width !== void 0 ? width : this.width;
26908
- this.height = height !== null && height !== void 0 ? height : this.height;
27052
+ this.width = width || this.rootEl.getBoundingClientRect().width;
27053
+ this.height = height || this.rootEl.getBoundingClientRect().height;
27054
+
27055
+ if (!this.width || !this.height) {
27056
+ console.warn('渲染画布的时候无法获取画布宽高,请确认在container已挂载到DOM。@see https://github.com/didi/LogicFlow/issues/675');
27057
+ }
26909
27058
  }
26910
27059
  /**
26911
27060
  * 清空画布
@@ -28966,7 +29115,7 @@ var BezierEdgeModel_BezierEdgeModel = /*#__PURE__*/function (_BaseEdgeModel) {
28966
29115
  BezierEdgeModel_createClass(BezierEdgeModel, [{
28967
29116
  key: "initEdgeData",
28968
29117
  value: function initEdgeData(data) {
28969
- this.offset = 100;
29118
+ this.offset = 0;
28970
29119
 
28971
29120
  BezierEdgeModel_get(BezierEdgeModel_getPrototypeOf(BezierEdgeModel.prototype), "initEdgeData", this).call(this, data);
28972
29121
  }
@@ -29303,6 +29452,8 @@ var BaseNodeModel_BaseNodeModel = /*#__PURE__*/function () {
29303
29452
 
29304
29453
  BaseNodeModel_defineProperty(this, "isHitable", true);
29305
29454
 
29455
+ BaseNodeModel_defineProperty(this, "isShowAnchor", false);
29456
+
29306
29457
  BaseNodeModel_defineProperty(this, "draggable", true);
29307
29458
 
29308
29459
  BaseNodeModel_defineProperty(this, "visible", true);
@@ -29619,7 +29770,7 @@ var BaseNodeModel_BaseNodeModel = /*#__PURE__*/function () {
29619
29770
 
29620
29771
  }, {
29621
29772
  key: "getAnchorLineStyle",
29622
- value: function getAnchorLineStyle() {
29773
+ value: function getAnchorLineStyle(anchorInfo) {
29623
29774
  var anchorLine = this.graphModel.theme.anchorLine;
29624
29775
  return lodash_es_cloneDeep(anchorLine);
29625
29776
  }
@@ -29871,13 +30022,61 @@ var BaseNodeModel_BaseNodeModel = /*#__PURE__*/function () {
29871
30022
 
29872
30023
  return isAllowMoveX || isAllowMoveY;
29873
30024
  }
30025
+ }, {
30026
+ key: "getMoveDistance",
30027
+ value: function getMoveDistance(deltaX, deltaY) {
30028
+ var isIgnoreRule = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
30029
+ var isAllowMoveX = false;
30030
+ var isAllowMoveY = false;
30031
+ var moveX = 0;
30032
+ var moveY = 0;
30033
+
30034
+ if (isIgnoreRule) {
30035
+ isAllowMoveX = true;
30036
+ isAllowMoveY = true;
30037
+ } else {
30038
+ var r = this.isAllowMoveNode(deltaX, deltaY);
30039
+
30040
+ if (typeof r === 'boolean') {
30041
+ isAllowMoveX = r;
30042
+ isAllowMoveY = r;
30043
+ } else {
30044
+ isAllowMoveX = r.x;
30045
+ isAllowMoveY = r.y;
30046
+ }
30047
+ }
30048
+
30049
+ if (isAllowMoveX && deltaX) {
30050
+ var targetX = this.x + deltaX;
30051
+ this.x = targetX;
30052
+ this.text && this.moveText(deltaX, 0);
30053
+ moveX = deltaX;
30054
+ }
30055
+
30056
+ if (isAllowMoveY && deltaY) {
30057
+ var targetY = this.y + deltaY;
30058
+ this.y = targetY;
30059
+ this.text && this.moveText(0, deltaY);
30060
+ moveY = deltaY;
30061
+ }
30062
+
30063
+ return [moveX, moveY];
30064
+ }
29874
30065
  }, {
29875
30066
  key: "moveTo",
29876
30067
  value: function moveTo(x, y) {
29877
30068
  var isIgnoreRule = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
29878
30069
  var deltaX = x - this.x;
29879
30070
  var deltaY = y - this.y;
29880
- return this.move(deltaX, deltaY, isIgnoreRule);
30071
+ if (!isIgnoreRule && !this.isAllowMoveNode(deltaX, deltaY)) return false;
30072
+
30073
+ if (this.text) {
30074
+ this.text && this.moveText(deltaX, deltaY);
30075
+ }
30076
+
30077
+ this.x = x;
30078
+ this.y = y;
30079
+ return true;
29881
30080
  }
29882
30081
  }, {
29883
30082
  key: "moveText",
@@ -29919,6 +30118,13 @@ var BaseNodeModel_BaseNodeModel = /*#__PURE__*/function () {
29919
30118
  value: function setHovered() {
29920
30119
  var flag = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
29921
30120
  this.isHovered = flag;
30121
+ this.setIsShowAnchor(flag);
30122
+ }
30123
+ }, {
30124
+ key: "setIsShowAnchor",
30125
+ value: function setIsShowAnchor() {
30126
+ var flag = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
30127
+ this.isShowAnchor = flag;
29922
30128
  }
29923
30129
  }, {
29924
30130
  key: "setHitable",
@@ -29952,6 +30158,12 @@ var BaseNodeModel_BaseNodeModel = /*#__PURE__*/function () {
29952
30158
  data: properties
29953
30159
  });
29954
30160
  }
30161
+ }, {
30162
+ key: "deleteProperty",
30163
+ value: function deleteProperty(key) {
30164
+ delete this.properties[key];
30165
+ this.setAttributes();
30166
+ }
29955
30167
  }, {
29956
30168
  key: "setStyle",
29957
30169
  value: function setStyle(key, val) {
@@ -31268,6 +31480,39 @@ var SnaplineModel_SnaplineModel = /*#__PURE__*/function () {
31268
31480
 
31269
31481
 
31270
31482
 
31483
+ // CONCATENATED MODULE: ./src/util/raf.ts
31484
+
31485
+
31486
+
31487
+
31488
+
31489
+
31490
+ var rafIdMap = new Map();
31491
+ var raf_createRaf = function createRaf(callback) {
31492
+ var rafId = uuid_createUuid();
31493
+
31494
+ function run() {
31495
+ callback();
31496
+ var eId = rafIdMap.get(rafId);
31497
+
31498
+ if (eId) {
31499
+ var nId = window.requestAnimationFrame(run);
31500
+ rafIdMap.set(rafId, nId);
31501
+ }
31502
+ }
31503
+
31504
+ var id = window.requestAnimationFrame(run);
31505
+ rafIdMap.set(rafId, id);
31506
+ return rafId;
31507
+ };
31508
+ var cancelRaf = function cancelRaf(rafId) {
31509
+ var eId = rafIdMap.get(rafId);
31510
+
31511
+ if (eId) {
31512
+ window.cancelAnimationFrame(eId);
31513
+ rafIdMap.delete(rafId);
31514
+ }
31515
+ };
31271
31516
  // CONCATENATED MODULE: ./src/view/Anchor.tsx
31272
31517
  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); }
31273
31518
 
@@ -31342,6 +31587,7 @@ function Anchor_defineProperty(obj, key, value) { if (key in obj) { Object.defin
31342
31587
 
31343
31588
 
31344
31589
 
31590
+
31345
31591
  var Anchor_Anchor = /*#__PURE__*/function (_Component) {
31346
31592
  Anchor_inherits(Anchor, _Component);
31347
31593
 
@@ -31404,7 +31650,9 @@ var Anchor_Anchor = /*#__PURE__*/function (_Component) {
31404
31650
  eventCenter = graphModel.eventCenter,
31405
31651
  width = graphModel.width,
31406
31652
  height = graphModel.height,
31407
- editConfigModel = graphModel.editConfigModel;
31653
+ _graphModel$editConfi = graphModel.editConfigModel,
31654
+ autoExpand = _graphModel$editConfi.autoExpand,
31655
+ stopMoveGraph = _graphModel$editConfi.stopMoveGraph;
31408
31656
  var clientX = event.clientX,
31409
31657
  clientY = event.clientY;
31410
31658
 
@@ -31420,7 +31668,7 @@ var Anchor_Anchor = /*#__PURE__*/function (_Component) {
31420
31668
  y1 = _graphModel$getPointB3.y;
31421
31669
 
31422
31670
  if (_this.t) {
31423
- clearInterval(_this.t);
31671
+ cancelRaf(_this.t);
31424
31672
  }
31425
31673
 
31426
31674
  var nearBoundary = [];
@@ -31444,8 +31692,8 @@ var Anchor_Anchor = /*#__PURE__*/function (_Component) {
31444
31692
 
31445
31693
  _this.moveAnchorEnd(x1, y1);
31446
31694
 
31447
- if (nearBoundary.length > 0 && !editConfigModel.stopMoveGraph) {
31448
- _this.t = setInterval(function () {
31695
+ if (nearBoundary.length > 0 && !stopMoveGraph && autoExpand) {
31696
+ _this.t = raf_createRaf(function () {
31449
31697
  var _nearBoundary = nearBoundary,
31450
31698
  _nearBoundary2 = Anchor_slicedToArray(_nearBoundary, 2),
31451
31699
  translateX = _nearBoundary2[0],
@@ -31462,7 +31710,7 @@ var Anchor_Anchor = /*#__PURE__*/function (_Component) {
31462
31710
  });
31463
31711
 
31464
31712
  _this.moveAnchorEnd(endX - translateX, endY - translateY);
31465
- }, 50);
31713
+ });
31466
31714
  }
31467
31715
 
31468
31716
  eventCenter.emit(EventType.ANCHOR_DRAG, {
@@ -31474,7 +31722,7 @@ var Anchor_Anchor = /*#__PURE__*/function (_Component) {
31474
31722
 
31475
31723
  Anchor_defineProperty(Anchor_assertThisInitialized(_this), "onDragEnd", function (event) {
31476
31724
  if (_this.t) {
31477
- clearInterval(_this.t);
31725
+ cancelRaf(_this.t);
31478
31726
  }
31479
31727
 
31480
31728
  _this.checkEnd(event);
@@ -31491,16 +31739,26 @@ var Anchor_Anchor = /*#__PURE__*/function (_Component) {
31491
31739
  _this.sourceRuleResults.clear();
31492
31740
 
31493
31741
  _this.targetRuleResults.clear();
31494
- });
31495
31742
 
31496
- Anchor_defineProperty(Anchor_assertThisInitialized(_this), "checkEnd", function (event) {
31497
31743
  var _this$props3 = _this.props,
31498
31744
  graphModel = _this$props3.graphModel,
31499
31745
  nodeModel = _this$props3.nodeModel,
31500
- _this$props3$anchorDa = _this$props3.anchorData,
31501
- x = _this$props3$anchorDa.x,
31502
- y = _this$props3$anchorDa.y,
31503
- id = _this$props3$anchorDa.id; // nodeModel.setSelected(false);
31746
+ anchorData = _this$props3.anchorData;
31747
+ graphModel.eventCenter.emit(EventType.ANCHOR_DRAGEND, {
31748
+ data: anchorData,
31749
+ e: event,
31750
+ nodeModel: nodeModel
31751
+ });
31752
+ });
31753
+
31754
+ Anchor_defineProperty(Anchor_assertThisInitialized(_this), "checkEnd", function (event) {
31755
+ var _this$props4 = _this.props,
31756
+ graphModel = _this$props4.graphModel,
31757
+ nodeModel = _this$props4.nodeModel,
31758
+ _this$props4$anchorDa = _this$props4.anchorData,
31759
+ x = _this$props4$anchorDa.x,
31760
+ y = _this$props4$anchorDa.y,
31761
+ id = _this$props4$anchorDa.id; // nodeModel.setSelected(false);
31504
31762
 
31505
31763
  /* 创建边 */
31506
31764
 
@@ -31536,8 +31794,8 @@ var Anchor_Anchor = /*#__PURE__*/function (_Component) {
31536
31794
 
31537
31795
  if (isSourcePass && isTargetPass) {
31538
31796
  targetNode.setElementState(ElementState.DEFAULT);
31539
- var edgeModel = graphModel.addEdge({
31540
- type: edgeType,
31797
+ var edgeData = graphModel.edgeGenerator(nodeModel.getData(), graphModel.getNodeModelById(info.node.id).getData());
31798
+ var edgeModel = graphModel.addEdge(Anchor_objectSpread(Anchor_objectSpread({}, edgeData), {}, {
31541
31799
  sourceNodeId: nodeModel.id,
31542
31800
  sourceAnchorId: id,
31543
31801
  startPoint: {
@@ -31550,7 +31808,7 @@ var Anchor_Anchor = /*#__PURE__*/function (_Component) {
31550
31808
  x: info.anchor.x,
31551
31809
  y: info.anchor.y
31552
31810
  }
31553
- });
31811
+ }));
31554
31812
  var anchorData = _this.props.anchorData;
31555
31813
  graphModel.eventCenter.emit(EventType.ANCHOR_DROP, {
31556
31814
  data: anchorData,
@@ -31588,10 +31846,10 @@ var Anchor_Anchor = /*#__PURE__*/function (_Component) {
31588
31846
  Anchor_createClass(Anchor, [{
31589
31847
  key: "getAnchorShape",
31590
31848
  value: function getAnchorShape() {
31591
- var _this$props4 = this.props,
31592
- anchorData = _this$props4.anchorData,
31593
- style = _this$props4.style,
31594
- node = _this$props4.node;
31849
+ var _this$props5 = this.props,
31850
+ anchorData = _this$props5.anchorData,
31851
+ style = _this$props5.style,
31852
+ node = _this$props5.node;
31595
31853
  var anchorShape = node.getAnchorShape(anchorData);
31596
31854
  if (anchorShape) return anchorShape;
31597
31855
  var x = anchorData.x,
@@ -31614,10 +31872,10 @@ var Anchor_Anchor = /*#__PURE__*/function (_Component) {
31614
31872
  }, {
31615
31873
  key: "moveAnchorEnd",
31616
31874
  value: function moveAnchorEnd(endX, endY) {
31617
- var _this$props5 = this.props,
31618
- graphModel = _this$props5.graphModel,
31619
- nodeModel = _this$props5.nodeModel,
31620
- anchorData = _this$props5.anchorData;
31875
+ var _this$props6 = this.props,
31876
+ graphModel = _this$props6.graphModel,
31877
+ nodeModel = _this$props6.nodeModel,
31878
+ anchorData = _this$props6.anchorData;
31621
31879
  var info = targetNodeInfo({
31622
31880
  x: endX,
31623
31881
  y: endY
@@ -31686,9 +31944,9 @@ var Anchor_Anchor = /*#__PURE__*/function (_Component) {
31686
31944
  startY = _this$state4.startY,
31687
31945
  endX = _this$state4.endX,
31688
31946
  endY = _this$state4.endY;
31689
- var _this$props6 = this.props,
31690
- edgeAddable = _this$props6.anchorData.edgeAddable,
31691
- edgeStyle = _this$props6.edgeStyle;
31947
+ var _this$props7 = this.props,
31948
+ edgeAddable = _this$props7.anchorData.edgeAddable,
31949
+ edgeStyle = _this$props7.edgeStyle;
31692
31950
  return (// className="lf-anchor" 作为下载时,需要将锚点删除的依据,不要修改类名
31693
31951
  preact_module_v("g", {
31694
31952
  className: "lf-anchor"
@@ -32080,39 +32338,6 @@ var BaseText_BaseText = /*#__PURE__*/function (_Component) {
32080
32338
 
32081
32339
 
32082
32340
  var isIe = window.navigator.userAgent.match(/MSIE|Trident/) !== null;
32083
- // CONCATENATED MODULE: ./src/util/raf.ts
32084
-
32085
-
32086
-
32087
-
32088
-
32089
-
32090
- var rafIdMap = new Map();
32091
- var raf_createRaf = function createRaf(callback) {
32092
- var rafId = uuid_createUuid();
32093
-
32094
- function run() {
32095
- callback();
32096
- var eId = rafIdMap.get(rafId);
32097
-
32098
- if (eId) {
32099
- var nId = window.requestAnimationFrame(run);
32100
- rafIdMap.set(rafId, nId);
32101
- }
32102
- }
32103
-
32104
- var id = window.requestAnimationFrame(run);
32105
- rafIdMap.set(rafId, id);
32106
- return rafId;
32107
- };
32108
- var cancelRaf = function cancelRaf(rafId) {
32109
- var eId = rafIdMap.get(rafId);
32110
-
32111
- if (eId) {
32112
- window.cancelAnimationFrame(eId);
32113
- rafIdMap.delete(rafId);
32114
- }
32115
- };
32116
32341
  // CONCATENATED MODULE: ./src/view/node/BaseNode.tsx
32117
32342
  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); }
32118
32343
 
@@ -32228,7 +32453,9 @@ var BaseNode_BaseNode = /*#__PURE__*/function (_Component) {
32228
32453
  model = _this$props2.model,
32229
32454
  graphModel = _this$props2.graphModel; // const { isDragging } = model;
32230
32455
 
32231
- var editConfigModel = graphModel.editConfigModel,
32456
+ var _graphModel$editConfi = graphModel.editConfigModel,
32457
+ stopMoveGraph = _graphModel$editConfi.stopMoveGraph,
32458
+ autoExpand = _graphModel$editConfi.autoExpand,
32232
32459
  transformModel = graphModel.transformModel,
32233
32460
  width = graphModel.width,
32234
32461
  height = graphModel.height,
@@ -32250,7 +32477,7 @@ var BaseNode_BaseNode = /*#__PURE__*/function (_Component) {
32250
32477
  x1 = _transformModel$Canva2[0],
32251
32478
  y1 = _transformModel$Canva2[1];
32252
32479
 
32253
- if (x1 < 0 || y1 < 0 || x1 > width || y1 > height) {
32480
+ if (autoExpand && !stopMoveGraph && (x1 < 0 || y1 < 0 || x1 > width || y1 > height)) {
32254
32481
  // 鼠标超出画布后的拖动,不处理,而是让上一次setInterval持续滚动画布
32255
32482
  return;
32256
32483
  } // 1. 考虑画布被缩放
@@ -32261,7 +32488,20 @@ var BaseNode_BaseNode = /*#__PURE__*/function (_Component) {
32261
32488
  y = y + _this.moveOffset.y; // 将x, y移动到grid上
32262
32489
 
32263
32490
  x = snapToGrid(x, gridSize);
32264
- y = snapToGrid(y, gridSize); // 取节点左上角和右下角,计算节点移动是否超出范围
32491
+ y = snapToGrid(y, gridSize);
32492
+
32493
+ if (!width || !height) {
32494
+ graphModel.moveNode2Coordinate(model.id, x, y);
32495
+ return;
32496
+ }
32497
+
32498
+ var isOutCanvas = x1 < 0 || y1 < 0 || x1 > width || y1 > height;
32499
+
32500
+ if (autoExpand && !stopMoveGraph && isOutCanvas) {
32501
+ // 鼠标超出画布后的拖动,不处理,而是让上一次setInterval持续滚动画布
32502
+ return;
32503
+ } // 取节点左上角和右下角,计算节点移动是否超出范围
32504
+
32265
32505
 
32266
32506
  var _transformModel$Canva3 = transformModel.CanvasPointToHtmlPoint([x - model.width / 2, y - model.height / 2]),
32267
32507
  _transformModel$Canva4 = BaseNode_slicedToArray(_transformModel$Canva3, 2),
@@ -32290,7 +32530,7 @@ var BaseNode_BaseNode = /*#__PURE__*/function (_Component) {
32290
32530
  cancelRaf(_this.t);
32291
32531
  }
32292
32532
 
32293
- if (nearBoundary.length > 0 && !editConfigModel.stopMoveGraph && editConfigModel.autoExpand) {
32533
+ if (nearBoundary.length > 0 && !stopMoveGraph && autoExpand) {
32294
32534
  _this.t = raf_createRaf(function () {
32295
32535
  var _nearBoundary = nearBoundary,
32296
32536
  _nearBoundary2 = BaseNode_slicedToArray(_nearBoundary, 2),
@@ -32321,7 +32561,7 @@ var BaseNode_BaseNode = /*#__PURE__*/function (_Component) {
32321
32561
 
32322
32562
  var time = new Date().getTime() - _this.startTime;
32323
32563
 
32324
- if (time > 200) return; // 事件大于200ms,认为是拖拽。
32564
+ if (time > 200) return; // 事件大于200ms,认为是拖拽, 不触发click事件。
32325
32565
 
32326
32566
  var _this$props3 = _this.props,
32327
32567
  model = _this$props3.model,
@@ -32387,9 +32627,6 @@ var BaseNode_BaseNode = /*#__PURE__*/function (_Component) {
32387
32627
  var _this$props5 = _this.props,
32388
32628
  model = _this$props5.model,
32389
32629
  graphModel = _this$props5.graphModel;
32390
-
32391
- _this.toFront();
32392
-
32393
32630
  _this.startTime = new Date().getTime();
32394
32631
  var editConfigModel = graphModel.editConfigModel;
32395
32632
 
@@ -32399,16 +32636,10 @@ var BaseNode_BaseNode = /*#__PURE__*/function (_Component) {
32399
32636
  });
32400
32637
 
32401
32638
  BaseNode_defineProperty(BaseNode_assertThisInitialized(_this), "setHoverON", function (ev) {
32402
- var isHovered = _this.state.isHovered;
32403
- if (isHovered) return;
32404
-
32405
- _this.setState({
32406
- isHovered: true
32407
- });
32408
-
32409
32639
  var _this$props6 = _this.props,
32410
32640
  model = _this$props6.model,
32411
32641
  graphModel = _this$props6.graphModel;
32642
+ if (model.isHovered) return;
32412
32643
  var nodeData = model.getData();
32413
32644
  model.setHovered(true);
32414
32645
  graphModel.eventCenter.emit(EventType.NODE_MOUSEENTER, {
@@ -32418,14 +32649,11 @@ var BaseNode_BaseNode = /*#__PURE__*/function (_Component) {
32418
32649
  });
32419
32650
 
32420
32651
  BaseNode_defineProperty(BaseNode_assertThisInitialized(_this), "setHoverOFF", function (ev) {
32421
- _this.setState({
32422
- isHovered: false
32423
- });
32424
-
32425
32652
  var _this$props7 = _this.props,
32426
32653
  model = _this$props7.model,
32427
32654
  graphModel = _this$props7.graphModel;
32428
32655
  var nodeData = model.getData();
32656
+ if (!model.isHovered) return;
32429
32657
  model.setHovered(false);
32430
32658
  graphModel.eventCenter.emit(EventType.NODE_MOUSELEAVE, {
32431
32659
  data: nodeData,
@@ -32454,9 +32682,6 @@ var BaseNode_BaseNode = /*#__PURE__*/function (_Component) {
32454
32682
  eventCenter: eventCenter,
32455
32683
  model: _model
32456
32684
  });
32457
- _this.state = {
32458
- isHovered: false
32459
- };
32460
32685
  return _this;
32461
32686
  }
32462
32687
 
@@ -32475,12 +32700,12 @@ var BaseNode_BaseNode = /*#__PURE__*/function (_Component) {
32475
32700
  graphModel = _this$props8.graphModel;
32476
32701
  var isSelected = model.isSelected,
32477
32702
  isHitable = model.isHitable,
32478
- isDragging = model.isDragging;
32479
- var isHovered = this.state.isHovered;
32703
+ isDragging = model.isDragging,
32704
+ isShowAnchor = model.isShowAnchor;
32480
32705
 
32481
- if (isHitable && (isSelected || isHovered) && !isDragging) {
32482
- var edgeStyle = model.getAnchorLineStyle();
32706
+ if (isHitable && (isSelected || isShowAnchor) && !isDragging) {
32483
32707
  return lodash_es_map(model.anchors, function (anchor, index) {
32708
+ var edgeStyle = model.getAnchorLineStyle(anchor);
32484
32709
  var style = model.getAnchorStyle(anchor);
32485
32710
  return preact_module_v(view_Anchor, {
32486
32711
  anchorData: anchor,
@@ -32579,9 +32804,9 @@ var BaseNode_BaseNode = /*#__PURE__*/function (_Component) {
32579
32804
  var _this$props11 = this.props,
32580
32805
  model = _this$props11.model,
32581
32806
  graphModel = _this$props11.graphModel;
32582
- var _graphModel$editConfi = graphModel.editConfigModel,
32583
- hideAnchors = _graphModel$editConfi.hideAnchors,
32584
- adjustNodePosition = _graphModel$editConfi.adjustNodePosition,
32807
+ var _graphModel$editConfi2 = graphModel.editConfigModel,
32808
+ hideAnchors = _graphModel$editConfi2.hideAnchors,
32809
+ adjustNodePosition = _graphModel$editConfi2.adjustNodePosition,
32585
32810
  gridSize = graphModel.gridSize,
32586
32811
  SCALE_X = graphModel.transformModel.SCALE_X;
32587
32812
  var isHitable = model.isHitable,
@@ -32603,7 +32828,7 @@ var BaseNode_BaseNode = /*#__PURE__*/function (_Component) {
32603
32828
  nodeShape = preact_module_v("g", {
32604
32829
  className: this.getStateClassName(),
32605
32830
  onMouseDown: this.handleMouseDown,
32606
- onMouseUp: this.handleClick,
32831
+ onClick: this.handleClick,
32607
32832
  onMouseEnter: this.setHoverON,
32608
32833
  onMouseOver: this.setHoverON,
32609
32834
  onMouseLeave: this.setHoverOFF,
@@ -33350,6 +33575,7 @@ var HtmlNode_HtmlNode = /*#__PURE__*/function (_BaseNode) {
33350
33575
  width = model.width;
33351
33576
  this.currentProperties = JSON.stringify(model.properties);
33352
33577
  var style = model.getNodeStyle();
33578
+ this.currentProperties = JSON.stringify(model.properties);
33353
33579
  return preact_module_v("foreignObject", HtmlNode_extends({}, style, {
33354
33580
  x: x - width / 2,
33355
33581
  y: y - height / 2,
@@ -33835,7 +34061,8 @@ var AdjustPoint_AdjustPoint = /*#__PURE__*/function (_Component) {
33835
34061
 
33836
34062
 
33837
34063
  if (type === AdjustType.SOURCE) {
33838
- createEdgeInfo = AdjustPoint_objectSpread(AdjustPoint_objectSpread({}, createEdgeInfo), {}, {
34064
+ var edgeInfo = graphModel.edgeGenerator(graphModel.getNodeModelById(info.node.id).getData(), graphModel.getNodeModelById(edgeModel.targetNodeId).getData(), createEdgeInfo);
34065
+ createEdgeInfo = AdjustPoint_objectSpread(AdjustPoint_objectSpread({}, edgeInfo), {}, {
33839
34066
  sourceNodeId: info.node.id,
33840
34067
  sourceAnchorId: info.anchor.id,
33841
34068
  startPoint: {
@@ -33846,7 +34073,9 @@ var AdjustPoint_AdjustPoint = /*#__PURE__*/function (_Component) {
33846
34073
  endPoint: AdjustPoint_objectSpread({}, edgeModel.endPoint)
33847
34074
  });
33848
34075
  } else if (type === AdjustType.TARGET) {
33849
- createEdgeInfo = AdjustPoint_objectSpread(AdjustPoint_objectSpread({}, createEdgeInfo), {}, {
34076
+ var _edgeInfo = graphModel.edgeGenerator(graphModel.getNodeModelById(edgeModel.sourceNodeId).getData(), graphModel.getNodeModelById(info.node.id).getData(), createEdgeInfo);
34077
+
34078
+ createEdgeInfo = AdjustPoint_objectSpread(AdjustPoint_objectSpread({}, _edgeInfo), {}, {
33850
34079
  sourceNodeId: edgeModel.sourceNodeId,
33851
34080
  startPoint: AdjustPoint_objectSpread({}, edgeModel.startPoint),
33852
34081
  targetNodeId: info.node.id,
@@ -34221,7 +34450,7 @@ var BaseEdge_BaseEdge = /*#__PURE__*/function (_Component) {
34221
34450
  _this.toFront();
34222
34451
  });
34223
34452
 
34224
- BaseEdge_defineProperty(BaseEdge_assertThisInitialized(_this), "getIsDraging", function () {
34453
+ BaseEdge_defineProperty(BaseEdge_assertThisInitialized(_this), "getIsDragging", function () {
34225
34454
  return false;
34226
34455
  });
34227
34456
 
@@ -34231,6 +34460,13 @@ var BaseEdge_BaseEdge = /*#__PURE__*/function (_Component) {
34231
34460
  BaseEdge_createClass(BaseEdge, [{
34232
34461
  key: "getShape",
34233
34462
  value: function getShape() {}
34463
+ /**
34464
+ * 支持重写此方法来实现在连线上定义额外内容。
34465
+ */
34466
+
34467
+ }, {
34468
+ key: "getExtraShape",
34469
+ value: function getExtraShape() {}
34234
34470
  }, {
34235
34471
  key: "getTextStyle",
34236
34472
  value: function getTextStyle() {}
@@ -34293,72 +34529,70 @@ var BaseEdge_BaseEdge = /*#__PURE__*/function (_Component) {
34293
34529
  }, {
34294
34530
  key: "getArrow",
34295
34531
  value: function getArrow() {
34296
- return preact_module_v("g", null, preact_module_v("defs", null, this.getStartArrow(), this.getEndArrow()));
34297
- }
34298
- }, {
34299
- key: "getStartArrow",
34300
- value: function getStartArrow() {
34301
- var _this$props6 = this.props,
34302
- model = _this$props6.model,
34303
- graphModel = _this$props6.graphModel;
34304
- var id = model.id;
34305
- var arrow = graphModel.theme.arrow;
34306
- var offset = arrow.offset,
34307
- verticalLength = arrow.verticalLength;
34532
+ var id = this.props.model.id;
34308
34533
 
34309
34534
  var _this$getArrowStyle = this.getArrowStyle(),
34310
- stroke = _this$getArrowStyle.stroke,
34311
- strokeWidth = _this$getArrowStyle.strokeWidth;
34535
+ _this$getArrowStyle$r = _this$getArrowStyle.refY,
34536
+ refY = _this$getArrowStyle$r === void 0 ? 0 : _this$getArrowStyle$r,
34537
+ _this$getArrowStyle$r2 = _this$getArrowStyle.refX,
34538
+ refX = _this$getArrowStyle$r2 === void 0 ? 2 : _this$getArrowStyle$r2;
34312
34539
 
34313
- return preact_module_v("marker", {
34540
+ return preact_module_v("g", null, preact_module_v("defs", null, preact_module_v("marker", {
34314
34541
  id: "marker-start-".concat(id),
34315
- refX: "-1",
34542
+ refX: refX,
34543
+ refY: refY,
34544
+ overflow: "visible",
34545
+ orient: "auto",
34546
+ markerUnits: "userSpaceOnUse"
34547
+ }, this.getStartArrow()), preact_module_v("marker", {
34548
+ id: "marker-end-".concat(id),
34549
+ refX: refX,
34550
+ refY: refY,
34316
34551
  overflow: "visible",
34317
34552
  orient: "auto",
34318
34553
  markerUnits: "userSpaceOnUse"
34319
- }, preact_module_v("path", {
34554
+ }, this.getEndArrow())));
34555
+ }
34556
+ }, {
34557
+ key: "getStartArrow",
34558
+ value: function getStartArrow() {
34559
+ var _this$getArrowStyle2 = this.getArrowStyle(),
34560
+ stroke = _this$getArrowStyle2.stroke,
34561
+ strokeWidth = _this$getArrowStyle2.strokeWidth,
34562
+ offset = _this$getArrowStyle2.offset,
34563
+ verticalLength = _this$getArrowStyle2.verticalLength;
34564
+
34565
+ return preact_module_v("path", {
34320
34566
  stroke: stroke,
34321
34567
  fill: stroke,
34322
34568
  strokeWidth: strokeWidth,
34323
34569
  d: "M 0 0 L ".concat(offset, " -").concat(verticalLength, " L ").concat(offset, " ").concat(verticalLength, " Z")
34324
- }));
34570
+ });
34325
34571
  }
34326
34572
  }, {
34327
34573
  key: "getEndArrow",
34328
34574
  value: function getEndArrow() {
34329
- var _this$props7 = this.props,
34330
- model = _this$props7.model,
34331
- graphModel = _this$props7.graphModel;
34332
- var id = model.id;
34333
- var arrow = graphModel.theme.arrow;
34334
- var offset = arrow.offset,
34335
- verticalLength = arrow.verticalLength;
34336
-
34337
- var _this$getArrowStyle2 = this.getArrowStyle(),
34338
- stroke = _this$getArrowStyle2.stroke,
34339
- strokeWidth = _this$getArrowStyle2.strokeWidth;
34575
+ var _this$getArrowStyle3 = this.getArrowStyle(),
34576
+ stroke = _this$getArrowStyle3.stroke,
34577
+ strokeWidth = _this$getArrowStyle3.strokeWidth,
34578
+ offset = _this$getArrowStyle3.offset,
34579
+ verticalLength = _this$getArrowStyle3.verticalLength;
34340
34580
 
34341
- return preact_module_v("marker", {
34342
- id: "marker-end-".concat(id),
34343
- refX: "-1",
34344
- overflow: "visible",
34345
- orient: "auto",
34346
- markerUnits: "userSpaceOnUse"
34347
- }, preact_module_v("path", {
34581
+ return preact_module_v("path", {
34348
34582
  stroke: stroke,
34349
34583
  fill: stroke,
34350
34584
  strokeWidth: strokeWidth,
34351
34585
  transform: "rotate(180)",
34352
34586
  d: "M 0 0 L ".concat(offset, " -").concat(verticalLength, " L ").concat(offset, " ").concat(verticalLength, " Z")
34353
- }));
34587
+ });
34354
34588
  } // 起点终点,可以修改起点/终点为其他节点
34355
34589
 
34356
34590
  }, {
34357
34591
  key: "getAdjustPoints",
34358
34592
  value: function getAdjustPoints() {
34359
- var _this$props8 = this.props,
34360
- model = _this$props8.model,
34361
- graphModel = _this$props8.graphModel;
34593
+ var _this$props6 = this.props,
34594
+ model = _this$props6.model,
34595
+ graphModel = _this$props6.graphModel;
34362
34596
  var start = model.getAdjustStart();
34363
34597
  var end = model.getAdjustEnd();
34364
34598
  return preact_module_v("g", null, preact_module_v(AdjustPoint_AdjustPoint, BaseEdge_extends({
@@ -34391,9 +34625,9 @@ var BaseEdge_BaseEdge = /*#__PURE__*/function (_Component) {
34391
34625
  }, {
34392
34626
  key: "toFront",
34393
34627
  value: function toFront() {
34394
- var _this$props9 = this.props,
34395
- graphModel = _this$props9.graphModel,
34396
- model = _this$props9.model;
34628
+ var _this$props7 = this.props,
34629
+ graphModel = _this$props7.graphModel,
34630
+ model = _this$props7.model;
34397
34631
  var overlapMode = graphModel.overlapMode;
34398
34632
 
34399
34633
  if (overlapMode !== OverlapMode.INCREASE) {
@@ -34403,12 +34637,12 @@ var BaseEdge_BaseEdge = /*#__PURE__*/function (_Component) {
34403
34637
  }, {
34404
34638
  key: "render",
34405
34639
  value: function render() {
34406
- var _this$props10 = this.props,
34407
- _this$props10$model = _this$props10.model,
34408
- isSelected = _this$props10$model.isSelected,
34409
- isHitable = _this$props10$model.isHitable,
34410
- graphModel = _this$props10.graphModel;
34411
- var isDragging = this.getIsDraging();
34640
+ var _this$props8 = this.props,
34641
+ _this$props8$model = _this$props8.model,
34642
+ isSelected = _this$props8$model.isSelected,
34643
+ isHitable = _this$props8$model.isHitable,
34644
+ graphModel = _this$props8.graphModel;
34645
+ var isDragging = this.getIsDragging();
34412
34646
  var adjustEdgeStartAndEnd = graphModel.editConfigModel.adjustEdgeStartAndEnd,
34413
34647
  animation = graphModel.animation; // performance 只允许出现一条edge有动画
34414
34648
 
@@ -34842,7 +35076,7 @@ var PolylineEdge_PolylineEdge = /*#__PURE__*/function (_BaseEdge) {
34842
35076
  _this.appendInfo = appendInfo;
34843
35077
  });
34844
35078
 
34845
- PolylineEdge_defineProperty(PolylineEdge_assertThisInitialized(_this), "getIsDraging", function () {
35079
+ PolylineEdge_defineProperty(PolylineEdge_assertThisInitialized(_this), "getIsDragging", function () {
34846
35080
  return _this.isDragging;
34847
35081
  });
34848
35082
 
@@ -35477,7 +35711,11 @@ var History_History = /*#__PURE__*/function () {
35477
35711
 
35478
35712
  this.eventCenter = graphModel.eventCenter;
35479
35713
  var NODE_ADD = EventType.NODE_ADD,
35714
+ NODE_DELETE = EventType.NODE_DELETE,
35715
+ NODE_DND_ADD = EventType.NODE_DND_ADD,
35480
35716
  EDGE_ADD = EventType.EDGE_ADD,
35717
+ EDGE_DELETE = EventType.EDGE_DELETE,
35718
+ TEXT_UPDATE = EventType.TEXT_UPDATE,
35481
35719
  NODE_DROP = EventType.NODE_DROP,
35482
35720
  EDGE_ADJUST = EventType.EDGE_ADJUST,
35483
35721
  SELECTION_DROP = EventType.SELECTION_DROP,
@@ -35488,7 +35726,7 @@ var History_History = /*#__PURE__*/function () {
35488
35726
  NODE_PROPERTY_UPDATE = EventType.NODE_PROPERTY_UPDATE,
35489
35727
  EDGE_PROPERTY_UPDATE = EventType.EDGE_PROPERTY_UPDATE,
35490
35728
  HISTORY_INSERT = EventType.HISTORY_INSERT;
35491
- var historyChangeKeys = "\n ".concat(NODE_ADD, ",\n ").concat(EDGE_ADD, ",\n ").concat(NODE_DROP, ",\n ").concat(EDGE_ADJUST, ",\n ").concat(SELECTION_DROP, ",\n ").concat(TEXT_DROP, ",\n ").concat(NODE_TEXT_UPDATE, ",\n ").concat(EDGE_TEXT_UPDATE, ",\n ").concat(GRAPH_RENDERED, "\n ");
35729
+ var historyChangeKeys = "\n ".concat(NODE_ADD, ",\n ").concat(EDGE_ADD, ",\n ").concat(NODE_DELETE, ",\n ").concat(NODE_DND_ADD, ",\n ").concat(EDGE_DELETE, ",\n ").concat(TEXT_UPDATE, ",\n ").concat(NODE_DROP, ",\n ").concat(EDGE_ADJUST, ",\n ").concat(SELECTION_DROP, ",\n ").concat(TEXT_DROP, ",\n ").concat(NODE_TEXT_UPDATE, ",\n ").concat(EDGE_TEXT_UPDATE, ",\n ").concat(GRAPH_RENDERED, "\n ");
35492
35730
 
35493
35731
  if (isPropertiesChangeHistory) {
35494
35732
  historyChangeKeys += ",".concat(NODE_PROPERTY_UPDATE, ",").concat(EDGE_PROPERTY_UPDATE);
@@ -35662,7 +35900,7 @@ var TextEditTool_TextEdit = stateUtil_observer(TextEditTool_class = (_temp = _cl
35662
35900
  });
35663
35901
 
35664
35902
  TextEditTool_defineProperty(TextEditTool_assertThisInitialized(_this), "keyupHandler", function (ev) {
35665
- var textEditElement = _this.props.graphModel.textEditElement;
35903
+ var textEditElement = _this.props.graphModel.textEditElement; // 按下alt+enter表示输入完成
35666
35904
 
35667
35905
  if (ev.key === 'Enter' && ev.altKey) {
35668
35906
  textEditElement.setElementState(0);
@@ -35765,6 +36003,7 @@ var TextEditTool_TextEdit = stateUtil_observer(TextEditTool_class = (_temp = _cl
35765
36003
  key: textEditElement.id,
35766
36004
  onKeyUp: this.keyupHandler,
35767
36005
  onKeyDown: this.keydownHandler,
36006
+ onKeyPress: this.keydownHandler,
35768
36007
  onInput: this.inputHandler
35769
36008
  }, (_textEditElement$text = textEditElement.text) === null || _textEditElement$text === void 0 ? void 0 : _textEditElement$text.value) : null;
35770
36009
  }
@@ -36540,10 +36779,6 @@ var LogicFlow_LogicFlow = /*#__PURE__*/function () {
36540
36779
 
36541
36780
  LogicFlow_defineProperty(this, "container", void 0);
36542
36781
 
36543
- LogicFlow_defineProperty(this, "width", void 0);
36544
-
36545
- LogicFlow_defineProperty(this, "height", void 0);
36546
-
36547
36782
  LogicFlow_defineProperty(this, "graphModel", void 0);
36548
36783
 
36549
36784
  LogicFlow_defineProperty(this, "history", void 0);
@@ -36861,14 +37096,15 @@ var LogicFlow_LogicFlow = /*#__PURE__*/function () {
36861
37096
  }
36862
37097
  /**
36863
37098
  * 重新设置画布的宽高
37099
+ * 不传会自动计算画布宽高
36864
37100
  */
36865
37101
 
36866
37102
  }, {
36867
37103
  key: "resize",
36868
37104
  value: function resize(width, height) {
36869
- this.options.width = width !== null && width !== void 0 ? width : this.options.width;
36870
- this.options.height = height !== null && height !== void 0 ? height : this.options.height;
36871
37105
  this.graphModel.resize(width, height);
37106
+ this.options.width = this.graphModel.width;
37107
+ this.options.height = this.graphModel.height;
36872
37108
  }
36873
37109
  /**
36874
37110
  * 设置默认的边类型。
@@ -37262,6 +37498,13 @@ var LogicFlow_LogicFlow = /*#__PURE__*/function () {
37262
37498
 
37263
37499
  (_this$graphModel$getE = this.graphModel.getElement(id)) === null || _this$graphModel$getE === void 0 ? void 0 : _this$graphModel$getE.setProperties(compatible_formatData(properties));
37264
37500
  }
37501
+ }, {
37502
+ key: "deleteProperty",
37503
+ value: function deleteProperty(id, key) {
37504
+ var _this$graphModel$getE2;
37505
+
37506
+ (_this$graphModel$getE2 = this.graphModel.getElement(id)) === null || _this$graphModel$getE2 === void 0 ? void 0 : _this$graphModel$getE2.deleteProperty(key);
37507
+ }
37265
37508
  /**
37266
37509
  * 获取元素的自定义属性
37267
37510
  * @param id 元素的id
@@ -37271,9 +37514,9 @@ var LogicFlow_LogicFlow = /*#__PURE__*/function () {
37271
37514
  }, {
37272
37515
  key: "getProperties",
37273
37516
  value: function getProperties(id) {
37274
- var _this$graphModel$getE2;
37517
+ var _this$graphModel$getE3;
37275
37518
 
37276
- return (_this$graphModel$getE2 = this.graphModel.getElement(id)) === null || _this$graphModel$getE2 === void 0 ? void 0 : _this$graphModel$getE2.getProperties();
37519
+ return (_this$graphModel$getE3 = this.graphModel.getElement(id)) === null || _this$graphModel$getE3 === void 0 ? void 0 : _this$graphModel$getE3.getProperties();
37277
37520
  }
37278
37521
  /**
37279
37522
  * 将某个元素放置到顶部。
@@ -37352,7 +37595,8 @@ var LogicFlow_LogicFlow = /*#__PURE__*/function () {
37352
37595
  value: function getAreaElement(leftTopPoint, rightBottomPoint) {
37353
37596
  var wholeEdge = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
37354
37597
  var wholeNode = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
37355
- return this.graphModel.getAreaElement(leftTopPoint, rightBottomPoint, wholeEdge, wholeNode).map(function (element) {
37598
+ var ignoreHideElement = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
37599
+ return this.graphModel.getAreaElement(leftTopPoint, rightBottomPoint, wholeEdge, wholeNode, ignoreHideElement).map(function (element) {
37356
37600
  return element.getData();
37357
37601
  });
37358
37602
  }