@meta2d/core 1.1.23 → 1.1.24

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.23",
3
+ "version": "1.1.24",
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",
@@ -3606,6 +3606,12 @@ export class Canvas {
3606
3606
  const i = this.store.data.pens.findIndex((item) => item.id === pen.id);
3607
3607
  if (i > -1) {
3608
3608
  pen.onDestroy?.(this.store.pens[pen.id]);
3609
+ const parent = pen.parentId
3610
+ ? this.store.pens[pen.parentId]
3611
+ : undefined;
3612
+ if (parent?.children) {
3613
+ parent.children = parent.children.filter((item) => item !== pen.id);
3614
+ }
3609
3615
  this.store.data.pens.splice(i, 1);
3610
3616
  this.store.pens[pen.id] = undefined;
3611
3617
  if (!pen.calculative) {
@@ -3678,6 +3684,13 @@ export class Canvas {
3678
3684
  }
3679
3685
  // 先放进去,pens 可能是子节点在前,而父节点在后
3680
3686
  this.store.pens[pen.id] = pen;
3687
+ if (pen.parentId) {
3688
+ !this.store.pens[pen.parentId].children &&
3689
+ (this.store.pens[pen.parentId].children = []);
3690
+ if (!this.store.pens[pen.parentId].children.includes(pen.id)) {
3691
+ this.store.pens[pen.parentId].children.push(pen.id);
3692
+ }
3693
+ }
3681
3694
  if (pen.type && pen.lastConnected) {
3682
3695
  for (let key in pen.lastConnected) {
3683
3696
  this.store.pens[key] && (this.store.pens[key].connectedLines = pen.lastConnected[key]);