@meta2d/core 1.0.53 → 1.0.54

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meta2d/core",
3
- "version": "1.0.53",
3
+ "version": "1.0.54",
4
4
  "description": "@meta2d/core: Powerful, Beautiful, Simple, Open - Web-Based 2D At Its Best .",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -843,6 +843,15 @@ var Canvas = /** @class */ (function () {
843
843
  this.calibrateMouse(pt);
844
844
  this.dropPens(obj, pt);
845
845
  this.addCaches = [];
846
+ // 拖拽新增图元判断是否是在容器上
847
+ this.getContainerHover(pt);
848
+ this.mousePos.x = pt.x;
849
+ this.mousePos.y = pt.y;
850
+ this.store.emitter.emit('mouseup', {
851
+ x: pt.x,
852
+ y: pt.y,
853
+ pen: this.store.hoverContainer,
854
+ });
846
855
  }
847
856
  this.store.emitter.emit('drop', obj || json);
848
857
  return [2 /*return*/];
@@ -1733,11 +1742,13 @@ var Canvas = /** @class */ (function () {
1733
1742
  if (_this.store.hover) {
1734
1743
  _this.store.hover.calculative.mouseDown = false;
1735
1744
  }
1736
- _this.store.emitter.emit('mouseup', {
1737
- x: e.x,
1738
- y: e.y,
1739
- pen: _this.store.hover,
1740
- });
1745
+ if (_this.store.hover != _this.store.hoverContainer) {
1746
+ _this.store.emitter.emit('mouseup', {
1747
+ x: e.x,
1748
+ y: e.y,
1749
+ pen: _this.store.hover,
1750
+ });
1751
+ }
1741
1752
  _this.store.emitter.emit('mouseup', {
1742
1753
  x: e.x,
1743
1754
  y: e.y,
@@ -1828,8 +1839,7 @@ var Canvas = /** @class */ (function () {
1828
1839
  var pen = containerPens[i];
1829
1840
  if (pen.visible == false ||
1830
1841
  pen.calculative.inView == false ||
1831
- pen.locked === LockState.Disable ||
1832
- pen.calculative.active) {
1842
+ pen.locked === LockState.Disable) {
1833
1843
  continue;
1834
1844
  }
1835
1845
  if (pointInRect(pt, pen.calculative.worldRect)) {
@@ -1852,7 +1862,8 @@ var Canvas = /** @class */ (function () {
1852
1862
  _this.store.hoverContainer = undefined;
1853
1863
  if (_this.store.lastHoverContainer !== _this.store.hoverContainer) {
1854
1864
  _this.patchFlags = true;
1855
- if (_this.store.lastHoverContainer) {
1865
+ var movingPen = _this.store.lastHoverContainer.calculative.canvas.store.pens[_this.store.lastHoverContainer.id + movingSuffix];
1866
+ if (_this.store.lastHoverContainer && !movingPen) {
1856
1867
  _this.store.lastHoverContainer.calculative.containerHover = false;
1857
1868
  _this.store.emitter.emit('leave', _this.store.lastHoverContainer);
1858
1869
  }
@@ -2904,6 +2915,7 @@ var Canvas = /** @class */ (function () {
2904
2915
  pens: [deepClone(pen, true)],
2905
2916
  initPens: initPens,
2906
2917
  });
2918
+ _this.store.emitter.emit('change', pen);
2907
2919
  _this.store.emitter.emit('valueUpdate', pen);
2908
2920
  }
2909
2921
  else if (pen.text === _this.inputDiv.dataset.value && pen.calculative.textLines.length == 0) {
@@ -3010,6 +3022,7 @@ var Canvas = /** @class */ (function () {
3010
3022
  initPens: initPens,
3011
3023
  });
3012
3024
  _this.render();
3025
+ _this.store.emitter.emit('change', pen);
3013
3026
  _this.store.emitter.emit('valueUpdate', pen);
3014
3027
  };
3015
3028
  this.inFitBorder = function (pt) {
@@ -4389,8 +4402,8 @@ var Canvas = /** @class */ (function () {
4389
4402
  if (_this.store.data.pens[i].type &&
4390
4403
  _this.store.data.pens[i].lastConnected) {
4391
4404
  for (var key in _this.store.data.pens[i].lastConnected) {
4392
- _this.store.pens[key].connectedLines =
4393
- _this.store.data.pens[i].lastConnected[key];
4405
+ _this.store.pens[key] && (_this.store.pens[key].connectedLines =
4406
+ _this.store.data.pens[i].lastConnected[key]);
4394
4407
  }
4395
4408
  }
4396
4409
  _this.store.data.pens[i] = pen;
@@ -4430,7 +4443,7 @@ var Canvas = /** @class */ (function () {
4430
4443
  _this.store.pens[pen.id] = pen;
4431
4444
  if (pen.type && pen.lastConnected) {
4432
4445
  for (var key in pen.lastConnected) {
4433
- _this.store.pens[key].connectedLines = pen.lastConnected[key];
4446
+ _this.store.pens[key] && (_this.store.pens[key].connectedLines = pen.lastConnected[key]);
4434
4447
  }
4435
4448
  }
4436
4449
  pen.calculative.canvas = _this;
@@ -4482,7 +4495,7 @@ var Canvas = /** @class */ (function () {
4482
4495
  _this.store.pens[pen.id] = pen;
4483
4496
  if (pen.type && pen.lastConnected) {
4484
4497
  for (var key in pen.lastConnected) {
4485
- _this.store.pens[key].connectedLines = pen.lastConnected[key];
4498
+ _this.store.pens[key] && (_this.store.pens[key].connectedLines = pen.lastConnected[key]);
4486
4499
  }
4487
4500
  }
4488
4501
  pen.calculative.canvas = _this;
@@ -6116,7 +6129,7 @@ var Canvas = /** @class */ (function () {
6116
6129
  if (!pen.connectedLines) {
6117
6130
  return;
6118
6131
  }
6119
- pen.connectedLines.forEach(function (item) {
6132
+ pen.connectedLines.forEach(function (item, index) {
6120
6133
  var line = _this.store.pens[item.lineId];
6121
6134
  // 活动层的线不需要更新,会在活动层处理
6122
6135
  if (!line || line.calculative.active) {
@@ -6126,6 +6139,11 @@ var Canvas = /** @class */ (function () {
6126
6139
  if (!lineAnchor) {
6127
6140
  return;
6128
6141
  }
6142
+ if (!lineAnchor.connectTo) {
6143
+ // 如果pen有连接关系但连线中没有连接关系,删除pen的连接关系
6144
+ pen.connectedLines.splice(index, 1);
6145
+ return;
6146
+ }
6129
6147
  if (line.autoFrom) {
6130
6148
  var from = getFromAnchor(line);
6131
6149
  if (from.id === lineAnchor.id) {
@@ -7084,6 +7102,7 @@ var Canvas = /** @class */ (function () {
7084
7102
  _this.inputDiv.style.paddingTop = '';
7085
7103
  }
7086
7104
  }
7105
+ _this.store.emitter.emit('input', pen);
7087
7106
  };
7088
7107
  this.inputDiv.onclick = function (e) {
7089
7108
  e.stopPropagation();