@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.
@@ -4056,7 +4056,7 @@ const LeafHelper = {
4056
4056
  updateAllMatrix(leaf, checkAutoLayout, waitAutoLayout) {
4057
4057
  if (checkAutoLayout && leaf.__hasAutoLayout && leaf.__layout.matrixChanged)
4058
4058
  waitAutoLayout = true;
4059
- updateMatrix$2(leaf, checkAutoLayout, waitAutoLayout);
4059
+ updateMatrix$3(leaf, checkAutoLayout, waitAutoLayout);
4060
4060
  if (leaf.isBranch) {
4061
4061
  const { children } = leaf;
4062
4062
  for (let i = 0, len = children.length; i < len; i++) {
@@ -4226,7 +4226,7 @@ const LeafHelper = {
4226
4226
  }
4227
4227
  };
4228
4228
  const L$3 = LeafHelper;
4229
- const { updateAllMatrix: updateAllMatrix$3, updateMatrix: updateMatrix$2, updateAllWorldOpacity: updateAllWorldOpacity$1, updateAllChange: updateAllChange$1 } = L$3;
4229
+ const { updateAllMatrix: updateAllMatrix$3, updateMatrix: updateMatrix$3, updateAllWorldOpacity: updateAllWorldOpacity$1, updateAllChange: updateAllChange$1 } = L$3;
4230
4230
  function moveByMatrix(t, matrix) {
4231
4231
  const { e, f } = t.__localMatrix;
4232
4232
  t.x += matrix.e - e;
@@ -4755,6 +4755,7 @@ class RenderEvent extends Event {
4755
4755
  }
4756
4756
  }
4757
4757
  RenderEvent.REQUEST = 'render.request';
4758
+ RenderEvent.CHILD_START = 'render.child_start';
4758
4759
  RenderEvent.START = 'render.start';
4759
4760
  RenderEvent.BEFORE = 'render.before';
4760
4761
  RenderEvent.RENDER = 'render';
@@ -4930,7 +4931,7 @@ const { isFinite } = Number;
4930
4931
  const debug$8 = Debug.get('setAttr');
4931
4932
  const LeafDataProxy = {
4932
4933
  __setAttr(name, newValue, checkFiniteNumber) {
4933
- if (this.leafer && this.leafer.created) {
4934
+ if (this.leaferIsCreated) {
4934
4935
  const oldValue = this.__.__getInput(name);
4935
4936
  if (checkFiniteNumber && !isFinite(newValue) && newValue !== undefined) {
4936
4937
  debug$8.warn(this.innerName, name, newValue);
@@ -5000,9 +5001,9 @@ const LeafMatrix = {
5000
5001
  }
5001
5002
  };
5002
5003
 
5003
- const { updateMatrix: updateMatrix$1, updateAllMatrix: updateAllMatrix$2 } = LeafHelper;
5004
+ const { updateMatrix: updateMatrix$2, updateAllMatrix: updateAllMatrix$2 } = LeafHelper;
5004
5005
  const { updateBounds: updateBounds$1 } = BranchHelper;
5005
- const { toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$2, copy: copy$8 } = BoundsHelper;
5006
+ const { toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$1, copy: copy$8 } = BoundsHelper;
5006
5007
  const { toBounds: toBounds$2 } = PathBounds;
5007
5008
  const LeafBounds = {
5008
5009
  __updateWorldBounds() {
@@ -5085,7 +5086,7 @@ const LeafBounds = {
5085
5086
  const b = this.__layout.boxBounds;
5086
5087
  const data = this.__;
5087
5088
  if (data.__pathInputed) {
5088
- toBounds$2(data.__pathForRender, b);
5089
+ toBounds$2(data.path, b);
5089
5090
  }
5090
5091
  else {
5091
5092
  b.x = 0;
@@ -5097,7 +5098,7 @@ const LeafBounds = {
5097
5098
  __updateAutoLayout() {
5098
5099
  this.__layout.matrixChanged = true;
5099
5100
  if (this.isBranch) {
5100
- if (this.leafer && this.leafer.ready)
5101
+ if (this.leaferIsReady)
5101
5102
  this.leafer.layouter.addExtra(this);
5102
5103
  if (this.__.flow) {
5103
5104
  if (this.__layout.boxChanged)
@@ -5113,7 +5114,7 @@ const LeafBounds = {
5113
5114
  }
5114
5115
  }
5115
5116
  else {
5116
- updateMatrix$1(this);
5117
+ updateMatrix$2(this);
5117
5118
  }
5118
5119
  },
5119
5120
  __updateNaturalSize() {
@@ -5123,11 +5124,11 @@ const LeafBounds = {
5123
5124
  },
5124
5125
  __updateStrokeBounds() {
5125
5126
  const layout = this.__layout;
5126
- copyAndSpread$2(layout.strokeBounds, layout.boxBounds, layout.strokeBoxSpread);
5127
+ copyAndSpread$1(layout.strokeBounds, layout.boxBounds, layout.strokeBoxSpread);
5127
5128
  },
5128
5129
  __updateRenderBounds() {
5129
5130
  const layout = this.__layout;
5130
- layout.renderSpread > 0 ? copyAndSpread$2(layout.renderBounds, layout.boxBounds, layout.renderSpread) : copy$8(layout.renderBounds, layout.strokeBounds);
5131
+ layout.renderSpread > 0 ? copyAndSpread$1(layout.renderBounds, layout.boxBounds, layout.renderSpread) : copy$8(layout.renderBounds, layout.strokeBounds);
5131
5132
  }
5132
5133
  };
5133
5134
 
@@ -5232,6 +5233,8 @@ let Leaf = class Leaf {
5232
5233
  get innerName() { return this.__.name || this.tag + this.innerId; }
5233
5234
  get __DataProcessor() { return LeafData; }
5234
5235
  get __LayoutProcessor() { return LeafLayout; }
5236
+ get leaferIsCreated() { return this.leafer && this.leafer.created; }
5237
+ get leaferIsReady() { return this.leafer && this.leafer.ready; }
5235
5238
  get isLeafer() { return false; }
5236
5239
  get isBranch() { return false; }
5237
5240
  get isBranchLeaf() { return false; }
@@ -5673,6 +5676,7 @@ let Branch = class Branch extends Leaf {
5673
5676
  add(child, index) {
5674
5677
  if (child === this)
5675
5678
  return;
5679
+ child.__ || (child = UICreator.get(child.tag, child));
5676
5680
  if (child.parent)
5677
5681
  child.parent.remove(child);
5678
5682
  child.parent = this;
@@ -5695,10 +5699,14 @@ let Branch = class Branch extends Leaf {
5695
5699
  }
5696
5700
  remove(child, destroy) {
5697
5701
  if (child) {
5698
- if (child.animationOut)
5699
- child.__runAnimation('out', () => this.__remove(child, destroy));
5702
+ if (child.__) {
5703
+ if (child.animationOut)
5704
+ child.__runAnimation('out', () => this.__remove(child, destroy));
5705
+ else
5706
+ this.__remove(child, destroy);
5707
+ }
5700
5708
  else
5701
- this.__remove(child, destroy);
5709
+ this.find(child).forEach(item => this.remove(item, destroy));
5702
5710
  }
5703
5711
  else if (child === undefined) {
5704
5712
  super.remove(null, destroy);
@@ -5916,7 +5924,7 @@ class LeafLevelList {
5916
5924
  }
5917
5925
  }
5918
5926
 
5919
- const version = "1.0.4";
5927
+ const version = "1.0.5";
5920
5928
 
5921
5929
  class LeaferCanvas extends LeaferCanvasBase {
5922
5930
  get allowBackgroundColor() { return true; }
@@ -6102,7 +6110,7 @@ class Watcher {
6102
6110
 
6103
6111
  const { updateAllMatrix: updateAllMatrix$1, updateBounds: updateOneBounds, updateAllWorldOpacity } = LeafHelper;
6104
6112
  const { pushAllChildBranch, pushAllParent } = BranchHelper;
6105
- function updateMatrix(updateList, levelList) {
6113
+ function updateMatrix$1(updateList, levelList) {
6106
6114
  let layout;
6107
6115
  updateList.list.forEach(leaf => {
6108
6116
  layout = leaf.__layout;
@@ -6270,7 +6278,7 @@ class Layouter {
6270
6278
  target.emitEvent(new LayoutEvent(BEFORE, blocks, this.times));
6271
6279
  this.extraBlock = null;
6272
6280
  updateList.sort();
6273
- updateMatrix(updateList, this.__levelList);
6281
+ updateMatrix$1(updateList, this.__levelList);
6274
6282
  updateBounds(this.__levelList);
6275
6283
  updateChange(updateList);
6276
6284
  if (this.extraBlock)
@@ -6385,6 +6393,7 @@ class Renderer {
6385
6393
  this.totalBounds = new Bounds();
6386
6394
  debug$6.log(target.innerName, '--->');
6387
6395
  try {
6396
+ target.app.emit(RenderEvent.CHILD_START, target);
6388
6397
  this.emitRender(RenderEvent.START);
6389
6398
  this.renderOnce(callback);
6390
6399
  this.emitRender(RenderEvent.END, this.totalBounds);
@@ -6682,7 +6691,7 @@ class Picker {
6682
6691
  if (child.isBranch) {
6683
6692
  if (hit || child.__ignoreHitWorld) {
6684
6693
  this.eachFind(child.children, child.__onlyHitMask);
6685
- if (child.isBranchLeaf && !this.findList.length)
6694
+ if (child.isBranchLeaf)
6686
6695
  this.hitChild(child, point);
6687
6696
  }
6688
6697
  }
@@ -7392,12 +7401,7 @@ let UI = UI_1 = class UI extends Leaf {
7392
7401
  this.__drawPathByData(canvas, this.__.path);
7393
7402
  }
7394
7403
  __drawPathByData(drawer, data) {
7395
- if (data) {
7396
- PathDrawer.drawPathByData(drawer, data);
7397
- }
7398
- else {
7399
- this.__drawPathByBox(drawer);
7400
- }
7404
+ data ? PathDrawer.drawPathByData(drawer, data) : this.__drawPathByBox(drawer);
7401
7405
  }
7402
7406
  __drawPathByBox(drawer) {
7403
7407
  const { x, y, width, height } = this.__layout.boxBounds;
@@ -7405,9 +7409,8 @@ let UI = UI_1 = class UI extends Leaf {
7405
7409
  const { cornerRadius } = this.__;
7406
7410
  drawer.roundRect(x, y, width, height, typeof cornerRadius === 'number' ? [cornerRadius] : cornerRadius);
7407
7411
  }
7408
- else {
7412
+ else
7409
7413
  drawer.rect(x, y, width, height);
7410
- }
7411
7414
  }
7412
7415
  animate(_keyframe, _options, _type, _isTemp) {
7413
7416
  return needPlugin('animate');
@@ -8090,10 +8093,9 @@ Rect = __decorate([
8090
8093
  registerUI()
8091
8094
  ], Rect);
8092
8095
 
8093
- const rect$1 = Rect.prototype;
8094
- const group$1 = Group.prototype;
8096
+ const { copy: copy$6, add, includes: includes$1 } = BoundsHelper;
8097
+ const rect$1 = Rect.prototype, group$1 = Group.prototype;
8095
8098
  const childrenRenderBounds = {};
8096
- const { copy: copy$6, add, includes: includes$1, copyAndSpread: copyAndSpread$1 } = BoundsHelper;
8097
8099
  let Box = class Box extends Group {
8098
8100
  get __tag() { return 'Box'; }
8099
8101
  get isBranchLeaf() { return true; }
@@ -8107,29 +8109,27 @@ let Box = class Box extends Group {
8107
8109
  return this.__updateRectRenderSpread() || -1;
8108
8110
  }
8109
8111
  __updateRectBoxBounds() { }
8110
- __updateBoxBounds(secondLayout) {
8112
+ __updateBoxBounds(_secondLayout) {
8111
8113
  const data = this.__;
8112
8114
  if (this.children.length) {
8113
8115
  if (data.__autoSide) {
8114
- if (this.leafer && this.leafer.ready)
8115
- this.leafer.layouter.addExtra(this);
8116
8116
  super.__updateBoxBounds();
8117
8117
  const { boxBounds } = this.__layout;
8118
8118
  if (!data.__autoSize) {
8119
- if (data.__autoWidth)
8120
- boxBounds.width += boxBounds.x, boxBounds.height = data.height, boxBounds.y = boxBounds.x = 0;
8121
- else
8122
- boxBounds.height += boxBounds.y, boxBounds.width = data.width, boxBounds.x = boxBounds.y = 0;
8119
+ if (data.__autoWidth) {
8120
+ boxBounds.width += boxBounds.x, boxBounds.x = 0;
8121
+ boxBounds.height = data.height, boxBounds.y = 0;
8122
+ }
8123
+ else {
8124
+ boxBounds.height += boxBounds.y, boxBounds.y = 0;
8125
+ boxBounds.width = data.width, boxBounds.x = 0;
8126
+ }
8123
8127
  }
8124
- if (secondLayout && data.flow && data.padding)
8125
- copyAndSpread$1(boxBounds, boxBounds, data.padding, false, data.__autoSize ? null : (data.__autoWidth ? 'width' : 'height'));
8126
8128
  this.__updateNaturalSize();
8127
8129
  }
8128
8130
  else {
8129
8131
  this.__updateRectBoxBounds();
8130
8132
  }
8131
- if (data.flow)
8132
- this.__updateContentBounds();
8133
8133
  }
8134
8134
  else {
8135
8135
  this.__updateRectBoxBounds();
@@ -8195,6 +8195,9 @@ __decorate([
8195
8195
  __decorate([
8196
8196
  dataType(false)
8197
8197
  ], Box.prototype, "resizeChildren", void 0);
8198
+ __decorate([
8199
+ dataType(false)
8200
+ ], Box.prototype, "textBox", void 0);
8198
8201
  __decorate([
8199
8202
  affectRenderBoundsType('show')
8200
8203
  ], Box.prototype, "overflow", void 0);
@@ -8724,6 +8727,9 @@ __decorate([
8724
8727
  __decorate([
8725
8728
  boundsType('top')
8726
8729
  ], Text.prototype, "verticalAlign", void 0);
8730
+ __decorate([
8731
+ boundsType(true)
8732
+ ], Text.prototype, "autoSizeAlign", void 0);
8727
8733
  __decorate([
8728
8734
  boundsType('normal')
8729
8735
  ], Text.prototype, "textWrap", void 0);
@@ -9444,9 +9450,10 @@ class Dragger {
9444
9450
  this.dragData = getDragEventData(data, data, data);
9445
9451
  this.canAnimate = this.canDragOut = true;
9446
9452
  }
9447
- getList() {
9453
+ getList(realDraggable, hover) {
9448
9454
  const { proxy } = this.interaction.selector;
9449
- return this.dragging && (!proxy || !proxy.list.length) ? (DragEvent.list || this.dragableList || emptyList) : emptyList;
9455
+ const hasProxyList = proxy && proxy.list.length, dragList = DragEvent.list || this.draggableList || emptyList;
9456
+ return this.dragging && (hasProxyList ? (realDraggable ? emptyList : new LeafList(hover ? [...proxy.list, ...proxy.dragHoverExclude] : proxy.list)) : dragList);
9450
9457
  }
9451
9458
  checkDrag(data, canDrag) {
9452
9459
  const { interaction } = this;
@@ -9471,8 +9478,8 @@ class Dragger {
9471
9478
  this.dragging = canDrag && PointerButton.left(data);
9472
9479
  if (this.dragging) {
9473
9480
  this.interaction.emit(DragEvent.START, this.dragData);
9474
- this.getDragableList(this.dragData.path);
9475
- this.setDragStartPoints(this.realDragableList = this.getList());
9481
+ this.getDraggableList(this.dragData.path);
9482
+ this.setDragStartPoints(this.realDraggableList = this.getList(true));
9476
9483
  }
9477
9484
  }
9478
9485
  }
@@ -9480,12 +9487,12 @@ class Dragger {
9480
9487
  this.dragStartPoints = {};
9481
9488
  list.forEach(leaf => this.dragStartPoints[leaf.innerId] = { x: leaf.x, y: leaf.y });
9482
9489
  }
9483
- getDragableList(path) {
9490
+ getDraggableList(path) {
9484
9491
  let leaf;
9485
9492
  for (let i = 0, len = path.length; i < len; i++) {
9486
9493
  leaf = path.list[i];
9487
- if ((leaf.__.draggable || leaf.__.editable) && leaf.__.hitSelf && !leaf.__.locked) {
9488
- this.dragableList = new LeafList(leaf);
9494
+ if ((leaf.draggable || leaf.editable) && leaf.hitSelf && !leaf.locked) {
9495
+ this.draggableList = new LeafList(leaf);
9489
9496
  break;
9490
9497
  }
9491
9498
  }
@@ -9510,7 +9517,7 @@ class Dragger {
9510
9517
  }
9511
9518
  dragReal() {
9512
9519
  const { running } = this.interaction;
9513
- const list = this.realDragableList;
9520
+ const list = this.realDraggableList;
9514
9521
  if (list.length && running) {
9515
9522
  const { totalX, totalY } = this.dragData;
9516
9523
  list.forEach(leaf => leaf.draggable && leaf.move(DragEvent.getValidMove(leaf, this.dragStartPoints[leaf.innerId], { x: totalX, y: totalY })));
@@ -9599,7 +9606,7 @@ class Dragger {
9599
9606
  this.interaction.emit(DragEvent.LEAVE, data, dragEnterPath);
9600
9607
  }
9601
9608
  dragReset() {
9602
- DragEvent.list = DragEvent.data = this.dragableList = this.dragData = this.downData = this.dragOverPath = this.dragEnterPath = null;
9609
+ DragEvent.list = DragEvent.data = this.draggableList = this.dragData = this.downData = this.dragOverPath = this.dragEnterPath = null;
9603
9610
  }
9604
9611
  checkDragOut(data) {
9605
9612
  const { interaction } = this;
@@ -9740,6 +9747,7 @@ const config$1 = {
9740
9747
  touch: {
9741
9748
  preventDefault: true
9742
9749
  },
9750
+ multiTouch: {},
9743
9751
  cursor: true,
9744
9752
  keyEvent: true
9745
9753
  };
@@ -9866,6 +9874,8 @@ class InteractionBase {
9866
9874
  this.pointerUp(data);
9867
9875
  }
9868
9876
  multiTouch(data, list) {
9877
+ if (this.config.multiTouch.disabled)
9878
+ return;
9869
9879
  const { move, angle, scale, center } = MultiTouchHelper.getData(list);
9870
9880
  this.rotate(getRotateEventData(center, angle, data));
9871
9881
  this.zoom(getZoomEventData(center, scale, data));
@@ -10055,7 +10065,7 @@ class InteractionBase {
10055
10065
  data = this.hoverData;
10056
10066
  if (!data)
10057
10067
  return;
10058
- this.findPath(data, { exclude: this.dragger.getList(), name: PointerEvent.MOVE });
10068
+ this.findPath(data, { exclude: this.dragger.getList(false, true), name: PointerEvent.MOVE });
10059
10069
  this.hoverData = data;
10060
10070
  }
10061
10071
  updateCursor(data) {
@@ -10077,7 +10087,7 @@ class InteractionBase {
10077
10087
  const { path } = data;
10078
10088
  for (let i = 0, len = path.length; i < len; i++) {
10079
10089
  leaf = path.list[i];
10080
- cursor = leaf.syncEventer ? leaf.syncEventer.cursor : leaf.cursor;
10090
+ cursor = (leaf.syncEventer && leaf.syncEventer.cursor) || leaf.cursor;
10081
10091
  if (cursor)
10082
10092
  break;
10083
10093
  }
@@ -10259,7 +10269,7 @@ ui$3.__updateHitCanvas = function () {
10259
10269
  if (isHitPixel) {
10260
10270
  const { renderBounds } = this.__layout;
10261
10271
  const size = Platform.image.hitCanvasSize;
10262
- const scale = h.hitScale = tempBounds$1.set(0, 0, size, size).getFitMatrix(renderBounds, 0.5).a;
10272
+ const scale = h.hitScale = tempBounds$1.set(0, 0, size, size).getFitMatrix(renderBounds).a;
10263
10273
  const { x, y, width, height } = tempBounds$1.set(renderBounds).scale(scale);
10264
10274
  h.resize({ width, height, pixelRatio: 1 });
10265
10275
  h.clear();
@@ -10315,15 +10325,14 @@ ui$3.__hit = function (inner) {
10315
10325
  return hitWidth ? this.__hitStroke(inner, hitWidth) : false;
10316
10326
  };
10317
10327
 
10318
- const ui$2 = new UI();
10319
- const rect = Rect.prototype;
10320
- rect.__updateHitCanvas = function () {
10328
+ const ui$2 = UI.prototype, rect = Rect.prototype, box$1 = Box.prototype;
10329
+ rect.__updateHitCanvas = box$1.__updateHitCanvas = function () {
10321
10330
  if (this.stroke || this.cornerRadius || ((this.fill || this.__.__isCanvas) && this.hitFill === 'pixel') || this.hitStroke === 'all')
10322
10331
  ui$2.__updateHitCanvas.call(this);
10323
10332
  else if (this.__hitCanvas)
10324
10333
  this.__hitCanvas = null;
10325
10334
  };
10326
- rect.__hitFill = function (inner) {
10335
+ rect.__hitFill = box$1.__hitFill = function (inner) {
10327
10336
  return this.__hitCanvas ? ui$2.__hitFill.call(this, inner) : BoundsHelper.hitRadiusPoint(this.__layout.boxBounds, inner);
10328
10337
  };
10329
10338
 
@@ -10662,7 +10671,7 @@ const PaintModule = {
10662
10671
  shape
10663
10672
  };
10664
10673
 
10665
- let origin = {};
10674
+ let origin$1 = {};
10666
10675
  const { get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, scale: scaleHelper, rotate: rotate$2 } = MatrixHelper;
10667
10676
  function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
10668
10677
  const transform = get$3();
@@ -10702,11 +10711,11 @@ function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, al
10702
10711
  }
10703
10712
  }
10704
10713
  }
10705
- origin.x = box.x + x;
10706
- origin.y = box.y + y;
10707
- translate$1(transform, origin.x, origin.y);
10714
+ origin$1.x = box.x + x;
10715
+ origin$1.y = box.y + y;
10716
+ translate$1(transform, origin$1.x, origin$1.y);
10708
10717
  if (scaleX)
10709
- scaleOfOuter$1(transform, origin, scaleX, scaleY);
10718
+ scaleOfOuter$1(transform, origin$1, scaleX, scaleY);
10710
10719
  data.transform = transform;
10711
10720
  }
10712
10721
 
@@ -10822,9 +10831,10 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
10822
10831
  onLoadError(ui, event, image.error);
10823
10832
  }
10824
10833
  else {
10825
- ignoreRender(ui, true);
10826
- if (firstUse)
10834
+ if (firstUse) {
10835
+ ignoreRender(ui, true);
10827
10836
  onLoad(ui, event);
10837
+ }
10828
10838
  leafPaint.loadId = image.load(() => {
10829
10839
  ignoreRender(ui, false);
10830
10840
  if (!ui.destroyed) {
@@ -11436,14 +11446,15 @@ const { trimRight } = TextRowHelper;
11436
11446
  const { Letter, Single, Before, After, Symbol, Break } = CharType;
11437
11447
  let word, row, wordWidth, rowWidth, realWidth;
11438
11448
  let char, charWidth, startCharSize, charSize, charType, lastCharType, langBreak, afterBreak, paraStart;
11439
- let textDrawData, rows = [], bounds;
11449
+ let textDrawData, rows = [], bounds$1, findMaxWidth;
11440
11450
  function createRows(drawData, content, style) {
11441
11451
  textDrawData = drawData;
11442
11452
  rows = drawData.rows;
11443
- bounds = drawData.bounds;
11453
+ bounds$1 = drawData.bounds;
11454
+ findMaxWidth = !bounds$1.width && !style.autoSizeAlign;
11444
11455
  const { __letterSpacing, paraIndent, textCase } = style;
11445
11456
  const { canvas } = Platform;
11446
- const { width, height } = bounds;
11457
+ const { width, height } = bounds$1;
11447
11458
  const charMode = width || height || __letterSpacing || (textCase !== 'none');
11448
11459
  if (charMode) {
11449
11460
  const wrap = style.textWrap !== 'none';
@@ -11525,7 +11536,10 @@ function createRows(drawData, content, style) {
11525
11536
  else {
11526
11537
  content.split('\n').forEach(content => {
11527
11538
  textDrawData.paraNumber++;
11528
- rows.push({ x: paraIndent || 0, text: content, width: canvas.measureText(content).width, paraStart: true });
11539
+ rowWidth = canvas.measureText(content).width;
11540
+ rows.push({ x: paraIndent || 0, text: content, width: rowWidth, paraStart: true });
11541
+ if (findMaxWidth)
11542
+ setMaxWidth();
11529
11543
  });
11530
11544
  }
11531
11545
  }
@@ -11554,12 +11568,18 @@ function addRow() {
11554
11568
  startCharSize = 0;
11555
11569
  }
11556
11570
  row.width = rowWidth;
11557
- if (bounds.width)
11571
+ if (bounds$1.width)
11558
11572
  trimRight(row);
11573
+ else if (findMaxWidth)
11574
+ setMaxWidth();
11559
11575
  rows.push(row);
11560
11576
  row = { words: [] };
11561
11577
  rowWidth = 0;
11562
11578
  }
11579
+ function setMaxWidth() {
11580
+ if (rowWidth > (textDrawData.maxWidth || 0))
11581
+ textDrawData.maxWidth = rowWidth;
11582
+ }
11563
11583
 
11564
11584
  const CharMode = 0;
11565
11585
  const WordMode = 1;
@@ -11631,34 +11651,32 @@ function toChar(data, charX, rowData, isOverflow) {
11631
11651
 
11632
11652
  function layoutText(drawData, style) {
11633
11653
  const { rows, bounds } = drawData;
11634
- const { __lineHeight, __baseLine, __letterSpacing, __clipText, textAlign, verticalAlign, paraSpacing } = style;
11654
+ const { __lineHeight, __baseLine, __letterSpacing, __clipText, textAlign, verticalAlign, paraSpacing, autoSizeAlign } = style;
11635
11655
  let { x, y, width, height } = bounds, realHeight = __lineHeight * rows.length + (paraSpacing ? paraSpacing * (drawData.paraNumber - 1) : 0);
11636
11656
  let starY = __baseLine;
11637
11657
  if (__clipText && realHeight > height) {
11638
11658
  realHeight = Math.max(height, __lineHeight);
11639
11659
  drawData.overflow = rows.length;
11640
11660
  }
11641
- else {
11661
+ else if (height || autoSizeAlign) {
11642
11662
  switch (verticalAlign) {
11643
11663
  case 'middle':
11644
11664
  y += (height - realHeight) / 2;
11645
11665
  break;
11646
- case 'bottom':
11647
- y += (height - realHeight);
11666
+ case 'bottom': y += (height - realHeight);
11648
11667
  }
11649
11668
  }
11650
11669
  starY += y;
11651
- let row, rowX, rowWidth;
11670
+ let row, rowX, rowWidth, layoutWidth = (width || autoSizeAlign) ? width : drawData.maxWidth;
11652
11671
  for (let i = 0, len = rows.length; i < len; i++) {
11653
11672
  row = rows[i];
11654
11673
  row.x = x;
11655
11674
  if (row.width < width || (row.width > width && !__clipText)) {
11656
11675
  switch (textAlign) {
11657
11676
  case 'center':
11658
- row.x += (width - row.width) / 2;
11677
+ row.x += (layoutWidth - row.width) / 2;
11659
11678
  break;
11660
- case 'right':
11661
- row.x += width - row.width;
11679
+ case 'right': row.x += layoutWidth - row.width;
11662
11680
  }
11663
11681
  }
11664
11682
  if (row.paraStart && paraSpacing && i > 0)
@@ -11763,14 +11781,14 @@ function getDrawData(content, style) {
11763
11781
  let height = style.__getInput('height') || 0;
11764
11782
  const { textDecoration, __font, __padding: padding } = style;
11765
11783
  if (padding) {
11766
- if (width) {
11784
+ if (width)
11785
+ x = padding[left$3], width -= (padding[right$3] + padding[left$3]);
11786
+ else if (!style.autoSizeAlign)
11767
11787
  x = padding[left$3];
11768
- width -= (padding[right$3] + padding[left$3]);
11769
- }
11770
- if (height) {
11788
+ if (height)
11789
+ y = padding[top$2], height -= (padding[top$2] + padding[bottom$2]);
11790
+ else if (!style.autoSizeAlign)
11771
11791
  y = padding[top$2];
11772
- height -= (padding[top$2] + padding[bottom$2]);
11773
- }
11774
11792
  }
11775
11793
  const drawData = {
11776
11794
  bounds: { x, y, width, height },
@@ -11790,22 +11808,20 @@ function getDrawData(content, style) {
11790
11808
  return drawData;
11791
11809
  }
11792
11810
  function padAutoText(padding, drawData, style, width, height) {
11793
- if (!width) {
11811
+ if (!width && style.autoSizeAlign) {
11794
11812
  switch (style.textAlign) {
11795
11813
  case 'left':
11796
11814
  offsetText(drawData, 'x', padding[left$3]);
11797
11815
  break;
11798
- case 'right':
11799
- offsetText(drawData, 'x', -padding[right$3]);
11816
+ case 'right': offsetText(drawData, 'x', -padding[right$3]);
11800
11817
  }
11801
11818
  }
11802
- if (!height) {
11819
+ if (!height && style.autoSizeAlign) {
11803
11820
  switch (style.verticalAlign) {
11804
11821
  case 'top':
11805
11822
  offsetText(drawData, 'y', padding[top$2]);
11806
11823
  break;
11807
- case 'bottom':
11808
- offsetText(drawData, 'y', -padding[bottom$2]);
11824
+ case 'bottom': offsetText(drawData, 'y', -padding[bottom$2]);
11809
11825
  }
11810
11826
  }
11811
11827
  }
@@ -12327,31 +12343,29 @@ class Stroker extends UI {
12327
12343
  const { list } = this;
12328
12344
  if (list.length) {
12329
12345
  let leaf;
12330
- const { stroke, strokeWidth, fill } = this.__;
12331
- const { bounds } = options;
12346
+ const data = this.__, { stroke, strokeWidth, fill } = data, { bounds } = options;
12332
12347
  for (let i = 0; i < list.length; i++) {
12333
12348
  leaf = list[i];
12334
- if (bounds && bounds.hit(leaf.__world, options.matrix)) {
12335
- const aScaleX = abs(leaf.__world.scaleX), aScaleY = abs(leaf.__world.scaleY);
12349
+ const { worldTransform, worldRenderBounds } = leaf;
12350
+ if (bounds && bounds.hit(worldRenderBounds, options.matrix)) {
12351
+ const aScaleX = abs(worldTransform.scaleX), aScaleY = abs(worldTransform.scaleY);
12336
12352
  if (aScaleX !== aScaleY) {
12337
- copy$2(matrix, leaf.__world);
12353
+ copy$2(matrix, worldTransform);
12338
12354
  scale$1(matrix, 1 / aScaleX, 1 / aScaleY);
12339
12355
  canvas.setWorld(matrix, options.matrix);
12340
12356
  canvas.beginPath();
12341
- this.__.strokeWidth = strokeWidth;
12357
+ data.strokeWidth = strokeWidth;
12342
12358
  const { x, y, width, height } = leaf.__layout.boxBounds;
12343
12359
  canvas.rect(x * aScaleX, y * aScaleY, width * aScaleX, height * aScaleY);
12344
12360
  }
12345
12361
  else {
12346
- canvas.setWorld(leaf.__world, options.matrix);
12362
+ canvas.setWorld(worldTransform, options.matrix);
12347
12363
  canvas.beginPath();
12348
- if (leaf.__.__useArrow) {
12364
+ if (leaf.__.__useArrow)
12349
12365
  leaf.__drawPath(canvas);
12350
- }
12351
- else {
12366
+ else
12352
12367
  leaf.__.__pathForRender ? leaf.__drawRenderPath(canvas) : leaf.__drawPathByBox(canvas);
12353
- }
12354
- this.__.strokeWidth = strokeWidth / abs(leaf.__world.scaleX);
12368
+ data.strokeWidth = strokeWidth / abs(worldTransform.scaleX);
12355
12369
  }
12356
12370
  if (stroke)
12357
12371
  typeof stroke === 'string' ? Paint.stroke(stroke, this, canvas) : Paint.strokes(stroke, this, canvas);
@@ -12359,7 +12373,7 @@ class Stroker extends UI {
12359
12373
  typeof fill === 'string' ? Paint.fill(fill, this, canvas) : Paint.fills(fill, this, canvas);
12360
12374
  }
12361
12375
  }
12362
- this.__.strokeWidth = strokeWidth;
12376
+ data.strokeWidth = strokeWidth;
12363
12377
  }
12364
12378
  }
12365
12379
  destroy() {
@@ -12910,7 +12924,6 @@ class EditBox extends Group {
12910
12924
  this.editor = editor;
12911
12925
  this.visible = false;
12912
12926
  this.create();
12913
- this.rect.syncEventer = editor;
12914
12927
  this.__listenEvents();
12915
12928
  }
12916
12929
  create() {
@@ -12950,8 +12963,11 @@ class EditBox extends Group {
12950
12963
  circle.set(this.getPointStyle(mergeConfig.circle || mergeConfig.rotatePoint || pointsStyle[0]));
12951
12964
  rect.set(Object.assign({ stroke, strokeWidth }, (mergeConfig.rect || {})));
12952
12965
  rect.hittable = !single && !!moveable;
12953
- element.syncEventer = (single && moveable) ? rect : null;
12954
- this.app.interaction.bottomList = (single && moveable) ? [{ target: rect, proxy: element }] : null;
12966
+ rect.syncEventer = single && this.editor;
12967
+ if (single && moveable) {
12968
+ element.syncEventer = rect;
12969
+ this.app.interaction.bottomList = [{ target: rect, proxy: element }];
12970
+ }
12955
12971
  }
12956
12972
  update(bounds) {
12957
12973
  this.visible = !this.editor.element.locked;
@@ -13123,6 +13139,11 @@ class EditBox extends Group {
13123
13139
  if (editor.single) {
13124
13140
  const { element } = editor;
13125
13141
  if (element.isBranch) {
13142
+ if (element.textBox) {
13143
+ const find = element.children.find(item => item.editable && item instanceof Text);
13144
+ if (find)
13145
+ return editor.openInnerEditor(find);
13146
+ }
13126
13147
  editor.openGroup(element);
13127
13148
  editor.target = editor.selector.findDeepOne(e);
13128
13149
  }
@@ -13268,12 +13289,12 @@ const config = {
13268
13289
  skewable: true
13269
13290
  };
13270
13291
 
13292
+ const bounds = new Bounds();
13271
13293
  function simulate(editor) {
13272
- const { simulateTarget, leafList: targetList } = editor;
13273
- const { x, y, width, height } = new Bounds().setListWithFn(targetList.list, (leaf) => leaf.worldBoxBounds);
13274
- const parent = simulateTarget.parent = targetList.list[0].leafer.zoomLayer;
13275
- const { scaleX, scaleY, e: worldX, f: worldY } = parent.__world;
13276
- simulateTarget.reset({ x: (x - worldX) / scaleX, y: (y - worldY) / scaleY, width: width / scaleX, height: height / scaleY });
13294
+ const { simulateTarget, list } = editor;
13295
+ const { zoomLayer } = list[0].leafer.zoomLayer;
13296
+ simulateTarget.safeChange(() => simulateTarget.reset(bounds.setListWithFn(list, (leaf) => leaf.getBounds('box', 'page')).get()));
13297
+ zoomLayer.add(simulateTarget);
13277
13298
  }
13278
13299
 
13279
13300
  function onTarget(editor, oldValue) {
@@ -13282,6 +13303,7 @@ function onTarget(editor, oldValue) {
13282
13303
  editor.leafList = target instanceof LeafList ? target : new LeafList(target instanceof Array ? target : target);
13283
13304
  }
13284
13305
  else {
13306
+ editor.simulateTarget.remove();
13285
13307
  editor.leafList.reset();
13286
13308
  editor.closeInnerEditor();
13287
13309
  }
@@ -13336,7 +13358,7 @@ const EditorHelper = {
13336
13358
  const ungroupList = [];
13337
13359
  app.lockLayout();
13338
13360
  list.forEach(leaf => {
13339
- if (leaf.isBranch) {
13361
+ if (leaf.isBranch && !leaf.isBranchLeaf) {
13340
13362
  const { parent, children } = leaf;
13341
13363
  while (children.length) {
13342
13364
  ungroupList.push(children[0]);
@@ -13407,17 +13429,77 @@ EditorGroupEvent.UNGROUP = 'editor.ungroup';
13407
13429
  EditorGroupEvent.OPEN = 'editor.open_group';
13408
13430
  EditorGroupEvent.CLOSE = 'editor.close_group';
13409
13431
 
13432
+ const { updateMatrix } = LeafHelper;
13433
+ const checkMap = { x: 1, y: 1, scaleX: 1, scaleY: 1, rotation: 1, skewX: 1, skewY: 1 }, origin = 'top-left';
13434
+ class SimulateElement extends Rect {
13435
+ get __tag() { return 'SimulateElement'; }
13436
+ constructor(editor) {
13437
+ super();
13438
+ this.checkChange = true;
13439
+ this.canChange = true;
13440
+ this.visible = this.hittable = false;
13441
+ this.on(PropertyEvent.CHANGE, (event) => {
13442
+ if (this.checkChange && checkMap[event.attrName]) {
13443
+ const { attrName, newValue, oldValue } = event;
13444
+ const addValue = attrName[0] === 's' ? (newValue || 1) / (oldValue || 1) : (newValue || 0) - (oldValue || 0);
13445
+ this.canChange = false;
13446
+ const data = this.__;
13447
+ data[attrName] = oldValue;
13448
+ updateMatrix(this.parent);
13449
+ updateMatrix(this);
13450
+ const oldMatrix = new Matrix(this.__world);
13451
+ data[attrName] = newValue;
13452
+ this.__layout.rotationChange();
13453
+ updateMatrix(this);
13454
+ this.changedTransform = new Matrix(this.__world).divide(oldMatrix);
13455
+ switch (attrName) {
13456
+ case 'x':
13457
+ editor.move(addValue, 0);
13458
+ break;
13459
+ case 'y':
13460
+ editor.move(0, addValue);
13461
+ break;
13462
+ case 'rotation':
13463
+ editor.rotateOf(origin, addValue);
13464
+ break;
13465
+ case 'scaleX':
13466
+ editor.scaleOf(origin, addValue, 1);
13467
+ break;
13468
+ case 'scaleY':
13469
+ editor.scaleOf(origin, 1, addValue);
13470
+ break;
13471
+ case 'skewX':
13472
+ editor.skewOf(origin, addValue, 0);
13473
+ break;
13474
+ case 'skewY':
13475
+ editor.skewOf(origin, 0, addValue);
13476
+ }
13477
+ this.canChange = true;
13478
+ }
13479
+ });
13480
+ }
13481
+ safeChange(changeFn) {
13482
+ if (this.canChange) {
13483
+ this.checkChange = false;
13484
+ changeFn();
13485
+ this.checkChange = true;
13486
+ }
13487
+ }
13488
+ }
13489
+
13410
13490
  class Editor extends Group {
13411
13491
  get mergeConfig() {
13412
13492
  const { element, config } = this;
13413
13493
  return this.single && element.editConfig ? Object.assign(Object.assign({}, config), element.editConfig) : config;
13414
13494
  }
13415
13495
  get list() { return this.leafList.list; }
13496
+ get dragHoverExclude() { return [this.editBox.rect]; }
13416
13497
  get editing() { return !!this.list.length; }
13417
13498
  get groupOpening() { return !!this.openedGroupList.length; }
13418
13499
  get multiple() { return this.list.length > 1; }
13419
13500
  get single() { return this.list.length === 1; }
13420
13501
  get dragging() { return this.editBox.dragging; }
13502
+ get moving() { return this.editBox.moving; }
13421
13503
  get element() { return this.multiple ? this.simulateTarget : this.list[0]; }
13422
13504
  get buttons() { return this.editBox.buttons; }
13423
13505
  constructor(userConfig, data) {
@@ -13425,7 +13507,7 @@ class Editor extends Group {
13425
13507
  this.config = DataHelper.clone(config);
13426
13508
  this.leafList = new LeafList();
13427
13509
  this.openedGroupList = new LeafList();
13428
- this.simulateTarget = new Rect({ visible: false });
13510
+ this.simulateTarget = new SimulateElement(this);
13429
13511
  this.editBox = new EditBox(this);
13430
13512
  this.editToolList = {};
13431
13513
  this.selector = new EditSelect(this);
@@ -13563,18 +13645,18 @@ class Editor extends Group {
13563
13645
  this.skewOf(origin, skewX, skewY);
13564
13646
  }
13565
13647
  move(x, y = 0) {
13566
- if (!this.mergeConfig.moveable || this.element.locked)
13648
+ if (!this.checkTransform('moveable'))
13567
13649
  return;
13568
13650
  const { element } = this;
13569
13651
  const world = element.getWorldPointByLocal(typeof x === 'object' ? Object.assign({}, x) : { x, y }, null, true);
13652
+ if (this.multiple)
13653
+ element.safeChange(() => element.move(x, y));
13570
13654
  const event = new EditorMoveEvent(EditorMoveEvent.MOVE, { target: element, editor: this, moveX: world.x, moveY: world.y });
13571
13655
  this.editTool.onMove(event);
13572
13656
  this.emitEvent(event);
13573
- if (this.multiple)
13574
- element.move(x, y);
13575
13657
  }
13576
13658
  scaleWithDrag(data) {
13577
- if (!this.mergeConfig.resizeable || this.element.locked)
13659
+ if (!this.checkTransform('resizeable'))
13578
13660
  return;
13579
13661
  const { element } = this;
13580
13662
  const event = new EditorScaleEvent(EditorScaleEvent.SCALE, Object.assign(Object.assign({}, data), { target: element, editor: this, worldOrigin: element.getWorldPoint(data.origin) }));
@@ -13582,50 +13664,53 @@ class Editor extends Group {
13582
13664
  this.emitEvent(event);
13583
13665
  }
13584
13666
  scaleOf(origin, scaleX, scaleY = scaleX, _resize) {
13585
- if (!this.mergeConfig.resizeable || this.element.locked)
13667
+ if (!this.checkTransform('resizeable'))
13586
13668
  return;
13587
13669
  const { element } = this;
13588
13670
  const worldOrigin = this.getWorldOrigin(origin);
13589
- const transform = this.multiple && this.getChangedTransform(() => element.scaleOf(origin, scaleX, scaleY));
13671
+ const transform = this.multiple && this.getChangedTransform(() => element.safeChange(() => element.scaleOf(origin, scaleX, scaleY)));
13590
13672
  const event = new EditorScaleEvent(EditorScaleEvent.SCALE, { target: element, editor: this, worldOrigin, scaleX, scaleY, transform });
13591
13673
  this.editTool.onScale(event);
13592
13674
  this.emitEvent(event);
13593
13675
  }
13594
13676
  flip(axis) {
13595
- if (this.element.locked)
13677
+ if (!this.checkTransform('resizeable'))
13596
13678
  return;
13597
13679
  const { element } = this;
13598
13680
  const worldOrigin = this.getWorldOrigin('center');
13599
- const transform = this.multiple ? this.getChangedTransform(() => element.flip(axis)) : new Matrix(LeafHelper.getFlipTransform(element, axis));
13681
+ const transform = this.multiple ? this.getChangedTransform(() => element.safeChange(() => element.flip(axis))) : new Matrix(LeafHelper.getFlipTransform(element, axis));
13600
13682
  const event = new EditorScaleEvent(EditorScaleEvent.SCALE, { target: element, editor: this, worldOrigin, scaleX: axis === 'x' ? -1 : 1, scaleY: axis === 'y' ? -1 : 1, transform });
13601
13683
  this.editTool.onScale(event);
13602
13684
  this.emitEvent(event);
13603
13685
  }
13604
13686
  rotateOf(origin, rotation) {
13605
- if (!this.mergeConfig.rotateable || this.element.locked)
13687
+ if (!this.checkTransform('rotateable'))
13606
13688
  return;
13607
13689
  const { element } = this;
13608
13690
  const worldOrigin = this.getWorldOrigin(origin);
13609
- const transform = this.multiple && this.getChangedTransform(() => element.rotateOf(origin, rotation));
13691
+ const transform = this.multiple && this.getChangedTransform(() => element.safeChange(() => element.rotateOf(origin, rotation)));
13610
13692
  const event = new EditorRotateEvent(EditorRotateEvent.ROTATE, { target: element, editor: this, worldOrigin, rotation, transform });
13611
13693
  this.editTool.onRotate(event);
13612
13694
  this.emitEvent(event);
13613
13695
  }
13614
13696
  skewOf(origin, skewX, skewY = 0, _resize) {
13615
- if (!this.mergeConfig.skewable || this.element.locked)
13697
+ if (!this.checkTransform('skewable'))
13616
13698
  return;
13617
13699
  const { element } = this;
13618
13700
  const worldOrigin = this.getWorldOrigin(origin);
13619
- const transform = this.multiple && this.getChangedTransform(() => element.skewOf(origin, skewX, skewY));
13701
+ const transform = this.multiple && this.getChangedTransform(() => element.safeChange(() => element.skewOf(origin, skewX, skewY)));
13620
13702
  const event = new EditorSkewEvent(EditorSkewEvent.SKEW, { target: element, editor: this, worldOrigin, skewX, skewY, transform });
13621
13703
  this.editTool.onSkew(event);
13622
13704
  this.emitEvent(event);
13623
13705
  }
13706
+ checkTransform(type) { return this.element && !this.element.locked && this.mergeConfig[type]; }
13624
13707
  getWorldOrigin(origin) {
13625
13708
  return this.element.getWorldPoint(LeafHelper.getInnerOrigin(this.element, origin));
13626
13709
  }
13627
13710
  getChangedTransform(func) {
13628
13711
  const { element } = this;
13712
+ if (this.multiple && !element.canChange)
13713
+ return element.changedTransform;
13629
13714
  const oldMatrix = new Matrix(element.worldTransform);
13630
13715
  func();
13631
13716
  return new Matrix(element.worldTransform).divide(oldMatrix);
@@ -13682,11 +13767,11 @@ class Editor extends Group {
13682
13767
  this.emitEvent(event);
13683
13768
  group.emitEvent(event);
13684
13769
  }
13685
- openInnerEditor(target) {
13686
- if (target)
13770
+ openInnerEditor(target, select) {
13771
+ if (target && select)
13687
13772
  this.target = target;
13688
13773
  if (this.single) {
13689
- const editTarget = this.element;
13774
+ const editTarget = target || this.element;
13690
13775
  const tag = editTarget.editInner;
13691
13776
  if (tag && EditToolCreator.list[tag]) {
13692
13777
  this.editTool.unload();
@@ -13738,14 +13823,15 @@ class Editor extends Group {
13738
13823
  }
13739
13824
  listenTargetEvents() {
13740
13825
  if (!this.targetEventIds.length) {
13741
- const { leafer } = this.list[0];
13826
+ const { app, leafer } = this;
13742
13827
  this.targetEventIds = [
13743
- this.app.on_(MoveEvent.BEFORE_MOVE, this.onMove, this, true),
13744
- this.app.on_(ZoomEvent.BEFORE_ZOOM, this.onScale, this, true),
13745
- this.app.on_(RotateEvent.BEFORE_ROTATE, this.onRotate, this, true),
13746
13828
  leafer.on_(RenderEvent.START, this.update, this),
13747
- leafer.on_([KeyEvent.HOLD, KeyEvent.UP], (e) => { updateCursor(this, e); }),
13748
- leafer.on_(KeyEvent.DOWN, this.editBox.onArrow, this.editBox)
13829
+ app.on_(RenderEvent.CHILD_START, this.forceRender, this),
13830
+ app.on_(MoveEvent.BEFORE_MOVE, this.onMove, this, true),
13831
+ app.on_(ZoomEvent.BEFORE_ZOOM, this.onScale, this, true),
13832
+ app.on_(RotateEvent.BEFORE_ROTATE, this.onRotate, this, true),
13833
+ app.on_([KeyEvent.HOLD, KeyEvent.UP], (e) => { updateCursor(this, e); }),
13834
+ app.on_(KeyEvent.DOWN, this.editBox.onArrow, this.editBox)
13749
13835
  ];
13750
13836
  }
13751
13837
  }
@@ -13878,10 +13964,7 @@ let EditTool = class EditTool extends InnerEditor {
13878
13964
  }
13879
13965
  update() {
13880
13966
  const { editor, editBox } = this;
13881
- const { simulateTarget, element } = editor;
13882
- if (editor.multiple)
13883
- simulateTarget.parent.updateLayout();
13884
- const { x, y, scaleX, scaleY, rotation, skewX, skewY, width, height } = element.getLayoutBounds('box', editor, true);
13967
+ const { x, y, scaleX, scaleY, rotation, skewX, skewY, width, height } = editor.element.getLayoutBounds('box', editor, true);
13885
13968
  editBox.set({ x, y, scaleX, scaleY, rotation, skewX, skewY });
13886
13969
  editBox.update({ x: 0, y: 0, width, height });
13887
13970
  this.onUpdate();
@@ -14570,18 +14653,7 @@ let TextEditor = class TextEditor extends InnerEditor {
14570
14653
  style.position = 'fixed';
14571
14654
  style.transformOrigin = 'left top';
14572
14655
  style.boxSizing = 'border-box';
14573
- if (this.isHTMLText) {
14574
- div.innerHTML = text.text;
14575
- this.textScale = 1;
14576
- }
14577
- else {
14578
- div.innerText = text.text;
14579
- const { scaleX, scaleY } = text.worldTransform;
14580
- this.textScale = Math.max(Math.abs(scaleX), Math.abs(scaleY));
14581
- const fontSize = text.fontSize * this.textScale;
14582
- if (fontSize < 12)
14583
- this.textScale *= 12 / fontSize;
14584
- }
14656
+ this.isHTMLText ? div.innerHTML = text.text : div.innerText = text.text;
14585
14657
  const { view } = editor.app;
14586
14658
  (this.inBody = view instanceof HTMLCanvasElement) ? document.body.appendChild(div) : view.appendChild(div);
14587
14659
  this.eventIds = [
@@ -14630,16 +14702,46 @@ let TextEditor = class TextEditor extends InnerEditor {
14630
14702
  this.editor.closeInnerEditor();
14631
14703
  }
14632
14704
  onUpdate() {
14633
- const { editTarget: text, textScale } = this;
14634
- const { style } = this.editDom;
14635
- const { x, y } = this.inBody ? text.app.clientBounds : text.app.tree.clientBounds;
14705
+ const { editTarget: text } = this;
14706
+ let textScale = 1;
14707
+ if (!this.isHTMLText) {
14708
+ const { scaleX, scaleY } = text.worldTransform;
14709
+ textScale = Math.max(Math.abs(scaleX), Math.abs(scaleY));
14710
+ const fontSize = text.fontSize * textScale;
14711
+ if (fontSize < 12)
14712
+ textScale *= 12 / text.fontSize;
14713
+ }
14714
+ this.textScale = textScale;
14636
14715
  const { a, b, c, d, e, f } = new Matrix(text.worldTransform).scale(1 / textScale);
14716
+ let { x, y } = this.inBody ? text.app.clientBounds : text.app.tree.clientBounds;
14717
+ let { width, height } = text;
14718
+ x -= window.scrollX, y -= window.scrollY, width *= textScale, height *= textScale;
14719
+ const data = text.__;
14720
+ if (data.__autoWidth && data.autoSizeAlign) {
14721
+ width += 20;
14722
+ switch (data.textAlign) {
14723
+ case 'center':
14724
+ x -= width / 2;
14725
+ break;
14726
+ case 'right': x -= width;
14727
+ }
14728
+ }
14729
+ if (data.__autoHeight && data.autoSizeAlign) {
14730
+ height += 20;
14731
+ switch (data.verticalAlign) {
14732
+ case 'middle':
14733
+ y -= height / 2;
14734
+ break;
14735
+ case 'bottom': y -= height;
14736
+ }
14737
+ }
14738
+ const { style } = this.editDom;
14637
14739
  style.transform = `matrix(${a},${b},${c},${d},${e},${f})`;
14638
- style.left = x - window.scrollX + 'px';
14639
- style.top = y - window.scrollY + 'px';
14640
- style.width = text.width * textScale + (text.__.__autoWidth ? 20 : 0) + 'px';
14641
- style.height = text.height * textScale + (text.__.__autoHeight ? 20 : 0) + 'px';
14642
- this.isHTMLText || updateStyle(this.editDom, text, this.textScale);
14740
+ style.left = x + 'px';
14741
+ style.top = y + 'px';
14742
+ style.width = width + 'px';
14743
+ style.height = height + 'px';
14744
+ this.isHTMLText || updateStyle(this.editDom, text, textScale);
14643
14745
  }
14644
14746
  onUnload() {
14645
14747
  const { editTarget: text, editor, editDom: dom } = this;