@leafer-editor/worker 1.1.2 → 1.2.0
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 +291 -269
- package/dist/worker.min.js +1 -1
- package/dist/worker.module.js +291 -263
- package/dist/worker.module.min.js +1 -1
- package/package.json +6 -6
package/dist/worker.module.js
CHANGED
|
@@ -1402,9 +1402,21 @@ const Run = {
|
|
|
1402
1402
|
};
|
|
1403
1403
|
const R = Run;
|
|
1404
1404
|
|
|
1405
|
-
|
|
1406
|
-
|
|
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 = {
|
|
@@ -5629,10 +5641,10 @@ let Leaf = class Leaf {
|
|
|
5629
5641
|
__updatePath() { }
|
|
5630
5642
|
__updateRenderPath() { }
|
|
5631
5643
|
getMotionPathData() {
|
|
5632
|
-
return
|
|
5644
|
+
return Plugin.need('path');
|
|
5633
5645
|
}
|
|
5634
5646
|
getMotionPoint(_motionDistance) {
|
|
5635
|
-
return
|
|
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.
|
|
6004
|
+
const version = "1.2.0";
|
|
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
|
|
6991
|
-
set(_leaf, _stateName) { return
|
|
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
|
|
7504
|
+
return Plugin.need('animate');
|
|
7493
7505
|
}
|
|
7494
7506
|
killAnimate(_type) { }
|
|
7495
7507
|
export(filename, options) {
|
|
@@ -8067,7 +8079,7 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
8067
8079
|
this.requestRender();
|
|
8068
8080
|
}
|
|
8069
8081
|
zoom(_zoomType, _padding, _fixedScale) {
|
|
8070
|
-
return
|
|
8082
|
+
return Plugin.need('view');
|
|
8071
8083
|
}
|
|
8072
8084
|
getValidMove(moveX, moveY) { return { x: moveX, y: moveY }; }
|
|
8073
8085
|
getValidScale(changeScale) { return changeScale; }
|
|
@@ -11806,218 +11818,6 @@ Object.assign(Creator, {
|
|
|
11806
11818
|
});
|
|
11807
11819
|
useCanvas();
|
|
11808
11820
|
|
|
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
11821
|
function toList(value) {
|
|
12022
11822
|
return value ? (value instanceof Array ? value : [value]) : [];
|
|
12023
11823
|
}
|
|
@@ -12079,7 +11879,7 @@ const { abs: abs$1 } = Math;
|
|
|
12079
11879
|
const { copy: copy$2, scale: scale$1 } = MatrixHelper;
|
|
12080
11880
|
const { setListWithFn } = BoundsHelper;
|
|
12081
11881
|
const { worldBounds } = LeafBoundsHelper;
|
|
12082
|
-
const matrix = getMatrixData();
|
|
11882
|
+
const matrix$1 = getMatrixData();
|
|
12083
11883
|
const bounds$2 = getBoundsData();
|
|
12084
11884
|
class Stroker extends UI {
|
|
12085
11885
|
constructor() {
|
|
@@ -12114,9 +11914,9 @@ class Stroker extends UI {
|
|
|
12114
11914
|
if (!bounds || bounds.hit(worldRenderBounds, options.matrix)) {
|
|
12115
11915
|
const aScaleX = abs$1(worldTransform.scaleX), aScaleY = abs$1(worldTransform.scaleY);
|
|
12116
11916
|
if (aScaleX !== aScaleY) {
|
|
12117
|
-
copy$2(matrix, worldTransform);
|
|
12118
|
-
scale$1(matrix, 1 / aScaleX, 1 / aScaleY);
|
|
12119
|
-
canvas.setWorld(matrix, options.matrix);
|
|
11917
|
+
copy$2(matrix$1, worldTransform);
|
|
11918
|
+
scale$1(matrix$1, 1 / aScaleX, 1 / aScaleY);
|
|
11919
|
+
canvas.setWorld(matrix$1, options.matrix);
|
|
12120
11920
|
canvas.beginPath();
|
|
12121
11921
|
data.strokeWidth = strokeWidth;
|
|
12122
11922
|
const { x, y, width, height } = leaf.__layout.boxBounds;
|
|
@@ -12411,7 +12211,7 @@ class EditSelect extends Group {
|
|
|
12411
12211
|
}
|
|
12412
12212
|
}
|
|
12413
12213
|
|
|
12414
|
-
const { topLeft, top, topRight, right: right$
|
|
12214
|
+
const { topLeft: topLeft$1, top: top$1, topRight: topRight$1, right: right$2, bottomRight, bottom: bottom$1, bottomLeft, left: left$2 } = Direction9;
|
|
12415
12215
|
const { toPoint } = AroundHelper;
|
|
12416
12216
|
const { within } = MathHelper;
|
|
12417
12217
|
const EditDataHelper = {
|
|
@@ -12440,28 +12240,28 @@ const EditDataHelper = {
|
|
|
12440
12240
|
const bottomScale = (totalMove.y + height) / height;
|
|
12441
12241
|
const leftScale = (-totalMove.x + width) / width;
|
|
12442
12242
|
switch (direction) {
|
|
12443
|
-
case top:
|
|
12243
|
+
case top$1:
|
|
12444
12244
|
scaleY = topScale;
|
|
12445
12245
|
align = 'bottom';
|
|
12446
12246
|
break;
|
|
12447
|
-
case right$
|
|
12247
|
+
case right$2:
|
|
12448
12248
|
scaleX = rightScale;
|
|
12449
12249
|
align = 'left';
|
|
12450
12250
|
break;
|
|
12451
|
-
case bottom:
|
|
12251
|
+
case bottom$1:
|
|
12452
12252
|
scaleY = bottomScale;
|
|
12453
12253
|
align = 'top';
|
|
12454
12254
|
break;
|
|
12455
|
-
case left$
|
|
12255
|
+
case left$2:
|
|
12456
12256
|
scaleX = leftScale;
|
|
12457
12257
|
align = 'right';
|
|
12458
12258
|
break;
|
|
12459
|
-
case topLeft:
|
|
12259
|
+
case topLeft$1:
|
|
12460
12260
|
scaleY = topScale;
|
|
12461
12261
|
scaleX = leftScale;
|
|
12462
12262
|
align = 'bottom-right';
|
|
12463
12263
|
break;
|
|
12464
|
-
case topRight:
|
|
12264
|
+
case topRight$1:
|
|
12465
12265
|
scaleY = topScale;
|
|
12466
12266
|
scaleX = rightScale;
|
|
12467
12267
|
align = 'bottom-left';
|
|
@@ -12481,12 +12281,12 @@ const EditDataHelper = {
|
|
|
12481
12281
|
if (!unlockSide) {
|
|
12482
12282
|
let scale;
|
|
12483
12283
|
switch (direction) {
|
|
12484
|
-
case top:
|
|
12485
|
-
case bottom:
|
|
12284
|
+
case top$1:
|
|
12285
|
+
case bottom$1:
|
|
12486
12286
|
scale = scaleY;
|
|
12487
12287
|
break;
|
|
12488
|
-
case left$
|
|
12489
|
-
case right$
|
|
12288
|
+
case left$2:
|
|
12289
|
+
case right$2:
|
|
12490
12290
|
scale = scaleX;
|
|
12491
12291
|
break;
|
|
12492
12292
|
default:
|
|
@@ -12519,10 +12319,10 @@ const EditDataHelper = {
|
|
|
12519
12319
|
getRotateData(bounds, direction, current, last, around) {
|
|
12520
12320
|
let align, origin = {};
|
|
12521
12321
|
switch (direction) {
|
|
12522
|
-
case topLeft:
|
|
12322
|
+
case topLeft$1:
|
|
12523
12323
|
align = 'bottom-right';
|
|
12524
12324
|
break;
|
|
12525
|
-
case topRight:
|
|
12325
|
+
case topRight$1:
|
|
12526
12326
|
align = 'bottom-left';
|
|
12527
12327
|
break;
|
|
12528
12328
|
case bottomRight:
|
|
@@ -12541,22 +12341,22 @@ const EditDataHelper = {
|
|
|
12541
12341
|
let align, origin = {}, skewX = 0, skewY = 0;
|
|
12542
12342
|
let last;
|
|
12543
12343
|
switch (direction) {
|
|
12544
|
-
case top:
|
|
12344
|
+
case top$1:
|
|
12545
12345
|
last = { x: 0.5, y: 0 };
|
|
12546
12346
|
align = 'bottom';
|
|
12547
12347
|
skewX = 1;
|
|
12548
12348
|
break;
|
|
12549
|
-
case bottom:
|
|
12349
|
+
case bottom$1:
|
|
12550
12350
|
last = { x: 0.5, y: 1 };
|
|
12551
12351
|
align = 'top';
|
|
12552
12352
|
skewX = 1;
|
|
12553
12353
|
break;
|
|
12554
|
-
case left$
|
|
12354
|
+
case left$2:
|
|
12555
12355
|
last = { x: 0, y: 0.5 };
|
|
12556
12356
|
align = 'right';
|
|
12557
12357
|
skewY = 1;
|
|
12558
12358
|
break;
|
|
12559
|
-
case right$
|
|
12359
|
+
case right$2:
|
|
12560
12360
|
last = { x: 1, y: 0.5 };
|
|
12561
12361
|
align = 'left';
|
|
12562
12362
|
skewY = 1;
|
|
@@ -12581,20 +12381,20 @@ const EditDataHelper = {
|
|
|
12581
12381
|
getFlipDirection(direction, flipedX, flipedY) {
|
|
12582
12382
|
if (flipedX) {
|
|
12583
12383
|
switch (direction) {
|
|
12584
|
-
case left$
|
|
12585
|
-
direction = right$
|
|
12384
|
+
case left$2:
|
|
12385
|
+
direction = right$2;
|
|
12586
12386
|
break;
|
|
12587
|
-
case topLeft:
|
|
12588
|
-
direction = topRight;
|
|
12387
|
+
case topLeft$1:
|
|
12388
|
+
direction = topRight$1;
|
|
12589
12389
|
break;
|
|
12590
12390
|
case bottomLeft:
|
|
12591
12391
|
direction = bottomRight;
|
|
12592
12392
|
break;
|
|
12593
|
-
case right$
|
|
12594
|
-
direction = left$
|
|
12393
|
+
case right$2:
|
|
12394
|
+
direction = left$2;
|
|
12595
12395
|
break;
|
|
12596
|
-
case topRight:
|
|
12597
|
-
direction = topLeft;
|
|
12396
|
+
case topRight$1:
|
|
12397
|
+
direction = topLeft$1;
|
|
12598
12398
|
break;
|
|
12599
12399
|
case bottomRight:
|
|
12600
12400
|
direction = bottomLeft;
|
|
@@ -12603,23 +12403,23 @@ const EditDataHelper = {
|
|
|
12603
12403
|
}
|
|
12604
12404
|
if (flipedY) {
|
|
12605
12405
|
switch (direction) {
|
|
12606
|
-
case top:
|
|
12607
|
-
direction = bottom;
|
|
12406
|
+
case top$1:
|
|
12407
|
+
direction = bottom$1;
|
|
12608
12408
|
break;
|
|
12609
|
-
case topLeft:
|
|
12409
|
+
case topLeft$1:
|
|
12610
12410
|
direction = bottomLeft;
|
|
12611
12411
|
break;
|
|
12612
|
-
case topRight:
|
|
12412
|
+
case topRight$1:
|
|
12613
12413
|
direction = bottomRight;
|
|
12614
12414
|
break;
|
|
12615
|
-
case bottom:
|
|
12616
|
-
direction = top;
|
|
12415
|
+
case bottom$1:
|
|
12416
|
+
direction = top$1;
|
|
12617
12417
|
break;
|
|
12618
12418
|
case bottomLeft:
|
|
12619
|
-
direction = topLeft;
|
|
12419
|
+
direction = topLeft$1;
|
|
12620
12420
|
break;
|
|
12621
12421
|
case bottomRight:
|
|
12622
|
-
direction = topRight;
|
|
12422
|
+
direction = topRight$1;
|
|
12623
12423
|
break;
|
|
12624
12424
|
}
|
|
12625
12425
|
}
|
|
@@ -13282,6 +13082,8 @@ class Editor extends Group {
|
|
|
13282
13082
|
if (userConfig)
|
|
13283
13083
|
this.config = DataHelper.default(userConfig, this.config);
|
|
13284
13084
|
this.addMany(this.editMask, this.selector, this.editBox);
|
|
13085
|
+
if (!Plugin.check('resize', true))
|
|
13086
|
+
this.config.editSize = 'scale';
|
|
13285
13087
|
}
|
|
13286
13088
|
select(target) {
|
|
13287
13089
|
this.target = target;
|
|
@@ -13753,7 +13555,7 @@ EditTool = __decorate([
|
|
|
13753
13555
|
registerEditTool()
|
|
13754
13556
|
], EditTool);
|
|
13755
13557
|
|
|
13756
|
-
const { left, right } = Direction9;
|
|
13558
|
+
const { left: left$1, right: right$1 } = Direction9;
|
|
13757
13559
|
const { move, copy: copy$1, toNumberPoints } = PointHelper;
|
|
13758
13560
|
let LineEditTool = class LineEditTool extends EditTool {
|
|
13759
13561
|
constructor() {
|
|
@@ -13764,7 +13566,7 @@ let LineEditTool = class LineEditTool extends EditTool {
|
|
|
13764
13566
|
onScaleWithDrag(e) {
|
|
13765
13567
|
const { drag, direction, lockRatio, around } = e;
|
|
13766
13568
|
const line = e.target;
|
|
13767
|
-
const isDragFrom = direction === left;
|
|
13569
|
+
const isDragFrom = direction === left$1;
|
|
13768
13570
|
if (line.pathInputed) {
|
|
13769
13571
|
const { path } = line.__;
|
|
13770
13572
|
const { from, to } = this.getFromToByPath(path);
|
|
@@ -13849,7 +13651,7 @@ let LineEditTool = class LineEditTool extends EditTool {
|
|
|
13849
13651
|
for (let i = 0; i < 8; i++) {
|
|
13850
13652
|
if (i < 4)
|
|
13851
13653
|
resizeLines[i].visible = false;
|
|
13852
|
-
leftOrRight = i === left || i === right;
|
|
13654
|
+
leftOrRight = i === left$1 || i === right$1;
|
|
13853
13655
|
resizePoints[i].visible = leftOrRight;
|
|
13854
13656
|
rotatePoints[i].visible = fromTo ? false : leftOrRight;
|
|
13855
13657
|
}
|
|
@@ -13859,6 +13661,221 @@ LineEditTool = __decorate([
|
|
|
13859
13661
|
registerEditTool()
|
|
13860
13662
|
], LineEditTool);
|
|
13861
13663
|
|
|
13664
|
+
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;
|
|
13665
|
+
const PathScaler = {
|
|
13666
|
+
scale(data, scaleX, scaleY) {
|
|
13667
|
+
if (!data)
|
|
13668
|
+
return;
|
|
13669
|
+
let command;
|
|
13670
|
+
let i = 0, len = data.length;
|
|
13671
|
+
while (i < len) {
|
|
13672
|
+
command = data[i];
|
|
13673
|
+
switch (command) {
|
|
13674
|
+
case M$2:
|
|
13675
|
+
case L$2:
|
|
13676
|
+
scalePoints(data, scaleX, scaleY, i, 1);
|
|
13677
|
+
i += 3;
|
|
13678
|
+
break;
|
|
13679
|
+
case C$2:
|
|
13680
|
+
scalePoints(data, scaleX, scaleY, i, 3);
|
|
13681
|
+
i += 7;
|
|
13682
|
+
break;
|
|
13683
|
+
case Q$2:
|
|
13684
|
+
scalePoints(data, scaleX, scaleY, i, 2);
|
|
13685
|
+
i += 5;
|
|
13686
|
+
break;
|
|
13687
|
+
case Z$1:
|
|
13688
|
+
i += 1;
|
|
13689
|
+
break;
|
|
13690
|
+
case N$1:
|
|
13691
|
+
scalePoints(data, scaleX, scaleY, i, 2);
|
|
13692
|
+
i += 5;
|
|
13693
|
+
break;
|
|
13694
|
+
case D$1:
|
|
13695
|
+
scalePoints(data, scaleX, scaleY, i, 2);
|
|
13696
|
+
i += 9;
|
|
13697
|
+
break;
|
|
13698
|
+
case X$1:
|
|
13699
|
+
scalePoints(data, scaleX, scaleY, i, 2);
|
|
13700
|
+
i += 6;
|
|
13701
|
+
break;
|
|
13702
|
+
case G$1:
|
|
13703
|
+
scalePoints(data, scaleX, scaleY, i, 2);
|
|
13704
|
+
i += 9;
|
|
13705
|
+
break;
|
|
13706
|
+
case F$1:
|
|
13707
|
+
scalePoints(data, scaleX, scaleY, i, 2);
|
|
13708
|
+
i += 5;
|
|
13709
|
+
break;
|
|
13710
|
+
case O$2:
|
|
13711
|
+
data[i] = G$1;
|
|
13712
|
+
data.splice(i + 4, 0, data[i + 3], 0);
|
|
13713
|
+
scalePoints(data, scaleX, scaleY, i, 2);
|
|
13714
|
+
i += 7 + 2;
|
|
13715
|
+
len += 2;
|
|
13716
|
+
break;
|
|
13717
|
+
case P$1:
|
|
13718
|
+
data[i] = F$1;
|
|
13719
|
+
data.splice(i + 4, 0, data[i + 3]);
|
|
13720
|
+
scalePoints(data, scaleX, scaleY, i, 2);
|
|
13721
|
+
i += 4 + 1;
|
|
13722
|
+
len += 1;
|
|
13723
|
+
break;
|
|
13724
|
+
case U$1:
|
|
13725
|
+
scalePoints(data, scaleX, scaleY, i, 2);
|
|
13726
|
+
i += 6;
|
|
13727
|
+
break;
|
|
13728
|
+
}
|
|
13729
|
+
}
|
|
13730
|
+
},
|
|
13731
|
+
scalePoints(data, scaleX, scaleY, start, pointCount) {
|
|
13732
|
+
for (let i = pointCount ? start + 1 : 0, end = pointCount ? i + pointCount * 2 : data.length; i < end; i += 2) {
|
|
13733
|
+
data[i] *= scaleX;
|
|
13734
|
+
data[i + 1] *= scaleY;
|
|
13735
|
+
}
|
|
13736
|
+
}
|
|
13737
|
+
};
|
|
13738
|
+
const { scalePoints } = PathScaler;
|
|
13739
|
+
|
|
13740
|
+
const matrix = MatrixHelper.get();
|
|
13741
|
+
const { topLeft, top, topRight, right, bottom, left } = Direction9;
|
|
13742
|
+
function scaleResize(leaf, scaleX, scaleY) {
|
|
13743
|
+
if (leaf.pathInputed) {
|
|
13744
|
+
scaleResizePath(leaf, scaleX, scaleY);
|
|
13745
|
+
}
|
|
13746
|
+
else {
|
|
13747
|
+
if (scaleX !== 1)
|
|
13748
|
+
leaf.width *= scaleX;
|
|
13749
|
+
if (scaleY !== 1)
|
|
13750
|
+
leaf.height *= scaleY;
|
|
13751
|
+
}
|
|
13752
|
+
}
|
|
13753
|
+
function scaleResizeFontSize(leaf, scaleX, scaleY) {
|
|
13754
|
+
const { app } = leaf;
|
|
13755
|
+
const editor = app && app.editor;
|
|
13756
|
+
let fontScale = scaleX;
|
|
13757
|
+
if (editor.editing) {
|
|
13758
|
+
const layout = leaf.__layout;
|
|
13759
|
+
let { width, height } = layout.boxBounds;
|
|
13760
|
+
width *= scaleY - scaleX;
|
|
13761
|
+
height *= scaleX - scaleY;
|
|
13762
|
+
switch (editor.resizeDirection) {
|
|
13763
|
+
case top:
|
|
13764
|
+
case bottom:
|
|
13765
|
+
fontScale = scaleY;
|
|
13766
|
+
layout.affectScaleOrRotation ? leaf.moveInner(-width / 2, 0) : leaf.x -= width / 2;
|
|
13767
|
+
break;
|
|
13768
|
+
case left:
|
|
13769
|
+
case right:
|
|
13770
|
+
layout.affectScaleOrRotation ? leaf.moveInner(0, -height / 2) : leaf.y -= height / 2;
|
|
13771
|
+
break;
|
|
13772
|
+
case topLeft:
|
|
13773
|
+
case topRight:
|
|
13774
|
+
layout.affectScaleOrRotation ? leaf.moveInner(0, -height) : leaf.y -= height;
|
|
13775
|
+
break;
|
|
13776
|
+
}
|
|
13777
|
+
}
|
|
13778
|
+
leaf.fontSize *= fontScale;
|
|
13779
|
+
const data = leaf.__;
|
|
13780
|
+
if (!data.__autoWidth)
|
|
13781
|
+
leaf.width *= fontScale;
|
|
13782
|
+
if (!data.__autoHeight)
|
|
13783
|
+
leaf.height *= fontScale;
|
|
13784
|
+
}
|
|
13785
|
+
function scaleResizePath(leaf, scaleX, scaleY) {
|
|
13786
|
+
PathScaler.scale(leaf.__.path, scaleX, scaleY);
|
|
13787
|
+
leaf.path = leaf.__.path;
|
|
13788
|
+
}
|
|
13789
|
+
function scaleResizePoints(leaf, scaleX, scaleY) {
|
|
13790
|
+
const { points } = leaf;
|
|
13791
|
+
typeof points[0] === 'object' ? points.forEach(p => { p.x *= scaleX, p.y *= scaleY; }) : PathScaler.scalePoints(points, scaleX, scaleY);
|
|
13792
|
+
leaf.points = points;
|
|
13793
|
+
}
|
|
13794
|
+
function scaleResizeGroup(group, scaleX, scaleY) {
|
|
13795
|
+
const { children } = group;
|
|
13796
|
+
for (let i = 0; i < children.length; i++) {
|
|
13797
|
+
matrix.a = scaleX;
|
|
13798
|
+
matrix.d = scaleY;
|
|
13799
|
+
children[i].transform(matrix, true);
|
|
13800
|
+
}
|
|
13801
|
+
}
|
|
13802
|
+
|
|
13803
|
+
const leaf = Leaf.prototype;
|
|
13804
|
+
leaf.scaleResize = function (scaleX, scaleY = scaleX, noResize) {
|
|
13805
|
+
const data = this;
|
|
13806
|
+
if (noResize || (data.editConfig && data.editConfig.editSize === 'scale')) {
|
|
13807
|
+
data.scaleX *= scaleX;
|
|
13808
|
+
data.scaleY *= scaleY;
|
|
13809
|
+
}
|
|
13810
|
+
else {
|
|
13811
|
+
if (scaleX < 0)
|
|
13812
|
+
data.scaleX *= -1, scaleX = -scaleX;
|
|
13813
|
+
if (scaleY < 0)
|
|
13814
|
+
data.scaleY *= -1, scaleY = -scaleY;
|
|
13815
|
+
this.__scaleResize(scaleX, scaleY);
|
|
13816
|
+
}
|
|
13817
|
+
};
|
|
13818
|
+
leaf.__scaleResize = function (scaleX, scaleY) {
|
|
13819
|
+
scaleResize(this, scaleX, scaleY);
|
|
13820
|
+
};
|
|
13821
|
+
leaf.resizeWidth = function (width) {
|
|
13822
|
+
const scale = width / this.getBounds('box', 'local').width;
|
|
13823
|
+
this.scaleOf(this.__layout.boxBounds, scale, this.__.lockRatio ? scale : 1, true);
|
|
13824
|
+
};
|
|
13825
|
+
leaf.resizeHeight = function (height) {
|
|
13826
|
+
const scale = height / this.getBounds('box', 'local').height;
|
|
13827
|
+
this.scaleOf(this.__layout.boxBounds, this.__.lockRatio ? scale : 1, scale, true);
|
|
13828
|
+
};
|
|
13829
|
+
Text.prototype.__scaleResize = function (scaleX, scaleY) {
|
|
13830
|
+
if (this.__.resizeFontSize || (this.editConfig && this.editConfig.editSize === 'font-size')) {
|
|
13831
|
+
scaleResizeFontSize(this, scaleX, scaleY);
|
|
13832
|
+
}
|
|
13833
|
+
else {
|
|
13834
|
+
scaleResize(this, scaleX, scaleY);
|
|
13835
|
+
}
|
|
13836
|
+
};
|
|
13837
|
+
Path.prototype.__scaleResize = function (scaleX, scaleY) {
|
|
13838
|
+
scaleResizePath(this, scaleX, scaleY);
|
|
13839
|
+
};
|
|
13840
|
+
Line.prototype.__scaleResize = function (scaleX, scaleY) {
|
|
13841
|
+
if (this.pathInputed) {
|
|
13842
|
+
scaleResizePath(this, scaleX, scaleY);
|
|
13843
|
+
}
|
|
13844
|
+
else if (this.points) {
|
|
13845
|
+
scaleResizePoints(this, scaleX, scaleY);
|
|
13846
|
+
}
|
|
13847
|
+
else {
|
|
13848
|
+
this.width *= scaleX;
|
|
13849
|
+
}
|
|
13850
|
+
};
|
|
13851
|
+
Polygon.prototype.__scaleResize = function (scaleX, scaleY) {
|
|
13852
|
+
if (this.pathInputed) {
|
|
13853
|
+
scaleResizePath(this, scaleX, scaleY);
|
|
13854
|
+
}
|
|
13855
|
+
else if (this.points) {
|
|
13856
|
+
scaleResizePoints(this, scaleX, scaleY);
|
|
13857
|
+
}
|
|
13858
|
+
else {
|
|
13859
|
+
scaleResize(this, scaleX, scaleY);
|
|
13860
|
+
}
|
|
13861
|
+
};
|
|
13862
|
+
Group.prototype.__scaleResize = function (scaleX, scaleY) {
|
|
13863
|
+
scaleResizeGroup(this, scaleX, scaleY);
|
|
13864
|
+
};
|
|
13865
|
+
Box.prototype.__scaleResize = function (scaleX, scaleY) {
|
|
13866
|
+
if (this.__.__autoSize && this.children.length) {
|
|
13867
|
+
scaleResizeGroup(this, scaleX, scaleY);
|
|
13868
|
+
}
|
|
13869
|
+
else {
|
|
13870
|
+
scaleResize(this, scaleX, scaleY);
|
|
13871
|
+
if (this.__.resizeChildren)
|
|
13872
|
+
scaleResizeGroup(this, scaleX, scaleY);
|
|
13873
|
+
}
|
|
13874
|
+
};
|
|
13875
|
+
|
|
13876
|
+
Plugin.add('resize');
|
|
13877
|
+
|
|
13878
|
+
Plugin.add('editor');
|
|
13862
13879
|
Creator.editor = function (options) { return new Editor(options); };
|
|
13863
13880
|
dataType(false)(Box.prototype, 'textBox');
|
|
13864
13881
|
defineKey(UI.prototype, 'editOuter', {
|
|
@@ -14232,6 +14249,8 @@ dragger.autoMoveCancel = function () {
|
|
|
14232
14249
|
}
|
|
14233
14250
|
};
|
|
14234
14251
|
|
|
14252
|
+
Plugin.add('viewport');
|
|
14253
|
+
|
|
14235
14254
|
function getZoomScale(scaleX, type) {
|
|
14236
14255
|
let scale = 1;
|
|
14237
14256
|
const out = type === 'out', absScale = Math.abs(scaleX);
|
|
@@ -14259,6 +14278,7 @@ function getFixBounds(bounds, scaleBounds) {
|
|
|
14259
14278
|
return fix ? { x, y, width, height } : bounds;
|
|
14260
14279
|
}
|
|
14261
14280
|
|
|
14281
|
+
Plugin.add('view');
|
|
14262
14282
|
Leafer.prototype.zoom = function (zoomType, padding, fixed) {
|
|
14263
14283
|
const { zoomLayer } = this;
|
|
14264
14284
|
const limitBounds = this.canvas.bounds.clone().shrink(padding !== undefined ? padding : 30), bounds = new Bounds();
|
|
@@ -14431,6 +14451,8 @@ class ScrollBar extends Group {
|
|
|
14431
14451
|
}
|
|
14432
14452
|
}
|
|
14433
14453
|
|
|
14454
|
+
Plugin.add('scroll');
|
|
14455
|
+
|
|
14434
14456
|
class ArrowData extends LineData {
|
|
14435
14457
|
}
|
|
14436
14458
|
|
|
@@ -14690,6 +14712,7 @@ function arrowType(defaultValue) {
|
|
|
14690
14712
|
}));
|
|
14691
14713
|
}
|
|
14692
14714
|
|
|
14715
|
+
Plugin.add('arrow');
|
|
14693
14716
|
const ui = UI.prototype;
|
|
14694
14717
|
arrowType('none')(ui, 'startArrow');
|
|
14695
14718
|
arrowType('none')(ui, 'endArrow');
|
|
@@ -14897,6 +14920,9 @@ TextEditor = __decorate([
|
|
|
14897
14920
|
registerInnerEditor()
|
|
14898
14921
|
], TextEditor);
|
|
14899
14922
|
|
|
14923
|
+
Plugin.add('text-editor');
|
|
14924
|
+
setTimeout(() => Plugin.check('editor', true));
|
|
14925
|
+
|
|
14900
14926
|
class HTMLTextData extends ImageData {
|
|
14901
14927
|
setText(value) {
|
|
14902
14928
|
this._text = value;
|
|
@@ -14955,4 +14981,6 @@ HTMLText = __decorate([
|
|
|
14955
14981
|
registerUI()
|
|
14956
14982
|
], HTMLText);
|
|
14957
14983
|
|
|
14958
|
-
|
|
14984
|
+
Plugin.add('html');
|
|
14985
|
+
|
|
14986
|
+
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 };
|