@leafer/miniapp 1.9.2 → 1.9.4

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.
@@ -54,7 +54,7 @@ function isUndefined(value) {
54
54
  }
55
55
 
56
56
  function isNull(value) {
57
- return value === undefined || value === null;
57
+ return value == null;
58
58
  }
59
59
 
60
60
  function isString(value) {
@@ -304,6 +304,9 @@ const MathHelper = {
304
304
  num = round$6(num * a) / a;
305
305
  return num === -0 ? 0 : num;
306
306
  },
307
+ sign(num) {
308
+ return num < 0 ? -1 : 1;
309
+ },
307
310
  getScaleData(scale, size, originSize, scaleData) {
308
311
  if (!scaleData) scaleData = {};
309
312
  if (size) {
@@ -659,7 +662,7 @@ const M$a = MatrixHelper;
659
662
 
660
663
  const {toInnerPoint: toInnerPoint$2, toOuterPoint: toOuterPoint$3} = MatrixHelper;
661
664
 
662
- const {sin: sin$5, cos: cos$5, abs: abs$6, sqrt: sqrt$4, atan2: atan2$2, min: min$1, round: round$5} = Math;
665
+ const {sin: sin$5, cos: cos$5, abs: abs$7, sqrt: sqrt$4, atan2: atan2$2, min: min$1, round: round$5} = Math;
663
666
 
664
667
  const PointHelper = {
665
668
  defaultPoint: getPointData(),
@@ -752,8 +755,8 @@ const PointHelper = {
752
755
  return getDistanceFrom(t.x, t.y, point.x, point.y);
753
756
  },
754
757
  getDistanceFrom(x1, y1, x2, y2) {
755
- const x = abs$6(x2 - x1);
756
- const y = abs$6(y2 - y1);
758
+ const x = abs$7(x2 - x1);
759
+ const y = abs$7(y2 - y1);
757
760
  return sqrt$4(x * x + y * y);
758
761
  },
759
762
  getMinDistanceFrom(x1, y1, x2, y2, x3, y3) {
@@ -1191,10 +1194,8 @@ const BoundsHelper = {
1191
1194
  t.y += y;
1192
1195
  },
1193
1196
  scroll(t, data) {
1194
- if (data.scrollY || data.scrollX) {
1195
- t.x += data.scrollX;
1196
- t.y += data.scrollY;
1197
- }
1197
+ t.x += data.scrollX;
1198
+ t.y += data.scrollY;
1198
1199
  },
1199
1200
  getByMove(t, x, y) {
1200
1201
  t = Object.assign({}, t);
@@ -2542,7 +2543,7 @@ const RectHelper = {
2542
2543
  }
2543
2544
  };
2544
2545
 
2545
- const {sin: sin$4, cos: cos$4, atan2: atan2$1, ceil: ceil$1, abs: abs$5, PI: PI$3, sqrt: sqrt$3, pow: pow$1} = Math;
2546
+ const {sin: sin$4, cos: cos$4, atan2: atan2$1, ceil: ceil$1, abs: abs$6, PI: PI$3, sqrt: sqrt$3, pow: pow$1} = Math;
2546
2547
 
2547
2548
  const {setPoint: setPoint$4, addPoint: addPoint$2} = TwoPointBoundsHelper;
2548
2549
 
@@ -2615,7 +2616,7 @@ const BezierHelper = {
2615
2616
  let endRadian = atan2$1(CBy, CBx);
2616
2617
  let totalRadian = endRadian - startRadian;
2617
2618
  if (totalRadian < 0) totalRadian += PI2;
2618
- if (totalRadian === PI$3 || abs$5(BAx + BAy) < 1e-12 || abs$5(CBx + CBy) < 1e-12) {
2619
+ if (totalRadian === PI$3 || abs$6(BAx + BAy) < 1e-12 || abs$6(CBx + CBy) < 1e-12) {
2619
2620
  if (data) data.push(L$a, x1, y1);
2620
2621
  if (setPointBounds) {
2621
2622
  setPoint$4(setPointBounds, fromX, fromY);
@@ -2648,7 +2649,7 @@ const BezierHelper = {
2648
2649
  let totalRadian = endRadian - startRadian;
2649
2650
  if (totalRadian < 0) totalRadian += PI2; else if (totalRadian > PI2) totalRadian -= PI2;
2650
2651
  if (anticlockwise) totalRadian -= PI2;
2651
- const parts = ceil$1(abs$5(totalRadian / PI_2));
2652
+ const parts = ceil$1(abs$6(totalRadian / PI_2));
2652
2653
  const partRadian = totalRadian / parts;
2653
2654
  const partRadian4Sin = sin$4(partRadian / 4);
2654
2655
  const control = 8 / 3 * partRadian4Sin * partRadian4Sin / sin$4(partRadian / 2);
@@ -3115,7 +3116,7 @@ const {M: M$7, L: L$8, C: C$6, Q: Q$5, Z: Z$6, N: N$4, D: D$5, X: X$4, G: G$4, F
3115
3116
 
3116
3117
  const {getMinDistanceFrom: getMinDistanceFrom, getRadianFrom: getRadianFrom} = PointHelper;
3117
3118
 
3118
- const {tan: tan, min: min, abs: abs$4} = Math;
3119
+ const {tan: tan, min: min, abs: abs$5} = Math;
3119
3120
 
3120
3121
  const startPoint = {};
3121
3122
 
@@ -3173,7 +3174,7 @@ const PathCommandDataHelper = {
3173
3174
  arcTo(data, x1, y1, x2, y2, radius, lastX, lastY) {
3174
3175
  if (!isUndefined(lastX)) {
3175
3176
  const d = getMinDistanceFrom(lastX, lastY, x1, y1, x2, y2);
3176
- radius = min(radius, min(d / 2, d / 2 * abs$4(tan(getRadianFrom(lastX, lastY, x1, y1, x2, y2) / 2))));
3177
+ radius = min(radius, min(d / 2, d / 2 * abs$5(tan(getRadianFrom(lastX, lastY, x1, y1, x2, y2) / 2))));
3177
3178
  }
3178
3179
  data.push(U$4, x1, y1, x2, y2, radius);
3179
3180
  },
@@ -3971,7 +3972,7 @@ const I$1 = ImageManager;
3971
3972
 
3972
3973
  const {IMAGE: IMAGE, create: create$1} = IncrementId;
3973
3974
 
3974
- const {floor: floor$2, max: max$1} = Math;
3975
+ const {floor: floor$2, max: max$2} = Math;
3975
3976
 
3976
3977
  class LeaferImage {
3977
3978
  get url() {
@@ -4060,7 +4061,7 @@ class LeaferImage {
4060
4061
  }
4061
4062
  if (data) return data;
4062
4063
  }
4063
- const canvas = Platform.origin.createCanvas(max$1(floor$2(width + (xGap || 0)), 1), max$1(floor$2(height + (yGap || 0)), 1));
4064
+ const canvas = Platform.origin.createCanvas(max$2(floor$2(width + (xGap || 0)), 1), max$2(floor$2(height + (yGap || 0)), 1));
4064
4065
  const ctx = canvas.getContext("2d");
4065
4066
  if (opacity) ctx.globalAlpha = opacity;
4066
4067
  ctx.drawImage(this.view, 0, 0, width, height);
@@ -4104,7 +4105,7 @@ function createDescriptor(key, defaultValue) {
4104
4105
  return {
4105
4106
  get() {
4106
4107
  const v = this[privateKey];
4107
- return isUndefined(v) ? defaultValue : v;
4108
+ return v == null ? defaultValue : v;
4108
4109
  },
4109
4110
  set(value) {
4110
4111
  this[privateKey] = value;
@@ -4390,21 +4391,21 @@ function defineDataProcessor(target, key, defaultValue) {
4390
4391
  };
4391
4392
  } else if (typeof defaultValue === "function") {
4392
4393
  property.get = function() {
4393
- let v = this[computedKey];
4394
- return v === undefined ? defaultValue(this.__leaf) : v;
4394
+ const v = this[computedKey];
4395
+ return v == null ? defaultValue(this.__leaf) : v;
4395
4396
  };
4396
4397
  } else if (isObject(defaultValue)) {
4397
4398
  const isEmpty = isEmptyData(defaultValue);
4398
4399
  property.get = function() {
4399
- let v = this[computedKey];
4400
- return v === undefined ? this[computedKey] = isEmpty ? {} : DataHelper.clone(defaultValue) : v;
4400
+ const v = this[computedKey];
4401
+ return v == null ? this[computedKey] = isEmpty ? {} : DataHelper.clone(defaultValue) : v;
4401
4402
  };
4402
4403
  }
4403
4404
  const isBox = target.isBranchLeaf;
4404
4405
  if (key === "width") {
4405
4406
  property.get = function() {
4406
4407
  const v = this[computedKey];
4407
- if (v === undefined) {
4408
+ if (v == null) {
4408
4409
  const t = this, naturalWidth = t.__naturalWidth, leaf = t.__leaf;
4409
4410
  if (!defaultValue || leaf.pathInputed) return leaf.boxBounds.width;
4410
4411
  if (naturalWidth) return t._height && t.__useNaturalRatio ? t._height * naturalWidth / t.__naturalHeight : naturalWidth;
@@ -4414,7 +4415,7 @@ function defineDataProcessor(target, key, defaultValue) {
4414
4415
  } else if (key === "height") {
4415
4416
  property.get = function() {
4416
4417
  const v = this[computedKey];
4417
- if (v === undefined) {
4418
+ if (v == null) {
4418
4419
  const t = this, naturalHeight = t.__naturalHeight, leaf = t.__leaf;
4419
4420
  if (!defaultValue || leaf.pathInputed) return leaf.boxBounds.height;
4420
4421
  if (naturalHeight) return t._width && t.__useNaturalRatio ? t._width * naturalHeight / t.__naturalWidth : naturalHeight;
@@ -5174,7 +5175,7 @@ class LeafLayout {
5174
5175
  }
5175
5176
  boxChange() {
5176
5177
  this.boxChanged = true;
5177
- this.localBoxChanged || this.localBoxChange();
5178
+ this.localBoxChanged ? this.boundsChanged || (this.boundsChanged = true) : this.localBoxChange();
5178
5179
  this.hitCanvasChanged = true;
5179
5180
  }
5180
5181
  localBoxChange() {
@@ -5208,7 +5209,7 @@ class LeafLayout {
5208
5209
  }
5209
5210
  matrixChange() {
5210
5211
  this.matrixChanged = true;
5211
- this.localBoxChanged || this.localBoxChange();
5212
+ this.localBoxChanged ? this.boundsChanged || (this.boundsChanged = true) : this.localBoxChange();
5212
5213
  }
5213
5214
  surfaceChange() {
5214
5215
  this.surfaceChanged = true;
@@ -6274,10 +6275,10 @@ let Leaf = class Leaf {
6274
6275
  relative.innerToWorld(world, to, distance);
6275
6276
  world = to ? to : world;
6276
6277
  }
6277
- toInnerPoint(this.worldTransform, world, to, distance);
6278
+ toInnerPoint(this.scrollWorldTransform, world, to, distance);
6278
6279
  }
6279
6280
  innerToWorld(inner, to, distance, relative) {
6280
- toOuterPoint(this.worldTransform, inner, to, distance);
6281
+ toOuterPoint(this.scrollWorldTransform, inner, to, distance);
6281
6282
  if (relative) relative.worldToInner(to ? to : inner, null, distance);
6282
6283
  }
6283
6284
  getBoxPoint(world, relative, distance, change) {
@@ -6741,7 +6742,7 @@ class LeafLevelList {
6741
6742
  }
6742
6743
  }
6743
6744
 
6744
- const version = "1.9.2";
6745
+ const version = "1.9.4";
6745
6746
 
6746
6747
  class LeaferCanvas extends LeaferCanvasBase {
6747
6748
  get allowBackgroundColor() {
@@ -9091,26 +9092,24 @@ let Box = class Box extends Group {
9091
9092
  }
9092
9093
  __updateStrokeBounds() {}
9093
9094
  __updateRenderBounds() {
9094
- let isOverflow;
9095
+ let isOverflow, isScrollMode;
9095
9096
  if (this.children.length) {
9096
- const data = this.__, layout = this.__layout, {renderBounds: renderBounds, boxBounds: boxBounds} = layout;
9097
+ const data = this.__, layout = this.__layout, {renderBounds: renderBounds, boxBounds: boxBounds} = layout, {overflow: overflow} = data;
9097
9098
  const childrenRenderBounds = layout.childrenRenderBounds || (layout.childrenRenderBounds = getBoundsData());
9098
9099
  super.__updateRenderBounds(childrenRenderBounds);
9099
- scroll(childrenRenderBounds, data);
9100
+ if (isScrollMode = overflow.includes("scroll")) {
9101
+ add(childrenRenderBounds, boxBounds);
9102
+ scroll(childrenRenderBounds, data);
9103
+ }
9100
9104
  this.__updateRectRenderBounds();
9101
9105
  isOverflow = !includes$1(boxBounds, childrenRenderBounds);
9102
- if (isOverflow && data.overflow === "show") add(renderBounds, childrenRenderBounds);
9106
+ if (isOverflow && overflow === "show") add(renderBounds, childrenRenderBounds);
9103
9107
  } else this.__updateRectRenderBounds();
9104
9108
  DataHelper.stintSet(this, "isOverflow", isOverflow);
9105
- this.__checkScroll();
9109
+ this.__checkScroll(isScrollMode);
9106
9110
  }
9107
9111
  __updateRectRenderBounds() {}
9108
- __updateWorldBounds() {
9109
- if (this.hasScroller) this.__updateScroll();
9110
- super.__updateWorldBounds();
9111
- }
9112
- __checkScroll() {}
9113
- __updateScroll() {}
9112
+ __checkScroll(_isScrollMode) {}
9114
9113
  __updateRectChange() {}
9115
9114
  __updateChange() {
9116
9115
  super.__updateChange();
@@ -11834,7 +11833,7 @@ function ignoreRender(ui, value) {
11834
11833
 
11835
11834
  const {get: get$1, scale: scale$2, copy: copy$4} = MatrixHelper;
11836
11835
 
11837
- const {floor: floor$1, max: max, abs: abs$3} = Math;
11836
+ const {floor: floor$1, max: max$1, abs: abs$4} = Math;
11838
11837
 
11839
11838
  function createPattern(ui, paint, pixelRatio) {
11840
11839
  let {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true, paint.scaleFixed);
@@ -11847,8 +11846,8 @@ function createPattern(ui, paint, pixelRatio) {
11847
11846
  const xGap = gap && gap.x * scaleX;
11848
11847
  const yGap = gap && gap.y * scaleY;
11849
11848
  if (sx) {
11850
- sx = abs$3(sx);
11851
- sy = abs$3(sy);
11849
+ sx = abs$4(sx);
11850
+ sy = abs$4(sy);
11852
11851
  imageMatrix = get$1();
11853
11852
  copy$4(imageMatrix, transform);
11854
11853
  scale$2(imageMatrix, 1 / sx, 1 / sy);
@@ -11886,7 +11885,7 @@ function createPattern(ui, paint, pixelRatio) {
11886
11885
  }
11887
11886
  if (imageMatrix) {
11888
11887
  const canvasWidth = width + (xGap || 0), canvasHeight = height + (yGap || 0);
11889
- scale$2(imageMatrix, canvasWidth / max(floor$1(canvasWidth), 1), canvasHeight / max(floor$1(canvasHeight), 1));
11888
+ scale$2(imageMatrix, canvasWidth / max$1(floor$1(canvasWidth), 1), canvasHeight / max$1(floor$1(canvasHeight), 1));
11890
11889
  }
11891
11890
  const canvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap);
11892
11891
  const pattern = image.getPattern(canvas, repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
@@ -12916,7 +12915,7 @@ function mergeConfigAttr() {
12916
12915
  return (target, key) => {
12917
12916
  defineKey(target, key, {
12918
12917
  get() {
12919
- const {config: config, element: element, dragPoint: dragPoint, editBox: editBox} = this, mergeConfig = Object.assign({}, config);
12918
+ const {config: config, element: element, dragPoint: dragPoint, editBox: editBox, app: app} = this, mergeConfig = Object.assign({}, config);
12920
12919
  if (element && element.editConfig) Object.assign(mergeConfig, element.editConfig);
12921
12920
  if (editBox.config) Object.assign(mergeConfig, editBox.config);
12922
12921
  if (dragPoint) {
@@ -12927,13 +12926,14 @@ function mergeConfigAttr() {
12927
12926
  isNull(mergeConfig.lockRatio) && (mergeConfig.lockRatio = true);
12928
12927
  }
12929
12928
  }
12929
+ if (isUndefined(mergeConfig.dragLimitAnimate)) mergeConfig.dragLimitAnimate = app && app.config.pointer.dragLimitAnimate;
12930
12930
  return this.mergedConfig = mergeConfig;
12931
12931
  }
12932
12932
  });
12933
12933
  };
12934
12934
  }
12935
12935
 
12936
- const {abs: abs$2} = Math;
12936
+ const {abs: abs$3} = Math;
12937
12937
 
12938
12938
  const {copy: copy$2, scale: scale$1} = MatrixHelper;
12939
12939
 
@@ -12976,7 +12976,7 @@ class Stroker extends UI {
12976
12976
  leaf = list[i];
12977
12977
  const {worldTransform: worldTransform, worldRenderBounds: worldRenderBounds} = leaf;
12978
12978
  if (worldRenderBounds.width && worldRenderBounds.height && (!bounds || bounds.hit(worldRenderBounds, options.matrix))) {
12979
- const aScaleX = abs$2(worldTransform.scaleX), aScaleY = abs$2(worldTransform.scaleY);
12979
+ const aScaleX = abs$3(worldTransform.scaleX), aScaleY = abs$3(worldTransform.scaleY);
12980
12980
  copy$2(matrix$1, worldTransform);
12981
12981
  matrix$1.half = strokeWidth % 2;
12982
12982
  if (aScaleX !== aScaleY) {
@@ -12990,7 +12990,7 @@ class Stroker extends UI {
12990
12990
  canvas.setWorld(matrix$1, options.matrix);
12991
12991
  canvas.beginPath();
12992
12992
  if (leaf.__.__useArrow) leaf.__drawPath(canvas); else leaf.__.__pathForRender ? leaf.__drawRenderPath(canvas) : leaf.__drawPathByBox(canvas);
12993
- data.strokeWidth = strokeWidth / abs$2(worldTransform.scaleX);
12993
+ data.strokeWidth = strokeWidth / abs$3(worldTransform.scaleX);
12994
12994
  }
12995
12995
  if (stroke) isString(stroke) ? Paint.stroke(stroke, this, canvas) : Paint.strokes(stroke, this, canvas);
12996
12996
  if (fill) isString(fill) ? Paint.fill(fill, this, canvas) : Paint.fills(fill, this, canvas);
@@ -13284,7 +13284,7 @@ const {topLeft: topLeft$1, top: top$1, topRight: topRight$1, right: right$2, bot
13284
13284
 
13285
13285
  const {toPoint: toPoint} = AroundHelper;
13286
13286
 
13287
- const {within: within$2} = MathHelper;
13287
+ const {within: within$3, sign: sign$1} = MathHelper;
13288
13288
 
13289
13289
  const EditDataHelper = {
13290
13290
  getScaleData(target, startBounds, direction, totalMove, lockRatio, around, flipable, scaleMode) {
@@ -13297,8 +13297,8 @@ const EditDataHelper = {
13297
13297
  }
13298
13298
  const originChangedScaleX = target.scaleX / startBounds.scaleX;
13299
13299
  const originChangedScaleY = target.scaleY / startBounds.scaleY;
13300
- const signX = originChangedScaleX < 0 ? -1 : 1;
13301
- const signY = originChangedScaleY < 0 ? -1 : 1;
13300
+ const signX = sign$1(originChangedScaleX);
13301
+ const signY = sign$1(originChangedScaleY);
13302
13302
  const changedScaleX = scaleMode ? originChangedScaleX : signX * boxBounds.width / width;
13303
13303
  const changedScaleY = scaleMode ? originChangedScaleY : signY * boxBounds.height / height;
13304
13304
  totalMove.x *= scaleMode ? originChangedScaleX : signX;
@@ -13398,14 +13398,14 @@ const EditDataHelper = {
13398
13398
  }
13399
13399
  if (useScaleX && widthRange) {
13400
13400
  const nowWidth = boxBounds.width * target.scaleX;
13401
- scaleX = within$2(nowWidth * scaleX, widthRange) / nowWidth;
13401
+ scaleX = within$3(nowWidth * scaleX, widthRange) / nowWidth;
13402
13402
  }
13403
13403
  if (useScaleY && heightRange) {
13404
13404
  const nowHeight = boxBounds.height * target.scaleY;
13405
- scaleY = within$2(nowHeight * scaleY, heightRange) / nowHeight;
13405
+ scaleY = within$3(nowHeight * scaleY, heightRange) / nowHeight;
13406
13406
  }
13407
- if (useScaleX && Math.abs(scaleX * worldBoxBounds.width) < 1) scaleX = (scaleX < 0 ? -1 : 1) / worldBoxBounds.width;
13408
- if (useScaleY && Math.abs(scaleY * worldBoxBounds.height) < 1) scaleY = (scaleY < 0 ? -1 : 1) / worldBoxBounds.height;
13407
+ if (useScaleX && Math.abs(scaleX * worldBoxBounds.width) < 1) scaleX = sign$1(scaleX) / worldBoxBounds.width;
13408
+ if (useScaleY && Math.abs(scaleY * worldBoxBounds.height) < 1) scaleY = sign$1(scaleY) / worldBoxBounds.height;
13409
13409
  if (lockRatio && scaleX !== scaleY) scaleY = scaleX = Math.min(scaleX, scaleY);
13410
13410
  return {
13411
13411
  origin: origin,
@@ -13907,7 +13907,7 @@ class EditBox extends Group {
13907
13907
  if (pointType && pointType.includes("resize")) ResizeEvent.resizingKeys = editor.leafList.keys;
13908
13908
  }
13909
13909
  onDragEnd(e) {
13910
- if (this.moving) this.transformTool.onMove(e);
13910
+ if (this.moving && this.mergeConfig.dragLimitAnimate && this.target.dragBounds) this.transformTool.onMove(e);
13911
13911
  this.dragPoint = null;
13912
13912
  this.resetDoing();
13913
13913
  const {name: name, pointType: pointType} = e.current;
@@ -14427,9 +14427,8 @@ EditorSkewEvent.SKEW = "editor.skew";
14427
14427
 
14428
14428
  class TransformTool {
14429
14429
  onMove(e) {
14430
- const {target: target, mergeConfig: mergeConfig, dragStartData: dragStartData, app: app} = this.editBox;
14430
+ const {target: target, mergeConfig: mergeConfig, dragStartData: dragStartData} = this.editBox;
14431
14431
  let move, {dragLimitAnimate: dragLimitAnimate} = mergeConfig;
14432
- if (isUndefined(dragLimitAnimate)) dragLimitAnimate = app && app.config.pointer.dragLimitAnimate;
14433
14432
  const isMoveEnd = e.type === MoveEvent.END || e.type === DragEvent.END;
14434
14433
  const axisDrag = isString(target.draggable);
14435
14434
  const checkLimitMove = !dragLimitAnimate || isMoveEnd || axisDrag;
@@ -14776,11 +14775,22 @@ let Editor = class Editor extends Group {
14776
14775
  updateEditTool() {
14777
14776
  this.unloadEditTool();
14778
14777
  if (this.editing) {
14779
- const name = this.element.editOuter || "EditTool";
14780
- const tool = this.editTool = this.editToolList[name] = this.editToolList[name] || EditToolCreator.get(name, this);
14781
- this.editBox.load();
14782
- tool.load();
14783
- this.update();
14778
+ const target = this.element;
14779
+ let name = target.editOuter || "EditTool";
14780
+ const {beforeEditOuter: beforeEditOuter} = this.mergeConfig;
14781
+ if (beforeEditOuter) {
14782
+ const check = beforeEditOuter({
14783
+ target: target,
14784
+ name: name
14785
+ });
14786
+ if (isString(check)) name = check; else if (check === false) return;
14787
+ }
14788
+ if (EditToolCreator.list[name]) {
14789
+ const tool = this.editTool = this.editToolList[name] = this.editToolList[name] || EditToolCreator.get(name, this);
14790
+ this.editBox.load();
14791
+ tool.load();
14792
+ this.update();
14793
+ }
14784
14794
  }
14785
14795
  }
14786
14796
  unloadEditTool() {
@@ -14873,13 +14883,21 @@ let Editor = class Editor extends Group {
14873
14883
  if (isString(nameOrSelect)) name = nameOrSelect; else if (!select) select = nameOrSelect;
14874
14884
  if (target && select) this.target = target;
14875
14885
  if (this.single) {
14876
- const editTarget = target || this.element;
14877
- name || (name = editTarget.editInner);
14878
- if (name && EditToolCreator.list[name]) {
14886
+ if (!target) target = this.element;
14887
+ if (!name) name = target.editInner;
14888
+ const {beforeEditInner: beforeEditInner} = this.mergeConfig;
14889
+ if (beforeEditInner) {
14890
+ const check = beforeEditInner({
14891
+ target: target,
14892
+ name: name
14893
+ });
14894
+ if (isString(check)) name = check; else if (check === false) return;
14895
+ }
14896
+ if (EditToolCreator.list[name]) {
14879
14897
  this.editTool.unload();
14880
14898
  this.innerEditing = true;
14881
14899
  this.innerEditor = this.editToolList[name] = this.editToolList[name] || EditToolCreator.get(name, this);
14882
- this.innerEditor.editTarget = editTarget;
14900
+ this.innerEditor.editTarget = target;
14883
14901
  this.emitInnerEvent(InnerEditorEvent.BEFORE_OPEN);
14884
14902
  this.innerEditor.load();
14885
14903
  this.emitInnerEvent(InnerEditorEvent.OPEN);
@@ -15564,6 +15582,8 @@ const MultiTouchHelper = {
15564
15582
  }
15565
15583
  };
15566
15584
 
15585
+ const {abs: abs$2, max: max} = Math, {sign: sign, within: within$2} = MathHelper;
15586
+
15567
15587
  const WheelEventHelper = {
15568
15588
  getMove(event, config) {
15569
15589
  let {moveSpeed: moveSpeed} = config;
@@ -15572,8 +15592,9 @@ const WheelEventHelper = {
15572
15592
  deltaX = deltaY;
15573
15593
  deltaY = 0;
15574
15594
  }
15575
- if (deltaX > 50) deltaX = Math.max(50, deltaX / 3);
15576
- if (deltaY > 50) deltaY = Math.max(50, deltaY / 3);
15595
+ const absX = abs$2(deltaX), absY = abs$2(deltaY);
15596
+ if (absX > 50) deltaX = max(50, absX / 3) * sign(deltaX);
15597
+ if (absY > 50) deltaY = max(50, absY / 3) * sign(deltaY);
15577
15598
  return {
15578
15599
  x: -deltaX * moveSpeed * 2,
15579
15600
  y: -deltaY * moveSpeed * 2
@@ -15591,11 +15612,9 @@ const WheelEventHelper = {
15591
15612
  zoom = !event.shiftKey && (event.metaKey || event.ctrlKey);
15592
15613
  }
15593
15614
  if (zoom) {
15594
- zoomSpeed = MathHelper.within(zoomSpeed, 0, 1);
15615
+ zoomSpeed = within$2(zoomSpeed, 0, 1);
15595
15616
  const min = event.deltaY ? config.delta.y : config.delta.x;
15596
- scale = 1 - delta / (min * 4) * zoomSpeed;
15597
- if (scale < .5) scale = .5;
15598
- if (scale >= 1.5) scale = 1.5;
15617
+ scale = within$2(1 - delta / (min * 4) * zoomSpeed, .5, 1.5);
15599
15618
  }
15600
15619
  return scale;
15601
15620
  }