@leafer-editor/worker 1.0.1 → 1.0.2
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.cjs +54 -0
- package/dist/worker.js +280 -146
- package/dist/worker.min.cjs +1 -0
- package/dist/worker.min.js +1 -1
- package/dist/worker.module.js +278 -147
- package/dist/worker.module.min.js +1 -1
- package/package.json +12 -6
package/dist/worker.module.js
CHANGED
|
@@ -111,6 +111,19 @@ const MathHelper = {
|
|
|
111
111
|
const a = maxLength ? pow$1(10, maxLength) : 1000000000000;
|
|
112
112
|
num = round(num * a) / a;
|
|
113
113
|
return num === -0 ? 0 : num;
|
|
114
|
+
},
|
|
115
|
+
getScaleData(scale, size, originSize, scaleData) {
|
|
116
|
+
if (!scaleData)
|
|
117
|
+
scaleData = {};
|
|
118
|
+
if (size) {
|
|
119
|
+
scaleData.scaleX = (typeof size === 'number' ? size : size.width) / originSize.width;
|
|
120
|
+
scaleData.scaleY = (typeof size === 'number' ? size : size.height) / originSize.height;
|
|
121
|
+
}
|
|
122
|
+
else if (scale) {
|
|
123
|
+
scaleData.scaleX = typeof scale === 'number' ? scale : scale.x;
|
|
124
|
+
scaleData.scaleY = typeof scale === 'number' ? scale : scale.y;
|
|
125
|
+
}
|
|
126
|
+
return scaleData;
|
|
114
127
|
}
|
|
115
128
|
};
|
|
116
129
|
const OneRadian = PI$4 / 180;
|
|
@@ -409,7 +422,7 @@ const MatrixHelper = {
|
|
|
409
422
|
};
|
|
410
423
|
const M$9 = MatrixHelper;
|
|
411
424
|
|
|
412
|
-
const { toInnerPoint: toInnerPoint$2, toOuterPoint: toOuterPoint$
|
|
425
|
+
const { toInnerPoint: toInnerPoint$2, toOuterPoint: toOuterPoint$3 } = MatrixHelper;
|
|
413
426
|
const { sin: sin$4, cos: cos$4, abs: abs$5, sqrt: sqrt$2, atan2: atan2$2, min: min$1, PI: PI$3 } = Math;
|
|
414
427
|
const PointHelper = {
|
|
415
428
|
defaultPoint: getPointData(),
|
|
@@ -465,7 +478,7 @@ const PointHelper = {
|
|
|
465
478
|
tempToOuterOf(t, matrix) {
|
|
466
479
|
const { tempPoint: temp } = P$7;
|
|
467
480
|
copy$e(temp, t);
|
|
468
|
-
toOuterPoint$
|
|
481
|
+
toOuterPoint$3(matrix, temp, temp);
|
|
469
482
|
return temp;
|
|
470
483
|
},
|
|
471
484
|
tempToInnerRadiusPointOf(t, matrix) {
|
|
@@ -484,7 +497,7 @@ const PointHelper = {
|
|
|
484
497
|
toInnerPoint$2(matrix, t, to);
|
|
485
498
|
},
|
|
486
499
|
toOuterOf(t, matrix, to) {
|
|
487
|
-
toOuterPoint$
|
|
500
|
+
toOuterPoint$3(matrix, t, to);
|
|
488
501
|
},
|
|
489
502
|
getCenter(t, to) {
|
|
490
503
|
return { x: t.x + (to.x - t.x) / 2, y: t.y + (to.y - t.y) / 2 };
|
|
@@ -764,10 +777,10 @@ const TwoPointBoundsHelper = {
|
|
|
764
777
|
const { addPoint: addPoint$4 } = TwoPointBoundsHelper;
|
|
765
778
|
|
|
766
779
|
const { tempPointBounds: tempPointBounds$1, setPoint: setPoint$5, addPoint: addPoint$3, toBounds: toBounds$4 } = TwoPointBoundsHelper;
|
|
767
|
-
const { toOuterPoint: toOuterPoint$
|
|
780
|
+
const { toOuterPoint: toOuterPoint$2 } = MatrixHelper;
|
|
768
781
|
const { float, fourNumber } = MathHelper;
|
|
769
782
|
const { floor, ceil: ceil$2 } = Math;
|
|
770
|
-
let right$
|
|
783
|
+
let right$4, bottom$3, boundsRight, boundsBottom;
|
|
771
784
|
const point$1 = {};
|
|
772
785
|
const toPoint$6 = {};
|
|
773
786
|
const BoundsHelper = {
|
|
@@ -784,17 +797,24 @@ const BoundsHelper = {
|
|
|
784
797
|
t.width = bounds.width;
|
|
785
798
|
t.height = bounds.height;
|
|
786
799
|
},
|
|
787
|
-
copyAndSpread(t, bounds, spread, isShrink) {
|
|
800
|
+
copyAndSpread(t, bounds, spread, isShrink, side) {
|
|
801
|
+
const { x, y, width, height } = bounds;
|
|
788
802
|
if (spread instanceof Array) {
|
|
789
803
|
const four = fourNumber(spread);
|
|
790
804
|
isShrink
|
|
791
|
-
? B.set(t,
|
|
792
|
-
: B.set(t,
|
|
805
|
+
? B.set(t, x + four[3], y + four[0], width - four[1] - four[3], height - four[2] - four[0])
|
|
806
|
+
: B.set(t, x - four[3], y - four[0], width + four[1] + four[3], height + four[2] + four[0]);
|
|
793
807
|
}
|
|
794
808
|
else {
|
|
795
809
|
if (isShrink)
|
|
796
810
|
spread = -spread;
|
|
797
|
-
B.set(t,
|
|
811
|
+
B.set(t, x - spread, y - spread, width + spread * 2, height + spread * 2);
|
|
812
|
+
}
|
|
813
|
+
if (side) {
|
|
814
|
+
if (side === 'width')
|
|
815
|
+
t.y = y, t.height = height;
|
|
816
|
+
else
|
|
817
|
+
t.x = x, t.width = width;
|
|
798
818
|
}
|
|
799
819
|
},
|
|
800
820
|
minX(t) { return t.width > 0 ? t.x : t.x + t.width; },
|
|
@@ -871,16 +891,16 @@ const BoundsHelper = {
|
|
|
871
891
|
else {
|
|
872
892
|
point$1.x = t.x;
|
|
873
893
|
point$1.y = t.y;
|
|
874
|
-
toOuterPoint$
|
|
894
|
+
toOuterPoint$2(matrix, point$1, toPoint$6);
|
|
875
895
|
setPoint$5(tempPointBounds$1, toPoint$6.x, toPoint$6.y);
|
|
876
896
|
point$1.x = t.x + t.width;
|
|
877
|
-
toOuterPoint$
|
|
897
|
+
toOuterPoint$2(matrix, point$1, toPoint$6);
|
|
878
898
|
addPoint$3(tempPointBounds$1, toPoint$6.x, toPoint$6.y);
|
|
879
899
|
point$1.y = t.y + t.height;
|
|
880
|
-
toOuterPoint$
|
|
900
|
+
toOuterPoint$2(matrix, point$1, toPoint$6);
|
|
881
901
|
addPoint$3(tempPointBounds$1, toPoint$6.x, toPoint$6.y);
|
|
882
902
|
point$1.x = t.x;
|
|
883
|
-
toOuterPoint$
|
|
903
|
+
toOuterPoint$2(matrix, point$1, toPoint$6);
|
|
884
904
|
addPoint$3(tempPointBounds$1, toPoint$6.x, toPoint$6.y);
|
|
885
905
|
toBounds$4(tempPointBounds$1, to);
|
|
886
906
|
}
|
|
@@ -894,16 +914,16 @@ const BoundsHelper = {
|
|
|
894
914
|
const scale = Math.min(baseScale, Math.min(t.width / put.width, t.height / put.height));
|
|
895
915
|
return new Matrix(scale, 0, 0, scale, -put.x * scale, -put.y * scale);
|
|
896
916
|
},
|
|
897
|
-
getSpread(t, spread) {
|
|
917
|
+
getSpread(t, spread, side) {
|
|
898
918
|
const n = {};
|
|
899
|
-
B.copyAndSpread(n, t, spread);
|
|
919
|
+
B.copyAndSpread(n, t, spread, false, side);
|
|
900
920
|
return n;
|
|
901
921
|
},
|
|
902
|
-
spread(t, spread) {
|
|
903
|
-
B.copyAndSpread(t, t, spread);
|
|
922
|
+
spread(t, spread, side) {
|
|
923
|
+
B.copyAndSpread(t, t, spread, false, side);
|
|
904
924
|
},
|
|
905
|
-
shrink(t, shrink) {
|
|
906
|
-
B.copyAndSpread(t, t, shrink, true);
|
|
925
|
+
shrink(t, shrink, side) {
|
|
926
|
+
B.copyAndSpread(t, t, shrink, true, side);
|
|
907
927
|
},
|
|
908
928
|
ceil(t) {
|
|
909
929
|
const { x, y } = t;
|
|
@@ -929,20 +949,20 @@ const BoundsHelper = {
|
|
|
929
949
|
t.height = float(t.height, maxLength);
|
|
930
950
|
},
|
|
931
951
|
add(t, bounds, isPoint) {
|
|
932
|
-
right$
|
|
933
|
-
bottom$
|
|
952
|
+
right$4 = t.x + t.width;
|
|
953
|
+
bottom$3 = t.y + t.height;
|
|
934
954
|
boundsRight = bounds.x;
|
|
935
955
|
boundsBottom = bounds.y;
|
|
936
956
|
if (!isPoint) {
|
|
937
957
|
boundsRight += bounds.width;
|
|
938
958
|
boundsBottom += bounds.height;
|
|
939
959
|
}
|
|
940
|
-
right$
|
|
941
|
-
bottom$
|
|
960
|
+
right$4 = right$4 > boundsRight ? right$4 : boundsRight;
|
|
961
|
+
bottom$3 = bottom$3 > boundsBottom ? bottom$3 : boundsBottom;
|
|
942
962
|
t.x = t.x < bounds.x ? t.x : bounds.x;
|
|
943
963
|
t.y = t.y < bounds.y ? t.y : bounds.y;
|
|
944
|
-
t.width = right$
|
|
945
|
-
t.height = bottom$
|
|
964
|
+
t.width = right$4 - t.x;
|
|
965
|
+
t.height = bottom$3 - t.y;
|
|
946
966
|
},
|
|
947
967
|
addList(t, list) {
|
|
948
968
|
B.setListWithFn(t, list, undefined, true);
|
|
@@ -1016,16 +1036,16 @@ const BoundsHelper = {
|
|
|
1016
1036
|
if (!B.hit(t, other))
|
|
1017
1037
|
return getBoundsData();
|
|
1018
1038
|
let { x, y, width, height } = other;
|
|
1019
|
-
right$
|
|
1020
|
-
bottom$
|
|
1039
|
+
right$4 = x + width;
|
|
1040
|
+
bottom$3 = y + height;
|
|
1021
1041
|
boundsRight = t.x + t.width;
|
|
1022
1042
|
boundsBottom = t.y + t.height;
|
|
1023
1043
|
x = x > t.x ? x : t.x;
|
|
1024
1044
|
y = y > t.y ? y : t.y;
|
|
1025
|
-
right$
|
|
1026
|
-
bottom$
|
|
1027
|
-
width = right$
|
|
1028
|
-
height = bottom$
|
|
1045
|
+
right$4 = right$4 < boundsRight ? right$4 : boundsRight;
|
|
1046
|
+
bottom$3 = bottom$3 < boundsBottom ? bottom$3 : boundsBottom;
|
|
1047
|
+
width = right$4 - x;
|
|
1048
|
+
height = bottom$3 - y;
|
|
1029
1049
|
return { x, y, width, height };
|
|
1030
1050
|
},
|
|
1031
1051
|
intersect(t, other, otherMatrix) {
|
|
@@ -1086,12 +1106,12 @@ class Bounds {
|
|
|
1086
1106
|
getFitMatrix(put, baseScale) {
|
|
1087
1107
|
return BoundsHelper.getFitMatrix(this, put, baseScale);
|
|
1088
1108
|
}
|
|
1089
|
-
spread(fourNumber) {
|
|
1090
|
-
BoundsHelper.spread(this, fourNumber);
|
|
1109
|
+
spread(fourNumber, side) {
|
|
1110
|
+
BoundsHelper.spread(this, fourNumber, side);
|
|
1091
1111
|
return this;
|
|
1092
1112
|
}
|
|
1093
|
-
shrink(fourNumber) {
|
|
1094
|
-
BoundsHelper.shrink(this, fourNumber);
|
|
1113
|
+
shrink(fourNumber, side) {
|
|
1114
|
+
BoundsHelper.shrink(this, fourNumber, side);
|
|
1095
1115
|
return this;
|
|
1096
1116
|
}
|
|
1097
1117
|
ceil() {
|
|
@@ -2908,60 +2928,75 @@ class PathCreator {
|
|
|
2908
2928
|
}
|
|
2909
2929
|
beginPath() {
|
|
2910
2930
|
beginPath(this.__path);
|
|
2931
|
+
this.paint();
|
|
2911
2932
|
return this;
|
|
2912
2933
|
}
|
|
2913
2934
|
moveTo(x, y) {
|
|
2914
2935
|
moveTo$4(this.__path, x, y);
|
|
2936
|
+
this.paint();
|
|
2915
2937
|
return this;
|
|
2916
2938
|
}
|
|
2917
2939
|
lineTo(x, y) {
|
|
2918
2940
|
lineTo$3(this.__path, x, y);
|
|
2941
|
+
this.paint();
|
|
2919
2942
|
return this;
|
|
2920
2943
|
}
|
|
2921
2944
|
bezierCurveTo(x1, y1, x2, y2, x, y) {
|
|
2922
2945
|
bezierCurveTo(this.__path, x1, y1, x2, y2, x, y);
|
|
2946
|
+
this.paint();
|
|
2923
2947
|
return this;
|
|
2924
2948
|
}
|
|
2925
2949
|
quadraticCurveTo(x1, y1, x, y) {
|
|
2926
2950
|
quadraticCurveTo(this.__path, x1, y1, x, y);
|
|
2951
|
+
this.paint();
|
|
2927
2952
|
return this;
|
|
2928
2953
|
}
|
|
2929
2954
|
closePath() {
|
|
2930
2955
|
closePath$3(this.__path);
|
|
2956
|
+
this.paint();
|
|
2931
2957
|
return this;
|
|
2932
2958
|
}
|
|
2933
2959
|
rect(x, y, width, height) {
|
|
2934
2960
|
rect$2(this.__path, x, y, width, height);
|
|
2961
|
+
this.paint();
|
|
2935
2962
|
return this;
|
|
2936
2963
|
}
|
|
2937
2964
|
roundRect(x, y, width, height, cornerRadius) {
|
|
2938
2965
|
roundRect$1(this.__path, x, y, width, height, cornerRadius);
|
|
2966
|
+
this.paint();
|
|
2939
2967
|
return this;
|
|
2940
2968
|
}
|
|
2941
2969
|
ellipse(x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise) {
|
|
2942
2970
|
ellipse$2(this.__path, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise);
|
|
2971
|
+
this.paint();
|
|
2943
2972
|
return this;
|
|
2944
2973
|
}
|
|
2945
2974
|
arc(x, y, radius, startAngle, endAngle, anticlockwise) {
|
|
2946
2975
|
arc$1(this.__path, x, y, radius, startAngle, endAngle, anticlockwise);
|
|
2976
|
+
this.paint();
|
|
2947
2977
|
return this;
|
|
2948
2978
|
}
|
|
2949
2979
|
arcTo(x1, y1, x2, y2, radius) {
|
|
2950
2980
|
arcTo$2(this.__path, x1, y1, x2, y2, radius);
|
|
2981
|
+
this.paint();
|
|
2951
2982
|
return this;
|
|
2952
2983
|
}
|
|
2953
2984
|
drawEllipse(x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise) {
|
|
2954
2985
|
drawEllipse(this.__path, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise);
|
|
2986
|
+
this.paint();
|
|
2955
2987
|
return this;
|
|
2956
2988
|
}
|
|
2957
2989
|
drawArc(x, y, radius, startAngle, endAngle, anticlockwise) {
|
|
2958
2990
|
drawArc(this.__path, x, y, radius, startAngle, endAngle, anticlockwise);
|
|
2991
|
+
this.paint();
|
|
2959
2992
|
return this;
|
|
2960
2993
|
}
|
|
2961
2994
|
drawPoints(points, curve, close) {
|
|
2962
2995
|
drawPoints$2(this.__path, points, curve, close);
|
|
2996
|
+
this.paint();
|
|
2963
2997
|
return this;
|
|
2964
2998
|
}
|
|
2999
|
+
paint() { }
|
|
2965
3000
|
}
|
|
2966
3001
|
|
|
2967
3002
|
const { M: M$5, L: L$6, C: C$5, Q: Q$4, Z: Z$4, N: N$3, D: D$3, X: X$3, G: G$3, F: F$4, O: O$4, P: P$3, U: U$3 } = PathCommandMap;
|
|
@@ -3983,7 +4018,7 @@ function registerUIEvent() {
|
|
|
3983
4018
|
};
|
|
3984
4019
|
}
|
|
3985
4020
|
|
|
3986
|
-
const { copy: copy$a, toInnerPoint: toInnerPoint$1, scaleOfOuter: scaleOfOuter$2, rotateOfOuter: rotateOfOuter$2, skewOfOuter, multiplyParent: multiplyParent$2, divideParent, getLayout } = MatrixHelper;
|
|
4021
|
+
const { copy: copy$a, toInnerPoint: toInnerPoint$1, toOuterPoint: toOuterPoint$1, scaleOfOuter: scaleOfOuter$2, rotateOfOuter: rotateOfOuter$2, skewOfOuter, multiplyParent: multiplyParent$2, divideParent, getLayout } = MatrixHelper;
|
|
3987
4022
|
const matrix$3 = {};
|
|
3988
4023
|
const LeafHelper = {
|
|
3989
4024
|
updateAllMatrix(leaf, checkAutoLayout, waitAutoLayout) {
|
|
@@ -4048,10 +4083,9 @@ const LeafHelper = {
|
|
|
4048
4083
|
}
|
|
4049
4084
|
return true;
|
|
4050
4085
|
},
|
|
4051
|
-
moveWorld(t, x, y = 0) {
|
|
4086
|
+
moveWorld(t, x, y = 0, isInnerPoint) {
|
|
4052
4087
|
const local = typeof x === 'object' ? Object.assign({}, x) : { x, y };
|
|
4053
|
-
|
|
4054
|
-
toInnerPoint$1(t.parent.worldTransform, local, local, true);
|
|
4088
|
+
isInnerPoint ? toOuterPoint$1(t.localTransform, local, local, true) : (t.parent && toInnerPoint$1(t.parent.worldTransform, local, local, true));
|
|
4055
4089
|
L$3.moveLocal(t, local.x, local.y);
|
|
4056
4090
|
},
|
|
4057
4091
|
moveLocal(t, x, y = 0) {
|
|
@@ -4918,7 +4952,7 @@ const LeafMatrix = {
|
|
|
4918
4952
|
|
|
4919
4953
|
const { updateMatrix: updateMatrix$1, updateAllMatrix: updateAllMatrix$2 } = LeafHelper;
|
|
4920
4954
|
const { updateBounds: updateBounds$1 } = BranchHelper;
|
|
4921
|
-
const { toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$
|
|
4955
|
+
const { toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$2, copy: copy$8 } = BoundsHelper;
|
|
4922
4956
|
const { toBounds: toBounds$2 } = PathBounds;
|
|
4923
4957
|
const LeafBounds = {
|
|
4924
4958
|
__updateWorldBounds() {
|
|
@@ -5019,7 +5053,7 @@ const LeafBounds = {
|
|
|
5019
5053
|
updateAllMatrix$2(this);
|
|
5020
5054
|
updateBounds$1(this, this);
|
|
5021
5055
|
if (this.__.__autoSide)
|
|
5022
|
-
this.__updateBoxBounds();
|
|
5056
|
+
this.__updateBoxBounds(true);
|
|
5023
5057
|
}
|
|
5024
5058
|
else {
|
|
5025
5059
|
updateAllMatrix$2(this);
|
|
@@ -5037,11 +5071,11 @@ const LeafBounds = {
|
|
|
5037
5071
|
},
|
|
5038
5072
|
__updateStrokeBounds() {
|
|
5039
5073
|
const layout = this.__layout;
|
|
5040
|
-
copyAndSpread$
|
|
5074
|
+
copyAndSpread$2(layout.strokeBounds, layout.boxBounds, layout.strokeBoxSpread);
|
|
5041
5075
|
},
|
|
5042
5076
|
__updateRenderBounds() {
|
|
5043
5077
|
const layout = this.__layout;
|
|
5044
|
-
layout.renderSpread > 0 ? copyAndSpread$
|
|
5078
|
+
layout.renderSpread > 0 ? copyAndSpread$2(layout.renderBounds, layout.boxBounds, layout.renderSpread) : copy$8(layout.renderBounds, layout.strokeBounds);
|
|
5045
5079
|
}
|
|
5046
5080
|
};
|
|
5047
5081
|
|
|
@@ -5401,6 +5435,9 @@ let Leaf = class Leaf {
|
|
|
5401
5435
|
move(x, y) {
|
|
5402
5436
|
moveLocal(this, x, y);
|
|
5403
5437
|
}
|
|
5438
|
+
moveInner(x, y) {
|
|
5439
|
+
moveWorld(this, x, y, true);
|
|
5440
|
+
}
|
|
5404
5441
|
scaleOf(origin, scaleX, scaleY, resize) {
|
|
5405
5442
|
zoomOfLocal(this, getLocalOrigin(this, origin), scaleX, scaleY, resize);
|
|
5406
5443
|
}
|
|
@@ -6938,6 +6975,11 @@ class BoxData extends GroupData {
|
|
|
6938
6975
|
}
|
|
6939
6976
|
|
|
6940
6977
|
class LeaferData extends GroupData {
|
|
6978
|
+
__getInputData() {
|
|
6979
|
+
const data = super.__getInputData();
|
|
6980
|
+
canvasSizeAttrs.forEach(key => delete data[key]);
|
|
6981
|
+
return data;
|
|
6982
|
+
}
|
|
6941
6983
|
}
|
|
6942
6984
|
|
|
6943
6985
|
class FrameData extends BoxData {
|
|
@@ -7015,6 +7057,11 @@ class ImageData extends RectData {
|
|
|
7015
7057
|
}
|
|
7016
7058
|
|
|
7017
7059
|
class CanvasData extends RectData {
|
|
7060
|
+
__getInputData() {
|
|
7061
|
+
const data = super.__getInputData();
|
|
7062
|
+
data.url = this.__leaf.canvas.toDataURL('image/png');
|
|
7063
|
+
return data;
|
|
7064
|
+
}
|
|
7018
7065
|
}
|
|
7019
7066
|
|
|
7020
7067
|
const UIBounds = {
|
|
@@ -7927,6 +7974,13 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
7927
7974
|
getWorldPointByClient(clientPoint, updateClient) {
|
|
7928
7975
|
return this.interaction && this.interaction.getLocal(clientPoint, updateClient);
|
|
7929
7976
|
}
|
|
7977
|
+
getPagePointByClient(clientPoint, updateClient) {
|
|
7978
|
+
return this.getPagePoint(this.getWorldPointByClient(clientPoint, updateClient));
|
|
7979
|
+
}
|
|
7980
|
+
updateClientBounds() {
|
|
7981
|
+
this.canvas && this.canvas.updateClientBounds();
|
|
7982
|
+
}
|
|
7983
|
+
receiveEvent(_event) { }
|
|
7930
7984
|
__checkUpdateLayout() {
|
|
7931
7985
|
this.__layout.update();
|
|
7932
7986
|
}
|
|
@@ -8010,7 +8064,7 @@ Rect = __decorate([
|
|
|
8010
8064
|
const rect$1 = Rect.prototype;
|
|
8011
8065
|
const group$1 = Group.prototype;
|
|
8012
8066
|
const childrenRenderBounds = {};
|
|
8013
|
-
const { copy: copy$6, add, includes: includes$1 } = BoundsHelper;
|
|
8067
|
+
const { copy: copy$6, add, includes: includes$1, copyAndSpread: copyAndSpread$1 } = BoundsHelper;
|
|
8014
8068
|
let Box = class Box extends Group {
|
|
8015
8069
|
get __tag() { return 'Box'; }
|
|
8016
8070
|
get isBranchLeaf() { return true; }
|
|
@@ -8024,20 +8078,23 @@ let Box = class Box extends Group {
|
|
|
8024
8078
|
return this.__updateRectRenderSpread() || -1;
|
|
8025
8079
|
}
|
|
8026
8080
|
__updateRectBoxBounds() { }
|
|
8027
|
-
__updateBoxBounds() {
|
|
8081
|
+
__updateBoxBounds(secondLayout) {
|
|
8028
8082
|
const data = this.__;
|
|
8029
8083
|
if (this.children.length) {
|
|
8030
8084
|
if (data.__autoSide) {
|
|
8031
8085
|
if (this.leafer && this.leafer.ready)
|
|
8032
8086
|
this.leafer.layouter.addExtra(this);
|
|
8033
8087
|
super.__updateBoxBounds();
|
|
8088
|
+
const { boxBounds } = this.__layout;
|
|
8034
8089
|
if (!data.__autoSize) {
|
|
8035
|
-
|
|
8036
|
-
|
|
8037
|
-
|
|
8038
|
-
|
|
8039
|
-
b.width += b.x, b.height = data.height, b.y = b.x = 0;
|
|
8090
|
+
if (data.__autoWidth)
|
|
8091
|
+
boxBounds.width += boxBounds.x, boxBounds.height = data.height, boxBounds.y = boxBounds.x = 0;
|
|
8092
|
+
else
|
|
8093
|
+
boxBounds.height += boxBounds.y, boxBounds.width = data.width, boxBounds.x = boxBounds.y = 0;
|
|
8040
8094
|
}
|
|
8095
|
+
if (secondLayout && data.flow && data.padding)
|
|
8096
|
+
copyAndSpread$1(boxBounds, boxBounds, data.padding, false, data.__autoSize ? null : (data.__autoWidth ? 'width' : 'height'));
|
|
8097
|
+
this.__updateNaturalSize();
|
|
8041
8098
|
}
|
|
8042
8099
|
else {
|
|
8043
8100
|
this.__updateRectBoxBounds();
|
|
@@ -8057,13 +8114,13 @@ let Box = class Box extends Group {
|
|
|
8057
8114
|
super.__updateRenderBounds();
|
|
8058
8115
|
copy$6(childrenRenderBounds, renderBounds);
|
|
8059
8116
|
this.__updateRectRenderBounds();
|
|
8060
|
-
isOverflow = !includes$1(renderBounds, childrenRenderBounds) ||
|
|
8117
|
+
isOverflow = !includes$1(renderBounds, childrenRenderBounds) || !this.pathInputed || !this.__.cornerRadius;
|
|
8061
8118
|
}
|
|
8062
8119
|
else {
|
|
8063
8120
|
this.__updateRectRenderBounds();
|
|
8064
8121
|
}
|
|
8065
8122
|
this.isOverflow !== isOverflow && (this.isOverflow = isOverflow);
|
|
8066
|
-
if (
|
|
8123
|
+
if (!(this.__.__drawAfterFill = this.__.overflow === 'hide') && isOverflow)
|
|
8067
8124
|
add(renderBounds, childrenRenderBounds);
|
|
8068
8125
|
}
|
|
8069
8126
|
__updateRectRenderBounds() { }
|
|
@@ -8397,14 +8454,26 @@ __decorate([
|
|
|
8397
8454
|
Image = __decorate([
|
|
8398
8455
|
registerUI()
|
|
8399
8456
|
], Image);
|
|
8457
|
+
const MyImage = Image;
|
|
8400
8458
|
|
|
8401
8459
|
let Canvas = class Canvas extends Rect {
|
|
8402
8460
|
get __tag() { return 'Canvas'; }
|
|
8461
|
+
get ready() { return !this.url; }
|
|
8403
8462
|
constructor(data) {
|
|
8404
8463
|
super(data);
|
|
8405
8464
|
this.canvas = Creator.canvas(this.__);
|
|
8406
8465
|
this.context = this.canvas.context;
|
|
8407
8466
|
this.__.__isCanvas = this.__.__drawAfterFill = true;
|
|
8467
|
+
if (data && data.url)
|
|
8468
|
+
this.drawImage(data.url);
|
|
8469
|
+
}
|
|
8470
|
+
drawImage(url) {
|
|
8471
|
+
new LeaferImage({ url }).load((image) => {
|
|
8472
|
+
this.context.drawImage(image.view, 0, 0);
|
|
8473
|
+
this.url = undefined;
|
|
8474
|
+
this.paint();
|
|
8475
|
+
this.emitEvent(new ImageEvent(ImageEvent.LOADED, { image }));
|
|
8476
|
+
});
|
|
8408
8477
|
}
|
|
8409
8478
|
draw(ui, offset, scale, rotation) {
|
|
8410
8479
|
ui.__layout.update();
|
|
@@ -8463,7 +8532,7 @@ __decorate([
|
|
|
8463
8532
|
resizeType(100)
|
|
8464
8533
|
], Canvas.prototype, "height", void 0);
|
|
8465
8534
|
__decorate([
|
|
8466
|
-
resizeType(
|
|
8535
|
+
resizeType(1)
|
|
8467
8536
|
], Canvas.prototype, "pixelRatio", void 0);
|
|
8468
8537
|
__decorate([
|
|
8469
8538
|
resizeType(true)
|
|
@@ -8487,13 +8556,13 @@ let Text = class Text extends UI {
|
|
|
8487
8556
|
super(data);
|
|
8488
8557
|
}
|
|
8489
8558
|
__drawHitPath(canvas) {
|
|
8490
|
-
const { __lineHeight, __baseLine, __textDrawData: data } = this.__;
|
|
8559
|
+
const { __lineHeight, fontSize, __baseLine, __textDrawData: data } = this.__;
|
|
8491
8560
|
canvas.beginPath();
|
|
8492
8561
|
if (this.__.__letterSpacing < 0) {
|
|
8493
8562
|
this.__drawPathByData(canvas);
|
|
8494
8563
|
}
|
|
8495
8564
|
else {
|
|
8496
|
-
data.rows.forEach(row => canvas.rect(row.x, row.y - __baseLine, row.width, __lineHeight));
|
|
8565
|
+
data.rows.forEach(row => canvas.rect(row.x, row.y - __baseLine, row.width, __lineHeight < fontSize ? fontSize : __lineHeight));
|
|
8497
8566
|
}
|
|
8498
8567
|
}
|
|
8499
8568
|
__drawPathByData(drawer, _data) {
|
|
@@ -8686,7 +8755,8 @@ let Pen = class Pen extends Group {
|
|
|
8686
8755
|
drawPoints(_points, _curve, _close) { return this; }
|
|
8687
8756
|
clearPath() { return this; }
|
|
8688
8757
|
paint() {
|
|
8689
|
-
this.pathElement.
|
|
8758
|
+
if (!this.pathElement.__layout.boxChanged)
|
|
8759
|
+
this.pathElement.forceUpdate('path');
|
|
8690
8760
|
}
|
|
8691
8761
|
};
|
|
8692
8762
|
__decorate([
|
|
@@ -8696,7 +8766,7 @@ __decorate([
|
|
|
8696
8766
|
penPathType()
|
|
8697
8767
|
], Pen.prototype, "path", void 0);
|
|
8698
8768
|
Pen = __decorate([
|
|
8699
|
-
useModule(PathCreator, ['set', 'beginPath', 'path']),
|
|
8769
|
+
useModule(PathCreator, ['set', 'beginPath', 'path', 'paint']),
|
|
8700
8770
|
registerUI()
|
|
8701
8771
|
], Pen);
|
|
8702
8772
|
function penPathType() {
|
|
@@ -8919,6 +8989,7 @@ PointerEvent.MENU_TAP = 'pointer.menu_tap';
|
|
|
8919
8989
|
PointerEvent = __decorate([
|
|
8920
8990
|
registerUIEvent()
|
|
8921
8991
|
], PointerEvent);
|
|
8992
|
+
const MyPointerEvent = PointerEvent;
|
|
8922
8993
|
|
|
8923
8994
|
const move$1 = {};
|
|
8924
8995
|
let DragEvent = class DragEvent extends PointerEvent {
|
|
@@ -9018,6 +9089,7 @@ DragEvent.LEAVE = 'drag.leave';
|
|
|
9018
9089
|
DragEvent = __decorate([
|
|
9019
9090
|
registerUIEvent()
|
|
9020
9091
|
], DragEvent);
|
|
9092
|
+
const MyDragEvent = DragEvent;
|
|
9021
9093
|
|
|
9022
9094
|
let DropEvent = class DropEvent extends PointerEvent {
|
|
9023
9095
|
static setList(data) {
|
|
@@ -9099,36 +9171,32 @@ function addInteractionWindow(leafer) {
|
|
|
9099
9171
|
|
|
9100
9172
|
function document$1(leafer) {
|
|
9101
9173
|
addInteractionWindow(leafer);
|
|
9102
|
-
|
|
9103
|
-
|
|
9174
|
+
const { move, zoom } = leafer.config;
|
|
9175
|
+
move.scroll = 'limit';
|
|
9176
|
+
zoom.min = 1;
|
|
9177
|
+
}
|
|
9178
|
+
|
|
9179
|
+
function block(leafer) {
|
|
9180
|
+
const { config } = leafer;
|
|
9181
|
+
(config.wheel || (config.wheel = {})).preventDefault = false;
|
|
9182
|
+
(config.touch || (config.touch = {})).preventDefault = 'auto';
|
|
9104
9183
|
}
|
|
9105
9184
|
|
|
9106
9185
|
const debug$3 = Debug.get('LeaferTypeCreator');
|
|
9107
9186
|
const LeaferTypeCreator = {
|
|
9108
9187
|
list: {},
|
|
9109
9188
|
register(name, fn) {
|
|
9110
|
-
|
|
9111
|
-
debug$3.repeat(name);
|
|
9112
|
-
}
|
|
9113
|
-
else {
|
|
9114
|
-
list$1[name] = fn;
|
|
9115
|
-
}
|
|
9189
|
+
list$1[name] ? debug$3.repeat(name) : list$1[name] = fn;
|
|
9116
9190
|
},
|
|
9117
9191
|
run(name, leafer) {
|
|
9118
9192
|
const fn = list$1[name];
|
|
9119
|
-
|
|
9120
|
-
fn(leafer);
|
|
9121
|
-
}
|
|
9122
|
-
else {
|
|
9123
|
-
debug$3.error('no', name);
|
|
9124
|
-
}
|
|
9193
|
+
fn && fn(leafer);
|
|
9125
9194
|
}
|
|
9126
9195
|
};
|
|
9127
9196
|
const { list: list$1, register } = LeaferTypeCreator;
|
|
9128
|
-
register('draw', () => { });
|
|
9129
|
-
register('custom', () => { });
|
|
9130
9197
|
register('design', addInteractionWindow);
|
|
9131
9198
|
register('document', document$1);
|
|
9199
|
+
register('block', block);
|
|
9132
9200
|
|
|
9133
9201
|
const leafer = Leafer.prototype;
|
|
9134
9202
|
leafer.initType = function (type) {
|
|
@@ -9317,7 +9385,13 @@ const InteractionHelper = {
|
|
|
9317
9385
|
find.add(list[i]);
|
|
9318
9386
|
}
|
|
9319
9387
|
return find;
|
|
9320
|
-
}
|
|
9388
|
+
},
|
|
9389
|
+
pathCanDrag(path) {
|
|
9390
|
+
return path && path.list.some(item => item.draggable || item.editable || (!item.isLeafer && item.hasEvent(DragEvent.DRAG)));
|
|
9391
|
+
},
|
|
9392
|
+
pathHasOutside(path) {
|
|
9393
|
+
return path && path.list.some(item => item.isOutside);
|
|
9394
|
+
},
|
|
9321
9395
|
};
|
|
9322
9396
|
const I = InteractionHelper;
|
|
9323
9397
|
|
|
@@ -9627,15 +9701,18 @@ const config$1 = {
|
|
|
9627
9701
|
swipeDistance: 20,
|
|
9628
9702
|
preventDefaultMenu: true
|
|
9629
9703
|
},
|
|
9704
|
+
touch: {
|
|
9705
|
+
preventDefault: true
|
|
9706
|
+
},
|
|
9630
9707
|
cursor: true,
|
|
9631
9708
|
keyEvent: true
|
|
9632
9709
|
};
|
|
9633
9710
|
|
|
9634
|
-
const { pathHasEventType, getMoveEventData, getZoomEventData, getRotateEventData } = InteractionHelper;
|
|
9711
|
+
const { pathHasEventType, getMoveEventData, getZoomEventData, getRotateEventData, pathCanDrag, pathHasOutside } = InteractionHelper;
|
|
9635
9712
|
class InteractionBase {
|
|
9636
9713
|
get dragging() { return this.dragger.dragging; }
|
|
9637
9714
|
get transforming() { return this.transformer.transforming; }
|
|
9638
|
-
get moveMode() { return this.config.move.drag || this.isHoldSpaceKey || this.isHoldMiddleKey || (this.isHoldRightKey && this.dragger.moving) || this.isDragEmpty; }
|
|
9715
|
+
get moveMode() { return this.config.move.drag === true || this.isHoldSpaceKey || this.isHoldMiddleKey || (this.isHoldRightKey && this.dragger.moving) || this.isDragEmpty; }
|
|
9639
9716
|
get canHover() { return this.config.pointer.hover && !this.config.mobile; }
|
|
9640
9717
|
get isDragEmpty() { return this.config.move.dragEmpty && this.isRootPath(this.hoverData) && (!this.downData || this.isRootPath(this.downData)); }
|
|
9641
9718
|
get isMobileDragEmpty() { return this.config.move.dragEmpty && !this.canHover && this.downData && this.isTreePath(this.downData); }
|
|
@@ -9644,7 +9721,7 @@ class InteractionBase {
|
|
|
9644
9721
|
get isHoldSpaceKey() { return this.config.move.holdSpaceKey && Keyboard.isHoldSpaceKey(); }
|
|
9645
9722
|
get hitRadius() { return this.config.pointer.hitRadius; }
|
|
9646
9723
|
constructor(target, canvas, selector, userConfig) {
|
|
9647
|
-
this.config = config$1;
|
|
9724
|
+
this.config = DataHelper.clone(config$1);
|
|
9648
9725
|
this.tapCount = 0;
|
|
9649
9726
|
this.downKeyMap = {};
|
|
9650
9727
|
this.target = target;
|
|
@@ -9896,11 +9973,11 @@ class InteractionBase {
|
|
|
9896
9973
|
return app.editor && (!data.path.has(app.editor) && data.path.has(app.tree) && !data.target.syncEventer);
|
|
9897
9974
|
}
|
|
9898
9975
|
checkPath(data, useDefaultPath) {
|
|
9899
|
-
if (useDefaultPath || this.
|
|
9976
|
+
if (useDefaultPath || (this.moveMode && !pathHasOutside(data.path)))
|
|
9900
9977
|
data.path = this.defaultPath;
|
|
9901
9978
|
}
|
|
9902
9979
|
canMove(data) {
|
|
9903
|
-
return this.moveMode
|
|
9980
|
+
return data && (this.moveMode || (this.config.move.drag === 'auto' && !pathCanDrag(data.path))) && !pathHasOutside(data.path);
|
|
9904
9981
|
}
|
|
9905
9982
|
isDrag(leaf) {
|
|
9906
9983
|
return this.dragger.getList().has(leaf);
|
|
@@ -10595,10 +10672,13 @@ function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, al
|
|
|
10595
10672
|
const { get: get$2, translate } = MatrixHelper;
|
|
10596
10673
|
const tempBox = new Bounds();
|
|
10597
10674
|
const tempPoint = {};
|
|
10675
|
+
const tempScaleData = {};
|
|
10598
10676
|
function createData(leafPaint, image, paint, box) {
|
|
10599
|
-
const { blendMode } = paint;
|
|
10677
|
+
const { blendMode, sync } = paint;
|
|
10600
10678
|
if (blendMode)
|
|
10601
10679
|
leafPaint.blendMode = blendMode;
|
|
10680
|
+
if (sync)
|
|
10681
|
+
leafPaint.sync = sync;
|
|
10602
10682
|
leafPaint.data = getPatternData(paint, box, image);
|
|
10603
10683
|
}
|
|
10604
10684
|
function getPatternData(paint, box, image) {
|
|
@@ -10618,13 +10698,10 @@ function getPatternData(paint, box, image) {
|
|
|
10618
10698
|
x += (box.width - width * scaleX) / 2, y += (box.height - height * scaleY) / 2;
|
|
10619
10699
|
}
|
|
10620
10700
|
}
|
|
10621
|
-
else if (size) {
|
|
10622
|
-
|
|
10623
|
-
|
|
10624
|
-
|
|
10625
|
-
else if (scale) {
|
|
10626
|
-
scaleX = typeof scale === 'number' ? scale : scale.x;
|
|
10627
|
-
scaleY = typeof scale === 'number' ? scale : scale.y;
|
|
10701
|
+
else if (scale || size) {
|
|
10702
|
+
MathHelper.getScaleData(scale, size, image, tempScaleData);
|
|
10703
|
+
scaleX = tempScaleData.scaleX;
|
|
10704
|
+
scaleY = tempScaleData.scaleY;
|
|
10628
10705
|
}
|
|
10629
10706
|
if (align) {
|
|
10630
10707
|
const imageBounds = { x, y, width: swapWidth, height: swapHeight };
|
|
@@ -10863,7 +10940,7 @@ function checkImage(ui, canvas, paint, allowPaint) {
|
|
|
10863
10940
|
return true;
|
|
10864
10941
|
}
|
|
10865
10942
|
else {
|
|
10866
|
-
if (!paint.style || Export.running) {
|
|
10943
|
+
if (!paint.style || paint.sync || Export.running) {
|
|
10867
10944
|
createPattern(ui, paint, canvas.pixelRatio);
|
|
10868
10945
|
}
|
|
10869
10946
|
else {
|
|
@@ -11631,7 +11708,7 @@ function decorationText(drawData, style) {
|
|
|
11631
11708
|
}
|
|
11632
11709
|
}
|
|
11633
11710
|
|
|
11634
|
-
const { top: top$
|
|
11711
|
+
const { top: top$2, right: right$3, bottom: bottom$2, left: left$3 } = Direction4;
|
|
11635
11712
|
function getDrawData(content, style) {
|
|
11636
11713
|
if (typeof content !== 'string')
|
|
11637
11714
|
content = String(content);
|
|
@@ -11641,12 +11718,12 @@ function getDrawData(content, style) {
|
|
|
11641
11718
|
const { textDecoration, __font, __padding: padding } = style;
|
|
11642
11719
|
if (padding) {
|
|
11643
11720
|
if (width) {
|
|
11644
|
-
x = padding[left$
|
|
11645
|
-
width -= (padding[right$
|
|
11721
|
+
x = padding[left$3];
|
|
11722
|
+
width -= (padding[right$3] + padding[left$3]);
|
|
11646
11723
|
}
|
|
11647
11724
|
if (height) {
|
|
11648
|
-
y = padding[top$
|
|
11649
|
-
height -= (padding[top$
|
|
11725
|
+
y = padding[top$2];
|
|
11726
|
+
height -= (padding[top$2] + padding[bottom$2]);
|
|
11650
11727
|
}
|
|
11651
11728
|
}
|
|
11652
11729
|
const drawData = {
|
|
@@ -11670,19 +11747,19 @@ function padAutoText(padding, drawData, style, width, height) {
|
|
|
11670
11747
|
if (!width) {
|
|
11671
11748
|
switch (style.textAlign) {
|
|
11672
11749
|
case 'left':
|
|
11673
|
-
offsetText(drawData, 'x', padding[left$
|
|
11750
|
+
offsetText(drawData, 'x', padding[left$3]);
|
|
11674
11751
|
break;
|
|
11675
11752
|
case 'right':
|
|
11676
|
-
offsetText(drawData, 'x', -padding[right$
|
|
11753
|
+
offsetText(drawData, 'x', -padding[right$3]);
|
|
11677
11754
|
}
|
|
11678
11755
|
}
|
|
11679
11756
|
if (!height) {
|
|
11680
11757
|
switch (style.verticalAlign) {
|
|
11681
11758
|
case 'top':
|
|
11682
|
-
offsetText(drawData, 'y', padding[top$
|
|
11759
|
+
offsetText(drawData, 'y', padding[top$2]);
|
|
11683
11760
|
break;
|
|
11684
11761
|
case 'bottom':
|
|
11685
|
-
offsetText(drawData, 'y', -padding[bottom$
|
|
11762
|
+
offsetText(drawData, 'y', -padding[bottom$2]);
|
|
11686
11763
|
}
|
|
11687
11764
|
}
|
|
11688
11765
|
}
|
|
@@ -11733,6 +11810,7 @@ const ExportModule = {
|
|
|
11733
11810
|
export(leaf, filename, options) {
|
|
11734
11811
|
this.running = true;
|
|
11735
11812
|
const fileType = FileHelper.fileType(filename);
|
|
11813
|
+
const isDownload = filename.includes('.');
|
|
11736
11814
|
options = FileHelper.getExportOptions(options);
|
|
11737
11815
|
return addTask((success) => new Promise((resolve) => {
|
|
11738
11816
|
const over = (result) => {
|
|
@@ -11742,19 +11820,13 @@ const ExportModule = {
|
|
|
11742
11820
|
};
|
|
11743
11821
|
const { toURL } = Platform;
|
|
11744
11822
|
const { download } = Platform.origin;
|
|
11745
|
-
if (
|
|
11746
|
-
|
|
11747
|
-
|
|
11748
|
-
else if (fileType === 'json') {
|
|
11749
|
-
download(toURL(JSON.stringify(leaf.toJSON(options.json)), 'text'), filename);
|
|
11750
|
-
return over({ data: true });
|
|
11823
|
+
if (fileType === 'json') {
|
|
11824
|
+
isDownload && download(toURL(JSON.stringify(leaf.toJSON(options.json)), 'text'), filename);
|
|
11825
|
+
return over({ data: isDownload ? true : leaf.toJSON(options.json) });
|
|
11751
11826
|
}
|
|
11752
|
-
if (
|
|
11753
|
-
|
|
11754
|
-
|
|
11755
|
-
else if (fileType === 'svg') {
|
|
11756
|
-
download(toURL(leaf.toSVG(), 'svg'), filename);
|
|
11757
|
-
return over({ data: true });
|
|
11827
|
+
if (fileType === 'svg') {
|
|
11828
|
+
isDownload && download(toURL(leaf.toSVG(), 'svg'), filename);
|
|
11829
|
+
return over({ data: isDownload ? true : leaf.toSVG() });
|
|
11758
11830
|
}
|
|
11759
11831
|
const { leafer } = leaf;
|
|
11760
11832
|
if (leafer) {
|
|
@@ -11763,14 +11835,8 @@ const ExportModule = {
|
|
|
11763
11835
|
let renderBounds, trimBounds, scaleX = 1, scaleY = 1;
|
|
11764
11836
|
const { worldTransform, isLeafer, isFrame } = leaf;
|
|
11765
11837
|
const { slice, trim, onCanvas } = options;
|
|
11766
|
-
let scale = options.scale || 1;
|
|
11767
|
-
let pixelRatio = options.pixelRatio || 1;
|
|
11768
11838
|
const smooth = options.smooth === undefined ? leafer.config.smooth : options.smooth;
|
|
11769
11839
|
const contextSettings = options.contextSettings || leafer.config.contextSettings;
|
|
11770
|
-
if (leaf.isApp) {
|
|
11771
|
-
scale *= pixelRatio;
|
|
11772
|
-
pixelRatio = leaf.app.pixelRatio;
|
|
11773
|
-
}
|
|
11774
11840
|
const screenshot = options.screenshot || leaf.isApp;
|
|
11775
11841
|
const fill = (isLeafer && screenshot) ? (options.fill === undefined ? leaf.fill : options.fill) : options.fill;
|
|
11776
11842
|
const needFill = FileHelper.isOpaqueImage(filename) || fill, matrix = new Matrix();
|
|
@@ -11804,9 +11870,17 @@ const ExportModule = {
|
|
|
11804
11870
|
}
|
|
11805
11871
|
renderBounds = leaf.getBounds('render', relative);
|
|
11806
11872
|
}
|
|
11807
|
-
const {
|
|
11873
|
+
const scaleData = { scaleX: 1, scaleY: 1 };
|
|
11874
|
+
MathHelper.getScaleData(options.scale, options.size, renderBounds, scaleData);
|
|
11875
|
+
let pixelRatio = options.pixelRatio || 1;
|
|
11876
|
+
if (leaf.isApp) {
|
|
11877
|
+
scaleData.scaleX *= pixelRatio;
|
|
11878
|
+
scaleData.scaleY *= pixelRatio;
|
|
11879
|
+
pixelRatio = leaf.app.pixelRatio;
|
|
11880
|
+
}
|
|
11881
|
+
const { x, y, width, height } = new Bounds(renderBounds).scale(scaleData.scaleX, scaleData.scaleY);
|
|
11882
|
+
const renderOptions = { matrix: matrix.scale(1 / scaleData.scaleX, 1 / scaleData.scaleY).invert().translate(-x, -y).withScale(1 / scaleX * scaleData.scaleX, 1 / scaleY * scaleData.scaleY) };
|
|
11808
11883
|
let canvas = Creator.canvas({ width: Math.round(width), height: Math.round(height), pixelRatio, smooth, contextSettings });
|
|
11809
|
-
const renderOptions = { matrix: matrix.scale(1 / scale).invert().translate(-x, -y).withScale(1 / scaleX * scale, 1 / scaleY * scale) };
|
|
11810
11884
|
let sliceLeaf;
|
|
11811
11885
|
if (slice) {
|
|
11812
11886
|
sliceLeaf = leaf;
|
|
@@ -11996,6 +12070,7 @@ const PathScaler = {
|
|
|
11996
12070
|
const { scalePoints } = PathScaler;
|
|
11997
12071
|
|
|
11998
12072
|
const matrix$1 = MatrixHelper.get();
|
|
12073
|
+
const { topLeft: topLeft$1, top: top$1, topRight: topRight$1, right: right$2, bottom: bottom$1, left: left$2 } = Direction9;
|
|
11999
12074
|
function scaleResize(leaf, scaleX, scaleY) {
|
|
12000
12075
|
if (leaf.pathInputed) {
|
|
12001
12076
|
scaleResizePath(leaf, scaleX, scaleY);
|
|
@@ -12008,14 +12083,35 @@ function scaleResize(leaf, scaleX, scaleY) {
|
|
|
12008
12083
|
}
|
|
12009
12084
|
}
|
|
12010
12085
|
function scaleResizeFontSize(leaf, scaleX, scaleY) {
|
|
12011
|
-
const {
|
|
12012
|
-
|
|
12013
|
-
|
|
12014
|
-
|
|
12086
|
+
const { app } = leaf;
|
|
12087
|
+
const editor = app && app.editor;
|
|
12088
|
+
if (editor.editing) {
|
|
12089
|
+
const layout = leaf.__layout;
|
|
12090
|
+
let { width, height } = layout.boxBounds;
|
|
12091
|
+
width *= (scaleY - scaleX) * (leaf.scaleX < 0 ? -1 : 1);
|
|
12092
|
+
height *= (scaleX - scaleY) * (leaf.scaleY < 0 ? -1 : 1);
|
|
12093
|
+
switch (editor.resizeDirection) {
|
|
12094
|
+
case top$1:
|
|
12095
|
+
case bottom$1:
|
|
12096
|
+
leaf.fontSize *= scaleY;
|
|
12097
|
+
layout.affectScaleOrRotation ? leaf.moveInner(-width / 2, 0) : leaf.x -= width / 2;
|
|
12098
|
+
break;
|
|
12099
|
+
case left$2:
|
|
12100
|
+
case right$2:
|
|
12101
|
+
leaf.fontSize *= scaleX;
|
|
12102
|
+
layout.affectScaleOrRotation ? leaf.moveInner(0, -height / 2) : leaf.y -= height / 2;
|
|
12103
|
+
break;
|
|
12104
|
+
case topLeft$1:
|
|
12105
|
+
case topRight$1:
|
|
12106
|
+
leaf.fontSize *= scaleX;
|
|
12107
|
+
layout.affectScaleOrRotation ? leaf.moveInner(0, -height) : leaf.y -= height;
|
|
12108
|
+
break;
|
|
12109
|
+
default:
|
|
12110
|
+
leaf.fontSize *= scaleX;
|
|
12111
|
+
}
|
|
12015
12112
|
}
|
|
12016
|
-
else
|
|
12017
|
-
leaf.fontSize *=
|
|
12018
|
-
leaf.x -= width * (scaleY - scaleX) / 2;
|
|
12113
|
+
else {
|
|
12114
|
+
leaf.fontSize *= scaleX;
|
|
12019
12115
|
}
|
|
12020
12116
|
}
|
|
12021
12117
|
function scaleResizePath(leaf, scaleX, scaleY) {
|
|
@@ -12558,7 +12654,19 @@ const EditDataHelper = {
|
|
|
12558
12654
|
if (lockRatio) {
|
|
12559
12655
|
const unlockSide = lockRatio === 'corner' && direction % 2;
|
|
12560
12656
|
if (!unlockSide) {
|
|
12561
|
-
|
|
12657
|
+
let scale;
|
|
12658
|
+
switch (direction) {
|
|
12659
|
+
case top:
|
|
12660
|
+
case bottom:
|
|
12661
|
+
scale = scaleY;
|
|
12662
|
+
break;
|
|
12663
|
+
case left$1:
|
|
12664
|
+
case right$1:
|
|
12665
|
+
scale = scaleX;
|
|
12666
|
+
break;
|
|
12667
|
+
default:
|
|
12668
|
+
scale = Math.sqrt(Math.abs(scaleX * scaleY));
|
|
12669
|
+
}
|
|
12562
12670
|
scaleX = scaleX < 0 ? -scale : scale;
|
|
12563
12671
|
scaleY = scaleY < 0 ? -scale : scale;
|
|
12564
12672
|
}
|
|
@@ -12912,6 +13020,7 @@ class EditBox extends Group {
|
|
|
12912
13020
|
}
|
|
12913
13021
|
else if (e.current.pointType === 'resize') {
|
|
12914
13022
|
editor.dragStartBounds = Object.assign({}, editor.element.getLayoutBounds('box', 'local'));
|
|
13023
|
+
editor.resizeDirection = e.current.direction;
|
|
12915
13024
|
}
|
|
12916
13025
|
}
|
|
12917
13026
|
onDragEnd(e) {
|
|
@@ -12919,6 +13028,7 @@ class EditBox extends Group {
|
|
|
12919
13028
|
this.moving = false;
|
|
12920
13029
|
if (e.current.name === 'rect')
|
|
12921
13030
|
this.editor.opacity = 1;
|
|
13031
|
+
this.editor.resizeDirection = undefined;
|
|
12922
13032
|
}
|
|
12923
13033
|
onDrag(e) {
|
|
12924
13034
|
const { editor } = this;
|
|
@@ -13263,7 +13373,7 @@ class Editor extends Group {
|
|
|
13263
13373
|
get buttons() { return this.editBox.buttons; }
|
|
13264
13374
|
constructor(userConfig, data) {
|
|
13265
13375
|
super(data);
|
|
13266
|
-
this.config = config;
|
|
13376
|
+
this.config = DataHelper.clone(config);
|
|
13267
13377
|
this.leafList = new LeafList();
|
|
13268
13378
|
this.openedGroupList = new LeafList();
|
|
13269
13379
|
this.simulateTarget = new Rect({ visible: false });
|
|
@@ -14385,26 +14495,42 @@ let TextEditor = class TextEditor extends InnerEditor {
|
|
|
14385
14495
|
onLoad() {
|
|
14386
14496
|
const { editor } = this;
|
|
14387
14497
|
const { config } = editor.app;
|
|
14388
|
-
this._keyEvent = config.keyEvent;
|
|
14389
|
-
config.keyEvent = false;
|
|
14390
14498
|
const text = this.editTarget;
|
|
14391
14499
|
text.visible = false;
|
|
14500
|
+
this.isHTMLText = !(text instanceof Text);
|
|
14501
|
+
this._keyEvent = config.keyEvent;
|
|
14502
|
+
config.keyEvent = false;
|
|
14392
14503
|
const div = this.editDom = document.createElement('div');
|
|
14393
14504
|
const { style } = div;
|
|
14394
14505
|
div.contentEditable = 'true';
|
|
14395
|
-
div.innerText = text.text;
|
|
14396
14506
|
style.position = 'fixed';
|
|
14397
14507
|
style.transformOrigin = 'left top';
|
|
14398
14508
|
style.boxSizing = 'border-box';
|
|
14399
|
-
|
|
14400
|
-
|
|
14401
|
-
|
|
14402
|
-
|
|
14403
|
-
|
|
14404
|
-
|
|
14509
|
+
if (this.isHTMLText) {
|
|
14510
|
+
div.innerHTML = text.text;
|
|
14511
|
+
this.textScale = 1;
|
|
14512
|
+
}
|
|
14513
|
+
else {
|
|
14514
|
+
div.innerText = text.text;
|
|
14515
|
+
const { scaleX, scaleY } = text.worldTransform;
|
|
14516
|
+
this.textScale = Math.max(Math.abs(scaleX), Math.abs(scaleY));
|
|
14517
|
+
const fontSize = text.fontSize * this.textScale;
|
|
14518
|
+
if (fontSize < 12)
|
|
14519
|
+
this.textScale *= 12 / fontSize;
|
|
14520
|
+
}
|
|
14521
|
+
const { view } = editor.app;
|
|
14522
|
+
(this.inBody = view instanceof HTMLCanvasElement) ? document.body.appendChild(div) : view.appendChild(div);
|
|
14405
14523
|
this.eventIds = [
|
|
14406
|
-
editor.app.on_(PointerEvent.DOWN, (e) => {
|
|
14407
|
-
|
|
14524
|
+
editor.app.on_(PointerEvent.DOWN, (e) => {
|
|
14525
|
+
let { target } = e.origin, find;
|
|
14526
|
+
while (target) {
|
|
14527
|
+
if (target === div)
|
|
14528
|
+
find = true;
|
|
14529
|
+
target = target.parentElement;
|
|
14530
|
+
}
|
|
14531
|
+
if (!find)
|
|
14532
|
+
editor.closeInnerEditor();
|
|
14533
|
+
})
|
|
14408
14534
|
];
|
|
14409
14535
|
this.onFocus = this.onFocus.bind(this);
|
|
14410
14536
|
this.onInput = this.onInput.bind(this);
|
|
@@ -14429,7 +14555,8 @@ let TextEditor = class TextEditor extends InnerEditor {
|
|
|
14429
14555
|
selection.addRange(range);
|
|
14430
14556
|
}
|
|
14431
14557
|
onInput() {
|
|
14432
|
-
|
|
14558
|
+
const { editDom } = this;
|
|
14559
|
+
this.editTarget.text = this.isHTMLText ? editDom.innerHTML : editDom.innerText.replace(/\n\n/, '\n');
|
|
14433
14560
|
}
|
|
14434
14561
|
onFocus() {
|
|
14435
14562
|
this.editDom.style.outline = 'none';
|
|
@@ -14441,14 +14568,14 @@ let TextEditor = class TextEditor extends InnerEditor {
|
|
|
14441
14568
|
onUpdate() {
|
|
14442
14569
|
const { editTarget: text, textScale } = this;
|
|
14443
14570
|
const { style } = this.editDom;
|
|
14444
|
-
const { x, y } = text.app.tree.clientBounds;
|
|
14571
|
+
const { x, y } = this.inBody ? text.app.clientBounds : text.app.tree.clientBounds;
|
|
14445
14572
|
const { a, b, c, d, e, f } = new Matrix(text.worldTransform).scale(1 / textScale);
|
|
14446
14573
|
style.transform = `matrix(${a},${b},${c},${d},${e},${f})`;
|
|
14447
14574
|
style.left = x - window.scrollX + 'px';
|
|
14448
14575
|
style.top = y - window.scrollY + 'px';
|
|
14449
14576
|
style.width = text.width * textScale + (text.__.__autoWidth ? 20 : 0) + 'px';
|
|
14450
14577
|
style.height = text.height * textScale + (text.__.__autoHeight ? 20 : 0) + 'px';
|
|
14451
|
-
updateStyle(this.editDom, text, this.textScale);
|
|
14578
|
+
this.isHTMLText || updateStyle(this.editDom, text, this.textScale);
|
|
14452
14579
|
}
|
|
14453
14580
|
onUnload() {
|
|
14454
14581
|
const { editTarget: text, editor, editDom: dom } = this;
|
|
@@ -14479,11 +14606,13 @@ class HTMLTextData extends ImageData {
|
|
|
14479
14606
|
|
|
14480
14607
|
let HTMLText = class HTMLText extends Image {
|
|
14481
14608
|
get __tag() { return 'HTMLText'; }
|
|
14609
|
+
get editInner() { return 'TextEditor'; }
|
|
14482
14610
|
constructor(data) {
|
|
14483
14611
|
super(data);
|
|
14484
14612
|
}
|
|
14485
14613
|
__updateBoxBounds() {
|
|
14486
|
-
|
|
14614
|
+
const data = this.__;
|
|
14615
|
+
if (data.__htmlChanged) {
|
|
14487
14616
|
const div = document.createElement('div');
|
|
14488
14617
|
const { style } = div;
|
|
14489
14618
|
style.all = 'initial';
|
|
@@ -14492,9 +14621,9 @@ let HTMLText = class HTMLText extends Image {
|
|
|
14492
14621
|
div.innerHTML = this.text;
|
|
14493
14622
|
document.body.appendChild(div);
|
|
14494
14623
|
const { width, height } = div.getBoundingClientRect();
|
|
14495
|
-
const
|
|
14496
|
-
const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="${
|
|
14497
|
-
<foreignObject width="${
|
|
14624
|
+
const realWidth = width + 10;
|
|
14625
|
+
const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="${realWidth}" height="${height}">
|
|
14626
|
+
<foreignObject width="${realWidth}" height="${height}">
|
|
14498
14627
|
<style>
|
|
14499
14628
|
* {
|
|
14500
14629
|
margin: 0;
|
|
@@ -14507,8 +14636,10 @@ let HTMLText = class HTMLText extends Image {
|
|
|
14507
14636
|
</body>
|
|
14508
14637
|
</foreignObject>
|
|
14509
14638
|
</svg>`;
|
|
14510
|
-
|
|
14511
|
-
|
|
14639
|
+
data.__setImageFill('data:image/svg+xml,' + encodeURIComponent(svg));
|
|
14640
|
+
data.__naturalWidth = realWidth / data.pixelRatio;
|
|
14641
|
+
data.__naturalHeight = height / data.pixelRatio;
|
|
14642
|
+
data.__htmlChanged = false;
|
|
14512
14643
|
div.remove();
|
|
14513
14644
|
}
|
|
14514
14645
|
super.__updateBoxBounds();
|
|
@@ -14524,4 +14655,4 @@ HTMLText = __decorate([
|
|
|
14524
14655
|
registerUI()
|
|
14525
14656
|
], HTMLText);
|
|
14526
14657
|
|
|
14527
|
-
export { AlignHelper, AnimateEvent, 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, DropEvent, EditBox, EditDataHelper, EditPoint, EditSelect, EditSelectHelper, EditTool, EditToolCreator, Editor, EditorEvent, EditorGroupEvent, EditorHelper, EditorMoveEvent, EditorRotateEvent, EditorScaleEvent, EditorSkewEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, 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, 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, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, ZoomEvent, addInteractionWindow, 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, inviteCode, layoutProcessor, maskType, naturalBoundsType, opacityType, pathInputType, pathType, pen, positionType, registerEditTool, registerInnerEditor, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleResize, scaleResizeFontSize, scaleResizeGroup, scaleResizePath, scaleResizePoints, scaleType, sortType, stateType, strokeType, surfaceType, tempBounds$1 as tempBounds, tempMatrix, tempPoint$3 as tempPoint, useCanvas, useModule, version, visibleType, zoomLayerType };
|
|
14658
|
+
export { AlignHelper, AnimateEvent, 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, DropEvent, EditBox, EditDataHelper, EditPoint, EditSelect, EditSelectHelper, EditTool, EditToolCreator, Editor, EditorEvent, EditorGroupEvent, EditorHelper, EditorMoveEvent, EditorRotateEvent, EditorScaleEvent, EditorSkewEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, 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, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, ZoomEvent, addInteractionWindow, 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, inviteCode, layoutProcessor, maskType, naturalBoundsType, opacityType, pathInputType, pathType, pen, positionType, registerEditTool, registerInnerEditor, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleResize, scaleResizeFontSize, scaleResizeGroup, scaleResizePath, scaleResizePoints, scaleType, sortType, stateType, strokeType, surfaceType, tempBounds$1 as tempBounds, tempMatrix, tempPoint$3 as tempPoint, useCanvas, useModule, version, visibleType, zoomLayerType };
|