@anu3ev/fabric-image-editor 0.5.7 → 0.5.8
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 +358 -341
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -2,24 +2,24 @@ var ds = Object.defineProperty, ls = Object.defineProperties;
|
|
|
2
2
|
var hs = Object.getOwnPropertyDescriptors;
|
|
3
3
|
var Gt = Object.getOwnPropertySymbols;
|
|
4
4
|
var _e = Object.prototype.hasOwnProperty, Ne = Object.prototype.propertyIsEnumerable;
|
|
5
|
-
var Re = (
|
|
5
|
+
var Re = (l, t, e) => t in l ? ds(l, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : l[t] = e, _ = (l, t) => {
|
|
6
6
|
for (var e in t || (t = {}))
|
|
7
|
-
_e.call(t, e) && Re(
|
|
7
|
+
_e.call(t, e) && Re(l, e, t[e]);
|
|
8
8
|
if (Gt)
|
|
9
9
|
for (var e of Gt(t))
|
|
10
|
-
Ne.call(t, e) && Re(
|
|
11
|
-
return
|
|
12
|
-
}, yt = (
|
|
13
|
-
var vt = (
|
|
10
|
+
Ne.call(t, e) && Re(l, e, t[e]);
|
|
11
|
+
return l;
|
|
12
|
+
}, yt = (l, t) => ls(l, hs(t));
|
|
13
|
+
var vt = (l, t) => {
|
|
14
14
|
var e = {};
|
|
15
|
-
for (var s in
|
|
16
|
-
_e.call(
|
|
17
|
-
if (
|
|
18
|
-
for (var s of Gt(
|
|
19
|
-
t.indexOf(s) < 0 && Ne.call(
|
|
15
|
+
for (var s in l)
|
|
16
|
+
_e.call(l, s) && t.indexOf(s) < 0 && (e[s] = l[s]);
|
|
17
|
+
if (l != null && Gt)
|
|
18
|
+
for (var s of Gt(l))
|
|
19
|
+
t.indexOf(s) < 0 && Ne.call(l, s) && (e[s] = l[s]);
|
|
20
20
|
return e;
|
|
21
21
|
};
|
|
22
|
-
var N = (
|
|
22
|
+
var N = (l, t, e) => new Promise((s, o) => {
|
|
23
23
|
var n = (r) => {
|
|
24
24
|
try {
|
|
25
25
|
a(e.next(r));
|
|
@@ -33,7 +33,7 @@ var N = (h, t, e) => new Promise((s, o) => {
|
|
|
33
33
|
o(c);
|
|
34
34
|
}
|
|
35
35
|
}, a = (r) => r.done ? s(r.value) : Promise.resolve(r.value).then(n, i);
|
|
36
|
-
a((e = e.apply(
|
|
36
|
+
a((e = e.apply(l, t)).next());
|
|
37
37
|
});
|
|
38
38
|
import { ActiveSelection as k, Textbox as nt, util as dt, controlsUtils as xe, InteractiveFabricObject as Be, Point as tt, FitContentLayout as ke, loadSVGFromURL as us, FabricImage as zt, Gradient as ze, Rect as gs, Circle as fs, Triangle as ps, Group as Et, Color as ms, classRegistry as Pe, loadSVGFromString as ys, Canvas as vs, Pattern as bs } from "fabric";
|
|
39
39
|
import { create as Ms } from "jsondiffpatch";
|
|
@@ -361,11 +361,11 @@ class Ut {
|
|
|
361
361
|
if (c != null && c.length && r)
|
|
362
362
|
for (const d of c)
|
|
363
363
|
try {
|
|
364
|
-
const
|
|
365
|
-
if (
|
|
364
|
+
const h = r;
|
|
365
|
+
if (h.matches && h.matches(d) || h.closest && h.closest(d))
|
|
366
366
|
return !0;
|
|
367
|
-
} catch (
|
|
368
|
-
console.warn(`Error checking selection container with selector "${d}":`,
|
|
367
|
+
} catch (h) {
|
|
368
|
+
console.warn(`Error checking selection container with selector "${d}":`, h);
|
|
369
369
|
}
|
|
370
370
|
}
|
|
371
371
|
return !1;
|
|
@@ -409,11 +409,11 @@ class As {
|
|
|
409
409
|
return this.loaders[t] ? (this.cache.has(t) || this.cache.set(t, this.loaders[t]()), this.cache.get(t)) : Promise.reject(new Error(`Unknown module "${t}"`));
|
|
410
410
|
}
|
|
411
411
|
}
|
|
412
|
-
function js(
|
|
412
|
+
function js(l) {
|
|
413
413
|
return new Worker(
|
|
414
414
|
"" + new URL("assets/worker-CN39s7P7.js", import.meta.url).href,
|
|
415
415
|
{
|
|
416
|
-
name:
|
|
416
|
+
name: l == null ? void 0 : l.name
|
|
417
417
|
}
|
|
418
418
|
);
|
|
419
419
|
}
|
|
@@ -464,23 +464,23 @@ class Is {
|
|
|
464
464
|
}
|
|
465
465
|
}
|
|
466
466
|
const rt = 12, Cs = 2, le = 8, he = 20, Ts = 100, ue = 20, ge = 8, Es = 100, qt = 32, ye = 1, Os = "#2B2D33", ve = "#3D8BF4", be = "#FFFFFF";
|
|
467
|
-
function Vt(
|
|
467
|
+
function Vt(l, t, e, s, o) {
|
|
468
468
|
const n = rt, i = Cs;
|
|
469
|
-
|
|
469
|
+
l.save(), l.translate(t, e), l.rotate(dt.degreesToRadians(o.angle)), l.fillStyle = be, l.strokeStyle = ve, l.lineWidth = ye, l.beginPath(), l.roundRect(-n / 2, -n / 2, n, n, i), l.fill(), l.stroke(), l.restore();
|
|
470
470
|
}
|
|
471
|
-
function Ue(
|
|
471
|
+
function Ue(l, t, e, s, o) {
|
|
472
472
|
const n = le, i = he, a = Ts;
|
|
473
|
-
|
|
473
|
+
l.save(), l.translate(t, e), l.rotate(dt.degreesToRadians(o.angle)), l.fillStyle = be, l.strokeStyle = ve, l.lineWidth = ye, l.beginPath(), l.roundRect(-n / 2, -i / 2, n, i, a), l.fill(), l.stroke(), l.restore();
|
|
474
474
|
}
|
|
475
|
-
function Ye(
|
|
475
|
+
function Ye(l, t, e, s, o) {
|
|
476
476
|
const n = ue, i = ge, a = Es;
|
|
477
|
-
|
|
477
|
+
l.save(), l.translate(t, e), l.rotate(dt.degreesToRadians(o.angle)), l.fillStyle = be, l.strokeStyle = ve, l.lineWidth = ye, l.beginPath(), l.roundRect(-n / 2, -i / 2, n, i, a), l.fill(), l.stroke(), l.restore();
|
|
478
478
|
}
|
|
479
479
|
const Ls = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTE4Ljc1IDQuMzc1djMuNzVhLjYyNS42MjUgMCAwIDEtLjYyNS42MjVoLTMuNzVhLjYyNS42MjUgMCAwIDEgMC0xLjI1aDIuMTRsLTIuMDc3LTEuOTAzLS4wMi0uMDE5YTYuMjUgNi4yNSAwIDEgMC0uMTMgOC45NjcuNjI2LjYyNiAwIDAgMSAuODYuOTA5QTcuNDU2IDcuNDU2IDAgMCAxIDEwIDE3LjVoLS4xMDNhNy41IDcuNSAwIDEgMSA1LjM5Ni0xMi44MTJMMTcuNSA2LjcwM1Y0LjM3NWEuNjI1LjYyNSAwIDAgMSAxLjI1IDBaIi8+PC9zdmc+", es = new Image();
|
|
480
480
|
es.src = Ls;
|
|
481
|
-
function Ds(
|
|
481
|
+
function Ds(l, t, e, s, o) {
|
|
482
482
|
const i = qt / 2;
|
|
483
|
-
|
|
483
|
+
l.save(), l.translate(t, e), l.rotate(dt.degreesToRadians(o.angle)), l.fillStyle = Os, l.beginPath(), l.arc(0, 0, i, 0, 2 * Math.PI), l.fill(), l.drawImage(es, -i / 2, -i / 2, i, i), l.restore();
|
|
484
484
|
}
|
|
485
485
|
const Rs = {
|
|
486
486
|
// Угловые точки
|
|
@@ -602,14 +602,14 @@ class J {
|
|
|
602
602
|
});
|
|
603
603
|
if (!a)
|
|
604
604
|
return e ? e.apply(this, n) : void 0;
|
|
605
|
-
const { left: r, top: c, width: d, height:
|
|
605
|
+
const { left: r, top: c, width: d, height: h } = a;
|
|
606
606
|
this.set({
|
|
607
607
|
flipX: !1,
|
|
608
608
|
flipY: !1,
|
|
609
609
|
width: d,
|
|
610
|
-
height:
|
|
610
|
+
height: h
|
|
611
611
|
});
|
|
612
|
-
const u = new tt(r + d / 2, c +
|
|
612
|
+
const u = new tt(r + d / 2, c + h / 2);
|
|
613
613
|
return this.setPositionByOrigin(u, "center", "center"), a;
|
|
614
614
|
};
|
|
615
615
|
const s = t._onAfterObjectsChange;
|
|
@@ -624,7 +624,7 @@ class J {
|
|
|
624
624
|
objects: r
|
|
625
625
|
});
|
|
626
626
|
if (!c) return a;
|
|
627
|
-
const { left: d, top:
|
|
627
|
+
const { left: d, top: h, width: u, height: g } = c, f = new tt(d + u / 2, h + g / 2);
|
|
628
628
|
return this.set({
|
|
629
629
|
width: u,
|
|
630
630
|
height: g
|
|
@@ -644,7 +644,7 @@ class J {
|
|
|
644
644
|
const d = J.calculateActiveSelectionBounds({ objects: n });
|
|
645
645
|
if (!d)
|
|
646
646
|
return o.call(this, n, i);
|
|
647
|
-
const { left:
|
|
647
|
+
const { left: h, top: u, width: g, height: f } = d, p = new tt(g, f), m = new tt(h + g / 2, u + f / 2);
|
|
648
648
|
return r === "initialization" ? {
|
|
649
649
|
center: m,
|
|
650
650
|
relativeCorrection: new tt(0, 0),
|
|
@@ -720,8 +720,8 @@ const B = class B {
|
|
|
720
720
|
const u = yield new FontFace(o, i, t.descriptors).load();
|
|
721
721
|
e.fonts.add(u), B.registeredFontKeys.add(r);
|
|
722
722
|
return;
|
|
723
|
-
} catch (
|
|
724
|
-
console.warn(`Не удалось загрузить шрифт "${o}" через FontFace API`,
|
|
723
|
+
} catch (h) {
|
|
724
|
+
console.warn(`Не удалось загрузить шрифт "${o}" через FontFace API`, h);
|
|
725
725
|
}
|
|
726
726
|
B.injectFontFace({
|
|
727
727
|
font: t,
|
|
@@ -747,7 +747,7 @@ const B = class B {
|
|
|
747
747
|
"@font-face {",
|
|
748
748
|
` font-family: ${B.formatFontFamilyForCss(i)};`,
|
|
749
749
|
` src: ${e};`,
|
|
750
|
-
...r.map((
|
|
750
|
+
...r.map((h) => ` ${h}`),
|
|
751
751
|
"}"
|
|
752
752
|
];
|
|
753
753
|
a.textContent = c.join(`
|
|
@@ -932,29 +932,29 @@ const _s = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMj
|
|
|
932
932
|
sendBackwards: ks
|
|
933
933
|
},
|
|
934
934
|
handlers: {
|
|
935
|
-
copyPaste: (
|
|
936
|
-
|
|
935
|
+
copyPaste: (l) => N(null, null, function* () {
|
|
936
|
+
l.clipboardManager.copyPaste();
|
|
937
937
|
}),
|
|
938
|
-
delete: (
|
|
939
|
-
|
|
938
|
+
delete: (l) => {
|
|
939
|
+
l.deletionManager.deleteSelectedObjects();
|
|
940
940
|
},
|
|
941
|
-
lock: (
|
|
942
|
-
|
|
941
|
+
lock: (l) => {
|
|
942
|
+
l.objectLockManager.lockObject();
|
|
943
943
|
},
|
|
944
|
-
unlock: (
|
|
945
|
-
|
|
944
|
+
unlock: (l) => {
|
|
945
|
+
l.objectLockManager.unlockObject();
|
|
946
946
|
},
|
|
947
|
-
bringForward: (
|
|
948
|
-
|
|
947
|
+
bringForward: (l) => {
|
|
948
|
+
l.layerManager.bringForward();
|
|
949
949
|
},
|
|
950
|
-
bringToFront: (
|
|
951
|
-
|
|
950
|
+
bringToFront: (l) => {
|
|
951
|
+
l.layerManager.bringToFront();
|
|
952
952
|
},
|
|
953
|
-
sendToBack: (
|
|
954
|
-
|
|
953
|
+
sendToBack: (l) => {
|
|
954
|
+
l.layerManager.sendToBack();
|
|
955
955
|
},
|
|
956
|
-
sendBackwards: (
|
|
957
|
-
|
|
956
|
+
sendBackwards: (l) => {
|
|
957
|
+
l.layerManager.sendBackwards();
|
|
958
958
|
}
|
|
959
959
|
}
|
|
960
960
|
};
|
|
@@ -1381,14 +1381,14 @@ class Jt {
|
|
|
1381
1381
|
if (!t) return;
|
|
1382
1382
|
console.log("loadStateFromFullState fullState", t);
|
|
1383
1383
|
const { canvas: e, canvasManager: s, interactionBlocker: o, backgroundManager: n } = this.editor, { width: i, height: a } = e;
|
|
1384
|
-
o.overlayMask = null, Jt._serializeCustomData(t), yield e.loadFromJSON(t, (
|
|
1385
|
-
Jt._deserializeCustomData(
|
|
1384
|
+
o.overlayMask = null, Jt._serializeCustomData(t), yield e.loadFromJSON(t, (h, u) => {
|
|
1385
|
+
Jt._deserializeCustomData(h, u);
|
|
1386
1386
|
});
|
|
1387
|
-
const r = e.getObjects().find((
|
|
1387
|
+
const r = e.getObjects().find((h) => h.id === "montage-area");
|
|
1388
1388
|
r && (this.editor.montageArea = r, (i !== e.getWidth() || a !== e.getHeight()) && s.updateCanvas());
|
|
1389
|
-
const c = e.getObjects().find((
|
|
1389
|
+
const c = e.getObjects().find((h) => h.id === "overlay-mask");
|
|
1390
1390
|
c && (o.overlayMask = c, o.overlayMask.visible = !1);
|
|
1391
|
-
const d = e.getObjects().find((
|
|
1391
|
+
const d = e.getObjects().find((h) => h.id === "background");
|
|
1392
1392
|
d ? (n.backgroundObject = d, n.refresh()) : n.removeBackground({ withoutSave: !0 }), e.renderAll(), e.fire("editor:history-state-loaded", {
|
|
1393
1393
|
fullState: t,
|
|
1394
1394
|
currentIndex: this.currentIndex,
|
|
@@ -1479,8 +1479,8 @@ class Jt {
|
|
|
1479
1479
|
((i = (n = (o = this.canvas).getObjects) == null ? void 0 : n.call(o)) != null ? i : []).forEach((a) => {
|
|
1480
1480
|
const r = typeof a.type == "string" ? a.type.toLowerCase() : "";
|
|
1481
1481
|
if (!(r === "textbox" || r === "i-text" || typeof a.isEditing == "boolean") || a.locked) return;
|
|
1482
|
-
const d = !!a.lockMovementX,
|
|
1483
|
-
!d && !
|
|
1482
|
+
const d = !!a.lockMovementX, h = !!a.lockMovementY;
|
|
1483
|
+
!d && !h || (e.push({
|
|
1484
1484
|
object: a,
|
|
1485
1485
|
lockMovementX: a.lockMovementX,
|
|
1486
1486
|
lockMovementY: a.lockMovementY,
|
|
@@ -1538,7 +1538,7 @@ class ct {
|
|
|
1538
1538
|
withoutSelection: a = !1
|
|
1539
1539
|
} = t;
|
|
1540
1540
|
if (!e) return null;
|
|
1541
|
-
const { canvas: r, montageArea: c, transformManager: d, historyManager:
|
|
1541
|
+
const { canvas: r, montageArea: c, transformManager: d, historyManager: h, errorManager: u } = this.editor, g = yield this.getContentType(e), f = ct.getFormatFromContentType(g), { acceptContentTypes: p, acceptFormats: m } = this;
|
|
1542
1542
|
if (!this.isAllowedContentType(g)) {
|
|
1543
1543
|
const v = `Неверный contentType для изображения: ${g}. Ожидается один из: ${this.acceptContentTypes.join(", ")}.`;
|
|
1544
1544
|
return u.emitError({
|
|
@@ -1558,7 +1558,7 @@ class ct {
|
|
|
1558
1558
|
}
|
|
1559
1559
|
}), null;
|
|
1560
1560
|
}
|
|
1561
|
-
|
|
1561
|
+
h.suspendHistory();
|
|
1562
1562
|
try {
|
|
1563
1563
|
let v, b;
|
|
1564
1564
|
if (e instanceof File)
|
|
@@ -1606,7 +1606,7 @@ class ct {
|
|
|
1606
1606
|
const { width: A, height: j } = c, M = this.calculateScaleFactor({ imageObject: b, scaleType: s });
|
|
1607
1607
|
s === "image-contain" && M < 1 ? d.fitObject({ object: b, type: "contain", withoutSave: !0 }) : s === "image-cover" && (I > A || y > j) && d.fitObject({ object: b, type: "cover", withoutSave: !0 });
|
|
1608
1608
|
}
|
|
1609
|
-
r.add(b), r.centerObject(b), a || r.setActiveObject(b), r.renderAll(),
|
|
1609
|
+
r.add(b), r.centerObject(b), a || r.setActiveObject(b), r.renderAll(), h.resumeHistory(), o || h.saveState();
|
|
1610
1610
|
const w = {
|
|
1611
1611
|
image: b,
|
|
1612
1612
|
format: f,
|
|
@@ -1635,7 +1635,7 @@ class ct {
|
|
|
1635
1635
|
isBackground: i,
|
|
1636
1636
|
withoutSelection: a
|
|
1637
1637
|
}
|
|
1638
|
-
}),
|
|
1638
|
+
}), h.resumeHistory(), null;
|
|
1639
1639
|
}
|
|
1640
1640
|
});
|
|
1641
1641
|
}
|
|
@@ -1688,10 +1688,10 @@ class ct {
|
|
|
1688
1688
|
exportAsBlob: n = !1
|
|
1689
1689
|
} = t, { canvas: i, montageArea: a, workerManager: r, interactionBlocker: c } = this.editor;
|
|
1690
1690
|
try {
|
|
1691
|
-
const d = s === "application/pdf",
|
|
1691
|
+
const d = s === "application/pdf", h = d ? "image/jpg" : s, u = ct.getFormatFromContentType(h);
|
|
1692
1692
|
a.setCoords();
|
|
1693
1693
|
const { left: g, top: f, width: p, height: m } = a.getBoundingRect(), v = yield i.clone(["id", "format", "locked"]);
|
|
1694
|
-
v.enableRetinaScaling = !1, ["image/jpg", "image/jpeg"].includes(
|
|
1694
|
+
v.enableRetinaScaling = !1, ["image/jpg", "image/jpeg"].includes(h) && (v.backgroundColor = "#ffffff");
|
|
1695
1695
|
const b = v.getObjects().find((S) => S.id === a.id);
|
|
1696
1696
|
if (b && (b.visible = !1), c != null && c.isBlocked) {
|
|
1697
1697
|
const S = v.getObjects().find((C) => C.id === c.overlayMask.id);
|
|
@@ -1723,7 +1723,7 @@ class ct {
|
|
|
1723
1723
|
const S = {
|
|
1724
1724
|
image: y,
|
|
1725
1725
|
format: u,
|
|
1726
|
-
contentType:
|
|
1726
|
+
contentType: h,
|
|
1727
1727
|
fileName: e
|
|
1728
1728
|
};
|
|
1729
1729
|
return i.fire("editor:canvas-exported", S), S;
|
|
@@ -1760,15 +1760,15 @@ class ct {
|
|
|
1760
1760
|
const S = {
|
|
1761
1761
|
image: A,
|
|
1762
1762
|
format: u,
|
|
1763
|
-
contentType:
|
|
1763
|
+
contentType: h,
|
|
1764
1764
|
fileName: e
|
|
1765
1765
|
};
|
|
1766
1766
|
return i.fire("editor:canvas-exported", S), S;
|
|
1767
1767
|
}
|
|
1768
1768
|
const j = u === "svg" && !I ? e.replace(/\.[^/.]+$/, ".png") : e, T = {
|
|
1769
|
-
image: new File([y], j, { type:
|
|
1769
|
+
image: new File([y], j, { type: h }),
|
|
1770
1770
|
format: u,
|
|
1771
|
-
contentType:
|
|
1771
|
+
contentType: h,
|
|
1772
1772
|
fileName: j
|
|
1773
1773
|
};
|
|
1774
1774
|
return i.fire("editor:canvas-exported", T), T;
|
|
@@ -1845,10 +1845,10 @@ class ct {
|
|
|
1845
1845
|
};
|
|
1846
1846
|
return a.fire("editor:object-exported", v), v;
|
|
1847
1847
|
}
|
|
1848
|
-
const
|
|
1848
|
+
const h = c.toCanvasElement({
|
|
1849
1849
|
enableRetinaScaling: !1
|
|
1850
1850
|
}), u = yield new Promise((p, m) => {
|
|
1851
|
-
|
|
1851
|
+
h.toBlob((v) => {
|
|
1852
1852
|
v ? p(v) : m(new Error("Failed to create Blob from canvas"));
|
|
1853
1853
|
});
|
|
1854
1854
|
});
|
|
@@ -1998,9 +1998,9 @@ class ct {
|
|
|
1998
1998
|
return e ? e[1] : "";
|
|
1999
1999
|
}
|
|
2000
2000
|
}
|
|
2001
|
-
const Tt = (
|
|
2002
|
-
function Ks(
|
|
2003
|
-
return ((
|
|
2001
|
+
const Tt = (l, t, e) => Math.max(Math.min(l, e), t), Ge = (l, t) => l * t, Xs = (l, t) => new tt(l / 2, t / 2);
|
|
2002
|
+
function Ks(l) {
|
|
2003
|
+
return ((l == null ? void 0 : l.type) === "image" || (l == null ? void 0 : l.format) === "svg") && typeof (l == null ? void 0 : l.width) == "number" && typeof (l == null ? void 0 : l.height) == "number";
|
|
2004
2004
|
}
|
|
2005
2005
|
class Qs {
|
|
2006
2006
|
/**
|
|
@@ -2039,8 +2039,8 @@ class Qs {
|
|
|
2039
2039
|
this.setResolutionHeight(m);
|
|
2040
2040
|
return;
|
|
2041
2041
|
}
|
|
2042
|
-
const { left:
|
|
2043
|
-
n.setViewportTransform([g, 0, 0, g,
|
|
2042
|
+
const { left: h, top: u } = this.getObjectDefaultCoords(i), g = n.getZoom();
|
|
2043
|
+
n.setViewportTransform([g, 0, 0, g, h, u]), this.centerMontageArea(), s || this.editor.historyManager.saveState(), n.fire("editor:resolution-width-changed", {
|
|
2044
2044
|
width: d,
|
|
2045
2045
|
preserveProportional: e,
|
|
2046
2046
|
withoutSave: s,
|
|
@@ -2069,8 +2069,8 @@ class Qs {
|
|
|
2069
2069
|
this.setResolutionWidth(m);
|
|
2070
2070
|
return;
|
|
2071
2071
|
}
|
|
2072
|
-
const { left:
|
|
2073
|
-
n.setViewportTransform([g, 0, 0, g,
|
|
2072
|
+
const { left: h, top: u } = this.getObjectDefaultCoords(i), g = n.getZoom();
|
|
2073
|
+
n.setViewportTransform([g, 0, 0, g, h, u]), this.centerMontageArea(), s || this.editor.historyManager.saveState(), n.fire("editor:resolution-height-changed", {
|
|
2074
2074
|
height: d,
|
|
2075
2075
|
preserveProportional: e,
|
|
2076
2076
|
withoutSave: s,
|
|
@@ -2156,22 +2156,22 @@ class Qs {
|
|
|
2156
2156
|
if (a !== 0 || r !== 0) {
|
|
2157
2157
|
const c = t.getActiveObject(), d = [];
|
|
2158
2158
|
if ((c == null ? void 0 : c.type) === "activeselection") {
|
|
2159
|
-
const
|
|
2160
|
-
d.push(...
|
|
2159
|
+
const h = c;
|
|
2160
|
+
d.push(...h.getObjects()), t.discardActiveObject();
|
|
2161
2161
|
}
|
|
2162
|
-
if (t.getObjects().forEach((
|
|
2163
|
-
|
|
2164
|
-
left:
|
|
2165
|
-
top:
|
|
2166
|
-
}),
|
|
2162
|
+
if (t.getObjects().forEach((h) => {
|
|
2163
|
+
h.id === "montage-area" || h.id === "overlay-mask" || h.id === "background" || (h.set({
|
|
2164
|
+
left: h.left + a,
|
|
2165
|
+
top: h.top + r
|
|
2166
|
+
}), h.setCoords());
|
|
2167
2167
|
}), d.length > 0)
|
|
2168
2168
|
if (d.length === 1)
|
|
2169
2169
|
t.setActiveObject(d[0]);
|
|
2170
2170
|
else {
|
|
2171
|
-
const
|
|
2171
|
+
const h = new k(d, {
|
|
2172
2172
|
canvas: t
|
|
2173
2173
|
});
|
|
2174
|
-
t.setActiveObject(
|
|
2174
|
+
t.setActiveObject(h);
|
|
2175
2175
|
}
|
|
2176
2176
|
}
|
|
2177
2177
|
t.renderAll(), t.fire("editor:canvas-updated", {
|
|
@@ -2335,16 +2335,16 @@ class Qs {
|
|
|
2335
2335
|
}
|
|
2336
2336
|
} = this.editor, c = t || o.getActiveObject();
|
|
2337
2337
|
if (!Ks(c)) return;
|
|
2338
|
-
const { width: d, height:
|
|
2339
|
-
let u = Math.min(d, Mt), g = Math.min(
|
|
2338
|
+
const { width: d, height: h } = c;
|
|
2339
|
+
let u = Math.min(d, Mt), g = Math.min(h, wt);
|
|
2340
2340
|
if (e) {
|
|
2341
2341
|
const {
|
|
2342
2342
|
width: f,
|
|
2343
2343
|
height: p
|
|
2344
|
-
} = n, m = d / f, v =
|
|
2344
|
+
} = n, m = d / f, v = h / p, b = Math.max(m, v);
|
|
2345
2345
|
u = f * b, g = p * b;
|
|
2346
2346
|
}
|
|
2347
|
-
this.setResolutionWidth(u, { withoutSave: !0 }), this.setResolutionHeight(g, { withoutSave: !0 }), this.editor.backgroundManager.backgroundObject && this.editor.backgroundManager.refresh(), (d > a ||
|
|
2347
|
+
this.setResolutionWidth(u, { withoutSave: !0 }), this.setResolutionHeight(g, { withoutSave: !0 }), this.editor.backgroundManager.backgroundObject && this.editor.backgroundManager.refresh(), (d > a || h > r) && this.editor.zoomManager.calculateAndApplyDefaultZoom(), i.resetObject({ object: c, withoutSave: !0 }), o.centerObject(c), o.renderAll(), s || this.editor.historyManager.saveState(), o.fire("editor:montage-area-scaled-to-image", {
|
|
2348
2348
|
object: c,
|
|
2349
2349
|
width: u,
|
|
2350
2350
|
height: g,
|
|
@@ -2506,7 +2506,7 @@ class qs {
|
|
|
2506
2506
|
* @private
|
|
2507
2507
|
*/
|
|
2508
2508
|
_fitSingleObject(t, e) {
|
|
2509
|
-
const { canvas: s, montageArea: o } = this.editor, { width: n, height: i, scaleX: a = 1, scaleY: r = 1, angle: c = 0 } = t, d = n * Math.abs(a),
|
|
2509
|
+
const { canvas: s, montageArea: o } = this.editor, { width: n, height: i, scaleX: a = 1, scaleY: r = 1, angle: c = 0 } = t, d = n * Math.abs(a), h = i * Math.abs(r), u = c * Math.PI / 180, g = Math.abs(Math.cos(u)), f = Math.abs(Math.sin(u)), p = d * g + h * f, m = d * f + h * g, v = o.width, b = o.height;
|
|
2510
2510
|
let I;
|
|
2511
2511
|
e === "contain" ? I = Math.min(v / p, b / m) : I = Math.max(v / p, b / m), t.set({
|
|
2512
2512
|
scaleX: a * I,
|
|
@@ -2547,11 +2547,11 @@ class qs {
|
|
|
2547
2547
|
}), e)
|
|
2548
2548
|
this.fitObject({ object: c, withoutSave: !0, fitAsOneObject: !0 });
|
|
2549
2549
|
else {
|
|
2550
|
-
const { width:
|
|
2550
|
+
const { width: h, height: u } = n, { width: g, height: f } = c, p = i.calculateScaleFactor({
|
|
2551
2551
|
imageObject: c,
|
|
2552
2552
|
scaleType: r
|
|
2553
2553
|
});
|
|
2554
|
-
r === "contain" && p < 1 || r === "cover" && (g >
|
|
2554
|
+
r === "contain" && p < 1 || r === "cover" && (g > h || f > u) ? this.fitObject({ object: c, withoutSave: !0, fitAsOneObject: !0 }) : c.set({ scaleX: 1, scaleY: 1 });
|
|
2555
2555
|
}
|
|
2556
2556
|
c.set({ flipX: !1, flipY: !1, angle: 0 }), o.centerObject(c), o.renderAll(), a.resumeHistory(), s || a.saveState(), o.fire("editor:object-reset", {
|
|
2557
2557
|
object: c,
|
|
@@ -2584,7 +2584,7 @@ class Js {
|
|
|
2584
2584
|
* @private
|
|
2585
2585
|
*/
|
|
2586
2586
|
_getClampedPointerCoordinates(t) {
|
|
2587
|
-
const { canvas: e, montageArea: s } = this.editor, o = e.getPointer(t, !0), n = e.viewportTransform, i = e.getZoom(), a = s.left - s.width / 2, r = s.left + s.width / 2, c = s.top - s.height / 2, d = s.top + s.height / 2,
|
|
2587
|
+
const { canvas: e, montageArea: s } = this.editor, o = e.getPointer(t, !0), n = e.viewportTransform, i = e.getZoom(), a = s.left - s.width / 2, r = s.left + s.width / 2, c = s.top - s.height / 2, d = s.top + s.height / 2, h = a * i + n[4], u = r * i + n[4], g = c * i + n[5], f = d * i + n[5], p = Math.max(h, Math.min(u, o.x)), m = Math.max(g, Math.min(f, o.y));
|
|
2588
2588
|
return {
|
|
2589
2589
|
x: p,
|
|
2590
2590
|
y: m
|
|
@@ -2619,9 +2619,9 @@ class Js {
|
|
|
2619
2619
|
* @private
|
|
2620
2620
|
*/
|
|
2621
2621
|
_calculateEmptySpaceRatio(t) {
|
|
2622
|
-
const { canvas: e, montageArea: s } = this.editor, o = e.viewportTransform, n = e.getWidth(), i = e.getHeight(), a = s.left - s.width / 2, r = s.left + s.width / 2, c = s.top - s.height / 2, d = s.top + s.height / 2,
|
|
2622
|
+
const { canvas: e, montageArea: s } = this.editor, o = e.viewportTransform, n = e.getWidth(), i = e.getHeight(), a = s.left - s.width / 2, r = s.left + s.width / 2, c = s.top - s.height / 2, d = s.top + s.height / 2, h = -o[4] / t, u = (-o[4] + n) / t, g = -o[5] / t, f = (-o[5] + i) / t, p = h < a, m = u > r, v = g < c, b = f > d;
|
|
2623
2623
|
if (!(p || m || v || b)) return 0;
|
|
2624
|
-
const y = Math.max(0, a -
|
|
2624
|
+
const y = Math.max(0, a - h), w = Math.max(0, u - r), A = Math.max(0, c - g), j = Math.max(0, f - d), M = Math.max(y, w), T = Math.max(A, j), S = M / n, C = T / i;
|
|
2625
2625
|
return Math.max(S, C);
|
|
2626
2626
|
}
|
|
2627
2627
|
/**
|
|
@@ -2635,10 +2635,10 @@ class Js {
|
|
|
2635
2635
|
* @private
|
|
2636
2636
|
*/
|
|
2637
2637
|
_calculateSmoothCenteringStep(t, e, s, o, n) {
|
|
2638
|
-
const { canvas: i, montageArea: a } = this.editor, r = i.viewportTransform, c = i.getWidth(), d = i.getHeight(),
|
|
2638
|
+
const { canvas: i, montageArea: a } = this.editor, r = i.viewportTransform, c = i.getWidth(), d = i.getHeight(), h = t.x - r[4], u = t.y - r[5], g = Math.abs(o), f = e - s;
|
|
2639
2639
|
if (Math.abs(f) / g <= 0.1)
|
|
2640
|
-
return { x:
|
|
2641
|
-
const m = c / 2, v = d / 2, b = a.left, I = a.top, y = m - b * s, w = v - I * s, A = (y - r[4]) / (e - s), j = (w - r[5]) / (e - s), M = A * g, T = j * g, S = M * n, C = T * n, x = Math.abs(S) > Math.abs(
|
|
2640
|
+
return { x: h, y: u };
|
|
2641
|
+
const m = c / 2, v = d / 2, b = a.left, I = a.top, y = m - b * s, w = v - I * s, A = (y - r[4]) / (e - s), j = (w - r[5]) / (e - s), M = A * g, T = j * g, S = M * n, C = T * n, x = Math.abs(S) > Math.abs(h) ? h : S, F = Math.abs(C) > Math.abs(u) ? u : C;
|
|
2642
2642
|
return { x, y: F };
|
|
2643
2643
|
}
|
|
2644
2644
|
/**
|
|
@@ -2712,10 +2712,10 @@ class Js {
|
|
|
2712
2712
|
});
|
|
2713
2713
|
return;
|
|
2714
2714
|
}
|
|
2715
|
-
const
|
|
2715
|
+
const h = this._getClampedPointerCoordinates(e);
|
|
2716
2716
|
this.zoom(t, {
|
|
2717
|
-
pointX:
|
|
2718
|
-
pointY:
|
|
2717
|
+
pointX: h.x,
|
|
2718
|
+
pointY: h.y
|
|
2719
2719
|
});
|
|
2720
2720
|
}
|
|
2721
2721
|
/**
|
|
@@ -2729,13 +2729,13 @@ class Js {
|
|
|
2729
2729
|
zoom(t = He, e = {}) {
|
|
2730
2730
|
var g, f;
|
|
2731
2731
|
if (!t) return;
|
|
2732
|
-
const { minZoom: s, maxZoom: o } = this, { canvas: n } = this.editor, i = t < 0, a = n.getZoom(), r = n.getCenterPoint(), c = (g = e.pointX) != null ? g : r.x, d = (f = e.pointY) != null ? f : r.y,
|
|
2732
|
+
const { minZoom: s, maxZoom: o } = this, { canvas: n } = this.editor, i = t < 0, a = n.getZoom(), r = n.getCenterPoint(), c = (g = e.pointX) != null ? g : r.x, d = (f = e.pointY) != null ? f : r.y, h = new tt(c, d);
|
|
2733
2733
|
this.editor.montageArea.setCoords(), this.editor.canvas.requestRenderAll();
|
|
2734
2734
|
let u = Number((a + Number(t)).toFixed(3));
|
|
2735
|
-
u > o && (u = o), u < s && (u = s), n.zoomToPoint(
|
|
2735
|
+
u > o && (u = o), u < s && (u = s), n.zoomToPoint(h, u), this.editor.panConstraintManager.updateBounds(), this._applyViewportCentering(u, i, t), n.fire("editor:zoom-changed", {
|
|
2736
2736
|
currentZoom: n.getZoom(),
|
|
2737
2737
|
zoom: u,
|
|
2738
|
-
point:
|
|
2738
|
+
point: h
|
|
2739
2739
|
});
|
|
2740
2740
|
}
|
|
2741
2741
|
/**
|
|
@@ -2911,8 +2911,9 @@ class Ot {
|
|
|
2911
2911
|
endColor: s,
|
|
2912
2912
|
startPosition: o,
|
|
2913
2913
|
endPosition: n,
|
|
2914
|
-
|
|
2915
|
-
|
|
2914
|
+
colorStops: i,
|
|
2915
|
+
customData: a = {},
|
|
2916
|
+
withoutSave: r = !1
|
|
2916
2917
|
}) {
|
|
2917
2918
|
this.setGradientBackground({
|
|
2918
2919
|
gradient: {
|
|
@@ -2921,10 +2922,11 @@ class Ot {
|
|
|
2921
2922
|
startColor: e,
|
|
2922
2923
|
endColor: s,
|
|
2923
2924
|
startPosition: o,
|
|
2924
|
-
endPosition: n
|
|
2925
|
+
endPosition: n,
|
|
2926
|
+
colorStops: i
|
|
2925
2927
|
},
|
|
2926
|
-
customData:
|
|
2927
|
-
withoutSave:
|
|
2928
|
+
customData: a,
|
|
2929
|
+
withoutSave: r
|
|
2928
2930
|
});
|
|
2929
2931
|
}
|
|
2930
2932
|
/**
|
|
@@ -2939,8 +2941,9 @@ class Ot {
|
|
|
2939
2941
|
endColor: n,
|
|
2940
2942
|
startPosition: i,
|
|
2941
2943
|
endPosition: a,
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
+
colorStops: r,
|
|
2945
|
+
customData: c = {},
|
|
2946
|
+
withoutSave: d = !1
|
|
2944
2947
|
}) {
|
|
2945
2948
|
this.setGradientBackground({
|
|
2946
2949
|
gradient: {
|
|
@@ -2951,10 +2954,11 @@ class Ot {
|
|
|
2951
2954
|
startColor: o,
|
|
2952
2955
|
endColor: n,
|
|
2953
2956
|
startPosition: i,
|
|
2954
|
-
endPosition: a
|
|
2957
|
+
endPosition: a,
|
|
2958
|
+
colorStops: r
|
|
2955
2959
|
},
|
|
2956
|
-
customData:
|
|
2957
|
-
withoutSave:
|
|
2960
|
+
customData: c,
|
|
2961
|
+
withoutSave: d
|
|
2958
2962
|
});
|
|
2959
2963
|
}
|
|
2960
2964
|
/**
|
|
@@ -3095,37 +3099,45 @@ class Ot {
|
|
|
3095
3099
|
startColor: e,
|
|
3096
3100
|
endColor: s,
|
|
3097
3101
|
startPosition: o = 0,
|
|
3098
|
-
endPosition: n = 100
|
|
3099
|
-
|
|
3102
|
+
endPosition: n = 100,
|
|
3103
|
+
colorStops: i
|
|
3104
|
+
} = t;
|
|
3105
|
+
let a;
|
|
3106
|
+
if (i && i.length > 0 ? a = i.map((u) => ({
|
|
3107
|
+
offset: u.offset / 100,
|
|
3108
|
+
color: u.color
|
|
3109
|
+
})) : e && s ? a = [
|
|
3100
3110
|
{ offset: o / 100, color: e },
|
|
3101
3111
|
{ offset: n / 100, color: s }
|
|
3102
|
-
]
|
|
3103
|
-
|
|
3104
|
-
|
|
3112
|
+
] : a = [
|
|
3113
|
+
{ offset: 0, color: "#000000" },
|
|
3114
|
+
{ offset: 1, color: "#ffffff" }
|
|
3115
|
+
], t.type === "linear") {
|
|
3116
|
+
const u = t.angle * Math.PI / 180, g = Ot._angleToCoords(u);
|
|
3105
3117
|
return new ze({
|
|
3106
3118
|
type: "linear",
|
|
3107
3119
|
gradientUnits: "percentage",
|
|
3108
|
-
coords:
|
|
3109
|
-
colorStops:
|
|
3120
|
+
coords: g,
|
|
3121
|
+
colorStops: a
|
|
3110
3122
|
});
|
|
3111
3123
|
}
|
|
3112
3124
|
const {
|
|
3113
|
-
centerX:
|
|
3114
|
-
centerY:
|
|
3115
|
-
radius:
|
|
3116
|
-
} = t,
|
|
3117
|
-
x1:
|
|
3118
|
-
y1:
|
|
3119
|
-
x2:
|
|
3120
|
-
y2:
|
|
3125
|
+
centerX: r = 50,
|
|
3126
|
+
centerY: c = 50,
|
|
3127
|
+
radius: d = 50
|
|
3128
|
+
} = t, h = {
|
|
3129
|
+
x1: r / 100,
|
|
3130
|
+
y1: c / 100,
|
|
3131
|
+
x2: r / 100,
|
|
3132
|
+
y2: c / 100,
|
|
3121
3133
|
r1: 0,
|
|
3122
|
-
r2:
|
|
3134
|
+
r2: d / 100
|
|
3123
3135
|
};
|
|
3124
3136
|
return new ze({
|
|
3125
3137
|
type: "radial",
|
|
3126
3138
|
gradientUnits: "percentage",
|
|
3127
|
-
coords:
|
|
3128
|
-
colorStops:
|
|
3139
|
+
coords: h,
|
|
3140
|
+
colorStops: a
|
|
3129
3141
|
});
|
|
3130
3142
|
}
|
|
3131
3143
|
/**
|
|
@@ -3309,14 +3321,14 @@ class to {
|
|
|
3309
3321
|
* @param flags.withoutAdding - Не добавлять объект в canvas
|
|
3310
3322
|
*/
|
|
3311
3323
|
addRectangle(d = {}, { withoutSelection: r, withoutAdding: c } = {}) {
|
|
3312
|
-
var
|
|
3324
|
+
var h = d, {
|
|
3313
3325
|
id: t = `rect-${G()}`,
|
|
3314
3326
|
left: e,
|
|
3315
3327
|
top: s,
|
|
3316
3328
|
width: o = 100,
|
|
3317
3329
|
height: n = 100,
|
|
3318
3330
|
fill: i = "blue"
|
|
3319
|
-
} =
|
|
3331
|
+
} = h, a = vt(h, [
|
|
3320
3332
|
"id",
|
|
3321
3333
|
"left",
|
|
3322
3334
|
"top",
|
|
@@ -3364,14 +3376,14 @@ class to {
|
|
|
3364
3376
|
"radius",
|
|
3365
3377
|
"fill"
|
|
3366
3378
|
]);
|
|
3367
|
-
const { canvas:
|
|
3379
|
+
const { canvas: h } = this.editor, u = new fs(_({
|
|
3368
3380
|
id: t,
|
|
3369
3381
|
left: e,
|
|
3370
3382
|
top: s,
|
|
3371
3383
|
fill: n,
|
|
3372
3384
|
radius: o
|
|
3373
3385
|
}, i));
|
|
3374
|
-
return !e && !s &&
|
|
3386
|
+
return !e && !s && h.centerObject(u), r || (h.add(u), a || h.setActiveObject(u), h.renderAll()), u;
|
|
3375
3387
|
}
|
|
3376
3388
|
/**
|
|
3377
3389
|
* Добавление треугольника
|
|
@@ -3391,14 +3403,14 @@ class to {
|
|
|
3391
3403
|
* @param flags.withoutAdding - Не добавлять объект в canvas
|
|
3392
3404
|
*/
|
|
3393
3405
|
addTriangle(d = {}, { withoutSelection: r, withoutAdding: c } = {}) {
|
|
3394
|
-
var
|
|
3406
|
+
var h = d, {
|
|
3395
3407
|
id: t = `triangle-${G()}`,
|
|
3396
3408
|
left: e,
|
|
3397
3409
|
top: s,
|
|
3398
3410
|
width: o = 100,
|
|
3399
3411
|
height: n = 100,
|
|
3400
3412
|
fill: i = "yellow"
|
|
3401
|
-
} =
|
|
3413
|
+
} = h, a = vt(h, [
|
|
3402
3414
|
"id",
|
|
3403
3415
|
"left",
|
|
3404
3416
|
"top",
|
|
@@ -3495,8 +3507,8 @@ class eo {
|
|
|
3495
3507
|
return N(this, null, function* () {
|
|
3496
3508
|
try {
|
|
3497
3509
|
const o = t.toCanvasElement({ enableRetinaScaling: !1 }).toDataURL(), n = o.slice(5).split(";")[0], i = o.split(",")[1], a = atob(i), r = new Uint8Array(a.length);
|
|
3498
|
-
for (let
|
|
3499
|
-
r[
|
|
3510
|
+
for (let h = 0; h < a.length; h += 1)
|
|
3511
|
+
r[h] = a.charCodeAt(h);
|
|
3500
3512
|
const c = new Blob([r.buffer], { type: n }), d = new ClipboardItem({ [n]: c });
|
|
3501
3513
|
return yield navigator.clipboard.write([d]), console.info("Image copied to clipboard successfully"), !0;
|
|
3502
3514
|
} catch (s) {
|
|
@@ -3615,13 +3627,13 @@ class eo {
|
|
|
3615
3627
|
if (n.type !== "text/html" && i) {
|
|
3616
3628
|
const c = new FileReader();
|
|
3617
3629
|
c.onload = (d) => {
|
|
3618
|
-
d.target && this._handleImageImport(d.target.result).catch((
|
|
3630
|
+
d.target && this._handleImageImport(d.target.result).catch((h) => {
|
|
3619
3631
|
this.editor.errorManager.emitError({
|
|
3620
3632
|
origin: "ClipboardManager",
|
|
3621
3633
|
method: "handlePasteEvent",
|
|
3622
3634
|
code: "PASTE_IMAGE_FAILED",
|
|
3623
3635
|
message: "Ошибка вставки изображения из буфера обмена",
|
|
3624
|
-
data:
|
|
3636
|
+
data: h
|
|
3625
3637
|
});
|
|
3626
3638
|
});
|
|
3627
3639
|
}, c.readAsDataURL(i);
|
|
@@ -3629,9 +3641,9 @@ class eo {
|
|
|
3629
3641
|
}
|
|
3630
3642
|
const a = t.getData("text/html");
|
|
3631
3643
|
if (a) {
|
|
3632
|
-
const
|
|
3633
|
-
if (
|
|
3634
|
-
this._handleImageImport(
|
|
3644
|
+
const h = new DOMParser().parseFromString(a, "text/html").querySelector("img");
|
|
3645
|
+
if (h != null && h.src) {
|
|
3646
|
+
this._handleImageImport(h.src).catch((u) => {
|
|
3635
3647
|
this.editor.errorManager.emitError({
|
|
3636
3648
|
origin: "ClipboardManager",
|
|
3637
3649
|
method: "handlePasteEvent",
|
|
@@ -3828,8 +3840,8 @@ class so {
|
|
|
3828
3840
|
const i = [];
|
|
3829
3841
|
n.forEach((c) => {
|
|
3830
3842
|
const d = c.removeAll();
|
|
3831
|
-
s.remove(c), d.forEach((
|
|
3832
|
-
s.add(
|
|
3843
|
+
s.remove(c), d.forEach((h) => {
|
|
3844
|
+
s.add(h), i.push(h);
|
|
3833
3845
|
});
|
|
3834
3846
|
});
|
|
3835
3847
|
const a = new k(i, {
|
|
@@ -3910,8 +3922,8 @@ class we {
|
|
|
3910
3922
|
const r = [];
|
|
3911
3923
|
if (a.forEach((d) => {
|
|
3912
3924
|
if (we._isUngroupableGroup(d)) {
|
|
3913
|
-
const
|
|
3914
|
-
r.push(...
|
|
3925
|
+
const h = this._handleGroupDeletion(d);
|
|
3926
|
+
r.push(...h);
|
|
3915
3927
|
return;
|
|
3916
3928
|
}
|
|
3917
3929
|
o.remove(d), r.push(d);
|
|
@@ -4161,12 +4173,12 @@ class no {
|
|
|
4161
4173
|
constrainPan(t, e) {
|
|
4162
4174
|
if (!this.currentBounds || !this.currentBounds.canPan)
|
|
4163
4175
|
return { x: 0, y: 0 };
|
|
4164
|
-
const { canvas: s, montageArea: o } = this.editor, n = s.getZoom(), i = o.left, a = o.top, r = s.getWidth() / 2, c = s.getHeight() / 2, d = i * n + t - r,
|
|
4176
|
+
const { canvas: s, montageArea: o } = this.editor, n = s.getZoom(), i = o.left, a = o.top, r = s.getWidth() / 2, c = s.getHeight() / 2, d = i * n + t - r, h = a * n + e - c, u = Math.max(
|
|
4165
4177
|
this.currentBounds.minX,
|
|
4166
4178
|
Math.min(this.currentBounds.maxX, d)
|
|
4167
4179
|
), g = Math.max(
|
|
4168
4180
|
this.currentBounds.minY,
|
|
4169
|
-
Math.min(this.currentBounds.maxY,
|
|
4181
|
+
Math.min(this.currentBounds.maxY, h)
|
|
4170
4182
|
), f = u + r - i * n, p = g + c - a * n;
|
|
4171
4183
|
return {
|
|
4172
4184
|
x: f,
|
|
@@ -4197,13 +4209,13 @@ class no {
|
|
|
4197
4209
|
}
|
|
4198
4210
|
}
|
|
4199
4211
|
const at = ({
|
|
4200
|
-
value:
|
|
4212
|
+
value: l,
|
|
4201
4213
|
min: t,
|
|
4202
4214
|
max: e
|
|
4203
|
-
}) => Math.min(Math.max(
|
|
4215
|
+
}) => Math.min(Math.max(l, t), e), Dt = class Dt extends nt {
|
|
4204
4216
|
constructor(t, e = {}) {
|
|
4205
|
-
var s, o, n, i, a, r, c, d,
|
|
4206
|
-
super(t, e), this.backgroundOpacity = (s = e.backgroundOpacity) != null ? s : 1, this.paddingTop = (o = e.paddingTop) != null ? o : 0, this.paddingRight = (n = e.paddingRight) != null ? n : 0, this.paddingBottom = (i = e.paddingBottom) != null ? i : 0, this.paddingLeft = (a = e.paddingLeft) != null ? a : 0, this.radiusTopLeft = (r = e.radiusTopLeft) != null ? r : 0, this.radiusTopRight = (c = e.radiusTopRight) != null ? c : 0, this.radiusBottomRight = (d = e.radiusBottomRight) != null ? d : 0, this.radiusBottomLeft = (
|
|
4217
|
+
var s, o, n, i, a, r, c, d, h;
|
|
4218
|
+
super(t, e), this.backgroundOpacity = (s = e.backgroundOpacity) != null ? s : 1, this.paddingTop = (o = e.paddingTop) != null ? o : 0, this.paddingRight = (n = e.paddingRight) != null ? n : 0, this.paddingBottom = (i = e.paddingBottom) != null ? i : 0, this.paddingLeft = (a = e.paddingLeft) != null ? a : 0, this.radiusTopLeft = (r = e.radiusTopLeft) != null ? r : 0, this.radiusTopRight = (c = e.radiusTopRight) != null ? c : 0, this.radiusBottomRight = (d = e.radiusBottomRight) != null ? d : 0, this.radiusBottomLeft = (h = e.radiusBottomLeft) != null ? h : 0, this._roundDimensions();
|
|
4207
4219
|
}
|
|
4208
4220
|
/**
|
|
4209
4221
|
* Пересчитывает размеры текста и округляет их до целых значений.
|
|
@@ -4251,11 +4263,11 @@ const at = ({
|
|
|
4251
4263
|
var s, o;
|
|
4252
4264
|
const e = this._getEffectiveBackgroundFill();
|
|
4253
4265
|
if (e && e) {
|
|
4254
|
-
const n = this._getPadding(), i = (s = this.width) != null ? s : 0, a = (o = this.height) != null ? o : 0, r = i + n.left + n.right, c = a + n.top + n.bottom, d = this._getCornerRadii({ width: r, height: c }),
|
|
4266
|
+
const n = this._getPadding(), i = (s = this.width) != null ? s : 0, a = (o = this.height) != null ? o : 0, r = i + n.left + n.right, c = a + n.top + n.bottom, d = this._getCornerRadii({ width: r, height: c }), h = this._getLeftOffset() - n.left, u = this._getTopOffset() - n.top;
|
|
4255
4267
|
t.save(), Dt._renderRoundedRect({
|
|
4256
4268
|
ctx: t,
|
|
4257
4269
|
height: c,
|
|
4258
|
-
left:
|
|
4270
|
+
left: h,
|
|
4259
4271
|
radii: d,
|
|
4260
4272
|
top: u,
|
|
4261
4273
|
width: r
|
|
@@ -4319,9 +4331,9 @@ const at = ({
|
|
|
4319
4331
|
const a = s + i, r = n + e, {
|
|
4320
4332
|
topLeft: c,
|
|
4321
4333
|
topRight: d,
|
|
4322
|
-
bottomRight:
|
|
4334
|
+
bottomRight: h,
|
|
4323
4335
|
bottomLeft: u
|
|
4324
|
-
} = o, g = at({ value: c, min: 0, max: i }), f = at({ value: d, min: 0, max: i }), p = at({ value:
|
|
4336
|
+
} = o, g = at({ value: c, min: 0, max: i }), f = at({ value: d, min: 0, max: i }), p = at({ value: h, min: 0, max: i }), m = at({ value: u, min: 0, max: i });
|
|
4325
4337
|
t.beginPath(), t.moveTo(s + g, n), t.lineTo(a - f, n), t.quadraticCurveTo(a, n, a, n + f), t.lineTo(a, r - p), t.quadraticCurveTo(a, r, a - p, r), t.lineTo(s + m, r), t.quadraticCurveTo(s, r, s, r - m), t.lineTo(s, n + g), t.quadraticCurveTo(s, n, s + g, n), t.closePath();
|
|
4326
4338
|
}
|
|
4327
4339
|
/**
|
|
@@ -4362,51 +4374,51 @@ Dt.type = "background-textbox", Dt.cacheProperties = [
|
|
|
4362
4374
|
];
|
|
4363
4375
|
let ee = Dt;
|
|
4364
4376
|
const io = () => {
|
|
4365
|
-
var
|
|
4366
|
-
(
|
|
4367
|
-
}, ao = ({ textbox:
|
|
4377
|
+
var l;
|
|
4378
|
+
(l = Pe) != null && l.setClass && Pe.setClass(ee, "background-textbox");
|
|
4379
|
+
}, ao = ({ textbox: l }) => {
|
|
4368
4380
|
var s, o;
|
|
4369
|
-
if (!
|
|
4370
|
-
const t = (s =
|
|
4381
|
+
if (!l.isEditing) return null;
|
|
4382
|
+
const t = (s = l.selectionStart) != null ? s : 0, e = (o = l.selectionEnd) != null ? o : t;
|
|
4371
4383
|
return t === e ? null : {
|
|
4372
4384
|
start: Math.min(t, e),
|
|
4373
4385
|
end: Math.max(t, e)
|
|
4374
4386
|
};
|
|
4375
|
-
}, ro = ({ textbox:
|
|
4387
|
+
}, ro = ({ textbox: l }) => {
|
|
4376
4388
|
var e, s;
|
|
4377
|
-
const t = (s = (e =
|
|
4389
|
+
const t = (s = (e = l.text) == null ? void 0 : e.length) != null ? s : 0;
|
|
4378
4390
|
return t <= 0 ? null : { start: 0, end: t };
|
|
4379
|
-
}, co = ({ textbox:
|
|
4391
|
+
}, co = ({ textbox: l, range: t }) => {
|
|
4380
4392
|
var s, o;
|
|
4381
4393
|
if (!t) return !1;
|
|
4382
|
-
const e = (o = (s =
|
|
4394
|
+
const e = (o = (s = l.text) == null ? void 0 : s.length) != null ? o : 0;
|
|
4383
4395
|
return e <= 0 ? !1 : t.start <= 0 && t.end >= e;
|
|
4384
4396
|
}, ne = ({
|
|
4385
|
-
textbox:
|
|
4397
|
+
textbox: l,
|
|
4386
4398
|
styles: t,
|
|
4387
4399
|
range: e
|
|
4388
4400
|
}) => {
|
|
4389
4401
|
if (!t || !Object.keys(t).length) return !1;
|
|
4390
4402
|
const { start: s, end: o } = e;
|
|
4391
|
-
return o <= s ? !1 : (
|
|
4403
|
+
return o <= s ? !1 : (l.setSelectionStyles(t, s, o), !0);
|
|
4392
4404
|
}, Ve = ({
|
|
4393
|
-
textbox:
|
|
4405
|
+
textbox: l,
|
|
4394
4406
|
range: t,
|
|
4395
4407
|
property: e
|
|
4396
4408
|
}) => {
|
|
4397
4409
|
var o;
|
|
4398
4410
|
if (!t) return;
|
|
4399
|
-
const s =
|
|
4411
|
+
const s = l.getSelectionStyles(
|
|
4400
4412
|
t.start,
|
|
4401
4413
|
t.end,
|
|
4402
4414
|
!0
|
|
4403
4415
|
);
|
|
4404
4416
|
if (s.length)
|
|
4405
4417
|
return (o = s[0]) == null ? void 0 : o[e];
|
|
4406
|
-
}, Xe = ({ strokeColor:
|
|
4418
|
+
}, Xe = ({ strokeColor: l, width: t }) => {
|
|
4407
4419
|
if (!(t <= 0))
|
|
4408
|
-
return
|
|
4409
|
-
}, Ke = ({ width:
|
|
4420
|
+
return l != null ? l : "#000000";
|
|
4421
|
+
}, Ke = ({ width: l = 0 }) => l ? Math.max(0, l) : 0, ie = ({ value: l }) => typeof l == "string" ? l.toLocaleUpperCase() : "", st = 0.01;
|
|
4410
4422
|
class Z {
|
|
4411
4423
|
constructor({ editor: t }) {
|
|
4412
4424
|
var e;
|
|
@@ -4448,7 +4460,7 @@ class Z {
|
|
|
4448
4460
|
baseLeft: r,
|
|
4449
4461
|
baseFontSize: c,
|
|
4450
4462
|
basePadding: d,
|
|
4451
|
-
baseRadii:
|
|
4463
|
+
baseRadii: h,
|
|
4452
4464
|
baseStyles: u
|
|
4453
4465
|
} = i, g = typeof ((X = n.original) == null ? void 0 : X.width) == "number" ? n.original.width : void 0, f = typeof ((It = n.original) == null ? void 0 : It.left) == "number" ? n.original.left : void 0, p = g != null ? g : a, m = f != null ? f : r, v = (Wt = n.corner) != null ? Wt : "", b = (mt = n.action) != null ? mt : "", I = ["ml", "mr"].includes(v) || b === "scaleX", y = ["mt", "mb"].includes(v) || b === "scaleY", w = ["tl", "tr", "bl", "br"].includes(v) || b === "scale", A = w || y;
|
|
4454
4466
|
if (!I && !y && !w) return;
|
|
@@ -4470,11 +4482,11 @@ class Z {
|
|
|
4470
4482
|
bottom: Math.max(0, d.bottom * M),
|
|
4471
4483
|
left: Math.max(0, d.left * M)
|
|
4472
4484
|
} : d, Q = q ? {
|
|
4473
|
-
topLeft: Math.max(0,
|
|
4474
|
-
topRight: Math.max(0,
|
|
4475
|
-
bottomRight: Math.max(0,
|
|
4476
|
-
bottomLeft: Math.max(0,
|
|
4477
|
-
} :
|
|
4485
|
+
topLeft: Math.max(0, h.topLeft * M),
|
|
4486
|
+
topRight: Math.max(0, h.topRight * M),
|
|
4487
|
+
bottomRight: Math.max(0, h.bottomRight * M),
|
|
4488
|
+
bottomLeft: Math.max(0, h.bottomLeft * M)
|
|
4489
|
+
} : h, St = Object.keys(u).length > 0;
|
|
4478
4490
|
let et;
|
|
4479
4491
|
if (A && St) {
|
|
4480
4492
|
const se = {};
|
|
@@ -4585,7 +4597,7 @@ class Z {
|
|
|
4585
4597
|
const i = (b = o.width) != null ? b : o.calcTextWidth(), a = (y = (I = o.fontSize) != null ? I : n == null ? void 0 : n.baseFontSize) != null ? y : 16, r = !!(n.baseStyles && Object.keys(n.baseStyles).length), {
|
|
4586
4598
|
paddingTop: c = 0,
|
|
4587
4599
|
paddingRight: d = 0,
|
|
4588
|
-
paddingBottom:
|
|
4600
|
+
paddingBottom: h = 0,
|
|
4589
4601
|
paddingLeft: u = 0,
|
|
4590
4602
|
radiusTopLeft: g = 0,
|
|
4591
4603
|
radiusTopRight: f = 0,
|
|
@@ -4595,7 +4607,7 @@ class Z {
|
|
|
4595
4607
|
width: i,
|
|
4596
4608
|
paddingTop: c,
|
|
4597
4609
|
paddingRight: d,
|
|
4598
|
-
paddingBottom:
|
|
4610
|
+
paddingBottom: h,
|
|
4599
4611
|
paddingLeft: u,
|
|
4600
4612
|
radiusTopLeft: g,
|
|
4601
4613
|
radiusTopRight: f,
|
|
@@ -4625,7 +4637,7 @@ class Z {
|
|
|
4625
4637
|
uppercase: r = !1,
|
|
4626
4638
|
strikethrough: c = !1,
|
|
4627
4639
|
align: d = "left",
|
|
4628
|
-
color:
|
|
4640
|
+
color: h = "#000000",
|
|
4629
4641
|
strokeColor: u,
|
|
4630
4642
|
strokeWidth: g = 0,
|
|
4631
4643
|
opacity: f = 1,
|
|
@@ -4681,7 +4693,7 @@ class Z {
|
|
|
4681
4693
|
uppercase: r,
|
|
4682
4694
|
linethrough: c,
|
|
4683
4695
|
textAlign: d,
|
|
4684
|
-
fill:
|
|
4696
|
+
fill: h,
|
|
4685
4697
|
stroke: z,
|
|
4686
4698
|
strokeWidth: D,
|
|
4687
4699
|
strokeUniform: !0,
|
|
@@ -4709,7 +4721,7 @@ class Z {
|
|
|
4709
4721
|
italic: i,
|
|
4710
4722
|
strikethrough: c,
|
|
4711
4723
|
align: d,
|
|
4712
|
-
color:
|
|
4724
|
+
color: h,
|
|
4713
4725
|
strokeColor: z,
|
|
4714
4726
|
strokeWidth: D
|
|
4715
4727
|
}),
|
|
@@ -4737,7 +4749,7 @@ class Z {
|
|
|
4737
4749
|
const r = Z._getSnapshot(n), Nt = e, {
|
|
4738
4750
|
text: c,
|
|
4739
4751
|
fontFamily: d,
|
|
4740
|
-
fontSize:
|
|
4752
|
+
fontSize: h,
|
|
4741
4753
|
bold: u,
|
|
4742
4754
|
italic: g,
|
|
4743
4755
|
underline: f,
|
|
@@ -4783,7 +4795,7 @@ class Z {
|
|
|
4783
4795
|
"radiusBottomRight",
|
|
4784
4796
|
"radiusBottomLeft"
|
|
4785
4797
|
]), L = _({}, V), D = ao({ textbox: n }), z = D ? this._expandRangeToFullLines({ textbox: n, range: D }) : null, H = {}, P = {}, K = {}, $ = co({ textbox: n, range: D }), q = !D || $, Y = !D;
|
|
4786
|
-
if (d !== void 0 && (z && (P.fontFamily = d), q && (L.fontFamily = d, Y && (K.fontFamily = d))),
|
|
4798
|
+
if (d !== void 0 && (z && (P.fontFamily = d), q && (L.fontFamily = d, Y && (K.fontFamily = d))), h !== void 0 && (z && (P.fontSize = h), q && (L.fontSize = h, Y && (K.fontSize = h))), u !== void 0) {
|
|
4787
4799
|
const X = u ? "bold" : "normal";
|
|
4788
4800
|
D && (H.fontWeight = X), q && (L.fontWeight = X, Y && (K.fontWeight = X));
|
|
4789
4801
|
}
|
|
@@ -4904,7 +4916,7 @@ class Z {
|
|
|
4904
4916
|
if (!e) {
|
|
4905
4917
|
const i = (s = t.width) != null ? s : t.calcTextWidth(), a = (o = t.left) != null ? o : 0, r = (n = t.fontSize) != null ? n : 16, { styles: c = {} } = t, {
|
|
4906
4918
|
paddingTop: d = 0,
|
|
4907
|
-
paddingRight:
|
|
4919
|
+
paddingRight: h = 0,
|
|
4908
4920
|
paddingBottom: u = 0,
|
|
4909
4921
|
paddingLeft: g = 0
|
|
4910
4922
|
} = t, {
|
|
@@ -4919,7 +4931,7 @@ class Z {
|
|
|
4919
4931
|
baseLeft: a,
|
|
4920
4932
|
basePadding: {
|
|
4921
4933
|
top: d,
|
|
4922
|
-
right:
|
|
4934
|
+
right: h,
|
|
4923
4935
|
bottom: u,
|
|
4924
4936
|
left: g
|
|
4925
4937
|
},
|
|
@@ -4956,8 +4968,8 @@ class Z {
|
|
|
4956
4968
|
}), c = Z._resolveDimension({
|
|
4957
4969
|
rawValue: s,
|
|
4958
4970
|
calculatedValue: a
|
|
4959
|
-
}), d = Number.isFinite(r) ? Math.round(r) : null,
|
|
4960
|
-
return d !== null && d !== r && (u.width = Math.max(0, d)),
|
|
4971
|
+
}), d = Number.isFinite(r) ? Math.round(r) : null, h = Number.isFinite(c) ? Math.round(c) : null, u = {};
|
|
4972
|
+
return d !== null && d !== r && (u.width = Math.max(0, d)), h !== null && h !== c && (u.height = Math.max(0, h)), Object.keys(u).length ? (t.set(u), !0) : !1;
|
|
4961
4973
|
}
|
|
4962
4974
|
/**
|
|
4963
4975
|
* Формирует снимок текущих свойств текстового объекта для истории и событий.
|
|
@@ -4979,7 +4991,7 @@ class Z {
|
|
|
4979
4991
|
fontSize: r,
|
|
4980
4992
|
fontWeight: c,
|
|
4981
4993
|
fontStyle: d,
|
|
4982
|
-
underline:
|
|
4994
|
+
underline: h,
|
|
4983
4995
|
linethrough: u,
|
|
4984
4996
|
textAlign: g,
|
|
4985
4997
|
fill: f,
|
|
@@ -5017,7 +5029,7 @@ class Z {
|
|
|
5017
5029
|
fontSize: r,
|
|
5018
5030
|
fontWeight: c,
|
|
5019
5031
|
fontStyle: d,
|
|
5020
|
-
underline:
|
|
5032
|
+
underline: h,
|
|
5021
5033
|
linethrough: u,
|
|
5022
5034
|
fill: f,
|
|
5023
5035
|
stroke: p,
|
|
@@ -5052,23 +5064,23 @@ class Z {
|
|
|
5052
5064
|
}
|
|
5053
5065
|
}
|
|
5054
5066
|
const ot = ({
|
|
5055
|
-
value:
|
|
5067
|
+
value: l,
|
|
5056
5068
|
fallback: t = 0
|
|
5057
|
-
}) => typeof
|
|
5058
|
-
value:
|
|
5069
|
+
}) => typeof l == "number" && Number.isFinite(l) ? l : typeof t == "number" && Number.isFinite(t) ? t : 0, Kt = ({
|
|
5070
|
+
value: l,
|
|
5059
5071
|
dimension: t,
|
|
5060
5072
|
useRelativePositions: e
|
|
5061
5073
|
}) => {
|
|
5062
|
-
const s = ot({ value:
|
|
5074
|
+
const s = ot({ value: l });
|
|
5063
5075
|
return e ? s : s / (t || 1);
|
|
5064
5076
|
}, lo = ({
|
|
5065
|
-
object:
|
|
5077
|
+
object: l,
|
|
5066
5078
|
baseWidth: t,
|
|
5067
5079
|
baseHeight: e,
|
|
5068
5080
|
useRelativePositions: s,
|
|
5069
5081
|
centerKeys: o
|
|
5070
5082
|
}) => {
|
|
5071
|
-
const n =
|
|
5083
|
+
const n = l;
|
|
5072
5084
|
if (typeof n[o.x] == "number" && typeof n[o.y] == "number")
|
|
5073
5085
|
return {
|
|
5074
5086
|
x: Kt({
|
|
@@ -5082,7 +5094,7 @@ const ot = ({
|
|
|
5082
5094
|
useRelativePositions: s
|
|
5083
5095
|
})
|
|
5084
5096
|
};
|
|
5085
|
-
const { left: a, top: r, width: c, height: d } =
|
|
5097
|
+
const { left: a, top: r, width: c, height: d } = l, h = Kt({
|
|
5086
5098
|
value: a,
|
|
5087
5099
|
dimension: t,
|
|
5088
5100
|
useRelativePositions: s
|
|
@@ -5092,11 +5104,11 @@ const ot = ({
|
|
|
5092
5104
|
useRelativePositions: s
|
|
5093
5105
|
}), g = ot({ value: c }) / (t || 1), f = ot({ value: d }) / (e || 1);
|
|
5094
5106
|
return {
|
|
5095
|
-
x:
|
|
5107
|
+
x: h + g / 2,
|
|
5096
5108
|
y: u + f / 2
|
|
5097
5109
|
};
|
|
5098
5110
|
}, ho = ({
|
|
5099
|
-
normalizedX:
|
|
5111
|
+
normalizedX: l,
|
|
5100
5112
|
normalizedY: t,
|
|
5101
5113
|
bounds: e,
|
|
5102
5114
|
targetSize: s,
|
|
@@ -5104,33 +5116,33 @@ const ot = ({
|
|
|
5104
5116
|
}) => {
|
|
5105
5117
|
const { left: n, top: i, width: a, height: r } = e;
|
|
5106
5118
|
if (!o) {
|
|
5107
|
-
const { width:
|
|
5119
|
+
const { width: h, height: u } = s, g = n + l * (h || a), f = i + t * (u || r);
|
|
5108
5120
|
return new tt(g, f);
|
|
5109
5121
|
}
|
|
5110
|
-
const c = n +
|
|
5122
|
+
const c = n + l * a, d = i + t * r;
|
|
5111
5123
|
return new tt(c, d);
|
|
5112
5124
|
}, uo = ({
|
|
5113
|
-
object:
|
|
5125
|
+
object: l,
|
|
5114
5126
|
montageArea: t,
|
|
5115
5127
|
bounds: e
|
|
5116
5128
|
}) => {
|
|
5117
5129
|
if (!t || !e) return null;
|
|
5118
5130
|
try {
|
|
5119
|
-
const s =
|
|
5131
|
+
const s = l.getCenterPoint(), { left: o, top: n, width: i, height: a } = e, r = s.x - o, c = s.y - n, d = r / i, h = c / a;
|
|
5120
5132
|
return {
|
|
5121
5133
|
x: d,
|
|
5122
|
-
y:
|
|
5134
|
+
y: h
|
|
5123
5135
|
};
|
|
5124
5136
|
} catch (s) {
|
|
5125
5137
|
return null;
|
|
5126
5138
|
}
|
|
5127
5139
|
}, ft = ({
|
|
5128
|
-
object:
|
|
5140
|
+
object: l
|
|
5129
5141
|
}) => {
|
|
5130
|
-
if (!
|
|
5142
|
+
if (!l) return null;
|
|
5131
5143
|
try {
|
|
5132
|
-
|
|
5133
|
-
const t =
|
|
5144
|
+
l.setCoords();
|
|
5145
|
+
const t = l.getBoundingRect(!1, !0), {
|
|
5134
5146
|
left: e = 0,
|
|
5135
5147
|
top: s = 0,
|
|
5136
5148
|
width: o = 0,
|
|
@@ -5148,38 +5160,43 @@ const ot = ({
|
|
|
5148
5160
|
return null;
|
|
5149
5161
|
}
|
|
5150
5162
|
}, go = ({
|
|
5151
|
-
x1:
|
|
5163
|
+
x1: l,
|
|
5152
5164
|
y1: t,
|
|
5153
5165
|
x2: e,
|
|
5154
5166
|
y2: s
|
|
5155
|
-
}) => (Math.atan2(s - t, e -
|
|
5156
|
-
if (!
|
|
5157
|
-
const { type: t, coords: e, colorStops: s } =
|
|
5167
|
+
}) => (Math.atan2(s - t, e - l) * 180 / Math.PI + 360) % 360, fo = (l) => {
|
|
5168
|
+
if (!l || typeof l != "object") return null;
|
|
5169
|
+
const { type: t, coords: e, colorStops: s } = l, o = Array.isArray(s) ? s : [], n = o[0], i = o[o.length - 1], a = typeof (n == null ? void 0 : n.color) == "string" ? n.color : void 0, r = typeof (i == null ? void 0 : i.color) == "string" ? i.color : a, c = typeof (n == null ? void 0 : n.offset) == "number" ? n.offset * 100 : void 0, d = typeof (i == null ? void 0 : i.offset) == "number" ? i.offset * 100 : void 0, h = o.map((u) => ({
|
|
5170
|
+
color: typeof u.color == "string" ? u.color : "#000000",
|
|
5171
|
+
offset: typeof u.offset == "number" ? u.offset * 100 : 0
|
|
5172
|
+
}));
|
|
5158
5173
|
if (!a || !r || !e) return null;
|
|
5159
5174
|
if (t === "linear") {
|
|
5160
|
-
const { x1:
|
|
5161
|
-
if (typeof
|
|
5175
|
+
const { x1: u, y1: g, x2: f, y2: p } = e;
|
|
5176
|
+
if (typeof u == "number" && typeof g == "number" && typeof f == "number" && typeof p == "number")
|
|
5162
5177
|
return {
|
|
5163
5178
|
type: "linear",
|
|
5164
|
-
angle: go({ x1:
|
|
5179
|
+
angle: go({ x1: u, y1: g, x2: f, y2: p }),
|
|
5165
5180
|
startColor: a,
|
|
5166
5181
|
endColor: r,
|
|
5167
5182
|
startPosition: c,
|
|
5168
|
-
endPosition: d
|
|
5183
|
+
endPosition: d,
|
|
5184
|
+
colorStops: h
|
|
5169
5185
|
};
|
|
5170
5186
|
}
|
|
5171
5187
|
if (t === "radial") {
|
|
5172
|
-
const { x1:
|
|
5173
|
-
if (typeof
|
|
5188
|
+
const { x1: u, y1: g, r2: f } = e;
|
|
5189
|
+
if (typeof u == "number" && typeof g == "number" && typeof f == "number")
|
|
5174
5190
|
return {
|
|
5175
5191
|
type: "radial",
|
|
5176
|
-
centerX:
|
|
5177
|
-
centerY:
|
|
5178
|
-
radius:
|
|
5192
|
+
centerX: u * 100,
|
|
5193
|
+
centerY: g * 100,
|
|
5194
|
+
radius: f * 100,
|
|
5179
5195
|
startColor: a,
|
|
5180
5196
|
endColor: r,
|
|
5181
5197
|
startPosition: c,
|
|
5182
|
-
endPosition: d
|
|
5198
|
+
endPosition: d,
|
|
5199
|
+
colorStops: h
|
|
5183
5200
|
};
|
|
5184
5201
|
}
|
|
5185
5202
|
return null;
|
|
@@ -5203,7 +5220,7 @@ class R {
|
|
|
5203
5220
|
montageArea: i,
|
|
5204
5221
|
errorManager: a,
|
|
5205
5222
|
backgroundManager: r
|
|
5206
|
-
} = this.editor, c = n.getActiveObject(), d = R._collectObjects(c), { backgroundObject:
|
|
5223
|
+
} = this.editor, c = n.getActiveObject(), d = R._collectObjects(c), { backgroundObject: h } = r != null ? r : {}, u = o && h ? [h] : [], g = [...d, ...u];
|
|
5207
5224
|
if (!g.length)
|
|
5208
5225
|
return a.emitWarning({
|
|
5209
5226
|
origin: "TemplateManager",
|
|
@@ -5246,7 +5263,7 @@ class R {
|
|
|
5246
5263
|
historyManager: i,
|
|
5247
5264
|
errorManager: a,
|
|
5248
5265
|
backgroundManager: r
|
|
5249
|
-
} = this.editor, { objects: c, meta: d, id:
|
|
5266
|
+
} = this.editor, { objects: c, meta: d, id: h } = t != null ? t : {};
|
|
5250
5267
|
if (!(c != null && c.length))
|
|
5251
5268
|
return a.emitWarning({
|
|
5252
5269
|
origin: "TemplateManager",
|
|
@@ -5305,7 +5322,7 @@ class R {
|
|
|
5305
5322
|
code: bt.TEMPLATE_MANAGER.APPLY_FAILED,
|
|
5306
5323
|
message: "Ошибка применения шаблона",
|
|
5307
5324
|
data: {
|
|
5308
|
-
templateId:
|
|
5325
|
+
templateId: h,
|
|
5309
5326
|
error: I
|
|
5310
5327
|
}
|
|
5311
5328
|
}), null;
|
|
@@ -5369,7 +5386,7 @@ class R {
|
|
|
5369
5386
|
scaleY: a
|
|
5370
5387
|
} = e, r = t, c = "getElement" in r && typeof r.getElement == "function" ? r.getElement() : null, {
|
|
5371
5388
|
naturalWidth: d = 0,
|
|
5372
|
-
naturalHeight:
|
|
5389
|
+
naturalHeight: h = 0,
|
|
5373
5390
|
width: u = 0,
|
|
5374
5391
|
height: g = 0
|
|
5375
5392
|
} = c instanceof HTMLImageElement ? c : {
|
|
@@ -5377,7 +5394,7 @@ class R {
|
|
|
5377
5394
|
naturalHeight: 0,
|
|
5378
5395
|
width: 0,
|
|
5379
5396
|
height: 0
|
|
5380
|
-
}, f = ot({ value: d || u || r.width, fallback: 0 }), p = ot({ value:
|
|
5397
|
+
}, f = ot({ value: d || u || r.width, fallback: 0 }), p = ot({ value: h || g || r.height, fallback: 0 }), m = ot({ value: o, fallback: f }), v = ot({ value: n, fallback: p }), b = ot({ value: i, fallback: r.scaleX || 1 }), I = ot({ value: a, fallback: r.scaleY || 1 }), y = m * b, w = v * I, A = f ? y / f : null, j = p ? w / p : null, M = {};
|
|
5381
5398
|
f > 0 && (M.width = f), p > 0 && (M.height = p), A && A > 0 && (M.scaleX = A), j && j > 0 && (M.scaleY = j), r.set(M);
|
|
5382
5399
|
}
|
|
5383
5400
|
/**
|
|
@@ -5453,7 +5470,7 @@ class R {
|
|
|
5453
5470
|
montageArea: a,
|
|
5454
5471
|
useRelativePositions: r
|
|
5455
5472
|
}) {
|
|
5456
|
-
const c = t, { x: d, y:
|
|
5473
|
+
const c = t, { x: d, y: h } = lo({
|
|
5457
5474
|
object: t,
|
|
5458
5475
|
baseWidth: n,
|
|
5459
5476
|
baseHeight: i,
|
|
@@ -5472,7 +5489,7 @@ class R {
|
|
|
5472
5489
|
anchorY: R._resolveAnchor(c, de)
|
|
5473
5490
|
}), v = ho({
|
|
5474
5491
|
normalizedX: d,
|
|
5475
|
-
normalizedY:
|
|
5492
|
+
normalizedY: h,
|
|
5476
5493
|
bounds: m,
|
|
5477
5494
|
targetSize: o,
|
|
5478
5495
|
montageArea: a
|
|
@@ -5496,7 +5513,7 @@ class R {
|
|
|
5496
5513
|
anchorY: a
|
|
5497
5514
|
}) {
|
|
5498
5515
|
if (!n) return t;
|
|
5499
|
-
const r = (e || t.width) * o, c = (s || t.height) * o, d = t.width - r,
|
|
5516
|
+
const r = (e || t.width) * o, c = (s || t.height) * o, d = t.width - r, h = t.height - c, u = t.left + R._calculateAnchorOffset(i, d), g = t.top + R._calculateAnchorOffset(a, h);
|
|
5500
5517
|
return {
|
|
5501
5518
|
left: u,
|
|
5502
5519
|
top: g,
|
|
@@ -5593,7 +5610,7 @@ class R {
|
|
|
5593
5610
|
top: r,
|
|
5594
5611
|
width: c,
|
|
5595
5612
|
height: d
|
|
5596
|
-
} = e,
|
|
5613
|
+
} = e, h = t.getBoundingRect(!1, !0), u = s || c || 1, g = o || d || 1, f = uo({
|
|
5597
5614
|
object: t,
|
|
5598
5615
|
montageArea: n,
|
|
5599
5616
|
bounds: e
|
|
@@ -5603,7 +5620,7 @@ class R {
|
|
|
5603
5620
|
x: (y.x - a) / u,
|
|
5604
5621
|
y: (y.y - r) / g
|
|
5605
5622
|
};
|
|
5606
|
-
})(), m = (
|
|
5623
|
+
})(), m = (h.left - a) / u, v = (h.top - r) / g, b = m + h.width / u, I = v + h.height / g;
|
|
5607
5624
|
return i[ae] = p.x, i[re] = p.y, i[ce] = R._detectAnchor({
|
|
5608
5625
|
center: p.x,
|
|
5609
5626
|
start: m,
|
|
@@ -5723,13 +5740,13 @@ class R {
|
|
|
5723
5740
|
}
|
|
5724
5741
|
}
|
|
5725
5742
|
const po = 5, os = "#3D8BF4", pe = 1, Qt = 1, Qe = ({
|
|
5726
|
-
anchors:
|
|
5743
|
+
anchors: l,
|
|
5727
5744
|
positions: t,
|
|
5728
5745
|
threshold: e
|
|
5729
5746
|
}) => {
|
|
5730
5747
|
let s = 0, o = e + 1, n = null;
|
|
5731
5748
|
for (const i of t)
|
|
5732
|
-
for (const a of
|
|
5749
|
+
for (const a of l) {
|
|
5733
5750
|
const r = Math.abs(a - i);
|
|
5734
5751
|
r > e || r >= o || (s = a - i, o = r, n = a);
|
|
5735
5752
|
}
|
|
@@ -5738,11 +5755,11 @@ const po = 5, os = "#3D8BF4", pe = 1, Qt = 1, Qe = ({
|
|
|
5738
5755
|
guidePosition: n
|
|
5739
5756
|
};
|
|
5740
5757
|
}, mo = ({
|
|
5741
|
-
activeBounds:
|
|
5758
|
+
activeBounds: l,
|
|
5742
5759
|
threshold: t,
|
|
5743
5760
|
anchors: e
|
|
5744
5761
|
}) => {
|
|
5745
|
-
const { left: s, right: o, centerX: n, top: i, bottom: a, centerY: r } =
|
|
5762
|
+
const { left: s, right: o, centerX: n, top: i, bottom: a, centerY: r } = l, c = Qe({
|
|
5746
5763
|
anchors: e.vertical,
|
|
5747
5764
|
positions: [s, n, o],
|
|
5748
5765
|
threshold: t
|
|
@@ -5750,20 +5767,20 @@ const po = 5, os = "#3D8BF4", pe = 1, Qt = 1, Qe = ({
|
|
|
5750
5767
|
anchors: e.horizontal,
|
|
5751
5768
|
positions: [i, r, a],
|
|
5752
5769
|
threshold: t
|
|
5753
|
-
}),
|
|
5754
|
-
return c.guidePosition !== null &&
|
|
5770
|
+
}), h = [];
|
|
5771
|
+
return c.guidePosition !== null && h.push({
|
|
5755
5772
|
type: "vertical",
|
|
5756
5773
|
position: c.guidePosition
|
|
5757
|
-
}), d.guidePosition !== null &&
|
|
5774
|
+
}), d.guidePosition !== null && h.push({
|
|
5758
5775
|
type: "horizontal",
|
|
5759
5776
|
position: d.guidePosition
|
|
5760
5777
|
}), {
|
|
5761
5778
|
deltaX: c.delta,
|
|
5762
5779
|
deltaY: d.delta,
|
|
5763
|
-
guides:
|
|
5780
|
+
guides: h
|
|
5764
5781
|
};
|
|
5765
5782
|
}, ns = ({
|
|
5766
|
-
activeBounds:
|
|
5783
|
+
activeBounds: l,
|
|
5767
5784
|
aligned: t,
|
|
5768
5785
|
threshold: e,
|
|
5769
5786
|
patterns: s,
|
|
@@ -5775,59 +5792,59 @@ const po = 5, os = "#3D8BF4", pe = 1, Qt = 1, Qe = ({
|
|
|
5775
5792
|
bottom: i,
|
|
5776
5793
|
left: a,
|
|
5777
5794
|
right: r
|
|
5778
|
-
} =
|
|
5795
|
+
} = l, c = [];
|
|
5779
5796
|
for (const d of s)
|
|
5780
|
-
for (const
|
|
5797
|
+
for (const h of t)
|
|
5781
5798
|
if (o === "vertical") {
|
|
5782
|
-
const u = n -
|
|
5799
|
+
const u = n - h.bottom, g = Math.abs(u - d.distance);
|
|
5783
5800
|
if (g <= e) {
|
|
5784
5801
|
const m = d.distance - u, v = {
|
|
5785
5802
|
type: o,
|
|
5786
5803
|
axis: d.axis,
|
|
5787
5804
|
refStart: d.start,
|
|
5788
5805
|
refEnd: d.end,
|
|
5789
|
-
activeStart:
|
|
5790
|
-
activeEnd:
|
|
5806
|
+
activeStart: h.bottom,
|
|
5807
|
+
activeEnd: h.bottom + d.distance,
|
|
5791
5808
|
distance: d.distance
|
|
5792
5809
|
};
|
|
5793
5810
|
c.push({ delta: m, guide: v, diff: g });
|
|
5794
5811
|
}
|
|
5795
|
-
const f =
|
|
5812
|
+
const f = h.top - i, p = Math.abs(f - d.distance);
|
|
5796
5813
|
if (p <= e) {
|
|
5797
5814
|
const m = d.distance - f, v = {
|
|
5798
5815
|
type: o,
|
|
5799
5816
|
axis: d.axis,
|
|
5800
5817
|
refStart: d.start,
|
|
5801
5818
|
refEnd: d.end,
|
|
5802
|
-
activeStart:
|
|
5803
|
-
activeEnd:
|
|
5819
|
+
activeStart: h.top - d.distance,
|
|
5820
|
+
activeEnd: h.top,
|
|
5804
5821
|
distance: d.distance
|
|
5805
5822
|
};
|
|
5806
5823
|
c.push({ delta: m, guide: v, diff: p });
|
|
5807
5824
|
}
|
|
5808
5825
|
} else {
|
|
5809
|
-
const u = a -
|
|
5826
|
+
const u = a - h.right, g = Math.abs(u - d.distance);
|
|
5810
5827
|
if (g <= e) {
|
|
5811
5828
|
const m = d.distance - u, v = {
|
|
5812
5829
|
type: o,
|
|
5813
5830
|
axis: d.axis,
|
|
5814
5831
|
refStart: d.start,
|
|
5815
5832
|
refEnd: d.end,
|
|
5816
|
-
activeStart:
|
|
5817
|
-
activeEnd:
|
|
5833
|
+
activeStart: h.right,
|
|
5834
|
+
activeEnd: h.right + d.distance,
|
|
5818
5835
|
distance: d.distance
|
|
5819
5836
|
};
|
|
5820
5837
|
c.push({ delta: m, guide: v, diff: g });
|
|
5821
5838
|
}
|
|
5822
|
-
const f =
|
|
5839
|
+
const f = h.left - r, p = Math.abs(f - d.distance);
|
|
5823
5840
|
if (p <= e) {
|
|
5824
5841
|
const m = d.distance - f, v = {
|
|
5825
5842
|
type: o,
|
|
5826
5843
|
axis: d.axis,
|
|
5827
5844
|
refStart: d.start,
|
|
5828
5845
|
refEnd: d.end,
|
|
5829
|
-
activeStart:
|
|
5830
|
-
activeEnd:
|
|
5846
|
+
activeStart: h.left - d.distance,
|
|
5847
|
+
activeEnd: h.left,
|
|
5831
5848
|
distance: d.distance
|
|
5832
5849
|
};
|
|
5833
5850
|
c.push({ delta: m, guide: v, diff: p });
|
|
@@ -5835,7 +5852,7 @@ const po = 5, os = "#3D8BF4", pe = 1, Qt = 1, Qe = ({
|
|
|
5835
5852
|
}
|
|
5836
5853
|
return c;
|
|
5837
5854
|
}, yo = ({
|
|
5838
|
-
activeBounds:
|
|
5855
|
+
activeBounds: l,
|
|
5839
5856
|
candidates: t,
|
|
5840
5857
|
threshold: e,
|
|
5841
5858
|
patterns: s
|
|
@@ -5846,18 +5863,18 @@ const po = 5, os = "#3D8BF4", pe = 1, Qt = 1, Qe = ({
|
|
|
5846
5863
|
bottom: i,
|
|
5847
5864
|
left: a,
|
|
5848
5865
|
right: r
|
|
5849
|
-
} =
|
|
5866
|
+
} = l, c = t.filter((y) => Math.min(y.right, r) - Math.max(y.left, a) >= -e);
|
|
5850
5867
|
if (!c.length)
|
|
5851
5868
|
return { delta: 0, guide: null };
|
|
5852
5869
|
const d = [
|
|
5853
5870
|
...c.map((y) => ({ bounds: y, isActive: !1 })),
|
|
5854
|
-
{ bounds:
|
|
5871
|
+
{ bounds: l, isActive: !0 }
|
|
5855
5872
|
];
|
|
5856
5873
|
d.sort((y, w) => y.bounds.top - w.bounds.top);
|
|
5857
|
-
const
|
|
5858
|
-
if (
|
|
5874
|
+
const h = d.findIndex((y) => y.isActive);
|
|
5875
|
+
if (h === -1)
|
|
5859
5876
|
return { delta: 0, guide: null };
|
|
5860
|
-
const u = d[
|
|
5877
|
+
const u = d[h - 1], g = d[h - 2], f = d[h + 1], p = d[h + 2], m = [], v = i - n;
|
|
5861
5878
|
if (u && g) {
|
|
5862
5879
|
const { bounds: y } = u, { bounds: w } = g, A = y.top - w.bottom, j = n - y.bottom, M = Math.abs(j - A);
|
|
5863
5880
|
if (M <= e) {
|
|
@@ -5907,7 +5924,7 @@ const po = 5, os = "#3D8BF4", pe = 1, Qt = 1, Qe = ({
|
|
|
5907
5924
|
}
|
|
5908
5925
|
}
|
|
5909
5926
|
const b = ns({
|
|
5910
|
-
activeBounds:
|
|
5927
|
+
activeBounds: l,
|
|
5911
5928
|
aligned: c,
|
|
5912
5929
|
threshold: e,
|
|
5913
5930
|
patterns: s,
|
|
@@ -5921,7 +5938,7 @@ const po = 5, os = "#3D8BF4", pe = 1, Qt = 1, Qe = ({
|
|
|
5921
5938
|
guide: I.guide
|
|
5922
5939
|
};
|
|
5923
5940
|
}, vo = ({
|
|
5924
|
-
activeBounds:
|
|
5941
|
+
activeBounds: l,
|
|
5925
5942
|
candidates: t,
|
|
5926
5943
|
threshold: e,
|
|
5927
5944
|
patterns: s
|
|
@@ -5932,18 +5949,18 @@ const po = 5, os = "#3D8BF4", pe = 1, Qt = 1, Qe = ({
|
|
|
5932
5949
|
right: i,
|
|
5933
5950
|
top: a,
|
|
5934
5951
|
bottom: r
|
|
5935
|
-
} =
|
|
5952
|
+
} = l, c = t.filter((y) => Math.min(y.bottom, r) - Math.max(y.top, a) >= -e);
|
|
5936
5953
|
if (!c.length)
|
|
5937
5954
|
return { delta: 0, guide: null };
|
|
5938
5955
|
const d = [
|
|
5939
5956
|
...c.map((y) => ({ bounds: y, isActive: !1 })),
|
|
5940
|
-
{ bounds:
|
|
5957
|
+
{ bounds: l, isActive: !0 }
|
|
5941
5958
|
];
|
|
5942
5959
|
d.sort((y, w) => y.bounds.left - w.bounds.left);
|
|
5943
|
-
const
|
|
5944
|
-
if (
|
|
5960
|
+
const h = d.findIndex((y) => y.isActive);
|
|
5961
|
+
if (h === -1)
|
|
5945
5962
|
return { delta: 0, guide: null };
|
|
5946
|
-
const u = d[
|
|
5963
|
+
const u = d[h - 1], g = d[h - 2], f = d[h + 1], p = d[h + 2], m = [], v = i - n;
|
|
5947
5964
|
if (u && g) {
|
|
5948
5965
|
const { bounds: y } = u, { bounds: w } = g, A = y.left - w.right, j = n - y.right, M = Math.abs(j - A);
|
|
5949
5966
|
if (M <= e) {
|
|
@@ -5993,7 +6010,7 @@ const po = 5, os = "#3D8BF4", pe = 1, Qt = 1, Qe = ({
|
|
|
5993
6010
|
}
|
|
5994
6011
|
}
|
|
5995
6012
|
const b = ns({
|
|
5996
|
-
activeBounds:
|
|
6013
|
+
activeBounds: l,
|
|
5997
6014
|
aligned: c,
|
|
5998
6015
|
threshold: e,
|
|
5999
6016
|
patterns: s,
|
|
@@ -6007,18 +6024,18 @@ const po = 5, os = "#3D8BF4", pe = 1, Qt = 1, Qe = ({
|
|
|
6007
6024
|
guide: I.guide
|
|
6008
6025
|
};
|
|
6009
6026
|
}, bo = ({
|
|
6010
|
-
activeBounds:
|
|
6027
|
+
activeBounds: l,
|
|
6011
6028
|
candidates: t,
|
|
6012
6029
|
threshold: e,
|
|
6013
6030
|
spacingPatterns: s
|
|
6014
6031
|
}) => {
|
|
6015
6032
|
const o = yo({
|
|
6016
|
-
activeBounds:
|
|
6033
|
+
activeBounds: l,
|
|
6017
6034
|
candidates: t,
|
|
6018
6035
|
threshold: e,
|
|
6019
6036
|
patterns: s.vertical
|
|
6020
6037
|
}), n = vo({
|
|
6021
|
-
activeBounds:
|
|
6038
|
+
activeBounds: l,
|
|
6022
6039
|
candidates: t,
|
|
6023
6040
|
threshold: e,
|
|
6024
6041
|
patterns: s.horizontal
|
|
@@ -6029,7 +6046,7 @@ const po = 5, os = "#3D8BF4", pe = 1, Qt = 1, Qe = ({
|
|
|
6029
6046
|
guides: i
|
|
6030
6047
|
};
|
|
6031
6048
|
}, Mo = ({
|
|
6032
|
-
context:
|
|
6049
|
+
context: l,
|
|
6033
6050
|
x: t,
|
|
6034
6051
|
y: e,
|
|
6035
6052
|
width: s,
|
|
@@ -6037,9 +6054,9 @@ const po = 5, os = "#3D8BF4", pe = 1, Qt = 1, Qe = ({
|
|
|
6037
6054
|
radius: n
|
|
6038
6055
|
}) => {
|
|
6039
6056
|
const i = Math.min(n, s / 2, o / 2);
|
|
6040
|
-
|
|
6057
|
+
l.moveTo(t + i, e), l.lineTo(t + s - i, e), l.quadraticCurveTo(t + s, e, t + s, e + i), l.lineTo(t + s, e + o - i), l.quadraticCurveTo(t + s, e + o, t + s - i, e + o), l.lineTo(t + i, e + o), l.quadraticCurveTo(t, e + o, t, e + o - i), l.lineTo(t, e + i), l.quadraticCurveTo(t, e, t + i, e), l.closePath();
|
|
6041
6058
|
}, me = ({
|
|
6042
|
-
context:
|
|
6059
|
+
context: l,
|
|
6043
6060
|
type: t,
|
|
6044
6061
|
axis: e,
|
|
6045
6062
|
start: s,
|
|
@@ -6050,24 +6067,24 @@ const po = 5, os = "#3D8BF4", pe = 1, Qt = 1, Qe = ({
|
|
|
6050
6067
|
textColor: r = "#ffffff",
|
|
6051
6068
|
fontFamily: c = "sans-serif",
|
|
6052
6069
|
lineWidth: d = 1,
|
|
6053
|
-
padding:
|
|
6070
|
+
padding: h = 4,
|
|
6054
6071
|
radius: u = 4,
|
|
6055
6072
|
offsetAlongAxis: g = 0,
|
|
6056
6073
|
offsetPerpendicular: f = 0
|
|
6057
6074
|
}) => {
|
|
6058
|
-
const p = i || 1, m = 12 / p, v =
|
|
6059
|
-
|
|
6060
|
-
const j =
|
|
6061
|
-
|
|
6062
|
-
context:
|
|
6075
|
+
const p = i || 1, m = 12 / p, v = h / p, b = u / p, I = (s + o) / 2 + g, y = t === "vertical" ? e + f : I, w = t === "vertical" ? I : e + f;
|
|
6076
|
+
l.save(), l.setLineDash([]), l.fillStyle = a, l.strokeStyle = a, l.lineWidth = d / p, l.font = `${m}px ${c}`, l.textAlign = "center", l.textBaseline = "middle";
|
|
6077
|
+
const j = l.measureText(n).width + v * 2, M = m + v * 2, T = y - j / 2, S = w - M / 2;
|
|
6078
|
+
l.beginPath(), Mo({
|
|
6079
|
+
context: l,
|
|
6063
6080
|
x: T,
|
|
6064
6081
|
y: S,
|
|
6065
6082
|
width: j,
|
|
6066
6083
|
height: M,
|
|
6067
6084
|
radius: b
|
|
6068
|
-
}),
|
|
6085
|
+
}), l.fill(), l.fillStyle = r, l.fillText(n, y, w), l.restore();
|
|
6069
6086
|
}, wo = ({
|
|
6070
|
-
context:
|
|
6087
|
+
context: l,
|
|
6071
6088
|
guide: t,
|
|
6072
6089
|
zoom: e
|
|
6073
6090
|
}) => {
|
|
@@ -6080,31 +6097,31 @@ const po = 5, os = "#3D8BF4", pe = 1, Qt = 1, Qe = ({
|
|
|
6080
6097
|
activeEnd: r,
|
|
6081
6098
|
distance: c
|
|
6082
6099
|
} = t, d = Math.round(c).toString();
|
|
6083
|
-
|
|
6084
|
-
const
|
|
6100
|
+
l.beginPath(), s === "vertical" ? (l.moveTo(o, n), l.lineTo(o, i), l.moveTo(o, a), l.lineTo(o, r)) : (l.moveTo(n, o), l.lineTo(i, o), l.moveTo(a, o), l.lineTo(r, o)), l.stroke();
|
|
6101
|
+
const h = os;
|
|
6085
6102
|
me({
|
|
6086
|
-
context:
|
|
6103
|
+
context: l,
|
|
6087
6104
|
type: s,
|
|
6088
6105
|
axis: o,
|
|
6089
6106
|
start: n,
|
|
6090
6107
|
end: i,
|
|
6091
6108
|
text: d,
|
|
6092
6109
|
zoom: e,
|
|
6093
|
-
color:
|
|
6110
|
+
color: h,
|
|
6094
6111
|
lineWidth: pe
|
|
6095
6112
|
}), me({
|
|
6096
|
-
context:
|
|
6113
|
+
context: l,
|
|
6097
6114
|
type: s,
|
|
6098
6115
|
axis: o,
|
|
6099
6116
|
start: a,
|
|
6100
6117
|
end: r,
|
|
6101
6118
|
text: d,
|
|
6102
6119
|
zoom: e,
|
|
6103
|
-
color:
|
|
6120
|
+
color: h,
|
|
6104
6121
|
lineWidth: pe
|
|
6105
6122
|
});
|
|
6106
6123
|
}, qe = ({
|
|
6107
|
-
anchors:
|
|
6124
|
+
anchors: l,
|
|
6108
6125
|
bounds: t
|
|
6109
6126
|
}) => {
|
|
6110
6127
|
const {
|
|
@@ -6115,24 +6132,24 @@ const po = 5, os = "#3D8BF4", pe = 1, Qt = 1, Qe = ({
|
|
|
6115
6132
|
bottom: i,
|
|
6116
6133
|
centerY: a
|
|
6117
6134
|
} = t;
|
|
6118
|
-
|
|
6135
|
+
l.vertical.push(e, o, s), l.horizontal.push(n, a, i);
|
|
6119
6136
|
}, Je = ({
|
|
6120
|
-
bounds:
|
|
6137
|
+
bounds: l,
|
|
6121
6138
|
type: t,
|
|
6122
6139
|
primaryStart: e,
|
|
6123
6140
|
primaryEnd: s
|
|
6124
6141
|
}) => {
|
|
6125
|
-
const o = [], n = e === "top" ? "left" : "top", i = s === "bottom" ? "right" : "bottom", a = [...
|
|
6142
|
+
const o = [], n = e === "top" ? "left" : "top", i = s === "bottom" ? "right" : "bottom", a = [...l].sort((r, c) => r[e] - c[e]);
|
|
6126
6143
|
for (let r = 0; r < a.length; r += 1) {
|
|
6127
6144
|
const c = a[r];
|
|
6128
|
-
let d = null,
|
|
6145
|
+
let d = null, h = Number.POSITIVE_INFINITY;
|
|
6129
6146
|
for (let p = r + 1; p < a.length; p += 1) {
|
|
6130
6147
|
const m = a[p];
|
|
6131
6148
|
if (Math.min(c[i], m[i]) - Math.max(c[n], m[n]) < 0) continue;
|
|
6132
6149
|
const b = m[e] - c[s];
|
|
6133
|
-
b < 0 || b <
|
|
6150
|
+
b < 0 || b < h && (h = b, d = m);
|
|
6134
6151
|
}
|
|
6135
|
-
if (!d ||
|
|
6152
|
+
if (!d || h === Number.POSITIVE_INFINITY) continue;
|
|
6136
6153
|
const u = Math.max(c[n], d[n]), g = Math.min(c[i], d[i]), f = (u + g) / 2;
|
|
6137
6154
|
o.push({
|
|
6138
6155
|
type: t,
|
|
@@ -6144,34 +6161,34 @@ const po = 5, os = "#3D8BF4", pe = 1, Qt = 1, Qe = ({
|
|
|
6144
6161
|
}
|
|
6145
6162
|
return o;
|
|
6146
6163
|
}, So = ({
|
|
6147
|
-
bounds:
|
|
6164
|
+
bounds: l
|
|
6148
6165
|
}) => {
|
|
6149
6166
|
const t = Je({
|
|
6150
|
-
bounds:
|
|
6167
|
+
bounds: l,
|
|
6151
6168
|
type: "vertical",
|
|
6152
6169
|
primaryStart: "top",
|
|
6153
6170
|
primaryEnd: "bottom"
|
|
6154
6171
|
}), e = Je({
|
|
6155
|
-
bounds:
|
|
6172
|
+
bounds: l,
|
|
6156
6173
|
type: "horizontal",
|
|
6157
6174
|
primaryStart: "left",
|
|
6158
6175
|
primaryEnd: "right"
|
|
6159
6176
|
});
|
|
6160
6177
|
return { vertical: t, horizontal: e };
|
|
6161
6178
|
}, Ao = ["montage-area", "background", "interaction-blocker"], is = ({
|
|
6162
|
-
activeObject:
|
|
6179
|
+
activeObject: l
|
|
6163
6180
|
}) => {
|
|
6164
6181
|
const t = /* @__PURE__ */ new Set();
|
|
6165
|
-
return
|
|
6182
|
+
return l && (t.add(l), l instanceof k && l.getObjects().forEach((e) => t.add(e))), t;
|
|
6166
6183
|
}, as = ({
|
|
6167
|
-
object:
|
|
6184
|
+
object: l,
|
|
6168
6185
|
excluded: t,
|
|
6169
6186
|
ignoredIds: e = Ao
|
|
6170
6187
|
}) => {
|
|
6171
|
-
if (t.has(
|
|
6172
|
-
const { visible: s = !0 } =
|
|
6188
|
+
if (t.has(l)) return !0;
|
|
6189
|
+
const { visible: s = !0 } = l;
|
|
6173
6190
|
if (!s) return !0;
|
|
6174
|
-
const { id: o } =
|
|
6191
|
+
const { id: o } = l;
|
|
6175
6192
|
return !!(o && e.includes(o));
|
|
6176
6193
|
};
|
|
6177
6194
|
class jo {
|
|
@@ -6241,12 +6258,12 @@ class jo {
|
|
|
6241
6258
|
activeBounds: n,
|
|
6242
6259
|
threshold: r,
|
|
6243
6260
|
anchors: this.anchors
|
|
6244
|
-
}), { deltaX: d, deltaY:
|
|
6245
|
-
if (d !== 0 ||
|
|
6261
|
+
}), { deltaX: d, deltaY: h, guides: u } = c;
|
|
6262
|
+
if (d !== 0 || h !== 0) {
|
|
6246
6263
|
const { left: v = 0, top: b = 0 } = e;
|
|
6247
6264
|
e.set({
|
|
6248
6265
|
left: v + d,
|
|
6249
|
-
top: b +
|
|
6266
|
+
top: b + h
|
|
6250
6267
|
}), e.setCoords(), n = (p = ft({ object: e })) != null ? p : n;
|
|
6251
6268
|
}
|
|
6252
6269
|
const g = this.cachedTargetBounds.length ? this.cachedTargetBounds : this._collectTargets({ activeObject: e }).map((v) => ft({ object: v })).filter((v) => !!v), f = bo({
|
|
@@ -6289,12 +6306,12 @@ class jo {
|
|
|
6289
6306
|
if (!s) return;
|
|
6290
6307
|
const o = e != null ? e : this._calculateViewportBounds(), { left: n, right: i, top: a, bottom: r } = o, { viewportTransform: c } = t, d = t.getZoom() || 1;
|
|
6291
6308
|
s.save(), Array.isArray(c) && s.transform(...c), s.lineWidth = pe / d, s.strokeStyle = os, s.setLineDash([4, 4]);
|
|
6292
|
-
for (const
|
|
6293
|
-
s.beginPath(),
|
|
6294
|
-
for (const
|
|
6309
|
+
for (const h of this.activeGuides)
|
|
6310
|
+
s.beginPath(), h.type === "vertical" ? (s.moveTo(h.position, a), s.lineTo(h.position, r)) : (s.moveTo(n, h.position), s.lineTo(i, h.position)), s.stroke();
|
|
6311
|
+
for (const h of this.activeSpacingGuides)
|
|
6295
6312
|
wo({
|
|
6296
6313
|
context: s,
|
|
6297
|
-
guide:
|
|
6314
|
+
guide: h,
|
|
6298
6315
|
zoom: d
|
|
6299
6316
|
});
|
|
6300
6317
|
s.restore();
|
|
@@ -6377,10 +6394,10 @@ class jo {
|
|
|
6377
6394
|
i = 1,
|
|
6378
6395
|
a = 0,
|
|
6379
6396
|
r = 0
|
|
6380
|
-
] = e != null ? e : [], c = (0 - a) / n, d = (0 - r) / i,
|
|
6397
|
+
] = e != null ? e : [], c = (0 - a) / n, d = (0 - r) / i, h = (s - a) / n, u = (o - r) / i;
|
|
6381
6398
|
return {
|
|
6382
6399
|
left: c,
|
|
6383
|
-
right:
|
|
6400
|
+
right: h,
|
|
6384
6401
|
top: d,
|
|
6385
6402
|
bottom: u
|
|
6386
6403
|
};
|
|
@@ -6565,7 +6582,7 @@ class Lt {
|
|
|
6565
6582
|
centerY: c = 0
|
|
6566
6583
|
} = t, {
|
|
6567
6584
|
left: d = 0,
|
|
6568
|
-
right:
|
|
6585
|
+
right: h = 0,
|
|
6569
6586
|
top: u = 0,
|
|
6570
6587
|
bottom: g = 0,
|
|
6571
6588
|
centerY: f = 0
|
|
@@ -6581,19 +6598,19 @@ class Lt {
|
|
|
6581
6598
|
distance: C
|
|
6582
6599
|
}), o;
|
|
6583
6600
|
}
|
|
6584
|
-
if (
|
|
6601
|
+
if (h <= n) {
|
|
6585
6602
|
if (s) return o;
|
|
6586
|
-
const C = n -
|
|
6603
|
+
const C = n - h;
|
|
6587
6604
|
return C > 0 && o.push({
|
|
6588
6605
|
type: "horizontal",
|
|
6589
6606
|
axis: b,
|
|
6590
|
-
start:
|
|
6607
|
+
start: h,
|
|
6591
6608
|
end: n,
|
|
6592
6609
|
distance: C
|
|
6593
6610
|
}), o;
|
|
6594
6611
|
}
|
|
6595
6612
|
if (!s) return o;
|
|
6596
|
-
const I = n < d, y = i >
|
|
6613
|
+
const I = n < d, y = i > h, w = Math.min(n, d), A = Math.max(n, d), j = A - w;
|
|
6597
6614
|
j > 0 && !I && o.push({
|
|
6598
6615
|
type: "horizontal",
|
|
6599
6616
|
axis: b,
|
|
@@ -6601,7 +6618,7 @@ class Lt {
|
|
|
6601
6618
|
end: A,
|
|
6602
6619
|
distance: j
|
|
6603
6620
|
});
|
|
6604
|
-
const M = Math.min(i,
|
|
6621
|
+
const M = Math.min(i, h), T = Math.max(i, h), S = T - M;
|
|
6605
6622
|
return S > 0 && !y && o.push({
|
|
6606
6623
|
type: "horizontal",
|
|
6607
6624
|
axis: b,
|
|
@@ -6626,7 +6643,7 @@ class Lt {
|
|
|
6626
6643
|
centerX: c = 0
|
|
6627
6644
|
} = t, {
|
|
6628
6645
|
top: d = 0,
|
|
6629
|
-
bottom:
|
|
6646
|
+
bottom: h = 0,
|
|
6630
6647
|
left: u = 0,
|
|
6631
6648
|
right: g = 0,
|
|
6632
6649
|
centerX: f = 0
|
|
@@ -6642,19 +6659,19 @@ class Lt {
|
|
|
6642
6659
|
distance: C
|
|
6643
6660
|
}), o;
|
|
6644
6661
|
}
|
|
6645
|
-
if (
|
|
6662
|
+
if (h <= n) {
|
|
6646
6663
|
if (s) return o;
|
|
6647
|
-
const C = n -
|
|
6664
|
+
const C = n - h;
|
|
6648
6665
|
return C > 0 && o.push({
|
|
6649
6666
|
type: "vertical",
|
|
6650
6667
|
axis: b,
|
|
6651
|
-
start:
|
|
6668
|
+
start: h,
|
|
6652
6669
|
end: n,
|
|
6653
6670
|
distance: C
|
|
6654
6671
|
}), o;
|
|
6655
6672
|
}
|
|
6656
6673
|
if (!s) return o;
|
|
6657
|
-
const I = n < d, y = i >
|
|
6674
|
+
const I = n < d, y = i > h, w = Math.min(n, d), A = Math.max(n, d), j = A - w;
|
|
6658
6675
|
j > 0 && !I && o.push({
|
|
6659
6676
|
type: "vertical",
|
|
6660
6677
|
axis: b,
|
|
@@ -6662,7 +6679,7 @@ class Lt {
|
|
|
6662
6679
|
end: A,
|
|
6663
6680
|
distance: j
|
|
6664
6681
|
});
|
|
6665
|
-
const M = Math.min(i,
|
|
6682
|
+
const M = Math.min(i, h), T = Math.max(i, h), S = T - M;
|
|
6666
6683
|
return S > 0 && !y && o.push({
|
|
6667
6684
|
type: "vertical",
|
|
6668
6685
|
axis: b,
|
|
@@ -6698,11 +6715,11 @@ class Lt {
|
|
|
6698
6715
|
const { viewportTransform: s } = t, o = t.getZoom() || 1, n = this.activeGuides.some((c) => c.type === "vertical"), i = this.activeGuides.some((c) => c.type === "horizontal"), a = n && i && !this.isTargetMontageArea, r = a ? 12 / o : 0;
|
|
6699
6716
|
e.save(), Array.isArray(s) && e.transform(...s), e.lineWidth = ts / o, e.strokeStyle = $e, e.setLineDash([]);
|
|
6700
6717
|
for (const c of this.activeGuides) {
|
|
6701
|
-
const { type: d, axis:
|
|
6702
|
-
e.beginPath(), d === "vertical" ? (e.moveTo(
|
|
6718
|
+
const { type: d, axis: h, start: u, end: g, distance: f } = c, p = Math.abs(g - u), m = u <= g ? -1 : 1, v = a ? m * (p / 2 + r) : 0, b = 0;
|
|
6719
|
+
e.beginPath(), d === "vertical" ? (e.moveTo(h, u), e.lineTo(h, g)) : (e.moveTo(u, h), e.lineTo(g, h)), e.stroke(), me({
|
|
6703
6720
|
context: e,
|
|
6704
6721
|
type: d,
|
|
6705
|
-
axis:
|
|
6722
|
+
axis: h,
|
|
6706
6723
|
start: u,
|
|
6707
6724
|
end: g,
|
|
6708
6725
|
text: Math.round(f).toString(),
|
|
@@ -6762,7 +6779,7 @@ class Se {
|
|
|
6762
6779
|
initialStateJSON: r,
|
|
6763
6780
|
scaleType: c,
|
|
6764
6781
|
showRotationAngle: d,
|
|
6765
|
-
_onReadyCallback:
|
|
6782
|
+
_onReadyCallback: h
|
|
6766
6783
|
} = this.options;
|
|
6767
6784
|
if (J.apply(), this.canvas = new vs(this.containerId, this.options), this.moduleLoader = new As(), this.workerManager = new Is(), this.errorManager = new Yt({ editor: this }), this.historyManager = new Jt({ editor: this }), this.toolbar = new Ys({ editor: this }), this.transformManager = new qs({ editor: this }), this.zoomManager = new Js({ editor: this }), this.canvasManager = new Qs({ editor: this }), this.imageManager = new ct({ editor: this }), this.layerManager = new $t({ editor: this }), this.shapeManager = new to({ editor: this }), this.interactionBlocker = new $s({ editor: this }), this.backgroundManager = new Ot({ editor: this }), this.clipboardManager = new eo({ editor: this }), this.objectLockManager = new te({ editor: this }), this.groupingManager = new so({ editor: this }), this.selectionManager = new oo({ editor: this }), this.deletionManager = new we({ editor: this }), this.panConstraintManager = new no({ editor: this }), this.snappingManager = new jo({ editor: this }), this.measurementManager = new Lt({ editor: this }), this.fontManager = new fe((u = this.options.fonts) != null ? u : []), this.textManager = new Z({ editor: this }), this.templateManager = new R({ editor: this }), d && (this.angleIndicator = new Me({ editor: this })), this._createMontageArea(), this._createClippingArea(), this.listeners = new Ut({ editor: this, options: this.options }), this.canvasManager.setEditorContainerWidth(t), this.canvasManager.setEditorContainerHeight(e), this.canvasManager.setCanvasWrapperWidth(s), this.canvasManager.setCanvasWrapperHeight(o), this.canvasManager.setCanvasCSSWidth(n), this.canvasManager.setCanvasCSSHeight(i), this.canvasManager.updateCanvas(), this.zoomManager.calculateAndApplyDefaultZoom(), yield this.fontManager.loadFonts(), a != null && a.source) {
|
|
6768
6785
|
const {
|
|
@@ -6772,7 +6789,7 @@ class Se {
|
|
|
6772
6789
|
} = a;
|
|
6773
6790
|
yield this.imageManager.importImage({ source: g, scale: f, withoutSave: p });
|
|
6774
6791
|
}
|
|
6775
|
-
r && this.historyManager.loadStateFromFullState(r), this.historyManager.saveState(), console.log("editor:ready"), this.canvas.fire("editor:ready", this), typeof
|
|
6792
|
+
r && this.historyManager.loadStateFromFullState(r), this.historyManager.saveState(), console.log("editor:ready"), this.canvas.fire("editor:ready", this), typeof h == "function" && h(this);
|
|
6776
6793
|
});
|
|
6777
6794
|
}
|
|
6778
6795
|
/**
|
|
@@ -7753,15 +7770,15 @@ const E = [
|
|
|
7753
7770
|
*/
|
|
7754
7771
|
fonts: Io
|
|
7755
7772
|
};
|
|
7756
|
-
function Do(
|
|
7757
|
-
const e = _(_({}, Co), t), s = document.getElementById(
|
|
7773
|
+
function Do(l, t = {}) {
|
|
7774
|
+
const e = _(_({}, Co), t), s = document.getElementById(l);
|
|
7758
7775
|
if (!s)
|
|
7759
|
-
return Promise.reject(new Error(`Контейнер с ID "${
|
|
7776
|
+
return Promise.reject(new Error(`Контейнер с ID "${l}" не найден.`));
|
|
7760
7777
|
const o = document.createElement("canvas");
|
|
7761
|
-
return o.id = `${
|
|
7778
|
+
return o.id = `${l}-canvas`, s.appendChild(o), e.editorContainer = s, new Promise((n) => {
|
|
7762
7779
|
e._onReadyCallback = n;
|
|
7763
7780
|
const i = new Se(o.id, e);
|
|
7764
|
-
window[
|
|
7781
|
+
window[l] = i;
|
|
7765
7782
|
});
|
|
7766
7783
|
}
|
|
7767
7784
|
export {
|