@meta2d/core 1.1.3 → 1.1.5
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 +1 -1
- package/src/canvas/canvas.js +33 -6
- package/src/canvas/canvas.js.map +1 -1
- package/src/core.js +28 -10
- package/src/core.js.map +1 -1
- package/src/diagrams/form.js +55 -12
- package/src/diagrams/form.js.map +1 -1
- package/src/diagrams/index.d.ts +3 -0
- package/src/diagrams/index.js +3 -0
- package/src/diagrams/index.js.map +1 -1
- package/src/diagrams/sceneContainer.d.ts +2 -0
- package/src/diagrams/sceneContainer.js +112 -0
- package/src/diagrams/sceneContainer.js.map +1 -0
- package/src/pen/model.d.ts +1 -0
- package/src/pen/model.js.map +1 -1
- package/src/pen/plugin.js +1 -1
- package/src/pen/plugin.js.map +1 -1
- package/src/pen/render.js +2 -1
- package/src/pen/render.js.map +1 -1
- package/src/store/store.js +2 -1
- package/src/store/store.js.map +1 -1
- package/src/tooltip/tooltip.js +3 -0
- package/src/tooltip/tooltip.js.map +1 -1
- package/src/utils/debounce.d.ts +2 -0
- package/src/utils/debounce.js +28 -0
- package/src/utils/debounce.js.map +1 -0
- package/src/utils/index.d.ts +1 -0
- package/src/utils/index.js +1 -0
- package/src/utils/index.js.map +1 -1
package/package.json
CHANGED
package/src/canvas/canvas.js
CHANGED
|
@@ -1122,7 +1122,7 @@ export class Canvas {
|
|
|
1122
1122
|
if (obj[0] && obj[0].draggable !== false) {
|
|
1123
1123
|
const pt = { x: event.offsetX, y: event.offsetY };
|
|
1124
1124
|
this.calibrateMouse(pt);
|
|
1125
|
-
this.dropPens(obj, pt);
|
|
1125
|
+
await this.dropPens(obj, pt);
|
|
1126
1126
|
this.addCaches = [];
|
|
1127
1127
|
// 拖拽新增图元判断是否是在容器上
|
|
1128
1128
|
this.getContainerHover(pt);
|
|
@@ -1328,6 +1328,13 @@ export class Canvas {
|
|
|
1328
1328
|
return [];
|
|
1329
1329
|
}
|
|
1330
1330
|
const list = [];
|
|
1331
|
+
for (const pen of pens) {
|
|
1332
|
+
if (!pen.id) {
|
|
1333
|
+
pen.id = s8();
|
|
1334
|
+
}
|
|
1335
|
+
!pen.calculative && (pen.calculative = { canvas: this });
|
|
1336
|
+
this.store.pens[pen.id] = pen;
|
|
1337
|
+
}
|
|
1331
1338
|
for (const pen of pens) {
|
|
1332
1339
|
if (this.beforeAddPen && this.beforeAddPen(pen) != true) {
|
|
1333
1340
|
continue;
|
|
@@ -1383,6 +1390,7 @@ export class Canvas {
|
|
|
1383
1390
|
buttons: 1,
|
|
1384
1391
|
});
|
|
1385
1392
|
if (e.touches.length === 2) {
|
|
1393
|
+
this.mouseDown = undefined;
|
|
1386
1394
|
this.initTouchDis = Math.hypot(e.touches[0].pageX - e.touches[1].pageX, e.touches[0].pageY - e.touches[1].pageY);
|
|
1387
1395
|
this.initScale = this.store.data.scale;
|
|
1388
1396
|
this.startTouches = e.touches;
|
|
@@ -1450,16 +1458,17 @@ export class Canvas {
|
|
|
1450
1458
|
});
|
|
1451
1459
|
}
|
|
1452
1460
|
else if (len === 2 && this.startTouches?.length === 2) {
|
|
1461
|
+
this.mouseDown = undefined;
|
|
1453
1462
|
if (!this.touchMoving && !this.touchScaling) {
|
|
1454
1463
|
const x1 = this.startTouches[0].pageX - touches[0].pageX;
|
|
1455
1464
|
const x2 = this.startTouches[1].pageX - touches[1].pageX;
|
|
1456
1465
|
const y1 = this.startTouches[0].pageY - touches[0].pageY;
|
|
1457
1466
|
const y2 = this.startTouches[1].pageY - touches[1].pageY;
|
|
1458
|
-
if (((x1 >= 0 && x2 < 0) || (x1 <= 0 && x2 > 0)) &&
|
|
1459
|
-
((y1 >= 0 && y2 < 0) || (y1 <= 0 && y2 > 0))) {
|
|
1467
|
+
if ((((x1 >= 0 && x2 < 0) || (x1 <= 0 && x2 > 0)) &&
|
|
1468
|
+
((y1 >= 0 && y2 < 0) || (y1 <= 0 && y2 > 0))) || (x2 == 0 && y2 == 0) || (x1 == 0 && y1 == 0)) {
|
|
1460
1469
|
this.touchScaling = true;
|
|
1461
1470
|
}
|
|
1462
|
-
else {
|
|
1471
|
+
else if (y1 * y2 > 0 && x1 * x2 > 0) {
|
|
1463
1472
|
this.touchMoving = true;
|
|
1464
1473
|
}
|
|
1465
1474
|
}
|
|
@@ -2812,7 +2821,7 @@ export class Canvas {
|
|
|
2812
2821
|
if (this.dragRect) {
|
|
2813
2822
|
return;
|
|
2814
2823
|
}
|
|
2815
|
-
this.store.hoverContainer = undefined;
|
|
2824
|
+
// this.store.hoverContainer = undefined;
|
|
2816
2825
|
const containerPens = this.store.data.pens.filter((pen) => pen.container || this.store.options.containerShapes?.includes(pen.name));
|
|
2817
2826
|
if (containerPens.length) {
|
|
2818
2827
|
for (let i = containerPens.length - 1; i >= 0; --i) {
|
|
@@ -2974,6 +2983,9 @@ export class Canvas {
|
|
|
2974
2983
|
pen.locked === LockState.Disable) {
|
|
2975
2984
|
continue;
|
|
2976
2985
|
}
|
|
2986
|
+
if (this.store.data.locked && pen.name === 'sceneContainer') {
|
|
2987
|
+
continue;
|
|
2988
|
+
}
|
|
2977
2989
|
const r = getLineR(pen);
|
|
2978
2990
|
if (!pen.calculative.active &&
|
|
2979
2991
|
!pointInSimpleRect(pt, pen.calculative.worldRect, r) &&
|
|
@@ -6023,10 +6035,25 @@ export class Canvas {
|
|
|
6023
6035
|
this.store.clipboard = undefined;
|
|
6024
6036
|
localStorage.removeItem(this.clipboardName);
|
|
6025
6037
|
sessionStorage.setItem('page', page);
|
|
6026
|
-
let
|
|
6038
|
+
let precCopyPens = deepClone(pens, true);
|
|
6039
|
+
if (!precCopyPens) {
|
|
6040
|
+
precCopyPens = deepClone(this.store.active, true);
|
|
6041
|
+
if (precCopyPens.length === 1 && precCopyPens[0].parentId) {
|
|
6042
|
+
//复制子图元
|
|
6043
|
+
precCopyPens[0].parentId = undefined;
|
|
6044
|
+
precCopyPens[0].x = precCopyPens[0].calculative.worldRect.x;
|
|
6045
|
+
precCopyPens[0].y = precCopyPens[0].calculative.worldRect.y;
|
|
6046
|
+
precCopyPens[0].width = precCopyPens[0].calculative.worldRect.width;
|
|
6047
|
+
precCopyPens[0].height = precCopyPens[0].calculative.worldRect.height;
|
|
6048
|
+
}
|
|
6049
|
+
}
|
|
6050
|
+
let copyPens = this.getAllByPens(precCopyPens);
|
|
6027
6051
|
//根据pens顺序复制
|
|
6028
6052
|
copyPens.forEach((activePen) => {
|
|
6029
6053
|
activePen.copyIndex = this.store.data.pens.findIndex((pen) => pen.id === activePen.id);
|
|
6054
|
+
if (activePen.followers?.length) {
|
|
6055
|
+
activePen.followers = undefined;
|
|
6056
|
+
}
|
|
6030
6057
|
if (activePen.pathId) {
|
|
6031
6058
|
//复制svgpath
|
|
6032
6059
|
activePen.path = this.store.data.paths[activePen.pathId];
|