@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.
@@ -1402,9 +1402,21 @@ const Run = {
1402
1402
  };
1403
1403
  const R = Run;
1404
1404
 
1405
- function needPlugin(name) {
1406
- console.error('need plugin: @leafer-in/' + name);
1407
- }
1405
+ const Plugin = {
1406
+ list: {},
1407
+ add(name) {
1408
+ this.list[name] = true;
1409
+ },
1410
+ check(name, tip) {
1411
+ const rs = this.list[name];
1412
+ if (!rs && tip)
1413
+ this.need(name);
1414
+ return rs;
1415
+ },
1416
+ need(name) {
1417
+ console.error('need plugin: @leafer-in/' + name);
1418
+ }
1419
+ };
1408
1420
 
1409
1421
  const debug$g = Debug.get('UICreator');
1410
1422
  const UICreator = {
@@ -5419,7 +5431,7 @@ let Leaf = class Leaf {
5419
5431
  this.__[attrName] = value === undefined ? null : undefined;
5420
5432
  this[attrName] = value;
5421
5433
  }
5422
- forceRender(_bounds) {
5434
+ forceRender(_bounds, _sync) {
5423
5435
  this.forceUpdate('surface');
5424
5436
  }
5425
5437
  __updateWorldMatrix() { }
@@ -5629,10 +5641,10 @@ let Leaf = class Leaf {
5629
5641
  __updatePath() { }
5630
5642
  __updateRenderPath() { }
5631
5643
  getMotionPathData() {
5632
- return needPlugin('path');
5644
+ return Plugin.need('path');
5633
5645
  }
5634
5646
  getMotionPoint(_motionDistance) {
5635
- return needPlugin('path');
5647
+ return Plugin.need('path');
5636
5648
  }
5637
5649
  getMotionTotal() {
5638
5650
  return 0;
@@ -5989,7 +6001,7 @@ class LeafLevelList {
5989
6001
  }
5990
6002
  }
5991
6003
 
5992
- const version = "1.1.1";
6004
+ const version = "1.2.1";
5993
6005
 
5994
6006
  class LeaferCanvas extends LeaferCanvasBase {
5995
6007
  get allowBackgroundColor() { return true; }
@@ -6987,8 +6999,8 @@ const PaintGradient = {};
6987
6999
  const Effect = {};
6988
7000
  const Export = {};
6989
7001
  const State = {
6990
- setStyleName(_leaf, _styleName, _value) { return needPlugin('state'); },
6991
- set(_leaf, _stateName) { return needPlugin('state'); }
7002
+ setStyleName(_leaf, _styleName, _value) { return Plugin.need('state'); },
7003
+ set(_leaf, _stateName) { return Plugin.need('state'); }
6992
7004
  };
6993
7005
  const Transition = {
6994
7006
  list: {},
@@ -7489,7 +7501,7 @@ let UI = UI_1 = class UI extends Leaf {
7489
7501
  drawer.rect(x, y, width, height);
7490
7502
  }
7491
7503
  animate(_keyframe, _options, _type, _isTemp) {
7492
- return needPlugin('animate');
7504
+ return Plugin.need('animate');
7493
7505
  }
7494
7506
  killAnimate(_type) { }
7495
7507
  export(filename, options) {
@@ -7888,10 +7900,13 @@ let Leafer = Leafer_1 = class Leafer extends Group {
7888
7900
  const data = DataHelper.copyAttrs({}, size, canvasSizeAttrs);
7889
7901
  Object.keys(data).forEach(key => this[key] = data[key]);
7890
7902
  }
7891
- forceRender(bounds) {
7892
- this.renderer.addBlock(bounds ? new Bounds(bounds) : this.canvas.bounds);
7893
- if (this.viewReady)
7894
- this.renderer.render();
7903
+ forceRender(bounds, sync) {
7904
+ const { renderer } = this;
7905
+ if (renderer) {
7906
+ renderer.addBlock(bounds ? new Bounds(bounds) : this.canvas.bounds);
7907
+ if (this.viewReady)
7908
+ sync ? renderer.render() : renderer.update();
7909
+ }
7895
7910
  }
7896
7911
  requestRender(change = false) {
7897
7912
  if (this.renderer)
@@ -8067,7 +8082,7 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8067
8082
  this.requestRender();
8068
8083
  }
8069
8084
  zoom(_zoomType, _padding, _fixedScale) {
8070
- return needPlugin('view');
8085
+ return Plugin.need('view');
8071
8086
  }
8072
8087
  getValidMove(moveX, moveY) { return { x: moveX, y: moveY }; }
8073
8088
  getValidScale(changeScale) { return changeScale; }
@@ -8880,8 +8895,8 @@ let App = class App extends Leafer {
8880
8895
  super.lockLayout();
8881
8896
  this.children.forEach(leafer => leafer.lockLayout());
8882
8897
  }
8883
- forceRender(bounds) {
8884
- this.children.forEach(leafer => leafer.forceRender(bounds));
8898
+ forceRender(bounds, sync) {
8899
+ this.children.forEach(leafer => leafer.forceRender(bounds, sync));
8885
8900
  }
8886
8901
  addLeafer(merge) {
8887
8902
  const leafer = new Leafer(merge);
@@ -11806,218 +11821,6 @@ Object.assign(Creator, {
11806
11821
  });
11807
11822
  useCanvas();
11808
11823
 
11809
- 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;
11810
- const PathScaler = {
11811
- scale(data, scaleX, scaleY) {
11812
- if (!data)
11813
- return;
11814
- let command;
11815
- let i = 0, len = data.length;
11816
- while (i < len) {
11817
- command = data[i];
11818
- switch (command) {
11819
- case M$2:
11820
- case L$2:
11821
- scalePoints(data, scaleX, scaleY, i, 1);
11822
- i += 3;
11823
- break;
11824
- case C$2:
11825
- scalePoints(data, scaleX, scaleY, i, 3);
11826
- i += 7;
11827
- break;
11828
- case Q$2:
11829
- scalePoints(data, scaleX, scaleY, i, 2);
11830
- i += 5;
11831
- break;
11832
- case Z$1:
11833
- i += 1;
11834
- break;
11835
- case N$1:
11836
- scalePoints(data, scaleX, scaleY, i, 2);
11837
- i += 5;
11838
- break;
11839
- case D$1:
11840
- scalePoints(data, scaleX, scaleY, i, 2);
11841
- i += 9;
11842
- break;
11843
- case X$1:
11844
- scalePoints(data, scaleX, scaleY, i, 2);
11845
- i += 6;
11846
- break;
11847
- case G$1:
11848
- scalePoints(data, scaleX, scaleY, i, 2);
11849
- i += 9;
11850
- break;
11851
- case F$1:
11852
- scalePoints(data, scaleX, scaleY, i, 2);
11853
- i += 5;
11854
- break;
11855
- case O$2:
11856
- data[i] = G$1;
11857
- data.splice(i + 4, 0, data[i + 3], 0);
11858
- scalePoints(data, scaleX, scaleY, i, 2);
11859
- i += 7 + 2;
11860
- len += 2;
11861
- break;
11862
- case P$1:
11863
- data[i] = F$1;
11864
- data.splice(i + 4, 0, data[i + 3]);
11865
- scalePoints(data, scaleX, scaleY, i, 2);
11866
- i += 4 + 1;
11867
- len += 1;
11868
- break;
11869
- case U$1:
11870
- scalePoints(data, scaleX, scaleY, i, 2);
11871
- i += 6;
11872
- break;
11873
- }
11874
- }
11875
- },
11876
- scalePoints(data, scaleX, scaleY, start, pointCount) {
11877
- for (let i = pointCount ? start + 1 : 0, end = pointCount ? i + pointCount * 2 : data.length; i < end; i += 2) {
11878
- data[i] *= scaleX;
11879
- data[i + 1] *= scaleY;
11880
- }
11881
- }
11882
- };
11883
- const { scalePoints } = PathScaler;
11884
-
11885
- const matrix$1 = MatrixHelper.get();
11886
- const { topLeft: topLeft$1, top: top$1, topRight: topRight$1, right: right$2, bottom: bottom$1, left: left$2 } = Direction9;
11887
- function scaleResize(leaf, scaleX, scaleY) {
11888
- if (leaf.pathInputed) {
11889
- scaleResizePath(leaf, scaleX, scaleY);
11890
- }
11891
- else {
11892
- if (scaleX !== 1)
11893
- leaf.width *= scaleX;
11894
- if (scaleY !== 1)
11895
- leaf.height *= scaleY;
11896
- }
11897
- }
11898
- function scaleResizeFontSize(leaf, scaleX, scaleY) {
11899
- const { app } = leaf;
11900
- const editor = app && app.editor;
11901
- let fontScale = scaleX;
11902
- if (editor.editing) {
11903
- const layout = leaf.__layout;
11904
- let { width, height } = layout.boxBounds;
11905
- width *= scaleY - scaleX;
11906
- height *= scaleX - scaleY;
11907
- switch (editor.resizeDirection) {
11908
- case top$1:
11909
- case bottom$1:
11910
- fontScale = scaleY;
11911
- layout.affectScaleOrRotation ? leaf.moveInner(-width / 2, 0) : leaf.x -= width / 2;
11912
- break;
11913
- case left$2:
11914
- case right$2:
11915
- layout.affectScaleOrRotation ? leaf.moveInner(0, -height / 2) : leaf.y -= height / 2;
11916
- break;
11917
- case topLeft$1:
11918
- case topRight$1:
11919
- layout.affectScaleOrRotation ? leaf.moveInner(0, -height) : leaf.y -= height;
11920
- break;
11921
- }
11922
- }
11923
- leaf.fontSize *= fontScale;
11924
- const data = leaf.__;
11925
- if (!data.__autoWidth)
11926
- leaf.width *= fontScale;
11927
- if (!data.__autoHeight)
11928
- leaf.height *= fontScale;
11929
- }
11930
- function scaleResizePath(leaf, scaleX, scaleY) {
11931
- PathScaler.scale(leaf.__.path, scaleX, scaleY);
11932
- leaf.path = leaf.__.path;
11933
- }
11934
- function scaleResizePoints(leaf, scaleX, scaleY) {
11935
- const { points } = leaf;
11936
- typeof points[0] === 'object' ? points.forEach(p => { p.x *= scaleX, p.y *= scaleY; }) : PathScaler.scalePoints(points, scaleX, scaleY);
11937
- leaf.points = points;
11938
- }
11939
- function scaleResizeGroup(group, scaleX, scaleY) {
11940
- const { children } = group;
11941
- for (let i = 0; i < children.length; i++) {
11942
- matrix$1.a = scaleX;
11943
- matrix$1.d = scaleY;
11944
- children[i].transform(matrix$1, true);
11945
- }
11946
- }
11947
-
11948
- const leaf = Leaf.prototype;
11949
- leaf.scaleResize = function (scaleX, scaleY = scaleX, noResize) {
11950
- const data = this;
11951
- if (noResize || (data.editConfig && data.editConfig.editSize === 'scale')) {
11952
- data.scaleX *= scaleX;
11953
- data.scaleY *= scaleY;
11954
- }
11955
- else {
11956
- if (scaleX < 0)
11957
- data.scaleX *= -1, scaleX = -scaleX;
11958
- if (scaleY < 0)
11959
- data.scaleY *= -1, scaleY = -scaleY;
11960
- this.__scaleResize(scaleX, scaleY);
11961
- }
11962
- };
11963
- leaf.__scaleResize = function (scaleX, scaleY) {
11964
- scaleResize(this, scaleX, scaleY);
11965
- };
11966
- leaf.resizeWidth = function (width) {
11967
- const scale = width / this.getBounds('box', 'local').width;
11968
- this.scaleOf(this.__layout.boxBounds, scale, this.__.lockRatio ? scale : 1, true);
11969
- };
11970
- leaf.resizeHeight = function (height) {
11971
- const scale = height / this.getBounds('box', 'local').height;
11972
- this.scaleOf(this.__layout.boxBounds, this.__.lockRatio ? scale : 1, scale, true);
11973
- };
11974
- Text.prototype.__scaleResize = function (scaleX, scaleY) {
11975
- if (this.__.resizeFontSize || (this.editConfig && this.editConfig.editSize === 'font-size')) {
11976
- scaleResizeFontSize(this, scaleX, scaleY);
11977
- }
11978
- else {
11979
- scaleResize(this, scaleX, scaleY);
11980
- }
11981
- };
11982
- Path.prototype.__scaleResize = function (scaleX, scaleY) {
11983
- scaleResizePath(this, scaleX, scaleY);
11984
- };
11985
- Line.prototype.__scaleResize = function (scaleX, scaleY) {
11986
- if (this.pathInputed) {
11987
- scaleResizePath(this, scaleX, scaleY);
11988
- }
11989
- else if (this.points) {
11990
- scaleResizePoints(this, scaleX, scaleY);
11991
- }
11992
- else {
11993
- this.width *= scaleX;
11994
- }
11995
- };
11996
- Polygon.prototype.__scaleResize = function (scaleX, scaleY) {
11997
- if (this.pathInputed) {
11998
- scaleResizePath(this, scaleX, scaleY);
11999
- }
12000
- else if (this.points) {
12001
- scaleResizePoints(this, scaleX, scaleY);
12002
- }
12003
- else {
12004
- scaleResize(this, scaleX, scaleY);
12005
- }
12006
- };
12007
- Group.prototype.__scaleResize = function (scaleX, scaleY) {
12008
- scaleResizeGroup(this, scaleX, scaleY);
12009
- };
12010
- Box.prototype.__scaleResize = function (scaleX, scaleY) {
12011
- if (this.__.__autoSize && this.children.length) {
12012
- scaleResizeGroup(this, scaleX, scaleY);
12013
- }
12014
- else {
12015
- scaleResize(this, scaleX, scaleY);
12016
- if (this.__.resizeChildren)
12017
- scaleResizeGroup(this, scaleX, scaleY);
12018
- }
12019
- };
12020
-
12021
11824
  function toList(value) {
12022
11825
  return value ? (value instanceof Array ? value : [value]) : [];
12023
11826
  }
@@ -12079,7 +11882,7 @@ const { abs: abs$1 } = Math;
12079
11882
  const { copy: copy$2, scale: scale$1 } = MatrixHelper;
12080
11883
  const { setListWithFn } = BoundsHelper;
12081
11884
  const { worldBounds } = LeafBoundsHelper;
12082
- const matrix = getMatrixData();
11885
+ const matrix$1 = getMatrixData();
12083
11886
  const bounds$2 = getBoundsData();
12084
11887
  class Stroker extends UI {
12085
11888
  constructor() {
@@ -12114,9 +11917,9 @@ class Stroker extends UI {
12114
11917
  if (!bounds || bounds.hit(worldRenderBounds, options.matrix)) {
12115
11918
  const aScaleX = abs$1(worldTransform.scaleX), aScaleY = abs$1(worldTransform.scaleY);
12116
11919
  if (aScaleX !== aScaleY) {
12117
- copy$2(matrix, worldTransform);
12118
- scale$1(matrix, 1 / aScaleX, 1 / aScaleY);
12119
- canvas.setWorld(matrix, options.matrix);
11920
+ copy$2(matrix$1, worldTransform);
11921
+ scale$1(matrix$1, 1 / aScaleX, 1 / aScaleY);
11922
+ canvas.setWorld(matrix$1, options.matrix);
12120
11923
  canvas.beginPath();
12121
11924
  data.strokeWidth = strokeWidth;
12122
11925
  const { x, y, width, height } = leaf.__layout.boxBounds;
@@ -12411,7 +12214,7 @@ class EditSelect extends Group {
12411
12214
  }
12412
12215
  }
12413
12216
 
12414
- const { topLeft, top, topRight, right: right$1, bottomRight, bottom, bottomLeft, left: left$1 } = Direction9;
12217
+ const { topLeft: topLeft$1, top: top$1, topRight: topRight$1, right: right$2, bottomRight, bottom: bottom$1, bottomLeft, left: left$2 } = Direction9;
12415
12218
  const { toPoint } = AroundHelper;
12416
12219
  const { within } = MathHelper;
12417
12220
  const EditDataHelper = {
@@ -12440,28 +12243,28 @@ const EditDataHelper = {
12440
12243
  const bottomScale = (totalMove.y + height) / height;
12441
12244
  const leftScale = (-totalMove.x + width) / width;
12442
12245
  switch (direction) {
12443
- case top:
12246
+ case top$1:
12444
12247
  scaleY = topScale;
12445
12248
  align = 'bottom';
12446
12249
  break;
12447
- case right$1:
12250
+ case right$2:
12448
12251
  scaleX = rightScale;
12449
12252
  align = 'left';
12450
12253
  break;
12451
- case bottom:
12254
+ case bottom$1:
12452
12255
  scaleY = bottomScale;
12453
12256
  align = 'top';
12454
12257
  break;
12455
- case left$1:
12258
+ case left$2:
12456
12259
  scaleX = leftScale;
12457
12260
  align = 'right';
12458
12261
  break;
12459
- case topLeft:
12262
+ case topLeft$1:
12460
12263
  scaleY = topScale;
12461
12264
  scaleX = leftScale;
12462
12265
  align = 'bottom-right';
12463
12266
  break;
12464
- case topRight:
12267
+ case topRight$1:
12465
12268
  scaleY = topScale;
12466
12269
  scaleX = rightScale;
12467
12270
  align = 'bottom-left';
@@ -12481,12 +12284,12 @@ const EditDataHelper = {
12481
12284
  if (!unlockSide) {
12482
12285
  let scale;
12483
12286
  switch (direction) {
12484
- case top:
12485
- case bottom:
12287
+ case top$1:
12288
+ case bottom$1:
12486
12289
  scale = scaleY;
12487
12290
  break;
12488
- case left$1:
12489
- case right$1:
12291
+ case left$2:
12292
+ case right$2:
12490
12293
  scale = scaleX;
12491
12294
  break;
12492
12295
  default:
@@ -12519,10 +12322,10 @@ const EditDataHelper = {
12519
12322
  getRotateData(bounds, direction, current, last, around) {
12520
12323
  let align, origin = {};
12521
12324
  switch (direction) {
12522
- case topLeft:
12325
+ case topLeft$1:
12523
12326
  align = 'bottom-right';
12524
12327
  break;
12525
- case topRight:
12328
+ case topRight$1:
12526
12329
  align = 'bottom-left';
12527
12330
  break;
12528
12331
  case bottomRight:
@@ -12541,22 +12344,22 @@ const EditDataHelper = {
12541
12344
  let align, origin = {}, skewX = 0, skewY = 0;
12542
12345
  let last;
12543
12346
  switch (direction) {
12544
- case top:
12347
+ case top$1:
12545
12348
  last = { x: 0.5, y: 0 };
12546
12349
  align = 'bottom';
12547
12350
  skewX = 1;
12548
12351
  break;
12549
- case bottom:
12352
+ case bottom$1:
12550
12353
  last = { x: 0.5, y: 1 };
12551
12354
  align = 'top';
12552
12355
  skewX = 1;
12553
12356
  break;
12554
- case left$1:
12357
+ case left$2:
12555
12358
  last = { x: 0, y: 0.5 };
12556
12359
  align = 'right';
12557
12360
  skewY = 1;
12558
12361
  break;
12559
- case right$1:
12362
+ case right$2:
12560
12363
  last = { x: 1, y: 0.5 };
12561
12364
  align = 'left';
12562
12365
  skewY = 1;
@@ -12581,20 +12384,20 @@ const EditDataHelper = {
12581
12384
  getFlipDirection(direction, flipedX, flipedY) {
12582
12385
  if (flipedX) {
12583
12386
  switch (direction) {
12584
- case left$1:
12585
- direction = right$1;
12387
+ case left$2:
12388
+ direction = right$2;
12586
12389
  break;
12587
- case topLeft:
12588
- direction = topRight;
12390
+ case topLeft$1:
12391
+ direction = topRight$1;
12589
12392
  break;
12590
12393
  case bottomLeft:
12591
12394
  direction = bottomRight;
12592
12395
  break;
12593
- case right$1:
12594
- direction = left$1;
12396
+ case right$2:
12397
+ direction = left$2;
12595
12398
  break;
12596
- case topRight:
12597
- direction = topLeft;
12399
+ case topRight$1:
12400
+ direction = topLeft$1;
12598
12401
  break;
12599
12402
  case bottomRight:
12600
12403
  direction = bottomLeft;
@@ -12603,23 +12406,23 @@ const EditDataHelper = {
12603
12406
  }
12604
12407
  if (flipedY) {
12605
12408
  switch (direction) {
12606
- case top:
12607
- direction = bottom;
12409
+ case top$1:
12410
+ direction = bottom$1;
12608
12411
  break;
12609
- case topLeft:
12412
+ case topLeft$1:
12610
12413
  direction = bottomLeft;
12611
12414
  break;
12612
- case topRight:
12415
+ case topRight$1:
12613
12416
  direction = bottomRight;
12614
12417
  break;
12615
- case bottom:
12616
- direction = top;
12418
+ case bottom$1:
12419
+ direction = top$1;
12617
12420
  break;
12618
12421
  case bottomLeft:
12619
- direction = topLeft;
12422
+ direction = topLeft$1;
12620
12423
  break;
12621
12424
  case bottomRight:
12622
- direction = topRight;
12425
+ direction = topRight$1;
12623
12426
  break;
12624
12427
  }
12625
12428
  }
@@ -13282,6 +13085,8 @@ class Editor extends Group {
13282
13085
  if (userConfig)
13283
13086
  this.config = DataHelper.default(userConfig, this.config);
13284
13087
  this.addMany(this.editMask, this.selector, this.editBox);
13088
+ if (!Plugin.check('resize', true))
13089
+ this.config.editSize = 'scale';
13285
13090
  }
13286
13091
  select(target) {
13287
13092
  this.target = target;
@@ -13753,7 +13558,7 @@ EditTool = __decorate([
13753
13558
  registerEditTool()
13754
13559
  ], EditTool);
13755
13560
 
13756
- const { left, right } = Direction9;
13561
+ const { left: left$1, right: right$1 } = Direction9;
13757
13562
  const { move, copy: copy$1, toNumberPoints } = PointHelper;
13758
13563
  let LineEditTool = class LineEditTool extends EditTool {
13759
13564
  constructor() {
@@ -13764,7 +13569,7 @@ let LineEditTool = class LineEditTool extends EditTool {
13764
13569
  onScaleWithDrag(e) {
13765
13570
  const { drag, direction, lockRatio, around } = e;
13766
13571
  const line = e.target;
13767
- const isDragFrom = direction === left;
13572
+ const isDragFrom = direction === left$1;
13768
13573
  if (line.pathInputed) {
13769
13574
  const { path } = line.__;
13770
13575
  const { from, to } = this.getFromToByPath(path);
@@ -13849,7 +13654,7 @@ let LineEditTool = class LineEditTool extends EditTool {
13849
13654
  for (let i = 0; i < 8; i++) {
13850
13655
  if (i < 4)
13851
13656
  resizeLines[i].visible = false;
13852
- leftOrRight = i === left || i === right;
13657
+ leftOrRight = i === left$1 || i === right$1;
13853
13658
  resizePoints[i].visible = leftOrRight;
13854
13659
  rotatePoints[i].visible = fromTo ? false : leftOrRight;
13855
13660
  }
@@ -13859,6 +13664,221 @@ LineEditTool = __decorate([
13859
13664
  registerEditTool()
13860
13665
  ], LineEditTool);
13861
13666
 
13667
+ 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;
13668
+ const PathScaler = {
13669
+ scale(data, scaleX, scaleY) {
13670
+ if (!data)
13671
+ return;
13672
+ let command;
13673
+ let i = 0, len = data.length;
13674
+ while (i < len) {
13675
+ command = data[i];
13676
+ switch (command) {
13677
+ case M$2:
13678
+ case L$2:
13679
+ scalePoints(data, scaleX, scaleY, i, 1);
13680
+ i += 3;
13681
+ break;
13682
+ case C$2:
13683
+ scalePoints(data, scaleX, scaleY, i, 3);
13684
+ i += 7;
13685
+ break;
13686
+ case Q$2:
13687
+ scalePoints(data, scaleX, scaleY, i, 2);
13688
+ i += 5;
13689
+ break;
13690
+ case Z$1:
13691
+ i += 1;
13692
+ break;
13693
+ case N$1:
13694
+ scalePoints(data, scaleX, scaleY, i, 2);
13695
+ i += 5;
13696
+ break;
13697
+ case D$1:
13698
+ scalePoints(data, scaleX, scaleY, i, 2);
13699
+ i += 9;
13700
+ break;
13701
+ case X$1:
13702
+ scalePoints(data, scaleX, scaleY, i, 2);
13703
+ i += 6;
13704
+ break;
13705
+ case G$1:
13706
+ scalePoints(data, scaleX, scaleY, i, 2);
13707
+ i += 9;
13708
+ break;
13709
+ case F$1:
13710
+ scalePoints(data, scaleX, scaleY, i, 2);
13711
+ i += 5;
13712
+ break;
13713
+ case O$2:
13714
+ data[i] = G$1;
13715
+ data.splice(i + 4, 0, data[i + 3], 0);
13716
+ scalePoints(data, scaleX, scaleY, i, 2);
13717
+ i += 7 + 2;
13718
+ len += 2;
13719
+ break;
13720
+ case P$1:
13721
+ data[i] = F$1;
13722
+ data.splice(i + 4, 0, data[i + 3]);
13723
+ scalePoints(data, scaleX, scaleY, i, 2);
13724
+ i += 4 + 1;
13725
+ len += 1;
13726
+ break;
13727
+ case U$1:
13728
+ scalePoints(data, scaleX, scaleY, i, 2);
13729
+ i += 6;
13730
+ break;
13731
+ }
13732
+ }
13733
+ },
13734
+ scalePoints(data, scaleX, scaleY, start, pointCount) {
13735
+ for (let i = pointCount ? start + 1 : 0, end = pointCount ? i + pointCount * 2 : data.length; i < end; i += 2) {
13736
+ data[i] *= scaleX;
13737
+ data[i + 1] *= scaleY;
13738
+ }
13739
+ }
13740
+ };
13741
+ const { scalePoints } = PathScaler;
13742
+
13743
+ const matrix = MatrixHelper.get();
13744
+ const { topLeft, top, topRight, right, bottom, left } = Direction9;
13745
+ function scaleResize(leaf, scaleX, scaleY) {
13746
+ if (leaf.pathInputed) {
13747
+ scaleResizePath(leaf, scaleX, scaleY);
13748
+ }
13749
+ else {
13750
+ if (scaleX !== 1)
13751
+ leaf.width *= scaleX;
13752
+ if (scaleY !== 1)
13753
+ leaf.height *= scaleY;
13754
+ }
13755
+ }
13756
+ function scaleResizeFontSize(leaf, scaleX, scaleY) {
13757
+ const { app } = leaf;
13758
+ const editor = app && app.editor;
13759
+ let fontScale = scaleX;
13760
+ if (editor.editing) {
13761
+ const layout = leaf.__layout;
13762
+ let { width, height } = layout.boxBounds;
13763
+ width *= scaleY - scaleX;
13764
+ height *= scaleX - scaleY;
13765
+ switch (editor.resizeDirection) {
13766
+ case top:
13767
+ case bottom:
13768
+ fontScale = scaleY;
13769
+ layout.affectScaleOrRotation ? leaf.moveInner(-width / 2, 0) : leaf.x -= width / 2;
13770
+ break;
13771
+ case left:
13772
+ case right:
13773
+ layout.affectScaleOrRotation ? leaf.moveInner(0, -height / 2) : leaf.y -= height / 2;
13774
+ break;
13775
+ case topLeft:
13776
+ case topRight:
13777
+ layout.affectScaleOrRotation ? leaf.moveInner(0, -height) : leaf.y -= height;
13778
+ break;
13779
+ }
13780
+ }
13781
+ leaf.fontSize *= fontScale;
13782
+ const data = leaf.__;
13783
+ if (!data.__autoWidth)
13784
+ leaf.width *= fontScale;
13785
+ if (!data.__autoHeight)
13786
+ leaf.height *= fontScale;
13787
+ }
13788
+ function scaleResizePath(leaf, scaleX, scaleY) {
13789
+ PathScaler.scale(leaf.__.path, scaleX, scaleY);
13790
+ leaf.path = leaf.__.path;
13791
+ }
13792
+ function scaleResizePoints(leaf, scaleX, scaleY) {
13793
+ const { points } = leaf;
13794
+ typeof points[0] === 'object' ? points.forEach(p => { p.x *= scaleX, p.y *= scaleY; }) : PathScaler.scalePoints(points, scaleX, scaleY);
13795
+ leaf.points = points;
13796
+ }
13797
+ function scaleResizeGroup(group, scaleX, scaleY) {
13798
+ const { children } = group;
13799
+ for (let i = 0; i < children.length; i++) {
13800
+ matrix.a = scaleX;
13801
+ matrix.d = scaleY;
13802
+ children[i].transform(matrix, true);
13803
+ }
13804
+ }
13805
+
13806
+ const leaf = Leaf.prototype;
13807
+ leaf.scaleResize = function (scaleX, scaleY = scaleX, noResize) {
13808
+ const data = this;
13809
+ if (noResize || (data.editConfig && data.editConfig.editSize === 'scale')) {
13810
+ data.scaleX *= scaleX;
13811
+ data.scaleY *= scaleY;
13812
+ }
13813
+ else {
13814
+ if (scaleX < 0)
13815
+ data.scaleX *= -1, scaleX = -scaleX;
13816
+ if (scaleY < 0)
13817
+ data.scaleY *= -1, scaleY = -scaleY;
13818
+ this.__scaleResize(scaleX, scaleY);
13819
+ }
13820
+ };
13821
+ leaf.__scaleResize = function (scaleX, scaleY) {
13822
+ scaleResize(this, scaleX, scaleY);
13823
+ };
13824
+ leaf.resizeWidth = function (width) {
13825
+ const scale = width / this.getBounds('box', 'local').width;
13826
+ this.scaleOf(this.__layout.boxBounds, scale, this.__.lockRatio ? scale : 1, true);
13827
+ };
13828
+ leaf.resizeHeight = function (height) {
13829
+ const scale = height / this.getBounds('box', 'local').height;
13830
+ this.scaleOf(this.__layout.boxBounds, this.__.lockRatio ? scale : 1, scale, true);
13831
+ };
13832
+ Text.prototype.__scaleResize = function (scaleX, scaleY) {
13833
+ if (this.__.resizeFontSize || (this.editConfig && this.editConfig.editSize === 'font-size')) {
13834
+ scaleResizeFontSize(this, scaleX, scaleY);
13835
+ }
13836
+ else {
13837
+ scaleResize(this, scaleX, scaleY);
13838
+ }
13839
+ };
13840
+ Path.prototype.__scaleResize = function (scaleX, scaleY) {
13841
+ scaleResizePath(this, scaleX, scaleY);
13842
+ };
13843
+ Line.prototype.__scaleResize = function (scaleX, scaleY) {
13844
+ if (this.pathInputed) {
13845
+ scaleResizePath(this, scaleX, scaleY);
13846
+ }
13847
+ else if (this.points) {
13848
+ scaleResizePoints(this, scaleX, scaleY);
13849
+ }
13850
+ else {
13851
+ this.width *= scaleX;
13852
+ }
13853
+ };
13854
+ Polygon.prototype.__scaleResize = function (scaleX, scaleY) {
13855
+ if (this.pathInputed) {
13856
+ scaleResizePath(this, scaleX, scaleY);
13857
+ }
13858
+ else if (this.points) {
13859
+ scaleResizePoints(this, scaleX, scaleY);
13860
+ }
13861
+ else {
13862
+ scaleResize(this, scaleX, scaleY);
13863
+ }
13864
+ };
13865
+ Group.prototype.__scaleResize = function (scaleX, scaleY) {
13866
+ scaleResizeGroup(this, scaleX, scaleY);
13867
+ };
13868
+ Box.prototype.__scaleResize = function (scaleX, scaleY) {
13869
+ if (this.__.__autoSize && this.children.length) {
13870
+ scaleResizeGroup(this, scaleX, scaleY);
13871
+ }
13872
+ else {
13873
+ scaleResize(this, scaleX, scaleY);
13874
+ if (this.__.resizeChildren)
13875
+ scaleResizeGroup(this, scaleX, scaleY);
13876
+ }
13877
+ };
13878
+
13879
+ Plugin.add('resize');
13880
+
13881
+ Plugin.add('editor');
13862
13882
  Creator.editor = function (options) { return new Editor(options); };
13863
13883
  dataType(false)(Box.prototype, 'textBox');
13864
13884
  defineKey(UI.prototype, 'editOuter', {
@@ -14232,6 +14252,8 @@ dragger.autoMoveCancel = function () {
14232
14252
  }
14233
14253
  };
14234
14254
 
14255
+ Plugin.add('viewport');
14256
+
14235
14257
  function getZoomScale(scaleX, type) {
14236
14258
  let scale = 1;
14237
14259
  const out = type === 'out', absScale = Math.abs(scaleX);
@@ -14259,6 +14281,7 @@ function getFixBounds(bounds, scaleBounds) {
14259
14281
  return fix ? { x, y, width, height } : bounds;
14260
14282
  }
14261
14283
 
14284
+ Plugin.add('view');
14262
14285
  Leafer.prototype.zoom = function (zoomType, padding, fixed) {
14263
14286
  const { zoomLayer } = this;
14264
14287
  const limitBounds = this.canvas.bounds.clone().shrink(padding !== undefined ? padding : 30), bounds = new Bounds();
@@ -14431,6 +14454,8 @@ class ScrollBar extends Group {
14431
14454
  }
14432
14455
  }
14433
14456
 
14457
+ Plugin.add('scroll');
14458
+
14434
14459
  class ArrowData extends LineData {
14435
14460
  }
14436
14461
 
@@ -14690,6 +14715,7 @@ function arrowType(defaultValue) {
14690
14715
  }));
14691
14716
  }
14692
14717
 
14718
+ Plugin.add('arrow');
14693
14719
  const ui = UI.prototype;
14694
14720
  arrowType('none')(ui, 'startArrow');
14695
14721
  arrowType('none')(ui, 'endArrow');
@@ -14897,6 +14923,9 @@ TextEditor = __decorate([
14897
14923
  registerInnerEditor()
14898
14924
  ], TextEditor);
14899
14925
 
14926
+ Plugin.add('text-editor');
14927
+ setTimeout(() => Plugin.check('editor', true));
14928
+
14900
14929
  class HTMLTextData extends ImageData {
14901
14930
  setText(value) {
14902
14931
  this._text = value;
@@ -14955,4 +14984,6 @@ HTMLText = __decorate([
14955
14984
  registerUI()
14956
14985
  ], HTMLText);
14957
14986
 
14958
- export { AlignHelper, Answer, App, AroundHelper, Arrow, ArrowData, AutoBounds, BezierHelper, Bounds, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, Cursor, DataHelper, Debug, Direction4, Direction9, DragEvent, Dragger, DropEvent, EditBox, EditDataHelper, EditPoint, EditSelect, EditSelectHelper, EditTool, EditToolCreator, Editor, EditorEvent, EditorGroupEvent, EditorHelper, EditorMoveEvent, EditorRotateEvent, EditorScaleEvent, EditorSkewEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Frame, FrameData, Group, GroupData, HTMLText, HTMLTextData, HitCanvasManager, Image, ImageData, ImageEvent, ImageManager, IncrementId, InnerEditor, InnerEditorEvent, InteractionBase, InteractionHelper, KeyEvent, Keyboard, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, LeaferTypeCreator, Line, LineData, LineEditTool, MathHelper, Matrix, MatrixHelper, MoveEvent, MultiTouchHelper, MyDragEvent, MyImage, MyPointerEvent, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathArrowModule, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathMatrixHelper, PathNumberCommandLengthMap, PathNumberCommandMap, PathScaler, Pen, PenData, Platform, Point, PointHelper, PointerButton, PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, RotateEvent, Run, ScrollBar, SelectArea, Selector, Star, StarData, State, StringNumberMap, Stroker, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert, TextData, TextEditor, Transformer, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, WheelEventHelper, ZoomEvent, addViewport, addViewportConfig, affectRenderBoundsType, affectStrokeBoundsType, arrowType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, doBoundsType, doStrokeType, effectType, emptyData, eraserType, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isNull, layoutProcessor, maskType, naturalBoundsType, needPlugin, opacityType, pathInputType, pathType, pen, positionType, registerEditTool, registerInnerEditor, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleResize, scaleResizeFontSize, scaleResizeGroup, scaleResizePath, scaleResizePoints, scaleType, sortType, strokeType, surfaceType, tempBounds$1 as tempBounds, tempMatrix, tempPoint$3 as tempPoint, useCanvas, useModule, version, visibleType, zoomLayerType };
14987
+ Plugin.add('html');
14988
+
14989
+ export { AlignHelper, Answer, App, AroundHelper, Arrow, ArrowData, AutoBounds, BezierHelper, Bounds, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, Cursor, DataHelper, Debug, Direction4, Direction9, DragEvent, Dragger, DropEvent, EditBox, EditDataHelper, EditPoint, EditSelect, EditSelectHelper, EditTool, EditToolCreator, Editor, EditorEvent, EditorGroupEvent, EditorHelper, EditorMoveEvent, EditorRotateEvent, EditorScaleEvent, EditorSkewEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Frame, FrameData, Group, GroupData, HTMLText, HTMLTextData, HitCanvasManager, Image, ImageData, ImageEvent, ImageManager, IncrementId, InnerEditor, InnerEditorEvent, InteractionBase, InteractionHelper, KeyEvent, Keyboard, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, LeaferTypeCreator, Line, LineData, LineEditTool, MathHelper, Matrix, MatrixHelper, MoveEvent, MultiTouchHelper, MyDragEvent, MyImage, MyPointerEvent, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathArrowModule, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathMatrixHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Pen, PenData, Platform, Plugin, Point, PointHelper, PointerButton, PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, RotateEvent, Run, ScrollBar, SelectArea, Selector, Star, StarData, State, StringNumberMap, Stroker, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert, TextData, TextEditor, Transformer, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, WheelEventHelper, ZoomEvent, addViewport, addViewportConfig, affectRenderBoundsType, affectStrokeBoundsType, arrowType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, doBoundsType, doStrokeType, effectType, emptyData, eraserType, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isNull, layoutProcessor, maskType, naturalBoundsType, opacityType, pathInputType, pathType, pen, positionType, registerEditTool, registerInnerEditor, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, sortType, strokeType, surfaceType, tempBounds$1 as tempBounds, tempMatrix, tempPoint$3 as tempPoint, useCanvas, useModule, version, visibleType, zoomLayerType };