@anu3ev/fabric-image-editor 0.7.4 → 0.7.6
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/main.js +1312 -981
- package/dist/stats.html +1 -1
- package/package.json +1 -1
- package/readme.md +3 -0
package/dist/main.js
CHANGED
|
@@ -2780,37 +2780,37 @@ var Xe = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
|
|
|
2780
2780
|
});
|
|
2781
2781
|
}
|
|
2782
2782
|
}, G = 180, et = {
|
|
2783
|
-
top:
|
|
2784
|
-
right:
|
|
2785
|
-
bottom:
|
|
2786
|
-
left:
|
|
2787
|
-
}, tt = ({ value: e }) => Number(e.toFixed(4)),
|
|
2783
|
+
top: 0,
|
|
2784
|
+
right: 0,
|
|
2785
|
+
bottom: 0,
|
|
2786
|
+
left: 0
|
|
2787
|
+
}, tt = .45, nt = ({ value: e }) => Number(e.toFixed(4)), rt = ({ sides: e, radius: t = 50, centerX: n = 50, centerY: r = 50, rotation: i = -Math.PI / 2 }) => {
|
|
2788
2788
|
let a = [];
|
|
2789
2789
|
for (let o = 0; o < e; o += 1) {
|
|
2790
2790
|
let s = i + o * Math.PI * 2 / e;
|
|
2791
2791
|
a.push({
|
|
2792
|
-
x:
|
|
2793
|
-
y:
|
|
2792
|
+
x: nt({ value: n + t * Math.cos(s) }),
|
|
2793
|
+
y: nt({ value: r + t * Math.sin(s) })
|
|
2794
2794
|
});
|
|
2795
2795
|
}
|
|
2796
2796
|
return a;
|
|
2797
|
-
},
|
|
2797
|
+
}, it = ({ spikes: e, outerRadius: t = 50, innerRadius: n = 22, centerX: r = 50, centerY: i = 50, rotation: a = -Math.PI / 2 }) => {
|
|
2798
2798
|
let o = [], s = e * 2;
|
|
2799
2799
|
for (let c = 0; c < s; c += 1) {
|
|
2800
2800
|
let s = c % 2 == 0 ? t : n, l = a + c * Math.PI / e;
|
|
2801
2801
|
o.push({
|
|
2802
|
-
x:
|
|
2803
|
-
y:
|
|
2802
|
+
x: nt({ value: r + s * Math.cos(l) }),
|
|
2803
|
+
y: nt({ value: i + s * Math.sin(l) })
|
|
2804
2804
|
});
|
|
2805
2805
|
}
|
|
2806
2806
|
return o;
|
|
2807
|
-
},
|
|
2807
|
+
}, at = [
|
|
2808
2808
|
{
|
|
2809
2809
|
key: "circle",
|
|
2810
2810
|
type: "ellipse",
|
|
2811
2811
|
width: G,
|
|
2812
2812
|
height: G,
|
|
2813
|
-
|
|
2813
|
+
internalTextInset: {
|
|
2814
2814
|
top: .24,
|
|
2815
2815
|
right: .24,
|
|
2816
2816
|
bottom: .24,
|
|
@@ -2822,7 +2822,7 @@ var Xe = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
|
|
|
2822
2822
|
type: "triangle",
|
|
2823
2823
|
width: G,
|
|
2824
2824
|
height: G,
|
|
2825
|
-
|
|
2825
|
+
internalTextInset: {
|
|
2826
2826
|
top: .38,
|
|
2827
2827
|
right: .2,
|
|
2828
2828
|
bottom: .14,
|
|
@@ -2858,7 +2858,7 @@ var Xe = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
|
|
|
2858
2858
|
y: 50
|
|
2859
2859
|
}
|
|
2860
2860
|
],
|
|
2861
|
-
|
|
2861
|
+
internalTextInset: {
|
|
2862
2862
|
top: .3,
|
|
2863
2863
|
right: .3,
|
|
2864
2864
|
bottom: .3,
|
|
@@ -2870,12 +2870,12 @@ var Xe = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
|
|
|
2870
2870
|
type: "polygon",
|
|
2871
2871
|
width: G,
|
|
2872
2872
|
height: G,
|
|
2873
|
-
points:
|
|
2873
|
+
points: rt({
|
|
2874
2874
|
sides: 5,
|
|
2875
2875
|
radius: 50,
|
|
2876
2876
|
rotation: -Math.PI / 2
|
|
2877
2877
|
}),
|
|
2878
|
-
|
|
2878
|
+
internalTextInset: {
|
|
2879
2879
|
top: .28,
|
|
2880
2880
|
right: .2,
|
|
2881
2881
|
bottom: .2,
|
|
@@ -2887,12 +2887,12 @@ var Xe = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
|
|
|
2887
2887
|
type: "polygon",
|
|
2888
2888
|
width: G,
|
|
2889
2889
|
height: G,
|
|
2890
|
-
points:
|
|
2890
|
+
points: rt({
|
|
2891
2891
|
sides: 6,
|
|
2892
2892
|
radius: 50,
|
|
2893
2893
|
rotation: 0
|
|
2894
2894
|
}),
|
|
2895
|
-
|
|
2895
|
+
internalTextInset: {
|
|
2896
2896
|
top: .24,
|
|
2897
2897
|
right: .2,
|
|
2898
2898
|
bottom: .24,
|
|
@@ -2904,13 +2904,13 @@ var Xe = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
|
|
|
2904
2904
|
type: "polygon",
|
|
2905
2905
|
width: G,
|
|
2906
2906
|
height: G,
|
|
2907
|
-
points:
|
|
2907
|
+
points: it({
|
|
2908
2908
|
spikes: 5,
|
|
2909
2909
|
outerRadius: 50,
|
|
2910
2910
|
innerRadius: 21,
|
|
2911
2911
|
rotation: -Math.PI / 2
|
|
2912
2912
|
}),
|
|
2913
|
-
|
|
2913
|
+
internalTextInset: {
|
|
2914
2914
|
top: .32,
|
|
2915
2915
|
right: .32,
|
|
2916
2916
|
bottom: .32,
|
|
@@ -2922,13 +2922,13 @@ var Xe = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
|
|
|
2922
2922
|
type: "polygon",
|
|
2923
2923
|
width: G,
|
|
2924
2924
|
height: G,
|
|
2925
|
-
points:
|
|
2925
|
+
points: it({
|
|
2926
2926
|
spikes: 4,
|
|
2927
2927
|
outerRadius: 50,
|
|
2928
2928
|
innerRadius: 16,
|
|
2929
2929
|
rotation: -Math.PI / 2
|
|
2930
2930
|
}),
|
|
2931
|
-
|
|
2931
|
+
internalTextInset: {
|
|
2932
2932
|
top: .34,
|
|
2933
2933
|
right: .34,
|
|
2934
2934
|
bottom: .34,
|
|
@@ -2946,7 +2946,7 @@ var Xe = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
|
|
|
2946
2946
|
"C53 12 60 8 70 8 C84 8 96 19 96 35",
|
|
2947
2947
|
"C96 56 80 74 50 92 Z"
|
|
2948
2948
|
].join(" "),
|
|
2949
|
-
|
|
2949
|
+
internalTextInset: {
|
|
2950
2950
|
top: .3,
|
|
2951
2951
|
right: .28,
|
|
2952
2952
|
bottom: .22,
|
|
@@ -2988,7 +2988,7 @@ var Xe = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
|
|
|
2988
2988
|
y: 62
|
|
2989
2989
|
}
|
|
2990
2990
|
],
|
|
2991
|
-
|
|
2991
|
+
internalTextInset: {
|
|
2992
2992
|
top: .24,
|
|
2993
2993
|
right: .42,
|
|
2994
2994
|
bottom: .24,
|
|
@@ -3030,7 +3030,7 @@ var Xe = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
|
|
|
3030
3030
|
y: 100
|
|
3031
3031
|
}
|
|
3032
3032
|
],
|
|
3033
|
-
|
|
3033
|
+
internalTextInset: {
|
|
3034
3034
|
top: .4,
|
|
3035
3035
|
right: .24,
|
|
3036
3036
|
bottom: .16,
|
|
@@ -3072,7 +3072,7 @@ var Xe = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
|
|
|
3072
3072
|
y: 58
|
|
3073
3073
|
}
|
|
3074
3074
|
],
|
|
3075
|
-
|
|
3075
|
+
internalTextInset: {
|
|
3076
3076
|
top: .24,
|
|
3077
3077
|
right: .4,
|
|
3078
3078
|
bottom: .24,
|
|
@@ -3114,7 +3114,7 @@ var Xe = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
|
|
|
3114
3114
|
y: 0
|
|
3115
3115
|
}
|
|
3116
3116
|
],
|
|
3117
|
-
|
|
3117
|
+
internalTextInset: {
|
|
3118
3118
|
top: .16,
|
|
3119
3119
|
right: .24,
|
|
3120
3120
|
bottom: .4,
|
|
@@ -3168,7 +3168,7 @@ var Xe = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
|
|
|
3168
3168
|
y: 34
|
|
3169
3169
|
}
|
|
3170
3170
|
],
|
|
3171
|
-
|
|
3171
|
+
internalTextInset: {
|
|
3172
3172
|
top: .38,
|
|
3173
3173
|
right: .26,
|
|
3174
3174
|
bottom: .38,
|
|
@@ -3222,7 +3222,7 @@ var Xe = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
|
|
|
3222
3222
|
y: 82
|
|
3223
3223
|
}
|
|
3224
3224
|
],
|
|
3225
|
-
|
|
3225
|
+
internalTextInset: {
|
|
3226
3226
|
top: .26,
|
|
3227
3227
|
right: .34,
|
|
3228
3228
|
bottom: .26,
|
|
@@ -3235,7 +3235,7 @@ var Xe = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
|
|
|
3235
3235
|
width: 140,
|
|
3236
3236
|
height: G,
|
|
3237
3237
|
path: "M50 0 C68 18 88 41 88 62 C88 84 71 100 50 100 C29 100 12 84 12 62 C12 41 32 18 50 0 Z",
|
|
3238
|
-
|
|
3238
|
+
internalTextInset: {
|
|
3239
3239
|
top: .3,
|
|
3240
3240
|
right: .27,
|
|
3241
3241
|
bottom: .2,
|
|
@@ -3297,7 +3297,7 @@ var Xe = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
|
|
|
3297
3297
|
y: 36
|
|
3298
3298
|
}
|
|
3299
3299
|
],
|
|
3300
|
-
|
|
3300
|
+
internalTextInset: {
|
|
3301
3301
|
top: .34,
|
|
3302
3302
|
right: .34,
|
|
3303
3303
|
bottom: .34,
|
|
@@ -3309,13 +3309,13 @@ var Xe = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
|
|
|
3309
3309
|
type: "polygon",
|
|
3310
3310
|
width: G,
|
|
3311
3311
|
height: G,
|
|
3312
|
-
points:
|
|
3312
|
+
points: it({
|
|
3313
3313
|
spikes: 14,
|
|
3314
3314
|
outerRadius: 50,
|
|
3315
3315
|
innerRadius: 40,
|
|
3316
3316
|
rotation: -Math.PI / 2
|
|
3317
3317
|
}),
|
|
3318
|
-
|
|
3318
|
+
internalTextInset: {
|
|
3319
3319
|
top: .28,
|
|
3320
3320
|
right: .28,
|
|
3321
3321
|
bottom: .28,
|
|
@@ -3328,7 +3328,7 @@ var Xe = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
|
|
|
3328
3328
|
width: G,
|
|
3329
3329
|
height: G,
|
|
3330
3330
|
path: "M24 6 H76 L94 24 V76 L76 94 H24 L6 76 V24 Z",
|
|
3331
|
-
|
|
3331
|
+
internalTextInset: {
|
|
3332
3332
|
top: .24,
|
|
3333
3333
|
right: .24,
|
|
3334
3334
|
bottom: .24,
|
|
@@ -3362,7 +3362,7 @@ var Xe = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
|
|
|
3362
3362
|
y: 100
|
|
3363
3363
|
}
|
|
3364
3364
|
],
|
|
3365
|
-
|
|
3365
|
+
internalTextInset: {
|
|
3366
3366
|
top: .2,
|
|
3367
3367
|
right: .22,
|
|
3368
3368
|
bottom: .34,
|
|
@@ -3375,7 +3375,7 @@ var Xe = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
|
|
|
3375
3375
|
width: G,
|
|
3376
3376
|
height: 130,
|
|
3377
3377
|
path: "M4 20 L64 20 L96 50 L64 80 L4 80 Z",
|
|
3378
|
-
|
|
3378
|
+
internalTextInset: {
|
|
3379
3379
|
top: .24,
|
|
3380
3380
|
right: .34,
|
|
3381
3381
|
bottom: .24,
|
|
@@ -3393,28 +3393,45 @@ var Xe = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
|
|
|
3393
3393
|
"C82 102 58 78 58 48 C58 28 68 12 84 4",
|
|
3394
3394
|
"C79 4 74 4 68 4 Z"
|
|
3395
3395
|
].join(" "),
|
|
3396
|
-
|
|
3396
|
+
internalTextInset: {
|
|
3397
3397
|
top: .28,
|
|
3398
3398
|
right: .34,
|
|
3399
3399
|
bottom: .28,
|
|
3400
3400
|
left: .2
|
|
3401
3401
|
}
|
|
3402
3402
|
}
|
|
3403
|
-
],
|
|
3404
|
-
for (let e = 0; e <
|
|
3405
|
-
let t =
|
|
3406
|
-
|
|
3403
|
+
], ot = "circle", st = "center", ct = {};
|
|
3404
|
+
for (let e = 0; e < at.length; e += 1) {
|
|
3405
|
+
let t = at[e];
|
|
3406
|
+
ct[t.key] = t;
|
|
3407
|
+
}
|
|
3408
|
+
var lt = ct, ut = ({ presetKey: e }) => lt[e] ?? null, dt = ({ preset: e, rounding: t }) => (typeof t == "number" ? t : 0) <= 0 || e.type === "rect" ? e.key : e.roundedVariant ?? e.key;
|
|
3409
|
+
function ft({ value: e, size: t }) {
|
|
3410
|
+
let n = Number.isFinite(e) ? Math.min(Math.max(e, 0), tt) : 0;
|
|
3411
|
+
return (Number.isFinite(t) && t > 0 ? t : 0) * n;
|
|
3407
3412
|
}
|
|
3408
|
-
var
|
|
3409
|
-
let
|
|
3413
|
+
var pt = ({ preset: e, width: t, height: n }) => {
|
|
3414
|
+
let r = e.internalTextInset ?? {};
|
|
3410
3415
|
return {
|
|
3411
|
-
top:
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3416
|
+
top: ft({
|
|
3417
|
+
value: r.top ?? et.top,
|
|
3418
|
+
size: n
|
|
3419
|
+
}),
|
|
3420
|
+
right: ft({
|
|
3421
|
+
value: r.right ?? et.right,
|
|
3422
|
+
size: t
|
|
3423
|
+
}),
|
|
3424
|
+
bottom: ft({
|
|
3425
|
+
value: r.bottom ?? et.bottom,
|
|
3426
|
+
size: n
|
|
3427
|
+
}),
|
|
3428
|
+
left: ft({
|
|
3429
|
+
value: r.left ?? et.left,
|
|
3430
|
+
size: t
|
|
3431
|
+
})
|
|
3415
3432
|
};
|
|
3416
|
-
}
|
|
3417
|
-
function
|
|
3433
|
+
};
|
|
3434
|
+
function mt({ path: e }) {
|
|
3418
3435
|
let t = e.match(/[a-zA-Z]/g) ?? [], n = new Set([
|
|
3419
3436
|
"M",
|
|
3420
3437
|
"L",
|
|
@@ -3428,13 +3445,24 @@ function pt({ path: e }) {
|
|
|
3428
3445
|
}
|
|
3429
3446
|
return t.length > 0;
|
|
3430
3447
|
}
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3448
|
+
var ht = ({ preset: e }) => e.type === "rect" || e.type === "triangle" || e.type === "polygon" || e.type === "polyline" ? !0 : e.type === "ellipse" || e.type === "svg" ? !1 : mt({ path: e.path }), gt = 1, _t = 1e-4;
|
|
3449
|
+
function K({ value: e }) {
|
|
3450
|
+
return Number(e.toFixed(4));
|
|
3451
|
+
}
|
|
3452
|
+
function vt({ rounding: e }) {
|
|
3453
|
+
return Math.max(0, e ?? 0) > 0;
|
|
3454
|
+
}
|
|
3455
|
+
function yt({ width: e, height: t, strokeWidth: n }) {
|
|
3456
|
+
let r = Math.max(0, n ?? 0);
|
|
3457
|
+
return {
|
|
3458
|
+
width: Math.max(gt, e - r),
|
|
3459
|
+
height: Math.max(gt, t - r)
|
|
3460
|
+
};
|
|
3461
|
+
}
|
|
3462
|
+
function bt({ shape: e, width: t, height: n, rounding: r, strokeWidth: i }) {
|
|
3463
|
+
let a = yt({
|
|
3464
|
+
width: Math.max(gt, t),
|
|
3465
|
+
height: Math.max(gt, n),
|
|
3438
3466
|
strokeWidth: i
|
|
3439
3467
|
});
|
|
3440
3468
|
if (e instanceof g) {
|
|
@@ -3453,7 +3481,7 @@ function gt({ shape: e, width: t, height: n, rounding: r, strokeWidth: i }) {
|
|
|
3453
3481
|
}), e.setCoords();
|
|
3454
3482
|
return;
|
|
3455
3483
|
}
|
|
3456
|
-
let { width: o =
|
|
3484
|
+
let { width: o = gt, height: s = gt } = e, c = Math.max(gt, o), l = Math.max(gt, s);
|
|
3457
3485
|
e.set({
|
|
3458
3486
|
scaleX: a.width / c,
|
|
3459
3487
|
scaleY: a.height / l,
|
|
@@ -3463,33 +3491,11 @@ function gt({ shape: e, width: t, height: n, rounding: r, strokeWidth: i }) {
|
|
|
3463
3491
|
originY: "center"
|
|
3464
3492
|
}), e.setCoords();
|
|
3465
3493
|
}
|
|
3466
|
-
|
|
3467
|
-
let a = await yt({
|
|
3468
|
-
preset: e,
|
|
3469
|
-
rounding: i
|
|
3470
|
-
});
|
|
3471
|
-
return vt({
|
|
3472
|
-
shape: a,
|
|
3473
|
-
style: r
|
|
3474
|
-
}), gt({
|
|
3475
|
-
shape: a,
|
|
3476
|
-
width: t,
|
|
3477
|
-
height: n,
|
|
3478
|
-
rounding: i,
|
|
3479
|
-
strokeWidth: r.strokeWidth
|
|
3480
|
-
}), a.set({
|
|
3481
|
-
selectable: !1,
|
|
3482
|
-
evented: !1,
|
|
3483
|
-
hasControls: !1,
|
|
3484
|
-
hasBorders: !1,
|
|
3485
|
-
shapeNodeType: "shape"
|
|
3486
|
-
}), a;
|
|
3487
|
-
}
|
|
3488
|
-
function vt({ shape: e, style: t }) {
|
|
3494
|
+
function xt({ shape: e, style: t }) {
|
|
3489
3495
|
let { fill: n, stroke: r, strokeWidth: i, strokeDashArray: a, opacity: o } = t;
|
|
3490
3496
|
if (e instanceof l) {
|
|
3491
3497
|
let n = e.getObjects();
|
|
3492
|
-
for (let e = 0; e < n.length; e += 1)
|
|
3498
|
+
for (let e = 0; e < n.length; e += 1) xt({
|
|
3493
3499
|
shape: n[e],
|
|
3494
3500
|
style: t
|
|
3495
3501
|
});
|
|
@@ -3503,50 +3509,106 @@ function vt({ shape: e, style: t }) {
|
|
|
3503
3509
|
};
|
|
3504
3510
|
n !== void 0 && (s.fill = n), r !== void 0 && (s.stroke = r), i !== void 0 && (s.strokeWidth = i), a !== void 0 && (s.strokeDashArray = a), o !== void 0 && (s.opacity = o), e.set(s), e.setCoords();
|
|
3505
3511
|
}
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
}
|
|
3533
|
-
|
|
3534
|
-
|
|
3512
|
+
function St({ points: e, closed: t }) {
|
|
3513
|
+
if (e.length === 0) return "";
|
|
3514
|
+
let n = `M ${K({ value: e[0].x })} ${K({ value: e[0].y })}`;
|
|
3515
|
+
for (let t = 1; t < e.length; t += 1) {
|
|
3516
|
+
let r = e[t];
|
|
3517
|
+
n += ` L ${K({ value: r.x })} ${K({ value: r.y })}`;
|
|
3518
|
+
}
|
|
3519
|
+
return t && (n += " Z"), n;
|
|
3520
|
+
}
|
|
3521
|
+
function Ct({ previous: e, current: t, next: n, radius: r }) {
|
|
3522
|
+
let i = {
|
|
3523
|
+
x: e.x - t.x,
|
|
3524
|
+
y: e.y - t.y
|
|
3525
|
+
}, a = {
|
|
3526
|
+
x: n.x - t.x,
|
|
3527
|
+
y: n.y - t.y
|
|
3528
|
+
}, o = Math.hypot(i.x, i.y), s = Math.hypot(a.x, a.y);
|
|
3529
|
+
if (o <= _t || s <= _t) return {
|
|
3530
|
+
start: {
|
|
3531
|
+
x: K({ value: t.x }),
|
|
3532
|
+
y: K({ value: t.y })
|
|
3533
|
+
},
|
|
3534
|
+
end: {
|
|
3535
|
+
x: K({ value: t.x }),
|
|
3536
|
+
y: K({ value: t.y })
|
|
3537
|
+
}
|
|
3538
|
+
};
|
|
3539
|
+
let c = Math.min(Math.max(0, r), o / 2, s / 2);
|
|
3540
|
+
return {
|
|
3541
|
+
start: {
|
|
3542
|
+
x: K({ value: t.x + i.x / o * c }),
|
|
3543
|
+
y: K({ value: t.y + i.y / o * c })
|
|
3544
|
+
},
|
|
3545
|
+
end: {
|
|
3546
|
+
x: K({ value: t.x + a.x / s * c }),
|
|
3547
|
+
y: K({ value: t.y + a.y / s * c })
|
|
3548
|
+
}
|
|
3549
|
+
};
|
|
3550
|
+
}
|
|
3551
|
+
function wt({ points: e, radius: t, closed: n }) {
|
|
3552
|
+
let r = e.length;
|
|
3553
|
+
if (r === 0) return "";
|
|
3554
|
+
if (!n && r === 1) {
|
|
3555
|
+
let t = e[0];
|
|
3556
|
+
return `M ${K({ value: t.x })} ${K({ value: t.y })}`;
|
|
3557
|
+
}
|
|
3558
|
+
let i = Math.max(0, t);
|
|
3559
|
+
if (i <= 0) return St({
|
|
3560
|
+
points: e,
|
|
3561
|
+
closed: n
|
|
3562
|
+
});
|
|
3563
|
+
if (n) {
|
|
3564
|
+
let t = [];
|
|
3565
|
+
for (let n = 0; n < r; n += 1) {
|
|
3566
|
+
let a = n === 0 ? r - 1 : n - 1, o = n === r - 1 ? 0 : n + 1;
|
|
3567
|
+
t.push(Ct({
|
|
3568
|
+
previous: e[a],
|
|
3569
|
+
current: e[n],
|
|
3570
|
+
next: e[o],
|
|
3571
|
+
radius: i
|
|
3572
|
+
}));
|
|
3573
|
+
}
|
|
3574
|
+
let n = t[0], a = `M ${n.start.x} ${n.start.y}`;
|
|
3575
|
+
for (let n = 0; n < r; n += 1) {
|
|
3576
|
+
let i = e[n], o = t[n], s = t[n === r - 1 ? 0 : n + 1];
|
|
3577
|
+
a += ` Q ${i.x} ${i.y} ${o.end.x} ${o.end.y}`, a += ` L ${s.start.x} ${s.start.y}`;
|
|
3578
|
+
}
|
|
3579
|
+
return a += " Z", a;
|
|
3580
|
+
}
|
|
3581
|
+
if (r === 2) return St({
|
|
3582
|
+
points: e,
|
|
3583
|
+
closed: !1
|
|
3584
|
+
});
|
|
3585
|
+
let a = `M ${K({ value: e[0].x })} ${K({ value: e[0].y })}`;
|
|
3586
|
+
for (let t = 1; t < r - 1; t += 1) {
|
|
3587
|
+
let n = Ct({
|
|
3588
|
+
previous: e[t - 1],
|
|
3589
|
+
current: e[t],
|
|
3590
|
+
next: e[t + 1],
|
|
3591
|
+
radius: i
|
|
3592
|
+
});
|
|
3593
|
+
a += ` L ${n.start.x} ${n.start.y}`, a += ` Q ${e[t].x} ${e[t].y} ${n.end.x} ${n.end.y}`;
|
|
3594
|
+
}
|
|
3595
|
+
let o = e[r - 1];
|
|
3596
|
+
return a += ` L ${K({ value: o.x })} ${K({ value: o.y })}`, a;
|
|
3597
|
+
}
|
|
3598
|
+
function Tt({ points: e, rounding: t, closed: n }) {
|
|
3599
|
+
return new d(wt({
|
|
3600
|
+
points: e,
|
|
3601
|
+
radius: t,
|
|
3602
|
+
closed: n
|
|
3603
|
+
}), {
|
|
3535
3604
|
originX: "center",
|
|
3536
3605
|
originY: "center",
|
|
3537
3606
|
left: 0,
|
|
3538
3607
|
top: 0
|
|
3539
3608
|
});
|
|
3540
3609
|
}
|
|
3541
|
-
function
|
|
3542
|
-
|
|
3543
|
-
return {
|
|
3544
|
-
width: Math.max(mt, e - r),
|
|
3545
|
-
height: Math.max(mt, t - r)
|
|
3546
|
-
};
|
|
3547
|
-
}
|
|
3548
|
-
function xt({ rounding: e }) {
|
|
3549
|
-
return At({ rounding: e }) ? Et({
|
|
3610
|
+
function Et({ rounding: e }) {
|
|
3611
|
+
return vt({ rounding: e }) ? Tt({
|
|
3550
3612
|
points: [
|
|
3551
3613
|
{
|
|
3552
3614
|
x: 50,
|
|
@@ -3572,13 +3634,48 @@ function xt({ rounding: e }) {
|
|
|
3572
3634
|
top: 0
|
|
3573
3635
|
});
|
|
3574
3636
|
}
|
|
3575
|
-
function
|
|
3576
|
-
return
|
|
3637
|
+
function Dt({ path: e }) {
|
|
3638
|
+
return new d(e, {
|
|
3639
|
+
originX: "center",
|
|
3640
|
+
originY: "center",
|
|
3641
|
+
left: 0,
|
|
3642
|
+
top: 0
|
|
3643
|
+
});
|
|
3644
|
+
}
|
|
3645
|
+
function Ot({ path: e, rounding: t }) {
|
|
3646
|
+
let n = Dt({ path: e }).path ?? [], r = C.makePathSimpler(n), i = [], a = !1;
|
|
3647
|
+
for (let e = 0; e < r.length; e += 1) {
|
|
3648
|
+
let t = r[e];
|
|
3649
|
+
if (!t) return null;
|
|
3650
|
+
let n = t[0], o = typeof n == "string" ? n.toUpperCase() : "";
|
|
3651
|
+
if (o === "M" || o === "L") {
|
|
3652
|
+
let e = Number(t[1]), n = Number(t[2]);
|
|
3653
|
+
if (!Number.isFinite(e) || !Number.isFinite(n)) return null;
|
|
3654
|
+
i.push({
|
|
3655
|
+
x: e,
|
|
3656
|
+
y: n
|
|
3657
|
+
});
|
|
3658
|
+
continue;
|
|
3659
|
+
}
|
|
3660
|
+
if (o === "Z") {
|
|
3661
|
+
a = !0;
|
|
3662
|
+
continue;
|
|
3663
|
+
}
|
|
3664
|
+
return null;
|
|
3665
|
+
}
|
|
3666
|
+
return i.length < 2 || a && i.length < 3 ? null : Tt({
|
|
3667
|
+
points: i,
|
|
3668
|
+
rounding: t,
|
|
3669
|
+
closed: a
|
|
3670
|
+
});
|
|
3671
|
+
}
|
|
3672
|
+
function kt({ path: e, rounding: t }) {
|
|
3673
|
+
return vt({ rounding: t }) && Ot({
|
|
3577
3674
|
path: e,
|
|
3578
3675
|
rounding: Math.max(0, t ?? 0)
|
|
3579
|
-
}) ||
|
|
3676
|
+
}) || Dt({ path: e });
|
|
3580
3677
|
}
|
|
3581
|
-
function
|
|
3678
|
+
function At({ points: e, type: t, rounding: n }) {
|
|
3582
3679
|
let r = e.length > 0 ? e : [
|
|
3583
3680
|
{
|
|
3584
3681
|
x: 0,
|
|
@@ -3592,208 +3689,405 @@ function Ct({ points: e, type: t, rounding: n }) {
|
|
|
3592
3689
|
x: 100,
|
|
3593
3690
|
y: 100
|
|
3594
3691
|
}
|
|
3595
|
-
];
|
|
3596
|
-
if (
|
|
3597
|
-
if (t === "polygon" && r.length >= 3) return
|
|
3692
|
+
], i = Math.max(0, n ?? 0);
|
|
3693
|
+
if (vt({ rounding: n })) {
|
|
3694
|
+
if (t === "polygon" && r.length >= 3) return Tt({
|
|
3598
3695
|
points: r,
|
|
3599
|
-
rounding:
|
|
3696
|
+
rounding: i,
|
|
3600
3697
|
closed: !0
|
|
3601
3698
|
});
|
|
3602
|
-
if (t === "polyline" && r.length >= 2) return
|
|
3699
|
+
if (t === "polyline" && r.length >= 2) return Tt({
|
|
3603
3700
|
points: r,
|
|
3604
|
-
rounding:
|
|
3701
|
+
rounding: i,
|
|
3605
3702
|
closed: !1
|
|
3606
3703
|
});
|
|
3607
3704
|
}
|
|
3608
|
-
return t === "polyline" ?
|
|
3609
|
-
originX: "center",
|
|
3610
|
-
originY: "center",
|
|
3611
|
-
left: 0,
|
|
3612
|
-
top: 0
|
|
3613
|
-
}) : new m(r, {
|
|
3705
|
+
return new (t === "polyline" ? h : m)(r, {
|
|
3614
3706
|
originX: "center",
|
|
3615
3707
|
originY: "center",
|
|
3616
3708
|
left: 0,
|
|
3617
3709
|
top: 0
|
|
3618
3710
|
});
|
|
3619
3711
|
}
|
|
3620
|
-
function
|
|
3621
|
-
|
|
3712
|
+
async function jt({ svg: e }) {
|
|
3713
|
+
let t = await x(e), n = C.groupSVGElements(t.objects, t.options);
|
|
3714
|
+
return n.set({
|
|
3622
3715
|
originX: "center",
|
|
3623
3716
|
originY: "center",
|
|
3624
3717
|
left: 0,
|
|
3625
3718
|
top: 0
|
|
3626
|
-
});
|
|
3719
|
+
}), n.setCoords(), n;
|
|
3627
3720
|
}
|
|
3628
|
-
function
|
|
3629
|
-
|
|
3630
|
-
|
|
3631
|
-
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
}
|
|
3647
|
-
return
|
|
3721
|
+
async function Mt({ preset: e, rounding: t }) {
|
|
3722
|
+
switch (e.type) {
|
|
3723
|
+
case "rect": return new g({
|
|
3724
|
+
width: 100,
|
|
3725
|
+
height: 100,
|
|
3726
|
+
originX: "center",
|
|
3727
|
+
originY: "center",
|
|
3728
|
+
left: 0,
|
|
3729
|
+
top: 0
|
|
3730
|
+
});
|
|
3731
|
+
case "ellipse": return new i({
|
|
3732
|
+
rx: 50,
|
|
3733
|
+
ry: 50,
|
|
3734
|
+
originX: "center",
|
|
3735
|
+
originY: "center",
|
|
3736
|
+
left: 0,
|
|
3737
|
+
top: 0
|
|
3738
|
+
});
|
|
3739
|
+
case "triangle": return Et({ rounding: t });
|
|
3740
|
+
case "polygon": return At({
|
|
3741
|
+
points: e.points,
|
|
3742
|
+
type: "polygon",
|
|
3743
|
+
rounding: t
|
|
3744
|
+
});
|
|
3745
|
+
case "polyline": return At({
|
|
3746
|
+
points: e.points,
|
|
3747
|
+
type: "polyline",
|
|
3748
|
+
rounding: t
|
|
3749
|
+
});
|
|
3750
|
+
case "path": return kt({
|
|
3751
|
+
path: e.path,
|
|
3752
|
+
rounding: t
|
|
3753
|
+
});
|
|
3754
|
+
case "svg": return jt({ svg: e.svg });
|
|
3755
|
+
default: return new g({
|
|
3756
|
+
width: 100,
|
|
3757
|
+
height: 100,
|
|
3758
|
+
originX: "center",
|
|
3759
|
+
originY: "center",
|
|
3760
|
+
left: 0,
|
|
3761
|
+
top: 0
|
|
3762
|
+
});
|
|
3648
3763
|
}
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3764
|
+
}
|
|
3765
|
+
async function Nt({ preset: e, width: t, height: n, style: r, rounding: i }) {
|
|
3766
|
+
let a = await Mt({
|
|
3767
|
+
preset: e,
|
|
3768
|
+
rounding: i
|
|
3653
3769
|
});
|
|
3770
|
+
return xt({
|
|
3771
|
+
shape: a,
|
|
3772
|
+
style: r
|
|
3773
|
+
}), bt({
|
|
3774
|
+
shape: a,
|
|
3775
|
+
width: t,
|
|
3776
|
+
height: n,
|
|
3777
|
+
rounding: i,
|
|
3778
|
+
strokeWidth: r.strokeWidth
|
|
3779
|
+
}), a.set({
|
|
3780
|
+
selectable: !1,
|
|
3781
|
+
evented: !1,
|
|
3782
|
+
hasControls: !1,
|
|
3783
|
+
hasBorders: !1,
|
|
3784
|
+
shapeNodeType: "shape"
|
|
3785
|
+
}), a;
|
|
3654
3786
|
}
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3787
|
+
//#endregion
|
|
3788
|
+
//#region src/editor/shape-manager/layout/shape-padding.ts
|
|
3789
|
+
function Pt({ value: e }) {
|
|
3790
|
+
return Number.isFinite(e) ? Math.max(0, e ?? 0) : 0;
|
|
3791
|
+
}
|
|
3792
|
+
function Ft({ value: e }) {
|
|
3793
|
+
return Number.isFinite(e) ? Math.max(0, Math.floor(e ?? 0)) : 0;
|
|
3794
|
+
}
|
|
3795
|
+
function It({ stroke: e, strokeWidth: t }) {
|
|
3796
|
+
return e == null ? !1 : Math.max(0, t ?? 0) > 0;
|
|
3797
|
+
}
|
|
3798
|
+
function Lt({ padding: e }) {
|
|
3799
|
+
return {
|
|
3800
|
+
top: Pt({ value: e?.top }),
|
|
3801
|
+
right: Pt({ value: e?.right }),
|
|
3802
|
+
bottom: Pt({ value: e?.bottom }),
|
|
3803
|
+
left: Pt({ value: e?.left })
|
|
3804
|
+
};
|
|
3805
|
+
}
|
|
3806
|
+
function Rt({ padding: e }) {
|
|
3807
|
+
return {
|
|
3808
|
+
top: Ft({ value: e?.top }),
|
|
3809
|
+
right: Ft({ value: e?.right }),
|
|
3810
|
+
bottom: Ft({ value: e?.bottom }),
|
|
3811
|
+
left: Ft({ value: e?.left })
|
|
3812
|
+
};
|
|
3813
|
+
}
|
|
3814
|
+
function zt({ stroke: e, strokeWidth: t }) {
|
|
3815
|
+
if (!It({
|
|
3816
|
+
stroke: e,
|
|
3817
|
+
strokeWidth: t
|
|
3818
|
+
})) return {
|
|
3819
|
+
top: 0,
|
|
3820
|
+
right: 0,
|
|
3821
|
+
bottom: 0,
|
|
3822
|
+
left: 0
|
|
3823
|
+
};
|
|
3824
|
+
let n = Math.max(0, t ?? 0);
|
|
3825
|
+
return {
|
|
3826
|
+
top: n,
|
|
3827
|
+
right: n,
|
|
3828
|
+
bottom: n,
|
|
3829
|
+
left: n
|
|
3830
|
+
};
|
|
3831
|
+
}
|
|
3832
|
+
function Bt({ base: e, override: t }) {
|
|
3833
|
+
return t ? Rt({ padding: {
|
|
3834
|
+
top: t.top ?? e.top,
|
|
3835
|
+
right: t.right ?? e.right,
|
|
3836
|
+
bottom: t.bottom ?? e.bottom,
|
|
3837
|
+
left: t.left ?? e.left
|
|
3838
|
+
} }) : e;
|
|
3839
|
+
}
|
|
3840
|
+
function Vt({ base: e, addition: t }) {
|
|
3841
|
+
let n = Lt({ padding: e }), r = Lt({ padding: t });
|
|
3842
|
+
return {
|
|
3843
|
+
top: n.top + r.top,
|
|
3844
|
+
right: n.right + r.right,
|
|
3845
|
+
bottom: n.bottom + r.bottom,
|
|
3846
|
+
left: n.left + r.left
|
|
3847
|
+
};
|
|
3848
|
+
}
|
|
3849
|
+
function Ht({ baseInset: e, stroke: t, strokeWidth: n }) {
|
|
3850
|
+
return Vt({
|
|
3851
|
+
base: e,
|
|
3852
|
+
addition: zt({
|
|
3853
|
+
stroke: t,
|
|
3854
|
+
strokeWidth: n
|
|
3855
|
+
})
|
|
3665
3856
|
});
|
|
3666
3857
|
}
|
|
3667
|
-
function
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
let
|
|
3672
|
-
|
|
3858
|
+
function Ut({ padding: e }) {
|
|
3859
|
+
if (!e) return {};
|
|
3860
|
+
let t = {}, n = Object.keys(e);
|
|
3861
|
+
for (let r = 0; r < n.length; r += 1) {
|
|
3862
|
+
let i = n[r];
|
|
3863
|
+
e[i] !== void 0 && (t[i] = !0);
|
|
3673
3864
|
}
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3865
|
+
return t;
|
|
3866
|
+
}
|
|
3867
|
+
//#endregion
|
|
3868
|
+
//#region src/editor/shape-manager/layout/shape-layout-padding.ts
|
|
3869
|
+
var Wt = .5, Gt = 12;
|
|
3870
|
+
function Kt({ width: e, padding: t }) {
|
|
3871
|
+
let n = Math.max(0, t.left), r = Math.max(0, t.right);
|
|
3872
|
+
return Math.max(1, e - n - r);
|
|
3873
|
+
}
|
|
3874
|
+
function qt({ text: e }) {
|
|
3875
|
+
return (e.text ?? "").trim().length > 0;
|
|
3876
|
+
}
|
|
3877
|
+
function Jt({ start: e, end: t, maxTotalPadding: n, startChanged: r, endChanged: i }) {
|
|
3878
|
+
let a = Math.max(0, e), o = Math.max(0, t), s = Math.max(0, n);
|
|
3879
|
+
if (a + o <= s + Wt) return {
|
|
3880
|
+
start: a,
|
|
3881
|
+
end: o
|
|
3882
|
+
};
|
|
3883
|
+
if (r && !i) {
|
|
3884
|
+
let e = Math.min(o, s);
|
|
3885
|
+
return {
|
|
3886
|
+
start: Math.min(a, Math.max(0, s - e)),
|
|
3887
|
+
end: e
|
|
3888
|
+
};
|
|
3696
3889
|
}
|
|
3697
|
-
if (
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
let n = kt({
|
|
3704
|
-
previous: e[t - 1],
|
|
3705
|
-
current: e[t],
|
|
3706
|
-
next: e[t + 1],
|
|
3707
|
-
radius: i
|
|
3708
|
-
});
|
|
3709
|
-
a += ` L ${n.start.x} ${n.start.y}`, a += ` Q ${e[t].x} ${e[t].y} ${n.end.x} ${n.end.y}`;
|
|
3890
|
+
if (i && !r) {
|
|
3891
|
+
let e = Math.min(a, s);
|
|
3892
|
+
return {
|
|
3893
|
+
start: e,
|
|
3894
|
+
end: Math.min(o, Math.max(0, s - e))
|
|
3895
|
+
};
|
|
3710
3896
|
}
|
|
3711
|
-
let
|
|
3712
|
-
|
|
3897
|
+
let c = a + o;
|
|
3898
|
+
if (c <= 0) return {
|
|
3899
|
+
start: 0,
|
|
3900
|
+
end: 0
|
|
3901
|
+
};
|
|
3902
|
+
let l = s / c;
|
|
3903
|
+
return {
|
|
3904
|
+
start: a * l,
|
|
3905
|
+
end: o * l
|
|
3906
|
+
};
|
|
3713
3907
|
}
|
|
3714
|
-
function
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3908
|
+
function Yt({ start: e, end: t, insetStart: n, insetEnd: r, maxTotalPadding: i, startChanged: a, endChanged: o }) {
|
|
3909
|
+
let s = Math.max(0, n), c = Math.max(0, r), l = Math.max(0, i - s - c), u = Jt({
|
|
3910
|
+
start: Math.max(0, e),
|
|
3911
|
+
end: Math.max(0, t),
|
|
3912
|
+
maxTotalPadding: l,
|
|
3913
|
+
startChanged: a,
|
|
3914
|
+
endChanged: o
|
|
3915
|
+
}), d = Math.max(0, Math.floor(u.start)), f = Math.max(0, Math.floor(u.end));
|
|
3916
|
+
return {
|
|
3917
|
+
appliedPaddingStart: s + d,
|
|
3918
|
+
appliedPaddingEnd: c + f,
|
|
3919
|
+
appliedUserPaddingStart: d,
|
|
3920
|
+
appliedUserPaddingEnd: f
|
|
3921
|
+
};
|
|
3922
|
+
}
|
|
3923
|
+
function Xt({ text: e, minFrameWidth: t, maxFrameWidth: n, frameHeight: r, measureTextboxHeightForFrame: i }) {
|
|
3924
|
+
let a = Math.max(1, t), o = Math.max(a, n), s = Math.max(1, r);
|
|
3925
|
+
if (!qt({ text: e }) || i({
|
|
3926
|
+
text: e,
|
|
3927
|
+
frameWidth: a
|
|
3928
|
+
}) <= s + Wt) return a;
|
|
3929
|
+
if (i({
|
|
3930
|
+
text: e,
|
|
3931
|
+
frameWidth: o
|
|
3932
|
+
}) > s + Wt) return o;
|
|
3933
|
+
let c = a, l = o;
|
|
3934
|
+
for (let t = 0; t < Gt; t += 1) {
|
|
3935
|
+
let t = (c + l) / 2;
|
|
3936
|
+
if (i({
|
|
3937
|
+
text: e,
|
|
3938
|
+
frameWidth: t
|
|
3939
|
+
}) <= s + Wt) {
|
|
3940
|
+
l = t;
|
|
3941
|
+
continue;
|
|
3942
|
+
}
|
|
3943
|
+
c = t;
|
|
3720
3944
|
}
|
|
3721
|
-
return
|
|
3945
|
+
return l;
|
|
3722
3946
|
}
|
|
3723
|
-
function
|
|
3724
|
-
let i =
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3947
|
+
function Zt({ text: e, width: t, height: n, padding: r, internalShapeTextInset: i, expandShapeHeightToFitText: a, changedPadding: o, measureTextboxHeightForFrame: s, resolveMinimumTextFrameWidth: c }) {
|
|
3948
|
+
let l = Math.max(1, t), u = Math.max(1, n), d = qt({ text: e }) ? c({ text: e }) : 1, f = i.top + i.bottom, p = Math.max(1, u - f), m = d;
|
|
3949
|
+
a || (m = Xt({
|
|
3950
|
+
text: e,
|
|
3951
|
+
minFrameWidth: d,
|
|
3952
|
+
maxFrameWidth: l,
|
|
3953
|
+
frameHeight: p,
|
|
3954
|
+
measureTextboxHeightForFrame: s
|
|
3955
|
+
}));
|
|
3956
|
+
let h = m + i.left + i.right, g = Math.max(0, l - m), _ = Yt({
|
|
3957
|
+
start: r.left,
|
|
3958
|
+
end: r.right,
|
|
3959
|
+
insetStart: i.left,
|
|
3960
|
+
insetEnd: i.right,
|
|
3961
|
+
maxTotalPadding: g,
|
|
3962
|
+
startChanged: !!o?.left,
|
|
3963
|
+
endChanged: !!o?.right
|
|
3964
|
+
});
|
|
3965
|
+
return {
|
|
3966
|
+
appliedPadding: {
|
|
3967
|
+
left: _.appliedPaddingStart,
|
|
3968
|
+
right: _.appliedPaddingEnd
|
|
3735
3969
|
},
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
}
|
|
3970
|
+
appliedUserPadding: {
|
|
3971
|
+
left: _.appliedUserPaddingStart,
|
|
3972
|
+
right: _.appliedUserPaddingEnd
|
|
3973
|
+
},
|
|
3974
|
+
requiredWidth: h
|
|
3740
3975
|
};
|
|
3741
|
-
|
|
3976
|
+
}
|
|
3977
|
+
function Qt({ padding: e, internalShapeTextInset: t, height: n, textHeight: r, changedPadding: i }) {
|
|
3978
|
+
let a = Math.max(0, Math.max(1, n) - Math.max(1, r)), o = Yt({
|
|
3979
|
+
start: e.top,
|
|
3980
|
+
end: e.bottom,
|
|
3981
|
+
insetStart: t.top,
|
|
3982
|
+
insetEnd: t.bottom,
|
|
3983
|
+
maxTotalPadding: a,
|
|
3984
|
+
startChanged: !!i?.top,
|
|
3985
|
+
endChanged: !!i?.bottom
|
|
3986
|
+
});
|
|
3742
3987
|
return {
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
|
|
3988
|
+
appliedPadding: {
|
|
3989
|
+
top: o.appliedPaddingStart,
|
|
3990
|
+
bottom: o.appliedPaddingEnd
|
|
3746
3991
|
},
|
|
3747
|
-
|
|
3748
|
-
|
|
3749
|
-
|
|
3992
|
+
appliedUserPadding: {
|
|
3993
|
+
top: o.appliedUserPaddingStart,
|
|
3994
|
+
bottom: o.appliedUserPaddingEnd
|
|
3750
3995
|
}
|
|
3751
3996
|
};
|
|
3752
3997
|
}
|
|
3753
|
-
function
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
|
|
3758
|
-
|
|
3759
|
-
|
|
3760
|
-
|
|
3761
|
-
|
|
3762
|
-
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
|
|
3998
|
+
function $t({ text: e, width: t, height: n, padding: r, internalShapeTextInset: i, expandShapeHeightToFitText: a, changedPadding: o, measureTextboxHeightForFrame: s, resolveMinimumTextFrameWidth: c }) {
|
|
3999
|
+
let l = Math.max(1, t), u = Math.max(1, n), d = Lt({ padding: r }), f = Lt({ padding: i }), p = Zt({
|
|
4000
|
+
text: e,
|
|
4001
|
+
width: l,
|
|
4002
|
+
height: u,
|
|
4003
|
+
padding: d,
|
|
4004
|
+
internalShapeTextInset: f,
|
|
4005
|
+
expandShapeHeightToFitText: a,
|
|
4006
|
+
changedPadding: o,
|
|
4007
|
+
measureTextboxHeightForFrame: s,
|
|
4008
|
+
resolveMinimumTextFrameWidth: c
|
|
4009
|
+
}), m = Kt({
|
|
4010
|
+
width: l,
|
|
4011
|
+
padding: {
|
|
4012
|
+
top: 0,
|
|
4013
|
+
right: p.appliedPadding.right,
|
|
4014
|
+
bottom: 0,
|
|
4015
|
+
left: p.appliedPadding.left
|
|
4016
|
+
}
|
|
4017
|
+
}), h = qt({ text: e }) ? s({
|
|
4018
|
+
text: e,
|
|
4019
|
+
frameWidth: m
|
|
4020
|
+
}) : 1, g = f.top + f.bottom, _ = a ? Math.max(u, h + g) : u, v = Qt({
|
|
4021
|
+
padding: d,
|
|
4022
|
+
internalShapeTextInset: f,
|
|
4023
|
+
height: _,
|
|
4024
|
+
textHeight: h,
|
|
4025
|
+
changedPadding: o
|
|
4026
|
+
});
|
|
4027
|
+
return {
|
|
4028
|
+
appliedPadding: {
|
|
4029
|
+
top: v.appliedPadding.top,
|
|
4030
|
+
right: p.appliedPadding.right,
|
|
4031
|
+
bottom: v.appliedPadding.bottom,
|
|
4032
|
+
left: p.appliedPadding.left
|
|
4033
|
+
},
|
|
4034
|
+
appliedUserPadding: {
|
|
4035
|
+
top: v.appliedUserPadding.top,
|
|
4036
|
+
right: p.appliedUserPadding.right,
|
|
4037
|
+
bottom: v.appliedUserPadding.bottom,
|
|
4038
|
+
left: p.appliedUserPadding.left
|
|
4039
|
+
},
|
|
4040
|
+
requiredWidth: p.requiredWidth,
|
|
4041
|
+
requiredHeight: _
|
|
4042
|
+
};
|
|
3767
4043
|
}
|
|
3768
4044
|
//#endregion
|
|
3769
|
-
//#region src/editor/shape-manager/shape-layout.ts
|
|
3770
|
-
var q = 1,
|
|
3771
|
-
let
|
|
4045
|
+
//#region src/editor/shape-manager/layout/shape-layout.ts
|
|
4046
|
+
var q = 1, en = .5, tn = 8, nn = ({ group: e, shape: t, text: n, width: r, height: i, alignH: a, alignV: o, padding: s, internalShapeTextInset: c, expandShapeHeightToFitText: l = !0, changedPadding: u }) => {
|
|
4047
|
+
let d = Rt({ padding: s }), f = Lt({ padding: c }), p = Math.max(q, e.shapeManualBaseWidth ?? r), m = Math.max(q, e.shapeManualBaseHeight ?? i), h = Math.max(q, i), g = Math.max(q, r), _ = $t({
|
|
3772
4048
|
text: n,
|
|
3773
|
-
|
|
3774
|
-
|
|
3775
|
-
|
|
3776
|
-
|
|
3777
|
-
|
|
3778
|
-
|
|
3779
|
-
|
|
3780
|
-
|
|
4049
|
+
width: g,
|
|
4050
|
+
height: h,
|
|
4051
|
+
padding: d,
|
|
4052
|
+
internalShapeTextInset: f,
|
|
4053
|
+
expandShapeHeightToFitText: l,
|
|
4054
|
+
changedPadding: u,
|
|
4055
|
+
measureTextboxHeightForFrame: fn,
|
|
4056
|
+
resolveMinimumTextFrameWidth: pn
|
|
4057
|
+
});
|
|
4058
|
+
for (let e = 0; e < tn; e += 1) {
|
|
4059
|
+
let e = Math.max(g, _.requiredWidth);
|
|
4060
|
+
if (e <= g + en) break;
|
|
4061
|
+
g = e, _ = $t({
|
|
4062
|
+
text: n,
|
|
4063
|
+
width: g,
|
|
4064
|
+
height: h,
|
|
4065
|
+
padding: d,
|
|
4066
|
+
internalShapeTextInset: f,
|
|
4067
|
+
expandShapeHeightToFitText: l,
|
|
4068
|
+
changedPadding: u,
|
|
4069
|
+
measureTextboxHeightForFrame: fn,
|
|
4070
|
+
resolveMinimumTextFrameWidth: pn
|
|
4071
|
+
});
|
|
4072
|
+
}
|
|
4073
|
+
let { appliedPadding: v, appliedUserPadding: y, requiredHeight: b } = _, x = Math.max(q, b);
|
|
4074
|
+
bt({
|
|
3781
4075
|
shape: t,
|
|
3782
|
-
width:
|
|
3783
|
-
height:
|
|
4076
|
+
width: g,
|
|
4077
|
+
height: x,
|
|
3784
4078
|
rounding: e.shapeRounding,
|
|
3785
4079
|
strokeWidth: e.shapeStrokeWidth
|
|
3786
4080
|
});
|
|
3787
|
-
let { frame:
|
|
4081
|
+
let { frame: S, splitByGrapheme: C, textTop: w } = on({
|
|
3788
4082
|
text: n,
|
|
3789
|
-
width:
|
|
3790
|
-
height:
|
|
4083
|
+
width: g,
|
|
4084
|
+
height: x,
|
|
3791
4085
|
alignV: o,
|
|
3792
|
-
padding:
|
|
4086
|
+
padding: v
|
|
3793
4087
|
});
|
|
3794
4088
|
n.set({
|
|
3795
4089
|
autoExpand: !1,
|
|
3796
|
-
width:
|
|
4090
|
+
width: S.width,
|
|
3797
4091
|
textAlign: a,
|
|
3798
4092
|
scaleX: 1,
|
|
3799
4093
|
scaleY: 1,
|
|
@@ -3802,67 +4096,56 @@ var q = 1, Mt = .5, Nt = 12, Pt = 12, Ft = .45, It = 8, Lt = 8, Rt = ({ group: e
|
|
|
3802
4096
|
skewY: 0,
|
|
3803
4097
|
flipX: !1,
|
|
3804
4098
|
flipY: !1,
|
|
3805
|
-
left:
|
|
3806
|
-
top:
|
|
4099
|
+
left: S.left,
|
|
4100
|
+
top: w,
|
|
3807
4101
|
originX: "left",
|
|
3808
4102
|
originY: "top",
|
|
3809
|
-
splitByGrapheme:
|
|
3810
|
-
}), n.initDimensions(), n.setCoords(), t.setCoords(), e.shapeBaseWidth =
|
|
3811
|
-
width:
|
|
3812
|
-
height:
|
|
4103
|
+
splitByGrapheme: C
|
|
4104
|
+
}), n.initDimensions(), n.setCoords(), t.setCoords(), e.shapeBaseWidth = g, e.shapeBaseHeight = x, e.shapeManualBaseWidth = p, e.shapeManualBaseHeight = m, e.shapePaddingTop = y.top, e.shapePaddingRight = y.right, e.shapePaddingBottom = y.bottom, e.shapePaddingLeft = y.left, e.shapeAlignHorizontal = a, e.shapeAlignVertical = o, e.set({
|
|
4105
|
+
width: g,
|
|
4106
|
+
height: x,
|
|
3813
4107
|
scaleX: 1,
|
|
3814
4108
|
scaleY: 1
|
|
3815
4109
|
}), e.set("dirty", !0), e.setCoords();
|
|
3816
|
-
},
|
|
3817
|
-
let
|
|
3818
|
-
if (!
|
|
3819
|
-
let
|
|
3820
|
-
|
|
3821
|
-
|
|
4110
|
+
}, rn = ({ text: e, currentWidth: t, minimumWidth: n, padding: r, montageAreaWidth: i }) => {
|
|
4111
|
+
let a = Math.max(q, t), o = Math.max(q, n);
|
|
4112
|
+
if (!cn({ text: e })) return o;
|
|
4113
|
+
let s = Number.isFinite(i) && i > 0 ? Math.max(q, i) : Math.max(a, o), c = Lt({ padding: r }), l = Math.max(o, s), u = Kt({
|
|
4114
|
+
width: l,
|
|
4115
|
+
padding: c
|
|
4116
|
+
}), d = l, f = dn({
|
|
3822
4117
|
text: e,
|
|
3823
|
-
frameWidth:
|
|
3824
|
-
width: f,
|
|
3825
|
-
padding: d
|
|
3826
|
-
})
|
|
4118
|
+
frameWidth: u
|
|
3827
4119
|
});
|
|
3828
|
-
if (
|
|
3829
|
-
let m = Math.max(q, p.
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
})));
|
|
3833
|
-
for (let t = 0; t < It; t += 1) {
|
|
3834
|
-
let t = Jt({
|
|
4120
|
+
if (f.hasWrappedLines) return d;
|
|
4121
|
+
let p = Math.max(q, f.longestLineWidth), m = Math.max(q, p + c.left + c.right), h = Math.min(d, Math.max(o, m));
|
|
4122
|
+
for (let t = 0; t < tn; t += 1) {
|
|
4123
|
+
let t = Kt({
|
|
3835
4124
|
width: h,
|
|
3836
|
-
padding:
|
|
3837
|
-
}), n =
|
|
4125
|
+
padding: c
|
|
4126
|
+
}), n = dn({
|
|
3838
4127
|
text: e,
|
|
3839
4128
|
frameWidth: t
|
|
3840
|
-
}), r = t >=
|
|
4129
|
+
}), r = t >= p - en;
|
|
3841
4130
|
if (!n.hasWrappedLines && r) return h;
|
|
3842
|
-
if (h >=
|
|
3843
|
-
let i = n.hasWrappedLines ? Math.max(m + 1,
|
|
3844
|
-
h = Math.min(
|
|
3845
|
-
frameWidth: i,
|
|
3846
|
-
padding: d
|
|
3847
|
-
})));
|
|
4131
|
+
if (h >= d - en) return d;
|
|
4132
|
+
let i = n.hasWrappedLines ? Math.max(m + 1, h + 1) : p;
|
|
4133
|
+
h = Math.min(d, Math.max(h + 1, n.hasWrappedLines ? i : m));
|
|
3848
4134
|
}
|
|
3849
4135
|
return h;
|
|
3850
|
-
},
|
|
3851
|
-
if (!
|
|
3852
|
-
let n =
|
|
3853
|
-
return
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
});
|
|
3857
|
-
}, Vt = ({ text: e, width: t, height: n, alignV: r, padding: i }) => {
|
|
3858
|
-
let a = qt({
|
|
4136
|
+
}, an = ({ text: e, padding: t }) => {
|
|
4137
|
+
if (!cn({ text: e })) return q;
|
|
4138
|
+
let n = Lt({ padding: t });
|
|
4139
|
+
return pn({ text: e }) + n.left + n.right;
|
|
4140
|
+
}, on = ({ text: e, width: t, height: n, alignV: r, padding: i }) => {
|
|
4141
|
+
let a = ln({
|
|
3859
4142
|
width: Math.max(q, t),
|
|
3860
4143
|
height: Math.max(q, n),
|
|
3861
|
-
padding:
|
|
3862
|
-
}), o =
|
|
4144
|
+
padding: Lt({ padding: i })
|
|
4145
|
+
}), o = gn({
|
|
3863
4146
|
text: e,
|
|
3864
4147
|
frameWidth: a.width
|
|
3865
|
-
}), s =
|
|
4148
|
+
}), s = fn({
|
|
3866
4149
|
text: e,
|
|
3867
4150
|
frameWidth: a.width,
|
|
3868
4151
|
splitByGrapheme: o
|
|
@@ -3870,77 +4153,30 @@ var q = 1, Mt = .5, Nt = 12, Pt = 12, Ft = .45, It = 8, Lt = 8, Rt = ({ group: e
|
|
|
3870
4153
|
return {
|
|
3871
4154
|
frame: a,
|
|
3872
4155
|
splitByGrapheme: o,
|
|
3873
|
-
textTop:
|
|
4156
|
+
textTop: hn({
|
|
3874
4157
|
alignV: r,
|
|
3875
4158
|
frameHeight: a.height,
|
|
3876
4159
|
frameTop: a.top,
|
|
3877
4160
|
textHeight: s
|
|
3878
4161
|
})
|
|
3879
4162
|
};
|
|
3880
|
-
},
|
|
4163
|
+
}, sn = ({ text: e, width: t, height: n, padding: r }) => {
|
|
3881
4164
|
let i = Math.max(q, n);
|
|
3882
|
-
if (!
|
|
3883
|
-
let a = Math.max(q, t), o =
|
|
3884
|
-
|
|
3885
|
-
|
|
4165
|
+
if (!cn({ text: e })) return i;
|
|
4166
|
+
let a = Math.max(q, t), o = Lt({ padding: r }), s = fn({
|
|
4167
|
+
text: e,
|
|
4168
|
+
frameWidth: Kt({
|
|
3886
4169
|
width: a,
|
|
3887
|
-
height: s,
|
|
3888
4170
|
padding: o
|
|
3889
|
-
})
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
});
|
|
3893
|
-
if (n <= t.height + Mt) return s;
|
|
3894
|
-
let r = n - t.height;
|
|
3895
|
-
s = Math.max(s + r, s * 1.05);
|
|
3896
|
-
}
|
|
3897
|
-
return s;
|
|
4171
|
+
})
|
|
4172
|
+
});
|
|
4173
|
+
return Math.max(i, s + o.top + o.bottom);
|
|
3898
4174
|
};
|
|
3899
|
-
function
|
|
3900
|
-
let n = Math.max(q, e), r = n;
|
|
3901
|
-
for (let e = 0; e < It; e += 1) {
|
|
3902
|
-
let e = Jt({
|
|
3903
|
-
width: r,
|
|
3904
|
-
padding: t
|
|
3905
|
-
});
|
|
3906
|
-
if (e >= n - Mt) return r;
|
|
3907
|
-
let i = n - e;
|
|
3908
|
-
r = Math.max(r + i, r * 1.05);
|
|
3909
|
-
}
|
|
3910
|
-
return r;
|
|
3911
|
-
}
|
|
3912
|
-
function Wt({ padding: e }) {
|
|
3913
|
-
return {
|
|
3914
|
-
top: Kt({ value: e.top }),
|
|
3915
|
-
right: Kt({ value: e.right }),
|
|
3916
|
-
bottom: Kt({ value: e.bottom }),
|
|
3917
|
-
left: Kt({ value: e.left })
|
|
3918
|
-
};
|
|
3919
|
-
}
|
|
3920
|
-
function Gt({ text: e }) {
|
|
4175
|
+
function cn({ text: e }) {
|
|
3921
4176
|
return (e.text ?? "").trim().length > 0;
|
|
3922
4177
|
}
|
|
3923
|
-
function
|
|
3924
|
-
|
|
3925
|
-
}
|
|
3926
|
-
function qt({ width: e, height: t, padding: n }) {
|
|
3927
|
-
let r = tn({
|
|
3928
|
-
size: e,
|
|
3929
|
-
ratio: n.left,
|
|
3930
|
-
axis: "horizontal"
|
|
3931
|
-
}), i = tn({
|
|
3932
|
-
size: e,
|
|
3933
|
-
ratio: n.right,
|
|
3934
|
-
axis: "horizontal"
|
|
3935
|
-
}), a = tn({
|
|
3936
|
-
size: t,
|
|
3937
|
-
ratio: n.top,
|
|
3938
|
-
axis: "vertical"
|
|
3939
|
-
}), o = tn({
|
|
3940
|
-
size: t,
|
|
3941
|
-
ratio: n.bottom,
|
|
3942
|
-
axis: "vertical"
|
|
3943
|
-
});
|
|
4178
|
+
function ln({ width: e, height: t, padding: n }) {
|
|
4179
|
+
let r = Math.max(0, n.left), i = Math.max(0, n.right), a = Math.max(0, n.top), o = Math.max(0, n.bottom);
|
|
3944
4180
|
return {
|
|
3945
4181
|
left: -e / 2 + r,
|
|
3946
4182
|
top: -t / 2 + a,
|
|
@@ -3948,19 +4184,7 @@ function qt({ width: e, height: t, padding: n }) {
|
|
|
3948
4184
|
height: Math.max(q, t - a - o)
|
|
3949
4185
|
};
|
|
3950
4186
|
}
|
|
3951
|
-
function
|
|
3952
|
-
let n = tn({
|
|
3953
|
-
size: e,
|
|
3954
|
-
ratio: t.left,
|
|
3955
|
-
axis: "horizontal"
|
|
3956
|
-
}), r = tn({
|
|
3957
|
-
size: e,
|
|
3958
|
-
ratio: t.right,
|
|
3959
|
-
axis: "horizontal"
|
|
3960
|
-
});
|
|
3961
|
-
return Math.max(q, e - n - r);
|
|
3962
|
-
}
|
|
3963
|
-
function Yt({ text: e }) {
|
|
4187
|
+
function un({ text: e }) {
|
|
3964
4188
|
let { height: t } = e;
|
|
3965
4189
|
if (typeof t == "number" && Number.isFinite(t)) return t;
|
|
3966
4190
|
if (typeof e.calcTextHeight == "function") {
|
|
@@ -3969,18 +4193,18 @@ function Yt({ text: e }) {
|
|
|
3969
4193
|
}
|
|
3970
4194
|
return q;
|
|
3971
4195
|
}
|
|
3972
|
-
function
|
|
3973
|
-
let n =
|
|
4196
|
+
function dn({ text: e, frameWidth: t }) {
|
|
4197
|
+
let n = vn({ text: e }), r = gn({
|
|
3974
4198
|
text: e,
|
|
3975
4199
|
frameWidth: t
|
|
3976
|
-
}), i =
|
|
4200
|
+
}), i = xn({ text: e });
|
|
3977
4201
|
e.set({
|
|
3978
4202
|
autoExpand: !1,
|
|
3979
4203
|
width: Math.max(q, t),
|
|
3980
4204
|
splitByGrapheme: r
|
|
3981
4205
|
}), e.initDimensions();
|
|
3982
|
-
let a =
|
|
3983
|
-
return
|
|
4206
|
+
let a = yn({ text: e }) > n, o = Math.ceil(_n({ text: e }));
|
|
4207
|
+
return Sn({
|
|
3984
4208
|
text: e,
|
|
3985
4209
|
state: i
|
|
3986
4210
|
}), {
|
|
@@ -3988,8 +4212,8 @@ function Xt({ text: e, frameWidth: t }) {
|
|
|
3988
4212
|
longestLineWidth: o
|
|
3989
4213
|
};
|
|
3990
4214
|
}
|
|
3991
|
-
function
|
|
3992
|
-
let r =
|
|
4215
|
+
function fn({ text: e, frameWidth: t, splitByGrapheme: n }) {
|
|
4216
|
+
let r = xn({ text: e }), i = n ?? gn({
|
|
3993
4217
|
text: e,
|
|
3994
4218
|
frameWidth: t
|
|
3995
4219
|
});
|
|
@@ -3998,75 +4222,71 @@ function Zt({ text: e, frameWidth: t, splitByGrapheme: n }) {
|
|
|
3998
4222
|
width: Math.max(q, t),
|
|
3999
4223
|
splitByGrapheme: i
|
|
4000
4224
|
}), e.initDimensions();
|
|
4001
|
-
let a =
|
|
4002
|
-
return
|
|
4225
|
+
let a = un({ text: e });
|
|
4226
|
+
return Sn({
|
|
4003
4227
|
text: e,
|
|
4004
4228
|
state: r
|
|
4005
4229
|
}), a;
|
|
4006
4230
|
}
|
|
4007
|
-
function
|
|
4008
|
-
let t =
|
|
4231
|
+
function pn({ text: e }) {
|
|
4232
|
+
let t = mn({
|
|
4009
4233
|
text: e,
|
|
4010
4234
|
frameWidth: q,
|
|
4011
4235
|
splitByGrapheme: !0
|
|
4012
4236
|
});
|
|
4013
4237
|
return Math.max(q, t);
|
|
4014
4238
|
}
|
|
4015
|
-
function
|
|
4016
|
-
let r =
|
|
4239
|
+
function mn({ text: e, frameWidth: t, splitByGrapheme: n }) {
|
|
4240
|
+
let r = xn({ text: e });
|
|
4017
4241
|
e.set({
|
|
4018
4242
|
autoExpand: !1,
|
|
4019
4243
|
width: Math.max(q, t),
|
|
4020
4244
|
splitByGrapheme: n
|
|
4021
4245
|
}), e.initDimensions();
|
|
4022
|
-
let i =
|
|
4023
|
-
return
|
|
4246
|
+
let i = _n({ text: e });
|
|
4247
|
+
return Sn({
|
|
4024
4248
|
text: e,
|
|
4025
4249
|
state: r
|
|
4026
4250
|
}), i;
|
|
4027
4251
|
}
|
|
4028
|
-
function
|
|
4252
|
+
function hn({ alignV: e, frameHeight: t, frameTop: n, textHeight: r }) {
|
|
4029
4253
|
let i = Math.max(0, t - r);
|
|
4030
4254
|
return e === "top" ? n : e === "bottom" ? n + i : n + i / 2;
|
|
4031
4255
|
}
|
|
4032
|
-
function
|
|
4033
|
-
let
|
|
4034
|
-
return Math.max(0, Math.min(i, r));
|
|
4035
|
-
}
|
|
4036
|
-
function nn({ text: e, frameWidth: t }) {
|
|
4037
|
-
let n = Math.max(q, t), r = cn({ text: e });
|
|
4256
|
+
function gn({ text: e, frameWidth: t }) {
|
|
4257
|
+
let n = Math.max(q, t), r = xn({ text: e });
|
|
4038
4258
|
e.set({
|
|
4039
4259
|
autoExpand: !1,
|
|
4040
4260
|
width: n,
|
|
4041
4261
|
splitByGrapheme: !1
|
|
4042
4262
|
}), e.initDimensions();
|
|
4043
|
-
let i =
|
|
4044
|
-
return
|
|
4263
|
+
let i = Cn({ text: e }) > n + en;
|
|
4264
|
+
return Sn({
|
|
4045
4265
|
text: e,
|
|
4046
4266
|
state: r
|
|
4047
4267
|
}), i;
|
|
4048
4268
|
}
|
|
4049
|
-
function
|
|
4050
|
-
let t =
|
|
4051
|
-
if (t > 0) return
|
|
4269
|
+
function _n({ text: e }) {
|
|
4270
|
+
let t = yn({ text: e });
|
|
4271
|
+
if (t > 0) return bn({
|
|
4052
4272
|
text: e,
|
|
4053
4273
|
lineCount: t
|
|
4054
4274
|
});
|
|
4055
4275
|
let n = e.text ?? "";
|
|
4056
|
-
return
|
|
4276
|
+
return bn({
|
|
4057
4277
|
text: e,
|
|
4058
4278
|
lineCount: Math.max(n.split("\n").length, 1)
|
|
4059
4279
|
});
|
|
4060
4280
|
}
|
|
4061
|
-
function
|
|
4281
|
+
function vn({ text: e }) {
|
|
4062
4282
|
let t = e.text ?? "";
|
|
4063
4283
|
return Math.max(t.split("\n").length, 1);
|
|
4064
4284
|
}
|
|
4065
|
-
function
|
|
4285
|
+
function yn({ text: e }) {
|
|
4066
4286
|
let t = e;
|
|
4067
4287
|
return Array.isArray(t.textLines) ? t.textLines.length : 0;
|
|
4068
4288
|
}
|
|
4069
|
-
function
|
|
4289
|
+
function bn({ text: e, lineCount: t }) {
|
|
4070
4290
|
let n = q;
|
|
4071
4291
|
for (let r = 0; r < t; r += 1) {
|
|
4072
4292
|
let t = e.getLineWidth(r);
|
|
@@ -4074,7 +4294,7 @@ function sn({ text: e, lineCount: t }) {
|
|
|
4074
4294
|
}
|
|
4075
4295
|
return n;
|
|
4076
4296
|
}
|
|
4077
|
-
function
|
|
4297
|
+
function xn({ text: e }) {
|
|
4078
4298
|
let { autoExpand: t, splitByGrapheme: n, width: r } = e;
|
|
4079
4299
|
return {
|
|
4080
4300
|
autoExpand: t,
|
|
@@ -4082,23 +4302,23 @@ function cn({ text: e }) {
|
|
|
4082
4302
|
width: typeof r == "number" ? r : void 0
|
|
4083
4303
|
};
|
|
4084
4304
|
}
|
|
4085
|
-
function
|
|
4305
|
+
function Sn({ text: e, state: t }) {
|
|
4086
4306
|
let { autoExpand: n, splitByGrapheme: r, width: i } = t, a = {};
|
|
4087
4307
|
n !== void 0 && (a.autoExpand = n), r !== void 0 && (a.splitByGrapheme = r), typeof i == "number" && (a.width = i), Object.keys(a).length > 0 && (e.set(a), e.initDimensions());
|
|
4088
4308
|
}
|
|
4089
|
-
function
|
|
4309
|
+
function Cn({ text: e }) {
|
|
4090
4310
|
let { dynamicMinWidth: t } = e;
|
|
4091
4311
|
return typeof t == "number" && Number.isFinite(t) ? t : 0;
|
|
4092
4312
|
}
|
|
4093
4313
|
//#endregion
|
|
4094
4314
|
//#region src/editor/shape-manager/shape-runtime.ts
|
|
4095
|
-
var
|
|
4315
|
+
var wn = ({ group: e }) => {
|
|
4096
4316
|
let t = e;
|
|
4097
4317
|
typeof t.setInteractive == "function" && t.setInteractive(!0), t.set({
|
|
4098
4318
|
interactive: !0,
|
|
4099
4319
|
subTargetCheck: !0
|
|
4100
4320
|
});
|
|
4101
|
-
},
|
|
4321
|
+
}, Tn = ({ text: e }) => {
|
|
4102
4322
|
let t = !!(e.locked || e.group?.locked);
|
|
4103
4323
|
e.set({
|
|
4104
4324
|
hasBorders: !1,
|
|
@@ -4111,7 +4331,7 @@ var dn = ({ group: e }) => {
|
|
|
4111
4331
|
autoExpand: !1,
|
|
4112
4332
|
shapeNodeType: "text"
|
|
4113
4333
|
}), e.setCoords();
|
|
4114
|
-
},
|
|
4334
|
+
}, En = ({ group: e }) => {
|
|
4115
4335
|
let { layoutManager: t } = e;
|
|
4116
4336
|
if (!t || typeof t.unsubscribeTargets != "function") return;
|
|
4117
4337
|
let n = e.getObjects();
|
|
@@ -4119,7 +4339,7 @@ var dn = ({ group: e }) => {
|
|
|
4119
4339
|
target: e,
|
|
4120
4340
|
targets: n
|
|
4121
4341
|
});
|
|
4122
|
-
},
|
|
4342
|
+
}, Dn = ({ group: e }) => {
|
|
4123
4343
|
let t = e.getObjects();
|
|
4124
4344
|
for (let e = 0; e < t.length; e += 1) {
|
|
4125
4345
|
let n = t[e];
|
|
@@ -4130,23 +4350,23 @@ var dn = ({ group: e }) => {
|
|
|
4130
4350
|
if (n instanceof _) return n;
|
|
4131
4351
|
}
|
|
4132
4352
|
return null;
|
|
4133
|
-
},
|
|
4353
|
+
}, On = [
|
|
4134
4354
|
"tl",
|
|
4135
4355
|
"tr",
|
|
4136
4356
|
"bl",
|
|
4137
4357
|
"br"
|
|
4138
|
-
],
|
|
4358
|
+
], kn = ({ transform: e }) => {
|
|
4139
4359
|
let { originX: t, originY: n } = e;
|
|
4140
4360
|
return (t === "center" || t === .5) && (n === "center" || n === .5);
|
|
4141
|
-
},
|
|
4361
|
+
}, An = ({ transform: e, x: t, y: n }) => {
|
|
4142
4362
|
let r = e, { target: i } = r, { scaleX: a = 1, scaleY: o = 1 } = i, s = b.getLocalPoint(r, r.originX, r.originY, t, n), c = Math.sign(s.x || r.signX || 1), l = Math.sign(s.y || r.signY || 1);
|
|
4143
4363
|
r.signX === void 0 && (r.signX = c), r.signY === void 0 && (r.signY = l);
|
|
4144
4364
|
let u = i._getTransformedDimensions(), d = Math.abs(s.x * a / u.x), f = Math.abs(s.y * o / u.y);
|
|
4145
|
-
|
|
4365
|
+
kn({ transform: r }) && (d *= 2, f *= 2);
|
|
4146
4366
|
let p = !i.lockScalingX && (!i.lockScalingFlip || r.signX === c), m = !i.lockScalingY && (!i.lockScalingFlip || r.signY === l);
|
|
4147
4367
|
return p && i.set("scaleX", d), m && i.set("scaleY", f), a !== i.scaleX || o !== i.scaleY;
|
|
4148
|
-
},
|
|
4149
|
-
let e = b.wrapWithFireEvent("scaling", b.wrapWithFixedAnchor((e, t, n, r) =>
|
|
4368
|
+
}, jn = () => {
|
|
4369
|
+
let e = b.wrapWithFireEvent("scaling", b.wrapWithFixedAnchor((e, t, n, r) => An({
|
|
4150
4370
|
transform: t,
|
|
4151
4371
|
x: n,
|
|
4152
4372
|
y: r
|
|
@@ -4162,31 +4382,31 @@ var dn = ({ group: e }) => {
|
|
|
4162
4382
|
a.uniformScaling = s;
|
|
4163
4383
|
}
|
|
4164
4384
|
};
|
|
4165
|
-
},
|
|
4385
|
+
}, Mn = ({ control: e }) => {
|
|
4166
4386
|
let t = new r({
|
|
4167
4387
|
...e,
|
|
4168
|
-
actionHandler:
|
|
4388
|
+
actionHandler: jn()
|
|
4169
4389
|
});
|
|
4170
4390
|
return t.shapeFreeScaleCornerControl = !0, t;
|
|
4171
|
-
},
|
|
4391
|
+
}, Nn = ({ group: e }) => {
|
|
4172
4392
|
let t = { ...e.controls };
|
|
4173
|
-
|
|
4393
|
+
On.forEach((n) => {
|
|
4174
4394
|
let r = e.controls[n];
|
|
4175
|
-
r && (r.shapeFreeScaleCornerControl || (t[n] =
|
|
4395
|
+
r && (r.shapeFreeScaleCornerControl || (t[n] = Mn({ control: r })));
|
|
4176
4396
|
}), e.controls = t;
|
|
4177
|
-
},
|
|
4178
|
-
function
|
|
4397
|
+
}, Pn = "shape-group";
|
|
4398
|
+
function Fn() {
|
|
4179
4399
|
return { performLayout() {} };
|
|
4180
4400
|
}
|
|
4181
|
-
function
|
|
4401
|
+
function In({ layoutManager: e }) {
|
|
4182
4402
|
let t = y.getClass("layoutManager");
|
|
4183
4403
|
if (!e) return new t();
|
|
4184
4404
|
let { strategy: n, type: r } = e, i = y.getClass(r);
|
|
4185
4405
|
return n ? new i(new (y.getClass(n))()) : new i();
|
|
4186
4406
|
}
|
|
4187
|
-
var
|
|
4407
|
+
var Ln = class e extends l {
|
|
4188
4408
|
static {
|
|
4189
|
-
this.type =
|
|
4409
|
+
this.type = Pn;
|
|
4190
4410
|
}
|
|
4191
4411
|
constructor(e = [], t = {}) {
|
|
4192
4412
|
let { layoutManager: n, objectCaching: r, centeredScaling: i, lockScalingFlip: a, ...o } = t;
|
|
@@ -4202,17 +4422,24 @@ var wn = class e extends l {
|
|
|
4202
4422
|
this.set({
|
|
4203
4423
|
objectCaching: !1,
|
|
4204
4424
|
shapeComposite: !0
|
|
4205
|
-
}), this.shapeTextAutoExpand === void 0 && (this.shapeTextAutoExpand = !0)
|
|
4206
|
-
let e =
|
|
4207
|
-
|
|
4425
|
+
}), this.shapeTextAutoExpand === void 0 && (this.shapeTextAutoExpand = !0);
|
|
4426
|
+
let e = Rt({ padding: {
|
|
4427
|
+
top: this.shapePaddingTop,
|
|
4428
|
+
right: this.shapePaddingRight,
|
|
4429
|
+
bottom: this.shapePaddingBottom,
|
|
4430
|
+
left: this.shapePaddingLeft
|
|
4431
|
+
} });
|
|
4432
|
+
this.shapePaddingTop = e.top, this.shapePaddingRight = e.right, this.shapePaddingBottom = e.bottom, this.shapePaddingLeft = e.left, this._syncRoundability(), wn({ group: this }), Nn({ group: this });
|
|
4433
|
+
let t = Dn({ group: this });
|
|
4434
|
+
t && Tn({ text: t }), En({ group: this }), this.setCoords();
|
|
4208
4435
|
}
|
|
4209
4436
|
static async fromObject({ type: t, objects: n = [], layoutManager: r, ...i }, a) {
|
|
4210
4437
|
let [o, s] = await Promise.all([C.enlivenObjects(n, a), C.enlivenObjectEnlivables(i, a)]), c = new e(o, {
|
|
4211
4438
|
...i,
|
|
4212
4439
|
...s,
|
|
4213
|
-
layoutManager:
|
|
4440
|
+
layoutManager: Fn()
|
|
4214
4441
|
});
|
|
4215
|
-
return c.layoutManager =
|
|
4442
|
+
return c.layoutManager = In({ layoutManager: r }), c.layoutManager.subscribeTargets({
|
|
4216
4443
|
type: "initialization",
|
|
4217
4444
|
target: c,
|
|
4218
4445
|
targets: c.getObjects()
|
|
@@ -4222,12 +4449,12 @@ var wn = class e extends l {
|
|
|
4222
4449
|
if (typeof this.shapeCanRound == "boolean") return;
|
|
4223
4450
|
let e = this.shapePresetKey;
|
|
4224
4451
|
if (!e) return;
|
|
4225
|
-
let t =
|
|
4226
|
-
t && (this.shapeCanRound =
|
|
4452
|
+
let t = ut({ presetKey: e });
|
|
4453
|
+
t && (this.shapeCanRound = ht({ preset: t }));
|
|
4227
4454
|
}
|
|
4228
|
-
},
|
|
4229
|
-
y?.setClass && y.setClass(
|
|
4230
|
-
}, J = (e) => e instanceof
|
|
4455
|
+
}, Rn = () => {
|
|
4456
|
+
y?.setClass && y.setClass(Ln, Pn);
|
|
4457
|
+
}, J = (e) => e instanceof Ln || e instanceof l && e.shapeComposite === !0, zn = ({ target: e, subTargets: t = [] }) => {
|
|
4231
4458
|
if (J(e)) return e;
|
|
4232
4459
|
if (e?.group && J(e.group)) return e.group;
|
|
4233
4460
|
for (let e = 0; e < t.length; e += 1) {
|
|
@@ -4237,7 +4464,7 @@ var wn = class e extends l {
|
|
|
4237
4464
|
if (r && J(r)) return r;
|
|
4238
4465
|
}
|
|
4239
4466
|
return null;
|
|
4240
|
-
},
|
|
4467
|
+
}, Bn = ({ group: e }) => {
|
|
4241
4468
|
let t = e.getObjects();
|
|
4242
4469
|
for (let e = 0; e < t.length; e += 1) {
|
|
4243
4470
|
let n = t[e];
|
|
@@ -4248,7 +4475,7 @@ var wn = class e extends l {
|
|
|
4248
4475
|
if (!(n instanceof _)) return n;
|
|
4249
4476
|
}
|
|
4250
4477
|
return null;
|
|
4251
|
-
},
|
|
4478
|
+
}, Vn = ({ group: e }) => {
|
|
4252
4479
|
let t = e.getObjects();
|
|
4253
4480
|
for (let e = 0; e < t.length; e += 1) {
|
|
4254
4481
|
let n = t[e];
|
|
@@ -4260,16 +4487,16 @@ var wn = class e extends l {
|
|
|
4260
4487
|
}
|
|
4261
4488
|
return null;
|
|
4262
4489
|
}, Y = ({ group: e }) => ({
|
|
4263
|
-
shape:
|
|
4264
|
-
text:
|
|
4265
|
-
}),
|
|
4266
|
-
|
|
4267
|
-
},
|
|
4490
|
+
shape: Bn({ group: e }),
|
|
4491
|
+
text: Vn({ group: e })
|
|
4492
|
+
}), Hn = ({ group: e }) => {
|
|
4493
|
+
wn({ group: e });
|
|
4494
|
+
}, Un = ({ transform: e, key: t }) => {
|
|
4268
4495
|
let n = e?.original;
|
|
4269
4496
|
if (!n || typeof n != "object") return null;
|
|
4270
4497
|
let r = n[t];
|
|
4271
4498
|
return typeof r != "number" || !Number.isFinite(r) ? null : r;
|
|
4272
|
-
},
|
|
4499
|
+
}, Wn = ({ value: e }) => e === "left" || e === "center" || e === "right" || typeof e == "number" && Number.isFinite(e) ? e : null, Gn = ({ value: e }) => e === "top" || e === "center" || e === "bottom" || typeof e == "number" && Number.isFinite(e) ? e : null, Kn = ({ transform: e }) => {
|
|
4273
4500
|
let t = e?.action ?? "", n = typeof e?.corner == "string" ? e.corner : "", r = n === "tl" || n === "tr" || n === "bl" || n === "br", i = t === "scaleX" || n === "ml" || n === "mr", a = t === "scaleY" || n === "mt" || n === "mb", o = i || r, s = a || r;
|
|
4274
4501
|
return {
|
|
4275
4502
|
canScaleWidth: o,
|
|
@@ -4277,37 +4504,37 @@ var wn = class e extends l {
|
|
|
4277
4504
|
isCornerScaleAction: r,
|
|
4278
4505
|
isVerticalOnlyScale: s && !o
|
|
4279
4506
|
};
|
|
4280
|
-
},
|
|
4507
|
+
}, qn = ({ event: e, group: t, transform: n, canvas: r }) => {
|
|
4281
4508
|
if (!e) return null;
|
|
4282
4509
|
let i = t.canvas ?? r, a = i.getScenePoint(e), o = t.getRelativeCenterPoint(), s = t.translateToGivenOrigin(o, "center", "center", n.originX, n.originY), c = t.angle ?? 0, l = (c === 0 ? a : a.rotate(-c * Math.PI / 180, o)).subtract(s), u = t.controls[n.corner], d = i.getZoom() || 1, f = (t.padding ?? 0) / d;
|
|
4283
4510
|
return l.x >= f && (l.x -= f), l.x <= -f && (l.x += f), l.y >= f && (l.y -= f), l.y <= -f && (l.y += f), l.x -= u?.offsetX ?? 0, l.y -= u?.offsetY ?? 0, l;
|
|
4284
|
-
},
|
|
4511
|
+
}, Jn = ({ group: e, originX: t, originY: n }) => {
|
|
4285
4512
|
if (t === null || n === null) return null;
|
|
4286
4513
|
let r = e, i = typeof r.getRelativeCenterPoint == "function" ? r.getRelativeCenterPoint() : e.getCenterPoint();
|
|
4287
4514
|
return typeof r.translateToOriginPoint == "function" ? r.translateToOriginPoint(i, t, n) : i;
|
|
4288
|
-
},
|
|
4515
|
+
}, Yn = ({ state: e, transform: t }) => {
|
|
4289
4516
|
if (!t || e.startTransformOriginX === null && e.startTransformOriginY === null) return !1;
|
|
4290
|
-
let n =
|
|
4517
|
+
let n = Wn({ value: t.originX }), r = Gn({ value: t.originY });
|
|
4291
4518
|
return n !== e.startTransformOriginX || r !== e.startTransformOriginY;
|
|
4292
|
-
},
|
|
4519
|
+
}, Xn = ({ state: e, transform: t }) => !t || !e.startTransformCorner ? !1 : t.corner !== e.startTransformCorner;
|
|
4293
4520
|
//#endregion
|
|
4294
4521
|
//#region src/editor/shape-manager/scaling/shape-scaling-preview.ts
|
|
4295
|
-
function
|
|
4522
|
+
function Zn({ size: e, scale: t, strokeWidth: n, minSize: r, scaleEpsilon: i }) {
|
|
4296
4523
|
let a = Math.max(i, Math.abs(t) || 1), o = Math.max(0, n);
|
|
4297
4524
|
return o <= 0 ? Math.max(r, e / a) : Math.max(r, e / a + o - o / a);
|
|
4298
4525
|
}
|
|
4299
|
-
function
|
|
4526
|
+
function Qn({ group: e, shape: t, width: n, height: r, scaleX: i, scaleY: a, minSize: o, scaleEpsilon: s }) {
|
|
4300
4527
|
let c = Math.max(0, e.shapeStrokeWidth ?? 0);
|
|
4301
|
-
|
|
4528
|
+
bt({
|
|
4302
4529
|
shape: t,
|
|
4303
|
-
width:
|
|
4530
|
+
width: Zn({
|
|
4304
4531
|
size: n,
|
|
4305
4532
|
scale: i,
|
|
4306
4533
|
strokeWidth: c,
|
|
4307
4534
|
minSize: o,
|
|
4308
4535
|
scaleEpsilon: s
|
|
4309
4536
|
}),
|
|
4310
|
-
height:
|
|
4537
|
+
height: Zn({
|
|
4311
4538
|
size: r,
|
|
4312
4539
|
scale: a,
|
|
4313
4540
|
strokeWidth: c,
|
|
@@ -4318,8 +4545,8 @@ function zn({ group: e, shape: t, width: n, height: r, scaleX: i, scaleY: a, min
|
|
|
4318
4545
|
strokeWidth: c
|
|
4319
4546
|
});
|
|
4320
4547
|
}
|
|
4321
|
-
function
|
|
4322
|
-
let l = Math.max(c, Math.abs(o) || 1), u = Math.max(c, Math.abs(s) || 1), d = i ?? "center", { frame: f, splitByGrapheme: p, textTop: m } =
|
|
4548
|
+
function $n({ text: e, width: t, height: n, padding: r, alignH: i, alignV: a, scaleX: o, scaleY: s, scaleEpsilon: c }) {
|
|
4549
|
+
let l = Math.max(c, Math.abs(o) || 1), u = Math.max(c, Math.abs(s) || 1), d = i ?? "center", { frame: f, splitByGrapheme: p, textTop: m } = on({
|
|
4323
4550
|
text: e,
|
|
4324
4551
|
width: t,
|
|
4325
4552
|
height: n,
|
|
@@ -4339,13 +4566,13 @@ function Bn({ text: e, width: t, height: n, padding: r, alignH: i, alignV: a, sc
|
|
|
4339
4566
|
scaleY: 1 / u
|
|
4340
4567
|
}), e.initDimensions(), e.setCoords();
|
|
4341
4568
|
}
|
|
4342
|
-
var
|
|
4569
|
+
var er = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH: o, alignV: s, scaleX: c, scaleY: l, minSize: u, scaleEpsilon: d }) => {
|
|
4343
4570
|
let f = Math.max(d, Math.abs(c) || 1), p = Math.max(d, Math.abs(l) || 1);
|
|
4344
4571
|
e.set({
|
|
4345
4572
|
width: r / f,
|
|
4346
4573
|
height: i / p,
|
|
4347
4574
|
dirty: !0
|
|
4348
|
-
}),
|
|
4575
|
+
}), Qn({
|
|
4349
4576
|
group: e,
|
|
4350
4577
|
shape: t,
|
|
4351
4578
|
width: r,
|
|
@@ -4354,7 +4581,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4354
4581
|
scaleY: l,
|
|
4355
4582
|
minSize: u,
|
|
4356
4583
|
scaleEpsilon: d
|
|
4357
|
-
}),
|
|
4584
|
+
}), $n({
|
|
4358
4585
|
text: n,
|
|
4359
4586
|
width: r,
|
|
4360
4587
|
height: i,
|
|
@@ -4365,7 +4592,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4365
4592
|
scaleY: l,
|
|
4366
4593
|
scaleEpsilon: d
|
|
4367
4594
|
});
|
|
4368
|
-
}, X = 1, Z = 1e-4,
|
|
4595
|
+
}, X = 1, Z = 1e-4, tr = .5, nr = class e {
|
|
4369
4596
|
constructor({ canvas: t }) {
|
|
4370
4597
|
this.handleObjectScaling = (t) => {
|
|
4371
4598
|
let { target: n, transform: r } = t;
|
|
@@ -4376,117 +4603,117 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4376
4603
|
lockScalingFlip: !0,
|
|
4377
4604
|
centeredScaling: !1
|
|
4378
4605
|
});
|
|
4379
|
-
let s = e.
|
|
4606
|
+
let s = e._resolveEffectivePadding({ group: i }), c = e._resolveScalingConstraintPadding({ group: i }), l = this._ensureScalingState({
|
|
4380
4607
|
group: i,
|
|
4381
4608
|
text: o,
|
|
4382
|
-
|
|
4609
|
+
constraintPadding: c,
|
|
4383
4610
|
transform: r
|
|
4384
|
-
}), { isCornerScaleAction:
|
|
4385
|
-
|
|
4386
|
-
let
|
|
4611
|
+
}), { isCornerScaleAction: u } = Kn({ transform: r }), d = !!(t.e && "shiftKey" in t.e && t.e.shiftKey);
|
|
4612
|
+
l.isProportionalScaling = u && d;
|
|
4613
|
+
let f = i.left ?? 0, p = i.top ?? 0, m = !!i.flipX, h = !!i.flipY, g = i.shapeAlignHorizontal ?? "center", _ = i.shapeAlignVertical ?? "middle", v = this._resolveScalingDecision({
|
|
4387
4614
|
group: i,
|
|
4388
4615
|
text: o,
|
|
4389
|
-
|
|
4390
|
-
state:
|
|
4616
|
+
constraintPadding: c,
|
|
4617
|
+
state: l,
|
|
4391
4618
|
transform: r
|
|
4392
|
-
}),
|
|
4393
|
-
(
|
|
4619
|
+
}), y = Math.abs(i.scaleX ?? 1) || 1, b = Math.abs(i.scaleY ?? 1) || 1;
|
|
4620
|
+
(v.shouldHandleAsNoop || v.shouldRestoreLastAllowedTransform || Math.abs(v.appliedScaleX - y) > Z || Math.abs(v.appliedScaleY - b) > Z) && this._applyResolvedScalingState({
|
|
4394
4621
|
group: i,
|
|
4395
|
-
state:
|
|
4396
|
-
shouldHandleAsNoop:
|
|
4397
|
-
scaleX:
|
|
4398
|
-
scaleY:
|
|
4399
|
-
}),
|
|
4622
|
+
state: l,
|
|
4623
|
+
shouldHandleAsNoop: v.shouldHandleAsNoop,
|
|
4624
|
+
scaleX: v.appliedScaleX,
|
|
4625
|
+
scaleY: v.appliedScaleY
|
|
4626
|
+
}), er({
|
|
4400
4627
|
group: i,
|
|
4401
4628
|
shape: a,
|
|
4402
4629
|
text: o,
|
|
4403
|
-
width:
|
|
4404
|
-
height:
|
|
4630
|
+
width: v.previewWidth,
|
|
4631
|
+
height: v.previewHeight,
|
|
4405
4632
|
padding: s,
|
|
4406
|
-
alignH:
|
|
4407
|
-
alignV:
|
|
4408
|
-
scaleX:
|
|
4409
|
-
scaleY:
|
|
4633
|
+
alignH: g,
|
|
4634
|
+
alignV: _,
|
|
4635
|
+
scaleX: v.appliedScaleX,
|
|
4636
|
+
scaleY: v.appliedScaleY,
|
|
4410
4637
|
minSize: X,
|
|
4411
4638
|
scaleEpsilon: Z
|
|
4412
4639
|
}), this._restoreScalingAnchorPosition({
|
|
4413
4640
|
group: i,
|
|
4414
|
-
state:
|
|
4415
|
-
}), !
|
|
4641
|
+
state: l
|
|
4642
|
+
}), !v.shouldHandleAsNoop && !v.shouldRestoreLastAllowedTransform && this._storeLastAllowedTransform({
|
|
4416
4643
|
group: i,
|
|
4417
|
-
state:
|
|
4644
|
+
state: l,
|
|
4418
4645
|
scaleX: i.scaleX ?? 1,
|
|
4419
4646
|
scaleY: i.scaleY ?? 1,
|
|
4420
|
-
currentLeft:
|
|
4421
|
-
currentTop:
|
|
4422
|
-
currentFlipX:
|
|
4423
|
-
currentFlipY:
|
|
4647
|
+
currentLeft: f,
|
|
4648
|
+
currentTop: p,
|
|
4649
|
+
currentFlipX: m,
|
|
4650
|
+
currentFlipY: h
|
|
4424
4651
|
}), this.canvas.requestRenderAll();
|
|
4425
4652
|
}, this.handleCanvasMouseMove = (t) => {
|
|
4426
4653
|
let n = this.canvas._currentTransform;
|
|
4427
4654
|
if (!n) return;
|
|
4428
4655
|
let { target: r } = n;
|
|
4429
4656
|
if (!J(r)) return;
|
|
4430
|
-
let { canScaleHeight: i, canScaleWidth: a } =
|
|
4657
|
+
let { canScaleHeight: i, canScaleWidth: a } = Kn({ transform: n });
|
|
4431
4658
|
if (!a && !i) return;
|
|
4432
4659
|
let o = r, s = this.scalingState.get(o);
|
|
4433
4660
|
if (!s || s.isProportionalScaling) return;
|
|
4434
4661
|
let { shape: c, text: l } = Y({ group: o });
|
|
4435
4662
|
if (!c || !l) return;
|
|
4436
|
-
let u = e.
|
|
4663
|
+
let u = e._resolveEffectivePadding({ group: o }), d = e._resolveScalingConstraintPadding({ group: o }), f = o.shapeAlignHorizontal ?? "center", p = o.shapeAlignVertical ?? "middle", m = Math.abs(o.scaleX ?? s.lastAllowedScaleX ?? 1) || 1, h = Math.abs(o.scaleY ?? s.lastAllowedScaleY ?? 1) || 1, g = {
|
|
4437
4664
|
...t,
|
|
4438
4665
|
transform: n
|
|
4439
|
-
},
|
|
4666
|
+
}, _ = m, v = h, y = null, b = !1, x = !1;
|
|
4440
4667
|
if (a && this._hasPointerReachedScaleOrigin({
|
|
4441
|
-
event:
|
|
4668
|
+
event: g,
|
|
4442
4669
|
group: o,
|
|
4443
4670
|
axis: "x"
|
|
4444
4671
|
})) {
|
|
4445
|
-
let e =
|
|
4672
|
+
let e = an({
|
|
4446
4673
|
text: l,
|
|
4447
|
-
padding:
|
|
4674
|
+
padding: d
|
|
4448
4675
|
}), t = Math.max(X / s.startWidth, e / s.startWidth);
|
|
4449
|
-
s.lastAllowedScaleX > t + Z && (
|
|
4676
|
+
s.lastAllowedScaleX > t + Z && (_ = t, b = !0, x = !0);
|
|
4450
4677
|
}
|
|
4451
4678
|
if (i && this._hasPointerReachedScaleOrigin({
|
|
4452
|
-
event:
|
|
4679
|
+
event: g,
|
|
4453
4680
|
group: o,
|
|
4454
4681
|
axis: "y"
|
|
4455
4682
|
})) {
|
|
4456
|
-
|
|
4683
|
+
y = this._resolveMinimumTextFitHeight({
|
|
4457
4684
|
text: l,
|
|
4458
|
-
width: Math.max(X, s.startWidth *
|
|
4459
|
-
padding:
|
|
4685
|
+
width: Math.max(X, s.startWidth * _),
|
|
4686
|
+
padding: d
|
|
4460
4687
|
});
|
|
4461
|
-
let e = Math.max(X / s.startHeight,
|
|
4462
|
-
s.lastAllowedScaleY > e + Z && (
|
|
4688
|
+
let e = Math.max(X / s.startHeight, y / s.startHeight);
|
|
4689
|
+
s.lastAllowedScaleY > e + Z && (v = e, x = !0);
|
|
4463
4690
|
}
|
|
4464
|
-
if (!
|
|
4465
|
-
let
|
|
4691
|
+
if (!x) return;
|
|
4692
|
+
let S = this._resolvePreviewDimensions({
|
|
4466
4693
|
text: l,
|
|
4467
|
-
|
|
4694
|
+
constraintPadding: d,
|
|
4468
4695
|
state: s,
|
|
4469
|
-
appliedScaleX:
|
|
4470
|
-
appliedScaleY:
|
|
4471
|
-
minimumHeight:
|
|
4696
|
+
appliedScaleX: _,
|
|
4697
|
+
appliedScaleY: v,
|
|
4698
|
+
minimumHeight: b ? null : y
|
|
4472
4699
|
});
|
|
4473
4700
|
this._applyResolvedScalingState({
|
|
4474
4701
|
group: o,
|
|
4475
4702
|
state: s,
|
|
4476
4703
|
shouldHandleAsNoop: !1,
|
|
4477
|
-
scaleX:
|
|
4478
|
-
scaleY:
|
|
4479
|
-
}),
|
|
4704
|
+
scaleX: _,
|
|
4705
|
+
scaleY: v
|
|
4706
|
+
}), er({
|
|
4480
4707
|
group: o,
|
|
4481
4708
|
shape: c,
|
|
4482
4709
|
text: l,
|
|
4483
|
-
width:
|
|
4484
|
-
height:
|
|
4710
|
+
width: S.previewWidth,
|
|
4711
|
+
height: S.previewHeight,
|
|
4485
4712
|
padding: u,
|
|
4486
|
-
alignH:
|
|
4487
|
-
alignV:
|
|
4488
|
-
scaleX:
|
|
4489
|
-
scaleY:
|
|
4713
|
+
alignH: f,
|
|
4714
|
+
alignV: p,
|
|
4715
|
+
scaleX: _,
|
|
4716
|
+
scaleY: v,
|
|
4490
4717
|
minSize: X,
|
|
4491
4718
|
scaleEpsilon: Z
|
|
4492
4719
|
}), this._restoreScalingAnchorPosition({
|
|
@@ -4495,8 +4722,8 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4495
4722
|
}), this._storeLastAllowedTransform({
|
|
4496
4723
|
group: o,
|
|
4497
4724
|
state: s,
|
|
4498
|
-
scaleX:
|
|
4499
|
-
scaleY:
|
|
4725
|
+
scaleX: _,
|
|
4726
|
+
scaleY: v,
|
|
4500
4727
|
currentLeft: s.lastAllowedLeft,
|
|
4501
4728
|
currentTop: s.lastAllowedTop,
|
|
4502
4729
|
currentFlipX: s.lastAllowedFlipX,
|
|
@@ -4523,7 +4750,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4523
4750
|
this.scalingState.delete(r);
|
|
4524
4751
|
return;
|
|
4525
4752
|
}
|
|
4526
|
-
let p = r.shapeAlignHorizontal ?? "center", m = r.shapeAlignVertical ?? "middle", h = e.
|
|
4753
|
+
let p = r.shapeAlignHorizontal ?? "center", m = r.shapeAlignVertical ?? "middle", h = e._resolveScalingConstraintPadding({ group: r }), g = t.transform ? Kn({ transform: t.transform }) : null, _ = i?.canScaleWidth ?? g?.canScaleWidth ?? Math.abs(a - 1) > Z, v = i?.canScaleHeight ?? g?.canScaleHeight ?? Math.abs(o - 1) > Z, y = an({
|
|
4527
4754
|
text: f,
|
|
4528
4755
|
padding: h
|
|
4529
4756
|
}), b = i?.lastAllowedScaleX ?? a, x = i?.lastAllowedScaleY ?? o;
|
|
@@ -4546,7 +4773,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4546
4773
|
state: i
|
|
4547
4774
|
}) && (x = Math.max(X / c, e / c));
|
|
4548
4775
|
}
|
|
4549
|
-
let S = _ ? Math.max(X, s * b) : s, C = v ? Math.max(X, c * x) : u, w = Math.abs(S - s) >
|
|
4776
|
+
let S = _ ? Math.max(X, s * b) : s, C = v ? Math.max(X, c * x) : u, w = Math.abs(S - s) > tr, T = Math.abs(C - c) > tr, E = w || T, D = S, O = C;
|
|
4550
4777
|
if (!E && i) {
|
|
4551
4778
|
this._restoreShapeStateWithoutResize({
|
|
4552
4779
|
group: r,
|
|
@@ -4557,7 +4784,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4557
4784
|
startHeight: c,
|
|
4558
4785
|
alignH: p,
|
|
4559
4786
|
alignV: m,
|
|
4560
|
-
|
|
4787
|
+
userPadding: e._resolveUserPadding({ group: r })
|
|
4561
4788
|
}), this.scalingState.delete(r), this.canvas.requestRenderAll();
|
|
4562
4789
|
return;
|
|
4563
4790
|
}
|
|
@@ -4575,7 +4802,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4575
4802
|
});
|
|
4576
4803
|
r.shapeManualBaseWidth = k.width, r.shapeManualBaseHeight = k.height;
|
|
4577
4804
|
let A = i?.baseRounding ?? Math.max(0, r.shapeRounding ?? 0);
|
|
4578
|
-
r.shapeRounding = Math.max(0, A * Math.min(b, x)),
|
|
4805
|
+
r.shapeRounding = Math.max(0, A * Math.min(b, x)), nn({
|
|
4579
4806
|
group: r,
|
|
4580
4807
|
shape: d,
|
|
4581
4808
|
text: f,
|
|
@@ -4583,7 +4810,12 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4583
4810
|
height: O,
|
|
4584
4811
|
alignH: p,
|
|
4585
4812
|
alignV: m,
|
|
4586
|
-
padding:
|
|
4813
|
+
padding: e._resolveUserPadding({ group: r }),
|
|
4814
|
+
internalShapeTextInset: e._resolveInternalShapeTextInset({
|
|
4815
|
+
group: r,
|
|
4816
|
+
width: D,
|
|
4817
|
+
height: O
|
|
4818
|
+
})
|
|
4587
4819
|
}), f.set({
|
|
4588
4820
|
scaleX: 1,
|
|
4589
4821
|
scaleY: 1
|
|
@@ -4596,18 +4828,18 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4596
4828
|
}), r.setCoords(), f.setCoords(), d.setCoords(), this.scalingState.delete(r), r.shapeScalingNoopTransform = !1, this.canvas.requestRenderAll();
|
|
4597
4829
|
}, this.canvas = t, this.scalingState = /* @__PURE__ */ new WeakMap();
|
|
4598
4830
|
}
|
|
4599
|
-
_resolveScalingDecision({ group: e, text: t,
|
|
4600
|
-
let a = e.scaleX ?? 1, o = e.scaleY ?? 1, s = Math.abs(a) || 1, c = Math.abs(o) || 1, l = a < 0 || o < 0, u =
|
|
4831
|
+
_resolveScalingDecision({ group: e, text: t, constraintPadding: n, state: r, transform: i }) {
|
|
4832
|
+
let a = e.scaleX ?? 1, o = e.scaleY ?? 1, s = Math.abs(a) || 1, c = Math.abs(o) || 1, l = a < 0 || o < 0, u = Yn({
|
|
4601
4833
|
state: r,
|
|
4602
4834
|
transform: i
|
|
4603
|
-
}), d =
|
|
4835
|
+
}), d = Xn({
|
|
4604
4836
|
state: r,
|
|
4605
4837
|
transform: i
|
|
4606
4838
|
});
|
|
4607
4839
|
(l || u || d) && (r.crossedOppositeCorner = !0);
|
|
4608
4840
|
let f = this._resolveScalingConstraintState({
|
|
4609
4841
|
text: t,
|
|
4610
|
-
|
|
4842
|
+
constraintPadding: n,
|
|
4611
4843
|
state: r,
|
|
4612
4844
|
transform: i,
|
|
4613
4845
|
scaleX: s,
|
|
@@ -4616,7 +4848,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4616
4848
|
f.shouldRestoreLastAllowedTransform && (h = r.lastAllowedScaleX, g = r.lastAllowedScaleY), f.shouldHandleAsNoop && (h = r.startScaleX, g = r.startScaleY);
|
|
4617
4849
|
let _ = !f.shouldHandleAsNoop && !f.shouldRestoreLastAllowedTransform && f.clampedScaleX === null, v = this._resolvePreviewDimensions({
|
|
4618
4850
|
text: t,
|
|
4619
|
-
|
|
4851
|
+
constraintPadding: n,
|
|
4620
4852
|
state: r,
|
|
4621
4853
|
appliedScaleX: h,
|
|
4622
4854
|
appliedScaleY: g,
|
|
@@ -4631,8 +4863,8 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4631
4863
|
shouldRestoreLastAllowedTransform: f.shouldRestoreLastAllowedTransform
|
|
4632
4864
|
};
|
|
4633
4865
|
}
|
|
4634
|
-
_resolveScalingConstraintState({ text: e,
|
|
4635
|
-
let { startHeight: o, startWidth: s, cannotScaleDownAtStart: c, crossedOppositeCorner: l, isProportionalScaling: u, lastAllowedScaleX: d, lastAllowedScaleY: f, startScaleY: p } = n, m = Math.max(X, s * i), h = Math.max(X, o * a), g = i < d - Z, _ = a < f - Z, v = a < p - Z, { canScaleHeight: y, canScaleWidth: b, isVerticalOnlyScale: x } =
|
|
4866
|
+
_resolveScalingConstraintState({ text: e, constraintPadding: t, state: n, transform: r, scaleX: i, scaleY: a }) {
|
|
4867
|
+
let { startHeight: o, startWidth: s, cannotScaleDownAtStart: c, crossedOppositeCorner: l, isProportionalScaling: u, lastAllowedScaleX: d, lastAllowedScaleY: f, startScaleY: p } = n, m = Math.max(X, s * i), h = Math.max(X, o * a), g = i < d - Z, _ = a < f - Z, v = a < p - Z, { canScaleHeight: y, canScaleWidth: b, isVerticalOnlyScale: x } = Kn({ transform: r }), S = b && g ? an({
|
|
4636
4868
|
text: e,
|
|
4637
4869
|
padding: t
|
|
4638
4870
|
}) : null, C = y && _ ? this._resolveMinimumTextFitHeight({
|
|
@@ -4650,8 +4882,8 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4650
4882
|
resolvedMinimumHeight: C
|
|
4651
4883
|
};
|
|
4652
4884
|
}
|
|
4653
|
-
_resolvePreviewDimensions({ text: e,
|
|
4654
|
-
let o = n.canScaleWidth ? Math.max(X, n.startWidth * r) : n.startWidth, s = n.canScaleHeight ? Math.max(X, n.startHeight * i) : n.startManualBaseHeight, c = a ??
|
|
4885
|
+
_resolvePreviewDimensions({ text: e, constraintPadding: t, state: n, appliedScaleX: r, appliedScaleY: i, minimumHeight: a }) {
|
|
4886
|
+
let o = n.canScaleWidth ? Math.max(X, n.startWidth * r) : n.startWidth, s = n.canScaleHeight ? Math.max(X, n.startHeight * i) : n.startManualBaseHeight, c = a ?? sn({
|
|
4655
4887
|
text: e,
|
|
4656
4888
|
width: o,
|
|
4657
4889
|
height: s,
|
|
@@ -4684,7 +4916,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4684
4916
|
if (!r) return !1;
|
|
4685
4917
|
let { transform: i } = e;
|
|
4686
4918
|
if (!i) return !1;
|
|
4687
|
-
let { canScaleWidth: a } =
|
|
4919
|
+
let { canScaleWidth: a } = Kn({ transform: i });
|
|
4688
4920
|
if (!a || !this._hasPointerReachedScaleOrigin({
|
|
4689
4921
|
event: e,
|
|
4690
4922
|
group: t,
|
|
@@ -4697,7 +4929,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4697
4929
|
if (!r) return !1;
|
|
4698
4930
|
let { transform: i } = e;
|
|
4699
4931
|
if (!i) return !1;
|
|
4700
|
-
let { canScaleHeight: a } =
|
|
4932
|
+
let { canScaleHeight: a } = Kn({ transform: i });
|
|
4701
4933
|
if (!a || !this._hasPointerReachedScaleOrigin({
|
|
4702
4934
|
event: e,
|
|
4703
4935
|
group: t,
|
|
@@ -4711,7 +4943,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4711
4943
|
if (!r) return !1;
|
|
4712
4944
|
let i = r, a = n === "x" ? i.signX : i.signY;
|
|
4713
4945
|
if (typeof a != "number" || !Number.isFinite(a)) return !1;
|
|
4714
|
-
let o =
|
|
4946
|
+
let o = qn({
|
|
4715
4947
|
event: e.e,
|
|
4716
4948
|
group: t,
|
|
4717
4949
|
transform: r,
|
|
@@ -4722,25 +4954,25 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4722
4954
|
clearState({ group: e }) {
|
|
4723
4955
|
this.scalingState.delete(e);
|
|
4724
4956
|
}
|
|
4725
|
-
_ensureScalingState({ group: e, text: t,
|
|
4957
|
+
_ensureScalingState({ group: e, text: t, constraintPadding: n, transform: r }) {
|
|
4726
4958
|
let i = this.scalingState.get(e);
|
|
4727
4959
|
if (!i) {
|
|
4728
4960
|
let a = this._resolveScalingStartDimensions({
|
|
4729
4961
|
group: e,
|
|
4730
4962
|
transform: r
|
|
4731
|
-
}), o =
|
|
4963
|
+
}), o = Un({
|
|
4732
4964
|
transform: r,
|
|
4733
4965
|
key: "scaleX"
|
|
4734
|
-
}), s =
|
|
4966
|
+
}), s = Un({
|
|
4735
4967
|
transform: r,
|
|
4736
4968
|
key: "scaleY"
|
|
4737
|
-
}), c =
|
|
4969
|
+
}), c = Un({
|
|
4738
4970
|
transform: r,
|
|
4739
4971
|
key: "left"
|
|
4740
|
-
}), l =
|
|
4972
|
+
}), l = Un({
|
|
4741
4973
|
transform: r,
|
|
4742
4974
|
key: "top"
|
|
4743
|
-
}), u = Math.abs(o ?? e.scaleX ?? 1) || 1, d = Math.abs(s ?? e.scaleY ?? 1) || 1, f = c ?? e.left ?? 0, p = l ?? e.top ?? 0, m =
|
|
4975
|
+
}), u = Math.abs(o ?? e.scaleX ?? 1) || 1, d = Math.abs(s ?? e.scaleY ?? 1) || 1, f = c ?? e.left ?? 0, p = l ?? e.top ?? 0, m = Wn({ value: r?.original?.originX ?? r?.originX }), h = Gn({ value: r?.original?.originY ?? r?.originY }), g = typeof r?.corner == "string" ? r.corner : null, _ = Jn({
|
|
4744
4976
|
group: e,
|
|
4745
4977
|
originX: m,
|
|
4746
4978
|
originY: h
|
|
@@ -4783,20 +5015,51 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4783
5015
|
return i;
|
|
4784
5016
|
}
|
|
4785
5017
|
_resolveMinimumTextFitHeight({ text: e, width: t, padding: n }) {
|
|
4786
|
-
return
|
|
5018
|
+
return sn({
|
|
4787
5019
|
text: e,
|
|
4788
5020
|
width: t,
|
|
4789
5021
|
height: X,
|
|
4790
5022
|
padding: n
|
|
4791
5023
|
});
|
|
4792
5024
|
}
|
|
4793
|
-
static
|
|
4794
|
-
return {
|
|
4795
|
-
top: e.shapePaddingTop
|
|
4796
|
-
right: e.shapePaddingRight
|
|
4797
|
-
bottom: e.shapePaddingBottom
|
|
4798
|
-
left: e.shapePaddingLeft
|
|
4799
|
-
};
|
|
5025
|
+
static _resolveUserPadding({ group: e }) {
|
|
5026
|
+
return Rt({ padding: {
|
|
5027
|
+
top: e.shapePaddingTop,
|
|
5028
|
+
right: e.shapePaddingRight,
|
|
5029
|
+
bottom: e.shapePaddingBottom,
|
|
5030
|
+
left: e.shapePaddingLeft
|
|
5031
|
+
} });
|
|
5032
|
+
}
|
|
5033
|
+
static _resolveInternalShapeTextInset({ group: e, width: t, height: n }) {
|
|
5034
|
+
let r = e.shapePresetKey ?? "", i = r ? ut({ presetKey: r }) : null;
|
|
5035
|
+
return Ht({
|
|
5036
|
+
baseInset: i ? pt({
|
|
5037
|
+
preset: i,
|
|
5038
|
+
width: t,
|
|
5039
|
+
height: n
|
|
5040
|
+
}) : void 0,
|
|
5041
|
+
stroke: e.shapeStroke,
|
|
5042
|
+
strokeWidth: e.shapeStrokeWidth
|
|
5043
|
+
});
|
|
5044
|
+
}
|
|
5045
|
+
static _resolveEffectivePadding({ group: t }) {
|
|
5046
|
+
let n = Math.max(X, t.shapeBaseWidth ?? t.width ?? t.shapeManualBaseWidth ?? X), r = Math.max(X, t.shapeBaseHeight ?? t.height ?? t.shapeManualBaseHeight ?? X), i = e._resolveUserPadding({ group: t });
|
|
5047
|
+
return Vt({
|
|
5048
|
+
base: e._resolveInternalShapeTextInset({
|
|
5049
|
+
group: t,
|
|
5050
|
+
width: n,
|
|
5051
|
+
height: r
|
|
5052
|
+
}),
|
|
5053
|
+
addition: i
|
|
5054
|
+
});
|
|
5055
|
+
}
|
|
5056
|
+
static _resolveScalingConstraintPadding({ group: t }) {
|
|
5057
|
+
let n = Math.max(X, t.shapeBaseWidth ?? t.width ?? t.shapeManualBaseWidth ?? X), r = Math.max(X, t.shapeBaseHeight ?? t.height ?? t.shapeManualBaseHeight ?? X);
|
|
5058
|
+
return e._resolveInternalShapeTextInset({
|
|
5059
|
+
group: t,
|
|
5060
|
+
width: n,
|
|
5061
|
+
height: r
|
|
5062
|
+
});
|
|
4800
5063
|
}
|
|
4801
5064
|
_restoreScalingAnchorPosition({ group: e, state: t }) {
|
|
4802
5065
|
let { scalingAnchorX: n, scalingAnchorY: r, scalingAnchorOriginX: i, scalingAnchorOriginY: a } = t;
|
|
@@ -4806,31 +5069,37 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4806
5069
|
}
|
|
4807
5070
|
e.setPositionByOrigin(new p(n, r), i, a), e.setCoords();
|
|
4808
5071
|
}
|
|
4809
|
-
_restoreShapeStateWithoutResize({ group:
|
|
4810
|
-
|
|
4811
|
-
|
|
4812
|
-
|
|
4813
|
-
|
|
4814
|
-
|
|
4815
|
-
|
|
4816
|
-
|
|
4817
|
-
|
|
4818
|
-
|
|
4819
|
-
|
|
4820
|
-
|
|
4821
|
-
|
|
4822
|
-
|
|
4823
|
-
|
|
5072
|
+
_restoreShapeStateWithoutResize({ group: t, shape: n, text: r, state: i, startWidth: a, startHeight: o, alignH: s, alignV: c, userPadding: l }) {
|
|
5073
|
+
let u = Math.max(X, t.shapeBaseWidth ?? t.width ?? a), d = Math.max(X, t.shapeBaseHeight ?? t.height ?? o);
|
|
5074
|
+
nn({
|
|
5075
|
+
group: t,
|
|
5076
|
+
shape: n,
|
|
5077
|
+
text: r,
|
|
5078
|
+
width: u,
|
|
5079
|
+
height: d,
|
|
5080
|
+
alignH: s,
|
|
5081
|
+
alignV: c,
|
|
5082
|
+
padding: l,
|
|
5083
|
+
internalShapeTextInset: e._resolveInternalShapeTextInset({
|
|
5084
|
+
group: t,
|
|
5085
|
+
width: u,
|
|
5086
|
+
height: d
|
|
5087
|
+
})
|
|
5088
|
+
}), t.set({
|
|
5089
|
+
left: i.lastAllowedLeft,
|
|
5090
|
+
top: i.lastAllowedTop,
|
|
5091
|
+
flipX: i.lastAllowedFlipX,
|
|
5092
|
+
flipY: i.lastAllowedFlipY,
|
|
4824
5093
|
scaleX: 1,
|
|
4825
5094
|
scaleY: 1
|
|
4826
5095
|
}), this._restoreScalingAnchorPosition({
|
|
4827
|
-
group:
|
|
4828
|
-
state:
|
|
5096
|
+
group: t,
|
|
5097
|
+
state: i
|
|
4829
5098
|
});
|
|
4830
5099
|
}
|
|
4831
5100
|
_restoreGroupTransformOnly({ group: e, shape: t, text: n, state: r }) {
|
|
4832
5101
|
let i = Math.max(X, e.shapeBaseWidth ?? e.width ?? r.startWidth), a = Math.max(X, e.shapeBaseHeight ?? e.height ?? r.startHeight);
|
|
4833
|
-
t && (
|
|
5102
|
+
t && (bt({
|
|
4834
5103
|
shape: t,
|
|
4835
5104
|
width: i,
|
|
4836
5105
|
height: a,
|
|
@@ -4854,7 +5123,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4854
5123
|
});
|
|
4855
5124
|
}
|
|
4856
5125
|
_resolveScalingStartDimensions({ group: e, transform: t }) {
|
|
4857
|
-
let { canScaleWidth: n, canScaleHeight: r } =
|
|
5126
|
+
let { canScaleWidth: n, canScaleHeight: r } = Kn({ transform: t }), i = Math.max(X, e.shapeBaseWidth ?? e.width ?? e.shapeManualBaseWidth ?? X), a = Math.max(X, e.shapeBaseHeight ?? e.height ?? e.shapeManualBaseHeight ?? X);
|
|
4858
5127
|
return {
|
|
4859
5128
|
startWidth: i,
|
|
4860
5129
|
startHeight: a,
|
|
@@ -4873,10 +5142,10 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4873
5142
|
height: s
|
|
4874
5143
|
};
|
|
4875
5144
|
}
|
|
4876
|
-
},
|
|
5145
|
+
}, rr = class {
|
|
4877
5146
|
constructor({ canvas: e }) {
|
|
4878
5147
|
this.handleMouseDown = (e) => {
|
|
4879
|
-
let { target: t, e: n, subTargets: r = [] } = e, i =
|
|
5148
|
+
let { target: t, e: n, subTargets: r = [] } = e, i = zn({
|
|
4880
5149
|
target: t,
|
|
4881
5150
|
subTargets: r
|
|
4882
5151
|
});
|
|
@@ -4886,7 +5155,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4886
5155
|
let o = this.canvas.getActiveObject(), s = o === i;
|
|
4887
5156
|
if (!(o === a && a.isEditing)) {
|
|
4888
5157
|
if (!s) {
|
|
4889
|
-
a.isEditing ||
|
|
5158
|
+
a.isEditing || Tn({ text: a });
|
|
4890
5159
|
return;
|
|
4891
5160
|
}
|
|
4892
5161
|
n instanceof MouseEvent && (n.detail < 2 || this.enterTextEditing({ group: i }));
|
|
@@ -4906,14 +5175,14 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4906
5175
|
J(r) && (this._restoreTextEditingInteractionMode({
|
|
4907
5176
|
group: r,
|
|
4908
5177
|
text: n
|
|
4909
|
-
}),
|
|
5178
|
+
}), Tn({ text: n }), this.canvas.getActiveObject() === n && this.canvas.setActiveObject(r), this.canvas.requestRenderAll());
|
|
4910
5179
|
}, this.canvas = e, this.editingInteractionState = /* @__PURE__ */ new WeakMap();
|
|
4911
5180
|
}
|
|
4912
5181
|
enterTextEditing({ group: e }) {
|
|
4913
5182
|
let { text: t } = Y({ group: e });
|
|
4914
5183
|
if (t) {
|
|
4915
5184
|
if (e.locked || t.locked) {
|
|
4916
|
-
|
|
5185
|
+
Tn({ text: t }), this.canvas.requestRenderAll();
|
|
4917
5186
|
return;
|
|
4918
5187
|
}
|
|
4919
5188
|
this._enterTextEditingInteractionMode({
|
|
@@ -4963,7 +5232,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4963
5232
|
lockMovementY: n.textLockMovementY
|
|
4964
5233
|
}), this.editingInteractionState.delete(e), e.setCoords(), t.setCoords());
|
|
4965
5234
|
}
|
|
4966
|
-
},
|
|
5235
|
+
}, ir = "#B0B5BF", ar = 0, or = 1, sr = class {
|
|
4967
5236
|
constructor({ editor: e }) {
|
|
4968
5237
|
this._handleObjectScaling = (e) => {
|
|
4969
5238
|
this.scalingController.handleObjectScaling(e);
|
|
@@ -5000,63 +5269,72 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5000
5269
|
textNode: r,
|
|
5001
5270
|
textStyle: n
|
|
5002
5271
|
});
|
|
5003
|
-
}, this.editor = e,
|
|
5272
|
+
}, this.editor = e, Rn(), this.scalingController = new nr({ canvas: e.canvas }), this.editingController = new rr({ canvas: e.canvas }), this.editingPlacements = /* @__PURE__ */ new WeakMap(), this.internalTextUpdates = /* @__PURE__ */ new WeakSet(), this._bindEvents();
|
|
5004
5273
|
}
|
|
5005
|
-
async add({ presetKey: e =
|
|
5006
|
-
let n =
|
|
5274
|
+
async add({ presetKey: e = ot, options: t = {} } = {}) {
|
|
5275
|
+
let n = ut({ presetKey: e });
|
|
5007
5276
|
if (!n) return null;
|
|
5008
|
-
let { width: r, height: i, shapeTextAutoExpand: a, left: o, top: s, originX: c, originY: l, text: u, textStyle: d, alignH: f, alignV: p, textPadding: m, rounding: h, withoutAdding: g, withoutSelection: _, withoutSave: v, id: y } = t, b =
|
|
5277
|
+
let { width: r, height: i, shapeTextAutoExpand: a, left: o, top: s, originX: c, originY: l, text: u, textStyle: d, alignH: f, alignV: p, textPadding: m, rounding: h, withoutAdding: g, withoutSelection: _, withoutSave: v, id: y } = t, b = ut({ presetKey: dt({
|
|
5009
5278
|
preset: n,
|
|
5010
5279
|
rounding: h
|
|
5011
5280
|
}) }) ?? n, x = Math.max(1, r ?? b.width), S = Math.max(1, i ?? b.height), C = a !== !1, w = this._resolveHorizontalAlign({
|
|
5012
5281
|
explicitAlign: f,
|
|
5013
5282
|
textStyle: d
|
|
5014
|
-
}), T = p ?? "middle", E =
|
|
5015
|
-
preset: b,
|
|
5016
|
-
overridePadding: m
|
|
5017
|
-
}), O = this._resolveShapeStyle({
|
|
5283
|
+
}), T = p ?? "middle", E = this._resolveShapeStyle({
|
|
5018
5284
|
options: t,
|
|
5019
5285
|
fallback: null
|
|
5020
|
-
}), k =
|
|
5286
|
+
}), O = Rt({ padding: m }), k = Ht({
|
|
5287
|
+
baseInset: pt({
|
|
5288
|
+
preset: b,
|
|
5289
|
+
width: x,
|
|
5290
|
+
height: S
|
|
5291
|
+
}),
|
|
5292
|
+
stroke: E.stroke,
|
|
5293
|
+
strokeWidth: E.strokeWidth
|
|
5294
|
+
}), A = Vt({
|
|
5295
|
+
base: k,
|
|
5296
|
+
addition: O
|
|
5297
|
+
}), j = Ut({ padding: m }), M = this._createTextNode({
|
|
5021
5298
|
text: u,
|
|
5022
5299
|
textStyle: d,
|
|
5023
5300
|
width: x,
|
|
5024
5301
|
align: w,
|
|
5025
|
-
opacity:
|
|
5026
|
-
}),
|
|
5027
|
-
text:
|
|
5302
|
+
opacity: E.opacity
|
|
5303
|
+
}), N = this._resolveShapeLayoutWidth({
|
|
5304
|
+
text: M,
|
|
5028
5305
|
currentWidth: x,
|
|
5029
5306
|
manualWidth: x,
|
|
5030
5307
|
shapeTextAutoExpandEnabled: C,
|
|
5031
|
-
padding:
|
|
5032
|
-
|
|
5033
|
-
}), j = await _t({
|
|
5308
|
+
padding: A
|
|
5309
|
+
}), P = await Nt({
|
|
5034
5310
|
preset: b,
|
|
5035
|
-
width:
|
|
5311
|
+
width: N,
|
|
5036
5312
|
height: S,
|
|
5037
|
-
style:
|
|
5313
|
+
style: E,
|
|
5038
5314
|
rounding: h
|
|
5039
|
-
}),
|
|
5315
|
+
}), F = this._createShapeGroup({
|
|
5040
5316
|
id: y ?? `shape-${D()}`,
|
|
5041
5317
|
presetKey: b.key,
|
|
5042
|
-
presetCanRound:
|
|
5043
|
-
shape:
|
|
5044
|
-
text:
|
|
5045
|
-
width:
|
|
5318
|
+
presetCanRound: ht({ preset: b }),
|
|
5319
|
+
shape: P,
|
|
5320
|
+
text: M,
|
|
5321
|
+
width: N,
|
|
5046
5322
|
height: S,
|
|
5047
5323
|
manualWidth: x,
|
|
5048
5324
|
manualHeight: S,
|
|
5049
5325
|
shapeTextAutoExpand: C,
|
|
5050
5326
|
alignH: w,
|
|
5051
5327
|
alignV: T,
|
|
5052
|
-
padding:
|
|
5053
|
-
|
|
5328
|
+
padding: O,
|
|
5329
|
+
internalShapeTextInset: k,
|
|
5330
|
+
changedPadding: j,
|
|
5331
|
+
style: E,
|
|
5054
5332
|
rounding: h
|
|
5055
5333
|
});
|
|
5056
|
-
if (o === void 0 && s === void 0) this.editor.canvasManager.centerObjectToMontageArea({ object:
|
|
5334
|
+
if (o === void 0 && s === void 0) this.editor.canvasManager.centerObjectToMontageArea({ object: F });
|
|
5057
5335
|
else {
|
|
5058
5336
|
let e = this.editor.canvasManager.resolveObjectPlacement({
|
|
5059
|
-
object:
|
|
5337
|
+
object: F,
|
|
5060
5338
|
left: o,
|
|
5061
5339
|
top: s,
|
|
5062
5340
|
originX: c,
|
|
@@ -5064,23 +5342,23 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5064
5342
|
fallbackPoint: this.editor.canvasManager.getMontageAreaSceneCenter()
|
|
5065
5343
|
});
|
|
5066
5344
|
this.editor.canvasManager.applyObjectPlacement({
|
|
5067
|
-
object:
|
|
5345
|
+
object: F,
|
|
5068
5346
|
placement: e
|
|
5069
5347
|
});
|
|
5070
5348
|
}
|
|
5071
|
-
if (g) return
|
|
5349
|
+
if (g) return F;
|
|
5072
5350
|
this._beginMutation();
|
|
5073
5351
|
try {
|
|
5074
|
-
this.editor.canvas.add(
|
|
5352
|
+
this.editor.canvas.add(F), _ || this.editor.canvas.setActiveObject(F), this.editor.canvas.requestRenderAll();
|
|
5075
5353
|
} finally {
|
|
5076
5354
|
this._endMutation({ withoutSave: v });
|
|
5077
5355
|
}
|
|
5078
|
-
return
|
|
5356
|
+
return F;
|
|
5079
5357
|
}
|
|
5080
5358
|
async update({ target: e, presetKey: t, options: n = {} } = {}) {
|
|
5081
5359
|
let r = this._resolveShapeGroup({ target: e });
|
|
5082
5360
|
if (!r) return null;
|
|
5083
|
-
let i =
|
|
5361
|
+
let i = ut({ presetKey: t ?? r.shapePresetKey ?? "circle" });
|
|
5084
5362
|
if (!i) return null;
|
|
5085
5363
|
let { left: a, top: o, originX: s, originY: c, width: l, height: u, shapeTextAutoExpand: d, text: f, textStyle: p, alignH: m, alignV: h, textPadding: g, rounding: _, withoutSelection: v, withoutSave: y } = n, b = this.editor.canvasManager.resolveObjectPlacement({
|
|
5086
5364
|
object: r,
|
|
@@ -5088,20 +5366,31 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5088
5366
|
top: o,
|
|
5089
5367
|
originX: s,
|
|
5090
5368
|
originY: c
|
|
5091
|
-
}), x = this._resolveCurrentDimensions({ group: r }), S = Math.max(1, u ?? x.height), C = this._isShapeTextAutoExpandEnabled({ group: r }), w = d === void 0 ? C : d !== !1, T = _ ?? r.shapeRounding ?? 0, E =
|
|
5369
|
+
}), x = this._resolveCurrentDimensions({ group: r }), S = Math.max(1, u ?? x.height), C = this._isShapeTextAutoExpandEnabled({ group: r }), w = d === void 0 ? C : d !== !1, T = _ ?? r.shapeRounding ?? 0, E = ut({ presetKey: dt({
|
|
5092
5370
|
preset: i,
|
|
5093
5371
|
rounding: T
|
|
5094
|
-
}) }) ?? i, D = m ?? r.shapeAlignHorizontal ?? "center", O = h ?? r.shapeAlignVertical ?? "middle", k = this.
|
|
5095
|
-
|
|
5096
|
-
|
|
5097
|
-
}),
|
|
5372
|
+
}) }) ?? i, D = m ?? r.shapeAlignHorizontal ?? "center", O = h ?? r.shapeAlignVertical ?? "middle", k = this._resolveGroupUserPadding({ group: r }), A = Ut({ padding: g }), j = Bt({
|
|
5373
|
+
base: k,
|
|
5374
|
+
override: g
|
|
5375
|
+
}), M = this._resolveShapeStyle({
|
|
5098
5376
|
options: n,
|
|
5099
5377
|
fallback: r
|
|
5100
|
-
}),
|
|
5101
|
-
|
|
5102
|
-
|
|
5103
|
-
|
|
5104
|
-
|
|
5378
|
+
}), N = Ht({
|
|
5379
|
+
baseInset: pt({
|
|
5380
|
+
preset: E,
|
|
5381
|
+
width: x.width,
|
|
5382
|
+
height: S
|
|
5383
|
+
}),
|
|
5384
|
+
stroke: M.stroke,
|
|
5385
|
+
strokeWidth: M.strokeWidth
|
|
5386
|
+
}), P = Vt({
|
|
5387
|
+
base: N,
|
|
5388
|
+
addition: j
|
|
5389
|
+
}), F = Math.max(1, r.shapeManualBaseWidth ?? x.width);
|
|
5390
|
+
l !== void 0 && (F = Math.max(1, l)), l === void 0 && C && !w && (F = Math.max(1, x.width));
|
|
5391
|
+
let I = Math.max(1, u ?? r.shapeManualBaseHeight ?? S), { shape: ee, text: L } = Y({ group: r });
|
|
5392
|
+
if (!ee || !L) return null;
|
|
5393
|
+
let te = {
|
|
5105
5394
|
angle: 0,
|
|
5106
5395
|
skewX: 0,
|
|
5107
5396
|
skewY: 0,
|
|
@@ -5114,68 +5403,70 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5114
5403
|
top: 0,
|
|
5115
5404
|
originX: "left",
|
|
5116
5405
|
originY: "top"
|
|
5117
|
-
},
|
|
5118
|
-
text:
|
|
5119
|
-
textStyle: this._resolveCurrentTextStyle({ textNode:
|
|
5120
|
-
width: Math.max(1,
|
|
5406
|
+
}, ne = this._createTextNode({
|
|
5407
|
+
text: L.textCaseRaw ?? L.text ?? "",
|
|
5408
|
+
textStyle: this._resolveCurrentTextStyle({ textNode: L }),
|
|
5409
|
+
width: Math.max(1, L.width ?? x.width),
|
|
5121
5410
|
align: D
|
|
5122
5411
|
});
|
|
5123
|
-
|
|
5124
|
-
textNode:
|
|
5412
|
+
ne.set(te), this._applyTextUpdates({
|
|
5413
|
+
textNode: ne,
|
|
5125
5414
|
text: f,
|
|
5126
5415
|
textStyle: p,
|
|
5127
5416
|
align: D
|
|
5128
5417
|
});
|
|
5129
|
-
let
|
|
5130
|
-
text:
|
|
5418
|
+
let R = l === void 0 && u === void 0 && t === void 0 && d === void 0 && _ === void 0 && f === void 0 && !this._hasShapeTextSizeAffectingStyleChanges({ textStyle: p }), re = g !== void 0 && R, z = R ? x.width : this._resolveShapeLayoutWidth({
|
|
5419
|
+
text: ne,
|
|
5131
5420
|
currentWidth: x.width,
|
|
5132
|
-
manualWidth:
|
|
5421
|
+
manualWidth: F,
|
|
5133
5422
|
shapeTextAutoExpandEnabled: w,
|
|
5134
|
-
padding:
|
|
5135
|
-
|
|
5136
|
-
}), te = await _t({
|
|
5423
|
+
padding: P
|
|
5424
|
+
}), ie = await Nt({
|
|
5137
5425
|
preset: E,
|
|
5138
|
-
width:
|
|
5426
|
+
width: z,
|
|
5139
5427
|
height: S,
|
|
5140
|
-
style:
|
|
5428
|
+
style: M,
|
|
5141
5429
|
rounding: T
|
|
5142
|
-
}),
|
|
5143
|
-
if (
|
|
5144
|
-
let
|
|
5145
|
-
this._detachShapeGroupAutoLayout({ group: r }),
|
|
5146
|
-
textNode:
|
|
5430
|
+
}), B = r.getObjects().indexOf(ee);
|
|
5431
|
+
if (B < 0) return null;
|
|
5432
|
+
let ae = () => {
|
|
5433
|
+
this._detachShapeGroupAutoLayout({ group: r }), L.set(te), this._applyTextUpdates({
|
|
5434
|
+
textNode: L,
|
|
5147
5435
|
text: f,
|
|
5148
5436
|
textStyle: p,
|
|
5149
5437
|
align: D
|
|
5150
|
-
}), r.remove(
|
|
5438
|
+
}), r.remove(ee), r.insertAt(B, ie), this._applyShapeGroupMetadata({
|
|
5151
5439
|
group: r,
|
|
5152
5440
|
presetKey: E.key,
|
|
5153
|
-
presetCanRound:
|
|
5154
|
-
width:
|
|
5441
|
+
presetCanRound: ht({ preset: E }),
|
|
5442
|
+
width: z,
|
|
5155
5443
|
height: S,
|
|
5156
|
-
manualWidth:
|
|
5157
|
-
manualHeight:
|
|
5444
|
+
manualWidth: F,
|
|
5445
|
+
manualHeight: I,
|
|
5158
5446
|
shapeTextAutoExpand: w,
|
|
5159
5447
|
alignH: D,
|
|
5160
5448
|
alignV: O,
|
|
5161
|
-
padding:
|
|
5162
|
-
style:
|
|
5449
|
+
padding: j,
|
|
5450
|
+
style: M,
|
|
5163
5451
|
rounding: T
|
|
5164
5452
|
}), this._applyCurrentLayout({
|
|
5165
5453
|
group: r,
|
|
5166
|
-
shape:
|
|
5167
|
-
text:
|
|
5454
|
+
shape: ie,
|
|
5455
|
+
text: L,
|
|
5168
5456
|
placement: b,
|
|
5169
|
-
width:
|
|
5457
|
+
width: z,
|
|
5170
5458
|
height: S,
|
|
5171
5459
|
alignH: D,
|
|
5172
|
-
alignV: O
|
|
5173
|
-
|
|
5460
|
+
alignV: O,
|
|
5461
|
+
internalShapeTextInset: N,
|
|
5462
|
+
expandShapeHeightToFitText: !re,
|
|
5463
|
+
changedPadding: A
|
|
5464
|
+
}), L.isEditing && this.editingPlacements.set(r, b);
|
|
5174
5465
|
};
|
|
5175
|
-
if (!this._isOnCanvas({ object: r })) return
|
|
5466
|
+
if (!this._isOnCanvas({ object: r })) return ae(), r;
|
|
5176
5467
|
this._beginMutation();
|
|
5177
5468
|
try {
|
|
5178
|
-
|
|
5469
|
+
ae(), !L.isEditing && !v && this.editor.canvas.setActiveObject(r), this.editor.canvas.requestRenderAll();
|
|
5179
5470
|
} finally {
|
|
5180
5471
|
this._endMutation({ withoutSave: y });
|
|
5181
5472
|
}
|
|
@@ -5199,7 +5490,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5199
5490
|
if (!i) return null;
|
|
5200
5491
|
this._beginMutation();
|
|
5201
5492
|
try {
|
|
5202
|
-
|
|
5493
|
+
xt({
|
|
5203
5494
|
shape: i,
|
|
5204
5495
|
style: { fill: t }
|
|
5205
5496
|
}), r.shapeFill = t, r.setCoords(), this.editor.canvas.requestRenderAll();
|
|
@@ -5215,18 +5506,24 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5215
5506
|
if (!o) return null;
|
|
5216
5507
|
this._beginMutation();
|
|
5217
5508
|
try {
|
|
5218
|
-
|
|
5509
|
+
if (xt({
|
|
5219
5510
|
shape: o,
|
|
5220
5511
|
style: {
|
|
5221
5512
|
stroke: t,
|
|
5222
5513
|
strokeWidth: n,
|
|
5223
5514
|
strokeDashArray: r
|
|
5224
5515
|
}
|
|
5225
|
-
}), t !== void 0 && (a.shapeStroke = t), n !== void 0 && (a.shapeStrokeWidth = n), r !== void 0 && (a.shapeStrokeDashArray = r), s
|
|
5226
|
-
group: a
|
|
5227
|
-
|
|
5228
|
-
|
|
5229
|
-
|
|
5516
|
+
}), t !== void 0 && (a.shapeStroke = t), n !== void 0 && (a.shapeStrokeWidth = n), r !== void 0 && (a.shapeStrokeDashArray = r), s) {
|
|
5517
|
+
let e = this._resolveCurrentDimensions({ group: a });
|
|
5518
|
+
this._applyCurrentLayout({
|
|
5519
|
+
group: a,
|
|
5520
|
+
shape: o,
|
|
5521
|
+
text: s,
|
|
5522
|
+
width: e.width,
|
|
5523
|
+
height: e.height
|
|
5524
|
+
});
|
|
5525
|
+
}
|
|
5526
|
+
a.setCoords(), this.editor.canvas.requestRenderAll();
|
|
5230
5527
|
} finally {
|
|
5231
5528
|
this._endMutation({ withoutSave: i });
|
|
5232
5529
|
}
|
|
@@ -5239,7 +5536,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5239
5536
|
if (!i) return null;
|
|
5240
5537
|
this._beginMutation();
|
|
5241
5538
|
try {
|
|
5242
|
-
|
|
5539
|
+
xt({
|
|
5243
5540
|
shape: i,
|
|
5244
5541
|
style: { opacity: t }
|
|
5245
5542
|
}), a && (a.set({ opacity: t }), a.setCoords()), r.shapeOpacity = t, r.setCoords(), this.editor.canvas.requestRenderAll();
|
|
@@ -5331,8 +5628,8 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5331
5628
|
let { canvas: e } = this.editor;
|
|
5332
5629
|
e.on("object:scaling", this._handleObjectScaling), e.on("object:modified", this._handleObjectModified), e.on("mouse:move", this._handleMouseMove), e.on("mouse:down", this._handleMouseDown), e.on("text:editing:entered", this._handleTextEditingEntered), e.on("text:editing:exited", this._handleTextEditingExited), e.on("text:changed", this._handleTextChanged), e.on("editor:before:text-updated", this._handleBeforeTextUpdated);
|
|
5333
5630
|
}
|
|
5334
|
-
_createShapeGroup({ id: e, presetKey: t, presetCanRound: n, shape: r, text: i, width: a, height: o, manualWidth: s, manualHeight: c, shapeTextAutoExpand: l, alignH: u, alignV: d, padding: f,
|
|
5335
|
-
let
|
|
5631
|
+
_createShapeGroup({ id: e, presetKey: t, presetCanRound: n, shape: r, text: i, width: a, height: o, manualWidth: s, manualHeight: c, shapeTextAutoExpand: l, alignH: u, alignV: d, padding: f, internalShapeTextInset: p, changedPadding: m, style: h, rounding: g }) {
|
|
5632
|
+
let _ = new Ln([r, i], {
|
|
5336
5633
|
id: e,
|
|
5337
5634
|
originX: "center",
|
|
5338
5635
|
originY: "center",
|
|
@@ -5343,7 +5640,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5343
5640
|
objectCaching: !1
|
|
5344
5641
|
});
|
|
5345
5642
|
return this._applyShapeGroupMetadata({
|
|
5346
|
-
group:
|
|
5643
|
+
group: _,
|
|
5347
5644
|
presetKey: t,
|
|
5348
5645
|
presetCanRound: n,
|
|
5349
5646
|
width: a,
|
|
@@ -5354,18 +5651,20 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5354
5651
|
alignH: u,
|
|
5355
5652
|
alignV: d,
|
|
5356
5653
|
padding: f,
|
|
5357
|
-
style:
|
|
5358
|
-
rounding:
|
|
5359
|
-
}),
|
|
5360
|
-
group:
|
|
5654
|
+
style: h,
|
|
5655
|
+
rounding: g
|
|
5656
|
+
}), _.rehydrateRuntimeState(), Hn({ group: _ }), Tn({ text: i }), nn({
|
|
5657
|
+
group: _,
|
|
5361
5658
|
shape: r,
|
|
5362
5659
|
text: i,
|
|
5363
5660
|
width: a,
|
|
5364
5661
|
height: o,
|
|
5365
5662
|
alignH: u,
|
|
5366
5663
|
alignV: d,
|
|
5367
|
-
padding: f
|
|
5368
|
-
|
|
5664
|
+
padding: f,
|
|
5665
|
+
internalShapeTextInset: p,
|
|
5666
|
+
changedPadding: m
|
|
5667
|
+
}), this._detachShapeGroupAutoLayout({ group: _ }), _;
|
|
5369
5668
|
}
|
|
5370
5669
|
_applyShapeGroupMetadata({ group: e, presetKey: t, presetCanRound: n, width: r, height: i, manualWidth: a, manualHeight: o, shapeTextAutoExpand: s, alignH: c, alignV: l, padding: u, style: d, rounding: f }) {
|
|
5371
5670
|
let p = d.strokeDashArray ? d.strokeDashArray.slice() : d.strokeDashArray ?? null;
|
|
@@ -5412,7 +5711,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5412
5711
|
return s.set({
|
|
5413
5712
|
shapeNodeType: "text",
|
|
5414
5713
|
splitByGrapheme: !1
|
|
5415
|
-
}),
|
|
5714
|
+
}), Tn({ text: s }), s;
|
|
5416
5715
|
}
|
|
5417
5716
|
_applyTextUpdates({ textNode: e, text: t, textStyle: n, align: r }) {
|
|
5418
5717
|
let i = {};
|
|
@@ -5483,13 +5782,25 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5483
5782
|
height: Math.max(1, e.shapeManualBaseHeight ?? e.shapeBaseHeight ?? e.height ?? 1)
|
|
5484
5783
|
};
|
|
5485
5784
|
}
|
|
5486
|
-
|
|
5487
|
-
return {
|
|
5488
|
-
top: e.shapePaddingTop
|
|
5489
|
-
right: e.shapePaddingRight
|
|
5490
|
-
bottom: e.shapePaddingBottom
|
|
5491
|
-
left: e.shapePaddingLeft
|
|
5492
|
-
};
|
|
5785
|
+
_resolveGroupUserPadding({ group: e }) {
|
|
5786
|
+
return Rt({ padding: {
|
|
5787
|
+
top: e.shapePaddingTop,
|
|
5788
|
+
right: e.shapePaddingRight,
|
|
5789
|
+
bottom: e.shapePaddingBottom,
|
|
5790
|
+
left: e.shapePaddingLeft
|
|
5791
|
+
} });
|
|
5792
|
+
}
|
|
5793
|
+
_resolveGroupInternalShapeTextInset({ group: e, width: t, height: n }) {
|
|
5794
|
+
let r = ut({ presetKey: e.shapePresetKey ?? "circle" });
|
|
5795
|
+
return Ht({
|
|
5796
|
+
baseInset: r ? pt({
|
|
5797
|
+
preset: r,
|
|
5798
|
+
width: t,
|
|
5799
|
+
height: n
|
|
5800
|
+
}) : void 0,
|
|
5801
|
+
stroke: e.shapeStroke,
|
|
5802
|
+
strokeWidth: e.shapeStrokeWidth
|
|
5803
|
+
});
|
|
5493
5804
|
}
|
|
5494
5805
|
_isShapeTextAutoExpandEnabled({ group: e }) {
|
|
5495
5806
|
return e.shapeTextAutoExpand !== !1;
|
|
@@ -5500,53 +5811,64 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5500
5811
|
let { width: n } = e.getMontageAreaSceneBounds();
|
|
5501
5812
|
return !Number.isFinite(n) || n <= 0 ? null : n;
|
|
5502
5813
|
}
|
|
5503
|
-
_resolveAutoExpandShapeWidth({ text: e, currentWidth: t, minimumWidth: n, padding: r
|
|
5504
|
-
let
|
|
5505
|
-
return
|
|
5814
|
+
_resolveAutoExpandShapeWidth({ text: e, currentWidth: t, minimumWidth: n, padding: r }) {
|
|
5815
|
+
let i = this._resolveMontageAreaWidth();
|
|
5816
|
+
return i ? rn({
|
|
5506
5817
|
text: e,
|
|
5507
5818
|
currentWidth: t,
|
|
5508
5819
|
minimumWidth: n,
|
|
5509
5820
|
padding: r,
|
|
5510
|
-
|
|
5511
|
-
montageAreaWidth: a
|
|
5821
|
+
montageAreaWidth: i
|
|
5512
5822
|
}) : Math.max(1, t, n);
|
|
5513
5823
|
}
|
|
5514
|
-
_resolveShapeLayoutWidth({ text: e, currentWidth: t, manualWidth: n, shapeTextAutoExpandEnabled: r, padding: i
|
|
5824
|
+
_resolveShapeLayoutWidth({ text: e, currentWidth: t, manualWidth: n, shapeTextAutoExpandEnabled: r, padding: i }) {
|
|
5515
5825
|
return r ? this._resolveAutoExpandShapeWidth({
|
|
5516
5826
|
text: e,
|
|
5517
5827
|
currentWidth: t,
|
|
5518
5828
|
minimumWidth: n,
|
|
5519
|
-
padding: i
|
|
5520
|
-
strokeWidth: a
|
|
5829
|
+
padding: i
|
|
5521
5830
|
}) : Math.max(1, n);
|
|
5522
5831
|
}
|
|
5523
5832
|
_resolveShapeTextHorizontalAlign({ group: e, textStyle: t }) {
|
|
5524
5833
|
let n = t?.align;
|
|
5525
5834
|
return n === "left" || n === "center" || n === "right" ? n : e.shapeAlignHorizontal ?? "center";
|
|
5526
5835
|
}
|
|
5527
|
-
_applyCurrentLayout({ group: e, shape: t, text: n, placement: r, width: i, height: a, alignH: o, alignV: s }) {
|
|
5528
|
-
let
|
|
5529
|
-
|
|
5836
|
+
_applyCurrentLayout({ group: e, shape: t, text: n, placement: r, width: i, height: a, alignH: o, alignV: s, internalShapeTextInset: c, expandShapeHeightToFitText: l = !0, changedPadding: u }) {
|
|
5837
|
+
let d = this._resolveCurrentDimensions({ group: e }), f = this._resolveManualDimensions({ group: e }), p = this._resolveGroupUserPadding({ group: e }), m = d.width;
|
|
5838
|
+
m = i === void 0 ? this._resolveShapeLayoutWidth({
|
|
5530
5839
|
text: n,
|
|
5531
|
-
currentWidth:
|
|
5532
|
-
manualWidth:
|
|
5840
|
+
currentWidth: d.width,
|
|
5841
|
+
manualWidth: f.width,
|
|
5533
5842
|
shapeTextAutoExpandEnabled: this._isShapeTextAutoExpandEnabled({ group: e }),
|
|
5534
|
-
padding:
|
|
5535
|
-
|
|
5843
|
+
padding: Vt({
|
|
5844
|
+
base: c ?? this._resolveGroupInternalShapeTextInset({
|
|
5845
|
+
group: e,
|
|
5846
|
+
width: m,
|
|
5847
|
+
height: Math.max(1, a ?? d.height)
|
|
5848
|
+
}),
|
|
5849
|
+
addition: p
|
|
5850
|
+
})
|
|
5536
5851
|
}) : Math.max(1, i);
|
|
5537
|
-
let
|
|
5538
|
-
|
|
5852
|
+
let h = Math.max(1, a ?? d.height), g = c ?? this._resolveGroupInternalShapeTextInset({
|
|
5853
|
+
group: e,
|
|
5854
|
+
width: m,
|
|
5855
|
+
height: h
|
|
5856
|
+
}), _ = r ?? this.editor.canvasManager.getObjectPlacement({ object: e });
|
|
5857
|
+
nn({
|
|
5539
5858
|
group: e,
|
|
5540
5859
|
shape: t,
|
|
5541
5860
|
text: n,
|
|
5542
|
-
width:
|
|
5543
|
-
height:
|
|
5861
|
+
width: m,
|
|
5862
|
+
height: h,
|
|
5544
5863
|
alignH: o ?? e.shapeAlignHorizontal ?? "center",
|
|
5545
5864
|
alignV: s ?? e.shapeAlignVertical ?? "middle",
|
|
5546
|
-
padding:
|
|
5865
|
+
padding: p,
|
|
5866
|
+
internalShapeTextInset: g,
|
|
5867
|
+
expandShapeHeightToFitText: l,
|
|
5868
|
+
changedPadding: u
|
|
5547
5869
|
}), this.editor.canvasManager.applyObjectPlacement({
|
|
5548
5870
|
object: e,
|
|
5549
|
-
placement:
|
|
5871
|
+
placement: _
|
|
5550
5872
|
});
|
|
5551
5873
|
}
|
|
5552
5874
|
_syncShapeTextLayoutAfterTextMutation({ textNode: e, textStyle: t }) {
|
|
@@ -5572,21 +5894,30 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5572
5894
|
return this.editingPlacements.get(e) || this.editor.canvasManager.getObjectPlacement({ object: e });
|
|
5573
5895
|
}
|
|
5574
5896
|
_detachShapeGroupAutoLayout({ group: e }) {
|
|
5575
|
-
|
|
5897
|
+
En({ group: e });
|
|
5576
5898
|
}
|
|
5577
5899
|
_resolveHorizontalAlign({ explicitAlign: e, textStyle: t }) {
|
|
5578
5900
|
if (e) return e;
|
|
5579
5901
|
let n = t?.align;
|
|
5580
|
-
return n === "left" || n === "center" || n === "right" ? n :
|
|
5902
|
+
return n === "left" || n === "center" || n === "right" ? n : st;
|
|
5903
|
+
}
|
|
5904
|
+
_hasShapeTextSizeAffectingStyleChanges({ textStyle: e }) {
|
|
5905
|
+
if (!e) return !1;
|
|
5906
|
+
let t = Object.keys(e);
|
|
5907
|
+
for (let e = 0; e < t.length; e += 1) {
|
|
5908
|
+
let n = t[e];
|
|
5909
|
+
if (!(n === "align" || n === "color" || n === "strokeColor" || n === "strokeWidth" || n === "underline" || n === "strikethrough" || n === "opacity")) return !0;
|
|
5910
|
+
}
|
|
5911
|
+
return !1;
|
|
5581
5912
|
}
|
|
5582
5913
|
_resolveShapeStyle({ options: e, fallback: t }) {
|
|
5583
5914
|
let { fill: n, stroke: r, strokeWidth: i, strokeDashArray: a, opacity: o } = e, s = a === void 0 ? t?.shapeStrokeDashArray : a;
|
|
5584
5915
|
return {
|
|
5585
|
-
fill: n ?? t?.shapeFill ??
|
|
5916
|
+
fill: n ?? t?.shapeFill ?? ir,
|
|
5586
5917
|
stroke: r ?? t?.shapeStroke ?? null,
|
|
5587
|
-
strokeWidth: i ?? t?.shapeStrokeWidth ??
|
|
5918
|
+
strokeWidth: i ?? t?.shapeStrokeWidth ?? ar,
|
|
5588
5919
|
strokeDashArray: s ?? null,
|
|
5589
|
-
opacity: o ?? t?.shapeOpacity ??
|
|
5920
|
+
opacity: o ?? t?.shapeOpacity ?? or
|
|
5590
5921
|
};
|
|
5591
5922
|
}
|
|
5592
5923
|
_beginMutation() {
|
|
@@ -5622,7 +5953,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5622
5953
|
}
|
|
5623
5954
|
return null;
|
|
5624
5955
|
}
|
|
5625
|
-
},
|
|
5956
|
+
}, cr = class {
|
|
5626
5957
|
constructor({ editor: e }) {
|
|
5627
5958
|
this.editor = e, this.clipboard = null;
|
|
5628
5959
|
}
|
|
@@ -5878,12 +6209,12 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5878
6209
|
}), !1;
|
|
5879
6210
|
}
|
|
5880
6211
|
}
|
|
5881
|
-
},
|
|
6212
|
+
}, lr = class t {
|
|
5882
6213
|
constructor({ editor: e }) {
|
|
5883
6214
|
this.editor = e;
|
|
5884
6215
|
}
|
|
5885
6216
|
lockObject({ object: e, skipInnerObjects: n, withoutSave: r } = {}) {
|
|
5886
|
-
let { canvas: i, historyManager: a } = this.editor, o = e || i.getActiveObject(), s =
|
|
6217
|
+
let { canvas: i, historyManager: a } = this.editor, o = e || i.getActiveObject(), s = zn({ target: o }) ?? o;
|
|
5887
6218
|
if (!s || s.locked) return;
|
|
5888
6219
|
let c = {
|
|
5889
6220
|
lockMovementX: !0,
|
|
@@ -5905,7 +6236,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5905
6236
|
});
|
|
5906
6237
|
}
|
|
5907
6238
|
unlockObject({ object: e, withoutSave: n } = {}) {
|
|
5908
|
-
let { canvas: r, historyManager: i } = this.editor, a = e || r.getActiveObject(), o =
|
|
6239
|
+
let { canvas: r, historyManager: i } = this.editor, a = e || r.getActiveObject(), o = zn({ target: a }) ?? a;
|
|
5909
6240
|
if (!o) return;
|
|
5910
6241
|
let s = {
|
|
5911
6242
|
lockMovementX: !1,
|
|
@@ -5943,7 +6274,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5943
6274
|
!(n instanceof _) || !n.isEditing || n.exitEditing();
|
|
5944
6275
|
}
|
|
5945
6276
|
}
|
|
5946
|
-
},
|
|
6277
|
+
}, ur = class {
|
|
5947
6278
|
constructor({ editor: e }) {
|
|
5948
6279
|
this.editor = e;
|
|
5949
6280
|
}
|
|
@@ -6009,7 +6340,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6009
6340
|
i.resumeHistory(), n || i.saveState();
|
|
6010
6341
|
}
|
|
6011
6342
|
}
|
|
6012
|
-
},
|
|
6343
|
+
}, dr = class t {
|
|
6013
6344
|
constructor({ editor: e }) {
|
|
6014
6345
|
this.lastSelection = [], this.isCtrlSelectionBoxActive = !1, this.isSelectionMergeInProgress = !1, this.editor = e, this.selectionKey = this._resolveSelectionKey(), this.handleTextEditingEnteredBound = this._handleTextEditingEntered.bind(this), this.handleTextEditingExitedBound = this._handleTextEditingExited.bind(this), this.handleLockedSelectionBound = this._filterLockedSelection.bind(this), this.handleSelectionMergeBound = this._handleSelectionMerge.bind(this), this.handleSelectionChangeBound = this._handleSelectionChange.bind(this), this.handleSelectionClearedBound = this._handleSelectionCleared.bind(this), this.handleSelectionBoxStartBound = this._handleSelectionBoxStart.bind(this), this.handleSelectionBoxEndBound = this._handleSelectionBoxEnd.bind(this), this._applySelectionKey({ selectionKey: this.selectionKey }), this._bindEvents();
|
|
6015
6346
|
}
|
|
@@ -6203,7 +6534,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6203
6534
|
let { options: e } = this.editor, { selectionKey: t } = e;
|
|
6204
6535
|
return t === void 0 ? ["ctrlKey", "metaKey"] : t;
|
|
6205
6536
|
}
|
|
6206
|
-
},
|
|
6537
|
+
}, fr = class e {
|
|
6207
6538
|
constructor({ editor: e }) {
|
|
6208
6539
|
this.editor = e;
|
|
6209
6540
|
}
|
|
@@ -6243,7 +6574,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6243
6574
|
};
|
|
6244
6575
|
return i.fire("editor:objects-deleted", l), l;
|
|
6245
6576
|
}
|
|
6246
|
-
},
|
|
6577
|
+
}, pr = {
|
|
6247
6578
|
IMAGE_MANAGER: {
|
|
6248
6579
|
INVALID_CONTENT_TYPE: "INVALID_CONTENT_TYPE",
|
|
6249
6580
|
INVALID_SOURCE_TYPE: "INVALID_SOURCE_TYPE",
|
|
@@ -6281,7 +6612,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6281
6612
|
INVALID_TARGET: "TEMPLATE_INVALID_TARGET",
|
|
6282
6613
|
APPLY_FAILED: "TEMPLATE_APPLY_FAILED"
|
|
6283
6614
|
}
|
|
6284
|
-
},
|
|
6615
|
+
}, mr = class e {
|
|
6285
6616
|
constructor({ editor: e }) {
|
|
6286
6617
|
this._buffer = [], this.editor = e;
|
|
6287
6618
|
}
|
|
@@ -6339,9 +6670,9 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6339
6670
|
}), this.editor.canvas.fire("editor:warning", s);
|
|
6340
6671
|
}
|
|
6341
6672
|
static isValidErrorCode(e) {
|
|
6342
|
-
return e ? Object.values(
|
|
6673
|
+
return e ? Object.values(pr).some((t) => Object.values(t).includes(e)) : !1;
|
|
6343
6674
|
}
|
|
6344
|
-
},
|
|
6675
|
+
}, hr = class {
|
|
6345
6676
|
constructor({ editor: e }) {
|
|
6346
6677
|
this.currentBounds = null, this.editor = e;
|
|
6347
6678
|
}
|
|
@@ -6390,32 +6721,32 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6390
6721
|
updateBounds() {
|
|
6391
6722
|
this.currentBounds = this.calculatePanBounds();
|
|
6392
6723
|
}
|
|
6393
|
-
},
|
|
6724
|
+
}, gr = ({ textbox: e }) => {
|
|
6394
6725
|
if (!e.isEditing) return null;
|
|
6395
6726
|
let t = e.selectionStart ?? 0, n = e.selectionEnd ?? t;
|
|
6396
6727
|
return t === n ? null : {
|
|
6397
6728
|
start: Math.min(t, n),
|
|
6398
6729
|
end: Math.max(t, n)
|
|
6399
6730
|
};
|
|
6400
|
-
},
|
|
6731
|
+
}, _r = ({ textbox: e }) => {
|
|
6401
6732
|
let t = e.text?.length ?? 0;
|
|
6402
6733
|
return t <= 0 ? null : {
|
|
6403
6734
|
start: 0,
|
|
6404
6735
|
end: t
|
|
6405
6736
|
};
|
|
6406
|
-
},
|
|
6737
|
+
}, vr = ({ textbox: e, range: t }) => {
|
|
6407
6738
|
if (!t) return !1;
|
|
6408
6739
|
let n = e.text?.length ?? 0;
|
|
6409
6740
|
return n <= 0 ? !1 : t.start <= 0 && t.end >= n;
|
|
6410
|
-
},
|
|
6741
|
+
}, yr = ({ textbox: e, styles: t, range: n }) => {
|
|
6411
6742
|
if (!t || !Object.keys(t).length) return !1;
|
|
6412
6743
|
let { start: r, end: i } = n;
|
|
6413
6744
|
return i <= r ? !1 : (e.setSelectionStyles(t, r, i), !0);
|
|
6414
|
-
},
|
|
6745
|
+
}, br = ({ textbox: e, range: t, property: n }) => {
|
|
6415
6746
|
if (!t) return;
|
|
6416
6747
|
let r = e.getSelectionStyles(t.start, t.end, !0);
|
|
6417
6748
|
if (r.length) return r[0]?.[n];
|
|
6418
|
-
},
|
|
6749
|
+
}, xr = ({ strokeColor: e, width: t }) => t <= 0 ? null : e ?? "#000000", Sr = ({ width: e = 0 }) => e ? Math.max(0, e) : 0, Cr = ({ value: e }) => typeof e == "string" ? e.toLocaleUpperCase() : "", wr = ({ value: e, min: t, max: n }) => Math.min(Math.max(e, t), n), Tr = class e extends _ {
|
|
6419
6750
|
static {
|
|
6420
6751
|
this.type = "background-textbox";
|
|
6421
6752
|
}
|
|
@@ -6540,7 +6871,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6540
6871
|
this._removeShadow(e);
|
|
6541
6872
|
}
|
|
6542
6873
|
_getDecorationColorAt(e, t) {
|
|
6543
|
-
let n = this.getValueOfPropertyAt(e, t, "strokeWidth"), r =
|
|
6874
|
+
let n = this.getValueOfPropertyAt(e, t, "strokeWidth"), r = Sr({ width: typeof n == "number" && Number.isFinite(n) ? n : 0 }), i = this.getValueOfPropertyAt(e, t, "stroke"), a = i == null ? null : xr({
|
|
6544
6875
|
strokeColor: i,
|
|
6545
6876
|
width: r
|
|
6546
6877
|
});
|
|
@@ -6556,22 +6887,22 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6556
6887
|
_getCornerRadii({ width: e, height: t }) {
|
|
6557
6888
|
let n = e / 2, r = t / 2, i = Math.min(n, r);
|
|
6558
6889
|
return {
|
|
6559
|
-
bottomLeft:
|
|
6890
|
+
bottomLeft: wr({
|
|
6560
6891
|
value: this.radiusBottomLeft ?? 0,
|
|
6561
6892
|
min: 0,
|
|
6562
6893
|
max: i
|
|
6563
6894
|
}),
|
|
6564
|
-
bottomRight:
|
|
6895
|
+
bottomRight: wr({
|
|
6565
6896
|
value: this.radiusBottomRight ?? 0,
|
|
6566
6897
|
min: 0,
|
|
6567
6898
|
max: i
|
|
6568
6899
|
}),
|
|
6569
|
-
topLeft:
|
|
6900
|
+
topLeft: wr({
|
|
6570
6901
|
value: this.radiusTopLeft ?? 0,
|
|
6571
6902
|
min: 0,
|
|
6572
6903
|
max: i
|
|
6573
6904
|
}),
|
|
6574
|
-
topRight:
|
|
6905
|
+
topRight: wr({
|
|
6575
6906
|
value: this.radiusTopRight ?? 0,
|
|
6576
6907
|
min: 0,
|
|
6577
6908
|
max: i
|
|
@@ -6589,7 +6920,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6589
6920
|
_getEffectiveBackgroundFill() {
|
|
6590
6921
|
let e = this.backgroundColor;
|
|
6591
6922
|
if (!e) return null;
|
|
6592
|
-
let t =
|
|
6923
|
+
let t = wr({
|
|
6593
6924
|
value: this.backgroundOpacity ?? 1,
|
|
6594
6925
|
min: 0,
|
|
6595
6926
|
max: 1
|
|
@@ -6597,7 +6928,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6597
6928
|
try {
|
|
6598
6929
|
r = new n(e);
|
|
6599
6930
|
} catch (t) {
|
|
6600
|
-
return
|
|
6931
|
+
return mr.emitError({
|
|
6601
6932
|
origin: "BackgroundTextbox",
|
|
6602
6933
|
method: "_getEffectiveBackgroundFill",
|
|
6603
6934
|
code: "INVALID_COLOR_VALUE",
|
|
@@ -6611,19 +6942,19 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6611
6942
|
return r.setAlpha(t), r.toRgba();
|
|
6612
6943
|
}
|
|
6613
6944
|
static _renderRoundedRect({ ctx: e, height: t, left: n, radii: r, top: i, width: a }) {
|
|
6614
|
-
let o = n + a, s = i + t, { topLeft: c, topRight: l, bottomRight: u, bottomLeft: d } = r, f =
|
|
6945
|
+
let o = n + a, s = i + t, { topLeft: c, topRight: l, bottomRight: u, bottomLeft: d } = r, f = wr({
|
|
6615
6946
|
value: c,
|
|
6616
6947
|
min: 0,
|
|
6617
6948
|
max: a
|
|
6618
|
-
}), p =
|
|
6949
|
+
}), p = wr({
|
|
6619
6950
|
value: l,
|
|
6620
6951
|
min: 0,
|
|
6621
6952
|
max: a
|
|
6622
|
-
}), m =
|
|
6953
|
+
}), m = wr({
|
|
6623
6954
|
value: u,
|
|
6624
6955
|
min: 0,
|
|
6625
6956
|
max: a
|
|
6626
|
-
}), h =
|
|
6957
|
+
}), h = wr({
|
|
6627
6958
|
value: d,
|
|
6628
6959
|
min: 0,
|
|
6629
6960
|
max: a
|
|
@@ -6634,9 +6965,9 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6634
6965
|
let { width: e = 0, height: t = 0 } = this, n = Math.round(e), r = Math.round(t);
|
|
6635
6966
|
n !== e && (this.width = Math.max(0, n)), r !== t && (this.height = Math.max(0, r));
|
|
6636
6967
|
}
|
|
6637
|
-
},
|
|
6638
|
-
y?.setClass && y.setClass(
|
|
6639
|
-
},
|
|
6968
|
+
}, Er = () => {
|
|
6969
|
+
y?.setClass && y.setClass(Tr, "background-textbox");
|
|
6970
|
+
}, Dr = .01, Or = ({ textbox: e, lineIndices: t, updates: n }) => {
|
|
6640
6971
|
if (!t.length) return !1;
|
|
6641
6972
|
let { fontFamily: r, fontSize: i, fill: a, stroke: o } = n;
|
|
6642
6973
|
if (!(r !== void 0 || i !== void 0 || a !== void 0 || o !== void 0)) return !1;
|
|
@@ -6648,7 +6979,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6648
6979
|
r !== void 0 && d?.fontFamily !== r && (f.fontFamily = r, p = !0), i !== void 0 && d?.fontSize !== i && (f.fontSize = i, p = !0), a !== void 0 && d?.fill !== a && (f.fill = a, p = !0), o !== void 0 && (o === null && d?.stroke !== void 0 && (delete f.stroke, p = !0), o !== null && d?.stroke !== o && (f.stroke = o, p = !0)), p && (u ||= (c = { ...c }, !0), c[n] = f, l = !0);
|
|
6649
6980
|
}
|
|
6650
6981
|
return l && (e.lineFontDefaults = c), l;
|
|
6651
|
-
},
|
|
6982
|
+
}, kr = ({ lineText: e, lineStyles: t, lineDefaults: n }) => {
|
|
6652
6983
|
let r = e.length;
|
|
6653
6984
|
if (r === 0) return {
|
|
6654
6985
|
lineStyles: t,
|
|
@@ -6680,7 +7011,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6680
7011
|
lineStyles: l,
|
|
6681
7012
|
changed: u
|
|
6682
7013
|
};
|
|
6683
|
-
},
|
|
7014
|
+
}, Ar = ({ lineFontDefaults: e }) => {
|
|
6684
7015
|
if (!e) return;
|
|
6685
7016
|
let t = {};
|
|
6686
7017
|
for (let n in e) {
|
|
@@ -6691,7 +7022,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6691
7022
|
i && (t[r] = { ...i });
|
|
6692
7023
|
}
|
|
6693
7024
|
return t;
|
|
6694
|
-
},
|
|
7025
|
+
}, jr = ({ lineFontDefaults: e, scale: t }) => {
|
|
6695
7026
|
if (!e || !Number.isFinite(t) || Math.abs(t - 1) < .01) return;
|
|
6696
7027
|
let n = {}, r = !1, i = !1;
|
|
6697
7028
|
for (let a in e) {
|
|
@@ -6708,20 +7039,20 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6708
7039
|
n[o] = c, r = !0;
|
|
6709
7040
|
}
|
|
6710
7041
|
if (!(!r || !i)) return n;
|
|
6711
|
-
},
|
|
7042
|
+
}, Mr = ({ textbox: e, text: t }) => {
|
|
6712
7043
|
let { textLines: n } = e, r = Array.isArray(n) && n.length > 0 ? n.length : Math.max(t.split("\n").length, 1), i = 0;
|
|
6713
7044
|
for (let t = 0; t < r; t += 1) {
|
|
6714
7045
|
let n = e.getLineWidth(t);
|
|
6715
7046
|
n > i && (i = n);
|
|
6716
7047
|
}
|
|
6717
7048
|
return i;
|
|
6718
|
-
},
|
|
7049
|
+
}, Nr = ({ textbox: e, montageLeft: t, montageRight: n }) => {
|
|
6719
7050
|
e.setCoords();
|
|
6720
7051
|
let r = e.getBoundingRect(!1, !0), i = r.left ?? 0, a = i + (r.width ?? 0), o = n - t;
|
|
6721
7052
|
if (o > 0 && (r.width ?? 0) >= o - .01) return !1;
|
|
6722
7053
|
let s = 0;
|
|
6723
7054
|
return i < t ? s = t - i : a > n && (s = n - a), Math.abs(s) <= .01 ? !1 : (e.set({ left: (e.left ?? 0) + s }), !0);
|
|
6724
|
-
},
|
|
7055
|
+
}, Pr = ({ rawValue: e, calculatedValue: t }) => typeof e == "number" ? e : typeof t == "number" ? t : 0, Fr = ({ stylesList: e }) => {
|
|
6725
7056
|
let t = e.length;
|
|
6726
7057
|
if (!t) return !1;
|
|
6727
7058
|
for (let n = 0; n < t; n += 1) {
|
|
@@ -6731,16 +7062,16 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6731
7062
|
if (r !== void 0 || i !== void 0 || a !== void 0 || o !== void 0 || s !== void 0 || c !== void 0) return !0;
|
|
6732
7063
|
}
|
|
6733
7064
|
return !1;
|
|
6734
|
-
},
|
|
6735
|
-
let { width: t, height: n, calcTextWidth: r, calcTextHeight: i } = e, a = typeof r == "function" ? r.call(e) : void 0, o = typeof i == "function" ? i.call(e) : void 0, s =
|
|
7065
|
+
}, Ir = ({ textbox: e }) => {
|
|
7066
|
+
let { width: t, height: n, calcTextWidth: r, calcTextHeight: i } = e, a = typeof r == "function" ? r.call(e) : void 0, o = typeof i == "function" ? i.call(e) : void 0, s = Pr({
|
|
6736
7067
|
rawValue: t,
|
|
6737
7068
|
calculatedValue: a
|
|
6738
|
-
}), c =
|
|
7069
|
+
}), c = Pr({
|
|
6739
7070
|
rawValue: n,
|
|
6740
7071
|
calculatedValue: o
|
|
6741
7072
|
}), l = Number.isFinite(s) ? Math.round(s) : null, u = Number.isFinite(c) ? Math.round(c) : null, d = {};
|
|
6742
7073
|
return l !== null && l !== s && (d.width = Math.max(0, l)), u !== null && u !== c && (d.height = Math.max(0, u)), Object.keys(d).length ? (e.set(d), !0) : !1;
|
|
6743
|
-
},
|
|
7074
|
+
}, Lr = ({ textbox: e }) => {
|
|
6744
7075
|
let t = e.width ?? e.calcTextWidth(), n = e.fontSize ?? 16, { styles: r = {} } = e, { lineFontDefaults: i } = e, { paddingTop: a = 0, paddingRight: o = 0, paddingBottom: s = 0, paddingLeft: c = 0 } = e, { radiusTopLeft: l = 0, radiusTopRight: u = 0, radiusBottomRight: d = 0, radiusBottomLeft: f = 0 } = e;
|
|
6745
7076
|
return {
|
|
6746
7077
|
width: t,
|
|
@@ -6758,9 +7089,9 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6758
7089
|
bottomLeft: f
|
|
6759
7090
|
},
|
|
6760
7091
|
styles: JSON.parse(JSON.stringify(r)),
|
|
6761
|
-
lineFontDefaults:
|
|
7092
|
+
lineFontDefaults: Ar({ lineFontDefaults: i })
|
|
6762
7093
|
};
|
|
6763
|
-
},
|
|
7094
|
+
}, Rr = ({ base: e }) => {
|
|
6764
7095
|
let t = 1 / Math.max(1, e.width), n = [e.fontSize];
|
|
6765
7096
|
Object.values(e.styles).forEach((e) => {
|
|
6766
7097
|
Object.values(e).forEach((e) => {
|
|
@@ -6777,7 +7108,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6777
7108
|
fontScale: r,
|
|
6778
7109
|
proportionalScale: Math.max(t, r)
|
|
6779
7110
|
};
|
|
6780
|
-
},
|
|
7111
|
+
}, zr = ({ textbox: e, canvasManager: t, base: n, widthScale: r, heightScale: i, placement: a, shouldScaleFontSize: o, shouldScalePadding: s, shouldScaleRadii: c, shouldDisableAutoExpandOnHorizontalChange: l = !1, shouldRoundDimensions: u = !0 }) => {
|
|
6781
7112
|
let { width: d, fontSize: f, padding: p, radii: m, styles: h, lineFontDefaults: g } = n, _ = Math.max(1, d * r), v = u ? Math.max(1, Math.round(_)) : _, y = Math.max(Math.min(8, f), f * i), b = Object.keys(h).length > 0, x;
|
|
6782
7113
|
if (o && b) {
|
|
6783
7114
|
let e = {};
|
|
@@ -6796,7 +7127,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6796
7127
|
}), Object.keys(e).length && (x = e);
|
|
6797
7128
|
}
|
|
6798
7129
|
let S;
|
|
6799
|
-
o && (S =
|
|
7130
|
+
o && (S = jr({
|
|
6800
7131
|
lineFontDefaults: g,
|
|
6801
7132
|
scale: i
|
|
6802
7133
|
}));
|
|
@@ -6810,7 +7141,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6810
7141
|
topRight: Math.max(0, m.topRight * i),
|
|
6811
7142
|
bottomRight: Math.max(0, m.bottomRight * i),
|
|
6812
7143
|
bottomLeft: Math.max(0, m.bottomLeft * i)
|
|
6813
|
-
} : m, T = e.width ?? d, E = Math.abs(v - T) >
|
|
7144
|
+
} : m, T = e.width ?? d, E = Math.abs(v - T) > Dr;
|
|
6814
7145
|
l && E && (e.autoExpand = !1), x && (e.styles = x), S && (e.lineFontDefaults = S), e.set({
|
|
6815
7146
|
width: v,
|
|
6816
7147
|
fontSize: o ? y : f,
|
|
@@ -6832,7 +7163,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6832
7163
|
} finally {
|
|
6833
7164
|
e.shouldRoundDimensionsOnInit = D;
|
|
6834
7165
|
}
|
|
6835
|
-
let O = u ?
|
|
7166
|
+
let O = u ? Ir({ textbox: e }) : !1;
|
|
6836
7167
|
return O && (e.dirty = !0), t.applyObjectPlacement({
|
|
6837
7168
|
object: e,
|
|
6838
7169
|
placement: a
|
|
@@ -6840,18 +7171,18 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6840
7171
|
appliedWidth: e.width ?? v,
|
|
6841
7172
|
dimensionsRounded: O
|
|
6842
7173
|
};
|
|
6843
|
-
},
|
|
7174
|
+
}, Br = ({ transform: e }) => {
|
|
6844
7175
|
let { corner: t = "", action: n = "" } = e;
|
|
6845
7176
|
return {
|
|
6846
7177
|
isCornerHandle: t === "tl" || t === "tr" || t === "bl" || t === "br" || n === "scale",
|
|
6847
7178
|
isHorizontalHandle: t === "ml" || t === "mr" || n === "scaleX",
|
|
6848
7179
|
isVerticalHandle: t === "mt" || t === "mb" || n === "scaleY"
|
|
6849
7180
|
};
|
|
6850
|
-
},
|
|
7181
|
+
}, Vr = ({ textbox: e, transform: t, appliedWidth: n }) => {
|
|
6851
7182
|
t.scaleX = 1, t.scaleY = 1;
|
|
6852
7183
|
let { original: r } = t;
|
|
6853
7184
|
r && (r.scaleX = 1, r.scaleY = 1, r.width = n, r.height = e.height, r.left = e.left, r.top = e.top);
|
|
6854
|
-
},
|
|
7185
|
+
}, Hr = ({ textbox: e, transform: t, scenePoint: n }) => {
|
|
6855
7186
|
let { x: r, y: i } = e._getTransformedDimensions();
|
|
6856
7187
|
if (r <= 0 || i <= 0) return null;
|
|
6857
7188
|
let a = b.getLocalPoint(t, t.originX, t.originY, n.x, n.y), o = t, s = typeof o.signX == "number" && a.x * o.signX <= 0, c = typeof o.signY == "number" && a.y * o.signY <= 0, l = Math.abs(a.x / r), u = Math.abs(a.y / i);
|
|
@@ -6861,27 +7192,27 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6861
7192
|
stepScaleX: l,
|
|
6862
7193
|
stepScaleY: u
|
|
6863
7194
|
};
|
|
6864
|
-
},
|
|
6865
|
-
function
|
|
7195
|
+
}, Ur = 1e-4;
|
|
7196
|
+
function Wr(e) {
|
|
6866
7197
|
return !!e && e instanceof _;
|
|
6867
7198
|
}
|
|
6868
|
-
function
|
|
6869
|
-
if (!
|
|
7199
|
+
function Gr(e) {
|
|
7200
|
+
if (!Wr(e)) return !1;
|
|
6870
7201
|
let t = e.group;
|
|
6871
7202
|
return e.shapeNodeType === "text" && t?.shapeComposite === !0;
|
|
6872
7203
|
}
|
|
6873
|
-
var
|
|
7204
|
+
var Kr = class {
|
|
6874
7205
|
constructor({ canvas: t, canvasManager: n, persistScaledTextbox: r }) {
|
|
6875
7206
|
this.handleMouseMove = (e) => {
|
|
6876
7207
|
let t = this.canvas._currentTransform;
|
|
6877
7208
|
if (!t) return;
|
|
6878
7209
|
let { target: n } = t;
|
|
6879
|
-
if (!
|
|
7210
|
+
if (!Wr(n) || Gr(n)) return;
|
|
6880
7211
|
let r = this.scalingState.get(n);
|
|
6881
7212
|
if (!r || !e.e) return;
|
|
6882
|
-
let { isCornerHandle: i, isHorizontalHandle: a, isVerticalHandle: o } =
|
|
7213
|
+
let { isCornerHandle: i, isHorizontalHandle: a, isVerticalHandle: o } = Br({ transform: t });
|
|
6883
7214
|
if (!a && !o && !i) return;
|
|
6884
|
-
let s =
|
|
7215
|
+
let s = Hr({
|
|
6885
7216
|
textbox: n,
|
|
6886
7217
|
transform: t,
|
|
6887
7218
|
scenePoint: this.canvas.getScenePoint(e.e)
|
|
@@ -6904,20 +7235,20 @@ var Nr = class {
|
|
|
6904
7235
|
}, j = r.lastAllowedScaleX, M = r.lastAllowedScaleY;
|
|
6905
7236
|
if (i) {
|
|
6906
7237
|
let e = Math.max(r.minimumProportionalScale, r.lastAllowedScaleX * Math.sqrt(u * d)), t = c || l ? r.minimumProportionalScale : e;
|
|
6907
|
-
if (Math.abs(t - r.lastAllowedScaleX) <=
|
|
7238
|
+
if (Math.abs(t - r.lastAllowedScaleX) <= Ur) return;
|
|
6908
7239
|
j = t, M = t;
|
|
6909
7240
|
} else {
|
|
6910
7241
|
if (a) {
|
|
6911
7242
|
let e = r.lastAllowedScaleX * u, t = c ? r.minimumWidthScale : Math.max(r.minimumWidthScale, e);
|
|
6912
|
-
Math.abs(t - r.lastAllowedScaleX) >
|
|
7243
|
+
Math.abs(t - r.lastAllowedScaleX) > Ur && (j = t);
|
|
6913
7244
|
}
|
|
6914
7245
|
if (o) {
|
|
6915
7246
|
let e = r.lastAllowedScaleY * d, t = l ? r.minimumFontScale : Math.max(r.minimumFontScale, e);
|
|
6916
|
-
Math.abs(t - r.lastAllowedScaleY) >
|
|
7247
|
+
Math.abs(t - r.lastAllowedScaleY) > Ur && (M = t);
|
|
6917
7248
|
}
|
|
6918
|
-
if (Math.abs(j - r.lastAllowedScaleX) <=
|
|
7249
|
+
if (Math.abs(j - r.lastAllowedScaleX) <= Ur && Math.abs(M - r.lastAllowedScaleY) <= Ur) return;
|
|
6919
7250
|
}
|
|
6920
|
-
let { appliedWidth: N, dimensionsRounded: P } =
|
|
7251
|
+
let { appliedWidth: N, dimensionsRounded: P } = zr({
|
|
6921
7252
|
textbox: n,
|
|
6922
7253
|
canvasManager: this.canvasManager,
|
|
6923
7254
|
base: r.startBase,
|
|
@@ -6930,7 +7261,7 @@ var Nr = class {
|
|
|
6930
7261
|
shouldDisableAutoExpandOnHorizontalChange: a,
|
|
6931
7262
|
shouldRoundDimensions: !i
|
|
6932
7263
|
});
|
|
6933
|
-
|
|
7264
|
+
Vr({
|
|
6934
7265
|
textbox: n,
|
|
6935
7266
|
transform: t,
|
|
6936
7267
|
appliedWidth: N
|
|
@@ -6951,12 +7282,12 @@ var Nr = class {
|
|
|
6951
7282
|
}), this.canvas.requestRenderAll();
|
|
6952
7283
|
}, this.handleObjectScaling = (t) => {
|
|
6953
7284
|
let { target: n, transform: r } = t;
|
|
6954
|
-
if (n instanceof e || !
|
|
7285
|
+
if (n instanceof e || !Wr(n) || Gr(n) || !r) return;
|
|
6955
7286
|
n.isScaling = !0;
|
|
6956
7287
|
let i = this._ensureScalingState({
|
|
6957
7288
|
textbox: n,
|
|
6958
7289
|
transform: r
|
|
6959
|
-
}), { startBase: a } = i, { width: o, fontSize: s } = a, { isCornerHandle: c, isHorizontalHandle: l, isVerticalHandle: u } =
|
|
7290
|
+
}), { startBase: a } = i, { width: o, fontSize: s } = a, { isCornerHandle: c, isHorizontalHandle: l, isVerticalHandle: u } = Br({ transform: r }), d = r.corner ?? "", f = c || u;
|
|
6960
7291
|
if (!l && !u && !c) return;
|
|
6961
7292
|
let p = n.scaleX ?? r.scaleX ?? 1, m = n.scaleY ?? r.scaleY ?? 1, h = Math.abs(p) || 1, g = Math.abs(m) || 1, _ = r.originX ?? n.originX ?? "center", v = r.originY ?? n.originY ?? "center", y = this.canvasManager.getObjectPlacement({
|
|
6962
7293
|
object: n,
|
|
@@ -6971,7 +7302,7 @@ var Nr = class {
|
|
|
6971
7302
|
N = e, P = e;
|
|
6972
7303
|
}
|
|
6973
7304
|
} else l && (N = Math.max(i.minimumWidthScale, i.lastAllowedScaleX * h)), u && (P = Math.max(i.minimumFontScale, i.lastAllowedScaleY * g));
|
|
6974
|
-
let { appliedWidth: ee, dimensionsRounded: L } =
|
|
7305
|
+
let { appliedWidth: ee, dimensionsRounded: L } = zr({
|
|
6975
7306
|
textbox: n,
|
|
6976
7307
|
canvasManager: this.canvasManager,
|
|
6977
7308
|
base: a,
|
|
@@ -6984,7 +7315,7 @@ var Nr = class {
|
|
|
6984
7315
|
shouldDisableAutoExpandOnHorizontalChange: l,
|
|
6985
7316
|
shouldRoundDimensions: !c
|
|
6986
7317
|
});
|
|
6987
|
-
|
|
7318
|
+
Vr({
|
|
6988
7319
|
textbox: n,
|
|
6989
7320
|
transform: r,
|
|
6990
7321
|
appliedWidth: ee
|
|
@@ -7017,7 +7348,7 @@ var Nr = class {
|
|
|
7017
7348
|
let { target: n } = t;
|
|
7018
7349
|
if (n instanceof e) {
|
|
7019
7350
|
let t = n.getObjects();
|
|
7020
|
-
if (!t.some((e) =>
|
|
7351
|
+
if (!t.some((e) => Wr(e))) return;
|
|
7021
7352
|
let { scaleX: r = 1, scaleY: i = 1 } = n;
|
|
7022
7353
|
if (Math.abs(r - 1) < .01 && Math.abs(i - 1) < .01) return;
|
|
7023
7354
|
this.canvas.discardActiveObject(), t.forEach((e) => {
|
|
@@ -7027,7 +7358,7 @@ var Nr = class {
|
|
|
7027
7358
|
this.canvas.setActiveObject(a), this.canvas.requestRenderAll();
|
|
7028
7359
|
return;
|
|
7029
7360
|
}
|
|
7030
|
-
if (!
|
|
7361
|
+
if (!Wr(n) || Gr(n)) return;
|
|
7031
7362
|
n.isScaling = !1;
|
|
7032
7363
|
let r = this.scalingState.get(n);
|
|
7033
7364
|
if (this.scalingState.delete(n), !r?.hasScalingChange) return;
|
|
@@ -7052,11 +7383,11 @@ var Nr = class {
|
|
|
7052
7383
|
}, this.canvas = t, this.canvasManager = n, this.persistScaledTextbox = r, this.scalingState = /* @__PURE__ */ new WeakMap();
|
|
7053
7384
|
}
|
|
7054
7385
|
commitStandaloneTextScale({ target: e, shouldDisableAutoExpandOnHorizontalChange: t = !1 }) {
|
|
7055
|
-
if (!
|
|
7386
|
+
if (!Wr(e) || Gr(e)) return !1;
|
|
7056
7387
|
let n = Math.abs(e.scaleX ?? 1) || 1, r = Math.abs(e.scaleY ?? 1) || 1;
|
|
7057
7388
|
if (!(Math.abs(n - 1) > .01 || Math.abs(r - 1) > .01)) return !1;
|
|
7058
|
-
let i =
|
|
7059
|
-
return
|
|
7389
|
+
let i = Lr({ textbox: e }), a = this.canvasManager.getObjectPlacement({ object: e });
|
|
7390
|
+
return zr({
|
|
7060
7391
|
textbox: e,
|
|
7061
7392
|
canvasManager: this.canvasManager,
|
|
7062
7393
|
base: i,
|
|
@@ -7072,7 +7403,7 @@ var Nr = class {
|
|
|
7072
7403
|
_ensureScalingState({ textbox: e, transform: t }) {
|
|
7073
7404
|
let n = this.scalingState.get(e);
|
|
7074
7405
|
if (!n) {
|
|
7075
|
-
let r =
|
|
7406
|
+
let r = Lr({ textbox: e }), i = Rr({ base: r }), a = t.original?.originX ?? t.originX ?? e.originX ?? "center", o = t.original?.originY ?? t.originY ?? e.originY ?? "center";
|
|
7076
7407
|
n = {
|
|
7077
7408
|
startBase: r,
|
|
7078
7409
|
startTransformCorner: typeof t.corner == "string" ? t.corner : null,
|
|
@@ -7104,7 +7435,7 @@ var Nr = class {
|
|
|
7104
7435
|
topRight: e.radiusTopRight ?? 0,
|
|
7105
7436
|
bottomRight: e.radiusBottomRight ?? 0,
|
|
7106
7437
|
bottomLeft: e.radiusBottomLeft ?? 0
|
|
7107
|
-
}, v = Math.abs(n - o) >
|
|
7438
|
+
}, v = Math.abs(n - o) > Dr, y = Math.abs(h - r) > Dr, b = Math.abs(g.top - i.top) > .01 || Math.abs(g.right - i.right) > .01 || Math.abs(g.bottom - i.bottom) > .01 || Math.abs(g.left - i.left) > .01, x = Math.abs(_.topLeft - a.topLeft) > .01 || Math.abs(_.topRight - a.topRight) > .01 || Math.abs(_.bottomRight - a.bottomRight) > .01 || Math.abs(_.bottomLeft - a.bottomLeft) > .01, S = t.lastAllowedScaleX, C = t.lastAllowedScaleY;
|
|
7108
7439
|
if (c) {
|
|
7109
7440
|
let e = h / Math.max(1, m);
|
|
7110
7441
|
S = e, C = e;
|
|
@@ -7125,7 +7456,7 @@ var Nr = class {
|
|
|
7125
7456
|
originY: a
|
|
7126
7457
|
});
|
|
7127
7458
|
}
|
|
7128
|
-
},
|
|
7459
|
+
}, qr = ({ textbox: e }) => {
|
|
7129
7460
|
let t = e.text ?? "";
|
|
7130
7461
|
if (!t.length) return [];
|
|
7131
7462
|
let n = t.split("\n"), r = [], i = 0;
|
|
@@ -7137,7 +7468,7 @@ var Nr = class {
|
|
|
7137
7468
|
});
|
|
7138
7469
|
}
|
|
7139
7470
|
return r;
|
|
7140
|
-
},
|
|
7471
|
+
}, Jr = ({ range: e, text: t }) => {
|
|
7141
7472
|
if (!e) return null;
|
|
7142
7473
|
let n = t.length;
|
|
7143
7474
|
if (n <= 0) return null;
|
|
@@ -7146,8 +7477,8 @@ var Nr = class {
|
|
|
7146
7477
|
start: l,
|
|
7147
7478
|
end: u
|
|
7148
7479
|
};
|
|
7149
|
-
},
|
|
7150
|
-
let n =
|
|
7480
|
+
}, Yr = ({ textbox: e, range: t }) => {
|
|
7481
|
+
let n = qr({ textbox: e });
|
|
7151
7482
|
if (!n.length) return t;
|
|
7152
7483
|
let { start: r } = t, { end: i } = t;
|
|
7153
7484
|
for (let e = 0; e < n.length; e += 1) {
|
|
@@ -7160,7 +7491,7 @@ var Nr = class {
|
|
|
7160
7491
|
start: r,
|
|
7161
7492
|
end: i
|
|
7162
7493
|
};
|
|
7163
|
-
},
|
|
7494
|
+
}, Xr = ({ textbox: e, range: t }) => {
|
|
7164
7495
|
let n = e.text ?? "";
|
|
7165
7496
|
if (!n.length) return [];
|
|
7166
7497
|
let { start: r, end: i } = t, a = n.split("\n"), o = [], s = 0;
|
|
@@ -7169,7 +7500,7 @@ var Nr = class {
|
|
|
7169
7500
|
i > n && r < c && o.push(e), s = c + 1;
|
|
7170
7501
|
}
|
|
7171
7502
|
return o;
|
|
7172
|
-
},
|
|
7503
|
+
}, Zr = ({ textbox: e, range: t }) => {
|
|
7173
7504
|
let n = e.text ?? "";
|
|
7174
7505
|
if (!n.length) return [];
|
|
7175
7506
|
let { start: r, end: i } = t, a = n.split("\n"), o = [], s = 0;
|
|
@@ -7178,20 +7509,20 @@ var Nr = class {
|
|
|
7178
7509
|
r <= n && i >= c && o.push(e), s = c + 1;
|
|
7179
7510
|
}
|
|
7180
7511
|
return o;
|
|
7181
|
-
},
|
|
7512
|
+
}, Qr = ({ previous: e, next: t }) => {
|
|
7182
7513
|
let n = Math.min(e.length, t.length);
|
|
7183
7514
|
for (let r = 0; r < n; r += 1) if (e[r] !== t[r]) return r;
|
|
7184
7515
|
return n;
|
|
7185
|
-
},
|
|
7516
|
+
}, $r = ({ text: e, charIndex: t }) => {
|
|
7186
7517
|
let n = Math.max(0, Math.min(t, e.length)), r = 0;
|
|
7187
7518
|
for (let t = 0; t < n; t += 1) e[t] === "\n" && (r += 1);
|
|
7188
7519
|
return r;
|
|
7189
|
-
},
|
|
7520
|
+
}, ei = ({ text: e, lineIndex: t }) => {
|
|
7190
7521
|
if (t <= 0) return 0;
|
|
7191
7522
|
let n = 0;
|
|
7192
7523
|
for (let r = 0; r < e.length; r += 1) if (e[r] === "\n" && (n += 1, n === t)) return r + 1;
|
|
7193
7524
|
return e.length;
|
|
7194
|
-
},
|
|
7525
|
+
}, ti = class e {
|
|
7195
7526
|
constructor({ editor: t }) {
|
|
7196
7527
|
this._handleTextEditingEntered = (t) => {
|
|
7197
7528
|
this.isTextEditingActive = !0;
|
|
@@ -7204,7 +7535,7 @@ var Nr = class {
|
|
|
7204
7535
|
if (!e._isTextbox(n) || this.lineDefaultsSyncing.has(n)) return;
|
|
7205
7536
|
let r = e._isShapeOwnedTextbox(n), { text: i = "", uppercase: a, autoExpand: o } = n, s = !!a, c = o !== !1, l = i.toLocaleLowerCase(), u = r ? null : this.editingPlacementState?.get(n) ?? this.editor.canvasManager.getObjectPlacement({ object: n });
|
|
7206
7537
|
if (s) {
|
|
7207
|
-
let e =
|
|
7538
|
+
let e = Cr({ value: l });
|
|
7208
7539
|
e !== i && n.set({ text: e }), n.textCaseRaw = l;
|
|
7209
7540
|
} else n.textCaseRaw = i;
|
|
7210
7541
|
if (!r && o === void 0 && (n.autoExpand = !0), r) {
|
|
@@ -7222,7 +7553,7 @@ var Nr = class {
|
|
|
7222
7553
|
let r = e._isShapeOwnedTextbox(n);
|
|
7223
7554
|
this.editingPlacementState?.delete(n);
|
|
7224
7555
|
let i = n.text ?? "";
|
|
7225
|
-
n.uppercase ? n.textCaseRaw = n.textCaseRaw ?? i.toLocaleLowerCase() : n.textCaseRaw = i, r || (
|
|
7556
|
+
n.uppercase ? n.textCaseRaw = n.textCaseRaw ?? i.toLocaleLowerCase() : n.textCaseRaw = i, r || (Ir({ textbox: n }) && (n.setCoords(), n.dirty = !0, this.canvas.requestRenderAll()), n.locked || n.set({
|
|
7226
7557
|
lockMovementX: !1,
|
|
7227
7558
|
lockMovementY: !1
|
|
7228
7559
|
}));
|
|
@@ -7249,7 +7580,7 @@ var Nr = class {
|
|
|
7249
7580
|
transform: r,
|
|
7250
7581
|
event: i ?? null
|
|
7251
7582
|
});
|
|
7252
|
-
}, this.editor = t, this.canvas = t.canvas, this.fonts = t.options.fonts ?? [], this.scalingController = new
|
|
7583
|
+
}, this.editor = t, this.canvas = t.canvas, this.fonts = t.options.fonts ?? [], this.scalingController = new Kr({
|
|
7253
7584
|
canvas: t.canvas,
|
|
7254
7585
|
canvasManager: t.canvasManager,
|
|
7255
7586
|
persistScaledTextbox: ({ target: e, style: t }) => {
|
|
@@ -7258,12 +7589,12 @@ var Nr = class {
|
|
|
7258
7589
|
style: t
|
|
7259
7590
|
});
|
|
7260
7591
|
}
|
|
7261
|
-
}), this.editingPlacementState = /* @__PURE__ */ new WeakMap(), this.lineDefaultsSyncing = /* @__PURE__ */ new WeakSet(), this.isTextEditingActive = !1, this._bindEvents(),
|
|
7592
|
+
}), this.editingPlacementState = /* @__PURE__ */ new WeakMap(), this.lineDefaultsSyncing = /* @__PURE__ */ new WeakSet(), this.isTextEditingActive = !1, this._bindEvents(), Er();
|
|
7262
7593
|
}
|
|
7263
7594
|
addText({ id: t = `text-${D()}`, text: n = "Новый текст", autoExpand: r = !0, fontFamily: i, fontSize: a = 48, bold: o = !1, italic: s = !1, underline: c = !1, uppercase: l = !1, strikethrough: u = !1, align: d = "left", color: f = "#000000", strokeColor: p, strokeWidth: m = 0, opacity: h = 1, backgroundColor: g, backgroundOpacity: _ = 1, paddingTop: v = 0, paddingRight: y = 0, paddingBottom: b = 0, paddingLeft: x = 0, radiusTopLeft: S = 0, radiusTopRight: C = 0, radiusBottomRight: w = 0, radiusBottomLeft: T = 0, ...E } = {}, { withoutSelection: O = !1, withoutSave: k = !1, withoutAdding: A = !1 } = {}) {
|
|
7264
7595
|
let { canvasManager: j, historyManager: M } = this.editor, { canvas: N } = this;
|
|
7265
7596
|
M.suspendHistory();
|
|
7266
|
-
let P = i ?? this._getDefaultFontFamily(), F =
|
|
7597
|
+
let P = i ?? this._getDefaultFontFamily(), F = Sr({ width: m }), I = xr({
|
|
7267
7598
|
strokeColor: p,
|
|
7268
7599
|
width: F
|
|
7269
7600
|
}), ee = {
|
|
@@ -7292,14 +7623,14 @@ var Nr = class {
|
|
|
7292
7623
|
radiusBottomRight: w,
|
|
7293
7624
|
radiusBottomLeft: T,
|
|
7294
7625
|
...E
|
|
7295
|
-
}, L = new
|
|
7626
|
+
}, L = new Tr(n, ee), te = r !== !1;
|
|
7296
7627
|
L.autoExpand = te;
|
|
7297
7628
|
let ne = E.left !== void 0 || E.top !== void 0;
|
|
7298
7629
|
if (L.textCaseRaw = L.text ?? "", l) {
|
|
7299
|
-
let e =
|
|
7630
|
+
let e = Cr({ value: L.textCaseRaw });
|
|
7300
7631
|
e !== L.text && L.set({ text: e });
|
|
7301
7632
|
}
|
|
7302
|
-
|
|
7633
|
+
Ir({ textbox: L }) && (L.dirty = !0);
|
|
7303
7634
|
let R;
|
|
7304
7635
|
ne && (R = j.resolveObjectPlacement({
|
|
7305
7636
|
object: L,
|
|
@@ -7346,13 +7677,13 @@ var Nr = class {
|
|
|
7346
7677
|
top: ee,
|
|
7347
7678
|
originX: L,
|
|
7348
7679
|
originY: te
|
|
7349
|
-
}), z = a === void 0 ?
|
|
7680
|
+
}), z = a === void 0 ? gr({ textbox: o }) : Jr({
|
|
7350
7681
|
text: s,
|
|
7351
7682
|
range: a
|
|
7352
|
-
}), ie = z ?
|
|
7683
|
+
}), ie = z ? Yr({
|
|
7353
7684
|
textbox: o,
|
|
7354
7685
|
range: z
|
|
7355
|
-
}) : null, B = {}, ae = {}, V = {}, oe, se, ce =
|
|
7686
|
+
}) : null, B = {}, ae = {}, V = {}, oe, se, ce = vr({
|
|
7356
7687
|
textbox: o,
|
|
7357
7688
|
range: z
|
|
7358
7689
|
}), le = !z || ce, H = !z;
|
|
@@ -7365,72 +7696,72 @@ var Nr = class {
|
|
|
7365
7696
|
z && (B.fontStyle = e), le && (R.fontStyle = e, H && (V.fontStyle = e));
|
|
7366
7697
|
}
|
|
7367
7698
|
if (v !== void 0 && (z && (B.underline = v), le && (R.underline = v, H && (V.underline = v))), b !== void 0 && (z && (B.linethrough = b), le && (R.linethrough = b, H && (V.linethrough = b))), x !== void 0 && (R.textAlign = x), S !== void 0 && (z && (B.fill = S), le && (R.fill = S, H && (V.fill = S))), C !== void 0 || w !== void 0) {
|
|
7368
|
-
let e = z ?
|
|
7699
|
+
let e = z ? br({
|
|
7369
7700
|
textbox: o,
|
|
7370
7701
|
range: z,
|
|
7371
7702
|
property: "strokeWidth"
|
|
7372
|
-
}) : void 0, t = z ?
|
|
7703
|
+
}) : void 0, t = z ? br({
|
|
7373
7704
|
textbox: o,
|
|
7374
7705
|
range: z,
|
|
7375
7706
|
property: "stroke"
|
|
7376
7707
|
}) : void 0;
|
|
7377
|
-
se =
|
|
7708
|
+
se = Sr({ width: w ?? e ?? o.strokeWidth ?? 0 }), oe = xr({
|
|
7378
7709
|
strokeColor: C ?? t ?? o.stroke ?? void 0,
|
|
7379
7710
|
width: se
|
|
7380
7711
|
}), z && (B.stroke = oe, B.strokeWidth = se), le && (R.stroke = oe, R.strokeWidth = se, H && (V.stroke = oe, V.strokeWidth = se));
|
|
7381
7712
|
}
|
|
7382
7713
|
T !== void 0 && (R.opacity = T), E !== void 0 && (R.backgroundColor = E), D !== void 0 && (R.backgroundOpacity = D), O !== void 0 && (R.paddingTop = O), k !== void 0 && (R.paddingRight = k), A !== void 0 && (R.paddingBottom = A), j !== void 0 && (R.paddingLeft = j), M !== void 0 && (R.radiusTopLeft = M), N !== void 0 && (R.radiusTopRight = N), P !== void 0 && (R.radiusBottomRight = P), F !== void 0 && (R.radiusBottomLeft = F);
|
|
7383
7714
|
let ue = o.textCaseRaw ?? s, de = !!o.uppercase, fe = f !== void 0, pe = fe ? f ?? "" : ue, me = y ?? de, he = me !== de;
|
|
7384
|
-
fe || he ? (R.text = me ?
|
|
7715
|
+
fe || he ? (R.text = me ? Cr({ value: pe }) : pe, o.textCaseRaw = pe) : o.textCaseRaw === void 0 && (o.textCaseRaw = ue), o.uppercase = me, o.set(R);
|
|
7385
7716
|
let ge = !1;
|
|
7386
7717
|
if (z) {
|
|
7387
|
-
let e =
|
|
7718
|
+
let e = yr({
|
|
7388
7719
|
textbox: o,
|
|
7389
7720
|
styles: B,
|
|
7390
7721
|
range: z
|
|
7391
|
-
}), t = ie ?
|
|
7722
|
+
}), t = ie ? yr({
|
|
7392
7723
|
textbox: o,
|
|
7393
7724
|
styles: ae,
|
|
7394
7725
|
range: ie
|
|
7395
7726
|
}) : !1;
|
|
7396
7727
|
ge = e || t;
|
|
7397
7728
|
} else if (Object.keys(V).length) {
|
|
7398
|
-
let e =
|
|
7399
|
-
e && (ge =
|
|
7729
|
+
let e = _r({ textbox: o });
|
|
7730
|
+
e && (ge = yr({
|
|
7400
7731
|
textbox: o,
|
|
7401
7732
|
styles: V,
|
|
7402
7733
|
range: e
|
|
7403
7734
|
}));
|
|
7404
7735
|
}
|
|
7405
|
-
let _e = ge &&
|
|
7736
|
+
let _e = ge && Fr({ stylesList: [
|
|
7406
7737
|
B,
|
|
7407
7738
|
ae,
|
|
7408
7739
|
V
|
|
7409
7740
|
] });
|
|
7410
7741
|
if (ge && (o.dirty = !0), ie && (m !== void 0 || h !== void 0)) {
|
|
7411
|
-
let e =
|
|
7742
|
+
let e = Xr({
|
|
7412
7743
|
textbox: o,
|
|
7413
7744
|
range: ie
|
|
7414
7745
|
}), t = {};
|
|
7415
|
-
m !== void 0 && (t.fontFamily = m), h !== void 0 && (t.fontSize = h),
|
|
7746
|
+
m !== void 0 && (t.fontFamily = m), h !== void 0 && (t.fontSize = h), Or({
|
|
7416
7747
|
textbox: o,
|
|
7417
7748
|
lineIndices: e,
|
|
7418
7749
|
updates: t
|
|
7419
7750
|
});
|
|
7420
7751
|
}
|
|
7421
7752
|
if (z && (S !== void 0 || C !== void 0 || w !== void 0)) {
|
|
7422
|
-
let e =
|
|
7753
|
+
let e = Zr({
|
|
7423
7754
|
textbox: o,
|
|
7424
7755
|
range: z
|
|
7425
7756
|
}), t = {};
|
|
7426
|
-
S !== void 0 && (t.fill = S), (C !== void 0 || w !== void 0) && (oe === null && (t.stroke = null), oe != null && (t.stroke = oe)),
|
|
7757
|
+
S !== void 0 && (t.fill = S), (C !== void 0 || w !== void 0) && (oe === null && (t.stroke = null), oe != null && (t.stroke = oe)), Or({
|
|
7427
7758
|
textbox: o,
|
|
7428
7759
|
lineIndices: e,
|
|
7429
7760
|
updates: t
|
|
7430
7761
|
});
|
|
7431
7762
|
}
|
|
7432
7763
|
_e && (o.initDimensions(), o.dirty = !0), (E !== void 0 || D !== void 0 || O !== void 0 || k !== void 0 || A !== void 0 || j !== void 0 || M !== void 0 || N !== void 0 || P !== void 0 || F !== void 0) && (o.dirty = !0);
|
|
7433
|
-
let ve =
|
|
7764
|
+
let ve = Fr({ stylesList: [
|
|
7434
7765
|
R,
|
|
7435
7766
|
B,
|
|
7436
7767
|
ae,
|
|
@@ -7512,7 +7843,7 @@ var Nr = class {
|
|
|
7512
7843
|
clampToMontage: r
|
|
7513
7844
|
}));
|
|
7514
7845
|
let a = !1;
|
|
7515
|
-
i || (a =
|
|
7846
|
+
i || (a = Ir({ textbox: e }));
|
|
7516
7847
|
let o = !1;
|
|
7517
7848
|
return !i && t && (this.editor.canvasManager.applyObjectPlacement({
|
|
7518
7849
|
object: e,
|
|
@@ -7526,15 +7857,15 @@ var Nr = class {
|
|
|
7526
7857
|
_syncLineFontDefaultsOnTextChanged({ textbox: e }) {
|
|
7527
7858
|
let { text: t = "", lineFontDefaults: n, styles: r, fontFamily: i, fontSize: a, fill: o, stroke: s, selectionStart: c, isEditing: l } = e, u = t, d = e.__lineDefaultsPrevText ?? u, f = d.split("\n"), p = u.split("\n"), m = f.length, h = p.length - m, g = n, _ = !1, v = !1, y = typeof o == "string" ? o : void 0, b = typeof s == "string" ? s : void 0;
|
|
7528
7859
|
if (h !== 0 && n && Object.keys(n).length) {
|
|
7529
|
-
let e =
|
|
7860
|
+
let e = Qr({
|
|
7530
7861
|
previous: d,
|
|
7531
7862
|
next: u
|
|
7532
|
-
}), t =
|
|
7863
|
+
}), t = $r({
|
|
7533
7864
|
text: d,
|
|
7534
7865
|
charIndex: e
|
|
7535
7866
|
});
|
|
7536
7867
|
if (h > 0) {
|
|
7537
|
-
let r =
|
|
7868
|
+
let r = ei({
|
|
7538
7869
|
text: d,
|
|
7539
7870
|
lineIndex: t
|
|
7540
7871
|
}), i = t + 1;
|
|
@@ -7575,7 +7906,7 @@ var Nr = class {
|
|
|
7575
7906
|
let t = p[e] ?? "", n = g ? g[e] : void 0;
|
|
7576
7907
|
if (n && (T = n), t.length !== 0) {
|
|
7577
7908
|
if (n) {
|
|
7578
|
-
let r =
|
|
7909
|
+
let r = kr({
|
|
7579
7910
|
lineText: t,
|
|
7580
7911
|
lineStyles: S ? S[e] : void 0,
|
|
7581
7912
|
lineDefaults: n
|
|
@@ -7615,16 +7946,16 @@ var Nr = class {
|
|
|
7615
7946
|
if (!Number.isFinite(f) || f <= 0) return !1;
|
|
7616
7947
|
let p = a.split("\n").length, m = !1;
|
|
7617
7948
|
Math.abs((e.width ?? 0) - f) > .01 && (e.set({ width: f }), m = !0), e.initDimensions();
|
|
7618
|
-
let { textLines: h } = e, g = Array.isArray(h) && h.length > p, _ = Math.ceil(
|
|
7949
|
+
let { textLines: h } = e, g = Array.isArray(h) && h.length > p, _ = Math.ceil(Mr({
|
|
7619
7950
|
textbox: e,
|
|
7620
7951
|
text: a
|
|
7621
7952
|
})), v = Math.min(e.minWidth ?? 1, f), y = Math.min(f, Math.max(_, v));
|
|
7622
|
-
g && (y = f), Math.abs((e.width ?? 0) - y) > .01 && (e.set({ width: y }), e.initDimensions(), m = !0),
|
|
7953
|
+
g && (y = f), Math.abs((e.width ?? 0) - y) > .01 && (e.set({ width: y }), e.initDimensions(), m = !0), Ir({ textbox: e }) && (m = !0), t && r.applyObjectPlacement({
|
|
7623
7954
|
object: e,
|
|
7624
7955
|
placement: t
|
|
7625
7956
|
});
|
|
7626
7957
|
let b = !1;
|
|
7627
|
-
return n && (b =
|
|
7958
|
+
return n && (b = Nr({
|
|
7628
7959
|
textbox: e,
|
|
7629
7960
|
montageLeft: o,
|
|
7630
7961
|
montageRight: o + s
|
|
@@ -7682,7 +8013,7 @@ var Nr = class {
|
|
|
7682
8013
|
_getDefaultFontFamily() {
|
|
7683
8014
|
return this.fonts[0]?.family ?? "Arial";
|
|
7684
8015
|
}
|
|
7685
|
-
},
|
|
8016
|
+
}, ni = ({ x1: e, y1: t, x2: n, y2: r }) => (Math.atan2(r - t, n - e) * 180 / Math.PI + 360) % 360, ri = (e) => {
|
|
7686
8017
|
if (!e || typeof e != "object") return null;
|
|
7687
8018
|
let { type: t, coords: n, colorStops: r } = e, i = Array.isArray(r) ? r : [], a = i[0], o = i[i.length - 1], s = typeof a?.color == "string" ? a.color : void 0, c = typeof o?.color == "string" ? o.color : s, l = typeof a?.offset == "number" ? a.offset * 100 : void 0, u = typeof o?.offset == "number" ? o.offset * 100 : void 0, d = i.map((e) => ({
|
|
7688
8019
|
color: typeof e.color == "string" ? e.color : "#000000",
|
|
@@ -7693,7 +8024,7 @@ var Nr = class {
|
|
|
7693
8024
|
let { x1: e, y1: t, x2: r, y2: i } = n;
|
|
7694
8025
|
if (typeof e == "number" && typeof t == "number" && typeof r == "number" && typeof i == "number") return {
|
|
7695
8026
|
type: "linear",
|
|
7696
|
-
angle:
|
|
8027
|
+
angle: ni({
|
|
7697
8028
|
x1: e,
|
|
7698
8029
|
y1: t,
|
|
7699
8030
|
x2: r,
|
|
@@ -7721,7 +8052,7 @@ var Nr = class {
|
|
|
7721
8052
|
};
|
|
7722
8053
|
}
|
|
7723
8054
|
return null;
|
|
7724
|
-
},
|
|
8055
|
+
}, ii = "_templateAnchorX", ai = "_templateAnchorY", oi = class t {
|
|
7725
8056
|
constructor({ editor: e }) {
|
|
7726
8057
|
this.editor = e;
|
|
7727
8058
|
}
|
|
@@ -7730,7 +8061,7 @@ var Nr = class {
|
|
|
7730
8061
|
if (!p.length) return s.emitWarning({
|
|
7731
8062
|
origin: "TemplateManager",
|
|
7732
8063
|
method: "serializeSelection",
|
|
7733
|
-
code:
|
|
8064
|
+
code: pr.TEMPLATE_MANAGER.NO_OBJECTS_SELECTED,
|
|
7734
8065
|
message: "Нет объектов для сериализации шаблона"
|
|
7735
8066
|
}), null;
|
|
7736
8067
|
let m = t._getBounds(o), h = t._getMontageSize({
|
|
@@ -7759,14 +8090,14 @@ var Nr = class {
|
|
|
7759
8090
|
if (!s?.length) return a.emitWarning({
|
|
7760
8091
|
origin: "TemplateManager",
|
|
7761
8092
|
method: "applyTemplate",
|
|
7762
|
-
code:
|
|
8093
|
+
code: pr.TEMPLATE_MANAGER.INVALID_TEMPLATE,
|
|
7763
8094
|
message: "Шаблон не содержит объектов"
|
|
7764
8095
|
}), null;
|
|
7765
8096
|
let u = t._getBounds(r);
|
|
7766
8097
|
if (!u) return a.emitWarning({
|
|
7767
8098
|
origin: "TemplateManager",
|
|
7768
8099
|
method: "applyTemplate",
|
|
7769
|
-
code:
|
|
8100
|
+
code: pr.TEMPLATE_MANAGER.INVALID_TARGET,
|
|
7770
8101
|
message: "Не удалось определить границы монтажной области"
|
|
7771
8102
|
}), null;
|
|
7772
8103
|
let d = t._getMontageSize({
|
|
@@ -7785,7 +8116,7 @@ var Nr = class {
|
|
|
7785
8116
|
if (!r.length) return a.emitWarning({
|
|
7786
8117
|
origin: "TemplateManager",
|
|
7787
8118
|
method: "applyTemplate",
|
|
7788
|
-
code:
|
|
8119
|
+
code: pr.TEMPLATE_MANAGER.INVALID_TEMPLATE,
|
|
7789
8120
|
message: "Не удалось создать объекты шаблона"
|
|
7790
8121
|
}), null;
|
|
7791
8122
|
let { backgroundObject: i, contentObjects: c } = t._extractBackgroundObject(r);
|
|
@@ -7820,7 +8151,7 @@ var Nr = class {
|
|
|
7820
8151
|
return a.emitError({
|
|
7821
8152
|
origin: "TemplateManager",
|
|
7822
8153
|
method: "applyTemplate",
|
|
7823
|
-
code:
|
|
8154
|
+
code: pr.TEMPLATE_MANAGER.APPLY_FAILED,
|
|
7824
8155
|
message: "Ошибка применения шаблона",
|
|
7825
8156
|
data: {
|
|
7826
8157
|
templateId: l,
|
|
@@ -7974,8 +8305,8 @@ var Nr = class {
|
|
|
7974
8305
|
baseHeight: a,
|
|
7975
8306
|
scale: n,
|
|
7976
8307
|
useRelativePositions: o,
|
|
7977
|
-
anchorX: t._resolveAnchor(s,
|
|
7978
|
-
anchorY: t._resolveAnchor(s,
|
|
8308
|
+
anchorX: t._resolveAnchor(s, ii),
|
|
8309
|
+
anchorY: t._resolveAnchor(s, ai)
|
|
7979
8310
|
})
|
|
7980
8311
|
}), h = f * n, g = p * n, _ = e.originX ?? "center", v = e.originY ?? "center";
|
|
7981
8312
|
e.set({
|
|
@@ -7989,7 +8320,7 @@ var Nr = class {
|
|
|
7989
8320
|
originX: _,
|
|
7990
8321
|
originY: v
|
|
7991
8322
|
}
|
|
7992
|
-
}), delete s[
|
|
8323
|
+
}), delete s[ii], delete s[ai];
|
|
7993
8324
|
}
|
|
7994
8325
|
static _getPositioningBounds({ bounds: e, baseWidth: n, baseHeight: r, scale: i, useRelativePositions: a, anchorX: o, anchorY: s }) {
|
|
7995
8326
|
if (!a) return e;
|
|
@@ -8053,7 +8384,7 @@ var Nr = class {
|
|
|
8053
8384
|
});
|
|
8054
8385
|
if (!i || !s || !o) return;
|
|
8055
8386
|
e.setCoords();
|
|
8056
|
-
let c = e, l = t._resolveAnchor(c,
|
|
8387
|
+
let c = e, l = t._resolveAnchor(c, ii), u = typeof c.left == "number" ? c.left : null, d = e.originX ?? "center", f = e.originY ?? "center", p = e.getPointByOrigin(d, f), m = e.getBoundingRect(!1, !0), h = m.left + m.width;
|
|
8057
8388
|
e.set("width", i), e.initDimensions();
|
|
8058
8389
|
let g = t._getLongestLineWidth({
|
|
8059
8390
|
textbox: e,
|
|
@@ -8082,10 +8413,10 @@ var Nr = class {
|
|
|
8082
8413
|
x: (p.left - o) / d,
|
|
8083
8414
|
y: (p.top - s) / f
|
|
8084
8415
|
}, h = (u.left - o) / d, g = (u.top - s) / f, _ = h + u.width / d, v = g + u.height / f;
|
|
8085
|
-
return a[
|
|
8416
|
+
return a[ii] = t._detectAnchor({
|
|
8086
8417
|
start: h,
|
|
8087
8418
|
end: _
|
|
8088
|
-
}), a[
|
|
8419
|
+
}), a[ai] = t._detectAnchor({
|
|
8089
8420
|
start: g,
|
|
8090
8421
|
end: v
|
|
8091
8422
|
}), a.left = m.x, a.top = m.y, a;
|
|
@@ -8110,7 +8441,7 @@ var Nr = class {
|
|
|
8110
8441
|
withoutSave: !0
|
|
8111
8442
|
}), !0;
|
|
8112
8443
|
if (a === "gradient") {
|
|
8113
|
-
let e =
|
|
8444
|
+
let e = ri(r);
|
|
8114
8445
|
if (e) return n.setGradientBackground({
|
|
8115
8446
|
gradient: e,
|
|
8116
8447
|
customData: o,
|
|
@@ -8131,7 +8462,7 @@ var Nr = class {
|
|
|
8131
8462
|
r.emitWarning({
|
|
8132
8463
|
origin: "TemplateManager",
|
|
8133
8464
|
method: "applyTemplate",
|
|
8134
|
-
code:
|
|
8465
|
+
code: pr.TEMPLATE_MANAGER.APPLY_FAILED,
|
|
8135
8466
|
message: "Не удалось применить фон из шаблона",
|
|
8136
8467
|
data: e
|
|
8137
8468
|
});
|
|
@@ -8167,29 +8498,29 @@ var Nr = class {
|
|
|
8167
8498
|
enlivenObjectEnlivables(e) {
|
|
8168
8499
|
return C.enlivenObjectEnlivables(e);
|
|
8169
8500
|
}
|
|
8170
|
-
},
|
|
8171
|
-
let n =
|
|
8501
|
+
}, si = "#3D8BF4", ci = .5, li = ({ distance: e }) => Number.isFinite(e) ? Math.round(Math.max(0, e)) : 0, ui = ({ firstDistance: e, secondDistance: t }) => {
|
|
8502
|
+
let n = li({ distance: e }), r = li({ distance: t });
|
|
8172
8503
|
return {
|
|
8173
8504
|
firstDisplayDistance: n,
|
|
8174
8505
|
secondDisplayDistance: r,
|
|
8175
8506
|
displayDistanceDiff: Math.abs(n - r),
|
|
8176
8507
|
commonDisplayDistance: Math.max(n, r)
|
|
8177
8508
|
};
|
|
8178
|
-
},
|
|
8509
|
+
}, di = ({ firstStart: e, firstEnd: t, secondStart: n, secondEnd: r }) => Math.min(t, r) - Math.max(e, n), fi = ({ step: e }) => {
|
|
8179
8510
|
let t = Math.abs(e).toString(), n = t.indexOf(".");
|
|
8180
8511
|
return n === -1 ? 0 : t.slice(n + 1).length;
|
|
8181
|
-
},
|
|
8512
|
+
}, pi = ({ value: e, step: t }) => {
|
|
8182
8513
|
if (t === 0) return e;
|
|
8183
|
-
let n =
|
|
8514
|
+
let n = fi({ step: t }), r = Math.round(e / t) * t;
|
|
8184
8515
|
return Number(r.toFixed(n));
|
|
8185
|
-
},
|
|
8516
|
+
}, mi = ({ value: e, step: t }) => {
|
|
8186
8517
|
if (t === 0) return !0;
|
|
8187
|
-
let n =
|
|
8518
|
+
let n = pi({
|
|
8188
8519
|
value: e,
|
|
8189
8520
|
step: t
|
|
8190
|
-
}), r = 10 ** -(
|
|
8521
|
+
}), r = 10 ** -(fi({ step: t }) + 4);
|
|
8191
8522
|
return Math.abs(n - e) <= r;
|
|
8192
|
-
},
|
|
8523
|
+
}, hi = ({ bounds: e, axis: t }) => {
|
|
8193
8524
|
let { left: n = 0, right: r = 0, top: i = 0, bottom: a = 0 } = e;
|
|
8194
8525
|
return t === "vertical" ? {
|
|
8195
8526
|
start: i,
|
|
@@ -8198,7 +8529,7 @@ var Nr = class {
|
|
|
8198
8529
|
start: n,
|
|
8199
8530
|
end: r
|
|
8200
8531
|
};
|
|
8201
|
-
},
|
|
8532
|
+
}, gi = ({ items: e, axis: t }) => {
|
|
8202
8533
|
for (let n = 1; n < e.length; n += 1) {
|
|
8203
8534
|
let r = e[n], { bounds: i } = r, a = i[t], o = n - 1;
|
|
8204
8535
|
for (; o >= 0;) {
|
|
@@ -8208,10 +8539,10 @@ var Nr = class {
|
|
|
8208
8539
|
}
|
|
8209
8540
|
e[o + 1] = r;
|
|
8210
8541
|
}
|
|
8211
|
-
},
|
|
8542
|
+
}, _i = ({ items: e, index: t, axis: n, direction: r }) => {
|
|
8212
8543
|
let i = e[t];
|
|
8213
8544
|
if (!i) return null;
|
|
8214
|
-
let { bounds: a } = i, { start: o, end: s } =
|
|
8545
|
+
let { bounds: a } = i, { start: o, end: s } = hi({
|
|
8215
8546
|
bounds: a,
|
|
8216
8547
|
axis: n
|
|
8217
8548
|
});
|
|
@@ -8219,7 +8550,7 @@ var Nr = class {
|
|
|
8219
8550
|
for (let r = t - 1; r >= 0; --r) {
|
|
8220
8551
|
let t = e[r];
|
|
8221
8552
|
if (!t) continue;
|
|
8222
|
-
let { bounds: i } = t, { end: a } =
|
|
8553
|
+
let { bounds: i } = t, { end: a } = hi({
|
|
8223
8554
|
bounds: i,
|
|
8224
8555
|
axis: n
|
|
8225
8556
|
});
|
|
@@ -8230,26 +8561,26 @@ var Nr = class {
|
|
|
8230
8561
|
for (let r = t + 1; r < e.length; r += 1) {
|
|
8231
8562
|
let t = e[r];
|
|
8232
8563
|
if (!t) continue;
|
|
8233
|
-
let { bounds: i } = t, { start: a } =
|
|
8564
|
+
let { bounds: i } = t, { start: a } = hi({
|
|
8234
8565
|
bounds: i,
|
|
8235
8566
|
axis: n
|
|
8236
8567
|
});
|
|
8237
8568
|
if (a - s >= 0) return r;
|
|
8238
8569
|
}
|
|
8239
8570
|
return null;
|
|
8240
|
-
},
|
|
8571
|
+
}, vi = ({ items: e }) => {
|
|
8241
8572
|
for (let t = 0; t < e.length; t += 1) {
|
|
8242
8573
|
let { isActive: n } = e[t];
|
|
8243
8574
|
if (n) return t;
|
|
8244
8575
|
}
|
|
8245
8576
|
return -1;
|
|
8246
|
-
},
|
|
8577
|
+
}, yi = ({ patternAxis: e, activeRangeStart: t, activeRangeEnd: n, tolerance: r = 0 }) => {
|
|
8247
8578
|
let i = Math.min(t, n), a = Math.max(t, n);
|
|
8248
8579
|
return e >= i - r && e <= a + r;
|
|
8249
|
-
},
|
|
8580
|
+
}, bi = ({ patternStart: e, patternEnd: t, activeStart: n, activeEnd: r }) => t <= n ? "before" : e >= r ? "after" : null, xi = ({ baseOption: e, candidateOption: t }) => {
|
|
8250
8581
|
let { delta: n, guide: { distance: r } } = e, { delta: i, guide: { distance: a } } = t;
|
|
8251
8582
|
return n === i && r === a;
|
|
8252
|
-
},
|
|
8583
|
+
}, Si = ({ options: e }) => {
|
|
8253
8584
|
let t = e[0];
|
|
8254
8585
|
for (let n = 1; n < e.length; n += 1) {
|
|
8255
8586
|
let r = e[n];
|
|
@@ -8260,11 +8591,11 @@ var Nr = class {
|
|
|
8260
8591
|
r.diff === t.diff && Math.abs(r.delta) < Math.abs(t.delta) && (t = r);
|
|
8261
8592
|
}
|
|
8262
8593
|
return t;
|
|
8263
|
-
},
|
|
8594
|
+
}, Ci = ({ currentOption: e, nextOption: t }) => {
|
|
8264
8595
|
if (!e) return !0;
|
|
8265
8596
|
let { contextDistance: n, diff: r, delta: i } = e, { contextDistance: a, diff: o, delta: s } = t;
|
|
8266
8597
|
return a < n ? !0 : a > n ? !1 : o < r ? !0 : o > r ? !1 : Math.abs(s) < Math.abs(i);
|
|
8267
|
-
},
|
|
8598
|
+
}, wi = ({ options: e }) => {
|
|
8268
8599
|
let t = [], n = null, r = null;
|
|
8269
8600
|
for (let i of e) {
|
|
8270
8601
|
let { kind: e, side: a } = i;
|
|
@@ -8272,18 +8603,18 @@ var Nr = class {
|
|
|
8272
8603
|
t.push(i);
|
|
8273
8604
|
continue;
|
|
8274
8605
|
}
|
|
8275
|
-
a === "before" &&
|
|
8606
|
+
a === "before" && Ci({
|
|
8276
8607
|
currentOption: n,
|
|
8277
8608
|
nextOption: i
|
|
8278
|
-
}) && (n = i), a === "after" &&
|
|
8609
|
+
}) && (n = i), a === "after" && Ci({
|
|
8279
8610
|
currentOption: r,
|
|
8280
8611
|
nextOption: i
|
|
8281
8612
|
}) && (r = i);
|
|
8282
8613
|
}
|
|
8283
8614
|
return n && t.push(n), r && t.push(r), t;
|
|
8284
|
-
},
|
|
8615
|
+
}, Ti = ({ options: e, side: t, baseOption: n }) => {
|
|
8285
8616
|
let r = null;
|
|
8286
|
-
for (let i of e) if (i.side === t &&
|
|
8617
|
+
for (let i of e) if (i.side === t && xi({
|
|
8287
8618
|
baseOption: n,
|
|
8288
8619
|
candidateOption: i
|
|
8289
8620
|
})) {
|
|
@@ -8294,63 +8625,63 @@ var Nr = class {
|
|
|
8294
8625
|
!r || i.diff !== r.diff || Math.abs(i.delta) < Math.abs(r.delta) && (r = i);
|
|
8295
8626
|
}
|
|
8296
8627
|
return r;
|
|
8297
|
-
},
|
|
8628
|
+
}, Ei = ({ option: e }) => {
|
|
8298
8629
|
let { side: t, kind: n, guide: { distance: r } } = e;
|
|
8299
8630
|
return {
|
|
8300
8631
|
side: t,
|
|
8301
8632
|
kind: n,
|
|
8302
8633
|
distance: r
|
|
8303
8634
|
};
|
|
8304
|
-
},
|
|
8635
|
+
}, Di = ({ option: e, context: t }) => {
|
|
8305
8636
|
let { side: n, kind: r, distance: i } = t, { side: a, kind: o, guide: { distance: s } } = e;
|
|
8306
8637
|
return n !== a || r !== o ? !1 : Math.abs(s - i) <= 1;
|
|
8307
|
-
},
|
|
8638
|
+
}, Oi = ({ options: e, context: t }) => {
|
|
8308
8639
|
if (!t) return null;
|
|
8309
|
-
for (let n of e) if (
|
|
8640
|
+
for (let n of e) if (Di({
|
|
8310
8641
|
option: n,
|
|
8311
8642
|
context: t
|
|
8312
8643
|
})) return n;
|
|
8313
8644
|
return null;
|
|
8314
|
-
},
|
|
8315
|
-
let i =
|
|
8645
|
+
}, ki = ({ options: e, bestOption: t, previousContext: n, switchDistance: r = 0 }) => {
|
|
8646
|
+
let i = Oi({
|
|
8316
8647
|
options: e,
|
|
8317
8648
|
context: n
|
|
8318
8649
|
});
|
|
8319
8650
|
if (!i) return t;
|
|
8320
8651
|
let a = Math.max(0, r);
|
|
8321
8652
|
return a === 0 || Math.abs(t.delta - i.delta) >= a ? t : i;
|
|
8322
|
-
},
|
|
8653
|
+
}, Ai = ({ guides: e, seenGuideKeys: t, guide: n }) => {
|
|
8323
8654
|
let { type: r, axis: i, refStart: a, refEnd: o, activeStart: s, activeEnd: c, distance: l } = n, u = `${r}:${i}:${a}:${o}:${s}:${c}:${l}`;
|
|
8324
8655
|
t.has(u) || (t.add(u), e.push(n));
|
|
8325
|
-
},
|
|
8656
|
+
}, ji = ({ options: e, previousContext: t = null, switchDistance: n = 0 }) => {
|
|
8326
8657
|
if (!e.length) return {
|
|
8327
8658
|
delta: 0,
|
|
8328
8659
|
guides: [],
|
|
8329
8660
|
context: null
|
|
8330
8661
|
};
|
|
8331
|
-
let r =
|
|
8662
|
+
let r = wi({ options: e }), i = [];
|
|
8332
8663
|
for (let e of r) e.kind === "reference" && i.push(e);
|
|
8333
|
-
let a = i.length > 0, o = a ? i : r, s =
|
|
8664
|
+
let a = i.length > 0, o = a ? i : r, s = ki({
|
|
8334
8665
|
options: o,
|
|
8335
|
-
bestOption:
|
|
8666
|
+
bestOption: Si({ options: o }),
|
|
8336
8667
|
previousContext: t,
|
|
8337
8668
|
switchDistance: n
|
|
8338
|
-
}), c =
|
|
8669
|
+
}), c = Ti({
|
|
8339
8670
|
options: o,
|
|
8340
8671
|
side: "before",
|
|
8341
8672
|
baseOption: s
|
|
8342
|
-
}), l =
|
|
8673
|
+
}), l = Ti({
|
|
8343
8674
|
options: o,
|
|
8344
8675
|
side: "after",
|
|
8345
8676
|
baseOption: s
|
|
8346
|
-
}), u =
|
|
8677
|
+
}), u = Ti({
|
|
8347
8678
|
options: a ? r : o,
|
|
8348
8679
|
side: "center",
|
|
8349
8680
|
baseOption: s
|
|
8350
8681
|
}), d = [];
|
|
8351
8682
|
c && l ? d.push(c, l) : (d.push(s), s.side === "before" && l && d.push(l), s.side === "after" && c && d.push(c), s.side === "center" && (c && !l && d.push(c), l && !c && d.push(l)), a && s.side === "before" && !l && u && d.push(u), a && s.side === "after" && !c && u && d.push(u)), !d.length && u && d.push(u);
|
|
8352
8683
|
let f = [], p = /* @__PURE__ */ new Set();
|
|
8353
|
-
for (let e of d)
|
|
8684
|
+
for (let e of d) Ai({
|
|
8354
8685
|
guides: f,
|
|
8355
8686
|
seenGuideKeys: p,
|
|
8356
8687
|
guide: e.guide
|
|
@@ -8358,15 +8689,15 @@ var Nr = class {
|
|
|
8358
8689
|
return {
|
|
8359
8690
|
delta: s.delta,
|
|
8360
8691
|
guides: f,
|
|
8361
|
-
context:
|
|
8692
|
+
context: Ei({ option: s })
|
|
8362
8693
|
};
|
|
8363
|
-
},
|
|
8364
|
-
let s = n - (e - r), c =
|
|
8694
|
+
}, Mi = ({ activeStart: e, activeEnd: t, targetGap: n, beforeEdge: r, afterEdge: i, threshold: a, step: o }) => {
|
|
8695
|
+
let s = n - (e - r), c = pi({
|
|
8365
8696
|
value: s,
|
|
8366
8697
|
step: o
|
|
8367
8698
|
}), l = Math.max(1, Math.ceil(a / Math.max(o, 1))), u = null;
|
|
8368
8699
|
for (let d = -l; d <= l; d += 1) {
|
|
8369
|
-
let l = c + d * o, f = e + l, p = t + l, m = f - r, h = i - p, { displayDistanceDiff: g, commonDisplayDistance: _ } =
|
|
8700
|
+
let l = c + d * o, f = e + l, p = t + l, m = f - r, h = i - p, { displayDistanceDiff: g, commonDisplayDistance: _ } = ui({
|
|
8370
8701
|
firstDistance: m,
|
|
8371
8702
|
secondDistance: h
|
|
8372
8703
|
});
|
|
@@ -8381,13 +8712,13 @@ var Nr = class {
|
|
|
8381
8712
|
});
|
|
8382
8713
|
}
|
|
8383
8714
|
return u;
|
|
8384
|
-
},
|
|
8385
|
-
let { secondDisplayDistance: n, displayDistanceDiff: r } =
|
|
8715
|
+
}, Ni = ({ currentGap: e, referenceGap: t }) => {
|
|
8716
|
+
let { secondDisplayDistance: n, displayDistanceDiff: r } = ui({
|
|
8386
8717
|
firstDistance: e,
|
|
8387
8718
|
secondDistance: t
|
|
8388
8719
|
});
|
|
8389
8720
|
return r > 1 ? null : n;
|
|
8390
|
-
},
|
|
8721
|
+
}, Pi = ({ anchors: e, positions: t, threshold: n }) => {
|
|
8391
8722
|
let r = 0, i = n + 1, a = null;
|
|
8392
8723
|
for (let o of t) for (let t of e) {
|
|
8393
8724
|
let e = Math.abs(t - o);
|
|
@@ -8397,8 +8728,8 @@ var Nr = class {
|
|
|
8397
8728
|
delta: r,
|
|
8398
8729
|
guidePosition: a
|
|
8399
8730
|
};
|
|
8400
|
-
},
|
|
8401
|
-
let { left: r, right: i, centerX: a, top: o, bottom: s, centerY: c } = e, l =
|
|
8731
|
+
}, Fi = ({ activeBounds: e, threshold: t, anchors: n }) => {
|
|
8732
|
+
let { left: r, right: i, centerX: a, top: o, bottom: s, centerY: c } = e, l = Pi({
|
|
8402
8733
|
anchors: n.vertical,
|
|
8403
8734
|
positions: [
|
|
8404
8735
|
r,
|
|
@@ -8406,7 +8737,7 @@ var Nr = class {
|
|
|
8406
8737
|
i
|
|
8407
8738
|
],
|
|
8408
8739
|
threshold: t
|
|
8409
|
-
}), u =
|
|
8740
|
+
}), u = Pi({
|
|
8410
8741
|
anchors: n.horizontal,
|
|
8411
8742
|
positions: [
|
|
8412
8743
|
o,
|
|
@@ -8426,11 +8757,11 @@ var Nr = class {
|
|
|
8426
8757
|
deltaY: u.delta,
|
|
8427
8758
|
guides: d
|
|
8428
8759
|
};
|
|
8429
|
-
},
|
|
8760
|
+
}, Ii = ({ activeBounds: e, candidates: t, threshold: n, patterns: r, previousContext: i = null, switchDistance: a = 0 }) => {
|
|
8430
8761
|
let { centerX: o, top: s, bottom: c, left: l, right: u } = e, d = [];
|
|
8431
8762
|
for (let e of t) {
|
|
8432
8763
|
let { left: t, right: n } = e;
|
|
8433
|
-
|
|
8764
|
+
di({
|
|
8434
8765
|
firstStart: t,
|
|
8435
8766
|
firstEnd: n,
|
|
8436
8767
|
secondStart: l,
|
|
@@ -8450,22 +8781,22 @@ var Nr = class {
|
|
|
8450
8781
|
f.push({
|
|
8451
8782
|
bounds: e,
|
|
8452
8783
|
isActive: !0
|
|
8453
|
-
}),
|
|
8784
|
+
}), gi({
|
|
8454
8785
|
items: f,
|
|
8455
8786
|
axis: "top"
|
|
8456
8787
|
});
|
|
8457
|
-
let p =
|
|
8788
|
+
let p = vi({ items: f });
|
|
8458
8789
|
if (p === -1) return {
|
|
8459
8790
|
delta: 0,
|
|
8460
8791
|
guides: [],
|
|
8461
8792
|
context: null
|
|
8462
8793
|
};
|
|
8463
|
-
let m = [], h = c - s, g =
|
|
8794
|
+
let m = [], h = c - s, g = _i({
|
|
8464
8795
|
items: f,
|
|
8465
8796
|
index: p,
|
|
8466
8797
|
axis: "vertical",
|
|
8467
8798
|
direction: "prev"
|
|
8468
|
-
}), _ =
|
|
8799
|
+
}), _ = _i({
|
|
8469
8800
|
items: f,
|
|
8470
8801
|
index: p,
|
|
8471
8802
|
axis: "vertical",
|
|
@@ -8474,19 +8805,19 @@ var Nr = class {
|
|
|
8474
8805
|
if (v && y) {
|
|
8475
8806
|
let { bounds: e } = v, { bounds: t } = y, { bottom: r } = e, { top: i } = t, a = i - r - h;
|
|
8476
8807
|
if (a >= 0) {
|
|
8477
|
-
let e =
|
|
8808
|
+
let e = pi({
|
|
8478
8809
|
value: a / 2,
|
|
8479
8810
|
step: 1
|
|
8480
8811
|
}), t = s - r, l = i - c, u = Math.abs(t - e), d = Math.abs(l - e);
|
|
8481
8812
|
if (Math.max(u, d) <= n) {
|
|
8482
|
-
let t =
|
|
8813
|
+
let t = Mi({
|
|
8483
8814
|
activeStart: s,
|
|
8484
8815
|
activeEnd: c,
|
|
8485
8816
|
targetGap: e,
|
|
8486
8817
|
beforeEdge: r,
|
|
8487
8818
|
afterEdge: i,
|
|
8488
8819
|
threshold: n,
|
|
8489
|
-
step:
|
|
8820
|
+
step: ci
|
|
8490
8821
|
});
|
|
8491
8822
|
if (t) {
|
|
8492
8823
|
let { delta: e, distance: n, diff: i, activeStart: a, activeEnd: s } = t, c = {
|
|
@@ -8523,16 +8854,16 @@ var Nr = class {
|
|
|
8523
8854
|
}
|
|
8524
8855
|
for (let e of r) {
|
|
8525
8856
|
let { axis: t, start: r, end: i, distance: a } = e;
|
|
8526
|
-
if (!
|
|
8857
|
+
if (!mi({
|
|
8527
8858
|
value: a,
|
|
8528
8859
|
step: .5
|
|
8529
|
-
}) || !
|
|
8860
|
+
}) || !yi({
|
|
8530
8861
|
patternAxis: t,
|
|
8531
8862
|
activeRangeStart: l,
|
|
8532
8863
|
activeRangeEnd: u,
|
|
8533
8864
|
tolerance: n
|
|
8534
8865
|
})) continue;
|
|
8535
|
-
let d =
|
|
8866
|
+
let d = bi({
|
|
8536
8867
|
patternStart: r,
|
|
8537
8868
|
patternEnd: i,
|
|
8538
8869
|
activeStart: s,
|
|
@@ -8540,12 +8871,12 @@ var Nr = class {
|
|
|
8540
8871
|
});
|
|
8541
8872
|
if (d) {
|
|
8542
8873
|
if (b !== null && S && d === "before" && Math.abs(b - a) <= n) {
|
|
8543
|
-
let e =
|
|
8874
|
+
let e = pi({
|
|
8544
8875
|
value: a - b,
|
|
8545
8876
|
step: 1
|
|
8546
8877
|
}), t = s + e, { bottom: c } = S, l = t - c, u = Math.abs(l - a);
|
|
8547
8878
|
if (u > n) continue;
|
|
8548
|
-
let d =
|
|
8879
|
+
let d = Ni({
|
|
8549
8880
|
currentGap: l,
|
|
8550
8881
|
referenceGap: a
|
|
8551
8882
|
});
|
|
@@ -8569,12 +8900,12 @@ var Nr = class {
|
|
|
8569
8900
|
});
|
|
8570
8901
|
}
|
|
8571
8902
|
if (x !== null && C && d === "after" && Math.abs(x - a) <= n) {
|
|
8572
|
-
let e =
|
|
8903
|
+
let e = pi({
|
|
8573
8904
|
value: x - a,
|
|
8574
8905
|
step: 1
|
|
8575
8906
|
}), t = c + e, { top: s } = C, l = s - t, u = Math.abs(l - a);
|
|
8576
8907
|
if (u > n) continue;
|
|
8577
|
-
let d =
|
|
8908
|
+
let d = Ni({
|
|
8578
8909
|
currentGap: l,
|
|
8579
8910
|
referenceGap: a
|
|
8580
8911
|
});
|
|
@@ -8599,16 +8930,16 @@ var Nr = class {
|
|
|
8599
8930
|
}
|
|
8600
8931
|
}
|
|
8601
8932
|
}
|
|
8602
|
-
return
|
|
8933
|
+
return ji({
|
|
8603
8934
|
options: m,
|
|
8604
8935
|
previousContext: i,
|
|
8605
8936
|
switchDistance: a
|
|
8606
8937
|
});
|
|
8607
|
-
},
|
|
8938
|
+
}, Li = ({ activeBounds: e, candidates: t, threshold: n, patterns: r, previousContext: i = null, switchDistance: a = 0 }) => {
|
|
8608
8939
|
let { centerY: o, left: s, right: c, top: l, bottom: u } = e, d = [];
|
|
8609
8940
|
for (let e of t) {
|
|
8610
8941
|
let { top: t, bottom: n } = e;
|
|
8611
|
-
|
|
8942
|
+
di({
|
|
8612
8943
|
firstStart: t,
|
|
8613
8944
|
firstEnd: n,
|
|
8614
8945
|
secondStart: l,
|
|
@@ -8628,22 +8959,22 @@ var Nr = class {
|
|
|
8628
8959
|
f.push({
|
|
8629
8960
|
bounds: e,
|
|
8630
8961
|
isActive: !0
|
|
8631
|
-
}),
|
|
8962
|
+
}), gi({
|
|
8632
8963
|
items: f,
|
|
8633
8964
|
axis: "left"
|
|
8634
8965
|
});
|
|
8635
|
-
let p =
|
|
8966
|
+
let p = vi({ items: f });
|
|
8636
8967
|
if (p === -1) return {
|
|
8637
8968
|
delta: 0,
|
|
8638
8969
|
guides: [],
|
|
8639
8970
|
context: null
|
|
8640
8971
|
};
|
|
8641
|
-
let m = [], h = c - s, g =
|
|
8972
|
+
let m = [], h = c - s, g = _i({
|
|
8642
8973
|
items: f,
|
|
8643
8974
|
index: p,
|
|
8644
8975
|
axis: "horizontal",
|
|
8645
8976
|
direction: "prev"
|
|
8646
|
-
}), _ =
|
|
8977
|
+
}), _ = _i({
|
|
8647
8978
|
items: f,
|
|
8648
8979
|
index: p,
|
|
8649
8980
|
axis: "horizontal",
|
|
@@ -8652,19 +8983,19 @@ var Nr = class {
|
|
|
8652
8983
|
if (v && y) {
|
|
8653
8984
|
let { bounds: e } = v, { bounds: t } = y, { right: r } = e, { left: i } = t, a = i - r - h;
|
|
8654
8985
|
if (a >= 0) {
|
|
8655
|
-
let e =
|
|
8986
|
+
let e = pi({
|
|
8656
8987
|
value: a / 2,
|
|
8657
8988
|
step: 1
|
|
8658
8989
|
}), t = s - r, l = i - c, u = Math.abs(t - e), d = Math.abs(l - e);
|
|
8659
8990
|
if (Math.max(u, d) <= n) {
|
|
8660
|
-
let t =
|
|
8991
|
+
let t = Mi({
|
|
8661
8992
|
activeStart: s,
|
|
8662
8993
|
activeEnd: c,
|
|
8663
8994
|
targetGap: e,
|
|
8664
8995
|
beforeEdge: r,
|
|
8665
8996
|
afterEdge: i,
|
|
8666
8997
|
threshold: n,
|
|
8667
|
-
step:
|
|
8998
|
+
step: ci
|
|
8668
8999
|
});
|
|
8669
9000
|
if (t) {
|
|
8670
9001
|
let { delta: e, distance: n, diff: i, activeStart: a, activeEnd: s } = t, c = {
|
|
@@ -8701,16 +9032,16 @@ var Nr = class {
|
|
|
8701
9032
|
}
|
|
8702
9033
|
for (let e of r) {
|
|
8703
9034
|
let { axis: t, start: r, end: i, distance: a } = e;
|
|
8704
|
-
if (!
|
|
9035
|
+
if (!mi({
|
|
8705
9036
|
value: a,
|
|
8706
9037
|
step: .5
|
|
8707
|
-
}) || !
|
|
9038
|
+
}) || !yi({
|
|
8708
9039
|
patternAxis: t,
|
|
8709
9040
|
activeRangeStart: l,
|
|
8710
9041
|
activeRangeEnd: u,
|
|
8711
9042
|
tolerance: n
|
|
8712
9043
|
})) continue;
|
|
8713
|
-
let d =
|
|
9044
|
+
let d = bi({
|
|
8714
9045
|
patternStart: r,
|
|
8715
9046
|
patternEnd: i,
|
|
8716
9047
|
activeStart: s,
|
|
@@ -8718,12 +9049,12 @@ var Nr = class {
|
|
|
8718
9049
|
});
|
|
8719
9050
|
if (d) {
|
|
8720
9051
|
if (b !== null && S && d === "before" && Math.abs(b - a) <= n) {
|
|
8721
|
-
let e =
|
|
9052
|
+
let e = pi({
|
|
8722
9053
|
value: a - b,
|
|
8723
9054
|
step: 1
|
|
8724
9055
|
}), t = s + e, { right: c } = S, l = t - c, u = Math.abs(l - a);
|
|
8725
9056
|
if (u > n) continue;
|
|
8726
|
-
let d =
|
|
9057
|
+
let d = Ni({
|
|
8727
9058
|
currentGap: l,
|
|
8728
9059
|
referenceGap: a
|
|
8729
9060
|
});
|
|
@@ -8747,12 +9078,12 @@ var Nr = class {
|
|
|
8747
9078
|
});
|
|
8748
9079
|
}
|
|
8749
9080
|
if (x !== null && C && d === "after" && Math.abs(x - a) <= n) {
|
|
8750
|
-
let e =
|
|
9081
|
+
let e = pi({
|
|
8751
9082
|
value: x - a,
|
|
8752
9083
|
step: 1
|
|
8753
9084
|
}), t = c + e, { left: s } = C, l = s - t, u = Math.abs(l - a);
|
|
8754
9085
|
if (u > n) continue;
|
|
8755
|
-
let d =
|
|
9086
|
+
let d = Ni({
|
|
8756
9087
|
currentGap: l,
|
|
8757
9088
|
referenceGap: a
|
|
8758
9089
|
});
|
|
@@ -8777,20 +9108,20 @@ var Nr = class {
|
|
|
8777
9108
|
}
|
|
8778
9109
|
}
|
|
8779
9110
|
}
|
|
8780
|
-
return
|
|
9111
|
+
return ji({
|
|
8781
9112
|
options: m,
|
|
8782
9113
|
previousContext: i,
|
|
8783
9114
|
switchDistance: a
|
|
8784
9115
|
});
|
|
8785
|
-
},
|
|
8786
|
-
let { vertical: o = null, horizontal: s = null } = i ?? {}, c =
|
|
9116
|
+
}, Ri = ({ activeBounds: e, candidates: t, threshold: n, spacingPatterns: r, previousContexts: i, switchDistance: a = 0 }) => {
|
|
9117
|
+
let { vertical: o = null, horizontal: s = null } = i ?? {}, c = Ii({
|
|
8787
9118
|
activeBounds: e,
|
|
8788
9119
|
candidates: t,
|
|
8789
9120
|
threshold: n,
|
|
8790
9121
|
patterns: r.vertical,
|
|
8791
9122
|
previousContext: o,
|
|
8792
9123
|
switchDistance: a
|
|
8793
|
-
}), l =
|
|
9124
|
+
}), l = Li({
|
|
8794
9125
|
activeBounds: e,
|
|
8795
9126
|
candidates: t,
|
|
8796
9127
|
threshold: n,
|
|
@@ -8809,14 +9140,14 @@ var Nr = class {
|
|
|
8809
9140
|
horizontal: l.context
|
|
8810
9141
|
}
|
|
8811
9142
|
};
|
|
8812
|
-
},
|
|
9143
|
+
}, zi = ({ context: e, x: t, y: n, width: r, height: i, radius: a }) => {
|
|
8813
9144
|
let o = Math.min(a, r / 2, i / 2);
|
|
8814
9145
|
e.moveTo(t + o, n), e.lineTo(t + r - o, n), e.quadraticCurveTo(t + r, n, t + r, n + o), e.lineTo(t + r, n + i - o), e.quadraticCurveTo(t + r, n + i, t + r - o, n + i), e.lineTo(t + o, n + i), e.quadraticCurveTo(t, n + i, t, n + i - o), e.lineTo(t, n + o), e.quadraticCurveTo(t, n, t + o, n), e.closePath();
|
|
8815
|
-
},
|
|
9146
|
+
}, Bi = ({ context: e, type: t, axis: n, start: r, end: i, text: a, zoom: o, color: s, textColor: c = "#ffffff", fontFamily: l = "sans-serif", lineWidth: u = 1, padding: d = 4, radius: f = 4, offsetAlongAxis: p = 0, offsetPerpendicular: m = 0 }) => {
|
|
8816
9147
|
let h = o || 1, g = 12 / h, _ = d / h, v = f / h, y = (r + i) / 2 + p, b = t === "vertical" ? n + m : y, x = t === "vertical" ? y : n + m;
|
|
8817
9148
|
e.save(), e.setLineDash([]), e.fillStyle = s, e.strokeStyle = s, e.lineWidth = u / h, e.font = `${g}px ${l}`, e.textAlign = "center", e.textBaseline = "middle";
|
|
8818
9149
|
let S = e.measureText(a).width + _ * 2, C = g + _ * 2, w = b - S / 2, T = x - C / 2;
|
|
8819
|
-
e.beginPath(),
|
|
9150
|
+
e.beginPath(), zi({
|
|
8820
9151
|
context: e,
|
|
8821
9152
|
x: w,
|
|
8822
9153
|
y: T,
|
|
@@ -8824,11 +9155,11 @@ var Nr = class {
|
|
|
8824
9155
|
height: C,
|
|
8825
9156
|
radius: v
|
|
8826
9157
|
}), e.fill(), e.fillStyle = c, e.fillText(a, b, x), e.restore();
|
|
8827
|
-
},
|
|
8828
|
-
let { type: r, axis: i, refStart: a, refEnd: o, activeStart: s, activeEnd: c, distance: l } = t, u =
|
|
9158
|
+
}, Vi = ({ context: e, guide: t, zoom: n }) => {
|
|
9159
|
+
let { type: r, axis: i, refStart: a, refEnd: o, activeStart: s, activeEnd: c, distance: l } = t, u = li({ distance: l }).toString();
|
|
8829
9160
|
e.beginPath(), r === "vertical" ? (e.moveTo(i, a), e.lineTo(i, o), e.moveTo(i, s), e.lineTo(i, c)) : (e.moveTo(a, i), e.lineTo(o, i), e.moveTo(s, i), e.lineTo(c, i)), e.stroke();
|
|
8830
|
-
let d =
|
|
8831
|
-
|
|
9161
|
+
let d = si;
|
|
9162
|
+
Bi({
|
|
8832
9163
|
context: e,
|
|
8833
9164
|
type: r,
|
|
8834
9165
|
axis: i,
|
|
@@ -8838,7 +9169,7 @@ var Nr = class {
|
|
|
8838
9169
|
zoom: n,
|
|
8839
9170
|
color: d,
|
|
8840
9171
|
lineWidth: 1
|
|
8841
|
-
}),
|
|
9172
|
+
}), Bi({
|
|
8842
9173
|
context: e,
|
|
8843
9174
|
type: r,
|
|
8844
9175
|
axis: i,
|
|
@@ -8849,10 +9180,10 @@ var Nr = class {
|
|
|
8849
9180
|
color: d,
|
|
8850
9181
|
lineWidth: 1
|
|
8851
9182
|
});
|
|
8852
|
-
},
|
|
9183
|
+
}, Hi = ({ anchors: e, bounds: t }) => {
|
|
8853
9184
|
let { left: n, right: r, centerX: i, top: a, bottom: o, centerY: s } = t;
|
|
8854
9185
|
e.vertical.push(n, i, r), e.horizontal.push(a, s, o);
|
|
8855
|
-
},
|
|
9186
|
+
}, Ui = ({ bounds: e, type: t, primaryStart: n, primaryEnd: r }) => {
|
|
8856
9187
|
let i = [], a = n === "top" ? "left" : "top", o = r === "bottom" ? "right" : "bottom", s = [...e].sort((e, t) => e[n] - t[n]);
|
|
8857
9188
|
for (let e = 0; e < s.length; e += 1) {
|
|
8858
9189
|
let c = s[e], l = null, u = Infinity;
|
|
@@ -8873,35 +9204,35 @@ var Nr = class {
|
|
|
8873
9204
|
});
|
|
8874
9205
|
}
|
|
8875
9206
|
return i;
|
|
8876
|
-
},
|
|
8877
|
-
vertical:
|
|
9207
|
+
}, Wi = ({ bounds: e }) => ({
|
|
9208
|
+
vertical: Ui({
|
|
8878
9209
|
bounds: e,
|
|
8879
9210
|
axis: "centerX",
|
|
8880
9211
|
type: "vertical",
|
|
8881
9212
|
primaryStart: "top",
|
|
8882
9213
|
primaryEnd: "bottom"
|
|
8883
9214
|
}),
|
|
8884
|
-
horizontal:
|
|
9215
|
+
horizontal: Ui({
|
|
8885
9216
|
bounds: e,
|
|
8886
9217
|
axis: "centerY",
|
|
8887
9218
|
type: "horizontal",
|
|
8888
9219
|
primaryStart: "left",
|
|
8889
9220
|
primaryEnd: "right"
|
|
8890
9221
|
})
|
|
8891
|
-
}),
|
|
9222
|
+
}), Gi = [
|
|
8892
9223
|
"montage-area",
|
|
8893
9224
|
"background",
|
|
8894
9225
|
"interaction-blocker"
|
|
8895
|
-
],
|
|
9226
|
+
], Ki = ({ activeObject: t }) => {
|
|
8896
9227
|
let n = /* @__PURE__ */ new Set();
|
|
8897
9228
|
return t ? (n.add(t), t instanceof e && t.getObjects().forEach((e) => n.add(e)), n) : n;
|
|
8898
|
-
},
|
|
9229
|
+
}, qi = ({ object: e, excluded: t, ignoredIds: n = Gi }) => {
|
|
8899
9230
|
if (t.has(e)) return !0;
|
|
8900
9231
|
let { visible: r = !0 } = e;
|
|
8901
9232
|
if (!r) return !0;
|
|
8902
9233
|
let { id: i } = e;
|
|
8903
9234
|
return !!(i && n.includes(i));
|
|
8904
|
-
},
|
|
9235
|
+
}, Ji = class e {
|
|
8905
9236
|
constructor({ editor: e }) {
|
|
8906
9237
|
this.anchors = {
|
|
8907
9238
|
vertical: [],
|
|
@@ -8954,7 +9285,7 @@ var Nr = class {
|
|
|
8954
9285
|
this._clearSpacingContexts(), this._clearGuides();
|
|
8955
9286
|
return;
|
|
8956
9287
|
}
|
|
8957
|
-
let { canvas: o } = this, s = o.getZoom() || 1, c = 5 / s, { deltaX: l, deltaY: u } =
|
|
9288
|
+
let { canvas: o } = this, s = o.getZoom() || 1, c = 5 / s, { deltaX: l, deltaY: u } = Fi({
|
|
8958
9289
|
activeBounds: a,
|
|
8959
9290
|
threshold: c,
|
|
8960
9291
|
anchors: this.anchors
|
|
@@ -8966,7 +9297,7 @@ var Nr = class {
|
|
|
8966
9297
|
top: t + u
|
|
8967
9298
|
}), n.setCoords(), a = W({ object: n }) ?? a;
|
|
8968
9299
|
}
|
|
8969
|
-
let d = this._resolveCurrentTargetBounds({ activeObject: n }), f = this.spacingContexts.vertical || this.spacingContexts.horizontal ? 10 / s : c, p =
|
|
9300
|
+
let d = this._resolveCurrentTargetBounds({ activeObject: n }), f = this.spacingContexts.vertical || this.spacingContexts.horizontal ? 10 / s : c, p = Ri({
|
|
8970
9301
|
activeBounds: a,
|
|
8971
9302
|
candidates: d,
|
|
8972
9303
|
threshold: f,
|
|
@@ -8987,11 +9318,11 @@ var Nr = class {
|
|
|
8987
9318
|
target: n,
|
|
8988
9319
|
transform: i
|
|
8989
9320
|
});
|
|
8990
|
-
let h = W({ object: n }) ?? a, g =
|
|
9321
|
+
let h = W({ object: n }) ?? a, g = Fi({
|
|
8991
9322
|
activeBounds: h,
|
|
8992
9323
|
threshold: c,
|
|
8993
9324
|
anchors: this.anchors
|
|
8994
|
-
}), _ =
|
|
9325
|
+
}), _ = Ri({
|
|
8995
9326
|
activeBounds: h,
|
|
8996
9327
|
candidates: d,
|
|
8997
9328
|
threshold: c,
|
|
@@ -9222,9 +9553,9 @@ var Nr = class {
|
|
|
9222
9553
|
let { canvas: e, guideBounds: t } = this, n = e.getSelectionContext();
|
|
9223
9554
|
if (!n) return;
|
|
9224
9555
|
let { left: r, right: i, top: a, bottom: o } = t ?? this._calculateViewportBounds(), { viewportTransform: s } = e, c = e.getZoom() || 1;
|
|
9225
|
-
n.save(), Array.isArray(s) && n.transform(...s), n.lineWidth = 1 / c, n.strokeStyle =
|
|
9556
|
+
n.save(), Array.isArray(s) && n.transform(...s), n.lineWidth = 1 / c, n.strokeStyle = si, n.setLineDash([4, 4]);
|
|
9226
9557
|
for (let e of this.activeGuides) n.beginPath(), e.type === "vertical" ? (n.moveTo(e.position, a), n.lineTo(e.position, o)) : (n.moveTo(r, e.position), n.lineTo(i, e.position)), n.stroke();
|
|
9227
|
-
for (let e of this.activeSpacingGuides)
|
|
9558
|
+
for (let e of this.activeSpacingGuides) Vi({
|
|
9228
9559
|
context: n,
|
|
9229
9560
|
guide: e,
|
|
9230
9561
|
zoom: c
|
|
@@ -9435,14 +9766,14 @@ var Nr = class {
|
|
|
9435
9766
|
}, r = [];
|
|
9436
9767
|
for (let e of t) {
|
|
9437
9768
|
let t = W({ object: e });
|
|
9438
|
-
t && (
|
|
9769
|
+
t && (Hi({
|
|
9439
9770
|
anchors: n,
|
|
9440
9771
|
bounds: t
|
|
9441
9772
|
}), r.push(t));
|
|
9442
9773
|
}
|
|
9443
9774
|
let { montageArea: i } = this.editor, a = W({ object: i });
|
|
9444
9775
|
if (a) {
|
|
9445
|
-
|
|
9776
|
+
Hi({
|
|
9446
9777
|
anchors: n,
|
|
9447
9778
|
bounds: a
|
|
9448
9779
|
});
|
|
@@ -9454,12 +9785,12 @@ var Nr = class {
|
|
|
9454
9785
|
bottom: i
|
|
9455
9786
|
};
|
|
9456
9787
|
} else this.guideBounds = this._calculateViewportBounds();
|
|
9457
|
-
this.anchors = n, this.spacingPatterns =
|
|
9788
|
+
this.anchors = n, this.spacingPatterns = Wi({ bounds: r }), this.cachedTargetBounds = r;
|
|
9458
9789
|
}
|
|
9459
9790
|
_collectTargets({ activeObject: e }) {
|
|
9460
|
-
let t =
|
|
9791
|
+
let t = Ki({ activeObject: e }), n = [];
|
|
9461
9792
|
return this.canvas.forEachObject((e) => {
|
|
9462
|
-
|
|
9793
|
+
qi({
|
|
9463
9794
|
object: e,
|
|
9464
9795
|
excluded: t
|
|
9465
9796
|
}) || n.push(e);
|
|
@@ -9482,7 +9813,7 @@ var Nr = class {
|
|
|
9482
9813
|
bottom: (r - s) / a
|
|
9483
9814
|
};
|
|
9484
9815
|
}
|
|
9485
|
-
},
|
|
9816
|
+
}, Yi = "#3D8BF4", Xi = class e {
|
|
9486
9817
|
constructor({ editor: e }) {
|
|
9487
9818
|
this.activeGuides = [], this.isAltPressed = !1, this.pendingEvent = null, this.frameRequest = null, this.isToolbarHidden = !1, this.isTargetMontageArea = !1, this.lastMouseEvent = null, this.editor = e, this.canvas = e.canvas, this._onMouseMove = this._handleMouseMove.bind(this), this._onBeforeRender = this._handleBeforeRender.bind(this), this._onAfterRender = this._handleAfterRender.bind(this), this._onSelectionCleared = this._handleSelectionCleared.bind(this), this._onKeyDown = this._handleKeyDown.bind(this), this._onKeyUp = this._handleKeyUp.bind(this), this._onWindowBlur = this._handleWindowBlur.bind(this), this._bindEvents();
|
|
9488
9819
|
}
|
|
@@ -9575,8 +9906,8 @@ var Nr = class {
|
|
|
9575
9906
|
this.isTargetMontageArea = l, this.activeGuides = d, this._hideToolbar(), n.requestRenderAll();
|
|
9576
9907
|
}
|
|
9577
9908
|
static _resolveTarget({ event: e, activeObject: t }) {
|
|
9578
|
-
let { target: n } = e, r =
|
|
9579
|
-
return n && !
|
|
9909
|
+
let { target: n } = e, r = Ki({ activeObject: t });
|
|
9910
|
+
return n && !qi({
|
|
9580
9911
|
object: n,
|
|
9581
9912
|
excluded: r
|
|
9582
9913
|
}) ? n : null;
|
|
@@ -9693,18 +10024,18 @@ var Nr = class {
|
|
|
9693
10024
|
let { canvas: e } = this, t = e.getSelectionContext();
|
|
9694
10025
|
if (!t) return;
|
|
9695
10026
|
let { viewportTransform: n } = e, r = e.getZoom() || 1, i = this.activeGuides.some((e) => e.type === "vertical"), a = this.activeGuides.some((e) => e.type === "horizontal"), o = i && a && !this.isTargetMontageArea, s = o ? 12 / r : 0;
|
|
9696
|
-
t.save(), Array.isArray(n) && t.transform(...n), t.lineWidth = 1 / r, t.strokeStyle =
|
|
10027
|
+
t.save(), Array.isArray(n) && t.transform(...n), t.lineWidth = 1 / r, t.strokeStyle = Yi, t.setLineDash([]);
|
|
9697
10028
|
for (let e of this.activeGuides) {
|
|
9698
10029
|
let { type: n, axis: i, start: a, end: c, distance: l } = e, u = Math.abs(c - a), d = o ? (a <= c ? -1 : 1) * (u / 2 + s) : 0;
|
|
9699
|
-
t.beginPath(), n === "vertical" ? (t.moveTo(i, a), t.lineTo(i, c)) : (t.moveTo(a, i), t.lineTo(c, i)), t.stroke(),
|
|
10030
|
+
t.beginPath(), n === "vertical" ? (t.moveTo(i, a), t.lineTo(i, c)) : (t.moveTo(a, i), t.lineTo(c, i)), t.stroke(), Bi({
|
|
9700
10031
|
context: t,
|
|
9701
10032
|
type: n,
|
|
9702
10033
|
axis: i,
|
|
9703
10034
|
start: a,
|
|
9704
10035
|
end: c,
|
|
9705
|
-
text:
|
|
10036
|
+
text: li({ distance: l }).toString(),
|
|
9706
10037
|
zoom: r,
|
|
9707
|
-
color:
|
|
10038
|
+
color: Yi,
|
|
9708
10039
|
lineWidth: 1,
|
|
9709
10040
|
offsetAlongAxis: d,
|
|
9710
10041
|
offsetPerpendicular: 0
|
|
@@ -9722,13 +10053,13 @@ var Nr = class {
|
|
|
9722
10053
|
let { toolbar: e } = this.editor;
|
|
9723
10054
|
e?.showAfterTemporary?.(), this.isToolbarHidden = !1;
|
|
9724
10055
|
}
|
|
9725
|
-
},
|
|
10056
|
+
}, Zi = class e {
|
|
9726
10057
|
constructor(e, t) {
|
|
9727
10058
|
this.options = t, this.containerId = e, this.editorId = `${e}-${D()}`, this.init();
|
|
9728
10059
|
}
|
|
9729
10060
|
async init() {
|
|
9730
10061
|
let { editorContainerWidth: e, editorContainerHeight: n, canvasWrapperWidth: r, canvasWrapperHeight: i, canvasCSSWidth: a, canvasCSSHeight: o, initialImage: s, initialState: c, scaleType: l, showRotationAngle: u, _onReadyCallback: d } = this.options;
|
|
9731
|
-
if (z.apply(), this.canvas = new t(this.containerId, this.options), this.moduleLoader = new A(), this.workerManager = new M(), this.errorManager = new
|
|
10062
|
+
if (z.apply(), this.canvas = new t(this.containerId, this.options), this.moduleLoader = new A(), this.workerManager = new M(), this.errorManager = new mr({ editor: this }), this.historyManager = new Me({ editor: this }), this.toolbar = new ae({ editor: this }), this.transformManager = new Ue({ editor: this }), this.zoomManager = new We({ editor: this }), this.canvasManager = new He({ editor: this }), this.imageManager = new Re({ editor: this }), this.layerManager = new $e({ editor: this }), this.shapeManager = new sr({ editor: this }), this.interactionBlocker = new Ze({ editor: this }), this.backgroundManager = new Qe({ editor: this }), this.clipboardManager = new cr({ editor: this }), this.objectLockManager = new lr({ editor: this }), this.groupingManager = new ur({ editor: this }), this.selectionManager = new dr({ editor: this }), this.deletionManager = new fr({ editor: this }), this.panConstraintManager = new hr({ editor: this }), this.snappingManager = new Ji({ editor: this }), this.measurementManager = new Xi({ editor: this }), this.fontManager = new ie(this.options.fonts ?? []), this.textManager = new ti({ editor: this }), this.templateManager = new oi({ editor: this }), u && (this.angleIndicator = new se({ editor: this })), this._createMontageArea(), this._createClippingArea(), this.interactionBlocker.ensureOverlay(), this.listeners = new k({
|
|
9732
10063
|
editor: this,
|
|
9733
10064
|
options: this.options
|
|
9734
10065
|
}), this.canvasManager.setEditorContainerWidth(e), this.canvasManager.setEditorContainerHeight(n), this.canvasManager.setCanvasWrapperWidth(r), this.canvasManager.setCanvasWrapperHeight(i), this.canvasManager.setCanvasCSSWidth(a), this.canvasManager.setCanvasCSSHeight(o), this.canvasManager.updateCanvas(), this.zoomManager.calculateAndApplyDefaultZoom(), await this.fontManager.loadFonts(), c) {
|
|
@@ -9836,7 +10167,7 @@ var Nr = class {
|
|
|
9836
10167
|
"U+A640-A69F",
|
|
9837
10168
|
"U+FE2E-FE2F",
|
|
9838
10169
|
"U+2116"
|
|
9839
|
-
].join(", "),
|
|
10170
|
+
].join(", "), Qi = {
|
|
9840
10171
|
preserveObjectStacking: !0,
|
|
9841
10172
|
controlsAboveOverlay: !0,
|
|
9842
10173
|
centeredRotation: !0,
|
|
@@ -10690,20 +11021,20 @@ var Nr = class {
|
|
|
10690
11021
|
};
|
|
10691
11022
|
//#endregion
|
|
10692
11023
|
//#region src/main.ts
|
|
10693
|
-
function
|
|
11024
|
+
function $i(e, t = {}) {
|
|
10694
11025
|
let n = {
|
|
10695
|
-
...
|
|
11026
|
+
...Qi,
|
|
10696
11027
|
...t
|
|
10697
11028
|
}, r = document.getElementById(e);
|
|
10698
11029
|
if (!r) return Promise.reject(/* @__PURE__ */ Error(`Контейнер с ID "${e}" не найден.`));
|
|
10699
11030
|
let i = document.createElement("canvas");
|
|
10700
11031
|
return i.id = `${e}-canvas`, r.appendChild(i), n.editorContainer = r, new Promise((t) => {
|
|
10701
11032
|
n._onReadyCallback = t;
|
|
10702
|
-
let r = new
|
|
11033
|
+
let r = new Zi(i.id, n);
|
|
10703
11034
|
window[e] = r;
|
|
10704
11035
|
});
|
|
10705
11036
|
}
|
|
10706
11037
|
//#endregion
|
|
10707
|
-
export {
|
|
11038
|
+
export { $i as default };
|
|
10708
11039
|
|
|
10709
11040
|
//# sourceMappingURL=main.js.map
|