@meta2d/core 1.0.47 → 1.0.49

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.47",
3
+ "version": "1.0.49",
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",
@@ -229,6 +229,7 @@ export declare class Canvas {
229
229
  onScroll: () => void;
230
230
  calibrateMouse: (pt: Point) => Point;
231
231
  clearHover(): void;
232
+ private getContainerHover;
232
233
  private getHover;
233
234
  private inPens;
234
235
  private dockInAnchor;
@@ -370,6 +371,8 @@ export declare class Canvas {
370
371
  * @param pens 不包含子节点
371
372
  */
372
373
  getAllByPens(pens: Pen[]): Pen[];
374
+ getAllFollowersByPens(pens: Pen[], deep?: boolean): Pen[];
375
+ setFollowers(pens?: Pen[]): void;
373
376
  /**
374
377
  *
375
378
  * @param pen 当前复制的画笔
@@ -82,7 +82,7 @@ var __values = (this && this.__values) || function(o) {
82
82
  throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
83
83
  };
84
84
  import { KeydownType } from '../options';
85
- import { addLineAnchor, calcIconRect, calcTextRect, calcWorldAnchors, calcWorldRects, LockState, nearestAnchor, PenType, pushPenAnchor, removePenAnchor, renderPen, scalePen, translateLine, deleteTempAnchor, connectLine, disconnectLine, getAnchor, calcAnchorDock, calcMoveDock, calcTextLines, setNodeAnimate, setLineAnimate, calcPenRect, setChildrenActive, getParent, setHover, randomId, getPensLock, getToAnchor, getFromAnchor, calcPadding, getPensDisableRotate, getPensDisableResize, needCalcTextRectProps, calcResizeDock, needPatchFlagsPenRectProps, needCalcIconRectProps, isDomShapes, renderPenRaw, needSetPenProps, getAllChildren, calcInView, isShowChild, getTextColor, getGlobalColor, clearLifeCycle, rotatePen, calcTextAutoWidth, getGradientAnimatePath, CanvasLayer, ctxFlip, ctxRotate, setGlobalAlpha, drawImage, setElemPosition, } from '../pen';
85
+ import { addLineAnchor, calcIconRect, calcTextRect, calcWorldAnchors, calcWorldRects, LockState, nearestAnchor, PenType, pushPenAnchor, removePenAnchor, renderPen, scalePen, translateLine, deleteTempAnchor, connectLine, disconnectLine, getAnchor, calcAnchorDock, calcMoveDock, calcTextLines, setNodeAnimate, setLineAnimate, calcPenRect, setChildrenActive, getParent, setHover, randomId, getPensLock, getToAnchor, getFromAnchor, calcPadding, getPensDisableRotate, getPensDisableResize, needCalcTextRectProps, calcResizeDock, needPatchFlagsPenRectProps, needCalcIconRectProps, isDomShapes, renderPenRaw, needSetPenProps, getAllChildren, calcInView, isShowChild, getTextColor, getGlobalColor, clearLifeCycle, rotatePen, calcTextAutoWidth, getGradientAnimatePath, CanvasLayer, ctxFlip, ctxRotate, setGlobalAlpha, drawImage, setElemPosition, getAllFollowers, } from '../pen';
86
86
  import { calcRotate, distance, getDistance, hitPoint, PointType, PrevNextType, rotatePoint, samePoint, scalePoint, translatePoint, TwoWay, } from '../point';
87
87
  import { calcCenter, calcRightBottom, calcRelativePoint, getRect, getRectOfPoints, pointInRect, pointInSimpleRect, rectInRect, rectToPoints, resizeRect, translateRect, pointInPolygon } from '../rect';
88
88
  import { EditType, globalStore, } from '../store';
@@ -289,25 +289,33 @@ var Canvas = /** @class */ (function () {
289
289
  return;
290
290
  }
291
291
  var scaleOff = 0.015;
292
- var isMac = /mac os /i.test(navigator.userAgent);
293
- if (isMac) {
294
- if (!e.ctrlKey) {
295
- scaleOff *= e.wheelDeltaY / 240;
296
- }
297
- else if (e.deltaY > 0) {
298
- scaleOff *= -1;
292
+ if (_this.store.options.scaleOff) {
293
+ scaleOff = _this.store.options.scaleOff;
294
+ if (e.deltaY > 0) {
295
+ scaleOff = -_this.store.options.scaleOff;
299
296
  }
300
297
  }
301
298
  else {
302
- var offset = 0.2;
303
- if (e.deltaY.toString().indexOf('.') !== -1) {
304
- offset = 0.01;
305
- }
306
- if (e.deltaY > 0) {
307
- scaleOff = -offset;
299
+ var isMac = /mac os /i.test(navigator.userAgent);
300
+ if (isMac) {
301
+ if (!e.ctrlKey) {
302
+ scaleOff *= e.wheelDeltaY / 240;
303
+ }
304
+ else if (e.deltaY > 0) {
305
+ scaleOff *= -1;
306
+ }
308
307
  }
309
308
  else {
310
- scaleOff = offset;
309
+ var offset = 0.2;
310
+ if (e.deltaY.toString().indexOf('.') !== -1) {
311
+ offset = 0.01;
312
+ }
313
+ if (e.deltaY > 0) {
314
+ scaleOff = -offset;
315
+ }
316
+ else {
317
+ scaleOff = offset;
318
+ }
311
319
  }
312
320
  }
313
321
  var x = e.offsetX, y = e.offsetY;
@@ -719,6 +727,10 @@ var Canvas = /** @class */ (function () {
719
727
  //置顶
720
728
  _this.parent.top();
721
729
  break;
730
+ case 'F':
731
+ case 'f':
732
+ _this.setFollowers();
733
+ break;
722
734
  }
723
735
  _this.render(false);
724
736
  };
@@ -1145,10 +1157,12 @@ var Canvas = /** @class */ (function () {
1145
1157
  _this.willInactivePen = pen;
1146
1158
  }
1147
1159
  else {
1148
- pen.calculative.active = true;
1149
- setChildrenActive(pen); // 子节点也设置为active
1150
- _this.store.active.push(pen);
1151
- _this.store.emitter.emit('active', _this.store.active);
1160
+ if (_this.store.active.length > 0) {
1161
+ pen.calculative.active = true;
1162
+ setChildrenActive(pen); // 子节点也设置为active
1163
+ _this.store.active.push(pen);
1164
+ _this.store.emitter.emit('active', _this.store.active);
1165
+ }
1152
1166
  }
1153
1167
  _this.patchFlags = true;
1154
1168
  }
@@ -1156,10 +1170,12 @@ var Canvas = /** @class */ (function () {
1156
1170
  _this.active([_this.store.hover]);
1157
1171
  }
1158
1172
  else {
1159
- if (!pen.calculative.active) {
1160
- _this.active([pen]);
1161
- if (_this.store.options.resizeMode) {
1162
- _this.hotkeyType = HotkeyType.Resize;
1173
+ if (!(_this.activeRect && pointInRect({ x: e.x, y: e.y }, _this.activeRect)) || _this.store.active.length == 1) {
1174
+ if (!pen.calculative.active) {
1175
+ _this.active([pen]);
1176
+ if (_this.store.options.resizeMode) {
1177
+ _this.hotkeyType = HotkeyType.Resize;
1178
+ }
1163
1179
  }
1164
1180
  }
1165
1181
  }
@@ -1282,7 +1298,7 @@ var Canvas = /** @class */ (function () {
1282
1298
  return;
1283
1299
  }
1284
1300
  // 框选
1285
- if (e.buttons === 1 && !_this.hoverType && !_this.hotkeyType) {
1301
+ if (e.buttons === 1 && (e.ctrlKey || !_this.hoverType && !_this.hotkeyType)) {
1286
1302
  _this.dragRect = {
1287
1303
  x: Math.min(_this.mouseDown.x, e.x),
1288
1304
  y: Math.min(_this.mouseDown.y, e.y),
@@ -1360,6 +1376,8 @@ var Canvas = /** @class */ (function () {
1360
1376
  }
1361
1377
  }
1362
1378
  _this.movePens(e);
1379
+ //图元是否进入容器图元
1380
+ _this.getContainerHover(e);
1363
1381
  return;
1364
1382
  }
1365
1383
  }
@@ -1617,7 +1635,7 @@ var Canvas = /** @class */ (function () {
1617
1635
  pen.parentId || pen.isRuleLine) {
1618
1636
  return false;
1619
1637
  }
1620
- if (rectInRect(pen.calculative.worldRect, _this.dragRect, _this.store.options.dragAllIn)) {
1638
+ if (rectInRect(pen.calculative.worldRect, _this.dragRect, e.ctrlKey || _this.store.options.dragAllIn)) {
1621
1639
  // 先判断在区域内,若不在区域内,则锚点肯定不在框选区域内,避免每条连线过度计算
1622
1640
  if (pen.type === PenType.Line && !_this.store.options.dragAllIn) {
1623
1641
  return lineInRect(pen, _this.dragRect);
@@ -1644,6 +1662,11 @@ var Canvas = /** @class */ (function () {
1644
1662
  y: e.y,
1645
1663
  pen: _this.store.hover,
1646
1664
  });
1665
+ _this.store.emitter.emit('mouseup', {
1666
+ x: e.x,
1667
+ y: e.y,
1668
+ pen: _this.store.hoverContainer,
1669
+ });
1647
1670
  }
1648
1671
  if (_this.willInactivePen) {
1649
1672
  _this.willInactivePen.calculative.active = undefined;
@@ -1714,6 +1737,52 @@ var Canvas = /** @class */ (function () {
1714
1737
  pt.y -= _this.store.data.y;
1715
1738
  return pt;
1716
1739
  };
1740
+ this.getContainerHover = function (pt) {
1741
+ var _a;
1742
+ if (_this.dragRect) {
1743
+ return;
1744
+ }
1745
+ _this.store.hoverContainer = undefined;
1746
+ var containerPens = _this.store.data.pens.filter(function (pen) { var _a; return pen.container || ((_a = _this.store.options.containerShapes) === null || _a === void 0 ? void 0 : _a.includes(pen.name)); });
1747
+ if (containerPens.length) {
1748
+ for (var i = containerPens.length - 1; i >= 0; --i) {
1749
+ var pen = containerPens[i];
1750
+ if (pen.visible == false ||
1751
+ pen.calculative.inView == false ||
1752
+ pen.locked === LockState.Disable ||
1753
+ pen.calculative.active) {
1754
+ continue;
1755
+ }
1756
+ if (pointInRect(pt, pen.calculative.worldRect)) {
1757
+ _this.store.hoverContainer = pen;
1758
+ (_a = pen === null || pen === void 0 ? void 0 : pen.onMouseMove) === null || _a === void 0 ? void 0 : _a.call(pen, pen, pt);
1759
+ if (_this.store.lastHoverContainer !== _this.store.hoverContainer) {
1760
+ _this.patchFlags = true;
1761
+ if (_this.store.lastHoverContainer) {
1762
+ _this.store.lastHoverContainer.calculative.containerHover = false;
1763
+ _this.store.emitter.emit('leave', _this.store.lastHoverContainer);
1764
+ }
1765
+ if (_this.store.hoverContainer) {
1766
+ _this.store.hoverContainer.calculative.containerHover = true;
1767
+ _this.store.emitter.emit('enter', _this.store.hoverContainer);
1768
+ }
1769
+ _this.store.lastHoverContainer = _this.store.hoverContainer;
1770
+ }
1771
+ }
1772
+ else {
1773
+ _this.store.hoverContainer = undefined;
1774
+ if (_this.store.lastHoverContainer !== _this.store.hoverContainer) {
1775
+ _this.patchFlags = true;
1776
+ if (_this.store.lastHoverContainer) {
1777
+ _this.store.lastHoverContainer.calculative.containerHover = false;
1778
+ _this.store.emitter.emit('leave', _this.store.lastHoverContainer);
1779
+ }
1780
+ _this.store.lastHoverContainer = _this.store.hoverContainer;
1781
+ }
1782
+ }
1783
+ }
1784
+ }
1785
+ };
1717
1786
  this.getHover = function (pt) {
1718
1787
  var _a, _b;
1719
1788
  if (_this.dragRect) {
@@ -1742,7 +1811,7 @@ var Canvas = /** @class */ (function () {
1742
1811
  y: _this.activeRect.y - 30,
1743
1812
  };
1744
1813
  if (_this.activeRect.rotate) {
1745
- rotatePoint(rotatePt, _this.activeRect.rotate, _this.activeRect.center);
1814
+ rotatePoint(rotatePt, _this.activeRect.rotate, _this.activeRect.pivot || _this.activeRect.center);
1746
1815
  }
1747
1816
  // 旋转控制点
1748
1817
  if (!_this.hotkeyType && hitPoint(pt, rotatePt, _this.pointSize)) {
@@ -1896,6 +1965,9 @@ var Canvas = /** @class */ (function () {
1896
1965
  else {
1897
1966
  _this.externalElements.style.cursor = _this.store.options.hoverCursor;
1898
1967
  }
1968
+ if (pen.calculative.disabled) {
1969
+ _this.externalElements.style.cursor = 'not-allowed';
1970
+ }
1899
1971
  _this.store.hover = pen;
1900
1972
  _this.store.pointAt = pos.point;
1901
1973
  _this.store.pointAtIndex = pos.i;
@@ -1940,6 +2012,9 @@ var Canvas = /** @class */ (function () {
1940
2012
  else {
1941
2013
  _this.externalElements.style.cursor = _this.store.options.hoverCursor;
1942
2014
  }
2015
+ if (pen.calculative.disabled) {
2016
+ _this.externalElements.style.cursor = 'not-allowed';
2017
+ }
1943
2018
  _this.store.hover = pen;
1944
2019
  _this.initTemplateCanvas([_this.store.hover]);
1945
2020
  hoverType = HoverType.Node;
@@ -2186,10 +2261,11 @@ var Canvas = /** @class */ (function () {
2186
2261
  var ctx = _this.offscreen.getContext('2d');
2187
2262
  ctx.save();
2188
2263
  ctx.translate(0.5, 0.5);
2264
+ var pivot = _this.activeRect.pivot || _this.activeRect.center;
2189
2265
  if (_this.activeRect.rotate) {
2190
- ctx.translate(_this.activeRect.center.x, _this.activeRect.center.y);
2266
+ ctx.translate(pivot.x, pivot.y);
2191
2267
  ctx.rotate((_this.activeRect.rotate * Math.PI) / 180);
2192
- ctx.translate(-_this.activeRect.center.x, -_this.activeRect.center.y);
2268
+ ctx.translate(-pivot.x, -pivot.y);
2193
2269
  }
2194
2270
  ctx.strokeStyle = _this.store.options.activeColor;
2195
2271
  ctx.globalAlpha = _this.store.options.activeGlobalAlpha === undefined ? 0.3 : _this.store.options.activeGlobalAlpha;
@@ -2483,7 +2559,8 @@ var Canvas = /** @class */ (function () {
2483
2559
  !_this.store.hover ||
2484
2560
  _this.store.hover.locked ||
2485
2561
  _this.store.hover.externElement ||
2486
- _this.store.hover.disableInput) {
2562
+ _this.store.hover.disableInput ||
2563
+ _this.store.hover.disabled) {
2487
2564
  return;
2488
2565
  }
2489
2566
  if (_this.inputDiv.dataset.penId === pen.id) {
@@ -2761,7 +2838,8 @@ var Canvas = /** @class */ (function () {
2761
2838
  this.setDropdownList = function (search) {
2762
2839
  var e_6, _a;
2763
2840
  _this.clearDropdownList();
2764
- if (!_this.store.data.locked) {
2841
+ var pen = _this.store.pens[_this.inputDiv.dataset.penId];
2842
+ if (!_this.store.data.locked && !['table'].includes(pen.name)) {
2765
2843
  return;
2766
2844
  }
2767
2845
  _this.dropdown.style.display = 'block';
@@ -2770,7 +2848,6 @@ var Canvas = /** @class */ (function () {
2770
2848
  _this.inputRight.style.transform = 'rotate(315deg)';
2771
2849
  _this.inputRight.style.zoom = _this.store.data.scale;
2772
2850
  });
2773
- var pen = _this.store.pens[_this.inputDiv.dataset.penId];
2774
2851
  if (!pen || !pen.dropdownList) {
2775
2852
  _this.dropdown.style.display = 'none';
2776
2853
  _this.inputRight.style.display = 'none';
@@ -3536,13 +3613,19 @@ var Canvas = /** @class */ (function () {
3536
3613
  Canvas.prototype.movedActivePens = function (readyConnect) {
3537
3614
  var _this = this;
3538
3615
  // 鼠标松手才更新,此处是更新前的值
3539
- var initPens = deepClone(this.store.active, true);
3616
+ //follower
3617
+ var movedPens = this.getAllFollowersByPens(this.store.active, false);
3618
+ var initPens = deepClone(movedPens, true);
3540
3619
  // const pens = deepClone(this.store.active, true);
3541
3620
  var gridSize = this.store.data.gridSize || this.store.options.gridSize;
3542
3621
  var _a = this.store.data, origin = _a.origin, scale = _a.scale;
3543
3622
  var autoAlignGrid = this.store.options.autoAlignGrid && this.store.data.grid;
3544
- this.store.active.forEach(function (pen, i) {
3623
+ movedPens.forEach(function (pen) {
3545
3624
  var _a;
3625
+ var i = _this.movingPens.findIndex(function (item) { return item.id === pen.id + movingSuffix; });
3626
+ if (i < 0) {
3627
+ return;
3628
+ }
3546
3629
  var _b = _this.movingPens[i], x = _b.x, y = _b.y;
3547
3630
  var obj = { x: x, y: y };
3548
3631
  // 根据是否开启了自动网格对齐,来修正坐标
@@ -4786,10 +4869,10 @@ var Canvas = /** @class */ (function () {
4786
4869
  : pen.textHeight * scale;
4787
4870
  pen.calculative.textLeft =
4788
4871
  pen.textLeft < 1 && pen.textLeft > -1
4789
- ? pen.textLeft
4872
+ ? pen.textLeft * pen.calculative.worldRect.width
4790
4873
  : pen.textLeft * scale;
4791
4874
  pen.calculative.textTop =
4792
- pen.textTop < 1 && pen.textTop > -1 ? pen.textTop : pen.textTop * scale;
4875
+ pen.textTop < 1 && pen.textTop > -1 ? pen.textTop * pen.calculative.worldRect.height : pen.textTop * scale;
4793
4876
  if (pen.type === PenType.Line && pen.borderWidth) {
4794
4877
  pen.calculative.borderWidth = pen.borderWidth * scale;
4795
4878
  }
@@ -5344,6 +5427,7 @@ var Canvas = /** @class */ (function () {
5344
5427
  }
5345
5428
  }
5346
5429
  this.movingPens = deepClone(this.store.active, true);
5430
+ this.movingPens = this.getAllFollowersByPens(this.movingPens);
5347
5431
  var containChildPens = this.getAllByPens(this.movingPens);
5348
5432
  var copyContainChildPens = deepClone(containChildPens, true);
5349
5433
  // 考虑父子关系,修改 id
@@ -6266,6 +6350,10 @@ var Canvas = /** @class */ (function () {
6266
6350
  //根据pens顺序复制
6267
6351
  copyPens.forEach(function (activePen) {
6268
6352
  activePen.copyIndex = _this.store.data.pens.findIndex(function (pen) { return pen.id === activePen.id; });
6353
+ if (activePen.pathId) {
6354
+ //复制svgpath
6355
+ activePen.path = _this.store.data.paths[activePen.pathId];
6356
+ }
6269
6357
  });
6270
6358
  copyPens.sort(function (a, b) {
6271
6359
  return a.copyIndex - b.copyIndex;
@@ -6429,6 +6517,71 @@ var Canvas = /** @class */ (function () {
6429
6517
  }
6430
6518
  return retPens.concat(pens);
6431
6519
  };
6520
+ Canvas.prototype.getAllFollowersByPens = function (pens, deep) {
6521
+ var e_22, _a, e_23, _b;
6522
+ if (deep === void 0) { deep = true; }
6523
+ var retPens = pens;
6524
+ try {
6525
+ for (var pens_10 = __values(pens), pens_10_1 = pens_10.next(); !pens_10_1.done; pens_10_1 = pens_10.next()) {
6526
+ var pen = pens_10_1.value;
6527
+ var followers = getAllFollowers(pen, this.store);
6528
+ if (deep) {
6529
+ followers = deepClone(followers, true);
6530
+ }
6531
+ var _loop_6 = function (follower) {
6532
+ if (!retPens.find(function (p) { return p.id === follower.id; })) {
6533
+ retPens.push(follower);
6534
+ }
6535
+ };
6536
+ try {
6537
+ for (var followers_1 = (e_23 = void 0, __values(followers)), followers_1_1 = followers_1.next(); !followers_1_1.done; followers_1_1 = followers_1.next()) {
6538
+ var follower = followers_1_1.value;
6539
+ _loop_6(follower);
6540
+ }
6541
+ }
6542
+ catch (e_23_1) { e_23 = { error: e_23_1 }; }
6543
+ finally {
6544
+ try {
6545
+ if (followers_1_1 && !followers_1_1.done && (_b = followers_1.return)) _b.call(followers_1);
6546
+ }
6547
+ finally { if (e_23) throw e_23.error; }
6548
+ }
6549
+ }
6550
+ }
6551
+ catch (e_22_1) { e_22 = { error: e_22_1 }; }
6552
+ finally {
6553
+ try {
6554
+ if (pens_10_1 && !pens_10_1.done && (_a = pens_10.return)) _a.call(pens_10);
6555
+ }
6556
+ finally { if (e_22) throw e_22.error; }
6557
+ }
6558
+ return retPens;
6559
+ };
6560
+ Canvas.prototype.setFollowers = function (pens) {
6561
+ if (pens === void 0) { pens = this.store.active; }
6562
+ if (!pens) {
6563
+ return;
6564
+ }
6565
+ if (pens.length < 2) {
6566
+ pens[0].followers = [];
6567
+ }
6568
+ else {
6569
+ //以最后一个
6570
+ var ids = pens.map(function (pen) { return pen.id; });
6571
+ ids.pop();
6572
+ var lastPen_1 = pens[pens.length - 1];
6573
+ if (!lastPen_1.followers) {
6574
+ lastPen_1.followers = ids;
6575
+ }
6576
+ else {
6577
+ ids.forEach(function (id) {
6578
+ if (!lastPen_1.followers.includes(id)) {
6579
+ lastPen_1.followers.push(id);
6580
+ }
6581
+ });
6582
+ }
6583
+ }
6584
+ };
6432
6585
  /**
6433
6586
  * 修改对应连线的 anchors
6434
6587
  * @param oldId 老 id
@@ -6439,7 +6592,7 @@ var Canvas = /** @class */ (function () {
6439
6592
  if (!Array.isArray(pen.connectedLines)) {
6440
6593
  return;
6441
6594
  }
6442
- var _loop_6 = function (index) {
6595
+ var _loop_7 = function (index) {
6443
6596
  var lineId = pen.connectedLines[index].lineId;
6444
6597
  var line = pastePens.find(function (pen) { return pen.id === lineId; });
6445
6598
  if (line) {
@@ -6457,7 +6610,7 @@ var Canvas = /** @class */ (function () {
6457
6610
  };
6458
6611
  var out_index_1;
6459
6612
  for (var index = 0; index < pen.connectedLines.length; index++) {
6460
- _loop_6(index);
6613
+ _loop_7(index);
6461
6614
  index = out_index_1;
6462
6615
  }
6463
6616
  };
@@ -6468,13 +6621,13 @@ var Canvas = /** @class */ (function () {
6468
6621
  * @param pastePens 此处复制的全部 pens (包含子节点)
6469
6622
  */
6470
6623
  Canvas.prototype.changeNodeConnectedLine = function (oldId, line, pastePens) {
6471
- var e_22, _a;
6624
+ var e_24, _a;
6472
6625
  var _b;
6473
6626
  var from = line.anchors[0];
6474
6627
  var to = line.anchors[line.anchors.length - 1];
6475
6628
  // 修改对应节点的 connectedLines
6476
6629
  var anchors = [from, to];
6477
- var _loop_7 = function (anchor) {
6630
+ var _loop_8 = function (anchor) {
6478
6631
  var nodeId = anchor.connectTo;
6479
6632
  if (nodeId) {
6480
6633
  var node = pastePens.find(function (pen) { return pen.id === nodeId; });
@@ -6501,15 +6654,15 @@ var Canvas = /** @class */ (function () {
6501
6654
  try {
6502
6655
  for (var anchors_1 = __values(anchors), anchors_1_1 = anchors_1.next(); !anchors_1_1.done; anchors_1_1 = anchors_1.next()) {
6503
6656
  var anchor = anchors_1_1.value;
6504
- _loop_7(anchor);
6657
+ _loop_8(anchor);
6505
6658
  }
6506
6659
  }
6507
- catch (e_22_1) { e_22 = { error: e_22_1 }; }
6660
+ catch (e_24_1) { e_24 = { error: e_24_1 }; }
6508
6661
  finally {
6509
6662
  try {
6510
6663
  if (anchors_1_1 && !anchors_1_1.done && (_a = anchors_1.return)) _a.call(anchors_1);
6511
6664
  }
6512
- finally { if (e_22) throw e_22.error; }
6665
+ finally { if (e_24) throw e_24.error; }
6513
6666
  }
6514
6667
  };
6515
6668
  Canvas.prototype.delete = function (pens, canDelLocked, history) {
@@ -6652,7 +6805,7 @@ var Canvas = /** @class */ (function () {
6652
6805
  var _this = this;
6653
6806
  var _a;
6654
6807
  if (pen.connectedLines) {
6655
- var _loop_8 = function (i) {
6808
+ var _loop_9 = function (i) {
6656
6809
  var _b = pen.connectedLines[i], lineId = _b.lineId, lineAnchor = _b.lineAnchor;
6657
6810
  var line = this_2.store.pens[lineId];
6658
6811
  if (line) {
@@ -6674,7 +6827,7 @@ var Canvas = /** @class */ (function () {
6674
6827
  };
6675
6828
  var this_2 = this;
6676
6829
  for (var i = 0; i < pen.connectedLines.length; i++) {
6677
- _loop_8(i);
6830
+ _loop_9(i);
6678
6831
  }
6679
6832
  }
6680
6833
  if (!pen.type) {
@@ -6770,6 +6923,16 @@ var Canvas = /** @class */ (function () {
6770
6923
  }, 300);
6771
6924
  };
6772
6925
  this.inputDiv.oninput = function (e) {
6926
+ var pen = _this.store.pens[_this.inputDiv.dataset.penId];
6927
+ if (pen.inputType === 'number') {
6928
+ var value = e.target.innerText;
6929
+ var numericValue = value.replace(/[^0-9]/g, ''); // 移除非数字字符
6930
+ // 如果输入的值不是纯数字,则替换为纯数字
6931
+ if (value !== numericValue) {
6932
+ e.preventDefault();
6933
+ e.target.innerText = numericValue;
6934
+ }
6935
+ }
6773
6936
  // //无文本时,光标确保居中
6774
6937
  if (navigator.userAgent.includes('Firefox')) {
6775
6938
  if (!e.target.innerText.trim()) {
@@ -7117,7 +7280,7 @@ var Canvas = /** @class */ (function () {
7117
7280
  };
7118
7281
  };
7119
7282
  Canvas.prototype.toPng = function (padding, callback, containBkImg, maxWidth) {
7120
- var e_23, _a;
7283
+ var e_25, _a;
7121
7284
  if (padding === void 0) { padding = 2; }
7122
7285
  if (containBkImg === void 0) { containBkImg = false; }
7123
7286
  var rect = getRect(this.store.data.pens);
@@ -7249,12 +7412,12 @@ var Canvas = /** @class */ (function () {
7249
7412
  pen.calculative.active = active;
7250
7413
  }
7251
7414
  }
7252
- catch (e_23_1) { e_23 = { error: e_23_1 }; }
7415
+ catch (e_25_1) { e_25 = { error: e_25_1 }; }
7253
7416
  finally {
7254
7417
  try {
7255
7418
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
7256
7419
  }
7257
- finally { if (e_23) throw e_23.error; }
7420
+ finally { if (e_25) throw e_25.error; }
7258
7421
  }
7259
7422
  if (callback) {
7260
7423
  canvas.toBlob(callback);
@@ -7267,7 +7430,7 @@ var Canvas = /** @class */ (function () {
7267
7430
  return this.pensToPng(this.store.active, padding);
7268
7431
  };
7269
7432
  Canvas.prototype.pensToPng = function (pens, padding) {
7270
- var e_24, _a;
7433
+ var e_26, _a;
7271
7434
  if (pens === void 0) { pens = this.store.active; }
7272
7435
  if (padding === void 0) { padding = 2; }
7273
7436
  if (pens.length === 0) {
@@ -7321,12 +7484,12 @@ var Canvas = /** @class */ (function () {
7321
7484
  }
7322
7485
  }
7323
7486
  }
7324
- catch (e_24_1) { e_24 = { error: e_24_1 }; }
7487
+ catch (e_26_1) { e_26 = { error: e_26_1 }; }
7325
7488
  finally {
7326
7489
  try {
7327
7490
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
7328
7491
  }
7329
- finally { if (e_24) throw e_24.error; }
7492
+ finally { if (e_26) throw e_26.error; }
7330
7493
  }
7331
7494
  return canvas.toDataURL();
7332
7495
  };