@meta2d/core 1.1.3 → 1.1.4

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.1.3",
3
+ "version": "1.1.4",
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",
@@ -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;
@@ -2812,7 +2819,7 @@ export class Canvas {
2812
2819
  if (this.dragRect) {
2813
2820
  return;
2814
2821
  }
2815
- this.store.hoverContainer = undefined;
2822
+ // this.store.hoverContainer = undefined;
2816
2823
  const containerPens = this.store.data.pens.filter((pen) => pen.container || this.store.options.containerShapes?.includes(pen.name));
2817
2824
  if (containerPens.length) {
2818
2825
  for (let i = containerPens.length - 1; i >= 0; --i) {
@@ -2974,6 +2981,9 @@ export class Canvas {
2974
2981
  pen.locked === LockState.Disable) {
2975
2982
  continue;
2976
2983
  }
2984
+ if (this.store.data.locked && pen.name === 'sceneContainer') {
2985
+ continue;
2986
+ }
2977
2987
  const r = getLineR(pen);
2978
2988
  if (!pen.calculative.active &&
2979
2989
  !pointInSimpleRect(pt, pen.calculative.worldRect, r) &&
@@ -6023,10 +6033,25 @@ export class Canvas {
6023
6033
  this.store.clipboard = undefined;
6024
6034
  localStorage.removeItem(this.clipboardName);
6025
6035
  sessionStorage.setItem('page', page);
6026
- let copyPens = this.getAllByPens(deepClone(pens || this.store.active, true));
6036
+ let precCopyPens = deepClone(pens, true);
6037
+ if (!precCopyPens) {
6038
+ precCopyPens = deepClone(this.store.active, true);
6039
+ if (precCopyPens.length === 1 && precCopyPens[0].parentId) {
6040
+ //复制子图元
6041
+ precCopyPens[0].parentId = undefined;
6042
+ precCopyPens[0].x = precCopyPens[0].calculative.worldRect.x;
6043
+ precCopyPens[0].y = precCopyPens[0].calculative.worldRect.y;
6044
+ precCopyPens[0].width = precCopyPens[0].calculative.worldRect.width;
6045
+ precCopyPens[0].height = precCopyPens[0].calculative.worldRect.height;
6046
+ }
6047
+ }
6048
+ let copyPens = this.getAllByPens(precCopyPens);
6027
6049
  //根据pens顺序复制
6028
6050
  copyPens.forEach((activePen) => {
6029
6051
  activePen.copyIndex = this.store.data.pens.findIndex((pen) => pen.id === activePen.id);
6052
+ if (activePen.followers?.length) {
6053
+ activePen.followers = undefined;
6054
+ }
6030
6055
  if (activePen.pathId) {
6031
6056
  //复制svgpath
6032
6057
  activePen.path = this.store.data.paths[activePen.pathId];