@leafer/worker 1.6.7 → 1.8.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 +957 -632
- package/dist/worker.min.js +1 -1
- package/dist/worker.min.js.map +1 -1
- package/dist/worker.module.js +950 -627
- package/dist/worker.module.min.js +1 -1
- package/dist/worker.module.min.js.map +1 -1
- package/package.json +22 -22
package/dist/worker.js
CHANGED
|
@@ -46,7 +46,7 @@ var LeaferUI = (function (exports) {
|
|
|
46
46
|
};
|
|
47
47
|
const I$2 = IncrementId;
|
|
48
48
|
|
|
49
|
-
const { round: round$6, pow: pow$2, PI: PI$
|
|
49
|
+
const { round: round$6, pow: pow$2, PI: PI$4 } = Math;
|
|
50
50
|
const MathHelper = {
|
|
51
51
|
within(value, min, max) {
|
|
52
52
|
if (typeof min === 'object')
|
|
@@ -142,9 +142,9 @@ var LeaferUI = (function (exports) {
|
|
|
142
142
|
function randInt(num) {
|
|
143
143
|
return Math.round(Math.random() * num);
|
|
144
144
|
}
|
|
145
|
-
const OneRadian = PI$
|
|
146
|
-
const PI2 = PI$
|
|
147
|
-
const PI_2 = PI$
|
|
145
|
+
const OneRadian = PI$4 / 180;
|
|
146
|
+
const PI2 = PI$4 * 2;
|
|
147
|
+
const PI_2 = PI$4 / 2;
|
|
148
148
|
function getPointData() { return { x: 0, y: 0 }; }
|
|
149
149
|
function getBoundsData() { return { x: 0, y: 0, width: 0, height: 0 }; }
|
|
150
150
|
function getMatrixData() { return { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0 }; }
|
|
@@ -439,7 +439,7 @@ var LeaferUI = (function (exports) {
|
|
|
439
439
|
const M$a = MatrixHelper;
|
|
440
440
|
|
|
441
441
|
const { toInnerPoint: toInnerPoint$2, toOuterPoint: toOuterPoint$3 } = MatrixHelper;
|
|
442
|
-
const { sin: sin$5, cos: cos$5, abs: abs$
|
|
442
|
+
const { sin: sin$5, cos: cos$5, abs: abs$6, sqrt: sqrt$4, atan2: atan2$2, min: min$1, round: round$5 } = Math;
|
|
443
443
|
const PointHelper = {
|
|
444
444
|
defaultPoint: getPointData(),
|
|
445
445
|
tempPoint: {},
|
|
@@ -534,8 +534,8 @@ var LeaferUI = (function (exports) {
|
|
|
534
534
|
return getDistanceFrom(t.x, t.y, point.x, point.y);
|
|
535
535
|
},
|
|
536
536
|
getDistanceFrom(x1, y1, x2, y2) {
|
|
537
|
-
const x = abs$
|
|
538
|
-
const y = abs$
|
|
537
|
+
const x = abs$6(x2 - x1);
|
|
538
|
+
const y = abs$6(y2 - y1);
|
|
539
539
|
return sqrt$4(x * x + y * y);
|
|
540
540
|
},
|
|
541
541
|
getMinDistanceFrom(x1, y1, x2, y2, x3, y3) {
|
|
@@ -552,10 +552,11 @@ var LeaferUI = (function (exports) {
|
|
|
552
552
|
getRadianFrom(fromX, fromY, originX, originY, toX, toY, toOriginX, toOriginY) {
|
|
553
553
|
if (toOriginX === undefined)
|
|
554
554
|
toOriginX = originX, toOriginY = originY;
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
const
|
|
558
|
-
|
|
555
|
+
const a = fromX - originX;
|
|
556
|
+
const b = fromY - originY;
|
|
557
|
+
const c = toX - toOriginX;
|
|
558
|
+
const d = toY - toOriginY;
|
|
559
|
+
return Math.atan2(a * d - b * c, a * c + b * d);
|
|
559
560
|
},
|
|
560
561
|
getAtan2(t, to) {
|
|
561
562
|
return atan2$2(to.y - t.y, to.x - t.x);
|
|
@@ -765,7 +766,7 @@ var LeaferUI = (function (exports) {
|
|
|
765
766
|
MatrixHelper.reset(this);
|
|
766
767
|
}
|
|
767
768
|
}
|
|
768
|
-
const tempMatrix = new Matrix();
|
|
769
|
+
const tempMatrix$1 = new Matrix();
|
|
769
770
|
|
|
770
771
|
const TwoPointBoundsHelper = {
|
|
771
772
|
tempPointBounds: {},
|
|
@@ -862,6 +863,12 @@ var LeaferUI = (function (exports) {
|
|
|
862
863
|
}
|
|
863
864
|
if (!onlyBoxSize)
|
|
864
865
|
to.x += box.x, to.y += box.y;
|
|
866
|
+
},
|
|
867
|
+
getPoint(around, box, to) {
|
|
868
|
+
if (!to)
|
|
869
|
+
to = {};
|
|
870
|
+
AroundHelper.toPoint(around, box, to, true);
|
|
871
|
+
return to;
|
|
865
872
|
}
|
|
866
873
|
};
|
|
867
874
|
function get$4(around) {
|
|
@@ -1790,10 +1797,13 @@ var LeaferUI = (function (exports) {
|
|
|
1790
1797
|
return (target, key) => {
|
|
1791
1798
|
if (!realName)
|
|
1792
1799
|
realName = key;
|
|
1793
|
-
|
|
1800
|
+
const property = {
|
|
1794
1801
|
get() { return this.context[realName]; },
|
|
1795
1802
|
set(value) { this.context[realName] = value; }
|
|
1796
|
-
}
|
|
1803
|
+
};
|
|
1804
|
+
if (key === 'strokeCap')
|
|
1805
|
+
property.set = function (value) { this.context[realName] = value === 'none' ? 'butt' : value; };
|
|
1806
|
+
Object.defineProperty(target, key, property);
|
|
1797
1807
|
};
|
|
1798
1808
|
}
|
|
1799
1809
|
const contextMethodNameList = [];
|
|
@@ -2069,15 +2079,15 @@ var LeaferUI = (function (exports) {
|
|
|
2069
2079
|
contextMethod()
|
|
2070
2080
|
], Canvas.prototype, "strokeText", null);
|
|
2071
2081
|
|
|
2072
|
-
const { copy: copy$c, multiplyParent: multiplyParent$
|
|
2082
|
+
const { copy: copy$c, multiplyParent: multiplyParent$4 } = MatrixHelper, { round: round$4 } = Math;
|
|
2073
2083
|
const minSize = { width: 1, height: 1, pixelRatio: 1 };
|
|
2074
2084
|
const canvasSizeAttrs = ['width', 'height', 'pixelRatio'];
|
|
2075
2085
|
class LeaferCanvasBase extends Canvas {
|
|
2076
2086
|
get width() { return this.size.width; }
|
|
2077
2087
|
get height() { return this.size.height; }
|
|
2078
2088
|
get pixelRatio() { return this.size.pixelRatio; }
|
|
2079
|
-
get pixelWidth() { return this.width * this.pixelRatio; }
|
|
2080
|
-
get pixelHeight() { return this.height * this.pixelRatio; }
|
|
2089
|
+
get pixelWidth() { return this.width * this.pixelRatio || 0; }
|
|
2090
|
+
get pixelHeight() { return this.height * this.pixelRatio || 0; }
|
|
2081
2091
|
get pixelSnap() { return this.config.pixelSnap; }
|
|
2082
2092
|
set pixelSnap(value) { this.config.pixelSnap = value; }
|
|
2083
2093
|
get allowBackgroundColor() { return this.view && this.parentView; }
|
|
@@ -2142,7 +2152,7 @@ var LeaferUI = (function (exports) {
|
|
|
2142
2152
|
setWorld(matrix, parentMatrix) {
|
|
2143
2153
|
const { pixelRatio, pixelSnap } = this, w = this.worldTransform;
|
|
2144
2154
|
if (parentMatrix)
|
|
2145
|
-
multiplyParent$
|
|
2155
|
+
multiplyParent$4(matrix, parentMatrix, w);
|
|
2146
2156
|
w.a = matrix.a * pixelRatio;
|
|
2147
2157
|
w.b = matrix.b * pixelRatio;
|
|
2148
2158
|
w.c = matrix.c * pixelRatio;
|
|
@@ -2164,20 +2174,33 @@ var LeaferUI = (function (exports) {
|
|
|
2164
2174
|
if (w)
|
|
2165
2175
|
this.setTransform(w.a, w.b, w.c, w.d, w.e, w.f);
|
|
2166
2176
|
}
|
|
2167
|
-
setStroke(color, strokeWidth, options) {
|
|
2177
|
+
setStroke(color, strokeWidth, options, childOptions) {
|
|
2168
2178
|
if (strokeWidth)
|
|
2169
2179
|
this.strokeWidth = strokeWidth;
|
|
2170
2180
|
if (color)
|
|
2171
2181
|
this.strokeStyle = color;
|
|
2172
2182
|
if (options)
|
|
2173
|
-
this.setStrokeOptions(options);
|
|
2174
|
-
}
|
|
2175
|
-
setStrokeOptions(options) {
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2183
|
+
this.setStrokeOptions(options, childOptions);
|
|
2184
|
+
}
|
|
2185
|
+
setStrokeOptions(options, childOptions) {
|
|
2186
|
+
let { strokeCap, strokeJoin, dashPattern, dashOffset, miterLimit } = options;
|
|
2187
|
+
if (childOptions) {
|
|
2188
|
+
if (childOptions.strokeCap)
|
|
2189
|
+
strokeCap = childOptions.strokeCap;
|
|
2190
|
+
if (childOptions.strokeJoin)
|
|
2191
|
+
strokeJoin = childOptions.strokeJoin;
|
|
2192
|
+
if (childOptions.dashPattern !== undefined)
|
|
2193
|
+
dashPattern = childOptions.dashPattern;
|
|
2194
|
+
if (childOptions.dashOffset !== undefined)
|
|
2195
|
+
dashOffset = childOptions.dashOffset;
|
|
2196
|
+
if (childOptions.miterLimit)
|
|
2197
|
+
miterLimit = childOptions.miterLimit;
|
|
2198
|
+
}
|
|
2199
|
+
this.strokeCap = strokeCap;
|
|
2200
|
+
this.strokeJoin = strokeJoin;
|
|
2201
|
+
this.dashPattern = dashPattern;
|
|
2202
|
+
this.dashOffset = dashOffset;
|
|
2203
|
+
this.miterLimit = miterLimit;
|
|
2181
2204
|
}
|
|
2182
2205
|
saveBlendMode(blendMode) {
|
|
2183
2206
|
this.savedBlendMode = this.blendMode;
|
|
@@ -2411,7 +2434,7 @@ var LeaferUI = (function (exports) {
|
|
|
2411
2434
|
}
|
|
2412
2435
|
};
|
|
2413
2436
|
|
|
2414
|
-
const { sin: sin$4, cos: cos$4, atan2: atan2$1, ceil: ceil$2, abs: abs$
|
|
2437
|
+
const { sin: sin$4, cos: cos$4, atan2: atan2$1, ceil: ceil$2, abs: abs$5, PI: PI$3, sqrt: sqrt$3, pow: pow$1 } = Math;
|
|
2415
2438
|
const { setPoint: setPoint$4, addPoint: addPoint$2 } = TwoPointBoundsHelper;
|
|
2416
2439
|
const { set, toNumberPoints: toNumberPoints$1 } = PointHelper;
|
|
2417
2440
|
const { M: M$9, L: L$a, C: C$8, Q: Q$7, Z: Z$8 } = PathCommandMap;
|
|
@@ -2486,7 +2509,7 @@ var LeaferUI = (function (exports) {
|
|
|
2486
2509
|
let totalRadian = endRadian - startRadian;
|
|
2487
2510
|
if (totalRadian < 0)
|
|
2488
2511
|
totalRadian += PI2;
|
|
2489
|
-
if (totalRadian === PI$3 || (abs$
|
|
2512
|
+
if (totalRadian === PI$3 || (abs$5(BAx + BAy) < 1.e-12) || (abs$5(CBx + CBy) < 1.e-12)) {
|
|
2490
2513
|
if (data)
|
|
2491
2514
|
data.push(L$a, x1, y1);
|
|
2492
2515
|
if (setPointBounds) {
|
|
@@ -2528,7 +2551,7 @@ var LeaferUI = (function (exports) {
|
|
|
2528
2551
|
totalRadian -= PI2;
|
|
2529
2552
|
if (anticlockwise)
|
|
2530
2553
|
totalRadian -= PI2;
|
|
2531
|
-
const parts = ceil$2(abs$
|
|
2554
|
+
const parts = ceil$2(abs$5(totalRadian / PI_2));
|
|
2532
2555
|
const partRadian = totalRadian / parts;
|
|
2533
2556
|
const partRadian4Sin = sin$4(partRadian / 4);
|
|
2534
2557
|
const control = 8 / 3 * partRadian4Sin * partRadian4Sin / sin$4(partRadian / 2);
|
|
@@ -2973,7 +2996,7 @@ var LeaferUI = (function (exports) {
|
|
|
2973
2996
|
|
|
2974
2997
|
const { M: M$7, L: L$8, C: C$6, Q: Q$5, Z: Z$6, N: N$4, D: D$4, X: X$4, G: G$4, F: F$5, O: O$5, P: P$4, U: U$4 } = PathCommandMap;
|
|
2975
2998
|
const { getMinDistanceFrom, getRadianFrom } = PointHelper;
|
|
2976
|
-
const { tan, min, abs: abs$
|
|
2999
|
+
const { tan, min, abs: abs$4 } = Math;
|
|
2977
3000
|
const startPoint = {};
|
|
2978
3001
|
const PathCommandDataHelper = {
|
|
2979
3002
|
beginPath(data) {
|
|
@@ -3036,7 +3059,7 @@ var LeaferUI = (function (exports) {
|
|
|
3036
3059
|
arcTo(data, x1, y1, x2, y2, radius, lastX, lastY) {
|
|
3037
3060
|
if (lastX !== undefined) {
|
|
3038
3061
|
const d = getMinDistanceFrom(lastX, lastY, x1, y1, x2, y2);
|
|
3039
|
-
radius = min(radius, min(d / 2, d / 2 * abs$
|
|
3062
|
+
radius = min(radius, min(d / 2, d / 2 * abs$4(tan(getRadianFrom(lastX, lastY, x1, y1, x2, y2) / 2))));
|
|
3040
3063
|
}
|
|
3041
3064
|
data.push(U$4, x1, y1, x2, y2, radius);
|
|
3042
3065
|
},
|
|
@@ -3342,7 +3365,7 @@ var LeaferUI = (function (exports) {
|
|
|
3342
3365
|
const { arcTo } = PathCommandDataHelper;
|
|
3343
3366
|
const PathCorner = {
|
|
3344
3367
|
smooth(data, cornerRadius, _cornerSmoothing) {
|
|
3345
|
-
let command, commandLen;
|
|
3368
|
+
let command, lastCommand, commandLen;
|
|
3346
3369
|
let i = 0, x = 0, y = 0, startX = 0, startY = 0, secondX = 0, secondY = 0, lastX = 0, lastY = 0;
|
|
3347
3370
|
const len = data.length;
|
|
3348
3371
|
const smooth = [];
|
|
@@ -3380,8 +3403,10 @@ var LeaferUI = (function (exports) {
|
|
|
3380
3403
|
lastY = y;
|
|
3381
3404
|
break;
|
|
3382
3405
|
case Z$3:
|
|
3383
|
-
|
|
3384
|
-
|
|
3406
|
+
if (lastCommand !== Z$3) {
|
|
3407
|
+
arcTo(smooth, startX, startY, secondX, secondY, cornerRadius, lastX, lastY);
|
|
3408
|
+
smooth.push(Z$3);
|
|
3409
|
+
}
|
|
3385
3410
|
i += 1;
|
|
3386
3411
|
break;
|
|
3387
3412
|
default:
|
|
@@ -3390,6 +3415,7 @@ var LeaferUI = (function (exports) {
|
|
|
3390
3415
|
smooth.push(data[i + j]);
|
|
3391
3416
|
i += commandLen;
|
|
3392
3417
|
}
|
|
3418
|
+
lastCommand = command;
|
|
3393
3419
|
}
|
|
3394
3420
|
if (command !== Z$3) {
|
|
3395
3421
|
smooth[1] = startX;
|
|
@@ -3886,12 +3912,12 @@ var LeaferUI = (function (exports) {
|
|
|
3886
3912
|
try {
|
|
3887
3913
|
if (transform && pattern.setTransform) {
|
|
3888
3914
|
pattern.setTransform(transform);
|
|
3889
|
-
transform =
|
|
3915
|
+
transform = undefined;
|
|
3890
3916
|
}
|
|
3891
3917
|
}
|
|
3892
3918
|
catch (_a) { }
|
|
3893
3919
|
if (paint)
|
|
3894
|
-
paint
|
|
3920
|
+
DataHelper.stintSet(paint, 'transform', transform);
|
|
3895
3921
|
return pattern;
|
|
3896
3922
|
}
|
|
3897
3923
|
destroy() {
|
|
@@ -3909,6 +3935,13 @@ var LeaferUI = (function (exports) {
|
|
|
3909
3935
|
function getDescriptor(object, name) {
|
|
3910
3936
|
return Object.getOwnPropertyDescriptor(object, name);
|
|
3911
3937
|
}
|
|
3938
|
+
function createDescriptor(key, defaultValue) {
|
|
3939
|
+
const privateKey = '_' + key;
|
|
3940
|
+
return {
|
|
3941
|
+
get() { const v = this[privateKey]; return v === undefined ? defaultValue : v; },
|
|
3942
|
+
set(value) { this[privateKey] = value; }
|
|
3943
|
+
};
|
|
3944
|
+
}
|
|
3912
3945
|
function getNames(object) {
|
|
3913
3946
|
return Object.getOwnPropertyNames(object);
|
|
3914
3947
|
}
|
|
@@ -3996,10 +4029,14 @@ var LeaferUI = (function (exports) {
|
|
|
3996
4029
|
}));
|
|
3997
4030
|
}
|
|
3998
4031
|
const pathType = boundsType;
|
|
3999
|
-
function affectStrokeBoundsType(defaultValue) {
|
|
4032
|
+
function affectStrokeBoundsType(defaultValue, useStroke) {
|
|
4000
4033
|
return decorateLeafAttr(defaultValue, (key) => attr({
|
|
4001
4034
|
set(value) {
|
|
4002
|
-
this.__setAttr(key, value)
|
|
4035
|
+
if (this.__setAttr(key, value)) {
|
|
4036
|
+
doStrokeType(this);
|
|
4037
|
+
if (useStroke)
|
|
4038
|
+
this.__.__useStroke = true;
|
|
4039
|
+
}
|
|
4003
4040
|
}
|
|
4004
4041
|
}));
|
|
4005
4042
|
}
|
|
@@ -4137,15 +4174,7 @@ var LeaferUI = (function (exports) {
|
|
|
4137
4174
|
const data = target.__DataProcessor.prototype;
|
|
4138
4175
|
const computedKey = '_' + key;
|
|
4139
4176
|
const setMethodName = getSetMethodName(key);
|
|
4140
|
-
const property =
|
|
4141
|
-
get() {
|
|
4142
|
-
const v = this[computedKey];
|
|
4143
|
-
return v === undefined ? defaultValue : v;
|
|
4144
|
-
},
|
|
4145
|
-
set(value) {
|
|
4146
|
-
this[computedKey] = value;
|
|
4147
|
-
}
|
|
4148
|
-
};
|
|
4177
|
+
const property = createDescriptor(key, defaultValue);
|
|
4149
4178
|
if (defaultValue === undefined) {
|
|
4150
4179
|
property.get = function () { return this[computedKey]; };
|
|
4151
4180
|
}
|
|
@@ -4260,7 +4289,7 @@ var LeaferUI = (function (exports) {
|
|
|
4260
4289
|
};
|
|
4261
4290
|
}
|
|
4262
4291
|
|
|
4263
|
-
const { copy: copy$a, toInnerPoint: toInnerPoint$1, toOuterPoint: toOuterPoint$1, scaleOfOuter: scaleOfOuter$2, rotateOfOuter: rotateOfOuter$2, skewOfOuter, multiplyParent: multiplyParent$
|
|
4292
|
+
const { copy: copy$a, toInnerPoint: toInnerPoint$1, toOuterPoint: toOuterPoint$1, scaleOfOuter: scaleOfOuter$2, rotateOfOuter: rotateOfOuter$2, skewOfOuter, multiplyParent: multiplyParent$3, divideParent, getLayout } = MatrixHelper;
|
|
4264
4293
|
const matrix$3 = {}, { round: round$3 } = Math;
|
|
4265
4294
|
const LeafHelper = {
|
|
4266
4295
|
updateAllMatrix(leaf, checkAutoLayout, waitAutoLayout) {
|
|
@@ -4332,6 +4361,14 @@ var LeaferUI = (function (exports) {
|
|
|
4332
4361
|
}
|
|
4333
4362
|
return true;
|
|
4334
4363
|
},
|
|
4364
|
+
copyCanvasByWorld(leaf, currentCanvas, fromCanvas, fromWorld, blendMode, onlyResetTransform) {
|
|
4365
|
+
if (!fromWorld)
|
|
4366
|
+
fromWorld = leaf.__nowWorld;
|
|
4367
|
+
if (leaf.__worldFlipped || Platform.fullImageShadow)
|
|
4368
|
+
currentCanvas.copyWorldByReset(fromCanvas, fromWorld, leaf.__nowWorld, blendMode, onlyResetTransform);
|
|
4369
|
+
else
|
|
4370
|
+
currentCanvas.copyWorldToInner(fromCanvas, fromWorld, leaf.__layout.renderBounds, blendMode);
|
|
4371
|
+
},
|
|
4335
4372
|
moveWorld(t, x, y = 0, isInnerPoint, transition) {
|
|
4336
4373
|
const local = typeof x === 'object' ? Object.assign({}, x) : { x, y };
|
|
4337
4374
|
isInnerPoint ? toOuterPoint$1(t.localTransform, local, local, true) : (t.parent && toInnerPoint$1(t.parent.worldTransform, local, local, true));
|
|
@@ -4391,14 +4428,14 @@ var LeaferUI = (function (exports) {
|
|
|
4391
4428
|
},
|
|
4392
4429
|
transformWorld(t, transform, resize, transition) {
|
|
4393
4430
|
copy$a(matrix$3, t.worldTransform);
|
|
4394
|
-
multiplyParent$
|
|
4431
|
+
multiplyParent$3(matrix$3, transform);
|
|
4395
4432
|
if (t.parent)
|
|
4396
4433
|
divideParent(matrix$3, t.parent.worldTransform);
|
|
4397
4434
|
L$4.setTransform(t, matrix$3, resize, transition);
|
|
4398
4435
|
},
|
|
4399
4436
|
transform(t, transform, resize, transition) {
|
|
4400
4437
|
copy$a(matrix$3, t.localTransform);
|
|
4401
|
-
multiplyParent$
|
|
4438
|
+
multiplyParent$3(matrix$3, transform);
|
|
4402
4439
|
L$4.setTransform(t, matrix$3, resize, transition);
|
|
4403
4440
|
},
|
|
4404
4441
|
setTransform(t, transform, resize, transition) {
|
|
@@ -5260,17 +5297,18 @@ var LeaferUI = (function (exports) {
|
|
|
5260
5297
|
}
|
|
5261
5298
|
};
|
|
5262
5299
|
|
|
5263
|
-
const { setLayout, multiplyParent: multiplyParent$
|
|
5300
|
+
const { setLayout, multiplyParent: multiplyParent$2, translateInner, defaultWorld } = MatrixHelper;
|
|
5264
5301
|
const { toPoint: toPoint$4, tempPoint: tempPoint$1 } = AroundHelper;
|
|
5265
5302
|
const LeafMatrix = {
|
|
5266
5303
|
__updateWorldMatrix() {
|
|
5267
|
-
|
|
5304
|
+
const { parent, __layout } = this;
|
|
5305
|
+
multiplyParent$2(this.__local || __layout, parent ? parent.__world : defaultWorld, this.__world, !!__layout.affectScaleOrRotation, this.__, parent && (parent.scrollY || parent.scrollX) && parent.__);
|
|
5268
5306
|
},
|
|
5269
5307
|
__updateLocalMatrix() {
|
|
5270
5308
|
if (this.__local) {
|
|
5271
5309
|
const layout = this.__layout, local = this.__local, data = this.__;
|
|
5272
5310
|
if (layout.affectScaleOrRotation) {
|
|
5273
|
-
if ((layout.scaleChanged && (layout.resized = 'scale')) || layout.rotationChanged) {
|
|
5311
|
+
if ((layout.scaleChanged && (layout.resized || (layout.resized = 'scale'))) || layout.rotationChanged) {
|
|
5274
5312
|
setLayout(local, data, null, null, layout.affectRotation);
|
|
5275
5313
|
layout.scaleChanged = layout.rotationChanged = undefined;
|
|
5276
5314
|
}
|
|
@@ -5425,6 +5463,8 @@ var LeaferUI = (function (exports) {
|
|
|
5425
5463
|
|
|
5426
5464
|
const LeafRender = {
|
|
5427
5465
|
__render(canvas, options) {
|
|
5466
|
+
if (options.shape)
|
|
5467
|
+
return this.__renderShape(canvas, options);
|
|
5428
5468
|
if (this.__worldOpacity) {
|
|
5429
5469
|
const data = this.__;
|
|
5430
5470
|
canvas.setWorld(this.__nowWorld = this.__getNowWorld(options));
|
|
@@ -5434,12 +5474,7 @@ var LeaferUI = (function (exports) {
|
|
|
5434
5474
|
return this.__renderEraser(canvas, options);
|
|
5435
5475
|
const tempCanvas = canvas.getSameCanvas(true, true);
|
|
5436
5476
|
this.__draw(tempCanvas, options, canvas);
|
|
5437
|
-
|
|
5438
|
-
canvas.copyWorldByReset(tempCanvas, this.__nowWorld, null, data.__blendMode, true);
|
|
5439
|
-
}
|
|
5440
|
-
else {
|
|
5441
|
-
canvas.copyWorldToInner(tempCanvas, this.__nowWorld, this.__layout.renderBounds, data.__blendMode);
|
|
5442
|
-
}
|
|
5477
|
+
LeafHelper.copyCanvasByWorld(this, canvas, tempCanvas, this.__nowWorld, data.__blendMode, true);
|
|
5443
5478
|
tempCanvas.recycle(this.__nowWorld);
|
|
5444
5479
|
}
|
|
5445
5480
|
else {
|
|
@@ -5449,6 +5484,12 @@ var LeaferUI = (function (exports) {
|
|
|
5449
5484
|
Debug.drawBounds(this, canvas, options);
|
|
5450
5485
|
}
|
|
5451
5486
|
},
|
|
5487
|
+
__renderShape(canvas, options) {
|
|
5488
|
+
if (this.__worldOpacity) {
|
|
5489
|
+
canvas.setWorld(this.__nowWorld = this.__getNowWorld(options));
|
|
5490
|
+
this.__drawShape(canvas, options);
|
|
5491
|
+
}
|
|
5492
|
+
},
|
|
5452
5493
|
__clip(canvas, options) {
|
|
5453
5494
|
if (this.__worldOpacity) {
|
|
5454
5495
|
canvas.setWorld(this.__nowWorld = this.__getNowWorld(options));
|
|
@@ -5481,7 +5522,7 @@ var LeaferUI = (function (exports) {
|
|
|
5481
5522
|
options.dimOpacity = data.dim === true ? 0.2 : data.dim;
|
|
5482
5523
|
else if (data.dimskip)
|
|
5483
5524
|
options.dimOpacity && (options.dimOpacity = 0);
|
|
5484
|
-
if (data.__single) {
|
|
5525
|
+
if (data.__single && !this.isBranchLeaf) {
|
|
5485
5526
|
if (data.eraser === 'path')
|
|
5486
5527
|
return this.__renderEraser(canvas, options);
|
|
5487
5528
|
const tempCanvas = canvas.getSameCanvas(false, true);
|
|
@@ -5503,9 +5544,7 @@ var LeaferUI = (function (exports) {
|
|
|
5503
5544
|
else {
|
|
5504
5545
|
const { children } = this;
|
|
5505
5546
|
for (let i = 0, len = children.length; i < len; i++) {
|
|
5506
|
-
|
|
5507
|
-
continue;
|
|
5508
|
-
children[i].__render(canvas, options);
|
|
5547
|
+
excludeRenderBounds$1(children[i], options) || children[i].__render(canvas, options);
|
|
5509
5548
|
}
|
|
5510
5549
|
}
|
|
5511
5550
|
},
|
|
@@ -5513,16 +5552,15 @@ var LeaferUI = (function (exports) {
|
|
|
5513
5552
|
if (this.__worldOpacity) {
|
|
5514
5553
|
const { children } = this;
|
|
5515
5554
|
for (let i = 0, len = children.length; i < len; i++) {
|
|
5516
|
-
|
|
5517
|
-
continue;
|
|
5518
|
-
children[i].__clip(canvas, options);
|
|
5555
|
+
excludeRenderBounds$1(children[i], options) || children[i].__clip(canvas, options);
|
|
5519
5556
|
}
|
|
5520
5557
|
}
|
|
5521
5558
|
}
|
|
5522
5559
|
};
|
|
5523
5560
|
|
|
5561
|
+
const tempScaleData$1 = {};
|
|
5524
5562
|
const { LEAF, create } = IncrementId;
|
|
5525
|
-
const { toInnerPoint, toOuterPoint, multiplyParent } = MatrixHelper;
|
|
5563
|
+
const { toInnerPoint, toOuterPoint, multiplyParent: multiplyParent$1 } = MatrixHelper;
|
|
5526
5564
|
const { toOuterOf } = BoundsHelper;
|
|
5527
5565
|
const { copy: copy$7, move: move$5 } = PointHelper;
|
|
5528
5566
|
const { moveLocal, zoomOfLocal, rotateOfLocal, skewOfLocal, moveWorld, zoomOfWorld, rotateOfWorld, skewOfWorld, transform, transformWorld, setTransform, getFlipTransform, getLocalOrigin, getRelativeWorld, drop } = LeafHelper;
|
|
@@ -5704,7 +5742,7 @@ var LeaferUI = (function (exports) {
|
|
|
5704
5742
|
if (!this.__cameraWorld)
|
|
5705
5743
|
this.__cameraWorld = {};
|
|
5706
5744
|
const cameraWorld = this.__cameraWorld, world = this.__world;
|
|
5707
|
-
multiplyParent(world, options.matrix, cameraWorld, undefined, world);
|
|
5745
|
+
multiplyParent$1(world, options.matrix, cameraWorld, undefined, world);
|
|
5708
5746
|
toOuterOf(this.__layout.renderBounds, cameraWorld, cameraWorld);
|
|
5709
5747
|
cameraWorld.half !== world.half && (cameraWorld.half = world.half);
|
|
5710
5748
|
return cameraWorld;
|
|
@@ -5713,6 +5751,22 @@ var LeaferUI = (function (exports) {
|
|
|
5713
5751
|
return this.__world;
|
|
5714
5752
|
}
|
|
5715
5753
|
}
|
|
5754
|
+
getClampRenderScale() {
|
|
5755
|
+
let { scaleX } = this.__nowWorld || this.__world;
|
|
5756
|
+
if (scaleX < 0)
|
|
5757
|
+
scaleX = -scaleX;
|
|
5758
|
+
return scaleX > 1 ? scaleX : 1;
|
|
5759
|
+
}
|
|
5760
|
+
getRenderScaleData(abs, scaleFixed) {
|
|
5761
|
+
const { scaleX, scaleY } = ImageManager.patternLocked ? this.__world : this.__nowWorld;
|
|
5762
|
+
if (scaleFixed)
|
|
5763
|
+
tempScaleData$1.scaleX = tempScaleData$1.scaleY = 1;
|
|
5764
|
+
else if (abs)
|
|
5765
|
+
tempScaleData$1.scaleX = scaleX < 0 ? -scaleX : scaleX, tempScaleData$1.scaleY = scaleY < 0 ? -scaleY : scaleY;
|
|
5766
|
+
else
|
|
5767
|
+
tempScaleData$1.scaleX = scaleX, tempScaleData$1.scaleY = scaleY;
|
|
5768
|
+
return tempScaleData$1;
|
|
5769
|
+
}
|
|
5716
5770
|
getTransform(relative) {
|
|
5717
5771
|
return this.__layout.getTransform(relative || 'local');
|
|
5718
5772
|
}
|
|
@@ -5868,7 +5922,8 @@ var LeaferUI = (function (exports) {
|
|
|
5868
5922
|
__drawFast(_canvas, _options) { }
|
|
5869
5923
|
__draw(_canvas, _options, _originCanvas) { }
|
|
5870
5924
|
__clip(_canvas, _options) { }
|
|
5871
|
-
__renderShape(_canvas, _options
|
|
5925
|
+
__renderShape(_canvas, _options) { }
|
|
5926
|
+
__drawShape(_canvas, _options) { }
|
|
5872
5927
|
__updateWorldOpacity() { }
|
|
5873
5928
|
__updateChange() { }
|
|
5874
5929
|
__drawPath(_canvas) { }
|
|
@@ -6236,7 +6291,7 @@ var LeaferUI = (function (exports) {
|
|
|
6236
6291
|
}
|
|
6237
6292
|
}
|
|
6238
6293
|
|
|
6239
|
-
const version = "1.
|
|
6294
|
+
const version = "1.8.0";
|
|
6240
6295
|
|
|
6241
6296
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
6242
6297
|
get allowBackgroundColor() { return true; }
|
|
@@ -7084,6 +7139,11 @@ var LeaferUI = (function (exports) {
|
|
|
7084
7139
|
});
|
|
7085
7140
|
};
|
|
7086
7141
|
}
|
|
7142
|
+
function createAttr(defaultValue) {
|
|
7143
|
+
return (target, key) => {
|
|
7144
|
+
defineKey(target, key, createDescriptor(key, defaultValue));
|
|
7145
|
+
};
|
|
7146
|
+
}
|
|
7087
7147
|
|
|
7088
7148
|
function hasTransparent$3(color) {
|
|
7089
7149
|
if (!color || color.length === 7 || color.length === 4)
|
|
@@ -7141,26 +7201,9 @@ var LeaferUI = (function (exports) {
|
|
|
7141
7201
|
const debug$5 = Debug.get('UIData');
|
|
7142
7202
|
class UIData extends LeafData {
|
|
7143
7203
|
get scale() { const { scaleX, scaleY } = this; return scaleX !== scaleY ? { x: scaleX, y: scaleY } : scaleX; }
|
|
7144
|
-
get __strokeWidth() {
|
|
7145
|
-
|
|
7146
|
-
|
|
7147
|
-
const ui = this.__leaf;
|
|
7148
|
-
let { scaleX } = ui.__nowWorld || ui.__world;
|
|
7149
|
-
if (scaleX < 0)
|
|
7150
|
-
scaleX = -scaleX;
|
|
7151
|
-
return scaleX > 1 ? strokeWidth / scaleX : strokeWidth;
|
|
7152
|
-
}
|
|
7153
|
-
else
|
|
7154
|
-
return strokeWidth;
|
|
7155
|
-
}
|
|
7156
|
-
get __hasStroke() { return this.stroke && this.strokeWidth; }
|
|
7157
|
-
get __hasHalf() { const t = this; return (t.stroke && t.strokeAlign === 'center' && t.strokeWidth % 2) || undefined; }
|
|
7158
|
-
get __hasMultiPaint() {
|
|
7159
|
-
const t = this;
|
|
7160
|
-
if ((t.__isFills && t.fill.length > 1) || (t.__isStrokes && t.stroke.length > 1) || t.__useEffect)
|
|
7161
|
-
return true;
|
|
7162
|
-
return t.fill && this.__hasStroke;
|
|
7163
|
-
}
|
|
7204
|
+
get __strokeWidth() { return this.__getRealStrokeWidth(); }
|
|
7205
|
+
get __maxStrokeWidth() { const t = this; return t.__hasMultiStrokeStyle ? Math.max(t.__hasMultiStrokeStyle, t.strokeWidth) : t.strokeWidth; }
|
|
7206
|
+
get __hasMultiPaint() { const t = this; return (t.fill && this.__useStroke) || (t.__isFills && t.fill.length > 1) || (t.__isStrokes && t.stroke.length > 1) || t.__useEffect; }
|
|
7164
7207
|
get __clipAfterFill() { const t = this; return (t.cornerRadius || t.innerShadow || t.__pathInputed); }
|
|
7165
7208
|
get __hasSurface() { const t = this; return (t.fill || t.stroke); }
|
|
7166
7209
|
get __autoWidth() { return !this._width; }
|
|
@@ -7242,6 +7285,21 @@ var LeaferUI = (function (exports) {
|
|
|
7242
7285
|
Paint.compute('stroke', this.__leaf);
|
|
7243
7286
|
this.__needComputePaint = undefined;
|
|
7244
7287
|
}
|
|
7288
|
+
__getRealStrokeWidth(childStyle) {
|
|
7289
|
+
let { strokeWidth, strokeWidthFixed } = this;
|
|
7290
|
+
if (childStyle) {
|
|
7291
|
+
if (childStyle.strokeWidth)
|
|
7292
|
+
strokeWidth = childStyle.strokeWidth;
|
|
7293
|
+
if (childStyle.strokeWidthFixed !== undefined)
|
|
7294
|
+
strokeWidthFixed = childStyle.strokeWidthFixed;
|
|
7295
|
+
}
|
|
7296
|
+
if (strokeWidthFixed) {
|
|
7297
|
+
const scale = this.__leaf.getClampRenderScale();
|
|
7298
|
+
return scale > 1 ? strokeWidth / scale : strokeWidth;
|
|
7299
|
+
}
|
|
7300
|
+
else
|
|
7301
|
+
return strokeWidth;
|
|
7302
|
+
}
|
|
7245
7303
|
__setPaint(attrName, value) {
|
|
7246
7304
|
this.__setInput(attrName, value);
|
|
7247
7305
|
const layout = this.__leaf.__layout;
|
|
@@ -7266,6 +7324,7 @@ var LeaferUI = (function (exports) {
|
|
|
7266
7324
|
}
|
|
7267
7325
|
else {
|
|
7268
7326
|
stintSet$2(this, '__isAlphaPixelStroke', undefined);
|
|
7327
|
+
stintSet$2(this, '__hasMultiStrokeStyle', undefined);
|
|
7269
7328
|
this._stroke = this.__isStrokes = undefined;
|
|
7270
7329
|
}
|
|
7271
7330
|
}
|
|
@@ -7287,8 +7346,8 @@ var LeaferUI = (function (exports) {
|
|
|
7287
7346
|
|
|
7288
7347
|
class BoxData extends GroupData {
|
|
7289
7348
|
get __boxStroke() { return !this.__pathInputed; }
|
|
7290
|
-
get __drawAfterFill() { const t = this; return
|
|
7291
|
-
get __clipAfterFill() { return
|
|
7349
|
+
get __drawAfterFill() { const t = this; return t.__single || t.__clipAfterFill; }
|
|
7350
|
+
get __clipAfterFill() { const t = this; return t.overflow === 'hide' && t.__leaf.children.length && (t.__leaf.isOverflow || super.__clipAfterFill); }
|
|
7292
7351
|
}
|
|
7293
7352
|
|
|
7294
7353
|
class LeaferData extends GroupData {
|
|
@@ -7408,7 +7467,7 @@ var LeaferUI = (function (exports) {
|
|
|
7408
7467
|
const UIBounds = {
|
|
7409
7468
|
__updateStrokeSpread() {
|
|
7410
7469
|
let width = 0, boxWidth = 0;
|
|
7411
|
-
const data = this.__, { strokeAlign, strokeWidth } = data, box = this.__box;
|
|
7470
|
+
const data = this.__, { strokeAlign, __maxStrokeWidth: strokeWidth } = data, box = this.__box;
|
|
7412
7471
|
if ((data.stroke || data.hitStroke === 'all') && strokeWidth && strokeAlign !== 'inside') {
|
|
7413
7472
|
boxWidth = width = strokeAlign === 'center' ? strokeWidth / 2 : strokeWidth;
|
|
7414
7473
|
if (!data.__boxStroke) {
|
|
@@ -7428,13 +7487,15 @@ var LeaferUI = (function (exports) {
|
|
|
7428
7487
|
},
|
|
7429
7488
|
__updateRenderSpread() {
|
|
7430
7489
|
let width = 0;
|
|
7431
|
-
const { shadow, innerShadow, blur, backgroundBlur, filter } = this.__;
|
|
7490
|
+
const { shadow, innerShadow, blur, backgroundBlur, filter, renderSpread } = this.__;
|
|
7432
7491
|
if (shadow)
|
|
7433
7492
|
shadow.forEach(item => width = Math.max(width, Math.max(Math.abs(item.y), Math.abs(item.x)) + (item.spread > 0 ? item.spread : 0) + item.blur * 1.5));
|
|
7434
7493
|
if (blur)
|
|
7435
7494
|
width = Math.max(width, blur);
|
|
7436
7495
|
if (filter)
|
|
7437
7496
|
width += Filter.getSpread(filter);
|
|
7497
|
+
if (renderSpread)
|
|
7498
|
+
width += renderSpread;
|
|
7438
7499
|
let shapeWidth = width = Math.ceil(width);
|
|
7439
7500
|
if (innerShadow)
|
|
7440
7501
|
innerShadow.forEach(item => shapeWidth = Math.max(shapeWidth, Math.max(Math.abs(item.y), Math.abs(item.x)) + (item.spread < 0 ? -item.spread : 0) + item.blur * 1.5));
|
|
@@ -7450,15 +7511,18 @@ var LeaferUI = (function (exports) {
|
|
|
7450
7511
|
const UIRender = {
|
|
7451
7512
|
__updateChange() {
|
|
7452
7513
|
const data = this.__;
|
|
7514
|
+
if (data.__useStroke) {
|
|
7515
|
+
const useStroke = data.__useStroke = !!(data.stroke && data.strokeWidth);
|
|
7516
|
+
stintSet$1(this.__world, 'half', useStroke && data.strokeAlign === 'center' && data.strokeWidth % 2);
|
|
7517
|
+
stintSet$1(data, '__fillAfterStroke', useStroke && data.strokeAlign === 'outside' && data.fill && !data.__isTransparentFill);
|
|
7518
|
+
}
|
|
7453
7519
|
if (data.__useEffect) {
|
|
7454
7520
|
const { shadow, fill, stroke } = data, otherEffect = data.innerShadow || data.blur || data.backgroundBlur || data.filter;
|
|
7455
|
-
stintSet$1(data, '__isFastShadow', shadow && !otherEffect && shadow.length < 2 && !shadow[0].spread &&
|
|
7521
|
+
stintSet$1(data, '__isFastShadow', shadow && !otherEffect && shadow.length < 2 && !shadow[0].spread && fill && !data.__isTransparentFill && !(fill instanceof Array && fill.length > 1) && (this.useFastShadow || !stroke || (stroke && data.strokeAlign === 'inside')));
|
|
7456
7522
|
data.__useEffect = !!(shadow || otherEffect);
|
|
7457
7523
|
}
|
|
7458
|
-
stintSet$1(this.__world, 'half', data.__hasHalf);
|
|
7459
|
-
stintSet$1(data, '__fillAfterStroke', data.stroke && data.strokeAlign === 'outside' && data.fill && !data.__isTransparentFill);
|
|
7460
7524
|
data.__checkSingle();
|
|
7461
|
-
stintSet$1(data, '__complex', data.__isFills || data.__isStrokes || data.cornerRadius || data.__useEffect);
|
|
7525
|
+
stintSet$1(data, '__complex', (data.__isFills || data.__isStrokes || data.cornerRadius || data.__useEffect));
|
|
7462
7526
|
},
|
|
7463
7527
|
__drawFast(canvas, options) {
|
|
7464
7528
|
drawFast(this, canvas, options);
|
|
@@ -7516,18 +7580,15 @@ var LeaferUI = (function (exports) {
|
|
|
7516
7580
|
this.__drawFast(canvas, options);
|
|
7517
7581
|
}
|
|
7518
7582
|
},
|
|
7519
|
-
|
|
7520
|
-
|
|
7521
|
-
|
|
7522
|
-
|
|
7523
|
-
this.
|
|
7524
|
-
|
|
7525
|
-
|
|
7526
|
-
|
|
7527
|
-
|
|
7528
|
-
if (stroke && !ignoreStroke)
|
|
7529
|
-
this.__.__isAlphaPixelStroke ? Paint.strokes(stroke, this, canvas) : Paint.stroke('#000000', this, canvas);
|
|
7530
|
-
}
|
|
7583
|
+
__drawShape(canvas, options) {
|
|
7584
|
+
this.__drawRenderPath(canvas);
|
|
7585
|
+
const data = this.__, { fill, stroke } = data;
|
|
7586
|
+
if (fill && !options.ignoreFill)
|
|
7587
|
+
data.__isAlphaPixelFill ? Paint.fills(fill, this, canvas) : Paint.fill('#000000', this, canvas);
|
|
7588
|
+
if (data.__isCanvas)
|
|
7589
|
+
this.__drawAfterFill(canvas, options);
|
|
7590
|
+
if (stroke && !options.ignoreStroke)
|
|
7591
|
+
data.__isAlphaPixelStroke ? Paint.strokes(stroke, this, canvas) : Paint.stroke('#000000', this, canvas);
|
|
7531
7592
|
},
|
|
7532
7593
|
__drawAfterFill(canvas, options) {
|
|
7533
7594
|
if (this.__.__clipAfterFill) {
|
|
@@ -7564,17 +7625,17 @@ var LeaferUI = (function (exports) {
|
|
|
7564
7625
|
if (__drawAfterFill)
|
|
7565
7626
|
this.__drawAfterFill(canvas, options);
|
|
7566
7627
|
if (stroke) {
|
|
7567
|
-
const { strokeAlign, __strokeWidth } = this.__;
|
|
7568
|
-
if (!
|
|
7628
|
+
const { strokeAlign, __strokeWidth: strokeWidth } = this.__;
|
|
7629
|
+
if (!strokeWidth)
|
|
7569
7630
|
return;
|
|
7570
|
-
canvas.setStroke(stroke,
|
|
7571
|
-
const half =
|
|
7631
|
+
canvas.setStroke(stroke, strokeWidth, this.__);
|
|
7632
|
+
const half = strokeWidth / 2;
|
|
7572
7633
|
switch (strokeAlign) {
|
|
7573
7634
|
case 'center':
|
|
7574
7635
|
canvas.strokeRect(0, 0, width, height);
|
|
7575
7636
|
break;
|
|
7576
7637
|
case 'inside':
|
|
7577
|
-
width -=
|
|
7638
|
+
width -= strokeWidth, height -= strokeWidth;
|
|
7578
7639
|
if (width < 0 || height < 0) {
|
|
7579
7640
|
canvas.save();
|
|
7580
7641
|
this.__clip(canvas, options);
|
|
@@ -7585,7 +7646,7 @@ var LeaferUI = (function (exports) {
|
|
|
7585
7646
|
canvas.strokeRect(x + half, y + half, width, height);
|
|
7586
7647
|
break;
|
|
7587
7648
|
case 'outside':
|
|
7588
|
-
canvas.strokeRect(x - half, y - half, width +
|
|
7649
|
+
canvas.strokeRect(x - half, y - half, width + strokeWidth, height + strokeWidth);
|
|
7589
7650
|
break;
|
|
7590
7651
|
}
|
|
7591
7652
|
}
|
|
@@ -7598,6 +7659,8 @@ var LeaferUI = (function (exports) {
|
|
|
7598
7659
|
get isFrame() { return false; }
|
|
7599
7660
|
set scale(value) { MathHelper.assignScale(this, value); }
|
|
7600
7661
|
get scale() { return this.__.scale; }
|
|
7662
|
+
get isAutoWidth() { const t = this.__; return t.__autoWidth || t.autoWidth; }
|
|
7663
|
+
get isAutoHeight() { const t = this.__; return t.__autoHeight || t.autoHeight; }
|
|
7601
7664
|
get pen() {
|
|
7602
7665
|
const { path } = this.__;
|
|
7603
7666
|
pen.set(this.path = path || []);
|
|
@@ -7652,12 +7715,14 @@ var LeaferUI = (function (exports) {
|
|
|
7652
7715
|
}
|
|
7653
7716
|
}
|
|
7654
7717
|
__updateRenderPath() {
|
|
7655
|
-
|
|
7656
|
-
|
|
7718
|
+
const data = this.__;
|
|
7719
|
+
if (data.path) {
|
|
7657
7720
|
data.__pathForRender = data.cornerRadius ? PathCorner.smooth(data.path, data.cornerRadius, data.cornerSmoothing) : data.path;
|
|
7658
7721
|
if (data.__useArrow)
|
|
7659
7722
|
PathArrow.addArrows(this, !data.cornerRadius);
|
|
7660
7723
|
}
|
|
7724
|
+
else
|
|
7725
|
+
data.__pathForRender && (data.__pathForRender = undefined);
|
|
7661
7726
|
}
|
|
7662
7727
|
__drawRenderPath(canvas) {
|
|
7663
7728
|
canvas.beginPath();
|
|
@@ -7810,6 +7875,9 @@ var LeaferUI = (function (exports) {
|
|
|
7810
7875
|
__decorate([
|
|
7811
7876
|
naturalBoundsType(1)
|
|
7812
7877
|
], exports.UI.prototype, "pixelRatio", void 0);
|
|
7878
|
+
__decorate([
|
|
7879
|
+
affectRenderBoundsType(0)
|
|
7880
|
+
], exports.UI.prototype, "renderSpread", void 0);
|
|
7813
7881
|
__decorate([
|
|
7814
7882
|
pathInputType()
|
|
7815
7883
|
], exports.UI.prototype, "path", void 0);
|
|
@@ -7868,13 +7936,13 @@ var LeaferUI = (function (exports) {
|
|
|
7868
7936
|
surfaceType()
|
|
7869
7937
|
], exports.UI.prototype, "fill", void 0);
|
|
7870
7938
|
__decorate([
|
|
7871
|
-
strokeType()
|
|
7939
|
+
strokeType(undefined, true)
|
|
7872
7940
|
], exports.UI.prototype, "stroke", void 0);
|
|
7873
7941
|
__decorate([
|
|
7874
7942
|
strokeType('inside')
|
|
7875
7943
|
], exports.UI.prototype, "strokeAlign", void 0);
|
|
7876
7944
|
__decorate([
|
|
7877
|
-
strokeType(1)
|
|
7945
|
+
strokeType(1, true)
|
|
7878
7946
|
], exports.UI.prototype, "strokeWidth", void 0);
|
|
7879
7947
|
__decorate([
|
|
7880
7948
|
strokeType(false)
|
|
@@ -7966,7 +8034,8 @@ var LeaferUI = (function (exports) {
|
|
|
7966
8034
|
}
|
|
7967
8035
|
toJSON(options) {
|
|
7968
8036
|
const data = super.toJSON(options);
|
|
7969
|
-
|
|
8037
|
+
if (!this.childlessJSON)
|
|
8038
|
+
data.children = this.children.map(child => child.toJSON(options));
|
|
7970
8039
|
return data;
|
|
7971
8040
|
}
|
|
7972
8041
|
pick(_hitPoint, _options) { return undefined; }
|
|
@@ -8301,7 +8370,7 @@ var LeaferUI = (function (exports) {
|
|
|
8301
8370
|
list.push(item);
|
|
8302
8371
|
this.requestRender();
|
|
8303
8372
|
}
|
|
8304
|
-
zoom(_zoomType,
|
|
8373
|
+
zoom(_zoomType, _optionsOrPadding, _scroll, _transition) {
|
|
8305
8374
|
return Plugin.need('view');
|
|
8306
8375
|
}
|
|
8307
8376
|
getValidMove(moveX, moveY) { return { x: moveX, y: moveY }; }
|
|
@@ -8346,7 +8415,7 @@ var LeaferUI = (function (exports) {
|
|
|
8346
8415
|
Leafer_1.list.remove(this);
|
|
8347
8416
|
try {
|
|
8348
8417
|
this.stop();
|
|
8349
|
-
this.
|
|
8418
|
+
this.emitLeafer(LeaferEvent.END);
|
|
8350
8419
|
this.__removeListenEvents();
|
|
8351
8420
|
this.__controllers.forEach(item => !(this.parent && item === this.interaction) && item.destroy());
|
|
8352
8421
|
this.__controllers.length = 0;
|
|
@@ -8413,8 +8482,8 @@ var LeaferUI = (function (exports) {
|
|
|
8413
8482
|
__updateRenderSpread() { return this.__updateRectRenderSpread() || -1; }
|
|
8414
8483
|
__updateRectBoxBounds() { }
|
|
8415
8484
|
__updateBoxBounds(_secondLayout) {
|
|
8416
|
-
const data = this.__;
|
|
8417
8485
|
if (this.children.length && !this.pathInputed) {
|
|
8486
|
+
const data = this.__;
|
|
8418
8487
|
if (data.__autoSide) {
|
|
8419
8488
|
if (data.__hasSurface)
|
|
8420
8489
|
this.__extraUpdate();
|
|
@@ -8441,20 +8510,26 @@ var LeaferUI = (function (exports) {
|
|
|
8441
8510
|
__updateStrokeBounds() { }
|
|
8442
8511
|
__updateRenderBounds() {
|
|
8443
8512
|
let isOverflow;
|
|
8444
|
-
const { renderBounds } = this.__layout;
|
|
8445
8513
|
if (this.children.length) {
|
|
8514
|
+
const data = this.__, { renderBounds, boxBounds } = this.__layout;
|
|
8446
8515
|
super.__updateRenderBounds();
|
|
8447
8516
|
copy$6(childrenRenderBounds, renderBounds);
|
|
8448
8517
|
this.__updateRectRenderBounds();
|
|
8449
|
-
|
|
8450
|
-
|
|
8518
|
+
if (data.scrollY || data.scrollX) {
|
|
8519
|
+
childrenRenderBounds.x += data.scrollX;
|
|
8520
|
+
childrenRenderBounds.y += data.scrollY;
|
|
8521
|
+
}
|
|
8522
|
+
isOverflow = !includes$1(boxBounds, childrenRenderBounds);
|
|
8523
|
+
if (isOverflow && data.overflow !== 'hide')
|
|
8451
8524
|
add(renderBounds, childrenRenderBounds);
|
|
8452
8525
|
}
|
|
8453
8526
|
else
|
|
8454
8527
|
this.__updateRectRenderBounds();
|
|
8455
8528
|
DataHelper.stintSet(this, 'isOverflow', isOverflow);
|
|
8529
|
+
this.__updateScrollBar();
|
|
8456
8530
|
}
|
|
8457
8531
|
__updateRectRenderBounds() { }
|
|
8532
|
+
__updateScrollBar() { }
|
|
8458
8533
|
__updateRectChange() { }
|
|
8459
8534
|
__updateChange() {
|
|
8460
8535
|
super.__updateChange();
|
|
@@ -8471,10 +8546,12 @@ var LeaferUI = (function (exports) {
|
|
|
8471
8546
|
if (this.children.length)
|
|
8472
8547
|
this.__renderGroup(canvas, options);
|
|
8473
8548
|
}
|
|
8549
|
+
if (this.scrollBar)
|
|
8550
|
+
this.scrollBar.__render(canvas, options);
|
|
8474
8551
|
}
|
|
8475
8552
|
__drawContent(canvas, options) {
|
|
8476
8553
|
this.__renderGroup(canvas, options);
|
|
8477
|
-
if (this.__.
|
|
8554
|
+
if (this.__.__useStroke || this.__.__useEffect) {
|
|
8478
8555
|
canvas.setWorld(this.__nowWorld);
|
|
8479
8556
|
this.__drawRenderPath(canvas);
|
|
8480
8557
|
}
|
|
@@ -8694,8 +8771,8 @@ var LeaferUI = (function (exports) {
|
|
|
8694
8771
|
for (let i = 1; i < sides; i++) {
|
|
8695
8772
|
lineTo$1(path, rx + rx * sin$2((i * 2 * PI$2) / sides), ry - ry * cos$2((i * 2 * PI$2) / sides));
|
|
8696
8773
|
}
|
|
8774
|
+
closePath$1(path);
|
|
8697
8775
|
}
|
|
8698
|
-
closePath$1(path);
|
|
8699
8776
|
}
|
|
8700
8777
|
__updateRenderPath() { }
|
|
8701
8778
|
__updateBoxBounds() { }
|
|
@@ -8933,6 +9010,11 @@ var LeaferUI = (function (exports) {
|
|
|
8933
9010
|
return;
|
|
8934
9011
|
super.__draw(canvas, options, originCanvas);
|
|
8935
9012
|
}
|
|
9013
|
+
__drawShape(canvas, options) {
|
|
9014
|
+
if (options.shape)
|
|
9015
|
+
this.__box && this.__box.__drawShape(canvas, options);
|
|
9016
|
+
super.__drawShape(canvas, options);
|
|
9017
|
+
}
|
|
8936
9018
|
destroy() {
|
|
8937
9019
|
if (this.boxStyle)
|
|
8938
9020
|
this.boxStyle = null;
|
|
@@ -9754,6 +9836,7 @@ var LeaferUI = (function (exports) {
|
|
|
9754
9836
|
delta: { x: 80 / 4, y: 8.0 },
|
|
9755
9837
|
},
|
|
9756
9838
|
pointer: {
|
|
9839
|
+
type: 'pointer',
|
|
9757
9840
|
snap: true,
|
|
9758
9841
|
hitRadius: 5,
|
|
9759
9842
|
tapTime: 120,
|
|
@@ -10271,18 +10354,20 @@ var LeaferUI = (function (exports) {
|
|
|
10271
10354
|
}
|
|
10272
10355
|
return this.__hit(inner);
|
|
10273
10356
|
};
|
|
10274
|
-
leaf$1.__hitFill = function (inner) {
|
|
10275
|
-
leaf$1.__hitStroke = function (inner, strokeWidth) {
|
|
10276
|
-
leaf$1.__hitPixel = function (inner) {
|
|
10277
|
-
leaf$1.__drawHitPath = function (canvas) {
|
|
10278
|
-
this.__drawRenderPath(canvas); };
|
|
10357
|
+
leaf$1.__hitFill = function (inner) { const h = this.__hitCanvas; return h && h.hitFill(inner, this.__.windingRule); };
|
|
10358
|
+
leaf$1.__hitStroke = function (inner, strokeWidth) { const h = this.__hitCanvas; return h && h.hitStroke(inner, strokeWidth); };
|
|
10359
|
+
leaf$1.__hitPixel = function (inner) { const h = this.__hitCanvas; return h && h.hitPixel(inner, this.__layout.renderBounds, h.hitScale); };
|
|
10360
|
+
leaf$1.__drawHitPath = function (canvas) { canvas && this.__drawRenderPath(canvas); };
|
|
10279
10361
|
|
|
10280
10362
|
const matrix$2 = new Matrix();
|
|
10281
10363
|
const ui$5 = exports.UI.prototype;
|
|
10282
10364
|
ui$5.__updateHitCanvas = function () {
|
|
10283
10365
|
if (this.__box)
|
|
10284
10366
|
this.__box.__updateHitCanvas();
|
|
10285
|
-
const
|
|
10367
|
+
const leafer = this.leafer || (this.parent && this.parent.leafer);
|
|
10368
|
+
if (!leafer)
|
|
10369
|
+
return;
|
|
10370
|
+
const data = this.__, { hitCanvasManager } = leafer;
|
|
10286
10371
|
const isHitPixelFill = (data.__isAlphaPixelFill || data.__isCanvas) && data.hitFill === 'pixel';
|
|
10287
10372
|
const isHitPixelStroke = data.__isAlphaPixelStroke && data.hitStroke === 'pixel';
|
|
10288
10373
|
const isHitPixel = isHitPixelFill || isHitPixelStroke;
|
|
@@ -10297,7 +10382,7 @@ var LeaferUI = (function (exports) {
|
|
|
10297
10382
|
h.resize({ width, height, pixelRatio: 1 });
|
|
10298
10383
|
h.clear();
|
|
10299
10384
|
ImageManager.patternLocked = true;
|
|
10300
|
-
this.__renderShape(h, { matrix: matrix$2.setWith(this.__world).scaleWith(1 / scale).invertWith().translate(-x, -y)
|
|
10385
|
+
this.__renderShape(h, { matrix: matrix$2.setWith(this.__world).scaleWith(1 / scale).invertWith().translate(-x, -y), ignoreFill: !isHitPixelFill, ignoreStroke: !isHitPixelStroke });
|
|
10301
10386
|
ImageManager.patternLocked = false;
|
|
10302
10387
|
h.resetTransform();
|
|
10303
10388
|
data.__isHitPixel = true;
|
|
@@ -10318,7 +10403,7 @@ var LeaferUI = (function (exports) {
|
|
|
10318
10403
|
const needHitFillPath = ((data.fill || data.__isCanvas) && (hitFill === 'path' || (hitFill === 'pixel' && !(data.__isAlphaPixelFill || data.__isCanvas)))) || hitFill === 'all';
|
|
10319
10404
|
if (needHitFillPath && this.__hitFill(inner))
|
|
10320
10405
|
return true;
|
|
10321
|
-
const { hitStroke,
|
|
10406
|
+
const { hitStroke, __maxStrokeWidth: strokeWidth } = data;
|
|
10322
10407
|
const needHitStrokePath = (data.stroke && (hitStroke === 'path' || (hitStroke === 'pixel' && !data.__isAlphaPixelStroke))) || hitStroke === 'all';
|
|
10323
10408
|
if (!needHitFillPath && !needHitStrokePath)
|
|
10324
10409
|
return false;
|
|
@@ -10327,16 +10412,16 @@ var LeaferUI = (function (exports) {
|
|
|
10327
10412
|
if (needHitStrokePath) {
|
|
10328
10413
|
switch (data.strokeAlign) {
|
|
10329
10414
|
case 'inside':
|
|
10330
|
-
hitWidth +=
|
|
10415
|
+
hitWidth += strokeWidth * 2;
|
|
10331
10416
|
if (!needHitFillPath && this.__hitFill(inner) && this.__hitStroke(inner, hitWidth))
|
|
10332
10417
|
return true;
|
|
10333
10418
|
hitWidth = radiusWidth;
|
|
10334
10419
|
break;
|
|
10335
10420
|
case 'center':
|
|
10336
|
-
hitWidth +=
|
|
10421
|
+
hitWidth += strokeWidth;
|
|
10337
10422
|
break;
|
|
10338
10423
|
case 'outside':
|
|
10339
|
-
hitWidth +=
|
|
10424
|
+
hitWidth += strokeWidth * 2;
|
|
10340
10425
|
if (!needHitFillPath) {
|
|
10341
10426
|
if (!this.__hitFill(inner) && this.__hitStroke(inner, hitWidth))
|
|
10342
10427
|
return true;
|
|
@@ -10436,9 +10521,14 @@ var LeaferUI = (function (exports) {
|
|
|
10436
10521
|
}
|
|
10437
10522
|
}
|
|
10438
10523
|
canvas.fillStyle = item.style;
|
|
10439
|
-
if (item.transform) {
|
|
10524
|
+
if (item.transform || item.scaleFixed) {
|
|
10440
10525
|
canvas.save();
|
|
10441
|
-
|
|
10526
|
+
if (item.transform)
|
|
10527
|
+
canvas.transform(item.transform);
|
|
10528
|
+
if (item.scaleFixed) {
|
|
10529
|
+
const { scaleX, scaleY } = ui.getRenderScaleData(true);
|
|
10530
|
+
canvas.scale(1 / scaleX, 1 / scaleY);
|
|
10531
|
+
}
|
|
10442
10532
|
if (item.blendMode)
|
|
10443
10533
|
canvas.blendMode = item.blendMode;
|
|
10444
10534
|
fillPathOrText(ui, canvas);
|
|
@@ -10474,8 +10564,13 @@ var LeaferUI = (function (exports) {
|
|
|
10474
10564
|
}
|
|
10475
10565
|
function drawCenter$1(stroke, strokeWidthScale, ui, canvas) {
|
|
10476
10566
|
const data = ui.__;
|
|
10477
|
-
|
|
10478
|
-
|
|
10567
|
+
if (typeof stroke === 'object') {
|
|
10568
|
+
drawStrokesStyle(stroke, strokeWidthScale, true, ui, canvas);
|
|
10569
|
+
}
|
|
10570
|
+
else {
|
|
10571
|
+
canvas.setStroke(stroke, data.__strokeWidth * strokeWidthScale, data);
|
|
10572
|
+
drawTextStroke(ui, canvas);
|
|
10573
|
+
}
|
|
10479
10574
|
}
|
|
10480
10575
|
function drawAlign(stroke, align, ui, canvas) {
|
|
10481
10576
|
const out = canvas.getSameCanvas(true, true);
|
|
@@ -10484,15 +10579,9 @@ var LeaferUI = (function (exports) {
|
|
|
10484
10579
|
out.blendMode = align === 'outside' ? 'destination-out' : 'destination-in';
|
|
10485
10580
|
fillText(ui, out);
|
|
10486
10581
|
out.blendMode = 'normal';
|
|
10487
|
-
|
|
10582
|
+
LeafHelper.copyCanvasByWorld(ui, canvas, out);
|
|
10488
10583
|
out.recycle(ui.__nowWorld);
|
|
10489
10584
|
}
|
|
10490
|
-
function copyWorld(canvas, out, ui) {
|
|
10491
|
-
if (ui.__worldFlipped || Platform.fullImageShadow)
|
|
10492
|
-
canvas.copyWorldByReset(out, ui.__nowWorld);
|
|
10493
|
-
else
|
|
10494
|
-
canvas.copyWorldToInner(out, ui.__nowWorld, ui.__layout.renderBounds);
|
|
10495
|
-
}
|
|
10496
10585
|
function drawTextStroke(ui, canvas) {
|
|
10497
10586
|
let row, data = ui.__.__textDrawData;
|
|
10498
10587
|
const { rows, decorationY } = data;
|
|
@@ -10508,14 +10597,21 @@ var LeaferUI = (function (exports) {
|
|
|
10508
10597
|
rows.forEach(row => decorationY.forEach(value => canvas.strokeRect(row.x, row.y + value, row.width, decorationHeight)));
|
|
10509
10598
|
}
|
|
10510
10599
|
}
|
|
10511
|
-
function drawStrokesStyle(strokes, isText, ui, canvas) {
|
|
10600
|
+
function drawStrokesStyle(strokes, strokeWidthScale, isText, ui, canvas) {
|
|
10512
10601
|
let item;
|
|
10602
|
+
const data = ui.__, { __hasMultiStrokeStyle } = data;
|
|
10603
|
+
__hasMultiStrokeStyle || canvas.setStroke(undefined, data.__strokeWidth * strokeWidthScale, data);
|
|
10513
10604
|
for (let i = 0, len = strokes.length; i < len; i++) {
|
|
10514
10605
|
item = strokes[i];
|
|
10515
10606
|
if (item.image && PaintImage.checkImage(ui, canvas, item, false))
|
|
10516
10607
|
continue;
|
|
10517
10608
|
if (item.style) {
|
|
10518
|
-
|
|
10609
|
+
if (__hasMultiStrokeStyle) {
|
|
10610
|
+
const { strokeStyle } = item;
|
|
10611
|
+
strokeStyle ? canvas.setStroke(item.style, data.__getRealStrokeWidth(strokeStyle) * strokeWidthScale, data, strokeStyle) : canvas.setStroke(item.style, data.__strokeWidth * strokeWidthScale, data);
|
|
10612
|
+
}
|
|
10613
|
+
else
|
|
10614
|
+
canvas.strokeStyle = item.style;
|
|
10519
10615
|
if (item.blendMode) {
|
|
10520
10616
|
canvas.saveBlendMode(item.blendMode);
|
|
10521
10617
|
isText ? drawTextStroke(ui, canvas) : canvas.stroke();
|
|
@@ -10554,8 +10650,13 @@ var LeaferUI = (function (exports) {
|
|
|
10554
10650
|
}
|
|
10555
10651
|
function drawCenter(stroke, strokeWidthScale, ui, canvas) {
|
|
10556
10652
|
const data = ui.__;
|
|
10557
|
-
|
|
10558
|
-
|
|
10653
|
+
if (typeof stroke === 'object') {
|
|
10654
|
+
drawStrokesStyle(stroke, strokeWidthScale, false, ui, canvas);
|
|
10655
|
+
}
|
|
10656
|
+
else {
|
|
10657
|
+
canvas.setStroke(stroke, data.__strokeWidth * strokeWidthScale, data);
|
|
10658
|
+
canvas.stroke();
|
|
10659
|
+
}
|
|
10559
10660
|
if (data.__useArrow)
|
|
10560
10661
|
Paint.strokeArrow(stroke, ui, canvas);
|
|
10561
10662
|
}
|
|
@@ -10577,7 +10678,7 @@ var LeaferUI = (function (exports) {
|
|
|
10577
10678
|
drawCenter(stroke, 2, ui, out);
|
|
10578
10679
|
out.clipUI(data);
|
|
10579
10680
|
out.clearWorld(renderBounds);
|
|
10580
|
-
|
|
10681
|
+
LeafHelper.copyCanvasByWorld(ui, canvas, out);
|
|
10581
10682
|
out.recycle(ui.__nowWorld);
|
|
10582
10683
|
}
|
|
10583
10684
|
}
|
|
@@ -10632,8 +10733,16 @@ var LeaferUI = (function (exports) {
|
|
|
10632
10733
|
if (!(paints instanceof Array))
|
|
10633
10734
|
paints = [paints];
|
|
10634
10735
|
recycleMap = PaintImage.recycleImage(attrName, data);
|
|
10736
|
+
let maxChildStrokeWidth;
|
|
10635
10737
|
for (let i = 0, len = paints.length, item; i < len; i++) {
|
|
10636
|
-
(item = getLeafPaint(attrName, paints[i], ui))
|
|
10738
|
+
if (item = getLeafPaint(attrName, paints[i], ui)) {
|
|
10739
|
+
leafPaints.push(item);
|
|
10740
|
+
if (item.strokeStyle) {
|
|
10741
|
+
maxChildStrokeWidth || (maxChildStrokeWidth = 1);
|
|
10742
|
+
if (item.strokeStyle.strokeWidth)
|
|
10743
|
+
maxChildStrokeWidth = Math.max(maxChildStrokeWidth, item.strokeStyle.strokeWidth);
|
|
10744
|
+
}
|
|
10745
|
+
}
|
|
10637
10746
|
}
|
|
10638
10747
|
data['_' + attrName] = leafPaints.length ? leafPaints : undefined;
|
|
10639
10748
|
if (leafPaints.length) {
|
|
@@ -10650,6 +10759,7 @@ var LeaferUI = (function (exports) {
|
|
|
10650
10759
|
else {
|
|
10651
10760
|
stintSet(data, '__isAlphaPixelStroke', isAlphaPixel);
|
|
10652
10761
|
stintSet(data, '__isTransparentStroke', isTransparent);
|
|
10762
|
+
stintSet(data, '__hasMultiStrokeStyle', maxChildStrokeWidth);
|
|
10653
10763
|
}
|
|
10654
10764
|
}
|
|
10655
10765
|
function getLeafPaint(attrName, paint, ui) {
|
|
@@ -10681,6 +10791,11 @@ var LeaferUI = (function (exports) {
|
|
|
10681
10791
|
if (data) {
|
|
10682
10792
|
if (typeof data.style === 'string' && hasTransparent$1(data.style))
|
|
10683
10793
|
data.isTransparent = true;
|
|
10794
|
+
if (paint.style) {
|
|
10795
|
+
if (paint.style.strokeWidth === 0)
|
|
10796
|
+
return undefined;
|
|
10797
|
+
data.strokeStyle = paint.style;
|
|
10798
|
+
}
|
|
10684
10799
|
if (paint.blendMode)
|
|
10685
10800
|
data.blendMode = paint.blendMode;
|
|
10686
10801
|
}
|
|
@@ -10700,8 +10815,8 @@ var LeaferUI = (function (exports) {
|
|
|
10700
10815
|
shape
|
|
10701
10816
|
};
|
|
10702
10817
|
|
|
10703
|
-
let origin$1 = {};
|
|
10704
|
-
const { get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, scale: scaleHelper, rotate: rotate$2 } = MatrixHelper;
|
|
10818
|
+
let origin$1 = {}, tempMatrix = getMatrixData();
|
|
10819
|
+
const { get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, multiplyParent, scale: scaleHelper, rotate: rotate$2, skew: skewHelper } = MatrixHelper;
|
|
10705
10820
|
function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
10706
10821
|
const transform = get$3();
|
|
10707
10822
|
translate$1(transform, box.x + x, box.y + y);
|
|
@@ -10710,13 +10825,19 @@ var LeaferUI = (function (exports) {
|
|
|
10710
10825
|
rotateOfOuter$1(transform, { x: box.x + box.width / 2, y: box.y + box.height / 2 }, rotation);
|
|
10711
10826
|
data.transform = transform;
|
|
10712
10827
|
}
|
|
10713
|
-
function clipMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
10828
|
+
function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew, clipSize) {
|
|
10714
10829
|
const transform = get$3();
|
|
10715
|
-
translate$1(transform, box.x + x, box.y + y);
|
|
10716
|
-
if (scaleX)
|
|
10717
|
-
scaleHelper(transform, scaleX, scaleY);
|
|
10718
10830
|
if (rotation)
|
|
10719
10831
|
rotate$2(transform, rotation);
|
|
10832
|
+
if (skew)
|
|
10833
|
+
skewHelper(transform, skew.x, skew.y);
|
|
10834
|
+
if (scaleX)
|
|
10835
|
+
scaleHelper(transform, scaleX, scaleY);
|
|
10836
|
+
translate$1(transform, box.x + x, box.y + y);
|
|
10837
|
+
if (clipSize) {
|
|
10838
|
+
tempMatrix.a = box.width / clipSize.width, tempMatrix.d = box.height / clipSize.height;
|
|
10839
|
+
multiplyParent(transform, tempMatrix);
|
|
10840
|
+
}
|
|
10720
10841
|
data.transform = transform;
|
|
10721
10842
|
}
|
|
10722
10843
|
function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, align) {
|
|
@@ -10753,11 +10874,15 @@ var LeaferUI = (function (exports) {
|
|
|
10753
10874
|
const tempScaleData = {};
|
|
10754
10875
|
const tempImage = {};
|
|
10755
10876
|
function createData(leafPaint, image, paint, box) {
|
|
10756
|
-
const { changeful, sync } = paint;
|
|
10877
|
+
const { changeful, sync, editing, scaleFixed } = paint;
|
|
10757
10878
|
if (changeful)
|
|
10758
10879
|
leafPaint.changeful = changeful;
|
|
10759
10880
|
if (sync)
|
|
10760
10881
|
leafPaint.sync = sync;
|
|
10882
|
+
if (editing)
|
|
10883
|
+
leafPaint.editing = editing;
|
|
10884
|
+
if (scaleFixed)
|
|
10885
|
+
leafPaint.scaleFixed = scaleFixed;
|
|
10761
10886
|
leafPaint.data = getPatternData(paint, box, image);
|
|
10762
10887
|
}
|
|
10763
10888
|
function getPatternData(paint, box, image) {
|
|
@@ -10766,7 +10891,7 @@ var LeaferUI = (function (exports) {
|
|
|
10766
10891
|
if (paint.mode === 'strench')
|
|
10767
10892
|
paint.mode = 'stretch';
|
|
10768
10893
|
let { width, height } = image;
|
|
10769
|
-
const { opacity, mode, align, offset, scale, size, rotation, repeat, filters } = paint;
|
|
10894
|
+
const { opacity, mode, align, offset, scale, size, rotation, skew, clipSize, repeat, filters } = paint;
|
|
10770
10895
|
const sameBox = box.width === width && box.height === height;
|
|
10771
10896
|
const data = { mode };
|
|
10772
10897
|
const swapSize = align !== 'center' && (rotation || 0) % 180 === 90;
|
|
@@ -10800,8 +10925,8 @@ var LeaferUI = (function (exports) {
|
|
|
10800
10925
|
break;
|
|
10801
10926
|
case 'normal':
|
|
10802
10927
|
case 'clip':
|
|
10803
|
-
if (tempImage.x || tempImage.y || scaleX || rotation)
|
|
10804
|
-
clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
|
|
10928
|
+
if (tempImage.x || tempImage.y || scaleX || clipSize || rotation || skew)
|
|
10929
|
+
clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, paint.clipSize);
|
|
10805
10930
|
break;
|
|
10806
10931
|
case 'repeat':
|
|
10807
10932
|
if (!sameBox || scaleX || rotation)
|
|
@@ -10878,11 +11003,11 @@ var LeaferUI = (function (exports) {
|
|
|
10878
11003
|
}
|
|
10879
11004
|
onLoadSuccess(ui, event);
|
|
10880
11005
|
}
|
|
10881
|
-
leafPaint.loadId =
|
|
11006
|
+
leafPaint.loadId = undefined;
|
|
10882
11007
|
}, (error) => {
|
|
10883
11008
|
ignoreRender(ui, false);
|
|
10884
11009
|
onLoadError(ui, event, error);
|
|
10885
|
-
leafPaint.loadId =
|
|
11010
|
+
leafPaint.loadId = undefined;
|
|
10886
11011
|
});
|
|
10887
11012
|
if (ui.placeholderColor) {
|
|
10888
11013
|
if (!ui.placeholderDelay)
|
|
@@ -10938,16 +11063,16 @@ var LeaferUI = (function (exports) {
|
|
|
10938
11063
|
}
|
|
10939
11064
|
|
|
10940
11065
|
const { get: get$1, scale: scale$2, copy: copy$4 } = MatrixHelper;
|
|
10941
|
-
const { ceil: ceil$1, abs: abs$
|
|
11066
|
+
const { ceil: ceil$1, abs: abs$3 } = Math;
|
|
10942
11067
|
function createPattern(ui, paint, pixelRatio) {
|
|
10943
|
-
let { scaleX, scaleY } =
|
|
11068
|
+
let { scaleX, scaleY } = ui.getRenderScaleData(true, paint.scaleFixed);
|
|
10944
11069
|
const id = scaleX + '-' + scaleY + '-' + pixelRatio;
|
|
10945
11070
|
if (paint.patternId !== id && !ui.destroyed) {
|
|
10946
|
-
scaleX = abs$4(scaleX);
|
|
10947
|
-
scaleY = abs$4(scaleY);
|
|
10948
11071
|
const { image, data } = paint;
|
|
10949
11072
|
let imageScale, imageMatrix, { width, height, scaleX: sx, scaleY: sy, transform, repeat } = data;
|
|
10950
11073
|
if (sx) {
|
|
11074
|
+
sx = abs$3(sx);
|
|
11075
|
+
sy = abs$3(sy);
|
|
10951
11076
|
imageMatrix = get$1();
|
|
10952
11077
|
copy$4(imageMatrix, transform);
|
|
10953
11078
|
scale$2(imageMatrix, 1 / sx, 1 / sy);
|
|
@@ -11000,9 +11125,8 @@ var LeaferUI = (function (exports) {
|
|
|
11000
11125
|
}
|
|
11001
11126
|
}
|
|
11002
11127
|
|
|
11003
|
-
const { abs: abs$3 } = Math;
|
|
11004
11128
|
function checkImage(ui, canvas, paint, allowDraw) {
|
|
11005
|
-
const { scaleX, scaleY } =
|
|
11129
|
+
const { scaleX, scaleY } = ui.getRenderScaleData(true, paint.scaleFixed);
|
|
11006
11130
|
const { pixelRatio } = canvas, { data } = paint;
|
|
11007
11131
|
if (!data || (paint.patternId === scaleX + '-' + scaleY + '-' + pixelRatio && !Export.running)) {
|
|
11008
11132
|
return false;
|
|
@@ -11015,8 +11139,8 @@ var LeaferUI = (function (exports) {
|
|
|
11015
11139
|
else {
|
|
11016
11140
|
if (!(paint.changeful || ResizeEvent.isResizing(ui) || Export.running)) {
|
|
11017
11141
|
let { width, height } = data;
|
|
11018
|
-
width *=
|
|
11019
|
-
height *=
|
|
11142
|
+
width *= scaleX * pixelRatio;
|
|
11143
|
+
height *= scaleY * pixelRatio;
|
|
11020
11144
|
if (data.scaleX) {
|
|
11021
11145
|
width *= data.scaleX;
|
|
11022
11146
|
height *= data.scaleY;
|
|
@@ -11026,6 +11150,10 @@ var LeaferUI = (function (exports) {
|
|
|
11026
11150
|
}
|
|
11027
11151
|
}
|
|
11028
11152
|
if (allowDraw) {
|
|
11153
|
+
if (ui.__.__isFastShadow) {
|
|
11154
|
+
canvas.fillStyle = paint.style || '#000';
|
|
11155
|
+
canvas.fill();
|
|
11156
|
+
}
|
|
11029
11157
|
drawImage(ui, canvas, paint, data);
|
|
11030
11158
|
return true;
|
|
11031
11159
|
}
|
|
@@ -11214,10 +11342,7 @@ var LeaferUI = (function (exports) {
|
|
|
11214
11342
|
}
|
|
11215
11343
|
worldCanvas ? other.copyWorld(worldCanvas, nowWorld, nowWorld, 'destination-out') : other.copyWorld(shape.canvas, shapeBounds, bounds, 'destination-out');
|
|
11216
11344
|
}
|
|
11217
|
-
|
|
11218
|
-
current.copyWorldByReset(other, copyBounds, nowWorld, item.blendMode);
|
|
11219
|
-
else
|
|
11220
|
-
current.copyWorldToInner(other, copyBounds, __layout.renderBounds, item.blendMode);
|
|
11345
|
+
LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
|
|
11221
11346
|
if (end && index < end)
|
|
11222
11347
|
other.clearWorld(copyBounds, true);
|
|
11223
11348
|
});
|
|
@@ -11276,10 +11401,7 @@ var LeaferUI = (function (exports) {
|
|
|
11276
11401
|
copyBounds = bounds;
|
|
11277
11402
|
}
|
|
11278
11403
|
other.fillWorld(copyBounds, ColorConvert.string(item.color), 'source-in');
|
|
11279
|
-
|
|
11280
|
-
current.copyWorldByReset(other, copyBounds, nowWorld, item.blendMode);
|
|
11281
|
-
else
|
|
11282
|
-
current.copyWorldToInner(other, copyBounds, __layout.renderBounds, item.blendMode);
|
|
11404
|
+
LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
|
|
11283
11405
|
if (end && index < end)
|
|
11284
11406
|
other.clearWorld(copyBounds, true);
|
|
11285
11407
|
});
|
|
@@ -11335,12 +11457,11 @@ var LeaferUI = (function (exports) {
|
|
|
11335
11457
|
contentCanvas = getCanvas(canvas);
|
|
11336
11458
|
child.__render(maskCanvas, options);
|
|
11337
11459
|
}
|
|
11338
|
-
if (
|
|
11339
|
-
|
|
11340
|
-
}
|
|
11341
|
-
if (excludeRenderBounds(child, options))
|
|
11460
|
+
if (mask === 'clipping' || mask === 'clipping-path')
|
|
11461
|
+
excludeRenderBounds(child, options) || child.__render(canvas, options);
|
|
11342
11462
|
continue;
|
|
11343
|
-
|
|
11463
|
+
}
|
|
11464
|
+
excludeRenderBounds(child, options) || child.__render(contentCanvas || canvas, options);
|
|
11344
11465
|
}
|
|
11345
11466
|
maskEnd(this, currentMask, canvas, contentCanvas, maskCanvas, maskOpacity);
|
|
11346
11467
|
};
|
|
@@ -11941,41 +12062,10 @@ var LeaferUI = (function (exports) {
|
|
|
11941
12062
|
}
|
|
11942
12063
|
EditorEvent.BEFORE_SELECT = 'editor.before_select';
|
|
11943
12064
|
EditorEvent.SELECT = 'editor.select';
|
|
12065
|
+
EditorEvent.AFTER_SELECT = 'editor.after_select';
|
|
11944
12066
|
EditorEvent.BEFORE_HOVER = 'editor.before_hover';
|
|
11945
12067
|
EditorEvent.HOVER = 'editor.hover';
|
|
11946
12068
|
|
|
11947
|
-
class EditorMoveEvent extends EditorEvent {
|
|
11948
|
-
constructor(type, data) {
|
|
11949
|
-
super(type, data);
|
|
11950
|
-
}
|
|
11951
|
-
}
|
|
11952
|
-
EditorMoveEvent.BEFORE_MOVE = 'editor.before_move';
|
|
11953
|
-
EditorMoveEvent.MOVE = 'editor.move';
|
|
11954
|
-
|
|
11955
|
-
class EditorScaleEvent extends EditorEvent {
|
|
11956
|
-
constructor(type, data) {
|
|
11957
|
-
super(type, data);
|
|
11958
|
-
}
|
|
11959
|
-
}
|
|
11960
|
-
EditorScaleEvent.BEFORE_SCALE = 'editor.before_scale';
|
|
11961
|
-
EditorScaleEvent.SCALE = 'editor.scale';
|
|
11962
|
-
|
|
11963
|
-
class EditorRotateEvent extends EditorEvent {
|
|
11964
|
-
constructor(type, data) {
|
|
11965
|
-
super(type, data);
|
|
11966
|
-
}
|
|
11967
|
-
}
|
|
11968
|
-
EditorRotateEvent.BEFORE_ROTATE = 'editor.before_rotate';
|
|
11969
|
-
EditorRotateEvent.ROTATE = 'editor.rotate';
|
|
11970
|
-
|
|
11971
|
-
class EditorSkewEvent extends EditorEvent {
|
|
11972
|
-
constructor(type, data) {
|
|
11973
|
-
super(type, data);
|
|
11974
|
-
}
|
|
11975
|
-
}
|
|
11976
|
-
EditorSkewEvent.BEFORE_SKEW = 'editor.before_skew';
|
|
11977
|
-
EditorSkewEvent.SKEW = 'editor.skew';
|
|
11978
|
-
|
|
11979
12069
|
function targetAttr(fn) {
|
|
11980
12070
|
return (target, key) => {
|
|
11981
12071
|
const privateKey = '_' + key;
|
|
@@ -11989,6 +12079,8 @@ var LeaferUI = (function (exports) {
|
|
|
11989
12079
|
if (isSelect) {
|
|
11990
12080
|
if (value instanceof Array && value.length > 1 && value[0].locked)
|
|
11991
12081
|
value.splice(0, 1);
|
|
12082
|
+
if (this.single)
|
|
12083
|
+
this.element.syncEventer = null;
|
|
11992
12084
|
const { beforeSelect } = this.config;
|
|
11993
12085
|
if (beforeSelect) {
|
|
11994
12086
|
const check = beforeSelect({ target: value });
|
|
@@ -12012,9 +12104,11 @@ var LeaferUI = (function (exports) {
|
|
|
12012
12104
|
return (target, key) => {
|
|
12013
12105
|
defineKey(target, key, {
|
|
12014
12106
|
get() {
|
|
12015
|
-
const { config, element, dragPoint } = this, mergeConfig = Object.assign({}, config);
|
|
12107
|
+
const { config, element, dragPoint, editBox } = this, mergeConfig = Object.assign({}, config);
|
|
12016
12108
|
if (element && element.editConfig)
|
|
12017
12109
|
Object.assign(mergeConfig, element.editConfig);
|
|
12110
|
+
if (editBox.config)
|
|
12111
|
+
Object.assign(mergeConfig, editBox.config);
|
|
12018
12112
|
if (dragPoint) {
|
|
12019
12113
|
if (dragPoint.editConfig)
|
|
12020
12114
|
Object.assign(mergeConfig, dragPoint.editConfig);
|
|
@@ -12046,14 +12140,17 @@ var LeaferUI = (function (exports) {
|
|
|
12046
12140
|
this.strokeAlign = 'center';
|
|
12047
12141
|
}
|
|
12048
12142
|
setTarget(target, style) {
|
|
12049
|
-
|
|
12143
|
+
if (style)
|
|
12144
|
+
this.set(style);
|
|
12050
12145
|
this.target = target;
|
|
12051
12146
|
this.update();
|
|
12052
12147
|
}
|
|
12053
|
-
update() {
|
|
12148
|
+
update(style) {
|
|
12054
12149
|
const { list } = this;
|
|
12055
12150
|
if (list.length) {
|
|
12056
12151
|
setListWithFn(bounds$2, list, worldBounds);
|
|
12152
|
+
if (style)
|
|
12153
|
+
this.set(style);
|
|
12057
12154
|
this.set(bounds$2);
|
|
12058
12155
|
this.visible = true;
|
|
12059
12156
|
}
|
|
@@ -12196,15 +12293,14 @@ var LeaferUI = (function (exports) {
|
|
|
12196
12293
|
}
|
|
12197
12294
|
onSelect() {
|
|
12198
12295
|
if (this.running) {
|
|
12199
|
-
|
|
12200
|
-
const { stroke, strokeWidth, selectedStyle } = mergeConfig;
|
|
12201
|
-
this.targetStroker.setTarget(list, Object.assign({ stroke, strokeWidth: Math.max(1, strokeWidth / 2) }, (selectedStyle || {})));
|
|
12296
|
+
this.targetStroker.setTarget(this.editor.list);
|
|
12202
12297
|
this.hoverStroker.target = null;
|
|
12203
12298
|
}
|
|
12204
12299
|
}
|
|
12205
12300
|
update() {
|
|
12206
12301
|
this.hoverStroker.update();
|
|
12207
|
-
this.
|
|
12302
|
+
const { stroke, strokeWidth, selectedStyle } = this.editor.mergedConfig;
|
|
12303
|
+
this.targetStroker.update(Object.assign({ stroke, strokeWidth: strokeWidth && Math.max(1, strokeWidth / 2) }, (selectedStyle || {})));
|
|
12208
12304
|
}
|
|
12209
12305
|
onPointerMove(e) {
|
|
12210
12306
|
const { app, editor } = this;
|
|
@@ -12386,16 +12482,16 @@ var LeaferUI = (function (exports) {
|
|
|
12386
12482
|
const { toPoint } = AroundHelper;
|
|
12387
12483
|
const { within: within$2 } = MathHelper;
|
|
12388
12484
|
const EditDataHelper = {
|
|
12389
|
-
getScaleData(
|
|
12485
|
+
getScaleData(target, startBounds, direction, totalMove, lockRatio, around, flipable, scaleMode) {
|
|
12390
12486
|
let align, origin = {}, scaleX = 1, scaleY = 1;
|
|
12391
|
-
const { boxBounds, widthRange, heightRange, dragBounds, worldBoxBounds } =
|
|
12487
|
+
const { boxBounds, widthRange, heightRange, dragBounds, worldBoxBounds } = target;
|
|
12392
12488
|
const { width, height } = startBounds;
|
|
12393
12489
|
if (around) {
|
|
12394
12490
|
totalMove.x *= 2;
|
|
12395
12491
|
totalMove.y *= 2;
|
|
12396
12492
|
}
|
|
12397
|
-
const originChangedScaleX =
|
|
12398
|
-
const originChangedScaleY =
|
|
12493
|
+
const originChangedScaleX = target.scaleX / startBounds.scaleX;
|
|
12494
|
+
const originChangedScaleY = target.scaleY / startBounds.scaleY;
|
|
12399
12495
|
const signX = originChangedScaleX < 0 ? -1 : 1;
|
|
12400
12496
|
const signY = originChangedScaleY < 0 ? -1 : 1;
|
|
12401
12497
|
const changedScaleX = scaleMode ? originChangedScaleX : signX * boxBounds.width / width;
|
|
@@ -12471,7 +12567,7 @@ var LeaferUI = (function (exports) {
|
|
|
12471
12567
|
if (useScaleY)
|
|
12472
12568
|
scaleY /= changedScaleY;
|
|
12473
12569
|
if (!flipable) {
|
|
12474
|
-
const { worldTransform } =
|
|
12570
|
+
const { worldTransform } = target;
|
|
12475
12571
|
if (scaleX < 0)
|
|
12476
12572
|
scaleX = 1 / boxBounds.width / worldTransform.scaleX;
|
|
12477
12573
|
if (scaleY < 0)
|
|
@@ -12479,24 +12575,26 @@ var LeaferUI = (function (exports) {
|
|
|
12479
12575
|
}
|
|
12480
12576
|
toPoint(around || align, boxBounds, origin, true);
|
|
12481
12577
|
if (dragBounds) {
|
|
12482
|
-
const allowBounds = dragBounds === 'parent' ?
|
|
12483
|
-
const
|
|
12484
|
-
|
|
12485
|
-
|
|
12486
|
-
|
|
12487
|
-
|
|
12488
|
-
|
|
12489
|
-
|
|
12490
|
-
|
|
12491
|
-
|
|
12578
|
+
const allowBounds = dragBounds === 'parent' ? target.parent.boxBounds : dragBounds;
|
|
12579
|
+
const childBounds = new Bounds(target.__localBoxBounds);
|
|
12580
|
+
if (BoundsHelper.includes(new Bounds(allowBounds).spread(0.1), childBounds)) {
|
|
12581
|
+
childBounds.scaleOf(target.getLocalPointByInner(origin), scaleX, scaleY);
|
|
12582
|
+
if (!BoundsHelper.includes(allowBounds, childBounds)) {
|
|
12583
|
+
const realBounds = childBounds.getIntersect(allowBounds);
|
|
12584
|
+
const fitScaleX = realBounds.width / childBounds.width, fitScaleY = realBounds.height / childBounds.height;
|
|
12585
|
+
if (useScaleX)
|
|
12586
|
+
scaleX *= fitScaleX;
|
|
12587
|
+
if (useScaleY)
|
|
12588
|
+
scaleY *= fitScaleY;
|
|
12589
|
+
}
|
|
12492
12590
|
}
|
|
12493
12591
|
}
|
|
12494
12592
|
if (useScaleX && widthRange) {
|
|
12495
|
-
const nowWidth = boxBounds.width *
|
|
12593
|
+
const nowWidth = boxBounds.width * target.scaleX;
|
|
12496
12594
|
scaleX = within$2(nowWidth * scaleX, widthRange) / nowWidth;
|
|
12497
12595
|
}
|
|
12498
12596
|
if (useScaleY && heightRange) {
|
|
12499
|
-
const nowHeight = boxBounds.height *
|
|
12597
|
+
const nowHeight = boxBounds.height * target.scaleY;
|
|
12500
12598
|
scaleY = within$2(nowHeight * scaleY, heightRange) / nowHeight;
|
|
12501
12599
|
}
|
|
12502
12600
|
if (useScaleX && Math.abs(scaleX * worldBoxBounds.width) < 1)
|
|
@@ -12507,7 +12605,7 @@ var LeaferUI = (function (exports) {
|
|
|
12507
12605
|
scaleY = scaleX = Math.min(scaleX, scaleY);
|
|
12508
12606
|
return { origin, scaleX, scaleY, direction, lockRatio, around };
|
|
12509
12607
|
},
|
|
12510
|
-
getRotateData(
|
|
12608
|
+
getRotateData(target, direction, current, last, around) {
|
|
12511
12609
|
let align, origin = {};
|
|
12512
12610
|
switch (direction) {
|
|
12513
12611
|
case topLeft$1:
|
|
@@ -12525,8 +12623,8 @@ var LeaferUI = (function (exports) {
|
|
|
12525
12623
|
default:
|
|
12526
12624
|
align = 'center';
|
|
12527
12625
|
}
|
|
12528
|
-
toPoint(around || align,
|
|
12529
|
-
return { origin, rotation: PointHelper.getRotation(last, origin, current) };
|
|
12626
|
+
toPoint(around || align, target.boxBounds, origin, true);
|
|
12627
|
+
return { origin, rotation: PointHelper.getRotation(last, target.getWorldPointByBox(origin), current) };
|
|
12530
12628
|
},
|
|
12531
12629
|
getSkewData(bounds, direction, move, around) {
|
|
12532
12630
|
let align, origin = {}, skewX = 0, skewY = 0;
|
|
@@ -12623,9 +12721,9 @@ var LeaferUI = (function (exports) {
|
|
|
12623
12721
|
};
|
|
12624
12722
|
|
|
12625
12723
|
const cacheCursors = {};
|
|
12626
|
-
function
|
|
12627
|
-
const {
|
|
12628
|
-
if (!point || !editor.editing || !editBox.
|
|
12724
|
+
function updatePointCursor(editBox, e) {
|
|
12725
|
+
const { enterPoint: point, dragging, skewing, resizing, flippedX, flippedY } = editBox;
|
|
12726
|
+
if (!point || !editBox.editor.editing || !editBox.canUse)
|
|
12629
12727
|
return;
|
|
12630
12728
|
if (point.name === 'circle')
|
|
12631
12729
|
return;
|
|
@@ -12635,13 +12733,14 @@ var LeaferUI = (function (exports) {
|
|
|
12635
12733
|
return;
|
|
12636
12734
|
}
|
|
12637
12735
|
let { rotation } = editBox;
|
|
12638
|
-
const { resizeCursor, rotateCursor, skewCursor, resizeable, rotateable, skewable } =
|
|
12639
|
-
const { pointType } = point, { flippedX, flippedY } = editBox;
|
|
12736
|
+
const { pointType } = point, { resizeCursor, rotateCursor, skewCursor, resizeable, rotateable, skewable } = editBox.mergeConfig;
|
|
12640
12737
|
let showResize = pointType.includes('resize');
|
|
12641
12738
|
if (showResize && rotateable && (e.metaKey || e.ctrlKey || !resizeable))
|
|
12642
12739
|
showResize = false;
|
|
12643
12740
|
const showSkew = skewable && !showResize && (point.name === 'resize-line' || pointType === 'skew');
|
|
12644
|
-
const cursor =
|
|
12741
|
+
const cursor = dragging
|
|
12742
|
+
? (skewing ? skewCursor : (resizing ? resizeCursor : rotateCursor))
|
|
12743
|
+
: (showSkew ? skewCursor : (showResize ? resizeCursor : rotateCursor));
|
|
12645
12744
|
rotation += (EditDataHelper.getFlipDirection(point.direction, flippedX, flippedY) + 1) * 45;
|
|
12646
12745
|
rotation = Math.round(MathHelper.formatRotation(rotation, true) / 2) * 2;
|
|
12647
12746
|
const { url, x, y } = cursor;
|
|
@@ -12653,9 +12752,10 @@ var LeaferUI = (function (exports) {
|
|
|
12653
12752
|
cacheCursors[key] = point.cursor = { url: toDataURL(url, rotation), x, y };
|
|
12654
12753
|
}
|
|
12655
12754
|
}
|
|
12656
|
-
function updateMoveCursor(
|
|
12657
|
-
const { moveCursor, moveable } =
|
|
12658
|
-
|
|
12755
|
+
function updateMoveCursor(editBox) {
|
|
12756
|
+
const { moveCursor, moveable } = editBox.mergeConfig;
|
|
12757
|
+
if (editBox.canUse)
|
|
12758
|
+
editBox.rect.cursor = moveable ? moveCursor : undefined;
|
|
12659
12759
|
}
|
|
12660
12760
|
function toDataURL(svg, rotation) {
|
|
12661
12761
|
return '"data:image/svg+xml,' + encodeURIComponent(svg.replace('{{rotation}}', rotation.toString())) + '"';
|
|
@@ -12670,10 +12770,26 @@ var LeaferUI = (function (exports) {
|
|
|
12670
12770
|
|
|
12671
12771
|
const fourDirection = ['top', 'right', 'bottom', 'left'], editConfig = undefined;
|
|
12672
12772
|
class EditBox extends exports.Group {
|
|
12773
|
+
get mergeConfig() {
|
|
12774
|
+
const { config } = this, { mergeConfig, editBox } = this.editor;
|
|
12775
|
+
return this.mergedConfig = config && (editBox !== this) ? Object.assign(Object.assign({}, mergeConfig), config) : mergeConfig;
|
|
12776
|
+
}
|
|
12777
|
+
get target() { return this._target || this.editor.element; }
|
|
12778
|
+
set target(target) { this._target = target; }
|
|
12779
|
+
get single() { return !!this._target || this.editor.single; }
|
|
12780
|
+
get transformTool() { return this._transformTool || this.editor; }
|
|
12781
|
+
set transformTool(tool) { this._transformTool = tool; }
|
|
12673
12782
|
get flipped() { return this.flippedX || this.flippedY; }
|
|
12674
12783
|
get flippedX() { return this.scaleX < 0; }
|
|
12675
12784
|
get flippedY() { return this.scaleY < 0; }
|
|
12676
12785
|
get flippedOne() { return this.scaleX * this.scaleY < 0; }
|
|
12786
|
+
get canUse() { return (this.visible && this.view.visible); }
|
|
12787
|
+
get canGesture() {
|
|
12788
|
+
if (!this.canUse)
|
|
12789
|
+
return false;
|
|
12790
|
+
const { moveable, resizeable, rotateable } = this.mergeConfig;
|
|
12791
|
+
return typeof moveable === 'string' || typeof resizeable === 'string' || typeof rotateable === 'string';
|
|
12792
|
+
}
|
|
12677
12793
|
constructor(editor) {
|
|
12678
12794
|
super();
|
|
12679
12795
|
this.view = new exports.Group();
|
|
@@ -12712,8 +12828,7 @@ var LeaferUI = (function (exports) {
|
|
|
12712
12828
|
this.add(view);
|
|
12713
12829
|
}
|
|
12714
12830
|
load() {
|
|
12715
|
-
const {
|
|
12716
|
-
const { rect, circle, resizePoints } = this;
|
|
12831
|
+
const { target, mergeConfig, single, rect, circle, resizePoints } = this;
|
|
12717
12832
|
const { stroke, strokeWidth } = mergeConfig;
|
|
12718
12833
|
const pointsStyle = this.getPointsStyle();
|
|
12719
12834
|
const middlePointsStyle = this.getMiddlePointsStyle();
|
|
@@ -12721,24 +12836,38 @@ var LeaferUI = (function (exports) {
|
|
|
12721
12836
|
for (let i = 0; i < 8; i++) {
|
|
12722
12837
|
resizeP = resizePoints[i];
|
|
12723
12838
|
resizeP.set(this.getPointStyle((i % 2) ? middlePointsStyle[((i - 1) / 2) % middlePointsStyle.length] : pointsStyle[(i / 2) % pointsStyle.length]));
|
|
12724
|
-
|
|
12725
|
-
resizeP.rotation = (i / 2) * 90;
|
|
12839
|
+
resizeP.rotation = ((i - (i % 2 ? 1 : 0)) / 2) * 90;
|
|
12726
12840
|
}
|
|
12727
12841
|
circle.set(this.getPointStyle(mergeConfig.circle || mergeConfig.rotatePoint || pointsStyle[0]));
|
|
12728
12842
|
rect.set(Object.assign({ stroke, strokeWidth, editConfig }, (mergeConfig.rect || {})));
|
|
12729
|
-
|
|
12730
|
-
rect.
|
|
12731
|
-
|
|
12732
|
-
|
|
12733
|
-
|
|
12734
|
-
|
|
12735
|
-
|
|
12736
|
-
|
|
12737
|
-
|
|
12738
|
-
|
|
12739
|
-
const {
|
|
12740
|
-
this.
|
|
12843
|
+
const syncEventer = single && this.transformTool.editTool;
|
|
12844
|
+
rect.hittable = !syncEventer;
|
|
12845
|
+
rect.syncEventer = syncEventer && this.editor;
|
|
12846
|
+
if (syncEventer) {
|
|
12847
|
+
target.syncEventer = rect;
|
|
12848
|
+
this.app.interaction.bottomList = [{ target: rect, proxy: target }];
|
|
12849
|
+
}
|
|
12850
|
+
updateMoveCursor(this);
|
|
12851
|
+
}
|
|
12852
|
+
update() {
|
|
12853
|
+
const { editor } = this;
|
|
12854
|
+
const { x, y, scaleX, scaleY, rotation, skewX, skewY, width, height } = this.target.getLayoutBounds('box', editor, true);
|
|
12855
|
+
this.set({ x, y, scaleX, scaleY, rotation, skewX, skewY });
|
|
12856
|
+
this.updateBounds({ x: 0, y: 0, width, height });
|
|
12857
|
+
}
|
|
12858
|
+
unload() {
|
|
12859
|
+
this.visible = false;
|
|
12860
|
+
if (this.app)
|
|
12861
|
+
this.rect.syncEventer = this.app.interaction.bottomList = null;
|
|
12862
|
+
}
|
|
12863
|
+
updateBounds(bounds) {
|
|
12864
|
+
const { editMask } = this.editor;
|
|
12865
|
+
const { mergeConfig, single, rect, circle, buttons, resizePoints, rotatePoints, resizeLines } = this;
|
|
12866
|
+
const { middlePoint, resizeable, rotateable, hideOnSmall, editBox, mask, spread } = mergeConfig;
|
|
12867
|
+
this.visible = !this.target.locked;
|
|
12741
12868
|
editMask.visible = mask ? true : 0;
|
|
12869
|
+
if (spread)
|
|
12870
|
+
BoundsHelper.spread(bounds, spread);
|
|
12742
12871
|
if (this.view.worldOpacity) {
|
|
12743
12872
|
const { width, height } = bounds;
|
|
12744
12873
|
const smallSize = typeof hideOnSmall === 'number' ? hideOnSmall : 10;
|
|
@@ -12763,7 +12892,6 @@ var LeaferUI = (function (exports) {
|
|
|
12763
12892
|
}
|
|
12764
12893
|
else {
|
|
12765
12894
|
resizeL.height = height;
|
|
12766
|
-
resizeP.rotation = 90;
|
|
12767
12895
|
if (hideOnSmall && resizeP.width * 2 > height)
|
|
12768
12896
|
resizeP.visible = false;
|
|
12769
12897
|
}
|
|
@@ -12771,25 +12899,25 @@ var LeaferUI = (function (exports) {
|
|
|
12771
12899
|
}
|
|
12772
12900
|
circle.visible = showPoints && rotateable && !!(mergeConfig.circle || mergeConfig.rotatePoint);
|
|
12773
12901
|
if (circle.visible)
|
|
12774
|
-
this.layoutCircle(
|
|
12902
|
+
this.layoutCircle();
|
|
12775
12903
|
if (rect.path)
|
|
12776
12904
|
rect.path = null;
|
|
12777
|
-
rect.set(Object.assign(Object.assign({}, bounds), { visible:
|
|
12905
|
+
rect.set(Object.assign(Object.assign({}, bounds), { visible: single ? editBox : true }));
|
|
12778
12906
|
buttons.visible = showPoints && buttons.children.length > 0 || 0;
|
|
12779
12907
|
if (buttons.visible)
|
|
12780
|
-
this.layoutButtons(
|
|
12908
|
+
this.layoutButtons();
|
|
12781
12909
|
}
|
|
12782
12910
|
else
|
|
12783
12911
|
rect.set(bounds);
|
|
12784
12912
|
}
|
|
12785
|
-
layoutCircle(
|
|
12786
|
-
const { circleDirection, circleMargin, buttonsMargin, buttonsDirection, middlePoint } =
|
|
12913
|
+
layoutCircle() {
|
|
12914
|
+
const { circleDirection, circleMargin, buttonsMargin, buttonsDirection, middlePoint } = this.mergedConfig;
|
|
12787
12915
|
const direction = fourDirection.indexOf(circleDirection || ((this.buttons.children.length && buttonsDirection === 'bottom') ? 'top' : 'bottom'));
|
|
12788
12916
|
this.setButtonPosition(this.circle, direction, circleMargin || buttonsMargin, !!middlePoint);
|
|
12789
12917
|
}
|
|
12790
|
-
layoutButtons(
|
|
12918
|
+
layoutButtons() {
|
|
12791
12919
|
const { buttons } = this;
|
|
12792
|
-
const { buttonsDirection, buttonsFixed, buttonsMargin, middlePoint } =
|
|
12920
|
+
const { buttonsDirection, buttonsFixed, buttonsMargin, middlePoint } = this.mergedConfig;
|
|
12793
12921
|
const { flippedX, flippedY } = this;
|
|
12794
12922
|
let index = fourDirection.indexOf(buttonsDirection);
|
|
12795
12923
|
if ((index % 2 && flippedX) || ((index + 1) % 2 && flippedY)) {
|
|
@@ -12818,49 +12946,51 @@ var LeaferUI = (function (exports) {
|
|
|
12818
12946
|
buttons.y = point.y + margin;
|
|
12819
12947
|
}
|
|
12820
12948
|
}
|
|
12821
|
-
unload() {
|
|
12822
|
-
this.visible = false;
|
|
12823
|
-
}
|
|
12824
12949
|
getPointStyle(userStyle) {
|
|
12825
|
-
const { stroke, strokeWidth, pointFill, pointSize, pointRadius } = this.
|
|
12950
|
+
const { stroke, strokeWidth, pointFill, pointSize, pointRadius } = this.mergedConfig;
|
|
12826
12951
|
const defaultStyle = { fill: pointFill, stroke, strokeWidth, around: 'center', strokeAlign: 'center', width: pointSize, height: pointSize, cornerRadius: pointRadius, offsetX: 0, offsetY: 0, editConfig };
|
|
12827
12952
|
return userStyle ? Object.assign(defaultStyle, userStyle) : defaultStyle;
|
|
12828
12953
|
}
|
|
12829
12954
|
getPointsStyle() {
|
|
12830
|
-
const { point } = this.
|
|
12955
|
+
const { point } = this.mergedConfig;
|
|
12831
12956
|
return point instanceof Array ? point : [point];
|
|
12832
12957
|
}
|
|
12833
12958
|
getMiddlePointsStyle() {
|
|
12834
|
-
const { middlePoint } = this.
|
|
12959
|
+
const { middlePoint } = this.mergedConfig;
|
|
12835
12960
|
return middlePoint instanceof Array ? middlePoint : (middlePoint ? [middlePoint] : this.getPointsStyle());
|
|
12836
12961
|
}
|
|
12837
|
-
onSelect(e) {
|
|
12838
|
-
if (e.oldList.length === 1) {
|
|
12839
|
-
e.oldList[0].syncEventer = null;
|
|
12840
|
-
if (this.app)
|
|
12841
|
-
this.app.interaction.bottomList = null;
|
|
12842
|
-
}
|
|
12843
|
-
}
|
|
12844
12962
|
onDragStart(e) {
|
|
12845
12963
|
this.dragging = true;
|
|
12846
12964
|
const point = this.dragPoint = e.current, { pointType } = point;
|
|
12847
|
-
const { editor, dragStartData } = this, {
|
|
12965
|
+
const { editor, dragStartData } = this, { target } = this, { moveable, resizeable, rotateable, skewable, hideOnMove } = this.mergeConfig;
|
|
12848
12966
|
if (point.name === 'rect') {
|
|
12849
|
-
this.moving = true;
|
|
12850
|
-
editor.opacity =
|
|
12967
|
+
moveable && (this.moving = true);
|
|
12968
|
+
editor.opacity = hideOnMove ? 0 : 1;
|
|
12969
|
+
}
|
|
12970
|
+
else {
|
|
12971
|
+
if (pointType.includes('rotate') || e.metaKey || e.ctrlKey || !resizeable) {
|
|
12972
|
+
rotateable && (this.rotating = true);
|
|
12973
|
+
if (pointType === 'resize-rotate')
|
|
12974
|
+
resizeable && (this.resizing = true);
|
|
12975
|
+
else if (point.name === 'resize-line')
|
|
12976
|
+
skewable && (this.skewing = true), this.rotating = false;
|
|
12977
|
+
}
|
|
12978
|
+
else if (pointType === 'resize')
|
|
12979
|
+
resizeable && (this.resizing = true);
|
|
12980
|
+
if (pointType === 'skew')
|
|
12981
|
+
skewable && (this.skewing = true);
|
|
12851
12982
|
}
|
|
12852
12983
|
dragStartData.x = e.x;
|
|
12853
12984
|
dragStartData.y = e.y;
|
|
12854
|
-
dragStartData.point = { x:
|
|
12855
|
-
dragStartData.bounds = Object.assign({},
|
|
12856
|
-
dragStartData.rotation =
|
|
12985
|
+
dragStartData.point = { x: target.x, y: target.y };
|
|
12986
|
+
dragStartData.bounds = Object.assign({}, target.getLayoutBounds('box', 'local'));
|
|
12987
|
+
dragStartData.rotation = target.rotation;
|
|
12857
12988
|
if (pointType && pointType.includes('resize'))
|
|
12858
12989
|
ResizeEvent.resizingKeys = editor.leafList.keys;
|
|
12859
12990
|
}
|
|
12860
12991
|
onDragEnd(e) {
|
|
12861
|
-
this.dragging = false;
|
|
12862
12992
|
this.dragPoint = null;
|
|
12863
|
-
this.
|
|
12993
|
+
this.resetDoing();
|
|
12864
12994
|
const { name, pointType } = e.current;
|
|
12865
12995
|
if (name === 'rect')
|
|
12866
12996
|
this.editor.opacity = 1;
|
|
@@ -12868,22 +12998,61 @@ var LeaferUI = (function (exports) {
|
|
|
12868
12998
|
ResizeEvent.resizingKeys = null;
|
|
12869
12999
|
}
|
|
12870
13000
|
onDrag(e) {
|
|
12871
|
-
const {
|
|
12872
|
-
|
|
12873
|
-
|
|
12874
|
-
|
|
12875
|
-
|
|
12876
|
-
|
|
12877
|
-
|
|
12878
|
-
|
|
12879
|
-
|
|
12880
|
-
|
|
12881
|
-
|
|
12882
|
-
|
|
13001
|
+
const { transformTool, moving, resizing, rotating, skewing } = this;
|
|
13002
|
+
if (moving) {
|
|
13003
|
+
transformTool.onMove(e);
|
|
13004
|
+
updateMoveCursor(this);
|
|
13005
|
+
}
|
|
13006
|
+
else if (resizing || rotating || skewing) {
|
|
13007
|
+
const point = e.current;
|
|
13008
|
+
if (point.pointType)
|
|
13009
|
+
this.enterPoint = point;
|
|
13010
|
+
if (rotating)
|
|
13011
|
+
transformTool.onRotate(e);
|
|
13012
|
+
if (resizing)
|
|
13013
|
+
transformTool.onScale(e);
|
|
13014
|
+
if (skewing)
|
|
13015
|
+
transformTool.onSkew(e);
|
|
13016
|
+
updatePointCursor(this, e);
|
|
13017
|
+
}
|
|
13018
|
+
}
|
|
13019
|
+
resetDoing() {
|
|
13020
|
+
if (this.canUse)
|
|
13021
|
+
this.dragging = this.gesturing = this.moving = this.resizing = this.rotating = this.skewing = false;
|
|
13022
|
+
}
|
|
13023
|
+
onMove(e) {
|
|
13024
|
+
if (this.canGesture && e.moveType !== 'drag') {
|
|
13025
|
+
e.stop();
|
|
13026
|
+
if (typeof this.mergeConfig.moveable === 'string') {
|
|
13027
|
+
this.gesturing = this.moving = true;
|
|
13028
|
+
this.transformTool.onMove(e);
|
|
13029
|
+
}
|
|
13030
|
+
}
|
|
13031
|
+
}
|
|
13032
|
+
onScale(e) {
|
|
13033
|
+
if (this.canGesture) {
|
|
13034
|
+
e.stop();
|
|
13035
|
+
if (typeof this.mergeConfig.resizeable === 'string') {
|
|
13036
|
+
this.gesturing = this.resizing = true;
|
|
13037
|
+
this.transformTool.onScale(e);
|
|
13038
|
+
}
|
|
13039
|
+
}
|
|
13040
|
+
}
|
|
13041
|
+
onRotate(e) {
|
|
13042
|
+
if (this.canGesture) {
|
|
13043
|
+
e.stop();
|
|
13044
|
+
if (typeof this.mergeConfig.rotateable === 'string') {
|
|
13045
|
+
this.gesturing = this.rotating = true;
|
|
13046
|
+
this.transformTool.onRotate(e);
|
|
13047
|
+
}
|
|
13048
|
+
}
|
|
13049
|
+
}
|
|
13050
|
+
onKey(e) {
|
|
13051
|
+
updatePointCursor(this, e);
|
|
12883
13052
|
}
|
|
12884
13053
|
onArrow(e) {
|
|
12885
|
-
const { editor } = this;
|
|
12886
|
-
if (editor.editing &&
|
|
13054
|
+
const { editor, transformTool } = this;
|
|
13055
|
+
if (this.canUse && editor.editing && this.mergeConfig.keyEvent) {
|
|
12887
13056
|
let x = 0, y = 0;
|
|
12888
13057
|
const distance = e.shiftKey ? 10 : 1;
|
|
12889
13058
|
switch (e.code) {
|
|
@@ -12900,31 +13069,32 @@ var LeaferUI = (function (exports) {
|
|
|
12900
13069
|
x = distance;
|
|
12901
13070
|
}
|
|
12902
13071
|
if (x || y)
|
|
12903
|
-
|
|
13072
|
+
transformTool.move(x, y);
|
|
12904
13073
|
}
|
|
12905
13074
|
}
|
|
12906
13075
|
onDoubleTap(e) {
|
|
12907
|
-
|
|
13076
|
+
const { openInner, preventEditInner } = this.mergeConfig;
|
|
13077
|
+
if (openInner === 'double' && !preventEditInner)
|
|
12908
13078
|
this.openInner(e);
|
|
12909
13079
|
}
|
|
12910
13080
|
onLongPress(e) {
|
|
12911
|
-
|
|
13081
|
+
const { openInner, preventEditInner } = this.mergeConfig;
|
|
13082
|
+
if (openInner === 'long' && preventEditInner)
|
|
12912
13083
|
this.openInner(e);
|
|
12913
13084
|
}
|
|
12914
13085
|
openInner(e) {
|
|
12915
|
-
const { editor } = this;
|
|
12916
|
-
if (
|
|
12917
|
-
|
|
12918
|
-
if (element.locked)
|
|
13086
|
+
const { editor, target } = this;
|
|
13087
|
+
if (this.single) {
|
|
13088
|
+
if (target.locked)
|
|
12919
13089
|
return;
|
|
12920
|
-
if (
|
|
12921
|
-
if (
|
|
12922
|
-
const { children } =
|
|
13090
|
+
if (target.isBranch && !target.editInner) {
|
|
13091
|
+
if (target.textBox) {
|
|
13092
|
+
const { children } = target;
|
|
12923
13093
|
const find = children.find(item => item.editable && item instanceof exports.Text) || children.find(item => item instanceof exports.Text);
|
|
12924
13094
|
if (find)
|
|
12925
13095
|
return editor.openInnerEditor(find);
|
|
12926
13096
|
}
|
|
12927
|
-
editor.openGroup(
|
|
13097
|
+
editor.openGroup(target);
|
|
12928
13098
|
editor.target = editor.selector.findDeepOne(e);
|
|
12929
13099
|
}
|
|
12930
13100
|
else {
|
|
@@ -12933,7 +13103,6 @@ var LeaferUI = (function (exports) {
|
|
|
12933
13103
|
}
|
|
12934
13104
|
}
|
|
12935
13105
|
listenPointEvents(point, type, direction) {
|
|
12936
|
-
const { editor } = this;
|
|
12937
13106
|
point.direction = direction;
|
|
12938
13107
|
point.pointType = type;
|
|
12939
13108
|
const events = [
|
|
@@ -12943,19 +13112,31 @@ var LeaferUI = (function (exports) {
|
|
|
12943
13112
|
[exports.PointerEvent.LEAVE, () => { this.enterPoint = null; }],
|
|
12944
13113
|
];
|
|
12945
13114
|
if (point.name !== 'circle')
|
|
12946
|
-
events.push([exports.PointerEvent.ENTER, (e) => { this.enterPoint = point,
|
|
13115
|
+
events.push([exports.PointerEvent.ENTER, (e) => { this.enterPoint = point, updatePointCursor(this, e); }]);
|
|
12947
13116
|
this.__eventIds.push(point.on_(events));
|
|
12948
13117
|
}
|
|
12949
13118
|
__listenEvents() {
|
|
12950
|
-
const { rect, editor } = this;
|
|
12951
|
-
|
|
13119
|
+
const { rect, editor, __eventIds: events } = this;
|
|
13120
|
+
events.push(rect.on_([
|
|
12952
13121
|
[exports.DragEvent.START, this.onDragStart, this],
|
|
12953
|
-
[exports.DragEvent.DRAG,
|
|
13122
|
+
[exports.DragEvent.DRAG, this.onDrag, this],
|
|
12954
13123
|
[exports.DragEvent.END, this.onDragEnd, this],
|
|
12955
|
-
[exports.PointerEvent.ENTER, () => updateMoveCursor(
|
|
13124
|
+
[exports.PointerEvent.ENTER, () => updateMoveCursor(this)],
|
|
12956
13125
|
[exports.PointerEvent.DOUBLE_TAP, this.onDoubleTap, this],
|
|
12957
13126
|
[exports.PointerEvent.LONG_PRESS, this.onLongPress, this]
|
|
12958
13127
|
]));
|
|
13128
|
+
this.waitLeafer(() => {
|
|
13129
|
+
events.push(editor.app.on_([
|
|
13130
|
+
[[exports.KeyEvent.HOLD, exports.KeyEvent.UP], this.onKey, this],
|
|
13131
|
+
[exports.KeyEvent.DOWN, this.onArrow, this],
|
|
13132
|
+
[exports.MoveEvent.BEFORE_MOVE, this.onMove, this, true],
|
|
13133
|
+
[exports.ZoomEvent.BEFORE_ZOOM, this.onScale, this, true],
|
|
13134
|
+
[exports.RotateEvent.BEFORE_ROTATE, this.onRotate, this, true],
|
|
13135
|
+
[exports.MoveEvent.END, this.resetDoing, this],
|
|
13136
|
+
[exports.ZoomEvent.END, this.resetDoing, this],
|
|
13137
|
+
[exports.RotateEvent.END, this.resetDoing, this],
|
|
13138
|
+
]));
|
|
13139
|
+
});
|
|
12959
13140
|
}
|
|
12960
13141
|
__removeListenEvents() {
|
|
12961
13142
|
this.off_(this.__eventIds);
|
|
@@ -12986,11 +13167,12 @@ var LeaferUI = (function (exports) {
|
|
|
12986
13167
|
if (options.bounds && !options.bounds.hit(editor.editBox.rect.__world, options.matrix))
|
|
12987
13168
|
return;
|
|
12988
13169
|
canvas.saveBlendMode('destination-out');
|
|
13170
|
+
options = Object.assign(Object.assign({}, options), { shape: true });
|
|
12989
13171
|
editor.list.forEach(item => {
|
|
12990
|
-
item.
|
|
12991
|
-
const {
|
|
12992
|
-
if (
|
|
12993
|
-
|
|
13172
|
+
item.__render(canvas, options);
|
|
13173
|
+
const { parent } = item;
|
|
13174
|
+
if (parent && parent.textBox)
|
|
13175
|
+
parent.__renderShape(canvas, options);
|
|
12994
13176
|
});
|
|
12995
13177
|
canvas.restoreBlendMode();
|
|
12996
13178
|
}
|
|
@@ -13085,7 +13267,7 @@ ${filterStyle$1}
|
|
|
13085
13267
|
const bounds$1 = new Bounds();
|
|
13086
13268
|
function simulate(editor) {
|
|
13087
13269
|
const { simulateTarget, list } = editor;
|
|
13088
|
-
const { zoomLayer } = list[0].leafer
|
|
13270
|
+
const { zoomLayer } = list[0].leafer;
|
|
13089
13271
|
simulateTarget.safeChange(() => {
|
|
13090
13272
|
bounds$1.setListWithFn(list, (leaf) => leaf.getBounds('box', 'page'));
|
|
13091
13273
|
if (bounds$1.width === 0)
|
|
@@ -13107,15 +13289,15 @@ ${filterStyle$1}
|
|
|
13107
13289
|
else {
|
|
13108
13290
|
editor.simulateTarget.remove();
|
|
13109
13291
|
editor.leafList.reset();
|
|
13110
|
-
editor.closeInnerEditor();
|
|
13111
13292
|
}
|
|
13112
|
-
editor.
|
|
13293
|
+
editor.closeInnerEditor(true);
|
|
13294
|
+
editor.unloadEditTool();
|
|
13295
|
+
const data = { editor, value: target, oldValue };
|
|
13296
|
+
editor.emitEvent(new EditorEvent(EditorEvent.SELECT, data));
|
|
13113
13297
|
editor.checkOpenedGroups();
|
|
13114
13298
|
if (editor.editing) {
|
|
13115
13299
|
editor.waitLeafer(() => {
|
|
13116
|
-
updateMoveCursor(editor);
|
|
13117
13300
|
editor.updateEditTool();
|
|
13118
|
-
editor.update();
|
|
13119
13301
|
editor.listenTargetEvents();
|
|
13120
13302
|
});
|
|
13121
13303
|
}
|
|
@@ -13123,6 +13305,7 @@ ${filterStyle$1}
|
|
|
13123
13305
|
editor.updateEditTool();
|
|
13124
13306
|
editor.removeTargetEvents();
|
|
13125
13307
|
}
|
|
13308
|
+
editor.emitEvent(new EditorEvent(EditorEvent.AFTER_SELECT, data));
|
|
13126
13309
|
}
|
|
13127
13310
|
function onHover(editor, oldValue) {
|
|
13128
13311
|
editor.emitEvent(new EditorEvent(EditorEvent.HOVER, { editor, value: editor.hoverTarget, oldValue }));
|
|
@@ -13294,98 +13477,44 @@ ${filterStyle$1}
|
|
|
13294
13477
|
}
|
|
13295
13478
|
}
|
|
13296
13479
|
|
|
13297
|
-
class
|
|
13298
|
-
|
|
13299
|
-
|
|
13300
|
-
get editing() { return !!this.list.length; }
|
|
13301
|
-
get groupOpening() { return !!this.openedGroupList.length; }
|
|
13302
|
-
get multiple() { return this.list.length > 1; }
|
|
13303
|
-
get single() { return this.list.length === 1; }
|
|
13304
|
-
get dragging() { return this.editBox.dragging; }
|
|
13305
|
-
get moving() { return this.editBox.moving; }
|
|
13306
|
-
get dragPoint() { return this.editBox.dragPoint; }
|
|
13307
|
-
get element() { return this.multiple ? this.simulateTarget : this.list[0]; }
|
|
13308
|
-
get buttons() { return this.editBox.buttons; }
|
|
13309
|
-
constructor(userConfig, data) {
|
|
13310
|
-
super(data);
|
|
13311
|
-
this.leafList = new LeafList();
|
|
13312
|
-
this.openedGroupList = new LeafList();
|
|
13313
|
-
this.simulateTarget = new SimulateElement(this);
|
|
13314
|
-
this.editBox = new EditBox(this);
|
|
13315
|
-
this.editToolList = {};
|
|
13316
|
-
this.selector = new EditSelect(this);
|
|
13317
|
-
this.editMask = new EditMask(this);
|
|
13318
|
-
this.targetEventIds = [];
|
|
13319
|
-
let mergedConfig = DataHelper.clone(config);
|
|
13320
|
-
if (userConfig)
|
|
13321
|
-
mergedConfig = DataHelper.default(userConfig, mergedConfig);
|
|
13322
|
-
this.mergedConfig = this.config = mergedConfig;
|
|
13323
|
-
this.addMany(this.editMask, this.selector, this.editBox);
|
|
13324
|
-
if (!Plugin.has('resize'))
|
|
13325
|
-
this.config.editSize = 'scale';
|
|
13326
|
-
}
|
|
13327
|
-
select(target) {
|
|
13328
|
-
this.target = target;
|
|
13329
|
-
}
|
|
13330
|
-
cancel() {
|
|
13331
|
-
this.target = null;
|
|
13332
|
-
}
|
|
13333
|
-
hasItem(item) {
|
|
13334
|
-
return this.leafList.has(item);
|
|
13335
|
-
}
|
|
13336
|
-
addItem(item) {
|
|
13337
|
-
if (!this.hasItem(item) && !item.locked)
|
|
13338
|
-
this.leafList.add(item), this.target = this.leafList.list;
|
|
13339
|
-
}
|
|
13340
|
-
removeItem(item) {
|
|
13341
|
-
if (this.hasItem(item))
|
|
13342
|
-
this.leafList.remove(item), this.target = this.leafList.list;
|
|
13343
|
-
}
|
|
13344
|
-
shiftItem(item) {
|
|
13345
|
-
this.hasItem(item) ? this.removeItem(item) : this.addItem(item);
|
|
13346
|
-
}
|
|
13347
|
-
update() {
|
|
13348
|
-
if (this.editing) {
|
|
13349
|
-
if (!this.element.parent)
|
|
13350
|
-
return this.cancel();
|
|
13351
|
-
if (this.innerEditing)
|
|
13352
|
-
this.innerEditor.update();
|
|
13353
|
-
this.editTool.update();
|
|
13354
|
-
this.selector.update();
|
|
13355
|
-
}
|
|
13480
|
+
class EditorMoveEvent extends EditorEvent {
|
|
13481
|
+
constructor(type, data) {
|
|
13482
|
+
super(type, data);
|
|
13356
13483
|
}
|
|
13357
|
-
|
|
13358
|
-
|
|
13359
|
-
|
|
13360
|
-
|
|
13484
|
+
}
|
|
13485
|
+
EditorMoveEvent.BEFORE_MOVE = 'editor.before_move';
|
|
13486
|
+
EditorMoveEvent.MOVE = 'editor.move';
|
|
13487
|
+
|
|
13488
|
+
class EditorScaleEvent extends EditorEvent {
|
|
13489
|
+
constructor(type, data) {
|
|
13490
|
+
super(type, data);
|
|
13361
13491
|
}
|
|
13362
|
-
|
|
13363
|
-
|
|
13364
|
-
|
|
13365
|
-
|
|
13366
|
-
|
|
13367
|
-
|
|
13368
|
-
|
|
13369
|
-
if (this.editing) {
|
|
13370
|
-
const tag = this.single ? this.list[0].editOuter : 'EditTool';
|
|
13371
|
-
this.editTool = this.editToolList[tag] = this.editToolList[tag] || EditToolCreator.get(tag, this);
|
|
13372
|
-
this.editBox.load();
|
|
13373
|
-
this.editTool.load();
|
|
13374
|
-
}
|
|
13492
|
+
}
|
|
13493
|
+
EditorScaleEvent.BEFORE_SCALE = 'editor.before_scale';
|
|
13494
|
+
EditorScaleEvent.SCALE = 'editor.scale';
|
|
13495
|
+
|
|
13496
|
+
class EditorRotateEvent extends EditorEvent {
|
|
13497
|
+
constructor(type, data) {
|
|
13498
|
+
super(type, data);
|
|
13375
13499
|
}
|
|
13376
|
-
|
|
13377
|
-
|
|
13500
|
+
}
|
|
13501
|
+
EditorRotateEvent.BEFORE_ROTATE = 'editor.before_rotate';
|
|
13502
|
+
EditorRotateEvent.ROTATE = 'editor.rotate';
|
|
13503
|
+
|
|
13504
|
+
class EditorSkewEvent extends EditorEvent {
|
|
13505
|
+
constructor(type, data) {
|
|
13506
|
+
super(type, data);
|
|
13378
13507
|
}
|
|
13508
|
+
}
|
|
13509
|
+
EditorSkewEvent.BEFORE_SKEW = 'editor.before_skew';
|
|
13510
|
+
EditorSkewEvent.SKEW = 'editor.skew';
|
|
13511
|
+
|
|
13512
|
+
class TransformTool {
|
|
13379
13513
|
onMove(e) {
|
|
13514
|
+
const { target, dragStartData } = this.editBox;
|
|
13380
13515
|
if (e instanceof exports.MoveEvent) {
|
|
13381
|
-
|
|
13382
|
-
|
|
13383
|
-
const move = e.getLocalMove(this.element);
|
|
13384
|
-
if (moveable === 'move')
|
|
13385
|
-
e.stop(), this.move(move.x, move.y);
|
|
13386
|
-
else if (resizeable === 'zoom')
|
|
13387
|
-
e.stop();
|
|
13388
|
-
}
|
|
13516
|
+
const move = e.getLocalMove(target);
|
|
13517
|
+
this.move(move.x, move.y);
|
|
13389
13518
|
}
|
|
13390
13519
|
else {
|
|
13391
13520
|
const total = { x: e.totalX, y: e.totalY };
|
|
@@ -13395,22 +13524,21 @@ ${filterStyle$1}
|
|
|
13395
13524
|
else
|
|
13396
13525
|
total.x = 0;
|
|
13397
13526
|
}
|
|
13398
|
-
this.move(exports.DragEvent.getValidMove(
|
|
13527
|
+
this.move(exports.DragEvent.getValidMove(target, dragStartData.point, total));
|
|
13399
13528
|
}
|
|
13400
13529
|
}
|
|
13401
13530
|
onScale(e) {
|
|
13402
|
-
const {
|
|
13403
|
-
let { around, lockRatio,
|
|
13531
|
+
const { target, mergeConfig, single, dragStartData } = this.editBox;
|
|
13532
|
+
let { around, lockRatio, flipable, editSize } = mergeConfig;
|
|
13404
13533
|
if (e instanceof exports.ZoomEvent) {
|
|
13405
|
-
|
|
13406
|
-
e.stop(), this.scaleOf(element.getBoxPoint(e), e.scale, e.scale);
|
|
13534
|
+
this.scaleOf(target.getBoxPoint(e), e.scale, e.scale);
|
|
13407
13535
|
}
|
|
13408
13536
|
else {
|
|
13409
13537
|
const { direction } = e.current;
|
|
13410
|
-
if (e.shiftKey ||
|
|
13538
|
+
if (e.shiftKey || target.lockRatio)
|
|
13411
13539
|
lockRatio = true;
|
|
13412
|
-
const data = EditDataHelper.getScaleData(
|
|
13413
|
-
if (this.editTool.onScaleWithDrag) {
|
|
13540
|
+
const data = EditDataHelper.getScaleData(target, dragStartData.bounds, direction, e.getInnerTotal(target), lockRatio, EditDataHelper.getAround(around, e.altKey), flipable, !single || editSize === 'scale');
|
|
13541
|
+
if (this.editTool && this.editTool.onScaleWithDrag) {
|
|
13414
13542
|
data.drag = e;
|
|
13415
13543
|
this.scaleWithDrag(data);
|
|
13416
13544
|
}
|
|
@@ -13420,38 +13548,28 @@ ${filterStyle$1}
|
|
|
13420
13548
|
}
|
|
13421
13549
|
}
|
|
13422
13550
|
onRotate(e) {
|
|
13423
|
-
const {
|
|
13424
|
-
const {
|
|
13425
|
-
|
|
13426
|
-
return this.onSkew(e);
|
|
13427
|
-
const { element } = this, { dragStartData } = this.editBox;
|
|
13551
|
+
const { target, mergeConfig, dragStartData } = this.editBox;
|
|
13552
|
+
const { around, rotateAround, rotateGap } = mergeConfig;
|
|
13553
|
+
const { direction } = e.current;
|
|
13428
13554
|
let origin, rotation;
|
|
13429
13555
|
if (e instanceof exports.RotateEvent) {
|
|
13430
|
-
|
|
13431
|
-
|
|
13432
|
-
else
|
|
13433
|
-
return;
|
|
13434
|
-
if (element.scaleX * element.scaleY < 0)
|
|
13435
|
-
rotation = -rotation;
|
|
13556
|
+
rotation = e.rotation;
|
|
13557
|
+
origin = rotateAround ? AroundHelper.getPoint(rotateAround, target.boxBounds) : target.getBoxPoint(e);
|
|
13436
13558
|
}
|
|
13437
13559
|
else {
|
|
13438
|
-
const data = EditDataHelper.getRotateData(
|
|
13439
|
-
rotation = data.rotation;
|
|
13560
|
+
const data = EditDataHelper.getRotateData(target, direction, e, dragStartData, e.shiftKey ? null : (rotateAround || target.around || target.origin || around || 'center'));
|
|
13561
|
+
rotation = dragStartData.rotation + data.rotation - target.rotation;
|
|
13440
13562
|
origin = data.origin;
|
|
13441
13563
|
}
|
|
13442
|
-
|
|
13443
|
-
rotation = -rotation;
|
|
13444
|
-
if (e instanceof exports.DragEvent)
|
|
13445
|
-
rotation = dragStartData.rotation + rotation - element.rotation;
|
|
13446
|
-
rotation = MathHelper.float(MathHelper.getGapRotation(rotation, rotateGap, element.rotation), 2);
|
|
13564
|
+
rotation = MathHelper.float(MathHelper.getGapRotation(rotation, rotateGap, target.rotation), 2);
|
|
13447
13565
|
if (!rotation)
|
|
13448
13566
|
return;
|
|
13449
13567
|
this.rotateOf(origin, rotation);
|
|
13450
13568
|
}
|
|
13451
13569
|
onSkew(e) {
|
|
13452
|
-
const {
|
|
13453
|
-
const { around } =
|
|
13454
|
-
const { origin, skewX, skewY } = EditDataHelper.getSkewData(
|
|
13570
|
+
const { target, mergeConfig } = this.editBox;
|
|
13571
|
+
const { around } = mergeConfig;
|
|
13572
|
+
const { origin, skewX, skewY } = EditDataHelper.getSkewData(target.boxBounds, e.current.direction, e.getInnerMove(target), EditDataHelper.getAround(around, e.altKey));
|
|
13455
13573
|
if (!skewX && !skewY)
|
|
13456
13574
|
return;
|
|
13457
13575
|
this.skewOf(origin, skewX, skewY);
|
|
@@ -13461,7 +13579,8 @@ ${filterStyle$1}
|
|
|
13461
13579
|
return;
|
|
13462
13580
|
if (typeof x === 'object')
|
|
13463
13581
|
y = x.y, x = x.x;
|
|
13464
|
-
const {
|
|
13582
|
+
const { target, mergeConfig, single, editor } = this.editBox;
|
|
13583
|
+
const { beforeMove } = mergeConfig;
|
|
13465
13584
|
if (beforeMove) {
|
|
13466
13585
|
const check = beforeMove({ target, x, y });
|
|
13467
13586
|
if (typeof check === 'object')
|
|
@@ -13470,25 +13589,26 @@ ${filterStyle$1}
|
|
|
13470
13589
|
return;
|
|
13471
13590
|
}
|
|
13472
13591
|
const world = target.getWorldPointByLocal({ x, y }, null, true);
|
|
13473
|
-
if (
|
|
13592
|
+
if (!single)
|
|
13474
13593
|
target.safeChange(() => target.move(x, y));
|
|
13475
|
-
const data = { target, editor
|
|
13594
|
+
const data = { target, editor, moveX: world.x, moveY: world.y };
|
|
13476
13595
|
this.emitEvent(new EditorMoveEvent(EditorMoveEvent.BEFORE_MOVE, data));
|
|
13477
13596
|
const event = new EditorMoveEvent(EditorMoveEvent.MOVE, data);
|
|
13478
|
-
this.
|
|
13597
|
+
this.doMove(event);
|
|
13479
13598
|
this.emitEvent(event);
|
|
13480
13599
|
}
|
|
13481
13600
|
scaleWithDrag(data) {
|
|
13482
13601
|
if (!this.checkTransform('resizeable'))
|
|
13483
13602
|
return;
|
|
13484
|
-
const {
|
|
13603
|
+
const { target, mergeConfig, editor } = this.editBox;
|
|
13604
|
+
const { beforeScale } = mergeConfig;
|
|
13485
13605
|
if (beforeScale) {
|
|
13486
13606
|
const { origin, scaleX, scaleY, drag } = data;
|
|
13487
13607
|
const check = beforeScale({ target, drag, origin, scaleX, scaleY });
|
|
13488
13608
|
if (check === false)
|
|
13489
13609
|
return;
|
|
13490
13610
|
}
|
|
13491
|
-
data = Object.assign(Object.assign({}, data), { target, editor
|
|
13611
|
+
data = Object.assign(Object.assign({}, data), { target, editor, worldOrigin: target.getWorldPoint(data.origin) });
|
|
13492
13612
|
this.emitEvent(new EditorScaleEvent(EditorScaleEvent.BEFORE_SCALE, data));
|
|
13493
13613
|
const event = new EditorScaleEvent(EditorScaleEvent.SCALE, data);
|
|
13494
13614
|
this.editTool.onScaleWithDrag(event);
|
|
@@ -13497,7 +13617,8 @@ ${filterStyle$1}
|
|
|
13497
13617
|
scaleOf(origin, scaleX, scaleY = scaleX, _resize) {
|
|
13498
13618
|
if (!this.checkTransform('resizeable'))
|
|
13499
13619
|
return;
|
|
13500
|
-
const {
|
|
13620
|
+
const { target, mergeConfig, single, editor } = this.editBox;
|
|
13621
|
+
const { beforeScale } = mergeConfig;
|
|
13501
13622
|
if (beforeScale) {
|
|
13502
13623
|
const check = beforeScale({ target, origin, scaleX, scaleY });
|
|
13503
13624
|
if (typeof check === 'object')
|
|
@@ -13506,29 +13627,30 @@ ${filterStyle$1}
|
|
|
13506
13627
|
return;
|
|
13507
13628
|
}
|
|
13508
13629
|
const worldOrigin = this.getWorldOrigin(origin);
|
|
13509
|
-
const transform =
|
|
13510
|
-
const data = { target, editor
|
|
13630
|
+
const transform = !single && this.getChangedTransform(() => target.safeChange(() => target.scaleOf(origin, scaleX, scaleY)));
|
|
13631
|
+
const data = { target, editor, worldOrigin, scaleX, scaleY, transform };
|
|
13511
13632
|
this.emitEvent(new EditorScaleEvent(EditorScaleEvent.BEFORE_SCALE, data));
|
|
13512
13633
|
const event = new EditorScaleEvent(EditorScaleEvent.SCALE, data);
|
|
13513
|
-
this.
|
|
13634
|
+
this.doScale(event);
|
|
13514
13635
|
this.emitEvent(event);
|
|
13515
13636
|
}
|
|
13516
13637
|
flip(axis) {
|
|
13517
13638
|
if (!this.checkTransform('resizeable'))
|
|
13518
13639
|
return;
|
|
13519
|
-
const {
|
|
13640
|
+
const { target, single, editor } = this.editBox;
|
|
13520
13641
|
const worldOrigin = this.getWorldOrigin('center');
|
|
13521
|
-
const transform =
|
|
13522
|
-
const data = { target
|
|
13642
|
+
const transform = !single ? this.getChangedTransform(() => target.safeChange(() => target.flip(axis))) : new Matrix(LeafHelper.getFlipTransform(target, axis));
|
|
13643
|
+
const data = { target, editor, worldOrigin, scaleX: axis === 'x' ? -1 : 1, scaleY: axis === 'y' ? -1 : 1, transform };
|
|
13523
13644
|
this.emitEvent(new EditorScaleEvent(EditorScaleEvent.BEFORE_SCALE, data));
|
|
13524
13645
|
const event = new EditorScaleEvent(EditorScaleEvent.SCALE, data);
|
|
13525
|
-
this.
|
|
13646
|
+
this.doScale(event);
|
|
13526
13647
|
this.emitEvent(event);
|
|
13527
13648
|
}
|
|
13528
13649
|
rotateOf(origin, rotation) {
|
|
13529
13650
|
if (!this.checkTransform('rotateable'))
|
|
13530
13651
|
return;
|
|
13531
|
-
const {
|
|
13652
|
+
const { target, mergeConfig, single, editor } = this.editBox;
|
|
13653
|
+
const { beforeRotate } = mergeConfig;
|
|
13532
13654
|
if (beforeRotate) {
|
|
13533
13655
|
const check = beforeRotate({ target, origin, rotation });
|
|
13534
13656
|
if (typeof check === 'number')
|
|
@@ -13537,17 +13659,18 @@ ${filterStyle$1}
|
|
|
13537
13659
|
return;
|
|
13538
13660
|
}
|
|
13539
13661
|
const worldOrigin = this.getWorldOrigin(origin);
|
|
13540
|
-
const transform =
|
|
13541
|
-
const data = { target, editor
|
|
13662
|
+
const transform = !single && this.getChangedTransform(() => target.safeChange(() => target.rotateOf(origin, rotation)));
|
|
13663
|
+
const data = { target, editor, worldOrigin, rotation, transform };
|
|
13542
13664
|
this.emitEvent(new EditorRotateEvent(EditorRotateEvent.BEFORE_ROTATE, data));
|
|
13543
13665
|
const event = new EditorRotateEvent(EditorRotateEvent.ROTATE, data);
|
|
13544
|
-
this.
|
|
13666
|
+
this.doRotate(event);
|
|
13545
13667
|
this.emitEvent(event);
|
|
13546
13668
|
}
|
|
13547
13669
|
skewOf(origin, skewX, skewY = 0, _resize) {
|
|
13548
13670
|
if (!this.checkTransform('skewable'))
|
|
13549
13671
|
return;
|
|
13550
|
-
const {
|
|
13672
|
+
const { target, mergeConfig, single, editor } = this.editBox;
|
|
13673
|
+
const { beforeSkew } = mergeConfig;
|
|
13551
13674
|
if (beforeSkew) {
|
|
13552
13675
|
const check = beforeSkew({ target, origin, skewX, skewY });
|
|
13553
13676
|
if (typeof check === 'object')
|
|
@@ -13556,25 +13679,149 @@ ${filterStyle$1}
|
|
|
13556
13679
|
return;
|
|
13557
13680
|
}
|
|
13558
13681
|
const worldOrigin = this.getWorldOrigin(origin);
|
|
13559
|
-
const transform =
|
|
13560
|
-
const data = { target, editor
|
|
13682
|
+
const transform = !single && this.getChangedTransform(() => target.safeChange(() => target.skewOf(origin, skewX, skewY)));
|
|
13683
|
+
const data = { target, editor, worldOrigin, skewX, skewY, transform };
|
|
13561
13684
|
this.emitEvent(new EditorSkewEvent(EditorSkewEvent.BEFORE_SKEW, data));
|
|
13562
13685
|
const event = new EditorSkewEvent(EditorSkewEvent.SKEW, data);
|
|
13563
|
-
this.
|
|
13686
|
+
this.doSkew(event);
|
|
13564
13687
|
this.emitEvent(event);
|
|
13565
13688
|
}
|
|
13566
|
-
|
|
13689
|
+
doMove(event) {
|
|
13690
|
+
this.editTool.onMove(event);
|
|
13691
|
+
}
|
|
13692
|
+
doScale(event) {
|
|
13693
|
+
this.editTool.onScale(event);
|
|
13694
|
+
}
|
|
13695
|
+
doRotate(event) {
|
|
13696
|
+
this.editTool.onRotate(event);
|
|
13697
|
+
}
|
|
13698
|
+
doSkew(event) {
|
|
13699
|
+
this.editTool.onSkew(event);
|
|
13700
|
+
}
|
|
13701
|
+
checkTransform(type) {
|
|
13702
|
+
const { target, mergeConfig } = this.editBox;
|
|
13703
|
+
return target && !target.locked && mergeConfig[type];
|
|
13704
|
+
}
|
|
13567
13705
|
getWorldOrigin(origin) {
|
|
13568
|
-
|
|
13706
|
+
const { target } = this.editBox;
|
|
13707
|
+
return target.getWorldPoint(LeafHelper.getInnerOrigin(target, origin));
|
|
13569
13708
|
}
|
|
13570
13709
|
getChangedTransform(func) {
|
|
13571
|
-
const {
|
|
13572
|
-
if (
|
|
13573
|
-
return
|
|
13574
|
-
const oldMatrix = new Matrix(
|
|
13710
|
+
const { target, single } = this.editBox;
|
|
13711
|
+
if (!single && !target.canChange)
|
|
13712
|
+
return target.changedTransform;
|
|
13713
|
+
const oldMatrix = new Matrix(target.worldTransform);
|
|
13575
13714
|
func();
|
|
13576
|
-
return new Matrix(
|
|
13715
|
+
return new Matrix(target.worldTransform).divide(oldMatrix);
|
|
13716
|
+
}
|
|
13717
|
+
emitEvent(event, capture) {
|
|
13718
|
+
this.editBox.editor.emitEvent(event, capture);
|
|
13719
|
+
}
|
|
13720
|
+
}
|
|
13721
|
+
|
|
13722
|
+
exports.Editor = class Editor extends exports.Group {
|
|
13723
|
+
get list() { return this.leafList.list; }
|
|
13724
|
+
get dragHoverExclude() { return [this.editBox.rect]; }
|
|
13725
|
+
get editing() { return !!this.list.length; }
|
|
13726
|
+
get groupOpening() { return !!this.openedGroupList.length; }
|
|
13727
|
+
get multiple() { return this.list.length > 1; }
|
|
13728
|
+
get single() { return this.list.length === 1; }
|
|
13729
|
+
get dragPoint() { return this.editBox.dragPoint; }
|
|
13730
|
+
get dragging() { return this.editBox.dragging; }
|
|
13731
|
+
get gesturing() { return this.editBox.gesturing; }
|
|
13732
|
+
get moving() { return this.editBox.moving; }
|
|
13733
|
+
get resizing() { return this.editBox.resizing; }
|
|
13734
|
+
get rotating() { return this.editBox.rotating; }
|
|
13735
|
+
get skewing() { return this.editBox.skewing; }
|
|
13736
|
+
get element() { return this.multiple ? this.simulateTarget : this.list[0]; }
|
|
13737
|
+
get buttons() { return this.editBox.buttons; }
|
|
13738
|
+
constructor(userConfig, data) {
|
|
13739
|
+
super(data);
|
|
13740
|
+
this.leafList = new LeafList();
|
|
13741
|
+
this.openedGroupList = new LeafList();
|
|
13742
|
+
this.simulateTarget = new SimulateElement(this);
|
|
13743
|
+
this.editBox = new EditBox(this);
|
|
13744
|
+
this.editToolList = {};
|
|
13745
|
+
this.selector = new EditSelect(this);
|
|
13746
|
+
this.editMask = new EditMask(this);
|
|
13747
|
+
this.targetEventIds = [];
|
|
13748
|
+
let mergedConfig = DataHelper.clone(config);
|
|
13749
|
+
if (userConfig)
|
|
13750
|
+
mergedConfig = DataHelper.default(userConfig, mergedConfig);
|
|
13751
|
+
this.mergedConfig = this.config = mergedConfig;
|
|
13752
|
+
this.addMany(this.editMask, this.selector, this.editBox);
|
|
13753
|
+
if (!Plugin.has('resize'))
|
|
13754
|
+
this.config.editSize = 'scale';
|
|
13577
13755
|
}
|
|
13756
|
+
select(target) {
|
|
13757
|
+
this.target = target;
|
|
13758
|
+
}
|
|
13759
|
+
cancel() {
|
|
13760
|
+
this.target = null;
|
|
13761
|
+
}
|
|
13762
|
+
hasItem(item) {
|
|
13763
|
+
return this.leafList.has(item);
|
|
13764
|
+
}
|
|
13765
|
+
addItem(item) {
|
|
13766
|
+
if (!this.hasItem(item) && !item.locked)
|
|
13767
|
+
this.leafList.add(item), this.target = this.leafList.list;
|
|
13768
|
+
}
|
|
13769
|
+
removeItem(item) {
|
|
13770
|
+
if (this.hasItem(item))
|
|
13771
|
+
this.leafList.remove(item), this.target = this.leafList.list;
|
|
13772
|
+
}
|
|
13773
|
+
shiftItem(item) {
|
|
13774
|
+
this.hasItem(item) ? this.removeItem(item) : this.addItem(item);
|
|
13775
|
+
}
|
|
13776
|
+
update() {
|
|
13777
|
+
if (this.editing) {
|
|
13778
|
+
if (!this.element.parent)
|
|
13779
|
+
return this.cancel();
|
|
13780
|
+
if (this.innerEditing)
|
|
13781
|
+
this.innerEditor.update();
|
|
13782
|
+
this.editTool.update();
|
|
13783
|
+
this.selector.update();
|
|
13784
|
+
}
|
|
13785
|
+
}
|
|
13786
|
+
updateEditBox() {
|
|
13787
|
+
if (this.multiple)
|
|
13788
|
+
simulate(this);
|
|
13789
|
+
this.update();
|
|
13790
|
+
}
|
|
13791
|
+
updateEditTool() {
|
|
13792
|
+
this.unloadEditTool();
|
|
13793
|
+
if (this.editing) {
|
|
13794
|
+
const name = this.element.editOuter || 'EditTool';
|
|
13795
|
+
const tool = this.editTool = this.editToolList[name] = this.editToolList[name] || EditToolCreator.get(name, this);
|
|
13796
|
+
this.editBox.load();
|
|
13797
|
+
tool.load();
|
|
13798
|
+
this.update();
|
|
13799
|
+
}
|
|
13800
|
+
}
|
|
13801
|
+
unloadEditTool() {
|
|
13802
|
+
let tool = this.editTool;
|
|
13803
|
+
if (tool) {
|
|
13804
|
+
this.editBox.unload();
|
|
13805
|
+
tool.unload();
|
|
13806
|
+
this.editTool = null;
|
|
13807
|
+
}
|
|
13808
|
+
}
|
|
13809
|
+
getEditSize(_ui) {
|
|
13810
|
+
return this.mergeConfig.editSize;
|
|
13811
|
+
}
|
|
13812
|
+
onMove(_e) { }
|
|
13813
|
+
onScale(_e) { }
|
|
13814
|
+
onRotate(_e) { }
|
|
13815
|
+
onSkew(_e) { }
|
|
13816
|
+
move(_x, _y = 0) { }
|
|
13817
|
+
scaleWithDrag(_data) { }
|
|
13818
|
+
scaleOf(_origin, scaleX, _scaleY = scaleX, _resize) { }
|
|
13819
|
+
flip(_axis) { }
|
|
13820
|
+
rotateOf(_origin, _rotation) { }
|
|
13821
|
+
skewOf(_origin, _skewX, _skewY = 0, _resize) { }
|
|
13822
|
+
checkTransform(_type) { return undefined; }
|
|
13823
|
+
getWorldOrigin(_origin) { return undefined; }
|
|
13824
|
+
getChangedTransform(_func) { return undefined; }
|
|
13578
13825
|
group(userGroup) {
|
|
13579
13826
|
if (this.multiple) {
|
|
13580
13827
|
this.emitGroupEvent(EditorGroupEvent.BEFORE_GROUP);
|
|
@@ -13631,16 +13878,21 @@ ${filterStyle$1}
|
|
|
13631
13878
|
if (group)
|
|
13632
13879
|
group.emitEvent(event);
|
|
13633
13880
|
}
|
|
13634
|
-
openInnerEditor(target, select) {
|
|
13881
|
+
openInnerEditor(target, nameOrSelect, select) {
|
|
13882
|
+
let name;
|
|
13883
|
+
if (typeof nameOrSelect === 'string')
|
|
13884
|
+
name = nameOrSelect;
|
|
13885
|
+
else if (!select)
|
|
13886
|
+
select = nameOrSelect;
|
|
13635
13887
|
if (target && select)
|
|
13636
13888
|
this.target = target;
|
|
13637
13889
|
if (this.single) {
|
|
13638
13890
|
const editTarget = target || this.element;
|
|
13639
|
-
|
|
13640
|
-
if (
|
|
13891
|
+
name || (name = editTarget.editInner);
|
|
13892
|
+
if (name && EditToolCreator.list[name]) {
|
|
13641
13893
|
this.editTool.unload();
|
|
13642
13894
|
this.innerEditing = true;
|
|
13643
|
-
this.innerEditor = this.editToolList[
|
|
13895
|
+
this.innerEditor = this.editToolList[name] = this.editToolList[name] || EditToolCreator.get(name, this);
|
|
13644
13896
|
this.innerEditor.editTarget = editTarget;
|
|
13645
13897
|
this.emitInnerEvent(InnerEditorEvent.BEFORE_OPEN);
|
|
13646
13898
|
this.innerEditor.load();
|
|
@@ -13648,13 +13900,14 @@ ${filterStyle$1}
|
|
|
13648
13900
|
}
|
|
13649
13901
|
}
|
|
13650
13902
|
}
|
|
13651
|
-
closeInnerEditor() {
|
|
13903
|
+
closeInnerEditor(onlyInnerEditor) {
|
|
13652
13904
|
if (this.innerEditing) {
|
|
13653
13905
|
this.innerEditing = false;
|
|
13654
13906
|
this.emitInnerEvent(InnerEditorEvent.BEFORE_CLOSE);
|
|
13655
13907
|
this.innerEditor.unload();
|
|
13656
13908
|
this.emitInnerEvent(InnerEditorEvent.CLOSE);
|
|
13657
|
-
|
|
13909
|
+
if (!onlyInnerEditor)
|
|
13910
|
+
this.updateEditTool();
|
|
13658
13911
|
this.innerEditor = null;
|
|
13659
13912
|
}
|
|
13660
13913
|
}
|
|
@@ -13692,22 +13945,12 @@ ${filterStyle$1}
|
|
|
13692
13945
|
if (this.targetChanged)
|
|
13693
13946
|
this.update();
|
|
13694
13947
|
}
|
|
13695
|
-
onKey(e) {
|
|
13696
|
-
updateCursor(this, e);
|
|
13697
|
-
}
|
|
13698
13948
|
listenTargetEvents() {
|
|
13699
13949
|
if (!this.targetEventIds.length) {
|
|
13700
|
-
const { app, leafer,
|
|
13950
|
+
const { app, leafer, editMask } = this;
|
|
13701
13951
|
this.targetEventIds = [
|
|
13702
13952
|
leafer.on_(RenderEvent.START, this.onRenderStart, this),
|
|
13703
|
-
app.on_(
|
|
13704
|
-
[RenderEvent.CHILD_START, this.onAppRenderStart, this],
|
|
13705
|
-
[exports.MoveEvent.BEFORE_MOVE, this.onMove, this, true],
|
|
13706
|
-
[exports.ZoomEvent.BEFORE_ZOOM, this.onScale, this, true],
|
|
13707
|
-
[exports.RotateEvent.BEFORE_ROTATE, this.onRotate, this, true],
|
|
13708
|
-
[[exports.KeyEvent.HOLD, exports.KeyEvent.UP], this.onKey, this],
|
|
13709
|
-
[exports.KeyEvent.DOWN, editBox.onArrow, editBox]
|
|
13710
|
-
])
|
|
13953
|
+
app.on_(RenderEvent.CHILD_START, this.onAppRenderStart, this)
|
|
13711
13954
|
];
|
|
13712
13955
|
if (editMask.visible)
|
|
13713
13956
|
editMask.forceRender();
|
|
@@ -13731,24 +13974,29 @@ ${filterStyle$1}
|
|
|
13731
13974
|
super.destroy();
|
|
13732
13975
|
}
|
|
13733
13976
|
}
|
|
13734
|
-
}
|
|
13977
|
+
};
|
|
13735
13978
|
__decorate([
|
|
13736
13979
|
mergeConfigAttr()
|
|
13737
|
-
], Editor.prototype, "mergeConfig", void 0);
|
|
13980
|
+
], exports.Editor.prototype, "mergeConfig", void 0);
|
|
13738
13981
|
__decorate([
|
|
13739
13982
|
targetAttr(onHover)
|
|
13740
|
-
], Editor.prototype, "hoverTarget", void 0);
|
|
13983
|
+
], exports.Editor.prototype, "hoverTarget", void 0);
|
|
13741
13984
|
__decorate([
|
|
13742
13985
|
targetAttr(onTarget)
|
|
13743
|
-
], Editor.prototype, "target", void 0);
|
|
13986
|
+
], exports.Editor.prototype, "target", void 0);
|
|
13987
|
+
exports.Editor = __decorate([
|
|
13988
|
+
useModule(TransformTool, ['editBox', 'editTool', 'emitEvent'])
|
|
13989
|
+
], exports.Editor);
|
|
13744
13990
|
|
|
13745
13991
|
class InnerEditor {
|
|
13746
13992
|
static registerInnerEditor() {
|
|
13747
13993
|
EditToolCreator.register(this);
|
|
13748
13994
|
}
|
|
13749
13995
|
get tag() { return 'InnerEditor'; }
|
|
13996
|
+
get mode() { return 'focus'; }
|
|
13750
13997
|
get editBox() { return this.editor.editBox; }
|
|
13751
13998
|
constructor(editor) {
|
|
13999
|
+
this.eventIds = [];
|
|
13752
14000
|
this.editor = editor;
|
|
13753
14001
|
this.create();
|
|
13754
14002
|
}
|
|
@@ -13761,7 +14009,7 @@ ${filterStyle$1}
|
|
|
13761
14009
|
load() {
|
|
13762
14010
|
const { editor } = this;
|
|
13763
14011
|
if (editor) {
|
|
13764
|
-
if (editor.app)
|
|
14012
|
+
if (editor.app && this.mode === 'focus')
|
|
13765
14013
|
editor.selector.hittable = editor.app.tree.hitChildren = false;
|
|
13766
14014
|
this.onLoad();
|
|
13767
14015
|
}
|
|
@@ -13772,7 +14020,7 @@ ${filterStyle$1}
|
|
|
13772
14020
|
unload() {
|
|
13773
14021
|
const { editor } = this;
|
|
13774
14022
|
if (editor) {
|
|
13775
|
-
if (editor.app)
|
|
14023
|
+
if (editor.app && this.mode === 'focus')
|
|
13776
14024
|
editor.selector.hittable = editor.app.tree.hitChildren = true;
|
|
13777
14025
|
this.onUnload();
|
|
13778
14026
|
}
|
|
@@ -13846,10 +14094,7 @@ ${filterStyle$1}
|
|
|
13846
14094
|
this.onLoad();
|
|
13847
14095
|
}
|
|
13848
14096
|
update() {
|
|
13849
|
-
|
|
13850
|
-
const { x, y, scaleX, scaleY, rotation, skewX, skewY, width, height } = editor.element.getLayoutBounds('box', editor, true);
|
|
13851
|
-
editBox.set({ x, y, scaleX, scaleY, rotation, skewX, skewY });
|
|
13852
|
-
editBox.update({ x: 0, y: 0, width, height });
|
|
14097
|
+
this.editBox.update();
|
|
13853
14098
|
this.onUpdate();
|
|
13854
14099
|
}
|
|
13855
14100
|
unload() {
|
|
@@ -14186,14 +14431,14 @@ ${filterStyle$1}
|
|
|
14186
14431
|
|
|
14187
14432
|
Plugin.add('editor', 'resize');
|
|
14188
14433
|
Creator.editor = function (options, app) {
|
|
14189
|
-
const editor = new Editor(options);
|
|
14434
|
+
const editor = new exports.Editor(options);
|
|
14190
14435
|
if (app)
|
|
14191
14436
|
app.sky.add(app.editor = editor);
|
|
14192
14437
|
return editor;
|
|
14193
14438
|
};
|
|
14194
14439
|
exports.Box.addAttr('textBox', false, dataType);
|
|
14195
14440
|
exports.UI.addAttr('editConfig', undefined, dataType);
|
|
14196
|
-
exports.UI.addAttr('editOuter', (ui) => ui.__.__isLinePath ? 'LineEditTool' : 'EditTool', dataType);
|
|
14441
|
+
exports.UI.addAttr('editOuter', (ui) => { ui.updateLayout(); return ui.__.__isLinePath ? 'LineEditTool' : 'EditTool'; }, dataType);
|
|
14197
14442
|
exports.UI.addAttr('editInner', 'PathEditor', dataType);
|
|
14198
14443
|
exports.Group.addAttr('editInner', '', dataType);
|
|
14199
14444
|
exports.Text.addAttr('editInner', 'TextEditor', dataType);
|
|
@@ -14318,10 +14563,12 @@ ${filterStyle$1}
|
|
|
14318
14563
|
];
|
|
14319
14564
|
this.onFocus = this.onFocus.bind(this);
|
|
14320
14565
|
this.onInput = this.onInput.bind(this);
|
|
14566
|
+
this.onPaste = this.onPaste.bind(this);
|
|
14321
14567
|
this.onUpdate = this.onUpdate.bind(this);
|
|
14322
14568
|
this.onKeydown = this.onKeydown.bind(this);
|
|
14323
14569
|
div.addEventListener("focus", this.onFocus);
|
|
14324
14570
|
div.addEventListener("input", this.onInput);
|
|
14571
|
+
div.addEventListener("paste", this.onPaste);
|
|
14325
14572
|
window.addEventListener('keydown', this.onKeydown);
|
|
14326
14573
|
window.addEventListener('scroll', this.onUpdate);
|
|
14327
14574
|
const selection = window.getSelection();
|
|
@@ -14351,15 +14598,43 @@ ${filterStyle$1}
|
|
|
14351
14598
|
if (e.key === 'Enter') {
|
|
14352
14599
|
e.preventDefault();
|
|
14353
14600
|
const br = document.createElement('br');
|
|
14601
|
+
const zwsp = document.createTextNode('\u200B');
|
|
14354
14602
|
const selection = window.getSelection();
|
|
14355
14603
|
const range = selection.getRangeAt(0);
|
|
14356
14604
|
range.deleteContents();
|
|
14605
|
+
range.insertNode(zwsp);
|
|
14357
14606
|
range.insertNode(br);
|
|
14358
14607
|
range.setStartAfter(br);
|
|
14359
14608
|
range.setEndAfter(br);
|
|
14360
14609
|
this.onInput();
|
|
14361
14610
|
}
|
|
14362
14611
|
}
|
|
14612
|
+
onPaste(event) {
|
|
14613
|
+
if (this.isHTMLText)
|
|
14614
|
+
return;
|
|
14615
|
+
event.preventDefault();
|
|
14616
|
+
const clipboardData = event.clipboardData;
|
|
14617
|
+
if (!clipboardData)
|
|
14618
|
+
return;
|
|
14619
|
+
let text = clipboardData.getData('text/plain').replace(/\r\n?/g, '\n');
|
|
14620
|
+
const selection = window.getSelection();
|
|
14621
|
+
if (!selection || !selection.rangeCount)
|
|
14622
|
+
return;
|
|
14623
|
+
const range = selection.getRangeAt(0);
|
|
14624
|
+
range.deleteContents();
|
|
14625
|
+
const lines = text.split('\n');
|
|
14626
|
+
const fragment = document.createDocumentFragment();
|
|
14627
|
+
lines.forEach((line, index) => {
|
|
14628
|
+
if (index > 0)
|
|
14629
|
+
fragment.appendChild(document.createElement('br'));
|
|
14630
|
+
fragment.appendChild(document.createTextNode(line));
|
|
14631
|
+
});
|
|
14632
|
+
range.insertNode(fragment);
|
|
14633
|
+
range.collapse(false);
|
|
14634
|
+
selection.removeAllRanges();
|
|
14635
|
+
selection.addRange(range);
|
|
14636
|
+
this.onInput();
|
|
14637
|
+
}
|
|
14363
14638
|
onUpdate() {
|
|
14364
14639
|
const { editTarget: text } = this;
|
|
14365
14640
|
let textScale = 1;
|
|
@@ -14418,6 +14693,7 @@ ${filterStyle$1}
|
|
|
14418
14693
|
editor.off_(this.eventIds);
|
|
14419
14694
|
dom.removeEventListener("focus", this.onFocus);
|
|
14420
14695
|
dom.removeEventListener("input", this.onInput);
|
|
14696
|
+
dom.removeEventListener("paste", this.onPaste);
|
|
14421
14697
|
window.removeEventListener('keydown', this.onKeydown);
|
|
14422
14698
|
window.removeEventListener('scroll', this.onUpdate);
|
|
14423
14699
|
dom.remove();
|
|
@@ -14820,8 +15096,16 @@ ${filterStyle$1}
|
|
|
14820
15096
|
}
|
|
14821
15097
|
|
|
14822
15098
|
Plugin.add('view');
|
|
14823
|
-
exports.Leafer.prototype.zoom = function (zoomType,
|
|
15099
|
+
exports.Leafer.prototype.zoom = function (zoomType, optionsOrPadding, scroll, transition) {
|
|
14824
15100
|
this.killAnimate();
|
|
15101
|
+
let padding;
|
|
15102
|
+
if (typeof optionsOrPadding === 'object' && !(optionsOrPadding instanceof Array)) {
|
|
15103
|
+
padding = optionsOrPadding.padding;
|
|
15104
|
+
scroll = optionsOrPadding.scroll;
|
|
15105
|
+
transition = optionsOrPadding.transition;
|
|
15106
|
+
}
|
|
15107
|
+
else
|
|
15108
|
+
padding = optionsOrPadding;
|
|
14825
15109
|
const { zoomLayer } = this;
|
|
14826
15110
|
const limitBounds = this.canvas.bounds.clone().shrink(padding !== undefined ? padding : 30), bounds = new Bounds();
|
|
14827
15111
|
const center = { x: limitBounds.x + limitBounds.width / 2, y: limitBounds.y + limitBounds.height / 2 };
|
|
@@ -14868,7 +15152,7 @@ ${filterStyle$1}
|
|
|
14868
15152
|
}
|
|
14869
15153
|
const { width, height } = bounds;
|
|
14870
15154
|
let moveX = limitBounds.x - bounds.x, moveY = limitBounds.y - bounds.y;
|
|
14871
|
-
if (
|
|
15155
|
+
if (scroll) {
|
|
14872
15156
|
moveX += Math.max((limitBounds.width - width) / 2, 0);
|
|
14873
15157
|
moveY += Math.max((limitBounds.height - height) / 2, 0);
|
|
14874
15158
|
}
|
|
@@ -14881,6 +15165,10 @@ ${filterStyle$1}
|
|
|
14881
15165
|
data.scaleX *= changeScale;
|
|
14882
15166
|
data.scaleY *= changeScale;
|
|
14883
15167
|
}
|
|
15168
|
+
if (scroll === 'x')
|
|
15169
|
+
moveY = 0;
|
|
15170
|
+
else if (scroll === 'y')
|
|
15171
|
+
moveX = 0;
|
|
14884
15172
|
PointHelper.move(data, moveX, moveY);
|
|
14885
15173
|
bounds.move(moveX, moveY);
|
|
14886
15174
|
zoomLayer.set(data, transition);
|
|
@@ -15046,6 +15334,11 @@ ${filterStyle$1}
|
|
|
15046
15334
|
}
|
|
15047
15335
|
super.__updateBoxBounds();
|
|
15048
15336
|
}
|
|
15337
|
+
__draw(canvas, options, originCanvas) {
|
|
15338
|
+
if (this.textEditing && !options.exporting)
|
|
15339
|
+
return;
|
|
15340
|
+
super.__draw(canvas, options, originCanvas);
|
|
15341
|
+
}
|
|
15049
15342
|
};
|
|
15050
15343
|
__decorate([
|
|
15051
15344
|
dataProcessor(HTMLTextData)
|
|
@@ -15056,6 +15349,9 @@ ${filterStyle$1}
|
|
|
15056
15349
|
__decorate([
|
|
15057
15350
|
dataType('TextEditor')
|
|
15058
15351
|
], exports.HTMLText.prototype, "editInner", void 0);
|
|
15352
|
+
__decorate([
|
|
15353
|
+
surfaceType(false)
|
|
15354
|
+
], exports.HTMLText.prototype, "textEditing", void 0);
|
|
15059
15355
|
exports.HTMLText = __decorate([
|
|
15060
15356
|
registerUI()
|
|
15061
15357
|
], exports.HTMLText);
|
|
@@ -15834,9 +16130,8 @@ ${filterStyle$1}
|
|
|
15834
16130
|
}
|
|
15835
16131
|
};
|
|
15836
16132
|
box.__updateBoxBounds = function (secondLayout) {
|
|
15837
|
-
const data = this.__;
|
|
15838
16133
|
if (this.children.length && !this.pathInputed) {
|
|
15839
|
-
const { flow } = data;
|
|
16134
|
+
const data = this.__, { flow } = data;
|
|
15840
16135
|
if (data.__autoSide) {
|
|
15841
16136
|
if (data.__hasSurface)
|
|
15842
16137
|
this.__extraUpdate();
|
|
@@ -16068,6 +16363,11 @@ ${filterStyle$1}
|
|
|
16068
16363
|
this.play();
|
|
16069
16364
|
}, 0);
|
|
16070
16365
|
}
|
|
16366
|
+
emitType(type) {
|
|
16367
|
+
this.emit(type, this);
|
|
16368
|
+
if (this.parent)
|
|
16369
|
+
this.parent.onChildEvent(type, this);
|
|
16370
|
+
}
|
|
16071
16371
|
play() {
|
|
16072
16372
|
if (this.destroyed)
|
|
16073
16373
|
return;
|
|
@@ -16076,20 +16376,20 @@ ${filterStyle$1}
|
|
|
16076
16376
|
this.clearTimer(), this.start();
|
|
16077
16377
|
else if (!this.timer)
|
|
16078
16378
|
this.requestAnimate();
|
|
16079
|
-
this.
|
|
16379
|
+
this.emitType(AnimateEvent.PLAY);
|
|
16080
16380
|
}
|
|
16081
16381
|
pause() {
|
|
16082
16382
|
if (this.destroyed)
|
|
16083
16383
|
return;
|
|
16084
16384
|
this.running = false;
|
|
16085
16385
|
this.clearTimer();
|
|
16086
|
-
this.
|
|
16386
|
+
this.emitType(AnimateEvent.PAUSE);
|
|
16087
16387
|
}
|
|
16088
16388
|
stop() {
|
|
16089
16389
|
if (this.destroyed)
|
|
16090
16390
|
return;
|
|
16091
16391
|
this.complete();
|
|
16092
|
-
this.
|
|
16392
|
+
this.emitType(AnimateEvent.STOP);
|
|
16093
16393
|
}
|
|
16094
16394
|
seek(time) {
|
|
16095
16395
|
if (this.destroyed)
|
|
@@ -16103,7 +16403,7 @@ ${filterStyle$1}
|
|
|
16103
16403
|
this.time = time;
|
|
16104
16404
|
this.animate(0, true);
|
|
16105
16405
|
this.clearTimer(() => this.requestAnimate());
|
|
16106
|
-
this.
|
|
16406
|
+
this.emitType(AnimateEvent.SEEK);
|
|
16107
16407
|
}
|
|
16108
16408
|
kill(complete = true, killStyle) {
|
|
16109
16409
|
this.killStyle = killStyle;
|
|
@@ -16170,7 +16470,7 @@ ${filterStyle$1}
|
|
|
16170
16470
|
if (totalTime)
|
|
16171
16471
|
this.changeDuration(totalTime);
|
|
16172
16472
|
}
|
|
16173
|
-
this.
|
|
16473
|
+
this.emitType(AnimateEvent.CREATED);
|
|
16174
16474
|
}
|
|
16175
16475
|
changeDuration(duration) {
|
|
16176
16476
|
const { config } = this;
|
|
@@ -16290,7 +16590,7 @@ ${filterStyle$1}
|
|
|
16290
16590
|
key in killStyle || (style[key] = endingStyle[key]);
|
|
16291
16591
|
this.setStyle(style);
|
|
16292
16592
|
this.clearTimer();
|
|
16293
|
-
this.
|
|
16593
|
+
this.emitType(AnimateEvent.COMPLETED);
|
|
16294
16594
|
}
|
|
16295
16595
|
setFrom() {
|
|
16296
16596
|
this.nowIndex = 0;
|
|
@@ -16334,7 +16634,7 @@ ${filterStyle$1}
|
|
|
16334
16634
|
Transition.setBetweenStyle(betweenStyle, fromStyle, toStyle, style, t, target, attrsMap);
|
|
16335
16635
|
this.setStyle(betweenStyle);
|
|
16336
16636
|
}
|
|
16337
|
-
this.
|
|
16637
|
+
this.emitType(AnimateEvent.UPDATE);
|
|
16338
16638
|
}
|
|
16339
16639
|
setStyle(style) {
|
|
16340
16640
|
const { target } = this;
|
|
@@ -16378,7 +16678,7 @@ ${filterStyle$1}
|
|
|
16378
16678
|
this.stop();
|
|
16379
16679
|
else
|
|
16380
16680
|
this.pause();
|
|
16381
|
-
this.target = this.config = this.frames = this.fromStyle = this.toStyle = this.style = this.killStyle = null;
|
|
16681
|
+
this.target = this.parent = this.config = this.frames = this.fromStyle = this.toStyle = this.style = this.killStyle = null;
|
|
16382
16682
|
this.destroyed = true;
|
|
16383
16683
|
}
|
|
16384
16684
|
}
|
|
@@ -16444,6 +16744,7 @@ ${filterStyle$1}
|
|
|
16444
16744
|
});
|
|
16445
16745
|
this.list = animation.map(item => {
|
|
16446
16746
|
const animate = item.target ? item : new exports.Animate(this.target, item, isTemp);
|
|
16747
|
+
animate.parent = this;
|
|
16447
16748
|
Object.assign(this.fromStyle, animate.fromStyle);
|
|
16448
16749
|
Object.assign(this.toStyle, animate.toStyle);
|
|
16449
16750
|
Object.assign(this._endingStyle, animate.endingStyle);
|
|
@@ -16452,20 +16753,34 @@ ${filterStyle$1}
|
|
|
16452
16753
|
}
|
|
16453
16754
|
play() {
|
|
16454
16755
|
this.each(item => item.play());
|
|
16756
|
+
this.emitType(AnimateEvent.PLAY);
|
|
16455
16757
|
}
|
|
16456
16758
|
pause() {
|
|
16457
16759
|
this.each(item => item.pause());
|
|
16760
|
+
this.emitType(AnimateEvent.PAUSE);
|
|
16458
16761
|
}
|
|
16459
16762
|
stop() {
|
|
16460
16763
|
this.each(item => item.stop());
|
|
16764
|
+
this.emitType(AnimateEvent.STOP);
|
|
16461
16765
|
}
|
|
16462
16766
|
seek(time) {
|
|
16463
16767
|
this.each(item => item.seek(time));
|
|
16768
|
+
this.emitType(AnimateEvent.SEEK);
|
|
16464
16769
|
}
|
|
16465
16770
|
kill(complete, killStyle) {
|
|
16466
16771
|
this.each(item => item.kill(complete, killStyle));
|
|
16467
16772
|
this.destroy();
|
|
16468
16773
|
}
|
|
16774
|
+
onChildEvent(type, _animate) {
|
|
16775
|
+
switch (type) {
|
|
16776
|
+
case AnimateEvent.COMPLETED:
|
|
16777
|
+
if (this.completed)
|
|
16778
|
+
this.emitType(type);
|
|
16779
|
+
break;
|
|
16780
|
+
case AnimateEvent.UPDATE:
|
|
16781
|
+
this.emitType(type);
|
|
16782
|
+
}
|
|
16783
|
+
}
|
|
16469
16784
|
each(func) {
|
|
16470
16785
|
this.list.forEach(func);
|
|
16471
16786
|
}
|
|
@@ -17924,123 +18239,131 @@ ${filterStyle$1}
|
|
|
17924
18239
|
index++;
|
|
17925
18240
|
}
|
|
17926
18241
|
const bounds = new Bounds();
|
|
17927
|
-
|
|
17928
|
-
|
|
18242
|
+
if (pointBounds) {
|
|
18243
|
+
toBounds(pointBounds, bounds);
|
|
18244
|
+
bounds.scale(1 / canvas.pixelRatio).ceil();
|
|
18245
|
+
}
|
|
18246
|
+
return bounds;
|
|
17929
18247
|
}
|
|
17930
18248
|
|
|
17931
18249
|
const ExportModule = {
|
|
17932
18250
|
syncExport(leaf, filename, options) {
|
|
17933
|
-
|
|
18251
|
+
Export.running = true;
|
|
17934
18252
|
let result;
|
|
17935
|
-
|
|
17936
|
-
|
|
17937
|
-
|
|
17938
|
-
|
|
17939
|
-
|
|
17940
|
-
|
|
17941
|
-
|
|
17942
|
-
|
|
17943
|
-
|
|
17944
|
-
|
|
17945
|
-
|
|
17946
|
-
|
|
17947
|
-
|
|
17948
|
-
else {
|
|
17949
|
-
let renderBounds, trimBounds, scaleX = 1, scaleY = 1;
|
|
17950
|
-
const { worldTransform, isLeafer, leafer, isFrame } = leaf;
|
|
17951
|
-
const { slice, clip, trim, screenshot, padding, onCanvas } = options;
|
|
17952
|
-
const smooth = options.smooth === undefined ? (leafer ? leafer.config.smooth : true) : options.smooth;
|
|
17953
|
-
const contextSettings = options.contextSettings || (leafer ? leafer.config.contextSettings : undefined);
|
|
17954
|
-
const fill = (isLeafer && screenshot) ? (options.fill === undefined ? leaf.fill : options.fill) : options.fill;
|
|
17955
|
-
const needFill = FileHelper.isOpaqueImage(filename) || fill, matrix = new Matrix();
|
|
17956
|
-
if (screenshot) {
|
|
17957
|
-
renderBounds = screenshot === true ? (isLeafer ? leafer.canvas.bounds : leaf.worldRenderBounds) : screenshot;
|
|
18253
|
+
try {
|
|
18254
|
+
const fileType = FileHelper.fileType(filename);
|
|
18255
|
+
const isDownload = filename.includes('.');
|
|
18256
|
+
options = FileHelper.getExportOptions(options);
|
|
18257
|
+
const { toURL } = Platform;
|
|
18258
|
+
const { download } = Platform.origin;
|
|
18259
|
+
if (fileType === 'json') {
|
|
18260
|
+
isDownload && download(toURL(JSON.stringify(leaf.toJSON(options.json)), 'text'), filename);
|
|
18261
|
+
result = { data: isDownload ? true : leaf.toJSON(options.json) };
|
|
18262
|
+
}
|
|
18263
|
+
else if (fileType === 'svg') {
|
|
18264
|
+
isDownload && download(toURL(leaf.toSVG(), 'svg'), filename);
|
|
18265
|
+
result = { data: isDownload ? true : leaf.toSVG() };
|
|
17958
18266
|
}
|
|
17959
18267
|
else {
|
|
17960
|
-
let
|
|
17961
|
-
|
|
17962
|
-
|
|
17963
|
-
|
|
17964
|
-
|
|
17965
|
-
|
|
17966
|
-
|
|
17967
|
-
|
|
17968
|
-
|
|
17969
|
-
scaleX /= leaf.scaleX;
|
|
17970
|
-
scaleY /= leaf.scaleY;
|
|
17971
|
-
break;
|
|
17972
|
-
case 'world':
|
|
17973
|
-
scaleX = 1;
|
|
17974
|
-
scaleY = 1;
|
|
17975
|
-
break;
|
|
17976
|
-
case 'page':
|
|
17977
|
-
relative = leafer || leaf;
|
|
17978
|
-
default:
|
|
17979
|
-
matrix.set(worldTransform).divide(leaf.getTransform(relative));
|
|
17980
|
-
const l = relative.worldTransform;
|
|
17981
|
-
scaleX /= scaleX / l.scaleX;
|
|
17982
|
-
scaleY /= scaleY / l.scaleY;
|
|
18268
|
+
let renderBounds, trimBounds, scaleX = 1, scaleY = 1;
|
|
18269
|
+
const { worldTransform, isLeafer, leafer, isFrame } = leaf;
|
|
18270
|
+
const { slice, clip, trim, screenshot, padding, onCanvas } = options;
|
|
18271
|
+
const smooth = options.smooth === undefined ? (leafer ? leafer.config.smooth : true) : options.smooth;
|
|
18272
|
+
const contextSettings = options.contextSettings || (leafer ? leafer.config.contextSettings : undefined);
|
|
18273
|
+
const fill = (isLeafer && screenshot) ? (options.fill === undefined ? leaf.fill : options.fill) : options.fill;
|
|
18274
|
+
const needFill = FileHelper.isOpaqueImage(filename) || fill, matrix = new Matrix();
|
|
18275
|
+
if (screenshot) {
|
|
18276
|
+
renderBounds = screenshot === true ? (isLeafer ? leafer.canvas.bounds : leaf.worldRenderBounds) : screenshot;
|
|
17983
18277
|
}
|
|
17984
|
-
|
|
17985
|
-
|
|
17986
|
-
|
|
17987
|
-
|
|
17988
|
-
|
|
17989
|
-
|
|
17990
|
-
|
|
17991
|
-
|
|
17992
|
-
|
|
17993
|
-
|
|
17994
|
-
|
|
17995
|
-
|
|
17996
|
-
|
|
17997
|
-
|
|
17998
|
-
|
|
17999
|
-
|
|
18000
|
-
|
|
18001
|
-
|
|
18002
|
-
|
|
18003
|
-
|
|
18004
|
-
|
|
18005
|
-
|
|
18006
|
-
|
|
18007
|
-
|
|
18008
|
-
|
|
18009
|
-
|
|
18010
|
-
|
|
18011
|
-
|
|
18012
|
-
|
|
18013
|
-
|
|
18014
|
-
|
|
18015
|
-
|
|
18016
|
-
|
|
18017
|
-
const
|
|
18018
|
-
canvas = Creator.canvas(
|
|
18019
|
-
|
|
18278
|
+
else {
|
|
18279
|
+
let relative = options.relative || (isLeafer ? 'inner' : 'local');
|
|
18280
|
+
scaleX = worldTransform.scaleX;
|
|
18281
|
+
scaleY = worldTransform.scaleY;
|
|
18282
|
+
switch (relative) {
|
|
18283
|
+
case 'inner':
|
|
18284
|
+
matrix.set(worldTransform);
|
|
18285
|
+
break;
|
|
18286
|
+
case 'local':
|
|
18287
|
+
matrix.set(worldTransform).divide(leaf.localTransform);
|
|
18288
|
+
scaleX /= leaf.scaleX;
|
|
18289
|
+
scaleY /= leaf.scaleY;
|
|
18290
|
+
break;
|
|
18291
|
+
case 'world':
|
|
18292
|
+
scaleX = 1;
|
|
18293
|
+
scaleY = 1;
|
|
18294
|
+
break;
|
|
18295
|
+
case 'page':
|
|
18296
|
+
relative = leafer || leaf;
|
|
18297
|
+
default:
|
|
18298
|
+
matrix.set(worldTransform).divide(leaf.getTransform(relative));
|
|
18299
|
+
const l = relative.worldTransform;
|
|
18300
|
+
scaleX /= scaleX / l.scaleX;
|
|
18301
|
+
scaleY /= scaleY / l.scaleY;
|
|
18302
|
+
}
|
|
18303
|
+
renderBounds = leaf.getBounds('render', relative);
|
|
18304
|
+
}
|
|
18305
|
+
const scaleData = { scaleX: 1, scaleY: 1 };
|
|
18306
|
+
MathHelper.getScaleData(options.scale, options.size, renderBounds, scaleData);
|
|
18307
|
+
let pixelRatio = options.pixelRatio || 1;
|
|
18308
|
+
let { x, y, width, height } = new Bounds(renderBounds).scale(scaleData.scaleX, scaleData.scaleY);
|
|
18309
|
+
if (clip)
|
|
18310
|
+
x += clip.x, y += clip.y, width = clip.width, height = clip.height;
|
|
18311
|
+
const renderOptions = { exporting: true, matrix: matrix.scale(1 / scaleData.scaleX, 1 / scaleData.scaleY).invert().translate(-x, -y).withScale(1 / scaleX * scaleData.scaleX, 1 / scaleY * scaleData.scaleY) };
|
|
18312
|
+
let canvas = Creator.canvas({ width: Math.floor(width), height: Math.floor(height), pixelRatio, smooth, contextSettings });
|
|
18313
|
+
let sliceLeaf;
|
|
18314
|
+
if (slice) {
|
|
18315
|
+
sliceLeaf = leaf;
|
|
18316
|
+
sliceLeaf.__worldOpacity = 0;
|
|
18317
|
+
leaf = leafer || leaf;
|
|
18318
|
+
renderOptions.bounds = canvas.bounds;
|
|
18319
|
+
}
|
|
18320
|
+
canvas.save();
|
|
18321
|
+
if (isFrame && fill !== undefined) {
|
|
18322
|
+
const oldFill = leaf.get('fill');
|
|
18323
|
+
leaf.fill = '';
|
|
18324
|
+
leaf.__render(canvas, renderOptions);
|
|
18325
|
+
leaf.fill = oldFill;
|
|
18326
|
+
}
|
|
18327
|
+
else {
|
|
18328
|
+
leaf.__render(canvas, renderOptions);
|
|
18329
|
+
}
|
|
18330
|
+
canvas.restore();
|
|
18331
|
+
if (sliceLeaf)
|
|
18332
|
+
sliceLeaf.__updateWorldOpacity();
|
|
18333
|
+
if (trim) {
|
|
18334
|
+
trimBounds = getTrimBounds(canvas);
|
|
18335
|
+
const old = canvas, { width, height } = trimBounds;
|
|
18336
|
+
const config = { x: 0, y: 0, width, height, pixelRatio };
|
|
18337
|
+
canvas = Creator.canvas(config);
|
|
18338
|
+
canvas.copyWorld(old, trimBounds, config);
|
|
18339
|
+
}
|
|
18340
|
+
if (padding) {
|
|
18341
|
+
const [top, right, bottom, left] = MathHelper.fourNumber(padding);
|
|
18342
|
+
const old = canvas, { width, height } = old;
|
|
18343
|
+
canvas = Creator.canvas({ width: width + left + right, height: height + top + bottom, pixelRatio });
|
|
18344
|
+
canvas.copyWorld(old, old.bounds, { x: left, y: top, width, height });
|
|
18345
|
+
}
|
|
18346
|
+
if (needFill)
|
|
18347
|
+
canvas.fillWorld(canvas.bounds, fill || '#FFFFFF', 'destination-over');
|
|
18348
|
+
if (onCanvas)
|
|
18349
|
+
onCanvas(canvas);
|
|
18350
|
+
const data = filename === 'canvas' ? canvas : canvas.export(filename, options);
|
|
18351
|
+
result = { data, width: canvas.pixelWidth, height: canvas.pixelHeight, renderBounds, trimBounds };
|
|
18020
18352
|
}
|
|
18021
|
-
if (padding) {
|
|
18022
|
-
const [top, right, bottom, left] = MathHelper.fourNumber(padding);
|
|
18023
|
-
const old = canvas, { width, height } = old;
|
|
18024
|
-
canvas = Creator.canvas({ width: width + left + right, height: height + top + bottom, pixelRatio });
|
|
18025
|
-
canvas.copyWorld(old, old.bounds, { x: left, y: top, width, height });
|
|
18026
|
-
}
|
|
18027
|
-
if (needFill)
|
|
18028
|
-
canvas.fillWorld(canvas.bounds, fill || '#FFFFFF', 'destination-over');
|
|
18029
|
-
if (onCanvas)
|
|
18030
|
-
onCanvas(canvas);
|
|
18031
|
-
const data = filename === 'canvas' ? canvas : canvas.export(filename, options);
|
|
18032
|
-
result = { data, width: canvas.pixelWidth, height: canvas.pixelHeight, renderBounds, trimBounds };
|
|
18033
18353
|
}
|
|
18034
|
-
|
|
18354
|
+
catch (error) {
|
|
18355
|
+
result = { data: '', error };
|
|
18356
|
+
}
|
|
18357
|
+
Export.running = false;
|
|
18035
18358
|
return result;
|
|
18036
18359
|
},
|
|
18037
18360
|
export(leaf, filename, options) {
|
|
18038
|
-
|
|
18361
|
+
Export.running = true;
|
|
18039
18362
|
return addTask((success) => new Promise((resolve) => {
|
|
18040
18363
|
const getResult = () => __awaiter(this, void 0, void 0, function* () {
|
|
18041
18364
|
if (!Resource.isComplete)
|
|
18042
18365
|
return Platform.requestRender(getResult);
|
|
18043
|
-
const result =
|
|
18366
|
+
const result = Export.syncExport(leaf, filename, options);
|
|
18044
18367
|
if (result.data instanceof Promise)
|
|
18045
18368
|
result.data = yield result.data;
|
|
18046
18369
|
success(result);
|
|
@@ -18168,7 +18491,6 @@ ${filterStyle$1}
|
|
|
18168
18491
|
exports.EditSelect = EditSelect;
|
|
18169
18492
|
exports.EditSelectHelper = EditSelectHelper;
|
|
18170
18493
|
exports.EditToolCreator = EditToolCreator;
|
|
18171
|
-
exports.Editor = Editor;
|
|
18172
18494
|
exports.EditorEvent = EditorEvent;
|
|
18173
18495
|
exports.EditorGroupEvent = EditorGroupEvent;
|
|
18174
18496
|
exports.EditorHelper = EditorHelper;
|
|
@@ -18279,6 +18601,7 @@ ${filterStyle$1}
|
|
|
18279
18601
|
exports.TaskProcessor = TaskProcessor;
|
|
18280
18602
|
exports.TextConvert = TextConvert;
|
|
18281
18603
|
exports.TextData = TextData;
|
|
18604
|
+
exports.TransformTool = TransformTool;
|
|
18282
18605
|
exports.Transformer = Transformer;
|
|
18283
18606
|
exports.Transition = Transition;
|
|
18284
18607
|
exports.TwoPointBoundsHelper = TwoPointBoundsHelper;
|
|
@@ -18302,6 +18625,8 @@ ${filterStyle$1}
|
|
|
18302
18625
|
exports.boundsType = boundsType;
|
|
18303
18626
|
exports.canvasPatch = canvasPatch;
|
|
18304
18627
|
exports.canvasSizeAttrs = canvasSizeAttrs;
|
|
18628
|
+
exports.createAttr = createAttr;
|
|
18629
|
+
exports.createDescriptor = createDescriptor;
|
|
18305
18630
|
exports.cursorType = cursorType;
|
|
18306
18631
|
exports.dataProcessor = dataProcessor;
|
|
18307
18632
|
exports.dataType = dataType;
|
|
@@ -18350,7 +18675,7 @@ ${filterStyle$1}
|
|
|
18350
18675
|
exports.strokeType = strokeType;
|
|
18351
18676
|
exports.surfaceType = surfaceType;
|
|
18352
18677
|
exports.tempBounds = tempBounds$1;
|
|
18353
|
-
exports.tempMatrix = tempMatrix;
|
|
18678
|
+
exports.tempMatrix = tempMatrix$1;
|
|
18354
18679
|
exports.tempPoint = tempPoint$3;
|
|
18355
18680
|
exports.useCanvas = useCanvas;
|
|
18356
18681
|
exports.useModule = useModule;
|