@leafer-editor/worker 1.1.2 → 1.2.1

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
@@ -1405,9 +1405,21 @@ var LeaferUI = (function (exports) {
1405
1405
  };
1406
1406
  const R = Run;
1407
1407
 
1408
- function needPlugin(name) {
1409
- console.error('need plugin: @leafer-in/' + name);
1410
- }
1408
+ const Plugin = {
1409
+ list: {},
1410
+ add(name) {
1411
+ this.list[name] = true;
1412
+ },
1413
+ check(name, tip) {
1414
+ const rs = this.list[name];
1415
+ if (!rs && tip)
1416
+ this.need(name);
1417
+ return rs;
1418
+ },
1419
+ need(name) {
1420
+ console.error('need plugin: @leafer-in/' + name);
1421
+ }
1422
+ };
1411
1423
 
1412
1424
  const debug$g = Debug.get('UICreator');
1413
1425
  const UICreator = {
@@ -5422,7 +5434,7 @@ var LeaferUI = (function (exports) {
5422
5434
  this.__[attrName] = value === undefined ? null : undefined;
5423
5435
  this[attrName] = value;
5424
5436
  }
5425
- forceRender(_bounds) {
5437
+ forceRender(_bounds, _sync) {
5426
5438
  this.forceUpdate('surface');
5427
5439
  }
5428
5440
  __updateWorldMatrix() { }
@@ -5632,10 +5644,10 @@ var LeaferUI = (function (exports) {
5632
5644
  __updatePath() { }
5633
5645
  __updateRenderPath() { }
5634
5646
  getMotionPathData() {
5635
- return needPlugin('path');
5647
+ return Plugin.need('path');
5636
5648
  }
5637
5649
  getMotionPoint(_motionDistance) {
5638
- return needPlugin('path');
5650
+ return Plugin.need('path');
5639
5651
  }
5640
5652
  getMotionTotal() {
5641
5653
  return 0;
@@ -5992,7 +6004,7 @@ var LeaferUI = (function (exports) {
5992
6004
  }
5993
6005
  }
5994
6006
 
5995
- const version = "1.1.1";
6007
+ const version = "1.2.1";
5996
6008
 
5997
6009
  class LeaferCanvas extends LeaferCanvasBase {
5998
6010
  get allowBackgroundColor() { return true; }
@@ -6990,8 +7002,8 @@ var LeaferUI = (function (exports) {
6990
7002
  const Effect = {};
6991
7003
  const Export = {};
6992
7004
  const State = {
6993
- setStyleName(_leaf, _styleName, _value) { return needPlugin('state'); },
6994
- set(_leaf, _stateName) { return needPlugin('state'); }
7005
+ setStyleName(_leaf, _styleName, _value) { return Plugin.need('state'); },
7006
+ set(_leaf, _stateName) { return Plugin.need('state'); }
6995
7007
  };
6996
7008
  const Transition = {
6997
7009
  list: {},
@@ -7492,7 +7504,7 @@ var LeaferUI = (function (exports) {
7492
7504
  drawer.rect(x, y, width, height);
7493
7505
  }
7494
7506
  animate(_keyframe, _options, _type, _isTemp) {
7495
- return needPlugin('animate');
7507
+ return Plugin.need('animate');
7496
7508
  }
7497
7509
  killAnimate(_type) { }
7498
7510
  export(filename, options) {
@@ -7891,10 +7903,13 @@ var LeaferUI = (function (exports) {
7891
7903
  const data = DataHelper.copyAttrs({}, size, canvasSizeAttrs);
7892
7904
  Object.keys(data).forEach(key => this[key] = data[key]);
7893
7905
  }
7894
- forceRender(bounds) {
7895
- this.renderer.addBlock(bounds ? new Bounds(bounds) : this.canvas.bounds);
7896
- if (this.viewReady)
7897
- this.renderer.render();
7906
+ forceRender(bounds, sync) {
7907
+ const { renderer } = this;
7908
+ if (renderer) {
7909
+ renderer.addBlock(bounds ? new Bounds(bounds) : this.canvas.bounds);
7910
+ if (this.viewReady)
7911
+ sync ? renderer.render() : renderer.update();
7912
+ }
7898
7913
  }
7899
7914
  requestRender(change = false) {
7900
7915
  if (this.renderer)
@@ -8070,7 +8085,7 @@ var LeaferUI = (function (exports) {
8070
8085
  this.requestRender();
8071
8086
  }
8072
8087
  zoom(_zoomType, _padding, _fixedScale) {
8073
- return needPlugin('view');
8088
+ return Plugin.need('view');
8074
8089
  }
8075
8090
  getValidMove(moveX, moveY) { return { x: moveX, y: moveY }; }
8076
8091
  getValidScale(changeScale) { return changeScale; }
@@ -8883,8 +8898,8 @@ var LeaferUI = (function (exports) {
8883
8898
  super.lockLayout();
8884
8899
  this.children.forEach(leafer => leafer.lockLayout());
8885
8900
  }
8886
- forceRender(bounds) {
8887
- this.children.forEach(leafer => leafer.forceRender(bounds));
8901
+ forceRender(bounds, sync) {
8902
+ this.children.forEach(leafer => leafer.forceRender(bounds, sync));
8888
8903
  }
8889
8904
  addLeafer(merge) {
8890
8905
  const leafer = new exports.Leafer(merge);
@@ -11809,218 +11824,6 @@ var LeaferUI = (function (exports) {
11809
11824
  });
11810
11825
  useCanvas();
11811
11826
 
11812
- const { M: M$2, L: L$2, C: C$2, Q: Q$2, Z: Z$1, N: N$1, D: D$1, X: X$1, G: G$1, F: F$1, O: O$2, P: P$1, U: U$1 } = PathCommandMap;
11813
- const PathScaler = {
11814
- scale(data, scaleX, scaleY) {
11815
- if (!data)
11816
- return;
11817
- let command;
11818
- let i = 0, len = data.length;
11819
- while (i < len) {
11820
- command = data[i];
11821
- switch (command) {
11822
- case M$2:
11823
- case L$2:
11824
- scalePoints(data, scaleX, scaleY, i, 1);
11825
- i += 3;
11826
- break;
11827
- case C$2:
11828
- scalePoints(data, scaleX, scaleY, i, 3);
11829
- i += 7;
11830
- break;
11831
- case Q$2:
11832
- scalePoints(data, scaleX, scaleY, i, 2);
11833
- i += 5;
11834
- break;
11835
- case Z$1:
11836
- i += 1;
11837
- break;
11838
- case N$1:
11839
- scalePoints(data, scaleX, scaleY, i, 2);
11840
- i += 5;
11841
- break;
11842
- case D$1:
11843
- scalePoints(data, scaleX, scaleY, i, 2);
11844
- i += 9;
11845
- break;
11846
- case X$1:
11847
- scalePoints(data, scaleX, scaleY, i, 2);
11848
- i += 6;
11849
- break;
11850
- case G$1:
11851
- scalePoints(data, scaleX, scaleY, i, 2);
11852
- i += 9;
11853
- break;
11854
- case F$1:
11855
- scalePoints(data, scaleX, scaleY, i, 2);
11856
- i += 5;
11857
- break;
11858
- case O$2:
11859
- data[i] = G$1;
11860
- data.splice(i + 4, 0, data[i + 3], 0);
11861
- scalePoints(data, scaleX, scaleY, i, 2);
11862
- i += 7 + 2;
11863
- len += 2;
11864
- break;
11865
- case P$1:
11866
- data[i] = F$1;
11867
- data.splice(i + 4, 0, data[i + 3]);
11868
- scalePoints(data, scaleX, scaleY, i, 2);
11869
- i += 4 + 1;
11870
- len += 1;
11871
- break;
11872
- case U$1:
11873
- scalePoints(data, scaleX, scaleY, i, 2);
11874
- i += 6;
11875
- break;
11876
- }
11877
- }
11878
- },
11879
- scalePoints(data, scaleX, scaleY, start, pointCount) {
11880
- for (let i = pointCount ? start + 1 : 0, end = pointCount ? i + pointCount * 2 : data.length; i < end; i += 2) {
11881
- data[i] *= scaleX;
11882
- data[i + 1] *= scaleY;
11883
- }
11884
- }
11885
- };
11886
- const { scalePoints } = PathScaler;
11887
-
11888
- const matrix$1 = MatrixHelper.get();
11889
- const { topLeft: topLeft$1, top: top$1, topRight: topRight$1, right: right$2, bottom: bottom$1, left: left$2 } = exports.Direction9;
11890
- function scaleResize(leaf, scaleX, scaleY) {
11891
- if (leaf.pathInputed) {
11892
- scaleResizePath(leaf, scaleX, scaleY);
11893
- }
11894
- else {
11895
- if (scaleX !== 1)
11896
- leaf.width *= scaleX;
11897
- if (scaleY !== 1)
11898
- leaf.height *= scaleY;
11899
- }
11900
- }
11901
- function scaleResizeFontSize(leaf, scaleX, scaleY) {
11902
- const { app } = leaf;
11903
- const editor = app && app.editor;
11904
- let fontScale = scaleX;
11905
- if (editor.editing) {
11906
- const layout = leaf.__layout;
11907
- let { width, height } = layout.boxBounds;
11908
- width *= scaleY - scaleX;
11909
- height *= scaleX - scaleY;
11910
- switch (editor.resizeDirection) {
11911
- case top$1:
11912
- case bottom$1:
11913
- fontScale = scaleY;
11914
- layout.affectScaleOrRotation ? leaf.moveInner(-width / 2, 0) : leaf.x -= width / 2;
11915
- break;
11916
- case left$2:
11917
- case right$2:
11918
- layout.affectScaleOrRotation ? leaf.moveInner(0, -height / 2) : leaf.y -= height / 2;
11919
- break;
11920
- case topLeft$1:
11921
- case topRight$1:
11922
- layout.affectScaleOrRotation ? leaf.moveInner(0, -height) : leaf.y -= height;
11923
- break;
11924
- }
11925
- }
11926
- leaf.fontSize *= fontScale;
11927
- const data = leaf.__;
11928
- if (!data.__autoWidth)
11929
- leaf.width *= fontScale;
11930
- if (!data.__autoHeight)
11931
- leaf.height *= fontScale;
11932
- }
11933
- function scaleResizePath(leaf, scaleX, scaleY) {
11934
- PathScaler.scale(leaf.__.path, scaleX, scaleY);
11935
- leaf.path = leaf.__.path;
11936
- }
11937
- function scaleResizePoints(leaf, scaleX, scaleY) {
11938
- const { points } = leaf;
11939
- typeof points[0] === 'object' ? points.forEach(p => { p.x *= scaleX, p.y *= scaleY; }) : PathScaler.scalePoints(points, scaleX, scaleY);
11940
- leaf.points = points;
11941
- }
11942
- function scaleResizeGroup(group, scaleX, scaleY) {
11943
- const { children } = group;
11944
- for (let i = 0; i < children.length; i++) {
11945
- matrix$1.a = scaleX;
11946
- matrix$1.d = scaleY;
11947
- children[i].transform(matrix$1, true);
11948
- }
11949
- }
11950
-
11951
- const leaf = exports.Leaf.prototype;
11952
- leaf.scaleResize = function (scaleX, scaleY = scaleX, noResize) {
11953
- const data = this;
11954
- if (noResize || (data.editConfig && data.editConfig.editSize === 'scale')) {
11955
- data.scaleX *= scaleX;
11956
- data.scaleY *= scaleY;
11957
- }
11958
- else {
11959
- if (scaleX < 0)
11960
- data.scaleX *= -1, scaleX = -scaleX;
11961
- if (scaleY < 0)
11962
- data.scaleY *= -1, scaleY = -scaleY;
11963
- this.__scaleResize(scaleX, scaleY);
11964
- }
11965
- };
11966
- leaf.__scaleResize = function (scaleX, scaleY) {
11967
- scaleResize(this, scaleX, scaleY);
11968
- };
11969
- leaf.resizeWidth = function (width) {
11970
- const scale = width / this.getBounds('box', 'local').width;
11971
- this.scaleOf(this.__layout.boxBounds, scale, this.__.lockRatio ? scale : 1, true);
11972
- };
11973
- leaf.resizeHeight = function (height) {
11974
- const scale = height / this.getBounds('box', 'local').height;
11975
- this.scaleOf(this.__layout.boxBounds, this.__.lockRatio ? scale : 1, scale, true);
11976
- };
11977
- exports.Text.prototype.__scaleResize = function (scaleX, scaleY) {
11978
- if (this.__.resizeFontSize || (this.editConfig && this.editConfig.editSize === 'font-size')) {
11979
- scaleResizeFontSize(this, scaleX, scaleY);
11980
- }
11981
- else {
11982
- scaleResize(this, scaleX, scaleY);
11983
- }
11984
- };
11985
- exports.Path.prototype.__scaleResize = function (scaleX, scaleY) {
11986
- scaleResizePath(this, scaleX, scaleY);
11987
- };
11988
- exports.Line.prototype.__scaleResize = function (scaleX, scaleY) {
11989
- if (this.pathInputed) {
11990
- scaleResizePath(this, scaleX, scaleY);
11991
- }
11992
- else if (this.points) {
11993
- scaleResizePoints(this, scaleX, scaleY);
11994
- }
11995
- else {
11996
- this.width *= scaleX;
11997
- }
11998
- };
11999
- exports.Polygon.prototype.__scaleResize = function (scaleX, scaleY) {
12000
- if (this.pathInputed) {
12001
- scaleResizePath(this, scaleX, scaleY);
12002
- }
12003
- else if (this.points) {
12004
- scaleResizePoints(this, scaleX, scaleY);
12005
- }
12006
- else {
12007
- scaleResize(this, scaleX, scaleY);
12008
- }
12009
- };
12010
- exports.Group.prototype.__scaleResize = function (scaleX, scaleY) {
12011
- scaleResizeGroup(this, scaleX, scaleY);
12012
- };
12013
- exports.Box.prototype.__scaleResize = function (scaleX, scaleY) {
12014
- if (this.__.__autoSize && this.children.length) {
12015
- scaleResizeGroup(this, scaleX, scaleY);
12016
- }
12017
- else {
12018
- scaleResize(this, scaleX, scaleY);
12019
- if (this.__.resizeChildren)
12020
- scaleResizeGroup(this, scaleX, scaleY);
12021
- }
12022
- };
12023
-
12024
11827
  function toList(value) {
12025
11828
  return value ? (value instanceof Array ? value : [value]) : [];
12026
11829
  }
@@ -12082,7 +11885,7 @@ var LeaferUI = (function (exports) {
12082
11885
  const { copy: copy$2, scale: scale$1 } = MatrixHelper;
12083
11886
  const { setListWithFn } = BoundsHelper;
12084
11887
  const { worldBounds } = LeafBoundsHelper;
12085
- const matrix = getMatrixData();
11888
+ const matrix$1 = getMatrixData();
12086
11889
  const bounds$2 = getBoundsData();
12087
11890
  class Stroker extends exports.UI {
12088
11891
  constructor() {
@@ -12117,9 +11920,9 @@ var LeaferUI = (function (exports) {
12117
11920
  if (!bounds || bounds.hit(worldRenderBounds, options.matrix)) {
12118
11921
  const aScaleX = abs$1(worldTransform.scaleX), aScaleY = abs$1(worldTransform.scaleY);
12119
11922
  if (aScaleX !== aScaleY) {
12120
- copy$2(matrix, worldTransform);
12121
- scale$1(matrix, 1 / aScaleX, 1 / aScaleY);
12122
- canvas.setWorld(matrix, options.matrix);
11923
+ copy$2(matrix$1, worldTransform);
11924
+ scale$1(matrix$1, 1 / aScaleX, 1 / aScaleY);
11925
+ canvas.setWorld(matrix$1, options.matrix);
12123
11926
  canvas.beginPath();
12124
11927
  data.strokeWidth = strokeWidth;
12125
11928
  const { x, y, width, height } = leaf.__layout.boxBounds;
@@ -12414,7 +12217,7 @@ var LeaferUI = (function (exports) {
12414
12217
  }
12415
12218
  }
12416
12219
 
12417
- const { topLeft, top, topRight, right: right$1, bottomRight, bottom, bottomLeft, left: left$1 } = exports.Direction9;
12220
+ const { topLeft: topLeft$1, top: top$1, topRight: topRight$1, right: right$2, bottomRight, bottom: bottom$1, bottomLeft, left: left$2 } = exports.Direction9;
12418
12221
  const { toPoint } = AroundHelper;
12419
12222
  const { within } = MathHelper;
12420
12223
  const EditDataHelper = {
@@ -12443,28 +12246,28 @@ var LeaferUI = (function (exports) {
12443
12246
  const bottomScale = (totalMove.y + height) / height;
12444
12247
  const leftScale = (-totalMove.x + width) / width;
12445
12248
  switch (direction) {
12446
- case top:
12249
+ case top$1:
12447
12250
  scaleY = topScale;
12448
12251
  align = 'bottom';
12449
12252
  break;
12450
- case right$1:
12253
+ case right$2:
12451
12254
  scaleX = rightScale;
12452
12255
  align = 'left';
12453
12256
  break;
12454
- case bottom:
12257
+ case bottom$1:
12455
12258
  scaleY = bottomScale;
12456
12259
  align = 'top';
12457
12260
  break;
12458
- case left$1:
12261
+ case left$2:
12459
12262
  scaleX = leftScale;
12460
12263
  align = 'right';
12461
12264
  break;
12462
- case topLeft:
12265
+ case topLeft$1:
12463
12266
  scaleY = topScale;
12464
12267
  scaleX = leftScale;
12465
12268
  align = 'bottom-right';
12466
12269
  break;
12467
- case topRight:
12270
+ case topRight$1:
12468
12271
  scaleY = topScale;
12469
12272
  scaleX = rightScale;
12470
12273
  align = 'bottom-left';
@@ -12484,12 +12287,12 @@ var LeaferUI = (function (exports) {
12484
12287
  if (!unlockSide) {
12485
12288
  let scale;
12486
12289
  switch (direction) {
12487
- case top:
12488
- case bottom:
12290
+ case top$1:
12291
+ case bottom$1:
12489
12292
  scale = scaleY;
12490
12293
  break;
12491
- case left$1:
12492
- case right$1:
12294
+ case left$2:
12295
+ case right$2:
12493
12296
  scale = scaleX;
12494
12297
  break;
12495
12298
  default:
@@ -12522,10 +12325,10 @@ var LeaferUI = (function (exports) {
12522
12325
  getRotateData(bounds, direction, current, last, around) {
12523
12326
  let align, origin = {};
12524
12327
  switch (direction) {
12525
- case topLeft:
12328
+ case topLeft$1:
12526
12329
  align = 'bottom-right';
12527
12330
  break;
12528
- case topRight:
12331
+ case topRight$1:
12529
12332
  align = 'bottom-left';
12530
12333
  break;
12531
12334
  case bottomRight:
@@ -12544,22 +12347,22 @@ var LeaferUI = (function (exports) {
12544
12347
  let align, origin = {}, skewX = 0, skewY = 0;
12545
12348
  let last;
12546
12349
  switch (direction) {
12547
- case top:
12350
+ case top$1:
12548
12351
  last = { x: 0.5, y: 0 };
12549
12352
  align = 'bottom';
12550
12353
  skewX = 1;
12551
12354
  break;
12552
- case bottom:
12355
+ case bottom$1:
12553
12356
  last = { x: 0.5, y: 1 };
12554
12357
  align = 'top';
12555
12358
  skewX = 1;
12556
12359
  break;
12557
- case left$1:
12360
+ case left$2:
12558
12361
  last = { x: 0, y: 0.5 };
12559
12362
  align = 'right';
12560
12363
  skewY = 1;
12561
12364
  break;
12562
- case right$1:
12365
+ case right$2:
12563
12366
  last = { x: 1, y: 0.5 };
12564
12367
  align = 'left';
12565
12368
  skewY = 1;
@@ -12584,20 +12387,20 @@ var LeaferUI = (function (exports) {
12584
12387
  getFlipDirection(direction, flipedX, flipedY) {
12585
12388
  if (flipedX) {
12586
12389
  switch (direction) {
12587
- case left$1:
12588
- direction = right$1;
12390
+ case left$2:
12391
+ direction = right$2;
12589
12392
  break;
12590
- case topLeft:
12591
- direction = topRight;
12393
+ case topLeft$1:
12394
+ direction = topRight$1;
12592
12395
  break;
12593
12396
  case bottomLeft:
12594
12397
  direction = bottomRight;
12595
12398
  break;
12596
- case right$1:
12597
- direction = left$1;
12399
+ case right$2:
12400
+ direction = left$2;
12598
12401
  break;
12599
- case topRight:
12600
- direction = topLeft;
12402
+ case topRight$1:
12403
+ direction = topLeft$1;
12601
12404
  break;
12602
12405
  case bottomRight:
12603
12406
  direction = bottomLeft;
@@ -12606,23 +12409,23 @@ var LeaferUI = (function (exports) {
12606
12409
  }
12607
12410
  if (flipedY) {
12608
12411
  switch (direction) {
12609
- case top:
12610
- direction = bottom;
12412
+ case top$1:
12413
+ direction = bottom$1;
12611
12414
  break;
12612
- case topLeft:
12415
+ case topLeft$1:
12613
12416
  direction = bottomLeft;
12614
12417
  break;
12615
- case topRight:
12418
+ case topRight$1:
12616
12419
  direction = bottomRight;
12617
12420
  break;
12618
- case bottom:
12619
- direction = top;
12421
+ case bottom$1:
12422
+ direction = top$1;
12620
12423
  break;
12621
12424
  case bottomLeft:
12622
- direction = topLeft;
12425
+ direction = topLeft$1;
12623
12426
  break;
12624
12427
  case bottomRight:
12625
- direction = topRight;
12428
+ direction = topRight$1;
12626
12429
  break;
12627
12430
  }
12628
12431
  }
@@ -13285,6 +13088,8 @@ ${filterStyle}
13285
13088
  if (userConfig)
13286
13089
  this.config = DataHelper.default(userConfig, this.config);
13287
13090
  this.addMany(this.editMask, this.selector, this.editBox);
13091
+ if (!Plugin.check('resize', true))
13092
+ this.config.editSize = 'scale';
13288
13093
  }
13289
13094
  select(target) {
13290
13095
  this.target = target;
@@ -13756,7 +13561,7 @@ ${filterStyle}
13756
13561
  registerEditTool()
13757
13562
  ], exports.EditTool);
13758
13563
 
13759
- const { left, right } = exports.Direction9;
13564
+ const { left: left$1, right: right$1 } = exports.Direction9;
13760
13565
  const { move, copy: copy$1, toNumberPoints } = PointHelper;
13761
13566
  exports.LineEditTool = class LineEditTool extends exports.EditTool {
13762
13567
  constructor() {
@@ -13767,7 +13572,7 @@ ${filterStyle}
13767
13572
  onScaleWithDrag(e) {
13768
13573
  const { drag, direction, lockRatio, around } = e;
13769
13574
  const line = e.target;
13770
- const isDragFrom = direction === left;
13575
+ const isDragFrom = direction === left$1;
13771
13576
  if (line.pathInputed) {
13772
13577
  const { path } = line.__;
13773
13578
  const { from, to } = this.getFromToByPath(path);
@@ -13852,7 +13657,7 @@ ${filterStyle}
13852
13657
  for (let i = 0; i < 8; i++) {
13853
13658
  if (i < 4)
13854
13659
  resizeLines[i].visible = false;
13855
- leftOrRight = i === left || i === right;
13660
+ leftOrRight = i === left$1 || i === right$1;
13856
13661
  resizePoints[i].visible = leftOrRight;
13857
13662
  rotatePoints[i].visible = fromTo ? false : leftOrRight;
13858
13663
  }
@@ -13862,6 +13667,221 @@ ${filterStyle}
13862
13667
  registerEditTool()
13863
13668
  ], exports.LineEditTool);
13864
13669
 
13670
+ const { M: M$2, L: L$2, C: C$2, Q: Q$2, Z: Z$1, N: N$1, D: D$1, X: X$1, G: G$1, F: F$1, O: O$2, P: P$1, U: U$1 } = PathCommandMap;
13671
+ const PathScaler = {
13672
+ scale(data, scaleX, scaleY) {
13673
+ if (!data)
13674
+ return;
13675
+ let command;
13676
+ let i = 0, len = data.length;
13677
+ while (i < len) {
13678
+ command = data[i];
13679
+ switch (command) {
13680
+ case M$2:
13681
+ case L$2:
13682
+ scalePoints(data, scaleX, scaleY, i, 1);
13683
+ i += 3;
13684
+ break;
13685
+ case C$2:
13686
+ scalePoints(data, scaleX, scaleY, i, 3);
13687
+ i += 7;
13688
+ break;
13689
+ case Q$2:
13690
+ scalePoints(data, scaleX, scaleY, i, 2);
13691
+ i += 5;
13692
+ break;
13693
+ case Z$1:
13694
+ i += 1;
13695
+ break;
13696
+ case N$1:
13697
+ scalePoints(data, scaleX, scaleY, i, 2);
13698
+ i += 5;
13699
+ break;
13700
+ case D$1:
13701
+ scalePoints(data, scaleX, scaleY, i, 2);
13702
+ i += 9;
13703
+ break;
13704
+ case X$1:
13705
+ scalePoints(data, scaleX, scaleY, i, 2);
13706
+ i += 6;
13707
+ break;
13708
+ case G$1:
13709
+ scalePoints(data, scaleX, scaleY, i, 2);
13710
+ i += 9;
13711
+ break;
13712
+ case F$1:
13713
+ scalePoints(data, scaleX, scaleY, i, 2);
13714
+ i += 5;
13715
+ break;
13716
+ case O$2:
13717
+ data[i] = G$1;
13718
+ data.splice(i + 4, 0, data[i + 3], 0);
13719
+ scalePoints(data, scaleX, scaleY, i, 2);
13720
+ i += 7 + 2;
13721
+ len += 2;
13722
+ break;
13723
+ case P$1:
13724
+ data[i] = F$1;
13725
+ data.splice(i + 4, 0, data[i + 3]);
13726
+ scalePoints(data, scaleX, scaleY, i, 2);
13727
+ i += 4 + 1;
13728
+ len += 1;
13729
+ break;
13730
+ case U$1:
13731
+ scalePoints(data, scaleX, scaleY, i, 2);
13732
+ i += 6;
13733
+ break;
13734
+ }
13735
+ }
13736
+ },
13737
+ scalePoints(data, scaleX, scaleY, start, pointCount) {
13738
+ for (let i = pointCount ? start + 1 : 0, end = pointCount ? i + pointCount * 2 : data.length; i < end; i += 2) {
13739
+ data[i] *= scaleX;
13740
+ data[i + 1] *= scaleY;
13741
+ }
13742
+ }
13743
+ };
13744
+ const { scalePoints } = PathScaler;
13745
+
13746
+ const matrix = MatrixHelper.get();
13747
+ const { topLeft, top, topRight, right, bottom, left } = exports.Direction9;
13748
+ function scaleResize(leaf, scaleX, scaleY) {
13749
+ if (leaf.pathInputed) {
13750
+ scaleResizePath(leaf, scaleX, scaleY);
13751
+ }
13752
+ else {
13753
+ if (scaleX !== 1)
13754
+ leaf.width *= scaleX;
13755
+ if (scaleY !== 1)
13756
+ leaf.height *= scaleY;
13757
+ }
13758
+ }
13759
+ function scaleResizeFontSize(leaf, scaleX, scaleY) {
13760
+ const { app } = leaf;
13761
+ const editor = app && app.editor;
13762
+ let fontScale = scaleX;
13763
+ if (editor.editing) {
13764
+ const layout = leaf.__layout;
13765
+ let { width, height } = layout.boxBounds;
13766
+ width *= scaleY - scaleX;
13767
+ height *= scaleX - scaleY;
13768
+ switch (editor.resizeDirection) {
13769
+ case top:
13770
+ case bottom:
13771
+ fontScale = scaleY;
13772
+ layout.affectScaleOrRotation ? leaf.moveInner(-width / 2, 0) : leaf.x -= width / 2;
13773
+ break;
13774
+ case left:
13775
+ case right:
13776
+ layout.affectScaleOrRotation ? leaf.moveInner(0, -height / 2) : leaf.y -= height / 2;
13777
+ break;
13778
+ case topLeft:
13779
+ case topRight:
13780
+ layout.affectScaleOrRotation ? leaf.moveInner(0, -height) : leaf.y -= height;
13781
+ break;
13782
+ }
13783
+ }
13784
+ leaf.fontSize *= fontScale;
13785
+ const data = leaf.__;
13786
+ if (!data.__autoWidth)
13787
+ leaf.width *= fontScale;
13788
+ if (!data.__autoHeight)
13789
+ leaf.height *= fontScale;
13790
+ }
13791
+ function scaleResizePath(leaf, scaleX, scaleY) {
13792
+ PathScaler.scale(leaf.__.path, scaleX, scaleY);
13793
+ leaf.path = leaf.__.path;
13794
+ }
13795
+ function scaleResizePoints(leaf, scaleX, scaleY) {
13796
+ const { points } = leaf;
13797
+ typeof points[0] === 'object' ? points.forEach(p => { p.x *= scaleX, p.y *= scaleY; }) : PathScaler.scalePoints(points, scaleX, scaleY);
13798
+ leaf.points = points;
13799
+ }
13800
+ function scaleResizeGroup(group, scaleX, scaleY) {
13801
+ const { children } = group;
13802
+ for (let i = 0; i < children.length; i++) {
13803
+ matrix.a = scaleX;
13804
+ matrix.d = scaleY;
13805
+ children[i].transform(matrix, true);
13806
+ }
13807
+ }
13808
+
13809
+ const leaf = exports.Leaf.prototype;
13810
+ leaf.scaleResize = function (scaleX, scaleY = scaleX, noResize) {
13811
+ const data = this;
13812
+ if (noResize || (data.editConfig && data.editConfig.editSize === 'scale')) {
13813
+ data.scaleX *= scaleX;
13814
+ data.scaleY *= scaleY;
13815
+ }
13816
+ else {
13817
+ if (scaleX < 0)
13818
+ data.scaleX *= -1, scaleX = -scaleX;
13819
+ if (scaleY < 0)
13820
+ data.scaleY *= -1, scaleY = -scaleY;
13821
+ this.__scaleResize(scaleX, scaleY);
13822
+ }
13823
+ };
13824
+ leaf.__scaleResize = function (scaleX, scaleY) {
13825
+ scaleResize(this, scaleX, scaleY);
13826
+ };
13827
+ leaf.resizeWidth = function (width) {
13828
+ const scale = width / this.getBounds('box', 'local').width;
13829
+ this.scaleOf(this.__layout.boxBounds, scale, this.__.lockRatio ? scale : 1, true);
13830
+ };
13831
+ leaf.resizeHeight = function (height) {
13832
+ const scale = height / this.getBounds('box', 'local').height;
13833
+ this.scaleOf(this.__layout.boxBounds, this.__.lockRatio ? scale : 1, scale, true);
13834
+ };
13835
+ exports.Text.prototype.__scaleResize = function (scaleX, scaleY) {
13836
+ if (this.__.resizeFontSize || (this.editConfig && this.editConfig.editSize === 'font-size')) {
13837
+ scaleResizeFontSize(this, scaleX, scaleY);
13838
+ }
13839
+ else {
13840
+ scaleResize(this, scaleX, scaleY);
13841
+ }
13842
+ };
13843
+ exports.Path.prototype.__scaleResize = function (scaleX, scaleY) {
13844
+ scaleResizePath(this, scaleX, scaleY);
13845
+ };
13846
+ exports.Line.prototype.__scaleResize = function (scaleX, scaleY) {
13847
+ if (this.pathInputed) {
13848
+ scaleResizePath(this, scaleX, scaleY);
13849
+ }
13850
+ else if (this.points) {
13851
+ scaleResizePoints(this, scaleX, scaleY);
13852
+ }
13853
+ else {
13854
+ this.width *= scaleX;
13855
+ }
13856
+ };
13857
+ exports.Polygon.prototype.__scaleResize = function (scaleX, scaleY) {
13858
+ if (this.pathInputed) {
13859
+ scaleResizePath(this, scaleX, scaleY);
13860
+ }
13861
+ else if (this.points) {
13862
+ scaleResizePoints(this, scaleX, scaleY);
13863
+ }
13864
+ else {
13865
+ scaleResize(this, scaleX, scaleY);
13866
+ }
13867
+ };
13868
+ exports.Group.prototype.__scaleResize = function (scaleX, scaleY) {
13869
+ scaleResizeGroup(this, scaleX, scaleY);
13870
+ };
13871
+ exports.Box.prototype.__scaleResize = function (scaleX, scaleY) {
13872
+ if (this.__.__autoSize && this.children.length) {
13873
+ scaleResizeGroup(this, scaleX, scaleY);
13874
+ }
13875
+ else {
13876
+ scaleResize(this, scaleX, scaleY);
13877
+ if (this.__.resizeChildren)
13878
+ scaleResizeGroup(this, scaleX, scaleY);
13879
+ }
13880
+ };
13881
+
13882
+ Plugin.add('resize');
13883
+
13884
+ Plugin.add('editor');
13865
13885
  Creator.editor = function (options) { return new Editor(options); };
13866
13886
  dataType(false)(exports.Box.prototype, 'textBox');
13867
13887
  defineKey(exports.UI.prototype, 'editOuter', {
@@ -14235,6 +14255,8 @@ ${filterStyle}
14235
14255
  }
14236
14256
  };
14237
14257
 
14258
+ Plugin.add('viewport');
14259
+
14238
14260
  function getZoomScale(scaleX, type) {
14239
14261
  let scale = 1;
14240
14262
  const out = type === 'out', absScale = Math.abs(scaleX);
@@ -14262,6 +14284,7 @@ ${filterStyle}
14262
14284
  return fix ? { x, y, width, height } : bounds;
14263
14285
  }
14264
14286
 
14287
+ Plugin.add('view');
14265
14288
  exports.Leafer.prototype.zoom = function (zoomType, padding, fixed) {
14266
14289
  const { zoomLayer } = this;
14267
14290
  const limitBounds = this.canvas.bounds.clone().shrink(padding !== undefined ? padding : 30), bounds = new Bounds();
@@ -14434,6 +14457,8 @@ ${filterStyle}
14434
14457
  }
14435
14458
  }
14436
14459
 
14460
+ Plugin.add('scroll');
14461
+
14437
14462
  class ArrowData extends LineData {
14438
14463
  }
14439
14464
 
@@ -14693,6 +14718,7 @@ ${filterStyle}
14693
14718
  }));
14694
14719
  }
14695
14720
 
14721
+ Plugin.add('arrow');
14696
14722
  const ui = exports.UI.prototype;
14697
14723
  arrowType('none')(ui, 'startArrow');
14698
14724
  arrowType('none')(ui, 'endArrow');
@@ -14900,6 +14926,9 @@ ${filterStyle}
14900
14926
  registerInnerEditor()
14901
14927
  ], exports.TextEditor);
14902
14928
 
14929
+ Plugin.add('text-editor');
14930
+ setTimeout(() => Plugin.check('editor', true));
14931
+
14903
14932
  class HTMLTextData extends ImageData {
14904
14933
  setText(value) {
14905
14934
  this._text = value;
@@ -14958,6 +14987,8 @@ ${filterStyle}
14958
14987
  registerUI()
14959
14988
  ], exports.HTMLText);
14960
14989
 
14990
+ Plugin.add('html');
14991
+
14961
14992
  exports.AlignHelper = AlignHelper;
14962
14993
  exports.AroundHelper = AroundHelper;
14963
14994
  exports.ArrowData = ArrowData;
@@ -15060,9 +15091,9 @@ ${filterStyle}
15060
15091
  exports.PathMatrixHelper = PathMatrixHelper;
15061
15092
  exports.PathNumberCommandLengthMap = PathNumberCommandLengthMap;
15062
15093
  exports.PathNumberCommandMap = PathNumberCommandMap;
15063
- exports.PathScaler = PathScaler;
15064
15094
  exports.PenData = PenData;
15065
15095
  exports.Platform = Platform;
15096
+ exports.Plugin = Plugin;
15066
15097
  exports.Point = Point;
15067
15098
  exports.PointHelper = PointHelper;
15068
15099
  exports.PointerButton = PointerButton;
@@ -15130,7 +15161,6 @@ ${filterStyle}
15130
15161
  exports.layoutProcessor = layoutProcessor;
15131
15162
  exports.maskType = maskType;
15132
15163
  exports.naturalBoundsType = naturalBoundsType;
15133
- exports.needPlugin = needPlugin;
15134
15164
  exports.opacityType = opacityType;
15135
15165
  exports.pathInputType = pathInputType;
15136
15166
  exports.pathType = pathType;
@@ -15144,11 +15174,6 @@ ${filterStyle}
15144
15174
  exports.rewrite = rewrite;
15145
15175
  exports.rewriteAble = rewriteAble;
15146
15176
  exports.rotationType = rotationType;
15147
- exports.scaleResize = scaleResize;
15148
- exports.scaleResizeFontSize = scaleResizeFontSize;
15149
- exports.scaleResizeGroup = scaleResizeGroup;
15150
- exports.scaleResizePath = scaleResizePath;
15151
- exports.scaleResizePoints = scaleResizePoints;
15152
15177
  exports.scaleType = scaleType;
15153
15178
  exports.sortType = sortType;
15154
15179
  exports.strokeType = strokeType;