@leafer-editor/worker 1.5.1 → 1.5.3

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/dist/worker.js CHANGED
@@ -119,8 +119,9 @@ var LeaferUI = (function (exports) {
119
119
  if (!scaleData)
120
120
  scaleData = {};
121
121
  if (size) {
122
- scaleData.scaleX = (typeof size === 'number' ? size : size.width) / originSize.width;
123
- scaleData.scaleY = (typeof size === 'number' ? size : size.height) / originSize.height;
122
+ const scaleX = (typeof size === 'number' ? size : size.width || 0) / originSize.width, scaleY = (typeof size === 'number' ? size : size.height || 0) / originSize.height;
123
+ scaleData.scaleX = scaleX || scaleY || 1;
124
+ scaleData.scaleY = scaleY || scaleX || 1;
124
125
  }
125
126
  else if (scale)
126
127
  MathHelper.assignScale(scaleData, scale);
@@ -1693,6 +1694,9 @@ var LeaferUI = (function (exports) {
1693
1694
  function isNull(value) {
1694
1695
  return value === undefined || value === null;
1695
1696
  }
1697
+ function isEmptyData(value) {
1698
+ return JSON.stringify(value) === '{}';
1699
+ }
1696
1700
 
1697
1701
  /******************************************************************************
1698
1702
  Copyright (c) Microsoft Corporation.
@@ -2348,7 +2352,7 @@ var LeaferUI = (function (exports) {
2348
2352
  const { sin: sin$3, cos: cos$3, atan2: atan2$1, ceil: ceil$1, abs: abs$5, PI: PI$2, sqrt: sqrt$1, pow } = Math;
2349
2353
  const { setPoint: setPoint$4, addPoint: addPoint$2 } = TwoPointBoundsHelper;
2350
2354
  const { set, toNumberPoints: toNumberPoints$1 } = PointHelper;
2351
- const { M: M$8, L: L$9, C: C$8, Q: Q$7, Z: Z$7 } = PathCommandMap;
2355
+ const { M: M$8, L: L$9, C: C$7, Q: Q$7, Z: Z$7 } = PathCommandMap;
2352
2356
  const tempPoint$2 = {};
2353
2357
  const BezierHelper = {
2354
2358
  points(data, originPoints, curve, close) {
@@ -2383,7 +2387,7 @@ var LeaferUI = (function (exports) {
2383
2387
  data.push(Q$7, c1X, c1Y, bX, bY);
2384
2388
  }
2385
2389
  else {
2386
- data.push(C$8, c2X, c2Y, c1X, c1Y, bX, bY);
2390
+ data.push(C$7, c2X, c2Y, c1X, c1Y, bX, bY);
2387
2391
  }
2388
2392
  c2X = bX + cb * cX;
2389
2393
  c2Y = bY + cb * cY;
@@ -2488,7 +2492,7 @@ var LeaferUI = (function (exports) {
2488
2492
  x2 = cx + x + control * (rotationCos * radiusX * endSin + rotationSin * radiusY * endCos);
2489
2493
  y2 = cy + y + control * (rotationSin * radiusX * endSin - rotationCos * radiusY * endCos);
2490
2494
  if (data)
2491
- data.push(C$8, x1, y1, x2, y2, cx + x, cy + y);
2495
+ data.push(C$7, x1, y1, x2, y2, cx + x, cy + y);
2492
2496
  if (setPointBounds)
2493
2497
  toTwoPointBounds$1(cx + startX, cy + startY, x1, y1, x2, y2, cx + x, cy + y, setPointBounds, true);
2494
2498
  startX = x;
@@ -2502,7 +2506,7 @@ var LeaferUI = (function (exports) {
2502
2506
  set(setEndPoint, cx + x, cy + y);
2503
2507
  },
2504
2508
  quadraticCurveTo(data, fromX, fromY, x1, y1, toX, toY) {
2505
- data.push(C$8, (fromX + 2 * x1) / 3, (fromY + 2 * y1) / 3, (toX + 2 * x1) / 3, (toY + 2 * y1) / 3, toX, toY);
2509
+ data.push(C$7, (fromX + 2 * x1) / 3, (fromY + 2 * y1) / 3, (toX + 2 * x1) / 3, (toY + 2 * y1) / 3, toX, toY);
2506
2510
  },
2507
2511
  toTwoPointBoundsByQuadraticCurve(fromX, fromY, x1, y1, toX, toY, pointBounds, addMode) {
2508
2512
  toTwoPointBounds$1(fromX, fromY, (fromX + 2 * x1) / 3, (fromY + 2 * y1) / 3, (toX + 2 * x1) / 3, (toY + 2 * y1) / 3, toX, toY, pointBounds, addMode);
@@ -2610,7 +2614,7 @@ var LeaferUI = (function (exports) {
2610
2614
  }
2611
2615
  };
2612
2616
 
2613
- const { M: M$7, m, L: L$8, l, H, h, V, v, C: C$7, c, S, s, Q: Q$6, q, T, t, A, a, Z: Z$6, z, N: N$5, D: D$5, X: X$5, G: G$5, F: F$6, O: O$6, P: P$5, U: U$5 } = PathCommandMap;
2617
+ const { M: M$7, m, L: L$8, l, H, h, V, v, C: C$6, c, S, s, Q: Q$6, q, T, t, A, a, Z: Z$6, z, N: N$5, D: D$5, X: X$5, G: G$5, F: F$6, O: O$6, P: P$5, U: U$5 } = PathCommandMap;
2614
2618
  const { rect: rect$3, roundRect: roundRect$2, arcTo: arcTo$3, arc: arc$3, ellipse: ellipse$4, quadraticCurveTo: quadraticCurveTo$1 } = BezierHelper;
2615
2619
  const { ellipticalArc } = EllipseHelper;
2616
2620
  const debug$f = Debug.get('PathConvert');
@@ -2738,14 +2742,14 @@ var LeaferUI = (function (exports) {
2738
2742
  old[i + 4] += y;
2739
2743
  command = S;
2740
2744
  case S:
2741
- smooth = (lastCommand === C$7) || (lastCommand === S);
2745
+ smooth = (lastCommand === C$6) || (lastCommand === S);
2742
2746
  x1 = smooth ? (x * 2 - controlX) : old[i + 1];
2743
2747
  y1 = smooth ? (y * 2 - controlY) : old[i + 2];
2744
2748
  controlX = old[i + 1];
2745
2749
  controlY = old[i + 2];
2746
2750
  x = old[i + 3];
2747
2751
  y = old[i + 4];
2748
- data.push(C$7, x1, y1, controlX, controlY, x, y);
2752
+ data.push(C$6, x1, y1, controlX, controlY, x, y);
2749
2753
  i += 5;
2750
2754
  break;
2751
2755
  case c:
@@ -2755,13 +2759,13 @@ var LeaferUI = (function (exports) {
2755
2759
  old[i + 4] += y;
2756
2760
  old[i + 5] += x;
2757
2761
  old[i + 6] += y;
2758
- command = C$7;
2759
- case C$7:
2762
+ command = C$6;
2763
+ case C$6:
2760
2764
  controlX = old[i + 3];
2761
2765
  controlY = old[i + 4];
2762
2766
  x = old[i + 5];
2763
2767
  y = old[i + 6];
2764
- data.push(C$7, old[i + 1], old[i + 2], controlX, controlY, x, y);
2768
+ data.push(C$6, old[i + 1], old[i + 2], controlX, controlY, x, y);
2765
2769
  i += 7;
2766
2770
  break;
2767
2771
  case t:
@@ -2872,7 +2876,7 @@ var LeaferUI = (function (exports) {
2872
2876
  data.push(L$8, item.x, item.y);
2873
2877
  break;
2874
2878
  case 'C':
2875
- data.push(C$7, item.x1, item.y1, item.x2, item.y2, item.x, item.y);
2879
+ data.push(C$6, item.x1, item.y1, item.x2, item.y2, item.x, item.y);
2876
2880
  break;
2877
2881
  case 'Q':
2878
2882
  data.push(Q$6, item.x1, item.y1, item.x, item.y);
@@ -2899,7 +2903,7 @@ var LeaferUI = (function (exports) {
2899
2903
  };
2900
2904
  const { current, pushData, copyData } = PathConvert;
2901
2905
 
2902
- const { M: M$6, L: L$7, C: C$6, Q: Q$5, Z: Z$5, N: N$4, D: D$4, X: X$4, G: G$4, F: F$5, O: O$5, P: P$4, U: U$4 } = PathCommandMap;
2906
+ const { M: M$6, L: L$7, C: C$5, Q: Q$5, Z: Z$5, N: N$4, D: D$4, X: X$4, G: G$4, F: F$5, O: O$5, P: P$4, U: U$4 } = PathCommandMap;
2903
2907
  const { getMinDistanceFrom, getRadianFrom } = PointHelper;
2904
2908
  const { tan, min, abs: abs$4 } = Math;
2905
2909
  const startPoint = {};
@@ -2914,7 +2918,7 @@ var LeaferUI = (function (exports) {
2914
2918
  data.push(L$7, x, y);
2915
2919
  },
2916
2920
  bezierCurveTo(data, x1, y1, x2, y2, x, y) {
2917
- data.push(C$6, x1, y1, x2, y2, x, y);
2921
+ data.push(C$5, x1, y1, x2, y2, x, y);
2918
2922
  },
2919
2923
  quadraticCurveTo(data, x1, y1, x, y) {
2920
2924
  data.push(Q$5, x1, y1, x, y);
@@ -3076,7 +3080,7 @@ var LeaferUI = (function (exports) {
3076
3080
  paint() { }
3077
3081
  }
3078
3082
 
3079
- const { M: M$5, L: L$6, C: C$5, Q: Q$4, Z: Z$4, N: N$3, D: D$3, X: X$3, G: G$3, F: F$4, O: O$4, P: P$3, U: U$3 } = PathCommandMap;
3083
+ const { M: M$5, L: L$6, C: C$4, Q: Q$4, Z: Z$4, N: N$3, D: D$3, X: X$3, G: G$3, F: F$4, O: O$4, P: P$3, U: U$3 } = PathCommandMap;
3080
3084
  const debug$e = Debug.get('PathDrawer');
3081
3085
  const PathDrawer = {
3082
3086
  drawPathByData(drawer, data) {
@@ -3095,7 +3099,7 @@ var LeaferUI = (function (exports) {
3095
3099
  drawer.lineTo(data[i + 1], data[i + 2]);
3096
3100
  i += 3;
3097
3101
  break;
3098
- case C$5:
3102
+ case C$4:
3099
3103
  drawer.bezierCurveTo(data[i + 1], data[i + 2], data[i + 3], data[i + 4], data[i + 5], data[i + 6]);
3100
3104
  i += 7;
3101
3105
  break;
@@ -3147,7 +3151,7 @@ var LeaferUI = (function (exports) {
3147
3151
  }
3148
3152
  };
3149
3153
 
3150
- const { M: M$4, L: L$5, C: C$4, Q: Q$3, Z: Z$3, N: N$2, D: D$2, X: X$2, G: G$2, F: F$3, O: O$3, P: P$2, U: U$2 } = PathCommandMap;
3154
+ const { M: M$4, L: L$5, C: C$3, Q: Q$3, Z: Z$3, N: N$2, D: D$2, X: X$2, G: G$2, F: F$3, O: O$3, P: P$2, U: U$2 } = PathCommandMap;
3151
3155
  const { toTwoPointBounds, toTwoPointBoundsByQuadraticCurve, arcTo: arcTo$1, arc, ellipse: ellipse$1 } = BezierHelper;
3152
3156
  const { addPointBounds, copy: copy$b, addPoint: addPoint$1, setPoint: setPoint$3, addBounds, toBounds: toBounds$3 } = TwoPointBoundsHelper;
3153
3157
  const debug$d = Debug.get('PathBounds');
@@ -3168,7 +3172,7 @@ var LeaferUI = (function (exports) {
3168
3172
  while (i < len) {
3169
3173
  command = data[i];
3170
3174
  if (i === 0) {
3171
- if (command === Z$3 || command === C$4 || command === Q$3) {
3175
+ if (command === Z$3 || command === C$3 || command === Q$3) {
3172
3176
  setPoint$3(setPointBounds, x, y);
3173
3177
  }
3174
3178
  else {
@@ -3183,7 +3187,7 @@ var LeaferUI = (function (exports) {
3183
3187
  addPoint$1(setPointBounds, x, y);
3184
3188
  i += 3;
3185
3189
  break;
3186
- case C$4:
3190
+ case C$3:
3187
3191
  toX = data[i + 5];
3188
3192
  toY = data[i + 6];
3189
3193
  toTwoPointBounds(x, y, data[i + 1], data[i + 2], data[i + 3], data[i + 4], toX, toY, tempPointBounds);
@@ -3265,12 +3269,12 @@ var LeaferUI = (function (exports) {
3265
3269
  }
3266
3270
  };
3267
3271
 
3268
- const { M: M$3, L: L$4, C: C$3, Z: Z$2 } = PathCommandMap;
3272
+ const { M: M$3, L: L$4, Z: Z$2 } = PathCommandMap;
3269
3273
  const { getCenterX, getCenterY } = PointHelper;
3270
3274
  const { arcTo } = PathCommandDataHelper;
3271
3275
  const PathCorner = {
3272
3276
  smooth(data, cornerRadius, _cornerSmoothing) {
3273
- let command;
3277
+ let command, commandLen;
3274
3278
  let i = 0, x = 0, y = 0, startX = 0, startY = 0, secondX = 0, secondY = 0, lastX = 0, lastY = 0;
3275
3279
  const len = data.length;
3276
3280
  const smooth = [];
@@ -3307,15 +3311,16 @@ var LeaferUI = (function (exports) {
3307
3311
  lastX = x;
3308
3312
  lastY = y;
3309
3313
  break;
3310
- case C$3:
3311
- smooth.push(C$3, data[i + 1], data[i + 2], data[i + 3], data[i + 4], data[i + 5], data[i + 6]);
3312
- i += 7;
3313
- break;
3314
3314
  case Z$2:
3315
3315
  arcTo(smooth, startX, startY, secondX, secondY, cornerRadius, lastX, lastY);
3316
3316
  smooth.push(Z$2);
3317
3317
  i += 1;
3318
3318
  break;
3319
+ default:
3320
+ commandLen = PathNumberCommandLengthMap[command];
3321
+ for (let j = 0; j < commandLen; j++)
3322
+ smooth.push(data[i + j]);
3323
+ i += commandLen;
3319
3324
  }
3320
3325
  }
3321
3326
  if (command !== Z$2) {
@@ -4077,28 +4082,42 @@ var LeaferUI = (function (exports) {
4077
4082
  return v === undefined ? defaultValue(this.__leaf) : v;
4078
4083
  };
4079
4084
  }
4085
+ else if (typeof defaultValue === 'object') {
4086
+ const isEmpty = isEmptyData(defaultValue);
4087
+ property.get = function () {
4088
+ let v = this[computedKey];
4089
+ return v === undefined ? this[computedKey] = isEmpty ? {} : DataHelper.clone(defaultValue) : v;
4090
+ };
4091
+ }
4092
+ const isBox = target.isBranchLeaf;
4080
4093
  if (key === 'width') {
4081
4094
  property.get = function () {
4082
4095
  const v = this[computedKey];
4083
4096
  if (v === undefined) {
4084
- const t = this;
4085
- return t._height && t.__naturalWidth && t.__useNaturalRatio ? t._height * t.__naturalWidth / t.__naturalHeight : t.__naturalWidth || defaultValue;
4097
+ const t = this, naturalWidth = t.__naturalWidth, leaf = t.__leaf;
4098
+ if (!defaultValue || leaf.pathInputed)
4099
+ return leaf.boxBounds.width;
4100
+ if (naturalWidth)
4101
+ return t._height && t.__useNaturalRatio ? t._height * naturalWidth / t.__naturalHeight : naturalWidth;
4102
+ return (isBox && leaf.children.length) ? leaf.boxBounds.width : defaultValue;
4086
4103
  }
4087
- else {
4104
+ else
4088
4105
  return v;
4089
- }
4090
4106
  };
4091
4107
  }
4092
4108
  else if (key === 'height') {
4093
4109
  property.get = function () {
4094
4110
  const v = this[computedKey];
4095
4111
  if (v === undefined) {
4096
- const t = this;
4097
- return t._width && t.__naturalHeight && t.__useNaturalRatio ? t._width * t.__naturalHeight / t.__naturalWidth : t.__naturalHeight || defaultValue;
4112
+ const t = this, naturalHeight = t.__naturalHeight, leaf = t.__leaf;
4113
+ if (!defaultValue || leaf.pathInputed)
4114
+ return leaf.boxBounds.height;
4115
+ if (naturalHeight)
4116
+ return t._width && t.__useNaturalRatio ? t._width * naturalHeight / t.__naturalWidth : naturalHeight;
4117
+ return (isBox && leaf.children.length) ? leaf.boxBounds.height : defaultValue;
4098
4118
  }
4099
- else {
4119
+ else
4100
4120
  return v;
4101
- }
4102
4121
  };
4103
4122
  }
4104
4123
  let descriptor, find = data;
@@ -4525,7 +4544,12 @@ var LeaferUI = (function (exports) {
4525
4544
  while (root.parent && !root.parent.leafer) {
4526
4545
  root = root.parent;
4527
4546
  }
4528
- Platform.layout(root);
4547
+ const r = root;
4548
+ if (r.__fullLayouting)
4549
+ return;
4550
+ r.__fullLayouting = true;
4551
+ Platform.layout(r);
4552
+ delete r.__fullLayouting;
4529
4553
  }
4530
4554
  }
4531
4555
  getTransform(relative = 'world') {
@@ -6050,7 +6074,7 @@ var LeaferUI = (function (exports) {
6050
6074
  }
6051
6075
  }
6052
6076
 
6053
- const version = "1.5.1";
6077
+ const version = "1.5.3";
6054
6078
 
6055
6079
  class LeaferCanvas extends LeaferCanvasBase {
6056
6080
  get allowBackgroundColor() { return true; }
@@ -7640,7 +7664,7 @@ var LeaferUI = (function (exports) {
7640
7664
  strokeType()
7641
7665
  ], exports.UI.prototype, "dashPattern", void 0);
7642
7666
  __decorate([
7643
- strokeType()
7667
+ strokeType(0)
7644
7668
  ], exports.UI.prototype, "dashOffset", void 0);
7645
7669
  __decorate([
7646
7670
  strokeType(10)
@@ -7733,6 +7757,12 @@ var LeaferUI = (function (exports) {
7733
7757
  __decorate([
7734
7758
  dataProcessor(GroupData)
7735
7759
  ], exports.Group.prototype, "__", void 0);
7760
+ __decorate([
7761
+ boundsType(0)
7762
+ ], exports.Group.prototype, "width", void 0);
7763
+ __decorate([
7764
+ boundsType(0)
7765
+ ], exports.Group.prototype, "height", void 0);
7736
7766
  exports.Group = __decorate([
7737
7767
  useModule(exports.Branch),
7738
7768
  registerUI()
@@ -8148,7 +8178,7 @@ var LeaferUI = (function (exports) {
8148
8178
  __updateRectBoxBounds() { }
8149
8179
  __updateBoxBounds(_secondLayout) {
8150
8180
  const data = this.__;
8151
- if (this.children.length) {
8181
+ if (this.children.length && !this.pathInputed) {
8152
8182
  if (data.__autoSide) {
8153
8183
  if (data.__hasSurface)
8154
8184
  this.__extraUpdate();
@@ -8217,6 +8247,12 @@ var LeaferUI = (function (exports) {
8217
8247
  __decorate([
8218
8248
  dataProcessor(BoxData)
8219
8249
  ], exports.Box.prototype, "__", void 0);
8250
+ __decorate([
8251
+ boundsType(100)
8252
+ ], exports.Box.prototype, "width", void 0);
8253
+ __decorate([
8254
+ boundsType(100)
8255
+ ], exports.Box.prototype, "height", void 0);
8220
8256
  __decorate([
8221
8257
  dataType(false)
8222
8258
  ], exports.Box.prototype, "resizeChildren", void 0);
@@ -10102,16 +10138,20 @@ var LeaferUI = (function (exports) {
10102
10138
  };
10103
10139
 
10104
10140
  function fillText(ui, canvas) {
10105
- let row;
10106
- const { rows, decorationY, decorationHeight } = ui.__.__textDrawData;
10141
+ let row, data = ui.__.__textDrawData;
10142
+ const { rows, decorationY } = data;
10107
10143
  for (let i = 0, len = rows.length; i < len; i++) {
10108
10144
  row = rows[i];
10109
10145
  if (row.text)
10110
10146
  canvas.fillText(row.text, row.x, row.y);
10111
10147
  else if (row.data)
10112
10148
  row.data.forEach(charData => { canvas.fillText(charData.char, charData.x, row.y); });
10113
- if (decorationY)
10114
- canvas.fillRect(row.x, row.y + decorationY, row.width, decorationHeight);
10149
+ }
10150
+ if (decorationY) {
10151
+ const { decorationColor, decorationHeight } = data;
10152
+ if (decorationColor)
10153
+ canvas.fillStyle = decorationColor;
10154
+ rows.forEach(row => decorationY.forEach(value => canvas.fillRect(row.x, row.y + value, row.width, decorationHeight)));
10115
10155
  }
10116
10156
  }
10117
10157
 
@@ -10182,16 +10222,18 @@ var LeaferUI = (function (exports) {
10182
10222
  out.recycle(ui.__nowWorld);
10183
10223
  }
10184
10224
  function drawTextStroke(ui, canvas) {
10185
- let row;
10186
- const { rows, decorationY, decorationHeight } = ui.__.__textDrawData;
10225
+ let row, data = ui.__.__textDrawData;
10226
+ const { rows, decorationY } = data;
10187
10227
  for (let i = 0, len = rows.length; i < len; i++) {
10188
10228
  row = rows[i];
10189
10229
  if (row.text)
10190
10230
  canvas.strokeText(row.text, row.x, row.y);
10191
10231
  else if (row.data)
10192
10232
  row.data.forEach(charData => { canvas.strokeText(charData.char, charData.x, row.y); });
10193
- if (decorationY)
10194
- canvas.strokeRect(row.x, row.y + decorationY, row.width, decorationHeight);
10233
+ }
10234
+ if (decorationY) {
10235
+ const { decorationHeight } = data;
10236
+ rows.forEach(row => decorationY.forEach(value => canvas.strokeRect(row.x, row.y + value, row.width, decorationHeight)));
10195
10237
  }
10196
10238
  }
10197
10239
  function drawStrokesStyle(strokes, isText, ui, canvas) {
@@ -10757,6 +10799,8 @@ var LeaferUI = (function (exports) {
10757
10799
  }
10758
10800
  image.unload(paints[i].loadId, !input.some((item) => item.url === url));
10759
10801
  }
10802
+ else
10803
+ paints[i].style = null;
10760
10804
  }
10761
10805
  }
10762
10806
  return recycleMap;
@@ -11489,14 +11533,25 @@ var LeaferUI = (function (exports) {
11489
11533
  }
11490
11534
 
11491
11535
  function decorationText(drawData, style) {
11492
- const { fontSize } = style;
11536
+ let type;
11537
+ const { fontSize, textDecoration } = style;
11493
11538
  drawData.decorationHeight = fontSize / 11;
11494
- switch (style.textDecoration) {
11539
+ if (typeof textDecoration === 'object') {
11540
+ type = textDecoration.type;
11541
+ if (textDecoration.color)
11542
+ drawData.decorationColor = ColorConvert.string(textDecoration.color);
11543
+ }
11544
+ else
11545
+ type = textDecoration;
11546
+ switch (type) {
11495
11547
  case 'under':
11496
- drawData.decorationY = fontSize * 0.15;
11548
+ drawData.decorationY = [fontSize * 0.15];
11497
11549
  break;
11498
11550
  case 'delete':
11499
- drawData.decorationY = -fontSize * 0.35;
11551
+ drawData.decorationY = [-fontSize * 0.35];
11552
+ break;
11553
+ case 'under-delete':
11554
+ drawData.decorationY = [fontSize * 0.15, -fontSize * 0.35];
11500
11555
  }
11501
11556
  }
11502
11557
 
@@ -11654,9 +11709,24 @@ var LeaferUI = (function (exports) {
11654
11709
  set(value) {
11655
11710
  const old = this[privateKey];
11656
11711
  if (old !== value) {
11657
- const type = key === 'target' ? EditorEvent.BEFORE_SELECT : EditorEvent.BEFORE_HOVER;
11658
- if (this.hasEvent(type))
11659
- this.emitEvent(new EditorEvent(type, { editor: this, value: value, oldValue: old }));
11712
+ if (this.config) {
11713
+ const isSelect = key === 'target';
11714
+ if (isSelect) {
11715
+ if (value instanceof Array && value.length > 1 && value[0].locked)
11716
+ value.splice(0, 1);
11717
+ const { beforeSelect } = this.config;
11718
+ if (beforeSelect) {
11719
+ const check = beforeSelect({ target: value });
11720
+ if (typeof check === 'object')
11721
+ value = check;
11722
+ else if (check === false)
11723
+ return;
11724
+ }
11725
+ }
11726
+ const type = isSelect ? EditorEvent.BEFORE_SELECT : EditorEvent.BEFORE_HOVER;
11727
+ if (this.hasEvent(type))
11728
+ this.emitEvent(new EditorEvent(type, { editor: this, value: value, oldValue: old }));
11729
+ }
11660
11730
  this[privateKey] = value, fn(this, old);
11661
11731
  }
11662
11732
  }
@@ -11957,7 +12027,8 @@ var LeaferUI = (function (exports) {
11957
12027
  return target.leafer !== this.editor.leafer;
11958
12028
  }
11959
12029
  allowDrag(e) {
11960
- if (this.running && (this.editor.mergeConfig.boxSelect) && !e.target.draggable) {
12030
+ const { boxSelect, multipleSelect } = this.editor.mergeConfig;
12031
+ if (this.running && (multipleSelect && boxSelect) && !e.target.draggable) {
11961
12032
  return (!this.editor.editing && this.allow(e.target)) || (e.shiftKey && !findOne(e.path));
11962
12033
  }
11963
12034
  else {
@@ -11975,7 +12046,8 @@ var LeaferUI = (function (exports) {
11975
12046
  return this.isMultipleSelect(e) ? this.findDeepOne(e) : findOne(e.path);
11976
12047
  }
11977
12048
  isMultipleSelect(e) {
11978
- return e.shiftKey || this.editor.mergeConfig.continuousSelect;
12049
+ const { multipleSelect, continuousSelect } = this.editor.mergeConfig;
12050
+ return multipleSelect && (e.shiftKey || continuousSelect);
11979
12051
  }
11980
12052
  __listenEvents() {
11981
12053
  const { editor } = this;
@@ -12150,21 +12222,25 @@ var LeaferUI = (function (exports) {
12150
12222
  let last;
12151
12223
  switch (direction) {
12152
12224
  case top$1:
12225
+ case topLeft$1:
12153
12226
  last = { x: 0.5, y: 0 };
12154
12227
  align = 'bottom';
12155
12228
  skewX = 1;
12156
12229
  break;
12157
12230
  case bottom$1:
12231
+ case bottomRight:
12158
12232
  last = { x: 0.5, y: 1 };
12159
12233
  align = 'top';
12160
12234
  skewX = 1;
12161
12235
  break;
12162
12236
  case left$2:
12237
+ case bottomLeft:
12163
12238
  last = { x: 0, y: 0.5 };
12164
12239
  align = 'right';
12165
12240
  skewY = 1;
12166
12241
  break;
12167
12242
  case right$2:
12243
+ case topRight$1:
12168
12244
  last = { x: 1, y: 0.5 };
12169
12245
  align = 'left';
12170
12246
  skewY = 1;
@@ -12253,7 +12329,7 @@ var LeaferUI = (function (exports) {
12253
12329
  let showResize = pointType.includes('resize');
12254
12330
  if (showResize && rotateable && (e.metaKey || e.ctrlKey || !resizeable))
12255
12331
  showResize = false;
12256
- const showSkew = skewable && !showResize && point.name === 'resize-line';
12332
+ const showSkew = skewable && !showResize && (point.name === 'resize-line' || pointType === 'skew');
12257
12333
  const cursor = showSkew ? skewCursor : (showResize ? resizeCursor : rotateCursor);
12258
12334
  rotation += (EditDataHelper.getFlipDirection(point.direction, flippedX, flippedY) + 1) * 45;
12259
12335
  rotation = Math.round(MathHelper.formatRotation(rotation, true) / 2) * 2;
@@ -12475,6 +12551,8 @@ var LeaferUI = (function (exports) {
12475
12551
  editor.onRotate(e);
12476
12552
  if (pointType.includes('resize'))
12477
12553
  editor.onScale(e);
12554
+ if (pointType === 'skew')
12555
+ editor.onSkew(e);
12478
12556
  updateCursor(editor, e);
12479
12557
  }
12480
12558
  onArrow(e) {
@@ -12656,6 +12734,7 @@ ${filterStyle}
12656
12734
  hover: true,
12657
12735
  select: 'press',
12658
12736
  openInner: 'double',
12737
+ multipleSelect: true,
12659
12738
  boxSelect: true,
12660
12739
  moveable: true,
12661
12740
  resizeable: true,
@@ -12682,11 +12761,7 @@ ${filterStyle}
12682
12761
  function onTarget(editor, oldValue) {
12683
12762
  const { target } = editor;
12684
12763
  if (target) {
12685
- const { list } = editor.leafList = target instanceof LeafList ? target : new LeafList(target instanceof Array ? target : target);
12686
- if (!list.every(checkEditable)) {
12687
- editor.target = list.filter(checkEditable);
12688
- return;
12689
- }
12764
+ editor.leafList = target instanceof LeafList ? target : new LeafList(target);
12690
12765
  if (editor.multiple)
12691
12766
  simulate(editor);
12692
12767
  }
@@ -12713,9 +12788,6 @@ ${filterStyle}
12713
12788
  function onHover(editor, oldValue) {
12714
12789
  editor.emitEvent(new EditorEvent(EditorEvent.HOVER, { editor, value: editor.hoverTarget, oldValue }));
12715
12790
  }
12716
- function checkEditable(item) {
12717
- return item.editable && !item.locked;
12718
- }
12719
12791
 
12720
12792
  const order = (a, b) => a.parent.children.indexOf(a) - b.parent.children.indexOf(b);
12721
12793
  const reverseOrder = (a, b) => b.parent.children.indexOf(b) - a.parent.children.indexOf(a);
@@ -12747,13 +12819,16 @@ ${filterStyle}
12747
12819
  const ungroupList = [];
12748
12820
  app.lockLayout();
12749
12821
  list.forEach(leaf => {
12750
- if (leaf.isBranch && !leaf.isBranchLeaf) {
12822
+ if (leaf.isBranch) {
12751
12823
  const { parent, children } = leaf;
12752
12824
  while (children.length) {
12753
12825
  ungroupList.push(children[0]);
12754
12826
  children[0].dropTo(parent, parent.children.indexOf(leaf));
12755
12827
  }
12756
- leaf.remove();
12828
+ if (leaf.isBranchLeaf)
12829
+ ungroupList.push(leaf);
12830
+ else
12831
+ leaf.remove();
12757
12832
  }
12758
12833
  else {
12759
12834
  ungroupList.push(leaf);
@@ -13058,13 +13133,22 @@ ${filterStyle}
13058
13133
  this.skewOf(origin, skewX, skewY);
13059
13134
  }
13060
13135
  move(x, y = 0) {
13061
- const { element } = this;
13062
13136
  if (!this.checkTransform('moveable'))
13063
13137
  return;
13064
- const world = element.getWorldPointByLocal(typeof x === 'object' ? Object.assign({}, x) : { x, y }, null, true);
13138
+ if (typeof x === 'object')
13139
+ y = x.y, x = x.x;
13140
+ const { element: target } = this, { beforeMove } = this.mergeConfig;
13141
+ if (beforeMove) {
13142
+ const check = beforeMove({ target, x, y });
13143
+ if (typeof check === 'object')
13144
+ x = check.x, y = check.y;
13145
+ else if (check === false)
13146
+ return;
13147
+ }
13148
+ const world = target.getWorldPointByLocal({ x, y }, null, true);
13065
13149
  if (this.multiple)
13066
- element.safeChange(() => element.move(x, y));
13067
- const data = { target: element, editor: this, moveX: world.x, moveY: world.y };
13150
+ target.safeChange(() => target.move(x, y));
13151
+ const data = { target, editor: this, moveX: world.x, moveY: world.y };
13068
13152
  this.emitEvent(new EditorMoveEvent(EditorMoveEvent.BEFORE_MOVE, data));
13069
13153
  const event = new EditorMoveEvent(EditorMoveEvent.MOVE, data);
13070
13154
  this.editTool.onMove(event);
@@ -13073,8 +13157,14 @@ ${filterStyle}
13073
13157
  scaleWithDrag(data) {
13074
13158
  if (!this.checkTransform('resizeable'))
13075
13159
  return;
13076
- const { element } = this;
13077
- data = Object.assign(Object.assign({}, data), { target: element, editor: this, worldOrigin: element.getWorldPoint(data.origin) });
13160
+ const { element: target } = this, { beforeScale } = this.mergeConfig;
13161
+ if (beforeScale) {
13162
+ const { origin, scaleX, scaleY, drag } = data;
13163
+ const check = beforeScale({ target, drag, origin, scaleX, scaleY });
13164
+ if (check === false)
13165
+ return;
13166
+ }
13167
+ data = Object.assign(Object.assign({}, data), { target, editor: this, worldOrigin: target.getWorldPoint(data.origin) });
13078
13168
  this.emitEvent(new EditorScaleEvent(EditorScaleEvent.BEFORE_SCALE, data));
13079
13169
  const event = new EditorScaleEvent(EditorScaleEvent.SCALE, data);
13080
13170
  this.editTool.onScaleWithDrag(event);
@@ -13083,10 +13173,17 @@ ${filterStyle}
13083
13173
  scaleOf(origin, scaleX, scaleY = scaleX, _resize) {
13084
13174
  if (!this.checkTransform('resizeable'))
13085
13175
  return;
13086
- const { element } = this;
13176
+ const { element: target } = this, { beforeScale } = this.mergeConfig;
13177
+ if (beforeScale) {
13178
+ const check = beforeScale({ target, origin, scaleX, scaleY });
13179
+ if (typeof check === 'object')
13180
+ scaleX = check.scaleX, scaleY = check.scaleY;
13181
+ else if (check === false)
13182
+ return;
13183
+ }
13087
13184
  const worldOrigin = this.getWorldOrigin(origin);
13088
- const transform = this.multiple && this.getChangedTransform(() => element.safeChange(() => element.scaleOf(origin, scaleX, scaleY)));
13089
- const data = { target: element, editor: this, worldOrigin, scaleX, scaleY, transform };
13185
+ const transform = this.multiple && this.getChangedTransform(() => target.safeChange(() => target.scaleOf(origin, scaleX, scaleY)));
13186
+ const data = { target, editor: this, worldOrigin, scaleX, scaleY, transform };
13090
13187
  this.emitEvent(new EditorScaleEvent(EditorScaleEvent.BEFORE_SCALE, data));
13091
13188
  const event = new EditorScaleEvent(EditorScaleEvent.SCALE, data);
13092
13189
  this.editTool.onScale(event);
@@ -13107,10 +13204,17 @@ ${filterStyle}
13107
13204
  rotateOf(origin, rotation) {
13108
13205
  if (!this.checkTransform('rotateable'))
13109
13206
  return;
13110
- const { element } = this;
13207
+ const { element: target } = this, { beforeRotate } = this.mergeConfig;
13208
+ if (beforeRotate) {
13209
+ const check = beforeRotate({ target, origin, rotation });
13210
+ if (typeof check === 'number')
13211
+ rotation = check;
13212
+ else if (check === false)
13213
+ return;
13214
+ }
13111
13215
  const worldOrigin = this.getWorldOrigin(origin);
13112
- const transform = this.multiple && this.getChangedTransform(() => element.safeChange(() => element.rotateOf(origin, rotation)));
13113
- const data = { target: element, editor: this, worldOrigin, rotation, transform };
13216
+ const transform = this.multiple && this.getChangedTransform(() => target.safeChange(() => target.rotateOf(origin, rotation)));
13217
+ const data = { target, editor: this, worldOrigin, rotation, transform };
13114
13218
  this.emitEvent(new EditorRotateEvent(EditorRotateEvent.BEFORE_ROTATE, data));
13115
13219
  const event = new EditorRotateEvent(EditorRotateEvent.ROTATE, data);
13116
13220
  this.editTool.onRotate(event);
@@ -13119,10 +13223,17 @@ ${filterStyle}
13119
13223
  skewOf(origin, skewX, skewY = 0, _resize) {
13120
13224
  if (!this.checkTransform('skewable'))
13121
13225
  return;
13122
- const { element } = this;
13226
+ const { element: target } = this, { beforeSkew } = this.mergeConfig;
13227
+ if (beforeSkew) {
13228
+ const check = beforeSkew({ target, origin, skewX, skewY });
13229
+ if (typeof check === 'object')
13230
+ skewX = check.skewX, skewY = check.skewY;
13231
+ else if (check === false)
13232
+ return;
13233
+ }
13123
13234
  const worldOrigin = this.getWorldOrigin(origin);
13124
- const transform = this.multiple && this.getChangedTransform(() => element.safeChange(() => element.skewOf(origin, skewX, skewY)));
13125
- const data = { target: element, editor: this, worldOrigin, skewX, skewY, transform };
13235
+ const transform = this.multiple && this.getChangedTransform(() => target.safeChange(() => target.skewOf(origin, skewX, skewY)));
13236
+ const data = { target, editor: this, worldOrigin, skewX, skewY, transform };
13126
13237
  this.emitEvent(new EditorSkewEvent(EditorSkewEvent.BEFORE_SKEW, data));
13127
13238
  const event = new EditorSkewEvent(EditorSkewEvent.SKEW, data);
13128
13239
  this.editTool.onSkew(event);
@@ -13635,7 +13746,9 @@ ${filterStyle}
13635
13746
  }
13636
13747
  }
13637
13748
  leaf.fontSize *= fontScale;
13638
- const data = leaf.__;
13749
+ const data = leaf.__, { padding } = data;
13750
+ if (padding)
13751
+ leaf.padding = padding instanceof Array ? padding.map(item => item * fontScale) : padding * fontScale;
13639
13752
  if (!data.__autoWidth)
13640
13753
  leaf.width *= fontScale;
13641
13754
  if (!data.__autoHeight)
@@ -13723,14 +13836,11 @@ ${filterStyle}
13723
13836
  scaleResizeGroup(this, scaleX, scaleY);
13724
13837
  };
13725
13838
  exports.Box.prototype.__scaleResize = function (scaleX, scaleY) {
13726
- if (this.__.__autoSize && this.children.length) {
13727
- scaleResizeGroup(this, scaleX, scaleY);
13728
- }
13729
- else {
13839
+ const { resizeChildren, __autoSize } = this.__;
13840
+ if (!(__autoSize && resizeChildren))
13730
13841
  scaleResize(this, scaleX, scaleY);
13731
- if (this.__.resizeChildren)
13732
- scaleResizeGroup(this, scaleX, scaleY);
13733
- }
13842
+ if (resizeChildren)
13843
+ scaleResizeGroup(this, scaleX, scaleY);
13734
13844
  };
13735
13845
 
13736
13846
  Plugin.add('resize');
@@ -14930,6 +15040,12 @@ ${filterStyle}
14930
15040
  'middle': 'center',
14931
15041
  'bottom': 'flex-end'
14932
15042
  };
15043
+ const textDecorationMap = {
15044
+ 'none': 'none',
15045
+ 'under': 'underline',
15046
+ 'delete': 'line-through',
15047
+ 'under-delete': 'underline line-through'
15048
+ };
14933
15049
  function updateStyle(textDom, text, textScale) {
14934
15050
  const { style } = textDom;
14935
15051
  const { fill, padding, textWrap, textOverflow, textDecoration } = text;
@@ -14938,7 +15054,16 @@ ${filterStyle}
14938
15054
  setFill(style, fill);
14939
15055
  style.fontStyle = text.italic ? 'italic' : 'normal';
14940
15056
  style.fontWeight = text.fontWeight;
14941
- style.textDecoration = textDecoration === 'delete' ? 'line-through' : textDecoration;
15057
+ let decorationType;
15058
+ if (typeof textDecoration === 'object') {
15059
+ decorationType = textDecoration.type;
15060
+ if (textDecoration.color)
15061
+ style.textDecorationColor = ColorConvert.string(textDecoration.color);
15062
+ }
15063
+ else {
15064
+ decorationType = textDecoration;
15065
+ }
15066
+ style.textDecoration = textDecorationMap[decorationType];
14942
15067
  style.textTransform = textCaseMap[text.textCase];
14943
15068
  style.textAlign = text.textAlign === 'both' ? 'justify' : text.textAlign;
14944
15069
  style.display = 'flex';
@@ -15367,6 +15492,7 @@ ${filterStyle}
15367
15492
  exports.getMatrixData = getMatrixData;
15368
15493
  exports.getPointData = getPointData;
15369
15494
  exports.hitType = hitType;
15495
+ exports.isEmptyData = isEmptyData;
15370
15496
  exports.isNull = isNull;
15371
15497
  exports.layoutProcessor = layoutProcessor;
15372
15498
  exports.maskType = maskType;