@anu3ev/fabric-image-editor 0.5.22 → 0.5.23
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 +664 -555
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
var ds = Object.defineProperty, ls = Object.defineProperties;
|
|
2
2
|
var hs = Object.getOwnPropertyDescriptors;
|
|
3
3
|
var ne = Object.getOwnPropertySymbols;
|
|
4
|
-
var
|
|
4
|
+
var xe = Object.prototype.hasOwnProperty, Ne = Object.prototype.propertyIsEnumerable;
|
|
5
5
|
var _e = (h, t, e) => t in h ? ds(h, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : h[t] = e, B = (h, t) => {
|
|
6
6
|
for (var e in t || (t = {}))
|
|
7
|
-
|
|
7
|
+
xe.call(t, e) && _e(h, e, t[e]);
|
|
8
8
|
if (ne)
|
|
9
9
|
for (var e of ne(t))
|
|
10
|
-
|
|
10
|
+
Ne.call(t, e) && _e(h, e, t[e]);
|
|
11
11
|
return h;
|
|
12
|
-
},
|
|
13
|
-
var
|
|
12
|
+
}, St = (h, t) => ls(h, hs(t));
|
|
13
|
+
var pt = (h, t) => {
|
|
14
14
|
var e = {};
|
|
15
15
|
for (var s in h)
|
|
16
|
-
|
|
16
|
+
xe.call(h, s) && t.indexOf(s) < 0 && (e[s] = h[s]);
|
|
17
17
|
if (h != null && ne)
|
|
18
18
|
for (var s of ne(h))
|
|
19
|
-
t.indexOf(s) < 0 &&
|
|
19
|
+
t.indexOf(s) < 0 && Ne.call(h, s) && (e[s] = h[s]);
|
|
20
20
|
return e;
|
|
21
21
|
};
|
|
22
|
-
var
|
|
22
|
+
var P = (h, t, e) => new Promise((s, n) => {
|
|
23
23
|
var o = (r) => {
|
|
24
24
|
try {
|
|
25
25
|
a(e.next(r));
|
|
@@ -35,15 +35,15 @@ var z = (h, t, e) => new Promise((s, n) => {
|
|
|
35
35
|
}, a = (r) => r.done ? s(r.value) : Promise.resolve(r.value).then(o, i);
|
|
36
36
|
a((e = e.apply(h, t)).next());
|
|
37
37
|
});
|
|
38
|
-
import { ActiveSelection as U, Textbox as
|
|
38
|
+
import { ActiveSelection as U, Textbox as it, util as ft, controlsUtils as Be, InteractiveFabricObject as ke, Point as et, FitContentLayout as ze, loadSVGFromURL as us, FabricImage as Gt, Gradient as Pe, Rect as fs, Circle as gs, Triangle as ps, Group as Ot, Color as ms, classRegistry as We, loadSVGFromString as ys, Canvas as vs, Pattern as bs } from "fabric";
|
|
39
39
|
import { create as Ms } from "jsondiffpatch";
|
|
40
40
|
import ws from "diff-match-patch";
|
|
41
|
-
var Ss = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",
|
|
41
|
+
var Ss = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", X = function() {
|
|
42
42
|
for (var t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 21, e = "", s = crypto.getRandomValues(new Uint8Array(t |= 0)); t--; )
|
|
43
43
|
e += Ss[s[t] & 63];
|
|
44
44
|
return e;
|
|
45
45
|
};
|
|
46
|
-
class
|
|
46
|
+
class Kt {
|
|
47
47
|
/**
|
|
48
48
|
* Конструктор принимает редактор и опции.
|
|
49
49
|
* @param params
|
|
@@ -61,7 +61,7 @@ class Xt {
|
|
|
61
61
|
* @param params.options.adaptCanvasToContainerOnResize — адаптировать канвас к размерам контейнера при изменении размеров окна
|
|
62
62
|
*/
|
|
63
63
|
constructor({ editor: t, options: e = {} }) {
|
|
64
|
-
this.isDragging = !1, this.lastMouseX = 0, this.lastMouseY = 0, this.isUndoRedoKeyPressed = !1, this.isSpacePressed = !1, this.savedSelection = [], this.canvasDragging = !1, this.mouseWheelZooming = !1, this.bringToFrontOnSelection = !1, this.resetObjectFitByDoubleClick = !1, this.copyObjectsByHotkey = !1, this.pasteImageFromClipboard = !1, this.undoRedoByHotKeys = !1, this.selectAllByHotkey = !1, this.deleteObjectsByHotkey = !1, this.adaptCanvasToContainerOnResize = !1, this.editor = t, this.canvas = t.canvas, this.options = e, this.handleContainerResizeBound =
|
|
64
|
+
this.isDragging = !1, this.lastMouseX = 0, this.lastMouseY = 0, this.isUndoRedoKeyPressed = !1, this.isSpacePressed = !1, this.savedSelection = [], this.canvasDragging = !1, this.mouseWheelZooming = !1, this.bringToFrontOnSelection = !1, this.resetObjectFitByDoubleClick = !1, this.copyObjectsByHotkey = !1, this.pasteImageFromClipboard = !1, this.undoRedoByHotKeys = !1, this.selectAllByHotkey = !1, this.deleteObjectsByHotkey = !1, this.adaptCanvasToContainerOnResize = !1, this.editor = t, this.canvas = t.canvas, this.options = e, this.handleContainerResizeBound = Kt.debounce(this.handleContainerResize.bind(this), 500), this.handleCopyEventBound = this.handleCopyEvent.bind(this), this.handlePasteEventBound = this.handlePasteEvent.bind(this), this.handleUndoRedoEventBound = this.handleUndoRedoEvent.bind(this), this.handleUndoRedoKeyUpBound = this.handleUndoRedoKeyUp.bind(this), this.handleSelectAllEventBound = this.handleSelectAllEvent.bind(this), this.handleDeleteObjectsEventBound = this.handleDeleteObjectsEvent.bind(this), this.handleSpaceKeyDownBound = this.handleSpaceKeyDown.bind(this), this.handleSpaceKeyUpBound = this.handleSpaceKeyUp.bind(this), this.handleObjectModifiedHistoryBound = Kt.debounce(this.handleObjectModifiedHistory.bind(this), 300), this.handleObjectRotatingHistoryBound = Kt.debounce(this.handleObjectRotatingHistory.bind(this), 300), this.handleObjectAddedHistoryBound = this.handleObjectAddedHistory.bind(this), this.handleObjectRemovedHistoryBound = this.handleObjectRemovedHistory.bind(this), this.handleOverlayUpdateBound = this.handleOverlayUpdate.bind(this), this.handleBackgroundUpdateBound = this.handleBackgroundUpdate.bind(this), this.handleCanvasDragStartBound = this.handleCanvasDragStart.bind(this), this.handleCanvasDraggingBound = this.handleCanvasDragging.bind(this), this.handleCanvasDragEndBound = this.handleCanvasDragEnd.bind(this), this.handleMouseWheelZoomBound = this.handleMouseWheelZoom.bind(this), this.handleBringToFrontBound = this.handleBringToFront.bind(this), this.handleResetObjectFitBound = this.handleResetObjectFit.bind(this), this.handleLockedSelectionBound = this._filterLockedSelection.bind(this), this.init();
|
|
65
65
|
}
|
|
66
66
|
/**
|
|
67
67
|
* Инициализация всех обработчиков согласно опциям.
|
|
@@ -175,7 +175,7 @@ class Xt {
|
|
|
175
175
|
* @param event.code — код клавиши
|
|
176
176
|
*/
|
|
177
177
|
handleUndoRedoEvent(t) {
|
|
178
|
-
return
|
|
178
|
+
return P(this, null, function* () {
|
|
179
179
|
const { ctrlKey: e, metaKey: s, code: n, repeat: o } = t;
|
|
180
180
|
this._shouldIgnoreKeyboardEvent(t) || !e && !s || o || !/Mac/i.test(navigator.userAgent) && this.isUndoRedoKeyPressed || (n === "KeyZ" ? (t.preventDefault(), this.isUndoRedoKeyPressed = !0, yield this.editor.historyManager.undo()) : n === "KeyY" && (t.preventDefault(), this.isUndoRedoKeyPressed = !0, yield this.editor.historyManager.redo()));
|
|
181
181
|
});
|
|
@@ -347,7 +347,7 @@ class Xt {
|
|
|
347
347
|
*/
|
|
348
348
|
handleResetObjectFit(t) {
|
|
349
349
|
const e = t == null ? void 0 : t.target;
|
|
350
|
-
!e || e instanceof
|
|
350
|
+
!e || e instanceof it || this.editor.transformManager.resetObject({ object: e });
|
|
351
351
|
}
|
|
352
352
|
/**
|
|
353
353
|
* Проверяет, должно ли событие клавиатуры быть проигнорировано
|
|
@@ -468,7 +468,7 @@ class Is {
|
|
|
468
468
|
* @returns Promise, который будет выполнен, когда воркер вернет ответ
|
|
469
469
|
*/
|
|
470
470
|
post(t, e, s = []) {
|
|
471
|
-
const n = `${t}:${
|
|
471
|
+
const n = `${t}:${X(8)}`;
|
|
472
472
|
return new Promise((o, i) => {
|
|
473
473
|
this._callbacks.set(n, { resolve: o, reject: i }), this.worker.postMessage({ action: t, payload: e, requestId: n }, s);
|
|
474
474
|
});
|
|
@@ -480,52 +480,52 @@ class Is {
|
|
|
480
480
|
this.worker.terminate();
|
|
481
481
|
}
|
|
482
482
|
}
|
|
483
|
-
const
|
|
483
|
+
const ht = 12, Cs = 2, ve = 8, be = 20, Ts = 100, Me = 20, we = 8, Es = 100, de = 32, Ie = 1, Os = "#2B2D33", Ce = "#3D8BF4", Te = "#FFFFFF";
|
|
484
484
|
function oe(h, t, e, s, n) {
|
|
485
|
-
const o =
|
|
486
|
-
h.save(), h.translate(t, e), h.rotate(
|
|
485
|
+
const o = ht, i = Cs;
|
|
486
|
+
h.save(), h.translate(t, e), h.rotate(ft.degreesToRadians(n.angle)), h.fillStyle = Te, h.strokeStyle = Ce, h.lineWidth = Ie, h.beginPath(), h.roundRect(-o / 2, -o / 2, o, o, i), h.fill(), h.stroke(), h.restore();
|
|
487
487
|
}
|
|
488
488
|
function Ue(h, t, e, s, n) {
|
|
489
489
|
const o = ve, i = be, a = Ts;
|
|
490
|
-
h.save(), h.translate(t, e), h.rotate(
|
|
490
|
+
h.save(), h.translate(t, e), h.rotate(ft.degreesToRadians(n.angle)), h.fillStyle = Te, h.strokeStyle = Ce, h.lineWidth = Ie, h.beginPath(), h.roundRect(-o / 2, -i / 2, o, i, a), h.fill(), h.stroke(), h.restore();
|
|
491
491
|
}
|
|
492
492
|
function Fe(h, t, e, s, n) {
|
|
493
493
|
const o = Me, i = we, a = Es;
|
|
494
|
-
h.save(), h.translate(t, e), h.rotate(
|
|
494
|
+
h.save(), h.translate(t, e), h.rotate(ft.degreesToRadians(n.angle)), h.fillStyle = Te, h.strokeStyle = Ce, h.lineWidth = Ie, h.beginPath(), h.roundRect(-o / 2, -i / 2, o, i, a), h.fill(), h.stroke(), h.restore();
|
|
495
495
|
}
|
|
496
496
|
const Ls = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTE4Ljc1IDQuMzc1djMuNzVhLjYyNS42MjUgMCAwIDEtLjYyNS42MjVoLTMuNzVhLjYyNS42MjUgMCAwIDEgMC0xLjI1aDIuMTRsLTIuMDc3LTEuOTAzLS4wMi0uMDE5YTYuMjUgNi4yNSAwIDEgMC0uMTMgOC45NjcuNjI2LjYyNiAwIDAgMSAuODYuOTA5QTcuNDU2IDcuNDU2IDAgMCAxIDEwIDE3LjVoLS4xMDNhNy41IDcuNSAwIDEgMSA1LjM5Ni0xMi44MTJMMTcuNSA2LjcwM1Y0LjM3NWEuNjI1LjYyNSAwIDAgMSAxLjI1IDBaIi8+PC9zdmc+", ss = new Image();
|
|
497
497
|
ss.src = Ls;
|
|
498
498
|
function Ds(h, t, e, s, n) {
|
|
499
499
|
const i = de / 2;
|
|
500
|
-
h.save(), h.translate(t, e), h.rotate(
|
|
500
|
+
h.save(), h.translate(t, e), h.rotate(ft.degreesToRadians(n.angle)), h.fillStyle = Os, h.beginPath(), h.arc(0, 0, i, 0, 2 * Math.PI), h.fill(), h.drawImage(ss, -i / 2, -i / 2, i, i), h.restore();
|
|
501
501
|
}
|
|
502
502
|
const Rs = {
|
|
503
503
|
// Угловые точки
|
|
504
504
|
tl: {
|
|
505
505
|
render: oe,
|
|
506
|
-
sizeX:
|
|
507
|
-
sizeY:
|
|
506
|
+
sizeX: ht,
|
|
507
|
+
sizeY: ht,
|
|
508
508
|
offsetX: 0,
|
|
509
509
|
offsetY: 0
|
|
510
510
|
},
|
|
511
511
|
tr: {
|
|
512
512
|
render: oe,
|
|
513
|
-
sizeX:
|
|
514
|
-
sizeY:
|
|
513
|
+
sizeX: ht,
|
|
514
|
+
sizeY: ht,
|
|
515
515
|
offsetX: 0,
|
|
516
516
|
offsetY: 0
|
|
517
517
|
},
|
|
518
518
|
bl: {
|
|
519
519
|
render: oe,
|
|
520
|
-
sizeX:
|
|
521
|
-
sizeY:
|
|
520
|
+
sizeX: ht,
|
|
521
|
+
sizeY: ht,
|
|
522
522
|
offsetX: 0,
|
|
523
523
|
offsetY: 0
|
|
524
524
|
},
|
|
525
525
|
br: {
|
|
526
526
|
render: oe,
|
|
527
|
-
sizeX:
|
|
528
|
-
sizeY:
|
|
527
|
+
sizeX: ht,
|
|
528
|
+
sizeY: ht,
|
|
529
529
|
offsetX: 0,
|
|
530
530
|
offsetY: 0
|
|
531
531
|
},
|
|
@@ -568,7 +568,7 @@ const Rs = {
|
|
|
568
568
|
offsetY: -de
|
|
569
569
|
}
|
|
570
570
|
};
|
|
571
|
-
class
|
|
571
|
+
class st {
|
|
572
572
|
/**
|
|
573
573
|
* Отключает изменение ширины по оси X для заблокированных объектов, сохраняя поведение остального хэндлера.
|
|
574
574
|
*/
|
|
@@ -598,9 +598,9 @@ class et {
|
|
|
598
598
|
*/
|
|
599
599
|
static apply() {
|
|
600
600
|
const t = Be.createObjectDefaultControls();
|
|
601
|
-
|
|
601
|
+
st.applyControlOverrides(t), ke.ownDefaults.controls = t;
|
|
602
602
|
const e = Be.createTextboxDefaultControls();
|
|
603
|
-
|
|
603
|
+
st.applyControlOverrides(e), e.mt && (e.mt.visible = !1), e.mb && (e.mb.visible = !1), st.wrapWidthControl(e.ml), st.wrapWidthControl(e.mr), it.ownDefaults.controls = e, st.patchActiveSelectionBounds(), ke.ownDefaults.snapAngle = 1;
|
|
604
604
|
}
|
|
605
605
|
/**
|
|
606
606
|
* Обновляет алгоритм расчёта границ ActiveSelection, чтобы учитывать фон и отступы текстовых объектов.
|
|
@@ -610,11 +610,11 @@ class et {
|
|
|
610
610
|
t._calcBoundsFromObjects = function(...o) {
|
|
611
611
|
var f, g;
|
|
612
612
|
const i = (g = (f = this.getObjects) == null ? void 0 : f.call(this)) != null ? g : [];
|
|
613
|
-
|
|
613
|
+
st.applyTextSelectionScalingLock({
|
|
614
614
|
selection: this,
|
|
615
615
|
objects: i
|
|
616
616
|
});
|
|
617
|
-
const a =
|
|
617
|
+
const a = st.calculateActiveSelectionBounds({
|
|
618
618
|
objects: i
|
|
619
619
|
});
|
|
620
620
|
if (!a)
|
|
@@ -626,45 +626,45 @@ class et {
|
|
|
626
626
|
width: d,
|
|
627
627
|
height: l
|
|
628
628
|
});
|
|
629
|
-
const u = new
|
|
629
|
+
const u = new et(r + d / 2, c + l / 2);
|
|
630
630
|
return this.setPositionByOrigin(u, "center", "center"), a;
|
|
631
631
|
};
|
|
632
632
|
const s = t._onAfterObjectsChange;
|
|
633
633
|
t._onAfterObjectsChange = function(o, i) {
|
|
634
634
|
var p, m;
|
|
635
635
|
const a = s ? s.call(this, o, i) : void 0, r = (m = (p = this.getObjects) == null ? void 0 : p.call(this)) != null ? m : [];
|
|
636
|
-
|
|
636
|
+
st.applyTextSelectionScalingLock({
|
|
637
637
|
selection: this,
|
|
638
638
|
objects: r
|
|
639
639
|
});
|
|
640
|
-
const c =
|
|
640
|
+
const c = st.calculateActiveSelectionBounds({
|
|
641
641
|
objects: r
|
|
642
642
|
});
|
|
643
643
|
if (!c) return a;
|
|
644
|
-
const { left: d, top: l, width: u, height: f } = c, g = new
|
|
644
|
+
const { left: d, top: l, width: u, height: f } = c, g = new et(d + u / 2, l + f / 2);
|
|
645
645
|
return this.set({
|
|
646
646
|
width: u,
|
|
647
647
|
height: f
|
|
648
648
|
}), this.setPositionByOrigin(g, "center", "center"), this.setCoords(), a;
|
|
649
649
|
};
|
|
650
|
-
const n =
|
|
651
|
-
|
|
650
|
+
const n = ze.prototype.calcBoundingBox;
|
|
651
|
+
ze.prototype.calcBoundingBox = function(o, i) {
|
|
652
652
|
const { target: a, type: r, overrides: c } = i;
|
|
653
653
|
if (r === "imperative" && c)
|
|
654
654
|
return c;
|
|
655
655
|
if (!(a instanceof U))
|
|
656
656
|
return n.call(this, o, i);
|
|
657
|
-
|
|
657
|
+
st.applyTextSelectionScalingLock({
|
|
658
658
|
selection: a,
|
|
659
659
|
objects: o
|
|
660
660
|
});
|
|
661
|
-
const d =
|
|
661
|
+
const d = st.calculateActiveSelectionBounds({ objects: o });
|
|
662
662
|
if (!d)
|
|
663
663
|
return n.call(this, o, i);
|
|
664
|
-
const { left: l, top: u, width: f, height: g } = d, p = new
|
|
664
|
+
const { left: l, top: u, width: f, height: g } = d, p = new et(f, g), m = new et(l + f / 2, u + g / 2);
|
|
665
665
|
return r === "initialization" ? {
|
|
666
666
|
center: m,
|
|
667
|
-
relativeCorrection: new
|
|
667
|
+
relativeCorrection: new et(0, 0),
|
|
668
668
|
size: p
|
|
669
669
|
} : {
|
|
670
670
|
center: m,
|
|
@@ -694,7 +694,7 @@ class et {
|
|
|
694
694
|
selection: t,
|
|
695
695
|
objects: e
|
|
696
696
|
}) {
|
|
697
|
-
const s = e.some((n) => n instanceof
|
|
697
|
+
const s = e.some((n) => n instanceof it);
|
|
698
698
|
t.setControlsVisibility({
|
|
699
699
|
mt: !s,
|
|
700
700
|
mb: !s,
|
|
@@ -703,7 +703,7 @@ class et {
|
|
|
703
703
|
});
|
|
704
704
|
}
|
|
705
705
|
}
|
|
706
|
-
const
|
|
706
|
+
const W = class W {
|
|
707
707
|
constructor(t = []) {
|
|
708
708
|
this.fonts = t;
|
|
709
709
|
}
|
|
@@ -711,36 +711,36 @@ const P = class P {
|
|
|
711
711
|
this.fonts = t;
|
|
712
712
|
}
|
|
713
713
|
loadFonts() {
|
|
714
|
-
return
|
|
714
|
+
return P(this, null, function* () {
|
|
715
715
|
var n;
|
|
716
716
|
const t = (n = this.fonts) != null ? n : [];
|
|
717
717
|
if (!t.length) return;
|
|
718
718
|
const e = typeof document != "undefined" ? document : void 0;
|
|
719
719
|
if (!e) return;
|
|
720
|
-
const s = t.map((o) =>
|
|
720
|
+
const s = t.map((o) => W.loadFont(o, e));
|
|
721
721
|
yield Promise.allSettled(s);
|
|
722
722
|
});
|
|
723
723
|
}
|
|
724
724
|
static loadFont(t, e) {
|
|
725
|
-
return
|
|
725
|
+
return P(this, null, function* () {
|
|
726
726
|
var c, d;
|
|
727
727
|
const s = typeof FontFace != "undefined", n = (c = t.family) == null ? void 0 : c.trim(), o = (d = t.source) == null ? void 0 : d.trim();
|
|
728
728
|
if (!n || !o) return;
|
|
729
|
-
const i =
|
|
730
|
-
if (!
|
|
731
|
-
if (
|
|
732
|
-
|
|
729
|
+
const i = W.normalizeFontSource(o), a = W.getDescriptorSnapshot(t.descriptors), r = W.getFontRegistrationKey(n, i, a);
|
|
730
|
+
if (!W.registeredFontKeys.has(r)) {
|
|
731
|
+
if (W.isFontFaceAlreadyApplied(e, n, a)) {
|
|
732
|
+
W.registeredFontKeys.add(r);
|
|
733
733
|
return;
|
|
734
734
|
}
|
|
735
735
|
if (s && e.fonts && typeof e.fonts.add == "function")
|
|
736
736
|
try {
|
|
737
737
|
const u = yield new FontFace(n, i, t.descriptors).load();
|
|
738
|
-
e.fonts.add(u),
|
|
738
|
+
e.fonts.add(u), W.registeredFontKeys.add(r);
|
|
739
739
|
return;
|
|
740
740
|
} catch (l) {
|
|
741
741
|
console.warn(`Не удалось загрузить шрифт "${n}" через FontFace API`, l);
|
|
742
742
|
}
|
|
743
|
-
|
|
743
|
+
W.injectFontFace({
|
|
744
744
|
font: t,
|
|
745
745
|
source: i,
|
|
746
746
|
doc: e,
|
|
@@ -760,15 +760,15 @@ const P = class P {
|
|
|
760
760
|
if (!i) return;
|
|
761
761
|
const a = s.createElement("style");
|
|
762
762
|
a.setAttribute("data-editor-font", i), a.setAttribute("data-editor-font-key", n);
|
|
763
|
-
const r =
|
|
763
|
+
const r = W.descriptorsToCss(o), c = [
|
|
764
764
|
"@font-face {",
|
|
765
|
-
` font-family: ${
|
|
765
|
+
` font-family: ${W.formatFontFamilyForCss(i)};`,
|
|
766
766
|
` src: ${e};`,
|
|
767
767
|
...r.map((l) => ` ${l}`),
|
|
768
768
|
"}"
|
|
769
769
|
];
|
|
770
770
|
a.textContent = c.join(`
|
|
771
|
-
`), s.head.appendChild(a),
|
|
771
|
+
`), s.head.appendChild(a), W.registeredFontKeys.add(n);
|
|
772
772
|
}
|
|
773
773
|
static normalizeFontSource(t) {
|
|
774
774
|
const e = t.trim();
|
|
@@ -791,15 +791,15 @@ const P = class P {
|
|
|
791
791
|
return t ? t.trim().replace(/^['"]+|['"]+$/g, "").toLowerCase() : "";
|
|
792
792
|
}
|
|
793
793
|
static getDescriptorSnapshot(t) {
|
|
794
|
-
const e =
|
|
794
|
+
const e = W.descriptorDefaults;
|
|
795
795
|
return {
|
|
796
|
-
style:
|
|
797
|
-
weight:
|
|
798
|
-
stretch:
|
|
799
|
-
unicodeRange:
|
|
800
|
-
variant:
|
|
801
|
-
featureSettings:
|
|
802
|
-
display:
|
|
796
|
+
style: W.normalizeDescriptorValue(t == null ? void 0 : t.style, e.style),
|
|
797
|
+
weight: W.normalizeDescriptorValue(t == null ? void 0 : t.weight, e.weight),
|
|
798
|
+
stretch: W.normalizeDescriptorValue(t == null ? void 0 : t.stretch, e.stretch),
|
|
799
|
+
unicodeRange: W.normalizeDescriptorValue(t == null ? void 0 : t.unicodeRange, e.unicodeRange),
|
|
800
|
+
variant: W.normalizeDescriptorValue(t == null ? void 0 : t.variant, e.variant),
|
|
801
|
+
featureSettings: W.normalizeDescriptorValue(t == null ? void 0 : t.featureSettings, e.featureSettings),
|
|
802
|
+
display: W.normalizeDescriptorValue(t == null ? void 0 : t.display, e.display)
|
|
803
803
|
};
|
|
804
804
|
}
|
|
805
805
|
static areDescriptorSnapshotsEqual(t, e) {
|
|
@@ -807,7 +807,7 @@ const P = class P {
|
|
|
807
807
|
}
|
|
808
808
|
static getFontRegistrationKey(t, e, s) {
|
|
809
809
|
return [
|
|
810
|
-
|
|
810
|
+
W.normalizeFamilyName(t),
|
|
811
811
|
e,
|
|
812
812
|
s.style,
|
|
813
813
|
s.weight,
|
|
@@ -821,12 +821,12 @@ const P = class P {
|
|
|
821
821
|
static isFontFaceAlreadyApplied(t, e, s) {
|
|
822
822
|
const n = t.fonts;
|
|
823
823
|
if (!n || typeof n.forEach != "function") return !1;
|
|
824
|
-
const o =
|
|
824
|
+
const o = W.normalizeFamilyName(e);
|
|
825
825
|
let i = !1;
|
|
826
826
|
try {
|
|
827
827
|
n.forEach((a) => {
|
|
828
|
-
if (i ||
|
|
829
|
-
const c =
|
|
828
|
+
if (i || W.normalizeFamilyName(a.family) !== o) return;
|
|
829
|
+
const c = W.getDescriptorSnapshot({
|
|
830
830
|
style: a.style,
|
|
831
831
|
weight: a.weight,
|
|
832
832
|
stretch: a.stretch,
|
|
@@ -835,7 +835,7 @@ const P = class P {
|
|
|
835
835
|
featureSettings: a.featureSettings,
|
|
836
836
|
display: a.display
|
|
837
837
|
});
|
|
838
|
-
|
|
838
|
+
W.areDescriptorSnapshotsEqual(s, c) && (i = !0);
|
|
839
839
|
});
|
|
840
840
|
} catch (a) {
|
|
841
841
|
return console.warn("Не удалось проверить, загружен ли шрифт ранее через FontFaceSet", a), !1;
|
|
@@ -862,7 +862,7 @@ const P = class P {
|
|
|
862
862
|
});
|
|
863
863
|
}
|
|
864
864
|
};
|
|
865
|
-
|
|
865
|
+
W.registeredFontKeys = /* @__PURE__ */ new Set(), W.descriptorDefaults = {
|
|
866
866
|
style: "normal",
|
|
867
867
|
weight: "normal",
|
|
868
868
|
stretch: "normal",
|
|
@@ -871,8 +871,8 @@ P.registeredFontKeys = /* @__PURE__ */ new Set(), P.descriptorDefaults = {
|
|
|
871
871
|
featureSettings: "normal",
|
|
872
872
|
display: "auto"
|
|
873
873
|
};
|
|
874
|
-
let Se =
|
|
875
|
-
const _s = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNNi44NzUgMi41YS42MjUuNjI1IDAgMCAwLS42MjUuNjI0VjYuMjVIMy4xMjVhLjYyNS42MjUgMCAwIDAtLjYyNS42MjV2MTBjMCAuMzQ1LjI4LjYyNS42MjUuNjI1aDEwYy4zNDUgMCAuNjI1LS4yOC42MjUtLjYyNXYtMy4xMjZoMy4xMjVjLjM0NSAwIC42MjUtLjI4LjYyNS0uNjI1di0xMGEuNjI1LjYyNSAwIDAgMC0uNjI1LS42MjVoLTEwWm02Ljg3NSAxMGgyLjVWMy43NUg3LjV2Mi41aDUuNjI1Yy4zNDUgMCAuNjI1LjI4LjYyNS42MjV2NS42MjRabS0xMCAzLjc1VjcuNWg4Ljc1djguNzVIMy43NVoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjwvc3ZnPg==",
|
|
874
|
+
let Se = W;
|
|
875
|
+
const _s = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNNi44NzUgMi41YS42MjUuNjI1IDAgMCAwLS42MjUuNjI0VjYuMjVIMy4xMjVhLjYyNS42MjUgMCAwIDAtLjYyNS42MjV2MTBjMCAuMzQ1LjI4LjYyNS42MjUuNjI1aDEwYy4zNDUgMCAuNjI1LS4yOC42MjUtLjYyNXYtMy4xMjZoMy4xMjVjLjM0NSAwIC42MjUtLjI4LjYyNS0uNjI1di0xMGEuNjI1LjYyNSAwIDAgMC0uNjI1LS42MjVoLTEwWm02Ljg3NSAxMGgyLjVWMy43NUg3LjV2Mi41aDUuNjI1Yy4zNDUgMCAuNjI1LjI4LjYyNS42MjV2NS42MjRabS0xMCAzLjc1VjcuNWg4Ljc1djguNzVIMy43NVoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjwvc3ZnPg==", xs = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMi41IDcuNWMwLS42OS41Ni0xLjI1IDEuMjUtMS4yNWgxMi41Yy42OSAwIDEuMjUuNTYgMS4yNSAxLjI1djguNzVjMCAuNjktLjU2IDEuMjUtMS4yNSAxLjI1SDMuNzVjLS42OSAwLTEuMjUtLjU2LTEuMjUtMS4yNVY3LjVabTEzLjc1IDBIMy43NXY4Ljc1aDEyLjVWNy41WiIgY2xpcC1ydWxlPSJldmVub2RkIi8+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMTAgMS44NzVhMi4xODggMi4xODggMCAwIDAtMi4xODggMi4xODh2Mi44MTJhLjYyNS42MjUgMCAxIDEtMS4yNSAwVjQuMDYyYTMuNDM3IDMuNDM3IDAgMSAxIDYuODc1IDB2Mi44MTNhLjYyNS42MjUgMCAxIDEtMS4yNSAwVjQuMDYyQTIuMTg4IDIuMTg4IDAgMCAwIDEwIDEuODc2WiIgY2xpcC1ydWxlPSJldmVub2RkIi8+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTEwIDEyLjgxM2EuOTM3LjkzNyAwIDEgMCAwLTEuODc1LjkzNy45MzcgMCAwIDAgMCAxLjg3NFoiLz48L3N2Zz4=", Ns = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTE2LjI1IDYuMjVINy41VjQuMzc1YTIuNSAyLjUgMCAwIDEgMi41LTIuNWMxLjIgMCAyLjI4MS44NiAyLjUxMiAyYS42MjUuNjI1IDAgMCAwIDEuMjI2LS4yNWMtLjM1NC0xLjczOC0xLjkyNS0zLTMuNzM4LTNhMy43NTQgMy43NTQgMCAwIDAtMy43NSAzLjc1VjYuMjVoLTIuNUExLjI1IDEuMjUgMCAwIDAgMi41IDcuNXY4Ljc1YTEuMjUgMS4yNSAwIDAgMCAxLjI1IDEuMjVoMTIuNWExLjI1IDEuMjUgMCAwIDAgMS4yNS0xLjI1VjcuNWExLjI1IDEuMjUgMCAwIDAtMS4yNS0xLjI1Wm0wIDEwSDMuNzVWNy41aDEyLjV2OC43NVptLTUuMzEzLTQuMzc1YS45MzcuOTM3IDAgMSAxLTEuODc0IDAgLjkzNy45MzcgMCAwIDEgMS44NzQgMFoiLz48L3N2Zz4K", Bs = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTIuNSA4LjEyNSAxMCAxMi41bDcuNS00LjM3NUwxMCAzLjc1IDIuNSA4LjEyNVoiLz48cGF0aCBmaWxsPSIjZmZmIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik05LjY4NSAzLjIxYS42MjUuNjI1IDAgMCAxIC42MyAwbDcuNSA0LjM3NWEuNjI1LjYyNSAwIDAgMSAwIDEuMDhsLTcuNSA0LjM3NWEuNjI1LjYyNSAwIDAgMS0uNjMgMGwtNy41LTQuMzc1YS42MjUuNjI1IDAgMCAxIDAtMS4wOGw3LjUtNC4zNzVaTTMuNzQgOC4xMjUgMTAgMTEuNzc2bDYuMjYtMy42NTFMMTAgNC40NzQgMy43NCA4LjEyNVoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjxwYXRoIGZpbGw9IiNmZmYiIGZpbGwtcnVsZT0iZXZlbm9kZCIgZD0iTTUuNCA5LjQ2YS42MjUuNjI1IDAgMCAxIC42MyAwTDEwIDExLjc3NmwzLjk3LTIuMzE2YS42MjUuNjI1IDAgMCAxIC42MyAwbDMuMjE1IDEuODc1YS42MjUuNjI1IDAgMCAxIDAgMS4wOGwtNy41IDQuMzc1YS42MjUuNjI1IDAgMCAxLS42MyAwbC03LjUtNC4zNzVhLjYyNS42MjUgMCAwIDEgMC0xLjA4TDUuNCA5LjQ2Wm0tMS42NiAyLjQxNUwxMCAxNS41MjZsNi4yNi0zLjY1MS0xLjk3NC0xLjE1MS0zLjk3MSAyLjMxNmEuNjI1LjYyNSAwIDAgMS0uNjMgMGwtMy45Ny0yLjMxNi0xLjk3NSAxLjE1MVoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjwvc3ZnPg==", ks = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNOS42ODUgMy4yMWEuNjI1LjYyNSAwIDAgMSAuNjMgMGw3LjUgNC4zNzVhLjYyNS42MjUgMCAwIDEgMCAxLjA4bC03LjUgNC4zNzVhLjYyNS42MjUgMCAwIDEtLjYzIDBsLTcuNS00LjM3NWEuNjI1LjYyNSAwIDAgMSAwLTEuMDhsNy41LTQuMzc1Wk0zLjc0IDguMTI1IDEwIDExLjc3Nmw2LjI2LTMuNjUxTDEwIDQuNDc0IDMuNzQgOC4xMjVaIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiLz48cGF0aCBmaWxsPSIjZmZmIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik01LjcxNCAxMCAxMCAxMi41bDQuMjg2LTIuNSAzLjIxNCAxLjg3NUwxMCAxNi4yNWwtNy41LTQuMzc1TDUuNzE0IDEwWiIgY2xpcC1ydWxlPSJldmVub2RkIi8+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNNS40IDkuNDZhLjYyNS42MjUgMCAwIDEgLjYzIDBMMTAgMTEuNzc2bDMuOTctMi4zMTZhLjYyNS42MjUgMCAwIDEgLjYzIDBsMy4yMTUgMS44NzVhLjYyNS42MjUgMCAwIDEgMCAxLjA4bC03LjUgNC4zNzVhLjYyNS42MjUgMCAwIDEtLjYzIDBsLTcuNS00LjM3NWEuNjI1LjYyNSAwIDAgMSAwLTEuMDhMNS40IDkuNDZabS0xLjY2IDIuNDE1TDEwIDE1LjUyNmw2LjI2LTMuNjUxLTEuOTc0LTEuMTUxLTMuOTcxIDIuMzE2YS42MjUuNjI1IDAgMCAxLS42MyAwbC0zLjk3LTIuMzE2LTEuOTc1IDEuMTUxWiIgY2xpcC1ydWxlPSJldmVub2RkIi8+PC9zdmc+", zs = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0ibTIuNSA2LjI1IDcuNSA0LjM3NSA3LjUtNC4zNzVMMTAgMS44NzUgMi41IDYuMjVaIi8+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNOS42ODUgMS4zMzVhLjYyNS42MjUgMCAwIDEgLjYzIDBsNy41IDQuMzc1YS42MjUuNjI1IDAgMCAxIDAgMS4wOGwtNy41IDQuMzc1YS42MjUuNjI1IDAgMCAxLS42MyAwbC03LjUtNC4zNzVhLjYyNS42MjUgMCAwIDEgMC0xLjA4bDcuNS00LjM3NVpNMy43NCA2LjI1IDEwIDkuOTAxbDYuMjYtMy42NTFMMTAgMi41OTkgMy43NCA2LjI1WiIgY2xpcC1ydWxlPSJldmVub2RkIi8+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNNS40IDExLjMzNWEuNjI1LjYyNSAwIDAgMSAuNjMgMEwxMCAxMy42NTFsMy45Ny0yLjMxNmEuNjI1LjYyNSAwIDAgMSAuNjMgMGwzLjIxNSAxLjg3NWEuNjI1LjYyNSAwIDAgMSAwIDEuMDhsLTcuNSA0LjM3NWEuNjI1LjYyNSAwIDAgMS0uNjMgMGwtNy41LTQuMzc1YS42MjUuNjI1IDAgMCAxIDAtMS4wOEw1LjQgMTEuMzM1Wk0zLjc0IDEzLjc1IDEwIDE3LjQwMWw2LjI2LTMuNjUxLTEuOTc0LTEuMTUxLTMuOTcxIDIuMzE2YS42MjUuNjI1IDAgMCAxLS42MyAwbC0zLjk3LTIuMzE2TDMuNzQgMTMuNzVaIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiLz48cGF0aCBmaWxsPSIjZmZmIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik01LjQgNy41ODVhLjYyNS42MjUgMCAwIDEgLjYzIDBMMTAgOS45MDFsMy45Ny0yLjMxNmEuNjI1LjYyNSAwIDAgMSAuNjMgMGwzLjIxNSAxLjg3NWEuNjI1LjYyNSAwIDAgMSAwIDEuMDhsLTcuNSA0LjM3NWEuNjI1LjYyNSAwIDAgMS0uNjMgMGwtNy41LTQuMzc1YS42MjUuNjI1IDAgMCAxIDAtMS4wOEw1LjQgNy41ODVaTTMuNzQgMTAgMTAgMTMuNjUxIDE2LjI2IDEwbC0xLjk3NC0xLjE1MS0zLjk3MSAyLjMxNmEuNjI1LjYyNSAwIDAgMS0uNjMgMGwtMy45Ny0yLjMxNkwzLjc0IDEwWiIgY2xpcC1ydWxlPSJldmVub2RkIi8+PC9zdmc+", Ps = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMS45NiAxMy40MzVhLjYyNS42MjUgMCAwIDEgLjg1NS0uMjI1TDEwIDE3LjQwMWw3LjE4NS00LjE5YS42MjUuNjI1IDAgMCAxIC42MyAxLjA3OWwtNy41IDQuMzc1YS42MjUuNjI1IDAgMCAxLS42MyAwbC03LjUtNC4zNzVhLjYyNS42MjUgMCAwIDEtLjIyNS0uODU1Wk05LjY4NSAxLjMzNWEuNjI1LjYyNSAwIDAgMSAuNjMgMGw3LjUgNC4zNzVhLjYyNS42MjUgMCAwIDEgMCAxLjA4bC03LjUgNC4zNzVhLjYyNS42MjUgMCAwIDEtLjYzIDBsLTcuNS00LjM3NWEuNjI1LjYyNSAwIDAgMSAwLTEuMDhsNy41LTQuMzc1Wk0zLjc0IDYuMjUgMTAgOS45MDFsNi4yNi0zLjY1MUwxMCAyLjU5OSAzLjc0IDYuMjVaIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiLz48cGF0aCBmaWxsPSIjZmZmIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGQ9Im01LjcxNCAxMS44NzUgNC4yODYgMi41IDQuMjg2LTIuNUwxNy41IDEzLjc1IDEwIDE4LjEyNSAyLjUgMTMuNzVsMy4yMTQtMS44NzVaIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiLz48cGF0aCBmaWxsPSIjZmZmIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik01LjQgMTEuMzM1YS42MjUuNjI1IDAgMCAxIC42MyAwTDEwIDEzLjY1MWwzLjk3LTIuMzE2YS42MjUuNjI1IDAgMCAxIC42MyAwbDMuMjE1IDEuODc1YS42MjUuNjI1IDAgMCAxIDAgMS4wOGwtNy41IDQuMzc1YS42MjUuNjI1IDAgMCAxLS42MyAwbC03LjUtNC4zNzVhLjYyNS42MjUgMCAwIDEgMC0xLjA4TDUuNCAxMS4zMzVaTTMuNzQgMTMuNzUgMTAgMTcuNDAxbDYuMjYtMy42NTEtMS45NzQtMS4xNTEtMy45NzEgMi4zMTZhLjYyNS42MjUgMCAwIDEtLjYzIDBsLTMuOTctMi4zMTZMMy43NCAxMy43NVoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjxwYXRoIGZpbGw9IiNmZmYiIGZpbGwtcnVsZT0iZXZlbm9kZCIgZD0iTTUuNCA3LjU4NWEuNjI1LjYyNSAwIDAgMSAuNjMgMEwxMCA5LjkwMWwzLjk3LTIuMzE2YS42MjUuNjI1IDAgMCAxIC42MyAwbDMuMjE1IDEuODc1YS42MjUuNjI1IDAgMCAxIDAgMS4wOGwtNy41IDQuMzc1YS42MjUuNjI1IDAgMCAxLS42MyAwbC03LjUtNC4zNzVhLjYyNS42MjUgMCAwIDEgMC0xLjA4TDUuNCA3LjU4NVpNMy43NCAxMCAxMCAxMy42NTEgMTYuMjYgMTBsLTEuOTc0LTEuMTUxLTMuOTcxIDIuMzE2YS42MjUuNjI1IDAgMCAxLS42MyAwbC0zLjk3LTIuMzE2TDMuNzQgMTBaIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiLz48L3N2Zz4=", Ws = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI0VDNEU0MCIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNOC4xMjUgMS4yNUExLjg3NSAxLjg3NSAwIDAgMCA2LjI1IDMuMTI1di42MjVIMy4xMjVhLjYyNS42MjUgMCAwIDAgMCAxLjI1aC42MjV2MTEuMjVBMS4yNSAxLjI1IDAgMCAwIDUgMTcuNWgxMGExLjI1IDEuMjUgMCAwIDAgMS4yNS0xLjI1VjVoLjYyNWEuNjI1LjYyNSAwIDAgMCAwLTEuMjVIMTMuNzV2LS42MjVhMS44NzUgMS44NzUgMCAwIDAtMS44NzUtMS44NzVoLTMuNzVabTQuMzc1IDIuNXYtLjYyNWEuNjI1LjYyNSAwIDAgMC0uNjI1LS42MjVoLTMuNzVhLjYyNS42MjUgMCAwIDAtLjYyNS42MjV2LjYyNWg1Wk01IDE2LjI1VjVoMTB2MTEuMjVINVpNOC4xMjUgNy41Yy4zNDUgMCAuNjI1LjI4LjYyNS42MjV2NWEuNjI1LjYyNSAwIDEgMS0xLjI1IDB2LTVjMC0uMzQ1LjI4LS42MjUuNjI1LS42MjVabTQuMzc1IDUuNjI1di01YS42MjUuNjI1IDAgMCAwLTEuMjUgMHY1YS42MjUuNjI1IDAgMSAwIDEuMjUgMFoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjwvc3ZnPg==", Vt = {
|
|
876
876
|
style: {
|
|
877
877
|
position: "absolute",
|
|
878
878
|
display: "none",
|
|
@@ -940,16 +940,16 @@ const _s = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMj
|
|
|
940
940
|
offsetTop: 50,
|
|
941
941
|
icons: {
|
|
942
942
|
copyPaste: _s,
|
|
943
|
-
delete:
|
|
944
|
-
lock:
|
|
945
|
-
unlock:
|
|
946
|
-
bringToFront:
|
|
947
|
-
sendToBack:
|
|
943
|
+
delete: Ws,
|
|
944
|
+
lock: xs,
|
|
945
|
+
unlock: Ns,
|
|
946
|
+
bringToFront: zs,
|
|
947
|
+
sendToBack: Ps,
|
|
948
948
|
bringForward: Bs,
|
|
949
949
|
sendBackwards: ks
|
|
950
950
|
},
|
|
951
951
|
handlers: {
|
|
952
|
-
copyPaste: (h) =>
|
|
952
|
+
copyPaste: (h) => P(null, null, function* () {
|
|
953
953
|
h.clipboardManager.copyPaste();
|
|
954
954
|
}),
|
|
955
955
|
delete: (h) => {
|
|
@@ -982,11 +982,11 @@ class Us {
|
|
|
982
982
|
_initToolbar() {
|
|
983
983
|
if (!this.options.showToolbar) return;
|
|
984
984
|
const t = this.options.toolbar || {};
|
|
985
|
-
this.config =
|
|
986
|
-
style: B(B({},
|
|
987
|
-
btnStyle: B(B({},
|
|
988
|
-
icons: B(B({},
|
|
989
|
-
handlers: B(B({},
|
|
985
|
+
this.config = St(B(B({}, Vt), t), {
|
|
986
|
+
style: B(B({}, Vt.style), t.style || {}),
|
|
987
|
+
btnStyle: B(B({}, Vt.btnStyle), t.btnStyle || {}),
|
|
988
|
+
icons: B(B({}, Vt.icons), t.icons || {}),
|
|
989
|
+
handlers: B(B({}, Vt.handlers), t.handlers || {})
|
|
990
990
|
}), this.currentTarget = null, this.currentLocked = !1, this.isTransforming = !1, this.isTemporarilyHidden = !1, this._onMouseDown = this._handleMouseDown.bind(this), this._onObjectMoving = this._startTransform.bind(this), this._onObjectScaling = this._startTransform.bind(this), this._onObjectRotating = this._startTransform.bind(this), this._onMouseUp = this._endTransform.bind(this), this._onObjectModified = this._endTransform.bind(this), this._onSelectionChange = this._updateToolbar.bind(this), this._onSelectionClear = () => {
|
|
991
991
|
this.el.style.display = "none";
|
|
992
992
|
}, this._createDOM(), this._bindEvents();
|
|
@@ -1211,8 +1211,6 @@ class Ee {
|
|
|
1211
1211
|
}
|
|
1212
1212
|
}
|
|
1213
1213
|
const ns = [
|
|
1214
|
-
"selectable",
|
|
1215
|
-
"evented",
|
|
1216
1214
|
"id",
|
|
1217
1215
|
"backgroundId",
|
|
1218
1216
|
"customData",
|
|
@@ -1222,6 +1220,8 @@ const ns = [
|
|
|
1222
1220
|
"height",
|
|
1223
1221
|
"locked",
|
|
1224
1222
|
"editable",
|
|
1223
|
+
"evented",
|
|
1224
|
+
"selectable",
|
|
1225
1225
|
"lockMovementX",
|
|
1226
1226
|
"lockMovementY",
|
|
1227
1227
|
"lockRotation",
|
|
@@ -1246,7 +1246,7 @@ const ns = [
|
|
|
1246
1246
|
"radiusBottomRight",
|
|
1247
1247
|
"radiusBottomLeft"
|
|
1248
1248
|
];
|
|
1249
|
-
class
|
|
1249
|
+
class G {
|
|
1250
1250
|
constructor({ editor: t }) {
|
|
1251
1251
|
this.editor = t, this.canvas = t.canvas, this._isSavingState = !1, this._historySuspendCount = 0, this.baseState = null, this.patches = [], this.currentIndex = 0, this.maxHistoryLength = t.options.maxHistoryLength, this.totalChangesCount = 0, this.baseStateChangesCount = 0, this._createDiffPatcher();
|
|
1252
1252
|
}
|
|
@@ -1260,48 +1260,7 @@ class Kt {
|
|
|
1260
1260
|
_createDiffPatcher() {
|
|
1261
1261
|
this.diffPatcher = Ms({
|
|
1262
1262
|
objectHash(t) {
|
|
1263
|
-
|
|
1264
|
-
return [
|
|
1265
|
-
e.id,
|
|
1266
|
-
e.backgroundId,
|
|
1267
|
-
e.format,
|
|
1268
|
-
e.locked,
|
|
1269
|
-
e.left,
|
|
1270
|
-
e.top,
|
|
1271
|
-
e.width,
|
|
1272
|
-
e.height,
|
|
1273
|
-
e.flipX,
|
|
1274
|
-
e.flipY,
|
|
1275
|
-
e.scaleX,
|
|
1276
|
-
e.scaleY,
|
|
1277
|
-
e.angle,
|
|
1278
|
-
e.opacity,
|
|
1279
|
-
o,
|
|
1280
|
-
s.text,
|
|
1281
|
-
s.textCaseRaw,
|
|
1282
|
-
s.uppercase,
|
|
1283
|
-
s.fontFamily,
|
|
1284
|
-
s.fontSize,
|
|
1285
|
-
s.fontWeight,
|
|
1286
|
-
s.fontStyle,
|
|
1287
|
-
s.underline,
|
|
1288
|
-
s.linethrough,
|
|
1289
|
-
s.textAlign,
|
|
1290
|
-
s.fill,
|
|
1291
|
-
s.stroke,
|
|
1292
|
-
s.strokeWidth,
|
|
1293
|
-
n,
|
|
1294
|
-
s.paddingTop,
|
|
1295
|
-
s.paddingRight,
|
|
1296
|
-
s.paddingBottom,
|
|
1297
|
-
s.paddingLeft,
|
|
1298
|
-
s.backgroundColor,
|
|
1299
|
-
s.backgroundOpacity,
|
|
1300
|
-
s.radiusTopLeft,
|
|
1301
|
-
s.radiusTopRight,
|
|
1302
|
-
s.radiusBottomRight,
|
|
1303
|
-
s.radiusBottomLeft
|
|
1304
|
-
].join("-");
|
|
1263
|
+
return [JSON.stringify(t)].join("-");
|
|
1305
1264
|
},
|
|
1306
1265
|
arrays: {
|
|
1307
1266
|
detectMove: !0,
|
|
@@ -1359,17 +1318,167 @@ class Kt {
|
|
|
1359
1318
|
}
|
|
1360
1319
|
const e = this.getFullState();
|
|
1361
1320
|
console.log("prevState", e);
|
|
1362
|
-
const
|
|
1363
|
-
|
|
1321
|
+
const {
|
|
1322
|
+
prevState: s,
|
|
1323
|
+
nextState: n
|
|
1324
|
+
} = G._prepareStatesForDiff({
|
|
1325
|
+
prevState: e,
|
|
1326
|
+
nextState: t
|
|
1327
|
+
}), o = this.diffPatcher.diff(s, n);
|
|
1328
|
+
if (!o) {
|
|
1364
1329
|
console.log("Нет изменений для сохранения.");
|
|
1365
1330
|
return;
|
|
1366
1331
|
}
|
|
1367
|
-
console.log("baseState", this.baseState), this.currentIndex < this.patches.length && this.patches.splice(this.currentIndex), console.log("diff",
|
|
1332
|
+
console.log("baseState", this.baseState), this.currentIndex < this.patches.length && this.patches.splice(this.currentIndex), console.log("diff", o), this.totalChangesCount += 1, this.patches.push({ id: X(), diff: o }), this.currentIndex += 1, this.patches.length > this.maxHistoryLength && (this.baseState = this.diffPatcher.patch(this.baseState, this.patches[0].diff), this.patches.shift(), this.currentIndex -= 1, this.baseStateChangesCount += 1), console.log("Состояние сохранено. Текущий индекс истории:", this.currentIndex);
|
|
1368
1333
|
} finally {
|
|
1369
1334
|
this._isSavingState = !1;
|
|
1370
1335
|
}
|
|
1371
1336
|
}
|
|
1372
1337
|
}
|
|
1338
|
+
/**
|
|
1339
|
+
* Подготавливает состояния для расчёта diff: нормализует технические изменения
|
|
1340
|
+
* и компенсирует смещения при ресайзе окна.
|
|
1341
|
+
*/
|
|
1342
|
+
static _prepareStatesForDiff({
|
|
1343
|
+
prevState: t,
|
|
1344
|
+
nextState: e
|
|
1345
|
+
}) {
|
|
1346
|
+
const s = G._cloneState({ state: t }), n = G._cloneState({ state: e });
|
|
1347
|
+
return G._normalizeTextBackground({ objects: s.objects }), G._normalizeTextBackground({ objects: n.objects }), G._normalizeCanvasSize({
|
|
1348
|
+
prevState: s,
|
|
1349
|
+
nextState: n
|
|
1350
|
+
}), G._normalizeTranslation({
|
|
1351
|
+
prevState: s,
|
|
1352
|
+
nextState: n
|
|
1353
|
+
}), {
|
|
1354
|
+
prevState: s,
|
|
1355
|
+
nextState: n
|
|
1356
|
+
};
|
|
1357
|
+
}
|
|
1358
|
+
/**
|
|
1359
|
+
* Делает глубокую копию состояния канваса.
|
|
1360
|
+
* @param state - исходное состояние
|
|
1361
|
+
*/
|
|
1362
|
+
static _cloneState({ state: t }) {
|
|
1363
|
+
return JSON.parse(JSON.stringify(t));
|
|
1364
|
+
}
|
|
1365
|
+
/**
|
|
1366
|
+
* Нормализует backgroundColor у текстовых объектов без фона, чтобы избежать шумовых диффов.
|
|
1367
|
+
* @param objects - список объектов канваса
|
|
1368
|
+
*/
|
|
1369
|
+
static _normalizeTextBackground({ objects: t }) {
|
|
1370
|
+
for (let e = 0; e < t.length; e += 1) {
|
|
1371
|
+
const s = t[e], { type: n } = s, o = s.backgroundOpacity, i = typeof o == "number" ? o : 0;
|
|
1372
|
+
(n === "textbox" || n === "i-text" || n === "text") && (i > 0 || (s.backgroundColor = null));
|
|
1373
|
+
}
|
|
1374
|
+
}
|
|
1375
|
+
/**
|
|
1376
|
+
* Игнорирует изменения размеров канваса, если размер монтажной области не менялся.
|
|
1377
|
+
* Это устраняет диффы от ресайза окна без влияния на историю документа.
|
|
1378
|
+
*/
|
|
1379
|
+
static _normalizeCanvasSize({
|
|
1380
|
+
prevState: t,
|
|
1381
|
+
nextState: e
|
|
1382
|
+
}) {
|
|
1383
|
+
const { width: s, height: n, objects: o } = t, { objects: i } = e, {
|
|
1384
|
+
width: a,
|
|
1385
|
+
height: r
|
|
1386
|
+
} = G._getMontageAreaSize({ objects: o }), {
|
|
1387
|
+
width: c,
|
|
1388
|
+
height: d
|
|
1389
|
+
} = G._getMontageAreaSize({ objects: i });
|
|
1390
|
+
a !== c || r !== d || (e.width = s, e.height = n);
|
|
1391
|
+
}
|
|
1392
|
+
/**
|
|
1393
|
+
* Компенсирует смещение монтажной области, чтобы не сохранять ресайз как изменение истории.
|
|
1394
|
+
*/
|
|
1395
|
+
static _normalizeTranslation({
|
|
1396
|
+
prevState: t,
|
|
1397
|
+
nextState: e
|
|
1398
|
+
}) {
|
|
1399
|
+
const { objects: s, clipPath: n } = t, { objects: o, clipPath: i } = e, {
|
|
1400
|
+
left: a,
|
|
1401
|
+
top: r
|
|
1402
|
+
} = G._getMontageAreaPosition({ objects: s }), {
|
|
1403
|
+
left: c,
|
|
1404
|
+
top: d
|
|
1405
|
+
} = G._getMontageAreaPosition({ objects: o }), l = c - a, u = d - r;
|
|
1406
|
+
if (l === 0 && u === 0) return;
|
|
1407
|
+
const f = G._getObjectById({
|
|
1408
|
+
objects: o,
|
|
1409
|
+
id: "montage-area"
|
|
1410
|
+
});
|
|
1411
|
+
f && (f.left = a, f.top = r);
|
|
1412
|
+
const g = G._getClipPathPosition({ clipPath: n });
|
|
1413
|
+
if (g && i && typeof i == "object") {
|
|
1414
|
+
const { left: m, top: v } = g, w = i;
|
|
1415
|
+
w.left = m, w.top = v;
|
|
1416
|
+
}
|
|
1417
|
+
const p = G._getTranslationIgnoredIds();
|
|
1418
|
+
for (let m = 0; m < o.length; m += 1) {
|
|
1419
|
+
const v = o[m], { id: w } = v;
|
|
1420
|
+
w && p.has(w) || (typeof v.left == "number" && (v.left -= l), typeof v.top == "number" && (v.top -= u));
|
|
1421
|
+
}
|
|
1422
|
+
}
|
|
1423
|
+
/**
|
|
1424
|
+
* Возвращает позицию clipPath из состояния, если она доступна.
|
|
1425
|
+
*/
|
|
1426
|
+
static _getClipPathPosition({
|
|
1427
|
+
clipPath: t
|
|
1428
|
+
}) {
|
|
1429
|
+
if (!t || typeof t != "object") return null;
|
|
1430
|
+
const { left: e, top: s } = t;
|
|
1431
|
+
return typeof e != "number" || typeof s != "number" ? null : { left: e, top: s };
|
|
1432
|
+
}
|
|
1433
|
+
/**
|
|
1434
|
+
* Возвращает позицию монтажной области из списка объектов.
|
|
1435
|
+
*/
|
|
1436
|
+
static _getMontageAreaPosition({
|
|
1437
|
+
objects: t
|
|
1438
|
+
}) {
|
|
1439
|
+
const e = G._getObjectById({
|
|
1440
|
+
objects: t,
|
|
1441
|
+
id: "montage-area"
|
|
1442
|
+
});
|
|
1443
|
+
if (!e)
|
|
1444
|
+
return { left: 0, top: 0 };
|
|
1445
|
+
const { left: s = 0, top: n = 0 } = e;
|
|
1446
|
+
return { left: s, top: n };
|
|
1447
|
+
}
|
|
1448
|
+
/**
|
|
1449
|
+
* Возвращает размеры монтажной области из списка объектов.
|
|
1450
|
+
*/
|
|
1451
|
+
static _getMontageAreaSize({
|
|
1452
|
+
objects: t
|
|
1453
|
+
}) {
|
|
1454
|
+
const e = G._getObjectById({
|
|
1455
|
+
objects: t,
|
|
1456
|
+
id: "montage-area"
|
|
1457
|
+
});
|
|
1458
|
+
if (!e)
|
|
1459
|
+
return { width: 0, height: 0 };
|
|
1460
|
+
const { width: s = 0, height: n = 0 } = e;
|
|
1461
|
+
return { width: s, height: n };
|
|
1462
|
+
}
|
|
1463
|
+
/**
|
|
1464
|
+
* Находит объект по id в массиве объектов канваса.
|
|
1465
|
+
*/
|
|
1466
|
+
static _getObjectById({
|
|
1467
|
+
objects: t,
|
|
1468
|
+
id: e
|
|
1469
|
+
}) {
|
|
1470
|
+
for (let s = 0; s < t.length; s += 1) {
|
|
1471
|
+
const n = t[s];
|
|
1472
|
+
if (n.id === e) return n;
|
|
1473
|
+
}
|
|
1474
|
+
return null;
|
|
1475
|
+
}
|
|
1476
|
+
/**
|
|
1477
|
+
* Возвращает набор id объектов, которые не должны сдвигаться при нормализации.
|
|
1478
|
+
*/
|
|
1479
|
+
static _getTranslationIgnoredIds() {
|
|
1480
|
+
return /* @__PURE__ */ new Set(["montage-area", "overlay-mask", "background"]);
|
|
1481
|
+
}
|
|
1373
1482
|
/**
|
|
1374
1483
|
* Создаёт безопасную копию состояния для загрузки в canvas.
|
|
1375
1484
|
* customData сериализуется, чтобы Fabric не обрабатывал её как параметры объекта.
|
|
@@ -1411,7 +1520,7 @@ class Kt {
|
|
|
1411
1520
|
for (let c = 0; c < i.length; c += 1) {
|
|
1412
1521
|
const d = i[c], { id: l } = d;
|
|
1413
1522
|
let u;
|
|
1414
|
-
typeof l == "string" && (u = n.get(l)), u || (u = o.get(c)), u && (d.customData =
|
|
1523
|
+
typeof l == "string" && (u = n.get(l)), u || (u = o.get(c)), u && (d.customData = G._cloneCustomData({ customData: u }));
|
|
1415
1524
|
}
|
|
1416
1525
|
}
|
|
1417
1526
|
/**
|
|
@@ -1427,13 +1536,13 @@ class Kt {
|
|
|
1427
1536
|
* @fires editor:history-state-loaded
|
|
1428
1537
|
*/
|
|
1429
1538
|
loadStateFromFullState(t) {
|
|
1430
|
-
return
|
|
1539
|
+
return P(this, null, function* () {
|
|
1431
1540
|
if (!t) return;
|
|
1432
1541
|
console.log("loadStateFromFullState fullState", t);
|
|
1433
1542
|
const { canvas: e, canvasManager: s, interactionBlocker: n, backgroundManager: o } = this.editor, { width: i, height: a } = e;
|
|
1434
1543
|
n.overlayMask = null;
|
|
1435
|
-
const r =
|
|
1436
|
-
yield e.loadFromJSON(r),
|
|
1544
|
+
const r = G._createLoadSafeState({ state: t });
|
|
1545
|
+
yield e.loadFromJSON(r), G._applyCustomDataFromState({ state: t, canvas: e });
|
|
1437
1546
|
const c = e.getObjects().find((u) => u.id === "montage-area");
|
|
1438
1547
|
c && (this.editor.montageArea = c, (i !== e.getWidth() || a !== e.getHeight()) && s.updateCanvas());
|
|
1439
1548
|
const d = e.getObjects().find((u) => u.id === "overlay-mask");
|
|
@@ -1454,7 +1563,7 @@ class Kt {
|
|
|
1454
1563
|
* @fires editor:undo
|
|
1455
1564
|
*/
|
|
1456
1565
|
undo() {
|
|
1457
|
-
return
|
|
1566
|
+
return P(this, null, function* () {
|
|
1458
1567
|
if (!this.skipHistory) {
|
|
1459
1568
|
if (this.saveState(), this.currentIndex <= 0) {
|
|
1460
1569
|
console.log("Нет предыдущих состояний для отмены.");
|
|
@@ -1491,9 +1600,9 @@ class Kt {
|
|
|
1491
1600
|
* @fires editor:redo
|
|
1492
1601
|
*/
|
|
1493
1602
|
redo() {
|
|
1494
|
-
return
|
|
1603
|
+
return P(this, null, function* () {
|
|
1495
1604
|
if (!this.skipHistory) {
|
|
1496
|
-
if (this.
|
|
1605
|
+
if (this.currentIndex >= this.patches.length) {
|
|
1497
1606
|
console.log("Нет состояний для повтора.");
|
|
1498
1607
|
return;
|
|
1499
1608
|
}
|
|
@@ -1546,7 +1655,7 @@ class Kt {
|
|
|
1546
1655
|
}
|
|
1547
1656
|
}
|
|
1548
1657
|
}
|
|
1549
|
-
const Hs = 0.1, Zs = 2, Ze = 0.1, Gs = 90,
|
|
1658
|
+
const Hs = 0.1, Zs = 2, Ze = 0.1, Gs = 90, _t = 16, xt = 16, jt = 4096, It = 4096, Ge = "application/image-editor:", ie = [
|
|
1550
1659
|
"format",
|
|
1551
1660
|
"uppercase",
|
|
1552
1661
|
"textCaseRaw",
|
|
@@ -1561,7 +1670,7 @@ const Hs = 0.1, Zs = 2, Ze = 0.1, Gs = 90, Rt = 16, _t = 16, At = 4096, jt = 409
|
|
|
1561
1670
|
"radiusBottomRight",
|
|
1562
1671
|
"radiusBottomLeft"
|
|
1563
1672
|
], Vs = 50;
|
|
1564
|
-
class
|
|
1673
|
+
class ut {
|
|
1565
1674
|
constructor({ editor: t }) {
|
|
1566
1675
|
this.editor = t, this.options = t.options, this._createdBlobUrls = [], this.acceptContentTypes = this.editor.options.acceptContentTypes, this.acceptFormats = this.getAllowedFormatsFromContentTypes();
|
|
1567
1676
|
}
|
|
@@ -1578,7 +1687,7 @@ class ht {
|
|
|
1578
1687
|
* @returns возвращает Promise с объектом изображения или null в случае ошибки
|
|
1579
1688
|
*/
|
|
1580
1689
|
importImage(t) {
|
|
1581
|
-
return
|
|
1690
|
+
return P(this, null, function* () {
|
|
1582
1691
|
const {
|
|
1583
1692
|
source: e,
|
|
1584
1693
|
scale: s = `image-${this.options.scaleType}`,
|
|
@@ -1590,7 +1699,7 @@ class ht {
|
|
|
1590
1699
|
customData: c = null
|
|
1591
1700
|
} = t;
|
|
1592
1701
|
if (!e) return null;
|
|
1593
|
-
const { canvas: d, montageArea: l, transformManager: u, historyManager: f, errorManager: g } = this.editor, p = yield this.getContentType(e), m =
|
|
1702
|
+
const { canvas: d, montageArea: l, transformManager: u, historyManager: f, errorManager: g } = this.editor, p = yield this.getContentType(e), m = ut.getFormatFromContentType(p), { acceptContentTypes: v, acceptFormats: w } = this;
|
|
1594
1703
|
if (!this.isAllowedContentType(p)) {
|
|
1595
1704
|
const A = `Неверный contentType для изображения: ${p}. Ожидается один из: ${this.acceptContentTypes.join(", ")}.`;
|
|
1596
1705
|
return g.emitError({
|
|
@@ -1603,7 +1712,7 @@ class ht {
|
|
|
1603
1712
|
format: m,
|
|
1604
1713
|
contentType: p,
|
|
1605
1714
|
acceptContentTypes: v,
|
|
1606
|
-
acceptFormats:
|
|
1715
|
+
acceptFormats: w,
|
|
1607
1716
|
fromClipboard: o,
|
|
1608
1717
|
isBackground: i,
|
|
1609
1718
|
withoutSelection: a,
|
|
@@ -1631,7 +1740,7 @@ class ht {
|
|
|
1631
1740
|
format: m,
|
|
1632
1741
|
contentType: p,
|
|
1633
1742
|
acceptContentTypes: v,
|
|
1634
|
-
acceptFormats:
|
|
1743
|
+
acceptFormats: w,
|
|
1635
1744
|
fromClipboard: o,
|
|
1636
1745
|
isBackground: i,
|
|
1637
1746
|
withoutSelection: a,
|
|
@@ -1640,27 +1749,27 @@ class ht {
|
|
|
1640
1749
|
}
|
|
1641
1750
|
}), null;
|
|
1642
1751
|
if (this._createdBlobUrls.push(A), m === "svg") {
|
|
1643
|
-
const
|
|
1644
|
-
y =
|
|
1752
|
+
const S = yield us(A);
|
|
1753
|
+
y = ft.groupSVGElements(S.objects, S.options);
|
|
1645
1754
|
} else
|
|
1646
|
-
y = yield
|
|
1755
|
+
y = yield Gt.fromURL(A, { crossOrigin: "anonymous" });
|
|
1647
1756
|
const { width: b, height: j } = y;
|
|
1648
|
-
if (y instanceof
|
|
1649
|
-
const
|
|
1757
|
+
if (y instanceof Gt) {
|
|
1758
|
+
const S = y.getElement();
|
|
1650
1759
|
let T = "";
|
|
1651
|
-
if (
|
|
1760
|
+
if (S instanceof HTMLImageElement ? T = S.src : S instanceof HTMLCanvasElement && (T = S.toDataURL()), j > It || b > jt) {
|
|
1652
1761
|
const M = yield this.resizeImageToBoundaries(T, "max"), C = URL.createObjectURL(M);
|
|
1653
|
-
this._createdBlobUrls.push(C), y = yield
|
|
1654
|
-
} else if (j <
|
|
1762
|
+
this._createdBlobUrls.push(C), y = yield Gt.fromURL(C, { crossOrigin: "anonymous" });
|
|
1763
|
+
} else if (j < xt || b < _t) {
|
|
1655
1764
|
const M = yield this.resizeImageToBoundaries(T, "min"), C = URL.createObjectURL(M);
|
|
1656
|
-
this._createdBlobUrls.push(C), y = yield
|
|
1765
|
+
this._createdBlobUrls.push(C), y = yield Gt.fromURL(C, { crossOrigin: "anonymous" });
|
|
1657
1766
|
}
|
|
1658
1767
|
}
|
|
1659
|
-
if (y.set("id", `${y.type}-${
|
|
1768
|
+
if (y.set("id", `${y.type}-${X()}`), y.set("format", m), y.set("customData", c || null), s === "scale-montage")
|
|
1660
1769
|
this.editor.canvasManager.scaleMontageAreaToImage({ object: y, withoutSave: !0 });
|
|
1661
1770
|
else {
|
|
1662
|
-
const { width:
|
|
1663
|
-
s === "image-contain" && M < 1 ? u.fitObject({ object: y, type: "contain", withoutSave: !0 }) : s === "image-cover" && (b >
|
|
1771
|
+
const { width: S, height: T } = l, M = this.calculateScaleFactor({ imageObject: y, scaleType: s });
|
|
1772
|
+
s === "image-contain" && M < 1 ? u.fitObject({ object: y, type: "contain", withoutSave: !0 }) : s === "image-cover" && (b > S || j > T) && u.fitObject({ object: y, type: "cover", withoutSave: !0 });
|
|
1664
1773
|
}
|
|
1665
1774
|
const I = {
|
|
1666
1775
|
image: y,
|
|
@@ -1707,16 +1816,16 @@ class ht {
|
|
|
1707
1816
|
* @returns возвращает Promise с Blob-объектом уменьшенного изображения
|
|
1708
1817
|
*/
|
|
1709
1818
|
resizeImageToBoundaries(t, e = "max") {
|
|
1710
|
-
return
|
|
1711
|
-
let s = `Размер изображения больше максимального размера канваса, поэтому оно будет уменьшено до максимальных размеров c сохранением пропорций: ${
|
|
1712
|
-
e === "min" && (s = `Размер изображения меньше минимального размера канваса, поэтому оно будет увеличено до минимальных размеров c сохранением пропорций: ${
|
|
1819
|
+
return P(this, null, function* () {
|
|
1820
|
+
let s = `Размер изображения больше максимального размера канваса, поэтому оно будет уменьшено до максимальных размеров c сохранением пропорций: ${jt}x${It}`;
|
|
1821
|
+
e === "min" && (s = `Размер изображения меньше минимального размера канваса, поэтому оно будет увеличено до минимальных размеров c сохранением пропорций: ${_t}x${xt}`);
|
|
1713
1822
|
const n = {
|
|
1714
1823
|
dataURL: t,
|
|
1715
1824
|
sizeType: e,
|
|
1716
|
-
maxWidth:
|
|
1717
|
-
maxHeight:
|
|
1718
|
-
minWidth:
|
|
1719
|
-
minHeight:
|
|
1825
|
+
maxWidth: jt,
|
|
1826
|
+
maxHeight: It,
|
|
1827
|
+
minWidth: _t,
|
|
1828
|
+
minHeight: xt
|
|
1720
1829
|
};
|
|
1721
1830
|
return this.editor.errorManager.emitWarning({
|
|
1722
1831
|
origin: "ImageManager",
|
|
@@ -1739,7 +1848,7 @@ class ht {
|
|
|
1739
1848
|
* @fires editor:canvas-exported
|
|
1740
1849
|
*/
|
|
1741
1850
|
exportCanvasAsImageFile() {
|
|
1742
|
-
return
|
|
1851
|
+
return P(this, arguments, function* (t = {}) {
|
|
1743
1852
|
const {
|
|
1744
1853
|
fileName: e = "image.png",
|
|
1745
1854
|
contentType: s = "image/png",
|
|
@@ -1747,12 +1856,12 @@ class ht {
|
|
|
1747
1856
|
exportAsBlob: o = !1
|
|
1748
1857
|
} = t, { canvas: i, montageArea: a, workerManager: r, interactionBlocker: c } = this.editor;
|
|
1749
1858
|
try {
|
|
1750
|
-
const d = s === "application/pdf", l = d ? "image/jpg" : s, u =
|
|
1859
|
+
const d = s === "application/pdf", l = d ? "image/jpg" : s, u = ut.getFormatFromContentType(l);
|
|
1751
1860
|
a.setCoords();
|
|
1752
1861
|
const { left: f, top: g, width: p, height: m } = a.getBoundingRect(), v = yield i.clone(["id", "format", "locked"]);
|
|
1753
1862
|
v.enableRetinaScaling = !1, ["image/jpg", "image/jpeg"].includes(l) && (v.backgroundColor = "#ffffff");
|
|
1754
|
-
const
|
|
1755
|
-
if (
|
|
1863
|
+
const w = v.getObjects().find((M) => M.id === a.id);
|
|
1864
|
+
if (w && (w.visible = !1), c != null && c.isBlocked) {
|
|
1756
1865
|
const M = v.getObjects().find((C) => C.id === c.overlayMask.id);
|
|
1757
1866
|
M && (M.visible = !1);
|
|
1758
1867
|
}
|
|
@@ -1762,7 +1871,7 @@ class ht {
|
|
|
1762
1871
|
const M = v.toSVG();
|
|
1763
1872
|
v.dispose();
|
|
1764
1873
|
const E = {
|
|
1765
|
-
image:
|
|
1874
|
+
image: ut._exportSVGStringAsFile(M, {
|
|
1766
1875
|
exportAsBase64: n,
|
|
1767
1876
|
exportAsBlob: o,
|
|
1768
1877
|
fileName: e
|
|
@@ -1793,27 +1902,27 @@ class ht {
|
|
|
1793
1902
|
[b]
|
|
1794
1903
|
);
|
|
1795
1904
|
if (d) {
|
|
1796
|
-
const C = p * 0.264583, E = m * 0.264583,
|
|
1905
|
+
const C = p * 0.264583, E = m * 0.264583, z = (yield this.editor.moduleLoader.loadModule("jspdf")).jsPDF, x = new z({
|
|
1797
1906
|
orientation: C > E ? "landscape" : "portrait",
|
|
1798
1907
|
unit: "mm",
|
|
1799
1908
|
format: [C, E]
|
|
1800
1909
|
});
|
|
1801
|
-
if (
|
|
1910
|
+
if (x.addImage(String(j), "JPG", 0, 0, C, E), n) {
|
|
1802
1911
|
const H = {
|
|
1803
|
-
image:
|
|
1912
|
+
image: x.output("datauristring"),
|
|
1804
1913
|
format: "pdf",
|
|
1805
1914
|
contentType: "application/pdf",
|
|
1806
1915
|
fileName: e
|
|
1807
1916
|
};
|
|
1808
1917
|
return i.fire("editor:canvas-exported", H), H;
|
|
1809
1918
|
}
|
|
1810
|
-
const
|
|
1811
|
-
image: new File([
|
|
1919
|
+
const N = x.output("blob"), V = {
|
|
1920
|
+
image: new File([N], e, { type: "application/pdf" }),
|
|
1812
1921
|
format: "pdf",
|
|
1813
1922
|
contentType: "application/pdf",
|
|
1814
1923
|
fileName: e
|
|
1815
1924
|
};
|
|
1816
|
-
return i.fire("editor:canvas-exported",
|
|
1925
|
+
return i.fire("editor:canvas-exported", V), V;
|
|
1817
1926
|
}
|
|
1818
1927
|
if (n) {
|
|
1819
1928
|
const M = {
|
|
@@ -1854,7 +1963,7 @@ class ht {
|
|
|
1854
1963
|
* @fires editor:object-exported
|
|
1855
1964
|
*/
|
|
1856
1965
|
exportObjectAsImageFile() {
|
|
1857
|
-
return
|
|
1966
|
+
return P(this, arguments, function* (t = {}) {
|
|
1858
1967
|
const {
|
|
1859
1968
|
object: e,
|
|
1860
1969
|
fileName: s = "image.png",
|
|
@@ -1871,9 +1980,9 @@ class ht {
|
|
|
1871
1980
|
data: { contentType: n, fileName: s, exportAsBase64: o, exportAsBlob: i }
|
|
1872
1981
|
}), null;
|
|
1873
1982
|
try {
|
|
1874
|
-
const d =
|
|
1983
|
+
const d = ut.getFormatFromContentType(n);
|
|
1875
1984
|
if (d === "svg") {
|
|
1876
|
-
const p = c.toSVG(), m =
|
|
1985
|
+
const p = c.toSVG(), m = ut._exportSVGStringAsFile(p, {
|
|
1877
1986
|
exportAsBase64: o,
|
|
1878
1987
|
exportAsBlob: i,
|
|
1879
1988
|
fileName: s
|
|
@@ -1886,7 +1995,7 @@ class ht {
|
|
|
1886
1995
|
};
|
|
1887
1996
|
return a.fire("editor:object-exported", v), v;
|
|
1888
1997
|
}
|
|
1889
|
-
if (o && c instanceof
|
|
1998
|
+
if (o && c instanceof Gt) {
|
|
1890
1999
|
const p = yield createImageBitmap(c.getElement()), m = yield r.post(
|
|
1891
2000
|
"toDataURL",
|
|
1892
2001
|
{
|
|
@@ -1951,7 +2060,7 @@ class ht {
|
|
|
1951
2060
|
* @returns массив допустимых форматов изображений
|
|
1952
2061
|
*/
|
|
1953
2062
|
getAllowedFormatsFromContentTypes() {
|
|
1954
|
-
return this.acceptContentTypes.map((t) =>
|
|
2063
|
+
return this.acceptContentTypes.map((t) => ut.getFormatFromContentType(t)).filter((t) => t);
|
|
1955
2064
|
}
|
|
1956
2065
|
/**
|
|
1957
2066
|
* Проверяет, является ли contentType допустимым типом изображения.
|
|
@@ -1967,7 +2076,7 @@ class ht {
|
|
|
1967
2076
|
* @public
|
|
1968
2077
|
*/
|
|
1969
2078
|
getContentType(t) {
|
|
1970
|
-
return
|
|
2079
|
+
return P(this, null, function* () {
|
|
1971
2080
|
return typeof t == "string" ? this.getContentTypeFromUrl(t) : t.type || "application/octet-stream";
|
|
1972
2081
|
});
|
|
1973
2082
|
}
|
|
@@ -1978,7 +2087,7 @@ class ht {
|
|
|
1978
2087
|
* @public
|
|
1979
2088
|
*/
|
|
1980
2089
|
getContentTypeFromUrl(t) {
|
|
1981
|
-
return
|
|
2090
|
+
return P(this, null, function* () {
|
|
1982
2091
|
if (t.startsWith("data:")) {
|
|
1983
2092
|
const e = t.match(/^data:([^;]+)/);
|
|
1984
2093
|
return e ? e[1] : "application/octet-stream";
|
|
@@ -2004,7 +2113,7 @@ class ht {
|
|
|
2004
2113
|
try {
|
|
2005
2114
|
const n = (e = new URL(t).pathname.split(".").pop()) == null ? void 0 : e.toLowerCase(), o = {};
|
|
2006
2115
|
return this.acceptContentTypes.forEach((i) => {
|
|
2007
|
-
const a =
|
|
2116
|
+
const a = ut.getFormatFromContentType(i);
|
|
2008
2117
|
a && (o[a] = i);
|
|
2009
2118
|
}), n && o[n] || "application/octet-stream";
|
|
2010
2119
|
} catch (s) {
|
|
@@ -2057,7 +2166,7 @@ class ht {
|
|
|
2057
2166
|
return e ? e[1] : "";
|
|
2058
2167
|
}
|
|
2059
2168
|
}
|
|
2060
|
-
const
|
|
2169
|
+
const mt = (h, t, e) => Math.max(Math.min(h, e), t), Ve = (h, t) => h * t, Xs = (h, t) => new et(h / 2, t / 2);
|
|
2061
2170
|
function Ks(h) {
|
|
2062
2171
|
return ((h == null ? void 0 : h.type) === "image" || (h == null ? void 0 : h.format) === "svg") && typeof (h == null ? void 0 : h.width) == "number" && typeof (h == null ? void 0 : h.height) == "number";
|
|
2063
2172
|
}
|
|
@@ -2081,16 +2190,16 @@ class Qs {
|
|
|
2081
2190
|
* Если точка находится за пределами монтажной области, она проецируется на ближайшую границу монтажной области.
|
|
2082
2191
|
*/
|
|
2083
2192
|
getVisibleCenterPoint() {
|
|
2084
|
-
const { canvas: t, montageArea: e } = this.editor, s = t.getZoom(), n = t.viewportTransform, o = t.getWidth(), i = t.getHeight(), a = (o / 2 - n[4]) / s, r = (i / 2 - n[5]) / s, c = e.width / 2, d = e.height / 2, l =
|
|
2193
|
+
const { canvas: t, montageArea: e } = this.editor, s = t.getZoom(), n = t.viewportTransform, o = t.getWidth(), i = t.getHeight(), a = (o / 2 - n[4]) / s, r = (i / 2 - n[5]) / s, c = e.width / 2, d = e.height / 2, l = mt(
|
|
2085
2194
|
a,
|
|
2086
2195
|
e.left - c,
|
|
2087
2196
|
e.left + c
|
|
2088
|
-
), u =
|
|
2197
|
+
), u = mt(
|
|
2089
2198
|
r,
|
|
2090
2199
|
e.top - d,
|
|
2091
2200
|
e.top + d
|
|
2092
2201
|
);
|
|
2093
|
-
return new
|
|
2202
|
+
return new et(l, u);
|
|
2094
2203
|
}
|
|
2095
2204
|
/**
|
|
2096
2205
|
* Устанавливаем внутреннюю ширину канваса (для экспорта)
|
|
@@ -2108,7 +2217,7 @@ class Qs {
|
|
|
2108
2217
|
canvas: o,
|
|
2109
2218
|
montageArea: i,
|
|
2110
2219
|
options: { canvasBackstoreWidth: a }
|
|
2111
|
-
} = this.editor, { width: r, height: c } = i, d =
|
|
2220
|
+
} = this.editor, { width: r, height: c } = i, d = mt(Number(t), _t, jt);
|
|
2112
2221
|
if (!a || a === "auto" || n ? this.adaptCanvasToContainer() : a ? this.setCanvasBackstoreWidth(Number(a)) : this.setCanvasBackstoreWidth(d), i.set({ width: d }), (g = o.clipPath) == null || g.set({ width: d }), e) {
|
|
2113
2222
|
const p = d / r, m = Ve(c, p);
|
|
2114
2223
|
this.setResolutionHeight(m);
|
|
@@ -2138,7 +2247,7 @@ class Qs {
|
|
|
2138
2247
|
canvas: o,
|
|
2139
2248
|
montageArea: i,
|
|
2140
2249
|
options: { canvasBackstoreHeight: a }
|
|
2141
|
-
} = this.editor, { width: r, height: c } = i, d =
|
|
2250
|
+
} = this.editor, { width: r, height: c } = i, d = mt(Number(t), xt, It);
|
|
2142
2251
|
if (!a || a === "auto" || n ? this.adaptCanvasToContainer() : a ? this.setCanvasBackstoreHeight(Number(a)) : this.setCanvasBackstoreHeight(d), i.set({ height: d }), (g = o.clipPath) == null || g.set({ height: d }), e) {
|
|
2143
2252
|
const p = d / c, m = Ve(r, p);
|
|
2144
2253
|
this.setResolutionWidth(m);
|
|
@@ -2191,7 +2300,7 @@ class Qs {
|
|
|
2191
2300
|
*/
|
|
2192
2301
|
setCanvasBackstoreWidth(t) {
|
|
2193
2302
|
if (!t || typeof t != "number") return;
|
|
2194
|
-
const e =
|
|
2303
|
+
const e = mt(t, _t, jt);
|
|
2195
2304
|
this.editor.canvas.setDimensions({ width: e }, { backstoreOnly: !0 });
|
|
2196
2305
|
}
|
|
2197
2306
|
/**
|
|
@@ -2200,7 +2309,7 @@ class Qs {
|
|
|
2200
2309
|
*/
|
|
2201
2310
|
setCanvasBackstoreHeight(t) {
|
|
2202
2311
|
if (!t || typeof t != "number") return;
|
|
2203
|
-
const e =
|
|
2312
|
+
const e = mt(t, xt, It);
|
|
2204
2313
|
this.editor.canvas.setDimensions({ height: e }, { backstoreOnly: !0 });
|
|
2205
2314
|
}
|
|
2206
2315
|
/**
|
|
@@ -2209,7 +2318,7 @@ class Qs {
|
|
|
2209
2318
|
* с учётом минимальных и максимальных значений.
|
|
2210
2319
|
*/
|
|
2211
2320
|
adaptCanvasToContainer() {
|
|
2212
|
-
const { canvas: t } = this.editor, e = this.getEditorContainer(), s = e.clientWidth, n = e.clientHeight, o =
|
|
2321
|
+
const { canvas: t } = this.editor, e = this.getEditorContainer(), s = e.clientWidth, n = e.clientHeight, o = mt(s, _t, jt), i = mt(n, xt, It);
|
|
2213
2322
|
t.setDimensions({ width: o, height: i }, { backstoreOnly: !0 });
|
|
2214
2323
|
}
|
|
2215
2324
|
/**
|
|
@@ -2411,13 +2520,13 @@ class Qs {
|
|
|
2411
2520
|
} = this.editor, c = t || n.getActiveObject();
|
|
2412
2521
|
if (!Ks(c)) return;
|
|
2413
2522
|
const { width: d, height: l } = c;
|
|
2414
|
-
let u = Math.min(d,
|
|
2523
|
+
let u = Math.min(d, jt), f = Math.min(l, It);
|
|
2415
2524
|
if (e) {
|
|
2416
2525
|
const {
|
|
2417
2526
|
width: g,
|
|
2418
2527
|
height: p
|
|
2419
|
-
} = o, m = d / g, v = l / p,
|
|
2420
|
-
u = g *
|
|
2528
|
+
} = o, m = d / g, v = l / p, w = Math.max(m, v);
|
|
2529
|
+
u = g * w, f = p * w;
|
|
2421
2530
|
}
|
|
2422
2531
|
this.setResolutionWidth(u, { withoutSave: !0 }), this.setResolutionHeight(f, { withoutSave: !0 }), this.editor.backgroundManager.backgroundObject && this.editor.backgroundManager.refresh(), (d > a || l > r) && this.editor.zoomManager.calculateAndApplyDefaultZoom(), i.resetObject({ object: c, withoutSave: !0 }), n.centerObject(c), n.renderAll(), s || this.editor.historyManager.saveState(), n.fire("editor:montage-area-scaled-to-image", {
|
|
2423
2532
|
object: c,
|
|
@@ -2581,9 +2690,9 @@ class Js {
|
|
|
2581
2690
|
* @private
|
|
2582
2691
|
*/
|
|
2583
2692
|
_fitSingleObject(t, e) {
|
|
2584
|
-
const { canvas: s, montageArea: n } = this.editor, { width: o, height: i, scaleX: a = 1, scaleY: r = 1, angle: c = 0 } = t, d = o * Math.abs(a), l = i * Math.abs(r), u = c * Math.PI / 180, f = Math.abs(Math.cos(u)), g = Math.abs(Math.sin(u)), p = d * f + l * g, m = d * g + l * f, v = n.width,
|
|
2693
|
+
const { canvas: s, montageArea: n } = this.editor, { width: o, height: i, scaleX: a = 1, scaleY: r = 1, angle: c = 0 } = t, d = o * Math.abs(a), l = i * Math.abs(r), u = c * Math.PI / 180, f = Math.abs(Math.cos(u)), g = Math.abs(Math.sin(u)), p = d * f + l * g, m = d * g + l * f, v = n.width, w = n.height;
|
|
2585
2694
|
let A;
|
|
2586
|
-
e === "contain" ? A = Math.min(v / p,
|
|
2695
|
+
e === "contain" ? A = Math.min(v / p, w / m) : A = Math.max(v / p, w / m), t.set({
|
|
2587
2696
|
scaleX: a * A,
|
|
2588
2697
|
scaleY: r * A
|
|
2589
2698
|
}), s.centerObject(t);
|
|
@@ -2703,9 +2812,9 @@ class qs {
|
|
|
2703
2812
|
* @private
|
|
2704
2813
|
*/
|
|
2705
2814
|
_calculateEmptySpaceRatio(t) {
|
|
2706
|
-
const { canvas: e, montageArea: s } = this.editor, n = e.viewportTransform, o = 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, l = -n[4] / t, u = (-n[4] + o) / t, f = -n[5] / t, g = (-n[5] + i) / t, p = l < a, m = u > r, v = f < c,
|
|
2707
|
-
if (!(p || m || v ||
|
|
2708
|
-
const y = Math.max(0, a - l), b = Math.max(0, u - r), j = Math.max(0, c - f), I = Math.max(0, g - d),
|
|
2815
|
+
const { canvas: e, montageArea: s } = this.editor, n = e.viewportTransform, o = 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, l = -n[4] / t, u = (-n[4] + o) / t, f = -n[5] / t, g = (-n[5] + i) / t, p = l < a, m = u > r, v = f < c, w = g > d;
|
|
2816
|
+
if (!(p || m || v || w)) return 0;
|
|
2817
|
+
const y = Math.max(0, a - l), b = Math.max(0, u - r), j = Math.max(0, c - f), I = Math.max(0, g - d), S = Math.max(y, b), T = Math.max(j, I), M = S / o, C = T / i;
|
|
2709
2818
|
return Math.max(M, C);
|
|
2710
2819
|
}
|
|
2711
2820
|
/**
|
|
@@ -2722,8 +2831,8 @@ class qs {
|
|
|
2722
2831
|
const { canvas: i, montageArea: a } = this.editor, r = i.viewportTransform, c = i.getWidth(), d = i.getHeight(), l = t.x - r[4], u = t.y - r[5], f = Math.abs(n), g = e - s;
|
|
2723
2832
|
if (Math.abs(g) / f <= 0.1)
|
|
2724
2833
|
return { x: l, y: u };
|
|
2725
|
-
const m = c / 2, v = d / 2,
|
|
2726
|
-
return { x: E, y:
|
|
2834
|
+
const m = c / 2, v = d / 2, w = a.left, A = a.top, y = m - w * s, b = v - A * s, j = (y - r[4]) / (e - s), I = (b - r[5]) / (e - s), S = j * f, T = I * f, M = S * o, C = T * o, E = Math.abs(M) > Math.abs(l) ? l : M, z = Math.abs(C) > Math.abs(u) ? u : C;
|
|
2835
|
+
return { x: E, y: z };
|
|
2727
2836
|
}
|
|
2728
2837
|
/**
|
|
2729
2838
|
* Применяет плавное центрирование viewport при приближении к defaultZoom.
|
|
@@ -2813,7 +2922,7 @@ class qs {
|
|
|
2813
2922
|
zoom(t = Ze, e = {}) {
|
|
2814
2923
|
var f, g;
|
|
2815
2924
|
if (!t) return;
|
|
2816
|
-
const { minZoom: s, maxZoom: n } = this, { canvas: o } = this.editor, i = t < 0, a = o.getZoom(), r = o.getCenterPoint(), c = (f = e.pointX) != null ? f : r.x, d = (g = e.pointY) != null ? g : r.y, l = new
|
|
2925
|
+
const { minZoom: s, maxZoom: n } = this, { canvas: o } = this.editor, i = t < 0, a = o.getZoom(), r = o.getCenterPoint(), c = (f = e.pointX) != null ? f : r.x, d = (g = e.pointY) != null ? g : r.y, l = new et(c, d);
|
|
2817
2926
|
this.editor.montageArea.setCoords(), this.editor.canvas.requestRenderAll();
|
|
2818
2927
|
let u = Number((a + Number(t)).toFixed(2));
|
|
2819
2928
|
u > n && (u = n), u < s && (u = s), o.zoomToPoint(l, u), this.editor.panConstraintManager.updateBounds(), this._applyViewportCentering(u, i, t), o.fire("editor:zoom-changed", {
|
|
@@ -2828,7 +2937,7 @@ class qs {
|
|
|
2828
2937
|
* @fires editor:zoom-changed
|
|
2829
2938
|
*/
|
|
2830
2939
|
setZoom(t = this.defaultZoom) {
|
|
2831
|
-
const { minZoom: e, maxZoom: s } = this, { canvas: n } = this.editor, o = new
|
|
2940
|
+
const { minZoom: e, maxZoom: s } = this, { canvas: n } = this.editor, o = new et(n.getCenterPoint());
|
|
2832
2941
|
let i = t;
|
|
2833
2942
|
t > s && (i = s), t < e && (i = e), n.zoomToPoint(o, i), n.fire("editor:zoom-changed", {
|
|
2834
2943
|
currentZoom: n.getZoom(),
|
|
@@ -2841,7 +2950,7 @@ class qs {
|
|
|
2841
2950
|
* @fires editor:zoom-changed
|
|
2842
2951
|
*/
|
|
2843
2952
|
resetZoom() {
|
|
2844
|
-
const { canvas: t } = this.editor, e = new
|
|
2953
|
+
const { canvas: t } = this.editor, e = new et(t.getCenterPoint());
|
|
2845
2954
|
t.zoomToPoint(e, this.defaultZoom), this.editor.canvas.fire("editor:zoom-changed", {
|
|
2846
2955
|
currentZoom: t.getZoom(),
|
|
2847
2956
|
point: e
|
|
@@ -2905,7 +3014,7 @@ class $s {
|
|
|
2905
3014
|
}), t.upperCanvasEl.style.pointerEvents = "", t.lowerCanvasEl.style.pointerEvents = "", this.overlayMask.visible = !1, t.requestRenderAll(), t.fire("editor:enabled"), s.resumeHistory();
|
|
2906
3015
|
}
|
|
2907
3016
|
}
|
|
2908
|
-
class
|
|
3017
|
+
class Lt {
|
|
2909
3018
|
constructor({ editor: t }) {
|
|
2910
3019
|
this.editor = t, this.backgroundObject = null;
|
|
2911
3020
|
}
|
|
@@ -2931,7 +3040,7 @@ class Ot {
|
|
|
2931
3040
|
}
|
|
2932
3041
|
a.set({
|
|
2933
3042
|
fill: t,
|
|
2934
|
-
backgroundId: `background-${
|
|
3043
|
+
backgroundId: `background-${X()}`
|
|
2935
3044
|
}), this.editor.canvas.requestRenderAll();
|
|
2936
3045
|
} else
|
|
2937
3046
|
this._removeCurrentBackground(), this._createColorBackground(t);
|
|
@@ -2968,14 +3077,14 @@ class Ot {
|
|
|
2968
3077
|
try {
|
|
2969
3078
|
const { historyManager: i } = this.editor, { backgroundObject: a } = this;
|
|
2970
3079
|
if (i.suspendHistory(), a && a.backgroundType === "gradient") {
|
|
2971
|
-
const r =
|
|
2972
|
-
if (
|
|
3080
|
+
const r = Lt._createFabricGradient(t);
|
|
3081
|
+
if (Lt._isGradientEqual(a.fill, r)) {
|
|
2973
3082
|
i.resumeHistory();
|
|
2974
3083
|
return;
|
|
2975
3084
|
}
|
|
2976
3085
|
a.set({
|
|
2977
3086
|
fill: r,
|
|
2978
|
-
backgroundId: `background-${
|
|
3087
|
+
backgroundId: `background-${X()}`
|
|
2979
3088
|
}), this.editor.canvas.requestRenderAll();
|
|
2980
3089
|
} else
|
|
2981
3090
|
this._removeCurrentBackground(), this._createGradientBackground(t);
|
|
@@ -3063,7 +3172,7 @@ class Ot {
|
|
|
3063
3172
|
* @param options.withoutSave - Если true, не сохранять состояние в историю
|
|
3064
3173
|
*/
|
|
3065
3174
|
setImageBackground(o) {
|
|
3066
|
-
return
|
|
3175
|
+
return P(this, arguments, function* ({
|
|
3067
3176
|
imageSource: t,
|
|
3068
3177
|
customData: e = {},
|
|
3069
3178
|
fromTemplate: s = !1,
|
|
@@ -3133,7 +3242,7 @@ class Ot {
|
|
|
3133
3242
|
hasControls: !1,
|
|
3134
3243
|
id: "background",
|
|
3135
3244
|
backgroundType: "color",
|
|
3136
|
-
backgroundId: `background-${
|
|
3245
|
+
backgroundId: `background-${X()}`
|
|
3137
3246
|
}, { withoutSelection: !0 }), this.refresh();
|
|
3138
3247
|
}
|
|
3139
3248
|
/**
|
|
@@ -3150,9 +3259,9 @@ class Ot {
|
|
|
3150
3259
|
hasControls: !1,
|
|
3151
3260
|
id: "background",
|
|
3152
3261
|
backgroundType: "gradient",
|
|
3153
|
-
backgroundId: `background-${
|
|
3262
|
+
backgroundId: `background-${X()}`
|
|
3154
3263
|
}, { withoutSelection: !0 }), this.refresh();
|
|
3155
|
-
const e =
|
|
3264
|
+
const e = Lt._createFabricGradient(t);
|
|
3156
3265
|
this.backgroundObject.set("fill", e), this.editor.canvas.requestRenderAll();
|
|
3157
3266
|
}
|
|
3158
3267
|
/**
|
|
@@ -3160,7 +3269,7 @@ class Ot {
|
|
|
3160
3269
|
* @param source - источник изображения (URL или File)
|
|
3161
3270
|
*/
|
|
3162
3271
|
_createImageBackground(t, e) {
|
|
3163
|
-
return
|
|
3272
|
+
return P(this, null, function* () {
|
|
3164
3273
|
var n;
|
|
3165
3274
|
const { image: s } = (n = yield this.editor.imageManager.importImage({
|
|
3166
3275
|
source: t,
|
|
@@ -3178,7 +3287,7 @@ class Ot {
|
|
|
3178
3287
|
hasControls: !1,
|
|
3179
3288
|
id: "background",
|
|
3180
3289
|
backgroundType: "image",
|
|
3181
|
-
backgroundId: `background-${
|
|
3290
|
+
backgroundId: `background-${X()}`,
|
|
3182
3291
|
customData: e
|
|
3183
3292
|
}), this._removeCurrentBackground(), this.backgroundObject = s, this.refresh();
|
|
3184
3293
|
});
|
|
@@ -3212,8 +3321,8 @@ class Ot {
|
|
|
3212
3321
|
{ offset: 0, color: "#000000" },
|
|
3213
3322
|
{ offset: 1, color: "#ffffff" }
|
|
3214
3323
|
], t.type === "linear") {
|
|
3215
|
-
const u = t.angle * Math.PI / 180, f =
|
|
3216
|
-
return new
|
|
3324
|
+
const u = t.angle * Math.PI / 180, f = Lt._angleToCoords(u);
|
|
3325
|
+
return new Pe({
|
|
3217
3326
|
type: "linear",
|
|
3218
3327
|
gradientUnits: "percentage",
|
|
3219
3328
|
coords: f,
|
|
@@ -3232,7 +3341,7 @@ class Ot {
|
|
|
3232
3341
|
r1: 0,
|
|
3233
3342
|
r2: d / 100
|
|
3234
3343
|
};
|
|
3235
|
-
return new
|
|
3344
|
+
return new Pe({
|
|
3236
3345
|
type: "radial",
|
|
3237
3346
|
gradientUnits: "percentage",
|
|
3238
3347
|
coords: l,
|
|
@@ -3421,13 +3530,13 @@ class tn {
|
|
|
3421
3530
|
*/
|
|
3422
3531
|
addRectangle(d = {}, { withoutSelection: r, withoutAdding: c } = {}) {
|
|
3423
3532
|
var l = d, {
|
|
3424
|
-
id: t = `rect-${
|
|
3533
|
+
id: t = `rect-${X()}`,
|
|
3425
3534
|
left: e,
|
|
3426
3535
|
top: s,
|
|
3427
3536
|
width: n = 100,
|
|
3428
3537
|
height: o = 100,
|
|
3429
3538
|
fill: i = "blue"
|
|
3430
|
-
} = l, a =
|
|
3539
|
+
} = l, a = pt(l, [
|
|
3431
3540
|
"id",
|
|
3432
3541
|
"left",
|
|
3433
3542
|
"top",
|
|
@@ -3463,12 +3572,12 @@ class tn {
|
|
|
3463
3572
|
*/
|
|
3464
3573
|
addCircle(c = {}, { withoutSelection: a, withoutAdding: r } = {}) {
|
|
3465
3574
|
var d = c, {
|
|
3466
|
-
id: t = `circle-${
|
|
3575
|
+
id: t = `circle-${X()}`,
|
|
3467
3576
|
left: e,
|
|
3468
3577
|
top: s,
|
|
3469
3578
|
radius: n = 50,
|
|
3470
3579
|
fill: o = "green"
|
|
3471
|
-
} = d, i =
|
|
3580
|
+
} = d, i = pt(d, [
|
|
3472
3581
|
"id",
|
|
3473
3582
|
"left",
|
|
3474
3583
|
"top",
|
|
@@ -3503,13 +3612,13 @@ class tn {
|
|
|
3503
3612
|
*/
|
|
3504
3613
|
addTriangle(d = {}, { withoutSelection: r, withoutAdding: c } = {}) {
|
|
3505
3614
|
var l = d, {
|
|
3506
|
-
id: t = `triangle-${
|
|
3615
|
+
id: t = `triangle-${X()}`,
|
|
3507
3616
|
left: e,
|
|
3508
3617
|
top: s,
|
|
3509
3618
|
width: n = 100,
|
|
3510
3619
|
height: o = 100,
|
|
3511
3620
|
fill: i = "yellow"
|
|
3512
|
-
} = l, a =
|
|
3621
|
+
} = l, a = pt(l, [
|
|
3513
3622
|
"id",
|
|
3514
3623
|
"left",
|
|
3515
3624
|
"top",
|
|
@@ -3556,7 +3665,7 @@ class en {
|
|
|
3556
3665
|
* Асинхронное клонирование для внутреннего буфера
|
|
3557
3666
|
*/
|
|
3558
3667
|
_cloneToInternalClipboard(t) {
|
|
3559
|
-
return
|
|
3668
|
+
return P(this, null, function* () {
|
|
3560
3669
|
const { canvas: e, errorManager: s } = this.editor;
|
|
3561
3670
|
try {
|
|
3562
3671
|
const n = yield t.clone(ie);
|
|
@@ -3576,7 +3685,7 @@ class en {
|
|
|
3576
3685
|
* Копирование в системный буфер обмена
|
|
3577
3686
|
*/
|
|
3578
3687
|
_copyToSystemClipboard(t) {
|
|
3579
|
-
return
|
|
3688
|
+
return P(this, null, function* () {
|
|
3580
3689
|
const { errorManager: e } = this.editor;
|
|
3581
3690
|
if (typeof ClipboardItem == "undefined" || !navigator.clipboard)
|
|
3582
3691
|
return e.emitWarning({
|
|
@@ -3603,7 +3712,7 @@ class en {
|
|
|
3603
3712
|
* Копирование изображения в буфер обмена
|
|
3604
3713
|
*/
|
|
3605
3714
|
_copyImageToClipboard(t, e) {
|
|
3606
|
-
return
|
|
3715
|
+
return P(this, null, function* () {
|
|
3607
3716
|
try {
|
|
3608
3717
|
const n = t.toCanvasElement({ enableRetinaScaling: !1 }).toDataURL(), o = n.slice(5).split(";")[0], i = n.split(",")[1], a = atob(i), r = new Uint8Array(a.length);
|
|
3609
3718
|
for (let l = 0; l < a.length; l += 1)
|
|
@@ -3625,7 +3734,7 @@ class en {
|
|
|
3625
3734
|
* Копирование текста в буфер обмена
|
|
3626
3735
|
*/
|
|
3627
3736
|
_copyTextToClipboard(t) {
|
|
3628
|
-
return
|
|
3737
|
+
return P(this, null, function* () {
|
|
3629
3738
|
try {
|
|
3630
3739
|
const e = `${Ge}${t}`;
|
|
3631
3740
|
return yield navigator.clipboard.writeText(e), console.info("Text copied to clipboard successfully"), !0;
|
|
@@ -3660,7 +3769,7 @@ class en {
|
|
|
3660
3769
|
* @param source - источник изображения (data URL или URL)
|
|
3661
3770
|
*/
|
|
3662
3771
|
_handleImageImport(t) {
|
|
3663
|
-
return
|
|
3772
|
+
return P(this, null, function* () {
|
|
3664
3773
|
var s;
|
|
3665
3774
|
const { image: e } = (s = yield this.editor.imageManager.importImage({
|
|
3666
3775
|
source: t,
|
|
@@ -3676,18 +3785,18 @@ class en {
|
|
|
3676
3785
|
* @fires editor:object-pasted
|
|
3677
3786
|
*/
|
|
3678
3787
|
copyPaste(t) {
|
|
3679
|
-
return
|
|
3788
|
+
return P(this, null, function* () {
|
|
3680
3789
|
const { canvas: e } = this.editor, s = t || e.getActiveObject();
|
|
3681
3790
|
if (!s || s.locked) return !1;
|
|
3682
3791
|
try {
|
|
3683
3792
|
const n = yield s.clone(ie);
|
|
3684
3793
|
return n instanceof U && n.forEachObject((o) => {
|
|
3685
3794
|
o.set({
|
|
3686
|
-
id: `${o.type}-${
|
|
3795
|
+
id: `${o.type}-${X()}`,
|
|
3687
3796
|
evented: !0
|
|
3688
3797
|
});
|
|
3689
3798
|
}), n.set({
|
|
3690
|
-
id: `${n.type}-${
|
|
3799
|
+
id: `${n.type}-${X()}`,
|
|
3691
3800
|
left: n.left + 10,
|
|
3692
3801
|
top: n.top + 10,
|
|
3693
3802
|
evented: !0
|
|
@@ -3711,7 +3820,7 @@ class en {
|
|
|
3711
3820
|
* @param event.clipboardData.items — элементы буфера обмена
|
|
3712
3821
|
*/
|
|
3713
3822
|
handlePasteEvent(e) {
|
|
3714
|
-
return
|
|
3823
|
+
return P(this, arguments, function* ({ clipboardData: t }) {
|
|
3715
3824
|
var r;
|
|
3716
3825
|
if (!((r = t == null ? void 0 : t.items) != null && r.length)) {
|
|
3717
3826
|
this.paste();
|
|
@@ -3762,18 +3871,18 @@ class en {
|
|
|
3762
3871
|
* @fires editor:object-pasted
|
|
3763
3872
|
*/
|
|
3764
3873
|
paste() {
|
|
3765
|
-
return
|
|
3874
|
+
return P(this, null, function* () {
|
|
3766
3875
|
const { canvas: t } = this.editor;
|
|
3767
3876
|
if (!this.clipboard) return !1;
|
|
3768
3877
|
try {
|
|
3769
3878
|
const e = yield this.clipboard.clone(ie);
|
|
3770
3879
|
return t.discardActiveObject(), e instanceof U && e.forEachObject((s) => {
|
|
3771
3880
|
s.set({
|
|
3772
|
-
id: `${s.type}-${
|
|
3881
|
+
id: `${s.type}-${X()}`,
|
|
3773
3882
|
evented: !0
|
|
3774
3883
|
});
|
|
3775
3884
|
}), e.set({
|
|
3776
|
-
id: `${e.type}-${
|
|
3885
|
+
id: `${e.type}-${X()}`,
|
|
3777
3886
|
left: e.left + 10,
|
|
3778
3887
|
top: e.top + 10,
|
|
3779
3888
|
evented: !0
|
|
@@ -3819,7 +3928,7 @@ class he {
|
|
|
3819
3928
|
};
|
|
3820
3929
|
i.set(a), !e && he._isGroupOrSelection(i) && i.getObjects().forEach((c) => {
|
|
3821
3930
|
c.set(a);
|
|
3822
|
-
}), i instanceof
|
|
3931
|
+
}), i instanceof it && i.isEditing && i.exitEditing(), n.renderAll(), s || o.saveState(), n.fire("editor:object-locked", {
|
|
3823
3932
|
object: i,
|
|
3824
3933
|
skipInnerObjects: e,
|
|
3825
3934
|
withoutSave: s
|
|
@@ -3854,7 +3963,7 @@ class he {
|
|
|
3854
3963
|
});
|
|
3855
3964
|
}
|
|
3856
3965
|
static _isGroupOrSelection(t) {
|
|
3857
|
-
return t instanceof U || t instanceof
|
|
3966
|
+
return t instanceof U || t instanceof Ot;
|
|
3858
3967
|
}
|
|
3859
3968
|
}
|
|
3860
3969
|
class sn {
|
|
@@ -3877,20 +3986,20 @@ class sn {
|
|
|
3877
3986
|
*/
|
|
3878
3987
|
_getGroupsToUngroup(t) {
|
|
3879
3988
|
if (Array.isArray(t)) {
|
|
3880
|
-
const s = t.filter((n) => n instanceof
|
|
3989
|
+
const s = t.filter((n) => n instanceof Ot);
|
|
3881
3990
|
return s.length > 0 ? s : null;
|
|
3882
3991
|
}
|
|
3883
3992
|
if (t instanceof U) {
|
|
3884
|
-
const s = t.getObjects().filter((n) => n instanceof
|
|
3993
|
+
const s = t.getObjects().filter((n) => n instanceof Ot);
|
|
3885
3994
|
return s.length > 0 ? s : null;
|
|
3886
3995
|
}
|
|
3887
3996
|
const e = t || this.editor.canvas.getActiveObject();
|
|
3888
3997
|
if (!e) return null;
|
|
3889
3998
|
if (e instanceof U) {
|
|
3890
|
-
const s = e.getObjects().filter((n) => n instanceof
|
|
3999
|
+
const s = e.getObjects().filter((n) => n instanceof Ot);
|
|
3891
4000
|
return s.length > 0 ? s : null;
|
|
3892
4001
|
}
|
|
3893
|
-
return e instanceof
|
|
4002
|
+
return e instanceof Ot ? [e] : null;
|
|
3894
4003
|
}
|
|
3895
4004
|
/**
|
|
3896
4005
|
* Группировка объектов
|
|
@@ -3907,8 +4016,8 @@ class sn {
|
|
|
3907
4016
|
if (!o) return null;
|
|
3908
4017
|
try {
|
|
3909
4018
|
n.suspendHistory();
|
|
3910
|
-
const i = new
|
|
3911
|
-
id: `group-${
|
|
4019
|
+
const i = new Ot(o, {
|
|
4020
|
+
id: `group-${X()}`
|
|
3912
4021
|
});
|
|
3913
4022
|
o.forEach((r) => s.remove(r)), s.add(i), s.setActiveObject(i), s.requestRenderAll();
|
|
3914
4023
|
const a = {
|
|
@@ -4035,7 +4144,7 @@ class Oe {
|
|
|
4035
4144
|
return n.fire("editor:objects-deleted", c), c;
|
|
4036
4145
|
}
|
|
4037
4146
|
}
|
|
4038
|
-
const
|
|
4147
|
+
const At = {
|
|
4039
4148
|
IMAGE_MANAGER: {
|
|
4040
4149
|
/**
|
|
4041
4150
|
* Некорректный Content-Type изображения
|
|
@@ -4219,7 +4328,7 @@ class Qt {
|
|
|
4219
4328
|
* @returns true, если код допустим, иначе false
|
|
4220
4329
|
*/
|
|
4221
4330
|
static isValidErrorCode(t) {
|
|
4222
|
-
return t ? Object.values(
|
|
4331
|
+
return t ? Object.values(At).some((e) => Object.values(e).includes(t)) : !1;
|
|
4223
4332
|
}
|
|
4224
4333
|
}
|
|
4225
4334
|
class on {
|
|
@@ -4307,11 +4416,11 @@ class on {
|
|
|
4307
4416
|
this.currentBounds = this.calculatePanBounds();
|
|
4308
4417
|
}
|
|
4309
4418
|
}
|
|
4310
|
-
const
|
|
4419
|
+
const lt = ({
|
|
4311
4420
|
value: h,
|
|
4312
4421
|
min: t,
|
|
4313
4422
|
max: e
|
|
4314
|
-
}) => Math.min(Math.max(h, t), e),
|
|
4423
|
+
}) => Math.min(Math.max(h, t), e), Rt = class Rt extends it {
|
|
4315
4424
|
constructor(t, e = {}) {
|
|
4316
4425
|
var s, n, o, i, a, r, c, d, l;
|
|
4317
4426
|
super(t, e), this.backgroundOpacity = (s = e.backgroundOpacity) != null ? s : 1, this.paddingTop = (n = e.paddingTop) != null ? n : 0, this.paddingRight = (o = e.paddingRight) != null ? o : 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 = (l = e.radiusBottomLeft) != null ? l : 0, this._roundDimensions();
|
|
@@ -4332,11 +4441,11 @@ const dt = ({
|
|
|
4332
4441
|
}
|
|
4333
4442
|
_getNonTransformedDimensions() {
|
|
4334
4443
|
const { width: t, height: e } = this._getBackgroundDimensions();
|
|
4335
|
-
return new
|
|
4444
|
+
return new et(t, e).scalarAdd(this.strokeWidth);
|
|
4336
4445
|
}
|
|
4337
4446
|
_getTransformedDimensions(t = {}) {
|
|
4338
4447
|
const { width: e, height: s } = this._getBackgroundDimensions();
|
|
4339
|
-
return super._getTransformedDimensions(
|
|
4448
|
+
return super._getTransformedDimensions(St(B({}, t), {
|
|
4340
4449
|
width: e,
|
|
4341
4450
|
height: s
|
|
4342
4451
|
}));
|
|
@@ -4346,7 +4455,7 @@ const dt = ({
|
|
|
4346
4455
|
*/
|
|
4347
4456
|
toObject(t = []) {
|
|
4348
4457
|
const e = super.toObject(t);
|
|
4349
|
-
return
|
|
4458
|
+
return St(B({}, e), {
|
|
4350
4459
|
backgroundOpacity: this.backgroundOpacity,
|
|
4351
4460
|
paddingTop: this.paddingTop,
|
|
4352
4461
|
paddingRight: this.paddingRight,
|
|
@@ -4363,7 +4472,7 @@ const dt = ({
|
|
|
4363
4472
|
const e = this._getEffectiveBackgroundFill();
|
|
4364
4473
|
if (e && e) {
|
|
4365
4474
|
const o = this._getPadding(), i = (s = this.width) != null ? s : 0, a = (n = this.height) != null ? n : 0, r = i + o.left + o.right, c = a + o.top + o.bottom, d = this._getCornerRadii({ width: r, height: c }), l = this._getLeftOffset() - o.left, u = this._getTopOffset() - o.top;
|
|
4366
|
-
t.save(),
|
|
4475
|
+
t.save(), Rt._renderRoundedRect({
|
|
4367
4476
|
ctx: t,
|
|
4368
4477
|
height: c,
|
|
4369
4478
|
left: l,
|
|
@@ -4385,10 +4494,10 @@ const dt = ({
|
|
|
4385
4494
|
var i, a, r, c;
|
|
4386
4495
|
const s = t / 2, n = e / 2, o = Math.min(s, n);
|
|
4387
4496
|
return {
|
|
4388
|
-
bottomLeft:
|
|
4389
|
-
bottomRight:
|
|
4390
|
-
topLeft:
|
|
4391
|
-
topRight:
|
|
4497
|
+
bottomLeft: lt({ value: (i = this.radiusBottomLeft) != null ? i : 0, min: 0, max: o }),
|
|
4498
|
+
bottomRight: lt({ value: (a = this.radiusBottomRight) != null ? a : 0, min: 0, max: o }),
|
|
4499
|
+
topLeft: lt({ value: (r = this.radiusTopLeft) != null ? r : 0, min: 0, max: o }),
|
|
4500
|
+
topRight: lt({ value: (c = this.radiusTopRight) != null ? c : 0, min: 0, max: o })
|
|
4392
4501
|
};
|
|
4393
4502
|
}
|
|
4394
4503
|
_getPadding() {
|
|
@@ -4404,7 +4513,7 @@ const dt = ({
|
|
|
4404
4513
|
var n;
|
|
4405
4514
|
const t = this.backgroundColor;
|
|
4406
4515
|
if (!t) return null;
|
|
4407
|
-
const e =
|
|
4516
|
+
const e = lt({ value: (n = this.backgroundOpacity) != null ? n : 1, min: 0, max: 1 });
|
|
4408
4517
|
let s;
|
|
4409
4518
|
try {
|
|
4410
4519
|
s = new ms(t);
|
|
@@ -4432,7 +4541,7 @@ const dt = ({
|
|
|
4432
4541
|
topRight: d,
|
|
4433
4542
|
bottomRight: l,
|
|
4434
4543
|
bottomLeft: u
|
|
4435
|
-
} = n, f =
|
|
4544
|
+
} = n, f = lt({ value: c, min: 0, max: i }), g = lt({ value: d, min: 0, max: i }), p = lt({ value: l, min: 0, max: i }), m = lt({ value: u, min: 0, max: i });
|
|
4436
4545
|
t.beginPath(), t.moveTo(s + f, o), t.lineTo(a - g, o), t.quadraticCurveTo(a, o, a, o + g), 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, o + f), t.quadraticCurveTo(s, o, s + f, o), t.closePath();
|
|
4437
4546
|
}
|
|
4438
4547
|
/**
|
|
@@ -4446,8 +4555,8 @@ const dt = ({
|
|
|
4446
4555
|
s !== t && (this.width = Math.max(0, s)), n !== e && (this.height = Math.max(0, n));
|
|
4447
4556
|
}
|
|
4448
4557
|
};
|
|
4449
|
-
|
|
4450
|
-
...Array.isArray(
|
|
4558
|
+
Rt.type = "background-textbox", Rt.cacheProperties = [
|
|
4559
|
+
...Array.isArray(it.cacheProperties) ? it.cacheProperties : [],
|
|
4451
4560
|
"backgroundColor",
|
|
4452
4561
|
"backgroundOpacity",
|
|
4453
4562
|
"paddingTop",
|
|
@@ -4458,8 +4567,8 @@ Dt.type = "background-textbox", Dt.cacheProperties = [
|
|
|
4458
4567
|
"radiusTopRight",
|
|
4459
4568
|
"radiusBottomRight",
|
|
4460
4569
|
"radiusBottomLeft"
|
|
4461
|
-
],
|
|
4462
|
-
...Array.isArray(
|
|
4570
|
+
], Rt.stateProperties = [
|
|
4571
|
+
...Array.isArray(it.stateProperties) ? it.stateProperties : [],
|
|
4463
4572
|
"backgroundColor",
|
|
4464
4573
|
"backgroundOpacity",
|
|
4465
4574
|
"paddingTop",
|
|
@@ -4471,10 +4580,10 @@ Dt.type = "background-textbox", Dt.cacheProperties = [
|
|
|
4471
4580
|
"radiusBottomRight",
|
|
4472
4581
|
"radiusBottomLeft"
|
|
4473
4582
|
];
|
|
4474
|
-
let ue =
|
|
4583
|
+
let ue = Rt;
|
|
4475
4584
|
const an = () => {
|
|
4476
4585
|
var h;
|
|
4477
|
-
(h =
|
|
4586
|
+
(h = We) != null && h.setClass && We.setClass(ue, "background-textbox");
|
|
4478
4587
|
}, rn = ({ textbox: h }) => {
|
|
4479
4588
|
var s, n;
|
|
4480
4589
|
if (!h.isEditing) return null;
|
|
@@ -4514,7 +4623,7 @@ const an = () => {
|
|
|
4514
4623
|
);
|
|
4515
4624
|
if (s.length)
|
|
4516
4625
|
return (n = s[0]) == null ? void 0 : n[e];
|
|
4517
|
-
}, Ke = ({ strokeColor: h, width: t }) => t <= 0 ? null : h != null ? h : "#000000", Qe = ({ width: h = 0 }) => h ? Math.max(0, h) : 0, pe = ({ value: h }) => typeof h == "string" ? h.toLocaleUpperCase() : "",
|
|
4626
|
+
}, Ke = ({ strokeColor: h, width: t }) => t <= 0 ? null : h != null ? h : "#000000", Qe = ({ width: h = 0 }) => h ? Math.max(0, h) : 0, pe = ({ value: h }) => typeof h == "string" ? h.toLocaleUpperCase() : "", tt = 0.01;
|
|
4518
4627
|
class k {
|
|
4519
4628
|
constructor({ editor: t }) {
|
|
4520
4629
|
var e;
|
|
@@ -4558,7 +4667,7 @@ class k {
|
|
|
4558
4667
|
this.isTextEditingActive = !1, this.editor.historyManager.saveState();
|
|
4559
4668
|
}, Vs);
|
|
4560
4669
|
}, this._handleObjectScaling = (s) => {
|
|
4561
|
-
var te,
|
|
4670
|
+
var te, Bt, kt, zt, Pt, Wt, Ut, Ft, Yt, K, Et, ee, wt;
|
|
4562
4671
|
const { target: n, transform: o } = s;
|
|
4563
4672
|
if (n instanceof U || !k._isTextbox(n) || !o) return;
|
|
4564
4673
|
n.isScaling = !0;
|
|
@@ -4569,124 +4678,124 @@ class k {
|
|
|
4569
4678
|
basePadding: d,
|
|
4570
4679
|
baseRadii: l,
|
|
4571
4680
|
baseStyles: u
|
|
4572
|
-
} = i, f = typeof ((te = o.original) == null ? void 0 : te.width) == "number" ? o.original.width : void 0, g = typeof ((
|
|
4681
|
+
} = i, f = typeof ((te = o.original) == null ? void 0 : te.width) == "number" ? o.original.width : void 0, g = typeof ((Bt = o.original) == null ? void 0 : Bt.left) == "number" ? o.original.left : void 0, p = f != null ? f : a, m = g != null ? g : r, v = (kt = o.corner) != null ? kt : "", w = (zt = o.action) != null ? zt : "", A = ["ml", "mr"].includes(v) || w === "scaleX", y = ["mt", "mb"].includes(v) || w === "scaleY", b = ["tl", "tr", "bl", "br"].includes(v) || w === "scale", j = b || y;
|
|
4573
4682
|
if (!A && !y && !b) return;
|
|
4574
|
-
const I = Math.abs((
|
|
4683
|
+
const I = Math.abs((Wt = (Pt = n.scaleX) != null ? Pt : o.scaleX) != null ? Wt : 1) || 1, S = Math.abs((Ft = (Ut = n.scaleY) != null ? Ut : o.scaleY) != null ? Ft : 1) || 1, T = Math.max(1, p * I), M = Math.max(1, Math.round(T)), C = Math.max(1, c * S), {
|
|
4575
4684
|
paddingTop: E = 0,
|
|
4576
|
-
paddingRight:
|
|
4577
|
-
paddingBottom:
|
|
4578
|
-
paddingLeft:
|
|
4685
|
+
paddingRight: z = 0,
|
|
4686
|
+
paddingBottom: x = 0,
|
|
4687
|
+
paddingLeft: N = 0,
|
|
4579
4688
|
radiusTopLeft: Y = 0,
|
|
4580
|
-
radiusTopRight:
|
|
4581
|
-
radiusBottomRight:
|
|
4689
|
+
radiusTopRight: V = 0,
|
|
4690
|
+
radiusBottomRight: Q = 0,
|
|
4582
4691
|
radiusBottomLeft: H = 0,
|
|
4583
4692
|
fontSize: R,
|
|
4584
4693
|
width: O,
|
|
4585
|
-
originX:
|
|
4586
|
-
} = n, Z = b || y,
|
|
4587
|
-
top: Math.max(0, d.top *
|
|
4588
|
-
right: Math.max(0, d.right *
|
|
4589
|
-
bottom: Math.max(0, d.bottom *
|
|
4590
|
-
left: Math.max(0, d.left *
|
|
4591
|
-
} : d,
|
|
4592
|
-
topLeft: Math.max(0, l.topLeft *
|
|
4593
|
-
topRight: Math.max(0, l.topRight *
|
|
4594
|
-
bottomRight: Math.max(0, l.bottomRight *
|
|
4595
|
-
bottomLeft: Math.max(0, l.bottomLeft *
|
|
4596
|
-
} : l,
|
|
4597
|
-
let
|
|
4598
|
-
if (j &&
|
|
4599
|
-
const
|
|
4600
|
-
Object.entries(u).forEach(([
|
|
4694
|
+
originX: at = "left"
|
|
4695
|
+
} = n, Z = b || y, nt = b || y, F = Z ? {
|
|
4696
|
+
top: Math.max(0, d.top * S),
|
|
4697
|
+
right: Math.max(0, d.right * S),
|
|
4698
|
+
bottom: Math.max(0, d.bottom * S),
|
|
4699
|
+
left: Math.max(0, d.left * S)
|
|
4700
|
+
} : d, $ = nt ? {
|
|
4701
|
+
topLeft: Math.max(0, l.topLeft * S),
|
|
4702
|
+
topRight: Math.max(0, l.topRight * S),
|
|
4703
|
+
bottomRight: Math.max(0, l.bottomRight * S),
|
|
4704
|
+
bottomLeft: Math.max(0, l.bottomLeft * S)
|
|
4705
|
+
} : l, ot = Object.keys(u).length > 0;
|
|
4706
|
+
let q;
|
|
4707
|
+
if (j && ot) {
|
|
4708
|
+
const Ht = {};
|
|
4709
|
+
Object.entries(u).forEach(([Zt, De]) => {
|
|
4601
4710
|
if (!De) return;
|
|
4602
4711
|
const fe = {};
|
|
4603
4712
|
Object.entries(De).forEach(([cs, se]) => {
|
|
4604
4713
|
if (!se) return;
|
|
4605
4714
|
const Re = B({}, se);
|
|
4606
|
-
typeof se.fontSize == "number" && (Re.fontSize = Math.max(1, se.fontSize *
|
|
4607
|
-
}), Object.keys(fe).length && (
|
|
4608
|
-
}), Object.keys(
|
|
4715
|
+
typeof se.fontSize == "number" && (Re.fontSize = Math.max(1, se.fontSize * S)), fe[cs] = Re;
|
|
4716
|
+
}), Object.keys(fe).length && (Ht[Zt] = fe);
|
|
4717
|
+
}), Object.keys(Ht).length && (q = Ht);
|
|
4609
4718
|
}
|
|
4610
|
-
const
|
|
4611
|
-
if (!
|
|
4719
|
+
const vt = (K = (Yt = o.originX) != null ? Yt : at) != null ? K : "left", Ct = m + p, rt = m + p / 2, gt = O != null ? O : p, ct = M !== gt, Nt = Math.abs(C - (R != null ? R : c)) > tt, bt = Math.abs(F.top - E) > tt || Math.abs(F.right - z) > tt || Math.abs(F.bottom - x) > tt || Math.abs(F.left - N) > tt, Jt = Math.abs($.topLeft - Y) > tt || Math.abs($.topRight - V) > tt || Math.abs($.bottomRight - Q) > tt || Math.abs($.bottomLeft - H) > tt;
|
|
4720
|
+
if (!ct && !Nt && !bt && !Jt) {
|
|
4612
4721
|
n.set({ scaleX: 1, scaleY: 1 }), o.scaleX = 1, o.scaleY = 1;
|
|
4613
4722
|
return;
|
|
4614
4723
|
}
|
|
4615
|
-
|
|
4724
|
+
q && (n.styles = q), n.set({
|
|
4616
4725
|
width: M,
|
|
4617
4726
|
fontSize: j ? C : c,
|
|
4618
4727
|
paddingTop: F.top,
|
|
4619
4728
|
paddingRight: F.right,
|
|
4620
4729
|
paddingBottom: F.bottom,
|
|
4621
4730
|
paddingLeft: F.left,
|
|
4622
|
-
radiusTopLeft:
|
|
4623
|
-
radiusTopRight:
|
|
4624
|
-
radiusBottomRight:
|
|
4625
|
-
radiusBottomLeft:
|
|
4731
|
+
radiusTopLeft: $.topLeft,
|
|
4732
|
+
radiusTopRight: $.topRight,
|
|
4733
|
+
radiusBottomRight: $.bottomRight,
|
|
4734
|
+
radiusBottomLeft: $.bottomLeft,
|
|
4626
4735
|
scaleX: 1,
|
|
4627
4736
|
scaleY: 1
|
|
4628
4737
|
});
|
|
4629
4738
|
const qt = k._roundTextboxDimensions({ textbox: n });
|
|
4630
4739
|
qt && (n.dirty = !0);
|
|
4631
|
-
const
|
|
4632
|
-
let
|
|
4633
|
-
$t && (A || b) && (
|
|
4634
|
-
const { original:
|
|
4635
|
-
|
|
4740
|
+
const Tt = (Et = n.width) != null ? Et : M, $t = Tt !== gt;
|
|
4741
|
+
let dt = m;
|
|
4742
|
+
$t && (A || b) && (vt === "right" ? dt = Ct - Tt : vt === "center" && (dt = rt - Tt / 2)), n.set({ left: dt }), i.baseLeft = dt, o.scaleX = 1, o.scaleY = 1;
|
|
4743
|
+
const { original: Mt } = o;
|
|
4744
|
+
Mt && (Mt.scaleX = 1, Mt.scaleY = 1, Mt.width = Tt, Mt.height = n.height, Mt.left = dt), n.setCoords(), this.canvas.requestRenderAll(), i.baseWidth = Tt, i.baseFontSize = (ee = n.fontSize) != null ? ee : C, i.baseStyles = JSON.parse(JSON.stringify((wt = n.styles) != null ? wt : {})), i.basePadding = {
|
|
4636
4745
|
top: F.top,
|
|
4637
4746
|
right: F.right,
|
|
4638
4747
|
bottom: F.bottom,
|
|
4639
4748
|
left: F.left
|
|
4640
4749
|
}, i.baseRadii = {
|
|
4641
|
-
topLeft:
|
|
4642
|
-
topRight:
|
|
4643
|
-
bottomRight:
|
|
4644
|
-
bottomLeft:
|
|
4645
|
-
}, i.hasWidthChange = $t || Nt ||
|
|
4750
|
+
topLeft: $.topLeft,
|
|
4751
|
+
topRight: $.topRight,
|
|
4752
|
+
bottomRight: $.bottomRight,
|
|
4753
|
+
bottomLeft: $.bottomLeft
|
|
4754
|
+
}, i.hasWidthChange = $t || Nt || bt || Jt || qt;
|
|
4646
4755
|
}, this._handleObjectModified = (s) => {
|
|
4647
|
-
var
|
|
4756
|
+
var w, A, y;
|
|
4648
4757
|
const { target: n } = s;
|
|
4649
4758
|
if (n instanceof U) {
|
|
4650
4759
|
const b = n.getObjects();
|
|
4651
4760
|
if (!b.some((M) => k._isTextbox(M))) return;
|
|
4652
|
-
const { scaleX: I = 1, scaleY:
|
|
4653
|
-
if (Math.abs(I - 1) <
|
|
4761
|
+
const { scaleX: I = 1, scaleY: S = 1 } = n;
|
|
4762
|
+
if (Math.abs(I - 1) < tt && Math.abs(S - 1) < tt) return;
|
|
4654
4763
|
this.canvas.discardActiveObject(), b.forEach((M) => {
|
|
4655
|
-
var C, E,
|
|
4764
|
+
var C, E, z, x;
|
|
4656
4765
|
if (k._isTextbox(M)) {
|
|
4657
|
-
const
|
|
4766
|
+
const N = (C = M.scaleX) != null ? C : 1, Y = (E = M.scaleY) != null ? E : 1, V = ((z = M.fontSize) != null ? z : 16) * Y, Q = ((x = M.width) != null ? x : 0) * N, H = Y, {
|
|
4658
4767
|
paddingTop: R = 0,
|
|
4659
4768
|
paddingRight: O = 0,
|
|
4660
|
-
paddingBottom:
|
|
4769
|
+
paddingBottom: at = 0,
|
|
4661
4770
|
paddingLeft: Z = 0,
|
|
4662
|
-
radiusTopLeft:
|
|
4771
|
+
radiusTopLeft: nt = 0,
|
|
4663
4772
|
radiusTopRight: F = 0,
|
|
4664
|
-
radiusBottomRight:
|
|
4665
|
-
radiusBottomLeft:
|
|
4666
|
-
styles:
|
|
4667
|
-
} = M,
|
|
4773
|
+
radiusBottomRight: $ = 0,
|
|
4774
|
+
radiusBottomLeft: ot = 0,
|
|
4775
|
+
styles: q
|
|
4776
|
+
} = M, vt = {
|
|
4668
4777
|
paddingTop: Math.max(0, R * H),
|
|
4669
4778
|
paddingRight: Math.max(0, O * H),
|
|
4670
|
-
paddingBottom: Math.max(0,
|
|
4779
|
+
paddingBottom: Math.max(0, at * H),
|
|
4671
4780
|
paddingLeft: Math.max(0, Z * H)
|
|
4672
|
-
},
|
|
4673
|
-
radiusTopLeft: Math.max(0,
|
|
4781
|
+
}, Ct = {
|
|
4782
|
+
radiusTopLeft: Math.max(0, nt * H),
|
|
4674
4783
|
radiusTopRight: Math.max(0, F * H),
|
|
4675
|
-
radiusBottomRight: Math.max(0,
|
|
4676
|
-
radiusBottomLeft: Math.max(0,
|
|
4784
|
+
radiusBottomRight: Math.max(0, $ * H),
|
|
4785
|
+
radiusBottomLeft: Math.max(0, ot * H)
|
|
4677
4786
|
};
|
|
4678
|
-
let
|
|
4679
|
-
|
|
4680
|
-
Object.values(
|
|
4681
|
-
typeof
|
|
4787
|
+
let rt = q;
|
|
4788
|
+
q && Object.keys(q).length > 0 && (rt = JSON.parse(JSON.stringify(q)), Object.values(rt).forEach((gt) => {
|
|
4789
|
+
Object.values(gt).forEach((ct) => {
|
|
4790
|
+
typeof ct.fontSize == "number" && (ct.fontSize = Math.max(1, ct.fontSize * H));
|
|
4682
4791
|
});
|
|
4683
|
-
})), M.set(
|
|
4684
|
-
fontSize:
|
|
4685
|
-
width:
|
|
4792
|
+
})), M.set(St(B(B({
|
|
4793
|
+
fontSize: V,
|
|
4794
|
+
width: Q,
|
|
4686
4795
|
scaleX: 1,
|
|
4687
4796
|
scaleY: 1
|
|
4688
|
-
},
|
|
4689
|
-
styles:
|
|
4797
|
+
}, vt), Ct), {
|
|
4798
|
+
styles: rt
|
|
4690
4799
|
})), k._roundTextboxDimensions({ textbox: M });
|
|
4691
4800
|
}
|
|
4692
4801
|
M.setCoords();
|
|
@@ -4701,7 +4810,7 @@ class k {
|
|
|
4701
4810
|
n.isScaling = !1;
|
|
4702
4811
|
const o = this.scalingState.get(n);
|
|
4703
4812
|
if (this.scalingState.delete(n), !(o != null && o.hasWidthChange)) return;
|
|
4704
|
-
const i = (
|
|
4813
|
+
const i = (w = n.width) != null ? w : n.calcTextWidth(), a = (y = (A = n.fontSize) != null ? A : o == null ? void 0 : o.baseFontSize) != null ? y : 16, r = !!(o.baseStyles && Object.keys(o.baseStyles).length), {
|
|
4705
4814
|
paddingTop: c = 0,
|
|
4706
4815
|
paddingRight: d = 0,
|
|
4707
4816
|
paddingBottom: l = 0,
|
|
@@ -4732,9 +4841,9 @@ class k {
|
|
|
4732
4841
|
* @param options — настройки текста
|
|
4733
4842
|
* @param flags — флаги поведения
|
|
4734
4843
|
*/
|
|
4735
|
-
addText(
|
|
4736
|
-
var
|
|
4737
|
-
id: t = `text-${
|
|
4844
|
+
addText(z = {}, { withoutSelection: M = !1, withoutSave: C = !1, withoutAdding: E = !1 } = {}) {
|
|
4845
|
+
var x = z, {
|
|
4846
|
+
id: t = `text-${X()}`,
|
|
4738
4847
|
text: e = "Новый текст",
|
|
4739
4848
|
fontFamily: s,
|
|
4740
4849
|
fontSize: n = 48,
|
|
@@ -4751,14 +4860,14 @@ class k {
|
|
|
4751
4860
|
backgroundColor: p,
|
|
4752
4861
|
backgroundOpacity: m = 1,
|
|
4753
4862
|
paddingTop: v = 0,
|
|
4754
|
-
paddingRight:
|
|
4863
|
+
paddingRight: w = 0,
|
|
4755
4864
|
paddingBottom: A = 0,
|
|
4756
4865
|
paddingLeft: y = 0,
|
|
4757
4866
|
radiusTopLeft: b = 0,
|
|
4758
4867
|
radiusTopRight: j = 0,
|
|
4759
4868
|
radiusBottomRight: I = 0,
|
|
4760
|
-
radiusBottomLeft:
|
|
4761
|
-
} =
|
|
4869
|
+
radiusBottomLeft: S = 0
|
|
4870
|
+
} = x, T = pt(x, [
|
|
4762
4871
|
"id",
|
|
4763
4872
|
"text",
|
|
4764
4873
|
"fontFamily",
|
|
@@ -4785,14 +4894,14 @@ class k {
|
|
|
4785
4894
|
"radiusBottomLeft"
|
|
4786
4895
|
]);
|
|
4787
4896
|
var Z;
|
|
4788
|
-
const { historyManager:
|
|
4789
|
-
|
|
4790
|
-
const
|
|
4897
|
+
const { historyManager: N } = this.editor, { canvas: Y } = this;
|
|
4898
|
+
N.suspendHistory();
|
|
4899
|
+
const V = s != null ? s : this._getDefaultFontFamily(), Q = Qe({ width: f }), H = Ke({
|
|
4791
4900
|
strokeColor: u,
|
|
4792
|
-
width:
|
|
4901
|
+
width: Q
|
|
4793
4902
|
}), R = B({
|
|
4794
4903
|
id: t,
|
|
4795
|
-
fontFamily:
|
|
4904
|
+
fontFamily: V,
|
|
4796
4905
|
fontSize: n,
|
|
4797
4906
|
fontWeight: o ? "bold" : "normal",
|
|
4798
4907
|
fontStyle: i ? "italic" : "normal",
|
|
@@ -4802,27 +4911,27 @@ class k {
|
|
|
4802
4911
|
textAlign: d,
|
|
4803
4912
|
fill: l,
|
|
4804
4913
|
stroke: H,
|
|
4805
|
-
strokeWidth:
|
|
4914
|
+
strokeWidth: Q,
|
|
4806
4915
|
strokeUniform: !0,
|
|
4807
4916
|
opacity: g,
|
|
4808
4917
|
backgroundColor: p,
|
|
4809
4918
|
backgroundOpacity: m,
|
|
4810
4919
|
paddingTop: v,
|
|
4811
|
-
paddingRight:
|
|
4920
|
+
paddingRight: w,
|
|
4812
4921
|
paddingBottom: A,
|
|
4813
4922
|
paddingLeft: y,
|
|
4814
4923
|
radiusTopLeft: b,
|
|
4815
4924
|
radiusTopRight: j,
|
|
4816
4925
|
radiusBottomRight: I,
|
|
4817
|
-
radiusBottomLeft:
|
|
4926
|
+
radiusBottomLeft: S
|
|
4818
4927
|
}, T), O = new ue(e, R);
|
|
4819
4928
|
if (O.textCaseRaw = (Z = O.text) != null ? Z : "", r) {
|
|
4820
|
-
const
|
|
4821
|
-
|
|
4929
|
+
const nt = pe({ value: O.textCaseRaw });
|
|
4930
|
+
nt !== O.text && O.set({ text: nt });
|
|
4822
4931
|
}
|
|
4823
|
-
return k._roundTextboxDimensions({ textbox: O }) && (O.dirty = !0), T.left === void 0 && T.top === void 0 && Y.centerObject(O), E || Y.add(O), M || Y.setActiveObject(O), Y.requestRenderAll(),
|
|
4932
|
+
return k._roundTextboxDimensions({ textbox: O }) && (O.dirty = !0), T.left === void 0 && T.top === void 0 && Y.centerObject(O), E || Y.add(O), M || Y.setActiveObject(O), Y.requestRenderAll(), N.resumeHistory(), C || N.saveState(), Y.fire("editor:text-added", {
|
|
4824
4933
|
textbox: O,
|
|
4825
|
-
options:
|
|
4934
|
+
options: St(B({}, R), {
|
|
4826
4935
|
text: e,
|
|
4827
4936
|
bold: o,
|
|
4828
4937
|
italic: i,
|
|
@@ -4830,7 +4939,7 @@ class k {
|
|
|
4830
4939
|
align: d,
|
|
4831
4940
|
color: l,
|
|
4832
4941
|
strokeColor: H,
|
|
4833
|
-
strokeWidth:
|
|
4942
|
+
strokeWidth: Q
|
|
4834
4943
|
}),
|
|
4835
4944
|
flags: {
|
|
4836
4945
|
withoutSelection: !!M,
|
|
@@ -4848,40 +4957,40 @@ class k {
|
|
|
4848
4957
|
* @param options.skipRender — не вызывать перерисовку канваса
|
|
4849
4958
|
*/
|
|
4850
4959
|
updateText({ target: t, style: e = {}, withoutSave: s, skipRender: n } = {}) {
|
|
4851
|
-
var
|
|
4960
|
+
var Bt, zt, Pt, Wt, Ut, Ft, Yt;
|
|
4852
4961
|
const o = this._resolveTextObject(t);
|
|
4853
4962
|
if (!o) return null;
|
|
4854
4963
|
const { historyManager: i } = this.editor, { canvas: a } = this;
|
|
4855
4964
|
i.suspendHistory();
|
|
4856
|
-
const r = k._getSnapshot(o), c = (
|
|
4965
|
+
const r = k._getSnapshot(o), c = (Bt = o.originY) != null ? Bt : "top", d = o.getPointByOrigin("center", c), l = {
|
|
4857
4966
|
originY: c,
|
|
4858
4967
|
x: d.x,
|
|
4859
4968
|
y: d.y
|
|
4860
|
-
},
|
|
4969
|
+
}, kt = e, {
|
|
4861
4970
|
text: u,
|
|
4862
4971
|
fontFamily: f,
|
|
4863
4972
|
fontSize: g,
|
|
4864
4973
|
bold: p,
|
|
4865
4974
|
italic: m,
|
|
4866
4975
|
underline: v,
|
|
4867
|
-
uppercase:
|
|
4976
|
+
uppercase: w,
|
|
4868
4977
|
strikethrough: A,
|
|
4869
4978
|
align: y,
|
|
4870
4979
|
color: b,
|
|
4871
4980
|
strokeColor: j,
|
|
4872
4981
|
strokeWidth: I,
|
|
4873
|
-
opacity:
|
|
4982
|
+
opacity: S,
|
|
4874
4983
|
backgroundColor: T,
|
|
4875
4984
|
backgroundOpacity: M,
|
|
4876
4985
|
paddingTop: C,
|
|
4877
4986
|
paddingRight: E,
|
|
4878
|
-
paddingBottom:
|
|
4879
|
-
paddingLeft:
|
|
4880
|
-
radiusTopLeft:
|
|
4987
|
+
paddingBottom: z,
|
|
4988
|
+
paddingLeft: x,
|
|
4989
|
+
radiusTopLeft: N,
|
|
4881
4990
|
radiusTopRight: Y,
|
|
4882
|
-
radiusBottomRight:
|
|
4883
|
-
radiusBottomLeft:
|
|
4884
|
-
} =
|
|
4991
|
+
radiusBottomRight: V,
|
|
4992
|
+
radiusBottomLeft: Q
|
|
4993
|
+
} = kt, H = pt(kt, [
|
|
4885
4994
|
"text",
|
|
4886
4995
|
"fontFamily",
|
|
4887
4996
|
"fontSize",
|
|
@@ -4905,57 +5014,57 @@ class k {
|
|
|
4905
5014
|
"radiusTopRight",
|
|
4906
5015
|
"radiusBottomRight",
|
|
4907
5016
|
"radiusBottomLeft"
|
|
4908
|
-
]), R = B({}, H), O = rn({ textbox: o }),
|
|
4909
|
-
if (f !== void 0 && (
|
|
4910
|
-
const
|
|
4911
|
-
O && (Z.fontWeight =
|
|
5017
|
+
]), R = B({}, H), O = rn({ textbox: o }), at = O ? k._expandRangeToFullLines({ textbox: o, range: O }) : null, Z = {}, nt = {}, F = {}, $ = dn({ textbox: o, range: O }), ot = !O || $, q = !O;
|
|
5018
|
+
if (f !== void 0 && (at && (nt.fontFamily = f), ot && (R.fontFamily = f, q && (F.fontFamily = f))), g !== void 0 && (at && (nt.fontSize = g), ot && (R.fontSize = g, q && (F.fontSize = g))), p !== void 0) {
|
|
5019
|
+
const K = p ? "bold" : "normal";
|
|
5020
|
+
O && (Z.fontWeight = K), ot && (R.fontWeight = K, q && (F.fontWeight = K));
|
|
4912
5021
|
}
|
|
4913
5022
|
if (m !== void 0) {
|
|
4914
|
-
const
|
|
4915
|
-
O && (Z.fontStyle =
|
|
5023
|
+
const K = m ? "italic" : "normal";
|
|
5024
|
+
O && (Z.fontStyle = K), ot && (R.fontStyle = K, q && (F.fontStyle = K));
|
|
4916
5025
|
}
|
|
4917
|
-
if (v !== void 0 && (O && (Z.underline = v),
|
|
4918
|
-
const
|
|
4919
|
-
strokeColor:
|
|
4920
|
-
width:
|
|
5026
|
+
if (v !== void 0 && (O && (Z.underline = v), ot && (R.underline = v, q && (F.underline = v))), A !== void 0 && (O && (Z.linethrough = A), ot && (R.linethrough = A, q && (F.linethrough = A))), y !== void 0 && (R.textAlign = y), b !== void 0 && (O && (Z.fill = b), ot && (R.fill = b, q && (F.fill = b))), j !== void 0 || I !== void 0) {
|
|
5027
|
+
const K = O ? Xe({ textbox: o, range: O, property: "strokeWidth" }) : void 0, Et = O ? Xe({ textbox: o, range: O, property: "stroke" }) : void 0, ee = (Pt = (zt = I != null ? I : K) != null ? zt : o.strokeWidth) != null ? Pt : 0, wt = Qe({ width: ee }), Ht = (Ut = (Wt = j != null ? j : Et) != null ? Wt : o.stroke) != null ? Ut : void 0, Zt = Ke({
|
|
5028
|
+
strokeColor: Ht,
|
|
5029
|
+
width: wt
|
|
4921
5030
|
});
|
|
4922
|
-
O && (Z.stroke =
|
|
4923
|
-
}
|
|
4924
|
-
|
|
4925
|
-
const
|
|
4926
|
-
if (
|
|
4927
|
-
const
|
|
4928
|
-
R.text =
|
|
4929
|
-
} else o.textCaseRaw === void 0 && (o.textCaseRaw =
|
|
4930
|
-
o.uppercase =
|
|
4931
|
-
let
|
|
5031
|
+
O && (Z.stroke = Zt, Z.strokeWidth = wt), ot && (R.stroke = Zt, R.strokeWidth = wt, q && (F.stroke = Zt, F.strokeWidth = wt));
|
|
5032
|
+
}
|
|
5033
|
+
S !== void 0 && (R.opacity = S), T !== void 0 && (R.backgroundColor = T), M !== void 0 && (R.backgroundOpacity = M), C !== void 0 && (R.paddingTop = C), E !== void 0 && (R.paddingRight = E), z !== void 0 && (R.paddingBottom = z), x !== void 0 && (R.paddingLeft = x), N !== void 0 && (R.radiusTopLeft = N), Y !== void 0 && (R.radiusTopRight = Y), V !== void 0 && (R.radiusBottomRight = V), Q !== void 0 && (R.radiusBottomLeft = Q);
|
|
5034
|
+
const vt = (Yt = o.textCaseRaw) != null ? Yt : (Ft = o.text) != null ? Ft : "", Ct = !!o.uppercase, rt = u !== void 0, gt = rt ? u != null ? u : "" : vt, ct = w != null ? w : Ct, Nt = ct !== Ct;
|
|
5035
|
+
if (rt || Nt) {
|
|
5036
|
+
const K = ct ? pe({ value: gt }) : gt;
|
|
5037
|
+
R.text = K, o.textCaseRaw = gt;
|
|
5038
|
+
} else o.textCaseRaw === void 0 && (o.textCaseRaw = vt);
|
|
5039
|
+
o.uppercase = ct, o.set(R);
|
|
5040
|
+
let bt = !1;
|
|
4932
5041
|
if (O) {
|
|
4933
|
-
const
|
|
4934
|
-
|
|
5042
|
+
const K = ge({ textbox: o, styles: Z, range: O }), Et = at ? ge({ textbox: o, styles: nt, range: at }) : !1;
|
|
5043
|
+
bt = K || Et;
|
|
4935
5044
|
} else if (Object.keys(F).length) {
|
|
4936
|
-
const
|
|
4937
|
-
|
|
5045
|
+
const K = cn({ textbox: o });
|
|
5046
|
+
K && (bt = ge({ textbox: o, styles: F, range: K }));
|
|
4938
5047
|
}
|
|
4939
|
-
const Jt =
|
|
5048
|
+
const Jt = bt && k._hasLayoutAffectingStyles({
|
|
4940
5049
|
stylesList: [
|
|
4941
5050
|
Z,
|
|
4942
|
-
|
|
5051
|
+
nt,
|
|
4943
5052
|
F
|
|
4944
5053
|
]
|
|
4945
5054
|
});
|
|
4946
|
-
|
|
5055
|
+
bt && (o.dirty = !0), Jt && (o.initDimensions(), o.dirty = !0), (T !== void 0 || M !== void 0 || C !== void 0 || E !== void 0 || z !== void 0 || x !== void 0 || N !== void 0 || Y !== void 0 || V !== void 0 || Q !== void 0) && (o.dirty = !0);
|
|
4947
5056
|
const qt = k._hasLayoutAffectingStyles({
|
|
4948
5057
|
stylesList: [
|
|
4949
5058
|
R,
|
|
4950
5059
|
Z,
|
|
4951
|
-
|
|
5060
|
+
nt,
|
|
4952
5061
|
F
|
|
4953
5062
|
]
|
|
4954
|
-
}), $t = !Object.prototype.hasOwnProperty.call(R, "width") && (
|
|
4955
|
-
let
|
|
4956
|
-
$t && (
|
|
5063
|
+
}), $t = !Object.prototype.hasOwnProperty.call(R, "width") && (rt || Nt || qt);
|
|
5064
|
+
let dt = !1;
|
|
5065
|
+
$t && (dt = this._autoExpandTextboxWidth(o, {
|
|
4957
5066
|
anchor: l
|
|
4958
|
-
}),
|
|
5067
|
+
}), dt && (o.dirty = !0)), (dt ? !1 : k._roundTextboxDimensions({ textbox: o })) && (o.dirty = !0), o.setCoords(), n || a.requestRenderAll(), i.resumeHistory(), s || i.saveState();
|
|
4959
5068
|
const te = k._getSnapshot(o);
|
|
4960
5069
|
return a.fire("editor:text-updated", {
|
|
4961
5070
|
textbox: o,
|
|
@@ -4983,7 +5092,7 @@ class k {
|
|
|
4983
5092
|
* Возвращает активный текст или ищет по id.
|
|
4984
5093
|
*/
|
|
4985
5094
|
_resolveTextObject(t) {
|
|
4986
|
-
if (t instanceof
|
|
5095
|
+
if (t instanceof it) return t;
|
|
4987
5096
|
const { canvas: e } = this;
|
|
4988
5097
|
if (!t) {
|
|
4989
5098
|
const s = e.getActiveObject();
|
|
@@ -4999,7 +5108,7 @@ class k {
|
|
|
4999
5108
|
* Проверяет, является ли объект текстовым блоком редактора.
|
|
5000
5109
|
*/
|
|
5001
5110
|
static _isTextbox(t) {
|
|
5002
|
-
return !!t && t instanceof
|
|
5111
|
+
return !!t && t instanceof it;
|
|
5003
5112
|
}
|
|
5004
5113
|
/**
|
|
5005
5114
|
* Вешает обработчики событий Fabric для работы с текстом.
|
|
@@ -5013,7 +5122,7 @@ class k {
|
|
|
5013
5122
|
* но не шире монтажной области, и удерживает объект в её пределах.
|
|
5014
5123
|
*/
|
|
5015
5124
|
_autoExpandTextboxWidth(t, { anchor: e } = {}) {
|
|
5016
|
-
var I,
|
|
5125
|
+
var I, S, T, M, C, E, z, x, N, Y, V, Q, H;
|
|
5017
5126
|
const { montageArea: s } = this.editor;
|
|
5018
5127
|
if (!s) return !1;
|
|
5019
5128
|
const n = typeof t.text == "string" ? t.text : "";
|
|
@@ -5021,7 +5130,7 @@ class k {
|
|
|
5021
5130
|
s.setCoords();
|
|
5022
5131
|
const o = s.getBoundingRect(!1, !0), i = (I = o.width) != null ? I : 0;
|
|
5023
5132
|
if (!Number.isFinite(i) || i <= 0) return !1;
|
|
5024
|
-
const a = e != null ? e : (
|
|
5133
|
+
const a = e != null ? e : (S = this.editingAnchorState) == null ? void 0 : S.get(t), r = (M = (T = a == null ? void 0 : a.originY) != null ? T : t.originY) != null ? M : "top", c = Math.abs((C = t.scaleX) != null ? C : 1) || 1, d = (E = t.paddingLeft) != null ? E : 0, l = (z = t.paddingRight) != null ? z : 0, u = (x = t.strokeWidth) != null ? x : 0, f = Math.max(
|
|
5025
5134
|
1,
|
|
5026
5135
|
i / c - d - l - u
|
|
5027
5136
|
);
|
|
@@ -5029,18 +5138,18 @@ class k {
|
|
|
5029
5138
|
const g = n.split(`
|
|
5030
5139
|
`).length;
|
|
5031
5140
|
let p = !1;
|
|
5032
|
-
Math.abs(((
|
|
5033
|
-
const { textLines: m } = t, v = Array.isArray(m) && m.length > g,
|
|
5141
|
+
Math.abs(((N = t.width) != null ? N : 0) - f) > tt && (t.set({ width: f }), p = !0), t.initDimensions();
|
|
5142
|
+
const { textLines: m } = t, v = Array.isArray(m) && m.length > g, w = Math.ceil(
|
|
5034
5143
|
k._getLongestLineWidth({ textbox: t, text: n })
|
|
5035
5144
|
), A = Math.min((Y = t.minWidth) != null ? Y : 1, f);
|
|
5036
5145
|
let y = Math.min(
|
|
5037
5146
|
f,
|
|
5038
|
-
Math.max(
|
|
5147
|
+
Math.max(w, A)
|
|
5039
5148
|
);
|
|
5040
|
-
v && (y = f), Math.abs(((
|
|
5149
|
+
v && (y = f), Math.abs(((V = t.width) != null ? V : 0) - y) > tt && (t.set({ width: y }), t.initDimensions(), p = !0), k._roundTextboxDimensions({ textbox: t }) && (p = !0), a && (t.setPositionByOrigin(new et(a.x, a.y), "center", r), p = !0);
|
|
5041
5150
|
const j = k._clampTextboxToMontage({
|
|
5042
5151
|
textbox: t,
|
|
5043
|
-
montageLeft: (
|
|
5152
|
+
montageLeft: (Q = o.left) != null ? Q : 0,
|
|
5044
5153
|
montageRight: ((H = o.left) != null ? H : 0) + i
|
|
5045
5154
|
});
|
|
5046
5155
|
return p || j;
|
|
@@ -5072,10 +5181,10 @@ class k {
|
|
|
5072
5181
|
var c, d, l, u;
|
|
5073
5182
|
t.setCoords();
|
|
5074
5183
|
const n = t.getBoundingRect(!1, !0), o = (c = n.left) != null ? c : 0, i = o + ((d = n.width) != null ? d : 0), a = s - e;
|
|
5075
|
-
if (a > 0 && ((l = n.width) != null ? l : 0) >= a -
|
|
5184
|
+
if (a > 0 && ((l = n.width) != null ? l : 0) >= a - tt)
|
|
5076
5185
|
return !1;
|
|
5077
5186
|
let r = 0;
|
|
5078
|
-
return o < e ? r = e - o : i > s && (r = s - i), Math.abs(r) <=
|
|
5187
|
+
return o < e ? r = e - o : i > s && (r = s - i), Math.abs(r) <= tt ? !1 : (t.set({ left: ((u = t.left) != null ? u : 0) + r }), !0);
|
|
5079
5188
|
}
|
|
5080
5189
|
/**
|
|
5081
5190
|
* Обрабатывает изменение ширины текстового объекта (resizing).
|
|
@@ -5097,7 +5206,7 @@ class k {
|
|
|
5097
5206
|
e.set({ width: r });
|
|
5098
5207
|
const c = (u = e.width) != null ? u : 0, d = a - c;
|
|
5099
5208
|
if (d !== 0 && s && s.corner === "ml") {
|
|
5100
|
-
const
|
|
5209
|
+
const w = ((f = e.angle) != null ? f : 0) * Math.PI / 180, A = Math.cos(w), y = Math.sin(w), b = (g = e.scaleX) != null ? g : 1, j = d * b;
|
|
5101
5210
|
e.set({
|
|
5102
5211
|
left: ((p = e.left) != null ? p : 0) + j * A,
|
|
5103
5212
|
top: ((m = e.top) != null ? m : 0) + j * y
|
|
@@ -5234,8 +5343,8 @@ class k {
|
|
|
5234
5343
|
snapshot: R,
|
|
5235
5344
|
entries: O
|
|
5236
5345
|
}) => {
|
|
5237
|
-
Object.entries(O).forEach(([
|
|
5238
|
-
Z != null && (R[
|
|
5346
|
+
Object.entries(O).forEach(([at, Z]) => {
|
|
5347
|
+
Z != null && (R[at] = Z);
|
|
5239
5348
|
});
|
|
5240
5349
|
}, {
|
|
5241
5350
|
id: s,
|
|
@@ -5253,23 +5362,23 @@ class k {
|
|
|
5253
5362
|
stroke: p,
|
|
5254
5363
|
strokeWidth: m,
|
|
5255
5364
|
opacity: v,
|
|
5256
|
-
backgroundColor:
|
|
5365
|
+
backgroundColor: w,
|
|
5257
5366
|
backgroundOpacity: A,
|
|
5258
5367
|
paddingTop: y,
|
|
5259
5368
|
paddingRight: b,
|
|
5260
5369
|
paddingBottom: j,
|
|
5261
5370
|
paddingLeft: I,
|
|
5262
|
-
radiusTopLeft:
|
|
5371
|
+
radiusTopLeft: S,
|
|
5263
5372
|
radiusTopRight: T,
|
|
5264
5373
|
radiusBottomRight: M,
|
|
5265
5374
|
radiusBottomLeft: C,
|
|
5266
5375
|
left: E,
|
|
5267
|
-
top:
|
|
5268
|
-
width:
|
|
5269
|
-
height:
|
|
5376
|
+
top: z,
|
|
5377
|
+
width: x,
|
|
5378
|
+
height: N,
|
|
5270
5379
|
angle: Y,
|
|
5271
|
-
scaleX:
|
|
5272
|
-
scaleY:
|
|
5380
|
+
scaleX: V,
|
|
5381
|
+
scaleY: Q
|
|
5273
5382
|
} = t, H = {
|
|
5274
5383
|
id: s,
|
|
5275
5384
|
uppercase: !!i,
|
|
@@ -5290,23 +5399,23 @@ class k {
|
|
|
5290
5399
|
stroke: p,
|
|
5291
5400
|
strokeWidth: m,
|
|
5292
5401
|
opacity: v,
|
|
5293
|
-
backgroundColor:
|
|
5402
|
+
backgroundColor: w,
|
|
5294
5403
|
backgroundOpacity: A,
|
|
5295
5404
|
paddingTop: y,
|
|
5296
5405
|
paddingRight: b,
|
|
5297
5406
|
paddingBottom: j,
|
|
5298
5407
|
paddingLeft: I,
|
|
5299
|
-
radiusTopLeft:
|
|
5408
|
+
radiusTopLeft: S,
|
|
5300
5409
|
radiusTopRight: T,
|
|
5301
5410
|
radiusBottomRight: M,
|
|
5302
5411
|
radiusBottomLeft: C,
|
|
5303
5412
|
left: E,
|
|
5304
|
-
top:
|
|
5305
|
-
width:
|
|
5306
|
-
height:
|
|
5413
|
+
top: z,
|
|
5414
|
+
width: x,
|
|
5415
|
+
height: N,
|
|
5307
5416
|
angle: Y,
|
|
5308
|
-
scaleX:
|
|
5309
|
-
scaleY:
|
|
5417
|
+
scaleX: V,
|
|
5418
|
+
scaleY: Q
|
|
5310
5419
|
}
|
|
5311
5420
|
}), H;
|
|
5312
5421
|
}
|
|
@@ -5318,7 +5427,7 @@ class k {
|
|
|
5318
5427
|
return (e = (t = this.fonts[0]) == null ? void 0 : t.family) != null ? e : "Arial";
|
|
5319
5428
|
}
|
|
5320
5429
|
}
|
|
5321
|
-
const
|
|
5430
|
+
const J = ({
|
|
5322
5431
|
value: h,
|
|
5323
5432
|
fallback: t = 0
|
|
5324
5433
|
}) => typeof h == "number" && Number.isFinite(h) ? h : typeof t == "number" && Number.isFinite(t) ? t : 0, ae = ({
|
|
@@ -5326,7 +5435,7 @@ const Q = ({
|
|
|
5326
5435
|
dimension: t,
|
|
5327
5436
|
useRelativePositions: e
|
|
5328
5437
|
}) => {
|
|
5329
|
-
const s =
|
|
5438
|
+
const s = J({ value: h });
|
|
5330
5439
|
return e ? s : s / (t || 1);
|
|
5331
5440
|
}, ln = ({
|
|
5332
5441
|
object: h,
|
|
@@ -5357,7 +5466,7 @@ const Q = ({
|
|
|
5357
5466
|
value: r,
|
|
5358
5467
|
dimension: e,
|
|
5359
5468
|
useRelativePositions: s
|
|
5360
|
-
}), f =
|
|
5469
|
+
}), f = J({ value: c }) / (t || 1), g = J({ value: d }) / (e || 1);
|
|
5361
5470
|
return {
|
|
5362
5471
|
x: l + f / 2,
|
|
5363
5472
|
y: u + g / 2
|
|
@@ -5372,10 +5481,10 @@ const Q = ({
|
|
|
5372
5481
|
const { left: o, top: i, width: a, height: r } = e;
|
|
5373
5482
|
if (!n) {
|
|
5374
5483
|
const { width: l, height: u } = s, f = o + h * (l || a), g = i + t * (u || r);
|
|
5375
|
-
return new
|
|
5484
|
+
return new et(f, g);
|
|
5376
5485
|
}
|
|
5377
5486
|
const c = o + h * a, d = i + t * r;
|
|
5378
|
-
return new
|
|
5487
|
+
return new et(c, d);
|
|
5379
5488
|
}, un = ({
|
|
5380
5489
|
object: h,
|
|
5381
5490
|
montageArea: t,
|
|
@@ -5391,7 +5500,7 @@ const Q = ({
|
|
|
5391
5500
|
} catch (s) {
|
|
5392
5501
|
return null;
|
|
5393
5502
|
}
|
|
5394
|
-
},
|
|
5503
|
+
}, yt = ({
|
|
5395
5504
|
object: h
|
|
5396
5505
|
}) => {
|
|
5397
5506
|
if (!h) return null;
|
|
@@ -5455,7 +5564,7 @@ const Q = ({
|
|
|
5455
5564
|
};
|
|
5456
5565
|
}
|
|
5457
5566
|
return null;
|
|
5458
|
-
},
|
|
5567
|
+
}, Xt = "_templateCenterX", me = "_templateCenterY", re = "_templateAnchorX", ye = "_templateAnchorY";
|
|
5459
5568
|
class _ {
|
|
5460
5569
|
constructor({ editor: t }) {
|
|
5461
5570
|
this.editor = t;
|
|
@@ -5480,25 +5589,25 @@ class _ {
|
|
|
5480
5589
|
return a.emitWarning({
|
|
5481
5590
|
origin: "TemplateManager",
|
|
5482
5591
|
method: "serializeSelection",
|
|
5483
|
-
code:
|
|
5592
|
+
code: At.TEMPLATE_MANAGER.NO_OBJECTS_SELECTED,
|
|
5484
5593
|
message: "Нет объектов для сериализации шаблона"
|
|
5485
5594
|
}), null;
|
|
5486
|
-
const g = _._getBounds(i), p = _._getMontageSize({ montageArea: i, bounds: g }), m = p.width, v = p.height,
|
|
5595
|
+
const g = _._getBounds(i), p = _._getMontageSize({ montageArea: i, bounds: g }), m = p.width, v = p.height, w = f.map((b) => _._serializeObject({
|
|
5487
5596
|
object: b,
|
|
5488
5597
|
bounds: g,
|
|
5489
5598
|
baseWidth: m,
|
|
5490
5599
|
baseHeight: v,
|
|
5491
5600
|
montageArea: i != null ? i : null
|
|
5492
|
-
})), A =
|
|
5601
|
+
})), A = St(B({}, s), {
|
|
5493
5602
|
baseWidth: m,
|
|
5494
5603
|
baseHeight: v,
|
|
5495
5604
|
positionsNormalized: !0,
|
|
5496
5605
|
previewId: e != null ? e : s.previewId
|
|
5497
5606
|
});
|
|
5498
5607
|
return {
|
|
5499
|
-
id: t != null ? t : `template-${
|
|
5608
|
+
id: t != null ? t : `template-${X()}`,
|
|
5500
5609
|
meta: A,
|
|
5501
|
-
objects:
|
|
5610
|
+
objects: w
|
|
5502
5611
|
};
|
|
5503
5612
|
}
|
|
5504
5613
|
/**
|
|
@@ -5508,7 +5617,7 @@ class _ {
|
|
|
5508
5617
|
* @param options.data - данные для заполнения текстов по customData.templateField
|
|
5509
5618
|
*/
|
|
5510
5619
|
applyTemplate(s) {
|
|
5511
|
-
return
|
|
5620
|
+
return P(this, arguments, function* ({
|
|
5512
5621
|
template: t,
|
|
5513
5622
|
data: e
|
|
5514
5623
|
}) {
|
|
@@ -5523,7 +5632,7 @@ class _ {
|
|
|
5523
5632
|
return a.emitWarning({
|
|
5524
5633
|
origin: "TemplateManager",
|
|
5525
5634
|
method: "applyTemplate",
|
|
5526
|
-
code:
|
|
5635
|
+
code: At.TEMPLATE_MANAGER.INVALID_TEMPLATE,
|
|
5527
5636
|
message: "Шаблон не содержит объектов"
|
|
5528
5637
|
}), null;
|
|
5529
5638
|
const u = _._getBounds(o);
|
|
@@ -5531,11 +5640,11 @@ class _ {
|
|
|
5531
5640
|
return a.emitWarning({
|
|
5532
5641
|
origin: "TemplateManager",
|
|
5533
5642
|
method: "applyTemplate",
|
|
5534
|
-
code:
|
|
5643
|
+
code: At.TEMPLATE_MANAGER.INVALID_TARGET,
|
|
5535
5644
|
message: "Не удалось определить границы монтажной области"
|
|
5536
5645
|
}), null;
|
|
5537
5646
|
const f = _._getMontageSize({ montageArea: o, bounds: u }), g = _._normalizeMeta({ meta: d, fallback: f }), p = _._calculateScale({ meta: g, target: f }), m = !!g.positionsNormalized;
|
|
5538
|
-
let v = !1,
|
|
5647
|
+
let v = !1, w = !1;
|
|
5539
5648
|
i.suspendHistory();
|
|
5540
5649
|
try {
|
|
5541
5650
|
const A = yield _._enlivenObjects(c);
|
|
@@ -5543,11 +5652,11 @@ class _ {
|
|
|
5543
5652
|
return a.emitWarning({
|
|
5544
5653
|
origin: "TemplateManager",
|
|
5545
5654
|
method: "applyTemplate",
|
|
5546
|
-
code:
|
|
5655
|
+
code: At.TEMPLATE_MANAGER.INVALID_TEMPLATE,
|
|
5547
5656
|
message: "Не удалось создать объекты шаблона"
|
|
5548
5657
|
}), null;
|
|
5549
5658
|
const { backgroundObject: y, contentObjects: b } = _._extractBackgroundObject(A);
|
|
5550
|
-
y && (
|
|
5659
|
+
y && (w = yield _._applyBackgroundFromObject({
|
|
5551
5660
|
backgroundObject: y,
|
|
5552
5661
|
backgroundManager: r,
|
|
5553
5662
|
errorManager: a
|
|
@@ -5565,10 +5674,10 @@ class _ {
|
|
|
5565
5674
|
montageArea: o,
|
|
5566
5675
|
useRelativePositions: m
|
|
5567
5676
|
}), I.set({
|
|
5568
|
-
id: `${I.type}-${
|
|
5677
|
+
id: `${I.type}-${X()}`,
|
|
5569
5678
|
evented: !0
|
|
5570
5679
|
}), n.add(I), I));
|
|
5571
|
-
return !j.length && !
|
|
5680
|
+
return !j.length && !w ? null : (v = j.length > 0 || w, j.length && _._activateObjects({ canvas: n, objects: j }), n.requestRenderAll(), n.fire("editor:template-applied", {
|
|
5572
5681
|
template: t,
|
|
5573
5682
|
objects: j,
|
|
5574
5683
|
bounds: u
|
|
@@ -5577,7 +5686,7 @@ class _ {
|
|
|
5577
5686
|
return a.emitError({
|
|
5578
5687
|
origin: "TemplateManager",
|
|
5579
5688
|
method: "applyTemplate",
|
|
5580
|
-
code:
|
|
5689
|
+
code: At.TEMPLATE_MANAGER.APPLY_FAILED,
|
|
5581
5690
|
message: "Ошибка применения шаблона",
|
|
5582
5691
|
data: {
|
|
5583
5692
|
templateId: l,
|
|
@@ -5617,14 +5726,14 @@ class _ {
|
|
|
5617
5726
|
* Превращает plain-описание объектов в Fabric объекты.
|
|
5618
5727
|
*/
|
|
5619
5728
|
static _enlivenObjects(t) {
|
|
5620
|
-
return
|
|
5621
|
-
return (yield Promise.all(t.map((s) =>
|
|
5729
|
+
return P(this, null, function* () {
|
|
5730
|
+
return (yield Promise.all(t.map((s) => P(null, null, function* () {
|
|
5622
5731
|
if (_._hasSerializedSvgMarkup(s)) {
|
|
5623
5732
|
const i = yield _._reviveSvgObject(s);
|
|
5624
5733
|
if (i)
|
|
5625
5734
|
return _._restoreImageScale({ revived: i, serialized: s }), i;
|
|
5626
5735
|
}
|
|
5627
|
-
const n = yield
|
|
5736
|
+
const n = yield ft.enlivenObjects([s]), o = n == null ? void 0 : n[0];
|
|
5628
5737
|
return o ? (_._restoreImageScale({ revived: o, serialized: s }), o) : null;
|
|
5629
5738
|
})))).filter((s) => !!s);
|
|
5630
5739
|
});
|
|
@@ -5653,22 +5762,22 @@ class _ {
|
|
|
5653
5762
|
naturalHeight: 0,
|
|
5654
5763
|
width: 0,
|
|
5655
5764
|
height: 0
|
|
5656
|
-
}, p =
|
|
5657
|
-
if (I && (E.width = p),
|
|
5765
|
+
}, p = J({ value: l || f || c.width, fallback: 0 }), m = J({ value: u || g || c.height, fallback: 0 }), v = J({ value: n, fallback: p }), w = J({ value: o, fallback: m }), A = J({ value: i, fallback: c.scaleX || 1 }), y = J({ value: a, fallback: c.scaleY || 1 }), b = v * A, j = w * y, I = p > 0, S = m > 0, T = b > 0, M = j > 0, C = _._resolveImageFit({ customData: r }), E = {};
|
|
5766
|
+
if (I && (E.width = p), S && (E.height = m), !I || !S) {
|
|
5658
5767
|
c.set(E);
|
|
5659
5768
|
return;
|
|
5660
5769
|
}
|
|
5661
5770
|
if (C === "stretch") {
|
|
5662
|
-
const
|
|
5663
|
-
|
|
5771
|
+
const x = T ? b / p : null, N = M ? j / m : null;
|
|
5772
|
+
x && x > 0 && (E.scaleX = x), N && N > 0 && (E.scaleY = N), c.set(E);
|
|
5664
5773
|
return;
|
|
5665
5774
|
}
|
|
5666
5775
|
if (!T || !M) {
|
|
5667
5776
|
c.set(E);
|
|
5668
5777
|
return;
|
|
5669
5778
|
}
|
|
5670
|
-
const
|
|
5671
|
-
Number.isFinite(
|
|
5779
|
+
const z = Math.min(b / p, j / m);
|
|
5780
|
+
Number.isFinite(z) && z > 0 && (E.scaleX = z, E.scaleY = z), c.set(E);
|
|
5672
5781
|
}
|
|
5673
5782
|
/**
|
|
5674
5783
|
* Определяет режим вписывания изображения при восстановлении.
|
|
@@ -5690,11 +5799,11 @@ class _ {
|
|
|
5690
5799
|
* Восстанавливает SVG-объект из компактного описания.
|
|
5691
5800
|
*/
|
|
5692
5801
|
static _reviveSvgObject(t) {
|
|
5693
|
-
return
|
|
5802
|
+
return P(this, null, function* () {
|
|
5694
5803
|
const e = typeof t.svgMarkup == "string" ? t.svgMarkup : null;
|
|
5695
5804
|
if (!e) return null;
|
|
5696
5805
|
try {
|
|
5697
|
-
const s = yield ys(e), n =
|
|
5806
|
+
const s = yield ys(e), n = ft.groupSVGElements(s.objects, s.options), o = yield ft.enlivenObjectEnlivables(
|
|
5698
5807
|
_._prepareSerializableProps(t)
|
|
5699
5808
|
);
|
|
5700
5809
|
return n.set(o), n.setCoords(), n;
|
|
@@ -5759,10 +5868,10 @@ class _ {
|
|
|
5759
5868
|
baseHeight: i,
|
|
5760
5869
|
useRelativePositions: r,
|
|
5761
5870
|
centerKeys: {
|
|
5762
|
-
x:
|
|
5871
|
+
x: Xt,
|
|
5763
5872
|
y: me
|
|
5764
5873
|
}
|
|
5765
|
-
}), { scaleX: u, scaleY: f } = t, g =
|
|
5874
|
+
}), { scaleX: u, scaleY: f } = t, g = J({ value: u, fallback: 1 }), p = J({ value: f, fallback: 1 }), m = _._getPositioningBounds({
|
|
5766
5875
|
bounds: s,
|
|
5767
5876
|
baseWidth: o,
|
|
5768
5877
|
baseHeight: i,
|
|
@@ -5776,11 +5885,11 @@ class _ {
|
|
|
5776
5885
|
bounds: m,
|
|
5777
5886
|
targetSize: n,
|
|
5778
5887
|
montageArea: a
|
|
5779
|
-
}),
|
|
5888
|
+
}), w = g * e, A = p * e;
|
|
5780
5889
|
t.set({
|
|
5781
|
-
scaleX:
|
|
5890
|
+
scaleX: w,
|
|
5782
5891
|
scaleY: A
|
|
5783
|
-
}), t.setPositionByOrigin(v, "center", "center"), t.setCoords(), delete c[
|
|
5892
|
+
}), t.setPositionByOrigin(v, "center", "center"), t.setCoords(), delete c[Xt], delete c[me], delete c[re], delete c[ye];
|
|
5784
5893
|
}
|
|
5785
5894
|
/**
|
|
5786
5895
|
* Возвращает bounds, в которых должны позиционироваться нормализованные объекты.
|
|
@@ -5827,7 +5936,7 @@ class _ {
|
|
|
5827
5936
|
meta: t,
|
|
5828
5937
|
fallback: e
|
|
5829
5938
|
}) {
|
|
5830
|
-
const { width: s, height: n } = e, r = t || {}, { baseWidth: o = s, baseHeight: i = n } = r, a =
|
|
5939
|
+
const { width: s, height: n } = e, r = t || {}, { baseWidth: o = s, baseHeight: i = n } = r, a = pt(r, ["baseWidth", "baseHeight"]);
|
|
5831
5940
|
return B({
|
|
5832
5941
|
baseWidth: o,
|
|
5833
5942
|
baseHeight: i
|
|
@@ -5865,30 +5974,30 @@ class _ {
|
|
|
5865
5974
|
object: t,
|
|
5866
5975
|
baseWidth: e
|
|
5867
5976
|
}) {
|
|
5868
|
-
var Y,
|
|
5869
|
-
if (!(t instanceof
|
|
5977
|
+
var Y, V;
|
|
5978
|
+
if (!(t instanceof it)) return;
|
|
5870
5979
|
const s = typeof t.text == "string" ? t.text : "";
|
|
5871
5980
|
if (!s) return;
|
|
5872
|
-
const n =
|
|
5873
|
-
value: (
|
|
5981
|
+
const n = J({
|
|
5982
|
+
value: (V = (Y = this.editor) == null ? void 0 : Y.montageArea) == null ? void 0 : V.width,
|
|
5874
5983
|
fallback: 0
|
|
5875
5984
|
}), {
|
|
5876
5985
|
width: o = 0,
|
|
5877
5986
|
scaleX: i = 1,
|
|
5878
5987
|
strokeWidth: a = 0
|
|
5879
|
-
} = t, r =
|
|
5988
|
+
} = t, r = J({ value: e, fallback: 0 }), c = t, d = J({ value: c.paddingLeft, fallback: 0 }), l = J({ value: c.paddingRight, fallback: 0 }), u = J({ value: i, fallback: 1 }), f = J({ value: a, fallback: 0 }) * u, g = J({ value: o, fallback: 0 }), p = g * u, m = d * u, v = l * u, w = p + m + v + f;
|
|
5880
5989
|
if (!n || !g || !r) return;
|
|
5881
5990
|
t.setCoords();
|
|
5882
|
-
const A = t, y = A[
|
|
5991
|
+
const A = t, y = A[Xt], b = typeof y == "number" ? y : null, j = _._resolveAnchor(A, re), I = w / r, S = b !== null ? b - I / 2 : null, T = b !== null ? b + I / 2 : null, M = t.getCenterPoint();
|
|
5883
5992
|
t.set("width", n), t.initDimensions();
|
|
5884
5993
|
const C = _._getLongestLineWidth({
|
|
5885
5994
|
textbox: t,
|
|
5886
5995
|
text: s
|
|
5887
5996
|
}), E = C > g ? C + 1 : g;
|
|
5888
5997
|
t.set("width", E), t.initDimensions(), t.setPositionByOrigin(M, "center", "center"), t.setCoords();
|
|
5889
|
-
const
|
|
5890
|
-
let
|
|
5891
|
-
j === "start" &&
|
|
5998
|
+
const x = (E * u + m + v + f) / r;
|
|
5999
|
+
let N = b;
|
|
6000
|
+
j === "start" && S !== null ? N = Math.max(0, S) + x / 2 : j === "end" && T !== null && (N = Math.min(1, T) - x / 2), typeof N == "number" && (A[Xt] = N);
|
|
5892
6001
|
}
|
|
5893
6002
|
/**
|
|
5894
6003
|
* Возвращает ширину самой длинной строки текстового объекта.
|
|
@@ -5939,11 +6048,11 @@ class _ {
|
|
|
5939
6048
|
x: (y.x - a) / u,
|
|
5940
6049
|
y: (y.y - r) / f
|
|
5941
6050
|
};
|
|
5942
|
-
})(), m = (l.left - a) / u, v = (l.top - r) / f,
|
|
5943
|
-
return i[
|
|
6051
|
+
})(), m = (l.left - a) / u, v = (l.top - r) / f, w = m + l.width / u, A = v + l.height / f;
|
|
6052
|
+
return i[Xt] = p.x, i[me] = p.y, i[re] = _._detectAnchor({
|
|
5944
6053
|
center: p.x,
|
|
5945
6054
|
start: m,
|
|
5946
|
-
end:
|
|
6055
|
+
end: w
|
|
5947
6056
|
}), i[ye] = _._detectAnchor({
|
|
5948
6057
|
center: p.y,
|
|
5949
6058
|
start: v,
|
|
@@ -5964,7 +6073,7 @@ class _ {
|
|
|
5964
6073
|
* Применяет фоновый объект шаблона к текущему холсту через BackgroundManager.
|
|
5965
6074
|
*/
|
|
5966
6075
|
static _applyBackgroundFromObject(n) {
|
|
5967
|
-
return
|
|
6076
|
+
return P(this, arguments, function* ({
|
|
5968
6077
|
backgroundObject: t,
|
|
5969
6078
|
backgroundManager: e,
|
|
5970
6079
|
errorManager: s
|
|
@@ -6002,7 +6111,7 @@ class _ {
|
|
|
6002
6111
|
s.emitWarning({
|
|
6003
6112
|
origin: "TemplateManager",
|
|
6004
6113
|
method: "applyTemplate",
|
|
6005
|
-
code:
|
|
6114
|
+
code: At.TEMPLATE_MANAGER.APPLY_FAILED,
|
|
6006
6115
|
message: "Не удалось применить фон из шаблона",
|
|
6007
6116
|
data: o
|
|
6008
6117
|
});
|
|
@@ -6058,7 +6167,7 @@ class _ {
|
|
|
6058
6167
|
*/
|
|
6059
6168
|
// eslint-disable-next-line class-methods-use-this
|
|
6060
6169
|
enlivenObjectEnlivables(t) {
|
|
6061
|
-
return
|
|
6170
|
+
return ft.enlivenObjectEnlivables(t);
|
|
6062
6171
|
}
|
|
6063
6172
|
}
|
|
6064
6173
|
const pn = 5, os = "#3D8BF4", Ae = 1, ce = 1, Je = ({
|
|
@@ -6198,8 +6307,8 @@ const pn = 5, os = "#3D8BF4", Ae = 1, ce = 1, Je = ({
|
|
|
6198
6307
|
return { delta: 0, guide: null };
|
|
6199
6308
|
const u = d[l - 1], f = d[l - 2], g = d[l + 1], p = d[l + 2], m = [], v = i - o;
|
|
6200
6309
|
if (u && f) {
|
|
6201
|
-
const { bounds: y } = u, { bounds: b } = f, j = y.top - b.bottom, I = o - y.bottom,
|
|
6202
|
-
if (
|
|
6310
|
+
const { bounds: y } = u, { bounds: b } = f, j = y.top - b.bottom, I = o - y.bottom, S = Math.abs(I - j);
|
|
6311
|
+
if (S <= e) {
|
|
6203
6312
|
const T = j - I, M = o + T, C = {
|
|
6204
6313
|
type: "vertical",
|
|
6205
6314
|
axis: n,
|
|
@@ -6209,12 +6318,12 @@ const pn = 5, os = "#3D8BF4", Ae = 1, ce = 1, Je = ({
|
|
|
6209
6318
|
activeEnd: M,
|
|
6210
6319
|
distance: j
|
|
6211
6320
|
};
|
|
6212
|
-
m.push({ delta: T, guide: C, diff:
|
|
6321
|
+
m.push({ delta: T, guide: C, diff: S });
|
|
6213
6322
|
}
|
|
6214
6323
|
}
|
|
6215
6324
|
if (g && p) {
|
|
6216
|
-
const { bounds: y } = g, { bounds: b } = p, j = b.top - y.bottom, I = y.top - i,
|
|
6217
|
-
if (
|
|
6325
|
+
const { bounds: y } = g, { bounds: b } = p, j = b.top - y.bottom, I = y.top - i, S = Math.abs(I - j);
|
|
6326
|
+
if (S <= e) {
|
|
6218
6327
|
const T = I - j, M = i + T, C = {
|
|
6219
6328
|
type: "vertical",
|
|
6220
6329
|
axis: n,
|
|
@@ -6224,35 +6333,35 @@ const pn = 5, os = "#3D8BF4", Ae = 1, ce = 1, Je = ({
|
|
|
6224
6333
|
activeEnd: y.top,
|
|
6225
6334
|
distance: j
|
|
6226
6335
|
};
|
|
6227
|
-
m.push({ delta: T, guide: C, diff:
|
|
6336
|
+
m.push({ delta: T, guide: C, diff: S });
|
|
6228
6337
|
}
|
|
6229
6338
|
}
|
|
6230
6339
|
if (u && g) {
|
|
6231
6340
|
const { bounds: y } = u, { bounds: b } = g, I = b.top - y.bottom - v;
|
|
6232
6341
|
if (I >= 0) {
|
|
6233
|
-
const
|
|
6234
|
-
if (
|
|
6235
|
-
const
|
|
6342
|
+
const S = I / 2, T = o - y.bottom, M = b.top - i, C = Math.abs(T - S), E = Math.abs(M - S), z = Math.max(C, E);
|
|
6343
|
+
if (z <= e) {
|
|
6344
|
+
const x = S - T, N = i + x, Y = {
|
|
6236
6345
|
type: "vertical",
|
|
6237
6346
|
axis: n,
|
|
6238
6347
|
refStart: y.bottom,
|
|
6239
|
-
refEnd: y.bottom +
|
|
6240
|
-
activeStart:
|
|
6241
|
-
activeEnd:
|
|
6242
|
-
distance:
|
|
6348
|
+
refEnd: y.bottom + S,
|
|
6349
|
+
activeStart: N,
|
|
6350
|
+
activeEnd: N + S,
|
|
6351
|
+
distance: S
|
|
6243
6352
|
};
|
|
6244
|
-
m.push({ delta:
|
|
6353
|
+
m.push({ delta: x, guide: Y, diff: z });
|
|
6245
6354
|
}
|
|
6246
6355
|
}
|
|
6247
6356
|
}
|
|
6248
|
-
const
|
|
6357
|
+
const w = is({
|
|
6249
6358
|
activeBounds: h,
|
|
6250
6359
|
aligned: c,
|
|
6251
6360
|
threshold: e,
|
|
6252
6361
|
patterns: s,
|
|
6253
6362
|
type: "vertical"
|
|
6254
6363
|
});
|
|
6255
|
-
if (m.push(...
|
|
6364
|
+
if (m.push(...w), !m.length)
|
|
6256
6365
|
return { delta: 0, guide: null };
|
|
6257
6366
|
const A = m.reduce((y, b) => b.diff < y.diff ? b : y, m[0]);
|
|
6258
6367
|
return {
|
|
@@ -6284,8 +6393,8 @@ const pn = 5, os = "#3D8BF4", Ae = 1, ce = 1, Je = ({
|
|
|
6284
6393
|
return { delta: 0, guide: null };
|
|
6285
6394
|
const u = d[l - 1], f = d[l - 2], g = d[l + 1], p = d[l + 2], m = [], v = i - o;
|
|
6286
6395
|
if (u && f) {
|
|
6287
|
-
const { bounds: y } = u, { bounds: b } = f, j = y.left - b.right, I = o - y.right,
|
|
6288
|
-
if (
|
|
6396
|
+
const { bounds: y } = u, { bounds: b } = f, j = y.left - b.right, I = o - y.right, S = Math.abs(I - j);
|
|
6397
|
+
if (S <= e) {
|
|
6289
6398
|
const T = j - I, M = o + T, C = {
|
|
6290
6399
|
type: "horizontal",
|
|
6291
6400
|
axis: n,
|
|
@@ -6295,12 +6404,12 @@ const pn = 5, os = "#3D8BF4", Ae = 1, ce = 1, Je = ({
|
|
|
6295
6404
|
activeEnd: M,
|
|
6296
6405
|
distance: j
|
|
6297
6406
|
};
|
|
6298
|
-
m.push({ delta: T, guide: C, diff:
|
|
6407
|
+
m.push({ delta: T, guide: C, diff: S });
|
|
6299
6408
|
}
|
|
6300
6409
|
}
|
|
6301
6410
|
if (g && p) {
|
|
6302
|
-
const { bounds: y } = g, { bounds: b } = p, j = b.left - y.right, I = y.left - i,
|
|
6303
|
-
if (
|
|
6411
|
+
const { bounds: y } = g, { bounds: b } = p, j = b.left - y.right, I = y.left - i, S = Math.abs(I - j);
|
|
6412
|
+
if (S <= e) {
|
|
6304
6413
|
const T = I - j, M = i + T, C = {
|
|
6305
6414
|
type: "horizontal",
|
|
6306
6415
|
axis: n,
|
|
@@ -6310,35 +6419,35 @@ const pn = 5, os = "#3D8BF4", Ae = 1, ce = 1, Je = ({
|
|
|
6310
6419
|
activeEnd: y.left,
|
|
6311
6420
|
distance: j
|
|
6312
6421
|
};
|
|
6313
|
-
m.push({ delta: T, guide: C, diff:
|
|
6422
|
+
m.push({ delta: T, guide: C, diff: S });
|
|
6314
6423
|
}
|
|
6315
6424
|
}
|
|
6316
6425
|
if (u && g) {
|
|
6317
6426
|
const { bounds: y } = u, { bounds: b } = g, I = b.left - y.right - v;
|
|
6318
6427
|
if (I >= 0) {
|
|
6319
|
-
const
|
|
6320
|
-
if (
|
|
6321
|
-
const
|
|
6428
|
+
const S = I / 2, T = o - y.right, M = b.left - i, C = Math.abs(T - S), E = Math.abs(M - S), z = Math.max(C, E);
|
|
6429
|
+
if (z <= e) {
|
|
6430
|
+
const x = S - T, N = i + x, Y = {
|
|
6322
6431
|
type: "horizontal",
|
|
6323
6432
|
axis: n,
|
|
6324
6433
|
refStart: y.right,
|
|
6325
|
-
refEnd: y.right +
|
|
6326
|
-
activeStart:
|
|
6327
|
-
activeEnd:
|
|
6328
|
-
distance:
|
|
6434
|
+
refEnd: y.right + S,
|
|
6435
|
+
activeStart: N,
|
|
6436
|
+
activeEnd: N + S,
|
|
6437
|
+
distance: S
|
|
6329
6438
|
};
|
|
6330
|
-
m.push({ delta:
|
|
6439
|
+
m.push({ delta: x, guide: Y, diff: z });
|
|
6331
6440
|
}
|
|
6332
6441
|
}
|
|
6333
6442
|
}
|
|
6334
|
-
const
|
|
6443
|
+
const w = is({
|
|
6335
6444
|
activeBounds: h,
|
|
6336
6445
|
aligned: c,
|
|
6337
6446
|
threshold: e,
|
|
6338
6447
|
patterns: s,
|
|
6339
6448
|
type: "horizontal"
|
|
6340
6449
|
});
|
|
6341
|
-
if (m.push(...
|
|
6450
|
+
if (m.push(...w), !m.length)
|
|
6342
6451
|
return { delta: 0, guide: null };
|
|
6343
6452
|
const A = m.reduce((y, b) => b.diff < y.diff ? b : y, m[0]);
|
|
6344
6453
|
return {
|
|
@@ -6394,16 +6503,16 @@ const pn = 5, os = "#3D8BF4", Ae = 1, ce = 1, Je = ({
|
|
|
6394
6503
|
offsetAlongAxis: f = 0,
|
|
6395
6504
|
offsetPerpendicular: g = 0
|
|
6396
6505
|
}) => {
|
|
6397
|
-
const p = i || 1, m = 12 / p, v = l / p,
|
|
6506
|
+
const p = i || 1, m = 12 / p, v = l / p, w = u / p, A = (s + n) / 2 + f, y = t === "vertical" ? e + g : A, b = t === "vertical" ? A : e + g;
|
|
6398
6507
|
h.save(), h.setLineDash([]), h.fillStyle = a, h.strokeStyle = a, h.lineWidth = d / p, h.font = `${m}px ${c}`, h.textAlign = "center", h.textBaseline = "middle";
|
|
6399
|
-
const I = h.measureText(o).width + v * 2,
|
|
6508
|
+
const I = h.measureText(o).width + v * 2, S = m + v * 2, T = y - I / 2, M = b - S / 2;
|
|
6400
6509
|
h.beginPath(), Mn({
|
|
6401
6510
|
context: h,
|
|
6402
6511
|
x: T,
|
|
6403
6512
|
y: M,
|
|
6404
6513
|
width: I,
|
|
6405
|
-
height:
|
|
6406
|
-
radius:
|
|
6514
|
+
height: S,
|
|
6515
|
+
radius: w
|
|
6407
6516
|
}), h.fill(), h.fillStyle = r, h.fillText(o, y, b), h.restore();
|
|
6408
6517
|
}, wn = ({
|
|
6409
6518
|
context: h,
|
|
@@ -6468,8 +6577,8 @@ const pn = 5, os = "#3D8BF4", Ae = 1, ce = 1, Je = ({
|
|
|
6468
6577
|
for (let p = r + 1; p < a.length; p += 1) {
|
|
6469
6578
|
const m = a[p];
|
|
6470
6579
|
if (Math.min(c[i], m[i]) - Math.max(c[o], m[o]) < 0) continue;
|
|
6471
|
-
const
|
|
6472
|
-
|
|
6580
|
+
const w = m[e] - c[s];
|
|
6581
|
+
w < 0 || w < l && (l = w, d = m);
|
|
6473
6582
|
}
|
|
6474
6583
|
if (!d || l === Number.POSITIVE_INFINITY) continue;
|
|
6475
6584
|
const u = Math.max(c[o], d[o]), f = Math.min(c[i], d[i]), g = (u + f) / 2;
|
|
@@ -6571,7 +6680,7 @@ class jn {
|
|
|
6571
6680
|
return;
|
|
6572
6681
|
}
|
|
6573
6682
|
!this.anchors.vertical.length && !this.anchors.horizontal.length && this._cacheAnchors({ activeObject: e });
|
|
6574
|
-
let o =
|
|
6683
|
+
let o = yt({ object: e });
|
|
6575
6684
|
if (!o) {
|
|
6576
6685
|
this._clearGuides();
|
|
6577
6686
|
return;
|
|
@@ -6582,24 +6691,24 @@ class jn {
|
|
|
6582
6691
|
anchors: this.anchors
|
|
6583
6692
|
}), { deltaX: d, deltaY: l, guides: u } = c;
|
|
6584
6693
|
if (d !== 0 || l !== 0) {
|
|
6585
|
-
const { left: v = 0, top:
|
|
6694
|
+
const { left: v = 0, top: w = 0 } = e;
|
|
6586
6695
|
e.set({
|
|
6587
6696
|
left: v + d,
|
|
6588
|
-
top:
|
|
6589
|
-
}), e.setCoords(), o = (p =
|
|
6697
|
+
top: w + l
|
|
6698
|
+
}), e.setCoords(), o = (p = yt({ object: e })) != null ? p : o;
|
|
6590
6699
|
}
|
|
6591
|
-
const f = this.cachedTargetBounds.length ? this.cachedTargetBounds : this._collectTargets({ activeObject: e }).map((v) =>
|
|
6700
|
+
const f = this.cachedTargetBounds.length ? this.cachedTargetBounds : this._collectTargets({ activeObject: e }).map((v) => yt({ object: v })).filter((v) => !!v), g = bn({
|
|
6592
6701
|
activeBounds: o,
|
|
6593
6702
|
candidates: f,
|
|
6594
6703
|
threshold: r,
|
|
6595
6704
|
spacingPatterns: this.spacingPatterns
|
|
6596
6705
|
});
|
|
6597
6706
|
if (g.deltaX !== 0 || g.deltaY !== 0) {
|
|
6598
|
-
const { left: v = 0, top:
|
|
6707
|
+
const { left: v = 0, top: w = 0 } = e;
|
|
6599
6708
|
e.set({
|
|
6600
6709
|
left: v + g.deltaX,
|
|
6601
|
-
top:
|
|
6602
|
-
}), e.setCoords(), o = (m =
|
|
6710
|
+
top: w + g.deltaY
|
|
6711
|
+
}), e.setCoords(), o = (m = yt({ object: e })) != null ? m : o;
|
|
6603
6712
|
}
|
|
6604
6713
|
this._applyGuides({
|
|
6605
6714
|
guides: u,
|
|
@@ -6679,10 +6788,10 @@ class jn {
|
|
|
6679
6788
|
_cacheAnchors({ activeObject: t }) {
|
|
6680
6789
|
const e = this._collectTargets({ activeObject: t }), s = { vertical: [], horizontal: [] }, n = [];
|
|
6681
6790
|
for (const a of e) {
|
|
6682
|
-
const r =
|
|
6791
|
+
const r = yt({ object: a });
|
|
6683
6792
|
r && (qe({ anchors: s, bounds: r }), n.push(r));
|
|
6684
6793
|
}
|
|
6685
|
-
const { montageArea: o } = this.editor, i =
|
|
6794
|
+
const { montageArea: o } = this.editor, i = yt({ object: o });
|
|
6686
6795
|
if (i) {
|
|
6687
6796
|
qe({ anchors: s, bounds: i });
|
|
6688
6797
|
const { left: a, right: r, top: c, bottom: d } = i;
|
|
@@ -6726,7 +6835,7 @@ class jn {
|
|
|
6726
6835
|
}
|
|
6727
6836
|
}
|
|
6728
6837
|
const ts = "#3D8BF4", es = 1;
|
|
6729
|
-
class
|
|
6838
|
+
class Dt {
|
|
6730
6839
|
/**
|
|
6731
6840
|
* Создаёт менеджер измерений и инициализирует события.
|
|
6732
6841
|
*/
|
|
@@ -6831,15 +6940,15 @@ class Lt {
|
|
|
6831
6940
|
this._clearGuides();
|
|
6832
6941
|
return;
|
|
6833
6942
|
}
|
|
6834
|
-
const o =
|
|
6943
|
+
const o = yt({ object: n });
|
|
6835
6944
|
if (!o) {
|
|
6836
6945
|
this._clearGuides();
|
|
6837
6946
|
return;
|
|
6838
6947
|
}
|
|
6839
|
-
const i =
|
|
6948
|
+
const i = Dt._resolveTarget({
|
|
6840
6949
|
event: t,
|
|
6841
6950
|
activeObject: n
|
|
6842
|
-
}), { montageArea: a } = s, r = i != null ? i : a, c = r === a, d =
|
|
6951
|
+
}), { montageArea: a } = s, r = i != null ? i : a, c = r === a, d = yt({ object: r });
|
|
6843
6952
|
if (!d) {
|
|
6844
6953
|
this._clearGuides();
|
|
6845
6954
|
return;
|
|
@@ -6848,7 +6957,7 @@ class Lt {
|
|
|
6848
6957
|
this._clearGuides();
|
|
6849
6958
|
return;
|
|
6850
6959
|
}
|
|
6851
|
-
const u =
|
|
6960
|
+
const u = Dt._buildGuides({
|
|
6852
6961
|
activeBounds: o,
|
|
6853
6962
|
targetBounds: d,
|
|
6854
6963
|
targetIsMontageArea: c
|
|
@@ -6877,11 +6986,11 @@ class Lt {
|
|
|
6877
6986
|
targetBounds: e,
|
|
6878
6987
|
targetIsMontageArea: s
|
|
6879
6988
|
}) {
|
|
6880
|
-
const n =
|
|
6989
|
+
const n = Dt._buildHorizontalGuides({
|
|
6881
6990
|
activeBounds: t,
|
|
6882
6991
|
targetBounds: e,
|
|
6883
6992
|
targetIsMontageArea: s
|
|
6884
|
-
}), o =
|
|
6993
|
+
}), o = Dt._buildVerticalGuides({
|
|
6885
6994
|
activeBounds: t,
|
|
6886
6995
|
targetBounds: e,
|
|
6887
6996
|
targetIsMontageArea: s
|
|
@@ -6908,13 +7017,13 @@ class Lt {
|
|
|
6908
7017
|
top: u = 0,
|
|
6909
7018
|
bottom: f = 0,
|
|
6910
7019
|
centerY: g = 0
|
|
6911
|
-
} = e, p = Math.max(a, u), m = Math.min(r, f),
|
|
7020
|
+
} = e, p = Math.max(a, u), m = Math.min(r, f), w = m >= p ? (p + m) / 2 : (c + g) / 2;
|
|
6912
7021
|
if (d >= i) {
|
|
6913
7022
|
if (s) return n;
|
|
6914
7023
|
const C = d - i;
|
|
6915
7024
|
return C > 0 && n.push({
|
|
6916
7025
|
type: "horizontal",
|
|
6917
|
-
axis:
|
|
7026
|
+
axis: w,
|
|
6918
7027
|
start: i,
|
|
6919
7028
|
end: d,
|
|
6920
7029
|
distance: C
|
|
@@ -6925,7 +7034,7 @@ class Lt {
|
|
|
6925
7034
|
const C = o - l;
|
|
6926
7035
|
return C > 0 && n.push({
|
|
6927
7036
|
type: "horizontal",
|
|
6928
|
-
axis:
|
|
7037
|
+
axis: w,
|
|
6929
7038
|
start: l,
|
|
6930
7039
|
end: o,
|
|
6931
7040
|
distance: C
|
|
@@ -6935,16 +7044,16 @@ class Lt {
|
|
|
6935
7044
|
const A = o < d, y = i > l, b = Math.min(o, d), j = Math.max(o, d), I = j - b;
|
|
6936
7045
|
I > 0 && !A && n.push({
|
|
6937
7046
|
type: "horizontal",
|
|
6938
|
-
axis:
|
|
7047
|
+
axis: w,
|
|
6939
7048
|
start: b,
|
|
6940
7049
|
end: j,
|
|
6941
7050
|
distance: I
|
|
6942
7051
|
});
|
|
6943
|
-
const
|
|
7052
|
+
const S = Math.min(i, l), T = Math.max(i, l), M = T - S;
|
|
6944
7053
|
return M > 0 && !y && n.push({
|
|
6945
7054
|
type: "horizontal",
|
|
6946
|
-
axis:
|
|
6947
|
-
start:
|
|
7055
|
+
axis: w,
|
|
7056
|
+
start: S,
|
|
6948
7057
|
end: T,
|
|
6949
7058
|
distance: M
|
|
6950
7059
|
}), n;
|
|
@@ -6969,13 +7078,13 @@ class Lt {
|
|
|
6969
7078
|
left: u = 0,
|
|
6970
7079
|
right: f = 0,
|
|
6971
7080
|
centerX: g = 0
|
|
6972
|
-
} = e, p = Math.max(a, u), m = Math.min(r, f),
|
|
7081
|
+
} = e, p = Math.max(a, u), m = Math.min(r, f), w = m >= p ? (p + m) / 2 : (c + g) / 2;
|
|
6973
7082
|
if (d >= i) {
|
|
6974
7083
|
if (s) return n;
|
|
6975
7084
|
const C = d - i;
|
|
6976
7085
|
return C > 0 && n.push({
|
|
6977
7086
|
type: "vertical",
|
|
6978
|
-
axis:
|
|
7087
|
+
axis: w,
|
|
6979
7088
|
start: i,
|
|
6980
7089
|
end: d,
|
|
6981
7090
|
distance: C
|
|
@@ -6986,7 +7095,7 @@ class Lt {
|
|
|
6986
7095
|
const C = o - l;
|
|
6987
7096
|
return C > 0 && n.push({
|
|
6988
7097
|
type: "vertical",
|
|
6989
|
-
axis:
|
|
7098
|
+
axis: w,
|
|
6990
7099
|
start: l,
|
|
6991
7100
|
end: o,
|
|
6992
7101
|
distance: C
|
|
@@ -6996,16 +7105,16 @@ class Lt {
|
|
|
6996
7105
|
const A = o < d, y = i > l, b = Math.min(o, d), j = Math.max(o, d), I = j - b;
|
|
6997
7106
|
I > 0 && !A && n.push({
|
|
6998
7107
|
type: "vertical",
|
|
6999
|
-
axis:
|
|
7108
|
+
axis: w,
|
|
7000
7109
|
start: b,
|
|
7001
7110
|
end: j,
|
|
7002
7111
|
distance: I
|
|
7003
7112
|
});
|
|
7004
|
-
const
|
|
7113
|
+
const S = Math.min(i, l), T = Math.max(i, l), M = T - S;
|
|
7005
7114
|
return M > 0 && !y && n.push({
|
|
7006
7115
|
type: "vertical",
|
|
7007
|
-
axis:
|
|
7008
|
-
start:
|
|
7116
|
+
axis: w,
|
|
7117
|
+
start: S,
|
|
7009
7118
|
end: T,
|
|
7010
7119
|
distance: M
|
|
7011
7120
|
}), n;
|
|
@@ -7037,7 +7146,7 @@ class Lt {
|
|
|
7037
7146
|
const { viewportTransform: s } = t, n = t.getZoom() || 1, o = this.activeGuides.some((c) => c.type === "vertical"), i = this.activeGuides.some((c) => c.type === "horizontal"), a = o && i && !this.isTargetMontageArea, r = a ? 12 / n : 0;
|
|
7038
7147
|
e.save(), Array.isArray(s) && e.transform(...s), e.lineWidth = es / n, e.strokeStyle = ts, e.setLineDash([]);
|
|
7039
7148
|
for (const c of this.activeGuides) {
|
|
7040
|
-
const { type: d, axis: l, start: u, end: f, distance: g } = c, p = Math.abs(f - u), m = u <= f ? -1 : 1, v = a ? m * (p / 2 + r) : 0,
|
|
7149
|
+
const { type: d, axis: l, start: u, end: f, distance: g } = c, p = Math.abs(f - u), m = u <= f ? -1 : 1, v = a ? m * (p / 2 + r) : 0, w = 0;
|
|
7041
7150
|
e.beginPath(), d === "vertical" ? (e.moveTo(l, u), e.lineTo(l, f)) : (e.moveTo(u, l), e.lineTo(f, l)), e.stroke(), je({
|
|
7042
7151
|
context: e,
|
|
7043
7152
|
type: d,
|
|
@@ -7049,7 +7158,7 @@ class Lt {
|
|
|
7049
7158
|
color: ts,
|
|
7050
7159
|
lineWidth: es,
|
|
7051
7160
|
offsetAlongAxis: v,
|
|
7052
|
-
offsetPerpendicular:
|
|
7161
|
+
offsetPerpendicular: w
|
|
7053
7162
|
});
|
|
7054
7163
|
}
|
|
7055
7164
|
e.restore();
|
|
@@ -7080,7 +7189,7 @@ class Le {
|
|
|
7080
7189
|
* @param options - опции и настройки редактора
|
|
7081
7190
|
*/
|
|
7082
7191
|
constructor(t, e) {
|
|
7083
|
-
this.options = e, this.containerId = t, this.editorId = `${t}-${
|
|
7192
|
+
this.options = e, this.containerId = t, this.editorId = `${t}-${X()}`, this.clipboard = null, this.init();
|
|
7084
7193
|
}
|
|
7085
7194
|
/**
|
|
7086
7195
|
* Инициализация редактора.
|
|
@@ -7088,7 +7197,7 @@ class Le {
|
|
|
7088
7197
|
* @fires editor:ready
|
|
7089
7198
|
*/
|
|
7090
7199
|
init() {
|
|
7091
|
-
return
|
|
7200
|
+
return P(this, null, function* () {
|
|
7092
7201
|
var u;
|
|
7093
7202
|
const {
|
|
7094
7203
|
editorContainerWidth: t,
|
|
@@ -7103,12 +7212,12 @@ class Le {
|
|
|
7103
7212
|
showRotationAngle: d,
|
|
7104
7213
|
_onReadyCallback: l
|
|
7105
7214
|
} = this.options;
|
|
7106
|
-
if (
|
|
7215
|
+
if (st.apply(), this.canvas = new vs(this.containerId, this.options), this.moduleLoader = new As(), this.workerManager = new Is(), this.errorManager = new Qt({ editor: this }), this.historyManager = new G({ editor: this }), this.toolbar = new Us({ editor: this }), this.transformManager = new Js({ editor: this }), this.zoomManager = new qs({ editor: this }), this.canvasManager = new Qs({ editor: this }), this.imageManager = new ut({ editor: this }), this.layerManager = new le({ editor: this }), this.shapeManager = new tn({ editor: this }), this.interactionBlocker = new $s({ editor: this }), this.backgroundManager = new Lt({ editor: this }), this.clipboardManager = new en({ editor: this }), this.objectLockManager = new he({ editor: this }), this.groupingManager = new sn({ editor: this }), this.selectionManager = new nn({ editor: this }), this.deletionManager = new Oe({ editor: this }), this.panConstraintManager = new on({ editor: this }), this.snappingManager = new jn({ editor: this }), this.measurementManager = new Dt({ editor: this }), this.fontManager = new Se((u = this.options.fonts) != null ? u : []), this.textManager = new k({ editor: this }), this.templateManager = new _({ editor: this }), d && (this.angleIndicator = new Ee({ editor: this })), this._createMontageArea(), this._createClippingArea(), this.listeners = new Kt({ editor: this, options: this.options }), this.canvasManager.setEditorContainerWidth(t), this.canvasManager.setEditorContainerHeight(e), this.canvasManager.setCanvasWrapperWidth(s), this.canvasManager.setCanvasWrapperHeight(n), this.canvasManager.setCanvasCSSWidth(o), this.canvasManager.setCanvasCSSHeight(i), this.canvasManager.updateCanvas(), this.zoomManager.calculateAndApplyDefaultZoom(), yield this.fontManager.loadFonts(), a != null && a.source) {
|
|
7107
7216
|
const f = a, {
|
|
7108
7217
|
source: g,
|
|
7109
7218
|
scale: p = `image-${c}`,
|
|
7110
7219
|
withoutSave: m = !0
|
|
7111
|
-
} = f, v =
|
|
7220
|
+
} = f, v = pt(f, [
|
|
7112
7221
|
"source",
|
|
7113
7222
|
"scale",
|
|
7114
7223
|
"withoutSave"
|