@leafer-editor/worker 1.0.3 → 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;
@@ -4486,15 +4486,16 @@ var LeaferUI = (function (exports) {
4486
4486
  }
4487
4487
  getLayoutBounds(type, relative = 'world', unscale) {
4488
4488
  const { leaf } = this;
4489
- let point, matrix, bounds = this.getInnerBounds(type);
4489
+ let point, matrix, layoutBounds, bounds = this.getInnerBounds(type);
4490
4490
  switch (relative) {
4491
4491
  case 'world':
4492
4492
  point = leaf.getWorldPoint(bounds);
4493
4493
  matrix = leaf.__world;
4494
4494
  break;
4495
4495
  case 'local':
4496
+ const { scaleX, scaleY, rotation, skewX, skewY } = leaf.__;
4497
+ layoutBounds = { scaleX, scaleY, rotation, skewX, skewY };
4496
4498
  point = leaf.getLocalPointByInner(bounds);
4497
- matrix = leaf.__localMatrix;
4498
4499
  break;
4499
4500
  case 'inner':
4500
4501
  point = bounds;
@@ -4506,7 +4507,8 @@ var LeaferUI = (function (exports) {
4506
4507
  point = leaf.getWorldPoint(bounds, relative);
4507
4508
  matrix = getRelativeWorld$1(leaf, relative, true);
4508
4509
  }
4509
- const layoutBounds = MatrixHelper.getLayout(matrix);
4510
+ if (!layoutBounds)
4511
+ layoutBounds = MatrixHelper.getLayout(matrix);
4510
4512
  copy$9(layoutBounds, bounds);
4511
4513
  PointHelper.copy(layoutBounds, point);
4512
4514
  if (unscale) {
@@ -4756,6 +4758,7 @@ var LeaferUI = (function (exports) {
4756
4758
  }
4757
4759
  }
4758
4760
  RenderEvent.REQUEST = 'render.request';
4761
+ RenderEvent.CHILD_START = 'render.child_start';
4759
4762
  RenderEvent.START = 'render.start';
4760
4763
  RenderEvent.BEFORE = 'render.before';
4761
4764
  RenderEvent.RENDER = 'render';
@@ -4931,7 +4934,7 @@ var LeaferUI = (function (exports) {
4931
4934
  const debug$8 = Debug.get('setAttr');
4932
4935
  const LeafDataProxy = {
4933
4936
  __setAttr(name, newValue, checkFiniteNumber) {
4934
- if (this.leafer && this.leafer.created) {
4937
+ if (this.leaferIsCreated) {
4935
4938
  const oldValue = this.__.__getInput(name);
4936
4939
  if (checkFiniteNumber && !isFinite(newValue) && newValue !== undefined) {
4937
4940
  debug$8.warn(this.innerName, name, newValue);
@@ -5001,9 +5004,9 @@ var LeaferUI = (function (exports) {
5001
5004
  }
5002
5005
  };
5003
5006
 
5004
- const { updateMatrix: updateMatrix$1, updateAllMatrix: updateAllMatrix$2 } = LeafHelper;
5007
+ const { updateMatrix: updateMatrix$2, updateAllMatrix: updateAllMatrix$2 } = LeafHelper;
5005
5008
  const { updateBounds: updateBounds$1 } = BranchHelper;
5006
- const { toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$2, copy: copy$8 } = BoundsHelper;
5009
+ const { toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$1, copy: copy$8 } = BoundsHelper;
5007
5010
  const { toBounds: toBounds$2 } = PathBounds;
5008
5011
  const LeafBounds = {
5009
5012
  __updateWorldBounds() {
@@ -5086,7 +5089,7 @@ var LeaferUI = (function (exports) {
5086
5089
  const b = this.__layout.boxBounds;
5087
5090
  const data = this.__;
5088
5091
  if (data.__pathInputed) {
5089
- toBounds$2(data.__pathForRender, b);
5092
+ toBounds$2(data.path, b);
5090
5093
  }
5091
5094
  else {
5092
5095
  b.x = 0;
@@ -5098,7 +5101,7 @@ var LeaferUI = (function (exports) {
5098
5101
  __updateAutoLayout() {
5099
5102
  this.__layout.matrixChanged = true;
5100
5103
  if (this.isBranch) {
5101
- if (this.leafer && this.leafer.ready)
5104
+ if (this.leaferIsReady)
5102
5105
  this.leafer.layouter.addExtra(this);
5103
5106
  if (this.__.flow) {
5104
5107
  if (this.__layout.boxChanged)
@@ -5114,7 +5117,7 @@ var LeaferUI = (function (exports) {
5114
5117
  }
5115
5118
  }
5116
5119
  else {
5117
- updateMatrix$1(this);
5120
+ updateMatrix$2(this);
5118
5121
  }
5119
5122
  },
5120
5123
  __updateNaturalSize() {
@@ -5124,11 +5127,11 @@ var LeaferUI = (function (exports) {
5124
5127
  },
5125
5128
  __updateStrokeBounds() {
5126
5129
  const layout = this.__layout;
5127
- copyAndSpread$2(layout.strokeBounds, layout.boxBounds, layout.strokeBoxSpread);
5130
+ copyAndSpread$1(layout.strokeBounds, layout.boxBounds, layout.strokeBoxSpread);
5128
5131
  },
5129
5132
  __updateRenderBounds() {
5130
5133
  const layout = this.__layout;
5131
- 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);
5132
5135
  }
5133
5136
  };
5134
5137
 
@@ -5233,6 +5236,8 @@ var LeaferUI = (function (exports) {
5233
5236
  get innerName() { return this.__.name || this.tag + this.innerId; }
5234
5237
  get __DataProcessor() { return LeafData; }
5235
5238
  get __LayoutProcessor() { return LeafLayout; }
5239
+ get leaferIsCreated() { return this.leafer && this.leafer.created; }
5240
+ get leaferIsReady() { return this.leafer && this.leafer.ready; }
5236
5241
  get isLeafer() { return false; }
5237
5242
  get isBranch() { return false; }
5238
5243
  get isBranchLeaf() { return false; }
@@ -5674,6 +5679,7 @@ var LeaferUI = (function (exports) {
5674
5679
  add(child, index) {
5675
5680
  if (child === this)
5676
5681
  return;
5682
+ child.__ || (child = UICreator.get(child.tag, child));
5677
5683
  if (child.parent)
5678
5684
  child.parent.remove(child);
5679
5685
  child.parent = this;
@@ -5696,10 +5702,14 @@ var LeaferUI = (function (exports) {
5696
5702
  }
5697
5703
  remove(child, destroy) {
5698
5704
  if (child) {
5699
- if (child.animationOut)
5700
- 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
+ }
5701
5711
  else
5702
- this.__remove(child, destroy);
5712
+ this.find(child).forEach(item => this.remove(item, destroy));
5703
5713
  }
5704
5714
  else if (child === undefined) {
5705
5715
  super.remove(null, destroy);
@@ -5917,7 +5927,7 @@ var LeaferUI = (function (exports) {
5917
5927
  }
5918
5928
  }
5919
5929
 
5920
- const version = "1.0.3";
5930
+ const version = "1.0.5";
5921
5931
 
5922
5932
  class LeaferCanvas extends LeaferCanvasBase {
5923
5933
  get allowBackgroundColor() { return true; }
@@ -6103,7 +6113,7 @@ var LeaferUI = (function (exports) {
6103
6113
 
6104
6114
  const { updateAllMatrix: updateAllMatrix$1, updateBounds: updateOneBounds, updateAllWorldOpacity } = LeafHelper;
6105
6115
  const { pushAllChildBranch, pushAllParent } = BranchHelper;
6106
- function updateMatrix(updateList, levelList) {
6116
+ function updateMatrix$1(updateList, levelList) {
6107
6117
  let layout;
6108
6118
  updateList.list.forEach(leaf => {
6109
6119
  layout = leaf.__layout;
@@ -6271,7 +6281,7 @@ var LeaferUI = (function (exports) {
6271
6281
  target.emitEvent(new LayoutEvent(BEFORE, blocks, this.times));
6272
6282
  this.extraBlock = null;
6273
6283
  updateList.sort();
6274
- updateMatrix(updateList, this.__levelList);
6284
+ updateMatrix$1(updateList, this.__levelList);
6275
6285
  updateBounds(this.__levelList);
6276
6286
  updateChange(updateList);
6277
6287
  if (this.extraBlock)
@@ -6386,6 +6396,7 @@ var LeaferUI = (function (exports) {
6386
6396
  this.totalBounds = new Bounds();
6387
6397
  debug$6.log(target.innerName, '--->');
6388
6398
  try {
6399
+ target.app.emit(RenderEvent.CHILD_START, target);
6389
6400
  this.emitRender(RenderEvent.START);
6390
6401
  this.renderOnce(callback);
6391
6402
  this.emitRender(RenderEvent.END, this.totalBounds);
@@ -6683,7 +6694,7 @@ var LeaferUI = (function (exports) {
6683
6694
  if (child.isBranch) {
6684
6695
  if (hit || child.__ignoreHitWorld) {
6685
6696
  this.eachFind(child.children, child.__onlyHitMask);
6686
- if (child.isBranchLeaf && !this.findList.length)
6697
+ if (child.isBranchLeaf)
6687
6698
  this.hitChild(child, point);
6688
6699
  }
6689
6700
  }
@@ -7393,12 +7404,7 @@ var LeaferUI = (function (exports) {
7393
7404
  this.__drawPathByData(canvas, this.__.path);
7394
7405
  }
7395
7406
  __drawPathByData(drawer, data) {
7396
- if (data) {
7397
- PathDrawer.drawPathByData(drawer, data);
7398
- }
7399
- else {
7400
- this.__drawPathByBox(drawer);
7401
- }
7407
+ data ? PathDrawer.drawPathByData(drawer, data) : this.__drawPathByBox(drawer);
7402
7408
  }
7403
7409
  __drawPathByBox(drawer) {
7404
7410
  const { x, y, width, height } = this.__layout.boxBounds;
@@ -7406,9 +7412,8 @@ var LeaferUI = (function (exports) {
7406
7412
  const { cornerRadius } = this.__;
7407
7413
  drawer.roundRect(x, y, width, height, typeof cornerRadius === 'number' ? [cornerRadius] : cornerRadius);
7408
7414
  }
7409
- else {
7415
+ else
7410
7416
  drawer.rect(x, y, width, height);
7411
- }
7412
7417
  }
7413
7418
  animate(_keyframe, _options, _type, _isTemp) {
7414
7419
  return needPlugin('animate');
@@ -7417,10 +7422,10 @@ var LeaferUI = (function (exports) {
7417
7422
  export(filename, options) {
7418
7423
  return Export.export(this, filename, options);
7419
7424
  }
7420
- clone(newData) {
7425
+ clone(data) {
7421
7426
  const json = this.toJSON();
7422
- if (newData)
7423
- Object.assign(json, newData);
7427
+ if (data)
7428
+ Object.assign(json, data);
7424
7429
  return UI_1.one(json);
7425
7430
  }
7426
7431
  static one(data, x, y, width, height) {
@@ -8091,10 +8096,9 @@ var LeaferUI = (function (exports) {
8091
8096
  registerUI()
8092
8097
  ], exports.Rect);
8093
8098
 
8094
- const rect$1 = exports.Rect.prototype;
8095
- 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;
8096
8101
  const childrenRenderBounds = {};
8097
- const { copy: copy$6, add, includes: includes$1, copyAndSpread: copyAndSpread$1 } = BoundsHelper;
8098
8102
  exports.Box = class Box extends exports.Group {
8099
8103
  get __tag() { return 'Box'; }
8100
8104
  get isBranchLeaf() { return true; }
@@ -8108,29 +8112,27 @@ var LeaferUI = (function (exports) {
8108
8112
  return this.__updateRectRenderSpread() || -1;
8109
8113
  }
8110
8114
  __updateRectBoxBounds() { }
8111
- __updateBoxBounds(secondLayout) {
8115
+ __updateBoxBounds(_secondLayout) {
8112
8116
  const data = this.__;
8113
8117
  if (this.children.length) {
8114
8118
  if (data.__autoSide) {
8115
- if (this.leafer && this.leafer.ready)
8116
- this.leafer.layouter.addExtra(this);
8117
8119
  super.__updateBoxBounds();
8118
8120
  const { boxBounds } = this.__layout;
8119
8121
  if (!data.__autoSize) {
8120
- if (data.__autoWidth)
8121
- boxBounds.width += boxBounds.x, boxBounds.height = data.height, boxBounds.y = boxBounds.x = 0;
8122
- else
8123
- 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
+ }
8124
8130
  }
8125
- if (secondLayout && data.flow && data.padding)
8126
- copyAndSpread$1(boxBounds, boxBounds, data.padding, false, data.__autoSize ? null : (data.__autoWidth ? 'width' : 'height'));
8127
8131
  this.__updateNaturalSize();
8128
8132
  }
8129
8133
  else {
8130
8134
  this.__updateRectBoxBounds();
8131
8135
  }
8132
- if (data.flow)
8133
- this.__updateContentBounds();
8134
8136
  }
8135
8137
  else {
8136
8138
  this.__updateRectBoxBounds();
@@ -8196,6 +8198,9 @@ var LeaferUI = (function (exports) {
8196
8198
  __decorate([
8197
8199
  dataType(false)
8198
8200
  ], exports.Box.prototype, "resizeChildren", void 0);
8201
+ __decorate([
8202
+ dataType(false)
8203
+ ], exports.Box.prototype, "textBox", void 0);
8199
8204
  __decorate([
8200
8205
  affectRenderBoundsType('show')
8201
8206
  ], exports.Box.prototype, "overflow", void 0);
@@ -8725,6 +8730,9 @@ var LeaferUI = (function (exports) {
8725
8730
  __decorate([
8726
8731
  boundsType('top')
8727
8732
  ], exports.Text.prototype, "verticalAlign", void 0);
8733
+ __decorate([
8734
+ boundsType(true)
8735
+ ], exports.Text.prototype, "autoSizeAlign", void 0);
8728
8736
  __decorate([
8729
8737
  boundsType('normal')
8730
8738
  ], exports.Text.prototype, "textWrap", void 0);
@@ -9445,9 +9453,10 @@ var LeaferUI = (function (exports) {
9445
9453
  this.dragData = getDragEventData(data, data, data);
9446
9454
  this.canAnimate = this.canDragOut = true;
9447
9455
  }
9448
- getList() {
9456
+ getList(realDraggable, hover) {
9449
9457
  const { proxy } = this.interaction.selector;
9450
- 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);
9451
9460
  }
9452
9461
  checkDrag(data, canDrag) {
9453
9462
  const { interaction } = this;
@@ -9472,8 +9481,8 @@ var LeaferUI = (function (exports) {
9472
9481
  this.dragging = canDrag && PointerButton.left(data);
9473
9482
  if (this.dragging) {
9474
9483
  this.interaction.emit(exports.DragEvent.START, this.dragData);
9475
- this.getDragableList(this.dragData.path);
9476
- this.setDragStartPoints(this.realDragableList = this.getList());
9484
+ this.getDraggableList(this.dragData.path);
9485
+ this.setDragStartPoints(this.realDraggableList = this.getList(true));
9477
9486
  }
9478
9487
  }
9479
9488
  }
@@ -9481,12 +9490,12 @@ var LeaferUI = (function (exports) {
9481
9490
  this.dragStartPoints = {};
9482
9491
  list.forEach(leaf => this.dragStartPoints[leaf.innerId] = { x: leaf.x, y: leaf.y });
9483
9492
  }
9484
- getDragableList(path) {
9493
+ getDraggableList(path) {
9485
9494
  let leaf;
9486
9495
  for (let i = 0, len = path.length; i < len; i++) {
9487
9496
  leaf = path.list[i];
9488
- if ((leaf.__.draggable || leaf.__.editable) && leaf.__.hitSelf && !leaf.__.locked) {
9489
- this.dragableList = new LeafList(leaf);
9497
+ if ((leaf.draggable || leaf.editable) && leaf.hitSelf && !leaf.locked) {
9498
+ this.draggableList = new LeafList(leaf);
9490
9499
  break;
9491
9500
  }
9492
9501
  }
@@ -9511,7 +9520,7 @@ var LeaferUI = (function (exports) {
9511
9520
  }
9512
9521
  dragReal() {
9513
9522
  const { running } = this.interaction;
9514
- const list = this.realDragableList;
9523
+ const list = this.realDraggableList;
9515
9524
  if (list.length && running) {
9516
9525
  const { totalX, totalY } = this.dragData;
9517
9526
  list.forEach(leaf => leaf.draggable && leaf.move(exports.DragEvent.getValidMove(leaf, this.dragStartPoints[leaf.innerId], { x: totalX, y: totalY })));
@@ -9600,7 +9609,7 @@ var LeaferUI = (function (exports) {
9600
9609
  this.interaction.emit(exports.DragEvent.LEAVE, data, dragEnterPath);
9601
9610
  }
9602
9611
  dragReset() {
9603
- 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;
9604
9613
  }
9605
9614
  checkDragOut(data) {
9606
9615
  const { interaction } = this;
@@ -9741,6 +9750,7 @@ var LeaferUI = (function (exports) {
9741
9750
  touch: {
9742
9751
  preventDefault: true
9743
9752
  },
9753
+ multiTouch: {},
9744
9754
  cursor: true,
9745
9755
  keyEvent: true
9746
9756
  };
@@ -9867,6 +9877,8 @@ var LeaferUI = (function (exports) {
9867
9877
  this.pointerUp(data);
9868
9878
  }
9869
9879
  multiTouch(data, list) {
9880
+ if (this.config.multiTouch.disabled)
9881
+ return;
9870
9882
  const { move, angle, scale, center } = MultiTouchHelper.getData(list);
9871
9883
  this.rotate(getRotateEventData(center, angle, data));
9872
9884
  this.zoom(getZoomEventData(center, scale, data));
@@ -10056,7 +10068,7 @@ var LeaferUI = (function (exports) {
10056
10068
  data = this.hoverData;
10057
10069
  if (!data)
10058
10070
  return;
10059
- 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 });
10060
10072
  this.hoverData = data;
10061
10073
  }
10062
10074
  updateCursor(data) {
@@ -10078,7 +10090,7 @@ var LeaferUI = (function (exports) {
10078
10090
  const { path } = data;
10079
10091
  for (let i = 0, len = path.length; i < len; i++) {
10080
10092
  leaf = path.list[i];
10081
- cursor = leaf.syncEventer ? leaf.syncEventer.cursor : leaf.cursor;
10093
+ cursor = (leaf.syncEventer && leaf.syncEventer.cursor) || leaf.cursor;
10082
10094
  if (cursor)
10083
10095
  break;
10084
10096
  }
@@ -10260,7 +10272,7 @@ var LeaferUI = (function (exports) {
10260
10272
  if (isHitPixel) {
10261
10273
  const { renderBounds } = this.__layout;
10262
10274
  const size = Platform.image.hitCanvasSize;
10263
- 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;
10264
10276
  const { x, y, width, height } = tempBounds$1.set(renderBounds).scale(scale);
10265
10277
  h.resize({ width, height, pixelRatio: 1 });
10266
10278
  h.clear();
@@ -10316,15 +10328,14 @@ var LeaferUI = (function (exports) {
10316
10328
  return hitWidth ? this.__hitStroke(inner, hitWidth) : false;
10317
10329
  };
10318
10330
 
10319
- const ui$2 = new exports.UI();
10320
- const rect = exports.Rect.prototype;
10321
- 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 () {
10322
10333
  if (this.stroke || this.cornerRadius || ((this.fill || this.__.__isCanvas) && this.hitFill === 'pixel') || this.hitStroke === 'all')
10323
10334
  ui$2.__updateHitCanvas.call(this);
10324
10335
  else if (this.__hitCanvas)
10325
10336
  this.__hitCanvas = null;
10326
10337
  };
10327
- rect.__hitFill = function (inner) {
10338
+ rect.__hitFill = box$1.__hitFill = function (inner) {
10328
10339
  return this.__hitCanvas ? ui$2.__hitFill.call(this, inner) : BoundsHelper.hitRadiusPoint(this.__layout.boxBounds, inner);
10329
10340
  };
10330
10341
 
@@ -10663,7 +10674,7 @@ var LeaferUI = (function (exports) {
10663
10674
  shape
10664
10675
  };
10665
10676
 
10666
- let origin = {};
10677
+ let origin$1 = {};
10667
10678
  const { get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, scale: scaleHelper, rotate: rotate$2 } = MatrixHelper;
10668
10679
  function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
10669
10680
  const transform = get$3();
@@ -10703,11 +10714,11 @@ var LeaferUI = (function (exports) {
10703
10714
  }
10704
10715
  }
10705
10716
  }
10706
- origin.x = box.x + x;
10707
- origin.y = box.y + y;
10708
- 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);
10709
10720
  if (scaleX)
10710
- scaleOfOuter$1(transform, origin, scaleX, scaleY);
10721
+ scaleOfOuter$1(transform, origin$1, scaleX, scaleY);
10711
10722
  data.transform = transform;
10712
10723
  }
10713
10724
 
@@ -10823,9 +10834,10 @@ var LeaferUI = (function (exports) {
10823
10834
  onLoadError(ui, event, image.error);
10824
10835
  }
10825
10836
  else {
10826
- ignoreRender(ui, true);
10827
- if (firstUse)
10837
+ if (firstUse) {
10838
+ ignoreRender(ui, true);
10828
10839
  onLoad(ui, event);
10840
+ }
10829
10841
  leafPaint.loadId = image.load(() => {
10830
10842
  ignoreRender(ui, false);
10831
10843
  if (!ui.destroyed) {
@@ -11437,14 +11449,15 @@ var LeaferUI = (function (exports) {
11437
11449
  const { Letter, Single, Before, After, Symbol, Break } = CharType;
11438
11450
  let word, row, wordWidth, rowWidth, realWidth;
11439
11451
  let char, charWidth, startCharSize, charSize, charType, lastCharType, langBreak, afterBreak, paraStart;
11440
- let textDrawData, rows = [], bounds;
11452
+ let textDrawData, rows = [], bounds$1, findMaxWidth;
11441
11453
  function createRows(drawData, content, style) {
11442
11454
  textDrawData = drawData;
11443
11455
  rows = drawData.rows;
11444
- bounds = drawData.bounds;
11456
+ bounds$1 = drawData.bounds;
11457
+ findMaxWidth = !bounds$1.width && !style.autoSizeAlign;
11445
11458
  const { __letterSpacing, paraIndent, textCase } = style;
11446
11459
  const { canvas } = Platform;
11447
- const { width, height } = bounds;
11460
+ const { width, height } = bounds$1;
11448
11461
  const charMode = width || height || __letterSpacing || (textCase !== 'none');
11449
11462
  if (charMode) {
11450
11463
  const wrap = style.textWrap !== 'none';
@@ -11526,7 +11539,10 @@ var LeaferUI = (function (exports) {
11526
11539
  else {
11527
11540
  content.split('\n').forEach(content => {
11528
11541
  textDrawData.paraNumber++;
11529
- 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();
11530
11546
  });
11531
11547
  }
11532
11548
  }
@@ -11555,12 +11571,18 @@ var LeaferUI = (function (exports) {
11555
11571
  startCharSize = 0;
11556
11572
  }
11557
11573
  row.width = rowWidth;
11558
- if (bounds.width)
11574
+ if (bounds$1.width)
11559
11575
  trimRight(row);
11576
+ else if (findMaxWidth)
11577
+ setMaxWidth();
11560
11578
  rows.push(row);
11561
11579
  row = { words: [] };
11562
11580
  rowWidth = 0;
11563
11581
  }
11582
+ function setMaxWidth() {
11583
+ if (rowWidth > (textDrawData.maxWidth || 0))
11584
+ textDrawData.maxWidth = rowWidth;
11585
+ }
11564
11586
 
11565
11587
  const CharMode = 0;
11566
11588
  const WordMode = 1;
@@ -11632,34 +11654,32 @@ var LeaferUI = (function (exports) {
11632
11654
 
11633
11655
  function layoutText(drawData, style) {
11634
11656
  const { rows, bounds } = drawData;
11635
- const { __lineHeight, __baseLine, __letterSpacing, __clipText, textAlign, verticalAlign, paraSpacing } = style;
11657
+ const { __lineHeight, __baseLine, __letterSpacing, __clipText, textAlign, verticalAlign, paraSpacing, autoSizeAlign } = style;
11636
11658
  let { x, y, width, height } = bounds, realHeight = __lineHeight * rows.length + (paraSpacing ? paraSpacing * (drawData.paraNumber - 1) : 0);
11637
11659
  let starY = __baseLine;
11638
11660
  if (__clipText && realHeight > height) {
11639
11661
  realHeight = Math.max(height, __lineHeight);
11640
11662
  drawData.overflow = rows.length;
11641
11663
  }
11642
- else {
11664
+ else if (height || autoSizeAlign) {
11643
11665
  switch (verticalAlign) {
11644
11666
  case 'middle':
11645
11667
  y += (height - realHeight) / 2;
11646
11668
  break;
11647
- case 'bottom':
11648
- y += (height - realHeight);
11669
+ case 'bottom': y += (height - realHeight);
11649
11670
  }
11650
11671
  }
11651
11672
  starY += y;
11652
- let row, rowX, rowWidth;
11673
+ let row, rowX, rowWidth, layoutWidth = (width || autoSizeAlign) ? width : drawData.maxWidth;
11653
11674
  for (let i = 0, len = rows.length; i < len; i++) {
11654
11675
  row = rows[i];
11655
11676
  row.x = x;
11656
11677
  if (row.width < width || (row.width > width && !__clipText)) {
11657
11678
  switch (textAlign) {
11658
11679
  case 'center':
11659
- row.x += (width - row.width) / 2;
11680
+ row.x += (layoutWidth - row.width) / 2;
11660
11681
  break;
11661
- case 'right':
11662
- row.x += width - row.width;
11682
+ case 'right': row.x += layoutWidth - row.width;
11663
11683
  }
11664
11684
  }
11665
11685
  if (row.paraStart && paraSpacing && i > 0)
@@ -11764,14 +11784,14 @@ var LeaferUI = (function (exports) {
11764
11784
  let height = style.__getInput('height') || 0;
11765
11785
  const { textDecoration, __font, __padding: padding } = style;
11766
11786
  if (padding) {
11767
- if (width) {
11787
+ if (width)
11788
+ x = padding[left$3], width -= (padding[right$3] + padding[left$3]);
11789
+ else if (!style.autoSizeAlign)
11768
11790
  x = padding[left$3];
11769
- width -= (padding[right$3] + padding[left$3]);
11770
- }
11771
- if (height) {
11791
+ if (height)
11792
+ y = padding[top$2], height -= (padding[top$2] + padding[bottom$2]);
11793
+ else if (!style.autoSizeAlign)
11772
11794
  y = padding[top$2];
11773
- height -= (padding[top$2] + padding[bottom$2]);
11774
- }
11775
11795
  }
11776
11796
  const drawData = {
11777
11797
  bounds: { x, y, width, height },
@@ -11791,22 +11811,20 @@ var LeaferUI = (function (exports) {
11791
11811
  return drawData;
11792
11812
  }
11793
11813
  function padAutoText(padding, drawData, style, width, height) {
11794
- if (!width) {
11814
+ if (!width && style.autoSizeAlign) {
11795
11815
  switch (style.textAlign) {
11796
11816
  case 'left':
11797
11817
  offsetText(drawData, 'x', padding[left$3]);
11798
11818
  break;
11799
- case 'right':
11800
- offsetText(drawData, 'x', -padding[right$3]);
11819
+ case 'right': offsetText(drawData, 'x', -padding[right$3]);
11801
11820
  }
11802
11821
  }
11803
- if (!height) {
11822
+ if (!height && style.autoSizeAlign) {
11804
11823
  switch (style.verticalAlign) {
11805
11824
  case 'top':
11806
11825
  offsetText(drawData, 'y', padding[top$2]);
11807
11826
  break;
11808
- case 'bottom':
11809
- offsetText(drawData, 'y', -padding[bottom$2]);
11827
+ case 'bottom': offsetText(drawData, 'y', -padding[bottom$2]);
11810
11828
  }
11811
11829
  }
11812
11830
  }
@@ -12328,31 +12346,29 @@ var LeaferUI = (function (exports) {
12328
12346
  const { list } = this;
12329
12347
  if (list.length) {
12330
12348
  let leaf;
12331
- const { stroke, strokeWidth, fill } = this.__;
12332
- const { bounds } = options;
12349
+ const data = this.__, { stroke, strokeWidth, fill } = data, { bounds } = options;
12333
12350
  for (let i = 0; i < list.length; i++) {
12334
12351
  leaf = list[i];
12335
- if (bounds && bounds.hit(leaf.__world, options.matrix)) {
12336
- 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);
12337
12355
  if (aScaleX !== aScaleY) {
12338
- copy$2(matrix, leaf.__world);
12356
+ copy$2(matrix, worldTransform);
12339
12357
  scale$1(matrix, 1 / aScaleX, 1 / aScaleY);
12340
12358
  canvas.setWorld(matrix, options.matrix);
12341
12359
  canvas.beginPath();
12342
- this.__.strokeWidth = strokeWidth;
12360
+ data.strokeWidth = strokeWidth;
12343
12361
  const { x, y, width, height } = leaf.__layout.boxBounds;
12344
12362
  canvas.rect(x * aScaleX, y * aScaleY, width * aScaleX, height * aScaleY);
12345
12363
  }
12346
12364
  else {
12347
- canvas.setWorld(leaf.__world, options.matrix);
12365
+ canvas.setWorld(worldTransform, options.matrix);
12348
12366
  canvas.beginPath();
12349
- if (leaf.__.__useArrow) {
12367
+ if (leaf.__.__useArrow)
12350
12368
  leaf.__drawPath(canvas);
12351
- }
12352
- else {
12369
+ else
12353
12370
  leaf.__.__pathForRender ? leaf.__drawRenderPath(canvas) : leaf.__drawPathByBox(canvas);
12354
- }
12355
- this.__.strokeWidth = strokeWidth / abs(leaf.__world.scaleX);
12371
+ data.strokeWidth = strokeWidth / abs(worldTransform.scaleX);
12356
12372
  }
12357
12373
  if (stroke)
12358
12374
  typeof stroke === 'string' ? Paint.stroke(stroke, this, canvas) : Paint.strokes(stroke, this, canvas);
@@ -12360,7 +12376,7 @@ var LeaferUI = (function (exports) {
12360
12376
  typeof fill === 'string' ? Paint.fill(fill, this, canvas) : Paint.fills(fill, this, canvas);
12361
12377
  }
12362
12378
  }
12363
- this.__.strokeWidth = strokeWidth;
12379
+ data.strokeWidth = strokeWidth;
12364
12380
  }
12365
12381
  }
12366
12382
  destroy() {
@@ -12738,7 +12754,6 @@ var LeaferUI = (function (exports) {
12738
12754
  scaleY = within(nowHeight * scaleY, heightRange) / nowHeight;
12739
12755
  }
12740
12756
  toPoint(around || align, boxBounds, origin, true);
12741
- console.log({ origin, scaleX, scaleY, direction, lockRatio, around });
12742
12757
  return { origin, scaleX, scaleY, direction, lockRatio, around };
12743
12758
  },
12744
12759
  getRotateData(bounds, direction, current, last, around) {
@@ -12912,7 +12927,6 @@ var LeaferUI = (function (exports) {
12912
12927
  this.editor = editor;
12913
12928
  this.visible = false;
12914
12929
  this.create();
12915
- this.rect.syncEventer = editor;
12916
12930
  this.__listenEvents();
12917
12931
  }
12918
12932
  create() {
@@ -12952,8 +12966,11 @@ var LeaferUI = (function (exports) {
12952
12966
  circle.set(this.getPointStyle(mergeConfig.circle || mergeConfig.rotatePoint || pointsStyle[0]));
12953
12967
  rect.set(Object.assign({ stroke, strokeWidth }, (mergeConfig.rect || {})));
12954
12968
  rect.hittable = !single && !!moveable;
12955
- element.syncEventer = (single && moveable) ? rect : null;
12956
- 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
+ }
12957
12974
  }
12958
12975
  update(bounds) {
12959
12976
  this.visible = !this.editor.element.locked;
@@ -13125,6 +13142,11 @@ var LeaferUI = (function (exports) {
13125
13142
  if (editor.single) {
13126
13143
  const { element } = editor;
13127
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
+ }
13128
13150
  editor.openGroup(element);
13129
13151
  editor.target = editor.selector.findDeepOne(e);
13130
13152
  }
@@ -13270,12 +13292,12 @@ ${filterStyle}
13270
13292
  skewable: true
13271
13293
  };
13272
13294
 
13295
+ const bounds = new Bounds();
13273
13296
  function simulate(editor) {
13274
- const { simulateTarget, leafList: targetList } = editor;
13275
- const { x, y, width, height } = new Bounds().setListWithFn(targetList.list, (leaf) => leaf.worldBoxBounds);
13276
- const parent = simulateTarget.parent = targetList.list[0].leafer.zoomLayer;
13277
- const { scaleX, scaleY, e: worldX, f: worldY } = parent.__world;
13278
- 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);
13279
13301
  }
13280
13302
 
13281
13303
  function onTarget(editor, oldValue) {
@@ -13284,6 +13306,7 @@ ${filterStyle}
13284
13306
  editor.leafList = target instanceof LeafList ? target : new LeafList(target instanceof Array ? target : target);
13285
13307
  }
13286
13308
  else {
13309
+ editor.simulateTarget.remove();
13287
13310
  editor.leafList.reset();
13288
13311
  editor.closeInnerEditor();
13289
13312
  }
@@ -13338,7 +13361,7 @@ ${filterStyle}
13338
13361
  const ungroupList = [];
13339
13362
  app.lockLayout();
13340
13363
  list.forEach(leaf => {
13341
- if (leaf.isBranch) {
13364
+ if (leaf.isBranch && !leaf.isBranchLeaf) {
13342
13365
  const { parent, children } = leaf;
13343
13366
  while (children.length) {
13344
13367
  ungroupList.push(children[0]);
@@ -13409,17 +13432,77 @@ ${filterStyle}
13409
13432
  EditorGroupEvent.OPEN = 'editor.open_group';
13410
13433
  EditorGroupEvent.CLOSE = 'editor.close_group';
13411
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
+
13412
13493
  class Editor extends exports.Group {
13413
13494
  get mergeConfig() {
13414
13495
  const { element, config } = this;
13415
13496
  return this.single && element.editConfig ? Object.assign(Object.assign({}, config), element.editConfig) : config;
13416
13497
  }
13417
13498
  get list() { return this.leafList.list; }
13499
+ get dragHoverExclude() { return [this.editBox.rect]; }
13418
13500
  get editing() { return !!this.list.length; }
13419
13501
  get groupOpening() { return !!this.openedGroupList.length; }
13420
13502
  get multiple() { return this.list.length > 1; }
13421
13503
  get single() { return this.list.length === 1; }
13422
13504
  get dragging() { return this.editBox.dragging; }
13505
+ get moving() { return this.editBox.moving; }
13423
13506
  get element() { return this.multiple ? this.simulateTarget : this.list[0]; }
13424
13507
  get buttons() { return this.editBox.buttons; }
13425
13508
  constructor(userConfig, data) {
@@ -13427,7 +13510,7 @@ ${filterStyle}
13427
13510
  this.config = DataHelper.clone(config);
13428
13511
  this.leafList = new LeafList();
13429
13512
  this.openedGroupList = new LeafList();
13430
- this.simulateTarget = new exports.Rect({ visible: false });
13513
+ this.simulateTarget = new SimulateElement(this);
13431
13514
  this.editBox = new EditBox(this);
13432
13515
  this.editToolList = {};
13433
13516
  this.selector = new EditSelect(this);
@@ -13565,18 +13648,18 @@ ${filterStyle}
13565
13648
  this.skewOf(origin, skewX, skewY);
13566
13649
  }
13567
13650
  move(x, y = 0) {
13568
- if (!this.mergeConfig.moveable || this.element.locked)
13651
+ if (!this.checkTransform('moveable'))
13569
13652
  return;
13570
13653
  const { element } = this;
13571
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));
13572
13657
  const event = new EditorMoveEvent(EditorMoveEvent.MOVE, { target: element, editor: this, moveX: world.x, moveY: world.y });
13573
13658
  this.editTool.onMove(event);
13574
13659
  this.emitEvent(event);
13575
- if (this.multiple)
13576
- element.move(x, y);
13577
13660
  }
13578
13661
  scaleWithDrag(data) {
13579
- if (!this.mergeConfig.resizeable || this.element.locked)
13662
+ if (!this.checkTransform('resizeable'))
13580
13663
  return;
13581
13664
  const { element } = this;
13582
13665
  const event = new EditorScaleEvent(EditorScaleEvent.SCALE, Object.assign(Object.assign({}, data), { target: element, editor: this, worldOrigin: element.getWorldPoint(data.origin) }));
@@ -13584,50 +13667,53 @@ ${filterStyle}
13584
13667
  this.emitEvent(event);
13585
13668
  }
13586
13669
  scaleOf(origin, scaleX, scaleY = scaleX, _resize) {
13587
- if (!this.mergeConfig.resizeable || this.element.locked)
13670
+ if (!this.checkTransform('resizeable'))
13588
13671
  return;
13589
13672
  const { element } = this;
13590
13673
  const worldOrigin = this.getWorldOrigin(origin);
13591
- 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)));
13592
13675
  const event = new EditorScaleEvent(EditorScaleEvent.SCALE, { target: element, editor: this, worldOrigin, scaleX, scaleY, transform });
13593
13676
  this.editTool.onScale(event);
13594
13677
  this.emitEvent(event);
13595
13678
  }
13596
13679
  flip(axis) {
13597
- if (this.element.locked)
13680
+ if (!this.checkTransform('resizeable'))
13598
13681
  return;
13599
13682
  const { element } = this;
13600
13683
  const worldOrigin = this.getWorldOrigin('center');
13601
- 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));
13602
13685
  const event = new EditorScaleEvent(EditorScaleEvent.SCALE, { target: element, editor: this, worldOrigin, scaleX: axis === 'x' ? -1 : 1, scaleY: axis === 'y' ? -1 : 1, transform });
13603
13686
  this.editTool.onScale(event);
13604
13687
  this.emitEvent(event);
13605
13688
  }
13606
13689
  rotateOf(origin, rotation) {
13607
- if (!this.mergeConfig.rotateable || this.element.locked)
13690
+ if (!this.checkTransform('rotateable'))
13608
13691
  return;
13609
13692
  const { element } = this;
13610
13693
  const worldOrigin = this.getWorldOrigin(origin);
13611
- const transform = this.multiple && this.getChangedTransform(() => element.rotateOf(origin, rotation));
13694
+ const transform = this.multiple && this.getChangedTransform(() => element.safeChange(() => element.rotateOf(origin, rotation)));
13612
13695
  const event = new EditorRotateEvent(EditorRotateEvent.ROTATE, { target: element, editor: this, worldOrigin, rotation, transform });
13613
13696
  this.editTool.onRotate(event);
13614
13697
  this.emitEvent(event);
13615
13698
  }
13616
13699
  skewOf(origin, skewX, skewY = 0, _resize) {
13617
- if (!this.mergeConfig.skewable || this.element.locked)
13700
+ if (!this.checkTransform('skewable'))
13618
13701
  return;
13619
13702
  const { element } = this;
13620
13703
  const worldOrigin = this.getWorldOrigin(origin);
13621
- 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)));
13622
13705
  const event = new EditorSkewEvent(EditorSkewEvent.SKEW, { target: element, editor: this, worldOrigin, skewX, skewY, transform });
13623
13706
  this.editTool.onSkew(event);
13624
13707
  this.emitEvent(event);
13625
13708
  }
13709
+ checkTransform(type) { return this.element && !this.element.locked && this.mergeConfig[type]; }
13626
13710
  getWorldOrigin(origin) {
13627
13711
  return this.element.getWorldPoint(LeafHelper.getInnerOrigin(this.element, origin));
13628
13712
  }
13629
13713
  getChangedTransform(func) {
13630
13714
  const { element } = this;
13715
+ if (this.multiple && !element.canChange)
13716
+ return element.changedTransform;
13631
13717
  const oldMatrix = new Matrix(element.worldTransform);
13632
13718
  func();
13633
13719
  return new Matrix(element.worldTransform).divide(oldMatrix);
@@ -13684,11 +13770,11 @@ ${filterStyle}
13684
13770
  this.emitEvent(event);
13685
13771
  group.emitEvent(event);
13686
13772
  }
13687
- openInnerEditor(target) {
13688
- if (target)
13773
+ openInnerEditor(target, select) {
13774
+ if (target && select)
13689
13775
  this.target = target;
13690
13776
  if (this.single) {
13691
- const editTarget = this.element;
13777
+ const editTarget = target || this.element;
13692
13778
  const tag = editTarget.editInner;
13693
13779
  if (tag && EditToolCreator.list[tag]) {
13694
13780
  this.editTool.unload();
@@ -13740,14 +13826,15 @@ ${filterStyle}
13740
13826
  }
13741
13827
  listenTargetEvents() {
13742
13828
  if (!this.targetEventIds.length) {
13743
- const { leafer } = this.list[0];
13829
+ const { app, leafer } = this;
13744
13830
  this.targetEventIds = [
13745
- this.app.on_(exports.MoveEvent.BEFORE_MOVE, this.onMove, this, true),
13746
- this.app.on_(exports.ZoomEvent.BEFORE_ZOOM, this.onScale, this, true),
13747
- this.app.on_(exports.RotateEvent.BEFORE_ROTATE, this.onRotate, this, true),
13748
13831
  leafer.on_(RenderEvent.START, this.update, this),
13749
- leafer.on_([exports.KeyEvent.HOLD, exports.KeyEvent.UP], (e) => { updateCursor(this, e); }),
13750
- 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)
13751
13838
  ];
13752
13839
  }
13753
13840
  }
@@ -13880,10 +13967,7 @@ ${filterStyle}
13880
13967
  }
13881
13968
  update() {
13882
13969
  const { editor, editBox } = this;
13883
- const { simulateTarget, element } = editor;
13884
- if (editor.multiple)
13885
- simulateTarget.parent.updateLayout();
13886
- 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);
13887
13971
  editBox.set({ x, y, scaleX, scaleY, rotation, skewX, skewY });
13888
13972
  editBox.update({ x: 0, y: 0, width, height });
13889
13973
  this.onUpdate();
@@ -14572,18 +14656,7 @@ ${filterStyle}
14572
14656
  style.position = 'fixed';
14573
14657
  style.transformOrigin = 'left top';
14574
14658
  style.boxSizing = 'border-box';
14575
- if (this.isHTMLText) {
14576
- div.innerHTML = text.text;
14577
- this.textScale = 1;
14578
- }
14579
- else {
14580
- div.innerText = text.text;
14581
- const { scaleX, scaleY } = text.worldTransform;
14582
- this.textScale = Math.max(Math.abs(scaleX), Math.abs(scaleY));
14583
- const fontSize = text.fontSize * this.textScale;
14584
- if (fontSize < 12)
14585
- this.textScale *= 12 / fontSize;
14586
- }
14659
+ this.isHTMLText ? div.innerHTML = text.text : div.innerText = text.text;
14587
14660
  const { view } = editor.app;
14588
14661
  (this.inBody = view instanceof HTMLCanvasElement) ? document.body.appendChild(div) : view.appendChild(div);
14589
14662
  this.eventIds = [
@@ -14632,16 +14705,46 @@ ${filterStyle}
14632
14705
  this.editor.closeInnerEditor();
14633
14706
  }
14634
14707
  onUpdate() {
14635
- const { editTarget: text, textScale } = this;
14636
- const { style } = this.editDom;
14637
- 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;
14638
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;
14639
14742
  style.transform = `matrix(${a},${b},${c},${d},${e},${f})`;
14640
- style.left = x - window.scrollX + 'px';
14641
- style.top = y - window.scrollY + 'px';
14642
- style.width = text.width * textScale + (text.__.__autoWidth ? 20 : 0) + 'px';
14643
- style.height = text.height * textScale + (text.__.__autoHeight ? 20 : 0) + 'px';
14644
- 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);
14645
14748
  }
14646
14749
  onUnload() {
14647
14750
  const { editTarget: text, editor, editDom: dom } = this;