@anu3ev/fabric-image-editor 0.5.4 → 0.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.js +673 -675
- 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
|
-
var
|
|
3
|
+
var Gt = Object.getOwnPropertySymbols;
|
|
4
4
|
var _e = Object.prototype.hasOwnProperty, Ne = Object.prototype.propertyIsEnumerable;
|
|
5
|
-
var Re = (h, t, e) => t in h ? ds(h, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : h[t] = e,
|
|
5
|
+
var Re = (h, t, e) => t in h ? ds(h, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : h[t] = e, _ = (h, t) => {
|
|
6
6
|
for (var e in t || (t = {}))
|
|
7
7
|
_e.call(t, e) && Re(h, e, t[e]);
|
|
8
|
-
if (
|
|
9
|
-
for (var e of
|
|
8
|
+
if (Gt)
|
|
9
|
+
for (var e of Gt(t))
|
|
10
10
|
Ne.call(t, e) && Re(h, e, t[e]);
|
|
11
11
|
return h;
|
|
12
|
-
},
|
|
13
|
-
var
|
|
12
|
+
}, yt = (h, t) => ls(h, hs(t));
|
|
13
|
+
var vt = (h, t) => {
|
|
14
14
|
var e = {};
|
|
15
15
|
for (var s in h)
|
|
16
16
|
_e.call(h, s) && t.indexOf(s) < 0 && (e[s] = h[s]);
|
|
17
|
-
if (h != null &&
|
|
18
|
-
for (var s of
|
|
17
|
+
if (h != null && Gt)
|
|
18
|
+
for (var s of Gt(h))
|
|
19
19
|
t.indexOf(s) < 0 && Ne.call(h, s) && (e[s] = h[s]);
|
|
20
20
|
return e;
|
|
21
21
|
};
|
|
22
|
-
var
|
|
22
|
+
var N = (h, t, e) => new Promise((s, o) => {
|
|
23
23
|
var n = (r) => {
|
|
24
24
|
try {
|
|
25
25
|
a(e.next(r));
|
|
@@ -35,15 +35,15 @@ var _ = (h, t, e) => new Promise((s, o) => {
|
|
|
35
35
|
}, a = (r) => r.done ? s(r.value) : Promise.resolve(r.value).then(n, i);
|
|
36
36
|
a((e = e.apply(h, t)).next());
|
|
37
37
|
});
|
|
38
|
-
import { ActiveSelection as
|
|
38
|
+
import { ActiveSelection as x, Textbox as nt, util as dt, controlsUtils as xe, InteractiveFabricObject as Be, Point as tt, FitContentLayout as ke, loadSVGFromURL as us, FabricImage as zt, Gradient as ze, Rect as gs, Circle as fs, Triangle as ps, Group as Et, Color as ms, classRegistry as Pe, loadSVGFromString as ys, Canvas as vs, Pattern as bs } from "fabric";
|
|
39
39
|
import { create as Ms } from "jsondiffpatch";
|
|
40
40
|
import ws from "diff-match-patch";
|
|
41
|
-
var Ss = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",
|
|
41
|
+
var Ss = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", G = 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 Ut {
|
|
47
47
|
/**
|
|
48
48
|
* Конструктор принимает редактор и опции.
|
|
49
49
|
* @param params
|
|
@@ -61,7 +61,7 @@ class Bt {
|
|
|
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 = Ut.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 = Ut.debounce(this.handleObjectModifiedHistory.bind(this), 300), this.handleObjectRotatingHistoryBound = Ut.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
|
* Инициализация всех обработчиков согласно опциям.
|
|
@@ -98,7 +98,7 @@ class Bt {
|
|
|
98
98
|
if (o.length === 1)
|
|
99
99
|
this.canvas.setActiveObject(o[0]);
|
|
100
100
|
else {
|
|
101
|
-
const i = new
|
|
101
|
+
const i = new x(o, {
|
|
102
102
|
canvas: this.canvas
|
|
103
103
|
});
|
|
104
104
|
this.canvas.setActiveObject(i);
|
|
@@ -106,7 +106,7 @@ class Bt {
|
|
|
106
106
|
this.canvas.requestRenderAll();
|
|
107
107
|
return;
|
|
108
108
|
}
|
|
109
|
-
const n = new
|
|
109
|
+
const n = new x(t, {
|
|
110
110
|
canvas: this.canvas
|
|
111
111
|
});
|
|
112
112
|
this.editor.objectLockManager.lockObject({
|
|
@@ -175,7 +175,7 @@ class Bt {
|
|
|
175
175
|
* @param event.code — код клавиши
|
|
176
176
|
*/
|
|
177
177
|
handleUndoRedoEvent(t) {
|
|
178
|
-
return
|
|
178
|
+
return N(this, null, function* () {
|
|
179
179
|
const { ctrlKey: e, metaKey: s, code: o, repeat: n } = t;
|
|
180
180
|
this._shouldIgnoreKeyboardEvent(t) || !e && !s || n || !/Mac/i.test(navigator.userAgent) && this.isUndoRedoKeyPressed || (o === "KeyZ" ? (t.preventDefault(), this.isUndoRedoKeyPressed = !0, yield this.editor.historyManager.undo()) : o === "KeyY" && (t.preventDefault(), this.isUndoRedoKeyPressed = !0, yield this.editor.historyManager.redo()));
|
|
181
181
|
});
|
|
@@ -220,7 +220,7 @@ class Bt {
|
|
|
220
220
|
if (o || n) return;
|
|
221
221
|
this.isSpacePressed = !0, t.preventDefault();
|
|
222
222
|
const i = e.getActiveObject() || null;
|
|
223
|
-
i instanceof
|
|
223
|
+
i instanceof x ? this.savedSelection = i.getObjects().slice() : i && (this.savedSelection = [i]), e.discardActiveObject(), e.set({
|
|
224
224
|
selection: !1,
|
|
225
225
|
defaultCursor: "grab"
|
|
226
226
|
}), e.setCursor("grab"), s.canvasManager.getObjects().forEach((a) => {
|
|
@@ -259,7 +259,7 @@ class Bt {
|
|
|
259
259
|
e.setActiveObject(t[0]);
|
|
260
260
|
return;
|
|
261
261
|
}
|
|
262
|
-
const o = t.filter((i) => s.canvasManager.getObjects().includes(i)), n = new
|
|
262
|
+
const o = t.filter((i) => s.canvasManager.getObjects().includes(i)), n = new x(o, { canvas: e });
|
|
263
263
|
e.setActiveObject(n);
|
|
264
264
|
}
|
|
265
265
|
// --- Обработчики для событий canvas (Fabric) ---
|
|
@@ -330,7 +330,7 @@ class Bt {
|
|
|
330
330
|
*/
|
|
331
331
|
handleResetObjectFit(t) {
|
|
332
332
|
const e = t == null ? void 0 : t.target;
|
|
333
|
-
!e || e instanceof
|
|
333
|
+
!e || e instanceof nt || this.editor.transformManager.resetObject({ object: e });
|
|
334
334
|
}
|
|
335
335
|
/**
|
|
336
336
|
* Проверяет, должно ли событие клавиатуры быть проигнорировано
|
|
@@ -451,7 +451,7 @@ class Is {
|
|
|
451
451
|
* @returns Promise, который будет выполнен, когда воркер вернет ответ
|
|
452
452
|
*/
|
|
453
453
|
post(t, e, s = []) {
|
|
454
|
-
const o = `${t}:${
|
|
454
|
+
const o = `${t}:${G(8)}`;
|
|
455
455
|
return new Promise((n, i) => {
|
|
456
456
|
this._callbacks.set(o, { resolve: n, reject: i }), this.worker.postMessage({ action: t, payload: e, requestId: o }, s);
|
|
457
457
|
});
|
|
@@ -463,95 +463,95 @@ class Is {
|
|
|
463
463
|
this.worker.terminate();
|
|
464
464
|
}
|
|
465
465
|
}
|
|
466
|
-
const
|
|
467
|
-
function
|
|
468
|
-
const n =
|
|
469
|
-
h.save(), h.translate(t, e), h.rotate(
|
|
466
|
+
const rt = 12, Cs = 2, le = 8, he = 20, Ts = 100, ue = 20, ge = 8, Es = 100, qt = 32, ye = 1, Os = "#2B2D33", ve = "#3D8BF4", be = "#FFFFFF";
|
|
467
|
+
function Vt(h, t, e, s, o) {
|
|
468
|
+
const n = rt, i = Cs;
|
|
469
|
+
h.save(), h.translate(t, e), h.rotate(dt.degreesToRadians(o.angle)), h.fillStyle = be, h.strokeStyle = ve, h.lineWidth = ye, h.beginPath(), h.roundRect(-n / 2, -n / 2, n, n, i), h.fill(), h.stroke(), h.restore();
|
|
470
470
|
}
|
|
471
471
|
function Ue(h, t, e, s, o) {
|
|
472
|
-
const n =
|
|
473
|
-
h.save(), h.translate(t, e), h.rotate(
|
|
472
|
+
const n = le, i = he, a = Ts;
|
|
473
|
+
h.save(), h.translate(t, e), h.rotate(dt.degreesToRadians(o.angle)), h.fillStyle = be, h.strokeStyle = ve, h.lineWidth = ye, h.beginPath(), h.roundRect(-n / 2, -i / 2, n, i, a), h.fill(), h.stroke(), h.restore();
|
|
474
474
|
}
|
|
475
475
|
function Ye(h, t, e, s, o) {
|
|
476
|
-
const n =
|
|
477
|
-
h.save(), h.translate(t, e), h.rotate(
|
|
476
|
+
const n = ue, i = ge, a = Es;
|
|
477
|
+
h.save(), h.translate(t, e), h.rotate(dt.degreesToRadians(o.angle)), h.fillStyle = be, h.strokeStyle = ve, h.lineWidth = ye, h.beginPath(), h.roundRect(-n / 2, -i / 2, n, i, a), h.fill(), h.stroke(), h.restore();
|
|
478
478
|
}
|
|
479
|
-
const
|
|
480
|
-
es.src =
|
|
481
|
-
function
|
|
482
|
-
const i =
|
|
483
|
-
h.save(), h.translate(t, e), h.rotate(
|
|
479
|
+
const Ls = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTE4Ljc1IDQuMzc1djMuNzVhLjYyNS42MjUgMCAwIDEtLjYyNS42MjVoLTMuNzVhLjYyNS42MjUgMCAwIDEgMC0xLjI1aDIuMTRsLTIuMDc3LTEuOTAzLS4wMi0uMDE5YTYuMjUgNi4yNSAwIDEgMC0uMTMgOC45NjcuNjI2LjYyNiAwIDAgMSAuODYuOTA5QTcuNDU2IDcuNDU2IDAgMCAxIDEwIDE3LjVoLS4xMDNhNy41IDcuNSAwIDEgMSA1LjM5Ni0xMi44MTJMMTcuNSA2LjcwM1Y0LjM3NWEuNjI1LjYyNSAwIDAgMSAxLjI1IDBaIi8+PC9zdmc+", es = new Image();
|
|
480
|
+
es.src = Ls;
|
|
481
|
+
function Ds(h, t, e, s, o) {
|
|
482
|
+
const i = qt / 2;
|
|
483
|
+
h.save(), h.translate(t, e), h.rotate(dt.degreesToRadians(o.angle)), h.fillStyle = Os, h.beginPath(), h.arc(0, 0, i, 0, 2 * Math.PI), h.fill(), h.drawImage(es, -i / 2, -i / 2, i, i), h.restore();
|
|
484
484
|
}
|
|
485
485
|
const Rs = {
|
|
486
486
|
// Угловые точки
|
|
487
487
|
tl: {
|
|
488
|
-
render:
|
|
489
|
-
sizeX:
|
|
490
|
-
sizeY:
|
|
488
|
+
render: Vt,
|
|
489
|
+
sizeX: rt,
|
|
490
|
+
sizeY: rt,
|
|
491
491
|
offsetX: 0,
|
|
492
492
|
offsetY: 0
|
|
493
493
|
},
|
|
494
494
|
tr: {
|
|
495
|
-
render:
|
|
496
|
-
sizeX:
|
|
497
|
-
sizeY:
|
|
495
|
+
render: Vt,
|
|
496
|
+
sizeX: rt,
|
|
497
|
+
sizeY: rt,
|
|
498
498
|
offsetX: 0,
|
|
499
499
|
offsetY: 0
|
|
500
500
|
},
|
|
501
501
|
bl: {
|
|
502
|
-
render:
|
|
503
|
-
sizeX:
|
|
504
|
-
sizeY:
|
|
502
|
+
render: Vt,
|
|
503
|
+
sizeX: rt,
|
|
504
|
+
sizeY: rt,
|
|
505
505
|
offsetX: 0,
|
|
506
506
|
offsetY: 0
|
|
507
507
|
},
|
|
508
508
|
br: {
|
|
509
|
-
render:
|
|
510
|
-
sizeX:
|
|
511
|
-
sizeY:
|
|
509
|
+
render: Vt,
|
|
510
|
+
sizeX: rt,
|
|
511
|
+
sizeY: rt,
|
|
512
512
|
offsetX: 0,
|
|
513
513
|
offsetY: 0
|
|
514
514
|
},
|
|
515
515
|
// Середина вертикалей
|
|
516
516
|
ml: {
|
|
517
517
|
render: Ue,
|
|
518
|
-
sizeX:
|
|
519
|
-
sizeY:
|
|
518
|
+
sizeX: le,
|
|
519
|
+
sizeY: he,
|
|
520
520
|
offsetX: 0,
|
|
521
521
|
offsetY: 0
|
|
522
522
|
},
|
|
523
523
|
mr: {
|
|
524
524
|
render: Ue,
|
|
525
|
-
sizeX:
|
|
526
|
-
sizeY:
|
|
525
|
+
sizeX: le,
|
|
526
|
+
sizeY: he,
|
|
527
527
|
offsetX: 0,
|
|
528
528
|
offsetY: 0
|
|
529
529
|
},
|
|
530
530
|
// Середина горизонталей
|
|
531
531
|
mt: {
|
|
532
532
|
render: Ye,
|
|
533
|
-
sizeX:
|
|
534
|
-
sizeY:
|
|
533
|
+
sizeX: ue,
|
|
534
|
+
sizeY: ge,
|
|
535
535
|
offsetX: 0,
|
|
536
536
|
offsetY: 0
|
|
537
537
|
},
|
|
538
538
|
mb: {
|
|
539
539
|
render: Ye,
|
|
540
|
-
sizeX:
|
|
541
|
-
sizeY:
|
|
540
|
+
sizeX: ue,
|
|
541
|
+
sizeY: ge,
|
|
542
542
|
offsetX: 0,
|
|
543
543
|
offsetY: 0
|
|
544
544
|
},
|
|
545
545
|
// Специальный «rotate» контрол
|
|
546
546
|
mtr: {
|
|
547
|
-
render:
|
|
548
|
-
sizeX:
|
|
549
|
-
sizeY:
|
|
547
|
+
render: Ds,
|
|
548
|
+
sizeX: qt,
|
|
549
|
+
sizeY: qt,
|
|
550
550
|
offsetX: 0,
|
|
551
|
-
offsetY: -
|
|
551
|
+
offsetY: -qt
|
|
552
552
|
}
|
|
553
553
|
};
|
|
554
|
-
class
|
|
554
|
+
class J {
|
|
555
555
|
/**
|
|
556
556
|
* Отключает изменение ширины по оси X для заблокированных объектов, сохраняя поведение остального хэндлера.
|
|
557
557
|
*/
|
|
@@ -581,23 +581,23 @@ class $ {
|
|
|
581
581
|
*/
|
|
582
582
|
static apply() {
|
|
583
583
|
const t = xe.createObjectDefaultControls();
|
|
584
|
-
|
|
584
|
+
J.applyControlOverrides(t), Be.ownDefaults.controls = t;
|
|
585
585
|
const e = xe.createTextboxDefaultControls();
|
|
586
|
-
|
|
586
|
+
J.applyControlOverrides(e), e.mt && (e.mt.visible = !1), e.mb && (e.mb.visible = !1), J.wrapWidthControl(e.ml), J.wrapWidthControl(e.mr), nt.ownDefaults.controls = e, J.patchActiveSelectionBounds(), Be.ownDefaults.snapAngle = 1;
|
|
587
587
|
}
|
|
588
588
|
/**
|
|
589
589
|
* Обновляет алгоритм расчёта границ ActiveSelection, чтобы учитывать фон и отступы текстовых объектов.
|
|
590
590
|
*/
|
|
591
591
|
static patchActiveSelectionBounds() {
|
|
592
|
-
const t =
|
|
592
|
+
const t = x.prototype, e = t._calcBoundsFromObjects;
|
|
593
593
|
t._calcBoundsFromObjects = function(...n) {
|
|
594
594
|
var g, f;
|
|
595
595
|
const i = (f = (g = this.getObjects) == null ? void 0 : g.call(this)) != null ? f : [];
|
|
596
|
-
|
|
596
|
+
J.applyTextSelectionScalingLock({
|
|
597
597
|
selection: this,
|
|
598
598
|
objects: i
|
|
599
599
|
});
|
|
600
|
-
const a =
|
|
600
|
+
const a = J.calculateActiveSelectionBounds({
|
|
601
601
|
objects: i
|
|
602
602
|
});
|
|
603
603
|
if (!a)
|
|
@@ -609,45 +609,45 @@ class $ {
|
|
|
609
609
|
width: d,
|
|
610
610
|
height: l
|
|
611
611
|
});
|
|
612
|
-
const u = new
|
|
612
|
+
const u = new tt(r + d / 2, c + l / 2);
|
|
613
613
|
return this.setPositionByOrigin(u, "center", "center"), a;
|
|
614
614
|
};
|
|
615
615
|
const s = t._onAfterObjectsChange;
|
|
616
616
|
t._onAfterObjectsChange = function(n, i) {
|
|
617
617
|
var p, m;
|
|
618
618
|
const a = s ? s.call(this, n, i) : void 0, r = (m = (p = this.getObjects) == null ? void 0 : p.call(this)) != null ? m : [];
|
|
619
|
-
|
|
619
|
+
J.applyTextSelectionScalingLock({
|
|
620
620
|
selection: this,
|
|
621
621
|
objects: r
|
|
622
622
|
});
|
|
623
|
-
const c =
|
|
623
|
+
const c = J.calculateActiveSelectionBounds({
|
|
624
624
|
objects: r
|
|
625
625
|
});
|
|
626
626
|
if (!c) return a;
|
|
627
|
-
const { left: d, top: l, width: u, height: g } = c, f = new
|
|
627
|
+
const { left: d, top: l, width: u, height: g } = c, f = new tt(d + u / 2, l + g / 2);
|
|
628
628
|
return this.set({
|
|
629
629
|
width: u,
|
|
630
630
|
height: g
|
|
631
631
|
}), this.setPositionByOrigin(f, "center", "center"), this.setCoords(), a;
|
|
632
632
|
};
|
|
633
|
-
const o =
|
|
634
|
-
|
|
633
|
+
const o = ke.prototype.calcBoundingBox;
|
|
634
|
+
ke.prototype.calcBoundingBox = function(n, i) {
|
|
635
635
|
const { target: a, type: r, overrides: c } = i;
|
|
636
636
|
if (r === "imperative" && c)
|
|
637
637
|
return c;
|
|
638
|
-
if (!(a instanceof
|
|
638
|
+
if (!(a instanceof x))
|
|
639
639
|
return o.call(this, n, i);
|
|
640
|
-
|
|
640
|
+
J.applyTextSelectionScalingLock({
|
|
641
641
|
selection: a,
|
|
642
642
|
objects: n
|
|
643
643
|
});
|
|
644
|
-
const d =
|
|
644
|
+
const d = J.calculateActiveSelectionBounds({ objects: n });
|
|
645
645
|
if (!d)
|
|
646
646
|
return o.call(this, n, i);
|
|
647
|
-
const { left: l, top: u, width: g, height: f } = d, p = new
|
|
647
|
+
const { left: l, top: u, width: g, height: f } = d, p = new tt(g, f), m = new tt(l + g / 2, u + f / 2);
|
|
648
648
|
return r === "initialization" ? {
|
|
649
649
|
center: m,
|
|
650
|
-
relativeCorrection: new
|
|
650
|
+
relativeCorrection: new tt(0, 0),
|
|
651
651
|
size: p
|
|
652
652
|
} : {
|
|
653
653
|
center: m,
|
|
@@ -671,22 +671,22 @@ class $ {
|
|
|
671
671
|
};
|
|
672
672
|
}
|
|
673
673
|
/**
|
|
674
|
-
* Блокирует
|
|
674
|
+
* Блокирует горизонтальное масштабирование ActiveSelection, если в выделении есть текстовые объекты.
|
|
675
675
|
*/
|
|
676
676
|
static applyTextSelectionScalingLock({
|
|
677
677
|
selection: t,
|
|
678
678
|
objects: e
|
|
679
679
|
}) {
|
|
680
|
-
const s = e.some((
|
|
681
|
-
t.
|
|
682
|
-
lockScalingY: s
|
|
683
|
-
}), t.setControlsVisibility({
|
|
680
|
+
const s = e.some((i) => i instanceof nt), o = t instanceof x && e.length > 1, n = s && o;
|
|
681
|
+
t.setControlsVisibility({
|
|
684
682
|
mt: !s,
|
|
685
|
-
mb: !s
|
|
683
|
+
mb: !s,
|
|
684
|
+
ml: !n,
|
|
685
|
+
mr: !n
|
|
686
686
|
});
|
|
687
687
|
}
|
|
688
688
|
}
|
|
689
|
-
const
|
|
689
|
+
const k = class k {
|
|
690
690
|
constructor(t = []) {
|
|
691
691
|
this.fonts = t;
|
|
692
692
|
}
|
|
@@ -694,36 +694,36 @@ const N = class N {
|
|
|
694
694
|
this.fonts = t;
|
|
695
695
|
}
|
|
696
696
|
loadFonts() {
|
|
697
|
-
return
|
|
697
|
+
return N(this, null, function* () {
|
|
698
698
|
var o;
|
|
699
699
|
const t = (o = this.fonts) != null ? o : [];
|
|
700
700
|
if (!t.length) return;
|
|
701
701
|
const e = typeof document != "undefined" ? document : void 0;
|
|
702
702
|
if (!e) return;
|
|
703
|
-
const s = t.map((n) =>
|
|
703
|
+
const s = t.map((n) => k.loadFont(n, e));
|
|
704
704
|
yield Promise.allSettled(s);
|
|
705
705
|
});
|
|
706
706
|
}
|
|
707
707
|
static loadFont(t, e) {
|
|
708
|
-
return
|
|
708
|
+
return N(this, null, function* () {
|
|
709
709
|
var c, d;
|
|
710
710
|
const s = typeof FontFace != "undefined", o = (c = t.family) == null ? void 0 : c.trim(), n = (d = t.source) == null ? void 0 : d.trim();
|
|
711
711
|
if (!o || !n) return;
|
|
712
|
-
const i =
|
|
713
|
-
if (!
|
|
714
|
-
if (
|
|
715
|
-
|
|
712
|
+
const i = k.normalizeFontSource(n), a = k.getDescriptorSnapshot(t.descriptors), r = k.getFontRegistrationKey(o, i, a);
|
|
713
|
+
if (!k.registeredFontKeys.has(r)) {
|
|
714
|
+
if (k.isFontFaceAlreadyApplied(e, o, a)) {
|
|
715
|
+
k.registeredFontKeys.add(r);
|
|
716
716
|
return;
|
|
717
717
|
}
|
|
718
718
|
if (s && e.fonts && typeof e.fonts.add == "function")
|
|
719
719
|
try {
|
|
720
720
|
const u = yield new FontFace(o, i, t.descriptors).load();
|
|
721
|
-
e.fonts.add(u),
|
|
721
|
+
e.fonts.add(u), k.registeredFontKeys.add(r);
|
|
722
722
|
return;
|
|
723
723
|
} catch (l) {
|
|
724
724
|
console.warn(`Не удалось загрузить шрифт "${o}" через FontFace API`, l);
|
|
725
725
|
}
|
|
726
|
-
|
|
726
|
+
k.injectFontFace({
|
|
727
727
|
font: t,
|
|
728
728
|
source: i,
|
|
729
729
|
doc: e,
|
|
@@ -743,15 +743,15 @@ const N = class N {
|
|
|
743
743
|
if (!i) return;
|
|
744
744
|
const a = s.createElement("style");
|
|
745
745
|
a.setAttribute("data-editor-font", i), a.setAttribute("data-editor-font-key", o);
|
|
746
|
-
const r =
|
|
746
|
+
const r = k.descriptorsToCss(n), c = [
|
|
747
747
|
"@font-face {",
|
|
748
|
-
` font-family: ${
|
|
748
|
+
` font-family: ${k.formatFontFamilyForCss(i)};`,
|
|
749
749
|
` src: ${e};`,
|
|
750
750
|
...r.map((l) => ` ${l}`),
|
|
751
751
|
"}"
|
|
752
752
|
];
|
|
753
753
|
a.textContent = c.join(`
|
|
754
|
-
`), s.head.appendChild(a),
|
|
754
|
+
`), s.head.appendChild(a), k.registeredFontKeys.add(o);
|
|
755
755
|
}
|
|
756
756
|
static normalizeFontSource(t) {
|
|
757
757
|
const e = t.trim();
|
|
@@ -774,15 +774,15 @@ const N = class N {
|
|
|
774
774
|
return t ? t.trim().replace(/^['"]+|['"]+$/g, "").toLowerCase() : "";
|
|
775
775
|
}
|
|
776
776
|
static getDescriptorSnapshot(t) {
|
|
777
|
-
const e =
|
|
777
|
+
const e = k.descriptorDefaults;
|
|
778
778
|
return {
|
|
779
|
-
style:
|
|
780
|
-
weight:
|
|
781
|
-
stretch:
|
|
782
|
-
unicodeRange:
|
|
783
|
-
variant:
|
|
784
|
-
featureSettings:
|
|
785
|
-
display:
|
|
779
|
+
style: k.normalizeDescriptorValue(t == null ? void 0 : t.style, e.style),
|
|
780
|
+
weight: k.normalizeDescriptorValue(t == null ? void 0 : t.weight, e.weight),
|
|
781
|
+
stretch: k.normalizeDescriptorValue(t == null ? void 0 : t.stretch, e.stretch),
|
|
782
|
+
unicodeRange: k.normalizeDescriptorValue(t == null ? void 0 : t.unicodeRange, e.unicodeRange),
|
|
783
|
+
variant: k.normalizeDescriptorValue(t == null ? void 0 : t.variant, e.variant),
|
|
784
|
+
featureSettings: k.normalizeDescriptorValue(t == null ? void 0 : t.featureSettings, e.featureSettings),
|
|
785
|
+
display: k.normalizeDescriptorValue(t == null ? void 0 : t.display, e.display)
|
|
786
786
|
};
|
|
787
787
|
}
|
|
788
788
|
static areDescriptorSnapshotsEqual(t, e) {
|
|
@@ -790,7 +790,7 @@ const N = class N {
|
|
|
790
790
|
}
|
|
791
791
|
static getFontRegistrationKey(t, e, s) {
|
|
792
792
|
return [
|
|
793
|
-
|
|
793
|
+
k.normalizeFamilyName(t),
|
|
794
794
|
e,
|
|
795
795
|
s.style,
|
|
796
796
|
s.weight,
|
|
@@ -804,12 +804,12 @@ const N = class N {
|
|
|
804
804
|
static isFontFaceAlreadyApplied(t, e, s) {
|
|
805
805
|
const o = t.fonts;
|
|
806
806
|
if (!o || typeof o.forEach != "function") return !1;
|
|
807
|
-
const n =
|
|
807
|
+
const n = k.normalizeFamilyName(e);
|
|
808
808
|
let i = !1;
|
|
809
809
|
try {
|
|
810
810
|
o.forEach((a) => {
|
|
811
|
-
if (i ||
|
|
812
|
-
const c =
|
|
811
|
+
if (i || k.normalizeFamilyName(a.family) !== n) return;
|
|
812
|
+
const c = k.getDescriptorSnapshot({
|
|
813
813
|
style: a.style,
|
|
814
814
|
weight: a.weight,
|
|
815
815
|
stretch: a.stretch,
|
|
@@ -818,7 +818,7 @@ const N = class N {
|
|
|
818
818
|
featureSettings: a.featureSettings,
|
|
819
819
|
display: a.display
|
|
820
820
|
});
|
|
821
|
-
|
|
821
|
+
k.areDescriptorSnapshotsEqual(s, c) && (i = !0);
|
|
822
822
|
});
|
|
823
823
|
} catch (a) {
|
|
824
824
|
return console.warn("Не удалось проверить, загружен ли шрифт ранее через FontFaceSet", a), !1;
|
|
@@ -845,7 +845,7 @@ const N = class N {
|
|
|
845
845
|
});
|
|
846
846
|
}
|
|
847
847
|
};
|
|
848
|
-
|
|
848
|
+
k.registeredFontKeys = /* @__PURE__ */ new Set(), k.descriptorDefaults = {
|
|
849
849
|
style: "normal",
|
|
850
850
|
weight: "normal",
|
|
851
851
|
stretch: "normal",
|
|
@@ -854,8 +854,8 @@ N.registeredFontKeys = /* @__PURE__ */ new Set(), N.descriptorDefaults = {
|
|
|
854
854
|
featureSettings: "normal",
|
|
855
855
|
display: "auto"
|
|
856
856
|
};
|
|
857
|
-
let
|
|
858
|
-
const _s = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNNi44NzUgMi41YS42MjUuNjI1IDAgMCAwLS42MjUuNjI0VjYuMjVIMy4xMjVhLjYyNS42MjUgMCAwIDAtLjYyNS42MjV2MTBjMCAuMzQ1LjI4LjYyNS42MjUuNjI1aDEwYy4zNDUgMCAuNjI1LS4yOC42MjUtLjYyNXYtMy4xMjZoMy4xMjVjLjM0NSAwIC42MjUtLjI4LjYyNS0uNjI1di0xMGEuNjI1LjYyNSAwIDAgMC0uNjI1LS42MjVoLTEwWm02Ljg3NSAxMGgyLjVWMy43NUg3LjV2Mi41aDUuNjI1Yy4zNDUgMCAuNjI1LjI4LjYyNS42MjV2NS42MjRabS0xMCAzLjc1VjcuNWg4Ljc1djguNzVIMy43NVoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjwvc3ZnPg==", Ns = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMi41IDcuNWMwLS42OS41Ni0xLjI1IDEuMjUtMS4yNWgxMi41Yy42OSAwIDEuMjUuNTYgMS4yNSAxLjI1djguNzVjMCAuNjktLjU2IDEuMjUtMS4yNSAxLjI1SDMuNzVjLS42OSAwLTEuMjUtLjU2LTEuMjUtMS4yNVY3LjVabTEzLjc1IDBIMy43NXY4Ljc1aDEyLjVWNy41WiIgY2xpcC1ydWxlPSJldmVub2RkIi8+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMTAgMS44NzVhMi4xODggMi4xODggMCAwIDAtMi4xODggMi4xODh2Mi44MTJhLjYyNS42MjUgMCAxIDEtMS4yNSAwVjQuMDYyYTMuNDM3IDMuNDM3IDAgMSAxIDYuODc1IDB2Mi44MTNhLjYyNS42MjUgMCAxIDEtMS4yNSAwVjQuMDYyQTIuMTg4IDIuMTg4IDAgMCAwIDEwIDEuODc2WiIgY2xpcC1ydWxlPSJldmVub2RkIi8+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTEwIDEyLjgxM2EuOTM3LjkzNyAwIDEgMCAwLTEuODc1LjkzNy45MzcgMCAwIDAgMCAxLjg3NFoiLz48L3N2Zz4=", xs = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTE2LjI1IDYuMjVINy41VjQuMzc1YTIuNSAyLjUgMCAwIDEgMi41LTIuNWMxLjIgMCAyLjI4MS44NiAyLjUxMiAyYS42MjUuNjI1IDAgMCAwIDEuMjI2LS4yNWMtLjM1NC0xLjczOC0xLjkyNS0zLTMuNzM4LTNhMy43NTQgMy43NTQgMCAwIDAtMy43NSAzLjc1VjYuMjVoLTIuNUExLjI1IDEuMjUgMCAwIDAgMi41IDcuNXY4Ljc1YTEuMjUgMS4yNSAwIDAgMCAxLjI1IDEuMjVoMTIuNWExLjI1IDEuMjUgMCAwIDAgMS4yNS0xLjI1VjcuNWExLjI1IDEuMjUgMCAwIDAtMS4yNS0xLjI1Wm0wIDEwSDMuNzVWNy41aDEyLjV2OC43NVptLTUuMzEzLTQuMzc1YS45MzcuOTM3IDAgMSAxLTEuODc0IDAgLjkzNy45MzcgMCAwIDEgMS44NzQgMFoiLz48L3N2Zz4K",
|
|
857
|
+
let fe = k;
|
|
858
|
+
const _s = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNNi44NzUgMi41YS42MjUuNjI1IDAgMCAwLS42MjUuNjI0VjYuMjVIMy4xMjVhLjYyNS42MjUgMCAwIDAtLjYyNS42MjV2MTBjMCAuMzQ1LjI4LjYyNS42MjUuNjI1aDEwYy4zNDUgMCAuNjI1LS4yOC42MjUtLjYyNXYtMy4xMjZoMy4xMjVjLjM0NSAwIC42MjUtLjI4LjYyNS0uNjI1di0xMGEuNjI1LjYyNSAwIDAgMC0uNjI1LS42MjVoLTEwWm02Ljg3NSAxMGgyLjVWMy43NUg3LjV2Mi41aDUuNjI1Yy4zNDUgMCAuNjI1LjI4LjYyNS42MjV2NS42MjRabS0xMCAzLjc1VjcuNWg4Ljc1djguNzVIMy43NVoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjwvc3ZnPg==", Ns = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMi41IDcuNWMwLS42OS41Ni0xLjI1IDEuMjUtMS4yNWgxMi41Yy42OSAwIDEuMjUuNTYgMS4yNSAxLjI1djguNzVjMCAuNjktLjU2IDEuMjUtMS4yNSAxLjI1SDMuNzVjLS42OSAwLTEuMjUtLjU2LTEuMjUtMS4yNVY3LjVabTEzLjc1IDBIMy43NXY4Ljc1aDEyLjVWNy41WiIgY2xpcC1ydWxlPSJldmVub2RkIi8+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMTAgMS44NzVhMi4xODggMi4xODggMCAwIDAtMi4xODggMi4xODh2Mi44MTJhLjYyNS42MjUgMCAxIDEtMS4yNSAwVjQuMDYyYTMuNDM3IDMuNDM3IDAgMSAxIDYuODc1IDB2Mi44MTNhLjYyNS42MjUgMCAxIDEtMS4yNSAwVjQuMDYyQTIuMTg4IDIuMTg4IDAgMCAwIDEwIDEuODc2WiIgY2xpcC1ydWxlPSJldmVub2RkIi8+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTEwIDEyLjgxM2EuOTM3LjkzNyAwIDEgMCAwLTEuODc1LjkzNy45MzcgMCAwIDAgMCAxLjg3NFoiLz48L3N2Zz4=", xs = "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=", Us = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI0VDNEU0MCIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNOC4xMjUgMS4yNUExLjg3NSAxLjg3NSAwIDAgMCA2LjI1IDMuMTI1di42MjVIMy4xMjVhLjYyNS42MjUgMCAwIDAgMCAxLjI1aC42MjV2MTEuMjVBMS4yNSAxLjI1IDAgMCAwIDUgMTcuNWgxMGExLjI1IDEuMjUgMCAwIDAgMS4yNS0xLjI1VjVoLjYyNWEuNjI1LjYyNSAwIDAgMCAwLTEuMjVIMTMuNzV2LS42MjVhMS44NzUgMS44NzUgMCAwIDAtMS44NzUtMS44NzVoLTMuNzVabTQuMzc1IDIuNXYtLjYyNWEuNjI1LjYyNSAwIDAgMC0uNjI1LS42MjVoLTMuNzVhLjYyNS42MjUgMCAwIDAtLjYyNS42MjV2LjYyNWg1Wk01IDE2LjI1VjVoMTB2MTEuMjVINVpNOC4xMjUgNy41Yy4zNDUgMCAuNjI1LjI4LjYyNS42MjV2NWEuNjI1LjYyNSAwIDEgMS0xLjI1IDB2LTVjMC0uMzQ1LjI4LS42MjUuNjI1LS42MjVabTQuMzc1IDUuNjI1di01YS42MjUuNjI1IDAgMCAwLTEuMjUgMHY1YS42MjUuNjI1IDAgMSAwIDEuMjUgMFoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjwvc3ZnPg==", Pt = {
|
|
859
859
|
style: {
|
|
860
860
|
position: "absolute",
|
|
861
861
|
display: "none",
|
|
@@ -928,11 +928,11 @@ const _s = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMj
|
|
|
928
928
|
unlock: xs,
|
|
929
929
|
bringToFront: zs,
|
|
930
930
|
sendToBack: Ps,
|
|
931
|
-
bringForward:
|
|
932
|
-
sendBackwards:
|
|
931
|
+
bringForward: Bs,
|
|
932
|
+
sendBackwards: ks
|
|
933
933
|
},
|
|
934
934
|
handlers: {
|
|
935
|
-
copyPaste: (h) =>
|
|
935
|
+
copyPaste: (h) => N(null, null, function* () {
|
|
936
936
|
h.clipboardManager.copyPaste();
|
|
937
937
|
}),
|
|
938
938
|
delete: (h) => {
|
|
@@ -965,11 +965,11 @@ class Ys {
|
|
|
965
965
|
_initToolbar() {
|
|
966
966
|
if (!this.options.showToolbar) return;
|
|
967
967
|
const t = this.options.toolbar || {};
|
|
968
|
-
this.config =
|
|
969
|
-
style:
|
|
970
|
-
btnStyle:
|
|
971
|
-
icons:
|
|
972
|
-
handlers:
|
|
968
|
+
this.config = yt(_(_({}, Pt), t), {
|
|
969
|
+
style: _(_({}, Pt.style), t.style || {}),
|
|
970
|
+
btnStyle: _(_({}, Pt.btnStyle), t.btnStyle || {}),
|
|
971
|
+
icons: _(_({}, Pt.icons), t.icons || {}),
|
|
972
|
+
handlers: _(_({}, Pt.handlers), t.handlers || {})
|
|
973
973
|
}), 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 = () => {
|
|
974
974
|
this.el.style.display = "none";
|
|
975
975
|
}, this._createDOM(), this._bindEvents();
|
|
@@ -1101,7 +1101,7 @@ const Fs = {
|
|
|
1101
1101
|
"white-space": "nowrap",
|
|
1102
1102
|
"box-shadow": "0 2px 8px rgba(0, 0, 0, 0.2)"
|
|
1103
1103
|
}, Fe = 16, He = 16, Hs = "fabric-editor-angle-indicator";
|
|
1104
|
-
class
|
|
1104
|
+
class Me {
|
|
1105
1105
|
constructor({ editor: t }) {
|
|
1106
1106
|
this.isActive = !1, this.currentAngle = 0, this.editor = t, this.canvas = t.canvas, this.options = t.options, this._createDOM(), this._bindEvents();
|
|
1107
1107
|
}
|
|
@@ -1129,7 +1129,7 @@ class ve {
|
|
|
1129
1129
|
return;
|
|
1130
1130
|
}
|
|
1131
1131
|
const s = e.angle || 0;
|
|
1132
|
-
this.currentAngle =
|
|
1132
|
+
this.currentAngle = Me._normalizeAngle(s), this.el.textContent = `${this.currentAngle}°`, this._positionIndicator(t.e), this.isActive || this._showIndicator();
|
|
1133
1133
|
}
|
|
1134
1134
|
/**
|
|
1135
1135
|
* Обработчик отпускания кнопки мыши
|
|
@@ -1229,7 +1229,7 @@ const ss = [
|
|
|
1229
1229
|
"radiusBottomRight",
|
|
1230
1230
|
"radiusBottomLeft"
|
|
1231
1231
|
];
|
|
1232
|
-
class
|
|
1232
|
+
class Jt {
|
|
1233
1233
|
constructor({ editor: t }) {
|
|
1234
1234
|
this.editor = t, this.canvas = t.canvas, this._historySuspendCount = 0, this.baseState = null, this.patches = [], this.currentIndex = 0, this.maxHistoryLength = t.options.maxHistoryLength, this.totalChangesCount = 0, this.baseStateChangesCount = 0, this._createDiffPatcher();
|
|
1235
1235
|
}
|
|
@@ -1344,7 +1344,7 @@ class Qt {
|
|
|
1344
1344
|
console.log("Нет изменений для сохранения.");
|
|
1345
1345
|
return;
|
|
1346
1346
|
}
|
|
1347
|
-
console.log("baseState", this.baseState), this.currentIndex < this.patches.length && this.patches.splice(this.currentIndex), console.log("diff", s), this.totalChangesCount += 1, this.patches.push({ id:
|
|
1347
|
+
console.log("baseState", this.baseState), this.currentIndex < this.patches.length && this.patches.splice(this.currentIndex), console.log("diff", s), this.totalChangesCount += 1, this.patches.push({ id: G(), diff: s }), 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);
|
|
1348
1348
|
}
|
|
1349
1349
|
/**
|
|
1350
1350
|
* Сериализует customData объектов в строку. Это необходимо чтобы при вызове loadFromJSON fabricjs не пытался обрабатывать свойства внутри customData, как свойства FabricObject, если их названия совпадают с зарезервированными.
|
|
@@ -1377,12 +1377,12 @@ class Qt {
|
|
|
1377
1377
|
* @fires editor:history-state-loaded
|
|
1378
1378
|
*/
|
|
1379
1379
|
loadStateFromFullState(t) {
|
|
1380
|
-
return
|
|
1380
|
+
return N(this, null, function* () {
|
|
1381
1381
|
if (!t) return;
|
|
1382
1382
|
console.log("loadStateFromFullState fullState", t);
|
|
1383
1383
|
const { canvas: e, canvasManager: s, interactionBlocker: o, backgroundManager: n } = this.editor, { width: i, height: a } = e;
|
|
1384
|
-
o.overlayMask = null,
|
|
1385
|
-
|
|
1384
|
+
o.overlayMask = null, Jt._serializeCustomData(t), yield e.loadFromJSON(t, (l, u) => {
|
|
1385
|
+
Jt._deserializeCustomData(l, u);
|
|
1386
1386
|
});
|
|
1387
1387
|
const r = e.getObjects().find((l) => l.id === "montage-area");
|
|
1388
1388
|
r && (this.editor.montageArea = r, (i !== e.getWidth() || a !== e.getHeight()) && s.updateCanvas());
|
|
@@ -1404,7 +1404,7 @@ class Qt {
|
|
|
1404
1404
|
* @fires editor:undo
|
|
1405
1405
|
*/
|
|
1406
1406
|
undo() {
|
|
1407
|
-
return
|
|
1407
|
+
return N(this, null, function* () {
|
|
1408
1408
|
if (!this.skipHistory) {
|
|
1409
1409
|
if (this.currentIndex <= 0) {
|
|
1410
1410
|
console.log("Нет предыдущих состояний для отмены.");
|
|
@@ -1441,7 +1441,7 @@ class Qt {
|
|
|
1441
1441
|
* @fires editor:redo
|
|
1442
1442
|
*/
|
|
1443
1443
|
redo() {
|
|
1444
|
-
return
|
|
1444
|
+
return N(this, null, function* () {
|
|
1445
1445
|
if (!this.skipHistory) {
|
|
1446
1446
|
if (this.currentIndex >= this.patches.length) {
|
|
1447
1447
|
console.log("Нет состояний для повтора.");
|
|
@@ -1496,7 +1496,7 @@ class Qt {
|
|
|
1496
1496
|
}
|
|
1497
1497
|
}
|
|
1498
1498
|
}
|
|
1499
|
-
const Ws = 0.1, Zs = 2, We = 0.1, Gs = 90,
|
|
1499
|
+
const Ws = 0.1, Zs = 2, We = 0.1, Gs = 90, Rt = 16, _t = 16, Mt = 4096, wt = 4096, Ze = "application/image-editor:", Xt = [
|
|
1500
1500
|
"format",
|
|
1501
1501
|
"uppercase",
|
|
1502
1502
|
"textCaseRaw",
|
|
@@ -1511,7 +1511,7 @@ const Ws = 0.1, Zs = 2, We = 0.1, Gs = 90, Et = 16, Ot = 16, pt = 4096, mt = 409
|
|
|
1511
1511
|
"radiusBottomRight",
|
|
1512
1512
|
"radiusBottomLeft"
|
|
1513
1513
|
], Vs = 50;
|
|
1514
|
-
class
|
|
1514
|
+
class ct {
|
|
1515
1515
|
constructor({ editor: t }) {
|
|
1516
1516
|
this.editor = t, this.options = t.options, this._createdBlobUrls = [], this.acceptContentTypes = this.editor.options.acceptContentTypes, this.acceptFormats = this.getAllowedFormatsFromContentTypes();
|
|
1517
1517
|
}
|
|
@@ -1528,7 +1528,7 @@ class rt {
|
|
|
1528
1528
|
* @returns возвращает Promise с объектом изображения или null в случае ошибки
|
|
1529
1529
|
*/
|
|
1530
1530
|
importImage(t) {
|
|
1531
|
-
return
|
|
1531
|
+
return N(this, null, function* () {
|
|
1532
1532
|
const {
|
|
1533
1533
|
source: e,
|
|
1534
1534
|
scale: s = `image-${this.options.scaleType}`,
|
|
@@ -1538,7 +1538,7 @@ class rt {
|
|
|
1538
1538
|
withoutSelection: a = !1
|
|
1539
1539
|
} = t;
|
|
1540
1540
|
if (!e) return null;
|
|
1541
|
-
const { canvas: r, montageArea: c, transformManager: d, historyManager: l, errorManager: u } = this.editor, g = yield this.getContentType(e), f =
|
|
1541
|
+
const { canvas: r, montageArea: c, transformManager: d, historyManager: l, errorManager: u } = this.editor, g = yield this.getContentType(e), f = ct.getFormatFromContentType(g), { acceptContentTypes: p, acceptFormats: m } = this;
|
|
1542
1542
|
if (!this.isAllowedContentType(g)) {
|
|
1543
1543
|
const v = `Неверный contentType для изображения: ${g}. Ожидается один из: ${this.acceptContentTypes.join(", ")}.`;
|
|
1544
1544
|
return u.emitError({
|
|
@@ -1564,8 +1564,8 @@ class rt {
|
|
|
1564
1564
|
if (e instanceof File)
|
|
1565
1565
|
v = URL.createObjectURL(e);
|
|
1566
1566
|
else if (typeof e == "string") {
|
|
1567
|
-
const
|
|
1568
|
-
v = URL.createObjectURL(
|
|
1567
|
+
const j = yield (yield fetch(e, { mode: "cors" })).blob();
|
|
1568
|
+
v = URL.createObjectURL(j);
|
|
1569
1569
|
} else
|
|
1570
1570
|
return u.emitError({
|
|
1571
1571
|
origin: "ImageManager",
|
|
@@ -1584,27 +1584,27 @@ class rt {
|
|
|
1584
1584
|
}
|
|
1585
1585
|
}), null;
|
|
1586
1586
|
if (this._createdBlobUrls.push(v), f === "svg") {
|
|
1587
|
-
const
|
|
1588
|
-
b =
|
|
1587
|
+
const A = yield us(v);
|
|
1588
|
+
b = dt.groupSVGElements(A.objects, A.options);
|
|
1589
1589
|
} else
|
|
1590
|
-
b = yield
|
|
1590
|
+
b = yield zt.fromURL(v, { crossOrigin: "anonymous" });
|
|
1591
1591
|
const { width: I, height: y } = b;
|
|
1592
|
-
if (b instanceof
|
|
1593
|
-
const
|
|
1594
|
-
let
|
|
1595
|
-
if (
|
|
1596
|
-
const M = yield this.resizeImageToBoundaries(
|
|
1597
|
-
this._createdBlobUrls.push(
|
|
1598
|
-
} else if (y <
|
|
1599
|
-
const M = yield this.resizeImageToBoundaries(
|
|
1600
|
-
this._createdBlobUrls.push(
|
|
1592
|
+
if (b instanceof zt) {
|
|
1593
|
+
const A = b.getElement();
|
|
1594
|
+
let j = "";
|
|
1595
|
+
if (A instanceof HTMLImageElement ? j = A.src : A instanceof HTMLCanvasElement && (j = A.toDataURL()), y > wt || I > Mt) {
|
|
1596
|
+
const M = yield this.resizeImageToBoundaries(j, "max"), T = URL.createObjectURL(M);
|
|
1597
|
+
this._createdBlobUrls.push(T), b = yield zt.fromURL(T, { crossOrigin: "anonymous" });
|
|
1598
|
+
} else if (y < _t || I < Rt) {
|
|
1599
|
+
const M = yield this.resizeImageToBoundaries(j, "min"), T = URL.createObjectURL(M);
|
|
1600
|
+
this._createdBlobUrls.push(T), b = yield zt.fromURL(T, { crossOrigin: "anonymous" });
|
|
1601
1601
|
}
|
|
1602
1602
|
}
|
|
1603
|
-
if (b.set("id", `${b.type}-${
|
|
1603
|
+
if (b.set("id", `${b.type}-${G()}`), b.set("format", f), s === "scale-montage")
|
|
1604
1604
|
this.editor.canvasManager.scaleMontageAreaToImage({ object: b, withoutSave: !0 });
|
|
1605
1605
|
else {
|
|
1606
|
-
const { width:
|
|
1607
|
-
s === "image-contain" && M < 1 ? d.fitObject({ object: b, type: "contain", withoutSave: !0 }) : s === "image-cover" && (I >
|
|
1606
|
+
const { width: A, height: j } = c, M = this.calculateScaleFactor({ imageObject: b, scaleType: s });
|
|
1607
|
+
s === "image-contain" && M < 1 ? d.fitObject({ object: b, type: "contain", withoutSave: !0 }) : s === "image-cover" && (I > A || y > j) && d.fitObject({ object: b, type: "cover", withoutSave: !0 });
|
|
1608
1608
|
}
|
|
1609
1609
|
r.add(b), r.centerObject(b), a || r.setActiveObject(b), r.renderAll(), l.resumeHistory(), o || l.saveState();
|
|
1610
1610
|
const w = {
|
|
@@ -1648,16 +1648,16 @@ class rt {
|
|
|
1648
1648
|
* @returns возвращает Promise с Blob-объектом уменьшенного изображения
|
|
1649
1649
|
*/
|
|
1650
1650
|
resizeImageToBoundaries(t, e = "max") {
|
|
1651
|
-
return
|
|
1652
|
-
let s = `Размер изображения больше максимального размера канваса, поэтому оно будет уменьшено до максимальных размеров c сохранением пропорций: ${
|
|
1653
|
-
e === "min" && (s = `Размер изображения меньше минимального размера канваса, поэтому оно будет увеличено до минимальных размеров c сохранением пропорций: ${
|
|
1651
|
+
return N(this, null, function* () {
|
|
1652
|
+
let s = `Размер изображения больше максимального размера канваса, поэтому оно будет уменьшено до максимальных размеров c сохранением пропорций: ${Mt}x${wt}`;
|
|
1653
|
+
e === "min" && (s = `Размер изображения меньше минимального размера канваса, поэтому оно будет увеличено до минимальных размеров c сохранением пропорций: ${Rt}x${_t}`);
|
|
1654
1654
|
const o = {
|
|
1655
1655
|
dataURL: t,
|
|
1656
1656
|
sizeType: e,
|
|
1657
|
-
maxWidth:
|
|
1658
|
-
maxHeight:
|
|
1659
|
-
minWidth:
|
|
1660
|
-
minHeight:
|
|
1657
|
+
maxWidth: Mt,
|
|
1658
|
+
maxHeight: wt,
|
|
1659
|
+
minWidth: Rt,
|
|
1660
|
+
minHeight: _t
|
|
1661
1661
|
};
|
|
1662
1662
|
return this.editor.errorManager.emitWarning({
|
|
1663
1663
|
origin: "ImageManager",
|
|
@@ -1680,7 +1680,7 @@ class rt {
|
|
|
1680
1680
|
* @fires editor:canvas-exported
|
|
1681
1681
|
*/
|
|
1682
1682
|
exportCanvasAsImageFile() {
|
|
1683
|
-
return
|
|
1683
|
+
return N(this, arguments, function* (t = {}) {
|
|
1684
1684
|
const {
|
|
1685
1685
|
fileName: e = "image.png",
|
|
1686
1686
|
contentType: s = "image/png",
|
|
@@ -1688,22 +1688,22 @@ class rt {
|
|
|
1688
1688
|
exportAsBlob: n = !1
|
|
1689
1689
|
} = t, { canvas: i, montageArea: a, workerManager: r, interactionBlocker: c } = this.editor;
|
|
1690
1690
|
try {
|
|
1691
|
-
const d = s === "application/pdf", l = d ? "image/jpg" : s, u =
|
|
1691
|
+
const d = s === "application/pdf", l = d ? "image/jpg" : s, u = ct.getFormatFromContentType(l);
|
|
1692
1692
|
a.setCoords();
|
|
1693
1693
|
const { left: g, top: f, width: p, height: m } = a.getBoundingRect(), v = yield i.clone(["id", "format", "locked"]);
|
|
1694
1694
|
v.enableRetinaScaling = !1, ["image/jpg", "image/jpeg"].includes(l) && (v.backgroundColor = "#ffffff");
|
|
1695
|
-
const b = v.getObjects().find((
|
|
1695
|
+
const b = v.getObjects().find((S) => S.id === a.id);
|
|
1696
1696
|
if (b && (b.visible = !1), c != null && c.isBlocked) {
|
|
1697
|
-
const
|
|
1698
|
-
|
|
1697
|
+
const S = v.getObjects().find((C) => C.id === c.overlayMask.id);
|
|
1698
|
+
S && (S.visible = !1);
|
|
1699
1699
|
}
|
|
1700
1700
|
v.viewportTransform = [1, 0, 0, 1, -g, -f], v.setDimensions({ width: p, height: m }, { backstoreOnly: !0 }), v.renderAll();
|
|
1701
|
-
const I = v.getObjects().filter((
|
|
1701
|
+
const I = v.getObjects().filter((S) => S.format).every((S) => S.format === "svg");
|
|
1702
1702
|
if (u === "svg" && I) {
|
|
1703
|
-
const
|
|
1703
|
+
const S = v.toSVG();
|
|
1704
1704
|
v.dispose();
|
|
1705
1705
|
const B = {
|
|
1706
|
-
image:
|
|
1706
|
+
image: ct._exportSVGStringAsFile(S, {
|
|
1707
1707
|
exportAsBase64: o,
|
|
1708
1708
|
exportAsBlob: n,
|
|
1709
1709
|
fileName: e
|
|
@@ -1714,64 +1714,64 @@ class rt {
|
|
|
1714
1714
|
};
|
|
1715
1715
|
return i.fire("editor:canvas-exported", B), B;
|
|
1716
1716
|
}
|
|
1717
|
-
const y = yield new Promise((
|
|
1717
|
+
const y = yield new Promise((S, C) => {
|
|
1718
1718
|
v.getElement().toBlob((B) => {
|
|
1719
|
-
B ?
|
|
1719
|
+
B ? S(B) : C(new Error("Failed to create Blob from canvas"));
|
|
1720
1720
|
});
|
|
1721
1721
|
});
|
|
1722
1722
|
if (v.dispose(), n) {
|
|
1723
|
-
const
|
|
1723
|
+
const S = {
|
|
1724
1724
|
image: y,
|
|
1725
1725
|
format: u,
|
|
1726
1726
|
contentType: l,
|
|
1727
1727
|
fileName: e
|
|
1728
1728
|
};
|
|
1729
|
-
return i.fire("editor:canvas-exported",
|
|
1729
|
+
return i.fire("editor:canvas-exported", S), S;
|
|
1730
1730
|
}
|
|
1731
|
-
const w = yield createImageBitmap(y),
|
|
1731
|
+
const w = yield createImageBitmap(y), A = yield r.post(
|
|
1732
1732
|
"toDataURL",
|
|
1733
1733
|
{ format: u, quality: 1, bitmap: w },
|
|
1734
1734
|
[w]
|
|
1735
1735
|
);
|
|
1736
1736
|
if (d) {
|
|
1737
|
-
const
|
|
1738
|
-
orientation:
|
|
1737
|
+
const C = p * 0.264583, B = m * 0.264583, F = (yield this.editor.moduleLoader.loadModule("jspdf")).jsPDF, U = new F({
|
|
1738
|
+
orientation: C > B ? "landscape" : "portrait",
|
|
1739
1739
|
unit: "mm",
|
|
1740
|
-
format: [
|
|
1740
|
+
format: [C, B]
|
|
1741
1741
|
});
|
|
1742
|
-
if (
|
|
1743
|
-
const
|
|
1744
|
-
image:
|
|
1742
|
+
if (U.addImage(String(A), "JPG", 0, 0, C, B), o) {
|
|
1743
|
+
const z = {
|
|
1744
|
+
image: U.output("datauristring"),
|
|
1745
1745
|
format: "pdf",
|
|
1746
1746
|
contentType: "application/pdf",
|
|
1747
1747
|
fileName: e
|
|
1748
1748
|
};
|
|
1749
|
-
return i.fire("editor:canvas-exported",
|
|
1749
|
+
return i.fire("editor:canvas-exported", z), z;
|
|
1750
1750
|
}
|
|
1751
|
-
const H =
|
|
1751
|
+
const H = U.output("blob"), L = {
|
|
1752
1752
|
image: new File([H], e, { type: "application/pdf" }),
|
|
1753
1753
|
format: "pdf",
|
|
1754
1754
|
contentType: "application/pdf",
|
|
1755
1755
|
fileName: e
|
|
1756
1756
|
};
|
|
1757
|
-
return i.fire("editor:canvas-exported",
|
|
1757
|
+
return i.fire("editor:canvas-exported", L), L;
|
|
1758
1758
|
}
|
|
1759
1759
|
if (o) {
|
|
1760
|
-
const
|
|
1761
|
-
image:
|
|
1760
|
+
const S = {
|
|
1761
|
+
image: A,
|
|
1762
1762
|
format: u,
|
|
1763
1763
|
contentType: l,
|
|
1764
1764
|
fileName: e
|
|
1765
1765
|
};
|
|
1766
|
-
return i.fire("editor:canvas-exported",
|
|
1766
|
+
return i.fire("editor:canvas-exported", S), S;
|
|
1767
1767
|
}
|
|
1768
|
-
const
|
|
1769
|
-
image: new File([y],
|
|
1768
|
+
const j = u === "svg" && !I ? e.replace(/\.[^/.]+$/, ".png") : e, T = {
|
|
1769
|
+
image: new File([y], j, { type: l }),
|
|
1770
1770
|
format: u,
|
|
1771
1771
|
contentType: l,
|
|
1772
|
-
fileName:
|
|
1772
|
+
fileName: j
|
|
1773
1773
|
};
|
|
1774
|
-
return i.fire("editor:canvas-exported",
|
|
1774
|
+
return i.fire("editor:canvas-exported", T), T;
|
|
1775
1775
|
} catch (d) {
|
|
1776
1776
|
return this.editor.errorManager.emitError({
|
|
1777
1777
|
origin: "ImageManager",
|
|
@@ -1795,7 +1795,7 @@ class rt {
|
|
|
1795
1795
|
* @fires editor:object-exported
|
|
1796
1796
|
*/
|
|
1797
1797
|
exportObjectAsImageFile() {
|
|
1798
|
-
return
|
|
1798
|
+
return N(this, arguments, function* (t = {}) {
|
|
1799
1799
|
const {
|
|
1800
1800
|
object: e,
|
|
1801
1801
|
fileName: s = "image.png",
|
|
@@ -1812,9 +1812,9 @@ class rt {
|
|
|
1812
1812
|
data: { contentType: o, fileName: s, exportAsBase64: n, exportAsBlob: i }
|
|
1813
1813
|
}), null;
|
|
1814
1814
|
try {
|
|
1815
|
-
const d =
|
|
1815
|
+
const d = ct.getFormatFromContentType(o);
|
|
1816
1816
|
if (d === "svg") {
|
|
1817
|
-
const p = c.toSVG(), m =
|
|
1817
|
+
const p = c.toSVG(), m = ct._exportSVGStringAsFile(p, {
|
|
1818
1818
|
exportAsBase64: n,
|
|
1819
1819
|
exportAsBlob: i,
|
|
1820
1820
|
fileName: s
|
|
@@ -1827,7 +1827,7 @@ class rt {
|
|
|
1827
1827
|
};
|
|
1828
1828
|
return a.fire("editor:object-exported", v), v;
|
|
1829
1829
|
}
|
|
1830
|
-
if (n && c instanceof
|
|
1830
|
+
if (n && c instanceof zt) {
|
|
1831
1831
|
const p = yield createImageBitmap(c.getElement()), m = yield r.post(
|
|
1832
1832
|
"toDataURL",
|
|
1833
1833
|
{
|
|
@@ -1892,7 +1892,7 @@ class rt {
|
|
|
1892
1892
|
* @returns массив допустимых форматов изображений
|
|
1893
1893
|
*/
|
|
1894
1894
|
getAllowedFormatsFromContentTypes() {
|
|
1895
|
-
return this.acceptContentTypes.map((t) =>
|
|
1895
|
+
return this.acceptContentTypes.map((t) => ct.getFormatFromContentType(t)).filter((t) => t);
|
|
1896
1896
|
}
|
|
1897
1897
|
/**
|
|
1898
1898
|
* Проверяет, является ли contentType допустимым типом изображения.
|
|
@@ -1908,7 +1908,7 @@ class rt {
|
|
|
1908
1908
|
* @public
|
|
1909
1909
|
*/
|
|
1910
1910
|
getContentType(t) {
|
|
1911
|
-
return
|
|
1911
|
+
return N(this, null, function* () {
|
|
1912
1912
|
return typeof t == "string" ? this.getContentTypeFromUrl(t) : t.type || "application/octet-stream";
|
|
1913
1913
|
});
|
|
1914
1914
|
}
|
|
@@ -1919,7 +1919,7 @@ class rt {
|
|
|
1919
1919
|
* @public
|
|
1920
1920
|
*/
|
|
1921
1921
|
getContentTypeFromUrl(t) {
|
|
1922
|
-
return
|
|
1922
|
+
return N(this, null, function* () {
|
|
1923
1923
|
if (t.startsWith("data:")) {
|
|
1924
1924
|
const e = t.match(/^data:([^;]+)/);
|
|
1925
1925
|
return e ? e[1] : "application/octet-stream";
|
|
@@ -1945,7 +1945,7 @@ class rt {
|
|
|
1945
1945
|
try {
|
|
1946
1946
|
const o = (e = new URL(t).pathname.split(".").pop()) == null ? void 0 : e.toLowerCase(), n = {};
|
|
1947
1947
|
return this.acceptContentTypes.forEach((i) => {
|
|
1948
|
-
const a =
|
|
1948
|
+
const a = ct.getFormatFromContentType(i);
|
|
1949
1949
|
a && (n[a] = i);
|
|
1950
1950
|
}), o && n[o] || "application/octet-stream";
|
|
1951
1951
|
} catch (s) {
|
|
@@ -1998,7 +1998,7 @@ class rt {
|
|
|
1998
1998
|
return e ? e[1] : "";
|
|
1999
1999
|
}
|
|
2000
2000
|
}
|
|
2001
|
-
const
|
|
2001
|
+
const Tt = (h, t, e) => Math.max(Math.min(h, e), t), Ge = (h, t) => h * t, Xs = (h, t) => new tt(h / 2, t / 2);
|
|
2002
2002
|
function Ks(h) {
|
|
2003
2003
|
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";
|
|
2004
2004
|
}
|
|
@@ -2033,7 +2033,7 @@ class Qs {
|
|
|
2033
2033
|
canvas: n,
|
|
2034
2034
|
montageArea: i,
|
|
2035
2035
|
options: { canvasBackstoreWidth: a }
|
|
2036
|
-
} = this.editor, { width: r, height: c } = i, d =
|
|
2036
|
+
} = this.editor, { width: r, height: c } = i, d = Tt(Number(t), Rt, Mt);
|
|
2037
2037
|
if (!a || a === "auto" || o ? this.adaptCanvasToContainer() : a ? this.setCanvasBackstoreWidth(Number(a)) : this.setCanvasBackstoreWidth(d), i.set({ width: d }), (f = n.clipPath) == null || f.set({ width: d }), e) {
|
|
2038
2038
|
const p = d / r, m = Ge(c, p);
|
|
2039
2039
|
this.setResolutionHeight(m);
|
|
@@ -2063,7 +2063,7 @@ class Qs {
|
|
|
2063
2063
|
canvas: n,
|
|
2064
2064
|
montageArea: i,
|
|
2065
2065
|
options: { canvasBackstoreHeight: a }
|
|
2066
|
-
} = this.editor, { width: r, height: c } = i, d =
|
|
2066
|
+
} = this.editor, { width: r, height: c } = i, d = Tt(Number(t), _t, wt);
|
|
2067
2067
|
if (!a || a === "auto" || o ? this.adaptCanvasToContainer() : a ? this.setCanvasBackstoreHeight(Number(a)) : this.setCanvasBackstoreHeight(d), i.set({ height: d }), (f = n.clipPath) == null || f.set({ height: d }), e) {
|
|
2068
2068
|
const p = d / c, m = Ge(r, p);
|
|
2069
2069
|
this.setResolutionWidth(m);
|
|
@@ -2116,7 +2116,7 @@ class Qs {
|
|
|
2116
2116
|
*/
|
|
2117
2117
|
setCanvasBackstoreWidth(t) {
|
|
2118
2118
|
if (!t || typeof t != "number") return;
|
|
2119
|
-
const e =
|
|
2119
|
+
const e = Tt(t, Rt, Mt);
|
|
2120
2120
|
this.editor.canvas.setDimensions({ width: e }, { backstoreOnly: !0 });
|
|
2121
2121
|
}
|
|
2122
2122
|
/**
|
|
@@ -2125,7 +2125,7 @@ class Qs {
|
|
|
2125
2125
|
*/
|
|
2126
2126
|
setCanvasBackstoreHeight(t) {
|
|
2127
2127
|
if (!t || typeof t != "number") return;
|
|
2128
|
-
const e =
|
|
2128
|
+
const e = Tt(t, _t, wt);
|
|
2129
2129
|
this.editor.canvas.setDimensions({ height: e }, { backstoreOnly: !0 });
|
|
2130
2130
|
}
|
|
2131
2131
|
/**
|
|
@@ -2134,7 +2134,7 @@ class Qs {
|
|
|
2134
2134
|
* с учётом минимальных и максимальных значений.
|
|
2135
2135
|
*/
|
|
2136
2136
|
adaptCanvasToContainer() {
|
|
2137
|
-
const { canvas: t } = this.editor, e = this.getEditorContainer(), s = e.clientWidth, o = e.clientHeight, n =
|
|
2137
|
+
const { canvas: t } = this.editor, e = this.getEditorContainer(), s = e.clientWidth, o = e.clientHeight, n = Tt(s, Rt, Mt), i = Tt(o, _t, wt);
|
|
2138
2138
|
t.setDimensions({ width: n, height: i }, { backstoreOnly: !0 });
|
|
2139
2139
|
}
|
|
2140
2140
|
/**
|
|
@@ -2168,7 +2168,7 @@ class Qs {
|
|
|
2168
2168
|
if (d.length === 1)
|
|
2169
2169
|
t.setActiveObject(d[0]);
|
|
2170
2170
|
else {
|
|
2171
|
-
const l = new
|
|
2171
|
+
const l = new x(d, {
|
|
2172
2172
|
canvas: t
|
|
2173
2173
|
});
|
|
2174
2174
|
t.setActiveObject(l);
|
|
@@ -2336,7 +2336,7 @@ class Qs {
|
|
|
2336
2336
|
} = this.editor, c = t || o.getActiveObject();
|
|
2337
2337
|
if (!Ks(c)) return;
|
|
2338
2338
|
const { width: d, height: l } = c;
|
|
2339
|
-
let u = Math.min(d,
|
|
2339
|
+
let u = Math.min(d, Mt), g = Math.min(l, wt);
|
|
2340
2340
|
if (e) {
|
|
2341
2341
|
const {
|
|
2342
2342
|
width: f,
|
|
@@ -2455,7 +2455,7 @@ class qs {
|
|
|
2455
2455
|
withoutSave: s
|
|
2456
2456
|
} = {}) {
|
|
2457
2457
|
const { canvas: o, historyManager: n } = this.editor, i = t || o.getActiveObject();
|
|
2458
|
-
i && (i instanceof
|
|
2458
|
+
i && (i instanceof x ? i.getObjects().forEach((a) => {
|
|
2459
2459
|
a.set("opacity", e);
|
|
2460
2460
|
}) : i.set("opacity", e), o.renderAll(), s || n.saveState(), o.fire("editor:object-opacity-changed", {
|
|
2461
2461
|
object: i,
|
|
@@ -2482,12 +2482,12 @@ class qs {
|
|
|
2482
2482
|
} = {}) {
|
|
2483
2483
|
const { canvas: n, historyManager: i } = this.editor, a = t || n.getActiveObject();
|
|
2484
2484
|
if (a) {
|
|
2485
|
-
if (a instanceof
|
|
2485
|
+
if (a instanceof x && !o) {
|
|
2486
2486
|
const r = a.getObjects();
|
|
2487
2487
|
n.discardActiveObject(), r.forEach((d) => {
|
|
2488
2488
|
this._fitSingleObject(d, e);
|
|
2489
2489
|
});
|
|
2490
|
-
const c = new
|
|
2490
|
+
const c = new x(r, { canvas: n });
|
|
2491
2491
|
n.setActiveObject(c);
|
|
2492
2492
|
} else
|
|
2493
2493
|
this._fitSingleObject(a, e);
|
|
@@ -2560,7 +2560,7 @@ class qs {
|
|
|
2560
2560
|
});
|
|
2561
2561
|
}
|
|
2562
2562
|
}
|
|
2563
|
-
class
|
|
2563
|
+
class Js {
|
|
2564
2564
|
constructor({ editor: t }) {
|
|
2565
2565
|
this.editor = t, this.options = t.options, this.minZoom = this.options.minZoom || Ws, this.maxZoom = this.options.maxZoom || Zs, this.defaultZoom = this.options.defaultScale;
|
|
2566
2566
|
}
|
|
@@ -2621,8 +2621,8 @@ class $s {
|
|
|
2621
2621
|
_calculateEmptySpaceRatio(t) {
|
|
2622
2622
|
const { canvas: e, montageArea: s } = this.editor, o = e.viewportTransform, n = e.getWidth(), i = e.getHeight(), a = s.left - s.width / 2, r = s.left + s.width / 2, c = s.top - s.height / 2, d = s.top + s.height / 2, l = -o[4] / t, u = (-o[4] + n) / t, g = -o[5] / t, f = (-o[5] + i) / t, p = l < a, m = u > r, v = g < c, b = f > d;
|
|
2623
2623
|
if (!(p || m || v || b)) return 0;
|
|
2624
|
-
const y = Math.max(0, a - l), w = Math.max(0, u - r),
|
|
2625
|
-
return Math.max(
|
|
2624
|
+
const y = Math.max(0, a - l), w = Math.max(0, u - r), A = Math.max(0, c - g), j = Math.max(0, f - d), M = Math.max(y, w), T = Math.max(A, j), S = M / n, C = T / i;
|
|
2625
|
+
return Math.max(S, C);
|
|
2626
2626
|
}
|
|
2627
2627
|
/**
|
|
2628
2628
|
* Вычисляет плавный шаг перемещения viewport к центру с ускорением
|
|
@@ -2638,8 +2638,8 @@ class $s {
|
|
|
2638
2638
|
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], g = Math.abs(o), f = e - s;
|
|
2639
2639
|
if (Math.abs(f) / g <= 0.1)
|
|
2640
2640
|
return { x: l, y: u };
|
|
2641
|
-
const m = c / 2, v = d / 2, b = a.left, I = a.top, y = m - b * s, w = v - I * s,
|
|
2642
|
-
return { x: B, y:
|
|
2641
|
+
const m = c / 2, v = d / 2, b = a.left, I = a.top, y = m - b * s, w = v - I * s, A = (y - r[4]) / (e - s), j = (w - r[5]) / (e - s), M = A * g, T = j * g, S = M * n, C = T * n, B = Math.abs(S) > Math.abs(l) ? l : S, F = Math.abs(C) > Math.abs(u) ? u : C;
|
|
2642
|
+
return { x: B, y: F };
|
|
2643
2643
|
}
|
|
2644
2644
|
/**
|
|
2645
2645
|
* Применяет плавное центрирование viewport при приближении к defaultZoom.
|
|
@@ -2729,7 +2729,7 @@ class $s {
|
|
|
2729
2729
|
zoom(t = We, e = {}) {
|
|
2730
2730
|
var g, f;
|
|
2731
2731
|
if (!t) return;
|
|
2732
|
-
const { minZoom: s, maxZoom: o } = this, { canvas: n } = this.editor, i = t < 0, a = n.getZoom(), r = n.getCenterPoint(), c = (g = e.pointX) != null ? g : r.x, d = (f = e.pointY) != null ? f : r.y, l = new
|
|
2732
|
+
const { minZoom: s, maxZoom: o } = this, { canvas: n } = this.editor, i = t < 0, a = n.getZoom(), r = n.getCenterPoint(), c = (g = e.pointX) != null ? g : r.x, d = (f = e.pointY) != null ? f : r.y, l = new tt(c, d);
|
|
2733
2733
|
this.editor.montageArea.setCoords(), this.editor.canvas.requestRenderAll();
|
|
2734
2734
|
let u = Number((a + Number(t)).toFixed(3));
|
|
2735
2735
|
u > o && (u = o), u < s && (u = s), n.zoomToPoint(l, u), this.editor.panConstraintManager.updateBounds(), this._applyViewportCentering(u, i, t), n.fire("editor:zoom-changed", {
|
|
@@ -2744,7 +2744,7 @@ class $s {
|
|
|
2744
2744
|
* @fires editor:zoom-changed
|
|
2745
2745
|
*/
|
|
2746
2746
|
setZoom(t = this.defaultZoom) {
|
|
2747
|
-
const { minZoom: e, maxZoom: s } = this, { canvas: o } = this.editor, n = new
|
|
2747
|
+
const { minZoom: e, maxZoom: s } = this, { canvas: o } = this.editor, n = new tt(o.getCenterPoint());
|
|
2748
2748
|
let i = t;
|
|
2749
2749
|
t > s && (i = s), t < e && (i = e), o.zoomToPoint(n, i), o.fire("editor:zoom-changed", {
|
|
2750
2750
|
currentZoom: o.getZoom(),
|
|
@@ -2757,14 +2757,14 @@ class $s {
|
|
|
2757
2757
|
* @fires editor:zoom-changed
|
|
2758
2758
|
*/
|
|
2759
2759
|
resetZoom() {
|
|
2760
|
-
const { canvas: t } = this.editor, e = new
|
|
2760
|
+
const { canvas: t } = this.editor, e = new tt(t.getCenterPoint());
|
|
2761
2761
|
t.zoomToPoint(e, this.defaultZoom), this.editor.canvas.fire("editor:zoom-changed", {
|
|
2762
2762
|
currentZoom: t.getZoom(),
|
|
2763
2763
|
point: e
|
|
2764
2764
|
}), this.editor.panConstraintManager.updateBounds();
|
|
2765
2765
|
}
|
|
2766
2766
|
}
|
|
2767
|
-
class
|
|
2767
|
+
class $s {
|
|
2768
2768
|
constructor({ editor: t }) {
|
|
2769
2769
|
this.editor = t, this.isBlocked = !1, this.overlayMask = null, this._createOverlay();
|
|
2770
2770
|
}
|
|
@@ -2821,7 +2821,7 @@ class Js {
|
|
|
2821
2821
|
}), t.upperCanvasEl.style.pointerEvents = "", t.lowerCanvasEl.style.pointerEvents = "", this.overlayMask.visible = !1, t.requestRenderAll(), t.fire("editor:enabled"), s.resumeHistory();
|
|
2822
2822
|
}
|
|
2823
2823
|
}
|
|
2824
|
-
class
|
|
2824
|
+
class Ot {
|
|
2825
2825
|
constructor({ editor: t }) {
|
|
2826
2826
|
this.editor = t, this.backgroundObject = null;
|
|
2827
2827
|
}
|
|
@@ -2846,7 +2846,7 @@ class It {
|
|
|
2846
2846
|
}
|
|
2847
2847
|
i.set({
|
|
2848
2848
|
fill: t,
|
|
2849
|
-
backgroundId: `background-${
|
|
2849
|
+
backgroundId: `background-${G()}`
|
|
2850
2850
|
}), this.editor.canvas.requestRenderAll();
|
|
2851
2851
|
} else
|
|
2852
2852
|
this._removeCurrentBackground(), this._createColorBackground(t);
|
|
@@ -2876,14 +2876,14 @@ class It {
|
|
|
2876
2876
|
try {
|
|
2877
2877
|
const { historyManager: n } = this.editor, { backgroundObject: i } = this;
|
|
2878
2878
|
if (n.suspendHistory(), i && i.backgroundType === "gradient") {
|
|
2879
|
-
const a =
|
|
2880
|
-
if (
|
|
2879
|
+
const a = Ot._createFabricGradient(t);
|
|
2880
|
+
if (Ot._isGradientEqual(i.fill, a)) {
|
|
2881
2881
|
n.resumeHistory();
|
|
2882
2882
|
return;
|
|
2883
2883
|
}
|
|
2884
2884
|
i.set({
|
|
2885
2885
|
fill: a,
|
|
2886
|
-
backgroundId: `background-${
|
|
2886
|
+
backgroundId: `background-${G()}`
|
|
2887
2887
|
}), this.editor.canvas.requestRenderAll();
|
|
2888
2888
|
} else
|
|
2889
2889
|
this._removeCurrentBackground(), this._createGradientBackground(t);
|
|
@@ -2964,7 +2964,7 @@ class It {
|
|
|
2964
2964
|
* @param options.withoutSave - Если true, не сохранять состояние в историю
|
|
2965
2965
|
*/
|
|
2966
2966
|
setImageBackground(o) {
|
|
2967
|
-
return
|
|
2967
|
+
return N(this, arguments, function* ({
|
|
2968
2968
|
imageSource: t,
|
|
2969
2969
|
customData: e = {},
|
|
2970
2970
|
withoutSave: s = !1
|
|
@@ -3030,7 +3030,7 @@ class It {
|
|
|
3030
3030
|
hasControls: !1,
|
|
3031
3031
|
id: "background",
|
|
3032
3032
|
backgroundType: "color",
|
|
3033
|
-
backgroundId: `background-${
|
|
3033
|
+
backgroundId: `background-${G()}`
|
|
3034
3034
|
}, { withoutSelection: !0 }), this.refresh();
|
|
3035
3035
|
}
|
|
3036
3036
|
/**
|
|
@@ -3047,9 +3047,9 @@ class It {
|
|
|
3047
3047
|
hasControls: !1,
|
|
3048
3048
|
id: "background",
|
|
3049
3049
|
backgroundType: "gradient",
|
|
3050
|
-
backgroundId: `background-${
|
|
3050
|
+
backgroundId: `background-${G()}`
|
|
3051
3051
|
}, { withoutSelection: !0 }), this.refresh();
|
|
3052
|
-
const e =
|
|
3052
|
+
const e = Ot._createFabricGradient(t);
|
|
3053
3053
|
this.backgroundObject.set("fill", e), this.editor.canvas.requestRenderAll();
|
|
3054
3054
|
}
|
|
3055
3055
|
/**
|
|
@@ -3057,7 +3057,7 @@ class It {
|
|
|
3057
3057
|
* @param source - источник изображения (URL или File)
|
|
3058
3058
|
*/
|
|
3059
3059
|
_createImageBackground(t, e) {
|
|
3060
|
-
return
|
|
3060
|
+
return N(this, null, function* () {
|
|
3061
3061
|
var o;
|
|
3062
3062
|
const { image: s } = (o = yield this.editor.imageManager.importImage({
|
|
3063
3063
|
source: t,
|
|
@@ -3075,7 +3075,7 @@ class It {
|
|
|
3075
3075
|
hasControls: !1,
|
|
3076
3076
|
id: "background",
|
|
3077
3077
|
backgroundType: "image",
|
|
3078
|
-
backgroundId: `background-${
|
|
3078
|
+
backgroundId: `background-${G()}`,
|
|
3079
3079
|
customData: e
|
|
3080
3080
|
}), this._removeCurrentBackground(), this.backgroundObject = s, this.refresh();
|
|
3081
3081
|
});
|
|
@@ -3101,7 +3101,7 @@ class It {
|
|
|
3101
3101
|
{ offset: n / 100, color: s }
|
|
3102
3102
|
];
|
|
3103
3103
|
if (t.type === "linear") {
|
|
3104
|
-
const l = t.angle * Math.PI / 180, u =
|
|
3104
|
+
const l = t.angle * Math.PI / 180, u = Ot._angleToCoords(l);
|
|
3105
3105
|
return new ze({
|
|
3106
3106
|
type: "linear",
|
|
3107
3107
|
gradientUnits: "percentage",
|
|
@@ -3156,7 +3156,7 @@ class It {
|
|
|
3156
3156
|
}) ? !1 : t.type === "linear" && e.type === "linear" ? Math.abs(t.coords.x1 - e.coords.x1) < 1e-4 && Math.abs(t.coords.y1 - e.coords.y1) < 1e-4 && Math.abs(t.coords.x2 - e.coords.x2) < 1e-4 && Math.abs(t.coords.y2 - e.coords.y2) < 1e-4 : t.type === "radial" && e.type === "radial" ? Math.abs(t.coords.x1 - e.coords.x1) < 1e-4 && Math.abs(t.coords.y1 - e.coords.y1) < 1e-4 && Math.abs(t.coords.x2 - e.coords.x2) < 1e-4 && Math.abs(t.coords.y2 - e.coords.y2) < 1e-4 && Math.abs(t.coords.r1 - e.coords.r1) < 1e-4 && Math.abs(t.coords.r2 - e.coords.r2) < 1e-4 : !1;
|
|
3157
3157
|
}
|
|
3158
3158
|
}
|
|
3159
|
-
class
|
|
3159
|
+
class $t {
|
|
3160
3160
|
constructor({ editor: t }) {
|
|
3161
3161
|
this.editor = t;
|
|
3162
3162
|
}
|
|
@@ -3171,7 +3171,7 @@ class qt {
|
|
|
3171
3171
|
const { canvas: s, historyManager: o } = this.editor;
|
|
3172
3172
|
o.suspendHistory();
|
|
3173
3173
|
const n = t || s.getActiveObject();
|
|
3174
|
-
n && (n instanceof
|
|
3174
|
+
n && (n instanceof x ? n.getObjects().forEach((i) => {
|
|
3175
3175
|
s.bringObjectToFront(i);
|
|
3176
3176
|
}) : s.bringObjectToFront(n), s.renderAll(), o.resumeHistory(), e || o.saveState(), s.fire("editor:object-bring-to-front", {
|
|
3177
3177
|
object: n,
|
|
@@ -3189,7 +3189,7 @@ class qt {
|
|
|
3189
3189
|
const { canvas: s, historyManager: o } = this.editor;
|
|
3190
3190
|
o.suspendHistory();
|
|
3191
3191
|
const n = t || s.getActiveObject();
|
|
3192
|
-
n && (n instanceof
|
|
3192
|
+
n && (n instanceof x ? $t._moveSelectionForward(s, n) : s.bringObjectForward(n), s.renderAll(), o.resumeHistory(), e || o.saveState(), s.fire("editor:object-bring-forward", {
|
|
3193
3193
|
object: n,
|
|
3194
3194
|
withoutSave: e
|
|
3195
3195
|
}));
|
|
@@ -3212,7 +3212,7 @@ class qt {
|
|
|
3212
3212
|
n.suspendHistory();
|
|
3213
3213
|
const r = t || s.getActiveObject();
|
|
3214
3214
|
if (r) {
|
|
3215
|
-
if (r instanceof
|
|
3215
|
+
if (r instanceof x) {
|
|
3216
3216
|
const c = r.getObjects();
|
|
3217
3217
|
for (let d = c.length - 1; d >= 0; d -= 1)
|
|
3218
3218
|
s.sendObjectToBack(c[d]);
|
|
@@ -3240,7 +3240,7 @@ class qt {
|
|
|
3240
3240
|
} = this.editor;
|
|
3241
3241
|
n.suspendHistory();
|
|
3242
3242
|
const r = t || s.getActiveObject();
|
|
3243
|
-
r && (r instanceof
|
|
3243
|
+
r && (r instanceof x ? $t._moveSelectionBackwards(s, r) : s.sendObjectBackwards(r), a && s.sendObjectToBack(a), s.sendObjectToBack(o), i && s.sendObjectToBack(i), s.renderAll(), n.resumeHistory(), e || n.saveState(), s.fire("editor:object-send-backwards", {
|
|
3244
3244
|
object: r,
|
|
3245
3245
|
withoutSave: e
|
|
3246
3246
|
}));
|
|
@@ -3310,13 +3310,13 @@ class to {
|
|
|
3310
3310
|
*/
|
|
3311
3311
|
addRectangle(d = {}, { withoutSelection: r, withoutAdding: c } = {}) {
|
|
3312
3312
|
var l = d, {
|
|
3313
|
-
id: t = `rect-${
|
|
3313
|
+
id: t = `rect-${G()}`,
|
|
3314
3314
|
left: e,
|
|
3315
3315
|
top: s,
|
|
3316
3316
|
width: o = 100,
|
|
3317
3317
|
height: n = 100,
|
|
3318
3318
|
fill: i = "blue"
|
|
3319
|
-
} = l, a =
|
|
3319
|
+
} = l, a = vt(l, [
|
|
3320
3320
|
"id",
|
|
3321
3321
|
"left",
|
|
3322
3322
|
"top",
|
|
@@ -3324,7 +3324,7 @@ class to {
|
|
|
3324
3324
|
"height",
|
|
3325
3325
|
"fill"
|
|
3326
3326
|
]);
|
|
3327
|
-
const { canvas: u } = this.editor, g = new gs(
|
|
3327
|
+
const { canvas: u } = this.editor, g = new gs(_({
|
|
3328
3328
|
id: t,
|
|
3329
3329
|
left: e,
|
|
3330
3330
|
top: s,
|
|
@@ -3352,19 +3352,19 @@ class to {
|
|
|
3352
3352
|
*/
|
|
3353
3353
|
addCircle(c = {}, { withoutSelection: a, withoutAdding: r } = {}) {
|
|
3354
3354
|
var d = c, {
|
|
3355
|
-
id: t = `circle-${
|
|
3355
|
+
id: t = `circle-${G()}`,
|
|
3356
3356
|
left: e,
|
|
3357
3357
|
top: s,
|
|
3358
3358
|
radius: o = 50,
|
|
3359
3359
|
fill: n = "green"
|
|
3360
|
-
} = d, i =
|
|
3360
|
+
} = d, i = vt(d, [
|
|
3361
3361
|
"id",
|
|
3362
3362
|
"left",
|
|
3363
3363
|
"top",
|
|
3364
3364
|
"radius",
|
|
3365
3365
|
"fill"
|
|
3366
3366
|
]);
|
|
3367
|
-
const { canvas: l } = this.editor, u = new fs(
|
|
3367
|
+
const { canvas: l } = this.editor, u = new fs(_({
|
|
3368
3368
|
id: t,
|
|
3369
3369
|
left: e,
|
|
3370
3370
|
top: s,
|
|
@@ -3392,13 +3392,13 @@ class to {
|
|
|
3392
3392
|
*/
|
|
3393
3393
|
addTriangle(d = {}, { withoutSelection: r, withoutAdding: c } = {}) {
|
|
3394
3394
|
var l = d, {
|
|
3395
|
-
id: t = `triangle-${
|
|
3395
|
+
id: t = `triangle-${G()}`,
|
|
3396
3396
|
left: e,
|
|
3397
3397
|
top: s,
|
|
3398
3398
|
width: o = 100,
|
|
3399
3399
|
height: n = 100,
|
|
3400
3400
|
fill: i = "yellow"
|
|
3401
|
-
} = l, a =
|
|
3401
|
+
} = l, a = vt(l, [
|
|
3402
3402
|
"id",
|
|
3403
3403
|
"left",
|
|
3404
3404
|
"top",
|
|
@@ -3406,7 +3406,7 @@ class to {
|
|
|
3406
3406
|
"height",
|
|
3407
3407
|
"fill"
|
|
3408
3408
|
]);
|
|
3409
|
-
const { canvas: u } = this.editor, g = new ps(
|
|
3409
|
+
const { canvas: u } = this.editor, g = new ps(_({
|
|
3410
3410
|
id: t,
|
|
3411
3411
|
left: e,
|
|
3412
3412
|
top: s,
|
|
@@ -3445,10 +3445,10 @@ class eo {
|
|
|
3445
3445
|
* Асинхронное клонирование для внутреннего буфера
|
|
3446
3446
|
*/
|
|
3447
3447
|
_cloneToInternalClipboard(t) {
|
|
3448
|
-
return
|
|
3448
|
+
return N(this, null, function* () {
|
|
3449
3449
|
const { canvas: e, errorManager: s } = this.editor;
|
|
3450
3450
|
try {
|
|
3451
|
-
const o = yield t.clone(
|
|
3451
|
+
const o = yield t.clone(Xt);
|
|
3452
3452
|
this.clipboard = o, e.fire("editor:object-copied", { object: o });
|
|
3453
3453
|
} catch (o) {
|
|
3454
3454
|
s.emitError({
|
|
@@ -3465,7 +3465,7 @@ class eo {
|
|
|
3465
3465
|
* Копирование в системный буфер обмена
|
|
3466
3466
|
*/
|
|
3467
3467
|
_copyToSystemClipboard(t) {
|
|
3468
|
-
return
|
|
3468
|
+
return N(this, null, function* () {
|
|
3469
3469
|
const { errorManager: e } = this.editor;
|
|
3470
3470
|
if (typeof ClipboardItem == "undefined" || !navigator.clipboard)
|
|
3471
3471
|
return e.emitWarning({
|
|
@@ -3475,7 +3475,7 @@ class eo {
|
|
|
3475
3475
|
message: "navigator.clipboard не поддерживается в этом браузере или отсутствует HTTPS-соединение."
|
|
3476
3476
|
}), !1;
|
|
3477
3477
|
try {
|
|
3478
|
-
const s = t.toObject(
|
|
3478
|
+
const s = t.toObject(Xt), o = JSON.stringify(s);
|
|
3479
3479
|
return t.type === "image" ? this._copyImageToClipboard(t, o) : this._copyTextToClipboard(o);
|
|
3480
3480
|
} catch (s) {
|
|
3481
3481
|
return e.emitError({
|
|
@@ -3492,7 +3492,7 @@ class eo {
|
|
|
3492
3492
|
* Копирование изображения в буфер обмена
|
|
3493
3493
|
*/
|
|
3494
3494
|
_copyImageToClipboard(t, e) {
|
|
3495
|
-
return
|
|
3495
|
+
return N(this, null, function* () {
|
|
3496
3496
|
try {
|
|
3497
3497
|
const o = t.toCanvasElement({ enableRetinaScaling: !1 }).toDataURL(), n = o.slice(5).split(";")[0], i = o.split(",")[1], a = atob(i), r = new Uint8Array(a.length);
|
|
3498
3498
|
for (let l = 0; l < a.length; l += 1)
|
|
@@ -3514,7 +3514,7 @@ class eo {
|
|
|
3514
3514
|
* Копирование текста в буфер обмена
|
|
3515
3515
|
*/
|
|
3516
3516
|
_copyTextToClipboard(t) {
|
|
3517
|
-
return
|
|
3517
|
+
return N(this, null, function* () {
|
|
3518
3518
|
try {
|
|
3519
3519
|
const e = `${Ze}${t}`;
|
|
3520
3520
|
return yield navigator.clipboard.writeText(e), console.info("Text copied to clipboard successfully"), !0;
|
|
@@ -3536,7 +3536,7 @@ class eo {
|
|
|
3536
3536
|
*/
|
|
3537
3537
|
_addClonedObjectToCanvas(t) {
|
|
3538
3538
|
const { canvas: e, historyManager: s } = this.editor;
|
|
3539
|
-
if (e.discardActiveObject(), t instanceof
|
|
3539
|
+
if (e.discardActiveObject(), t instanceof x) {
|
|
3540
3540
|
s.suspendHistory(), t.canvas = e, t.forEachObject((o) => {
|
|
3541
3541
|
e.add(o);
|
|
3542
3542
|
}), e.setActiveObject(t), e.requestRenderAll(), s.resumeHistory(), s.saveState();
|
|
@@ -3549,7 +3549,7 @@ class eo {
|
|
|
3549
3549
|
* @param source - источник изображения (data URL или URL)
|
|
3550
3550
|
*/
|
|
3551
3551
|
_handleImageImport(t) {
|
|
3552
|
-
return
|
|
3552
|
+
return N(this, null, function* () {
|
|
3553
3553
|
var s;
|
|
3554
3554
|
const { image: e } = (s = yield this.editor.imageManager.importImage({
|
|
3555
3555
|
source: t,
|
|
@@ -3565,18 +3565,18 @@ class eo {
|
|
|
3565
3565
|
* @fires editor:object-pasted
|
|
3566
3566
|
*/
|
|
3567
3567
|
copyPaste(t) {
|
|
3568
|
-
return
|
|
3568
|
+
return N(this, null, function* () {
|
|
3569
3569
|
const { canvas: e } = this.editor, s = t || e.getActiveObject();
|
|
3570
3570
|
if (!s || s.locked) return !1;
|
|
3571
3571
|
try {
|
|
3572
|
-
const o = yield s.clone(
|
|
3573
|
-
return o instanceof
|
|
3572
|
+
const o = yield s.clone(Xt);
|
|
3573
|
+
return o instanceof x && o.forEachObject((n) => {
|
|
3574
3574
|
n.set({
|
|
3575
|
-
id: `${n.type}-${
|
|
3575
|
+
id: `${n.type}-${G()}`,
|
|
3576
3576
|
evented: !0
|
|
3577
3577
|
});
|
|
3578
3578
|
}), o.set({
|
|
3579
|
-
id: `${o.type}-${
|
|
3579
|
+
id: `${o.type}-${G()}`,
|
|
3580
3580
|
left: o.left + 10,
|
|
3581
3581
|
top: o.top + 10,
|
|
3582
3582
|
evented: !0
|
|
@@ -3600,7 +3600,7 @@ class eo {
|
|
|
3600
3600
|
* @param event.clipboardData.items — элементы буфера обмена
|
|
3601
3601
|
*/
|
|
3602
3602
|
handlePasteEvent(e) {
|
|
3603
|
-
return
|
|
3603
|
+
return N(this, arguments, function* ({ clipboardData: t }) {
|
|
3604
3604
|
var r;
|
|
3605
3605
|
if (!((r = t == null ? void 0 : t.items) != null && r.length)) {
|
|
3606
3606
|
this.paste();
|
|
@@ -3651,18 +3651,18 @@ class eo {
|
|
|
3651
3651
|
* @fires editor:object-pasted
|
|
3652
3652
|
*/
|
|
3653
3653
|
paste() {
|
|
3654
|
-
return
|
|
3654
|
+
return N(this, null, function* () {
|
|
3655
3655
|
const { canvas: t } = this.editor;
|
|
3656
3656
|
if (!this.clipboard) return !1;
|
|
3657
3657
|
try {
|
|
3658
|
-
const e = yield this.clipboard.clone(
|
|
3659
|
-
return t.discardActiveObject(), e instanceof
|
|
3658
|
+
const e = yield this.clipboard.clone(Xt);
|
|
3659
|
+
return t.discardActiveObject(), e instanceof x && e.forEachObject((s) => {
|
|
3660
3660
|
s.set({
|
|
3661
|
-
id: `${s.type}-${
|
|
3661
|
+
id: `${s.type}-${G()}`,
|
|
3662
3662
|
evented: !0
|
|
3663
3663
|
});
|
|
3664
3664
|
}), e.set({
|
|
3665
|
-
id: `${e.type}-${
|
|
3665
|
+
id: `${e.type}-${G()}`,
|
|
3666
3666
|
left: e.left + 10,
|
|
3667
3667
|
top: e.top + 10,
|
|
3668
3668
|
evented: !0
|
|
@@ -3680,7 +3680,7 @@ class eo {
|
|
|
3680
3680
|
});
|
|
3681
3681
|
}
|
|
3682
3682
|
}
|
|
3683
|
-
class
|
|
3683
|
+
class te {
|
|
3684
3684
|
constructor({ editor: t }) {
|
|
3685
3685
|
this.editor = t;
|
|
3686
3686
|
}
|
|
@@ -3706,7 +3706,7 @@ class $t {
|
|
|
3706
3706
|
editable: !1,
|
|
3707
3707
|
locked: !0
|
|
3708
3708
|
};
|
|
3709
|
-
i.set(a), !e &&
|
|
3709
|
+
i.set(a), !e && te._isGroupOrSelection(i) && i.getObjects().forEach((c) => {
|
|
3710
3710
|
c.set(a);
|
|
3711
3711
|
}), o.renderAll(), s || n.saveState(), o.fire("editor:object-locked", {
|
|
3712
3712
|
object: i,
|
|
@@ -3735,7 +3735,7 @@ class $t {
|
|
|
3735
3735
|
editable: !0,
|
|
3736
3736
|
locked: !1
|
|
3737
3737
|
};
|
|
3738
|
-
n.set(i),
|
|
3738
|
+
n.set(i), te._isGroupOrSelection(n) && n.getObjects().forEach((a) => {
|
|
3739
3739
|
a.set(i);
|
|
3740
3740
|
}), s.renderAll(), e || o.saveState(), s.fire("editor:object-unlocked", {
|
|
3741
3741
|
object: n,
|
|
@@ -3743,7 +3743,7 @@ class $t {
|
|
|
3743
3743
|
});
|
|
3744
3744
|
}
|
|
3745
3745
|
static _isGroupOrSelection(t) {
|
|
3746
|
-
return t instanceof
|
|
3746
|
+
return t instanceof x || t instanceof Et;
|
|
3747
3747
|
}
|
|
3748
3748
|
}
|
|
3749
3749
|
class so {
|
|
@@ -3758,7 +3758,7 @@ class so {
|
|
|
3758
3758
|
if (Array.isArray(t))
|
|
3759
3759
|
return t.length > 0 ? t : null;
|
|
3760
3760
|
const e = t || this.editor.canvas.getActiveObject();
|
|
3761
|
-
return !e || !(e instanceof
|
|
3761
|
+
return !e || !(e instanceof x) ? null : e.getObjects();
|
|
3762
3762
|
}
|
|
3763
3763
|
/**
|
|
3764
3764
|
* Получить группы для разгруппировки
|
|
@@ -3766,20 +3766,20 @@ class so {
|
|
|
3766
3766
|
*/
|
|
3767
3767
|
_getGroupsToUngroup(t) {
|
|
3768
3768
|
if (Array.isArray(t)) {
|
|
3769
|
-
const s = t.filter((o) => o instanceof
|
|
3769
|
+
const s = t.filter((o) => o instanceof Et);
|
|
3770
3770
|
return s.length > 0 ? s : null;
|
|
3771
3771
|
}
|
|
3772
|
-
if (t instanceof
|
|
3773
|
-
const s = t.getObjects().filter((o) => o instanceof
|
|
3772
|
+
if (t instanceof x) {
|
|
3773
|
+
const s = t.getObjects().filter((o) => o instanceof Et);
|
|
3774
3774
|
return s.length > 0 ? s : null;
|
|
3775
3775
|
}
|
|
3776
3776
|
const e = t || this.editor.canvas.getActiveObject();
|
|
3777
3777
|
if (!e) return null;
|
|
3778
|
-
if (e instanceof
|
|
3779
|
-
const s = e.getObjects().filter((o) => o instanceof
|
|
3778
|
+
if (e instanceof x) {
|
|
3779
|
+
const s = e.getObjects().filter((o) => o instanceof Et);
|
|
3780
3780
|
return s.length > 0 ? s : null;
|
|
3781
3781
|
}
|
|
3782
|
-
return e instanceof
|
|
3782
|
+
return e instanceof Et ? [e] : null;
|
|
3783
3783
|
}
|
|
3784
3784
|
/**
|
|
3785
3785
|
* Группировка объектов
|
|
@@ -3796,8 +3796,8 @@ class so {
|
|
|
3796
3796
|
if (!n) return null;
|
|
3797
3797
|
try {
|
|
3798
3798
|
o.suspendHistory();
|
|
3799
|
-
const i = new
|
|
3800
|
-
id: `group-${
|
|
3799
|
+
const i = new Et(n, {
|
|
3800
|
+
id: `group-${G()}`
|
|
3801
3801
|
});
|
|
3802
3802
|
n.forEach((r) => s.remove(r)), s.add(i), s.setActiveObject(i), s.requestRenderAll();
|
|
3803
3803
|
const a = {
|
|
@@ -3832,7 +3832,7 @@ class so {
|
|
|
3832
3832
|
s.add(l), i.push(l);
|
|
3833
3833
|
});
|
|
3834
3834
|
});
|
|
3835
|
-
const a = new
|
|
3835
|
+
const a = new x(i, {
|
|
3836
3836
|
canvas: s
|
|
3837
3837
|
});
|
|
3838
3838
|
s.setActiveObject(a), s.requestRenderAll();
|
|
@@ -3858,11 +3858,11 @@ class oo {
|
|
|
3858
3858
|
selectAll() {
|
|
3859
3859
|
const { canvas: t, canvasManager: e, objectLockManager: s } = this.editor;
|
|
3860
3860
|
t.discardActiveObject();
|
|
3861
|
-
const o = e.getObjects(), n = o.some((a) => a.locked), i = o.length > 1 ? new
|
|
3861
|
+
const o = e.getObjects(), n = o.some((a) => a.locked), i = o.length > 1 ? new x(e.getObjects(), { canvas: t }) : o[0];
|
|
3862
3862
|
n && s.lockObject({ object: i, skipInnerObjects: !0, withoutSave: !0 }), t.setActiveObject(i), t.requestRenderAll(), t.fire("editor:all-objects-selected", { selected: i });
|
|
3863
3863
|
}
|
|
3864
3864
|
}
|
|
3865
|
-
class
|
|
3865
|
+
class we {
|
|
3866
3866
|
constructor({ editor: t }) {
|
|
3867
3867
|
this.editor = t;
|
|
3868
3868
|
}
|
|
@@ -3909,7 +3909,7 @@ class be {
|
|
|
3909
3909
|
s || n.suspendHistory();
|
|
3910
3910
|
const r = [];
|
|
3911
3911
|
if (a.forEach((d) => {
|
|
3912
|
-
if (
|
|
3912
|
+
if (we._isUngroupableGroup(d)) {
|
|
3913
3913
|
const l = this._handleGroupDeletion(d);
|
|
3914
3914
|
r.push(...l);
|
|
3915
3915
|
return;
|
|
@@ -3924,7 +3924,7 @@ class be {
|
|
|
3924
3924
|
return o.fire("editor:objects-deleted", c), c;
|
|
3925
3925
|
}
|
|
3926
3926
|
}
|
|
3927
|
-
const
|
|
3927
|
+
const bt = {
|
|
3928
3928
|
IMAGE_MANAGER: {
|
|
3929
3929
|
/**
|
|
3930
3930
|
* Некорректный Content-Type изображения
|
|
@@ -4029,7 +4029,7 @@ const ft = {
|
|
|
4029
4029
|
APPLY_FAILED: "TEMPLATE_APPLY_FAILED"
|
|
4030
4030
|
}
|
|
4031
4031
|
};
|
|
4032
|
-
class
|
|
4032
|
+
class Yt {
|
|
4033
4033
|
constructor({ editor: t }) {
|
|
4034
4034
|
this._buffer = [], this.editor = t;
|
|
4035
4035
|
}
|
|
@@ -4056,7 +4056,7 @@ class zt {
|
|
|
4056
4056
|
* @fires editor:error
|
|
4057
4057
|
*/
|
|
4058
4058
|
emitError({ origin: t = "ImageEditor", method: e = "Unknown Method", code: s, data: o, message: n }) {
|
|
4059
|
-
if (!
|
|
4059
|
+
if (!Yt.isValidErrorCode(s)) {
|
|
4060
4060
|
console.warn("Неизвестный код ошибки: ", { code: s, origin: t, method: e });
|
|
4061
4061
|
return;
|
|
4062
4062
|
}
|
|
@@ -4070,7 +4070,7 @@ class zt {
|
|
|
4070
4070
|
message: i,
|
|
4071
4071
|
data: o
|
|
4072
4072
|
};
|
|
4073
|
-
this._buffer.push(
|
|
4073
|
+
this._buffer.push(_({
|
|
4074
4074
|
type: "editor:error"
|
|
4075
4075
|
}, a)), this.editor.canvas.fire("editor:error", a);
|
|
4076
4076
|
}
|
|
@@ -4085,7 +4085,7 @@ class zt {
|
|
|
4085
4085
|
* @fires editor:warning
|
|
4086
4086
|
*/
|
|
4087
4087
|
emitWarning({ origin: t = "ImageEditor", method: e = "Unknown Method", code: s, message: o, data: n }) {
|
|
4088
|
-
if (!
|
|
4088
|
+
if (!Yt.isValidErrorCode(s)) {
|
|
4089
4089
|
console.warn("Неизвестный код предупреждения: ", { code: s, origin: t, method: e });
|
|
4090
4090
|
return;
|
|
4091
4091
|
}
|
|
@@ -4098,7 +4098,7 @@ class zt {
|
|
|
4098
4098
|
message: i,
|
|
4099
4099
|
data: n
|
|
4100
4100
|
};
|
|
4101
|
-
this._buffer.push(
|
|
4101
|
+
this._buffer.push(_({
|
|
4102
4102
|
type: "editor:warning"
|
|
4103
4103
|
}, a)), this.editor.canvas.fire("editor:warning", a);
|
|
4104
4104
|
}
|
|
@@ -4108,7 +4108,7 @@ class zt {
|
|
|
4108
4108
|
* @returns true, если код допустим, иначе false
|
|
4109
4109
|
*/
|
|
4110
4110
|
static isValidErrorCode(t) {
|
|
4111
|
-
return t ? Object.values(
|
|
4111
|
+
return t ? Object.values(bt).some((e) => Object.values(e).includes(t)) : !1;
|
|
4112
4112
|
}
|
|
4113
4113
|
}
|
|
4114
4114
|
class no {
|
|
@@ -4196,11 +4196,11 @@ class no {
|
|
|
4196
4196
|
this.currentBounds = this.calculatePanBounds();
|
|
4197
4197
|
}
|
|
4198
4198
|
}
|
|
4199
|
-
const
|
|
4199
|
+
const at = ({
|
|
4200
4200
|
value: h,
|
|
4201
4201
|
min: t,
|
|
4202
4202
|
max: e
|
|
4203
|
-
}) => Math.min(Math.max(h, t), e),
|
|
4203
|
+
}) => Math.min(Math.max(h, t), e), Dt = class Dt extends nt {
|
|
4204
4204
|
constructor(t, e = {}) {
|
|
4205
4205
|
var s, o, n, i, a, r, c, d, l;
|
|
4206
4206
|
super(t, e), this.backgroundOpacity = (s = e.backgroundOpacity) != null ? s : 1, this.paddingTop = (o = e.paddingTop) != null ? o : 0, this.paddingRight = (n = e.paddingRight) != null ? n : 0, this.paddingBottom = (i = e.paddingBottom) != null ? i : 0, this.paddingLeft = (a = e.paddingLeft) != null ? a : 0, this.radiusTopLeft = (r = e.radiusTopLeft) != null ? r : 0, this.radiusTopRight = (c = e.radiusTopRight) != null ? c : 0, this.radiusBottomRight = (d = e.radiusBottomRight) != null ? d : 0, this.radiusBottomLeft = (l = e.radiusBottomLeft) != null ? l : 0, this._roundDimensions();
|
|
@@ -4221,11 +4221,11 @@ const nt = ({
|
|
|
4221
4221
|
}
|
|
4222
4222
|
_getNonTransformedDimensions() {
|
|
4223
4223
|
const { width: t, height: e } = this._getBackgroundDimensions();
|
|
4224
|
-
return new
|
|
4224
|
+
return new tt(t, e).scalarAdd(this.strokeWidth);
|
|
4225
4225
|
}
|
|
4226
4226
|
_getTransformedDimensions(t = {}) {
|
|
4227
4227
|
const { width: e, height: s } = this._getBackgroundDimensions();
|
|
4228
|
-
return super._getTransformedDimensions(
|
|
4228
|
+
return super._getTransformedDimensions(yt(_({}, t), {
|
|
4229
4229
|
width: e,
|
|
4230
4230
|
height: s
|
|
4231
4231
|
}));
|
|
@@ -4235,7 +4235,7 @@ const nt = ({
|
|
|
4235
4235
|
*/
|
|
4236
4236
|
toObject(t = []) {
|
|
4237
4237
|
const e = super.toObject(t);
|
|
4238
|
-
return
|
|
4238
|
+
return yt(_({}, e), {
|
|
4239
4239
|
backgroundOpacity: this.backgroundOpacity,
|
|
4240
4240
|
paddingTop: this.paddingTop,
|
|
4241
4241
|
paddingRight: this.paddingRight,
|
|
@@ -4252,7 +4252,7 @@ const nt = ({
|
|
|
4252
4252
|
const e = this._getEffectiveBackgroundFill();
|
|
4253
4253
|
if (e && e) {
|
|
4254
4254
|
const n = this._getPadding(), i = (s = this.width) != null ? s : 0, a = (o = this.height) != null ? o : 0, r = i + n.left + n.right, c = a + n.top + n.bottom, d = this._getCornerRadii({ width: r, height: c }), l = this._getLeftOffset() - n.left, u = this._getTopOffset() - n.top;
|
|
4255
|
-
t.save(),
|
|
4255
|
+
t.save(), Dt._renderRoundedRect({
|
|
4256
4256
|
ctx: t,
|
|
4257
4257
|
height: c,
|
|
4258
4258
|
left: l,
|
|
@@ -4274,10 +4274,10 @@ const nt = ({
|
|
|
4274
4274
|
var i, a, r, c;
|
|
4275
4275
|
const s = t / 2, o = e / 2, n = Math.min(s, o);
|
|
4276
4276
|
return {
|
|
4277
|
-
bottomLeft:
|
|
4278
|
-
bottomRight:
|
|
4279
|
-
topLeft:
|
|
4280
|
-
topRight:
|
|
4277
|
+
bottomLeft: at({ value: (i = this.radiusBottomLeft) != null ? i : 0, min: 0, max: n }),
|
|
4278
|
+
bottomRight: at({ value: (a = this.radiusBottomRight) != null ? a : 0, min: 0, max: n }),
|
|
4279
|
+
topLeft: at({ value: (r = this.radiusTopLeft) != null ? r : 0, min: 0, max: n }),
|
|
4280
|
+
topRight: at({ value: (c = this.radiusTopRight) != null ? c : 0, min: 0, max: n })
|
|
4281
4281
|
};
|
|
4282
4282
|
}
|
|
4283
4283
|
_getPadding() {
|
|
@@ -4293,12 +4293,12 @@ const nt = ({
|
|
|
4293
4293
|
var o;
|
|
4294
4294
|
const t = this.backgroundColor;
|
|
4295
4295
|
if (!t) return null;
|
|
4296
|
-
const e =
|
|
4296
|
+
const e = at({ value: (o = this.backgroundOpacity) != null ? o : 1, min: 0, max: 1 });
|
|
4297
4297
|
let s;
|
|
4298
4298
|
try {
|
|
4299
4299
|
s = new ms(t);
|
|
4300
4300
|
} catch (n) {
|
|
4301
|
-
return
|
|
4301
|
+
return Yt.emitError({
|
|
4302
4302
|
origin: "BackgroundTextbox",
|
|
4303
4303
|
method: "_getEffectiveBackgroundFill",
|
|
4304
4304
|
code: "INVALID_COLOR_VALUE",
|
|
@@ -4321,7 +4321,7 @@ const nt = ({
|
|
|
4321
4321
|
topRight: d,
|
|
4322
4322
|
bottomRight: l,
|
|
4323
4323
|
bottomLeft: u
|
|
4324
|
-
} = o, g =
|
|
4324
|
+
} = o, g = at({ value: c, min: 0, max: i }), f = at({ value: d, min: 0, max: i }), p = at({ value: l, min: 0, max: i }), m = at({ value: u, min: 0, max: i });
|
|
4325
4325
|
t.beginPath(), t.moveTo(s + g, n), t.lineTo(a - f, n), t.quadraticCurveTo(a, n, a, n + f), t.lineTo(a, r - p), t.quadraticCurveTo(a, r, a - p, r), t.lineTo(s + m, r), t.quadraticCurveTo(s, r, s, r - m), t.lineTo(s, n + g), t.quadraticCurveTo(s, n, s + g, n), t.closePath();
|
|
4326
4326
|
}
|
|
4327
4327
|
/**
|
|
@@ -4335,8 +4335,8 @@ const nt = ({
|
|
|
4335
4335
|
s !== t && (this.width = Math.max(0, s)), o !== e && (this.height = Math.max(0, o));
|
|
4336
4336
|
}
|
|
4337
4337
|
};
|
|
4338
|
-
|
|
4339
|
-
...Array.isArray(
|
|
4338
|
+
Dt.type = "background-textbox", Dt.cacheProperties = [
|
|
4339
|
+
...Array.isArray(nt.cacheProperties) ? nt.cacheProperties : [],
|
|
4340
4340
|
"backgroundColor",
|
|
4341
4341
|
"backgroundOpacity",
|
|
4342
4342
|
"paddingTop",
|
|
@@ -4347,8 +4347,8 @@ Tt.type = "background-textbox", Tt.cacheProperties = [
|
|
|
4347
4347
|
"radiusTopRight",
|
|
4348
4348
|
"radiusBottomRight",
|
|
4349
4349
|
"radiusBottomLeft"
|
|
4350
|
-
],
|
|
4351
|
-
...Array.isArray(
|
|
4350
|
+
], Dt.stateProperties = [
|
|
4351
|
+
...Array.isArray(nt.stateProperties) ? nt.stateProperties : [],
|
|
4352
4352
|
"backgroundColor",
|
|
4353
4353
|
"backgroundOpacity",
|
|
4354
4354
|
"paddingTop",
|
|
@@ -4360,10 +4360,10 @@ Tt.type = "background-textbox", Tt.cacheProperties = [
|
|
|
4360
4360
|
"radiusBottomRight",
|
|
4361
4361
|
"radiusBottomLeft"
|
|
4362
4362
|
];
|
|
4363
|
-
let
|
|
4363
|
+
let ee = Dt;
|
|
4364
4364
|
const io = () => {
|
|
4365
4365
|
var h;
|
|
4366
|
-
(h = Pe) != null && h.setClass && Pe.setClass(
|
|
4366
|
+
(h = Pe) != null && h.setClass && Pe.setClass(ee, "background-textbox");
|
|
4367
4367
|
}, ao = ({ textbox: h }) => {
|
|
4368
4368
|
var s, o;
|
|
4369
4369
|
if (!h.isEditing) return null;
|
|
@@ -4381,7 +4381,7 @@ const io = () => {
|
|
|
4381
4381
|
if (!t) return !1;
|
|
4382
4382
|
const e = (o = (s = h.text) == null ? void 0 : s.length) != null ? o : 0;
|
|
4383
4383
|
return e <= 0 ? !1 : t.start <= 0 && t.end >= e;
|
|
4384
|
-
},
|
|
4384
|
+
}, ne = ({
|
|
4385
4385
|
textbox: h,
|
|
4386
4386
|
styles: t,
|
|
4387
4387
|
range: e
|
|
@@ -4406,49 +4406,42 @@ const io = () => {
|
|
|
4406
4406
|
}, Xe = ({ strokeColor: h, width: t }) => {
|
|
4407
4407
|
if (!(t <= 0))
|
|
4408
4408
|
return h != null ? h : "#000000";
|
|
4409
|
-
}, Ke = ({ width: h = 0 }) => h ? Math.max(0, h) : 0,
|
|
4410
|
-
class
|
|
4409
|
+
}, Ke = ({ width: h = 0 }) => h ? Math.max(0, h) : 0, ie = ({ value: h }) => typeof h == "string" ? h.toLocaleUpperCase() : "", st = 0.01;
|
|
4410
|
+
class Z {
|
|
4411
4411
|
constructor({ editor: t }) {
|
|
4412
4412
|
var e;
|
|
4413
4413
|
this._handleTextEditingEntered = () => {
|
|
4414
4414
|
this.isTextEditingActive = !0;
|
|
4415
4415
|
}, this._handleTextChanged = (s) => {
|
|
4416
4416
|
const { target: o } = s;
|
|
4417
|
-
if (!
|
|
4417
|
+
if (!Z._isTextbox(o)) return;
|
|
4418
4418
|
const { text: n = "", uppercase: i } = o, a = !!i, r = n.toLocaleLowerCase();
|
|
4419
4419
|
if (a) {
|
|
4420
|
-
const d =
|
|
4420
|
+
const d = ie({ value: r });
|
|
4421
4421
|
d !== n && o.set({ text: d }), o.textCaseRaw = r;
|
|
4422
4422
|
} else
|
|
4423
4423
|
o.textCaseRaw = n;
|
|
4424
|
-
|
|
4424
|
+
Z._roundTextboxDimensions({ textbox: o }) && (o.setCoords(), o.dirty = !0);
|
|
4425
4425
|
}, this._handleTextEditingExited = (s) => {
|
|
4426
4426
|
var r, c;
|
|
4427
4427
|
const { target: o } = s;
|
|
4428
|
-
if (!
|
|
4428
|
+
if (!Z._isTextbox(o)) return;
|
|
4429
4429
|
const n = (r = o.text) != null ? r : "";
|
|
4430
4430
|
if (!!o.uppercase) {
|
|
4431
4431
|
const d = (c = o.textCaseRaw) != null ? c : n.toLocaleLowerCase();
|
|
4432
4432
|
o.textCaseRaw = d;
|
|
4433
4433
|
} else
|
|
4434
4434
|
o.textCaseRaw = n;
|
|
4435
|
-
|
|
4435
|
+
Z._roundTextboxDimensions({ textbox: o }) && (o.setCoords(), o.dirty = !0, this.canvas.requestRenderAll()), o.locked || o.set({
|
|
4436
4436
|
lockMovementX: !1,
|
|
4437
4437
|
lockMovementY: !1
|
|
4438
4438
|
}), setTimeout(() => {
|
|
4439
4439
|
this.isTextEditingActive = !1, this.editor.historyManager.saveState();
|
|
4440
4440
|
}, Vs);
|
|
4441
4441
|
}, this._handleObjectScaling = (s) => {
|
|
4442
|
-
var
|
|
4442
|
+
var X, It, Ht, mt, Wt, Ct, Ae, je, Ie, Ce, Te, Ee, Oe;
|
|
4443
4443
|
const { target: o, transform: n } = s;
|
|
4444
|
-
if (o instanceof
|
|
4445
|
-
this._handleActiveSelectionScaling({
|
|
4446
|
-
selection: o,
|
|
4447
|
-
transform: n
|
|
4448
|
-
});
|
|
4449
|
-
return;
|
|
4450
|
-
}
|
|
4451
|
-
if (!U._isTextbox(o) || !n) return;
|
|
4444
|
+
if (o instanceof x || !Z._isTextbox(o) || !n) return;
|
|
4452
4445
|
o.isScaling = !0;
|
|
4453
4446
|
const i = this._ensureScalingState(o), {
|
|
4454
4447
|
baseWidth: a,
|
|
@@ -4457,21 +4450,21 @@ class U {
|
|
|
4457
4450
|
basePadding: d,
|
|
4458
4451
|
baseRadii: l,
|
|
4459
4452
|
baseStyles: u
|
|
4460
|
-
} = i, g = typeof ((
|
|
4453
|
+
} = i, g = typeof ((X = n.original) == null ? void 0 : X.width) == "number" ? n.original.width : void 0, f = typeof ((It = n.original) == null ? void 0 : It.left) == "number" ? n.original.left : void 0, p = g != null ? g : a, m = f != null ? f : r, v = (Ht = n.corner) != null ? Ht : "", b = (mt = n.action) != null ? mt : "", I = ["ml", "mr"].includes(v) || b === "scaleX", y = ["mt", "mb"].includes(v) || b === "scaleY", w = ["tl", "tr", "bl", "br"].includes(v) || b === "scale", A = w || y;
|
|
4461
4454
|
if (!I && !y && !w) return;
|
|
4462
|
-
const
|
|
4455
|
+
const j = Math.abs((Ct = (Wt = o.scaleX) != null ? Wt : n.scaleX) != null ? Ct : 1) || 1, M = Math.abs((je = (Ae = o.scaleY) != null ? Ae : n.scaleY) != null ? je : 1) || 1, T = Math.max(1, p * j), S = Math.max(1, Math.round(T)), C = Math.max(1, c * M), {
|
|
4463
4456
|
paddingTop: B = 0,
|
|
4464
|
-
paddingRight:
|
|
4465
|
-
paddingBottom:
|
|
4457
|
+
paddingRight: F = 0,
|
|
4458
|
+
paddingBottom: U = 0,
|
|
4466
4459
|
paddingLeft: H = 0,
|
|
4467
4460
|
radiusTopLeft: V = 0,
|
|
4468
|
-
radiusTopRight:
|
|
4469
|
-
radiusBottomRight:
|
|
4470
|
-
radiusBottomLeft:
|
|
4461
|
+
radiusTopRight: L = 0,
|
|
4462
|
+
radiusBottomRight: D = 0,
|
|
4463
|
+
radiusBottomLeft: z = 0,
|
|
4471
4464
|
fontSize: W,
|
|
4472
|
-
width:
|
|
4473
|
-
originX:
|
|
4474
|
-
} = o,
|
|
4465
|
+
width: P,
|
|
4466
|
+
originX: K = "left"
|
|
4467
|
+
} = o, $ = w || y, q = w || y, Y = $ ? {
|
|
4475
4468
|
top: Math.max(0, d.top * M),
|
|
4476
4469
|
right: Math.max(0, d.right * M),
|
|
4477
4470
|
bottom: Math.max(0, d.bottom * M),
|
|
@@ -4481,32 +4474,32 @@ class U {
|
|
|
4481
4474
|
topRight: Math.max(0, l.topRight * M),
|
|
4482
4475
|
bottomRight: Math.max(0, l.bottomRight * M),
|
|
4483
4476
|
bottomLeft: Math.max(0, l.bottomLeft * M)
|
|
4484
|
-
} : l,
|
|
4485
|
-
let
|
|
4486
|
-
if (
|
|
4487
|
-
const
|
|
4488
|
-
Object.entries(u).forEach(([rs,
|
|
4489
|
-
if (!
|
|
4490
|
-
const
|
|
4491
|
-
Object.entries(
|
|
4492
|
-
if (!
|
|
4493
|
-
const
|
|
4494
|
-
typeof
|
|
4495
|
-
}), Object.keys(
|
|
4496
|
-
}), Object.keys(
|
|
4477
|
+
} : l, St = Object.keys(u).length > 0;
|
|
4478
|
+
let et;
|
|
4479
|
+
if (A && St) {
|
|
4480
|
+
const se = {};
|
|
4481
|
+
Object.entries(u).forEach(([rs, Le]) => {
|
|
4482
|
+
if (!Le) return;
|
|
4483
|
+
const oe = {};
|
|
4484
|
+
Object.entries(Le).forEach(([cs, Zt]) => {
|
|
4485
|
+
if (!Zt) return;
|
|
4486
|
+
const De = _({}, Zt);
|
|
4487
|
+
typeof Zt.fontSize == "number" && (De.fontSize = Math.max(1, Zt.fontSize * M)), oe[cs] = De;
|
|
4488
|
+
}), Object.keys(oe).length && (se[rs] = oe);
|
|
4489
|
+
}), Object.keys(se).length && (et = se);
|
|
4497
4490
|
}
|
|
4498
|
-
const
|
|
4499
|
-
if (!
|
|
4491
|
+
const lt = (Ce = (Ie = n.originX) != null ? Ie : K) != null ? Ce : "left", pt = m + p, At = m + p / 2, ht = P != null ? P : p, jt = S !== ht, Ft = Math.abs(C - (W != null ? W : c)) > st, Nt = Math.abs(Y.top - B) > st || Math.abs(Y.right - F) > st || Math.abs(Y.bottom - U) > st || Math.abs(Y.left - H) > st, xt = Math.abs(Q.topLeft - V) > st || Math.abs(Q.topRight - L) > st || Math.abs(Q.bottomRight - D) > st || Math.abs(Q.bottomLeft - z) > st;
|
|
4492
|
+
if (!jt && !Ft && !Nt && !xt) {
|
|
4500
4493
|
o.set({ scaleX: 1, scaleY: 1 }), n.scaleX = 1, n.scaleY = 1;
|
|
4501
4494
|
return;
|
|
4502
4495
|
}
|
|
4503
|
-
|
|
4504
|
-
width:
|
|
4505
|
-
fontSize:
|
|
4506
|
-
paddingTop:
|
|
4507
|
-
paddingRight:
|
|
4508
|
-
paddingBottom:
|
|
4509
|
-
paddingLeft:
|
|
4496
|
+
et && (o.styles = et), o.set({
|
|
4497
|
+
width: S,
|
|
4498
|
+
fontSize: A ? C : c,
|
|
4499
|
+
paddingTop: Y.top,
|
|
4500
|
+
paddingRight: Y.right,
|
|
4501
|
+
paddingBottom: Y.bottom,
|
|
4502
|
+
paddingLeft: Y.left,
|
|
4510
4503
|
radiusTopLeft: Q.topLeft,
|
|
4511
4504
|
radiusTopRight: Q.topRight,
|
|
4512
4505
|
radiusBottomRight: Q.bottomRight,
|
|
@@ -4514,33 +4507,78 @@ class U {
|
|
|
4514
4507
|
scaleX: 1,
|
|
4515
4508
|
scaleY: 1
|
|
4516
4509
|
});
|
|
4517
|
-
const
|
|
4518
|
-
|
|
4519
|
-
const
|
|
4520
|
-
let
|
|
4521
|
-
|
|
4522
|
-
const { original:
|
|
4523
|
-
|
|
4524
|
-
top:
|
|
4525
|
-
right:
|
|
4526
|
-
bottom:
|
|
4527
|
-
left:
|
|
4510
|
+
const Bt = Z._roundTextboxDimensions({ textbox: o });
|
|
4511
|
+
Bt && (o.dirty = !0);
|
|
4512
|
+
const ut = (Te = o.width) != null ? Te : S, kt = ut !== ht;
|
|
4513
|
+
let gt = m;
|
|
4514
|
+
kt && (I || w) && (lt === "right" ? gt = pt - ut : lt === "center" && (gt = At - ut / 2)), o.set({ left: gt }), i.baseLeft = gt, n.scaleX = 1, n.scaleY = 1;
|
|
4515
|
+
const { original: it } = n;
|
|
4516
|
+
it && (it.scaleX = 1, it.scaleY = 1, it.width = ut, it.height = o.height, it.left = gt), o.setCoords(), this.canvas.requestRenderAll(), i.baseWidth = ut, i.baseFontSize = (Ee = o.fontSize) != null ? Ee : C, i.baseStyles = JSON.parse(JSON.stringify((Oe = o.styles) != null ? Oe : {})), i.basePadding = {
|
|
4517
|
+
top: Y.top,
|
|
4518
|
+
right: Y.right,
|
|
4519
|
+
bottom: Y.bottom,
|
|
4520
|
+
left: Y.left
|
|
4528
4521
|
}, i.baseRadii = {
|
|
4529
4522
|
topLeft: Q.topLeft,
|
|
4530
4523
|
topRight: Q.topRight,
|
|
4531
4524
|
bottomRight: Q.bottomRight,
|
|
4532
4525
|
bottomLeft: Q.bottomLeft
|
|
4533
|
-
}, i.hasWidthChange =
|
|
4526
|
+
}, i.hasWidthChange = kt || Ft || Nt || xt || Bt;
|
|
4534
4527
|
}, this._handleObjectModified = (s) => {
|
|
4535
4528
|
var b, I, y;
|
|
4536
4529
|
const { target: o } = s;
|
|
4537
|
-
if (o instanceof
|
|
4538
|
-
|
|
4539
|
-
|
|
4530
|
+
if (o instanceof x) {
|
|
4531
|
+
const w = o.getObjects();
|
|
4532
|
+
if (!w.some((S) => Z._isTextbox(S))) return;
|
|
4533
|
+
const { scaleX: j = 1, scaleY: M = 1 } = o;
|
|
4534
|
+
if (Math.abs(j - 1) < st && Math.abs(M - 1) < st) return;
|
|
4535
|
+
this.canvas.discardActiveObject(), w.forEach((S) => {
|
|
4536
|
+
var C, B, F, U;
|
|
4537
|
+
if (Z._isTextbox(S)) {
|
|
4538
|
+
const H = (C = S.scaleX) != null ? C : 1, V = (B = S.scaleY) != null ? B : 1, L = ((F = S.fontSize) != null ? F : 16) * V, D = ((U = S.width) != null ? U : 0) * H, z = V, {
|
|
4539
|
+
paddingTop: W = 0,
|
|
4540
|
+
paddingRight: P = 0,
|
|
4541
|
+
paddingBottom: K = 0,
|
|
4542
|
+
paddingLeft: $ = 0,
|
|
4543
|
+
radiusTopLeft: q = 0,
|
|
4544
|
+
radiusTopRight: Y = 0,
|
|
4545
|
+
radiusBottomRight: Q = 0,
|
|
4546
|
+
radiusBottomLeft: St = 0,
|
|
4547
|
+
styles: et
|
|
4548
|
+
} = S, lt = {
|
|
4549
|
+
paddingTop: Math.max(0, W * z),
|
|
4550
|
+
paddingRight: Math.max(0, P * z),
|
|
4551
|
+
paddingBottom: Math.max(0, K * z),
|
|
4552
|
+
paddingLeft: Math.max(0, $ * z)
|
|
4553
|
+
}, pt = {
|
|
4554
|
+
radiusTopLeft: Math.max(0, q * z),
|
|
4555
|
+
radiusTopRight: Math.max(0, Y * z),
|
|
4556
|
+
radiusBottomRight: Math.max(0, Q * z),
|
|
4557
|
+
radiusBottomLeft: Math.max(0, St * z)
|
|
4558
|
+
};
|
|
4559
|
+
let At = et;
|
|
4560
|
+
et && Object.keys(et).length > 0 && (At = JSON.parse(JSON.stringify(et)), Object.values(At).forEach((ht) => {
|
|
4561
|
+
Object.values(ht).forEach((jt) => {
|
|
4562
|
+
typeof jt.fontSize == "number" && (jt.fontSize = Math.max(1, jt.fontSize * z));
|
|
4563
|
+
});
|
|
4564
|
+
})), S.set(yt(_(_({
|
|
4565
|
+
fontSize: L,
|
|
4566
|
+
width: D,
|
|
4567
|
+
scaleX: 1,
|
|
4568
|
+
scaleY: 1
|
|
4569
|
+
}, lt), pt), {
|
|
4570
|
+
styles: At
|
|
4571
|
+
})), Z._roundTextboxDimensions({ textbox: S });
|
|
4572
|
+
}
|
|
4573
|
+
S.setCoords();
|
|
4540
4574
|
});
|
|
4575
|
+
const T = new x(w, {
|
|
4576
|
+
canvas: this.canvas
|
|
4577
|
+
});
|
|
4578
|
+
this.canvas.setActiveObject(T), this.canvas.requestRenderAll();
|
|
4541
4579
|
return;
|
|
4542
4580
|
}
|
|
4543
|
-
if (!
|
|
4581
|
+
if (!Z._isTextbox(o)) return;
|
|
4544
4582
|
o.isScaling = !1;
|
|
4545
4583
|
const n = this.scalingState.get(o);
|
|
4546
4584
|
if (this.scalingState.delete(o), !(n != null && n.hasWidthChange)) return;
|
|
@@ -4575,9 +4613,9 @@ class U {
|
|
|
4575
4613
|
* @param options — настройки текста
|
|
4576
4614
|
* @param flags — флаги поведения
|
|
4577
4615
|
*/
|
|
4578
|
-
addText(
|
|
4579
|
-
var
|
|
4580
|
-
id: t = `text-${
|
|
4616
|
+
addText(F = {}, { withoutSelection: S = !1, withoutSave: C = !1, withoutAdding: B = !1 } = {}) {
|
|
4617
|
+
var U = F, {
|
|
4618
|
+
id: t = `text-${G()}`,
|
|
4581
4619
|
text: e = "Новый текст",
|
|
4582
4620
|
fontFamily: s,
|
|
4583
4621
|
fontSize: o = 48,
|
|
@@ -4598,10 +4636,10 @@ class U {
|
|
|
4598
4636
|
paddingBottom: I = 0,
|
|
4599
4637
|
paddingLeft: y = 0,
|
|
4600
4638
|
radiusTopLeft: w = 0,
|
|
4601
|
-
radiusTopRight:
|
|
4602
|
-
radiusBottomRight:
|
|
4639
|
+
radiusTopRight: A = 0,
|
|
4640
|
+
radiusBottomRight: j = 0,
|
|
4603
4641
|
radiusBottomLeft: M = 0
|
|
4604
|
-
} =
|
|
4642
|
+
} = U, T = vt(U, [
|
|
4605
4643
|
"id",
|
|
4606
4644
|
"text",
|
|
4607
4645
|
"fontFamily",
|
|
@@ -4627,15 +4665,15 @@ class U {
|
|
|
4627
4665
|
"radiusBottomRight",
|
|
4628
4666
|
"radiusBottomLeft"
|
|
4629
4667
|
]);
|
|
4630
|
-
var
|
|
4668
|
+
var $;
|
|
4631
4669
|
const { historyManager: H } = this.editor, { canvas: V } = this;
|
|
4632
4670
|
H.suspendHistory();
|
|
4633
|
-
const
|
|
4671
|
+
const L = s != null ? s : this._getDefaultFontFamily(), D = Ke({ width: g }), z = Xe({
|
|
4634
4672
|
strokeColor: u,
|
|
4635
|
-
width:
|
|
4636
|
-
}), W =
|
|
4673
|
+
width: D
|
|
4674
|
+
}), W = _({
|
|
4637
4675
|
id: t,
|
|
4638
|
-
fontFamily:
|
|
4676
|
+
fontFamily: L,
|
|
4639
4677
|
fontSize: o,
|
|
4640
4678
|
fontWeight: n ? "bold" : "normal",
|
|
4641
4679
|
fontStyle: i ? "italic" : "normal",
|
|
@@ -4644,8 +4682,8 @@ class U {
|
|
|
4644
4682
|
linethrough: c,
|
|
4645
4683
|
textAlign: d,
|
|
4646
4684
|
fill: l,
|
|
4647
|
-
stroke:
|
|
4648
|
-
strokeWidth:
|
|
4685
|
+
stroke: z,
|
|
4686
|
+
strokeWidth: D,
|
|
4649
4687
|
strokeUniform: !0,
|
|
4650
4688
|
opacity: f,
|
|
4651
4689
|
backgroundColor: p,
|
|
@@ -4655,32 +4693,32 @@ class U {
|
|
|
4655
4693
|
paddingBottom: I,
|
|
4656
4694
|
paddingLeft: y,
|
|
4657
4695
|
radiusTopLeft: w,
|
|
4658
|
-
radiusTopRight:
|
|
4659
|
-
radiusBottomRight:
|
|
4696
|
+
radiusTopRight: A,
|
|
4697
|
+
radiusBottomRight: j,
|
|
4660
4698
|
radiusBottomLeft: M
|
|
4661
|
-
},
|
|
4662
|
-
if (
|
|
4663
|
-
const q =
|
|
4664
|
-
q !==
|
|
4665
|
-
}
|
|
4666
|
-
return
|
|
4667
|
-
textbox:
|
|
4668
|
-
options:
|
|
4699
|
+
}, T), P = new ee(e, W);
|
|
4700
|
+
if (P.textCaseRaw = ($ = P.text) != null ? $ : "", r) {
|
|
4701
|
+
const q = ie({ value: P.textCaseRaw });
|
|
4702
|
+
q !== P.text && P.set({ text: q });
|
|
4703
|
+
}
|
|
4704
|
+
return Z._roundTextboxDimensions({ textbox: P }) && (P.dirty = !0), T.left === void 0 && T.top === void 0 && V.centerObject(P), B || V.add(P), S || V.setActiveObject(P), V.requestRenderAll(), H.resumeHistory(), C || H.saveState(), V.fire("editor:text-added", {
|
|
4705
|
+
textbox: P,
|
|
4706
|
+
options: yt(_({}, W), {
|
|
4669
4707
|
text: e,
|
|
4670
4708
|
bold: n,
|
|
4671
4709
|
italic: i,
|
|
4672
4710
|
strikethrough: c,
|
|
4673
4711
|
align: d,
|
|
4674
4712
|
color: l,
|
|
4675
|
-
strokeColor:
|
|
4676
|
-
strokeWidth:
|
|
4713
|
+
strokeColor: z,
|
|
4714
|
+
strokeWidth: D
|
|
4677
4715
|
}),
|
|
4678
4716
|
flags: {
|
|
4679
|
-
withoutSelection: !!
|
|
4680
|
-
withoutSave: !!
|
|
4717
|
+
withoutSelection: !!S,
|
|
4718
|
+
withoutSave: !!C,
|
|
4681
4719
|
withoutAdding: !!B
|
|
4682
4720
|
}
|
|
4683
|
-
}),
|
|
4721
|
+
}), P;
|
|
4684
4722
|
}
|
|
4685
4723
|
/**
|
|
4686
4724
|
* Обновляет текстовый объект.
|
|
@@ -4691,12 +4729,12 @@ class U {
|
|
|
4691
4729
|
* @param options.skipRender — не вызывать перерисовку канваса
|
|
4692
4730
|
*/
|
|
4693
4731
|
updateText({ target: t, style: e = {}, withoutSave: s, skipRender: o } = {}) {
|
|
4694
|
-
var
|
|
4732
|
+
var xt, Bt, ut, kt, gt, it;
|
|
4695
4733
|
const n = this._resolveTextObject(t);
|
|
4696
4734
|
if (!n) return null;
|
|
4697
4735
|
const { historyManager: i } = this.editor, { canvas: a } = this;
|
|
4698
4736
|
i.suspendHistory();
|
|
4699
|
-
const r =
|
|
4737
|
+
const r = Z._getSnapshot(n), Nt = e, {
|
|
4700
4738
|
text: c,
|
|
4701
4739
|
fontFamily: d,
|
|
4702
4740
|
fontSize: l,
|
|
@@ -4710,17 +4748,17 @@ class U {
|
|
|
4710
4748
|
strokeColor: I,
|
|
4711
4749
|
strokeWidth: y,
|
|
4712
4750
|
opacity: w,
|
|
4713
|
-
backgroundColor:
|
|
4714
|
-
backgroundOpacity:
|
|
4751
|
+
backgroundColor: A,
|
|
4752
|
+
backgroundOpacity: j,
|
|
4715
4753
|
paddingTop: M,
|
|
4716
|
-
paddingRight:
|
|
4717
|
-
paddingBottom:
|
|
4718
|
-
paddingLeft:
|
|
4754
|
+
paddingRight: T,
|
|
4755
|
+
paddingBottom: S,
|
|
4756
|
+
paddingLeft: C,
|
|
4719
4757
|
radiusTopLeft: B,
|
|
4720
|
-
radiusTopRight:
|
|
4721
|
-
radiusBottomRight:
|
|
4758
|
+
radiusTopRight: F,
|
|
4759
|
+
radiusBottomRight: U,
|
|
4722
4760
|
radiusBottomLeft: H
|
|
4723
|
-
} =
|
|
4761
|
+
} = Nt, V = vt(Nt, [
|
|
4724
4762
|
"text",
|
|
4725
4763
|
"fontFamily",
|
|
4726
4764
|
"fontSize",
|
|
@@ -4744,39 +4782,39 @@ class U {
|
|
|
4744
4782
|
"radiusTopRight",
|
|
4745
4783
|
"radiusBottomRight",
|
|
4746
4784
|
"radiusBottomLeft"
|
|
4747
|
-
]),
|
|
4748
|
-
if (d !== void 0 && (
|
|
4749
|
-
const
|
|
4750
|
-
|
|
4785
|
+
]), L = _({}, V), D = ao({ textbox: n }), z = D ? this._expandRangeToFullLines({ textbox: n, range: D }) : null, W = {}, P = {}, K = {}, $ = co({ textbox: n, range: D }), q = !D || $, Y = !D;
|
|
4786
|
+
if (d !== void 0 && (z && (P.fontFamily = d), q && (L.fontFamily = d, Y && (K.fontFamily = d))), l !== void 0 && (z && (P.fontSize = l), q && (L.fontSize = l, Y && (K.fontSize = l))), u !== void 0) {
|
|
4787
|
+
const X = u ? "bold" : "normal";
|
|
4788
|
+
D && (W.fontWeight = X), q && (L.fontWeight = X, Y && (K.fontWeight = X));
|
|
4751
4789
|
}
|
|
4752
4790
|
if (g !== void 0) {
|
|
4753
|
-
const
|
|
4754
|
-
|
|
4791
|
+
const X = g ? "italic" : "normal";
|
|
4792
|
+
D && (W.fontStyle = X), q && (L.fontStyle = X, Y && (K.fontStyle = X));
|
|
4755
4793
|
}
|
|
4756
|
-
if (f !== void 0 && (
|
|
4757
|
-
const
|
|
4758
|
-
strokeColor:
|
|
4759
|
-
width:
|
|
4794
|
+
if (f !== void 0 && (D && (W.underline = f), q && (L.underline = f, Y && (K.underline = f))), m !== void 0 && (D && (W.linethrough = m), q && (L.linethrough = m, Y && (K.linethrough = m))), v !== void 0 && (L.textAlign = v), b !== void 0 && (D && (W.fill = b), q && (L.fill = b, Y && (K.fill = b))), I !== void 0 || y !== void 0) {
|
|
4795
|
+
const X = D ? Ve({ textbox: n, range: D, property: "strokeWidth" }) : void 0, It = D ? Ve({ textbox: n, range: D, property: "stroke" }) : void 0, Ht = (Bt = (xt = y != null ? y : X) != null ? xt : n.strokeWidth) != null ? Bt : 0, mt = Ke({ width: Ht }), Wt = (kt = (ut = I != null ? I : It) != null ? ut : n.stroke) != null ? kt : void 0, Ct = Xe({
|
|
4796
|
+
strokeColor: Wt,
|
|
4797
|
+
width: mt
|
|
4760
4798
|
});
|
|
4761
|
-
|
|
4799
|
+
D && (W.stroke = Ct, W.strokeWidth = mt), q && (L.stroke = Ct, L.strokeWidth = mt, Y && (K.stroke = Ct, K.strokeWidth = mt));
|
|
4762
4800
|
}
|
|
4763
|
-
w !== void 0 && (
|
|
4764
|
-
const Q = (
|
|
4765
|
-
if (
|
|
4766
|
-
const
|
|
4767
|
-
|
|
4801
|
+
w !== void 0 && (L.opacity = w), A !== void 0 && (L.backgroundColor = A), j !== void 0 && (L.backgroundOpacity = j), M !== void 0 && (L.paddingTop = M), T !== void 0 && (L.paddingRight = T), S !== void 0 && (L.paddingBottom = S), C !== void 0 && (L.paddingLeft = C), B !== void 0 && (L.radiusTopLeft = B), F !== void 0 && (L.radiusTopRight = F), U !== void 0 && (L.radiusBottomRight = U), H !== void 0 && (L.radiusBottomLeft = H);
|
|
4802
|
+
const Q = (it = n.textCaseRaw) != null ? it : (gt = n.text) != null ? gt : "", St = !!n.uppercase, et = c !== void 0, lt = et ? c != null ? c : "" : Q, pt = p != null ? p : St;
|
|
4803
|
+
if (et || pt !== St) {
|
|
4804
|
+
const X = pt ? ie({ value: lt }) : lt;
|
|
4805
|
+
L.text = X, n.textCaseRaw = lt;
|
|
4768
4806
|
} else n.textCaseRaw === void 0 && (n.textCaseRaw = Q);
|
|
4769
|
-
n.uppercase =
|
|
4770
|
-
let
|
|
4771
|
-
if (
|
|
4772
|
-
const
|
|
4773
|
-
|
|
4774
|
-
} else if (Object.keys(
|
|
4775
|
-
const
|
|
4776
|
-
|
|
4777
|
-
}
|
|
4778
|
-
|
|
4779
|
-
const
|
|
4807
|
+
n.uppercase = pt, n.set(L);
|
|
4808
|
+
let ht = !1;
|
|
4809
|
+
if (D) {
|
|
4810
|
+
const X = ne({ textbox: n, styles: W, range: D }), It = z ? ne({ textbox: n, styles: P, range: z }) : !1;
|
|
4811
|
+
ht = X || It;
|
|
4812
|
+
} else if (Object.keys(K).length) {
|
|
4813
|
+
const X = ro({ textbox: n });
|
|
4814
|
+
X && (ht = ne({ textbox: n, styles: K, range: X }));
|
|
4815
|
+
}
|
|
4816
|
+
ht && (n.dirty = !0), (A !== void 0 || j !== void 0 || M !== void 0 || T !== void 0 || S !== void 0 || C !== void 0 || B !== void 0 || F !== void 0 || U !== void 0 || H !== void 0) && (n.dirty = !0), Z._roundTextboxDimensions({ textbox: n }) && (n.dirty = !0), n.setCoords(), o || a.requestRenderAll(), i.resumeHistory(), s || i.saveState();
|
|
4817
|
+
const Ft = Z._getSnapshot(n);
|
|
4780
4818
|
return a.fire("editor:text-updated", {
|
|
4781
4819
|
textbox: n,
|
|
4782
4820
|
target: t,
|
|
@@ -4785,11 +4823,11 @@ class U {
|
|
|
4785
4823
|
withoutSave: !!s,
|
|
4786
4824
|
skipRender: !!o
|
|
4787
4825
|
},
|
|
4788
|
-
updates:
|
|
4826
|
+
updates: L,
|
|
4789
4827
|
before: r,
|
|
4790
|
-
after:
|
|
4791
|
-
selectionRange:
|
|
4792
|
-
selectionStyles:
|
|
4828
|
+
after: Ft,
|
|
4829
|
+
selectionRange: D != null ? D : void 0,
|
|
4830
|
+
selectionStyles: D && Object.keys(W).length ? W : void 0
|
|
4793
4831
|
}), n;
|
|
4794
4832
|
}
|
|
4795
4833
|
/**
|
|
@@ -4803,14 +4841,14 @@ class U {
|
|
|
4803
4841
|
* Возвращает активный текст или ищет по id.
|
|
4804
4842
|
*/
|
|
4805
4843
|
_resolveTextObject(t) {
|
|
4806
|
-
if (t instanceof
|
|
4844
|
+
if (t instanceof nt) return t;
|
|
4807
4845
|
const { canvas: e } = this;
|
|
4808
4846
|
if (!t) {
|
|
4809
4847
|
const s = e.getActiveObject();
|
|
4810
|
-
return
|
|
4848
|
+
return Z._isTextbox(s) ? s : null;
|
|
4811
4849
|
}
|
|
4812
4850
|
if (typeof t == "string") {
|
|
4813
|
-
const s = e.getObjects().find((o) =>
|
|
4851
|
+
const s = e.getObjects().find((o) => Z._isTextbox(o) && o.id === t);
|
|
4814
4852
|
return s != null ? s : null;
|
|
4815
4853
|
}
|
|
4816
4854
|
return null;
|
|
@@ -4819,7 +4857,7 @@ class U {
|
|
|
4819
4857
|
* Проверяет, является ли объект текстовым блоком редактора.
|
|
4820
4858
|
*/
|
|
4821
4859
|
static _isTextbox(t) {
|
|
4822
|
-
return !!t && t instanceof
|
|
4860
|
+
return !!t && t instanceof nt;
|
|
4823
4861
|
}
|
|
4824
4862
|
/**
|
|
4825
4863
|
* Вешает обработчики событий Fabric для работы с текстом.
|
|
@@ -4828,46 +4866,6 @@ class U {
|
|
|
4828
4866
|
const { canvas: t } = this;
|
|
4829
4867
|
t.on("object:scaling", this._handleObjectScaling), t.on("object:modified", this._handleObjectModified), t.on("text:editing:entered", this._handleTextEditingEntered), t.on("text:editing:exited", this._handleTextEditingExited), t.on("text:changed", this._handleTextChanged);
|
|
4830
4868
|
}
|
|
4831
|
-
/**
|
|
4832
|
-
* Обрабатывает горизонтальное масштабирование ActiveSelection: расширяет текстовые блоки по ширине без растяжения шрифта.
|
|
4833
|
-
*/
|
|
4834
|
-
_handleActiveSelectionScaling({
|
|
4835
|
-
selection: t,
|
|
4836
|
-
transform: e
|
|
4837
|
-
}) {
|
|
4838
|
-
var r, c, d, l;
|
|
4839
|
-
const s = (r = e == null ? void 0 : e.corner) != null ? r : "", o = (c = e == null ? void 0 : e.action) != null ? c : "";
|
|
4840
|
-
if (!(["ml", "mr", "tl", "tr", "bl", "br"].includes(s) || o === "scaleX" || o === "scale")) return;
|
|
4841
|
-
const i = Math.abs((l = (d = t.scaleX) != null ? d : e == null ? void 0 : e.scaleX) != null ? l : 1) || 1, a = i === 0 ? 1 : 1 / i;
|
|
4842
|
-
t.getObjects().forEach((u) => {
|
|
4843
|
-
if (!U._isTextbox(u)) return;
|
|
4844
|
-
const g = this._ensureScalingState(u), f = Math.max(1, Math.round(g.baseWidth * i));
|
|
4845
|
-
u.set({
|
|
4846
|
-
width: f,
|
|
4847
|
-
scaleX: a,
|
|
4848
|
-
scaleY: 1
|
|
4849
|
-
}), U._roundTextboxDimensions({ textbox: u }), u.setCoords(), u.dirty = !0;
|
|
4850
|
-
}), t.setCoords(), this.canvas.requestRenderAll();
|
|
4851
|
-
}
|
|
4852
|
-
/**
|
|
4853
|
-
* Завершает масштабирование ActiveSelection: фиксирует новую ширину текстовых объектов и сбрасывает компенсационный scale.
|
|
4854
|
-
*/
|
|
4855
|
-
_finalizeActiveSelectionScaling({
|
|
4856
|
-
selection: t
|
|
4857
|
-
}) {
|
|
4858
|
-
var o;
|
|
4859
|
-
const e = Math.abs((o = t.scaleX) != null ? o : 1) || 1, s = t.getObjects().filter((n) => U._isTextbox(n));
|
|
4860
|
-
s.length && (s.forEach((n) => {
|
|
4861
|
-
const i = this._ensureScalingState(n), a = Math.max(1, Math.round(i.baseWidth * e));
|
|
4862
|
-
n.set({
|
|
4863
|
-
width: a,
|
|
4864
|
-
scaleX: 1,
|
|
4865
|
-
scaleY: 1
|
|
4866
|
-
}), U._roundTextboxDimensions({ textbox: n }), n.setCoords(), n.dirty = !0, this.scalingState.delete(n);
|
|
4867
|
-
}), t.set({
|
|
4868
|
-
scaleX: 1
|
|
4869
|
-
}), t.setCoords(), this.canvas.requestRenderAll());
|
|
4870
|
-
}
|
|
4871
4869
|
/**
|
|
4872
4870
|
* Возвращает диапазоны символов для каждой строки текста без учёта символов переноса.
|
|
4873
4871
|
*/
|
|
@@ -4952,10 +4950,10 @@ class U {
|
|
|
4952
4950
|
static _roundTextboxDimensions({
|
|
4953
4951
|
textbox: t
|
|
4954
4952
|
}) {
|
|
4955
|
-
const { width: e, height: s, calcTextWidth: o, calcTextHeight: n } = t, i = typeof o == "function" ? o.call(t) : void 0, a = typeof n == "function" ? n.call(t) : void 0, r =
|
|
4953
|
+
const { width: e, height: s, calcTextWidth: o, calcTextHeight: n } = t, i = typeof o == "function" ? o.call(t) : void 0, a = typeof n == "function" ? n.call(t) : void 0, r = Z._resolveDimension({
|
|
4956
4954
|
rawValue: e,
|
|
4957
4955
|
calculatedValue: i
|
|
4958
|
-
}), c =
|
|
4956
|
+
}), c = Z._resolveDimension({
|
|
4959
4957
|
rawValue: s,
|
|
4960
4958
|
calculatedValue: a
|
|
4961
4959
|
}), d = Number.isFinite(r) ? Math.round(r) : null, l = Number.isFinite(c) ? Math.round(c) : null, u = {};
|
|
@@ -4967,10 +4965,10 @@ class U {
|
|
|
4967
4965
|
static _getSnapshot(t) {
|
|
4968
4966
|
const e = ({
|
|
4969
4967
|
snapshot: W,
|
|
4970
|
-
entries:
|
|
4968
|
+
entries: P
|
|
4971
4969
|
}) => {
|
|
4972
|
-
Object.entries(
|
|
4973
|
-
|
|
4970
|
+
Object.entries(P).forEach(([K, $]) => {
|
|
4971
|
+
$ != null && (W[K] = $);
|
|
4974
4972
|
});
|
|
4975
4973
|
}, {
|
|
4976
4974
|
id: s,
|
|
@@ -4992,26 +4990,26 @@ class U {
|
|
|
4992
4990
|
backgroundOpacity: I,
|
|
4993
4991
|
paddingTop: y,
|
|
4994
4992
|
paddingRight: w,
|
|
4995
|
-
paddingBottom:
|
|
4996
|
-
paddingLeft:
|
|
4993
|
+
paddingBottom: A,
|
|
4994
|
+
paddingLeft: j,
|
|
4997
4995
|
radiusTopLeft: M,
|
|
4998
|
-
radiusTopRight:
|
|
4999
|
-
radiusBottomRight:
|
|
5000
|
-
radiusBottomLeft:
|
|
4996
|
+
radiusTopRight: T,
|
|
4997
|
+
radiusBottomRight: S,
|
|
4998
|
+
radiusBottomLeft: C,
|
|
5001
4999
|
left: B,
|
|
5002
|
-
top:
|
|
5003
|
-
width:
|
|
5000
|
+
top: F,
|
|
5001
|
+
width: U,
|
|
5004
5002
|
height: H,
|
|
5005
5003
|
angle: V,
|
|
5006
|
-
scaleX:
|
|
5007
|
-
scaleY:
|
|
5008
|
-
} = t,
|
|
5004
|
+
scaleX: L,
|
|
5005
|
+
scaleY: D
|
|
5006
|
+
} = t, z = {
|
|
5009
5007
|
id: s,
|
|
5010
5008
|
uppercase: !!i,
|
|
5011
5009
|
textAlign: g
|
|
5012
5010
|
};
|
|
5013
5011
|
return e({
|
|
5014
|
-
snapshot:
|
|
5012
|
+
snapshot: z,
|
|
5015
5013
|
entries: {
|
|
5016
5014
|
text: o,
|
|
5017
5015
|
textCaseRaw: n,
|
|
@@ -5029,21 +5027,21 @@ class U {
|
|
|
5029
5027
|
backgroundOpacity: I,
|
|
5030
5028
|
paddingTop: y,
|
|
5031
5029
|
paddingRight: w,
|
|
5032
|
-
paddingBottom:
|
|
5033
|
-
paddingLeft:
|
|
5030
|
+
paddingBottom: A,
|
|
5031
|
+
paddingLeft: j,
|
|
5034
5032
|
radiusTopLeft: M,
|
|
5035
|
-
radiusTopRight:
|
|
5036
|
-
radiusBottomRight:
|
|
5037
|
-
radiusBottomLeft:
|
|
5033
|
+
radiusTopRight: T,
|
|
5034
|
+
radiusBottomRight: S,
|
|
5035
|
+
radiusBottomLeft: C,
|
|
5038
5036
|
left: B,
|
|
5039
|
-
top:
|
|
5040
|
-
width:
|
|
5037
|
+
top: F,
|
|
5038
|
+
width: U,
|
|
5041
5039
|
height: H,
|
|
5042
5040
|
angle: V,
|
|
5043
|
-
scaleX:
|
|
5044
|
-
scaleY:
|
|
5041
|
+
scaleX: L,
|
|
5042
|
+
scaleY: D
|
|
5045
5043
|
}
|
|
5046
|
-
}),
|
|
5044
|
+
}), z;
|
|
5047
5045
|
}
|
|
5048
5046
|
/**
|
|
5049
5047
|
* Возвращает первый доступный шрифт или дефолтный Arial.
|
|
@@ -5053,15 +5051,15 @@ class U {
|
|
|
5053
5051
|
return (e = (t = this.fonts[0]) == null ? void 0 : t.family) != null ? e : "Arial";
|
|
5054
5052
|
}
|
|
5055
5053
|
}
|
|
5056
|
-
const
|
|
5054
|
+
const ot = ({
|
|
5057
5055
|
value: h,
|
|
5058
5056
|
fallback: t = 0
|
|
5059
|
-
}) => typeof h == "number" && Number.isFinite(h) ? h : typeof t == "number" && Number.isFinite(t) ? t : 0,
|
|
5057
|
+
}) => typeof h == "number" && Number.isFinite(h) ? h : typeof t == "number" && Number.isFinite(t) ? t : 0, Kt = ({
|
|
5060
5058
|
value: h,
|
|
5061
5059
|
dimension: t,
|
|
5062
5060
|
useRelativePositions: e
|
|
5063
5061
|
}) => {
|
|
5064
|
-
const s =
|
|
5062
|
+
const s = ot({ value: h });
|
|
5065
5063
|
return e ? s : s / (t || 1);
|
|
5066
5064
|
}, lo = ({
|
|
5067
5065
|
object: h,
|
|
@@ -5073,26 +5071,26 @@ const tt = ({
|
|
|
5073
5071
|
const n = h;
|
|
5074
5072
|
if (typeof n[o.x] == "number" && typeof n[o.y] == "number")
|
|
5075
5073
|
return {
|
|
5076
|
-
x:
|
|
5074
|
+
x: Kt({
|
|
5077
5075
|
value: n[o.x],
|
|
5078
5076
|
dimension: t,
|
|
5079
5077
|
useRelativePositions: s
|
|
5080
5078
|
}),
|
|
5081
|
-
y:
|
|
5079
|
+
y: Kt({
|
|
5082
5080
|
value: n[o.y],
|
|
5083
5081
|
dimension: e,
|
|
5084
5082
|
useRelativePositions: s
|
|
5085
5083
|
})
|
|
5086
5084
|
};
|
|
5087
|
-
const { left: a, top: r, width: c, height: d } = h, l =
|
|
5085
|
+
const { left: a, top: r, width: c, height: d } = h, l = Kt({
|
|
5088
5086
|
value: a,
|
|
5089
5087
|
dimension: t,
|
|
5090
5088
|
useRelativePositions: s
|
|
5091
|
-
}), u =
|
|
5089
|
+
}), u = Kt({
|
|
5092
5090
|
value: r,
|
|
5093
5091
|
dimension: e,
|
|
5094
5092
|
useRelativePositions: s
|
|
5095
|
-
}), g =
|
|
5093
|
+
}), g = ot({ value: c }) / (t || 1), f = ot({ value: d }) / (e || 1);
|
|
5096
5094
|
return {
|
|
5097
5095
|
x: l + g / 2,
|
|
5098
5096
|
y: u + f / 2
|
|
@@ -5107,10 +5105,10 @@ const tt = ({
|
|
|
5107
5105
|
const { left: n, top: i, width: a, height: r } = e;
|
|
5108
5106
|
if (!o) {
|
|
5109
5107
|
const { width: l, height: u } = s, g = n + h * (l || a), f = i + t * (u || r);
|
|
5110
|
-
return new
|
|
5108
|
+
return new tt(g, f);
|
|
5111
5109
|
}
|
|
5112
5110
|
const c = n + h * a, d = i + t * r;
|
|
5113
|
-
return new
|
|
5111
|
+
return new tt(c, d);
|
|
5114
5112
|
}, uo = ({
|
|
5115
5113
|
object: h,
|
|
5116
5114
|
montageArea: t,
|
|
@@ -5126,7 +5124,7 @@ const tt = ({
|
|
|
5126
5124
|
} catch (s) {
|
|
5127
5125
|
return null;
|
|
5128
5126
|
}
|
|
5129
|
-
},
|
|
5127
|
+
}, ft = ({
|
|
5130
5128
|
object: h
|
|
5131
5129
|
}) => {
|
|
5132
5130
|
if (!h) return null;
|
|
@@ -5185,8 +5183,8 @@ const tt = ({
|
|
|
5185
5183
|
};
|
|
5186
5184
|
}
|
|
5187
5185
|
return null;
|
|
5188
|
-
},
|
|
5189
|
-
class
|
|
5186
|
+
}, ae = "_templateCenterX", re = "_templateCenterY", ce = "_templateAnchorX", de = "_templateAnchorY";
|
|
5187
|
+
class R {
|
|
5190
5188
|
constructor({ editor: t }) {
|
|
5191
5189
|
this.editor = t;
|
|
5192
5190
|
}
|
|
@@ -5205,28 +5203,28 @@ class L {
|
|
|
5205
5203
|
montageArea: i,
|
|
5206
5204
|
errorManager: a,
|
|
5207
5205
|
backgroundManager: r
|
|
5208
|
-
} = this.editor, c = n.getActiveObject(), d =
|
|
5206
|
+
} = this.editor, c = n.getActiveObject(), d = R._collectObjects(c), { backgroundObject: l } = r != null ? r : {}, u = o && l ? [l] : [], g = [...d, ...u];
|
|
5209
5207
|
if (!g.length)
|
|
5210
5208
|
return a.emitWarning({
|
|
5211
5209
|
origin: "TemplateManager",
|
|
5212
5210
|
method: "serializeSelection",
|
|
5213
|
-
code:
|
|
5211
|
+
code: bt.TEMPLATE_MANAGER.NO_OBJECTS_SELECTED,
|
|
5214
5212
|
message: "Нет объектов для сериализации шаблона"
|
|
5215
5213
|
}), null;
|
|
5216
|
-
const f =
|
|
5214
|
+
const f = R._getBounds(i), p = R._getMontageSize({ montageArea: i, bounds: f }), m = p.width, v = p.height, b = g.map((w) => R._serializeObject({
|
|
5217
5215
|
object: w,
|
|
5218
5216
|
bounds: f,
|
|
5219
5217
|
baseWidth: m,
|
|
5220
5218
|
baseHeight: v,
|
|
5221
5219
|
montageArea: i != null ? i : null
|
|
5222
|
-
})), I =
|
|
5220
|
+
})), I = yt(_({}, s), {
|
|
5223
5221
|
baseWidth: m,
|
|
5224
5222
|
baseHeight: v,
|
|
5225
5223
|
positionsNormalized: !0,
|
|
5226
5224
|
previewId: e != null ? e : s.previewId
|
|
5227
5225
|
});
|
|
5228
5226
|
return {
|
|
5229
|
-
id: t != null ? t : `template-${
|
|
5227
|
+
id: t != null ? t : `template-${G()}`,
|
|
5230
5228
|
meta: I,
|
|
5231
5229
|
objects: b
|
|
5232
5230
|
};
|
|
@@ -5238,7 +5236,7 @@ class L {
|
|
|
5238
5236
|
* @param options.data - данные для заполнения текстов по customData.templateField
|
|
5239
5237
|
*/
|
|
5240
5238
|
applyTemplate(s) {
|
|
5241
|
-
return
|
|
5239
|
+
return N(this, arguments, function* ({
|
|
5242
5240
|
template: t,
|
|
5243
5241
|
data: e
|
|
5244
5242
|
}) {
|
|
@@ -5253,37 +5251,37 @@ class L {
|
|
|
5253
5251
|
return a.emitWarning({
|
|
5254
5252
|
origin: "TemplateManager",
|
|
5255
5253
|
method: "applyTemplate",
|
|
5256
|
-
code:
|
|
5254
|
+
code: bt.TEMPLATE_MANAGER.INVALID_TEMPLATE,
|
|
5257
5255
|
message: "Шаблон не содержит объектов"
|
|
5258
5256
|
}), null;
|
|
5259
|
-
const u =
|
|
5257
|
+
const u = R._getBounds(n);
|
|
5260
5258
|
if (!u)
|
|
5261
5259
|
return a.emitWarning({
|
|
5262
5260
|
origin: "TemplateManager",
|
|
5263
5261
|
method: "applyTemplate",
|
|
5264
|
-
code:
|
|
5262
|
+
code: bt.TEMPLATE_MANAGER.INVALID_TARGET,
|
|
5265
5263
|
message: "Не удалось определить границы монтажной области"
|
|
5266
5264
|
}), null;
|
|
5267
|
-
const g =
|
|
5265
|
+
const g = R._getMontageSize({ montageArea: n, bounds: u }), f = R._normalizeMeta({ meta: d, fallback: g }), p = R._calculateScale({ meta: f, target: g }), m = !!f.positionsNormalized;
|
|
5268
5266
|
let v = !1, b = !1;
|
|
5269
5267
|
i.suspendHistory();
|
|
5270
5268
|
try {
|
|
5271
|
-
const I = yield
|
|
5269
|
+
const I = yield R._enlivenObjects(c);
|
|
5272
5270
|
if (!I.length)
|
|
5273
5271
|
return a.emitWarning({
|
|
5274
5272
|
origin: "TemplateManager",
|
|
5275
5273
|
method: "applyTemplate",
|
|
5276
|
-
code:
|
|
5274
|
+
code: bt.TEMPLATE_MANAGER.INVALID_TEMPLATE,
|
|
5277
5275
|
message: "Не удалось создать объекты шаблона"
|
|
5278
5276
|
}), null;
|
|
5279
|
-
const { backgroundObject: y, contentObjects: w } =
|
|
5280
|
-
y && (b = yield
|
|
5277
|
+
const { backgroundObject: y, contentObjects: w } = R._extractBackgroundObject(I);
|
|
5278
|
+
y && (b = yield R._applyBackgroundFromObject({
|
|
5281
5279
|
backgroundObject: y,
|
|
5282
5280
|
backgroundManager: r,
|
|
5283
5281
|
errorManager: a
|
|
5284
5282
|
}));
|
|
5285
|
-
const
|
|
5286
|
-
object:
|
|
5283
|
+
const A = w.map((j) => (R._applyTextOverrides({ object: j, data: e }), R._transformObject({
|
|
5284
|
+
object: j,
|
|
5287
5285
|
scale: p,
|
|
5288
5286
|
bounds: u,
|
|
5289
5287
|
targetSize: g,
|
|
@@ -5291,20 +5289,20 @@ class L {
|
|
|
5291
5289
|
baseHeight: f.baseHeight,
|
|
5292
5290
|
montageArea: n,
|
|
5293
5291
|
useRelativePositions: m
|
|
5294
|
-
}),
|
|
5295
|
-
id: `${
|
|
5292
|
+
}), j.set({
|
|
5293
|
+
id: `${j.type}-${G()}`,
|
|
5296
5294
|
evented: !0
|
|
5297
|
-
}), o.add(
|
|
5298
|
-
return !
|
|
5295
|
+
}), o.add(j), j));
|
|
5296
|
+
return !A.length && !b ? null : (v = A.length > 0 || b, A.length && R._activateObjects({ canvas: o, objects: A }), o.requestRenderAll(), o.fire("editor:template-applied", {
|
|
5299
5297
|
template: t,
|
|
5300
|
-
objects:
|
|
5298
|
+
objects: A,
|
|
5301
5299
|
bounds: u
|
|
5302
|
-
}),
|
|
5300
|
+
}), A);
|
|
5303
5301
|
} catch (I) {
|
|
5304
5302
|
return a.emitError({
|
|
5305
5303
|
origin: "TemplateManager",
|
|
5306
5304
|
method: "applyTemplate",
|
|
5307
|
-
code:
|
|
5305
|
+
code: bt.TEMPLATE_MANAGER.APPLY_FAILED,
|
|
5308
5306
|
message: "Ошибка применения шаблона",
|
|
5309
5307
|
data: {
|
|
5310
5308
|
templateId: l,
|
|
@@ -5320,7 +5318,7 @@ class L {
|
|
|
5320
5318
|
* Подготавливает объекты для сериализации.
|
|
5321
5319
|
*/
|
|
5322
5320
|
static _collectObjects(t) {
|
|
5323
|
-
return t ? t instanceof
|
|
5321
|
+
return t ? t instanceof x ? t.getObjects() : [t] : [];
|
|
5324
5322
|
}
|
|
5325
5323
|
/**
|
|
5326
5324
|
* Возвращает габариты объекта.
|
|
@@ -5344,15 +5342,15 @@ class L {
|
|
|
5344
5342
|
* Превращает plain-описание объектов в Fabric объекты.
|
|
5345
5343
|
*/
|
|
5346
5344
|
static _enlivenObjects(t) {
|
|
5347
|
-
return
|
|
5348
|
-
return (yield Promise.all(t.map((s) =>
|
|
5349
|
-
if (
|
|
5350
|
-
const i = yield
|
|
5345
|
+
return N(this, null, function* () {
|
|
5346
|
+
return (yield Promise.all(t.map((s) => N(null, null, function* () {
|
|
5347
|
+
if (R._hasSerializedSvgMarkup(s)) {
|
|
5348
|
+
const i = yield R._reviveSvgObject(s);
|
|
5351
5349
|
if (i)
|
|
5352
|
-
return
|
|
5350
|
+
return R._restoreImageScale({ revived: i, serialized: s }), i;
|
|
5353
5351
|
}
|
|
5354
|
-
const o = yield
|
|
5355
|
-
return n ? (
|
|
5352
|
+
const o = yield dt.enlivenObjects([s]), n = o == null ? void 0 : o[0];
|
|
5353
|
+
return n ? (R._restoreImageScale({ revived: n, serialized: s }), n) : null;
|
|
5356
5354
|
})))).filter((s) => !!s);
|
|
5357
5355
|
});
|
|
5358
5356
|
}
|
|
@@ -5379,8 +5377,8 @@ class L {
|
|
|
5379
5377
|
naturalHeight: 0,
|
|
5380
5378
|
width: 0,
|
|
5381
5379
|
height: 0
|
|
5382
|
-
}, f =
|
|
5383
|
-
f > 0 && (M.width = f), p > 0 && (M.height = p),
|
|
5380
|
+
}, f = ot({ value: d || u || r.width, fallback: 0 }), p = ot({ value: l || g || r.height, fallback: 0 }), m = ot({ value: o, fallback: f }), v = ot({ value: n, fallback: p }), b = ot({ value: i, fallback: r.scaleX || 1 }), I = ot({ value: a, fallback: r.scaleY || 1 }), y = m * b, w = v * I, A = f ? y / f : null, j = p ? w / p : null, M = {};
|
|
5381
|
+
f > 0 && (M.width = f), p > 0 && (M.height = p), A && A > 0 && (M.scaleX = A), j && j > 0 && (M.scaleY = j), r.set(M);
|
|
5384
5382
|
}
|
|
5385
5383
|
/**
|
|
5386
5384
|
* Проверяет, содержит ли сериализованный объект инлайн SVG.
|
|
@@ -5392,12 +5390,12 @@ class L {
|
|
|
5392
5390
|
* Восстанавливает SVG-объект из компактного описания.
|
|
5393
5391
|
*/
|
|
5394
5392
|
static _reviveSvgObject(t) {
|
|
5395
|
-
return
|
|
5393
|
+
return N(this, null, function* () {
|
|
5396
5394
|
const e = typeof t.svgMarkup == "string" ? t.svgMarkup : null;
|
|
5397
5395
|
if (!e) return null;
|
|
5398
5396
|
try {
|
|
5399
|
-
const s = yield ys(e), o =
|
|
5400
|
-
|
|
5397
|
+
const s = yield ys(e), o = dt.groupSVGElements(s.objects, s.options), n = yield dt.enlivenObjectEnlivables(
|
|
5398
|
+
R._prepareSerializableProps(t)
|
|
5401
5399
|
);
|
|
5402
5400
|
return o.set(n), o.setCoords(), o;
|
|
5403
5401
|
} catch (s) {
|
|
@@ -5409,7 +5407,7 @@ class L {
|
|
|
5409
5407
|
* Убирает технические поля сериализации, оставляя только применимые свойства.
|
|
5410
5408
|
*/
|
|
5411
5409
|
static _prepareSerializableProps(t) {
|
|
5412
|
-
const e =
|
|
5410
|
+
const e = _({}, t);
|
|
5413
5411
|
return delete e.svgMarkup, delete e.objects, delete e.path, delete e.paths, delete e.type, delete e.version, e;
|
|
5414
5412
|
}
|
|
5415
5413
|
/**
|
|
@@ -5461,17 +5459,17 @@ class L {
|
|
|
5461
5459
|
baseHeight: i,
|
|
5462
5460
|
useRelativePositions: r,
|
|
5463
5461
|
centerKeys: {
|
|
5464
|
-
x:
|
|
5465
|
-
y:
|
|
5462
|
+
x: ae,
|
|
5463
|
+
y: re
|
|
5466
5464
|
}
|
|
5467
|
-
}), { scaleX: u, scaleY: g } = t, f =
|
|
5465
|
+
}), { scaleX: u, scaleY: g } = t, f = ot({ value: u, fallback: 1 }), p = ot({ value: g, fallback: 1 }), m = R._getPositioningBounds({
|
|
5468
5466
|
bounds: s,
|
|
5469
5467
|
baseWidth: n,
|
|
5470
5468
|
baseHeight: i,
|
|
5471
5469
|
scale: e,
|
|
5472
5470
|
useRelativePositions: r,
|
|
5473
|
-
anchorX:
|
|
5474
|
-
anchorY:
|
|
5471
|
+
anchorX: R._resolveAnchor(c, ce),
|
|
5472
|
+
anchorY: R._resolveAnchor(c, de)
|
|
5475
5473
|
}), v = ho({
|
|
5476
5474
|
normalizedX: d,
|
|
5477
5475
|
normalizedY: l,
|
|
@@ -5482,7 +5480,7 @@ class L {
|
|
|
5482
5480
|
t.set({
|
|
5483
5481
|
scaleX: b,
|
|
5484
5482
|
scaleY: I
|
|
5485
|
-
}), t.setPositionByOrigin(v, "center", "center"), t.setCoords(), delete c[
|
|
5483
|
+
}), t.setPositionByOrigin(v, "center", "center"), t.setCoords(), delete c[ae], delete c[re], delete c[ce], delete c[de];
|
|
5486
5484
|
}
|
|
5487
5485
|
/**
|
|
5488
5486
|
* Возвращает bounds, в которых должны позиционироваться нормализованные объекты.
|
|
@@ -5498,7 +5496,7 @@ class L {
|
|
|
5498
5496
|
anchorY: a
|
|
5499
5497
|
}) {
|
|
5500
5498
|
if (!n) return t;
|
|
5501
|
-
const r = (e || t.width) * o, c = (s || t.height) * o, d = t.width - r, l = t.height - c, u = t.left +
|
|
5499
|
+
const r = (e || t.width) * o, c = (s || t.height) * o, d = t.width - r, l = t.height - c, u = t.left + R._calculateAnchorOffset(i, d), g = t.top + R._calculateAnchorOffset(a, l);
|
|
5502
5500
|
return {
|
|
5503
5501
|
left: u,
|
|
5504
5502
|
top: g,
|
|
@@ -5532,8 +5530,8 @@ class L {
|
|
|
5532
5530
|
meta: t,
|
|
5533
5531
|
fallback: e
|
|
5534
5532
|
}) {
|
|
5535
|
-
const { width: s, height: o } = e, r = t || {}, { baseWidth: n = s, baseHeight: i = o } = r, a =
|
|
5536
|
-
return
|
|
5533
|
+
const { width: s, height: o } = e, r = t || {}, { baseWidth: n = s, baseHeight: i = o } = r, a = vt(r, ["baseWidth", "baseHeight"]);
|
|
5534
|
+
return _({
|
|
5537
5535
|
baseWidth: n,
|
|
5538
5536
|
baseHeight: i
|
|
5539
5537
|
}, a);
|
|
@@ -5560,7 +5558,7 @@ class L {
|
|
|
5560
5558
|
t.setActiveObject(e[0]);
|
|
5561
5559
|
return;
|
|
5562
5560
|
}
|
|
5563
|
-
const s = new
|
|
5561
|
+
const s = new x(e, { canvas: t });
|
|
5564
5562
|
t.setActiveObject(s);
|
|
5565
5563
|
}
|
|
5566
5564
|
/**
|
|
@@ -5585,8 +5583,8 @@ class L {
|
|
|
5585
5583
|
montageArea: n
|
|
5586
5584
|
}) {
|
|
5587
5585
|
const i = t.toDatalessObject([...ss]);
|
|
5588
|
-
if (
|
|
5589
|
-
const y =
|
|
5586
|
+
if (R._isSvgObject(t)) {
|
|
5587
|
+
const y = R._extractSvgMarkup(t);
|
|
5590
5588
|
y && (i.svgMarkup = y, delete i.objects, delete i.path);
|
|
5591
5589
|
}
|
|
5592
5590
|
if (!e) return i;
|
|
@@ -5606,11 +5604,11 @@ class L {
|
|
|
5606
5604
|
y: (y.y - r) / g
|
|
5607
5605
|
};
|
|
5608
5606
|
})(), m = (l.left - a) / u, v = (l.top - r) / g, b = m + l.width / u, I = v + l.height / g;
|
|
5609
|
-
return i[
|
|
5607
|
+
return i[ae] = p.x, i[re] = p.y, i[ce] = R._detectAnchor({
|
|
5610
5608
|
center: p.x,
|
|
5611
5609
|
start: m,
|
|
5612
5610
|
end: b
|
|
5613
|
-
}), i[
|
|
5611
|
+
}), i[de] = R._detectAnchor({
|
|
5614
5612
|
center: p.y,
|
|
5615
5613
|
start: v,
|
|
5616
5614
|
end: I
|
|
@@ -5630,13 +5628,13 @@ class L {
|
|
|
5630
5628
|
* Применяет фоновый объект шаблона к текущему холсту через BackgroundManager.
|
|
5631
5629
|
*/
|
|
5632
5630
|
static _applyBackgroundFromObject(o) {
|
|
5633
|
-
return
|
|
5631
|
+
return N(this, arguments, function* ({
|
|
5634
5632
|
backgroundObject: t,
|
|
5635
5633
|
backgroundManager: e,
|
|
5636
5634
|
errorManager: s
|
|
5637
5635
|
}) {
|
|
5638
5636
|
try {
|
|
5639
|
-
const { fill: n, customData: i } = t, { backgroundType: a } = t, r =
|
|
5637
|
+
const { fill: n, customData: i } = t, { backgroundType: a } = t, r = R._cloneCustomData(i);
|
|
5640
5638
|
if (a === "color" && typeof n == "string")
|
|
5641
5639
|
return e.setColorBackground({
|
|
5642
5640
|
color: n,
|
|
@@ -5653,7 +5651,7 @@ class L {
|
|
|
5653
5651
|
}), !0;
|
|
5654
5652
|
}
|
|
5655
5653
|
if (a === "image") {
|
|
5656
|
-
const c =
|
|
5654
|
+
const c = R._getImageSource(t);
|
|
5657
5655
|
if (c)
|
|
5658
5656
|
return yield e.setImageBackground({
|
|
5659
5657
|
imageSource: c,
|
|
@@ -5665,7 +5663,7 @@ class L {
|
|
|
5665
5663
|
s.emitWarning({
|
|
5666
5664
|
origin: "TemplateManager",
|
|
5667
5665
|
method: "applyTemplate",
|
|
5668
|
-
code:
|
|
5666
|
+
code: bt.TEMPLATE_MANAGER.APPLY_FAILED,
|
|
5669
5667
|
message: "Не удалось применить фон из шаблона",
|
|
5670
5668
|
data: n
|
|
5671
5669
|
});
|
|
@@ -5695,7 +5693,7 @@ class L {
|
|
|
5695
5693
|
*/
|
|
5696
5694
|
static _cloneCustomData(t) {
|
|
5697
5695
|
if (!(!t || typeof t != "object"))
|
|
5698
|
-
return
|
|
5696
|
+
return _({}, t);
|
|
5699
5697
|
}
|
|
5700
5698
|
/**
|
|
5701
5699
|
* Извлекает src изображения из FabricImage или его исходного элемента.
|
|
@@ -5721,10 +5719,10 @@ class L {
|
|
|
5721
5719
|
*/
|
|
5722
5720
|
// eslint-disable-next-line class-methods-use-this
|
|
5723
5721
|
enlivenObjectEnlivables(t) {
|
|
5724
|
-
return
|
|
5722
|
+
return dt.enlivenObjectEnlivables(t);
|
|
5725
5723
|
}
|
|
5726
5724
|
}
|
|
5727
|
-
const po = 5, os = "#3D8BF4",
|
|
5725
|
+
const po = 5, os = "#3D8BF4", pe = 1, Qt = 1, Qe = ({
|
|
5728
5726
|
anchors: h,
|
|
5729
5727
|
positions: t,
|
|
5730
5728
|
threshold: e
|
|
@@ -5861,41 +5859,41 @@ const po = 5, os = "#3D8BF4", ge = 1, Xt = 1, Qe = ({
|
|
|
5861
5859
|
return { delta: 0, guide: null };
|
|
5862
5860
|
const u = d[l - 1], g = d[l - 2], f = d[l + 1], p = d[l + 2], m = [], v = i - n;
|
|
5863
5861
|
if (u && g) {
|
|
5864
|
-
const { bounds: y } = u, { bounds: w } = g,
|
|
5862
|
+
const { bounds: y } = u, { bounds: w } = g, A = y.top - w.bottom, j = n - y.bottom, M = Math.abs(j - A);
|
|
5865
5863
|
if (M <= e) {
|
|
5866
|
-
const
|
|
5864
|
+
const T = A - j, S = n + T, C = {
|
|
5867
5865
|
type: "vertical",
|
|
5868
5866
|
axis: o,
|
|
5869
5867
|
refStart: w.bottom,
|
|
5870
5868
|
refEnd: y.top,
|
|
5871
5869
|
activeStart: y.bottom,
|
|
5872
|
-
activeEnd:
|
|
5873
|
-
distance:
|
|
5870
|
+
activeEnd: S,
|
|
5871
|
+
distance: A
|
|
5874
5872
|
};
|
|
5875
|
-
m.push({ delta:
|
|
5873
|
+
m.push({ delta: T, guide: C, diff: M });
|
|
5876
5874
|
}
|
|
5877
5875
|
}
|
|
5878
5876
|
if (f && p) {
|
|
5879
|
-
const { bounds: y } = f, { bounds: w } = p,
|
|
5877
|
+
const { bounds: y } = f, { bounds: w } = p, A = w.top - y.bottom, j = y.top - i, M = Math.abs(j - A);
|
|
5880
5878
|
if (M <= e) {
|
|
5881
|
-
const
|
|
5879
|
+
const T = j - A, S = i + T, C = {
|
|
5882
5880
|
type: "vertical",
|
|
5883
5881
|
axis: o,
|
|
5884
5882
|
refStart: y.bottom,
|
|
5885
5883
|
refEnd: w.top,
|
|
5886
|
-
activeStart:
|
|
5884
|
+
activeStart: S,
|
|
5887
5885
|
activeEnd: y.top,
|
|
5888
|
-
distance:
|
|
5886
|
+
distance: A
|
|
5889
5887
|
};
|
|
5890
|
-
m.push({ delta:
|
|
5888
|
+
m.push({ delta: T, guide: C, diff: M });
|
|
5891
5889
|
}
|
|
5892
5890
|
}
|
|
5893
5891
|
if (u && f) {
|
|
5894
|
-
const { bounds: y } = u, { bounds: w } = f,
|
|
5895
|
-
if (
|
|
5896
|
-
const M =
|
|
5897
|
-
if (
|
|
5898
|
-
const
|
|
5892
|
+
const { bounds: y } = u, { bounds: w } = f, j = w.top - y.bottom - v;
|
|
5893
|
+
if (j >= 0) {
|
|
5894
|
+
const M = j / 2, T = n - y.bottom, S = w.top - i, C = Math.abs(T - M), B = Math.abs(S - M), F = Math.max(C, B);
|
|
5895
|
+
if (F <= e) {
|
|
5896
|
+
const U = M - T, H = i + U, V = {
|
|
5899
5897
|
type: "vertical",
|
|
5900
5898
|
axis: o,
|
|
5901
5899
|
refStart: y.bottom,
|
|
@@ -5904,7 +5902,7 @@ const po = 5, os = "#3D8BF4", ge = 1, Xt = 1, Qe = ({
|
|
|
5904
5902
|
activeEnd: H + M,
|
|
5905
5903
|
distance: M
|
|
5906
5904
|
};
|
|
5907
|
-
m.push({ delta:
|
|
5905
|
+
m.push({ delta: U, guide: V, diff: F });
|
|
5908
5906
|
}
|
|
5909
5907
|
}
|
|
5910
5908
|
}
|
|
@@ -5947,41 +5945,41 @@ const po = 5, os = "#3D8BF4", ge = 1, Xt = 1, Qe = ({
|
|
|
5947
5945
|
return { delta: 0, guide: null };
|
|
5948
5946
|
const u = d[l - 1], g = d[l - 2], f = d[l + 1], p = d[l + 2], m = [], v = i - n;
|
|
5949
5947
|
if (u && g) {
|
|
5950
|
-
const { bounds: y } = u, { bounds: w } = g,
|
|
5948
|
+
const { bounds: y } = u, { bounds: w } = g, A = y.left - w.right, j = n - y.right, M = Math.abs(j - A);
|
|
5951
5949
|
if (M <= e) {
|
|
5952
|
-
const
|
|
5950
|
+
const T = A - j, S = n + T, C = {
|
|
5953
5951
|
type: "horizontal",
|
|
5954
5952
|
axis: o,
|
|
5955
5953
|
refStart: w.right,
|
|
5956
5954
|
refEnd: y.left,
|
|
5957
5955
|
activeStart: y.right,
|
|
5958
|
-
activeEnd:
|
|
5959
|
-
distance:
|
|
5956
|
+
activeEnd: S,
|
|
5957
|
+
distance: A
|
|
5960
5958
|
};
|
|
5961
|
-
m.push({ delta:
|
|
5959
|
+
m.push({ delta: T, guide: C, diff: M });
|
|
5962
5960
|
}
|
|
5963
5961
|
}
|
|
5964
5962
|
if (f && p) {
|
|
5965
|
-
const { bounds: y } = f, { bounds: w } = p,
|
|
5963
|
+
const { bounds: y } = f, { bounds: w } = p, A = w.left - y.right, j = y.left - i, M = Math.abs(j - A);
|
|
5966
5964
|
if (M <= e) {
|
|
5967
|
-
const
|
|
5965
|
+
const T = j - A, S = i + T, C = {
|
|
5968
5966
|
type: "horizontal",
|
|
5969
5967
|
axis: o,
|
|
5970
5968
|
refStart: y.right,
|
|
5971
5969
|
refEnd: w.left,
|
|
5972
|
-
activeStart:
|
|
5970
|
+
activeStart: S,
|
|
5973
5971
|
activeEnd: y.left,
|
|
5974
|
-
distance:
|
|
5972
|
+
distance: A
|
|
5975
5973
|
};
|
|
5976
|
-
m.push({ delta:
|
|
5974
|
+
m.push({ delta: T, guide: C, diff: M });
|
|
5977
5975
|
}
|
|
5978
5976
|
}
|
|
5979
5977
|
if (u && f) {
|
|
5980
|
-
const { bounds: y } = u, { bounds: w } = f,
|
|
5981
|
-
if (
|
|
5982
|
-
const M =
|
|
5983
|
-
if (
|
|
5984
|
-
const
|
|
5978
|
+
const { bounds: y } = u, { bounds: w } = f, j = w.left - y.right - v;
|
|
5979
|
+
if (j >= 0) {
|
|
5980
|
+
const M = j / 2, T = n - y.right, S = w.left - i, C = Math.abs(T - M), B = Math.abs(S - M), F = Math.max(C, B);
|
|
5981
|
+
if (F <= e) {
|
|
5982
|
+
const U = M - T, H = i + U, V = {
|
|
5985
5983
|
type: "horizontal",
|
|
5986
5984
|
axis: o,
|
|
5987
5985
|
refStart: y.right,
|
|
@@ -5990,7 +5988,7 @@ const po = 5, os = "#3D8BF4", ge = 1, Xt = 1, Qe = ({
|
|
|
5990
5988
|
activeEnd: H + M,
|
|
5991
5989
|
distance: M
|
|
5992
5990
|
};
|
|
5993
|
-
m.push({ delta:
|
|
5991
|
+
m.push({ delta: U, guide: V, diff: F });
|
|
5994
5992
|
}
|
|
5995
5993
|
}
|
|
5996
5994
|
}
|
|
@@ -6040,7 +6038,7 @@ const po = 5, os = "#3D8BF4", ge = 1, Xt = 1, Qe = ({
|
|
|
6040
6038
|
}) => {
|
|
6041
6039
|
const i = Math.min(n, s / 2, o / 2);
|
|
6042
6040
|
h.moveTo(t + i, e), h.lineTo(t + s - i, e), h.quadraticCurveTo(t + s, e, t + s, e + i), h.lineTo(t + s, e + o - i), h.quadraticCurveTo(t + s, e + o, t + s - i, e + o), h.lineTo(t + i, e + o), h.quadraticCurveTo(t, e + o, t, e + o - i), h.lineTo(t, e + i), h.quadraticCurveTo(t, e, t + i, e), h.closePath();
|
|
6043
|
-
},
|
|
6041
|
+
}, me = ({
|
|
6044
6042
|
context: h,
|
|
6045
6043
|
type: t,
|
|
6046
6044
|
axis: e,
|
|
@@ -6059,12 +6057,12 @@ const po = 5, os = "#3D8BF4", ge = 1, Xt = 1, Qe = ({
|
|
|
6059
6057
|
}) => {
|
|
6060
6058
|
const p = i || 1, m = 12 / p, v = l / p, b = u / p, I = (s + o) / 2 + g, y = t === "vertical" ? e + f : I, w = t === "vertical" ? I : e + f;
|
|
6061
6059
|
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";
|
|
6062
|
-
const
|
|
6060
|
+
const j = h.measureText(n).width + v * 2, M = m + v * 2, T = y - j / 2, S = w - M / 2;
|
|
6063
6061
|
h.beginPath(), Mo({
|
|
6064
6062
|
context: h,
|
|
6065
|
-
x:
|
|
6066
|
-
y:
|
|
6067
|
-
width:
|
|
6063
|
+
x: T,
|
|
6064
|
+
y: S,
|
|
6065
|
+
width: j,
|
|
6068
6066
|
height: M,
|
|
6069
6067
|
radius: b
|
|
6070
6068
|
}), h.fill(), h.fillStyle = r, h.fillText(n, y, w), h.restore();
|
|
@@ -6084,7 +6082,7 @@ const po = 5, os = "#3D8BF4", ge = 1, Xt = 1, Qe = ({
|
|
|
6084
6082
|
} = t, d = Math.round(c).toString();
|
|
6085
6083
|
h.beginPath(), s === "vertical" ? (h.moveTo(o, n), h.lineTo(o, i), h.moveTo(o, a), h.lineTo(o, r)) : (h.moveTo(n, o), h.lineTo(i, o), h.moveTo(a, o), h.lineTo(r, o)), h.stroke();
|
|
6086
6084
|
const l = os;
|
|
6087
|
-
|
|
6085
|
+
me({
|
|
6088
6086
|
context: h,
|
|
6089
6087
|
type: s,
|
|
6090
6088
|
axis: o,
|
|
@@ -6093,8 +6091,8 @@ const po = 5, os = "#3D8BF4", ge = 1, Xt = 1, Qe = ({
|
|
|
6093
6091
|
text: d,
|
|
6094
6092
|
zoom: e,
|
|
6095
6093
|
color: l,
|
|
6096
|
-
lineWidth:
|
|
6097
|
-
}),
|
|
6094
|
+
lineWidth: pe
|
|
6095
|
+
}), me({
|
|
6098
6096
|
context: h,
|
|
6099
6097
|
type: s,
|
|
6100
6098
|
axis: o,
|
|
@@ -6103,7 +6101,7 @@ const po = 5, os = "#3D8BF4", ge = 1, Xt = 1, Qe = ({
|
|
|
6103
6101
|
text: d,
|
|
6104
6102
|
zoom: e,
|
|
6105
6103
|
color: l,
|
|
6106
|
-
lineWidth:
|
|
6104
|
+
lineWidth: pe
|
|
6107
6105
|
});
|
|
6108
6106
|
}, qe = ({
|
|
6109
6107
|
anchors: h,
|
|
@@ -6118,7 +6116,7 @@ const po = 5, os = "#3D8BF4", ge = 1, Xt = 1, Qe = ({
|
|
|
6118
6116
|
centerY: a
|
|
6119
6117
|
} = t;
|
|
6120
6118
|
h.vertical.push(e, o, s), h.horizontal.push(n, a, i);
|
|
6121
|
-
},
|
|
6119
|
+
}, Je = ({
|
|
6122
6120
|
bounds: h,
|
|
6123
6121
|
type: t,
|
|
6124
6122
|
primaryStart: e,
|
|
@@ -6148,12 +6146,12 @@ const po = 5, os = "#3D8BF4", ge = 1, Xt = 1, Qe = ({
|
|
|
6148
6146
|
}, So = ({
|
|
6149
6147
|
bounds: h
|
|
6150
6148
|
}) => {
|
|
6151
|
-
const t =
|
|
6149
|
+
const t = Je({
|
|
6152
6150
|
bounds: h,
|
|
6153
6151
|
type: "vertical",
|
|
6154
6152
|
primaryStart: "top",
|
|
6155
6153
|
primaryEnd: "bottom"
|
|
6156
|
-
}), e =
|
|
6154
|
+
}), e = Je({
|
|
6157
6155
|
bounds: h,
|
|
6158
6156
|
type: "horizontal",
|
|
6159
6157
|
primaryStart: "left",
|
|
@@ -6164,7 +6162,7 @@ const po = 5, os = "#3D8BF4", ge = 1, Xt = 1, Qe = ({
|
|
|
6164
6162
|
activeObject: h
|
|
6165
6163
|
}) => {
|
|
6166
6164
|
const t = /* @__PURE__ */ new Set();
|
|
6167
|
-
return h && (t.add(h), h instanceof
|
|
6165
|
+
return h && (t.add(h), h instanceof x && h.getObjects().forEach((e) => t.add(e))), t;
|
|
6168
6166
|
}, as = ({
|
|
6169
6167
|
object: h,
|
|
6170
6168
|
excluded: t,
|
|
@@ -6234,7 +6232,7 @@ class jo {
|
|
|
6234
6232
|
return;
|
|
6235
6233
|
}
|
|
6236
6234
|
!this.anchors.vertical.length && !this.anchors.horizontal.length && this._cacheAnchors({ activeObject: e });
|
|
6237
|
-
let n =
|
|
6235
|
+
let n = ft({ object: e });
|
|
6238
6236
|
if (!n) {
|
|
6239
6237
|
this._clearGuides();
|
|
6240
6238
|
return;
|
|
@@ -6249,9 +6247,9 @@ class jo {
|
|
|
6249
6247
|
e.set({
|
|
6250
6248
|
left: v + d,
|
|
6251
6249
|
top: b + l
|
|
6252
|
-
}), e.setCoords(), n = (p =
|
|
6250
|
+
}), e.setCoords(), n = (p = ft({ object: e })) != null ? p : n;
|
|
6253
6251
|
}
|
|
6254
|
-
const g = this.cachedTargetBounds.length ? this.cachedTargetBounds : this._collectTargets({ activeObject: e }).map((v) =>
|
|
6252
|
+
const g = this.cachedTargetBounds.length ? this.cachedTargetBounds : this._collectTargets({ activeObject: e }).map((v) => ft({ object: v })).filter((v) => !!v), f = bo({
|
|
6255
6253
|
activeBounds: n,
|
|
6256
6254
|
candidates: g,
|
|
6257
6255
|
threshold: r,
|
|
@@ -6262,7 +6260,7 @@ class jo {
|
|
|
6262
6260
|
e.set({
|
|
6263
6261
|
left: v + f.deltaX,
|
|
6264
6262
|
top: b + f.deltaY
|
|
6265
|
-
}), e.setCoords(), n = (m =
|
|
6263
|
+
}), e.setCoords(), n = (m = ft({ object: e })) != null ? m : n;
|
|
6266
6264
|
}
|
|
6267
6265
|
this._applyGuides({
|
|
6268
6266
|
guides: u,
|
|
@@ -6290,7 +6288,7 @@ class jo {
|
|
|
6290
6288
|
const { canvas: t, guideBounds: e } = this, s = t.getSelectionContext();
|
|
6291
6289
|
if (!s) return;
|
|
6292
6290
|
const o = e != null ? e : this._calculateViewportBounds(), { left: n, right: i, top: a, bottom: r } = o, { viewportTransform: c } = t, d = t.getZoom() || 1;
|
|
6293
|
-
s.save(), Array.isArray(c) && s.transform(...c), s.lineWidth =
|
|
6291
|
+
s.save(), Array.isArray(c) && s.transform(...c), s.lineWidth = pe / d, s.strokeStyle = os, s.setLineDash([4, 4]);
|
|
6294
6292
|
for (const l of this.activeGuides)
|
|
6295
6293
|
s.beginPath(), l.type === "vertical" ? (s.moveTo(l.position, a), s.lineTo(l.position, r)) : (s.moveTo(n, l.position), s.lineTo(i, l.position)), s.stroke();
|
|
6296
6294
|
for (const l of this.activeSpacingGuides)
|
|
@@ -6330,7 +6328,7 @@ class jo {
|
|
|
6330
6328
|
* Применяет шаг перемещения, округляя координаты объекта к сетке MOVE_SNAP_STEP.
|
|
6331
6329
|
*/
|
|
6332
6330
|
_applyMovementStep({ target: t }) {
|
|
6333
|
-
const { left: e = 0, top: s = 0 } = t, o = Math.round(e /
|
|
6331
|
+
const { left: e = 0, top: s = 0 } = t, o = Math.round(e / Qt) * Qt, n = Math.round(s / Qt) * Qt;
|
|
6334
6332
|
o === e && n === s || (t.set({
|
|
6335
6333
|
left: o,
|
|
6336
6334
|
top: n
|
|
@@ -6342,10 +6340,10 @@ class jo {
|
|
|
6342
6340
|
_cacheAnchors({ activeObject: t }) {
|
|
6343
6341
|
const e = this._collectTargets({ activeObject: t }), s = { vertical: [], horizontal: [] }, o = [];
|
|
6344
6342
|
for (const a of e) {
|
|
6345
|
-
const r =
|
|
6343
|
+
const r = ft({ object: a });
|
|
6346
6344
|
r && (qe({ anchors: s, bounds: r }), o.push(r));
|
|
6347
6345
|
}
|
|
6348
|
-
const { montageArea: n } = this.editor, i =
|
|
6346
|
+
const { montageArea: n } = this.editor, i = ft({ object: n });
|
|
6349
6347
|
if (i) {
|
|
6350
6348
|
qe({ anchors: s, bounds: i });
|
|
6351
6349
|
const { left: a, right: r, top: c, bottom: d } = i;
|
|
@@ -6388,8 +6386,8 @@ class jo {
|
|
|
6388
6386
|
};
|
|
6389
6387
|
}
|
|
6390
6388
|
}
|
|
6391
|
-
const
|
|
6392
|
-
class
|
|
6389
|
+
const $e = "#3D8BF4", ts = 1;
|
|
6390
|
+
class Lt {
|
|
6393
6391
|
/**
|
|
6394
6392
|
* Создаёт менеджер измерений и инициализирует события.
|
|
6395
6393
|
*/
|
|
@@ -6494,15 +6492,15 @@ class Ct {
|
|
|
6494
6492
|
this._clearGuides();
|
|
6495
6493
|
return;
|
|
6496
6494
|
}
|
|
6497
|
-
const n =
|
|
6495
|
+
const n = ft({ object: o });
|
|
6498
6496
|
if (!n) {
|
|
6499
6497
|
this._clearGuides();
|
|
6500
6498
|
return;
|
|
6501
6499
|
}
|
|
6502
|
-
const i =
|
|
6500
|
+
const i = Lt._resolveTarget({
|
|
6503
6501
|
event: t,
|
|
6504
6502
|
activeObject: o
|
|
6505
|
-
}), { montageArea: a } = s, r = i != null ? i : a, c = r === a, d =
|
|
6503
|
+
}), { montageArea: a } = s, r = i != null ? i : a, c = r === a, d = ft({ object: r });
|
|
6506
6504
|
if (!d) {
|
|
6507
6505
|
this._clearGuides();
|
|
6508
6506
|
return;
|
|
@@ -6511,7 +6509,7 @@ class Ct {
|
|
|
6511
6509
|
this._clearGuides();
|
|
6512
6510
|
return;
|
|
6513
6511
|
}
|
|
6514
|
-
const u =
|
|
6512
|
+
const u = Lt._buildGuides({
|
|
6515
6513
|
activeBounds: n,
|
|
6516
6514
|
targetBounds: d,
|
|
6517
6515
|
targetIsMontageArea: c
|
|
@@ -6540,11 +6538,11 @@ class Ct {
|
|
|
6540
6538
|
targetBounds: e,
|
|
6541
6539
|
targetIsMontageArea: s
|
|
6542
6540
|
}) {
|
|
6543
|
-
const o =
|
|
6541
|
+
const o = Lt._buildHorizontalGuides({
|
|
6544
6542
|
activeBounds: t,
|
|
6545
6543
|
targetBounds: e,
|
|
6546
6544
|
targetIsMontageArea: s
|
|
6547
|
-
}), n =
|
|
6545
|
+
}), n = Lt._buildVerticalGuides({
|
|
6548
6546
|
activeBounds: t,
|
|
6549
6547
|
targetBounds: e,
|
|
6550
6548
|
targetIsMontageArea: s
|
|
@@ -6574,42 +6572,42 @@ class Ct {
|
|
|
6574
6572
|
} = e, p = Math.max(a, u), m = Math.min(r, g), b = m >= p ? (p + m) / 2 : (c + f) / 2;
|
|
6575
6573
|
if (d >= i) {
|
|
6576
6574
|
if (s) return o;
|
|
6577
|
-
const
|
|
6578
|
-
return
|
|
6575
|
+
const C = d - i;
|
|
6576
|
+
return C > 0 && o.push({
|
|
6579
6577
|
type: "horizontal",
|
|
6580
6578
|
axis: b,
|
|
6581
6579
|
start: i,
|
|
6582
6580
|
end: d,
|
|
6583
|
-
distance:
|
|
6581
|
+
distance: C
|
|
6584
6582
|
}), o;
|
|
6585
6583
|
}
|
|
6586
6584
|
if (l <= n) {
|
|
6587
6585
|
if (s) return o;
|
|
6588
|
-
const
|
|
6589
|
-
return
|
|
6586
|
+
const C = n - l;
|
|
6587
|
+
return C > 0 && o.push({
|
|
6590
6588
|
type: "horizontal",
|
|
6591
6589
|
axis: b,
|
|
6592
6590
|
start: l,
|
|
6593
6591
|
end: n,
|
|
6594
|
-
distance:
|
|
6592
|
+
distance: C
|
|
6595
6593
|
}), o;
|
|
6596
6594
|
}
|
|
6597
6595
|
if (!s) return o;
|
|
6598
|
-
const I = n < d, y = i > l, w = Math.min(n, d),
|
|
6599
|
-
|
|
6596
|
+
const I = n < d, y = i > l, w = Math.min(n, d), A = Math.max(n, d), j = A - w;
|
|
6597
|
+
j > 0 && !I && o.push({
|
|
6600
6598
|
type: "horizontal",
|
|
6601
6599
|
axis: b,
|
|
6602
6600
|
start: w,
|
|
6603
|
-
end:
|
|
6604
|
-
distance:
|
|
6601
|
+
end: A,
|
|
6602
|
+
distance: j
|
|
6605
6603
|
});
|
|
6606
|
-
const M = Math.min(i, l),
|
|
6607
|
-
return
|
|
6604
|
+
const M = Math.min(i, l), T = Math.max(i, l), S = T - M;
|
|
6605
|
+
return S > 0 && !y && o.push({
|
|
6608
6606
|
type: "horizontal",
|
|
6609
6607
|
axis: b,
|
|
6610
6608
|
start: M,
|
|
6611
|
-
end:
|
|
6612
|
-
distance:
|
|
6609
|
+
end: T,
|
|
6610
|
+
distance: S
|
|
6613
6611
|
}), o;
|
|
6614
6612
|
}
|
|
6615
6613
|
/**
|
|
@@ -6635,42 +6633,42 @@ class Ct {
|
|
|
6635
6633
|
} = e, p = Math.max(a, u), m = Math.min(r, g), b = m >= p ? (p + m) / 2 : (c + f) / 2;
|
|
6636
6634
|
if (d >= i) {
|
|
6637
6635
|
if (s) return o;
|
|
6638
|
-
const
|
|
6639
|
-
return
|
|
6636
|
+
const C = d - i;
|
|
6637
|
+
return C > 0 && o.push({
|
|
6640
6638
|
type: "vertical",
|
|
6641
6639
|
axis: b,
|
|
6642
6640
|
start: i,
|
|
6643
6641
|
end: d,
|
|
6644
|
-
distance:
|
|
6642
|
+
distance: C
|
|
6645
6643
|
}), o;
|
|
6646
6644
|
}
|
|
6647
6645
|
if (l <= n) {
|
|
6648
6646
|
if (s) return o;
|
|
6649
|
-
const
|
|
6650
|
-
return
|
|
6647
|
+
const C = n - l;
|
|
6648
|
+
return C > 0 && o.push({
|
|
6651
6649
|
type: "vertical",
|
|
6652
6650
|
axis: b,
|
|
6653
6651
|
start: l,
|
|
6654
6652
|
end: n,
|
|
6655
|
-
distance:
|
|
6653
|
+
distance: C
|
|
6656
6654
|
}), o;
|
|
6657
6655
|
}
|
|
6658
6656
|
if (!s) return o;
|
|
6659
|
-
const I = n < d, y = i > l, w = Math.min(n, d),
|
|
6660
|
-
|
|
6657
|
+
const I = n < d, y = i > l, w = Math.min(n, d), A = Math.max(n, d), j = A - w;
|
|
6658
|
+
j > 0 && !I && o.push({
|
|
6661
6659
|
type: "vertical",
|
|
6662
6660
|
axis: b,
|
|
6663
6661
|
start: w,
|
|
6664
|
-
end:
|
|
6665
|
-
distance:
|
|
6662
|
+
end: A,
|
|
6663
|
+
distance: j
|
|
6666
6664
|
});
|
|
6667
|
-
const M = Math.min(i, l),
|
|
6668
|
-
return
|
|
6665
|
+
const M = Math.min(i, l), T = Math.max(i, l), S = T - M;
|
|
6666
|
+
return S > 0 && !y && o.push({
|
|
6669
6667
|
type: "vertical",
|
|
6670
6668
|
axis: b,
|
|
6671
6669
|
start: M,
|
|
6672
|
-
end:
|
|
6673
|
-
distance:
|
|
6670
|
+
end: T,
|
|
6671
|
+
distance: S
|
|
6674
6672
|
}), o;
|
|
6675
6673
|
}
|
|
6676
6674
|
/**
|
|
@@ -6698,10 +6696,10 @@ class Ct {
|
|
|
6698
6696
|
const { canvas: t } = this, e = t.getSelectionContext();
|
|
6699
6697
|
if (!e) return;
|
|
6700
6698
|
const { viewportTransform: s } = t, o = t.getZoom() || 1, n = this.activeGuides.some((c) => c.type === "vertical"), i = this.activeGuides.some((c) => c.type === "horizontal"), a = n && i && !this.isTargetMontageArea, r = a ? 12 / o : 0;
|
|
6701
|
-
e.save(), Array.isArray(s) && e.transform(...s), e.lineWidth = ts / o, e.strokeStyle =
|
|
6699
|
+
e.save(), Array.isArray(s) && e.transform(...s), e.lineWidth = ts / o, e.strokeStyle = $e, e.setLineDash([]);
|
|
6702
6700
|
for (const c of this.activeGuides) {
|
|
6703
6701
|
const { type: d, axis: l, start: u, end: g, distance: f } = c, p = Math.abs(g - u), m = u <= g ? -1 : 1, v = a ? m * (p / 2 + r) : 0, b = 0;
|
|
6704
|
-
e.beginPath(), d === "vertical" ? (e.moveTo(l, u), e.lineTo(l, g)) : (e.moveTo(u, l), e.lineTo(g, l)), e.stroke(),
|
|
6702
|
+
e.beginPath(), d === "vertical" ? (e.moveTo(l, u), e.lineTo(l, g)) : (e.moveTo(u, l), e.lineTo(g, l)), e.stroke(), me({
|
|
6705
6703
|
context: e,
|
|
6706
6704
|
type: d,
|
|
6707
6705
|
axis: l,
|
|
@@ -6709,7 +6707,7 @@ class Ct {
|
|
|
6709
6707
|
end: g,
|
|
6710
6708
|
text: Math.round(f).toString(),
|
|
6711
6709
|
zoom: o,
|
|
6712
|
-
color:
|
|
6710
|
+
color: $e,
|
|
6713
6711
|
lineWidth: ts,
|
|
6714
6712
|
offsetAlongAxis: v,
|
|
6715
6713
|
offsetPerpendicular: b
|
|
@@ -6736,14 +6734,14 @@ class Ct {
|
|
|
6736
6734
|
(e = t == null ? void 0 : t.showAfterTemporary) == null || e.call(t), this.isToolbarHidden = !1;
|
|
6737
6735
|
}
|
|
6738
6736
|
}
|
|
6739
|
-
class
|
|
6737
|
+
class Se {
|
|
6740
6738
|
/**
|
|
6741
6739
|
* Конструктор класса ImageEditor.
|
|
6742
6740
|
* @param canvasId - идентификатор канваса, в котором будет создан редактор
|
|
6743
6741
|
* @param options - опции и настройки редактора
|
|
6744
6742
|
*/
|
|
6745
6743
|
constructor(t, e) {
|
|
6746
|
-
this.options = e, this.containerId = t, this.editorId = `${t}-${
|
|
6744
|
+
this.options = e, this.containerId = t, this.editorId = `${t}-${G()}`, this.clipboard = null, this.init();
|
|
6747
6745
|
}
|
|
6748
6746
|
/**
|
|
6749
6747
|
* Инициализация редактора.
|
|
@@ -6751,7 +6749,7 @@ class Me {
|
|
|
6751
6749
|
* @fires editor:ready
|
|
6752
6750
|
*/
|
|
6753
6751
|
init() {
|
|
6754
|
-
return
|
|
6752
|
+
return N(this, null, function* () {
|
|
6755
6753
|
var u;
|
|
6756
6754
|
const {
|
|
6757
6755
|
editorContainerWidth: t,
|
|
@@ -6766,7 +6764,7 @@ class Me {
|
|
|
6766
6764
|
showRotationAngle: d,
|
|
6767
6765
|
_onReadyCallback: l
|
|
6768
6766
|
} = this.options;
|
|
6769
|
-
if (
|
|
6767
|
+
if (J.apply(), this.canvas = new vs(this.containerId, this.options), this.moduleLoader = new As(), this.workerManager = new Is(), this.errorManager = new Yt({ editor: this }), this.historyManager = new Jt({ editor: this }), this.toolbar = new Ys({ editor: this }), this.transformManager = new qs({ editor: this }), this.zoomManager = new Js({ editor: this }), this.canvasManager = new Qs({ editor: this }), this.imageManager = new ct({ editor: this }), this.layerManager = new $t({ editor: this }), this.shapeManager = new to({ editor: this }), this.interactionBlocker = new $s({ editor: this }), this.backgroundManager = new Ot({ editor: this }), this.clipboardManager = new eo({ editor: this }), this.objectLockManager = new te({ editor: this }), this.groupingManager = new so({ editor: this }), this.selectionManager = new oo({ editor: this }), this.deletionManager = new we({ editor: this }), this.panConstraintManager = new no({ editor: this }), this.snappingManager = new jo({ editor: this }), this.measurementManager = new Lt({ editor: this }), this.fontManager = new fe((u = this.options.fonts) != null ? u : []), this.textManager = new Z({ editor: this }), this.templateManager = new R({ editor: this }), d && (this.angleIndicator = new Me({ editor: this })), this._createMontageArea(), this._createClippingArea(), this.listeners = new Ut({ editor: this, options: this.options }), this.canvasManager.setEditorContainerWidth(t), this.canvasManager.setEditorContainerHeight(e), this.canvasManager.setCanvasWrapperWidth(s), this.canvasManager.setCanvasWrapperHeight(o), this.canvasManager.setCanvasCSSWidth(n), this.canvasManager.setCanvasCSSHeight(i), this.canvasManager.updateCanvas(), this.zoomManager.calculateAndApplyDefaultZoom(), yield this.fontManager.loadFonts(), a != null && a.source) {
|
|
6770
6768
|
const {
|
|
6771
6769
|
source: g,
|
|
6772
6770
|
scale: f = `image-${c}`,
|
|
@@ -6788,7 +6786,7 @@ class Me {
|
|
|
6788
6786
|
this.montageArea = this.shapeManager.addRectangle({
|
|
6789
6787
|
width: t,
|
|
6790
6788
|
height: e,
|
|
6791
|
-
fill:
|
|
6789
|
+
fill: Se._createMosaicPattern(),
|
|
6792
6790
|
stroke: null,
|
|
6793
6791
|
strokeWidth: 0,
|
|
6794
6792
|
selectable: !1,
|
|
@@ -7755,18 +7753,18 @@ const E = [
|
|
|
7755
7753
|
*/
|
|
7756
7754
|
fonts: Io
|
|
7757
7755
|
};
|
|
7758
|
-
function
|
|
7759
|
-
const e =
|
|
7756
|
+
function Do(h, t = {}) {
|
|
7757
|
+
const e = _(_({}, Co), t), s = document.getElementById(h);
|
|
7760
7758
|
if (!s)
|
|
7761
7759
|
return Promise.reject(new Error(`Контейнер с ID "${h}" не найден.`));
|
|
7762
7760
|
const o = document.createElement("canvas");
|
|
7763
7761
|
return o.id = `${h}-canvas`, s.appendChild(o), e.editorContainer = s, new Promise((n) => {
|
|
7764
7762
|
e._onReadyCallback = n;
|
|
7765
|
-
const i = new
|
|
7763
|
+
const i = new Se(o.id, e);
|
|
7766
7764
|
window[h] = i;
|
|
7767
7765
|
});
|
|
7768
7766
|
}
|
|
7769
7767
|
export {
|
|
7770
|
-
|
|
7768
|
+
Do as default
|
|
7771
7769
|
};
|
|
7772
7770
|
//# sourceMappingURL=main.js.map
|