@leafer-editor/worker 1.5.1 → 1.5.2

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.
@@ -116,8 +116,9 @@ const MathHelper = {
116
116
  if (!scaleData)
117
117
  scaleData = {};
118
118
  if (size) {
119
- scaleData.scaleX = (typeof size === 'number' ? size : size.width) / originSize.width;
120
- scaleData.scaleY = (typeof size === 'number' ? size : size.height) / originSize.height;
119
+ const scaleX = (typeof size === 'number' ? size : size.width || 0) / originSize.width, scaleY = (typeof size === 'number' ? size : size.height || 0) / originSize.height;
120
+ scaleData.scaleX = scaleX || scaleY || 1;
121
+ scaleData.scaleY = scaleY || scaleX || 1;
121
122
  }
122
123
  else if (scale)
123
124
  MathHelper.assignScale(scaleData, scale);
@@ -1690,6 +1691,9 @@ const emptyData = {};
1690
1691
  function isNull(value) {
1691
1692
  return value === undefined || value === null;
1692
1693
  }
1694
+ function isEmptyData(value) {
1695
+ return JSON.stringify(value) === '{}';
1696
+ }
1693
1697
 
1694
1698
  /******************************************************************************
1695
1699
  Copyright (c) Microsoft Corporation.
@@ -2345,7 +2349,7 @@ const RectHelper = {
2345
2349
  const { sin: sin$3, cos: cos$3, atan2: atan2$1, ceil: ceil$1, abs: abs$5, PI: PI$2, sqrt: sqrt$1, pow } = Math;
2346
2350
  const { setPoint: setPoint$4, addPoint: addPoint$2 } = TwoPointBoundsHelper;
2347
2351
  const { set, toNumberPoints: toNumberPoints$1 } = PointHelper;
2348
- const { M: M$8, L: L$9, C: C$8, Q: Q$7, Z: Z$7 } = PathCommandMap;
2352
+ const { M: M$8, L: L$9, C: C$7, Q: Q$7, Z: Z$7 } = PathCommandMap;
2349
2353
  const tempPoint$2 = {};
2350
2354
  const BezierHelper = {
2351
2355
  points(data, originPoints, curve, close) {
@@ -2380,7 +2384,7 @@ const BezierHelper = {
2380
2384
  data.push(Q$7, c1X, c1Y, bX, bY);
2381
2385
  }
2382
2386
  else {
2383
- data.push(C$8, c2X, c2Y, c1X, c1Y, bX, bY);
2387
+ data.push(C$7, c2X, c2Y, c1X, c1Y, bX, bY);
2384
2388
  }
2385
2389
  c2X = bX + cb * cX;
2386
2390
  c2Y = bY + cb * cY;
@@ -2485,7 +2489,7 @@ const BezierHelper = {
2485
2489
  x2 = cx + x + control * (rotationCos * radiusX * endSin + rotationSin * radiusY * endCos);
2486
2490
  y2 = cy + y + control * (rotationSin * radiusX * endSin - rotationCos * radiusY * endCos);
2487
2491
  if (data)
2488
- data.push(C$8, x1, y1, x2, y2, cx + x, cy + y);
2492
+ data.push(C$7, x1, y1, x2, y2, cx + x, cy + y);
2489
2493
  if (setPointBounds)
2490
2494
  toTwoPointBounds$1(cx + startX, cy + startY, x1, y1, x2, y2, cx + x, cy + y, setPointBounds, true);
2491
2495
  startX = x;
@@ -2499,7 +2503,7 @@ const BezierHelper = {
2499
2503
  set(setEndPoint, cx + x, cy + y);
2500
2504
  },
2501
2505
  quadraticCurveTo(data, fromX, fromY, x1, y1, toX, toY) {
2502
- data.push(C$8, (fromX + 2 * x1) / 3, (fromY + 2 * y1) / 3, (toX + 2 * x1) / 3, (toY + 2 * y1) / 3, toX, toY);
2506
+ data.push(C$7, (fromX + 2 * x1) / 3, (fromY + 2 * y1) / 3, (toX + 2 * x1) / 3, (toY + 2 * y1) / 3, toX, toY);
2503
2507
  },
2504
2508
  toTwoPointBoundsByQuadraticCurve(fromX, fromY, x1, y1, toX, toY, pointBounds, addMode) {
2505
2509
  toTwoPointBounds$1(fromX, fromY, (fromX + 2 * x1) / 3, (fromY + 2 * y1) / 3, (toX + 2 * x1) / 3, (toY + 2 * y1) / 3, toX, toY, pointBounds, addMode);
@@ -2607,7 +2611,7 @@ const EllipseHelper = {
2607
2611
  }
2608
2612
  };
2609
2613
 
2610
- 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;
2614
+ 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;
2611
2615
  const { rect: rect$3, roundRect: roundRect$2, arcTo: arcTo$3, arc: arc$3, ellipse: ellipse$4, quadraticCurveTo: quadraticCurveTo$1 } = BezierHelper;
2612
2616
  const { ellipticalArc } = EllipseHelper;
2613
2617
  const debug$f = Debug.get('PathConvert');
@@ -2735,14 +2739,14 @@ const PathConvert = {
2735
2739
  old[i + 4] += y;
2736
2740
  command = S;
2737
2741
  case S:
2738
- smooth = (lastCommand === C$7) || (lastCommand === S);
2742
+ smooth = (lastCommand === C$6) || (lastCommand === S);
2739
2743
  x1 = smooth ? (x * 2 - controlX) : old[i + 1];
2740
2744
  y1 = smooth ? (y * 2 - controlY) : old[i + 2];
2741
2745
  controlX = old[i + 1];
2742
2746
  controlY = old[i + 2];
2743
2747
  x = old[i + 3];
2744
2748
  y = old[i + 4];
2745
- data.push(C$7, x1, y1, controlX, controlY, x, y);
2749
+ data.push(C$6, x1, y1, controlX, controlY, x, y);
2746
2750
  i += 5;
2747
2751
  break;
2748
2752
  case c:
@@ -2752,13 +2756,13 @@ const PathConvert = {
2752
2756
  old[i + 4] += y;
2753
2757
  old[i + 5] += x;
2754
2758
  old[i + 6] += y;
2755
- command = C$7;
2756
- case C$7:
2759
+ command = C$6;
2760
+ case C$6:
2757
2761
  controlX = old[i + 3];
2758
2762
  controlY = old[i + 4];
2759
2763
  x = old[i + 5];
2760
2764
  y = old[i + 6];
2761
- data.push(C$7, old[i + 1], old[i + 2], controlX, controlY, x, y);
2765
+ data.push(C$6, old[i + 1], old[i + 2], controlX, controlY, x, y);
2762
2766
  i += 7;
2763
2767
  break;
2764
2768
  case t:
@@ -2869,7 +2873,7 @@ const PathConvert = {
2869
2873
  data.push(L$8, item.x, item.y);
2870
2874
  break;
2871
2875
  case 'C':
2872
- data.push(C$7, item.x1, item.y1, item.x2, item.y2, item.x, item.y);
2876
+ data.push(C$6, item.x1, item.y1, item.x2, item.y2, item.x, item.y);
2873
2877
  break;
2874
2878
  case 'Q':
2875
2879
  data.push(Q$6, item.x1, item.y1, item.x, item.y);
@@ -2896,7 +2900,7 @@ const PathConvert = {
2896
2900
  };
2897
2901
  const { current, pushData, copyData } = PathConvert;
2898
2902
 
2899
- 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;
2903
+ 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;
2900
2904
  const { getMinDistanceFrom, getRadianFrom } = PointHelper;
2901
2905
  const { tan, min, abs: abs$4 } = Math;
2902
2906
  const startPoint = {};
@@ -2911,7 +2915,7 @@ const PathCommandDataHelper = {
2911
2915
  data.push(L$7, x, y);
2912
2916
  },
2913
2917
  bezierCurveTo(data, x1, y1, x2, y2, x, y) {
2914
- data.push(C$6, x1, y1, x2, y2, x, y);
2918
+ data.push(C$5, x1, y1, x2, y2, x, y);
2915
2919
  },
2916
2920
  quadraticCurveTo(data, x1, y1, x, y) {
2917
2921
  data.push(Q$5, x1, y1, x, y);
@@ -3073,7 +3077,7 @@ class PathCreator {
3073
3077
  paint() { }
3074
3078
  }
3075
3079
 
3076
- 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;
3080
+ 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;
3077
3081
  const debug$e = Debug.get('PathDrawer');
3078
3082
  const PathDrawer = {
3079
3083
  drawPathByData(drawer, data) {
@@ -3092,7 +3096,7 @@ const PathDrawer = {
3092
3096
  drawer.lineTo(data[i + 1], data[i + 2]);
3093
3097
  i += 3;
3094
3098
  break;
3095
- case C$5:
3099
+ case C$4:
3096
3100
  drawer.bezierCurveTo(data[i + 1], data[i + 2], data[i + 3], data[i + 4], data[i + 5], data[i + 6]);
3097
3101
  i += 7;
3098
3102
  break;
@@ -3144,7 +3148,7 @@ const PathDrawer = {
3144
3148
  }
3145
3149
  };
3146
3150
 
3147
- 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;
3151
+ 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;
3148
3152
  const { toTwoPointBounds, toTwoPointBoundsByQuadraticCurve, arcTo: arcTo$1, arc, ellipse: ellipse$1 } = BezierHelper;
3149
3153
  const { addPointBounds, copy: copy$b, addPoint: addPoint$1, setPoint: setPoint$3, addBounds, toBounds: toBounds$3 } = TwoPointBoundsHelper;
3150
3154
  const debug$d = Debug.get('PathBounds');
@@ -3165,7 +3169,7 @@ const PathBounds = {
3165
3169
  while (i < len) {
3166
3170
  command = data[i];
3167
3171
  if (i === 0) {
3168
- if (command === Z$3 || command === C$4 || command === Q$3) {
3172
+ if (command === Z$3 || command === C$3 || command === Q$3) {
3169
3173
  setPoint$3(setPointBounds, x, y);
3170
3174
  }
3171
3175
  else {
@@ -3180,7 +3184,7 @@ const PathBounds = {
3180
3184
  addPoint$1(setPointBounds, x, y);
3181
3185
  i += 3;
3182
3186
  break;
3183
- case C$4:
3187
+ case C$3:
3184
3188
  toX = data[i + 5];
3185
3189
  toY = data[i + 6];
3186
3190
  toTwoPointBounds(x, y, data[i + 1], data[i + 2], data[i + 3], data[i + 4], toX, toY, tempPointBounds);
@@ -3262,12 +3266,12 @@ const PathBounds = {
3262
3266
  }
3263
3267
  };
3264
3268
 
3265
- const { M: M$3, L: L$4, C: C$3, Z: Z$2 } = PathCommandMap;
3269
+ const { M: M$3, L: L$4, Z: Z$2 } = PathCommandMap;
3266
3270
  const { getCenterX, getCenterY } = PointHelper;
3267
3271
  const { arcTo } = PathCommandDataHelper;
3268
3272
  const PathCorner = {
3269
3273
  smooth(data, cornerRadius, _cornerSmoothing) {
3270
- let command;
3274
+ let command, commandLen;
3271
3275
  let i = 0, x = 0, y = 0, startX = 0, startY = 0, secondX = 0, secondY = 0, lastX = 0, lastY = 0;
3272
3276
  const len = data.length;
3273
3277
  const smooth = [];
@@ -3304,15 +3308,16 @@ const PathCorner = {
3304
3308
  lastX = x;
3305
3309
  lastY = y;
3306
3310
  break;
3307
- case C$3:
3308
- smooth.push(C$3, data[i + 1], data[i + 2], data[i + 3], data[i + 4], data[i + 5], data[i + 6]);
3309
- i += 7;
3310
- break;
3311
3311
  case Z$2:
3312
3312
  arcTo(smooth, startX, startY, secondX, secondY, cornerRadius, lastX, lastY);
3313
3313
  smooth.push(Z$2);
3314
3314
  i += 1;
3315
3315
  break;
3316
+ default:
3317
+ commandLen = PathNumberCommandLengthMap[command];
3318
+ for (let j = 0; j < commandLen; j++)
3319
+ smooth.push(data[i + j]);
3320
+ i += commandLen;
3316
3321
  }
3317
3322
  }
3318
3323
  if (command !== Z$2) {
@@ -4074,28 +4079,42 @@ function defineDataProcessor(target, key, defaultValue) {
4074
4079
  return v === undefined ? defaultValue(this.__leaf) : v;
4075
4080
  };
4076
4081
  }
4082
+ else if (typeof defaultValue === 'object') {
4083
+ const isEmpty = isEmptyData(defaultValue);
4084
+ property.get = function () {
4085
+ let v = this[computedKey];
4086
+ return v === undefined ? this[computedKey] = isEmpty ? {} : DataHelper.clone(defaultValue) : v;
4087
+ };
4088
+ }
4089
+ const isBox = target.isBranchLeaf;
4077
4090
  if (key === 'width') {
4078
4091
  property.get = function () {
4079
4092
  const v = this[computedKey];
4080
4093
  if (v === undefined) {
4081
- const t = this;
4082
- return t._height && t.__naturalWidth && t.__useNaturalRatio ? t._height * t.__naturalWidth / t.__naturalHeight : t.__naturalWidth || defaultValue;
4094
+ const t = this, naturalWidth = t.__naturalWidth, leaf = t.__leaf;
4095
+ if (!defaultValue || leaf.pathInputed)
4096
+ return leaf.boxBounds.width;
4097
+ if (naturalWidth)
4098
+ return t._height && t.__useNaturalRatio ? t._height * naturalWidth / t.__naturalHeight : naturalWidth;
4099
+ return (isBox && leaf.children.length) ? leaf.boxBounds.width : defaultValue;
4083
4100
  }
4084
- else {
4101
+ else
4085
4102
  return v;
4086
- }
4087
4103
  };
4088
4104
  }
4089
4105
  else if (key === 'height') {
4090
4106
  property.get = function () {
4091
4107
  const v = this[computedKey];
4092
4108
  if (v === undefined) {
4093
- const t = this;
4094
- return t._width && t.__naturalHeight && t.__useNaturalRatio ? t._width * t.__naturalHeight / t.__naturalWidth : t.__naturalHeight || defaultValue;
4109
+ const t = this, naturalHeight = t.__naturalHeight, leaf = t.__leaf;
4110
+ if (!defaultValue || leaf.pathInputed)
4111
+ return leaf.boxBounds.height;
4112
+ if (naturalHeight)
4113
+ return t._width && t.__useNaturalRatio ? t._width * naturalHeight / t.__naturalWidth : naturalHeight;
4114
+ return (isBox && leaf.children.length) ? leaf.boxBounds.height : defaultValue;
4095
4115
  }
4096
- else {
4116
+ else
4097
4117
  return v;
4098
- }
4099
4118
  };
4100
4119
  }
4101
4120
  let descriptor, find = data;
@@ -4522,7 +4541,12 @@ class LeafLayout {
4522
4541
  while (root.parent && !root.parent.leafer) {
4523
4542
  root = root.parent;
4524
4543
  }
4525
- Platform.layout(root);
4544
+ const r = root;
4545
+ if (r.__fullLayouting)
4546
+ return;
4547
+ r.__fullLayouting = true;
4548
+ Platform.layout(r);
4549
+ delete r.__fullLayouting;
4526
4550
  }
4527
4551
  }
4528
4552
  getTransform(relative = 'world') {
@@ -6047,7 +6071,7 @@ class LeafLevelList {
6047
6071
  }
6048
6072
  }
6049
6073
 
6050
- const version = "1.5.1";
6074
+ const version = "1.5.2";
6051
6075
 
6052
6076
  class LeaferCanvas extends LeaferCanvasBase {
6053
6077
  get allowBackgroundColor() { return true; }
@@ -7637,7 +7661,7 @@ __decorate([
7637
7661
  strokeType()
7638
7662
  ], UI.prototype, "dashPattern", void 0);
7639
7663
  __decorate([
7640
- strokeType()
7664
+ strokeType(0)
7641
7665
  ], UI.prototype, "dashOffset", void 0);
7642
7666
  __decorate([
7643
7667
  strokeType(10)
@@ -7730,6 +7754,12 @@ let Group = class Group extends UI {
7730
7754
  __decorate([
7731
7755
  dataProcessor(GroupData)
7732
7756
  ], Group.prototype, "__", void 0);
7757
+ __decorate([
7758
+ boundsType(0)
7759
+ ], Group.prototype, "width", void 0);
7760
+ __decorate([
7761
+ boundsType(0)
7762
+ ], Group.prototype, "height", void 0);
7733
7763
  Group = __decorate([
7734
7764
  useModule(Branch),
7735
7765
  registerUI()
@@ -8145,7 +8175,7 @@ let Box = class Box extends Group {
8145
8175
  __updateRectBoxBounds() { }
8146
8176
  __updateBoxBounds(_secondLayout) {
8147
8177
  const data = this.__;
8148
- if (this.children.length) {
8178
+ if (this.children.length && !this.pathInputed) {
8149
8179
  if (data.__autoSide) {
8150
8180
  if (data.__hasSurface)
8151
8181
  this.__extraUpdate();
@@ -8214,6 +8244,12 @@ let Box = class Box extends Group {
8214
8244
  __decorate([
8215
8245
  dataProcessor(BoxData)
8216
8246
  ], Box.prototype, "__", void 0);
8247
+ __decorate([
8248
+ boundsType(100)
8249
+ ], Box.prototype, "width", void 0);
8250
+ __decorate([
8251
+ boundsType(100)
8252
+ ], Box.prototype, "height", void 0);
8217
8253
  __decorate([
8218
8254
  dataType(false)
8219
8255
  ], Box.prototype, "resizeChildren", void 0);
@@ -10099,16 +10135,20 @@ canvas$1.hitPixel = function (radiusPoint, offset, scale = 1) {
10099
10135
  };
10100
10136
 
10101
10137
  function fillText(ui, canvas) {
10102
- let row;
10103
- const { rows, decorationY, decorationHeight } = ui.__.__textDrawData;
10138
+ let row, data = ui.__.__textDrawData;
10139
+ const { rows, decorationY } = data;
10104
10140
  for (let i = 0, len = rows.length; i < len; i++) {
10105
10141
  row = rows[i];
10106
10142
  if (row.text)
10107
10143
  canvas.fillText(row.text, row.x, row.y);
10108
10144
  else if (row.data)
10109
10145
  row.data.forEach(charData => { canvas.fillText(charData.char, charData.x, row.y); });
10110
- if (decorationY)
10111
- canvas.fillRect(row.x, row.y + decorationY, row.width, decorationHeight);
10146
+ }
10147
+ if (decorationY) {
10148
+ const { decorationColor, decorationHeight } = data;
10149
+ if (decorationColor)
10150
+ canvas.fillStyle = decorationColor;
10151
+ rows.forEach(row => decorationY.forEach(value => canvas.fillRect(row.x, row.y + value, row.width, decorationHeight)));
10112
10152
  }
10113
10153
  }
10114
10154
 
@@ -10179,16 +10219,18 @@ function drawAlignStroke(align, stroke, isStrokes, ui, canvas) {
10179
10219
  out.recycle(ui.__nowWorld);
10180
10220
  }
10181
10221
  function drawTextStroke(ui, canvas) {
10182
- let row;
10183
- const { rows, decorationY, decorationHeight } = ui.__.__textDrawData;
10222
+ let row, data = ui.__.__textDrawData;
10223
+ const { rows, decorationY } = data;
10184
10224
  for (let i = 0, len = rows.length; i < len; i++) {
10185
10225
  row = rows[i];
10186
10226
  if (row.text)
10187
10227
  canvas.strokeText(row.text, row.x, row.y);
10188
10228
  else if (row.data)
10189
10229
  row.data.forEach(charData => { canvas.strokeText(charData.char, charData.x, row.y); });
10190
- if (decorationY)
10191
- canvas.strokeRect(row.x, row.y + decorationY, row.width, decorationHeight);
10230
+ }
10231
+ if (decorationY) {
10232
+ const { decorationHeight } = data;
10233
+ rows.forEach(row => decorationY.forEach(value => canvas.strokeRect(row.x, row.y + value, row.width, decorationHeight)));
10192
10234
  }
10193
10235
  }
10194
10236
  function drawStrokesStyle(strokes, isText, ui, canvas) {
@@ -10754,6 +10796,8 @@ function recycleImage(attrName, data) {
10754
10796
  }
10755
10797
  image.unload(paints[i].loadId, !input.some((item) => item.url === url));
10756
10798
  }
10799
+ else
10800
+ paints[i].style = null;
10757
10801
  }
10758
10802
  }
10759
10803
  return recycleMap;
@@ -11486,14 +11530,25 @@ function toTextChar(row) {
11486
11530
  }
11487
11531
 
11488
11532
  function decorationText(drawData, style) {
11489
- const { fontSize } = style;
11533
+ let type;
11534
+ const { fontSize, textDecoration } = style;
11490
11535
  drawData.decorationHeight = fontSize / 11;
11491
- switch (style.textDecoration) {
11536
+ if (typeof textDecoration === 'object') {
11537
+ type = textDecoration.type;
11538
+ if (textDecoration.color)
11539
+ drawData.decorationColor = ColorConvert.string(textDecoration.color);
11540
+ }
11541
+ else
11542
+ type = textDecoration;
11543
+ switch (type) {
11492
11544
  case 'under':
11493
- drawData.decorationY = fontSize * 0.15;
11545
+ drawData.decorationY = [fontSize * 0.15];
11494
11546
  break;
11495
11547
  case 'delete':
11496
- drawData.decorationY = -fontSize * 0.35;
11548
+ drawData.decorationY = [-fontSize * 0.35];
11549
+ break;
11550
+ case 'under-delete':
11551
+ drawData.decorationY = [fontSize * 0.15, -fontSize * 0.35];
11497
11552
  }
11498
11553
  }
11499
11554
 
@@ -11954,7 +12009,8 @@ class EditSelect extends Group {
11954
12009
  return target.leafer !== this.editor.leafer;
11955
12010
  }
11956
12011
  allowDrag(e) {
11957
- if (this.running && (this.editor.mergeConfig.boxSelect) && !e.target.draggable) {
12012
+ const { boxSelect, multipleSelect } = this.editor.mergeConfig;
12013
+ if (this.running && (multipleSelect && boxSelect) && !e.target.draggable) {
11958
12014
  return (!this.editor.editing && this.allow(e.target)) || (e.shiftKey && !findOne(e.path));
11959
12015
  }
11960
12016
  else {
@@ -11972,7 +12028,8 @@ class EditSelect extends Group {
11972
12028
  return this.isMultipleSelect(e) ? this.findDeepOne(e) : findOne(e.path);
11973
12029
  }
11974
12030
  isMultipleSelect(e) {
11975
- return e.shiftKey || this.editor.mergeConfig.continuousSelect;
12031
+ const { multipleSelect, continuousSelect } = this.editor.mergeConfig;
12032
+ return multipleSelect && (e.shiftKey || continuousSelect);
11976
12033
  }
11977
12034
  __listenEvents() {
11978
12035
  const { editor } = this;
@@ -12147,21 +12204,25 @@ const EditDataHelper = {
12147
12204
  let last;
12148
12205
  switch (direction) {
12149
12206
  case top$1:
12207
+ case topLeft$1:
12150
12208
  last = { x: 0.5, y: 0 };
12151
12209
  align = 'bottom';
12152
12210
  skewX = 1;
12153
12211
  break;
12154
12212
  case bottom$1:
12213
+ case bottomRight:
12155
12214
  last = { x: 0.5, y: 1 };
12156
12215
  align = 'top';
12157
12216
  skewX = 1;
12158
12217
  break;
12159
12218
  case left$2:
12219
+ case bottomLeft:
12160
12220
  last = { x: 0, y: 0.5 };
12161
12221
  align = 'right';
12162
12222
  skewY = 1;
12163
12223
  break;
12164
12224
  case right$2:
12225
+ case topRight$1:
12165
12226
  last = { x: 1, y: 0.5 };
12166
12227
  align = 'left';
12167
12228
  skewY = 1;
@@ -12250,7 +12311,7 @@ function updateCursor(editor, e) {
12250
12311
  let showResize = pointType.includes('resize');
12251
12312
  if (showResize && rotateable && (e.metaKey || e.ctrlKey || !resizeable))
12252
12313
  showResize = false;
12253
- const showSkew = skewable && !showResize && point.name === 'resize-line';
12314
+ const showSkew = skewable && !showResize && (point.name === 'resize-line' || pointType === 'skew');
12254
12315
  const cursor = showSkew ? skewCursor : (showResize ? resizeCursor : rotateCursor);
12255
12316
  rotation += (EditDataHelper.getFlipDirection(point.direction, flippedX, flippedY) + 1) * 45;
12256
12317
  rotation = Math.round(MathHelper.formatRotation(rotation, true) / 2) * 2;
@@ -12472,6 +12533,8 @@ class EditBox extends Group {
12472
12533
  editor.onRotate(e);
12473
12534
  if (pointType.includes('resize'))
12474
12535
  editor.onScale(e);
12536
+ if (pointType === 'skew')
12537
+ editor.onSkew(e);
12475
12538
  updateCursor(editor, e);
12476
12539
  }
12477
12540
  onArrow(e) {
@@ -12653,6 +12716,7 @@ const config = {
12653
12716
  hover: true,
12654
12717
  select: 'press',
12655
12718
  openInner: 'double',
12719
+ multipleSelect: true,
12656
12720
  boxSelect: true,
12657
12721
  moveable: true,
12658
12722
  resizeable: true,
@@ -12744,13 +12808,16 @@ const EditorHelper = {
12744
12808
  const ungroupList = [];
12745
12809
  app.lockLayout();
12746
12810
  list.forEach(leaf => {
12747
- if (leaf.isBranch && !leaf.isBranchLeaf) {
12811
+ if (leaf.isBranch) {
12748
12812
  const { parent, children } = leaf;
12749
12813
  while (children.length) {
12750
12814
  ungroupList.push(children[0]);
12751
12815
  children[0].dropTo(parent, parent.children.indexOf(leaf));
12752
12816
  }
12753
- leaf.remove();
12817
+ if (leaf.isBranchLeaf)
12818
+ ungroupList.push(leaf);
12819
+ else
12820
+ leaf.remove();
12754
12821
  }
12755
12822
  else {
12756
12823
  ungroupList.push(leaf);
@@ -13055,13 +13122,22 @@ class Editor extends Group {
13055
13122
  this.skewOf(origin, skewX, skewY);
13056
13123
  }
13057
13124
  move(x, y = 0) {
13058
- const { element } = this;
13059
13125
  if (!this.checkTransform('moveable'))
13060
13126
  return;
13061
- const world = element.getWorldPointByLocal(typeof x === 'object' ? Object.assign({}, x) : { x, y }, null, true);
13127
+ if (typeof x === 'object')
13128
+ y = x.y, x = x.x;
13129
+ const { element: target } = this, { beforeMove } = this.mergeConfig;
13130
+ if (beforeMove) {
13131
+ const check = beforeMove({ target, x, y });
13132
+ if (typeof check === 'object')
13133
+ x = check.x, y = check.y;
13134
+ else if (check === false)
13135
+ return;
13136
+ }
13137
+ const world = target.getWorldPointByLocal({ x, y }, null, true);
13062
13138
  if (this.multiple)
13063
- element.safeChange(() => element.move(x, y));
13064
- const data = { target: element, editor: this, moveX: world.x, moveY: world.y };
13139
+ target.safeChange(() => target.move(x, y));
13140
+ const data = { target, editor: this, moveX: world.x, moveY: world.y };
13065
13141
  this.emitEvent(new EditorMoveEvent(EditorMoveEvent.BEFORE_MOVE, data));
13066
13142
  const event = new EditorMoveEvent(EditorMoveEvent.MOVE, data);
13067
13143
  this.editTool.onMove(event);
@@ -13070,8 +13146,14 @@ class Editor extends Group {
13070
13146
  scaleWithDrag(data) {
13071
13147
  if (!this.checkTransform('resizeable'))
13072
13148
  return;
13073
- const { element } = this;
13074
- data = Object.assign(Object.assign({}, data), { target: element, editor: this, worldOrigin: element.getWorldPoint(data.origin) });
13149
+ const { element: target } = this, { beforeScale } = this.mergeConfig;
13150
+ if (beforeScale) {
13151
+ const { origin, scaleX, scaleY, drag } = data;
13152
+ const check = beforeScale({ target, drag, origin, scaleX, scaleY });
13153
+ if (check === false)
13154
+ return;
13155
+ }
13156
+ data = Object.assign(Object.assign({}, data), { target, editor: this, worldOrigin: target.getWorldPoint(data.origin) });
13075
13157
  this.emitEvent(new EditorScaleEvent(EditorScaleEvent.BEFORE_SCALE, data));
13076
13158
  const event = new EditorScaleEvent(EditorScaleEvent.SCALE, data);
13077
13159
  this.editTool.onScaleWithDrag(event);
@@ -13080,10 +13162,17 @@ class Editor extends Group {
13080
13162
  scaleOf(origin, scaleX, scaleY = scaleX, _resize) {
13081
13163
  if (!this.checkTransform('resizeable'))
13082
13164
  return;
13083
- const { element } = this;
13165
+ const { element: target } = this, { beforeScale } = this.mergeConfig;
13166
+ if (beforeScale) {
13167
+ const check = beforeScale({ target, origin, scaleX, scaleY });
13168
+ if (typeof check === 'object')
13169
+ scaleX = check.scaleX, scaleY = check.scaleY;
13170
+ else if (check === false)
13171
+ return;
13172
+ }
13084
13173
  const worldOrigin = this.getWorldOrigin(origin);
13085
- const transform = this.multiple && this.getChangedTransform(() => element.safeChange(() => element.scaleOf(origin, scaleX, scaleY)));
13086
- const data = { target: element, editor: this, worldOrigin, scaleX, scaleY, transform };
13174
+ const transform = this.multiple && this.getChangedTransform(() => target.safeChange(() => target.scaleOf(origin, scaleX, scaleY)));
13175
+ const data = { target, editor: this, worldOrigin, scaleX, scaleY, transform };
13087
13176
  this.emitEvent(new EditorScaleEvent(EditorScaleEvent.BEFORE_SCALE, data));
13088
13177
  const event = new EditorScaleEvent(EditorScaleEvent.SCALE, data);
13089
13178
  this.editTool.onScale(event);
@@ -13104,10 +13193,17 @@ class Editor extends Group {
13104
13193
  rotateOf(origin, rotation) {
13105
13194
  if (!this.checkTransform('rotateable'))
13106
13195
  return;
13107
- const { element } = this;
13196
+ const { element: target } = this, { beforeRotate } = this.mergeConfig;
13197
+ if (beforeRotate) {
13198
+ const check = beforeRotate({ target, origin, rotation });
13199
+ if (typeof check === 'number')
13200
+ rotation = check;
13201
+ else if (check === false)
13202
+ return;
13203
+ }
13108
13204
  const worldOrigin = this.getWorldOrigin(origin);
13109
- const transform = this.multiple && this.getChangedTransform(() => element.safeChange(() => element.rotateOf(origin, rotation)));
13110
- const data = { target: element, editor: this, worldOrigin, rotation, transform };
13205
+ const transform = this.multiple && this.getChangedTransform(() => target.safeChange(() => target.rotateOf(origin, rotation)));
13206
+ const data = { target, editor: this, worldOrigin, rotation, transform };
13111
13207
  this.emitEvent(new EditorRotateEvent(EditorRotateEvent.BEFORE_ROTATE, data));
13112
13208
  const event = new EditorRotateEvent(EditorRotateEvent.ROTATE, data);
13113
13209
  this.editTool.onRotate(event);
@@ -13116,10 +13212,17 @@ class Editor extends Group {
13116
13212
  skewOf(origin, skewX, skewY = 0, _resize) {
13117
13213
  if (!this.checkTransform('skewable'))
13118
13214
  return;
13119
- const { element } = this;
13215
+ const { element: target } = this, { beforeSkew } = this.mergeConfig;
13216
+ if (beforeSkew) {
13217
+ const check = beforeSkew({ target, origin, skewX, skewY });
13218
+ if (typeof check === 'object')
13219
+ skewX = check.skewX, skewY = check.skewY;
13220
+ else if (check === false)
13221
+ return;
13222
+ }
13120
13223
  const worldOrigin = this.getWorldOrigin(origin);
13121
- const transform = this.multiple && this.getChangedTransform(() => element.safeChange(() => element.skewOf(origin, skewX, skewY)));
13122
- const data = { target: element, editor: this, worldOrigin, skewX, skewY, transform };
13224
+ const transform = this.multiple && this.getChangedTransform(() => target.safeChange(() => target.skewOf(origin, skewX, skewY)));
13225
+ const data = { target, editor: this, worldOrigin, skewX, skewY, transform };
13123
13226
  this.emitEvent(new EditorSkewEvent(EditorSkewEvent.BEFORE_SKEW, data));
13124
13227
  const event = new EditorSkewEvent(EditorSkewEvent.SKEW, data);
13125
13228
  this.editTool.onSkew(event);
@@ -13632,7 +13735,9 @@ function scaleResizeFontSize(leaf, scaleX, scaleY, direction) {
13632
13735
  }
13633
13736
  }
13634
13737
  leaf.fontSize *= fontScale;
13635
- const data = leaf.__;
13738
+ const data = leaf.__, { padding } = data;
13739
+ if (padding)
13740
+ leaf.padding = padding instanceof Array ? padding.map(item => item * fontScale) : padding * fontScale;
13636
13741
  if (!data.__autoWidth)
13637
13742
  leaf.width *= fontScale;
13638
13743
  if (!data.__autoHeight)
@@ -13720,14 +13825,11 @@ Group.prototype.__scaleResize = function (scaleX, scaleY) {
13720
13825
  scaleResizeGroup(this, scaleX, scaleY);
13721
13826
  };
13722
13827
  Box.prototype.__scaleResize = function (scaleX, scaleY) {
13723
- if (this.__.__autoSize && this.children.length) {
13724
- scaleResizeGroup(this, scaleX, scaleY);
13725
- }
13726
- else {
13828
+ const { resizeChildren, __autoSize } = this.__;
13829
+ if (!(__autoSize && resizeChildren))
13727
13830
  scaleResize(this, scaleX, scaleY);
13728
- if (this.__.resizeChildren)
13729
- scaleResizeGroup(this, scaleX, scaleY);
13730
- }
13831
+ if (resizeChildren)
13832
+ scaleResizeGroup(this, scaleX, scaleY);
13731
13833
  };
13732
13834
 
13733
13835
  Plugin.add('resize');
@@ -14927,6 +15029,12 @@ const verticalAlignMap = {
14927
15029
  'middle': 'center',
14928
15030
  'bottom': 'flex-end'
14929
15031
  };
15032
+ const textDecorationMap = {
15033
+ 'none': 'none',
15034
+ 'under': 'underline',
15035
+ 'delete': 'line-through',
15036
+ 'under-delete': 'underline line-through'
15037
+ };
14930
15038
  function updateStyle(textDom, text, textScale) {
14931
15039
  const { style } = textDom;
14932
15040
  const { fill, padding, textWrap, textOverflow, textDecoration } = text;
@@ -14935,7 +15043,16 @@ function updateStyle(textDom, text, textScale) {
14935
15043
  setFill(style, fill);
14936
15044
  style.fontStyle = text.italic ? 'italic' : 'normal';
14937
15045
  style.fontWeight = text.fontWeight;
14938
- style.textDecoration = textDecoration === 'delete' ? 'line-through' : textDecoration;
15046
+ let decorationType;
15047
+ if (typeof textDecoration === 'object') {
15048
+ decorationType = textDecoration.type;
15049
+ if (textDecoration.color)
15050
+ style.textDecorationColor = ColorConvert.string(textDecoration.color);
15051
+ }
15052
+ else {
15053
+ decorationType = textDecoration;
15054
+ }
15055
+ style.textDecoration = textDecorationMap[decorationType];
14939
15056
  style.textTransform = textCaseMap[text.textCase];
14940
15057
  style.textAlign = text.textAlign === 'both' ? 'justify' : text.textAlign;
14941
15058
  style.display = 'flex';
@@ -15192,5 +15309,5 @@ HTMLText = __decorate([
15192
15309
 
15193
15310
  Plugin.add('html');
15194
15311
 
15195
- export { AlignHelper, Answer, App, AroundHelper, Arrow, ArrowData, AutoBounds, BezierHelper, Bounds, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, Cursor, DataHelper, Debug, Direction4, Direction9, DragEvent, Dragger, DropEvent, EditBox, EditDataHelper, EditPoint, EditSelect, EditSelectHelper, EditTool, EditToolCreator, Editor, EditorEvent, EditorGroupEvent, EditorHelper, EditorMoveEvent, EditorRotateEvent, EditorScaleEvent, EditorSkewEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Filter, Finder, Frame, FrameData, Group, GroupData, HTMLText, HTMLTextData, HitCanvasManager, Image, ImageData, ImageEvent, ImageManager, IncrementId, InnerEditor, InnerEditorEvent, InteractionBase, InteractionHelper, KeyEvent, Keyboard, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, LeaferTypeCreator, Line, LineData, LineEditTool, MathHelper, Matrix, MatrixHelper, MoveEvent, MultiTouchHelper, MyDragEvent, MyImage, MyPointerEvent, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathArrowModule, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathMatrixHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Pen, PenData, Picker, Platform, Plugin, Point, PointHelper, PointerButton, PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Resource, RotateEvent, Run, ScrollBar, SelectArea, Selector, Star, StarData, State, StringNumberMap, Stroker, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert, TextData, TextEditor, Transformer, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, WheelEventHelper, ZoomEvent, addViewport, addViewportConfig, affectRenderBoundsType, affectStrokeBoundsType, arrowType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, doBoundsType, doStrokeType, effectType, emptyData, eraserType, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isNull, layoutProcessor, maskType, naturalBoundsType, opacityType, pathInputType, pathType, pen, positionType, registerEditTool, registerInnerEditor, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, sortType, strokeType, surfaceType, tempBounds$1 as tempBounds, tempMatrix, tempPoint$3 as tempPoint, useCanvas, useModule, version, visibleType, zoomLayerType };
15312
+ export { AlignHelper, Answer, App, AroundHelper, Arrow, ArrowData, AutoBounds, BezierHelper, Bounds, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, Cursor, DataHelper, Debug, Direction4, Direction9, DragEvent, Dragger, DropEvent, EditBox, EditDataHelper, EditPoint, EditSelect, EditSelectHelper, EditTool, EditToolCreator, Editor, EditorEvent, EditorGroupEvent, EditorHelper, EditorMoveEvent, EditorRotateEvent, EditorScaleEvent, EditorSkewEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Filter, Finder, Frame, FrameData, Group, GroupData, HTMLText, HTMLTextData, HitCanvasManager, Image, ImageData, ImageEvent, ImageManager, IncrementId, InnerEditor, InnerEditorEvent, InteractionBase, InteractionHelper, KeyEvent, Keyboard, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, LeaferTypeCreator, Line, LineData, LineEditTool, MathHelper, Matrix, MatrixHelper, MoveEvent, MultiTouchHelper, MyDragEvent, MyImage, MyPointerEvent, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathArrowModule, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathMatrixHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Pen, PenData, Picker, Platform, Plugin, Point, PointHelper, PointerButton, PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Resource, RotateEvent, Run, ScrollBar, SelectArea, Selector, Star, StarData, State, StringNumberMap, Stroker, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert, TextData, TextEditor, Transformer, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, WheelEventHelper, ZoomEvent, addViewport, addViewportConfig, affectRenderBoundsType, affectStrokeBoundsType, arrowType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, doBoundsType, doStrokeType, effectType, emptyData, eraserType, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isEmptyData, isNull, layoutProcessor, maskType, naturalBoundsType, opacityType, pathInputType, pathType, pen, positionType, registerEditTool, registerInnerEditor, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, sortType, strokeType, surfaceType, tempBounds$1 as tempBounds, tempMatrix, tempPoint$3 as tempPoint, useCanvas, useModule, version, visibleType, zoomLayerType };
15196
15313
  //# sourceMappingURL=worker.module.js.map