@leafer-editor/worker 1.0.4 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/worker.js CHANGED
@@ -4059,7 +4059,7 @@ var LeaferUI = (function (exports) {
4059
4059
  updateAllMatrix(leaf, checkAutoLayout, waitAutoLayout) {
4060
4060
  if (checkAutoLayout && leaf.__hasAutoLayout && leaf.__layout.matrixChanged)
4061
4061
  waitAutoLayout = true;
4062
- updateMatrix$2(leaf, checkAutoLayout, waitAutoLayout);
4062
+ updateMatrix$3(leaf, checkAutoLayout, waitAutoLayout);
4063
4063
  if (leaf.isBranch) {
4064
4064
  const { children } = leaf;
4065
4065
  for (let i = 0, len = children.length; i < len; i++) {
@@ -4229,7 +4229,7 @@ var LeaferUI = (function (exports) {
4229
4229
  }
4230
4230
  };
4231
4231
  const L$3 = LeafHelper;
4232
- const { updateAllMatrix: updateAllMatrix$3, updateMatrix: updateMatrix$2, updateAllWorldOpacity: updateAllWorldOpacity$1, updateAllChange: updateAllChange$1 } = L$3;
4232
+ const { updateAllMatrix: updateAllMatrix$3, updateMatrix: updateMatrix$3, updateAllWorldOpacity: updateAllWorldOpacity$1, updateAllChange: updateAllChange$1 } = L$3;
4233
4233
  function moveByMatrix(t, matrix) {
4234
4234
  const { e, f } = t.__localMatrix;
4235
4235
  t.x += matrix.e - e;
@@ -4758,6 +4758,7 @@ var LeaferUI = (function (exports) {
4758
4758
  }
4759
4759
  }
4760
4760
  RenderEvent.REQUEST = 'render.request';
4761
+ RenderEvent.CHILD_START = 'render.child_start';
4761
4762
  RenderEvent.START = 'render.start';
4762
4763
  RenderEvent.BEFORE = 'render.before';
4763
4764
  RenderEvent.RENDER = 'render';
@@ -4933,7 +4934,7 @@ var LeaferUI = (function (exports) {
4933
4934
  const debug$8 = Debug.get('setAttr');
4934
4935
  const LeafDataProxy = {
4935
4936
  __setAttr(name, newValue, checkFiniteNumber) {
4936
- if (this.leafer && this.leafer.created) {
4937
+ if (this.leaferIsCreated) {
4937
4938
  const oldValue = this.__.__getInput(name);
4938
4939
  if (checkFiniteNumber && !isFinite(newValue) && newValue !== undefined) {
4939
4940
  debug$8.warn(this.innerName, name, newValue);
@@ -5003,9 +5004,9 @@ var LeaferUI = (function (exports) {
5003
5004
  }
5004
5005
  };
5005
5006
 
5006
- const { updateMatrix: updateMatrix$1, updateAllMatrix: updateAllMatrix$2 } = LeafHelper;
5007
+ const { updateMatrix: updateMatrix$2, updateAllMatrix: updateAllMatrix$2 } = LeafHelper;
5007
5008
  const { updateBounds: updateBounds$1 } = BranchHelper;
5008
- const { toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$2, copy: copy$8 } = BoundsHelper;
5009
+ const { toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$1, copy: copy$8 } = BoundsHelper;
5009
5010
  const { toBounds: toBounds$2 } = PathBounds;
5010
5011
  const LeafBounds = {
5011
5012
  __updateWorldBounds() {
@@ -5088,7 +5089,7 @@ var LeaferUI = (function (exports) {
5088
5089
  const b = this.__layout.boxBounds;
5089
5090
  const data = this.__;
5090
5091
  if (data.__pathInputed) {
5091
- toBounds$2(data.__pathForRender, b);
5092
+ toBounds$2(data.path, b);
5092
5093
  }
5093
5094
  else {
5094
5095
  b.x = 0;
@@ -5100,7 +5101,7 @@ var LeaferUI = (function (exports) {
5100
5101
  __updateAutoLayout() {
5101
5102
  this.__layout.matrixChanged = true;
5102
5103
  if (this.isBranch) {
5103
- if (this.leafer && this.leafer.ready)
5104
+ if (this.leaferIsReady)
5104
5105
  this.leafer.layouter.addExtra(this);
5105
5106
  if (this.__.flow) {
5106
5107
  if (this.__layout.boxChanged)
@@ -5116,7 +5117,7 @@ var LeaferUI = (function (exports) {
5116
5117
  }
5117
5118
  }
5118
5119
  else {
5119
- updateMatrix$1(this);
5120
+ updateMatrix$2(this);
5120
5121
  }
5121
5122
  },
5122
5123
  __updateNaturalSize() {
@@ -5126,11 +5127,11 @@ var LeaferUI = (function (exports) {
5126
5127
  },
5127
5128
  __updateStrokeBounds() {
5128
5129
  const layout = this.__layout;
5129
- copyAndSpread$2(layout.strokeBounds, layout.boxBounds, layout.strokeBoxSpread);
5130
+ copyAndSpread$1(layout.strokeBounds, layout.boxBounds, layout.strokeBoxSpread);
5130
5131
  },
5131
5132
  __updateRenderBounds() {
5132
5133
  const layout = this.__layout;
5133
- layout.renderSpread > 0 ? copyAndSpread$2(layout.renderBounds, layout.boxBounds, layout.renderSpread) : copy$8(layout.renderBounds, layout.strokeBounds);
5134
+ layout.renderSpread > 0 ? copyAndSpread$1(layout.renderBounds, layout.boxBounds, layout.renderSpread) : copy$8(layout.renderBounds, layout.strokeBounds);
5134
5135
  }
5135
5136
  };
5136
5137
 
@@ -5235,6 +5236,8 @@ var LeaferUI = (function (exports) {
5235
5236
  get innerName() { return this.__.name || this.tag + this.innerId; }
5236
5237
  get __DataProcessor() { return LeafData; }
5237
5238
  get __LayoutProcessor() { return LeafLayout; }
5239
+ get leaferIsCreated() { return this.leafer && this.leafer.created; }
5240
+ get leaferIsReady() { return this.leafer && this.leafer.ready; }
5238
5241
  get isLeafer() { return false; }
5239
5242
  get isBranch() { return false; }
5240
5243
  get isBranchLeaf() { return false; }
@@ -5676,6 +5679,7 @@ var LeaferUI = (function (exports) {
5676
5679
  add(child, index) {
5677
5680
  if (child === this)
5678
5681
  return;
5682
+ child.__ || (child = UICreator.get(child.tag, child));
5679
5683
  if (child.parent)
5680
5684
  child.parent.remove(child);
5681
5685
  child.parent = this;
@@ -5698,10 +5702,14 @@ var LeaferUI = (function (exports) {
5698
5702
  }
5699
5703
  remove(child, destroy) {
5700
5704
  if (child) {
5701
- if (child.animationOut)
5702
- child.__runAnimation('out', () => this.__remove(child, destroy));
5705
+ if (child.__) {
5706
+ if (child.animationOut)
5707
+ child.__runAnimation('out', () => this.__remove(child, destroy));
5708
+ else
5709
+ this.__remove(child, destroy);
5710
+ }
5703
5711
  else
5704
- this.__remove(child, destroy);
5712
+ this.find(child).forEach(item => this.remove(item, destroy));
5705
5713
  }
5706
5714
  else if (child === undefined) {
5707
5715
  super.remove(null, destroy);
@@ -5919,7 +5927,7 @@ var LeaferUI = (function (exports) {
5919
5927
  }
5920
5928
  }
5921
5929
 
5922
- const version = "1.0.4";
5930
+ const version = "1.0.5";
5923
5931
 
5924
5932
  class LeaferCanvas extends LeaferCanvasBase {
5925
5933
  get allowBackgroundColor() { return true; }
@@ -6105,7 +6113,7 @@ var LeaferUI = (function (exports) {
6105
6113
 
6106
6114
  const { updateAllMatrix: updateAllMatrix$1, updateBounds: updateOneBounds, updateAllWorldOpacity } = LeafHelper;
6107
6115
  const { pushAllChildBranch, pushAllParent } = BranchHelper;
6108
- function updateMatrix(updateList, levelList) {
6116
+ function updateMatrix$1(updateList, levelList) {
6109
6117
  let layout;
6110
6118
  updateList.list.forEach(leaf => {
6111
6119
  layout = leaf.__layout;
@@ -6273,7 +6281,7 @@ var LeaferUI = (function (exports) {
6273
6281
  target.emitEvent(new LayoutEvent(BEFORE, blocks, this.times));
6274
6282
  this.extraBlock = null;
6275
6283
  updateList.sort();
6276
- updateMatrix(updateList, this.__levelList);
6284
+ updateMatrix$1(updateList, this.__levelList);
6277
6285
  updateBounds(this.__levelList);
6278
6286
  updateChange(updateList);
6279
6287
  if (this.extraBlock)
@@ -6388,6 +6396,7 @@ var LeaferUI = (function (exports) {
6388
6396
  this.totalBounds = new Bounds();
6389
6397
  debug$6.log(target.innerName, '--->');
6390
6398
  try {
6399
+ target.app.emit(RenderEvent.CHILD_START, target);
6391
6400
  this.emitRender(RenderEvent.START);
6392
6401
  this.renderOnce(callback);
6393
6402
  this.emitRender(RenderEvent.END, this.totalBounds);
@@ -6685,7 +6694,7 @@ var LeaferUI = (function (exports) {
6685
6694
  if (child.isBranch) {
6686
6695
  if (hit || child.__ignoreHitWorld) {
6687
6696
  this.eachFind(child.children, child.__onlyHitMask);
6688
- if (child.isBranchLeaf && !this.findList.length)
6697
+ if (child.isBranchLeaf)
6689
6698
  this.hitChild(child, point);
6690
6699
  }
6691
6700
  }
@@ -7395,12 +7404,7 @@ var LeaferUI = (function (exports) {
7395
7404
  this.__drawPathByData(canvas, this.__.path);
7396
7405
  }
7397
7406
  __drawPathByData(drawer, data) {
7398
- if (data) {
7399
- PathDrawer.drawPathByData(drawer, data);
7400
- }
7401
- else {
7402
- this.__drawPathByBox(drawer);
7403
- }
7407
+ data ? PathDrawer.drawPathByData(drawer, data) : this.__drawPathByBox(drawer);
7404
7408
  }
7405
7409
  __drawPathByBox(drawer) {
7406
7410
  const { x, y, width, height } = this.__layout.boxBounds;
@@ -7408,9 +7412,8 @@ var LeaferUI = (function (exports) {
7408
7412
  const { cornerRadius } = this.__;
7409
7413
  drawer.roundRect(x, y, width, height, typeof cornerRadius === 'number' ? [cornerRadius] : cornerRadius);
7410
7414
  }
7411
- else {
7415
+ else
7412
7416
  drawer.rect(x, y, width, height);
7413
- }
7414
7417
  }
7415
7418
  animate(_keyframe, _options, _type, _isTemp) {
7416
7419
  return needPlugin('animate');
@@ -8093,10 +8096,9 @@ var LeaferUI = (function (exports) {
8093
8096
  registerUI()
8094
8097
  ], exports.Rect);
8095
8098
 
8096
- const rect$1 = exports.Rect.prototype;
8097
- const group$1 = exports.Group.prototype;
8099
+ const { copy: copy$6, add, includes: includes$1 } = BoundsHelper;
8100
+ const rect$1 = exports.Rect.prototype, group$1 = exports.Group.prototype;
8098
8101
  const childrenRenderBounds = {};
8099
- const { copy: copy$6, add, includes: includes$1, copyAndSpread: copyAndSpread$1 } = BoundsHelper;
8100
8102
  exports.Box = class Box extends exports.Group {
8101
8103
  get __tag() { return 'Box'; }
8102
8104
  get isBranchLeaf() { return true; }
@@ -8110,29 +8112,27 @@ var LeaferUI = (function (exports) {
8110
8112
  return this.__updateRectRenderSpread() || -1;
8111
8113
  }
8112
8114
  __updateRectBoxBounds() { }
8113
- __updateBoxBounds(secondLayout) {
8115
+ __updateBoxBounds(_secondLayout) {
8114
8116
  const data = this.__;
8115
8117
  if (this.children.length) {
8116
8118
  if (data.__autoSide) {
8117
- if (this.leafer && this.leafer.ready)
8118
- this.leafer.layouter.addExtra(this);
8119
8119
  super.__updateBoxBounds();
8120
8120
  const { boxBounds } = this.__layout;
8121
8121
  if (!data.__autoSize) {
8122
- if (data.__autoWidth)
8123
- boxBounds.width += boxBounds.x, boxBounds.height = data.height, boxBounds.y = boxBounds.x = 0;
8124
- else
8125
- boxBounds.height += boxBounds.y, boxBounds.width = data.width, boxBounds.x = boxBounds.y = 0;
8122
+ if (data.__autoWidth) {
8123
+ boxBounds.width += boxBounds.x, boxBounds.x = 0;
8124
+ boxBounds.height = data.height, boxBounds.y = 0;
8125
+ }
8126
+ else {
8127
+ boxBounds.height += boxBounds.y, boxBounds.y = 0;
8128
+ boxBounds.width = data.width, boxBounds.x = 0;
8129
+ }
8126
8130
  }
8127
- if (secondLayout && data.flow && data.padding)
8128
- copyAndSpread$1(boxBounds, boxBounds, data.padding, false, data.__autoSize ? null : (data.__autoWidth ? 'width' : 'height'));
8129
8131
  this.__updateNaturalSize();
8130
8132
  }
8131
8133
  else {
8132
8134
  this.__updateRectBoxBounds();
8133
8135
  }
8134
- if (data.flow)
8135
- this.__updateContentBounds();
8136
8136
  }
8137
8137
  else {
8138
8138
  this.__updateRectBoxBounds();
@@ -8198,6 +8198,9 @@ var LeaferUI = (function (exports) {
8198
8198
  __decorate([
8199
8199
  dataType(false)
8200
8200
  ], exports.Box.prototype, "resizeChildren", void 0);
8201
+ __decorate([
8202
+ dataType(false)
8203
+ ], exports.Box.prototype, "textBox", void 0);
8201
8204
  __decorate([
8202
8205
  affectRenderBoundsType('show')
8203
8206
  ], exports.Box.prototype, "overflow", void 0);
@@ -8727,6 +8730,9 @@ var LeaferUI = (function (exports) {
8727
8730
  __decorate([
8728
8731
  boundsType('top')
8729
8732
  ], exports.Text.prototype, "verticalAlign", void 0);
8733
+ __decorate([
8734
+ boundsType(true)
8735
+ ], exports.Text.prototype, "autoSizeAlign", void 0);
8730
8736
  __decorate([
8731
8737
  boundsType('normal')
8732
8738
  ], exports.Text.prototype, "textWrap", void 0);
@@ -9447,9 +9453,10 @@ var LeaferUI = (function (exports) {
9447
9453
  this.dragData = getDragEventData(data, data, data);
9448
9454
  this.canAnimate = this.canDragOut = true;
9449
9455
  }
9450
- getList() {
9456
+ getList(realDraggable, hover) {
9451
9457
  const { proxy } = this.interaction.selector;
9452
- return this.dragging && (!proxy || !proxy.list.length) ? (exports.DragEvent.list || this.dragableList || emptyList) : emptyList;
9458
+ const hasProxyList = proxy && proxy.list.length, dragList = exports.DragEvent.list || this.draggableList || emptyList;
9459
+ return this.dragging && (hasProxyList ? (realDraggable ? emptyList : new LeafList(hover ? [...proxy.list, ...proxy.dragHoverExclude] : proxy.list)) : dragList);
9453
9460
  }
9454
9461
  checkDrag(data, canDrag) {
9455
9462
  const { interaction } = this;
@@ -9474,8 +9481,8 @@ var LeaferUI = (function (exports) {
9474
9481
  this.dragging = canDrag && PointerButton.left(data);
9475
9482
  if (this.dragging) {
9476
9483
  this.interaction.emit(exports.DragEvent.START, this.dragData);
9477
- this.getDragableList(this.dragData.path);
9478
- this.setDragStartPoints(this.realDragableList = this.getList());
9484
+ this.getDraggableList(this.dragData.path);
9485
+ this.setDragStartPoints(this.realDraggableList = this.getList(true));
9479
9486
  }
9480
9487
  }
9481
9488
  }
@@ -9483,12 +9490,12 @@ var LeaferUI = (function (exports) {
9483
9490
  this.dragStartPoints = {};
9484
9491
  list.forEach(leaf => this.dragStartPoints[leaf.innerId] = { x: leaf.x, y: leaf.y });
9485
9492
  }
9486
- getDragableList(path) {
9493
+ getDraggableList(path) {
9487
9494
  let leaf;
9488
9495
  for (let i = 0, len = path.length; i < len; i++) {
9489
9496
  leaf = path.list[i];
9490
- if ((leaf.__.draggable || leaf.__.editable) && leaf.__.hitSelf && !leaf.__.locked) {
9491
- this.dragableList = new LeafList(leaf);
9497
+ if ((leaf.draggable || leaf.editable) && leaf.hitSelf && !leaf.locked) {
9498
+ this.draggableList = new LeafList(leaf);
9492
9499
  break;
9493
9500
  }
9494
9501
  }
@@ -9513,7 +9520,7 @@ var LeaferUI = (function (exports) {
9513
9520
  }
9514
9521
  dragReal() {
9515
9522
  const { running } = this.interaction;
9516
- const list = this.realDragableList;
9523
+ const list = this.realDraggableList;
9517
9524
  if (list.length && running) {
9518
9525
  const { totalX, totalY } = this.dragData;
9519
9526
  list.forEach(leaf => leaf.draggable && leaf.move(exports.DragEvent.getValidMove(leaf, this.dragStartPoints[leaf.innerId], { x: totalX, y: totalY })));
@@ -9602,7 +9609,7 @@ var LeaferUI = (function (exports) {
9602
9609
  this.interaction.emit(exports.DragEvent.LEAVE, data, dragEnterPath);
9603
9610
  }
9604
9611
  dragReset() {
9605
- exports.DragEvent.list = exports.DragEvent.data = this.dragableList = this.dragData = this.downData = this.dragOverPath = this.dragEnterPath = null;
9612
+ exports.DragEvent.list = exports.DragEvent.data = this.draggableList = this.dragData = this.downData = this.dragOverPath = this.dragEnterPath = null;
9606
9613
  }
9607
9614
  checkDragOut(data) {
9608
9615
  const { interaction } = this;
@@ -9743,6 +9750,7 @@ var LeaferUI = (function (exports) {
9743
9750
  touch: {
9744
9751
  preventDefault: true
9745
9752
  },
9753
+ multiTouch: {},
9746
9754
  cursor: true,
9747
9755
  keyEvent: true
9748
9756
  };
@@ -9869,6 +9877,8 @@ var LeaferUI = (function (exports) {
9869
9877
  this.pointerUp(data);
9870
9878
  }
9871
9879
  multiTouch(data, list) {
9880
+ if (this.config.multiTouch.disabled)
9881
+ return;
9872
9882
  const { move, angle, scale, center } = MultiTouchHelper.getData(list);
9873
9883
  this.rotate(getRotateEventData(center, angle, data));
9874
9884
  this.zoom(getZoomEventData(center, scale, data));
@@ -10058,7 +10068,7 @@ var LeaferUI = (function (exports) {
10058
10068
  data = this.hoverData;
10059
10069
  if (!data)
10060
10070
  return;
10061
- this.findPath(data, { exclude: this.dragger.getList(), name: exports.PointerEvent.MOVE });
10071
+ this.findPath(data, { exclude: this.dragger.getList(false, true), name: exports.PointerEvent.MOVE });
10062
10072
  this.hoverData = data;
10063
10073
  }
10064
10074
  updateCursor(data) {
@@ -10080,7 +10090,7 @@ var LeaferUI = (function (exports) {
10080
10090
  const { path } = data;
10081
10091
  for (let i = 0, len = path.length; i < len; i++) {
10082
10092
  leaf = path.list[i];
10083
- cursor = leaf.syncEventer ? leaf.syncEventer.cursor : leaf.cursor;
10093
+ cursor = (leaf.syncEventer && leaf.syncEventer.cursor) || leaf.cursor;
10084
10094
  if (cursor)
10085
10095
  break;
10086
10096
  }
@@ -10262,7 +10272,7 @@ var LeaferUI = (function (exports) {
10262
10272
  if (isHitPixel) {
10263
10273
  const { renderBounds } = this.__layout;
10264
10274
  const size = Platform.image.hitCanvasSize;
10265
- const scale = h.hitScale = tempBounds$1.set(0, 0, size, size).getFitMatrix(renderBounds, 0.5).a;
10275
+ const scale = h.hitScale = tempBounds$1.set(0, 0, size, size).getFitMatrix(renderBounds).a;
10266
10276
  const { x, y, width, height } = tempBounds$1.set(renderBounds).scale(scale);
10267
10277
  h.resize({ width, height, pixelRatio: 1 });
10268
10278
  h.clear();
@@ -10318,15 +10328,14 @@ var LeaferUI = (function (exports) {
10318
10328
  return hitWidth ? this.__hitStroke(inner, hitWidth) : false;
10319
10329
  };
10320
10330
 
10321
- const ui$2 = new exports.UI();
10322
- const rect = exports.Rect.prototype;
10323
- rect.__updateHitCanvas = function () {
10331
+ const ui$2 = exports.UI.prototype, rect = exports.Rect.prototype, box$1 = exports.Box.prototype;
10332
+ rect.__updateHitCanvas = box$1.__updateHitCanvas = function () {
10324
10333
  if (this.stroke || this.cornerRadius || ((this.fill || this.__.__isCanvas) && this.hitFill === 'pixel') || this.hitStroke === 'all')
10325
10334
  ui$2.__updateHitCanvas.call(this);
10326
10335
  else if (this.__hitCanvas)
10327
10336
  this.__hitCanvas = null;
10328
10337
  };
10329
- rect.__hitFill = function (inner) {
10338
+ rect.__hitFill = box$1.__hitFill = function (inner) {
10330
10339
  return this.__hitCanvas ? ui$2.__hitFill.call(this, inner) : BoundsHelper.hitRadiusPoint(this.__layout.boxBounds, inner);
10331
10340
  };
10332
10341
 
@@ -10665,7 +10674,7 @@ var LeaferUI = (function (exports) {
10665
10674
  shape
10666
10675
  };
10667
10676
 
10668
- let origin = {};
10677
+ let origin$1 = {};
10669
10678
  const { get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, scale: scaleHelper, rotate: rotate$2 } = MatrixHelper;
10670
10679
  function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
10671
10680
  const transform = get$3();
@@ -10705,11 +10714,11 @@ var LeaferUI = (function (exports) {
10705
10714
  }
10706
10715
  }
10707
10716
  }
10708
- origin.x = box.x + x;
10709
- origin.y = box.y + y;
10710
- translate$1(transform, origin.x, origin.y);
10717
+ origin$1.x = box.x + x;
10718
+ origin$1.y = box.y + y;
10719
+ translate$1(transform, origin$1.x, origin$1.y);
10711
10720
  if (scaleX)
10712
- scaleOfOuter$1(transform, origin, scaleX, scaleY);
10721
+ scaleOfOuter$1(transform, origin$1, scaleX, scaleY);
10713
10722
  data.transform = transform;
10714
10723
  }
10715
10724
 
@@ -10825,9 +10834,10 @@ var LeaferUI = (function (exports) {
10825
10834
  onLoadError(ui, event, image.error);
10826
10835
  }
10827
10836
  else {
10828
- ignoreRender(ui, true);
10829
- if (firstUse)
10837
+ if (firstUse) {
10838
+ ignoreRender(ui, true);
10830
10839
  onLoad(ui, event);
10840
+ }
10831
10841
  leafPaint.loadId = image.load(() => {
10832
10842
  ignoreRender(ui, false);
10833
10843
  if (!ui.destroyed) {
@@ -11439,14 +11449,15 @@ var LeaferUI = (function (exports) {
11439
11449
  const { Letter, Single, Before, After, Symbol, Break } = CharType;
11440
11450
  let word, row, wordWidth, rowWidth, realWidth;
11441
11451
  let char, charWidth, startCharSize, charSize, charType, lastCharType, langBreak, afterBreak, paraStart;
11442
- let textDrawData, rows = [], bounds;
11452
+ let textDrawData, rows = [], bounds$1, findMaxWidth;
11443
11453
  function createRows(drawData, content, style) {
11444
11454
  textDrawData = drawData;
11445
11455
  rows = drawData.rows;
11446
- bounds = drawData.bounds;
11456
+ bounds$1 = drawData.bounds;
11457
+ findMaxWidth = !bounds$1.width && !style.autoSizeAlign;
11447
11458
  const { __letterSpacing, paraIndent, textCase } = style;
11448
11459
  const { canvas } = Platform;
11449
- const { width, height } = bounds;
11460
+ const { width, height } = bounds$1;
11450
11461
  const charMode = width || height || __letterSpacing || (textCase !== 'none');
11451
11462
  if (charMode) {
11452
11463
  const wrap = style.textWrap !== 'none';
@@ -11528,7 +11539,10 @@ var LeaferUI = (function (exports) {
11528
11539
  else {
11529
11540
  content.split('\n').forEach(content => {
11530
11541
  textDrawData.paraNumber++;
11531
- rows.push({ x: paraIndent || 0, text: content, width: canvas.measureText(content).width, paraStart: true });
11542
+ rowWidth = canvas.measureText(content).width;
11543
+ rows.push({ x: paraIndent || 0, text: content, width: rowWidth, paraStart: true });
11544
+ if (findMaxWidth)
11545
+ setMaxWidth();
11532
11546
  });
11533
11547
  }
11534
11548
  }
@@ -11557,12 +11571,18 @@ var LeaferUI = (function (exports) {
11557
11571
  startCharSize = 0;
11558
11572
  }
11559
11573
  row.width = rowWidth;
11560
- if (bounds.width)
11574
+ if (bounds$1.width)
11561
11575
  trimRight(row);
11576
+ else if (findMaxWidth)
11577
+ setMaxWidth();
11562
11578
  rows.push(row);
11563
11579
  row = { words: [] };
11564
11580
  rowWidth = 0;
11565
11581
  }
11582
+ function setMaxWidth() {
11583
+ if (rowWidth > (textDrawData.maxWidth || 0))
11584
+ textDrawData.maxWidth = rowWidth;
11585
+ }
11566
11586
 
11567
11587
  const CharMode = 0;
11568
11588
  const WordMode = 1;
@@ -11634,34 +11654,32 @@ var LeaferUI = (function (exports) {
11634
11654
 
11635
11655
  function layoutText(drawData, style) {
11636
11656
  const { rows, bounds } = drawData;
11637
- const { __lineHeight, __baseLine, __letterSpacing, __clipText, textAlign, verticalAlign, paraSpacing } = style;
11657
+ const { __lineHeight, __baseLine, __letterSpacing, __clipText, textAlign, verticalAlign, paraSpacing, autoSizeAlign } = style;
11638
11658
  let { x, y, width, height } = bounds, realHeight = __lineHeight * rows.length + (paraSpacing ? paraSpacing * (drawData.paraNumber - 1) : 0);
11639
11659
  let starY = __baseLine;
11640
11660
  if (__clipText && realHeight > height) {
11641
11661
  realHeight = Math.max(height, __lineHeight);
11642
11662
  drawData.overflow = rows.length;
11643
11663
  }
11644
- else {
11664
+ else if (height || autoSizeAlign) {
11645
11665
  switch (verticalAlign) {
11646
11666
  case 'middle':
11647
11667
  y += (height - realHeight) / 2;
11648
11668
  break;
11649
- case 'bottom':
11650
- y += (height - realHeight);
11669
+ case 'bottom': y += (height - realHeight);
11651
11670
  }
11652
11671
  }
11653
11672
  starY += y;
11654
- let row, rowX, rowWidth;
11673
+ let row, rowX, rowWidth, layoutWidth = (width || autoSizeAlign) ? width : drawData.maxWidth;
11655
11674
  for (let i = 0, len = rows.length; i < len; i++) {
11656
11675
  row = rows[i];
11657
11676
  row.x = x;
11658
11677
  if (row.width < width || (row.width > width && !__clipText)) {
11659
11678
  switch (textAlign) {
11660
11679
  case 'center':
11661
- row.x += (width - row.width) / 2;
11680
+ row.x += (layoutWidth - row.width) / 2;
11662
11681
  break;
11663
- case 'right':
11664
- row.x += width - row.width;
11682
+ case 'right': row.x += layoutWidth - row.width;
11665
11683
  }
11666
11684
  }
11667
11685
  if (row.paraStart && paraSpacing && i > 0)
@@ -11766,14 +11784,14 @@ var LeaferUI = (function (exports) {
11766
11784
  let height = style.__getInput('height') || 0;
11767
11785
  const { textDecoration, __font, __padding: padding } = style;
11768
11786
  if (padding) {
11769
- if (width) {
11787
+ if (width)
11788
+ x = padding[left$3], width -= (padding[right$3] + padding[left$3]);
11789
+ else if (!style.autoSizeAlign)
11770
11790
  x = padding[left$3];
11771
- width -= (padding[right$3] + padding[left$3]);
11772
- }
11773
- if (height) {
11791
+ if (height)
11792
+ y = padding[top$2], height -= (padding[top$2] + padding[bottom$2]);
11793
+ else if (!style.autoSizeAlign)
11774
11794
  y = padding[top$2];
11775
- height -= (padding[top$2] + padding[bottom$2]);
11776
- }
11777
11795
  }
11778
11796
  const drawData = {
11779
11797
  bounds: { x, y, width, height },
@@ -11793,22 +11811,20 @@ var LeaferUI = (function (exports) {
11793
11811
  return drawData;
11794
11812
  }
11795
11813
  function padAutoText(padding, drawData, style, width, height) {
11796
- if (!width) {
11814
+ if (!width && style.autoSizeAlign) {
11797
11815
  switch (style.textAlign) {
11798
11816
  case 'left':
11799
11817
  offsetText(drawData, 'x', padding[left$3]);
11800
11818
  break;
11801
- case 'right':
11802
- offsetText(drawData, 'x', -padding[right$3]);
11819
+ case 'right': offsetText(drawData, 'x', -padding[right$3]);
11803
11820
  }
11804
11821
  }
11805
- if (!height) {
11822
+ if (!height && style.autoSizeAlign) {
11806
11823
  switch (style.verticalAlign) {
11807
11824
  case 'top':
11808
11825
  offsetText(drawData, 'y', padding[top$2]);
11809
11826
  break;
11810
- case 'bottom':
11811
- offsetText(drawData, 'y', -padding[bottom$2]);
11827
+ case 'bottom': offsetText(drawData, 'y', -padding[bottom$2]);
11812
11828
  }
11813
11829
  }
11814
11830
  }
@@ -12330,31 +12346,29 @@ var LeaferUI = (function (exports) {
12330
12346
  const { list } = this;
12331
12347
  if (list.length) {
12332
12348
  let leaf;
12333
- const { stroke, strokeWidth, fill } = this.__;
12334
- const { bounds } = options;
12349
+ const data = this.__, { stroke, strokeWidth, fill } = data, { bounds } = options;
12335
12350
  for (let i = 0; i < list.length; i++) {
12336
12351
  leaf = list[i];
12337
- if (bounds && bounds.hit(leaf.__world, options.matrix)) {
12338
- const aScaleX = abs(leaf.__world.scaleX), aScaleY = abs(leaf.__world.scaleY);
12352
+ const { worldTransform, worldRenderBounds } = leaf;
12353
+ if (bounds && bounds.hit(worldRenderBounds, options.matrix)) {
12354
+ const aScaleX = abs(worldTransform.scaleX), aScaleY = abs(worldTransform.scaleY);
12339
12355
  if (aScaleX !== aScaleY) {
12340
- copy$2(matrix, leaf.__world);
12356
+ copy$2(matrix, worldTransform);
12341
12357
  scale$1(matrix, 1 / aScaleX, 1 / aScaleY);
12342
12358
  canvas.setWorld(matrix, options.matrix);
12343
12359
  canvas.beginPath();
12344
- this.__.strokeWidth = strokeWidth;
12360
+ data.strokeWidth = strokeWidth;
12345
12361
  const { x, y, width, height } = leaf.__layout.boxBounds;
12346
12362
  canvas.rect(x * aScaleX, y * aScaleY, width * aScaleX, height * aScaleY);
12347
12363
  }
12348
12364
  else {
12349
- canvas.setWorld(leaf.__world, options.matrix);
12365
+ canvas.setWorld(worldTransform, options.matrix);
12350
12366
  canvas.beginPath();
12351
- if (leaf.__.__useArrow) {
12367
+ if (leaf.__.__useArrow)
12352
12368
  leaf.__drawPath(canvas);
12353
- }
12354
- else {
12369
+ else
12355
12370
  leaf.__.__pathForRender ? leaf.__drawRenderPath(canvas) : leaf.__drawPathByBox(canvas);
12356
- }
12357
- this.__.strokeWidth = strokeWidth / abs(leaf.__world.scaleX);
12371
+ data.strokeWidth = strokeWidth / abs(worldTransform.scaleX);
12358
12372
  }
12359
12373
  if (stroke)
12360
12374
  typeof stroke === 'string' ? Paint.stroke(stroke, this, canvas) : Paint.strokes(stroke, this, canvas);
@@ -12362,7 +12376,7 @@ var LeaferUI = (function (exports) {
12362
12376
  typeof fill === 'string' ? Paint.fill(fill, this, canvas) : Paint.fills(fill, this, canvas);
12363
12377
  }
12364
12378
  }
12365
- this.__.strokeWidth = strokeWidth;
12379
+ data.strokeWidth = strokeWidth;
12366
12380
  }
12367
12381
  }
12368
12382
  destroy() {
@@ -12913,7 +12927,6 @@ var LeaferUI = (function (exports) {
12913
12927
  this.editor = editor;
12914
12928
  this.visible = false;
12915
12929
  this.create();
12916
- this.rect.syncEventer = editor;
12917
12930
  this.__listenEvents();
12918
12931
  }
12919
12932
  create() {
@@ -12953,8 +12966,11 @@ var LeaferUI = (function (exports) {
12953
12966
  circle.set(this.getPointStyle(mergeConfig.circle || mergeConfig.rotatePoint || pointsStyle[0]));
12954
12967
  rect.set(Object.assign({ stroke, strokeWidth }, (mergeConfig.rect || {})));
12955
12968
  rect.hittable = !single && !!moveable;
12956
- element.syncEventer = (single && moveable) ? rect : null;
12957
- this.app.interaction.bottomList = (single && moveable) ? [{ target: rect, proxy: element }] : null;
12969
+ rect.syncEventer = single && this.editor;
12970
+ if (single && moveable) {
12971
+ element.syncEventer = rect;
12972
+ this.app.interaction.bottomList = [{ target: rect, proxy: element }];
12973
+ }
12958
12974
  }
12959
12975
  update(bounds) {
12960
12976
  this.visible = !this.editor.element.locked;
@@ -13126,6 +13142,11 @@ var LeaferUI = (function (exports) {
13126
13142
  if (editor.single) {
13127
13143
  const { element } = editor;
13128
13144
  if (element.isBranch) {
13145
+ if (element.textBox) {
13146
+ const find = element.children.find(item => item.editable && item instanceof exports.Text);
13147
+ if (find)
13148
+ return editor.openInnerEditor(find);
13149
+ }
13129
13150
  editor.openGroup(element);
13130
13151
  editor.target = editor.selector.findDeepOne(e);
13131
13152
  }
@@ -13271,12 +13292,12 @@ ${filterStyle}
13271
13292
  skewable: true
13272
13293
  };
13273
13294
 
13295
+ const bounds = new Bounds();
13274
13296
  function simulate(editor) {
13275
- const { simulateTarget, leafList: targetList } = editor;
13276
- const { x, y, width, height } = new Bounds().setListWithFn(targetList.list, (leaf) => leaf.worldBoxBounds);
13277
- const parent = simulateTarget.parent = targetList.list[0].leafer.zoomLayer;
13278
- const { scaleX, scaleY, e: worldX, f: worldY } = parent.__world;
13279
- simulateTarget.reset({ x: (x - worldX) / scaleX, y: (y - worldY) / scaleY, width: width / scaleX, height: height / scaleY });
13297
+ const { simulateTarget, list } = editor;
13298
+ const { zoomLayer } = list[0].leafer.zoomLayer;
13299
+ simulateTarget.safeChange(() => simulateTarget.reset(bounds.setListWithFn(list, (leaf) => leaf.getBounds('box', 'page')).get()));
13300
+ zoomLayer.add(simulateTarget);
13280
13301
  }
13281
13302
 
13282
13303
  function onTarget(editor, oldValue) {
@@ -13285,6 +13306,7 @@ ${filterStyle}
13285
13306
  editor.leafList = target instanceof LeafList ? target : new LeafList(target instanceof Array ? target : target);
13286
13307
  }
13287
13308
  else {
13309
+ editor.simulateTarget.remove();
13288
13310
  editor.leafList.reset();
13289
13311
  editor.closeInnerEditor();
13290
13312
  }
@@ -13339,7 +13361,7 @@ ${filterStyle}
13339
13361
  const ungroupList = [];
13340
13362
  app.lockLayout();
13341
13363
  list.forEach(leaf => {
13342
- if (leaf.isBranch) {
13364
+ if (leaf.isBranch && !leaf.isBranchLeaf) {
13343
13365
  const { parent, children } = leaf;
13344
13366
  while (children.length) {
13345
13367
  ungroupList.push(children[0]);
@@ -13410,17 +13432,77 @@ ${filterStyle}
13410
13432
  EditorGroupEvent.OPEN = 'editor.open_group';
13411
13433
  EditorGroupEvent.CLOSE = 'editor.close_group';
13412
13434
 
13435
+ const { updateMatrix } = LeafHelper;
13436
+ const checkMap = { x: 1, y: 1, scaleX: 1, scaleY: 1, rotation: 1, skewX: 1, skewY: 1 }, origin = 'top-left';
13437
+ class SimulateElement extends exports.Rect {
13438
+ get __tag() { return 'SimulateElement'; }
13439
+ constructor(editor) {
13440
+ super();
13441
+ this.checkChange = true;
13442
+ this.canChange = true;
13443
+ this.visible = this.hittable = false;
13444
+ this.on(PropertyEvent.CHANGE, (event) => {
13445
+ if (this.checkChange && checkMap[event.attrName]) {
13446
+ const { attrName, newValue, oldValue } = event;
13447
+ const addValue = attrName[0] === 's' ? (newValue || 1) / (oldValue || 1) : (newValue || 0) - (oldValue || 0);
13448
+ this.canChange = false;
13449
+ const data = this.__;
13450
+ data[attrName] = oldValue;
13451
+ updateMatrix(this.parent);
13452
+ updateMatrix(this);
13453
+ const oldMatrix = new Matrix(this.__world);
13454
+ data[attrName] = newValue;
13455
+ this.__layout.rotationChange();
13456
+ updateMatrix(this);
13457
+ this.changedTransform = new Matrix(this.__world).divide(oldMatrix);
13458
+ switch (attrName) {
13459
+ case 'x':
13460
+ editor.move(addValue, 0);
13461
+ break;
13462
+ case 'y':
13463
+ editor.move(0, addValue);
13464
+ break;
13465
+ case 'rotation':
13466
+ editor.rotateOf(origin, addValue);
13467
+ break;
13468
+ case 'scaleX':
13469
+ editor.scaleOf(origin, addValue, 1);
13470
+ break;
13471
+ case 'scaleY':
13472
+ editor.scaleOf(origin, 1, addValue);
13473
+ break;
13474
+ case 'skewX':
13475
+ editor.skewOf(origin, addValue, 0);
13476
+ break;
13477
+ case 'skewY':
13478
+ editor.skewOf(origin, 0, addValue);
13479
+ }
13480
+ this.canChange = true;
13481
+ }
13482
+ });
13483
+ }
13484
+ safeChange(changeFn) {
13485
+ if (this.canChange) {
13486
+ this.checkChange = false;
13487
+ changeFn();
13488
+ this.checkChange = true;
13489
+ }
13490
+ }
13491
+ }
13492
+
13413
13493
  class Editor extends exports.Group {
13414
13494
  get mergeConfig() {
13415
13495
  const { element, config } = this;
13416
13496
  return this.single && element.editConfig ? Object.assign(Object.assign({}, config), element.editConfig) : config;
13417
13497
  }
13418
13498
  get list() { return this.leafList.list; }
13499
+ get dragHoverExclude() { return [this.editBox.rect]; }
13419
13500
  get editing() { return !!this.list.length; }
13420
13501
  get groupOpening() { return !!this.openedGroupList.length; }
13421
13502
  get multiple() { return this.list.length > 1; }
13422
13503
  get single() { return this.list.length === 1; }
13423
13504
  get dragging() { return this.editBox.dragging; }
13505
+ get moving() { return this.editBox.moving; }
13424
13506
  get element() { return this.multiple ? this.simulateTarget : this.list[0]; }
13425
13507
  get buttons() { return this.editBox.buttons; }
13426
13508
  constructor(userConfig, data) {
@@ -13428,7 +13510,7 @@ ${filterStyle}
13428
13510
  this.config = DataHelper.clone(config);
13429
13511
  this.leafList = new LeafList();
13430
13512
  this.openedGroupList = new LeafList();
13431
- this.simulateTarget = new exports.Rect({ visible: false });
13513
+ this.simulateTarget = new SimulateElement(this);
13432
13514
  this.editBox = new EditBox(this);
13433
13515
  this.editToolList = {};
13434
13516
  this.selector = new EditSelect(this);
@@ -13566,18 +13648,18 @@ ${filterStyle}
13566
13648
  this.skewOf(origin, skewX, skewY);
13567
13649
  }
13568
13650
  move(x, y = 0) {
13569
- if (!this.mergeConfig.moveable || this.element.locked)
13651
+ if (!this.checkTransform('moveable'))
13570
13652
  return;
13571
13653
  const { element } = this;
13572
13654
  const world = element.getWorldPointByLocal(typeof x === 'object' ? Object.assign({}, x) : { x, y }, null, true);
13655
+ if (this.multiple)
13656
+ element.safeChange(() => element.move(x, y));
13573
13657
  const event = new EditorMoveEvent(EditorMoveEvent.MOVE, { target: element, editor: this, moveX: world.x, moveY: world.y });
13574
13658
  this.editTool.onMove(event);
13575
13659
  this.emitEvent(event);
13576
- if (this.multiple)
13577
- element.move(x, y);
13578
13660
  }
13579
13661
  scaleWithDrag(data) {
13580
- if (!this.mergeConfig.resizeable || this.element.locked)
13662
+ if (!this.checkTransform('resizeable'))
13581
13663
  return;
13582
13664
  const { element } = this;
13583
13665
  const event = new EditorScaleEvent(EditorScaleEvent.SCALE, Object.assign(Object.assign({}, data), { target: element, editor: this, worldOrigin: element.getWorldPoint(data.origin) }));
@@ -13585,50 +13667,53 @@ ${filterStyle}
13585
13667
  this.emitEvent(event);
13586
13668
  }
13587
13669
  scaleOf(origin, scaleX, scaleY = scaleX, _resize) {
13588
- if (!this.mergeConfig.resizeable || this.element.locked)
13670
+ if (!this.checkTransform('resizeable'))
13589
13671
  return;
13590
13672
  const { element } = this;
13591
13673
  const worldOrigin = this.getWorldOrigin(origin);
13592
- const transform = this.multiple && this.getChangedTransform(() => element.scaleOf(origin, scaleX, scaleY));
13674
+ const transform = this.multiple && this.getChangedTransform(() => element.safeChange(() => element.scaleOf(origin, scaleX, scaleY)));
13593
13675
  const event = new EditorScaleEvent(EditorScaleEvent.SCALE, { target: element, editor: this, worldOrigin, scaleX, scaleY, transform });
13594
13676
  this.editTool.onScale(event);
13595
13677
  this.emitEvent(event);
13596
13678
  }
13597
13679
  flip(axis) {
13598
- if (this.element.locked)
13680
+ if (!this.checkTransform('resizeable'))
13599
13681
  return;
13600
13682
  const { element } = this;
13601
13683
  const worldOrigin = this.getWorldOrigin('center');
13602
- const transform = this.multiple ? this.getChangedTransform(() => element.flip(axis)) : new Matrix(LeafHelper.getFlipTransform(element, axis));
13684
+ const transform = this.multiple ? this.getChangedTransform(() => element.safeChange(() => element.flip(axis))) : new Matrix(LeafHelper.getFlipTransform(element, axis));
13603
13685
  const event = new EditorScaleEvent(EditorScaleEvent.SCALE, { target: element, editor: this, worldOrigin, scaleX: axis === 'x' ? -1 : 1, scaleY: axis === 'y' ? -1 : 1, transform });
13604
13686
  this.editTool.onScale(event);
13605
13687
  this.emitEvent(event);
13606
13688
  }
13607
13689
  rotateOf(origin, rotation) {
13608
- if (!this.mergeConfig.rotateable || this.element.locked)
13690
+ if (!this.checkTransform('rotateable'))
13609
13691
  return;
13610
13692
  const { element } = this;
13611
13693
  const worldOrigin = this.getWorldOrigin(origin);
13612
- const transform = this.multiple && this.getChangedTransform(() => element.rotateOf(origin, rotation));
13694
+ const transform = this.multiple && this.getChangedTransform(() => element.safeChange(() => element.rotateOf(origin, rotation)));
13613
13695
  const event = new EditorRotateEvent(EditorRotateEvent.ROTATE, { target: element, editor: this, worldOrigin, rotation, transform });
13614
13696
  this.editTool.onRotate(event);
13615
13697
  this.emitEvent(event);
13616
13698
  }
13617
13699
  skewOf(origin, skewX, skewY = 0, _resize) {
13618
- if (!this.mergeConfig.skewable || this.element.locked)
13700
+ if (!this.checkTransform('skewable'))
13619
13701
  return;
13620
13702
  const { element } = this;
13621
13703
  const worldOrigin = this.getWorldOrigin(origin);
13622
- const transform = this.multiple && this.getChangedTransform(() => element.skewOf(origin, skewX, skewY));
13704
+ const transform = this.multiple && this.getChangedTransform(() => element.safeChange(() => element.skewOf(origin, skewX, skewY)));
13623
13705
  const event = new EditorSkewEvent(EditorSkewEvent.SKEW, { target: element, editor: this, worldOrigin, skewX, skewY, transform });
13624
13706
  this.editTool.onSkew(event);
13625
13707
  this.emitEvent(event);
13626
13708
  }
13709
+ checkTransform(type) { return this.element && !this.element.locked && this.mergeConfig[type]; }
13627
13710
  getWorldOrigin(origin) {
13628
13711
  return this.element.getWorldPoint(LeafHelper.getInnerOrigin(this.element, origin));
13629
13712
  }
13630
13713
  getChangedTransform(func) {
13631
13714
  const { element } = this;
13715
+ if (this.multiple && !element.canChange)
13716
+ return element.changedTransform;
13632
13717
  const oldMatrix = new Matrix(element.worldTransform);
13633
13718
  func();
13634
13719
  return new Matrix(element.worldTransform).divide(oldMatrix);
@@ -13685,11 +13770,11 @@ ${filterStyle}
13685
13770
  this.emitEvent(event);
13686
13771
  group.emitEvent(event);
13687
13772
  }
13688
- openInnerEditor(target) {
13689
- if (target)
13773
+ openInnerEditor(target, select) {
13774
+ if (target && select)
13690
13775
  this.target = target;
13691
13776
  if (this.single) {
13692
- const editTarget = this.element;
13777
+ const editTarget = target || this.element;
13693
13778
  const tag = editTarget.editInner;
13694
13779
  if (tag && EditToolCreator.list[tag]) {
13695
13780
  this.editTool.unload();
@@ -13741,14 +13826,15 @@ ${filterStyle}
13741
13826
  }
13742
13827
  listenTargetEvents() {
13743
13828
  if (!this.targetEventIds.length) {
13744
- const { leafer } = this.list[0];
13829
+ const { app, leafer } = this;
13745
13830
  this.targetEventIds = [
13746
- this.app.on_(exports.MoveEvent.BEFORE_MOVE, this.onMove, this, true),
13747
- this.app.on_(exports.ZoomEvent.BEFORE_ZOOM, this.onScale, this, true),
13748
- this.app.on_(exports.RotateEvent.BEFORE_ROTATE, this.onRotate, this, true),
13749
13831
  leafer.on_(RenderEvent.START, this.update, this),
13750
- leafer.on_([exports.KeyEvent.HOLD, exports.KeyEvent.UP], (e) => { updateCursor(this, e); }),
13751
- leafer.on_(exports.KeyEvent.DOWN, this.editBox.onArrow, this.editBox)
13832
+ app.on_(RenderEvent.CHILD_START, this.forceRender, this),
13833
+ app.on_(exports.MoveEvent.BEFORE_MOVE, this.onMove, this, true),
13834
+ app.on_(exports.ZoomEvent.BEFORE_ZOOM, this.onScale, this, true),
13835
+ app.on_(exports.RotateEvent.BEFORE_ROTATE, this.onRotate, this, true),
13836
+ app.on_([exports.KeyEvent.HOLD, exports.KeyEvent.UP], (e) => { updateCursor(this, e); }),
13837
+ app.on_(exports.KeyEvent.DOWN, this.editBox.onArrow, this.editBox)
13752
13838
  ];
13753
13839
  }
13754
13840
  }
@@ -13881,10 +13967,7 @@ ${filterStyle}
13881
13967
  }
13882
13968
  update() {
13883
13969
  const { editor, editBox } = this;
13884
- const { simulateTarget, element } = editor;
13885
- if (editor.multiple)
13886
- simulateTarget.parent.updateLayout();
13887
- const { x, y, scaleX, scaleY, rotation, skewX, skewY, width, height } = element.getLayoutBounds('box', editor, true);
13970
+ const { x, y, scaleX, scaleY, rotation, skewX, skewY, width, height } = editor.element.getLayoutBounds('box', editor, true);
13888
13971
  editBox.set({ x, y, scaleX, scaleY, rotation, skewX, skewY });
13889
13972
  editBox.update({ x: 0, y: 0, width, height });
13890
13973
  this.onUpdate();
@@ -14573,18 +14656,7 @@ ${filterStyle}
14573
14656
  style.position = 'fixed';
14574
14657
  style.transformOrigin = 'left top';
14575
14658
  style.boxSizing = 'border-box';
14576
- if (this.isHTMLText) {
14577
- div.innerHTML = text.text;
14578
- this.textScale = 1;
14579
- }
14580
- else {
14581
- div.innerText = text.text;
14582
- const { scaleX, scaleY } = text.worldTransform;
14583
- this.textScale = Math.max(Math.abs(scaleX), Math.abs(scaleY));
14584
- const fontSize = text.fontSize * this.textScale;
14585
- if (fontSize < 12)
14586
- this.textScale *= 12 / fontSize;
14587
- }
14659
+ this.isHTMLText ? div.innerHTML = text.text : div.innerText = text.text;
14588
14660
  const { view } = editor.app;
14589
14661
  (this.inBody = view instanceof HTMLCanvasElement) ? document.body.appendChild(div) : view.appendChild(div);
14590
14662
  this.eventIds = [
@@ -14633,16 +14705,46 @@ ${filterStyle}
14633
14705
  this.editor.closeInnerEditor();
14634
14706
  }
14635
14707
  onUpdate() {
14636
- const { editTarget: text, textScale } = this;
14637
- const { style } = this.editDom;
14638
- const { x, y } = this.inBody ? text.app.clientBounds : text.app.tree.clientBounds;
14708
+ const { editTarget: text } = this;
14709
+ let textScale = 1;
14710
+ if (!this.isHTMLText) {
14711
+ const { scaleX, scaleY } = text.worldTransform;
14712
+ textScale = Math.max(Math.abs(scaleX), Math.abs(scaleY));
14713
+ const fontSize = text.fontSize * textScale;
14714
+ if (fontSize < 12)
14715
+ textScale *= 12 / text.fontSize;
14716
+ }
14717
+ this.textScale = textScale;
14639
14718
  const { a, b, c, d, e, f } = new Matrix(text.worldTransform).scale(1 / textScale);
14719
+ let { x, y } = this.inBody ? text.app.clientBounds : text.app.tree.clientBounds;
14720
+ let { width, height } = text;
14721
+ x -= window.scrollX, y -= window.scrollY, width *= textScale, height *= textScale;
14722
+ const data = text.__;
14723
+ if (data.__autoWidth && data.autoSizeAlign) {
14724
+ width += 20;
14725
+ switch (data.textAlign) {
14726
+ case 'center':
14727
+ x -= width / 2;
14728
+ break;
14729
+ case 'right': x -= width;
14730
+ }
14731
+ }
14732
+ if (data.__autoHeight && data.autoSizeAlign) {
14733
+ height += 20;
14734
+ switch (data.verticalAlign) {
14735
+ case 'middle':
14736
+ y -= height / 2;
14737
+ break;
14738
+ case 'bottom': y -= height;
14739
+ }
14740
+ }
14741
+ const { style } = this.editDom;
14640
14742
  style.transform = `matrix(${a},${b},${c},${d},${e},${f})`;
14641
- style.left = x - window.scrollX + 'px';
14642
- style.top = y - window.scrollY + 'px';
14643
- style.width = text.width * textScale + (text.__.__autoWidth ? 20 : 0) + 'px';
14644
- style.height = text.height * textScale + (text.__.__autoHeight ? 20 : 0) + 'px';
14645
- this.isHTMLText || updateStyle(this.editDom, text, this.textScale);
14743
+ style.left = x + 'px';
14744
+ style.top = y + 'px';
14745
+ style.width = width + 'px';
14746
+ style.height = height + 'px';
14747
+ this.isHTMLText || updateStyle(this.editDom, text, textScale);
14646
14748
  }
14647
14749
  onUnload() {
14648
14750
  const { editTarget: text, editor, editDom: dom } = this;