@anu3ev/fabric-image-editor 0.9.15 → 0.9.17
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 +1125 -600
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -13455,49 +13455,742 @@ var go = class {
|
|
|
13455
13455
|
color: d,
|
|
13456
13456
|
lineWidth: 1
|
|
13457
13457
|
});
|
|
13458
|
-
};
|
|
13459
|
-
|
|
13460
|
-
//#region src/editor/snapping-manager/pixel-grid.ts
|
|
13461
|
-
function is({ target: e }) {
|
|
13458
|
+
}, is = .01, as = .1, os = 1e-6;
|
|
13459
|
+
function ss({ target: e }) {
|
|
13462
13460
|
let t = typeof e.type == "string" ? e.type.toLowerCase() : "", n = e instanceof v || t === "textbox" || t === "background-textbox";
|
|
13463
13461
|
return !(e instanceof a) && !n;
|
|
13464
13462
|
}
|
|
13465
|
-
function
|
|
13463
|
+
function cs({ target: e, transform: t }) {
|
|
13466
13464
|
let { left: n = 0, top: r = 0 } = e, i = Math.round(n / 1) * 1, a = Math.round(r / 1) * 1, o = typeof t?.original?.left == "number" ? t.original.left : null, s = typeof t?.original?.top == "number" ? t.original.top : null, c = o === null || o !== n, l = s === null || s !== r, u = {};
|
|
13467
13465
|
c && i !== n && (u.left = i), l && a !== r && (u.top = a), !(!("left" in u) && !("top" in u)) && (e.set(u), e.setCoords());
|
|
13468
13466
|
}
|
|
13469
|
-
function
|
|
13467
|
+
function ls({ target: e }) {
|
|
13470
13468
|
let { width: t = 0, height: n = 0, paddingTop: r = 0, paddingRight: i = 0, paddingBottom: a = 0, paddingLeft: o = 0, strokeWidth: s = 0 } = e;
|
|
13471
13469
|
return {
|
|
13472
13470
|
width: t + o + i + s,
|
|
13473
13471
|
height: n + r + a + s
|
|
13474
13472
|
};
|
|
13475
13473
|
}
|
|
13476
|
-
function
|
|
13477
|
-
|
|
13478
|
-
|
|
13474
|
+
function us({ target: e, scaleX: t, scaleY: n }) {
|
|
13475
|
+
let r = e.getObjectDisplaySize?.();
|
|
13476
|
+
if (!r) return null;
|
|
13477
|
+
let i = Math.abs(t), a = Math.abs(n);
|
|
13478
|
+
return i <= 0 || a <= 0 || !Number.isFinite(r.width) || !Number.isFinite(r.height) || r.width <= 0 || r.height <= 0 ? null : {
|
|
13479
|
+
width: r.width / i,
|
|
13480
|
+
height: r.height / a
|
|
13481
|
+
};
|
|
13482
|
+
}
|
|
13483
|
+
function ds({ target: e, scaleX: t, scaleY: n }) {
|
|
13484
|
+
let r = us({
|
|
13485
|
+
target: e,
|
|
13486
|
+
scaleX: t,
|
|
13487
|
+
scaleY: n
|
|
13488
|
+
});
|
|
13489
|
+
if (r) return r;
|
|
13490
|
+
if (e instanceof v) return ls({ target: e });
|
|
13491
|
+
let { width: i = 0, height: a = 0, strokeWidth: o = 0, strokeUniform: s = !1 } = e, c = s ? 0 : o;
|
|
13479
13492
|
return {
|
|
13480
|
-
width:
|
|
13481
|
-
height:
|
|
13493
|
+
width: i + c,
|
|
13494
|
+
height: a + c
|
|
13482
13495
|
};
|
|
13483
13496
|
}
|
|
13484
|
-
function
|
|
13485
|
-
let { scaleX:
|
|
13486
|
-
|
|
13487
|
-
|
|
13488
|
-
|
|
13497
|
+
function fs({ target: e, transform: t, preservePlacement: n, snapGuards: r = [] }) {
|
|
13498
|
+
let { scaleX: i = 1, scaleY: a = 1 } = e, o = ps({
|
|
13499
|
+
transform: t,
|
|
13500
|
+
rawScaleX: i,
|
|
13501
|
+
rawScaleY: a
|
|
13502
|
+
});
|
|
13503
|
+
if (!o.shouldRoundScaleX && !o.shouldRoundScaleY) return;
|
|
13504
|
+
let { width: s, height: c } = ds({
|
|
13505
|
+
target: e,
|
|
13506
|
+
scaleX: i,
|
|
13507
|
+
scaleY: a
|
|
13508
|
+
}), l = ms({
|
|
13509
|
+
rawScaleX: i,
|
|
13510
|
+
rawScaleY: a,
|
|
13511
|
+
snappedScale: _s({
|
|
13512
|
+
target: e,
|
|
13513
|
+
rawScaleX: i,
|
|
13514
|
+
rawScaleY: a,
|
|
13515
|
+
effectiveWidth: s,
|
|
13516
|
+
effectiveHeight: c,
|
|
13517
|
+
preservePlacement: n,
|
|
13518
|
+
snapGuards: r
|
|
13519
|
+
}),
|
|
13520
|
+
roundingState: o
|
|
13521
|
+
});
|
|
13522
|
+
l.scaleX === i && l.scaleY === a || hs({
|
|
13523
|
+
target: e,
|
|
13524
|
+
transform: t,
|
|
13525
|
+
preservePlacement: n,
|
|
13526
|
+
scale: l
|
|
13527
|
+
});
|
|
13528
|
+
}
|
|
13529
|
+
function ps({ transform: e, rawScaleX: t, rawScaleY: n }) {
|
|
13530
|
+
return {
|
|
13531
|
+
shouldRoundScaleX: gs({
|
|
13532
|
+
transform: e,
|
|
13533
|
+
axis: "x",
|
|
13534
|
+
rawScale: t
|
|
13535
|
+
}),
|
|
13536
|
+
shouldRoundScaleY: gs({
|
|
13537
|
+
transform: e,
|
|
13538
|
+
axis: "y",
|
|
13539
|
+
rawScale: n
|
|
13540
|
+
})
|
|
13541
|
+
};
|
|
13542
|
+
}
|
|
13543
|
+
function ms({ rawScaleX: e, rawScaleY: t, snappedScale: n, roundingState: r }) {
|
|
13544
|
+
let i = { ...n };
|
|
13545
|
+
return r.shouldRoundScaleX || (i.scaleX = e), r.shouldRoundScaleY || (i.scaleY = t), i;
|
|
13546
|
+
}
|
|
13547
|
+
function hs({ target: e, transform: t, preservePlacement: n, scale: r }) {
|
|
13548
|
+
e.set({
|
|
13549
|
+
scaleX: r.scaleX,
|
|
13550
|
+
scaleY: r.scaleY
|
|
13551
|
+
}), n && n.applyPlacement(n.placement), t && (t.scaleX = r.scaleX, t.scaleY = r.scaleY), e.setCoords();
|
|
13552
|
+
}
|
|
13553
|
+
function gs({ transform: e, axis: t, rawScale: n }) {
|
|
13554
|
+
if (!e) return !0;
|
|
13555
|
+
let r = t === "x" ? e.original?.scaleX : e.original?.scaleY;
|
|
13556
|
+
return typeof r == "number" ? r !== n : !0;
|
|
13557
|
+
}
|
|
13558
|
+
function _s({ target: e, rawScaleX: t, rawScaleY: n, effectiveWidth: r, effectiveHeight: i, preservePlacement: a, snapGuards: o }) {
|
|
13559
|
+
let s = vs({
|
|
13560
|
+
rawScaleX: t,
|
|
13561
|
+
rawScaleY: n,
|
|
13562
|
+
effectiveWidth: r,
|
|
13563
|
+
effectiveHeight: i
|
|
13564
|
+
});
|
|
13565
|
+
return o.length === 0 ? s : xs({
|
|
13566
|
+
target: e,
|
|
13567
|
+
rawScaleX: t,
|
|
13568
|
+
rawScaleY: n,
|
|
13569
|
+
effectiveWidth: r,
|
|
13570
|
+
effectiveHeight: i,
|
|
13571
|
+
fallbackScale: s,
|
|
13572
|
+
isUniform: t === n,
|
|
13573
|
+
preservePlacement: a,
|
|
13574
|
+
snapGuards: o
|
|
13575
|
+
});
|
|
13576
|
+
}
|
|
13577
|
+
function vs({ rawScaleX: e, rawScaleY: t, effectiveWidth: n, effectiveHeight: r }) {
|
|
13578
|
+
return e === t ? ys({
|
|
13579
|
+
rawScale: e,
|
|
13580
|
+
effectiveWidth: n,
|
|
13581
|
+
effectiveHeight: r
|
|
13582
|
+
}) : {
|
|
13583
|
+
scaleX: bs({
|
|
13584
|
+
rawScale: e,
|
|
13585
|
+
effectiveSize: n
|
|
13586
|
+
}),
|
|
13587
|
+
scaleY: bs({
|
|
13588
|
+
rawScale: t,
|
|
13589
|
+
effectiveSize: r
|
|
13590
|
+
})
|
|
13591
|
+
};
|
|
13592
|
+
}
|
|
13593
|
+
function ys({ rawScale: e, effectiveWidth: t, effectiveHeight: n }) {
|
|
13594
|
+
let r = bs({
|
|
13595
|
+
rawScale: e,
|
|
13596
|
+
effectiveSize: t
|
|
13597
|
+
}), i = bs({
|
|
13598
|
+
rawScale: e,
|
|
13599
|
+
effectiveSize: n
|
|
13600
|
+
}), a = Math.abs(r - e) <= Math.abs(i - e) ? r : i;
|
|
13601
|
+
return {
|
|
13602
|
+
scaleX: a,
|
|
13603
|
+
scaleY: a
|
|
13604
|
+
};
|
|
13605
|
+
}
|
|
13606
|
+
function bs({ rawScale: e, effectiveSize: t }) {
|
|
13607
|
+
return t <= 0 ? e : Math.max(1, Math.round(t * e)) / t;
|
|
13608
|
+
}
|
|
13609
|
+
function xs({ target: e, rawScaleX: t, rawScaleY: n, effectiveWidth: r, effectiveHeight: i, fallbackScale: a, isUniform: o, preservePlacement: s, snapGuards: c }) {
|
|
13610
|
+
if (Cs({
|
|
13611
|
+
target: e,
|
|
13612
|
+
snapGuards: c
|
|
13613
|
+
})) return {
|
|
13614
|
+
scaleX: t,
|
|
13615
|
+
scaleY: n
|
|
13616
|
+
};
|
|
13617
|
+
let l = js({
|
|
13618
|
+
rawScaleX: t,
|
|
13619
|
+
rawScaleY: n,
|
|
13620
|
+
effectiveWidth: r,
|
|
13621
|
+
effectiveHeight: i,
|
|
13622
|
+
isUniform: o
|
|
13623
|
+
}), u = Ss({
|
|
13624
|
+
target: e,
|
|
13625
|
+
snapGuards: c
|
|
13626
|
+
}), d = null, f = null;
|
|
13627
|
+
for (let t of l) {
|
|
13628
|
+
let n = Is({
|
|
13629
|
+
target: e,
|
|
13630
|
+
candidate: t,
|
|
13631
|
+
preservePlacement: s,
|
|
13632
|
+
snapGuards: c
|
|
13633
|
+
});
|
|
13634
|
+
if (n === "on-guide") {
|
|
13635
|
+
if (!u) return t;
|
|
13636
|
+
d ||= t;
|
|
13637
|
+
}
|
|
13638
|
+
n === "inside" && !f && (f = t);
|
|
13639
|
+
}
|
|
13640
|
+
return f || d || a;
|
|
13641
|
+
}
|
|
13642
|
+
function Ss({ target: e, snapGuards: t }) {
|
|
13643
|
+
return ws({
|
|
13644
|
+
target: e,
|
|
13645
|
+
snapGuards: t
|
|
13646
|
+
}) ? !Ts({
|
|
13647
|
+
target: e,
|
|
13648
|
+
snapGuards: t
|
|
13649
|
+
}) : !1;
|
|
13650
|
+
}
|
|
13651
|
+
function Cs({ target: e, snapGuards: t }) {
|
|
13652
|
+
if (ws({
|
|
13653
|
+
target: e,
|
|
13654
|
+
snapGuards: t
|
|
13655
|
+
})) return !1;
|
|
13656
|
+
let n = G({ object: e });
|
|
13657
|
+
if (!n) return !1;
|
|
13658
|
+
for (let e of t) if (!ks({ snapGuard: e }) || !Rs({
|
|
13659
|
+
bounds: n,
|
|
13660
|
+
snapGuard: e
|
|
13661
|
+
}) || !As({
|
|
13662
|
+
bounds: n,
|
|
13663
|
+
snapGuard: e
|
|
13664
|
+
})) return !1;
|
|
13665
|
+
return !0;
|
|
13666
|
+
}
|
|
13667
|
+
function ws({ target: e, snapGuards: t }) {
|
|
13668
|
+
if (typeof e.getObjectDisplaySize != "function") return !1;
|
|
13669
|
+
let n = e, r = t.some((e) => e.type === "vertical" && !Os({ scale: n.cropSourceScaleX })), i = t.some((e) => e.type === "horizontal" && !Os({ scale: n.cropSourceScaleY }));
|
|
13670
|
+
return r || i;
|
|
13671
|
+
}
|
|
13672
|
+
function Ts({ target: e, snapGuards: t }) {
|
|
13673
|
+
let { cropSource: n } = e;
|
|
13674
|
+
if (!n) return !1;
|
|
13675
|
+
let r = G({ object: n });
|
|
13676
|
+
return r ? t.some((e) => Es({
|
|
13677
|
+
snapGuard: e,
|
|
13678
|
+
sourceBounds: r
|
|
13679
|
+
})) : !1;
|
|
13680
|
+
}
|
|
13681
|
+
function Es({ snapGuard: e, sourceBounds: t }) {
|
|
13682
|
+
let { edge: n, position: r } = e, i = t.bottom;
|
|
13683
|
+
return n === "left" && (i = t.left), n === "right" && (i = t.right), n === "top" && (i = t.top), Ds({
|
|
13684
|
+
position: r,
|
|
13685
|
+
boundary: i
|
|
13686
|
+
});
|
|
13687
|
+
}
|
|
13688
|
+
function Ds({ position: e, boundary: t }) {
|
|
13689
|
+
return Math.abs(e - t) <= as;
|
|
13690
|
+
}
|
|
13691
|
+
function Os({ scale: e }) {
|
|
13692
|
+
return Math.abs(Math.abs(e ?? 1) - 1) <= os;
|
|
13693
|
+
}
|
|
13694
|
+
function ks({ snapGuard: e }) {
|
|
13695
|
+
let t = Math.round(e.position);
|
|
13696
|
+
return Math.abs(e.position - t) <= is;
|
|
13697
|
+
}
|
|
13698
|
+
function As({ bounds: e, snapGuard: t }) {
|
|
13699
|
+
let n = t.type === "vertical" ? e.right - e.left : e.bottom - e.top;
|
|
13700
|
+
return !Number.isFinite(n) || n <= 0 ? !1 : Math.round(n) > 0;
|
|
13701
|
+
}
|
|
13702
|
+
function js({ rawScaleX: e, rawScaleY: t, effectiveWidth: n, effectiveHeight: r, isUniform: i }) {
|
|
13703
|
+
let a = Ms({
|
|
13704
|
+
rawScale: e,
|
|
13705
|
+
effectiveSize: n
|
|
13706
|
+
}), o = Ms({
|
|
13707
|
+
rawScale: t,
|
|
13708
|
+
effectiveSize: r
|
|
13709
|
+
});
|
|
13710
|
+
return i ? Ps({
|
|
13711
|
+
scaleXCandidates: a,
|
|
13712
|
+
scaleYCandidates: o,
|
|
13713
|
+
rawScale: e
|
|
13714
|
+
}) : Fs({
|
|
13715
|
+
scaleXCandidates: a,
|
|
13716
|
+
scaleYCandidates: o,
|
|
13717
|
+
rawScaleX: e,
|
|
13718
|
+
rawScaleY: t
|
|
13719
|
+
});
|
|
13720
|
+
}
|
|
13721
|
+
function Ms({ rawScale: e, effectiveSize: t }) {
|
|
13722
|
+
if (t <= 0) return [e];
|
|
13723
|
+
let n = e < 0 ? -1 : 1, r = Math.abs(e) * t, i = Math.round(r), a = Math.floor(r), o = Math.ceil(r), s = [
|
|
13724
|
+
i,
|
|
13725
|
+
a,
|
|
13726
|
+
o,
|
|
13727
|
+
a - 1,
|
|
13728
|
+
o + 1
|
|
13729
|
+
], c = [];
|
|
13730
|
+
for (let e of s) Ns({
|
|
13731
|
+
candidates: c,
|
|
13732
|
+
scale: Math.max(1, e) / t * n
|
|
13733
|
+
});
|
|
13734
|
+
return c.sort((t, n) => Math.abs(t - e) - Math.abs(n - e)), c;
|
|
13735
|
+
}
|
|
13736
|
+
function Ns({ candidates: e, scale: t }) {
|
|
13737
|
+
Number.isFinite(t) && (e.includes(t) || e.push(t));
|
|
13738
|
+
}
|
|
13739
|
+
function Ps({ scaleXCandidates: e, scaleYCandidates: t, rawScale: n }) {
|
|
13740
|
+
let r = [...e];
|
|
13741
|
+
for (let e of t) Ns({
|
|
13742
|
+
candidates: r,
|
|
13743
|
+
scale: e
|
|
13744
|
+
});
|
|
13745
|
+
return r.sort((e, t) => Math.abs(e - n) - Math.abs(t - n)), r.map((e) => ({
|
|
13746
|
+
scaleX: e,
|
|
13747
|
+
scaleY: e
|
|
13748
|
+
}));
|
|
13749
|
+
}
|
|
13750
|
+
function Fs({ scaleXCandidates: e, scaleYCandidates: t, rawScaleX: n, rawScaleY: r }) {
|
|
13751
|
+
let i = [];
|
|
13752
|
+
for (let n of e) for (let e of t) i.push({
|
|
13753
|
+
scaleX: n,
|
|
13754
|
+
scaleY: e
|
|
13755
|
+
});
|
|
13756
|
+
return i.sort((e, t) => Math.abs(e.scaleX - n) + Math.abs(e.scaleY - r) - (Math.abs(t.scaleX - n) + Math.abs(t.scaleY - r))), i;
|
|
13757
|
+
}
|
|
13758
|
+
function Is({ target: e, candidate: t, preservePlacement: n, snapGuards: r }) {
|
|
13759
|
+
let i = e.scaleX ?? 1, a = e.scaleY ?? 1, o = null;
|
|
13760
|
+
try {
|
|
13761
|
+
e.set({
|
|
13762
|
+
scaleX: t.scaleX,
|
|
13763
|
+
scaleY: t.scaleY
|
|
13764
|
+
}), n ? n.applyPlacement(n.placement) : e.setCoords(), o = G({ object: e });
|
|
13765
|
+
} finally {
|
|
13766
|
+
e.set({
|
|
13767
|
+
scaleX: i,
|
|
13768
|
+
scaleY: a
|
|
13769
|
+
}), n ? n.applyPlacement(n.placement) : e.setCoords();
|
|
13770
|
+
}
|
|
13771
|
+
if (!o) return "outside";
|
|
13772
|
+
let s = !0;
|
|
13773
|
+
for (let e of r) {
|
|
13774
|
+
if (!Ls({
|
|
13775
|
+
bounds: o,
|
|
13776
|
+
snapGuard: e
|
|
13777
|
+
})) return "outside";
|
|
13778
|
+
Rs({
|
|
13779
|
+
bounds: o,
|
|
13780
|
+
snapGuard: e
|
|
13781
|
+
}) || (s = !1);
|
|
13782
|
+
}
|
|
13783
|
+
return s ? "on-guide" : "inside";
|
|
13784
|
+
}
|
|
13785
|
+
function Ls({ bounds: e, snapGuard: t }) {
|
|
13786
|
+
let { edge: n, position: r } = t;
|
|
13787
|
+
return n === "left" ? e.left >= r - as : n === "right" ? e.right <= r + as : n === "top" ? e.top >= r - as : e.bottom <= r + as;
|
|
13788
|
+
}
|
|
13789
|
+
function Rs({ bounds: e, snapGuard: t }) {
|
|
13790
|
+
let { edge: n, position: r } = t;
|
|
13791
|
+
return n === "left" ? Math.abs(e.left - r) <= as : n === "right" ? Math.abs(e.right - r) <= as : n === "top" ? Math.abs(e.top - r) <= as : Math.abs(e.bottom - r) <= as;
|
|
13792
|
+
}
|
|
13793
|
+
//#endregion
|
|
13794
|
+
//#region src/editor/snapping-manager/scaling.ts
|
|
13795
|
+
var zs = 1e-6;
|
|
13796
|
+
function Bs({ transform: e }) {
|
|
13797
|
+
let { corner: t = "", action: n = "" } = e, r = t === "ml" || t === "mr" || n === "scaleX", i = t === "mt" || t === "mb" || n === "scaleY", a = t === "tl" || t === "tr" || t === "bl" || t === "br" || n === "scale";
|
|
13798
|
+
return {
|
|
13799
|
+
isCornerHandle: a,
|
|
13800
|
+
shouldSnapX: r || a,
|
|
13801
|
+
shouldSnapY: i || a
|
|
13802
|
+
};
|
|
13803
|
+
}
|
|
13804
|
+
function Vs({ target: e, transform: t }) {
|
|
13805
|
+
let { originX: n, originY: r } = t, { originX: i = "left", originY: a = "top", scaleX: o = 1, scaleY: s = 1 } = e;
|
|
13806
|
+
return {
|
|
13807
|
+
originX: n ?? i,
|
|
13808
|
+
originY: r ?? a,
|
|
13809
|
+
scaleX: o,
|
|
13810
|
+
scaleY: s
|
|
13811
|
+
};
|
|
13812
|
+
}
|
|
13813
|
+
function Hs({ target: e, event: t, isCornerHandle: n }) {
|
|
13814
|
+
let r = e;
|
|
13815
|
+
if (r.cropSource) {
|
|
13816
|
+
let e = r.preserveAspectRatio ?? !0;
|
|
13817
|
+
return t.e?.shiftKey ? !e : e;
|
|
13818
|
+
}
|
|
13819
|
+
return n;
|
|
13820
|
+
}
|
|
13821
|
+
function Us({ bounds: e, corner: t, originX: n, originY: r, shouldSnapX: i, shouldSnapY: a, threshold: o, anchors: s }) {
|
|
13822
|
+
let c = Xs({
|
|
13823
|
+
bounds: e,
|
|
13824
|
+
corner: t,
|
|
13825
|
+
originX: n,
|
|
13826
|
+
shouldSnapX: i
|
|
13827
|
+
}), l = Zs({
|
|
13828
|
+
bounds: e,
|
|
13829
|
+
corner: t,
|
|
13830
|
+
originY: r,
|
|
13831
|
+
shouldSnapY: a
|
|
13832
|
+
}), u = ec({
|
|
13833
|
+
anchors: s.vertical,
|
|
13834
|
+
candidates: c,
|
|
13835
|
+
threshold: o
|
|
13836
|
+
}), d = ec({
|
|
13837
|
+
anchors: s.horizontal,
|
|
13838
|
+
candidates: l,
|
|
13839
|
+
threshold: o
|
|
13840
|
+
});
|
|
13841
|
+
return u.guidePosition === null && d.guidePosition === null ? null : {
|
|
13842
|
+
verticalSnap: u,
|
|
13843
|
+
horizontalSnap: d
|
|
13844
|
+
};
|
|
13845
|
+
}
|
|
13846
|
+
function Ws(e) {
|
|
13847
|
+
return e.shouldUseUniformScaleSnap ? Ks(e) : qs(e);
|
|
13848
|
+
}
|
|
13849
|
+
function Gs({ target: e, bounds: t, originX: n, verticalAnchors: r, threshold: i }) {
|
|
13850
|
+
let a = ec({
|
|
13851
|
+
anchors: r,
|
|
13852
|
+
candidates: Xs({
|
|
13853
|
+
bounds: t,
|
|
13854
|
+
originX: n,
|
|
13855
|
+
shouldSnapX: !0
|
|
13856
|
+
}),
|
|
13857
|
+
threshold: i
|
|
13858
|
+
}), { guidePosition: o } = a;
|
|
13859
|
+
if (o === null) return null;
|
|
13860
|
+
let s = lc({
|
|
13861
|
+
bounds: t,
|
|
13862
|
+
originX: n,
|
|
13863
|
+
snap: a
|
|
13864
|
+
});
|
|
13865
|
+
if (s === null) return null;
|
|
13866
|
+
let c = mc({
|
|
13867
|
+
target: e,
|
|
13868
|
+
boundsWidth: s
|
|
13869
|
+
});
|
|
13870
|
+
return c === null ? null : {
|
|
13871
|
+
nextWidth: c,
|
|
13872
|
+
guide: {
|
|
13873
|
+
type: "vertical",
|
|
13874
|
+
position: o
|
|
13875
|
+
}
|
|
13876
|
+
};
|
|
13877
|
+
}
|
|
13878
|
+
function Ks({ bounds: e, originX: t, originY: n, scaleX: r, scaleY: i, verticalSnap: a, horizontalSnap: o }) {
|
|
13879
|
+
let s = tc({
|
|
13880
|
+
bounds: e,
|
|
13881
|
+
originX: t,
|
|
13882
|
+
originY: n,
|
|
13883
|
+
verticalSnap: a,
|
|
13884
|
+
horizontalSnap: o
|
|
13885
|
+
});
|
|
13886
|
+
if (!s) return null;
|
|
13887
|
+
let { guide: c, scaleFactor: l, snapGuards: u } = s;
|
|
13888
|
+
return {
|
|
13889
|
+
guides: [c],
|
|
13890
|
+
snapGuards: u,
|
|
13891
|
+
nextScaleX: r * l,
|
|
13892
|
+
nextScaleY: i * l
|
|
13893
|
+
};
|
|
13894
|
+
}
|
|
13895
|
+
function qs(e) {
|
|
13896
|
+
let t = Js(e), n = Ys(e);
|
|
13897
|
+
if (!t && !n) return null;
|
|
13898
|
+
let r = [], i = [], a = null, o = null;
|
|
13899
|
+
return t && (r.push(t.guide), i.push(t.snapGuard), a = t.nextScale), n && (r.push(n.guide), i.push(n.snapGuard), o = n.nextScale), {
|
|
13900
|
+
guides: r,
|
|
13901
|
+
snapGuards: i,
|
|
13902
|
+
nextScaleX: a,
|
|
13903
|
+
nextScaleY: o
|
|
13904
|
+
};
|
|
13905
|
+
}
|
|
13906
|
+
function Js({ target: e, bounds: t, originX: n, scaleX: r, scaleY: i, verticalSnap: a }) {
|
|
13907
|
+
let { guidePosition: o } = a;
|
|
13908
|
+
if (o === null) return null;
|
|
13909
|
+
let s = lc({
|
|
13910
|
+
bounds: t,
|
|
13911
|
+
originX: n,
|
|
13912
|
+
snap: a
|
|
13913
|
+
});
|
|
13914
|
+
if (s === null) return null;
|
|
13915
|
+
let { angle: c = 0 } = e, { width: l, height: u } = dc({ target: e }), d = fc({
|
|
13916
|
+
desiredWidth: s,
|
|
13917
|
+
baseWidth: l,
|
|
13918
|
+
baseHeight: u,
|
|
13919
|
+
scaleY: Math.abs(i) || 1,
|
|
13920
|
+
angle: c
|
|
13921
|
+
});
|
|
13922
|
+
if (d === null) return null;
|
|
13923
|
+
let f = ac({
|
|
13924
|
+
type: "vertical",
|
|
13925
|
+
snap: a
|
|
13926
|
+
});
|
|
13927
|
+
return f ? {
|
|
13928
|
+
nextScale: d * (r < 0 ? -1 : 1),
|
|
13929
|
+
snapGuard: f,
|
|
13930
|
+
guide: {
|
|
13931
|
+
type: "vertical",
|
|
13932
|
+
position: o
|
|
13933
|
+
}
|
|
13934
|
+
} : null;
|
|
13935
|
+
}
|
|
13936
|
+
function Ys({ target: e, bounds: t, originY: n, scaleX: r, scaleY: i, horizontalSnap: a }) {
|
|
13937
|
+
let { guidePosition: o } = a;
|
|
13938
|
+
if (o === null) return null;
|
|
13939
|
+
let s = uc({
|
|
13940
|
+
bounds: t,
|
|
13941
|
+
originY: n,
|
|
13942
|
+
snap: a
|
|
13943
|
+
});
|
|
13944
|
+
if (s === null) return null;
|
|
13945
|
+
let { angle: c = 0 } = e, { width: l, height: u } = dc({ target: e }), d = pc({
|
|
13946
|
+
desiredHeight: s,
|
|
13947
|
+
baseWidth: l,
|
|
13948
|
+
baseHeight: u,
|
|
13949
|
+
scaleX: Math.abs(r) || 1,
|
|
13950
|
+
angle: c
|
|
13951
|
+
});
|
|
13952
|
+
if (d === null) return null;
|
|
13953
|
+
let f = ac({
|
|
13954
|
+
type: "horizontal",
|
|
13955
|
+
snap: a
|
|
13956
|
+
});
|
|
13957
|
+
return f ? {
|
|
13958
|
+
nextScale: d * (i < 0 ? -1 : 1),
|
|
13959
|
+
snapGuard: f,
|
|
13960
|
+
guide: {
|
|
13961
|
+
type: "horizontal",
|
|
13962
|
+
position: o
|
|
13963
|
+
}
|
|
13964
|
+
} : null;
|
|
13965
|
+
}
|
|
13966
|
+
function Xs({ bounds: e, corner: t = "", originX: n, shouldSnapX: r }) {
|
|
13967
|
+
let i = [];
|
|
13968
|
+
if (!r) return i;
|
|
13969
|
+
let { left: a, right: o } = e, s = "left";
|
|
13970
|
+
(n === "center" || n === "right") && (s = n);
|
|
13971
|
+
let c = Qs({ controlKey: t });
|
|
13972
|
+
return c && s !== "center" ? (i.push({
|
|
13973
|
+
edge: c,
|
|
13974
|
+
position: c === "left" ? a : o
|
|
13975
|
+
}), i) : (s === "left" && i.push({
|
|
13976
|
+
edge: "right",
|
|
13977
|
+
position: o
|
|
13978
|
+
}), s === "right" && i.push({
|
|
13979
|
+
edge: "left",
|
|
13980
|
+
position: a
|
|
13981
|
+
}), s === "center" && (i.push({
|
|
13982
|
+
edge: "left",
|
|
13983
|
+
position: a
|
|
13984
|
+
}), i.push({
|
|
13985
|
+
edge: "right",
|
|
13986
|
+
position: o
|
|
13987
|
+
})), i);
|
|
13988
|
+
}
|
|
13989
|
+
function Zs({ bounds: e, corner: t = "", originY: n, shouldSnapY: r }) {
|
|
13990
|
+
let i = [];
|
|
13991
|
+
if (!r) return i;
|
|
13992
|
+
let { top: a, bottom: o } = e, s = "top";
|
|
13993
|
+
(n === "center" || n === "bottom") && (s = n);
|
|
13994
|
+
let c = $s({ controlKey: t });
|
|
13995
|
+
return c && s !== "center" ? (i.push({
|
|
13996
|
+
edge: c,
|
|
13997
|
+
position: c === "top" ? a : o
|
|
13998
|
+
}), i) : (s === "top" && i.push({
|
|
13999
|
+
edge: "bottom",
|
|
14000
|
+
position: o
|
|
14001
|
+
}), s === "bottom" && i.push({
|
|
14002
|
+
edge: "top",
|
|
14003
|
+
position: a
|
|
14004
|
+
}), s === "center" && (i.push({
|
|
14005
|
+
edge: "top",
|
|
14006
|
+
position: a
|
|
14007
|
+
}), i.push({
|
|
14008
|
+
edge: "bottom",
|
|
14009
|
+
position: o
|
|
14010
|
+
})), i);
|
|
14011
|
+
}
|
|
14012
|
+
function Qs({ controlKey: e }) {
|
|
14013
|
+
return e === "tl" || e === "bl" || e === "ml" ? "left" : e === "tr" || e === "br" || e === "mr" ? "right" : null;
|
|
14014
|
+
}
|
|
14015
|
+
function $s({ controlKey: e }) {
|
|
14016
|
+
return e === "tl" || e === "tr" || e === "mt" ? "top" : e === "bl" || e === "br" || e === "mb" ? "bottom" : null;
|
|
14017
|
+
}
|
|
14018
|
+
function ec({ anchors: e, candidates: t, threshold: n }) {
|
|
14019
|
+
let r = 0, i = n + 1, a = null, o = null;
|
|
14020
|
+
for (let s of t) {
|
|
14021
|
+
let { position: t } = s;
|
|
14022
|
+
for (let c of e) {
|
|
14023
|
+
let e = Math.abs(c - t);
|
|
14024
|
+
e > n || e >= i || (r = c - t, i = e, a = c, o = s);
|
|
14025
|
+
}
|
|
14026
|
+
}
|
|
14027
|
+
return {
|
|
14028
|
+
delta: r,
|
|
14029
|
+
guidePosition: a,
|
|
14030
|
+
candidate: o
|
|
14031
|
+
};
|
|
14032
|
+
}
|
|
14033
|
+
function tc({ bounds: e, originX: t, originY: n, verticalSnap: r, horizontalSnap: i }) {
|
|
14034
|
+
let a = oc({
|
|
14035
|
+
bounds: e,
|
|
14036
|
+
originX: t,
|
|
14037
|
+
snap: r
|
|
14038
|
+
}), o = sc({
|
|
14039
|
+
bounds: e,
|
|
14040
|
+
originY: n,
|
|
14041
|
+
snap: i
|
|
14042
|
+
}), s = cc({
|
|
14043
|
+
scaleFactorX: a,
|
|
14044
|
+
scaleFactorY: o,
|
|
14045
|
+
verticalSnap: r,
|
|
14046
|
+
horizontalSnap: i
|
|
14047
|
+
}), c = null;
|
|
14048
|
+
if (s === "x" && (c = nc({
|
|
14049
|
+
type: "vertical",
|
|
14050
|
+
scaleFactor: a,
|
|
14051
|
+
snap: r
|
|
14052
|
+
})), s === "y" && (c = nc({
|
|
14053
|
+
type: "horizontal",
|
|
14054
|
+
scaleFactor: o,
|
|
14055
|
+
snap: i
|
|
14056
|
+
})), !c) return null;
|
|
14057
|
+
let l = rc({
|
|
14058
|
+
scaleFactor: c.scaleFactor,
|
|
14059
|
+
scaleFactorX: a,
|
|
14060
|
+
scaleFactorY: o,
|
|
14061
|
+
verticalSnap: r,
|
|
14062
|
+
horizontalSnap: i
|
|
14063
|
+
});
|
|
14064
|
+
return l.length === 0 ? null : {
|
|
14065
|
+
guide: c.guide,
|
|
14066
|
+
snapGuards: l,
|
|
14067
|
+
scaleFactor: c.scaleFactor
|
|
14068
|
+
};
|
|
14069
|
+
}
|
|
14070
|
+
function nc({ type: e, scaleFactor: t, snap: n }) {
|
|
14071
|
+
let { guidePosition: r } = n;
|
|
14072
|
+
if (t === null || r === null) return null;
|
|
14073
|
+
let i = ac({
|
|
14074
|
+
type: e,
|
|
14075
|
+
snap: n
|
|
14076
|
+
});
|
|
14077
|
+
return i ? {
|
|
14078
|
+
scaleFactor: t,
|
|
14079
|
+
snapGuard: i,
|
|
14080
|
+
guide: {
|
|
14081
|
+
type: e,
|
|
14082
|
+
position: r
|
|
14083
|
+
}
|
|
14084
|
+
} : null;
|
|
14085
|
+
}
|
|
14086
|
+
function rc({ scaleFactor: e, scaleFactorX: t, scaleFactorY: n, verticalSnap: r, horizontalSnap: i }) {
|
|
14087
|
+
let a = [];
|
|
14088
|
+
return ic({
|
|
14089
|
+
snapGuards: a,
|
|
14090
|
+
scaleFactor: e,
|
|
14091
|
+
axisScaleFactor: t,
|
|
14092
|
+
type: "vertical",
|
|
14093
|
+
snap: r
|
|
14094
|
+
}), ic({
|
|
14095
|
+
snapGuards: a,
|
|
14096
|
+
scaleFactor: e,
|
|
14097
|
+
axisScaleFactor: n,
|
|
14098
|
+
type: "horizontal",
|
|
14099
|
+
snap: i
|
|
14100
|
+
}), a;
|
|
14101
|
+
}
|
|
14102
|
+
function ic({ snapGuards: e, scaleFactor: t, axisScaleFactor: n, type: r, snap: i }) {
|
|
14103
|
+
if (n === null || Math.abs(n - t) > zs) return;
|
|
14104
|
+
let a = ac({
|
|
14105
|
+
type: r,
|
|
14106
|
+
snap: i
|
|
14107
|
+
});
|
|
14108
|
+
a && e.push(a);
|
|
14109
|
+
}
|
|
14110
|
+
function ac({ type: e, snap: t }) {
|
|
14111
|
+
let { candidate: n, guidePosition: r } = t;
|
|
14112
|
+
return !n || r === null ? null : {
|
|
14113
|
+
type: e,
|
|
14114
|
+
edge: n.edge,
|
|
14115
|
+
position: r
|
|
14116
|
+
};
|
|
14117
|
+
}
|
|
14118
|
+
function oc({ bounds: e, originX: t, snap: n }) {
|
|
14119
|
+
let { left: r, right: i } = e, a = i - r;
|
|
14120
|
+
if (n.guidePosition === null || a <= 0) return null;
|
|
14121
|
+
let o = lc({
|
|
14122
|
+
bounds: e,
|
|
14123
|
+
originX: t,
|
|
14124
|
+
snap: n
|
|
14125
|
+
});
|
|
14126
|
+
if (o === null) return null;
|
|
14127
|
+
let s = o / a;
|
|
14128
|
+
return !Number.isFinite(s) || s <= 0 ? null : s;
|
|
14129
|
+
}
|
|
14130
|
+
function sc({ bounds: e, originY: t, snap: n }) {
|
|
14131
|
+
let { top: r, bottom: i } = e, a = i - r;
|
|
14132
|
+
if (n.guidePosition === null || a <= 0) return null;
|
|
14133
|
+
let o = uc({
|
|
14134
|
+
bounds: e,
|
|
14135
|
+
originY: t,
|
|
14136
|
+
snap: n
|
|
14137
|
+
});
|
|
14138
|
+
if (o === null) return null;
|
|
14139
|
+
let s = o / a;
|
|
14140
|
+
return !Number.isFinite(s) || s <= 0 ? null : s;
|
|
14141
|
+
}
|
|
14142
|
+
function cc({ scaleFactorX: e, scaleFactorY: t, verticalSnap: n, horizontalSnap: r }) {
|
|
14143
|
+
return e !== null && t === null ? "x" : t !== null && e === null ? "y" : e === null || t === null ? null : Math.abs(n.delta) <= Math.abs(r.delta) ? "x" : "y";
|
|
14144
|
+
}
|
|
14145
|
+
function lc({ bounds: e, originX: t, snap: n }) {
|
|
14146
|
+
let { left: r, right: i, centerX: a } = e, { candidate: o, guidePosition: s } = n;
|
|
14147
|
+
if (!o || s === null) return null;
|
|
14148
|
+
let c = "left";
|
|
14149
|
+
(t === "center" || t === "right") && (c = t);
|
|
14150
|
+
let { edge: l } = o, u = null;
|
|
14151
|
+
return c !== "center" && l === "left" && (u = i - s), c !== "center" && l === "right" && (u = s - r), c === "center" && l === "left" && (u = (a - s) * 2), c === "center" && l === "right" && (u = (s - a) * 2), u === null || !Number.isFinite(u) || u <= 0 ? null : u;
|
|
14152
|
+
}
|
|
14153
|
+
function uc({ bounds: e, originY: t, snap: n }) {
|
|
14154
|
+
let { top: r, bottom: i, centerY: a } = e, { candidate: o, guidePosition: s } = n;
|
|
14155
|
+
if (!o || s === null) return null;
|
|
14156
|
+
let c = "top";
|
|
14157
|
+
(t === "center" || t === "bottom") && (c = t);
|
|
14158
|
+
let { edge: l } = o, u = null;
|
|
14159
|
+
return c !== "center" && l === "top" && (u = i - s), c !== "center" && l === "bottom" && (u = s - r), c === "center" && l === "top" && (u = (a - s) * 2), c === "center" && l === "bottom" && (u = (s - a) * 2), u === null || !Number.isFinite(u) || u <= 0 ? null : u;
|
|
14160
|
+
}
|
|
14161
|
+
function dc({ target: e }) {
|
|
14162
|
+
let { width: t = 0, height: n = 0 } = e, r = t, i = n;
|
|
14163
|
+
if (e instanceof v) {
|
|
14164
|
+
let { paddingTop: a = 0, paddingRight: o = 0, paddingBottom: s = 0, paddingLeft: c = 0, strokeWidth: l = 0 } = e;
|
|
14165
|
+
r = t + c + o + l, i = n + a + s + l;
|
|
13489
14166
|
}
|
|
13490
|
-
|
|
13491
|
-
|
|
13492
|
-
|
|
13493
|
-
}
|
|
14167
|
+
return {
|
|
14168
|
+
width: r,
|
|
14169
|
+
height: i
|
|
14170
|
+
};
|
|
14171
|
+
}
|
|
14172
|
+
function fc({ desiredWidth: e, baseWidth: t, baseHeight: n, scaleY: r, angle: i }) {
|
|
14173
|
+
let a = i * Math.PI / 180, o = Math.abs(Math.cos(a)), s = Math.abs(Math.sin(a)), c = t * o, l = n * r * s;
|
|
14174
|
+
if (c <= 0) return null;
|
|
14175
|
+
let u = (e - l) / c;
|
|
14176
|
+
return !Number.isFinite(u) || u <= 0 ? null : u;
|
|
14177
|
+
}
|
|
14178
|
+
function pc({ desiredHeight: e, baseWidth: t, baseHeight: n, scaleX: r, angle: i }) {
|
|
14179
|
+
let a = i * Math.PI / 180, o = Math.abs(Math.cos(a)), s = Math.abs(Math.sin(a)), c = n * o, l = t * r * s;
|
|
14180
|
+
if (c <= 0) return null;
|
|
14181
|
+
let u = (e - l) / c;
|
|
14182
|
+
return !Number.isFinite(u) || u <= 0 ? null : u;
|
|
14183
|
+
}
|
|
14184
|
+
function mc({ target: e, boundsWidth: t }) {
|
|
14185
|
+
let { paddingLeft: n = 0, paddingRight: r = 0, strokeWidth: i = 0 } = e, a = t - n - r - i;
|
|
14186
|
+
return !Number.isFinite(a) || a <= 0 ? null : Math.max(1, Math.round(a));
|
|
13494
14187
|
}
|
|
13495
14188
|
//#endregion
|
|
13496
14189
|
//#region src/editor/snapping-manager/utils.ts
|
|
13497
|
-
var
|
|
14190
|
+
var hc = ({ anchors: e, bounds: t }) => {
|
|
13498
14191
|
let { left: n, right: r, centerX: i, top: a, bottom: o, centerY: s } = t;
|
|
13499
14192
|
e.vertical.push(n, i, r), e.horizontal.push(a, s, o);
|
|
13500
|
-
},
|
|
14193
|
+
}, gc = ({ bounds: e, type: t, primaryStart: n, primaryEnd: r }) => {
|
|
13501
14194
|
let i = [], a = n === "top" ? "left" : "top", o = r === "bottom" ? "right" : "bottom", s = [...e].sort((e, t) => e[n] - t[n]);
|
|
13502
14195
|
for (let e = 0; e < s.length; e += 1) {
|
|
13503
14196
|
let c = s[e], l = null, u = Infinity;
|
|
@@ -13518,35 +14211,35 @@ var ls = ({ anchors: e, bounds: t }) => {
|
|
|
13518
14211
|
});
|
|
13519
14212
|
}
|
|
13520
14213
|
return i;
|
|
13521
|
-
},
|
|
13522
|
-
vertical:
|
|
14214
|
+
}, _c = ({ bounds: e }) => ({
|
|
14215
|
+
vertical: gc({
|
|
13523
14216
|
bounds: e,
|
|
13524
14217
|
axis: "centerX",
|
|
13525
14218
|
type: "vertical",
|
|
13526
14219
|
primaryStart: "top",
|
|
13527
14220
|
primaryEnd: "bottom"
|
|
13528
14221
|
}),
|
|
13529
|
-
horizontal:
|
|
14222
|
+
horizontal: gc({
|
|
13530
14223
|
bounds: e,
|
|
13531
14224
|
axis: "centerY",
|
|
13532
14225
|
type: "horizontal",
|
|
13533
14226
|
primaryStart: "left",
|
|
13534
14227
|
primaryEnd: "right"
|
|
13535
14228
|
})
|
|
13536
|
-
}),
|
|
14229
|
+
}), vc = [
|
|
13537
14230
|
"montage-area",
|
|
13538
14231
|
"background",
|
|
13539
14232
|
"interaction-blocker"
|
|
13540
|
-
],
|
|
14233
|
+
], yc = ({ activeObject: t }) => {
|
|
13541
14234
|
let n = /* @__PURE__ */ new Set();
|
|
13542
14235
|
return t ? (n.add(t), t instanceof e && t.getObjects().forEach((e) => n.add(e)), n) : n;
|
|
13543
|
-
},
|
|
14236
|
+
}, bc = ({ object: e, excluded: t, ignoredIds: n = vc }) => {
|
|
13544
14237
|
if (t.has(e)) return !0;
|
|
13545
14238
|
let { visible: r = !0 } = e;
|
|
13546
14239
|
if (!r) return !0;
|
|
13547
14240
|
let { id: i } = e;
|
|
13548
14241
|
return !!(i && n.includes(i));
|
|
13549
|
-
},
|
|
14242
|
+
}, xc = class {
|
|
13550
14243
|
constructor({ editor: e }) {
|
|
13551
14244
|
this.anchors = {
|
|
13552
14245
|
vertical: [],
|
|
@@ -13590,7 +14283,7 @@ var ls = ({ anchors: e, bounds: t }) => {
|
|
|
13590
14283
|
target: t,
|
|
13591
14284
|
event: e
|
|
13592
14285
|
})) return;
|
|
13593
|
-
|
|
14286
|
+
cs({
|
|
13594
14287
|
target: t,
|
|
13595
14288
|
transform: n
|
|
13596
14289
|
}), !this.anchors.vertical.length && !this.anchors.horizontal.length && this._cacheAnchors({ activeObject: t });
|
|
@@ -13622,7 +14315,7 @@ var ls = ({ anchors: e, bounds: t }) => {
|
|
|
13622
14315
|
activeBounds: r,
|
|
13623
14316
|
deltaX: s.deltaX,
|
|
13624
14317
|
deltaY: s.deltaY
|
|
13625
|
-
}), c ||
|
|
14318
|
+
}), c || cs({
|
|
13626
14319
|
target: t,
|
|
13627
14320
|
transform: n
|
|
13628
14321
|
});
|
|
@@ -13633,76 +14326,118 @@ var ls = ({ anchors: e, bounds: t }) => {
|
|
|
13633
14326
|
threshold: i
|
|
13634
14327
|
});
|
|
13635
14328
|
}
|
|
13636
|
-
_handleObjectScaling(
|
|
13637
|
-
let { target:
|
|
13638
|
-
if (!
|
|
14329
|
+
_handleObjectScaling(e) {
|
|
14330
|
+
let { target: t, transform: n } = e;
|
|
14331
|
+
if (!t || !n) {
|
|
13639
14332
|
this._clearGuides();
|
|
13640
14333
|
return;
|
|
13641
14334
|
}
|
|
13642
|
-
let
|
|
14335
|
+
let r = ss({ target: t });
|
|
13643
14336
|
if (this._shouldAbortObjectScaling({
|
|
13644
|
-
target:
|
|
13645
|
-
transform:
|
|
13646
|
-
event:
|
|
13647
|
-
canApplyPixelScalingStep:
|
|
14337
|
+
target: t,
|
|
14338
|
+
transform: n,
|
|
14339
|
+
event: e,
|
|
14340
|
+
canApplyPixelScalingStep: r
|
|
13648
14341
|
})) {
|
|
13649
14342
|
this._clearGuides();
|
|
13650
14343
|
return;
|
|
13651
14344
|
}
|
|
13652
|
-
|
|
13653
|
-
|
|
14345
|
+
if (!this._hasObjectScaleChanged({
|
|
14346
|
+
target: t,
|
|
14347
|
+
transform: n
|
|
14348
|
+
})) {
|
|
13654
14349
|
this._clearGuides();
|
|
13655
14350
|
return;
|
|
13656
14351
|
}
|
|
13657
|
-
let {
|
|
13658
|
-
!
|
|
13659
|
-
|
|
13660
|
-
|
|
13661
|
-
|
|
14352
|
+
let { shouldSnapX: i, shouldSnapY: a, isCornerHandle: o } = Bs({ transform: n });
|
|
14353
|
+
if (!i && !a) {
|
|
14354
|
+
this._finishObjectScalingWithoutSnap({
|
|
14355
|
+
target: t,
|
|
14356
|
+
transform: n,
|
|
14357
|
+
canApplyPixelScalingStep: r
|
|
14358
|
+
});
|
|
13662
14359
|
return;
|
|
13663
14360
|
}
|
|
13664
|
-
let
|
|
13665
|
-
|
|
13666
|
-
|
|
13667
|
-
|
|
13668
|
-
|
|
13669
|
-
|
|
13670
|
-
|
|
13671
|
-
|
|
13672
|
-
|
|
13673
|
-
|
|
14361
|
+
let { anchors: s } = this, { vertical: c, horizontal: l } = s;
|
|
14362
|
+
!c.length && !l.length && this._cacheAnchors({ activeObject: t });
|
|
14363
|
+
let u = G({ object: t });
|
|
14364
|
+
if (!u) {
|
|
14365
|
+
this._finishObjectScalingWithoutSnap({
|
|
14366
|
+
target: t,
|
|
14367
|
+
transform: n,
|
|
14368
|
+
canApplyPixelScalingStep: r
|
|
14369
|
+
});
|
|
14370
|
+
return;
|
|
14371
|
+
}
|
|
14372
|
+
let d = 5 / (this.canvas.getZoom() || 1), { originX: f, originY: p, scaleX: m, scaleY: h } = Vs({
|
|
14373
|
+
target: t,
|
|
14374
|
+
transform: n
|
|
14375
|
+
}), g = Us({
|
|
14376
|
+
bounds: u,
|
|
14377
|
+
corner: n.corner,
|
|
14378
|
+
originX: f,
|
|
14379
|
+
originY: p,
|
|
14380
|
+
shouldSnapX: i,
|
|
14381
|
+
shouldSnapY: a,
|
|
14382
|
+
threshold: d,
|
|
13674
14383
|
anchors: this.anchors
|
|
13675
14384
|
});
|
|
13676
|
-
if (!
|
|
13677
|
-
this.
|
|
14385
|
+
if (!g) {
|
|
14386
|
+
this._finishObjectScalingWithoutSnap({
|
|
14387
|
+
target: t,
|
|
14388
|
+
transform: n,
|
|
14389
|
+
canApplyPixelScalingStep: r
|
|
14390
|
+
});
|
|
13678
14391
|
return;
|
|
13679
14392
|
}
|
|
13680
|
-
let
|
|
13681
|
-
target:
|
|
13682
|
-
bounds:
|
|
13683
|
-
originX:
|
|
13684
|
-
originY:
|
|
13685
|
-
scaleX:
|
|
13686
|
-
scaleY:
|
|
13687
|
-
|
|
13688
|
-
|
|
13689
|
-
|
|
14393
|
+
let _ = Ws({
|
|
14394
|
+
target: t,
|
|
14395
|
+
bounds: u,
|
|
14396
|
+
originX: f,
|
|
14397
|
+
originY: p,
|
|
14398
|
+
scaleX: m,
|
|
14399
|
+
scaleY: h,
|
|
14400
|
+
shouldUseUniformScaleSnap: Hs({
|
|
14401
|
+
target: t,
|
|
14402
|
+
event: e,
|
|
14403
|
+
isCornerHandle: o
|
|
14404
|
+
}),
|
|
14405
|
+
verticalSnap: g.verticalSnap,
|
|
14406
|
+
horizontalSnap: g.horizontalSnap
|
|
13690
14407
|
});
|
|
13691
|
-
if (!
|
|
13692
|
-
this.
|
|
14408
|
+
if (!_) {
|
|
14409
|
+
this._finishObjectScalingWithoutSnap({
|
|
14410
|
+
target: t,
|
|
14411
|
+
transform: n,
|
|
14412
|
+
canApplyPixelScalingStep: r
|
|
14413
|
+
});
|
|
13693
14414
|
return;
|
|
13694
14415
|
}
|
|
13695
14416
|
this._applyScaleUpdatePlan({
|
|
13696
|
-
target:
|
|
13697
|
-
transform:
|
|
13698
|
-
originX:
|
|
13699
|
-
originY:
|
|
13700
|
-
plan:
|
|
13701
|
-
}),
|
|
13702
|
-
target:
|
|
13703
|
-
transform:
|
|
13704
|
-
|
|
13705
|
-
|
|
14417
|
+
target: t,
|
|
14418
|
+
transform: n,
|
|
14419
|
+
originX: f,
|
|
14420
|
+
originY: p,
|
|
14421
|
+
plan: _
|
|
14422
|
+
}), r && fs({
|
|
14423
|
+
target: t,
|
|
14424
|
+
transform: n,
|
|
14425
|
+
preservePlacement: {
|
|
14426
|
+
placement: this.editor.canvasManager.getObjectPlacement({
|
|
14427
|
+
object: t,
|
|
14428
|
+
originX: f,
|
|
14429
|
+
originY: p
|
|
14430
|
+
}),
|
|
14431
|
+
applyPlacement: (e) => {
|
|
14432
|
+
this.editor.canvasManager.applyObjectPlacement({
|
|
14433
|
+
object: t,
|
|
14434
|
+
placement: e
|
|
14435
|
+
});
|
|
14436
|
+
}
|
|
14437
|
+
},
|
|
14438
|
+
snapGuards: _.snapGuards
|
|
14439
|
+
}), !this._shouldHideOverflowingCropFrameGuides({ target: t }) && this._applyGuides({
|
|
14440
|
+
guides: _.guides,
|
|
13706
14441
|
spacingGuides: []
|
|
13707
14442
|
});
|
|
13708
14443
|
}
|
|
@@ -13713,13 +14448,23 @@ var ls = ({ anchors: e, bounds: t }) => {
|
|
|
13713
14448
|
});
|
|
13714
14449
|
}
|
|
13715
14450
|
_shouldAbortObjectScaling({ target: e, transform: t, event: n, canApplyPixelScalingStep: r }) {
|
|
13716
|
-
return
|
|
14451
|
+
return this.editor.cropManager.isFrameSourceScaleClamped({
|
|
13717
14452
|
target: e,
|
|
13718
14453
|
transform: t
|
|
13719
|
-
}), !0) : (r &&
|
|
14454
|
+
}) ? (this._clearGuides(), !0) : n.e?.ctrlKey ? (this._clearGuides(), r && fs({
|
|
13720
14455
|
target: e,
|
|
13721
14456
|
transform: t
|
|
13722
|
-
}),
|
|
14457
|
+
}), !0) : !1;
|
|
14458
|
+
}
|
|
14459
|
+
_finishObjectScalingWithoutSnap({ target: e, transform: t, canApplyPixelScalingStep: n }) {
|
|
14460
|
+
n && fs({
|
|
14461
|
+
target: e,
|
|
14462
|
+
transform: t
|
|
14463
|
+
}), this._clearGuides();
|
|
14464
|
+
}
|
|
14465
|
+
_hasObjectScaleChanged({ target: e, transform: t }) {
|
|
14466
|
+
let n = t.original?.scaleX, r = t.original?.scaleY;
|
|
14467
|
+
return typeof n != "number" || typeof r != "number" ? !0 : e.scaleX !== n || e.scaleY !== r;
|
|
13723
14468
|
}
|
|
13724
14469
|
_shouldHideOverflowingCropFrameGuides({ target: e, clearSpacingContexts: t = !1 }) {
|
|
13725
14470
|
return this.editor.cropManager.isFrameOverflowingSource({ target: e }) ? (t && this._clearSpacingContexts(), this._clearGuides(), !0) : !1;
|
|
@@ -13775,75 +14520,53 @@ var ls = ({ anchors: e, bounds: t }) => {
|
|
|
13775
14520
|
placement: s
|
|
13776
14521
|
}), e.setCoords();
|
|
13777
14522
|
}
|
|
13778
|
-
applyTextResizingSnap({ target:
|
|
13779
|
-
if (!
|
|
13780
|
-
if (!
|
|
13781
|
-
this._clearGuides();
|
|
13782
|
-
return;
|
|
13783
|
-
}
|
|
13784
|
-
if (r?.ctrlKey) {
|
|
13785
|
-
this._clearGuides();
|
|
13786
|
-
return;
|
|
13787
|
-
}
|
|
13788
|
-
let { corner: i = "" } = n;
|
|
13789
|
-
if (!(i === "ml" || i === "mr")) {
|
|
14523
|
+
applyTextResizingSnap({ target: e, transform: t, event: n }) {
|
|
14524
|
+
if (!e || !(e instanceof v)) return;
|
|
14525
|
+
if (!t) {
|
|
13790
14526
|
this._clearGuides();
|
|
13791
14527
|
return;
|
|
13792
14528
|
}
|
|
13793
|
-
|
|
13794
|
-
!o.length && !s.length && this._cacheAnchors({ activeObject: t });
|
|
13795
|
-
let c = G({ object: t });
|
|
13796
|
-
if (!c) {
|
|
14529
|
+
if (n?.ctrlKey) {
|
|
13797
14530
|
this._clearGuides();
|
|
13798
14531
|
return;
|
|
13799
14532
|
}
|
|
13800
|
-
let {
|
|
13801
|
-
|
|
13802
|
-
originX: h,
|
|
13803
|
-
shouldSnapX: !0
|
|
13804
|
-
}), y = e._findAxisSnapCandidate({
|
|
13805
|
-
anchors: o,
|
|
13806
|
-
candidates: _,
|
|
13807
|
-
threshold: u
|
|
13808
|
-
}), { guidePosition: b } = y;
|
|
13809
|
-
if (b === null) {
|
|
14533
|
+
let { corner: r = "" } = t;
|
|
14534
|
+
if (!(r === "ml" || r === "mr")) {
|
|
13810
14535
|
this._clearGuides();
|
|
13811
14536
|
return;
|
|
13812
14537
|
}
|
|
13813
|
-
let
|
|
13814
|
-
|
|
13815
|
-
|
|
13816
|
-
|
|
13817
|
-
});
|
|
13818
|
-
if (x === null) {
|
|
14538
|
+
let { anchors: i } = this, { vertical: a, horizontal: o } = i;
|
|
14539
|
+
!a.length && !o.length && this._cacheAnchors({ activeObject: e });
|
|
14540
|
+
let s = G({ object: e });
|
|
14541
|
+
if (!s) {
|
|
13819
14542
|
this._clearGuides();
|
|
13820
14543
|
return;
|
|
13821
14544
|
}
|
|
13822
|
-
let
|
|
13823
|
-
target:
|
|
13824
|
-
|
|
14545
|
+
let { canvas: c } = this, l = 5 / (c.getZoom() || 1), { originX: u, originY: d } = t, { originX: f = "left", originY: p = "top" } = e, m = u ?? f, h = d ?? p, g = Gs({
|
|
14546
|
+
target: e,
|
|
14547
|
+
bounds: s,
|
|
14548
|
+
originX: m,
|
|
14549
|
+
verticalAnchors: a,
|
|
14550
|
+
threshold: l
|
|
13825
14551
|
});
|
|
13826
|
-
if (
|
|
14552
|
+
if (!g) {
|
|
13827
14553
|
this._clearGuides();
|
|
13828
14554
|
return;
|
|
13829
14555
|
}
|
|
13830
|
-
let { width:
|
|
13831
|
-
if (
|
|
13832
|
-
let
|
|
13833
|
-
object:
|
|
13834
|
-
originX:
|
|
13835
|
-
originY:
|
|
14556
|
+
let { guide: _, nextWidth: y } = g, { width: b = 0 } = e;
|
|
14557
|
+
if (y !== b) {
|
|
14558
|
+
let t = this.editor.canvasManager.getObjectPlacement({
|
|
14559
|
+
object: e,
|
|
14560
|
+
originX: m,
|
|
14561
|
+
originY: h
|
|
13836
14562
|
});
|
|
13837
|
-
|
|
13838
|
-
object:
|
|
13839
|
-
placement:
|
|
14563
|
+
e.set({ width: y }), this.editor.canvasManager.applyObjectPlacement({
|
|
14564
|
+
object: e,
|
|
14565
|
+
placement: t
|
|
13840
14566
|
});
|
|
13841
14567
|
}
|
|
13842
14568
|
this._applyGuides({
|
|
13843
|
-
guides: [
|
|
13844
|
-
type: "vertical",
|
|
13845
|
-
position: b
|
|
13846
|
-
}],
|
|
14569
|
+
guides: [_],
|
|
13847
14570
|
spacingGuides: []
|
|
13848
14571
|
});
|
|
13849
14572
|
}
|
|
@@ -13893,247 +14616,6 @@ var ls = ({ anchors: e, bounds: t }) => {
|
|
|
13893
14616
|
horizontal: null
|
|
13894
14617
|
};
|
|
13895
14618
|
}
|
|
13896
|
-
static _resolveScalingAxisState({ transform: e }) {
|
|
13897
|
-
let { corner: t = "", action: n = "" } = e, r = t === "ml" || t === "mr" || n === "scaleX", i = t === "mt" || t === "mb" || n === "scaleY", a = t === "tl" || t === "tr" || t === "bl" || t === "br" || n === "scale";
|
|
13898
|
-
return {
|
|
13899
|
-
isCornerHandle: a,
|
|
13900
|
-
shouldSnapX: r || a,
|
|
13901
|
-
shouldSnapY: i || a
|
|
13902
|
-
};
|
|
13903
|
-
}
|
|
13904
|
-
static _resolveScalingTransformState({ target: e, transform: t }) {
|
|
13905
|
-
let { originX: n, originY: r } = t, { originX: i = "left", originY: a = "top", scaleX: o = 1, scaleY: s = 1 } = e;
|
|
13906
|
-
return {
|
|
13907
|
-
originX: n ?? i,
|
|
13908
|
-
originY: r ?? a,
|
|
13909
|
-
scaleX: o,
|
|
13910
|
-
scaleY: s
|
|
13911
|
-
};
|
|
13912
|
-
}
|
|
13913
|
-
static _resolveScaleAxisSnaps({ bounds: t, originX: n, originY: r, shouldSnapX: i, shouldSnapY: a, threshold: o, anchors: s }) {
|
|
13914
|
-
let c = e._collectVerticalSnapCandidates({
|
|
13915
|
-
bounds: t,
|
|
13916
|
-
originX: n,
|
|
13917
|
-
shouldSnapX: i
|
|
13918
|
-
}), l = e._collectHorizontalSnapCandidates({
|
|
13919
|
-
bounds: t,
|
|
13920
|
-
originY: r,
|
|
13921
|
-
shouldSnapY: a
|
|
13922
|
-
}), u = e._findAxisSnapCandidate({
|
|
13923
|
-
anchors: s.vertical,
|
|
13924
|
-
candidates: c,
|
|
13925
|
-
threshold: o
|
|
13926
|
-
}), d = e._findAxisSnapCandidate({
|
|
13927
|
-
anchors: s.horizontal,
|
|
13928
|
-
candidates: l,
|
|
13929
|
-
threshold: o
|
|
13930
|
-
});
|
|
13931
|
-
return u.guidePosition === null && d.guidePosition === null ? null : {
|
|
13932
|
-
verticalSnap: u,
|
|
13933
|
-
horizontalSnap: d
|
|
13934
|
-
};
|
|
13935
|
-
}
|
|
13936
|
-
static _resolveScaleUpdatePlan({ target: t, bounds: n, originX: r, originY: i, scaleX: a, scaleY: o, isCornerHandle: s, verticalSnap: c, horizontalSnap: l }) {
|
|
13937
|
-
let { guidePosition: u } = c, { guidePosition: d } = l, f = u !== null, p = d !== null, m = [], h = null, g = null;
|
|
13938
|
-
if (s) {
|
|
13939
|
-
let t = e._resolveUniformScale({
|
|
13940
|
-
bounds: n,
|
|
13941
|
-
originX: r,
|
|
13942
|
-
originY: i,
|
|
13943
|
-
verticalSnap: c,
|
|
13944
|
-
horizontalSnap: l
|
|
13945
|
-
});
|
|
13946
|
-
if (t) {
|
|
13947
|
-
let { scaleFactor: e, guide: n } = t;
|
|
13948
|
-
h = a * e, g = o * e, m.push(n);
|
|
13949
|
-
}
|
|
13950
|
-
}
|
|
13951
|
-
if (!s) {
|
|
13952
|
-
let { angle: s = 0 } = t, { width: _, height: v } = e._resolveBaseDimensions({ target: t }), y = Math.abs(a) || 1, b = Math.abs(o) || 1;
|
|
13953
|
-
if (f) {
|
|
13954
|
-
let t = e._resolveDesiredWidth({
|
|
13955
|
-
bounds: n,
|
|
13956
|
-
originX: r,
|
|
13957
|
-
snap: c
|
|
13958
|
-
});
|
|
13959
|
-
if (t !== null) {
|
|
13960
|
-
let n = e._resolveScaleForWidth({
|
|
13961
|
-
desiredWidth: t,
|
|
13962
|
-
baseWidth: _,
|
|
13963
|
-
baseHeight: v,
|
|
13964
|
-
scaleY: b,
|
|
13965
|
-
angle: s
|
|
13966
|
-
});
|
|
13967
|
-
n !== null && (h = n * (a < 0 ? -1 : 1), m.push({
|
|
13968
|
-
type: "vertical",
|
|
13969
|
-
position: u
|
|
13970
|
-
}));
|
|
13971
|
-
}
|
|
13972
|
-
}
|
|
13973
|
-
if (p) {
|
|
13974
|
-
let t = e._resolveDesiredHeight({
|
|
13975
|
-
bounds: n,
|
|
13976
|
-
originY: i,
|
|
13977
|
-
snap: l
|
|
13978
|
-
});
|
|
13979
|
-
if (t !== null) {
|
|
13980
|
-
let n = e._resolveScaleForHeight({
|
|
13981
|
-
desiredHeight: t,
|
|
13982
|
-
baseWidth: _,
|
|
13983
|
-
baseHeight: v,
|
|
13984
|
-
scaleX: y,
|
|
13985
|
-
angle: s
|
|
13986
|
-
});
|
|
13987
|
-
n !== null && (g = n * (o < 0 ? -1 : 1), m.push({
|
|
13988
|
-
type: "horizontal",
|
|
13989
|
-
position: d
|
|
13990
|
-
}));
|
|
13991
|
-
}
|
|
13992
|
-
}
|
|
13993
|
-
}
|
|
13994
|
-
return h === null && g === null && !m.length ? null : {
|
|
13995
|
-
guides: m,
|
|
13996
|
-
nextScaleX: h,
|
|
13997
|
-
nextScaleY: g
|
|
13998
|
-
};
|
|
13999
|
-
}
|
|
14000
|
-
static _collectVerticalSnapCandidates({ bounds: e, originX: t, shouldSnapX: n }) {
|
|
14001
|
-
let r = [];
|
|
14002
|
-
if (!n) return r;
|
|
14003
|
-
let { left: i, right: a } = e, o = "left";
|
|
14004
|
-
return (t === "center" || t === "right") && (o = t), o === "left" && r.push({
|
|
14005
|
-
edge: "right",
|
|
14006
|
-
position: a
|
|
14007
|
-
}), o === "right" && r.push({
|
|
14008
|
-
edge: "left",
|
|
14009
|
-
position: i
|
|
14010
|
-
}), o === "center" && (r.push({
|
|
14011
|
-
edge: "left",
|
|
14012
|
-
position: i
|
|
14013
|
-
}), r.push({
|
|
14014
|
-
edge: "right",
|
|
14015
|
-
position: a
|
|
14016
|
-
})), r;
|
|
14017
|
-
}
|
|
14018
|
-
static _collectHorizontalSnapCandidates({ bounds: e, originY: t, shouldSnapY: n }) {
|
|
14019
|
-
let r = [];
|
|
14020
|
-
if (!n) return r;
|
|
14021
|
-
let { top: i, bottom: a } = e, o = "top";
|
|
14022
|
-
return (t === "center" || t === "bottom") && (o = t), o === "top" && r.push({
|
|
14023
|
-
edge: "bottom",
|
|
14024
|
-
position: a
|
|
14025
|
-
}), o === "bottom" && r.push({
|
|
14026
|
-
edge: "top",
|
|
14027
|
-
position: i
|
|
14028
|
-
}), o === "center" && (r.push({
|
|
14029
|
-
edge: "top",
|
|
14030
|
-
position: i
|
|
14031
|
-
}), r.push({
|
|
14032
|
-
edge: "bottom",
|
|
14033
|
-
position: a
|
|
14034
|
-
})), r;
|
|
14035
|
-
}
|
|
14036
|
-
static _findAxisSnapCandidate({ anchors: e, candidates: t, threshold: n }) {
|
|
14037
|
-
let r = 0, i = n + 1, a = null, o = null;
|
|
14038
|
-
for (let s of t) {
|
|
14039
|
-
let { position: t } = s;
|
|
14040
|
-
for (let c of e) {
|
|
14041
|
-
let e = Math.abs(c - t);
|
|
14042
|
-
e > n || e >= i || (r = c - t, i = e, a = c, o = s);
|
|
14043
|
-
}
|
|
14044
|
-
}
|
|
14045
|
-
return {
|
|
14046
|
-
delta: r,
|
|
14047
|
-
guidePosition: a,
|
|
14048
|
-
candidate: o
|
|
14049
|
-
};
|
|
14050
|
-
}
|
|
14051
|
-
static _resolveUniformScale({ bounds: t, originX: n, originY: r, verticalSnap: i, horizontalSnap: a }) {
|
|
14052
|
-
let { left: o, right: s, top: c, bottom: l } = t, u = s - o, d = l - c, { guidePosition: f, delta: p } = i, { guidePosition: m, delta: h } = a, g = null, _ = null;
|
|
14053
|
-
if (f !== null && u > 0) {
|
|
14054
|
-
let r = e._resolveDesiredWidth({
|
|
14055
|
-
bounds: t,
|
|
14056
|
-
originX: n,
|
|
14057
|
-
snap: i
|
|
14058
|
-
});
|
|
14059
|
-
if (r !== null) {
|
|
14060
|
-
let e = r / u;
|
|
14061
|
-
Number.isFinite(e) && e > 0 && (g = e);
|
|
14062
|
-
}
|
|
14063
|
-
}
|
|
14064
|
-
if (m !== null && d > 0) {
|
|
14065
|
-
let n = e._resolveDesiredHeight({
|
|
14066
|
-
bounds: t,
|
|
14067
|
-
originY: r,
|
|
14068
|
-
snap: a
|
|
14069
|
-
});
|
|
14070
|
-
if (n !== null) {
|
|
14071
|
-
let e = n / d;
|
|
14072
|
-
Number.isFinite(e) && e > 0 && (_ = e);
|
|
14073
|
-
}
|
|
14074
|
-
}
|
|
14075
|
-
let v = null;
|
|
14076
|
-
if (g !== null && _ === null && (v = "x"), _ !== null && g === null && (v = "y"), g !== null && _ !== null) {
|
|
14077
|
-
let e = Math.abs(p), t = Math.abs(h);
|
|
14078
|
-
e <= t && (v = "x"), e > t && (v = "y");
|
|
14079
|
-
}
|
|
14080
|
-
return v === "x" && g !== null && f !== null ? {
|
|
14081
|
-
scaleFactor: g,
|
|
14082
|
-
guide: {
|
|
14083
|
-
type: "vertical",
|
|
14084
|
-
position: f
|
|
14085
|
-
}
|
|
14086
|
-
} : v === "y" && _ !== null && m !== null ? {
|
|
14087
|
-
scaleFactor: _,
|
|
14088
|
-
guide: {
|
|
14089
|
-
type: "horizontal",
|
|
14090
|
-
position: m
|
|
14091
|
-
}
|
|
14092
|
-
} : null;
|
|
14093
|
-
}
|
|
14094
|
-
static _resolveDesiredWidth({ bounds: e, originX: t, snap: n }) {
|
|
14095
|
-
let { left: r, right: i, centerX: a } = e, { candidate: o, guidePosition: s } = n;
|
|
14096
|
-
if (!o || s === null) return null;
|
|
14097
|
-
let c = "left";
|
|
14098
|
-
(t === "center" || t === "right") && (c = t);
|
|
14099
|
-
let { edge: l } = o, u = null;
|
|
14100
|
-
return c === "left" && l === "right" && (u = s - r), c === "right" && l === "left" && (u = i - s), c === "center" && l === "left" && (u = (a - s) * 2), c === "center" && l === "right" && (u = (s - a) * 2), u === null || !Number.isFinite(u) || u <= 0 ? null : u;
|
|
14101
|
-
}
|
|
14102
|
-
static _resolveDesiredHeight({ bounds: e, originY: t, snap: n }) {
|
|
14103
|
-
let { top: r, bottom: i, centerY: a } = e, { candidate: o, guidePosition: s } = n;
|
|
14104
|
-
if (!o || s === null) return null;
|
|
14105
|
-
let c = "top";
|
|
14106
|
-
(t === "center" || t === "bottom") && (c = t);
|
|
14107
|
-
let { edge: l } = o, u = null;
|
|
14108
|
-
return c === "top" && l === "bottom" && (u = s - r), c === "bottom" && l === "top" && (u = i - s), c === "center" && l === "top" && (u = (a - s) * 2), c === "center" && l === "bottom" && (u = (s - a) * 2), u === null || !Number.isFinite(u) || u <= 0 ? null : u;
|
|
14109
|
-
}
|
|
14110
|
-
static _resolveBaseDimensions({ target: e }) {
|
|
14111
|
-
let { width: t = 0, height: n = 0 } = e, r = t, i = n;
|
|
14112
|
-
if (e instanceof v) {
|
|
14113
|
-
let { paddingTop: a = 0, paddingRight: o = 0, paddingBottom: s = 0, paddingLeft: c = 0, strokeWidth: l = 0 } = e;
|
|
14114
|
-
r = t + c + o + l, i = n + a + s + l;
|
|
14115
|
-
}
|
|
14116
|
-
return {
|
|
14117
|
-
width: r,
|
|
14118
|
-
height: i
|
|
14119
|
-
};
|
|
14120
|
-
}
|
|
14121
|
-
static _resolveScaleForWidth({ desiredWidth: e, baseWidth: t, baseHeight: n, scaleY: r, angle: i }) {
|
|
14122
|
-
let a = i * Math.PI / 180, o = Math.abs(Math.cos(a)), s = Math.abs(Math.sin(a)), c = t * o, l = n * r * s;
|
|
14123
|
-
if (c <= 0) return null;
|
|
14124
|
-
let u = (e - l) / c;
|
|
14125
|
-
return !Number.isFinite(u) || u <= 0 ? null : u;
|
|
14126
|
-
}
|
|
14127
|
-
static _resolveScaleForHeight({ desiredHeight: e, baseWidth: t, baseHeight: n, scaleX: r, angle: i }) {
|
|
14128
|
-
let a = i * Math.PI / 180, o = Math.abs(Math.cos(a)), s = Math.abs(Math.sin(a)), c = n * o, l = t * r * s;
|
|
14129
|
-
if (c <= 0) return null;
|
|
14130
|
-
let u = (e - l) / c;
|
|
14131
|
-
return !Number.isFinite(u) || u <= 0 ? null : u;
|
|
14132
|
-
}
|
|
14133
|
-
static _resolveTextWidthForBounds({ target: e, boundsWidth: t }) {
|
|
14134
|
-
let { paddingLeft: n = 0, paddingRight: r = 0, strokeWidth: i = 0 } = e, a = t - n - r - i;
|
|
14135
|
-
return !Number.isFinite(a) || a <= 0 ? null : Math.max(1, Math.round(a));
|
|
14136
|
-
}
|
|
14137
14619
|
_cacheAnchors({ activeObject: e }) {
|
|
14138
14620
|
let t = this._collectTargets({ activeObject: e }), n = {
|
|
14139
14621
|
vertical: [],
|
|
@@ -14141,14 +14623,14 @@ var ls = ({ anchors: e, bounds: t }) => {
|
|
|
14141
14623
|
}, r = [];
|
|
14142
14624
|
for (let e of t) {
|
|
14143
14625
|
let t = G({ object: e });
|
|
14144
|
-
t && (
|
|
14626
|
+
t && (hc({
|
|
14145
14627
|
anchors: n,
|
|
14146
14628
|
bounds: t
|
|
14147
14629
|
}), r.push(t));
|
|
14148
14630
|
}
|
|
14149
14631
|
let { montageArea: i } = this.editor, a = G({ object: i });
|
|
14150
14632
|
if (a) {
|
|
14151
|
-
|
|
14633
|
+
hc({
|
|
14152
14634
|
anchors: n,
|
|
14153
14635
|
bounds: a
|
|
14154
14636
|
});
|
|
@@ -14160,12 +14642,12 @@ var ls = ({ anchors: e, bounds: t }) => {
|
|
|
14160
14642
|
bottom: i
|
|
14161
14643
|
};
|
|
14162
14644
|
} else this.guideBounds = this._calculateViewportBounds();
|
|
14163
|
-
this.anchors = n, this.spacingPatterns =
|
|
14645
|
+
this.anchors = n, this.spacingPatterns = _c({ bounds: r }), this.cachedTargetBounds = r;
|
|
14164
14646
|
}
|
|
14165
14647
|
_collectTargets({ activeObject: e }) {
|
|
14166
|
-
let t =
|
|
14648
|
+
let t = yc({ activeObject: e }), n = [];
|
|
14167
14649
|
return this.canvas.forEachObject((e) => {
|
|
14168
|
-
|
|
14650
|
+
bc({
|
|
14169
14651
|
object: e,
|
|
14170
14652
|
excluded: t
|
|
14171
14653
|
}) || n.push(e);
|
|
@@ -14188,7 +14670,7 @@ var ls = ({ anchors: e, bounds: t }) => {
|
|
|
14188
14670
|
bottom: (r - s) / a
|
|
14189
14671
|
};
|
|
14190
14672
|
}
|
|
14191
|
-
},
|
|
14673
|
+
}, Sc = "#3D8BF4", Cc = class e {
|
|
14192
14674
|
constructor({ editor: e }) {
|
|
14193
14675
|
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();
|
|
14194
14676
|
}
|
|
@@ -14281,8 +14763,8 @@ var ls = ({ anchors: e, bounds: t }) => {
|
|
|
14281
14763
|
this.isTargetMontageArea = l, this.activeGuides = d, this._hideToolbar(), n.requestRenderAll();
|
|
14282
14764
|
}
|
|
14283
14765
|
static _resolveTarget({ event: e, activeObject: t }) {
|
|
14284
|
-
let { target: n } = e, r =
|
|
14285
|
-
return n && !
|
|
14766
|
+
let { target: n } = e, r = yc({ activeObject: t });
|
|
14767
|
+
return n && !bc({
|
|
14286
14768
|
object: n,
|
|
14287
14769
|
excluded: r
|
|
14288
14770
|
}) ? n : null;
|
|
@@ -14399,7 +14881,7 @@ var ls = ({ anchors: e, bounds: t }) => {
|
|
|
14399
14881
|
let { canvas: e } = this, t = e.getSelectionContext();
|
|
14400
14882
|
if (!t) return;
|
|
14401
14883
|
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;
|
|
14402
|
-
t.save(), Array.isArray(n) && t.transform(...n), t.lineWidth = 1 / r, t.strokeStyle =
|
|
14884
|
+
t.save(), Array.isArray(n) && t.transform(...n), t.lineWidth = 1 / r, t.strokeStyle = Sc, t.setLineDash([]);
|
|
14403
14885
|
for (let e of this.activeGuides) {
|
|
14404
14886
|
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;
|
|
14405
14887
|
t.beginPath(), n === "vertical" ? (t.moveTo(i, a), t.lineTo(i, c)) : (t.moveTo(a, i), t.lineTo(c, i)), t.stroke(), ns({
|
|
@@ -14410,7 +14892,7 @@ var ls = ({ anchors: e, bounds: t }) => {
|
|
|
14410
14892
|
end: c,
|
|
14411
14893
|
text: To({ distance: l }).toString(),
|
|
14412
14894
|
zoom: r,
|
|
14413
|
-
color:
|
|
14895
|
+
color: Sc,
|
|
14414
14896
|
lineWidth: 1,
|
|
14415
14897
|
offsetAlongAxis: d,
|
|
14416
14898
|
offsetPerpendicular: 0
|
|
@@ -14428,13 +14910,13 @@ var ls = ({ anchors: e, bounds: t }) => {
|
|
|
14428
14910
|
let { toolbar: e } = this.editor;
|
|
14429
14911
|
e?.showAfterTemporary?.(), this.isToolbarHidden = !1;
|
|
14430
14912
|
}
|
|
14431
|
-
},
|
|
14432
|
-
function
|
|
14433
|
-
return t ?
|
|
14913
|
+
}, wc = 16, Tc = 16, Ec = Wt, Dc = Gt, Oc = wc;
|
|
14914
|
+
function kc({ sourceSize: e, size: t, aspectRatio: n, allowOverflow: r }) {
|
|
14915
|
+
return t ? Ic({
|
|
14434
14916
|
size: t,
|
|
14435
14917
|
sourceSize: e,
|
|
14436
14918
|
allowOverflow: r
|
|
14437
|
-
}) : n ?
|
|
14919
|
+
}) : n ? Fc({
|
|
14438
14920
|
aspectRatio: n,
|
|
14439
14921
|
sourceSize: e
|
|
14440
14922
|
}) : {
|
|
@@ -14448,29 +14930,29 @@ function Z({ source: e }) {
|
|
|
14448
14930
|
height: e.height
|
|
14449
14931
|
};
|
|
14450
14932
|
}
|
|
14451
|
-
function
|
|
14933
|
+
function Ac({ source: e, frame: t }) {
|
|
14452
14934
|
let n = e.calcTransformMatrix(), r = w.invertTransform(n), i = t.calcTransformMatrix();
|
|
14453
|
-
return
|
|
14935
|
+
return Nc({ points: Pc({ frame: t }).map((e) => e.transform(i).transform(r)) });
|
|
14454
14936
|
}
|
|
14455
|
-
function
|
|
14456
|
-
|
|
14937
|
+
function jc({ source: e, frame: t }) {
|
|
14938
|
+
Lc({
|
|
14457
14939
|
source: e,
|
|
14458
14940
|
frame: t
|
|
14459
|
-
}),
|
|
14941
|
+
}), zc({
|
|
14460
14942
|
source: e,
|
|
14461
14943
|
frame: t
|
|
14462
14944
|
});
|
|
14463
14945
|
}
|
|
14464
|
-
function
|
|
14465
|
-
|
|
14946
|
+
function Mc({ source: e, frame: t }) {
|
|
14947
|
+
Rc({
|
|
14466
14948
|
source: e,
|
|
14467
14949
|
frame: t
|
|
14468
|
-
}),
|
|
14950
|
+
}), zc({
|
|
14469
14951
|
source: e,
|
|
14470
14952
|
frame: t
|
|
14471
14953
|
});
|
|
14472
14954
|
}
|
|
14473
|
-
function
|
|
14955
|
+
function Nc({ points: e }) {
|
|
14474
14956
|
let t = Math.min(...e.map((e) => e.x)), n = Math.min(...e.map((e) => e.y)), r = Math.max(...e.map((e) => e.x)), i = Math.max(...e.map((e) => e.y));
|
|
14475
14957
|
return {
|
|
14476
14958
|
left: t,
|
|
@@ -14479,7 +14961,7 @@ function Ds({ points: e }) {
|
|
|
14479
14961
|
height: i - n
|
|
14480
14962
|
};
|
|
14481
14963
|
}
|
|
14482
|
-
function
|
|
14964
|
+
function Pc({ frame: e }) {
|
|
14483
14965
|
let t = e.width / 2, n = e.height / 2;
|
|
14484
14966
|
return [
|
|
14485
14967
|
new m(-t, -n),
|
|
@@ -14488,7 +14970,7 @@ function Os({ frame: e }) {
|
|
|
14488
14970
|
new m(-t, n)
|
|
14489
14971
|
];
|
|
14490
14972
|
}
|
|
14491
|
-
function
|
|
14973
|
+
function Fc({ sourceSize: e, aspectRatio: t }) {
|
|
14492
14974
|
let n = e.width / e.height, r = t.width / t.height;
|
|
14493
14975
|
return r >= n ? {
|
|
14494
14976
|
width: e.width,
|
|
@@ -14498,49 +14980,49 @@ function ks({ sourceSize: e, aspectRatio: t }) {
|
|
|
14498
14980
|
height: e.height
|
|
14499
14981
|
};
|
|
14500
14982
|
}
|
|
14501
|
-
function
|
|
14502
|
-
let r = n ?
|
|
14983
|
+
function Ic({ size: e, sourceSize: t, allowOverflow: n }) {
|
|
14984
|
+
let r = n ? Ec : Math.min(t.width, Ec), i = n ? Dc : Math.min(t.height, Dc);
|
|
14503
14985
|
return {
|
|
14504
|
-
width:
|
|
14986
|
+
width: Uc({
|
|
14505
14987
|
value: e.width,
|
|
14506
|
-
min:
|
|
14988
|
+
min: wc,
|
|
14507
14989
|
max: r
|
|
14508
14990
|
}),
|
|
14509
|
-
height:
|
|
14991
|
+
height: Uc({
|
|
14510
14992
|
value: e.height,
|
|
14511
|
-
min:
|
|
14993
|
+
min: Tc,
|
|
14512
14994
|
max: i
|
|
14513
14995
|
})
|
|
14514
14996
|
};
|
|
14515
14997
|
}
|
|
14516
|
-
function
|
|
14517
|
-
let n =
|
|
14998
|
+
function Lc({ source: e, frame: t }) {
|
|
14999
|
+
let n = Ac({
|
|
14518
15000
|
source: e,
|
|
14519
15001
|
frame: t
|
|
14520
|
-
}), r = Z({ source: e }), i = r.width / Math.max(n.width,
|
|
15002
|
+
}), r = Z({ source: e }), i = r.width / Math.max(n.width, wc), a = r.height / Math.max(n.height, Tc);
|
|
14521
15003
|
i < 1 && t.set({ scaleX: (t.scaleX ?? 1) * i }), a < 1 && t.set({ scaleY: (t.scaleY ?? 1) * a }), t.setCoords();
|
|
14522
15004
|
}
|
|
14523
|
-
function
|
|
14524
|
-
let n =
|
|
15005
|
+
function Rc({ source: e, frame: t }) {
|
|
15006
|
+
let n = Ac({
|
|
14525
15007
|
source: e,
|
|
14526
15008
|
frame: t
|
|
14527
|
-
}), r = Z({ source: e }), i = r.width / Math.max(n.width,
|
|
15009
|
+
}), r = Z({ source: e }), i = r.width / Math.max(n.width, wc), a = r.height / Math.max(n.height, Tc), o = Math.min(i, a);
|
|
14528
15010
|
o < 1 && t.set({
|
|
14529
15011
|
scaleX: (t.scaleX ?? 1) * o,
|
|
14530
15012
|
scaleY: (t.scaleY ?? 1) * o
|
|
14531
15013
|
}), t.setCoords();
|
|
14532
15014
|
}
|
|
14533
|
-
function
|
|
14534
|
-
let n =
|
|
15015
|
+
function zc({ source: e, frame: t }) {
|
|
15016
|
+
let n = Ac({
|
|
14535
15017
|
source: e,
|
|
14536
15018
|
frame: t
|
|
14537
|
-
}), r =
|
|
15019
|
+
}), r = Bc({ sourceSize: Z({ source: e }) }), i = Vc({ rect: n }), a = Hc({
|
|
14538
15020
|
rect: n,
|
|
14539
15021
|
sourceBounds: r
|
|
14540
15022
|
}), o = new m(i.x + a.x, i.y + a.y).transform(e.calcTransformMatrix());
|
|
14541
15023
|
t.setPositionByOrigin(o, "center", "center"), t.setCoords();
|
|
14542
15024
|
}
|
|
14543
|
-
function
|
|
15025
|
+
function Bc({ sourceSize: e }) {
|
|
14544
15026
|
return {
|
|
14545
15027
|
left: -e.width / 2,
|
|
14546
15028
|
top: -e.height / 2,
|
|
@@ -14548,19 +15030,19 @@ function Ps({ sourceSize: e }) {
|
|
|
14548
15030
|
height: e.height
|
|
14549
15031
|
};
|
|
14550
15032
|
}
|
|
14551
|
-
function
|
|
15033
|
+
function Vc({ rect: e }) {
|
|
14552
15034
|
return new m(e.left + e.width / 2, e.top + e.height / 2);
|
|
14553
15035
|
}
|
|
14554
|
-
function
|
|
15036
|
+
function Hc({ rect: e, sourceBounds: t }) {
|
|
14555
15037
|
let n = t.left + t.width, r = t.top + t.height, i = 0, a = 0;
|
|
14556
15038
|
return e.left < t.left && (i = t.left - e.left), e.left + e.width > n && (i = n - e.left - e.width), e.top < t.top && (a = t.top - e.top), e.top + e.height > r && (a = r - e.top - e.height), new m(i, a);
|
|
14557
15039
|
}
|
|
14558
|
-
function
|
|
15040
|
+
function Uc({ value: e, min: t, max: n }) {
|
|
14559
15041
|
return Math.max(t, Math.min(n, e));
|
|
14560
15042
|
}
|
|
14561
15043
|
//#endregion
|
|
14562
15044
|
//#region src/editor/crop-manager/domain/crop-frame-size.ts
|
|
14563
|
-
function
|
|
15045
|
+
function Wc({ frame: e, scaleX: t = e.scaleX ?? 1, scaleY: n = e.scaleY ?? 1 }) {
|
|
14564
15046
|
let r = Math.abs(e.cropSourceScaleX ?? 1) || 1, i = Math.abs(e.cropSourceScaleY ?? 1) || 1;
|
|
14565
15047
|
return {
|
|
14566
15048
|
width: Math.max(1, e.width * Math.abs(t) / r),
|
|
@@ -14569,152 +15051,166 @@ function Rs({ frame: e, scaleX: t = e.scaleX ?? 1, scaleY: n = e.scaleY ?? 1 })
|
|
|
14569
15051
|
}
|
|
14570
15052
|
//#endregion
|
|
14571
15053
|
//#region src/editor/crop-manager/domain/crop-proportional-source-scale.ts
|
|
14572
|
-
var
|
|
14573
|
-
function
|
|
14574
|
-
let i =
|
|
15054
|
+
var Gc = 1;
|
|
15055
|
+
function Kc({ sourceSize: e, startRect: t, anchorX: n, anchorY: r }) {
|
|
15056
|
+
let i = Math.max(1, t.width), a = Math.max(1, t.height);
|
|
15057
|
+
if (qc({
|
|
15058
|
+
sourceSize: e,
|
|
15059
|
+
rect: t,
|
|
15060
|
+
axis: "x"
|
|
15061
|
+
}) || qc({
|
|
15062
|
+
sourceSize: e,
|
|
15063
|
+
rect: t,
|
|
15064
|
+
axis: "y"
|
|
15065
|
+
})) return 1;
|
|
15066
|
+
let o = Jc({
|
|
14575
15067
|
sourceSize: e,
|
|
14576
15068
|
rect: t,
|
|
14577
15069
|
axis: "x",
|
|
14578
15070
|
anchor: n
|
|
14579
|
-
}),
|
|
15071
|
+
}), s = Jc({
|
|
14580
15072
|
sourceSize: e,
|
|
14581
15073
|
rect: t,
|
|
14582
15074
|
axis: "y",
|
|
14583
15075
|
anchor: r
|
|
14584
|
-
}),
|
|
14585
|
-
return (u - 1) * Math.min(
|
|
15076
|
+
}), c = Math.min(o / i, s / a), l = Math.min(e.width / i, e.height / a), u = Math.min(c, l);
|
|
15077
|
+
return (u - 1) * Math.min(i, a) <= Gc ? 1 : Math.max(1, u);
|
|
15078
|
+
}
|
|
15079
|
+
function qc({ sourceSize: e, rect: t, axis: n }) {
|
|
15080
|
+
let r = n === "x" ? e.width : e.height, i = n === "x" ? t.width : t.height;
|
|
15081
|
+
return Math.round(i) >= Math.round(r);
|
|
14586
15082
|
}
|
|
14587
|
-
function
|
|
15083
|
+
function Jc({ sourceSize: e, rect: t, axis: n, anchor: r }) {
|
|
14588
15084
|
let i = n === "x" ? e.width : e.height, a = n === "x" ? t.left : t.top, o = n === "x" ? t.width : t.height, s = -i / 2, c = i / 2, l = a + o, u = a + o / 2;
|
|
14589
15085
|
return r === "min" ? c - a : r === "max" ? l - s : Math.min(u - s, c - u) * 2;
|
|
14590
15086
|
}
|
|
14591
15087
|
//#endregion
|
|
14592
15088
|
//#region src/editor/crop-manager/interaction/crop-controls.ts
|
|
14593
|
-
var
|
|
15089
|
+
var Yc = .001, Xc = [
|
|
14594
15090
|
"tl",
|
|
14595
15091
|
"tr",
|
|
14596
15092
|
"bl",
|
|
14597
15093
|
"br"
|
|
14598
|
-
],
|
|
15094
|
+
], Zc = [
|
|
14599
15095
|
"ml",
|
|
14600
15096
|
"mr",
|
|
14601
15097
|
"mt",
|
|
14602
15098
|
"mb"
|
|
14603
|
-
],
|
|
15099
|
+
], Qc = {
|
|
14604
15100
|
ml: "w-resize",
|
|
14605
15101
|
mr: "e-resize",
|
|
14606
15102
|
mt: "n-resize",
|
|
14607
15103
|
mb: "s-resize"
|
|
14608
15104
|
};
|
|
14609
|
-
function
|
|
15105
|
+
function $c({ transform: e }) {
|
|
14610
15106
|
let { originX: t, originY: n } = e;
|
|
14611
15107
|
return (t === "center" || t === .5) && (n === "center" || n === .5);
|
|
14612
15108
|
}
|
|
14613
|
-
function
|
|
15109
|
+
function el({ transform: e, x: t, y: n }) {
|
|
14614
15110
|
let r = e, { target: i } = r, { scaleX: a = 1, scaleY: o = 1 } = i;
|
|
14615
|
-
if (
|
|
15111
|
+
if (il({
|
|
14616
15112
|
transform: r,
|
|
14617
15113
|
x: t,
|
|
14618
15114
|
y: n
|
|
14619
|
-
})) return
|
|
15115
|
+
})) return al({ transform: r }), !0;
|
|
14620
15116
|
let s = x.getLocalPoint(r, r.originX, r.originY, t, n);
|
|
14621
|
-
return
|
|
15117
|
+
return sl({ transform: r }), dl({
|
|
14622
15118
|
transform: r,
|
|
14623
15119
|
localPoint: s
|
|
14624
15120
|
}), a !== i.scaleX || o !== i.scaleY;
|
|
14625
15121
|
}
|
|
14626
|
-
function
|
|
15122
|
+
function tl({ transform: e, x: t, y: n }) {
|
|
14627
15123
|
let r = e, { target: i } = r, { scaleX: a = 1, scaleY: o = 1 } = i;
|
|
14628
|
-
if (
|
|
15124
|
+
if (il({
|
|
14629
15125
|
transform: r,
|
|
14630
15126
|
x: t,
|
|
14631
15127
|
y: n
|
|
14632
|
-
})) return
|
|
15128
|
+
})) return al({ transform: r }), !0;
|
|
14633
15129
|
let s = x.getLocalPoint(r, r.originX, r.originY, t, n);
|
|
14634
|
-
return
|
|
15130
|
+
return sl({ transform: r }), hl({
|
|
14635
15131
|
transform: r,
|
|
14636
15132
|
localPoint: s
|
|
14637
15133
|
}), a !== i.scaleX || o !== i.scaleY;
|
|
14638
15134
|
}
|
|
14639
|
-
function
|
|
15135
|
+
function nl({ transform: e, axis: t, x: n, y: r }) {
|
|
14640
15136
|
let i = e, { target: a } = i, o = t === "x" ? a.scaleX ?? 1 : a.scaleY ?? 1;
|
|
14641
|
-
if (
|
|
15137
|
+
if (il({
|
|
14642
15138
|
transform: i,
|
|
14643
15139
|
x: n,
|
|
14644
15140
|
y: r
|
|
14645
|
-
})) return
|
|
15141
|
+
})) return ol({
|
|
14646
15142
|
transform: i,
|
|
14647
15143
|
axis: t
|
|
14648
15144
|
}), !0;
|
|
14649
15145
|
let s = x.getLocalPoint(i, i.originX, i.originY, n, r);
|
|
14650
|
-
return
|
|
15146
|
+
return sl({ transform: i }), fl({
|
|
14651
15147
|
transform: i,
|
|
14652
15148
|
axis: t,
|
|
14653
15149
|
localPoint: s
|
|
14654
15150
|
}), t === "x" ? o !== a.scaleX : o !== a.scaleY;
|
|
14655
15151
|
}
|
|
14656
|
-
function
|
|
15152
|
+
function rl({ transform: e, axis: t, x: n, y: r }) {
|
|
14657
15153
|
let i = e, { target: a } = i, { scaleX: o = 1, scaleY: s = 1 } = a;
|
|
14658
|
-
if (
|
|
15154
|
+
if (il({
|
|
14659
15155
|
transform: i,
|
|
14660
15156
|
x: n,
|
|
14661
15157
|
y: r
|
|
14662
|
-
})) return
|
|
15158
|
+
})) return al({ transform: i }), !0;
|
|
14663
15159
|
let c = x.getLocalPoint(i, i.originX, i.originY, n, r);
|
|
14664
|
-
return
|
|
15160
|
+
return sl({ transform: i }), pl({
|
|
14665
15161
|
transform: i,
|
|
14666
15162
|
axis: t,
|
|
14667
15163
|
localPoint: c
|
|
14668
15164
|
}), o !== a.scaleX || s !== a.scaleY;
|
|
14669
15165
|
}
|
|
14670
|
-
function
|
|
14671
|
-
return Math.abs(t - e.ex) <=
|
|
15166
|
+
function il({ transform: e, x: t, y: n }) {
|
|
15167
|
+
return Math.abs(t - e.ex) <= Yc && Math.abs(n - e.ey) <= Yc;
|
|
14672
15168
|
}
|
|
14673
|
-
function
|
|
15169
|
+
function al({ transform: e }) {
|
|
14674
15170
|
e.target.set({
|
|
14675
15171
|
scaleX: e.original.scaleX,
|
|
14676
15172
|
scaleY: e.original.scaleY
|
|
14677
15173
|
});
|
|
14678
15174
|
}
|
|
14679
|
-
function
|
|
15175
|
+
function ol({ transform: e, axis: t }) {
|
|
14680
15176
|
if (t === "x") {
|
|
14681
15177
|
e.target.set("scaleX", e.original.scaleX);
|
|
14682
15178
|
return;
|
|
14683
15179
|
}
|
|
14684
15180
|
e.target.set("scaleY", e.original.scaleY);
|
|
14685
15181
|
}
|
|
14686
|
-
function
|
|
14687
|
-
let { signX: t, signY: n } =
|
|
15182
|
+
function sl({ transform: e }) {
|
|
15183
|
+
let { signX: t, signY: n } = cl({ controlKey: e.corner });
|
|
14688
15184
|
e.signX === void 0 && (e.signX = t), e.signY === void 0 && (e.signY = n);
|
|
14689
15185
|
}
|
|
14690
|
-
function
|
|
15186
|
+
function cl({ controlKey: e }) {
|
|
14691
15187
|
return {
|
|
14692
|
-
signX:
|
|
14693
|
-
signY:
|
|
15188
|
+
signX: ll({ controlKey: e }),
|
|
15189
|
+
signY: ul({ controlKey: e })
|
|
14694
15190
|
};
|
|
14695
15191
|
}
|
|
14696
|
-
function
|
|
15192
|
+
function ll({ controlKey: e }) {
|
|
14697
15193
|
return e === "tl" || e === "bl" || e === "ml" ? -1 : 1;
|
|
14698
15194
|
}
|
|
14699
|
-
function
|
|
15195
|
+
function ul({ controlKey: e }) {
|
|
14700
15196
|
return e === "tl" || e === "tr" || e === "mt" ? -1 : 1;
|
|
14701
15197
|
}
|
|
14702
|
-
function
|
|
14703
|
-
let { target: n } = e, r =
|
|
15198
|
+
function dl({ transform: e, localPoint: t }) {
|
|
15199
|
+
let { target: n } = e, r = ml({
|
|
14704
15200
|
transform: e,
|
|
14705
15201
|
axis: "x",
|
|
14706
15202
|
localPoint: t
|
|
14707
|
-
}), i =
|
|
15203
|
+
}), i = ml({
|
|
14708
15204
|
transform: e,
|
|
14709
15205
|
axis: "y",
|
|
14710
15206
|
localPoint: t
|
|
14711
15207
|
});
|
|
14712
15208
|
n.lockScalingX || n.set("scaleX", r), n.lockScalingY || n.set("scaleY", i);
|
|
14713
15209
|
}
|
|
14714
|
-
function
|
|
15210
|
+
function fl({ transform: e, axis: t, localPoint: n }) {
|
|
14715
15211
|
let { target: r } = e;
|
|
14716
15212
|
if (t === "x" && r.lockScalingX || t === "y" && r.lockScalingY) return;
|
|
14717
|
-
let i =
|
|
15213
|
+
let i = ml({
|
|
14718
15214
|
transform: e,
|
|
14719
15215
|
axis: t,
|
|
14720
15216
|
localPoint: n
|
|
@@ -14725,18 +15221,18 @@ function ac({ transform: e, axis: t, localPoint: n }) {
|
|
|
14725
15221
|
}
|
|
14726
15222
|
r.set("scaleY", i);
|
|
14727
15223
|
}
|
|
14728
|
-
function
|
|
15224
|
+
function pl({ transform: e, axis: t, localPoint: n }) {
|
|
14729
15225
|
let { target: r } = e;
|
|
14730
15226
|
if (r.lockScalingX || r.lockScalingY) return;
|
|
14731
|
-
let i =
|
|
15227
|
+
let i = ml({
|
|
14732
15228
|
transform: e,
|
|
14733
15229
|
axis: t,
|
|
14734
15230
|
localPoint: n
|
|
14735
|
-
}), a = t === "x" ? e.original.scaleX : e.original.scaleY, o =
|
|
15231
|
+
}), a = t === "x" ? e.original.scaleX : e.original.scaleY, o = yl({
|
|
14736
15232
|
target: r,
|
|
14737
15233
|
transform: e,
|
|
14738
15234
|
scale: a > 0 ? i / a : 1,
|
|
14739
|
-
forceMinimum:
|
|
15235
|
+
forceMinimum: Tl({
|
|
14740
15236
|
transform: e,
|
|
14741
15237
|
axis: t,
|
|
14742
15238
|
localPoint: n
|
|
@@ -14744,173 +15240,178 @@ function oc({ transform: e, axis: t, localPoint: n }) {
|
|
|
14744
15240
|
});
|
|
14745
15241
|
r.set("scaleX", o.scaleX), r.set("scaleY", o.scaleY);
|
|
14746
15242
|
}
|
|
14747
|
-
function
|
|
14748
|
-
let { target: r } = e, i =
|
|
14749
|
-
if (
|
|
15243
|
+
function ml({ transform: e, axis: t, localPoint: n }) {
|
|
15244
|
+
let { target: r } = e, i = vl({ target: r }), a = wl({ target: r }), o = t === "x" ? r.scaleX ?? 1 : r.scaleY ?? 1, s = t === "x" ? n.x : n.y, c = t === "x" ? i.x : i.y, l = t === "x" ? a.minScaleX : a.minScaleY, u = t === "x" ? a.maxScaleX : a.maxScaleY;
|
|
15245
|
+
if (Tl({
|
|
14750
15246
|
transform: e,
|
|
14751
15247
|
axis: t,
|
|
14752
15248
|
localPoint: n
|
|
14753
15249
|
})) return l;
|
|
14754
15250
|
let d = Math.abs((s || 0) * o / c);
|
|
14755
|
-
return
|
|
15251
|
+
return $c({ transform: e }) && (d *= 2), Al({
|
|
14756
15252
|
value: d,
|
|
14757
15253
|
min: l,
|
|
14758
15254
|
max: u
|
|
14759
15255
|
});
|
|
14760
15256
|
}
|
|
14761
|
-
function
|
|
15257
|
+
function hl({ transform: e, localPoint: t }) {
|
|
14762
15258
|
let { target: n } = e;
|
|
14763
15259
|
if (n.lockScalingX || n.lockScalingY) return;
|
|
14764
|
-
let r =
|
|
15260
|
+
let r = yl({
|
|
14765
15261
|
target: n,
|
|
14766
15262
|
transform: e,
|
|
14767
|
-
scale:
|
|
15263
|
+
scale: gl({
|
|
14768
15264
|
transform: e,
|
|
14769
15265
|
localPoint: t,
|
|
14770
|
-
dimensions:
|
|
15266
|
+
dimensions: vl({ target: n })
|
|
14771
15267
|
}),
|
|
14772
|
-
forceMinimum:
|
|
15268
|
+
forceMinimum: El({
|
|
14773
15269
|
transform: e,
|
|
14774
15270
|
localPoint: t
|
|
14775
15271
|
})
|
|
14776
15272
|
});
|
|
14777
15273
|
n.set("scaleX", r.scaleX), n.set("scaleY", r.scaleY);
|
|
14778
15274
|
}
|
|
14779
|
-
function
|
|
15275
|
+
function gl({ transform: e, localPoint: t, dimensions: n }) {
|
|
14780
15276
|
let r = "gestureScale" in e && typeof e.gestureScale == "number" ? e.gestureScale : null;
|
|
14781
15277
|
if (r !== null) return r;
|
|
14782
|
-
let i = Math.abs(t.x) + Math.abs(t.y), a =
|
|
15278
|
+
let i = Math.abs(t.x) + Math.abs(t.y), a = _l({
|
|
14783
15279
|
transform: e,
|
|
14784
15280
|
dimensions: n
|
|
14785
15281
|
}), o = a > 0 ? i / a : 1;
|
|
14786
|
-
return
|
|
15282
|
+
return $c({ transform: e }) && (o *= 2), o;
|
|
14787
15283
|
}
|
|
14788
|
-
function
|
|
15284
|
+
function _l({ transform: e, dimensions: t }) {
|
|
14789
15285
|
let { target: n, original: r } = e, i = n.scaleX ?? 1, a = n.scaleY ?? 1;
|
|
14790
15286
|
return Math.abs(t.x * r.scaleX / i) + Math.abs(t.y * r.scaleY / a);
|
|
14791
15287
|
}
|
|
14792
|
-
function
|
|
15288
|
+
function vl({ target: e }) {
|
|
14793
15289
|
let t = Math.abs(e.scaleX ?? 1), n = Math.abs(e.scaleY ?? 1);
|
|
14794
15290
|
return {
|
|
14795
15291
|
x: Math.max(1, e.width * t),
|
|
14796
15292
|
y: Math.max(1, e.height * n)
|
|
14797
15293
|
};
|
|
14798
15294
|
}
|
|
14799
|
-
function
|
|
14800
|
-
let i =
|
|
15295
|
+
function yl({ target: e, transform: t, scale: n, forceMinimum: r }) {
|
|
15296
|
+
let i = Wc({
|
|
14801
15297
|
frame: e,
|
|
14802
15298
|
scaleX: t.original.scaleX,
|
|
14803
15299
|
scaleY: t.original.scaleY
|
|
14804
|
-
}), a = Math.max(
|
|
15300
|
+
}), a = Math.max(wc / i.width, Tc / i.height), o = Math.min(Ec / i.width, Dc / i.height), s = bl({
|
|
14805
15301
|
target: e,
|
|
14806
15302
|
transform: t
|
|
14807
15303
|
}), c = Math.max(a, Math.min(o, s ?? o));
|
|
14808
15304
|
t.cropSourceScaleClamped = !r && n > c;
|
|
14809
15305
|
let l = a;
|
|
14810
|
-
|
|
15306
|
+
r || (l = Al({
|
|
14811
15307
|
value: n,
|
|
14812
15308
|
min: a,
|
|
14813
15309
|
max: c
|
|
14814
|
-
}))
|
|
14815
|
-
|
|
14816
|
-
|
|
15310
|
+
}));
|
|
15311
|
+
let u = t.original.scaleX * l, d = t.original.scaleY * l;
|
|
15312
|
+
return t.cropSourceScaleClamped ? t.cropSourceBoundScale = {
|
|
15313
|
+
scaleX: u,
|
|
15314
|
+
scaleY: d
|
|
15315
|
+
} : t.cropSourceBoundScale = null, {
|
|
15316
|
+
scaleX: u,
|
|
15317
|
+
scaleY: d
|
|
14817
15318
|
};
|
|
14818
15319
|
}
|
|
14819
|
-
function
|
|
14820
|
-
let n =
|
|
15320
|
+
function bl({ target: e, transform: t }) {
|
|
15321
|
+
let n = xl({
|
|
14821
15322
|
target: e,
|
|
14822
15323
|
transform: t
|
|
14823
15324
|
});
|
|
14824
|
-
return n ?
|
|
15325
|
+
return n ? Kc({
|
|
14825
15326
|
sourceSize: n.sourceSize,
|
|
14826
15327
|
startRect: n.startRect,
|
|
14827
|
-
anchorX:
|
|
14828
|
-
anchorY:
|
|
15328
|
+
anchorX: Sl({ transform: t }),
|
|
15329
|
+
anchorY: Cl({ transform: t })
|
|
14829
15330
|
}) : null;
|
|
14830
15331
|
}
|
|
14831
|
-
function
|
|
14832
|
-
if (t.cropProportionalSourceBounds
|
|
15332
|
+
function xl({ target: e, transform: t }) {
|
|
15333
|
+
if (t.cropProportionalSourceBounds) return t.cropProportionalSourceBounds;
|
|
14833
15334
|
let n = e;
|
|
14834
15335
|
return n.cropAllowFrameOverflow !== !1 || !n.cropSource ? (t.cropProportionalSourceBounds = null, null) : (t.cropProportionalSourceBounds = {
|
|
14835
15336
|
sourceSize: Z({ source: n.cropSource }),
|
|
14836
|
-
startRect:
|
|
15337
|
+
startRect: Ac({
|
|
14837
15338
|
source: n.cropSource,
|
|
14838
15339
|
frame: n
|
|
14839
15340
|
})
|
|
14840
15341
|
}, t.cropProportionalSourceBounds);
|
|
14841
15342
|
}
|
|
14842
|
-
function
|
|
15343
|
+
function Sl({ transform: e }) {
|
|
14843
15344
|
return e.corner === "tl" || e.corner === "bl" || e.corner === "ml" ? "max" : e.corner === "tr" || e.corner === "br" || e.corner === "mr" || e.originX === "left" || e.originX === 0 ? "min" : e.originX === "right" || e.originX === 1 ? "max" : "center";
|
|
14844
15345
|
}
|
|
14845
|
-
function
|
|
15346
|
+
function Cl({ transform: e }) {
|
|
14846
15347
|
return e.corner === "tl" || e.corner === "tr" || e.corner === "mt" ? "max" : e.corner === "bl" || e.corner === "br" || e.corner === "mb" || e.originY === "top" || e.originY === 0 ? "min" : e.originY === "bottom" || e.originY === 1 ? "max" : "center";
|
|
14847
15348
|
}
|
|
14848
|
-
function
|
|
15349
|
+
function wl({ target: e }) {
|
|
14849
15350
|
let t = e, n = Math.abs(t.cropSourceScaleX ?? 1) || 1, r = Math.abs(t.cropSourceScaleY ?? 1) || 1, i = Math.max(1, e.width), a = Math.max(1, e.height);
|
|
14850
15351
|
return {
|
|
14851
|
-
minScaleX:
|
|
14852
|
-
maxScaleX:
|
|
14853
|
-
minScaleY:
|
|
14854
|
-
maxScaleY:
|
|
15352
|
+
minScaleX: wc * n / i,
|
|
15353
|
+
maxScaleX: Ec * n / i,
|
|
15354
|
+
minScaleY: Tc * r / a,
|
|
15355
|
+
maxScaleY: Dc * r / a
|
|
14855
15356
|
};
|
|
14856
15357
|
}
|
|
14857
|
-
function
|
|
15358
|
+
function Tl({ transform: e, axis: t, localPoint: n }) {
|
|
14858
15359
|
let { target: r } = e;
|
|
14859
15360
|
if (!r.lockScalingFlip) return !1;
|
|
14860
15361
|
let i = t === "x" ? e.signX ?? 1 : e.signY ?? 1, a = t === "x" ? n.x : n.y;
|
|
14861
15362
|
return i !== Math.sign(a || i);
|
|
14862
15363
|
}
|
|
14863
|
-
function
|
|
14864
|
-
return
|
|
15364
|
+
function El({ transform: e, localPoint: t }) {
|
|
15365
|
+
return Tl({
|
|
14865
15366
|
transform: e,
|
|
14866
15367
|
axis: "x",
|
|
14867
15368
|
localPoint: t
|
|
14868
|
-
}) ||
|
|
15369
|
+
}) || Tl({
|
|
14869
15370
|
transform: e,
|
|
14870
15371
|
axis: "y",
|
|
14871
15372
|
localPoint: t
|
|
14872
15373
|
});
|
|
14873
15374
|
}
|
|
14874
|
-
function
|
|
15375
|
+
function Dl({ eventData: e, target: t }) {
|
|
14875
15376
|
let n = t.preserveAspectRatio ?? !0;
|
|
14876
15377
|
return e.shiftKey ? !n : n;
|
|
14877
15378
|
}
|
|
14878
|
-
function
|
|
14879
|
-
let e = x.wrapWithFireEvent("scaling", x.wrapWithFixedAnchor((e, t, n, r) =>
|
|
15379
|
+
function Ol() {
|
|
15380
|
+
let e = x.wrapWithFireEvent("scaling", x.wrapWithFixedAnchor((e, t, n, r) => el({
|
|
14880
15381
|
transform: t,
|
|
14881
15382
|
x: n,
|
|
14882
15383
|
y: r
|
|
14883
|
-
}))), t = x.wrapWithFireEvent("scaling", x.wrapWithFixedAnchor((e, t, n, r) =>
|
|
15384
|
+
}))), t = x.wrapWithFireEvent("scaling", x.wrapWithFixedAnchor((e, t, n, r) => tl({
|
|
14884
15385
|
transform: t,
|
|
14885
15386
|
x: n,
|
|
14886
15387
|
y: r
|
|
14887
15388
|
})));
|
|
14888
|
-
return (n, r, i, a) =>
|
|
15389
|
+
return (n, r, i, a) => Dl({
|
|
14889
15390
|
eventData: n,
|
|
14890
15391
|
target: r.target
|
|
14891
15392
|
}) ? t(n, r, i, a) : e(n, r, i, a);
|
|
14892
15393
|
}
|
|
14893
|
-
function
|
|
14894
|
-
let t = x.wrapWithFireEvent("scaling", x.wrapWithFixedAnchor((t, n, r, i) =>
|
|
15394
|
+
function kl({ axis: e }) {
|
|
15395
|
+
let t = x.wrapWithFireEvent("scaling", x.wrapWithFixedAnchor((t, n, r, i) => nl({
|
|
14895
15396
|
transform: n,
|
|
14896
15397
|
axis: e,
|
|
14897
15398
|
x: r,
|
|
14898
15399
|
y: i
|
|
14899
|
-
}))), n = x.wrapWithFireEvent("scaling", x.wrapWithFixedAnchor((t, n, r, i) =>
|
|
15400
|
+
}))), n = x.wrapWithFireEvent("scaling", x.wrapWithFixedAnchor((t, n, r, i) => rl({
|
|
14900
15401
|
transform: n,
|
|
14901
15402
|
axis: e,
|
|
14902
15403
|
x: r,
|
|
14903
15404
|
y: i
|
|
14904
15405
|
})));
|
|
14905
|
-
return (e, r, i, a) =>
|
|
15406
|
+
return (e, r, i, a) => Dl({
|
|
14906
15407
|
eventData: e,
|
|
14907
15408
|
target: r.target
|
|
14908
15409
|
}) ? n(e, r, i, a) : t(e, r, i, a);
|
|
14909
15410
|
}
|
|
14910
|
-
function
|
|
15411
|
+
function Al({ value: e, min: t, max: n }) {
|
|
14911
15412
|
return Math.max(t, Math.min(n, e));
|
|
14912
15413
|
}
|
|
14913
|
-
function
|
|
15414
|
+
function jl({ control: e, actionHandler: t, cursorStyleHandler: n, getActionName: i }) {
|
|
14914
15415
|
let a = {
|
|
14915
15416
|
...e,
|
|
14916
15417
|
actionHandler: t
|
|
@@ -14919,55 +15420,55 @@ function wc({ control: e, actionHandler: t, cursorStyleHandler: n, getActionName
|
|
|
14919
15420
|
let o = new r(a);
|
|
14920
15421
|
return o.cropResizeControl = !0, o;
|
|
14921
15422
|
}
|
|
14922
|
-
function
|
|
14923
|
-
return
|
|
15423
|
+
function Ml({ controlKey: e }) {
|
|
15424
|
+
return Qc[e];
|
|
14924
15425
|
}
|
|
14925
|
-
function
|
|
15426
|
+
function Nl({ axis: e }) {
|
|
14926
15427
|
return e === "x" ? "scaleX" : "scaleY";
|
|
14927
15428
|
}
|
|
14928
|
-
function
|
|
14929
|
-
let t = { ...e.controls }, n = !1, r =
|
|
14930
|
-
|
|
15429
|
+
function Pl({ target: e }) {
|
|
15430
|
+
let t = { ...e.controls }, n = !1, r = Ol(), i = kl({ axis: "x" }), a = kl({ axis: "y" });
|
|
15431
|
+
Xc.forEach((i) => {
|
|
14931
15432
|
let a = e.controls[i];
|
|
14932
|
-
a && (a.cropResizeControl || (t[i] =
|
|
15433
|
+
a && (a.cropResizeControl || (t[i] = jl({
|
|
14933
15434
|
control: a,
|
|
14934
15435
|
actionHandler: r
|
|
14935
15436
|
}), n = !0));
|
|
14936
|
-
}),
|
|
15437
|
+
}), Zc.forEach((r) => {
|
|
14937
15438
|
let o = e.controls[r];
|
|
14938
15439
|
if (!o || o.cropResizeControl) return;
|
|
14939
15440
|
let s = r === "ml" || r === "mr", c = s ? i : a, l = s ? "x" : "y";
|
|
14940
|
-
t[r] =
|
|
15441
|
+
t[r] = jl({
|
|
14941
15442
|
control: o,
|
|
14942
15443
|
actionHandler: c,
|
|
14943
|
-
cursorStyleHandler: () =>
|
|
14944
|
-
getActionName: () =>
|
|
15444
|
+
cursorStyleHandler: () => Ml({ controlKey: r }),
|
|
15445
|
+
getActionName: () => Nl({ axis: l })
|
|
14945
15446
|
}), n = !0;
|
|
14946
15447
|
}), n && (e.controls = t);
|
|
14947
15448
|
}
|
|
14948
15449
|
//#endregion
|
|
14949
15450
|
//#region src/editor/crop-manager/domain/crop-frame.ts
|
|
14950
|
-
var
|
|
15451
|
+
var Fl = "rgba(47, 128, 237, 0.42)", Il = class extends _ {
|
|
14951
15452
|
constructor(e) {
|
|
14952
15453
|
let { showGrid: t, source: n = null, allowFrameOverflow: r = !0, sourceScaleX: i = 1, sourceScaleY: a = 1, preserveAspectRatio: o = !0, ...s } = e;
|
|
14953
15454
|
super(s), this._showGrid = t, this.cropSource = n, this.cropAllowFrameOverflow = r, this.cropSourceScaleX = i, this.cropSourceScaleY = a, this.preserveAspectRatio = o;
|
|
14954
15455
|
}
|
|
14955
15456
|
_render(e) {
|
|
14956
|
-
super._render(e), this._showGrid &&
|
|
15457
|
+
super._render(e), this._showGrid && Rl({
|
|
14957
15458
|
ctx: e,
|
|
14958
15459
|
width: this.width,
|
|
14959
15460
|
height: this.height
|
|
14960
15461
|
});
|
|
14961
15462
|
}
|
|
14962
15463
|
getObjectDisplaySize() {
|
|
14963
|
-
return
|
|
15464
|
+
return Wc({ frame: this });
|
|
14964
15465
|
}
|
|
14965
15466
|
getObjectSnappingBounds() {
|
|
14966
|
-
return
|
|
15467
|
+
return Bl({ frame: this });
|
|
14967
15468
|
}
|
|
14968
15469
|
};
|
|
14969
|
-
function
|
|
14970
|
-
let a = e.getCenterPoint(), o = e.scaleX ?? 1, s = e.scaleY ?? 1, c = new
|
|
15470
|
+
function Ll({ source: e, cropSize: t, showGrid: n, allowFrameOverflow: r, preserveAspectRatio: i }) {
|
|
15471
|
+
let a = e.getCenterPoint(), o = e.scaleX ?? 1, s = e.scaleY ?? 1, c = new Il({
|
|
14971
15472
|
id: `crop-frame-${D()}`,
|
|
14972
15473
|
left: a.x,
|
|
14973
15474
|
top: a.y,
|
|
@@ -14999,18 +15500,18 @@ function Ac({ source: e, cropSize: t, showGrid: n, allowFrameOverflow: r, preser
|
|
|
14999
15500
|
sourceScaleX: o,
|
|
15000
15501
|
sourceScaleY: s
|
|
15001
15502
|
});
|
|
15002
|
-
return c.setControlsVisibility({ mtr: !1 }),
|
|
15503
|
+
return c.setControlsVisibility({ mtr: !1 }), Pl({ target: c }), c;
|
|
15003
15504
|
}
|
|
15004
|
-
function
|
|
15505
|
+
function Rl({ ctx: e, width: t, height: n }) {
|
|
15005
15506
|
if (!(t <= 0 || n <= 0)) {
|
|
15006
|
-
e.save(), e.strokeStyle =
|
|
15507
|
+
e.save(), e.strokeStyle = Fl, e.lineWidth = 1, e.setLineDash([]);
|
|
15007
15508
|
for (let r = 1; r <= 2; r += 1) {
|
|
15008
15509
|
let i = -t / 2 + t * r / 3, a = -n / 2 + n * r / 3;
|
|
15009
|
-
|
|
15510
|
+
zl({
|
|
15010
15511
|
ctx: e,
|
|
15011
15512
|
x: i,
|
|
15012
15513
|
height: n
|
|
15013
|
-
}),
|
|
15514
|
+
}), Hl({
|
|
15014
15515
|
ctx: e,
|
|
15015
15516
|
y: a,
|
|
15016
15517
|
width: t
|
|
@@ -15019,19 +15520,19 @@ function jc({ ctx: e, width: t, height: n }) {
|
|
|
15019
15520
|
e.restore();
|
|
15020
15521
|
}
|
|
15021
15522
|
}
|
|
15022
|
-
function
|
|
15523
|
+
function zl({ ctx: e, x: t, height: n }) {
|
|
15023
15524
|
e.beginPath(), e.moveTo(t, -n / 2), e.lineTo(t, n / 2), e.stroke();
|
|
15024
15525
|
}
|
|
15025
|
-
function
|
|
15526
|
+
function Bl({ frame: e }) {
|
|
15026
15527
|
let t = e.calcTransformMatrix(), n = e.width / 2, r = e.height / 2;
|
|
15027
|
-
return
|
|
15528
|
+
return Vl({ points: [
|
|
15028
15529
|
new m(-n, -r),
|
|
15029
15530
|
new m(n, -r),
|
|
15030
15531
|
new m(n, r),
|
|
15031
15532
|
new m(-n, r)
|
|
15032
15533
|
].map((e) => e.transform(t)) });
|
|
15033
15534
|
}
|
|
15034
|
-
function
|
|
15535
|
+
function Vl({ points: e }) {
|
|
15035
15536
|
let t = Math.min(...e.map((e) => e.x)), n = Math.max(...e.map((e) => e.x)), r = Math.min(...e.map((e) => e.y)), i = Math.max(...e.map((e) => e.y));
|
|
15036
15537
|
return {
|
|
15037
15538
|
left: t,
|
|
@@ -15042,18 +15543,18 @@ function Pc({ points: e }) {
|
|
|
15042
15543
|
centerY: r + (i - r) / 2
|
|
15043
15544
|
};
|
|
15044
15545
|
}
|
|
15045
|
-
function
|
|
15546
|
+
function Hl({ ctx: e, y: t, width: n }) {
|
|
15046
15547
|
e.beginPath(), e.moveTo(-n / 2, t), e.lineTo(n / 2, t), e.stroke();
|
|
15047
15548
|
}
|
|
15048
15549
|
//#endregion
|
|
15049
15550
|
//#region src/editor/crop-manager/domain/crop-result.ts
|
|
15050
|
-
function
|
|
15051
|
-
return e.mode === "canvas" ?
|
|
15551
|
+
function Ul({ session: e }) {
|
|
15552
|
+
return e.mode === "canvas" ? Kl({ session: e }) : ql({
|
|
15052
15553
|
target: e.target,
|
|
15053
15554
|
frame: e.frame
|
|
15054
15555
|
});
|
|
15055
15556
|
}
|
|
15056
|
-
function
|
|
15557
|
+
function Wl({ rect: e }) {
|
|
15057
15558
|
return {
|
|
15058
15559
|
left: Math.round(e.left),
|
|
15059
15560
|
top: Math.round(e.top),
|
|
@@ -15061,11 +15562,11 @@ function Lc({ rect: e }) {
|
|
|
15061
15562
|
height: Math.round(e.height)
|
|
15062
15563
|
};
|
|
15063
15564
|
}
|
|
15064
|
-
function
|
|
15065
|
-
return e.width >=
|
|
15565
|
+
function Gl({ rect: e }) {
|
|
15566
|
+
return e.width >= Oc && e.height >= Oc;
|
|
15066
15567
|
}
|
|
15067
|
-
function
|
|
15068
|
-
let t =
|
|
15568
|
+
function Kl({ session: e }) {
|
|
15569
|
+
let t = Ac({
|
|
15069
15570
|
source: e.source,
|
|
15070
15571
|
frame: e.frame
|
|
15071
15572
|
}), n = Z({ source: e.source });
|
|
@@ -15076,8 +15577,8 @@ function zc({ session: e }) {
|
|
|
15076
15577
|
height: t.height
|
|
15077
15578
|
};
|
|
15078
15579
|
}
|
|
15079
|
-
function
|
|
15080
|
-
let n =
|
|
15580
|
+
function ql({ target: e, frame: t }) {
|
|
15581
|
+
let n = Ac({
|
|
15081
15582
|
source: e,
|
|
15082
15583
|
frame: t
|
|
15083
15584
|
}), r = -e.width / 2, i = -e.height / 2;
|
|
@@ -15090,8 +15591,8 @@ function Bc({ target: e, frame: t }) {
|
|
|
15090
15591
|
}
|
|
15091
15592
|
//#endregion
|
|
15092
15593
|
//#region src/editor/crop-manager/mutation/crop-apply.ts
|
|
15093
|
-
function
|
|
15094
|
-
return
|
|
15594
|
+
function Jl({ editor: e, frame: t, rect: n }) {
|
|
15595
|
+
return Gl({ rect: n }) ? (nu({
|
|
15095
15596
|
editor: e,
|
|
15096
15597
|
frame: t,
|
|
15097
15598
|
offset: new m(-n.left, -n.top)
|
|
@@ -15101,9 +15602,9 @@ function Vc({ editor: e, frame: t, rect: n }) {
|
|
|
15101
15602
|
rect: n
|
|
15102
15603
|
}) : null;
|
|
15103
15604
|
}
|
|
15104
|
-
function
|
|
15105
|
-
if (!
|
|
15106
|
-
let i =
|
|
15605
|
+
function Yl({ editor: e, target: t, frame: n, rect: r }) {
|
|
15606
|
+
if (!Gl({ rect: r })) return null;
|
|
15607
|
+
let i = Xl({
|
|
15107
15608
|
target: t,
|
|
15108
15609
|
frame: n,
|
|
15109
15610
|
rect: r
|
|
@@ -15114,21 +15615,21 @@ function Hc({ editor: e, target: t, frame: n, rect: r }) {
|
|
|
15114
15615
|
rect: i
|
|
15115
15616
|
}) : null;
|
|
15116
15617
|
}
|
|
15117
|
-
function
|
|
15118
|
-
let r = Math.max(
|
|
15618
|
+
function Xl({ target: e, frame: t, rect: n }) {
|
|
15619
|
+
let r = Math.max(Oc, n.width), i = Math.max(Oc, n.height), a = {
|
|
15119
15620
|
width: r,
|
|
15120
15621
|
height: i
|
|
15121
15622
|
};
|
|
15122
|
-
if (
|
|
15623
|
+
if (Zl({
|
|
15123
15624
|
target: e,
|
|
15124
15625
|
rect: n
|
|
15125
|
-
}))
|
|
15626
|
+
})) Ql({
|
|
15126
15627
|
target: e,
|
|
15127
15628
|
size: a,
|
|
15128
15629
|
rect: n
|
|
15129
15630
|
});
|
|
15130
15631
|
else {
|
|
15131
|
-
let t =
|
|
15632
|
+
let t = $l({
|
|
15132
15633
|
target: e,
|
|
15133
15634
|
size: a,
|
|
15134
15635
|
rect: n
|
|
@@ -15148,10 +15649,10 @@ function Uc({ target: e, frame: t, rect: n }) {
|
|
|
15148
15649
|
height: i
|
|
15149
15650
|
};
|
|
15150
15651
|
}
|
|
15151
|
-
function
|
|
15652
|
+
function Zl({ target: e, rect: t }) {
|
|
15152
15653
|
return t.left >= 0 && t.top >= 0 && t.left + t.width <= e.width && t.top + t.height <= e.height;
|
|
15153
15654
|
}
|
|
15154
|
-
function
|
|
15655
|
+
function Ql({ target: e, size: t, rect: n }) {
|
|
15155
15656
|
let r = (e.cropX ?? 0) + n.left, i = (e.cropY ?? 0) + n.top;
|
|
15156
15657
|
e.set({
|
|
15157
15658
|
cropX: r,
|
|
@@ -15160,25 +15661,25 @@ function Gc({ target: e, size: t, rect: n }) {
|
|
|
15160
15661
|
height: t.height
|
|
15161
15662
|
});
|
|
15162
15663
|
}
|
|
15163
|
-
function
|
|
15164
|
-
let r = e.getElement(), i =
|
|
15664
|
+
function $l({ target: e, size: t, rect: n }) {
|
|
15665
|
+
let r = e.getElement(), i = eu({ target: e });
|
|
15165
15666
|
if (!r || !i) return null;
|
|
15166
15667
|
let a = i.createElement("canvas");
|
|
15167
15668
|
a.width = Math.round(t.width), a.height = Math.round(t.height);
|
|
15168
15669
|
let o = a.getContext("2d");
|
|
15169
15670
|
if (!o) return null;
|
|
15170
|
-
let s =
|
|
15671
|
+
let s = tu({
|
|
15171
15672
|
target: e,
|
|
15172
15673
|
size: t,
|
|
15173
15674
|
rect: n
|
|
15174
15675
|
});
|
|
15175
15676
|
return s && o.drawImage(r, s.sourceX, s.sourceY, s.sourceWidth, s.sourceHeight, s.destinationX, s.destinationY, s.sourceWidth, s.sourceHeight), a;
|
|
15176
15677
|
}
|
|
15177
|
-
function
|
|
15678
|
+
function eu({ target: e }) {
|
|
15178
15679
|
let t = e.canvas?.getElement();
|
|
15179
15680
|
return t?.ownerDocument ? t.ownerDocument : typeof document < "u" ? document : null;
|
|
15180
15681
|
}
|
|
15181
|
-
function
|
|
15682
|
+
function tu({ target: e, size: t, rect: n }) {
|
|
15182
15683
|
let r = Math.max(0, n.left), i = Math.max(0, n.top), a = Math.min(e.width, n.left + t.width), o = Math.min(e.height, n.top + t.height), s = a - r, c = o - i;
|
|
15183
15684
|
return s <= 0 || c <= 0 ? null : {
|
|
15184
15685
|
sourceX: (e.cropX ?? 0) + r,
|
|
@@ -15189,7 +15690,7 @@ function Jc({ target: e, size: t, rect: n }) {
|
|
|
15189
15690
|
destinationY: i - n.top
|
|
15190
15691
|
};
|
|
15191
15692
|
}
|
|
15192
|
-
function
|
|
15693
|
+
function nu({ editor: e, frame: t, offset: n }) {
|
|
15193
15694
|
e.canvasManager.getObjects().forEach((e) => {
|
|
15194
15695
|
e !== t && (e.set({
|
|
15195
15696
|
left: (e.left ?? 0) + n.x,
|
|
@@ -15199,12 +15700,12 @@ function Yc({ editor: e, frame: t, offset: n }) {
|
|
|
15199
15700
|
}
|
|
15200
15701
|
//#endregion
|
|
15201
15702
|
//#region src/editor/crop-manager/index.ts
|
|
15202
|
-
var
|
|
15703
|
+
var ru = {
|
|
15203
15704
|
allowFrameOverflow: !0,
|
|
15204
15705
|
showGrid: !0,
|
|
15205
15706
|
cancelOnSelectionClear: !0,
|
|
15206
15707
|
preserveAspectRatio: !0
|
|
15207
|
-
},
|
|
15708
|
+
}, iu = .5, au = class {
|
|
15208
15709
|
constructor({ editor: e }) {
|
|
15209
15710
|
this._handleCropFrameChanged = (e) => {
|
|
15210
15711
|
let { _session: t } = this;
|
|
@@ -15215,7 +15716,10 @@ var Xc = {
|
|
|
15215
15716
|
});
|
|
15216
15717
|
this._clampFrameIfNeeded({
|
|
15217
15718
|
session: t,
|
|
15218
|
-
preserveAspectRatio: this.
|
|
15719
|
+
preserveAspectRatio: this._shouldPreserveAspectRatioOnFrameClamp({
|
|
15720
|
+
session: t,
|
|
15721
|
+
event: e
|
|
15722
|
+
})
|
|
15219
15723
|
}), n || this._rememberSourceBoundFrameIfNeeded({
|
|
15220
15724
|
session: t,
|
|
15221
15725
|
event: e
|
|
@@ -15240,18 +15744,22 @@ var Xc = {
|
|
|
15240
15744
|
frame: e.frame,
|
|
15241
15745
|
options: e.options,
|
|
15242
15746
|
target: e.target,
|
|
15243
|
-
rect:
|
|
15747
|
+
rect: Ul({ session: e })
|
|
15244
15748
|
} : null;
|
|
15245
15749
|
}
|
|
15246
15750
|
isFrameOverflowingSource({ target: e }) {
|
|
15247
15751
|
let { _session: t } = this;
|
|
15248
15752
|
if (!t || !e || t.options.allowFrameOverflow || t.frame !== e) return !1;
|
|
15249
|
-
let n =
|
|
15753
|
+
let n = Ac({
|
|
15250
15754
|
source: t.source,
|
|
15251
15755
|
frame: t.frame
|
|
15252
|
-
}), r = Z({ source: t.source }), i = -r.width / 2, a = -r.height / 2, o = r.width / 2, s = r.height / 2;
|
|
15756
|
+
}), r = Z({ source: t.source }), i = -r.width / 2 - iu, a = -r.height / 2 - iu, o = r.width / 2 + iu, s = r.height / 2 + iu;
|
|
15253
15757
|
return n.left < i || n.top < a || n.left + n.width > o || n.top + n.height > s;
|
|
15254
15758
|
}
|
|
15759
|
+
isFrameSourceScaleClamped({ target: e, transform: t }) {
|
|
15760
|
+
let { _session: n } = this;
|
|
15761
|
+
return !n || !e || !t || n.frame !== e ? !1 : t.cropSourceScaleClamped === !0;
|
|
15762
|
+
}
|
|
15255
15763
|
startCanvasCrop(e = {}) {
|
|
15256
15764
|
this.cancel();
|
|
15257
15765
|
let t = this._createCanvasSession({
|
|
@@ -15274,7 +15782,7 @@ var Xc = {
|
|
|
15274
15782
|
setAspectRatio({ aspectRatio: e }) {
|
|
15275
15783
|
let { _session: t } = this;
|
|
15276
15784
|
if (!t) return null;
|
|
15277
|
-
let n =
|
|
15785
|
+
let n = kc({
|
|
15278
15786
|
sourceSize: Z({ source: t.source }),
|
|
15279
15787
|
aspectRatio: e ?? void 0,
|
|
15280
15788
|
allowOverflow: t.options.allowFrameOverflow
|
|
@@ -15287,7 +15795,7 @@ var Xc = {
|
|
|
15287
15795
|
setSize({ size: e }) {
|
|
15288
15796
|
let { _session: t } = this;
|
|
15289
15797
|
if (!t) return null;
|
|
15290
|
-
let n =
|
|
15798
|
+
let n = kc({
|
|
15291
15799
|
sourceSize: Z({ source: t.source }),
|
|
15292
15800
|
size: e,
|
|
15293
15801
|
allowOverflow: t.options.allowFrameOverflow
|
|
@@ -15365,16 +15873,16 @@ var Xc = {
|
|
|
15365
15873
|
}
|
|
15366
15874
|
_resolveSessionOptions({ options: e }) {
|
|
15367
15875
|
return {
|
|
15368
|
-
allowFrameOverflow: e.allowFrameOverflow ??
|
|
15369
|
-
showGrid: e.showGrid ??
|
|
15370
|
-
cancelOnSelectionClear: e.cancelOnSelectionClear ??
|
|
15371
|
-
preserveAspectRatio: e.preserveAspectRatio ??
|
|
15876
|
+
allowFrameOverflow: e.allowFrameOverflow ?? ru.allowFrameOverflow,
|
|
15877
|
+
showGrid: e.showGrid ?? ru.showGrid,
|
|
15878
|
+
cancelOnSelectionClear: e.cancelOnSelectionClear ?? ru.cancelOnSelectionClear,
|
|
15879
|
+
preserveAspectRatio: e.preserveAspectRatio ?? ru.preserveAspectRatio
|
|
15372
15880
|
};
|
|
15373
15881
|
}
|
|
15374
15882
|
_createCropFrameForSource({ source: e, options: t, sessionOptions: n }) {
|
|
15375
|
-
return
|
|
15883
|
+
return Ll({
|
|
15376
15884
|
source: e,
|
|
15377
|
-
cropSize:
|
|
15885
|
+
cropSize: kc({
|
|
15378
15886
|
sourceSize: Z({ source: e }),
|
|
15379
15887
|
size: t.size,
|
|
15380
15888
|
aspectRatio: t.aspectRatio,
|
|
@@ -15386,7 +15894,7 @@ var Xc = {
|
|
|
15386
15894
|
});
|
|
15387
15895
|
}
|
|
15388
15896
|
_setFramePreserveAspectRatio({ frame: e, preserveAspectRatio: t }) {
|
|
15389
|
-
if (!(e instanceof
|
|
15897
|
+
if (!(e instanceof Il)) throw Error("Crop session frame должен быть CropFrame");
|
|
15390
15898
|
e.preserveAspectRatio = t;
|
|
15391
15899
|
}
|
|
15392
15900
|
_activateSession({ session: e }) {
|
|
@@ -15406,10 +15914,24 @@ var Xc = {
|
|
|
15406
15914
|
this.editor.canvas.off("mouse:down:before", this._handleCanvasMouseDownBefore), this.editor.canvas.off("selection:cleared", this._handleCanvasSelectionChanged), this.editor.canvas.off("selection:updated", this._handleCanvasSelectionChanged);
|
|
15407
15915
|
}
|
|
15408
15916
|
_restoreSourceBoundFrameIfNeeded({ session: e, event: t }) {
|
|
15409
|
-
|
|
15917
|
+
if (!this._isSourceScaleClamped({ event: t })) return e.sourceBoundFrameState = null, !1;
|
|
15918
|
+
let n = e.sourceBoundFrameState ?? this._getSourceBoundFrameStateFromEvent({
|
|
15410
15919
|
session: e,
|
|
15411
|
-
|
|
15412
|
-
})
|
|
15920
|
+
event: t
|
|
15921
|
+
});
|
|
15922
|
+
return n ? (this._applyFrameTransformState({
|
|
15923
|
+
session: e,
|
|
15924
|
+
state: n
|
|
15925
|
+
}), !0) : !1;
|
|
15926
|
+
}
|
|
15927
|
+
_getSourceBoundFrameStateFromEvent({ session: e, event: t }) {
|
|
15928
|
+
let n = t?.transform?.cropSourceBoundScale;
|
|
15929
|
+
return !n || !Number.isFinite(n.scaleX) || !Number.isFinite(n.scaleY) ? null : {
|
|
15930
|
+
left: e.frame.left,
|
|
15931
|
+
top: e.frame.top,
|
|
15932
|
+
scaleX: n.scaleX,
|
|
15933
|
+
scaleY: n.scaleY
|
|
15934
|
+
};
|
|
15413
15935
|
}
|
|
15414
15936
|
_rememberSourceBoundFrameIfNeeded({ session: e, event: t }) {
|
|
15415
15937
|
if (!this._isSourceScaleClamped({ event: t })) {
|
|
@@ -15421,6 +15943,9 @@ var Xc = {
|
|
|
15421
15943
|
_isSourceScaleClamped({ event: e }) {
|
|
15422
15944
|
return e?.transform?.cropSourceScaleClamped === !0;
|
|
15423
15945
|
}
|
|
15946
|
+
_shouldPreserveAspectRatioOnFrameClamp({ session: e, event: t }) {
|
|
15947
|
+
return this._isSourceScaleClamped({ event: t }) ? !0 : t?.e?.shiftKey ? !e.options.preserveAspectRatio : e.options.preserveAspectRatio;
|
|
15948
|
+
}
|
|
15424
15949
|
_getFrameTransformState({ session: e }) {
|
|
15425
15950
|
return {
|
|
15426
15951
|
left: e.frame.left,
|
|
@@ -15477,25 +16002,25 @@ var Xc = {
|
|
|
15477
16002
|
_clampFrameIfNeeded({ session: e, preserveAspectRatio: t = !1 }) {
|
|
15478
16003
|
if (!e.options.allowFrameOverflow) {
|
|
15479
16004
|
if (t) {
|
|
15480
|
-
|
|
16005
|
+
Mc({
|
|
15481
16006
|
source: e.source,
|
|
15482
16007
|
frame: e.frame
|
|
15483
16008
|
});
|
|
15484
16009
|
return;
|
|
15485
16010
|
}
|
|
15486
|
-
|
|
16011
|
+
jc({
|
|
15487
16012
|
source: e.source,
|
|
15488
16013
|
frame: e.frame
|
|
15489
16014
|
});
|
|
15490
16015
|
}
|
|
15491
16016
|
}
|
|
15492
16017
|
_applySessionCrop({ session: e }) {
|
|
15493
|
-
let t =
|
|
15494
|
-
return e.mode === "canvas" ?
|
|
16018
|
+
let t = Wl({ rect: Ul({ session: e }) });
|
|
16019
|
+
return e.mode === "canvas" ? Jl({
|
|
15495
16020
|
editor: this.editor,
|
|
15496
16021
|
frame: e.frame,
|
|
15497
16022
|
rect: t
|
|
15498
|
-
}) :
|
|
16023
|
+
}) : Yl({
|
|
15499
16024
|
editor: this.editor,
|
|
15500
16025
|
target: e.target,
|
|
15501
16026
|
frame: e.frame,
|
|
@@ -15563,13 +16088,13 @@ var Xc = {
|
|
|
15563
16088
|
}
|
|
15564
16089
|
});
|
|
15565
16090
|
}
|
|
15566
|
-
},
|
|
16091
|
+
}, ou = class e {
|
|
15567
16092
|
constructor(e, t) {
|
|
15568
16093
|
this.options = t, this.containerId = e, this.editorId = `${e}-${D()}`, this.init();
|
|
15569
16094
|
}
|
|
15570
16095
|
async init() {
|
|
15571
16096
|
let { editorContainerWidth: e, editorContainerHeight: n, canvasWrapperWidth: r, canvasWrapperHeight: i, canvasCSSWidth: a, canvasCSSHeight: o, initialImage: s, initialState: c, scaleType: l, showRotationAngle: u, showObjectSizeOnScale: d, showViewportScrollbars: f, _onReadyCallback: p } = this.options;
|
|
15572
|
-
if (_e.apply(), this.canvas = new t(this.containerId, this.options), this.moduleLoader = new I(), this.workerManager = new te(), this.errorManager = new Ja({ editor: this }), this.historyManager = new Ht({ editor: this }), this.toolbar = new it({ editor: this }), this.transformManager = new $t({ editor: this }), this.zoomManager = new en({ editor: this }), this.canvasManager = new Qt({ editor: this }), this.imageManager = new Jt({ editor: this }), this.layerManager = new Bn({ editor: this }), this.shapeManager = new Ba({ editor: this }), this.interactionBlocker = new Rn({ editor: this }), this.backgroundManager = new zn({ editor: this }), this.clipboardManager = new Ha({ editor: this }), this.objectLockManager = new Ua({ editor: this }), this.groupingManager = new Wa({ editor: this }), this.selectionManager = new Ga({ editor: this }), this.deletionManager = new Ka({ editor: this }), this.panConstraintManager = new Xa({ editor: this }), this.snappingManager = new
|
|
16097
|
+
if (_e.apply(), this.canvas = new t(this.containerId, this.options), this.moduleLoader = new I(), this.workerManager = new te(), this.errorManager = new Ja({ editor: this }), this.historyManager = new Ht({ editor: this }), this.toolbar = new it({ editor: this }), this.transformManager = new $t({ editor: this }), this.zoomManager = new en({ editor: this }), this.canvasManager = new Qt({ editor: this }), this.imageManager = new Jt({ editor: this }), this.layerManager = new Bn({ editor: this }), this.shapeManager = new Ba({ editor: this }), this.interactionBlocker = new Rn({ editor: this }), this.backgroundManager = new zn({ editor: this }), this.clipboardManager = new Ha({ editor: this }), this.objectLockManager = new Ua({ editor: this }), this.groupingManager = new Wa({ editor: this }), this.selectionManager = new Ga({ editor: this }), this.deletionManager = new Ka({ editor: this }), this.panConstraintManager = new Xa({ editor: this }), this.snappingManager = new xc({ editor: this }), this.measurementManager = new Cc({ editor: this }), this.fontManager = new ve(this.options.fonts ?? []), this.textManager = new _o({ editor: this }), this.templateManager = new So({ editor: this }), this.cropManager = new au({ editor: this }), u && (this.angleIndicator = new ct({ editor: this })), d && (this.objectSizeIndicator = new ut({ editor: this })), this._createMontageArea(), this._createClippingArea(), this.interactionBlocker.ensureOverlay(), this.listeners = new F({
|
|
15573
16098
|
editor: this,
|
|
15574
16099
|
options: this.options
|
|
15575
16100
|
}), 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(), f && (this.viewportScrollbars = new gt({ editor: this })), await this.fontManager.loadFonts(), c) {
|
|
@@ -15677,7 +16202,7 @@ var Xc = {
|
|
|
15677
16202
|
"U+A640-A69F",
|
|
15678
16203
|
"U+FE2E-FE2F",
|
|
15679
16204
|
"U+2116"
|
|
15680
|
-
].join(", "),
|
|
16205
|
+
].join(", "), su = {
|
|
15681
16206
|
preserveObjectStacking: !0,
|
|
15682
16207
|
controlsAboveOverlay: !0,
|
|
15683
16208
|
centeredRotation: !0,
|
|
@@ -16535,20 +17060,20 @@ var Xc = {
|
|
|
16535
17060
|
};
|
|
16536
17061
|
//#endregion
|
|
16537
17062
|
//#region src/main.ts
|
|
16538
|
-
function
|
|
17063
|
+
function cu(e, t = {}) {
|
|
16539
17064
|
let n = {
|
|
16540
|
-
|
|
17065
|
+
...su,
|
|
16541
17066
|
...t
|
|
16542
17067
|
}, r = document.getElementById(e);
|
|
16543
17068
|
if (!r) return Promise.reject(/* @__PURE__ */ Error(`Контейнер с ID "${e}" не найден.`));
|
|
16544
17069
|
let i = document.createElement("canvas");
|
|
16545
17070
|
return i.id = `${e}-canvas`, r.appendChild(i), n.editorContainer = r, new Promise((t) => {
|
|
16546
17071
|
n._onReadyCallback = t;
|
|
16547
|
-
let r = new
|
|
17072
|
+
let r = new ou(i.id, n);
|
|
16548
17073
|
window[e] = r;
|
|
16549
17074
|
});
|
|
16550
17075
|
}
|
|
16551
17076
|
//#endregion
|
|
16552
|
-
export {
|
|
17077
|
+
export { cu as default };
|
|
16553
17078
|
|
|
16554
17079
|
//# sourceMappingURL=main.js.map
|