@meta2d/core 1.0.77 → 1.0.79

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.77",
3
+ "version": "1.0.79",
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",
@@ -1115,6 +1115,8 @@ export class Canvas {
1115
1115
  !pen.parentId && this.randomCombineId(pen, pens);
1116
1116
  }
1117
1117
  if (Object.keys(this.randomIdObj).length !== 0) {
1118
+ const keys = Object.keys(this.randomIdObj).join('|');
1119
+ const regex = new RegExp(`(${keys})`, "g");
1118
1120
  for (const pen of pens) {
1119
1121
  if (pen.type) {
1120
1122
  pen.anchors[0].connectTo = this.randomIdObj[pen.anchors[0].connectTo];
@@ -1127,6 +1129,19 @@ export class Canvas {
1127
1129
  item.lineId = this.randomIdObj[item.lineId];
1128
1130
  });
1129
1131
  }
1132
+ //动画、事件和状态
1133
+ if (pen.animations?.length) {
1134
+ const str = JSON.stringify(pen.animations).replace(regex, match => this.randomIdObj[match]);
1135
+ pen.animations = JSON.parse(str);
1136
+ }
1137
+ if (pen.triggers?.length) {
1138
+ const str = JSON.stringify(pen.triggers).replace(regex, match => this.randomIdObj[match]);
1139
+ pen.triggers = JSON.parse(str);
1140
+ }
1141
+ if (pen.events?.length) {
1142
+ const str = JSON.stringify(pen.events).replace(regex, match => this.randomIdObj[match]);
1143
+ pen.events = JSON.parse(str);
1144
+ }
1130
1145
  }
1131
1146
  }
1132
1147
  for (const pen of pens) {
@@ -1235,14 +1250,19 @@ export class Canvas {
1235
1250
  pen.anchors[pen.anchors.length - 1].id,
1236
1251
  ];
1237
1252
  }
1253
+ else {
1254
+ beforeIds = [pen.id];
1255
+ }
1238
1256
  }
1239
1257
  else {
1240
- if (pen.connectedLines && pen.connectedLines.length) {
1258
+ if (pens.length > 1) {
1259
+ // if (pen.connectedLines && pen.connectedLines.length) {
1241
1260
  beforeIds = [pen.id];
1242
1261
  }
1243
1262
  }
1244
1263
  randomId(pen);
1245
- if (beforeIds) {
1264
+ if (pens.length > 1) {
1265
+ // if (beforeIds) {
1246
1266
  if (beforeIds.length === 1) {
1247
1267
  this.randomIdObj[beforeIds[0]] = pen.id;
1248
1268
  }