@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.
@@ -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.3";
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
 
@@ -11651,9 +11706,24 @@ function targetAttr(fn) {
11651
11706
  set(value) {
11652
11707
  const old = this[privateKey];
11653
11708
  if (old !== value) {
11654
- const type = key === 'target' ? EditorEvent.BEFORE_SELECT : EditorEvent.BEFORE_HOVER;
11655
- if (this.hasEvent(type))
11656
- this.emitEvent(new EditorEvent(type, { editor: this, value: value, oldValue: old }));
11709
+ if (this.config) {
11710
+ const isSelect = key === 'target';
11711
+ if (isSelect) {
11712
+ if (value instanceof Array && value.length > 1 && value[0].locked)
11713
+ value.splice(0, 1);
11714
+ const { beforeSelect } = this.config;
11715
+ if (beforeSelect) {
11716
+ const check = beforeSelect({ target: value });
11717
+ if (typeof check === 'object')
11718
+ value = check;
11719
+ else if (check === false)
11720
+ return;
11721
+ }
11722
+ }
11723
+ const type = isSelect ? EditorEvent.BEFORE_SELECT : EditorEvent.BEFORE_HOVER;
11724
+ if (this.hasEvent(type))
11725
+ this.emitEvent(new EditorEvent(type, { editor: this, value: value, oldValue: old }));
11726
+ }
11657
11727
  this[privateKey] = value, fn(this, old);
11658
11728
  }
11659
11729
  }
@@ -11954,7 +12024,8 @@ class EditSelect extends Group {
11954
12024
  return target.leafer !== this.editor.leafer;
11955
12025
  }
11956
12026
  allowDrag(e) {
11957
- if (this.running && (this.editor.mergeConfig.boxSelect) && !e.target.draggable) {
12027
+ const { boxSelect, multipleSelect } = this.editor.mergeConfig;
12028
+ if (this.running && (multipleSelect && boxSelect) && !e.target.draggable) {
11958
12029
  return (!this.editor.editing && this.allow(e.target)) || (e.shiftKey && !findOne(e.path));
11959
12030
  }
11960
12031
  else {
@@ -11972,7 +12043,8 @@ class EditSelect extends Group {
11972
12043
  return this.isMultipleSelect(e) ? this.findDeepOne(e) : findOne(e.path);
11973
12044
  }
11974
12045
  isMultipleSelect(e) {
11975
- return e.shiftKey || this.editor.mergeConfig.continuousSelect;
12046
+ const { multipleSelect, continuousSelect } = this.editor.mergeConfig;
12047
+ return multipleSelect && (e.shiftKey || continuousSelect);
11976
12048
  }
11977
12049
  __listenEvents() {
11978
12050
  const { editor } = this;
@@ -12147,21 +12219,25 @@ const EditDataHelper = {
12147
12219
  let last;
12148
12220
  switch (direction) {
12149
12221
  case top$1:
12222
+ case topLeft$1:
12150
12223
  last = { x: 0.5, y: 0 };
12151
12224
  align = 'bottom';
12152
12225
  skewX = 1;
12153
12226
  break;
12154
12227
  case bottom$1:
12228
+ case bottomRight:
12155
12229
  last = { x: 0.5, y: 1 };
12156
12230
  align = 'top';
12157
12231
  skewX = 1;
12158
12232
  break;
12159
12233
  case left$2:
12234
+ case bottomLeft:
12160
12235
  last = { x: 0, y: 0.5 };
12161
12236
  align = 'right';
12162
12237
  skewY = 1;
12163
12238
  break;
12164
12239
  case right$2:
12240
+ case topRight$1:
12165
12241
  last = { x: 1, y: 0.5 };
12166
12242
  align = 'left';
12167
12243
  skewY = 1;
@@ -12250,7 +12326,7 @@ function updateCursor(editor, e) {
12250
12326
  let showResize = pointType.includes('resize');
12251
12327
  if (showResize && rotateable && (e.metaKey || e.ctrlKey || !resizeable))
12252
12328
  showResize = false;
12253
- const showSkew = skewable && !showResize && point.name === 'resize-line';
12329
+ const showSkew = skewable && !showResize && (point.name === 'resize-line' || pointType === 'skew');
12254
12330
  const cursor = showSkew ? skewCursor : (showResize ? resizeCursor : rotateCursor);
12255
12331
  rotation += (EditDataHelper.getFlipDirection(point.direction, flippedX, flippedY) + 1) * 45;
12256
12332
  rotation = Math.round(MathHelper.formatRotation(rotation, true) / 2) * 2;
@@ -12472,6 +12548,8 @@ class EditBox extends Group {
12472
12548
  editor.onRotate(e);
12473
12549
  if (pointType.includes('resize'))
12474
12550
  editor.onScale(e);
12551
+ if (pointType === 'skew')
12552
+ editor.onSkew(e);
12475
12553
  updateCursor(editor, e);
12476
12554
  }
12477
12555
  onArrow(e) {
@@ -12653,6 +12731,7 @@ const config = {
12653
12731
  hover: true,
12654
12732
  select: 'press',
12655
12733
  openInner: 'double',
12734
+ multipleSelect: true,
12656
12735
  boxSelect: true,
12657
12736
  moveable: true,
12658
12737
  resizeable: true,
@@ -12679,11 +12758,7 @@ function simulate(editor) {
12679
12758
  function onTarget(editor, oldValue) {
12680
12759
  const { target } = editor;
12681
12760
  if (target) {
12682
- const { list } = editor.leafList = target instanceof LeafList ? target : new LeafList(target instanceof Array ? target : target);
12683
- if (!list.every(checkEditable)) {
12684
- editor.target = list.filter(checkEditable);
12685
- return;
12686
- }
12761
+ editor.leafList = target instanceof LeafList ? target : new LeafList(target);
12687
12762
  if (editor.multiple)
12688
12763
  simulate(editor);
12689
12764
  }
@@ -12710,9 +12785,6 @@ function onTarget(editor, oldValue) {
12710
12785
  function onHover(editor, oldValue) {
12711
12786
  editor.emitEvent(new EditorEvent(EditorEvent.HOVER, { editor, value: editor.hoverTarget, oldValue }));
12712
12787
  }
12713
- function checkEditable(item) {
12714
- return item.editable && !item.locked;
12715
- }
12716
12788
 
12717
12789
  const order = (a, b) => a.parent.children.indexOf(a) - b.parent.children.indexOf(b);
12718
12790
  const reverseOrder = (a, b) => b.parent.children.indexOf(b) - a.parent.children.indexOf(a);
@@ -12744,13 +12816,16 @@ const EditorHelper = {
12744
12816
  const ungroupList = [];
12745
12817
  app.lockLayout();
12746
12818
  list.forEach(leaf => {
12747
- if (leaf.isBranch && !leaf.isBranchLeaf) {
12819
+ if (leaf.isBranch) {
12748
12820
  const { parent, children } = leaf;
12749
12821
  while (children.length) {
12750
12822
  ungroupList.push(children[0]);
12751
12823
  children[0].dropTo(parent, parent.children.indexOf(leaf));
12752
12824
  }
12753
- leaf.remove();
12825
+ if (leaf.isBranchLeaf)
12826
+ ungroupList.push(leaf);
12827
+ else
12828
+ leaf.remove();
12754
12829
  }
12755
12830
  else {
12756
12831
  ungroupList.push(leaf);
@@ -13055,13 +13130,22 @@ class Editor extends Group {
13055
13130
  this.skewOf(origin, skewX, skewY);
13056
13131
  }
13057
13132
  move(x, y = 0) {
13058
- const { element } = this;
13059
13133
  if (!this.checkTransform('moveable'))
13060
13134
  return;
13061
- const world = element.getWorldPointByLocal(typeof x === 'object' ? Object.assign({}, x) : { x, y }, null, true);
13135
+ if (typeof x === 'object')
13136
+ y = x.y, x = x.x;
13137
+ const { element: target } = this, { beforeMove } = this.mergeConfig;
13138
+ if (beforeMove) {
13139
+ const check = beforeMove({ target, x, y });
13140
+ if (typeof check === 'object')
13141
+ x = check.x, y = check.y;
13142
+ else if (check === false)
13143
+ return;
13144
+ }
13145
+ const world = target.getWorldPointByLocal({ x, y }, null, true);
13062
13146
  if (this.multiple)
13063
- element.safeChange(() => element.move(x, y));
13064
- const data = { target: element, editor: this, moveX: world.x, moveY: world.y };
13147
+ target.safeChange(() => target.move(x, y));
13148
+ const data = { target, editor: this, moveX: world.x, moveY: world.y };
13065
13149
  this.emitEvent(new EditorMoveEvent(EditorMoveEvent.BEFORE_MOVE, data));
13066
13150
  const event = new EditorMoveEvent(EditorMoveEvent.MOVE, data);
13067
13151
  this.editTool.onMove(event);
@@ -13070,8 +13154,14 @@ class Editor extends Group {
13070
13154
  scaleWithDrag(data) {
13071
13155
  if (!this.checkTransform('resizeable'))
13072
13156
  return;
13073
- const { element } = this;
13074
- data = Object.assign(Object.assign({}, data), { target: element, editor: this, worldOrigin: element.getWorldPoint(data.origin) });
13157
+ const { element: target } = this, { beforeScale } = this.mergeConfig;
13158
+ if (beforeScale) {
13159
+ const { origin, scaleX, scaleY, drag } = data;
13160
+ const check = beforeScale({ target, drag, origin, scaleX, scaleY });
13161
+ if (check === false)
13162
+ return;
13163
+ }
13164
+ data = Object.assign(Object.assign({}, data), { target, editor: this, worldOrigin: target.getWorldPoint(data.origin) });
13075
13165
  this.emitEvent(new EditorScaleEvent(EditorScaleEvent.BEFORE_SCALE, data));
13076
13166
  const event = new EditorScaleEvent(EditorScaleEvent.SCALE, data);
13077
13167
  this.editTool.onScaleWithDrag(event);
@@ -13080,10 +13170,17 @@ class Editor extends Group {
13080
13170
  scaleOf(origin, scaleX, scaleY = scaleX, _resize) {
13081
13171
  if (!this.checkTransform('resizeable'))
13082
13172
  return;
13083
- const { element } = this;
13173
+ const { element: target } = this, { beforeScale } = this.mergeConfig;
13174
+ if (beforeScale) {
13175
+ const check = beforeScale({ target, origin, scaleX, scaleY });
13176
+ if (typeof check === 'object')
13177
+ scaleX = check.scaleX, scaleY = check.scaleY;
13178
+ else if (check === false)
13179
+ return;
13180
+ }
13084
13181
  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 };
13182
+ const transform = this.multiple && this.getChangedTransform(() => target.safeChange(() => target.scaleOf(origin, scaleX, scaleY)));
13183
+ const data = { target, editor: this, worldOrigin, scaleX, scaleY, transform };
13087
13184
  this.emitEvent(new EditorScaleEvent(EditorScaleEvent.BEFORE_SCALE, data));
13088
13185
  const event = new EditorScaleEvent(EditorScaleEvent.SCALE, data);
13089
13186
  this.editTool.onScale(event);
@@ -13104,10 +13201,17 @@ class Editor extends Group {
13104
13201
  rotateOf(origin, rotation) {
13105
13202
  if (!this.checkTransform('rotateable'))
13106
13203
  return;
13107
- const { element } = this;
13204
+ const { element: target } = this, { beforeRotate } = this.mergeConfig;
13205
+ if (beforeRotate) {
13206
+ const check = beforeRotate({ target, origin, rotation });
13207
+ if (typeof check === 'number')
13208
+ rotation = check;
13209
+ else if (check === false)
13210
+ return;
13211
+ }
13108
13212
  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 };
13213
+ const transform = this.multiple && this.getChangedTransform(() => target.safeChange(() => target.rotateOf(origin, rotation)));
13214
+ const data = { target, editor: this, worldOrigin, rotation, transform };
13111
13215
  this.emitEvent(new EditorRotateEvent(EditorRotateEvent.BEFORE_ROTATE, data));
13112
13216
  const event = new EditorRotateEvent(EditorRotateEvent.ROTATE, data);
13113
13217
  this.editTool.onRotate(event);
@@ -13116,10 +13220,17 @@ class Editor extends Group {
13116
13220
  skewOf(origin, skewX, skewY = 0, _resize) {
13117
13221
  if (!this.checkTransform('skewable'))
13118
13222
  return;
13119
- const { element } = this;
13223
+ const { element: target } = this, { beforeSkew } = this.mergeConfig;
13224
+ if (beforeSkew) {
13225
+ const check = beforeSkew({ target, origin, skewX, skewY });
13226
+ if (typeof check === 'object')
13227
+ skewX = check.skewX, skewY = check.skewY;
13228
+ else if (check === false)
13229
+ return;
13230
+ }
13120
13231
  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 };
13232
+ const transform = this.multiple && this.getChangedTransform(() => target.safeChange(() => target.skewOf(origin, skewX, skewY)));
13233
+ const data = { target, editor: this, worldOrigin, skewX, skewY, transform };
13123
13234
  this.emitEvent(new EditorSkewEvent(EditorSkewEvent.BEFORE_SKEW, data));
13124
13235
  const event = new EditorSkewEvent(EditorSkewEvent.SKEW, data);
13125
13236
  this.editTool.onSkew(event);
@@ -13632,7 +13743,9 @@ function scaleResizeFontSize(leaf, scaleX, scaleY, direction) {
13632
13743
  }
13633
13744
  }
13634
13745
  leaf.fontSize *= fontScale;
13635
- const data = leaf.__;
13746
+ const data = leaf.__, { padding } = data;
13747
+ if (padding)
13748
+ leaf.padding = padding instanceof Array ? padding.map(item => item * fontScale) : padding * fontScale;
13636
13749
  if (!data.__autoWidth)
13637
13750
  leaf.width *= fontScale;
13638
13751
  if (!data.__autoHeight)
@@ -13720,14 +13833,11 @@ Group.prototype.__scaleResize = function (scaleX, scaleY) {
13720
13833
  scaleResizeGroup(this, scaleX, scaleY);
13721
13834
  };
13722
13835
  Box.prototype.__scaleResize = function (scaleX, scaleY) {
13723
- if (this.__.__autoSize && this.children.length) {
13724
- scaleResizeGroup(this, scaleX, scaleY);
13725
- }
13726
- else {
13836
+ const { resizeChildren, __autoSize } = this.__;
13837
+ if (!(__autoSize && resizeChildren))
13727
13838
  scaleResize(this, scaleX, scaleY);
13728
- if (this.__.resizeChildren)
13729
- scaleResizeGroup(this, scaleX, scaleY);
13730
- }
13839
+ if (resizeChildren)
13840
+ scaleResizeGroup(this, scaleX, scaleY);
13731
13841
  };
13732
13842
 
13733
13843
  Plugin.add('resize');
@@ -14927,6 +15037,12 @@ const verticalAlignMap = {
14927
15037
  'middle': 'center',
14928
15038
  'bottom': 'flex-end'
14929
15039
  };
15040
+ const textDecorationMap = {
15041
+ 'none': 'none',
15042
+ 'under': 'underline',
15043
+ 'delete': 'line-through',
15044
+ 'under-delete': 'underline line-through'
15045
+ };
14930
15046
  function updateStyle(textDom, text, textScale) {
14931
15047
  const { style } = textDom;
14932
15048
  const { fill, padding, textWrap, textOverflow, textDecoration } = text;
@@ -14935,7 +15051,16 @@ function updateStyle(textDom, text, textScale) {
14935
15051
  setFill(style, fill);
14936
15052
  style.fontStyle = text.italic ? 'italic' : 'normal';
14937
15053
  style.fontWeight = text.fontWeight;
14938
- style.textDecoration = textDecoration === 'delete' ? 'line-through' : textDecoration;
15054
+ let decorationType;
15055
+ if (typeof textDecoration === 'object') {
15056
+ decorationType = textDecoration.type;
15057
+ if (textDecoration.color)
15058
+ style.textDecorationColor = ColorConvert.string(textDecoration.color);
15059
+ }
15060
+ else {
15061
+ decorationType = textDecoration;
15062
+ }
15063
+ style.textDecoration = textDecorationMap[decorationType];
14939
15064
  style.textTransform = textCaseMap[text.textCase];
14940
15065
  style.textAlign = text.textAlign === 'both' ? 'justify' : text.textAlign;
14941
15066
  style.display = 'flex';
@@ -15192,5 +15317,5 @@ HTMLText = __decorate([
15192
15317
 
15193
15318
  Plugin.add('html');
15194
15319
 
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 };
15320
+ 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
15321
  //# sourceMappingURL=worker.module.js.map