@meta2d/core 1.0.26 → 1.0.27

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/src/core.d.ts CHANGED
@@ -282,6 +282,7 @@ export declare class Meta2d {
282
282
  formatPainter(): void;
283
283
  clearFormatPainter(): void;
284
284
  alignNodes(align: string, pens?: Pen[], rect?: Rect): void;
285
+ alignNodesV(align: string, pens?: Pen[]): void;
285
286
  /**
286
287
  * 对齐画笔,基于第一个画笔
287
288
  * @param align 左对齐,右对齐,上对齐,下对齐,居中对齐
package/src/core.js CHANGED
@@ -1234,7 +1234,8 @@ var Meta2d = /** @class */ (function () {
1234
1234
  // 没有参数 则播放有自动播放属性的动画
1235
1235
  if (!idOrTagOrPens) {
1236
1236
  pens = this.store.data.pens.filter(function (pen) {
1237
- return ((pen.type || pen.frames) && pen.autoPlay) || (pen.animations && pen.autoPlay);
1237
+ return (((pen.type || pen.frames) && pen.autoPlay) ||
1238
+ (pen.animations && pen.autoPlay));
1238
1239
  });
1239
1240
  }
1240
1241
  else if (typeof idOrTagOrPens === 'string') {
@@ -1341,7 +1342,8 @@ var Meta2d = /** @class */ (function () {
1341
1342
  });
1342
1343
  this.initImageCanvas(pens);
1343
1344
  setTimeout(function () {
1344
- _this.canvas.calcActiveRect();
1345
+ var _a;
1346
+ (_a = _this.canvas) === null || _a === void 0 ? void 0 : _a.calcActiveRect();
1345
1347
  _this.render();
1346
1348
  }, 20);
1347
1349
  };
@@ -2896,6 +2898,38 @@ var Meta2d = /** @class */ (function () {
2896
2898
  pens: pens,
2897
2899
  });
2898
2900
  };
2901
+ //对齐大屏
2902
+ Meta2d.prototype.alignNodesV = function (align, pens) {
2903
+ var e_9, _a;
2904
+ if (pens === void 0) { pens = this.store.data.pens; }
2905
+ var width = this.store.data.width || this.store.options.width;
2906
+ var height = this.store.data.height || this.store.options.height;
2907
+ var rect = {
2908
+ x: 0,
2909
+ y: 0,
2910
+ width: width,
2911
+ height: height,
2912
+ };
2913
+ var initPens = deepClone(pens); // 原 pens ,深拷贝一下
2914
+ try {
2915
+ for (var pens_2 = __values(pens), pens_2_1 = pens_2.next(); !pens_2_1.done; pens_2_1 = pens_2.next()) {
2916
+ var item = pens_2_1.value;
2917
+ this.alignPen(align, item, rect);
2918
+ }
2919
+ }
2920
+ catch (e_9_1) { e_9 = { error: e_9_1 }; }
2921
+ finally {
2922
+ try {
2923
+ if (pens_2_1 && !pens_2_1.done && (_a = pens_2.return)) _a.call(pens_2);
2924
+ }
2925
+ finally { if (e_9) throw e_9.error; }
2926
+ }
2927
+ this.pushHistory({
2928
+ type: EditType.Update,
2929
+ initPens: initPens,
2930
+ pens: pens,
2931
+ });
2932
+ };
2899
2933
  /**
2900
2934
  * 对齐画笔,基于第一个画笔
2901
2935
  * @param align 左对齐,右对齐,上对齐,下对齐,居中对齐
@@ -2976,7 +3010,7 @@ var Meta2d = /** @class */ (function () {
2976
3010
  * @param distance 总的宽 or 高
2977
3011
  */
2978
3012
  Meta2d.prototype.spaceBetweenByDirection = function (direction, pens, distance) {
2979
- var e_9, _a;
3013
+ var e_10, _a;
2980
3014
  var _this = this;
2981
3015
  if (pens === void 0) { pens = this.store.data.pens; }
2982
3016
  !distance && (distance = this.getPenRect(this.getRect(pens))[direction]);
@@ -3002,20 +3036,20 @@ var Meta2d = /** @class */ (function () {
3002
3036
  var pen0Rect = this.getPenRect(pens[0]);
3003
3037
  var left = direction === 'width' ? pen0Rect.x : pen0Rect.y;
3004
3038
  try {
3005
- for (var pens_2 = __values(pens), pens_2_1 = pens_2.next(); !pens_2_1.done; pens_2_1 = pens_2.next()) {
3006
- var pen = pens_2_1.value;
3039
+ for (var pens_3 = __values(pens), pens_3_1 = pens_3.next(); !pens_3_1.done; pens_3_1 = pens_3.next()) {
3040
+ var pen = pens_3_1.value;
3007
3041
  var penRect = this.getPenRect(pen);
3008
3042
  direction === 'width' ? (penRect.x = left) : (penRect.y = left);
3009
3043
  left += penRect[direction] + space;
3010
3044
  this.setValue(__assign({ id: pen.id }, penRect), { render: false, doEvent: false });
3011
3045
  }
3012
3046
  }
3013
- catch (e_9_1) { e_9 = { error: e_9_1 }; }
3047
+ catch (e_10_1) { e_10 = { error: e_10_1 }; }
3014
3048
  finally {
3015
3049
  try {
3016
- if (pens_2_1 && !pens_2_1.done && (_a = pens_2.return)) _a.call(pens_2);
3050
+ if (pens_3_1 && !pens_3_1.done && (_a = pens_3.return)) _a.call(pens_3);
3017
3051
  }
3018
- finally { if (e_9) throw e_9.error; }
3052
+ finally { if (e_10) throw e_10.error; }
3019
3053
  }
3020
3054
  this.render();
3021
3055
  this.pushHistory({
@@ -3132,7 +3166,7 @@ var Meta2d = /** @class */ (function () {
3132
3166
  * @param pens pen 置顶的画笔
3133
3167
  */
3134
3168
  Meta2d.prototype.top = function (pens) {
3135
- var e_10, _a;
3169
+ var e_11, _a;
3136
3170
  var _this = this;
3137
3171
  if (!pens)
3138
3172
  pens = this.store.active;
@@ -3160,12 +3194,12 @@ var Meta2d = /** @class */ (function () {
3160
3194
  _loop_3(pen);
3161
3195
  }
3162
3196
  }
3163
- catch (e_10_1) { e_10 = { error: e_10_1 }; }
3197
+ catch (e_11_1) { e_11 = { error: e_11_1 }; }
3164
3198
  finally {
3165
3199
  try {
3166
3200
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
3167
3201
  }
3168
- finally { if (e_10) throw e_10.error; }
3202
+ finally { if (e_11) throw e_11.error; }
3169
3203
  }
3170
3204
  };
3171
3205
  /**
@@ -3181,7 +3215,7 @@ var Meta2d = /** @class */ (function () {
3181
3215
  * @param pens 画笔们,注意 pen 必须在该数组内才有效
3182
3216
  */
3183
3217
  Meta2d.prototype.bottom = function (pens) {
3184
- var e_11, _a;
3218
+ var e_12, _a;
3185
3219
  if (!pens)
3186
3220
  pens = this.store.active;
3187
3221
  if (!Array.isArray(pens))
@@ -3212,12 +3246,12 @@ var Meta2d = /** @class */ (function () {
3212
3246
  _loop_4(pen);
3213
3247
  }
3214
3248
  }
3215
- catch (e_11_1) { e_11 = { error: e_11_1 }; }
3249
+ catch (e_12_1) { e_12 = { error: e_12_1 }; }
3216
3250
  finally {
3217
3251
  try {
3218
3252
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
3219
3253
  }
3220
- finally { if (e_11) throw e_11.error; }
3254
+ finally { if (e_12) throw e_12.error; }
3221
3255
  }
3222
3256
  };
3223
3257
  /**
@@ -3226,7 +3260,7 @@ var Meta2d = /** @class */ (function () {
3226
3260
  * @param pen 画笔
3227
3261
  */
3228
3262
  Meta2d.prototype.upByArea = function (pen) {
3229
- var _a, e_12, _b;
3263
+ var _a, e_13, _b;
3230
3264
  var _this = this;
3231
3265
  var index = this.store.data.pens.findIndex(function (p) { return p.id === pen.id; });
3232
3266
  if (index === -1) {
@@ -3276,12 +3310,12 @@ var Meta2d = /** @class */ (function () {
3276
3310
  _loop_6(pen_2);
3277
3311
  }
3278
3312
  }
3279
- catch (e_12_1) { e_12 = { error: e_12_1 }; }
3313
+ catch (e_13_1) { e_13 = { error: e_13_1 }; }
3280
3314
  finally {
3281
3315
  try {
3282
3316
  if (allPens_1_1 && !allPens_1_1.done && (_b = allPens_1.return)) _b.call(allPens_1);
3283
3317
  }
3284
- finally { if (e_12) throw e_12.error; }
3318
+ finally { if (e_13) throw e_13.error; }
3285
3319
  }
3286
3320
  this.initImageCanvas([pen]);
3287
3321
  };
@@ -3322,7 +3356,7 @@ var Meta2d = /** @class */ (function () {
3322
3356
  * @param pens 画笔
3323
3357
  */
3324
3358
  Meta2d.prototype.up = function (pens) {
3325
- var e_13, _a;
3359
+ var e_14, _a;
3326
3360
  var _this = this;
3327
3361
  if (!pens)
3328
3362
  pens = this.store.active;
@@ -3375,12 +3409,12 @@ var Meta2d = /** @class */ (function () {
3375
3409
  _loop_7(pen);
3376
3410
  }
3377
3411
  }
3378
- catch (e_13_1) { e_13 = { error: e_13_1 }; }
3412
+ catch (e_14_1) { e_14 = { error: e_14_1 }; }
3379
3413
  finally {
3380
3414
  try {
3381
3415
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
3382
3416
  }
3383
- finally { if (e_13) throw e_13.error; }
3417
+ finally { if (e_14) throw e_14.error; }
3384
3418
  }
3385
3419
  };
3386
3420
  /**
@@ -3388,7 +3422,7 @@ var Meta2d = /** @class */ (function () {
3388
3422
  * @param pen 画笔
3389
3423
  */
3390
3424
  Meta2d.prototype.down = function (pens) {
3391
- var e_14, _a;
3425
+ var e_15, _a;
3392
3426
  var _this = this;
3393
3427
  if (!pens)
3394
3428
  pens = this.store.active;
@@ -3443,12 +3477,12 @@ var Meta2d = /** @class */ (function () {
3443
3477
  _loop_9(pen);
3444
3478
  }
3445
3479
  }
3446
- catch (e_14_1) { e_14 = { error: e_14_1 }; }
3480
+ catch (e_15_1) { e_15 = { error: e_15_1 }; }
3447
3481
  finally {
3448
3482
  try {
3449
3483
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
3450
3484
  }
3451
- finally { if (e_14) throw e_14.error; }
3485
+ finally { if (e_15) throw e_15.error; }
3452
3486
  }
3453
3487
  };
3454
3488
  Meta2d.prototype.setLayer = function (pen, toIndex, pens) {
@@ -3490,6 +3524,10 @@ var Meta2d = /** @class */ (function () {
3490
3524
  console.warn(node, 'node contain a error connectedLine');
3491
3525
  return;
3492
3526
  }
3527
+ if (lines.find(function (_line) { return _line.id === line.id; })) {
3528
+ //去重
3529
+ return;
3530
+ }
3493
3531
  switch (type) {
3494
3532
  case 'all':
3495
3533
  lines.push(line);
@@ -3523,7 +3561,7 @@ var Meta2d = /** @class */ (function () {
3523
3561
  var nextNodes_1 = [];
3524
3562
  // 2. 遍历出线的 nextNode
3525
3563
  lines.forEach(function (line) {
3526
- var e_15, _a;
3564
+ var e_16, _a;
3527
3565
  var lineNextNode = _this.nextNode(line);
3528
3566
  var _loop_11 = function (node) {
3529
3567
  var have = nextNodes_1.find(function (next) { return next.id === node.id; });
@@ -3536,12 +3574,12 @@ var Meta2d = /** @class */ (function () {
3536
3574
  _loop_11(node);
3537
3575
  }
3538
3576
  }
3539
- catch (e_15_1) { e_15 = { error: e_15_1 }; }
3577
+ catch (e_16_1) { e_16 = { error: e_16_1 }; }
3540
3578
  finally {
3541
3579
  try {
3542
3580
  if (lineNextNode_1_1 && !lineNextNode_1_1.done && (_a = lineNextNode_1.return)) _a.call(lineNextNode_1);
3543
3581
  }
3544
- finally { if (e_15) throw e_15.error; }
3582
+ finally { if (e_16) throw e_16.error; }
3545
3583
  }
3546
3584
  });
3547
3585
  return nextNodes_1;
@@ -3564,7 +3602,7 @@ var Meta2d = /** @class */ (function () {
3564
3602
  var preNodes_1 = [];
3565
3603
  // 2. 遍历入线的 preNode
3566
3604
  lines.forEach(function (line) {
3567
- var e_16, _a;
3605
+ var e_17, _a;
3568
3606
  var linePreNode = _this.previousNode(line);
3569
3607
  var _loop_12 = function (node) {
3570
3608
  var have = preNodes_1.find(function (pre) { return pre.id === node.id; });
@@ -3577,12 +3615,12 @@ var Meta2d = /** @class */ (function () {
3577
3615
  _loop_12(node);
3578
3616
  }
3579
3617
  }
3580
- catch (e_16_1) { e_16 = { error: e_16_1 }; }
3618
+ catch (e_17_1) { e_17 = { error: e_17_1 }; }
3581
3619
  finally {
3582
3620
  try {
3583
3621
  if (linePreNode_1_1 && !linePreNode_1_1.done && (_a = linePreNode_1.return)) _a.call(linePreNode_1);
3584
3622
  }
3585
- finally { if (e_16) throw e_16.error; }
3623
+ finally { if (e_17) throw e_17.error; }
3586
3624
  }
3587
3625
  });
3588
3626
  return preNodes_1;
@@ -3858,7 +3896,7 @@ var Meta2d = /** @class */ (function () {
3858
3896
  : deepClone(__spreadArray([parent], __read(components), false));
3859
3897
  };
3860
3898
  Meta2d.prototype.setVisible = function (pen, visible, render) {
3861
- var e_17, _a;
3899
+ var e_18, _a;
3862
3900
  if (render === void 0) { render = true; }
3863
3901
  this.onSizeUpdate();
3864
3902
  this.setValue({ id: pen.id, visible: visible }, { render: false, doEvent: false });
@@ -3870,12 +3908,12 @@ var Meta2d = /** @class */ (function () {
3870
3908
  child && this.setVisible(child, visible, false);
3871
3909
  }
3872
3910
  }
3873
- catch (e_17_1) { e_17 = { error: e_17_1 }; }
3911
+ catch (e_18_1) { e_18 = { error: e_18_1 }; }
3874
3912
  finally {
3875
3913
  try {
3876
3914
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
3877
3915
  }
3878
- finally { if (e_17) throw e_17.error; }
3916
+ finally { if (e_18) throw e_18.error; }
3879
3917
  }
3880
3918
  }
3881
3919
  render && this.render();