@leafer-editor/worker 1.0.7 → 1.0.9

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
@@ -2961,7 +2961,6 @@ var LeaferUI = (function (exports) {
2961
2961
  set path(value) { this.__path = value; }
2962
2962
  get path() { return this.__path; }
2963
2963
  constructor(path) {
2964
- this.clearPath = this.beginPath;
2965
2964
  this.set(path);
2966
2965
  }
2967
2966
  set(path) {
@@ -3043,6 +3042,9 @@ var LeaferUI = (function (exports) {
3043
3042
  this.paint();
3044
3043
  return this;
3045
3044
  }
3045
+ clearPath() {
3046
+ return this.beginPath();
3047
+ }
3046
3048
  paint() { }
3047
3049
  }
3048
3050
 
@@ -3638,6 +3640,8 @@ var LeaferUI = (function (exports) {
3638
3640
  else {
3639
3641
  if (url.includes('.' + format) || url.includes('.' + FileHelper.upperCaseTypeMap[format]))
3640
3642
  return true;
3643
+ else if (format === 'png' && !url.includes('.'))
3644
+ return true;
3641
3645
  }
3642
3646
  return false;
3643
3647
  },
@@ -5255,7 +5259,7 @@ var LeaferUI = (function (exports) {
5255
5259
  const { LEAF, create } = IncrementId;
5256
5260
  const { toInnerPoint, toOuterPoint, multiplyParent } = MatrixHelper;
5257
5261
  const { toOuterOf } = BoundsHelper;
5258
- const { copy: copy$7, move: move$2 } = PointHelper;
5262
+ const { copy: copy$7, move: move$1 } = PointHelper;
5259
5263
  const { moveLocal, zoomOfLocal, rotateOfLocal, skewOfLocal, moveWorld, zoomOfWorld, rotateOfWorld, skewOfWorld, transform, transformWorld, setTransform, getFlipTransform, getLocalOrigin, getRelativeWorld, drop } = LeafHelper;
5260
5264
  exports.Leaf = class Leaf {
5261
5265
  get tag() { return this.__tag; }
@@ -5490,7 +5494,7 @@ var LeaferUI = (function (exports) {
5490
5494
  }
5491
5495
  getBoxPointByInner(inner, _relative, _distance, change) {
5492
5496
  const point = change ? inner : Object.assign({}, inner), { x, y } = this.boxBounds;
5493
- move$2(point, -x, -y);
5497
+ move$1(point, -x, -y);
5494
5498
  return point;
5495
5499
  }
5496
5500
  getInnerPoint(world, relative, distance, change) {
@@ -5500,7 +5504,7 @@ var LeaferUI = (function (exports) {
5500
5504
  }
5501
5505
  getInnerPointByBox(box, _relative, _distance, change) {
5502
5506
  const point = change ? box : Object.assign({}, box), { x, y } = this.boxBounds;
5503
- move$2(point, x, y);
5507
+ move$1(point, x, y);
5504
5508
  return point;
5505
5509
  }
5506
5510
  getInnerPointByLocal(local, _relative, distance, change) {
@@ -5641,11 +5645,10 @@ var LeaferUI = (function (exports) {
5641
5645
  }
5642
5646
  destroy() {
5643
5647
  if (!this.destroyed) {
5644
- const { parent } = this;
5645
- if (parent)
5648
+ if (this.parent)
5646
5649
  this.remove();
5647
5650
  if (this.children)
5648
- this.removeAll(true);
5651
+ this.clear();
5649
5652
  this.__emitLifeEvent(ChildEvent.DESTROY);
5650
5653
  this.__.destroy();
5651
5654
  this.__layout.destroy();
@@ -5959,7 +5962,7 @@ var LeaferUI = (function (exports) {
5959
5962
  }
5960
5963
  }
5961
5964
 
5962
- const version = "1.0.7";
5965
+ const version = "1.0.9";
5963
5966
 
5964
5967
  class LeaferCanvas extends LeaferCanvasBase {
5965
5968
  get allowBackgroundColor() { return true; }
@@ -6960,12 +6963,8 @@ var LeaferUI = (function (exports) {
6960
6963
  };
6961
6964
  const Transition = {
6962
6965
  list: {},
6963
- register(attrName, fn) {
6964
- Transition.list[attrName] = fn;
6965
- },
6966
- get(attrName) {
6967
- return Transition.list[attrName];
6968
- }
6966
+ register(attrName, fn) { Transition.list[attrName] = fn; },
6967
+ get(attrName) { return Transition.list[attrName]; }
6969
6968
  };
6970
6969
 
6971
6970
  const { parse, objectToCanvasData } = PathConvert;
@@ -7411,8 +7410,8 @@ var LeaferUI = (function (exports) {
7411
7410
  pen.set(path = []), this.__drawPathByBox(pen);
7412
7411
  return curve ? PathConvert.toCanvasData(path, true) : path;
7413
7412
  }
7414
- getPathString(curve, pathForRender) {
7415
- return PathConvert.stringify(this.getPath(curve, pathForRender));
7413
+ getPathString(curve, pathForRender, floatLength) {
7414
+ return PathConvert.stringify(this.getPath(curve, pathForRender), floatLength);
7416
7415
  }
7417
7416
  load() {
7418
7417
  this.__.__computePaint();
@@ -7821,11 +7820,11 @@ var LeaferUI = (function (exports) {
7821
7820
  start() {
7822
7821
  clearTimeout(this.__startTimer);
7823
7822
  if (!this.running && this.canvas) {
7823
+ this.running = true;
7824
7824
  this.ready ? this.emitLeafer(LeaferEvent.RESTART) : this.emitLeafer(LeaferEvent.START);
7825
7825
  this.__controllers.forEach(item => item.start());
7826
7826
  if (!this.isApp)
7827
7827
  this.renderer.render();
7828
- this.running = true;
7829
7828
  }
7830
7829
  }
7831
7830
  stop() {
@@ -7931,12 +7930,10 @@ var LeaferUI = (function (exports) {
7931
7930
  }
7932
7931
  __changeFill(newValue) {
7933
7932
  this.config.fill = newValue;
7934
- if (this.canvas.allowBackgroundColor) {
7933
+ if (this.canvas.allowBackgroundColor)
7935
7934
  this.canvas.backgroundColor = newValue;
7936
- }
7937
- else {
7935
+ else
7938
7936
  this.forceRender();
7939
- }
7940
7937
  }
7941
7938
  __onCreated() {
7942
7939
  this.created = true;
@@ -8003,13 +8000,10 @@ var LeaferUI = (function (exports) {
8003
8000
  if (bind)
8004
8001
  item = item.bind(bind);
8005
8002
  this.__viewCompletedWait.push(item);
8006
- if (this.viewCompleted) {
8003
+ if (this.viewCompleted)
8007
8004
  this.__checkViewCompleted(false);
8008
- }
8009
- else {
8010
- if (!this.running)
8011
- this.start();
8012
- }
8005
+ else if (!this.running)
8006
+ this.start();
8013
8007
  }
8014
8008
  nextRender(item, bind, off) {
8015
8009
  if (bind)
@@ -8023,9 +8017,8 @@ var LeaferUI = (function (exports) {
8023
8017
  }
8024
8018
  }
8025
8019
  }
8026
- else {
8020
+ else
8027
8021
  list.push(item);
8028
- }
8029
8022
  }
8030
8023
  zoom(_zoomType, _padding, _fixedScale) {
8031
8024
  return needPlugin('view');
@@ -8069,10 +8062,7 @@ var LeaferUI = (function (exports) {
8069
8062
  this.stop();
8070
8063
  this.emitEvent(new LeaferEvent(LeaferEvent.END, this));
8071
8064
  this.__removeListenEvents();
8072
- this.__controllers.forEach(item => {
8073
- if (!(this.parent && item === this.interaction))
8074
- item.destroy();
8075
- });
8065
+ this.__controllers.forEach(item => !(this.parent && item === this.interaction) && item.destroy());
8076
8066
  this.__controllers.length = 0;
8077
8067
  if (!this.parent) {
8078
8068
  if (this.selector)
@@ -8605,20 +8595,19 @@ var LeaferUI = (function (exports) {
8605
8595
  }
8606
8596
  __updateTextDrawData() {
8607
8597
  const data = this.__;
8608
- data.__textDrawData = TextConvert.getDrawData(data.text, this.__);
8609
- }
8610
- __updateBoxBounds() {
8611
- const data = this.__;
8612
- const layout = this.__layout;
8613
8598
  const { lineHeight, letterSpacing, fontFamily, fontSize, fontWeight, italic, textCase, textOverflow, padding } = data;
8614
- const autoWidth = data.__autoWidth;
8615
- const autoHeight = data.__autoHeight;
8616
8599
  data.__lineHeight = UnitConvert.number(lineHeight, fontSize);
8617
8600
  data.__letterSpacing = UnitConvert.number(letterSpacing, fontSize);
8618
8601
  data.__padding = padding ? MathHelper.fourNumber(padding) : undefined;
8619
8602
  data.__baseLine = data.__lineHeight - (data.__lineHeight - fontSize * 0.7) / 2;
8620
8603
  data.__font = `${italic ? 'italic ' : ''}${textCase === 'small-caps' ? 'small-caps ' : ''}${fontWeight !== 'normal' ? fontWeight + ' ' : ''}${fontSize}px ${fontFamily}`;
8621
8604
  data.__clipText = textOverflow !== 'show' && !data.__autoSize;
8605
+ data.__textDrawData = TextConvert.getDrawData(data.text, this.__);
8606
+ }
8607
+ __updateBoxBounds() {
8608
+ const data = this.__;
8609
+ const layout = this.__layout;
8610
+ const { fontSize, italic, padding, __autoWidth: autoWidth, __autoHeight: autoHeight } = data;
8622
8611
  this.__updateTextDrawData();
8623
8612
  const { bounds } = data.__textDrawData;
8624
8613
  const b = layout.boxBounds;
@@ -8631,20 +8620,15 @@ var LeaferUI = (function (exports) {
8631
8620
  b.height = autoHeight ? bounds.height : data.height;
8632
8621
  if (padding) {
8633
8622
  const [top, right, bottom, left] = data.__padding;
8634
- if (autoWidth) {
8635
- b.x -= left;
8636
- b.width += (right + left);
8637
- }
8638
- if (autoHeight) {
8639
- b.y -= top;
8640
- b.height += (bottom + top);
8641
- }
8623
+ if (autoWidth)
8624
+ b.x -= left, b.width += (right + left);
8625
+ if (autoHeight)
8626
+ b.y -= top, b.height += (bottom + top);
8642
8627
  }
8643
8628
  this.__updateNaturalSize();
8644
8629
  }
8645
- else {
8630
+ else
8646
8631
  super.__updateBoxBounds();
8647
- }
8648
8632
  if (italic)
8649
8633
  b.width += fontSize * 0.16;
8650
8634
  const contentBounds = includes(b, bounds) ? b : bounds;
@@ -8767,11 +8751,7 @@ var LeaferUI = (function (exports) {
8767
8751
  this.add(path);
8768
8752
  return this;
8769
8753
  }
8770
- beginPath() {
8771
- this.__path.length = 0;
8772
- this.paint();
8773
- return this;
8774
- }
8754
+ beginPath() { return this; }
8775
8755
  moveTo(_x, _y) { return this; }
8776
8756
  lineTo(_x, _y) { return this; }
8777
8757
  bezierCurveTo(_x1, _y1, _x2, _y2, _x, _y) { return this; }
@@ -8798,7 +8778,7 @@ var LeaferUI = (function (exports) {
8798
8778
  penPathType()
8799
8779
  ], exports.Pen.prototype, "path", void 0);
8800
8780
  exports.Pen = __decorate([
8801
- useModule(PathCreator, ['set', 'beginPath', 'path', 'paint']),
8781
+ useModule(PathCreator, ['set', 'path', 'paint']),
8802
8782
  registerUI()
8803
8783
  ], exports.Pen);
8804
8784
  function penPathType() {
@@ -8900,10 +8880,9 @@ var LeaferUI = (function (exports) {
8900
8880
  }
8901
8881
  __render(canvas, options) {
8902
8882
  if (canvas.context) {
8903
- if (options.matrix) {
8904
- const { a, b, c, d, e, f } = options.matrix;
8905
- canvas.setTransform(a, b, c, d, e, f);
8906
- }
8883
+ const m = options.matrix;
8884
+ if (m)
8885
+ canvas.setTransform(m.a, m.b, m.c, m.d, m.e, m.f);
8907
8886
  this.children.forEach(leafer => canvas.copyWorld(leafer.canvas));
8908
8887
  }
8909
8888
  }
@@ -8973,9 +8952,6 @@ var LeaferUI = (function (exports) {
8973
8952
  constructor(params) {
8974
8953
  super(params.type);
8975
8954
  this.bubbles = true;
8976
- this.getInner = this.getInnerPoint;
8977
- this.getLocal = this.getLocalPoint;
8978
- this.getPage = this.getPagePoint;
8979
8955
  Object.assign(this, params);
8980
8956
  }
8981
8957
  getBoxPoint(relative) {
@@ -8996,6 +8972,9 @@ var LeaferUI = (function (exports) {
8996
8972
  getPagePoint() {
8997
8973
  return this.current.getPagePoint(this);
8998
8974
  }
8975
+ getInner(relative) { return this.getInnerPoint(relative); }
8976
+ getLocal(relative) { return this.getLocalPoint(relative); }
8977
+ getPage() { return this.getPagePoint(); }
8999
8978
  static changeName(oldName, newName) {
9000
8979
  EventCreator.changeName(oldName, newName);
9001
8980
  }
@@ -9027,7 +9006,7 @@ var LeaferUI = (function (exports) {
9027
9006
  ], exports.PointerEvent);
9028
9007
  const MyPointerEvent = exports.PointerEvent;
9029
9008
 
9030
- const move$1 = {};
9009
+ const tempMove = {};
9031
9010
  exports.DragEvent = class DragEvent extends exports.PointerEvent {
9032
9011
  static setList(data) {
9033
9012
  this.list = data instanceof LeafList ? data : new LeafList(data);
@@ -9078,19 +9057,19 @@ var LeaferUI = (function (exports) {
9078
9057
  }
9079
9058
  getPageMove(total) {
9080
9059
  this.assignMove(total);
9081
- return this.current.getPagePoint(move$1, null, true);
9060
+ return this.current.getPagePoint(tempMove, null, true);
9082
9061
  }
9083
9062
  getInnerMove(relative, total) {
9084
9063
  if (!relative)
9085
9064
  relative = this.current;
9086
9065
  this.assignMove(total);
9087
- return relative.getInnerPoint(move$1, null, true);
9066
+ return relative.getInnerPoint(tempMove, null, true);
9088
9067
  }
9089
9068
  getLocalMove(relative, total) {
9090
9069
  if (!relative)
9091
9070
  relative = this.current;
9092
9071
  this.assignMove(total);
9093
- return relative.getLocalPoint(move$1, null, true);
9072
+ return relative.getLocalPoint(tempMove, null, true);
9094
9073
  }
9095
9074
  getPageTotal() {
9096
9075
  return this.getPageMove(true);
@@ -9110,8 +9089,8 @@ var LeaferUI = (function (exports) {
9110
9089
  return bounds;
9111
9090
  }
9112
9091
  assignMove(total) {
9113
- move$1.x = total ? this.totalX : this.moveX;
9114
- move$1.y = total ? this.totalY : this.moveY;
9092
+ tempMove.x = total ? this.totalX : this.moveX;
9093
+ tempMove.y = total ? this.totalY : this.moveY;
9115
9094
  }
9116
9095
  };
9117
9096
  exports.DragEvent.BEFORE_DRAG = 'drag.before_drag';
@@ -9525,9 +9504,8 @@ var LeaferUI = (function (exports) {
9525
9504
  interaction.emit(exports.DragEvent.OVER, data, path);
9526
9505
  }
9527
9506
  }
9528
- else {
9507
+ else
9529
9508
  interaction.emit(exports.DragEvent.OVER, data, path);
9530
- }
9531
9509
  }
9532
9510
  dragEnterOrLeave(data) {
9533
9511
  const { interaction } = this;
@@ -9548,9 +9526,8 @@ var LeaferUI = (function (exports) {
9548
9526
  this.drag(data);
9549
9527
  this.animate(() => { this.dragEnd(data, 1); });
9550
9528
  }
9551
- else {
9529
+ else
9552
9530
  this.dragEndReal(data);
9553
- }
9554
9531
  }
9555
9532
  dragEndReal(data) {
9556
9533
  const { interaction, downData, dragData } = this;
@@ -9747,14 +9724,16 @@ var LeaferUI = (function (exports) {
9747
9724
  class InteractionBase {
9748
9725
  get dragging() { return this.dragger.dragging; }
9749
9726
  get transforming() { return this.transformer.transforming; }
9750
- get moveMode() { return this.config.move.drag === true || this.isHoldSpaceKey || this.isHoldMiddleKey || (this.isHoldRightKey && this.dragger.moving) || this.isDragEmpty; }
9751
- get canHover() { return this.config.pointer.hover && !this.config.mobile; }
9752
- get isDragEmpty() { return this.config.move.dragEmpty && this.isRootPath(this.hoverData) && (!this.downData || this.isRootPath(this.downData)); }
9753
- get isMobileDragEmpty() { return this.config.move.dragEmpty && !this.canHover && this.downData && this.isTreePath(this.downData); }
9754
- get isHoldMiddleKey() { return this.config.move.holdMiddleKey && this.downData && PointerButton.middle(this.downData); }
9755
- get isHoldRightKey() { return this.config.move.holdRightKey && this.downData && PointerButton.right(this.downData); }
9756
- get isHoldSpaceKey() { return this.config.move.holdSpaceKey && Keyboard.isHoldSpaceKey(); }
9757
- get hitRadius() { return this.config.pointer.hitRadius; }
9727
+ get moveMode() { return this.m.drag === true || this.isHoldSpaceKey || this.isHoldMiddleKey || (this.isHoldRightKey && this.dragger.moving) || this.isDragEmpty; }
9728
+ get canHover() { return this.p.hover && !this.config.mobile; }
9729
+ get isDragEmpty() { return this.m.dragEmpty && this.isRootPath(this.hoverData) && (!this.downData || this.isRootPath(this.downData)); }
9730
+ get isMobileDragEmpty() { return this.m.dragEmpty && !this.canHover && this.downData && this.isTreePath(this.downData); }
9731
+ get isHoldMiddleKey() { return this.m.holdMiddleKey && this.downData && PointerButton.middle(this.downData); }
9732
+ get isHoldRightKey() { return this.m.holdRightKey && this.downData && PointerButton.right(this.downData); }
9733
+ get isHoldSpaceKey() { return this.m.holdSpaceKey && Keyboard.isHoldSpaceKey(); }
9734
+ get m() { return this.config.move; }
9735
+ get p() { return this.config.pointer; }
9736
+ get hitRadius() { return this.p.hitRadius; }
9758
9737
  constructor(target, canvas, selector, userConfig) {
9759
9738
  this.config = DataHelper.clone(config$1);
9760
9739
  this.tapCount = 0;
@@ -9812,7 +9791,7 @@ var LeaferUI = (function (exports) {
9812
9791
  }
9813
9792
  }
9814
9793
  pointerMoveReal(data) {
9815
- const { dragHover, dragDistance } = this.config.pointer;
9794
+ const { dragHover, dragDistance } = this.p;
9816
9795
  this.emit(exports.PointerEvent.BEFORE_MOVE, data, this.defaultPath);
9817
9796
  if (this.downData) {
9818
9797
  const canDrag = PointHelper.getDistance(this.downData, data) > dragDistance;
@@ -9997,7 +9976,7 @@ var LeaferUI = (function (exports) {
9997
9976
  }
9998
9977
  }
9999
9978
  findPath(data, options) {
10000
- const { hitRadius, through } = this.config.pointer;
9979
+ const { hitRadius, through } = this.p;
10001
9980
  const { bottomList } = this;
10002
9981
  const find = this.selector.getByPoint(data, hitRadius, Object.assign({ bottomList, name: data.type }, (options || { through })));
10003
9982
  if (find.throughPath)
@@ -10019,7 +9998,7 @@ var LeaferUI = (function (exports) {
10019
9998
  data.path = this.defaultPath;
10020
9999
  }
10021
10000
  canMove(data) {
10022
- return data && (this.moveMode || (this.config.move.drag === 'auto' && !pathCanDrag(data.path))) && !pathHasOutside(data.path);
10001
+ return data && (this.moveMode || (this.m.drag === 'auto' && !pathCanDrag(data.path))) && !pathHasOutside(data.path);
10023
10002
  }
10024
10003
  isDrag(leaf) {
10025
10004
  return this.dragger.getList().has(leaf);
@@ -10117,7 +10096,7 @@ var LeaferUI = (function (exports) {
10117
10096
  this.longPressTimer = setTimeout(() => {
10118
10097
  this.longPressed = true;
10119
10098
  this.emit(exports.PointerEvent.LONG_PRESS, data);
10120
- }, this.config.pointer.longPressTime);
10099
+ }, this.p.longPressTime);
10121
10100
  }
10122
10101
  longTap(data) {
10123
10102
  let hasLong;
@@ -10370,14 +10349,10 @@ var LeaferUI = (function (exports) {
10370
10349
  const { rows, decorationY, decorationHeight } = ui.__.__textDrawData;
10371
10350
  for (let i = 0, len = rows.length; i < len; i++) {
10372
10351
  row = rows[i];
10373
- if (row.text) {
10352
+ if (row.text)
10374
10353
  canvas.fillText(row.text, row.x, row.y);
10375
- }
10376
- else if (row.data) {
10377
- row.data.forEach(charData => {
10378
- canvas.fillText(charData.char, charData.x, row.y);
10379
- });
10380
- }
10354
+ else if (row.data)
10355
+ row.data.forEach(charData => { canvas.fillText(charData.char, charData.x, row.y); });
10381
10356
  if (decorationY)
10382
10357
  canvas.fillRect(row.x, row.y + decorationY, row.width, decorationHeight);
10383
10358
  }
@@ -10443,12 +10418,10 @@ var LeaferUI = (function (exports) {
10443
10418
  out.blendMode = align === 'outside' ? 'destination-out' : 'destination-in';
10444
10419
  fillText(ui, out);
10445
10420
  out.blendMode = 'normal';
10446
- if (ui.__worldFlipped) {
10421
+ if (ui.__worldFlipped)
10447
10422
  canvas.copyWorldByReset(out, ui.__nowWorld);
10448
- }
10449
- else {
10423
+ else
10450
10424
  canvas.copyWorldToInner(out, ui.__nowWorld, ui.__layout.renderBounds);
10451
- }
10452
10425
  out.recycle(ui.__nowWorld);
10453
10426
  }
10454
10427
  function drawTextStroke(ui, canvas) {
@@ -10456,14 +10429,10 @@ var LeaferUI = (function (exports) {
10456
10429
  const { rows, decorationY, decorationHeight } = ui.__.__textDrawData;
10457
10430
  for (let i = 0, len = rows.length; i < len; i++) {
10458
10431
  row = rows[i];
10459
- if (row.text) {
10432
+ if (row.text)
10460
10433
  canvas.strokeText(row.text, row.x, row.y);
10461
- }
10462
- else if (row.data) {
10463
- row.data.forEach(charData => {
10464
- canvas.strokeText(charData.char, charData.x, row.y);
10465
- });
10466
- }
10434
+ else if (row.data)
10435
+ row.data.forEach(charData => { canvas.strokeText(charData.char, charData.x, row.y); });
10467
10436
  if (decorationY)
10468
10437
  canvas.strokeRect(row.x, row.y + decorationY, row.width, decorationHeight);
10469
10438
  }
@@ -10516,12 +10485,10 @@ var LeaferUI = (function (exports) {
10516
10485
  out.stroke();
10517
10486
  options.windingRule ? out.clip(options.windingRule) : out.clip();
10518
10487
  out.clearWorld(ui.__layout.renderBounds);
10519
- if (ui.__worldFlipped) {
10488
+ if (ui.__worldFlipped)
10520
10489
  canvas.copyWorldByReset(out, ui.__nowWorld);
10521
- }
10522
- else {
10490
+ else
10523
10491
  canvas.copyWorldToInner(out, ui.__nowWorld, ui.__layout.renderBounds);
10524
- }
10525
10492
  out.recycle(ui.__nowWorld);
10526
10493
  break;
10527
10494
  }
@@ -10556,12 +10523,10 @@ var LeaferUI = (function (exports) {
10556
10523
  drawStrokesStyle(strokes, false, ui, out);
10557
10524
  options.windingRule ? out.clip(options.windingRule) : out.clip();
10558
10525
  out.clearWorld(renderBounds);
10559
- if (ui.__worldFlipped) {
10526
+ if (ui.__worldFlipped)
10560
10527
  canvas.copyWorldByReset(out, ui.__nowWorld);
10561
- }
10562
- else {
10528
+ else
10563
10529
  canvas.copyWorldToInner(out, ui.__nowWorld, renderBounds);
10564
- }
10565
10530
  out.recycle(ui.__nowWorld);
10566
10531
  break;
10567
10532
  }
@@ -10625,12 +10590,7 @@ var LeaferUI = (function (exports) {
10625
10590
  data['_' + attrName] = leafPaints.length ? leafPaints : undefined;
10626
10591
  if (leafPaints.length && leafPaints[0].image)
10627
10592
  hasOpacityPixel = leafPaints[0].image.hasOpacityPixel;
10628
- if (attrName === 'fill') {
10629
- data.__pixelFill = hasOpacityPixel;
10630
- }
10631
- else {
10632
- data.__pixelStroke = hasOpacityPixel;
10633
- }
10593
+ attrName === 'fill' ? data.__pixelFill = hasOpacityPixel : data.__pixelStroke = hasOpacityPixel;
10634
10594
  }
10635
10595
  function getLeafPaint(attrName, paint, ui) {
10636
10596
  if (typeof paint !== 'object' || paint.visible === false || paint.opacity === 0)
@@ -12891,7 +12851,8 @@ var LeaferUI = (function (exports) {
12891
12851
  }
12892
12852
  }
12893
12853
  function updateMoveCursor(editor) {
12894
- editor.editBox.rect.cursor = editor.mergeConfig.moveCursor;
12854
+ const { moveCursor, moveable } = editor.mergeConfig;
12855
+ editor.editBox.rect.cursor = moveable ? moveCursor : undefined;
12895
12856
  }
12896
12857
  function toDataURL(svg, rotation) {
12897
12858
  return '"data:image/svg+xml,' + encodeURIComponent(svg.replace('{{rotation}}', rotation.toString())) + '"';
@@ -12945,7 +12906,7 @@ var LeaferUI = (function (exports) {
12945
12906
  load() {
12946
12907
  const { mergeConfig, element, single } = this.editor;
12947
12908
  const { rect, circle, resizePoints } = this;
12948
- const { stroke, strokeWidth, moveable } = mergeConfig;
12909
+ const { stroke, strokeWidth } = mergeConfig;
12949
12910
  const pointsStyle = this.getPointsStyle();
12950
12911
  const middlePointsStyle = this.getMiddlePointsStyle();
12951
12912
  let resizeP;
@@ -12957,9 +12918,9 @@ var LeaferUI = (function (exports) {
12957
12918
  }
12958
12919
  circle.set(this.getPointStyle(mergeConfig.circle || mergeConfig.rotatePoint || pointsStyle[0]));
12959
12920
  rect.set(Object.assign({ stroke, strokeWidth }, (mergeConfig.rect || {})));
12960
- rect.hittable = !single && !!moveable;
12921
+ rect.hittable = !single;
12961
12922
  rect.syncEventer = single && this.editor;
12962
- if (single && moveable) {
12923
+ if (single) {
12963
12924
  element.syncEventer = rect;
12964
12925
  this.app.interaction.bottomList = [{ target: rect, proxy: element }];
12965
12926
  }
@@ -13839,10 +13800,10 @@ ${filterStyle}
13839
13800
  }
13840
13801
  destroy() {
13841
13802
  if (!this.destroyed) {
13842
- this.simulateTarget.destroy();
13803
+ this.target = this.hoverTarget = null;
13843
13804
  Object.values(this.editToolList).forEach(item => item.destroy());
13805
+ this.simulateTarget.destroy();
13844
13806
  this.editToolList = {};
13845
- this.target = this.hoverTarget = null;
13846
13807
  this.simulateTarget = this.editTool = this.innerEditor = null;
13847
13808
  super.destroy();
13848
13809
  }
@@ -13872,15 +13833,23 @@ ${filterStyle}
13872
13833
  }
13873
13834
  onLoad() { }
13874
13835
  load() {
13875
- this.editor.selector.hittable = this.editor.app.tree.hitChildren = false;
13876
- this.onLoad();
13836
+ const { editor } = this;
13837
+ if (editor) {
13838
+ if (editor.app)
13839
+ editor.selector.hittable = editor.app.tree.hitChildren = false;
13840
+ this.onLoad();
13841
+ }
13877
13842
  }
13878
13843
  onUpdate() { }
13879
13844
  update() { this.onUpdate(); }
13880
13845
  onUnload() { }
13881
13846
  unload() {
13882
- this.editor.selector.hittable = this.editor.app.tree.hitChildren = true;
13883
- this.onUnload();
13847
+ const { editor } = this;
13848
+ if (editor) {
13849
+ if (editor.app)
13850
+ editor.selector.hittable = editor.app.tree.hitChildren = true;
13851
+ this.onUnload();
13852
+ }
13884
13853
  }
13885
13854
  onDestroy() { }
13886
13855
  destroy() {
@@ -14748,7 +14717,8 @@ ${filterStyle}
14748
14717
  if (text) {
14749
14718
  this.onInput();
14750
14719
  text.visible = true;
14751
- editor.app.config.keyEvent = this._keyEvent;
14720
+ if (editor.app)
14721
+ editor.app.config.keyEvent = this._keyEvent;
14752
14722
  editor.off_(this.eventIds);
14753
14723
  dom.removeEventListener("focus", this.onFocus);
14754
14724
  dom.removeEventListener("input", this.onInput);