@anu3ev/fabric-image-editor 0.5.23 → 0.5.25
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 +935 -868
- 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
|
|
4
|
-
var
|
|
5
|
-
var _e = (h, t, e) => t in h ? ds(h, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : h[t] = e,
|
|
3
|
+
var ae = Object.getOwnPropertySymbols;
|
|
4
|
+
var Ne = Object.prototype.hasOwnProperty, Be = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var _e = (h, t, e) => t in h ? ds(h, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : h[t] = e, z = (h, t) => {
|
|
6
6
|
for (var e in t || (t = {}))
|
|
7
|
-
|
|
8
|
-
if (
|
|
9
|
-
for (var e of
|
|
10
|
-
|
|
7
|
+
Ne.call(t, e) && _e(h, e, t[e]);
|
|
8
|
+
if (ae)
|
|
9
|
+
for (var e of ae(t))
|
|
10
|
+
Be.call(t, e) && _e(h, e, t[e]);
|
|
11
11
|
return h;
|
|
12
|
-
},
|
|
13
|
-
var
|
|
12
|
+
}, wt = (h, t) => ls(h, hs(t));
|
|
13
|
+
var gt = (h, t) => {
|
|
14
14
|
var e = {};
|
|
15
15
|
for (var s in h)
|
|
16
|
-
|
|
17
|
-
if (h != null &&
|
|
18
|
-
for (var s of
|
|
19
|
-
t.indexOf(s) < 0 &&
|
|
16
|
+
Ne.call(h, s) && t.indexOf(s) < 0 && (e[s] = h[s]);
|
|
17
|
+
if (h != null && ae)
|
|
18
|
+
for (var s of ae(h))
|
|
19
|
+
t.indexOf(s) < 0 && Be.call(h, s) && (e[s] = h[s]);
|
|
20
20
|
return e;
|
|
21
21
|
};
|
|
22
|
-
var
|
|
22
|
+
var W = (h, t, e) => new Promise((s, n) => {
|
|
23
23
|
var o = (r) => {
|
|
24
24
|
try {
|
|
25
25
|
a(e.next(r));
|
|
@@ -35,15 +35,15 @@ var P = (h, t, e) => new Promise((s, n) => {
|
|
|
35
35
|
}, a = (r) => r.done ? s(r.value) : Promise.resolve(r.value).then(o, i);
|
|
36
36
|
a((e = e.apply(h, t)).next());
|
|
37
37
|
});
|
|
38
|
-
import { ActiveSelection as
|
|
38
|
+
import { ActiveSelection as F, Textbox as at, util as ht, controlsUtils as ke, InteractiveFabricObject as ze, Point as et, FitContentLayout as Pe, loadSVGFromURL as us, FabricImage as qt, Gradient as We, Rect as fs, Circle as gs, Triangle as ps, Group as xt, Color as ms, classRegistry as Ue, 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", K = 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 $t {
|
|
47
47
|
/**
|
|
48
48
|
* Конструктор принимает редактор и опции.
|
|
49
49
|
* @param params
|
|
@@ -61,7 +61,7 @@ class Kt {
|
|
|
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 = $t.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 = $t.debounce(this.handleObjectModifiedHistory.bind(this), 300), this.handleObjectRotatingHistoryBound = $t.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 Kt {
|
|
|
98
98
|
if (n.length === 1)
|
|
99
99
|
this.canvas.setActiveObject(n[0]);
|
|
100
100
|
else {
|
|
101
|
-
const i = new
|
|
101
|
+
const i = new F(n, {
|
|
102
102
|
canvas: this.canvas
|
|
103
103
|
});
|
|
104
104
|
this.canvas.setActiveObject(i);
|
|
@@ -106,7 +106,7 @@ class Kt {
|
|
|
106
106
|
this.canvas.requestRenderAll();
|
|
107
107
|
return;
|
|
108
108
|
}
|
|
109
|
-
const o = new
|
|
109
|
+
const o = new F(t, {
|
|
110
110
|
canvas: this.canvas
|
|
111
111
|
});
|
|
112
112
|
this.editor.objectLockManager.lockObject({
|
|
@@ -175,7 +175,7 @@ class Kt {
|
|
|
175
175
|
* @param event.code — код клавиши
|
|
176
176
|
*/
|
|
177
177
|
handleUndoRedoEvent(t) {
|
|
178
|
-
return
|
|
178
|
+
return W(this, null, function* () {
|
|
179
179
|
const { ctrlKey: e, metaKey: s, code: n, repeat: o } = t;
|
|
180
180
|
this._shouldIgnoreKeyboardEvent(t) || !e && !s || o || !/Mac/i.test(navigator.userAgent) && this.isUndoRedoKeyPressed || (n === "KeyZ" ? (t.preventDefault(), this.isUndoRedoKeyPressed = !0, yield this.editor.historyManager.undo()) : n === "KeyY" && (t.preventDefault(), this.isUndoRedoKeyPressed = !0, yield this.editor.historyManager.redo()));
|
|
181
181
|
});
|
|
@@ -225,7 +225,7 @@ class Kt {
|
|
|
225
225
|
if (o || i) return;
|
|
226
226
|
n.historyManager.skipHistory || n.historyManager.saveState(), n.historyManager.suspendHistory(), this.isSpacePressed = !0, t.preventDefault();
|
|
227
227
|
const a = s.getActiveObject() || null;
|
|
228
|
-
a instanceof
|
|
228
|
+
a instanceof F ? this.savedSelection = a.getObjects().slice() : a && (this.savedSelection = [a]), s.discardActiveObject(), s.set({
|
|
229
229
|
selection: !1,
|
|
230
230
|
defaultCursor: "grab"
|
|
231
231
|
}), s.setCursor("grab"), n.canvasManager.getObjects().forEach((r) => {
|
|
@@ -265,7 +265,7 @@ class Kt {
|
|
|
265
265
|
e.setActiveObject(t[0]);
|
|
266
266
|
return;
|
|
267
267
|
}
|
|
268
|
-
const n = t.filter((i) => s.canvasManager.getObjects().includes(i)), o = new
|
|
268
|
+
const n = t.filter((i) => s.canvasManager.getObjects().includes(i)), o = new F(n, { canvas: e });
|
|
269
269
|
n.some((i) => i.locked) && s.objectLockManager.lockObject({
|
|
270
270
|
object: o,
|
|
271
271
|
skipInnerObjects: !0,
|
|
@@ -347,7 +347,7 @@ class Kt {
|
|
|
347
347
|
*/
|
|
348
348
|
handleResetObjectFit(t) {
|
|
349
349
|
const e = t == null ? void 0 : t.target;
|
|
350
|
-
!e || e instanceof
|
|
350
|
+
!e || e instanceof at || this.editor.transformManager.resetObject({ object: e });
|
|
351
351
|
}
|
|
352
352
|
/**
|
|
353
353
|
* Проверяет, должно ли событие клавиатуры быть проигнорировано
|
|
@@ -434,7 +434,7 @@ function js(h) {
|
|
|
434
434
|
}
|
|
435
435
|
);
|
|
436
436
|
}
|
|
437
|
-
class
|
|
437
|
+
class Cs {
|
|
438
438
|
/**
|
|
439
439
|
* @param scriptUrl — URL скрипта воркера.
|
|
440
440
|
* По-умолчанию использует DefaultWorker из соседнего файла
|
|
@@ -468,7 +468,7 @@ class Is {
|
|
|
468
468
|
* @returns Promise, который будет выполнен, когда воркер вернет ответ
|
|
469
469
|
*/
|
|
470
470
|
post(t, e, s = []) {
|
|
471
|
-
const n = `${t}:${
|
|
471
|
+
const n = `${t}:${K(8)}`;
|
|
472
472
|
return new Promise((o, i) => {
|
|
473
473
|
this._callbacks.set(n, { resolve: o, reject: i }), this.worker.postMessage({ action: t, payload: e, requestId: n }, s);
|
|
474
474
|
});
|
|
@@ -480,95 +480,95 @@ class Is {
|
|
|
480
480
|
this.worker.terminate();
|
|
481
481
|
}
|
|
482
482
|
}
|
|
483
|
-
const
|
|
484
|
-
function
|
|
485
|
-
const o =
|
|
486
|
-
h.save(), h.translate(t, e), h.rotate(
|
|
487
|
-
}
|
|
488
|
-
function Ue(h, t, e, s, n) {
|
|
489
|
-
const o = ve, i = be, a = Ts;
|
|
490
|
-
h.save(), h.translate(t, e), h.rotate(ft.degreesToRadians(n.angle)), h.fillStyle = Te, h.strokeStyle = Ce, h.lineWidth = Ie, h.beginPath(), h.roundRect(-o / 2, -i / 2, o, i, a), h.fill(), h.stroke(), h.restore();
|
|
483
|
+
const dt = 12, Is = 2, we = 8, Se = 20, Es = 100, Ae = 20, je = 8, Ts = 100, ue = 32, Te = 1, Os = "#2B2D33", Oe = "#3D8BF4", Le = "#FFFFFF";
|
|
484
|
+
function re(h, t, e, s, n) {
|
|
485
|
+
const o = dt, i = Is;
|
|
486
|
+
h.save(), h.translate(t, e), h.rotate(ht.degreesToRadians(n.angle)), h.fillStyle = Le, h.strokeStyle = Oe, h.lineWidth = Te, h.beginPath(), h.roundRect(-o / 2, -o / 2, o, o, i), h.fill(), h.stroke(), h.restore();
|
|
491
487
|
}
|
|
492
488
|
function Fe(h, t, e, s, n) {
|
|
493
|
-
const o =
|
|
494
|
-
h.save(), h.translate(t, e), h.rotate(
|
|
489
|
+
const o = we, i = Se, a = Es;
|
|
490
|
+
h.save(), h.translate(t, e), h.rotate(ht.degreesToRadians(n.angle)), h.fillStyle = Le, h.strokeStyle = Oe, h.lineWidth = Te, h.beginPath(), h.roundRect(-o / 2, -i / 2, o, i, a), h.fill(), h.stroke(), h.restore();
|
|
491
|
+
}
|
|
492
|
+
function Ye(h, t, e, s, n) {
|
|
493
|
+
const o = Ae, i = je, a = Ts;
|
|
494
|
+
h.save(), h.translate(t, e), h.rotate(ht.degreesToRadians(n.angle)), h.fillStyle = Le, h.strokeStyle = Oe, h.lineWidth = Te, h.beginPath(), h.roundRect(-o / 2, -i / 2, o, i, a), h.fill(), h.stroke(), h.restore();
|
|
495
495
|
}
|
|
496
|
-
const Ls = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTE4Ljc1IDQuMzc1djMuNzVhLjYyNS42MjUgMCAwIDEtLjYyNS42MjVoLTMuNzVhLjYyNS42MjUgMCAwIDEgMC0xLjI1aDIuMTRsLTIuMDc3LTEuOTAzLS4wMi0uMDE5YTYuMjUgNi4yNSAwIDEgMC0uMTMgOC45NjcuNjI2LjYyNiAwIDAgMSAuODYuOTA5QTcuNDU2IDcuNDU2IDAgMCAxIDEwIDE3LjVoLS4xMDNhNy41IDcuNSAwIDEgMSA1LjM5Ni0xMi44MTJMMTcuNSA2LjcwM1Y0LjM3NWEuNjI1LjYyNSAwIDAgMSAxLjI1IDBaIi8+PC9zdmc+",
|
|
497
|
-
|
|
496
|
+
const Ls = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTE4Ljc1IDQuMzc1djMuNzVhLjYyNS42MjUgMCAwIDEtLjYyNS42MjVoLTMuNzVhLjYyNS42MjUgMCAwIDEgMC0xLjI1aDIuMTRsLTIuMDc3LTEuOTAzLS4wMi0uMDE5YTYuMjUgNi4yNSAwIDEgMC0uMTMgOC45NjcuNjI2LjYyNiAwIDAgMSAuODYuOTA5QTcuNDU2IDcuNDU2IDAgMCAxIDEwIDE3LjVoLS4xMDNhNy41IDcuNSAwIDEgMSA1LjM5Ni0xMi44MTJMMTcuNSA2LjcwM1Y0LjM3NWEuNjI1LjYyNSAwIDAgMSAxLjI1IDBaIi8+PC9zdmc+", ns = new Image();
|
|
497
|
+
ns.src = Ls;
|
|
498
498
|
function Ds(h, t, e, s, n) {
|
|
499
|
-
const i =
|
|
500
|
-
h.save(), h.translate(t, e), h.rotate(
|
|
499
|
+
const i = ue / 2;
|
|
500
|
+
h.save(), h.translate(t, e), h.rotate(ht.degreesToRadians(n.angle)), h.fillStyle = Os, h.beginPath(), h.arc(0, 0, i, 0, 2 * Math.PI), h.fill(), h.drawImage(ns, -i / 2, -i / 2, i, i), h.restore();
|
|
501
501
|
}
|
|
502
502
|
const Rs = {
|
|
503
503
|
// Угловые точки
|
|
504
504
|
tl: {
|
|
505
|
-
render:
|
|
506
|
-
sizeX:
|
|
507
|
-
sizeY:
|
|
505
|
+
render: re,
|
|
506
|
+
sizeX: dt,
|
|
507
|
+
sizeY: dt,
|
|
508
508
|
offsetX: 0,
|
|
509
509
|
offsetY: 0
|
|
510
510
|
},
|
|
511
511
|
tr: {
|
|
512
|
-
render:
|
|
513
|
-
sizeX:
|
|
514
|
-
sizeY:
|
|
512
|
+
render: re,
|
|
513
|
+
sizeX: dt,
|
|
514
|
+
sizeY: dt,
|
|
515
515
|
offsetX: 0,
|
|
516
516
|
offsetY: 0
|
|
517
517
|
},
|
|
518
518
|
bl: {
|
|
519
|
-
render:
|
|
520
|
-
sizeX:
|
|
521
|
-
sizeY:
|
|
519
|
+
render: re,
|
|
520
|
+
sizeX: dt,
|
|
521
|
+
sizeY: dt,
|
|
522
522
|
offsetX: 0,
|
|
523
523
|
offsetY: 0
|
|
524
524
|
},
|
|
525
525
|
br: {
|
|
526
|
-
render:
|
|
527
|
-
sizeX:
|
|
528
|
-
sizeY:
|
|
526
|
+
render: re,
|
|
527
|
+
sizeX: dt,
|
|
528
|
+
sizeY: dt,
|
|
529
529
|
offsetX: 0,
|
|
530
530
|
offsetY: 0
|
|
531
531
|
},
|
|
532
532
|
// Середина вертикалей
|
|
533
533
|
ml: {
|
|
534
|
-
render:
|
|
535
|
-
sizeX:
|
|
536
|
-
sizeY:
|
|
534
|
+
render: Fe,
|
|
535
|
+
sizeX: we,
|
|
536
|
+
sizeY: Se,
|
|
537
537
|
offsetX: 0,
|
|
538
538
|
offsetY: 0
|
|
539
539
|
},
|
|
540
540
|
mr: {
|
|
541
|
-
render:
|
|
542
|
-
sizeX:
|
|
543
|
-
sizeY:
|
|
541
|
+
render: Fe,
|
|
542
|
+
sizeX: we,
|
|
543
|
+
sizeY: Se,
|
|
544
544
|
offsetX: 0,
|
|
545
545
|
offsetY: 0
|
|
546
546
|
},
|
|
547
547
|
// Середина горизонталей
|
|
548
548
|
mt: {
|
|
549
|
-
render:
|
|
550
|
-
sizeX:
|
|
551
|
-
sizeY:
|
|
549
|
+
render: Ye,
|
|
550
|
+
sizeX: Ae,
|
|
551
|
+
sizeY: je,
|
|
552
552
|
offsetX: 0,
|
|
553
553
|
offsetY: 0
|
|
554
554
|
},
|
|
555
555
|
mb: {
|
|
556
|
-
render:
|
|
557
|
-
sizeX:
|
|
558
|
-
sizeY:
|
|
556
|
+
render: Ye,
|
|
557
|
+
sizeX: Ae,
|
|
558
|
+
sizeY: je,
|
|
559
559
|
offsetX: 0,
|
|
560
560
|
offsetY: 0
|
|
561
561
|
},
|
|
562
562
|
// Специальный «rotate» контрол
|
|
563
563
|
mtr: {
|
|
564
564
|
render: Ds,
|
|
565
|
-
sizeX:
|
|
566
|
-
sizeY:
|
|
565
|
+
sizeX: ue,
|
|
566
|
+
sizeY: ue,
|
|
567
567
|
offsetX: 0,
|
|
568
|
-
offsetY: -
|
|
568
|
+
offsetY: -ue
|
|
569
569
|
}
|
|
570
570
|
};
|
|
571
|
-
class
|
|
571
|
+
class ot {
|
|
572
572
|
/**
|
|
573
573
|
* Отключает изменение ширины по оси X для заблокированных объектов, сохраняя поведение остального хэндлера.
|
|
574
574
|
*/
|
|
@@ -597,24 +597,24 @@ class st {
|
|
|
597
597
|
* Регистрирует контролы и настройки поведения выделений.
|
|
598
598
|
*/
|
|
599
599
|
static apply() {
|
|
600
|
-
const t =
|
|
601
|
-
|
|
602
|
-
const e =
|
|
603
|
-
|
|
600
|
+
const t = ke.createObjectDefaultControls();
|
|
601
|
+
ot.applyControlOverrides(t), ze.ownDefaults.controls = t;
|
|
602
|
+
const e = ke.createTextboxDefaultControls();
|
|
603
|
+
ot.applyControlOverrides(e), e.mt && (e.mt.visible = !1), e.mb && (e.mb.visible = !1), ot.wrapWidthControl(e.ml), ot.wrapWidthControl(e.mr), at.ownDefaults.controls = e, ot.patchActiveSelectionBounds(), ze.ownDefaults.snapAngle = 1;
|
|
604
604
|
}
|
|
605
605
|
/**
|
|
606
606
|
* Обновляет алгоритм расчёта границ ActiveSelection, чтобы учитывать фон и отступы текстовых объектов.
|
|
607
607
|
*/
|
|
608
608
|
static patchActiveSelectionBounds() {
|
|
609
|
-
const t =
|
|
609
|
+
const t = F.prototype, e = t._calcBoundsFromObjects;
|
|
610
610
|
t._calcBoundsFromObjects = function(...o) {
|
|
611
611
|
var f, g;
|
|
612
612
|
const i = (g = (f = this.getObjects) == null ? void 0 : f.call(this)) != null ? g : [];
|
|
613
|
-
|
|
613
|
+
ot.applyTextSelectionScalingLock({
|
|
614
614
|
selection: this,
|
|
615
615
|
objects: i
|
|
616
616
|
});
|
|
617
|
-
const a =
|
|
617
|
+
const a = ot.calculateActiveSelectionBounds({
|
|
618
618
|
objects: i
|
|
619
619
|
});
|
|
620
620
|
if (!a)
|
|
@@ -633,11 +633,11 @@ class st {
|
|
|
633
633
|
t._onAfterObjectsChange = function(o, i) {
|
|
634
634
|
var p, m;
|
|
635
635
|
const a = s ? s.call(this, o, i) : void 0, r = (m = (p = this.getObjects) == null ? void 0 : p.call(this)) != null ? m : [];
|
|
636
|
-
|
|
636
|
+
ot.applyTextSelectionScalingLock({
|
|
637
637
|
selection: this,
|
|
638
638
|
objects: r
|
|
639
639
|
});
|
|
640
|
-
const c =
|
|
640
|
+
const c = ot.calculateActiveSelectionBounds({
|
|
641
641
|
objects: r
|
|
642
642
|
});
|
|
643
643
|
if (!c) return a;
|
|
@@ -647,18 +647,18 @@ class st {
|
|
|
647
647
|
height: f
|
|
648
648
|
}), this.setPositionByOrigin(g, "center", "center"), this.setCoords(), a;
|
|
649
649
|
};
|
|
650
|
-
const n =
|
|
651
|
-
|
|
650
|
+
const n = Pe.prototype.calcBoundingBox;
|
|
651
|
+
Pe.prototype.calcBoundingBox = function(o, i) {
|
|
652
652
|
const { target: a, type: r, overrides: c } = i;
|
|
653
653
|
if (r === "imperative" && c)
|
|
654
654
|
return c;
|
|
655
|
-
if (!(a instanceof
|
|
655
|
+
if (!(a instanceof F))
|
|
656
656
|
return n.call(this, o, i);
|
|
657
|
-
|
|
657
|
+
ot.applyTextSelectionScalingLock({
|
|
658
658
|
selection: a,
|
|
659
659
|
objects: o
|
|
660
660
|
});
|
|
661
|
-
const d =
|
|
661
|
+
const d = ot.calculateActiveSelectionBounds({ objects: o });
|
|
662
662
|
if (!d)
|
|
663
663
|
return n.call(this, o, i);
|
|
664
664
|
const { left: l, top: u, width: f, height: g } = d, p = new et(f, g), m = new et(l + f / 2, u + g / 2);
|
|
@@ -694,7 +694,7 @@ class st {
|
|
|
694
694
|
selection: t,
|
|
695
695
|
objects: e
|
|
696
696
|
}) {
|
|
697
|
-
const s = e.some((n) => n instanceof
|
|
697
|
+
const s = e.some((n) => n instanceof at);
|
|
698
698
|
t.setControlsVisibility({
|
|
699
699
|
mt: !s,
|
|
700
700
|
mb: !s,
|
|
@@ -703,7 +703,7 @@ class st {
|
|
|
703
703
|
});
|
|
704
704
|
}
|
|
705
705
|
}
|
|
706
|
-
const
|
|
706
|
+
const U = class U {
|
|
707
707
|
constructor(t = []) {
|
|
708
708
|
this.fonts = t;
|
|
709
709
|
}
|
|
@@ -711,36 +711,36 @@ const W = class W {
|
|
|
711
711
|
this.fonts = t;
|
|
712
712
|
}
|
|
713
713
|
loadFonts() {
|
|
714
|
-
return
|
|
714
|
+
return W(this, null, function* () {
|
|
715
715
|
var n;
|
|
716
716
|
const t = (n = this.fonts) != null ? n : [];
|
|
717
717
|
if (!t.length) return;
|
|
718
718
|
const e = typeof document != "undefined" ? document : void 0;
|
|
719
719
|
if (!e) return;
|
|
720
|
-
const s = t.map((o) =>
|
|
720
|
+
const s = t.map((o) => U.loadFont(o, e));
|
|
721
721
|
yield Promise.allSettled(s);
|
|
722
722
|
});
|
|
723
723
|
}
|
|
724
724
|
static loadFont(t, e) {
|
|
725
|
-
return
|
|
725
|
+
return W(this, null, function* () {
|
|
726
726
|
var c, d;
|
|
727
727
|
const s = typeof FontFace != "undefined", n = (c = t.family) == null ? void 0 : c.trim(), o = (d = t.source) == null ? void 0 : d.trim();
|
|
728
728
|
if (!n || !o) return;
|
|
729
|
-
const i =
|
|
730
|
-
if (!
|
|
731
|
-
if (
|
|
732
|
-
|
|
729
|
+
const i = U.normalizeFontSource(o), a = U.getDescriptorSnapshot(t.descriptors), r = U.getFontRegistrationKey(n, i, a);
|
|
730
|
+
if (!U.registeredFontKeys.has(r)) {
|
|
731
|
+
if (U.isFontFaceAlreadyApplied(e, n, a)) {
|
|
732
|
+
U.registeredFontKeys.add(r);
|
|
733
733
|
return;
|
|
734
734
|
}
|
|
735
735
|
if (s && e.fonts && typeof e.fonts.add == "function")
|
|
736
736
|
try {
|
|
737
737
|
const u = yield new FontFace(n, i, t.descriptors).load();
|
|
738
|
-
e.fonts.add(u),
|
|
738
|
+
e.fonts.add(u), U.registeredFontKeys.add(r);
|
|
739
739
|
return;
|
|
740
740
|
} catch (l) {
|
|
741
741
|
console.warn(`Не удалось загрузить шрифт "${n}" через FontFace API`, l);
|
|
742
742
|
}
|
|
743
|
-
|
|
743
|
+
U.injectFontFace({
|
|
744
744
|
font: t,
|
|
745
745
|
source: i,
|
|
746
746
|
doc: e,
|
|
@@ -760,15 +760,15 @@ const W = class W {
|
|
|
760
760
|
if (!i) return;
|
|
761
761
|
const a = s.createElement("style");
|
|
762
762
|
a.setAttribute("data-editor-font", i), a.setAttribute("data-editor-font-key", n);
|
|
763
|
-
const r =
|
|
763
|
+
const r = U.descriptorsToCss(o), c = [
|
|
764
764
|
"@font-face {",
|
|
765
|
-
` font-family: ${
|
|
765
|
+
` font-family: ${U.formatFontFamilyForCss(i)};`,
|
|
766
766
|
` src: ${e};`,
|
|
767
767
|
...r.map((l) => ` ${l}`),
|
|
768
768
|
"}"
|
|
769
769
|
];
|
|
770
770
|
a.textContent = c.join(`
|
|
771
|
-
`), s.head.appendChild(a),
|
|
771
|
+
`), s.head.appendChild(a), U.registeredFontKeys.add(n);
|
|
772
772
|
}
|
|
773
773
|
static normalizeFontSource(t) {
|
|
774
774
|
const e = t.trim();
|
|
@@ -791,15 +791,15 @@ const W = class W {
|
|
|
791
791
|
return t ? t.trim().replace(/^['"]+|['"]+$/g, "").toLowerCase() : "";
|
|
792
792
|
}
|
|
793
793
|
static getDescriptorSnapshot(t) {
|
|
794
|
-
const e =
|
|
794
|
+
const e = U.descriptorDefaults;
|
|
795
795
|
return {
|
|
796
|
-
style:
|
|
797
|
-
weight:
|
|
798
|
-
stretch:
|
|
799
|
-
unicodeRange:
|
|
800
|
-
variant:
|
|
801
|
-
featureSettings:
|
|
802
|
-
display:
|
|
796
|
+
style: U.normalizeDescriptorValue(t == null ? void 0 : t.style, e.style),
|
|
797
|
+
weight: U.normalizeDescriptorValue(t == null ? void 0 : t.weight, e.weight),
|
|
798
|
+
stretch: U.normalizeDescriptorValue(t == null ? void 0 : t.stretch, e.stretch),
|
|
799
|
+
unicodeRange: U.normalizeDescriptorValue(t == null ? void 0 : t.unicodeRange, e.unicodeRange),
|
|
800
|
+
variant: U.normalizeDescriptorValue(t == null ? void 0 : t.variant, e.variant),
|
|
801
|
+
featureSettings: U.normalizeDescriptorValue(t == null ? void 0 : t.featureSettings, e.featureSettings),
|
|
802
|
+
display: U.normalizeDescriptorValue(t == null ? void 0 : t.display, e.display)
|
|
803
803
|
};
|
|
804
804
|
}
|
|
805
805
|
static areDescriptorSnapshotsEqual(t, e) {
|
|
@@ -807,7 +807,7 @@ const W = class W {
|
|
|
807
807
|
}
|
|
808
808
|
static getFontRegistrationKey(t, e, s) {
|
|
809
809
|
return [
|
|
810
|
-
|
|
810
|
+
U.normalizeFamilyName(t),
|
|
811
811
|
e,
|
|
812
812
|
s.style,
|
|
813
813
|
s.weight,
|
|
@@ -821,12 +821,12 @@ const W = class W {
|
|
|
821
821
|
static isFontFaceAlreadyApplied(t, e, s) {
|
|
822
822
|
const n = t.fonts;
|
|
823
823
|
if (!n || typeof n.forEach != "function") return !1;
|
|
824
|
-
const o =
|
|
824
|
+
const o = U.normalizeFamilyName(e);
|
|
825
825
|
let i = !1;
|
|
826
826
|
try {
|
|
827
827
|
n.forEach((a) => {
|
|
828
|
-
if (i ||
|
|
829
|
-
const c =
|
|
828
|
+
if (i || U.normalizeFamilyName(a.family) !== o) return;
|
|
829
|
+
const c = U.getDescriptorSnapshot({
|
|
830
830
|
style: a.style,
|
|
831
831
|
weight: a.weight,
|
|
832
832
|
stretch: a.stretch,
|
|
@@ -835,7 +835,7 @@ const W = class W {
|
|
|
835
835
|
featureSettings: a.featureSettings,
|
|
836
836
|
display: a.display
|
|
837
837
|
});
|
|
838
|
-
|
|
838
|
+
U.areDescriptorSnapshotsEqual(s, c) && (i = !0);
|
|
839
839
|
});
|
|
840
840
|
} catch (a) {
|
|
841
841
|
return console.warn("Не удалось проверить, загружен ли шрифт ранее через FontFaceSet", a), !1;
|
|
@@ -862,7 +862,7 @@ const W = class W {
|
|
|
862
862
|
});
|
|
863
863
|
}
|
|
864
864
|
};
|
|
865
|
-
|
|
865
|
+
U.registeredFontKeys = /* @__PURE__ */ new Set(), U.descriptorDefaults = {
|
|
866
866
|
style: "normal",
|
|
867
867
|
weight: "normal",
|
|
868
868
|
stretch: "normal",
|
|
@@ -871,8 +871,8 @@ W.registeredFontKeys = /* @__PURE__ */ new Set(), W.descriptorDefaults = {
|
|
|
871
871
|
featureSettings: "normal",
|
|
872
872
|
display: "auto"
|
|
873
873
|
};
|
|
874
|
-
let
|
|
875
|
-
const
|
|
874
|
+
let Ce = U;
|
|
875
|
+
const xs = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNNi44NzUgMi41YS42MjUuNjI1IDAgMCAwLS42MjUuNjI0VjYuMjVIMy4xMjVhLjYyNS42MjUgMCAwIDAtLjYyNS42MjV2MTBjMCAuMzQ1LjI4LjYyNS42MjUuNjI1aDEwYy4zNDUgMCAuNjI1LS4yOC42MjUtLjYyNXYtMy4xMjZoMy4xMjVjLjM0NSAwIC42MjUtLjI4LjYyNS0uNjI1di0xMGEuNjI1LjYyNSAwIDAgMC0uNjI1LS42MjVoLTEwWm02Ljg3NSAxMGgyLjVWMy43NUg3LjV2Mi41aDUuNjI1Yy4zNDUgMCAuNjI1LjI4LjYyNS42MjV2NS42MjRabS0xMCAzLjc1VjcuNWg4Ljc1djguNzVIMy43NVoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjwvc3ZnPg==", _s = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMi41IDcuNWMwLS42OS41Ni0xLjI1IDEuMjUtMS4yNWgxMi41Yy42OSAwIDEuMjUuNTYgMS4yNSAxLjI1djguNzVjMCAuNjktLjU2IDEuMjUtMS4yNSAxLjI1SDMuNzVjLS42OSAwLTEuMjUtLjU2LTEuMjUtMS4yNVY3LjVabTEzLjc1IDBIMy43NXY4Ljc1aDEyLjVWNy41WiIgY2xpcC1ydWxlPSJldmVub2RkIi8+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMTAgMS44NzVhMi4xODggMi4xODggMCAwIDAtMi4xODggMi4xODh2Mi44MTJhLjYyNS42MjUgMCAxIDEtMS4yNSAwVjQuMDYyYTMuNDM3IDMuNDM3IDAgMSAxIDYuODc1IDB2Mi44MTNhLjYyNS42MjUgMCAxIDEtMS4yNSAwVjQuMDYyQTIuMTg4IDIuMTg4IDAgMCAwIDEwIDEuODc2WiIgY2xpcC1ydWxlPSJldmVub2RkIi8+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTEwIDEyLjgxM2EuOTM3LjkzNyAwIDEgMCAwLTEuODc1LjkzNy45MzcgMCAwIDAgMCAxLjg3NFoiLz48L3N2Zz4=", Ns = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTE2LjI1IDYuMjVINy41VjQuMzc1YTIuNSAyLjUgMCAwIDEgMi41LTIuNWMxLjIgMCAyLjI4MS44NiAyLjUxMiAyYS42MjUuNjI1IDAgMCAwIDEuMjI2LS4yNWMtLjM1NC0xLjczOC0xLjkyNS0zLTMuNzM4LTNhMy43NTQgMy43NTQgMCAwIDAtMy43NSAzLjc1VjYuMjVoLTIuNUExLjI1IDEuMjUgMCAwIDAgMi41IDcuNXY4Ljc1YTEuMjUgMS4yNSAwIDAgMCAxLjI1IDEuMjVoMTIuNWExLjI1IDEuMjUgMCAwIDAgMS4yNS0xLjI1VjcuNWExLjI1IDEuMjUgMCAwIDAtMS4yNS0xLjI1Wm0wIDEwSDMuNzVWNy41aDEyLjV2OC43NVptLTUuMzEzLTQuMzc1YS45MzcuOTM3IDAgMSAxLTEuODc0IDAgLjkzNy45MzcgMCAwIDEgMS44NzQgMFoiLz48L3N2Zz4K", Bs = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTIuNSA4LjEyNSAxMCAxMi41bDcuNS00LjM3NUwxMCAzLjc1IDIuNSA4LjEyNVoiLz48cGF0aCBmaWxsPSIjZmZmIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik05LjY4NSAzLjIxYS42MjUuNjI1IDAgMCAxIC42MyAwbDcuNSA0LjM3NWEuNjI1LjYyNSAwIDAgMSAwIDEuMDhsLTcuNSA0LjM3NWEuNjI1LjYyNSAwIDAgMS0uNjMgMGwtNy41LTQuMzc1YS42MjUuNjI1IDAgMCAxIDAtMS4wOGw3LjUtNC4zNzVaTTMuNzQgOC4xMjUgMTAgMTEuNzc2bDYuMjYtMy42NTFMMTAgNC40NzQgMy43NCA4LjEyNVoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjxwYXRoIGZpbGw9IiNmZmYiIGZpbGwtcnVsZT0iZXZlbm9kZCIgZD0iTTUuNCA5LjQ2YS42MjUuNjI1IDAgMCAxIC42MyAwTDEwIDExLjc3NmwzLjk3LTIuMzE2YS42MjUuNjI1IDAgMCAxIC42MyAwbDMuMjE1IDEuODc1YS42MjUuNjI1IDAgMCAxIDAgMS4wOGwtNy41IDQuMzc1YS42MjUuNjI1IDAgMCAxLS42MyAwbC03LjUtNC4zNzVhLjYyNS42MjUgMCAwIDEgMC0xLjA4TDUuNCA5LjQ2Wm0tMS42NiAyLjQxNUwxMCAxNS41MjZsNi4yNi0zLjY1MS0xLjk3NC0xLjE1MS0zLjk3MSAyLjMxNmEuNjI1LjYyNSAwIDAgMS0uNjMgMGwtMy45Ny0yLjMxNi0xLjk3NSAxLjE1MVoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjwvc3ZnPg==", ks = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNOS42ODUgMy4yMWEuNjI1LjYyNSAwIDAgMSAuNjMgMGw3LjUgNC4zNzVhLjYyNS42MjUgMCAwIDEgMCAxLjA4bC03LjUgNC4zNzVhLjYyNS42MjUgMCAwIDEtLjYzIDBsLTcuNS00LjM3NWEuNjI1LjYyNSAwIDAgMSAwLTEuMDhsNy41LTQuMzc1Wk0zLjc0IDguMTI1IDEwIDExLjc3Nmw2LjI2LTMuNjUxTDEwIDQuNDc0IDMuNzQgOC4xMjVaIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiLz48cGF0aCBmaWxsPSIjZmZmIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik01LjcxNCAxMCAxMCAxMi41bDQuMjg2LTIuNSAzLjIxNCAxLjg3NUwxMCAxNi4yNWwtNy41LTQuMzc1TDUuNzE0IDEwWiIgY2xpcC1ydWxlPSJldmVub2RkIi8+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNNS40IDkuNDZhLjYyNS42MjUgMCAwIDEgLjYzIDBMMTAgMTEuNzc2bDMuOTctMi4zMTZhLjYyNS42MjUgMCAwIDEgLjYzIDBsMy4yMTUgMS44NzVhLjYyNS42MjUgMCAwIDEgMCAxLjA4bC03LjUgNC4zNzVhLjYyNS42MjUgMCAwIDEtLjYzIDBsLTcuNS00LjM3NWEuNjI1LjYyNSAwIDAgMSAwLTEuMDhMNS40IDkuNDZabS0xLjY2IDIuNDE1TDEwIDE1LjUyNmw2LjI2LTMuNjUxLTEuOTc0LTEuMTUxLTMuOTcxIDIuMzE2YS42MjUuNjI1IDAgMCAxLS42MyAwbC0zLjk3LTIuMzE2LTEuOTc1IDEuMTUxWiIgY2xpcC1ydWxlPSJldmVub2RkIi8+PC9zdmc+", zs = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0ibTIuNSA2LjI1IDcuNSA0LjM3NSA3LjUtNC4zNzVMMTAgMS44NzUgMi41IDYuMjVaIi8+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNOS42ODUgMS4zMzVhLjYyNS42MjUgMCAwIDEgLjYzIDBsNy41IDQuMzc1YS42MjUuNjI1IDAgMCAxIDAgMS4wOGwtNy41IDQuMzc1YS42MjUuNjI1IDAgMCAxLS42MyAwbC03LjUtNC4zNzVhLjYyNS42MjUgMCAwIDEgMC0xLjA4bDcuNS00LjM3NVpNMy43NCA2LjI1IDEwIDkuOTAxbDYuMjYtMy42NTFMMTAgMi41OTkgMy43NCA2LjI1WiIgY2xpcC1ydWxlPSJldmVub2RkIi8+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNNS40IDExLjMzNWEuNjI1LjYyNSAwIDAgMSAuNjMgMEwxMCAxMy42NTFsMy45Ny0yLjMxNmEuNjI1LjYyNSAwIDAgMSAuNjMgMGwzLjIxNSAxLjg3NWEuNjI1LjYyNSAwIDAgMSAwIDEuMDhsLTcuNSA0LjM3NWEuNjI1LjYyNSAwIDAgMS0uNjMgMGwtNy41LTQuMzc1YS42MjUuNjI1IDAgMCAxIDAtMS4wOEw1LjQgMTEuMzM1Wk0zLjc0IDEzLjc1IDEwIDE3LjQwMWw2LjI2LTMuNjUxLTEuOTc0LTEuMTUxLTMuOTcxIDIuMzE2YS42MjUuNjI1IDAgMCAxLS42MyAwbC0zLjk3LTIuMzE2TDMuNzQgMTMuNzVaIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiLz48cGF0aCBmaWxsPSIjZmZmIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik01LjQgNy41ODVhLjYyNS42MjUgMCAwIDEgLjYzIDBMMTAgOS45MDFsMy45Ny0yLjMxNmEuNjI1LjYyNSAwIDAgMSAuNjMgMGwzLjIxNSAxLjg3NWEuNjI1LjYyNSAwIDAgMSAwIDEuMDhsLTcuNSA0LjM3NWEuNjI1LjYyNSAwIDAgMS0uNjMgMGwtNy41LTQuMzc1YS42MjUuNjI1IDAgMCAxIDAtMS4wOEw1LjQgNy41ODVaTTMuNzQgMTAgMTAgMTMuNjUxIDE2LjI2IDEwbC0xLjk3NC0xLjE1MS0zLjk3MSAyLjMxNmEuNjI1LjYyNSAwIDAgMS0uNjMgMGwtMy45Ny0yLjMxNkwzLjc0IDEwWiIgY2xpcC1ydWxlPSJldmVub2RkIi8+PC9zdmc+", Ps = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMS45NiAxMy40MzVhLjYyNS42MjUgMCAwIDEgLjg1NS0uMjI1TDEwIDE3LjQwMWw3LjE4NS00LjE5YS42MjUuNjI1IDAgMCAxIC42MyAxLjA3OWwtNy41IDQuMzc1YS42MjUuNjI1IDAgMCAxLS42MyAwbC03LjUtNC4zNzVhLjYyNS42MjUgMCAwIDEtLjIyNS0uODU1Wk05LjY4NSAxLjMzNWEuNjI1LjYyNSAwIDAgMSAuNjMgMGw3LjUgNC4zNzVhLjYyNS42MjUgMCAwIDEgMCAxLjA4bC03LjUgNC4zNzVhLjYyNS42MjUgMCAwIDEtLjYzIDBsLTcuNS00LjM3NWEuNjI1LjYyNSAwIDAgMSAwLTEuMDhsNy41LTQuMzc1Wk0zLjc0IDYuMjUgMTAgOS45MDFsNi4yNi0zLjY1MUwxMCAyLjU5OSAzLjc0IDYuMjVaIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiLz48cGF0aCBmaWxsPSIjZmZmIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGQ9Im01LjcxNCAxMS44NzUgNC4yODYgMi41IDQuMjg2LTIuNUwxNy41IDEzLjc1IDEwIDE4LjEyNSAyLjUgMTMuNzVsMy4yMTQtMS44NzVaIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiLz48cGF0aCBmaWxsPSIjZmZmIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik01LjQgMTEuMzM1YS42MjUuNjI1IDAgMCAxIC42MyAwTDEwIDEzLjY1MWwzLjk3LTIuMzE2YS42MjUuNjI1IDAgMCAxIC42MyAwbDMuMjE1IDEuODc1YS42MjUuNjI1IDAgMCAxIDAgMS4wOGwtNy41IDQuMzc1YS42MjUuNjI1IDAgMCAxLS42MyAwbC03LjUtNC4zNzVhLjYyNS42MjUgMCAwIDEgMC0xLjA4TDUuNCAxMS4zMzVaTTMuNzQgMTMuNzUgMTAgMTcuNDAxbDYuMjYtMy42NTEtMS45NzQtMS4xNTEtMy45NzEgMi4zMTZhLjYyNS42MjUgMCAwIDEtLjYzIDBsLTMuOTctMi4zMTZMMy43NCAxMy43NVoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjxwYXRoIGZpbGw9IiNmZmYiIGZpbGwtcnVsZT0iZXZlbm9kZCIgZD0iTTUuNCA3LjU4NWEuNjI1LjYyNSAwIDAgMSAuNjMgMEwxMCA5LjkwMWwzLjk3LTIuMzE2YS42MjUuNjI1IDAgMCAxIC42MyAwbDMuMjE1IDEuODc1YS42MjUuNjI1IDAgMCAxIDAgMS4wOGwtNy41IDQuMzc1YS42MjUuNjI1IDAgMCAxLS42MyAwbC03LjUtNC4zNzVhLjYyNS42MjUgMCAwIDEgMC0xLjA4TDUuNCA3LjU4NVpNMy43NCAxMCAxMCAxMy42NTEgMTYuMjYgMTBsLTEuOTc0LTEuMTUxLTMuOTcxIDIuMzE2YS42MjUuNjI1IDAgMCAxLS42MyAwbC0zLjk3LTIuMzE2TDMuNzQgMTBaIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiLz48L3N2Zz4=", Ws = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI0VDNEU0MCIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNOC4xMjUgMS4yNUExLjg3NSAxLjg3NSAwIDAgMCA2LjI1IDMuMTI1di42MjVIMy4xMjVhLjYyNS42MjUgMCAwIDAgMCAxLjI1aC42MjV2MTEuMjVBMS4yNSAxLjI1IDAgMCAwIDUgMTcuNWgxMGExLjI1IDEuMjUgMCAwIDAgMS4yNS0xLjI1VjVoLjYyNWEuNjI1LjYyNSAwIDAgMCAwLTEuMjVIMTMuNzV2LS42MjVhMS44NzUgMS44NzUgMCAwIDAtMS44NzUtMS44NzVoLTMuNzVabTQuMzc1IDIuNXYtLjYyNWEuNjI1LjYyNSAwIDAgMC0uNjI1LS42MjVoLTMuNzVhLjYyNS42MjUgMCAwIDAtLjYyNS42MjV2LjYyNWg1Wk01IDE2LjI1VjVoMTB2MTEuMjVINVpNOC4xMjUgNy41Yy4zNDUgMCAuNjI1LjI4LjYyNS42MjV2NWEuNjI1LjYyNSAwIDEgMS0xLjI1IDB2LTVjMC0uMzQ1LjI4LS42MjUuNjI1LS42MjVabTQuMzc1IDUuNjI1di01YS42MjUuNjI1IDAgMCAwLTEuMjUgMHY1YS42MjUuNjI1IDAgMSAwIDEuMjUgMFoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjwvc3ZnPg==", Jt = {
|
|
876
876
|
style: {
|
|
877
877
|
position: "absolute",
|
|
878
878
|
display: "none",
|
|
@@ -939,9 +939,9 @@ const _s = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMj
|
|
|
939
939
|
],
|
|
940
940
|
offsetTop: 50,
|
|
941
941
|
icons: {
|
|
942
|
-
copyPaste:
|
|
942
|
+
copyPaste: xs,
|
|
943
943
|
delete: Ws,
|
|
944
|
-
lock:
|
|
944
|
+
lock: _s,
|
|
945
945
|
unlock: Ns,
|
|
946
946
|
bringToFront: zs,
|
|
947
947
|
sendToBack: Ps,
|
|
@@ -949,7 +949,7 @@ const _s = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMj
|
|
|
949
949
|
sendBackwards: ks
|
|
950
950
|
},
|
|
951
951
|
handlers: {
|
|
952
|
-
copyPaste: (h) =>
|
|
952
|
+
copyPaste: (h) => W(null, null, function* () {
|
|
953
953
|
h.clipboardManager.copyPaste();
|
|
954
954
|
}),
|
|
955
955
|
delete: (h) => {
|
|
@@ -982,11 +982,11 @@ class Us {
|
|
|
982
982
|
_initToolbar() {
|
|
983
983
|
if (!this.options.showToolbar) return;
|
|
984
984
|
const t = this.options.toolbar || {};
|
|
985
|
-
this.config =
|
|
986
|
-
style:
|
|
987
|
-
btnStyle:
|
|
988
|
-
icons:
|
|
989
|
-
handlers:
|
|
985
|
+
this.config = wt(z(z({}, Jt), t), {
|
|
986
|
+
style: z(z({}, Jt.style), t.style || {}),
|
|
987
|
+
btnStyle: z(z({}, Jt.btnStyle), t.btnStyle || {}),
|
|
988
|
+
icons: z(z({}, Jt.icons), t.icons || {}),
|
|
989
|
+
handlers: z(z({}, Jt.handlers), t.handlers || {})
|
|
990
990
|
}), this.currentTarget = null, this.currentLocked = !1, this.isTransforming = !1, this.isTemporarilyHidden = !1, this._onMouseDown = this._handleMouseDown.bind(this), this._onObjectMoving = this._startTransform.bind(this), this._onObjectScaling = this._startTransform.bind(this), this._onObjectRotating = this._startTransform.bind(this), this._onMouseUp = this._endTransform.bind(this), this._onObjectModified = this._endTransform.bind(this), this._onSelectionChange = this._updateToolbar.bind(this), this._onSelectionClear = () => {
|
|
991
991
|
this.el.style.display = "none";
|
|
992
992
|
}, this._createDOM(), this._bindEvents();
|
|
@@ -1117,8 +1117,8 @@ const Fs = {
|
|
|
1117
1117
|
"pointer-events": "none",
|
|
1118
1118
|
"white-space": "nowrap",
|
|
1119
1119
|
"box-shadow": "0 2px 8px rgba(0, 0, 0, 0.2)"
|
|
1120
|
-
},
|
|
1121
|
-
class
|
|
1120
|
+
}, He = 16, Ze = 16, Ys = "fabric-editor-angle-indicator";
|
|
1121
|
+
class De {
|
|
1122
1122
|
constructor({ editor: t }) {
|
|
1123
1123
|
this.isActive = !1, this.currentAngle = 0, this.editor = t, this.canvas = t.canvas, this.options = t.options, this._createDOM(), this._bindEvents();
|
|
1124
1124
|
}
|
|
@@ -1146,7 +1146,7 @@ class Ee {
|
|
|
1146
1146
|
return;
|
|
1147
1147
|
}
|
|
1148
1148
|
const s = e.angle || 0;
|
|
1149
|
-
this.currentAngle =
|
|
1149
|
+
this.currentAngle = De._normalizeAngle(s), this.el.textContent = `${this.currentAngle}°`, this._positionIndicator(t.e), this.isActive || this._showIndicator();
|
|
1150
1150
|
}
|
|
1151
1151
|
/**
|
|
1152
1152
|
* Обработчик отпускания кнопки мыши
|
|
@@ -1177,9 +1177,9 @@ class Ee {
|
|
|
1177
1177
|
*/
|
|
1178
1178
|
_positionIndicator(t) {
|
|
1179
1179
|
const e = this.canvas.wrapperEl.getBoundingClientRect();
|
|
1180
|
-
let s = t.clientX - e.left +
|
|
1180
|
+
let s = t.clientX - e.left + He, n = t.clientY - e.top + Ze;
|
|
1181
1181
|
const o = this.el.getBoundingClientRect(), i = o.width, a = o.height;
|
|
1182
|
-
s + i > e.width && (s = t.clientX - e.left - i -
|
|
1182
|
+
s + i > e.width && (s = t.clientX - e.left - i - He), n + a > e.height && (n = t.clientY - e.top - a - Ze), this.el.style.left = `${s}px`, this.el.style.top = `${n}px`;
|
|
1183
1183
|
}
|
|
1184
1184
|
/**
|
|
1185
1185
|
* Показать индикатор
|
|
@@ -1210,7 +1210,7 @@ class Ee {
|
|
|
1210
1210
|
this.canvas && (this.canvas.off("object:rotating", this._onObjectRotating), this.canvas.off("mouse:up", this._onMouseUp), this.canvas.off("object:modified", this._onObjectModified), this.canvas.off("selection:cleared", this._onSelectionCleared)), (t = this.el) != null && t.parentNode && this.el.parentNode.removeChild(this.el), this.el = null, this.editor = null, this.canvas = null, this.options = null;
|
|
1211
1211
|
}
|
|
1212
1212
|
}
|
|
1213
|
-
const
|
|
1213
|
+
const os = [
|
|
1214
1214
|
"id",
|
|
1215
1215
|
"backgroundId",
|
|
1216
1216
|
"customData",
|
|
@@ -1232,6 +1232,7 @@ const ns = [
|
|
|
1232
1232
|
"styles",
|
|
1233
1233
|
"textCaseRaw",
|
|
1234
1234
|
"uppercase",
|
|
1235
|
+
"autoExpand",
|
|
1235
1236
|
"linethrough",
|
|
1236
1237
|
"underline",
|
|
1237
1238
|
"fontStyle",
|
|
@@ -1310,7 +1311,7 @@ class G {
|
|
|
1310
1311
|
this._isSavingState = !0, console.time("saveState");
|
|
1311
1312
|
try {
|
|
1312
1313
|
const t = this._withTemporaryUnlock(
|
|
1313
|
-
() => this.canvas.toDatalessObject([...
|
|
1314
|
+
() => this.canvas.toDatalessObject([...os])
|
|
1314
1315
|
);
|
|
1315
1316
|
if (console.timeEnd("saveState"), !this.baseState) {
|
|
1316
1317
|
this.baseState = t, this.patches = [], this.currentIndex = 0, console.log("Базовое состояние сохранено.");
|
|
@@ -1329,7 +1330,14 @@ class G {
|
|
|
1329
1330
|
console.log("Нет изменений для сохранения.");
|
|
1330
1331
|
return;
|
|
1331
1332
|
}
|
|
1332
|
-
|
|
1333
|
+
if (G._areStatesEqual({
|
|
1334
|
+
prevState: s,
|
|
1335
|
+
nextState: n
|
|
1336
|
+
})) {
|
|
1337
|
+
console.log("statesEqual. Нет изменений для сохранения.");
|
|
1338
|
+
return;
|
|
1339
|
+
}
|
|
1340
|
+
console.log("baseState", this.baseState), this.currentIndex < this.patches.length && this.patches.splice(this.currentIndex), console.log("diff", o), this.totalChangesCount += 1, this.patches.push({ id: K(), diff: o }), this.currentIndex += 1, this.patches.length > this.maxHistoryLength && (this.baseState = this.diffPatcher.patch(this.baseState, this.patches[0].diff), this.patches.shift(), this.currentIndex -= 1, this.baseStateChangesCount += 1), console.log("Состояние сохранено. Текущий индекс истории:", this.currentIndex);
|
|
1333
1341
|
} finally {
|
|
1334
1342
|
this._isSavingState = !1;
|
|
1335
1343
|
}
|
|
@@ -1362,14 +1370,57 @@ class G {
|
|
|
1362
1370
|
static _cloneState({ state: t }) {
|
|
1363
1371
|
return JSON.parse(JSON.stringify(t));
|
|
1364
1372
|
}
|
|
1373
|
+
/**
|
|
1374
|
+
* Проверяет, равны ли два состояния после нормализации с учётом устойчивого порядка ключей.
|
|
1375
|
+
* @param prevState - предыдущее состояние
|
|
1376
|
+
* @param nextState - следующее состояние
|
|
1377
|
+
*/
|
|
1378
|
+
static _areStatesEqual({
|
|
1379
|
+
prevState: t,
|
|
1380
|
+
nextState: e
|
|
1381
|
+
}) {
|
|
1382
|
+
const s = G._stableStringify({ value: t }), n = G._stableStringify({ value: e });
|
|
1383
|
+
return s === n;
|
|
1384
|
+
}
|
|
1385
|
+
/**
|
|
1386
|
+
* Делает устойчивую сериализацию значения с сортировкой ключей объектов.
|
|
1387
|
+
* @param value - значение для сериализации
|
|
1388
|
+
*/
|
|
1389
|
+
static _stableStringify({ value: t }) {
|
|
1390
|
+
const e = ({ value: s }) => {
|
|
1391
|
+
if (Array.isArray(s)) {
|
|
1392
|
+
const n = [];
|
|
1393
|
+
for (let o = 0; o < s.length; o += 1)
|
|
1394
|
+
n.push(e({ value: s[o] }));
|
|
1395
|
+
return n;
|
|
1396
|
+
}
|
|
1397
|
+
if (s && typeof s == "object") {
|
|
1398
|
+
const n = {}, o = Object.keys(s).sort();
|
|
1399
|
+
for (let i = 0; i < o.length; i += 1) {
|
|
1400
|
+
const a = o[i];
|
|
1401
|
+
n[a] = e({
|
|
1402
|
+
value: s[a]
|
|
1403
|
+
});
|
|
1404
|
+
}
|
|
1405
|
+
return n;
|
|
1406
|
+
}
|
|
1407
|
+
return s;
|
|
1408
|
+
};
|
|
1409
|
+
return JSON.stringify(e({ value: t }));
|
|
1410
|
+
}
|
|
1365
1411
|
/**
|
|
1366
1412
|
* Нормализует backgroundColor у текстовых объектов без фона, чтобы избежать шумовых диффов.
|
|
1367
1413
|
* @param objects - список объектов канваса
|
|
1368
1414
|
*/
|
|
1369
1415
|
static _normalizeTextBackground({ objects: t }) {
|
|
1370
1416
|
for (let e = 0; e < t.length; e += 1) {
|
|
1371
|
-
const s = t[e], {
|
|
1372
|
-
|
|
1417
|
+
const s = t[e], {
|
|
1418
|
+
type: n,
|
|
1419
|
+
backgroundOpacity: o,
|
|
1420
|
+
backgroundColor: i,
|
|
1421
|
+
textBackgroundColor: a
|
|
1422
|
+
} = s, r = typeof o == "number" ? o : 0, c = typeof i == "string" ? i : "", d = typeof a == "string" ? a : "", l = n === "textbox" || n === "i-text" || n === "text" || n === "background-textbox", u = c.length > 0 || d.length > 0;
|
|
1423
|
+
l && (r > 0 && u || (s.backgroundColor = null, s.textBackgroundColor = null));
|
|
1373
1424
|
}
|
|
1374
1425
|
}
|
|
1375
1426
|
/**
|
|
@@ -1536,7 +1587,7 @@ class G {
|
|
|
1536
1587
|
* @fires editor:history-state-loaded
|
|
1537
1588
|
*/
|
|
1538
1589
|
loadStateFromFullState(t) {
|
|
1539
|
-
return
|
|
1590
|
+
return W(this, null, function* () {
|
|
1540
1591
|
if (!t) return;
|
|
1541
1592
|
console.log("loadStateFromFullState fullState", t);
|
|
1542
1593
|
const { canvas: e, canvasManager: s, interactionBlocker: n, backgroundManager: o } = this.editor, { width: i, height: a } = e;
|
|
@@ -1563,7 +1614,7 @@ class G {
|
|
|
1563
1614
|
* @fires editor:undo
|
|
1564
1615
|
*/
|
|
1565
1616
|
undo() {
|
|
1566
|
-
return
|
|
1617
|
+
return W(this, null, function* () {
|
|
1567
1618
|
if (!this.skipHistory) {
|
|
1568
1619
|
if (this.saveState(), this.currentIndex <= 0) {
|
|
1569
1620
|
console.log("Нет предыдущих состояний для отмены.");
|
|
@@ -1600,7 +1651,7 @@ class G {
|
|
|
1600
1651
|
* @fires editor:redo
|
|
1601
1652
|
*/
|
|
1602
1653
|
redo() {
|
|
1603
|
-
return
|
|
1654
|
+
return W(this, null, function* () {
|
|
1604
1655
|
if (!this.skipHistory) {
|
|
1605
1656
|
if (this.currentIndex >= this.patches.length) {
|
|
1606
1657
|
console.log("Нет состояний для повтора.");
|
|
@@ -1637,7 +1688,7 @@ class G {
|
|
|
1637
1688
|
const e = [];
|
|
1638
1689
|
((i = (o = (n = this.canvas).getObjects) == null ? void 0 : o.call(n)) != null ? i : []).forEach((a) => {
|
|
1639
1690
|
const r = typeof a.type == "string" ? a.type.toLowerCase() : "";
|
|
1640
|
-
if (!(r === "textbox" || r === "i-text" || typeof a.isEditing == "boolean") || a.locked) return;
|
|
1691
|
+
if (!(r === "textbox" || r === "i-text" || typeof a.isEditing == "boolean" || r === "background-textbox") || a.locked) return;
|
|
1641
1692
|
const d = !!a.lockMovementX, l = !!a.lockMovementY;
|
|
1642
1693
|
!d && !l || (e.push({
|
|
1643
1694
|
object: a,
|
|
@@ -1655,7 +1706,7 @@ class G {
|
|
|
1655
1706
|
}
|
|
1656
1707
|
}
|
|
1657
1708
|
}
|
|
1658
|
-
const Hs = 0.1, Zs = 2,
|
|
1709
|
+
const Hs = 0.1, Zs = 2, Ge = 0.1, Gs = 90, kt = 16, zt = 16, At = 4096, jt = 4096, Ve = "application/image-editor:", ce = [
|
|
1659
1710
|
"format",
|
|
1660
1711
|
"uppercase",
|
|
1661
1712
|
"textCaseRaw",
|
|
@@ -1670,7 +1721,7 @@ const Hs = 0.1, Zs = 2, Ze = 0.1, Gs = 90, _t = 16, xt = 16, jt = 4096, It = 409
|
|
|
1670
1721
|
"radiusBottomRight",
|
|
1671
1722
|
"radiusBottomLeft"
|
|
1672
1723
|
], Vs = 50;
|
|
1673
|
-
class
|
|
1724
|
+
class lt {
|
|
1674
1725
|
constructor({ editor: t }) {
|
|
1675
1726
|
this.editor = t, this.options = t.options, this._createdBlobUrls = [], this.acceptContentTypes = this.editor.options.acceptContentTypes, this.acceptFormats = this.getAllowedFormatsFromContentTypes();
|
|
1676
1727
|
}
|
|
@@ -1687,7 +1738,7 @@ class ut {
|
|
|
1687
1738
|
* @returns возвращает Promise с объектом изображения или null в случае ошибки
|
|
1688
1739
|
*/
|
|
1689
1740
|
importImage(t) {
|
|
1690
|
-
return
|
|
1741
|
+
return W(this, null, function* () {
|
|
1691
1742
|
const {
|
|
1692
1743
|
source: e,
|
|
1693
1744
|
scale: s = `image-${this.options.scaleType}`,
|
|
@@ -1699,7 +1750,7 @@ class ut {
|
|
|
1699
1750
|
customData: c = null
|
|
1700
1751
|
} = t;
|
|
1701
1752
|
if (!e) return null;
|
|
1702
|
-
const { canvas: d, montageArea: l, transformManager: u, historyManager: f, errorManager: g } = this.editor, p = yield this.getContentType(e), m =
|
|
1753
|
+
const { canvas: d, montageArea: l, transformManager: u, historyManager: f, errorManager: g } = this.editor, p = yield this.getContentType(e), m = lt.getFormatFromContentType(p), { acceptContentTypes: v, acceptFormats: w } = this;
|
|
1703
1754
|
if (!this.isAllowedContentType(p)) {
|
|
1704
1755
|
const A = `Неверный contentType для изображения: ${p}. Ожидается один из: ${this.acceptContentTypes.join(", ")}.`;
|
|
1705
1756
|
return g.emitError({
|
|
@@ -1727,8 +1778,8 @@ class ut {
|
|
|
1727
1778
|
if (e instanceof File)
|
|
1728
1779
|
A = URL.createObjectURL(e);
|
|
1729
1780
|
else if (typeof e == "string") {
|
|
1730
|
-
const
|
|
1731
|
-
A = URL.createObjectURL(
|
|
1781
|
+
const E = yield (yield fetch(e, { mode: "cors" })).blob();
|
|
1782
|
+
A = URL.createObjectURL(E);
|
|
1732
1783
|
} else
|
|
1733
1784
|
return g.emitError({
|
|
1734
1785
|
origin: "ImageManager",
|
|
@@ -1750,28 +1801,28 @@ class ut {
|
|
|
1750
1801
|
}), null;
|
|
1751
1802
|
if (this._createdBlobUrls.push(A), m === "svg") {
|
|
1752
1803
|
const S = yield us(A);
|
|
1753
|
-
y =
|
|
1804
|
+
y = ht.groupSVGElements(S.objects, S.options);
|
|
1754
1805
|
} else
|
|
1755
|
-
y = yield
|
|
1756
|
-
const { width:
|
|
1757
|
-
if (y instanceof
|
|
1806
|
+
y = yield qt.fromURL(A, { crossOrigin: "anonymous" });
|
|
1807
|
+
const { width: M, height: j } = y;
|
|
1808
|
+
if (y instanceof qt) {
|
|
1758
1809
|
const S = y.getElement();
|
|
1759
|
-
let
|
|
1760
|
-
if (S instanceof HTMLImageElement ?
|
|
1761
|
-
const
|
|
1762
|
-
this._createdBlobUrls.push(
|
|
1763
|
-
} else if (j <
|
|
1764
|
-
const
|
|
1765
|
-
this._createdBlobUrls.push(
|
|
1810
|
+
let E = "";
|
|
1811
|
+
if (S instanceof HTMLImageElement ? E = S.src : S instanceof HTMLCanvasElement && (E = S.toDataURL()), j > jt || M > At) {
|
|
1812
|
+
const b = yield this.resizeImageToBoundaries(E, "max"), I = URL.createObjectURL(b);
|
|
1813
|
+
this._createdBlobUrls.push(I), y = yield qt.fromURL(I, { crossOrigin: "anonymous" });
|
|
1814
|
+
} else if (j < zt || M < kt) {
|
|
1815
|
+
const b = yield this.resizeImageToBoundaries(E, "min"), I = URL.createObjectURL(b);
|
|
1816
|
+
this._createdBlobUrls.push(I), y = yield qt.fromURL(I, { crossOrigin: "anonymous" });
|
|
1766
1817
|
}
|
|
1767
1818
|
}
|
|
1768
|
-
if (y.set("id", `${y.type}-${
|
|
1819
|
+
if (y.set("id", `${y.type}-${K()}`), y.set("format", m), y.set("customData", c || null), s === "scale-montage")
|
|
1769
1820
|
this.editor.canvasManager.scaleMontageAreaToImage({ object: y, withoutSave: !0 });
|
|
1770
1821
|
else {
|
|
1771
|
-
const { width: S, height:
|
|
1772
|
-
s === "image-contain" &&
|
|
1822
|
+
const { width: S, height: E } = l, b = this.calculateScaleFactor({ imageObject: y, scaleType: s });
|
|
1823
|
+
s === "image-contain" && b < 1 ? u.fitObject({ object: y, type: "contain", withoutSave: !0 }) : s === "image-cover" && (M > S || j > E) && u.fitObject({ object: y, type: "cover", withoutSave: !0 });
|
|
1773
1824
|
}
|
|
1774
|
-
const
|
|
1825
|
+
const C = {
|
|
1775
1826
|
image: y,
|
|
1776
1827
|
format: m,
|
|
1777
1828
|
contentType: p,
|
|
@@ -1784,7 +1835,7 @@ class ut {
|
|
|
1784
1835
|
withoutAdding: r,
|
|
1785
1836
|
customData: c
|
|
1786
1837
|
};
|
|
1787
|
-
return r ? (f.resumeHistory(), d.fire("editor:image-imported",
|
|
1838
|
+
return r ? (f.resumeHistory(), d.fire("editor:image-imported", C), C) : (d.add(y), d.centerObject(y), a || d.setActiveObject(y), d.renderAll(), f.resumeHistory(), n || f.saveState(), d.fire("editor:image-imported", C), C);
|
|
1788
1839
|
} catch (A) {
|
|
1789
1840
|
return g.emitError({
|
|
1790
1841
|
origin: "ImageManager",
|
|
@@ -1816,16 +1867,16 @@ class ut {
|
|
|
1816
1867
|
* @returns возвращает Promise с Blob-объектом уменьшенного изображения
|
|
1817
1868
|
*/
|
|
1818
1869
|
resizeImageToBoundaries(t, e = "max") {
|
|
1819
|
-
return
|
|
1820
|
-
let s = `Размер изображения больше максимального размера канваса, поэтому оно будет уменьшено до максимальных размеров c сохранением пропорций: ${
|
|
1821
|
-
e === "min" && (s = `Размер изображения меньше минимального размера канваса, поэтому оно будет увеличено до минимальных размеров c сохранением пропорций: ${
|
|
1870
|
+
return W(this, null, function* () {
|
|
1871
|
+
let s = `Размер изображения больше максимального размера канваса, поэтому оно будет уменьшено до максимальных размеров c сохранением пропорций: ${At}x${jt}`;
|
|
1872
|
+
e === "min" && (s = `Размер изображения меньше минимального размера канваса, поэтому оно будет увеличено до минимальных размеров c сохранением пропорций: ${kt}x${zt}`);
|
|
1822
1873
|
const n = {
|
|
1823
1874
|
dataURL: t,
|
|
1824
1875
|
sizeType: e,
|
|
1825
|
-
maxWidth:
|
|
1826
|
-
maxHeight:
|
|
1827
|
-
minWidth:
|
|
1828
|
-
minHeight:
|
|
1876
|
+
maxWidth: At,
|
|
1877
|
+
maxHeight: jt,
|
|
1878
|
+
minWidth: kt,
|
|
1879
|
+
minHeight: zt
|
|
1829
1880
|
};
|
|
1830
1881
|
return this.editor.errorManager.emitWarning({
|
|
1831
1882
|
origin: "ImageManager",
|
|
@@ -1848,7 +1899,7 @@ class ut {
|
|
|
1848
1899
|
* @fires editor:canvas-exported
|
|
1849
1900
|
*/
|
|
1850
1901
|
exportCanvasAsImageFile() {
|
|
1851
|
-
return
|
|
1902
|
+
return W(this, arguments, function* (t = {}) {
|
|
1852
1903
|
const {
|
|
1853
1904
|
fileName: e = "image.png",
|
|
1854
1905
|
contentType: s = "image/png",
|
|
@@ -1856,22 +1907,22 @@ class ut {
|
|
|
1856
1907
|
exportAsBlob: o = !1
|
|
1857
1908
|
} = t, { canvas: i, montageArea: a, workerManager: r, interactionBlocker: c } = this.editor;
|
|
1858
1909
|
try {
|
|
1859
|
-
const d = s === "application/pdf", l = d ? "image/jpg" : s, u =
|
|
1910
|
+
const d = s === "application/pdf", l = d ? "image/jpg" : s, u = lt.getFormatFromContentType(l);
|
|
1860
1911
|
a.setCoords();
|
|
1861
1912
|
const { left: f, top: g, width: p, height: m } = a.getBoundingRect(), v = yield i.clone(["id", "format", "locked"]);
|
|
1862
1913
|
v.enableRetinaScaling = !1, ["image/jpg", "image/jpeg"].includes(l) && (v.backgroundColor = "#ffffff");
|
|
1863
|
-
const w = v.getObjects().find((
|
|
1914
|
+
const w = v.getObjects().find((b) => b.id === a.id);
|
|
1864
1915
|
if (w && (w.visible = !1), c != null && c.isBlocked) {
|
|
1865
|
-
const
|
|
1866
|
-
|
|
1916
|
+
const b = v.getObjects().find((I) => I.id === c.overlayMask.id);
|
|
1917
|
+
b && (b.visible = !1);
|
|
1867
1918
|
}
|
|
1868
1919
|
v.viewportTransform = [1, 0, 0, 1, -f, -g], v.setDimensions({ width: p, height: m }, { backstoreOnly: !0 }), v.renderAll();
|
|
1869
|
-
const A = v.getObjects().filter((
|
|
1920
|
+
const A = v.getObjects().filter((b) => b.format).every((b) => b.format === "svg");
|
|
1870
1921
|
if (u === "svg" && A) {
|
|
1871
|
-
const
|
|
1922
|
+
const b = v.toSVG();
|
|
1872
1923
|
v.dispose();
|
|
1873
|
-
const
|
|
1874
|
-
image:
|
|
1924
|
+
const T = {
|
|
1925
|
+
image: lt._exportSVGStringAsFile(b, {
|
|
1875
1926
|
exportAsBase64: n,
|
|
1876
1927
|
exportAsBlob: o,
|
|
1877
1928
|
fileName: e
|
|
@@ -1880,66 +1931,66 @@ class ut {
|
|
|
1880
1931
|
contentType: "image/svg+xml",
|
|
1881
1932
|
fileName: e.replace(/\.[^/.]+$/, ".svg")
|
|
1882
1933
|
};
|
|
1883
|
-
return i.fire("editor:canvas-exported",
|
|
1934
|
+
return i.fire("editor:canvas-exported", T), T;
|
|
1884
1935
|
}
|
|
1885
|
-
const y = yield new Promise((
|
|
1886
|
-
v.getElement().toBlob((
|
|
1887
|
-
|
|
1936
|
+
const y = yield new Promise((b, I) => {
|
|
1937
|
+
v.getElement().toBlob((T) => {
|
|
1938
|
+
T ? b(T) : I(new Error("Failed to create Blob from canvas"));
|
|
1888
1939
|
});
|
|
1889
1940
|
});
|
|
1890
1941
|
if (v.dispose(), o) {
|
|
1891
|
-
const
|
|
1942
|
+
const b = {
|
|
1892
1943
|
image: y,
|
|
1893
1944
|
format: u,
|
|
1894
1945
|
contentType: l,
|
|
1895
1946
|
fileName: e
|
|
1896
1947
|
};
|
|
1897
|
-
return i.fire("editor:canvas-exported",
|
|
1948
|
+
return i.fire("editor:canvas-exported", b), b;
|
|
1898
1949
|
}
|
|
1899
|
-
const
|
|
1950
|
+
const M = yield createImageBitmap(y), j = yield r.post(
|
|
1900
1951
|
"toDataURL",
|
|
1901
|
-
{ format: u, quality: 1, bitmap:
|
|
1902
|
-
[
|
|
1952
|
+
{ format: u, quality: 1, bitmap: M },
|
|
1953
|
+
[M]
|
|
1903
1954
|
);
|
|
1904
1955
|
if (d) {
|
|
1905
|
-
const
|
|
1906
|
-
orientation:
|
|
1956
|
+
const I = p * 0.264583, T = m * 0.264583, _ = (yield this.editor.moduleLoader.loadModule("jspdf")).jsPDF, B = new _({
|
|
1957
|
+
orientation: I > T ? "landscape" : "portrait",
|
|
1907
1958
|
unit: "mm",
|
|
1908
|
-
format: [
|
|
1959
|
+
format: [I, T]
|
|
1909
1960
|
});
|
|
1910
|
-
if (
|
|
1911
|
-
const
|
|
1912
|
-
image:
|
|
1961
|
+
if (B.addImage(String(j), "JPG", 0, 0, I, T), n) {
|
|
1962
|
+
const Y = {
|
|
1963
|
+
image: B.output("datauristring"),
|
|
1913
1964
|
format: "pdf",
|
|
1914
1965
|
contentType: "application/pdf",
|
|
1915
1966
|
fileName: e
|
|
1916
1967
|
};
|
|
1917
|
-
return i.fire("editor:canvas-exported",
|
|
1968
|
+
return i.fire("editor:canvas-exported", Y), Y;
|
|
1918
1969
|
}
|
|
1919
|
-
const N =
|
|
1970
|
+
const N = B.output("blob"), Z = {
|
|
1920
1971
|
image: new File([N], e, { type: "application/pdf" }),
|
|
1921
1972
|
format: "pdf",
|
|
1922
1973
|
contentType: "application/pdf",
|
|
1923
1974
|
fileName: e
|
|
1924
1975
|
};
|
|
1925
|
-
return i.fire("editor:canvas-exported",
|
|
1976
|
+
return i.fire("editor:canvas-exported", Z), Z;
|
|
1926
1977
|
}
|
|
1927
1978
|
if (n) {
|
|
1928
|
-
const
|
|
1979
|
+
const b = {
|
|
1929
1980
|
image: j,
|
|
1930
1981
|
format: u,
|
|
1931
1982
|
contentType: l,
|
|
1932
1983
|
fileName: e
|
|
1933
1984
|
};
|
|
1934
|
-
return i.fire("editor:canvas-exported",
|
|
1985
|
+
return i.fire("editor:canvas-exported", b), b;
|
|
1935
1986
|
}
|
|
1936
|
-
const
|
|
1937
|
-
image: new File([y],
|
|
1987
|
+
const C = u === "svg" && !A ? e.replace(/\.[^/.]+$/, ".png") : e, E = {
|
|
1988
|
+
image: new File([y], C, { type: l }),
|
|
1938
1989
|
format: u,
|
|
1939
1990
|
contentType: l,
|
|
1940
|
-
fileName:
|
|
1991
|
+
fileName: C
|
|
1941
1992
|
};
|
|
1942
|
-
return i.fire("editor:canvas-exported",
|
|
1993
|
+
return i.fire("editor:canvas-exported", E), E;
|
|
1943
1994
|
} catch (d) {
|
|
1944
1995
|
return this.editor.errorManager.emitError({
|
|
1945
1996
|
origin: "ImageManager",
|
|
@@ -1963,7 +2014,7 @@ class ut {
|
|
|
1963
2014
|
* @fires editor:object-exported
|
|
1964
2015
|
*/
|
|
1965
2016
|
exportObjectAsImageFile() {
|
|
1966
|
-
return
|
|
2017
|
+
return W(this, arguments, function* (t = {}) {
|
|
1967
2018
|
const {
|
|
1968
2019
|
object: e,
|
|
1969
2020
|
fileName: s = "image.png",
|
|
@@ -1980,9 +2031,9 @@ class ut {
|
|
|
1980
2031
|
data: { contentType: n, fileName: s, exportAsBase64: o, exportAsBlob: i }
|
|
1981
2032
|
}), null;
|
|
1982
2033
|
try {
|
|
1983
|
-
const d =
|
|
2034
|
+
const d = lt.getFormatFromContentType(n);
|
|
1984
2035
|
if (d === "svg") {
|
|
1985
|
-
const p = c.toSVG(), m =
|
|
2036
|
+
const p = c.toSVG(), m = lt._exportSVGStringAsFile(p, {
|
|
1986
2037
|
exportAsBase64: o,
|
|
1987
2038
|
exportAsBlob: i,
|
|
1988
2039
|
fileName: s
|
|
@@ -1995,7 +2046,7 @@ class ut {
|
|
|
1995
2046
|
};
|
|
1996
2047
|
return a.fire("editor:object-exported", v), v;
|
|
1997
2048
|
}
|
|
1998
|
-
if (o && c instanceof
|
|
2049
|
+
if (o && c instanceof qt) {
|
|
1999
2050
|
const p = yield createImageBitmap(c.getElement()), m = yield r.post(
|
|
2000
2051
|
"toDataURL",
|
|
2001
2052
|
{
|
|
@@ -2060,7 +2111,7 @@ class ut {
|
|
|
2060
2111
|
* @returns массив допустимых форматов изображений
|
|
2061
2112
|
*/
|
|
2062
2113
|
getAllowedFormatsFromContentTypes() {
|
|
2063
|
-
return this.acceptContentTypes.map((t) =>
|
|
2114
|
+
return this.acceptContentTypes.map((t) => lt.getFormatFromContentType(t)).filter((t) => t);
|
|
2064
2115
|
}
|
|
2065
2116
|
/**
|
|
2066
2117
|
* Проверяет, является ли contentType допустимым типом изображения.
|
|
@@ -2076,7 +2127,7 @@ class ut {
|
|
|
2076
2127
|
* @public
|
|
2077
2128
|
*/
|
|
2078
2129
|
getContentType(t) {
|
|
2079
|
-
return
|
|
2130
|
+
return W(this, null, function* () {
|
|
2080
2131
|
return typeof t == "string" ? this.getContentTypeFromUrl(t) : t.type || "application/octet-stream";
|
|
2081
2132
|
});
|
|
2082
2133
|
}
|
|
@@ -2087,7 +2138,7 @@ class ut {
|
|
|
2087
2138
|
* @public
|
|
2088
2139
|
*/
|
|
2089
2140
|
getContentTypeFromUrl(t) {
|
|
2090
|
-
return
|
|
2141
|
+
return W(this, null, function* () {
|
|
2091
2142
|
if (t.startsWith("data:")) {
|
|
2092
2143
|
const e = t.match(/^data:([^;]+)/);
|
|
2093
2144
|
return e ? e[1] : "application/octet-stream";
|
|
@@ -2113,7 +2164,7 @@ class ut {
|
|
|
2113
2164
|
try {
|
|
2114
2165
|
const n = (e = new URL(t).pathname.split(".").pop()) == null ? void 0 : e.toLowerCase(), o = {};
|
|
2115
2166
|
return this.acceptContentTypes.forEach((i) => {
|
|
2116
|
-
const a =
|
|
2167
|
+
const a = lt.getFormatFromContentType(i);
|
|
2117
2168
|
a && (o[a] = i);
|
|
2118
2169
|
}), n && o[n] || "application/octet-stream";
|
|
2119
2170
|
} catch (s) {
|
|
@@ -2166,11 +2217,11 @@ class ut {
|
|
|
2166
2217
|
return e ? e[1] : "";
|
|
2167
2218
|
}
|
|
2168
2219
|
}
|
|
2169
|
-
const
|
|
2220
|
+
const pt = (h, t, e) => Math.max(Math.min(h, e), t), Xe = (h, t) => h * t, Xs = (h, t) => new et(h / 2, t / 2);
|
|
2170
2221
|
function Ks(h) {
|
|
2171
2222
|
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";
|
|
2172
2223
|
}
|
|
2173
|
-
class
|
|
2224
|
+
class qs {
|
|
2174
2225
|
/**
|
|
2175
2226
|
* @param options
|
|
2176
2227
|
* @param options.editor – экземпляр редактора
|
|
@@ -2190,11 +2241,11 @@ class Qs {
|
|
|
2190
2241
|
* Если точка находится за пределами монтажной области, она проецируется на ближайшую границу монтажной области.
|
|
2191
2242
|
*/
|
|
2192
2243
|
getVisibleCenterPoint() {
|
|
2193
|
-
const { canvas: t, montageArea: e } = this.editor, s = t.getZoom(), n = t.viewportTransform, o = t.getWidth(), i = t.getHeight(), a = (o / 2 - n[4]) / s, r = (i / 2 - n[5]) / s, c = e.width / 2, d = e.height / 2, l =
|
|
2244
|
+
const { canvas: t, montageArea: e } = this.editor, s = t.getZoom(), n = t.viewportTransform, o = t.getWidth(), i = t.getHeight(), a = (o / 2 - n[4]) / s, r = (i / 2 - n[5]) / s, c = e.width / 2, d = e.height / 2, l = pt(
|
|
2194
2245
|
a,
|
|
2195
2246
|
e.left - c,
|
|
2196
2247
|
e.left + c
|
|
2197
|
-
), u =
|
|
2248
|
+
), u = pt(
|
|
2198
2249
|
r,
|
|
2199
2250
|
e.top - d,
|
|
2200
2251
|
e.top + d
|
|
@@ -2217,9 +2268,9 @@ class Qs {
|
|
|
2217
2268
|
canvas: o,
|
|
2218
2269
|
montageArea: i,
|
|
2219
2270
|
options: { canvasBackstoreWidth: a }
|
|
2220
|
-
} = this.editor, { width: r, height: c } = i, d =
|
|
2271
|
+
} = this.editor, { width: r, height: c } = i, d = pt(Number(t), kt, At);
|
|
2221
2272
|
if (!a || a === "auto" || n ? this.adaptCanvasToContainer() : a ? this.setCanvasBackstoreWidth(Number(a)) : this.setCanvasBackstoreWidth(d), i.set({ width: d }), (g = o.clipPath) == null || g.set({ width: d }), e) {
|
|
2222
|
-
const p = d / r, m =
|
|
2273
|
+
const p = d / r, m = Xe(c, p);
|
|
2223
2274
|
this.setResolutionHeight(m);
|
|
2224
2275
|
return;
|
|
2225
2276
|
}
|
|
@@ -2247,9 +2298,9 @@ class Qs {
|
|
|
2247
2298
|
canvas: o,
|
|
2248
2299
|
montageArea: i,
|
|
2249
2300
|
options: { canvasBackstoreHeight: a }
|
|
2250
|
-
} = this.editor, { width: r, height: c } = i, d =
|
|
2301
|
+
} = this.editor, { width: r, height: c } = i, d = pt(Number(t), zt, jt);
|
|
2251
2302
|
if (!a || a === "auto" || n ? this.adaptCanvasToContainer() : a ? this.setCanvasBackstoreHeight(Number(a)) : this.setCanvasBackstoreHeight(d), i.set({ height: d }), (g = o.clipPath) == null || g.set({ height: d }), e) {
|
|
2252
|
-
const p = d / c, m =
|
|
2303
|
+
const p = d / c, m = Xe(r, p);
|
|
2253
2304
|
this.setResolutionWidth(m);
|
|
2254
2305
|
return;
|
|
2255
2306
|
}
|
|
@@ -2300,7 +2351,7 @@ class Qs {
|
|
|
2300
2351
|
*/
|
|
2301
2352
|
setCanvasBackstoreWidth(t) {
|
|
2302
2353
|
if (!t || typeof t != "number") return;
|
|
2303
|
-
const e =
|
|
2354
|
+
const e = pt(t, kt, At);
|
|
2304
2355
|
this.editor.canvas.setDimensions({ width: e }, { backstoreOnly: !0 });
|
|
2305
2356
|
}
|
|
2306
2357
|
/**
|
|
@@ -2309,7 +2360,7 @@ class Qs {
|
|
|
2309
2360
|
*/
|
|
2310
2361
|
setCanvasBackstoreHeight(t) {
|
|
2311
2362
|
if (!t || typeof t != "number") return;
|
|
2312
|
-
const e =
|
|
2363
|
+
const e = pt(t, zt, jt);
|
|
2313
2364
|
this.editor.canvas.setDimensions({ height: e }, { backstoreOnly: !0 });
|
|
2314
2365
|
}
|
|
2315
2366
|
/**
|
|
@@ -2318,7 +2369,7 @@ class Qs {
|
|
|
2318
2369
|
* с учётом минимальных и максимальных значений.
|
|
2319
2370
|
*/
|
|
2320
2371
|
adaptCanvasToContainer() {
|
|
2321
|
-
const { canvas: t } = this.editor, e = this.getEditorContainer(), s = e.clientWidth, n = e.clientHeight, o =
|
|
2372
|
+
const { canvas: t } = this.editor, e = this.getEditorContainer(), s = e.clientWidth, n = e.clientHeight, o = pt(s, kt, At), i = pt(n, zt, jt);
|
|
2322
2373
|
t.setDimensions({ width: o, height: i }, { backstoreOnly: !0 });
|
|
2323
2374
|
}
|
|
2324
2375
|
/**
|
|
@@ -2352,7 +2403,7 @@ class Qs {
|
|
|
2352
2403
|
if (d.length === 1)
|
|
2353
2404
|
t.setActiveObject(d[0]);
|
|
2354
2405
|
else {
|
|
2355
|
-
const l = new
|
|
2406
|
+
const l = new F(d, {
|
|
2356
2407
|
canvas: t
|
|
2357
2408
|
});
|
|
2358
2409
|
t.setActiveObject(l);
|
|
@@ -2520,7 +2571,7 @@ class Qs {
|
|
|
2520
2571
|
} = this.editor, c = t || n.getActiveObject();
|
|
2521
2572
|
if (!Ks(c)) return;
|
|
2522
2573
|
const { width: d, height: l } = c;
|
|
2523
|
-
let u = Math.min(d,
|
|
2574
|
+
let u = Math.min(d, At), f = Math.min(l, jt);
|
|
2524
2575
|
if (e) {
|
|
2525
2576
|
const {
|
|
2526
2577
|
width: g,
|
|
@@ -2639,7 +2690,7 @@ class Js {
|
|
|
2639
2690
|
withoutSave: s
|
|
2640
2691
|
} = {}) {
|
|
2641
2692
|
const { canvas: n, historyManager: o } = this.editor, i = t || n.getActiveObject();
|
|
2642
|
-
i && (i instanceof
|
|
2693
|
+
i && (i instanceof F ? i.getObjects().forEach((a) => {
|
|
2643
2694
|
a.set("opacity", e);
|
|
2644
2695
|
}) : i.set("opacity", e), n.renderAll(), s || o.saveState(), n.fire("editor:object-opacity-changed", {
|
|
2645
2696
|
object: i,
|
|
@@ -2666,12 +2717,12 @@ class Js {
|
|
|
2666
2717
|
} = {}) {
|
|
2667
2718
|
const { canvas: o, historyManager: i } = this.editor, a = t || o.getActiveObject();
|
|
2668
2719
|
if (a) {
|
|
2669
|
-
if (a instanceof
|
|
2720
|
+
if (a instanceof F && !n) {
|
|
2670
2721
|
const r = a.getObjects();
|
|
2671
2722
|
o.discardActiveObject(), r.forEach((d) => {
|
|
2672
2723
|
this._fitSingleObject(d, e);
|
|
2673
2724
|
});
|
|
2674
|
-
const c = new
|
|
2725
|
+
const c = new F(r, { canvas: o });
|
|
2675
2726
|
o.setActiveObject(c);
|
|
2676
2727
|
} else
|
|
2677
2728
|
this._fitSingleObject(a, e);
|
|
@@ -2744,7 +2795,7 @@ class Js {
|
|
|
2744
2795
|
});
|
|
2745
2796
|
}
|
|
2746
2797
|
}
|
|
2747
|
-
class
|
|
2798
|
+
class Qs {
|
|
2748
2799
|
constructor({ editor: t }) {
|
|
2749
2800
|
this.editor = t, this.options = t.options, this.minZoom = this.options.minZoom || Hs, this.maxZoom = this.options.maxZoom || Zs, this.defaultZoom = this._normalizeDefaultZoom(this.options.defaultScale);
|
|
2750
2801
|
}
|
|
@@ -2814,8 +2865,8 @@ class qs {
|
|
|
2814
2865
|
_calculateEmptySpaceRatio(t) {
|
|
2815
2866
|
const { canvas: e, montageArea: s } = this.editor, n = e.viewportTransform, o = e.getWidth(), i = e.getHeight(), a = s.left - s.width / 2, r = s.left + s.width / 2, c = s.top - s.height / 2, d = s.top + s.height / 2, l = -n[4] / t, u = (-n[4] + o) / t, f = -n[5] / t, g = (-n[5] + i) / t, p = l < a, m = u > r, v = f < c, w = g > d;
|
|
2816
2867
|
if (!(p || m || v || w)) return 0;
|
|
2817
|
-
const y = Math.max(0, a - l),
|
|
2818
|
-
return Math.max(
|
|
2868
|
+
const y = Math.max(0, a - l), M = Math.max(0, u - r), j = Math.max(0, c - f), C = Math.max(0, g - d), S = Math.max(y, M), E = Math.max(j, C), b = S / o, I = E / i;
|
|
2869
|
+
return Math.max(b, I);
|
|
2819
2870
|
}
|
|
2820
2871
|
/**
|
|
2821
2872
|
* Вычисляет плавный шаг перемещения viewport к центру с ускорением
|
|
@@ -2831,8 +2882,8 @@ class qs {
|
|
|
2831
2882
|
const { canvas: i, montageArea: a } = this.editor, r = i.viewportTransform, c = i.getWidth(), d = i.getHeight(), l = t.x - r[4], u = t.y - r[5], f = Math.abs(n), g = e - s;
|
|
2832
2883
|
if (Math.abs(g) / f <= 0.1)
|
|
2833
2884
|
return { x: l, y: u };
|
|
2834
|
-
const m = c / 2, v = d / 2, w = a.left, A = a.top, y = m - w * s,
|
|
2835
|
-
return { x:
|
|
2885
|
+
const m = c / 2, v = d / 2, w = a.left, A = a.top, y = m - w * s, M = v - A * s, j = (y - r[4]) / (e - s), C = (M - r[5]) / (e - s), S = j * f, E = C * f, b = S * o, I = E * o, T = Math.abs(b) > Math.abs(l) ? l : b, _ = Math.abs(I) > Math.abs(u) ? u : I;
|
|
2886
|
+
return { x: T, y: _ };
|
|
2836
2887
|
}
|
|
2837
2888
|
/**
|
|
2838
2889
|
* Применяет плавное центрирование viewport при приближении к defaultZoom.
|
|
@@ -2844,7 +2895,7 @@ class qs {
|
|
|
2844
2895
|
* @returns true если центрирование было применено
|
|
2845
2896
|
* @private
|
|
2846
2897
|
*/
|
|
2847
|
-
_applyViewportCentering(t, e = !1, s =
|
|
2898
|
+
_applyViewportCentering(t, e = !1, s = Ge) {
|
|
2848
2899
|
const { canvas: n } = this.editor, o = this._getScaledMontageDimensions(t), i = n.getWidth(), a = n.getHeight(), r = o.width > i || o.height > a, c = this._calculateFitZoom(), d = t - c;
|
|
2849
2900
|
if (!(!r || d) && !e)
|
|
2850
2901
|
return !1;
|
|
@@ -2919,7 +2970,7 @@ class qs {
|
|
|
2919
2970
|
* @param options.pointY - Координата Y точки зума
|
|
2920
2971
|
* @fires editor:zoom-changed
|
|
2921
2972
|
*/
|
|
2922
|
-
zoom(t =
|
|
2973
|
+
zoom(t = Ge, e = {}) {
|
|
2923
2974
|
var f, g;
|
|
2924
2975
|
if (!t) return;
|
|
2925
2976
|
const { minZoom: s, maxZoom: n } = this, { canvas: o } = this.editor, i = t < 0, a = o.getZoom(), r = o.getCenterPoint(), c = (f = e.pointX) != null ? f : r.x, d = (g = e.pointY) != null ? g : r.y, l = new et(c, d);
|
|
@@ -3014,7 +3065,7 @@ class $s {
|
|
|
3014
3065
|
}), t.upperCanvasEl.style.pointerEvents = "", t.lowerCanvasEl.style.pointerEvents = "", this.overlayMask.visible = !1, t.requestRenderAll(), t.fire("editor:enabled"), s.resumeHistory();
|
|
3015
3066
|
}
|
|
3016
3067
|
}
|
|
3017
|
-
class
|
|
3068
|
+
class _t {
|
|
3018
3069
|
constructor({ editor: t }) {
|
|
3019
3070
|
this.editor = t, this.backgroundObject = null;
|
|
3020
3071
|
}
|
|
@@ -3040,7 +3091,7 @@ class Lt {
|
|
|
3040
3091
|
}
|
|
3041
3092
|
a.set({
|
|
3042
3093
|
fill: t,
|
|
3043
|
-
backgroundId: `background-${
|
|
3094
|
+
backgroundId: `background-${K()}`
|
|
3044
3095
|
}), this.editor.canvas.requestRenderAll();
|
|
3045
3096
|
} else
|
|
3046
3097
|
this._removeCurrentBackground(), this._createColorBackground(t);
|
|
@@ -3077,14 +3128,14 @@ class Lt {
|
|
|
3077
3128
|
try {
|
|
3078
3129
|
const { historyManager: i } = this.editor, { backgroundObject: a } = this;
|
|
3079
3130
|
if (i.suspendHistory(), a && a.backgroundType === "gradient") {
|
|
3080
|
-
const r =
|
|
3081
|
-
if (
|
|
3131
|
+
const r = _t._createFabricGradient(t);
|
|
3132
|
+
if (_t._isGradientEqual(a.fill, r)) {
|
|
3082
3133
|
i.resumeHistory();
|
|
3083
3134
|
return;
|
|
3084
3135
|
}
|
|
3085
3136
|
a.set({
|
|
3086
3137
|
fill: r,
|
|
3087
|
-
backgroundId: `background-${
|
|
3138
|
+
backgroundId: `background-${K()}`
|
|
3088
3139
|
}), this.editor.canvas.requestRenderAll();
|
|
3089
3140
|
} else
|
|
3090
3141
|
this._removeCurrentBackground(), this._createGradientBackground(t);
|
|
@@ -3172,7 +3223,7 @@ class Lt {
|
|
|
3172
3223
|
* @param options.withoutSave - Если true, не сохранять состояние в историю
|
|
3173
3224
|
*/
|
|
3174
3225
|
setImageBackground(o) {
|
|
3175
|
-
return
|
|
3226
|
+
return W(this, arguments, function* ({
|
|
3176
3227
|
imageSource: t,
|
|
3177
3228
|
customData: e = {},
|
|
3178
3229
|
fromTemplate: s = !1,
|
|
@@ -3242,7 +3293,7 @@ class Lt {
|
|
|
3242
3293
|
hasControls: !1,
|
|
3243
3294
|
id: "background",
|
|
3244
3295
|
backgroundType: "color",
|
|
3245
|
-
backgroundId: `background-${
|
|
3296
|
+
backgroundId: `background-${K()}`
|
|
3246
3297
|
}, { withoutSelection: !0 }), this.refresh();
|
|
3247
3298
|
}
|
|
3248
3299
|
/**
|
|
@@ -3259,9 +3310,9 @@ class Lt {
|
|
|
3259
3310
|
hasControls: !1,
|
|
3260
3311
|
id: "background",
|
|
3261
3312
|
backgroundType: "gradient",
|
|
3262
|
-
backgroundId: `background-${
|
|
3313
|
+
backgroundId: `background-${K()}`
|
|
3263
3314
|
}, { withoutSelection: !0 }), this.refresh();
|
|
3264
|
-
const e =
|
|
3315
|
+
const e = _t._createFabricGradient(t);
|
|
3265
3316
|
this.backgroundObject.set("fill", e), this.editor.canvas.requestRenderAll();
|
|
3266
3317
|
}
|
|
3267
3318
|
/**
|
|
@@ -3269,7 +3320,7 @@ class Lt {
|
|
|
3269
3320
|
* @param source - источник изображения (URL или File)
|
|
3270
3321
|
*/
|
|
3271
3322
|
_createImageBackground(t, e) {
|
|
3272
|
-
return
|
|
3323
|
+
return W(this, null, function* () {
|
|
3273
3324
|
var n;
|
|
3274
3325
|
const { image: s } = (n = yield this.editor.imageManager.importImage({
|
|
3275
3326
|
source: t,
|
|
@@ -3287,7 +3338,7 @@ class Lt {
|
|
|
3287
3338
|
hasControls: !1,
|
|
3288
3339
|
id: "background",
|
|
3289
3340
|
backgroundType: "image",
|
|
3290
|
-
backgroundId: `background-${
|
|
3341
|
+
backgroundId: `background-${K()}`,
|
|
3291
3342
|
customData: e
|
|
3292
3343
|
}), this._removeCurrentBackground(), this.backgroundObject = s, this.refresh();
|
|
3293
3344
|
});
|
|
@@ -3321,8 +3372,8 @@ class Lt {
|
|
|
3321
3372
|
{ offset: 0, color: "#000000" },
|
|
3322
3373
|
{ offset: 1, color: "#ffffff" }
|
|
3323
3374
|
], t.type === "linear") {
|
|
3324
|
-
const u = t.angle * Math.PI / 180, f =
|
|
3325
|
-
return new
|
|
3375
|
+
const u = t.angle * Math.PI / 180, f = _t._angleToCoords(u);
|
|
3376
|
+
return new We({
|
|
3326
3377
|
type: "linear",
|
|
3327
3378
|
gradientUnits: "percentage",
|
|
3328
3379
|
coords: f,
|
|
@@ -3341,7 +3392,7 @@ class Lt {
|
|
|
3341
3392
|
r1: 0,
|
|
3342
3393
|
r2: d / 100
|
|
3343
3394
|
};
|
|
3344
|
-
return new
|
|
3395
|
+
return new We({
|
|
3345
3396
|
type: "radial",
|
|
3346
3397
|
gradientUnits: "percentage",
|
|
3347
3398
|
coords: l,
|
|
@@ -3376,7 +3427,7 @@ class Lt {
|
|
|
3376
3427
|
}) ? !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;
|
|
3377
3428
|
}
|
|
3378
3429
|
}
|
|
3379
|
-
class
|
|
3430
|
+
class fe {
|
|
3380
3431
|
constructor({ editor: t }) {
|
|
3381
3432
|
this.editor = t;
|
|
3382
3433
|
}
|
|
@@ -3391,7 +3442,7 @@ class le {
|
|
|
3391
3442
|
const { canvas: s, historyManager: n } = this.editor;
|
|
3392
3443
|
n.suspendHistory();
|
|
3393
3444
|
const o = t || s.getActiveObject();
|
|
3394
|
-
o && (o instanceof
|
|
3445
|
+
o && (o instanceof F ? o.getObjects().forEach((i) => {
|
|
3395
3446
|
s.bringObjectToFront(i);
|
|
3396
3447
|
}) : s.bringObjectToFront(o), s.renderAll(), n.resumeHistory(), e || n.saveState(), s.fire("editor:object-bring-to-front", {
|
|
3397
3448
|
object: o,
|
|
@@ -3409,7 +3460,7 @@ class le {
|
|
|
3409
3460
|
const { canvas: s, historyManager: n } = this.editor;
|
|
3410
3461
|
n.suspendHistory();
|
|
3411
3462
|
const o = t || s.getActiveObject();
|
|
3412
|
-
o && (o instanceof
|
|
3463
|
+
o && (o instanceof F ? fe._moveSelectionForward(s, o) : s.bringObjectForward(o), s.renderAll(), n.resumeHistory(), e || n.saveState(), s.fire("editor:object-bring-forward", {
|
|
3413
3464
|
object: o,
|
|
3414
3465
|
withoutSave: e
|
|
3415
3466
|
}));
|
|
@@ -3432,7 +3483,7 @@ class le {
|
|
|
3432
3483
|
o.suspendHistory();
|
|
3433
3484
|
const r = t || s.getActiveObject();
|
|
3434
3485
|
if (r) {
|
|
3435
|
-
if (r instanceof
|
|
3486
|
+
if (r instanceof F) {
|
|
3436
3487
|
const c = r.getObjects();
|
|
3437
3488
|
for (let d = c.length - 1; d >= 0; d -= 1)
|
|
3438
3489
|
s.sendObjectToBack(c[d]);
|
|
@@ -3460,7 +3511,7 @@ class le {
|
|
|
3460
3511
|
} = this.editor;
|
|
3461
3512
|
o.suspendHistory();
|
|
3462
3513
|
const r = t || s.getActiveObject();
|
|
3463
|
-
r && (r instanceof
|
|
3514
|
+
r && (r instanceof F ? fe._moveSelectionBackwards(s, r) : s.sendObjectBackwards(r), a && s.sendObjectToBack(a), s.sendObjectToBack(n), i && s.sendObjectToBack(i), s.renderAll(), o.resumeHistory(), e || o.saveState(), s.fire("editor:object-send-backwards", {
|
|
3464
3515
|
object: r,
|
|
3465
3516
|
withoutSave: e
|
|
3466
3517
|
}));
|
|
@@ -3530,13 +3581,13 @@ class tn {
|
|
|
3530
3581
|
*/
|
|
3531
3582
|
addRectangle(d = {}, { withoutSelection: r, withoutAdding: c } = {}) {
|
|
3532
3583
|
var l = d, {
|
|
3533
|
-
id: t = `rect-${
|
|
3584
|
+
id: t = `rect-${K()}`,
|
|
3534
3585
|
left: e,
|
|
3535
3586
|
top: s,
|
|
3536
3587
|
width: n = 100,
|
|
3537
3588
|
height: o = 100,
|
|
3538
3589
|
fill: i = "blue"
|
|
3539
|
-
} = l, a =
|
|
3590
|
+
} = l, a = gt(l, [
|
|
3540
3591
|
"id",
|
|
3541
3592
|
"left",
|
|
3542
3593
|
"top",
|
|
@@ -3544,7 +3595,7 @@ class tn {
|
|
|
3544
3595
|
"height",
|
|
3545
3596
|
"fill"
|
|
3546
3597
|
]);
|
|
3547
|
-
const { canvas: u } = this.editor, f = new fs(
|
|
3598
|
+
const { canvas: u } = this.editor, f = new fs(z({
|
|
3548
3599
|
id: t,
|
|
3549
3600
|
left: e,
|
|
3550
3601
|
top: s,
|
|
@@ -3572,19 +3623,19 @@ class tn {
|
|
|
3572
3623
|
*/
|
|
3573
3624
|
addCircle(c = {}, { withoutSelection: a, withoutAdding: r } = {}) {
|
|
3574
3625
|
var d = c, {
|
|
3575
|
-
id: t = `circle-${
|
|
3626
|
+
id: t = `circle-${K()}`,
|
|
3576
3627
|
left: e,
|
|
3577
3628
|
top: s,
|
|
3578
3629
|
radius: n = 50,
|
|
3579
3630
|
fill: o = "green"
|
|
3580
|
-
} = d, i =
|
|
3631
|
+
} = d, i = gt(d, [
|
|
3581
3632
|
"id",
|
|
3582
3633
|
"left",
|
|
3583
3634
|
"top",
|
|
3584
3635
|
"radius",
|
|
3585
3636
|
"fill"
|
|
3586
3637
|
]);
|
|
3587
|
-
const { canvas: l } = this.editor, u = new gs(
|
|
3638
|
+
const { canvas: l } = this.editor, u = new gs(z({
|
|
3588
3639
|
id: t,
|
|
3589
3640
|
left: e,
|
|
3590
3641
|
top: s,
|
|
@@ -3612,13 +3663,13 @@ class tn {
|
|
|
3612
3663
|
*/
|
|
3613
3664
|
addTriangle(d = {}, { withoutSelection: r, withoutAdding: c } = {}) {
|
|
3614
3665
|
var l = d, {
|
|
3615
|
-
id: t = `triangle-${
|
|
3666
|
+
id: t = `triangle-${K()}`,
|
|
3616
3667
|
left: e,
|
|
3617
3668
|
top: s,
|
|
3618
3669
|
width: n = 100,
|
|
3619
3670
|
height: o = 100,
|
|
3620
3671
|
fill: i = "yellow"
|
|
3621
|
-
} = l, a =
|
|
3672
|
+
} = l, a = gt(l, [
|
|
3622
3673
|
"id",
|
|
3623
3674
|
"left",
|
|
3624
3675
|
"top",
|
|
@@ -3626,7 +3677,7 @@ class tn {
|
|
|
3626
3677
|
"height",
|
|
3627
3678
|
"fill"
|
|
3628
3679
|
]);
|
|
3629
|
-
const { canvas: u } = this.editor, f = new ps(
|
|
3680
|
+
const { canvas: u } = this.editor, f = new ps(z({
|
|
3630
3681
|
id: t,
|
|
3631
3682
|
left: e,
|
|
3632
3683
|
top: s,
|
|
@@ -3665,10 +3716,10 @@ class en {
|
|
|
3665
3716
|
* Асинхронное клонирование для внутреннего буфера
|
|
3666
3717
|
*/
|
|
3667
3718
|
_cloneToInternalClipboard(t) {
|
|
3668
|
-
return
|
|
3719
|
+
return W(this, null, function* () {
|
|
3669
3720
|
const { canvas: e, errorManager: s } = this.editor;
|
|
3670
3721
|
try {
|
|
3671
|
-
const n = yield t.clone(
|
|
3722
|
+
const n = yield t.clone(ce);
|
|
3672
3723
|
this.clipboard = n, e.fire("editor:object-copied", { object: n });
|
|
3673
3724
|
} catch (n) {
|
|
3674
3725
|
s.emitError({
|
|
@@ -3685,7 +3736,7 @@ class en {
|
|
|
3685
3736
|
* Копирование в системный буфер обмена
|
|
3686
3737
|
*/
|
|
3687
3738
|
_copyToSystemClipboard(t) {
|
|
3688
|
-
return
|
|
3739
|
+
return W(this, null, function* () {
|
|
3689
3740
|
const { errorManager: e } = this.editor;
|
|
3690
3741
|
if (typeof ClipboardItem == "undefined" || !navigator.clipboard)
|
|
3691
3742
|
return e.emitWarning({
|
|
@@ -3695,7 +3746,7 @@ class en {
|
|
|
3695
3746
|
message: "navigator.clipboard не поддерживается в этом браузере или отсутствует HTTPS-соединение."
|
|
3696
3747
|
}), !1;
|
|
3697
3748
|
try {
|
|
3698
|
-
const s = t.toObject(
|
|
3749
|
+
const s = t.toObject(ce), n = JSON.stringify(s);
|
|
3699
3750
|
return t.type === "image" ? this._copyImageToClipboard(t, n) : this._copyTextToClipboard(n);
|
|
3700
3751
|
} catch (s) {
|
|
3701
3752
|
return e.emitError({
|
|
@@ -3712,7 +3763,7 @@ class en {
|
|
|
3712
3763
|
* Копирование изображения в буфер обмена
|
|
3713
3764
|
*/
|
|
3714
3765
|
_copyImageToClipboard(t, e) {
|
|
3715
|
-
return
|
|
3766
|
+
return W(this, null, function* () {
|
|
3716
3767
|
try {
|
|
3717
3768
|
const n = t.toCanvasElement({ enableRetinaScaling: !1 }).toDataURL(), o = n.slice(5).split(";")[0], i = n.split(",")[1], a = atob(i), r = new Uint8Array(a.length);
|
|
3718
3769
|
for (let l = 0; l < a.length; l += 1)
|
|
@@ -3734,9 +3785,9 @@ class en {
|
|
|
3734
3785
|
* Копирование текста в буфер обмена
|
|
3735
3786
|
*/
|
|
3736
3787
|
_copyTextToClipboard(t) {
|
|
3737
|
-
return
|
|
3788
|
+
return W(this, null, function* () {
|
|
3738
3789
|
try {
|
|
3739
|
-
const e = `${
|
|
3790
|
+
const e = `${Ve}${t}`;
|
|
3740
3791
|
return yield navigator.clipboard.writeText(e), console.info("Text copied to clipboard successfully"), !0;
|
|
3741
3792
|
} catch (e) {
|
|
3742
3793
|
const { errorManager: s } = this.editor;
|
|
@@ -3756,7 +3807,7 @@ class en {
|
|
|
3756
3807
|
*/
|
|
3757
3808
|
_addClonedObjectToCanvas(t) {
|
|
3758
3809
|
const { canvas: e, historyManager: s } = this.editor;
|
|
3759
|
-
if (e.discardActiveObject(), t instanceof
|
|
3810
|
+
if (e.discardActiveObject(), t instanceof F) {
|
|
3760
3811
|
s.suspendHistory(), t.canvas = e, t.forEachObject((n) => {
|
|
3761
3812
|
e.add(n);
|
|
3762
3813
|
}), e.setActiveObject(t), e.requestRenderAll(), s.resumeHistory(), s.saveState();
|
|
@@ -3769,7 +3820,7 @@ class en {
|
|
|
3769
3820
|
* @param source - источник изображения (data URL или URL)
|
|
3770
3821
|
*/
|
|
3771
3822
|
_handleImageImport(t) {
|
|
3772
|
-
return
|
|
3823
|
+
return W(this, null, function* () {
|
|
3773
3824
|
var s;
|
|
3774
3825
|
const { image: e } = (s = yield this.editor.imageManager.importImage({
|
|
3775
3826
|
source: t,
|
|
@@ -3785,18 +3836,18 @@ class en {
|
|
|
3785
3836
|
* @fires editor:object-pasted
|
|
3786
3837
|
*/
|
|
3787
3838
|
copyPaste(t) {
|
|
3788
|
-
return
|
|
3839
|
+
return W(this, null, function* () {
|
|
3789
3840
|
const { canvas: e } = this.editor, s = t || e.getActiveObject();
|
|
3790
3841
|
if (!s || s.locked) return !1;
|
|
3791
3842
|
try {
|
|
3792
|
-
const n = yield s.clone(
|
|
3793
|
-
return n instanceof
|
|
3843
|
+
const n = yield s.clone(ce);
|
|
3844
|
+
return n instanceof F && n.forEachObject((o) => {
|
|
3794
3845
|
o.set({
|
|
3795
|
-
id: `${o.type}-${
|
|
3846
|
+
id: `${o.type}-${K()}`,
|
|
3796
3847
|
evented: !0
|
|
3797
3848
|
});
|
|
3798
3849
|
}), n.set({
|
|
3799
|
-
id: `${n.type}-${
|
|
3850
|
+
id: `${n.type}-${K()}`,
|
|
3800
3851
|
left: n.left + 10,
|
|
3801
3852
|
top: n.top + 10,
|
|
3802
3853
|
evented: !0
|
|
@@ -3820,14 +3871,14 @@ class en {
|
|
|
3820
3871
|
* @param event.clipboardData.items — элементы буфера обмена
|
|
3821
3872
|
*/
|
|
3822
3873
|
handlePasteEvent(e) {
|
|
3823
|
-
return
|
|
3874
|
+
return W(this, arguments, function* ({ clipboardData: t }) {
|
|
3824
3875
|
var r;
|
|
3825
3876
|
if (!((r = t == null ? void 0 : t.items) != null && r.length)) {
|
|
3826
3877
|
this.paste();
|
|
3827
3878
|
return;
|
|
3828
3879
|
}
|
|
3829
3880
|
const s = t.getData("text/plain");
|
|
3830
|
-
if (s && s.startsWith(
|
|
3881
|
+
if (s && s.startsWith(Ve)) {
|
|
3831
3882
|
this.paste();
|
|
3832
3883
|
return;
|
|
3833
3884
|
}
|
|
@@ -3871,18 +3922,18 @@ class en {
|
|
|
3871
3922
|
* @fires editor:object-pasted
|
|
3872
3923
|
*/
|
|
3873
3924
|
paste() {
|
|
3874
|
-
return
|
|
3925
|
+
return W(this, null, function* () {
|
|
3875
3926
|
const { canvas: t } = this.editor;
|
|
3876
3927
|
if (!this.clipboard) return !1;
|
|
3877
3928
|
try {
|
|
3878
|
-
const e = yield this.clipboard.clone(
|
|
3879
|
-
return t.discardActiveObject(), e instanceof
|
|
3929
|
+
const e = yield this.clipboard.clone(ce);
|
|
3930
|
+
return t.discardActiveObject(), e instanceof F && e.forEachObject((s) => {
|
|
3880
3931
|
s.set({
|
|
3881
|
-
id: `${s.type}-${
|
|
3932
|
+
id: `${s.type}-${K()}`,
|
|
3882
3933
|
evented: !0
|
|
3883
3934
|
});
|
|
3884
3935
|
}), e.set({
|
|
3885
|
-
id: `${e.type}-${
|
|
3936
|
+
id: `${e.type}-${K()}`,
|
|
3886
3937
|
left: e.left + 10,
|
|
3887
3938
|
top: e.top + 10,
|
|
3888
3939
|
evented: !0
|
|
@@ -3900,7 +3951,7 @@ class en {
|
|
|
3900
3951
|
});
|
|
3901
3952
|
}
|
|
3902
3953
|
}
|
|
3903
|
-
class
|
|
3954
|
+
class ge {
|
|
3904
3955
|
constructor({ editor: t }) {
|
|
3905
3956
|
this.editor = t;
|
|
3906
3957
|
}
|
|
@@ -3926,9 +3977,9 @@ class he {
|
|
|
3926
3977
|
editable: !1,
|
|
3927
3978
|
locked: !0
|
|
3928
3979
|
};
|
|
3929
|
-
i.set(a), !e &&
|
|
3980
|
+
i.set(a), !e && ge._isGroupOrSelection(i) && i.getObjects().forEach((c) => {
|
|
3930
3981
|
c.set(a);
|
|
3931
|
-
}), i instanceof
|
|
3982
|
+
}), i instanceof at && i.isEditing && i.exitEditing(), n.renderAll(), s || o.saveState(), n.fire("editor:object-locked", {
|
|
3932
3983
|
object: i,
|
|
3933
3984
|
skipInnerObjects: e,
|
|
3934
3985
|
withoutSave: s
|
|
@@ -3955,7 +4006,7 @@ class he {
|
|
|
3955
4006
|
editable: !0,
|
|
3956
4007
|
locked: !1
|
|
3957
4008
|
};
|
|
3958
|
-
o.set(i),
|
|
4009
|
+
o.set(i), ge._isGroupOrSelection(o) && o.getObjects().forEach((a) => {
|
|
3959
4010
|
a.set(i);
|
|
3960
4011
|
}), s.renderAll(), e || n.saveState(), s.fire("editor:object-unlocked", {
|
|
3961
4012
|
object: o,
|
|
@@ -3963,7 +4014,7 @@ class he {
|
|
|
3963
4014
|
});
|
|
3964
4015
|
}
|
|
3965
4016
|
static _isGroupOrSelection(t) {
|
|
3966
|
-
return t instanceof
|
|
4017
|
+
return t instanceof F || t instanceof xt;
|
|
3967
4018
|
}
|
|
3968
4019
|
}
|
|
3969
4020
|
class sn {
|
|
@@ -3978,7 +4029,7 @@ class sn {
|
|
|
3978
4029
|
if (Array.isArray(t))
|
|
3979
4030
|
return t.length > 0 ? t : null;
|
|
3980
4031
|
const e = t || this.editor.canvas.getActiveObject();
|
|
3981
|
-
return !e || !(e instanceof
|
|
4032
|
+
return !e || !(e instanceof F) ? null : e.getObjects();
|
|
3982
4033
|
}
|
|
3983
4034
|
/**
|
|
3984
4035
|
* Получить группы для разгруппировки
|
|
@@ -3986,20 +4037,20 @@ class sn {
|
|
|
3986
4037
|
*/
|
|
3987
4038
|
_getGroupsToUngroup(t) {
|
|
3988
4039
|
if (Array.isArray(t)) {
|
|
3989
|
-
const s = t.filter((n) => n instanceof
|
|
4040
|
+
const s = t.filter((n) => n instanceof xt);
|
|
3990
4041
|
return s.length > 0 ? s : null;
|
|
3991
4042
|
}
|
|
3992
|
-
if (t instanceof
|
|
3993
|
-
const s = t.getObjects().filter((n) => n instanceof
|
|
4043
|
+
if (t instanceof F) {
|
|
4044
|
+
const s = t.getObjects().filter((n) => n instanceof xt);
|
|
3994
4045
|
return s.length > 0 ? s : null;
|
|
3995
4046
|
}
|
|
3996
4047
|
const e = t || this.editor.canvas.getActiveObject();
|
|
3997
4048
|
if (!e) return null;
|
|
3998
|
-
if (e instanceof
|
|
3999
|
-
const s = e.getObjects().filter((n) => n instanceof
|
|
4049
|
+
if (e instanceof F) {
|
|
4050
|
+
const s = e.getObjects().filter((n) => n instanceof xt);
|
|
4000
4051
|
return s.length > 0 ? s : null;
|
|
4001
4052
|
}
|
|
4002
|
-
return e instanceof
|
|
4053
|
+
return e instanceof xt ? [e] : null;
|
|
4003
4054
|
}
|
|
4004
4055
|
/**
|
|
4005
4056
|
* Группировка объектов
|
|
@@ -4016,8 +4067,8 @@ class sn {
|
|
|
4016
4067
|
if (!o) return null;
|
|
4017
4068
|
try {
|
|
4018
4069
|
n.suspendHistory();
|
|
4019
|
-
const i = new
|
|
4020
|
-
id: `group-${
|
|
4070
|
+
const i = new xt(o, {
|
|
4071
|
+
id: `group-${K()}`
|
|
4021
4072
|
});
|
|
4022
4073
|
o.forEach((r) => s.remove(r)), s.add(i), s.setActiveObject(i), s.requestRenderAll();
|
|
4023
4074
|
const a = {
|
|
@@ -4052,7 +4103,7 @@ class sn {
|
|
|
4052
4103
|
s.add(l), i.push(l);
|
|
4053
4104
|
});
|
|
4054
4105
|
});
|
|
4055
|
-
const a = new
|
|
4106
|
+
const a = new F(i, {
|
|
4056
4107
|
canvas: s
|
|
4057
4108
|
});
|
|
4058
4109
|
s.setActiveObject(a), s.requestRenderAll();
|
|
@@ -4078,11 +4129,11 @@ class nn {
|
|
|
4078
4129
|
selectAll() {
|
|
4079
4130
|
const { canvas: t, canvasManager: e, objectLockManager: s } = this.editor;
|
|
4080
4131
|
t.discardActiveObject();
|
|
4081
|
-
const n = e.getObjects(), o = n.some((a) => a.locked), i = n.length > 1 ? new
|
|
4132
|
+
const n = e.getObjects(), o = n.some((a) => a.locked), i = n.length > 1 ? new F(e.getObjects(), { canvas: t }) : n[0];
|
|
4082
4133
|
o && s.lockObject({ object: i, skipInnerObjects: !0, withoutSave: !0 }), t.setActiveObject(i), t.requestRenderAll(), t.fire("editor:all-objects-selected", { selected: i });
|
|
4083
4134
|
}
|
|
4084
4135
|
}
|
|
4085
|
-
class
|
|
4136
|
+
class Re {
|
|
4086
4137
|
constructor({ editor: t }) {
|
|
4087
4138
|
this.editor = t;
|
|
4088
4139
|
}
|
|
@@ -4129,7 +4180,7 @@ class Oe {
|
|
|
4129
4180
|
s || o.suspendHistory();
|
|
4130
4181
|
const r = [];
|
|
4131
4182
|
if (a.forEach((d) => {
|
|
4132
|
-
if (
|
|
4183
|
+
if (Re._isUngroupableGroup(d)) {
|
|
4133
4184
|
const l = this._handleGroupDeletion(d);
|
|
4134
4185
|
r.push(...l);
|
|
4135
4186
|
return;
|
|
@@ -4144,7 +4195,7 @@ class Oe {
|
|
|
4144
4195
|
return n.fire("editor:objects-deleted", c), c;
|
|
4145
4196
|
}
|
|
4146
4197
|
}
|
|
4147
|
-
const
|
|
4198
|
+
const St = {
|
|
4148
4199
|
IMAGE_MANAGER: {
|
|
4149
4200
|
/**
|
|
4150
4201
|
* Некорректный Content-Type изображения
|
|
@@ -4249,7 +4300,7 @@ const At = {
|
|
|
4249
4300
|
APPLY_FAILED: "TEMPLATE_APPLY_FAILED"
|
|
4250
4301
|
}
|
|
4251
4302
|
};
|
|
4252
|
-
class
|
|
4303
|
+
class te {
|
|
4253
4304
|
constructor({ editor: t }) {
|
|
4254
4305
|
this._buffer = [], this.editor = t;
|
|
4255
4306
|
}
|
|
@@ -4276,7 +4327,7 @@ class Qt {
|
|
|
4276
4327
|
* @fires editor:error
|
|
4277
4328
|
*/
|
|
4278
4329
|
emitError({ origin: t = "ImageEditor", method: e = "Unknown Method", code: s, data: n, message: o }) {
|
|
4279
|
-
if (!
|
|
4330
|
+
if (!te.isValidErrorCode(s)) {
|
|
4280
4331
|
console.warn("Неизвестный код ошибки: ", { code: s, origin: t, method: e });
|
|
4281
4332
|
return;
|
|
4282
4333
|
}
|
|
@@ -4290,7 +4341,7 @@ class Qt {
|
|
|
4290
4341
|
message: i,
|
|
4291
4342
|
data: n
|
|
4292
4343
|
};
|
|
4293
|
-
this._buffer.push(
|
|
4344
|
+
this._buffer.push(z({
|
|
4294
4345
|
type: "editor:error"
|
|
4295
4346
|
}, a)), this.editor.canvas.fire("editor:error", a);
|
|
4296
4347
|
}
|
|
@@ -4305,7 +4356,7 @@ class Qt {
|
|
|
4305
4356
|
* @fires editor:warning
|
|
4306
4357
|
*/
|
|
4307
4358
|
emitWarning({ origin: t = "ImageEditor", method: e = "Unknown Method", code: s, message: n, data: o }) {
|
|
4308
|
-
if (!
|
|
4359
|
+
if (!te.isValidErrorCode(s)) {
|
|
4309
4360
|
console.warn("Неизвестный код предупреждения: ", { code: s, origin: t, method: e });
|
|
4310
4361
|
return;
|
|
4311
4362
|
}
|
|
@@ -4318,7 +4369,7 @@ class Qt {
|
|
|
4318
4369
|
message: i,
|
|
4319
4370
|
data: o
|
|
4320
4371
|
};
|
|
4321
|
-
this._buffer.push(
|
|
4372
|
+
this._buffer.push(z({
|
|
4322
4373
|
type: "editor:warning"
|
|
4323
4374
|
}, a)), this.editor.canvas.fire("editor:warning", a);
|
|
4324
4375
|
}
|
|
@@ -4328,7 +4379,7 @@ class Qt {
|
|
|
4328
4379
|
* @returns true, если код допустим, иначе false
|
|
4329
4380
|
*/
|
|
4330
4381
|
static isValidErrorCode(t) {
|
|
4331
|
-
return t ? Object.values(
|
|
4382
|
+
return t ? Object.values(St).some((e) => Object.values(e).includes(t)) : !1;
|
|
4332
4383
|
}
|
|
4333
4384
|
}
|
|
4334
4385
|
class on {
|
|
@@ -4416,11 +4467,11 @@ class on {
|
|
|
4416
4467
|
this.currentBounds = this.calculatePanBounds();
|
|
4417
4468
|
}
|
|
4418
4469
|
}
|
|
4419
|
-
const
|
|
4470
|
+
const ct = ({
|
|
4420
4471
|
value: h,
|
|
4421
4472
|
min: t,
|
|
4422
4473
|
max: e
|
|
4423
|
-
}) => Math.min(Math.max(h, t), e),
|
|
4474
|
+
}) => Math.min(Math.max(h, t), e), Bt = class Bt extends at {
|
|
4424
4475
|
constructor(t, e = {}) {
|
|
4425
4476
|
var s, n, o, i, a, r, c, d, l;
|
|
4426
4477
|
super(t, e), this.backgroundOpacity = (s = e.backgroundOpacity) != null ? s : 1, this.paddingTop = (n = e.paddingTop) != null ? n : 0, this.paddingRight = (o = e.paddingRight) != null ? o : 0, this.paddingBottom = (i = e.paddingBottom) != null ? i : 0, this.paddingLeft = (a = e.paddingLeft) != null ? a : 0, this.radiusTopLeft = (r = e.radiusTopLeft) != null ? r : 0, this.radiusTopRight = (c = e.radiusTopRight) != null ? c : 0, this.radiusBottomRight = (d = e.radiusBottomRight) != null ? d : 0, this.radiusBottomLeft = (l = e.radiusBottomLeft) != null ? l : 0, this._roundDimensions();
|
|
@@ -4445,7 +4496,7 @@ const lt = ({
|
|
|
4445
4496
|
}
|
|
4446
4497
|
_getTransformedDimensions(t = {}) {
|
|
4447
4498
|
const { width: e, height: s } = this._getBackgroundDimensions();
|
|
4448
|
-
return super._getTransformedDimensions(
|
|
4499
|
+
return super._getTransformedDimensions(wt(z({}, t), {
|
|
4449
4500
|
width: e,
|
|
4450
4501
|
height: s
|
|
4451
4502
|
}));
|
|
@@ -4455,7 +4506,7 @@ const lt = ({
|
|
|
4455
4506
|
*/
|
|
4456
4507
|
toObject(t = []) {
|
|
4457
4508
|
const e = super.toObject(t);
|
|
4458
|
-
return
|
|
4509
|
+
return wt(z({}, e), {
|
|
4459
4510
|
backgroundOpacity: this.backgroundOpacity,
|
|
4460
4511
|
paddingTop: this.paddingTop,
|
|
4461
4512
|
paddingRight: this.paddingRight,
|
|
@@ -4472,7 +4523,7 @@ const lt = ({
|
|
|
4472
4523
|
const e = this._getEffectiveBackgroundFill();
|
|
4473
4524
|
if (e && e) {
|
|
4474
4525
|
const o = this._getPadding(), i = (s = this.width) != null ? s : 0, a = (n = this.height) != null ? n : 0, r = i + o.left + o.right, c = a + o.top + o.bottom, d = this._getCornerRadii({ width: r, height: c }), l = this._getLeftOffset() - o.left, u = this._getTopOffset() - o.top;
|
|
4475
|
-
t.save(),
|
|
4526
|
+
t.save(), Bt._renderRoundedRect({
|
|
4476
4527
|
ctx: t,
|
|
4477
4528
|
height: c,
|
|
4478
4529
|
left: l,
|
|
@@ -4494,10 +4545,10 @@ const lt = ({
|
|
|
4494
4545
|
var i, a, r, c;
|
|
4495
4546
|
const s = t / 2, n = e / 2, o = Math.min(s, n);
|
|
4496
4547
|
return {
|
|
4497
|
-
bottomLeft:
|
|
4498
|
-
bottomRight:
|
|
4499
|
-
topLeft:
|
|
4500
|
-
topRight:
|
|
4548
|
+
bottomLeft: ct({ value: (i = this.radiusBottomLeft) != null ? i : 0, min: 0, max: o }),
|
|
4549
|
+
bottomRight: ct({ value: (a = this.radiusBottomRight) != null ? a : 0, min: 0, max: o }),
|
|
4550
|
+
topLeft: ct({ value: (r = this.radiusTopLeft) != null ? r : 0, min: 0, max: o }),
|
|
4551
|
+
topRight: ct({ value: (c = this.radiusTopRight) != null ? c : 0, min: 0, max: o })
|
|
4501
4552
|
};
|
|
4502
4553
|
}
|
|
4503
4554
|
_getPadding() {
|
|
@@ -4513,12 +4564,12 @@ const lt = ({
|
|
|
4513
4564
|
var n;
|
|
4514
4565
|
const t = this.backgroundColor;
|
|
4515
4566
|
if (!t) return null;
|
|
4516
|
-
const e =
|
|
4567
|
+
const e = ct({ value: (n = this.backgroundOpacity) != null ? n : 1, min: 0, max: 1 });
|
|
4517
4568
|
let s;
|
|
4518
4569
|
try {
|
|
4519
4570
|
s = new ms(t);
|
|
4520
4571
|
} catch (o) {
|
|
4521
|
-
return
|
|
4572
|
+
return te.emitError({
|
|
4522
4573
|
origin: "BackgroundTextbox",
|
|
4523
4574
|
method: "_getEffectiveBackgroundFill",
|
|
4524
4575
|
code: "INVALID_COLOR_VALUE",
|
|
@@ -4541,7 +4592,7 @@ const lt = ({
|
|
|
4541
4592
|
topRight: d,
|
|
4542
4593
|
bottomRight: l,
|
|
4543
4594
|
bottomLeft: u
|
|
4544
|
-
} = n, f =
|
|
4595
|
+
} = n, f = ct({ value: c, min: 0, max: i }), g = ct({ value: d, min: 0, max: i }), p = ct({ value: l, min: 0, max: i }), m = ct({ value: u, min: 0, max: i });
|
|
4545
4596
|
t.beginPath(), t.moveTo(s + f, o), t.lineTo(a - g, o), t.quadraticCurveTo(a, o, a, o + g), t.lineTo(a, r - p), t.quadraticCurveTo(a, r, a - p, r), t.lineTo(s + m, r), t.quadraticCurveTo(s, r, s, r - m), t.lineTo(s, o + f), t.quadraticCurveTo(s, o, s + f, o), t.closePath();
|
|
4546
4597
|
}
|
|
4547
4598
|
/**
|
|
@@ -4555,8 +4606,8 @@ const lt = ({
|
|
|
4555
4606
|
s !== t && (this.width = Math.max(0, s)), n !== e && (this.height = Math.max(0, n));
|
|
4556
4607
|
}
|
|
4557
4608
|
};
|
|
4558
|
-
|
|
4559
|
-
...Array.isArray(
|
|
4609
|
+
Bt.type = "background-textbox", Bt.cacheProperties = [
|
|
4610
|
+
...Array.isArray(at.cacheProperties) ? at.cacheProperties : [],
|
|
4560
4611
|
"backgroundColor",
|
|
4561
4612
|
"backgroundOpacity",
|
|
4562
4613
|
"paddingTop",
|
|
@@ -4567,8 +4618,8 @@ Rt.type = "background-textbox", Rt.cacheProperties = [
|
|
|
4567
4618
|
"radiusTopRight",
|
|
4568
4619
|
"radiusBottomRight",
|
|
4569
4620
|
"radiusBottomLeft"
|
|
4570
|
-
],
|
|
4571
|
-
...Array.isArray(
|
|
4621
|
+
], Bt.stateProperties = [
|
|
4622
|
+
...Array.isArray(at.stateProperties) ? at.stateProperties : [],
|
|
4572
4623
|
"backgroundColor",
|
|
4573
4624
|
"backgroundOpacity",
|
|
4574
4625
|
"paddingTop",
|
|
@@ -4580,10 +4631,10 @@ Rt.type = "background-textbox", Rt.cacheProperties = [
|
|
|
4580
4631
|
"radiusBottomRight",
|
|
4581
4632
|
"radiusBottomLeft"
|
|
4582
4633
|
];
|
|
4583
|
-
let
|
|
4634
|
+
let pe = Bt;
|
|
4584
4635
|
const an = () => {
|
|
4585
4636
|
var h;
|
|
4586
|
-
(h =
|
|
4637
|
+
(h = Ue) != null && h.setClass && Ue.setClass(pe, "background-textbox");
|
|
4587
4638
|
}, rn = ({ textbox: h }) => {
|
|
4588
4639
|
var s, n;
|
|
4589
4640
|
if (!h.isEditing) return null;
|
|
@@ -4601,7 +4652,7 @@ const an = () => {
|
|
|
4601
4652
|
if (!t) return !1;
|
|
4602
4653
|
const e = (n = (s = h.text) == null ? void 0 : s.length) != null ? n : 0;
|
|
4603
4654
|
return e <= 0 ? !1 : t.start <= 0 && t.end >= e;
|
|
4604
|
-
},
|
|
4655
|
+
}, ye = ({
|
|
4605
4656
|
textbox: h,
|
|
4606
4657
|
styles: t,
|
|
4607
4658
|
range: e
|
|
@@ -4609,7 +4660,7 @@ const an = () => {
|
|
|
4609
4660
|
if (!t || !Object.keys(t).length) return !1;
|
|
4610
4661
|
const { start: s, end: n } = e;
|
|
4611
4662
|
return n <= s ? !1 : (h.setSelectionStyles(t, s, n), !0);
|
|
4612
|
-
},
|
|
4663
|
+
}, Ke = ({
|
|
4613
4664
|
textbox: h,
|
|
4614
4665
|
range: t,
|
|
4615
4666
|
property: e
|
|
@@ -4623,15 +4674,15 @@ const an = () => {
|
|
|
4623
4674
|
);
|
|
4624
4675
|
if (s.length)
|
|
4625
4676
|
return (n = s[0]) == null ? void 0 : n[e];
|
|
4626
|
-
},
|
|
4627
|
-
class
|
|
4677
|
+
}, qe = ({ strokeColor: h, width: t }) => t <= 0 ? null : h != null ? h : "#000000", Je = ({ width: h = 0 }) => h ? Math.max(0, h) : 0, ve = ({ value: h }) => typeof h == "string" ? h.toLocaleUpperCase() : "", tt = 0.01;
|
|
4678
|
+
class P {
|
|
4628
4679
|
constructor({ editor: t }) {
|
|
4629
4680
|
var e;
|
|
4630
4681
|
this._handleTextEditingEntered = (s) => {
|
|
4631
4682
|
var r;
|
|
4632
4683
|
this.isTextEditingActive = !0;
|
|
4633
4684
|
const { target: n } = s;
|
|
4634
|
-
if (!
|
|
4685
|
+
if (!P._isTextbox(n)) return;
|
|
4635
4686
|
const o = (r = n.originY) != null ? r : "top", i = n.getPointByOrigin("center", o);
|
|
4636
4687
|
this._ensureEditingAnchorState().set(n, {
|
|
4637
4688
|
originY: o,
|
|
@@ -4640,19 +4691,22 @@ class k {
|
|
|
4640
4691
|
});
|
|
4641
4692
|
}, this._handleTextChanged = (s) => {
|
|
4642
4693
|
const { target: n } = s;
|
|
4643
|
-
if (!
|
|
4644
|
-
const { text: o = "", uppercase: i } = n,
|
|
4645
|
-
if (
|
|
4646
|
-
const
|
|
4647
|
-
|
|
4694
|
+
if (!P._isTextbox(n)) return;
|
|
4695
|
+
const { text: o = "", uppercase: i, autoExpand: a } = n, r = !!i, c = a !== !1, d = o.toLocaleLowerCase();
|
|
4696
|
+
if (r) {
|
|
4697
|
+
const f = ve({ value: d });
|
|
4698
|
+
f !== o && n.set({ text: f }), n.textCaseRaw = d;
|
|
4648
4699
|
} else
|
|
4649
4700
|
n.textCaseRaw = o;
|
|
4650
|
-
|
|
4651
|
-
|
|
4701
|
+
a === void 0 && (n.autoExpand = !0);
|
|
4702
|
+
let l = !1;
|
|
4703
|
+
c && (l = this._autoExpandTextboxWidth(n));
|
|
4704
|
+
let u = !1;
|
|
4705
|
+
l || (u = P._roundTextboxDimensions({ textbox: n })), (l || u) && (n.setCoords(), n.dirty = !0);
|
|
4652
4706
|
}, this._handleTextEditingExited = (s) => {
|
|
4653
4707
|
var r, c, d;
|
|
4654
4708
|
const { target: n } = s;
|
|
4655
|
-
if (!
|
|
4709
|
+
if (!P._isTextbox(n)) return;
|
|
4656
4710
|
(r = this.editingAnchorState) == null || r.delete(n);
|
|
4657
4711
|
const o = (c = n.text) != null ? c : "";
|
|
4658
4712
|
if (!!n.uppercase) {
|
|
@@ -4660,16 +4714,16 @@ class k {
|
|
|
4660
4714
|
n.textCaseRaw = l;
|
|
4661
4715
|
} else
|
|
4662
4716
|
n.textCaseRaw = o;
|
|
4663
|
-
|
|
4717
|
+
P._roundTextboxDimensions({ textbox: n }) && (n.setCoords(), n.dirty = !0, this.canvas.requestRenderAll()), n.locked || n.set({
|
|
4664
4718
|
lockMovementX: !1,
|
|
4665
4719
|
lockMovementY: !1
|
|
4666
4720
|
}), setTimeout(() => {
|
|
4667
4721
|
this.isTextEditingActive = !1, this.editor.historyManager.saveState();
|
|
4668
4722
|
}, Vs);
|
|
4669
4723
|
}, this._handleObjectScaling = (s) => {
|
|
4670
|
-
var
|
|
4724
|
+
var se, ne, oe, Et, me, ie, Ft, Yt, Ht, Zt, Gt, Vt, Xt;
|
|
4671
4725
|
const { target: n, transform: o } = s;
|
|
4672
|
-
if (n instanceof
|
|
4726
|
+
if (n instanceof F || !P._isTextbox(n) || !o) return;
|
|
4673
4727
|
n.isScaling = !0;
|
|
4674
4728
|
const i = this._ensureScalingState(n), {
|
|
4675
4729
|
baseWidth: a,
|
|
@@ -4678,135 +4732,135 @@ class k {
|
|
|
4678
4732
|
basePadding: d,
|
|
4679
4733
|
baseRadii: l,
|
|
4680
4734
|
baseStyles: u
|
|
4681
|
-
} = i, f = typeof ((
|
|
4682
|
-
if (!A && !y && !
|
|
4683
|
-
const
|
|
4684
|
-
paddingTop:
|
|
4685
|
-
paddingRight:
|
|
4686
|
-
paddingBottom:
|
|
4735
|
+
} = i, f = typeof ((se = o.original) == null ? void 0 : se.width) == "number" ? o.original.width : void 0, g = typeof ((ne = o.original) == null ? void 0 : ne.left) == "number" ? o.original.left : void 0, p = f != null ? f : a, m = g != null ? g : r, v = (oe = o.corner) != null ? oe : "", w = (Et = o.action) != null ? Et : "", A = ["ml", "mr"].includes(v) || w === "scaleX", y = ["mt", "mb"].includes(v) || w === "scaleY", M = ["tl", "tr", "bl", "br"].includes(v) || w === "scale", j = M || y;
|
|
4736
|
+
if (!A && !y && !M) return;
|
|
4737
|
+
const C = Math.abs((ie = (me = n.scaleX) != null ? me : o.scaleX) != null ? ie : 1) || 1, S = Math.abs((Yt = (Ft = n.scaleY) != null ? Ft : o.scaleY) != null ? Yt : 1) || 1, E = Math.max(1, p * C), b = Math.max(1, Math.round(E)), I = Math.max(1, c * S), {
|
|
4738
|
+
paddingTop: T = 0,
|
|
4739
|
+
paddingRight: _ = 0,
|
|
4740
|
+
paddingBottom: B = 0,
|
|
4687
4741
|
paddingLeft: N = 0,
|
|
4688
|
-
radiusTopLeft:
|
|
4689
|
-
radiusTopRight:
|
|
4690
|
-
radiusBottomRight:
|
|
4691
|
-
radiusBottomLeft:
|
|
4692
|
-
fontSize:
|
|
4693
|
-
width:
|
|
4694
|
-
originX:
|
|
4695
|
-
} = n,
|
|
4742
|
+
radiusTopLeft: H = 0,
|
|
4743
|
+
radiusTopRight: Z = 0,
|
|
4744
|
+
radiusBottomRight: $ = 0,
|
|
4745
|
+
radiusBottomLeft: Y = 0,
|
|
4746
|
+
fontSize: st,
|
|
4747
|
+
width: R,
|
|
4748
|
+
originX: O = "left"
|
|
4749
|
+
} = n, it = M || y, X = M || y, V = it ? {
|
|
4696
4750
|
top: Math.max(0, d.top * S),
|
|
4697
4751
|
right: Math.max(0, d.right * S),
|
|
4698
4752
|
bottom: Math.max(0, d.bottom * S),
|
|
4699
4753
|
left: Math.max(0, d.left * S)
|
|
4700
|
-
} : d,
|
|
4754
|
+
} : d, k = X ? {
|
|
4701
4755
|
topLeft: Math.max(0, l.topLeft * S),
|
|
4702
4756
|
topRight: Math.max(0, l.topRight * S),
|
|
4703
4757
|
bottomRight: Math.max(0, l.bottomRight * S),
|
|
4704
4758
|
bottomLeft: Math.max(0, l.bottomLeft * S)
|
|
4705
|
-
} : l,
|
|
4706
|
-
let
|
|
4707
|
-
if (j &&
|
|
4708
|
-
const
|
|
4709
|
-
Object.entries(u).forEach(([
|
|
4710
|
-
if (!
|
|
4711
|
-
const
|
|
4712
|
-
Object.entries(
|
|
4713
|
-
if (!
|
|
4714
|
-
const
|
|
4715
|
-
typeof
|
|
4716
|
-
}), Object.keys(
|
|
4717
|
-
}), Object.keys(
|
|
4759
|
+
} : l, Pt = Object.keys(u).length > 0;
|
|
4760
|
+
let Q;
|
|
4761
|
+
if (j && Pt) {
|
|
4762
|
+
const Tt = {};
|
|
4763
|
+
Object.entries(u).forEach(([q, Ot]) => {
|
|
4764
|
+
if (!Ot) return;
|
|
4765
|
+
const Kt = {};
|
|
4766
|
+
Object.entries(Ot).forEach(([Lt, Dt]) => {
|
|
4767
|
+
if (!Dt) return;
|
|
4768
|
+
const Rt = z({}, Dt);
|
|
4769
|
+
typeof Dt.fontSize == "number" && (Rt.fontSize = Math.max(1, Dt.fontSize * S)), Kt[Lt] = Rt;
|
|
4770
|
+
}), Object.keys(Kt).length && (Tt[q] = Kt);
|
|
4771
|
+
}), Object.keys(Tt).length && (Q = Tt);
|
|
4718
4772
|
}
|
|
4719
|
-
const
|
|
4720
|
-
if (!
|
|
4773
|
+
const nt = (Zt = (Ht = o.originX) != null ? Ht : O) != null ? Zt : "left", Ct = m + p, ut = m + p / 2, ft = R != null ? R : p, rt = b !== ft, It = Math.abs(I - (st != null ? st : c)) > tt, Wt = Math.abs(V.top - T) > tt || Math.abs(V.right - _) > tt || Math.abs(V.bottom - B) > tt || Math.abs(V.left - N) > tt, yt = Math.abs(k.topLeft - H) > tt || Math.abs(k.topRight - Z) > tt || Math.abs(k.bottomRight - $) > tt || Math.abs(k.bottomLeft - Y) > tt;
|
|
4774
|
+
if (!rt && !It && !Wt && !yt) {
|
|
4721
4775
|
n.set({ scaleX: 1, scaleY: 1 }), o.scaleX = 1, o.scaleY = 1;
|
|
4722
4776
|
return;
|
|
4723
4777
|
}
|
|
4724
|
-
|
|
4725
|
-
width:
|
|
4726
|
-
fontSize: j ?
|
|
4727
|
-
paddingTop:
|
|
4728
|
-
paddingRight:
|
|
4729
|
-
paddingBottom:
|
|
4730
|
-
paddingLeft:
|
|
4731
|
-
radiusTopLeft:
|
|
4732
|
-
radiusTopRight:
|
|
4733
|
-
radiusBottomRight:
|
|
4734
|
-
radiusBottomLeft:
|
|
4778
|
+
Q && (n.styles = Q), n.set({
|
|
4779
|
+
width: b,
|
|
4780
|
+
fontSize: j ? I : c,
|
|
4781
|
+
paddingTop: V.top,
|
|
4782
|
+
paddingRight: V.right,
|
|
4783
|
+
paddingBottom: V.bottom,
|
|
4784
|
+
paddingLeft: V.left,
|
|
4785
|
+
radiusTopLeft: k.topLeft,
|
|
4786
|
+
radiusTopRight: k.topRight,
|
|
4787
|
+
radiusBottomRight: k.bottomRight,
|
|
4788
|
+
radiusBottomLeft: k.bottomLeft,
|
|
4735
4789
|
scaleX: 1,
|
|
4736
4790
|
scaleY: 1
|
|
4737
4791
|
});
|
|
4738
|
-
const
|
|
4739
|
-
|
|
4740
|
-
const
|
|
4741
|
-
let
|
|
4742
|
-
|
|
4792
|
+
const ee = P._roundTextboxDimensions({ textbox: n });
|
|
4793
|
+
ee && (n.dirty = !0);
|
|
4794
|
+
const vt = (Gt = n.width) != null ? Gt : b, Ut = vt !== ft;
|
|
4795
|
+
let bt = m;
|
|
4796
|
+
Ut && (A || M) && (nt === "right" ? bt = Ct - vt : nt === "center" && (bt = ut - vt / 2)), n.set({ left: bt }), i.baseLeft = bt, o.scaleX = 1, o.scaleY = 1;
|
|
4743
4797
|
const { original: Mt } = o;
|
|
4744
|
-
Mt && (Mt.scaleX = 1, Mt.scaleY = 1, Mt.width =
|
|
4745
|
-
top:
|
|
4746
|
-
right:
|
|
4747
|
-
bottom:
|
|
4748
|
-
left:
|
|
4798
|
+
Mt && (Mt.scaleX = 1, Mt.scaleY = 1, Mt.width = vt, Mt.height = n.height, Mt.left = bt), n.setCoords(), this.canvas.requestRenderAll(), i.baseWidth = vt, i.baseFontSize = (Vt = n.fontSize) != null ? Vt : I, i.baseStyles = JSON.parse(JSON.stringify((Xt = n.styles) != null ? Xt : {})), i.basePadding = {
|
|
4799
|
+
top: V.top,
|
|
4800
|
+
right: V.right,
|
|
4801
|
+
bottom: V.bottom,
|
|
4802
|
+
left: V.left
|
|
4749
4803
|
}, i.baseRadii = {
|
|
4750
|
-
topLeft:
|
|
4751
|
-
topRight:
|
|
4752
|
-
bottomRight:
|
|
4753
|
-
bottomLeft:
|
|
4754
|
-
}, i.hasWidthChange =
|
|
4804
|
+
topLeft: k.topLeft,
|
|
4805
|
+
topRight: k.topRight,
|
|
4806
|
+
bottomRight: k.bottomRight,
|
|
4807
|
+
bottomLeft: k.bottomLeft
|
|
4808
|
+
}, i.hasWidthChange = Ut || It || Wt || yt || ee;
|
|
4755
4809
|
}, this._handleObjectModified = (s) => {
|
|
4756
4810
|
var w, A, y;
|
|
4757
4811
|
const { target: n } = s;
|
|
4758
|
-
if (n instanceof
|
|
4759
|
-
const
|
|
4760
|
-
if (!
|
|
4761
|
-
const { scaleX:
|
|
4762
|
-
if (Math.abs(
|
|
4763
|
-
this.canvas.discardActiveObject(),
|
|
4764
|
-
var
|
|
4765
|
-
if (
|
|
4766
|
-
const N = (
|
|
4767
|
-
paddingTop:
|
|
4768
|
-
paddingRight:
|
|
4769
|
-
paddingBottom:
|
|
4770
|
-
paddingLeft:
|
|
4771
|
-
radiusTopLeft:
|
|
4772
|
-
radiusTopRight:
|
|
4773
|
-
radiusBottomRight:
|
|
4774
|
-
radiusBottomLeft:
|
|
4775
|
-
styles:
|
|
4776
|
-
} =
|
|
4777
|
-
paddingTop: Math.max(0,
|
|
4778
|
-
paddingRight: Math.max(0,
|
|
4779
|
-
paddingBottom: Math.max(0,
|
|
4780
|
-
paddingLeft: Math.max(0,
|
|
4812
|
+
if (n instanceof F) {
|
|
4813
|
+
const M = n.getObjects();
|
|
4814
|
+
if (!M.some((b) => P._isTextbox(b))) return;
|
|
4815
|
+
const { scaleX: C = 1, scaleY: S = 1 } = n;
|
|
4816
|
+
if (Math.abs(C - 1) < tt && Math.abs(S - 1) < tt) return;
|
|
4817
|
+
this.canvas.discardActiveObject(), M.forEach((b) => {
|
|
4818
|
+
var I, T, _, B;
|
|
4819
|
+
if (P._isTextbox(b)) {
|
|
4820
|
+
const N = (I = b.scaleX) != null ? I : 1, H = (T = b.scaleY) != null ? T : 1, Z = ((_ = b.fontSize) != null ? _ : 16) * H, $ = ((B = b.width) != null ? B : 0) * N, Y = H, {
|
|
4821
|
+
paddingTop: st = 0,
|
|
4822
|
+
paddingRight: R = 0,
|
|
4823
|
+
paddingBottom: O = 0,
|
|
4824
|
+
paddingLeft: it = 0,
|
|
4825
|
+
radiusTopLeft: X = 0,
|
|
4826
|
+
radiusTopRight: V = 0,
|
|
4827
|
+
radiusBottomRight: k = 0,
|
|
4828
|
+
radiusBottomLeft: Pt = 0,
|
|
4829
|
+
styles: Q
|
|
4830
|
+
} = b, nt = {
|
|
4831
|
+
paddingTop: Math.max(0, st * Y),
|
|
4832
|
+
paddingRight: Math.max(0, R * Y),
|
|
4833
|
+
paddingBottom: Math.max(0, O * Y),
|
|
4834
|
+
paddingLeft: Math.max(0, it * Y)
|
|
4781
4835
|
}, Ct = {
|
|
4782
|
-
radiusTopLeft: Math.max(0,
|
|
4783
|
-
radiusTopRight: Math.max(0,
|
|
4784
|
-
radiusBottomRight: Math.max(0,
|
|
4785
|
-
radiusBottomLeft: Math.max(0,
|
|
4836
|
+
radiusTopLeft: Math.max(0, X * Y),
|
|
4837
|
+
radiusTopRight: Math.max(0, V * Y),
|
|
4838
|
+
radiusBottomRight: Math.max(0, k * Y),
|
|
4839
|
+
radiusBottomLeft: Math.max(0, Pt * Y)
|
|
4786
4840
|
};
|
|
4787
|
-
let
|
|
4788
|
-
|
|
4789
|
-
Object.values(
|
|
4790
|
-
typeof
|
|
4841
|
+
let ut = Q;
|
|
4842
|
+
Q && Object.keys(Q).length > 0 && (ut = JSON.parse(JSON.stringify(Q)), Object.values(ut).forEach((ft) => {
|
|
4843
|
+
Object.values(ft).forEach((rt) => {
|
|
4844
|
+
typeof rt.fontSize == "number" && (rt.fontSize = Math.max(1, rt.fontSize * Y));
|
|
4791
4845
|
});
|
|
4792
|
-
})),
|
|
4793
|
-
fontSize:
|
|
4794
|
-
width:
|
|
4846
|
+
})), b.set(wt(z(z({
|
|
4847
|
+
fontSize: Z,
|
|
4848
|
+
width: $,
|
|
4795
4849
|
scaleX: 1,
|
|
4796
4850
|
scaleY: 1
|
|
4797
|
-
},
|
|
4798
|
-
styles:
|
|
4799
|
-
})),
|
|
4851
|
+
}, nt), Ct), {
|
|
4852
|
+
styles: ut
|
|
4853
|
+
})), P._roundTextboxDimensions({ textbox: b });
|
|
4800
4854
|
}
|
|
4801
|
-
|
|
4855
|
+
b.setCoords();
|
|
4802
4856
|
});
|
|
4803
|
-
const
|
|
4857
|
+
const E = new F(M, {
|
|
4804
4858
|
canvas: this.canvas
|
|
4805
4859
|
});
|
|
4806
|
-
this.canvas.setActiveObject(
|
|
4860
|
+
this.canvas.setActiveObject(E), this.canvas.requestRenderAll();
|
|
4807
4861
|
return;
|
|
4808
4862
|
}
|
|
4809
|
-
if (!
|
|
4863
|
+
if (!P._isTextbox(n)) return;
|
|
4810
4864
|
n.isScaling = !1;
|
|
4811
4865
|
const o = this.scalingState.get(n);
|
|
4812
4866
|
if (this.scalingState.delete(n), !(o != null && o.hasWidthChange)) return;
|
|
@@ -4841,35 +4895,37 @@ class k {
|
|
|
4841
4895
|
* @param options — настройки текста
|
|
4842
4896
|
* @param flags — флаги поведения
|
|
4843
4897
|
*/
|
|
4844
|
-
addText(
|
|
4845
|
-
var
|
|
4846
|
-
id: t = `text-${
|
|
4898
|
+
addText(B = {}, { withoutSelection: I = !1, withoutSave: T = !1, withoutAdding: _ = !1 } = {}) {
|
|
4899
|
+
var N = B, {
|
|
4900
|
+
id: t = `text-${K()}`,
|
|
4847
4901
|
text: e = "Новый текст",
|
|
4848
|
-
|
|
4849
|
-
|
|
4850
|
-
|
|
4851
|
-
|
|
4852
|
-
|
|
4853
|
-
|
|
4854
|
-
|
|
4855
|
-
|
|
4856
|
-
|
|
4857
|
-
|
|
4858
|
-
|
|
4859
|
-
|
|
4860
|
-
|
|
4861
|
-
|
|
4862
|
-
|
|
4863
|
-
|
|
4864
|
-
|
|
4865
|
-
|
|
4866
|
-
|
|
4867
|
-
|
|
4868
|
-
|
|
4869
|
-
|
|
4870
|
-
|
|
4902
|
+
autoExpand: s = !0,
|
|
4903
|
+
fontFamily: n,
|
|
4904
|
+
fontSize: o = 48,
|
|
4905
|
+
bold: i = !1,
|
|
4906
|
+
italic: a = !1,
|
|
4907
|
+
underline: r = !1,
|
|
4908
|
+
uppercase: c = !1,
|
|
4909
|
+
strikethrough: d = !1,
|
|
4910
|
+
align: l = "left",
|
|
4911
|
+
color: u = "#000000",
|
|
4912
|
+
strokeColor: f,
|
|
4913
|
+
strokeWidth: g = 0,
|
|
4914
|
+
opacity: p = 1,
|
|
4915
|
+
backgroundColor: m,
|
|
4916
|
+
backgroundOpacity: v = 1,
|
|
4917
|
+
paddingTop: w = 0,
|
|
4918
|
+
paddingRight: A = 0,
|
|
4919
|
+
paddingBottom: y = 0,
|
|
4920
|
+
paddingLeft: M = 0,
|
|
4921
|
+
radiusTopLeft: j = 0,
|
|
4922
|
+
radiusTopRight: C = 0,
|
|
4923
|
+
radiusBottomRight: S = 0,
|
|
4924
|
+
radiusBottomLeft: E = 0
|
|
4925
|
+
} = N, b = gt(N, [
|
|
4871
4926
|
"id",
|
|
4872
4927
|
"text",
|
|
4928
|
+
"autoExpand",
|
|
4873
4929
|
"fontFamily",
|
|
4874
4930
|
"fontSize",
|
|
4875
4931
|
"bold",
|
|
@@ -4893,58 +4949,58 @@ class k {
|
|
|
4893
4949
|
"radiusBottomRight",
|
|
4894
4950
|
"radiusBottomLeft"
|
|
4895
4951
|
]);
|
|
4896
|
-
var
|
|
4897
|
-
const { historyManager:
|
|
4898
|
-
|
|
4899
|
-
const
|
|
4900
|
-
strokeColor:
|
|
4901
|
-
width:
|
|
4902
|
-
}), R =
|
|
4952
|
+
var V;
|
|
4953
|
+
const { historyManager: H } = this.editor, { canvas: Z } = this;
|
|
4954
|
+
H.suspendHistory();
|
|
4955
|
+
const $ = n != null ? n : this._getDefaultFontFamily(), Y = Je({ width: g }), st = qe({
|
|
4956
|
+
strokeColor: f,
|
|
4957
|
+
width: Y
|
|
4958
|
+
}), R = z({
|
|
4903
4959
|
id: t,
|
|
4904
|
-
fontFamily:
|
|
4905
|
-
fontSize:
|
|
4906
|
-
fontWeight:
|
|
4907
|
-
fontStyle:
|
|
4908
|
-
underline:
|
|
4909
|
-
uppercase:
|
|
4910
|
-
linethrough:
|
|
4911
|
-
textAlign:
|
|
4912
|
-
fill:
|
|
4913
|
-
stroke:
|
|
4914
|
-
strokeWidth:
|
|
4960
|
+
fontFamily: $,
|
|
4961
|
+
fontSize: o,
|
|
4962
|
+
fontWeight: i ? "bold" : "normal",
|
|
4963
|
+
fontStyle: a ? "italic" : "normal",
|
|
4964
|
+
underline: r,
|
|
4965
|
+
uppercase: c,
|
|
4966
|
+
linethrough: d,
|
|
4967
|
+
textAlign: l,
|
|
4968
|
+
fill: u,
|
|
4969
|
+
stroke: st,
|
|
4970
|
+
strokeWidth: Y,
|
|
4915
4971
|
strokeUniform: !0,
|
|
4916
|
-
opacity:
|
|
4917
|
-
backgroundColor:
|
|
4918
|
-
backgroundOpacity:
|
|
4919
|
-
paddingTop:
|
|
4920
|
-
paddingRight:
|
|
4921
|
-
paddingBottom:
|
|
4922
|
-
paddingLeft:
|
|
4923
|
-
radiusTopLeft:
|
|
4924
|
-
radiusTopRight:
|
|
4925
|
-
radiusBottomRight:
|
|
4926
|
-
radiusBottomLeft:
|
|
4927
|
-
},
|
|
4928
|
-
if (O.textCaseRaw = (
|
|
4929
|
-
const
|
|
4930
|
-
|
|
4931
|
-
}
|
|
4932
|
-
return
|
|
4972
|
+
opacity: p,
|
|
4973
|
+
backgroundColor: m,
|
|
4974
|
+
backgroundOpacity: v,
|
|
4975
|
+
paddingTop: w,
|
|
4976
|
+
paddingRight: A,
|
|
4977
|
+
paddingBottom: y,
|
|
4978
|
+
paddingLeft: M,
|
|
4979
|
+
radiusTopLeft: j,
|
|
4980
|
+
radiusTopRight: C,
|
|
4981
|
+
radiusBottomRight: S,
|
|
4982
|
+
radiusBottomLeft: E
|
|
4983
|
+
}, b), O = new pe(e, R), it = s !== !1;
|
|
4984
|
+
if (O.autoExpand = it, O.textCaseRaw = (V = O.text) != null ? V : "", c) {
|
|
4985
|
+
const k = ve({ value: O.textCaseRaw });
|
|
4986
|
+
k !== O.text && O.set({ text: k });
|
|
4987
|
+
}
|
|
4988
|
+
return P._roundTextboxDimensions({ textbox: O }) && (O.dirty = !0), b.left === void 0 && b.top === void 0 && Z.centerObject(O), _ || Z.add(O), I || Z.setActiveObject(O), Z.requestRenderAll(), H.resumeHistory(), T || H.saveState(), Z.fire("editor:text-added", {
|
|
4933
4989
|
textbox: O,
|
|
4934
|
-
options:
|
|
4990
|
+
options: wt(z({}, R), {
|
|
4935
4991
|
text: e,
|
|
4936
|
-
bold:
|
|
4937
|
-
italic:
|
|
4938
|
-
strikethrough:
|
|
4939
|
-
align:
|
|
4940
|
-
color:
|
|
4941
|
-
strokeColor:
|
|
4942
|
-
strokeWidth:
|
|
4992
|
+
bold: i,
|
|
4993
|
+
italic: a,
|
|
4994
|
+
strikethrough: d,
|
|
4995
|
+
align: l,
|
|
4996
|
+
color: u,
|
|
4997
|
+
strokeColor: st,
|
|
4998
|
+
strokeWidth: Y
|
|
4943
4999
|
}),
|
|
4944
5000
|
flags: {
|
|
4945
|
-
withoutSelection: !!
|
|
4946
|
-
withoutSave: !!
|
|
4947
|
-
withoutAdding: !!
|
|
5001
|
+
withoutSelection: !!I,
|
|
5002
|
+
withoutSave: !!T,
|
|
5003
|
+
withoutAdding: !!_
|
|
4948
5004
|
}
|
|
4949
5005
|
}), O;
|
|
4950
5006
|
}
|
|
@@ -4956,42 +5012,49 @@ class k {
|
|
|
4956
5012
|
* @param options.withoutSave — не сохранять состояние в историю
|
|
4957
5013
|
* @param options.skipRender — не вызывать перерисовку канваса
|
|
4958
5014
|
*/
|
|
4959
|
-
updateText({
|
|
4960
|
-
|
|
5015
|
+
updateText({
|
|
5016
|
+
target: t,
|
|
5017
|
+
style: e = {},
|
|
5018
|
+
withoutSave: s,
|
|
5019
|
+
skipRender: n
|
|
5020
|
+
} = {}) {
|
|
5021
|
+
var Ft, Ht, Zt, Gt, Vt, Xt, Tt;
|
|
4961
5022
|
const o = this._resolveTextObject(t);
|
|
4962
5023
|
if (!o) return null;
|
|
4963
5024
|
const { historyManager: i } = this.editor, { canvas: a } = this;
|
|
4964
5025
|
i.suspendHistory();
|
|
4965
|
-
const r =
|
|
5026
|
+
const r = P._getSnapshot(o), c = (Ft = o.originY) != null ? Ft : "top", d = o.getPointByOrigin("center", c), l = {
|
|
4966
5027
|
originY: c,
|
|
4967
5028
|
x: d.x,
|
|
4968
5029
|
y: d.y
|
|
4969
|
-
},
|
|
5030
|
+
}, Yt = e, {
|
|
4970
5031
|
text: u,
|
|
4971
|
-
|
|
4972
|
-
|
|
4973
|
-
|
|
4974
|
-
|
|
4975
|
-
|
|
4976
|
-
|
|
4977
|
-
|
|
4978
|
-
|
|
4979
|
-
|
|
4980
|
-
|
|
4981
|
-
|
|
4982
|
-
|
|
4983
|
-
|
|
4984
|
-
|
|
4985
|
-
|
|
4986
|
-
|
|
4987
|
-
|
|
4988
|
-
|
|
4989
|
-
|
|
4990
|
-
|
|
4991
|
-
|
|
4992
|
-
|
|
4993
|
-
|
|
5032
|
+
autoExpand: f,
|
|
5033
|
+
fontFamily: g,
|
|
5034
|
+
fontSize: p,
|
|
5035
|
+
bold: m,
|
|
5036
|
+
italic: v,
|
|
5037
|
+
underline: w,
|
|
5038
|
+
uppercase: A,
|
|
5039
|
+
strikethrough: y,
|
|
5040
|
+
align: M,
|
|
5041
|
+
color: j,
|
|
5042
|
+
strokeColor: C,
|
|
5043
|
+
strokeWidth: S,
|
|
5044
|
+
opacity: E,
|
|
5045
|
+
backgroundColor: b,
|
|
5046
|
+
backgroundOpacity: I,
|
|
5047
|
+
paddingTop: T,
|
|
5048
|
+
paddingRight: _,
|
|
5049
|
+
paddingBottom: B,
|
|
5050
|
+
paddingLeft: N,
|
|
5051
|
+
radiusTopLeft: H,
|
|
5052
|
+
radiusTopRight: Z,
|
|
5053
|
+
radiusBottomRight: $,
|
|
5054
|
+
radiusBottomLeft: Y
|
|
5055
|
+
} = Yt, st = gt(Yt, [
|
|
4994
5056
|
"text",
|
|
5057
|
+
"autoExpand",
|
|
4995
5058
|
"fontFamily",
|
|
4996
5059
|
"fontSize",
|
|
4997
5060
|
"bold",
|
|
@@ -5014,58 +5077,60 @@ class k {
|
|
|
5014
5077
|
"radiusTopRight",
|
|
5015
5078
|
"radiusBottomRight",
|
|
5016
5079
|
"radiusBottomLeft"
|
|
5017
|
-
]), R =
|
|
5018
|
-
if (
|
|
5019
|
-
const
|
|
5020
|
-
O && (
|
|
5021
|
-
}
|
|
5022
|
-
if (
|
|
5023
|
-
const
|
|
5024
|
-
O && (
|
|
5025
|
-
}
|
|
5026
|
-
if (
|
|
5027
|
-
const
|
|
5028
|
-
strokeColor:
|
|
5029
|
-
width:
|
|
5080
|
+
]), R = z({}, st), O = rn({ textbox: o }), it = O ? P._expandRangeToFullLines({ textbox: o, range: O }) : null, X = {}, V = {}, k = {}, Pt = dn({ textbox: o, range: O }), Q = !O || Pt, nt = !O;
|
|
5081
|
+
if (g !== void 0 && (it && (V.fontFamily = g), Q && (R.fontFamily = g, nt && (k.fontFamily = g))), p !== void 0 && (it && (V.fontSize = p), Q && (R.fontSize = p, nt && (k.fontSize = p))), m !== void 0) {
|
|
5082
|
+
const q = m ? "bold" : "normal";
|
|
5083
|
+
O && (X.fontWeight = q), Q && (R.fontWeight = q, nt && (k.fontWeight = q));
|
|
5084
|
+
}
|
|
5085
|
+
if (v !== void 0) {
|
|
5086
|
+
const q = v ? "italic" : "normal";
|
|
5087
|
+
O && (X.fontStyle = q), Q && (R.fontStyle = q, nt && (k.fontStyle = q));
|
|
5088
|
+
}
|
|
5089
|
+
if (w !== void 0 && (O && (X.underline = w), Q && (R.underline = w, nt && (k.underline = w))), y !== void 0 && (O && (X.linethrough = y), Q && (R.linethrough = y, nt && (k.linethrough = y))), M !== void 0 && (R.textAlign = M), j !== void 0 && (O && (X.fill = j), Q && (R.fill = j, nt && (k.fill = j))), C !== void 0 || S !== void 0) {
|
|
5090
|
+
const q = O ? Ke({ textbox: o, range: O, property: "strokeWidth" }) : void 0, Ot = O ? Ke({ textbox: o, range: O, property: "stroke" }) : void 0, Kt = (Zt = (Ht = S != null ? S : q) != null ? Ht : o.strokeWidth) != null ? Zt : 0, Lt = Je({ width: Kt }), Dt = (Vt = (Gt = C != null ? C : Ot) != null ? Gt : o.stroke) != null ? Vt : void 0, Rt = qe({
|
|
5091
|
+
strokeColor: Dt,
|
|
5092
|
+
width: Lt
|
|
5030
5093
|
});
|
|
5031
|
-
O && (
|
|
5032
|
-
}
|
|
5033
|
-
|
|
5034
|
-
const
|
|
5035
|
-
if (
|
|
5036
|
-
const
|
|
5037
|
-
R.text =
|
|
5038
|
-
} else o.textCaseRaw === void 0 && (o.textCaseRaw =
|
|
5039
|
-
o.uppercase =
|
|
5040
|
-
let
|
|
5094
|
+
O && (X.stroke = Rt, X.strokeWidth = Lt), Q && (R.stroke = Rt, R.strokeWidth = Lt, nt && (k.stroke = Rt, k.strokeWidth = Lt));
|
|
5095
|
+
}
|
|
5096
|
+
E !== void 0 && (R.opacity = E), b !== void 0 && (R.backgroundColor = b), I !== void 0 && (R.backgroundOpacity = I), T !== void 0 && (R.paddingTop = T), _ !== void 0 && (R.paddingRight = _), B !== void 0 && (R.paddingBottom = B), N !== void 0 && (R.paddingLeft = N), H !== void 0 && (R.radiusTopLeft = H), Z !== void 0 && (R.radiusTopRight = Z), $ !== void 0 && (R.radiusBottomRight = $), Y !== void 0 && (R.radiusBottomLeft = Y);
|
|
5097
|
+
const Ct = (Tt = o.textCaseRaw) != null ? Tt : (Xt = o.text) != null ? Xt : "", ut = !!o.uppercase, ft = u !== void 0, rt = ft ? u != null ? u : "" : Ct, It = A != null ? A : ut, Wt = It !== ut;
|
|
5098
|
+
if (ft || Wt) {
|
|
5099
|
+
const q = It ? ve({ value: rt }) : rt;
|
|
5100
|
+
R.text = q, o.textCaseRaw = rt;
|
|
5101
|
+
} else o.textCaseRaw === void 0 && (o.textCaseRaw = Ct);
|
|
5102
|
+
o.uppercase = It, o.set(R);
|
|
5103
|
+
let yt = !1;
|
|
5041
5104
|
if (O) {
|
|
5042
|
-
const
|
|
5043
|
-
|
|
5044
|
-
} else if (Object.keys(
|
|
5045
|
-
const
|
|
5046
|
-
|
|
5105
|
+
const q = ye({ textbox: o, styles: X, range: O }), Ot = it ? ye({ textbox: o, styles: V, range: it }) : !1;
|
|
5106
|
+
yt = q || Ot;
|
|
5107
|
+
} else if (Object.keys(k).length) {
|
|
5108
|
+
const q = cn({ textbox: o });
|
|
5109
|
+
q && (yt = ye({ textbox: o, styles: k, range: q }));
|
|
5047
5110
|
}
|
|
5048
|
-
const
|
|
5111
|
+
const ee = yt && P._hasLayoutAffectingStyles({
|
|
5049
5112
|
stylesList: [
|
|
5050
|
-
|
|
5051
|
-
|
|
5052
|
-
|
|
5113
|
+
X,
|
|
5114
|
+
V,
|
|
5115
|
+
k
|
|
5053
5116
|
]
|
|
5054
5117
|
});
|
|
5055
|
-
|
|
5056
|
-
const
|
|
5118
|
+
yt && (o.dirty = !0), ee && (o.initDimensions(), o.dirty = !0), (b !== void 0 || I !== void 0 || T !== void 0 || _ !== void 0 || B !== void 0 || N !== void 0 || H !== void 0 || Z !== void 0 || $ !== void 0 || Y !== void 0) && (o.dirty = !0);
|
|
5119
|
+
const vt = P._hasLayoutAffectingStyles({
|
|
5057
5120
|
stylesList: [
|
|
5058
5121
|
R,
|
|
5059
|
-
|
|
5060
|
-
|
|
5061
|
-
|
|
5122
|
+
X,
|
|
5123
|
+
V,
|
|
5124
|
+
k
|
|
5062
5125
|
]
|
|
5063
|
-
}),
|
|
5064
|
-
|
|
5065
|
-
|
|
5126
|
+
}), { autoExpand: Ut } = o, bt = f !== void 0, se = (f != null ? f : Ut) !== !1;
|
|
5127
|
+
bt ? o.autoExpand = f !== !1 : Ut === void 0 && (o.autoExpand = !0);
|
|
5128
|
+
const ne = Object.prototype.hasOwnProperty.call(R, "width"), oe = se && !ne && (ft || Wt || vt);
|
|
5129
|
+
let Et = !1;
|
|
5130
|
+
oe && (Et = this._autoExpandTextboxWidth(o, {
|
|
5066
5131
|
anchor: l
|
|
5067
|
-
}),
|
|
5068
|
-
const
|
|
5132
|
+
}), Et && (o.dirty = !0)), (Et ? !1 : P._roundTextboxDimensions({ textbox: o })) && (o.dirty = !0), o.setCoords(), n || a.requestRenderAll(), i.resumeHistory(), s || i.saveState();
|
|
5133
|
+
const ie = P._getSnapshot(o);
|
|
5069
5134
|
return a.fire("editor:text-updated", {
|
|
5070
5135
|
textbox: o,
|
|
5071
5136
|
target: t,
|
|
@@ -5076,9 +5141,9 @@ class k {
|
|
|
5076
5141
|
},
|
|
5077
5142
|
updates: R,
|
|
5078
5143
|
before: r,
|
|
5079
|
-
after:
|
|
5144
|
+
after: ie,
|
|
5080
5145
|
selectionRange: O != null ? O : void 0,
|
|
5081
|
-
selectionStyles: O && Object.keys(
|
|
5146
|
+
selectionStyles: O && Object.keys(X).length ? X : void 0
|
|
5082
5147
|
}), o;
|
|
5083
5148
|
}
|
|
5084
5149
|
/**
|
|
@@ -5086,20 +5151,20 @@ class k {
|
|
|
5086
5151
|
*/
|
|
5087
5152
|
destroy() {
|
|
5088
5153
|
const { canvas: t } = this;
|
|
5089
|
-
t.off("object:scaling", this._handleObjectScaling), t.off("object:resizing",
|
|
5154
|
+
t.off("object:scaling", this._handleObjectScaling), t.off("object:resizing", P._handleObjectResizing), t.off("object:modified", this._handleObjectModified), t.off("text:editing:exited", this._handleTextEditingExited), t.off("text:editing:entered", this._handleTextEditingEntered), t.off("text:changed", this._handleTextChanged);
|
|
5090
5155
|
}
|
|
5091
5156
|
/**
|
|
5092
5157
|
* Возвращает активный текст или ищет по id.
|
|
5093
5158
|
*/
|
|
5094
5159
|
_resolveTextObject(t) {
|
|
5095
|
-
if (t instanceof
|
|
5160
|
+
if (t instanceof at) return t;
|
|
5096
5161
|
const { canvas: e } = this;
|
|
5097
5162
|
if (!t) {
|
|
5098
5163
|
const s = e.getActiveObject();
|
|
5099
|
-
return
|
|
5164
|
+
return P._isTextbox(s) ? s : null;
|
|
5100
5165
|
}
|
|
5101
5166
|
if (typeof t == "string") {
|
|
5102
|
-
const s = e.getObjects().find((n) =>
|
|
5167
|
+
const s = e.getObjects().find((n) => P._isTextbox(n) && n.id === t);
|
|
5103
5168
|
return s != null ? s : null;
|
|
5104
5169
|
}
|
|
5105
5170
|
return null;
|
|
@@ -5108,29 +5173,29 @@ class k {
|
|
|
5108
5173
|
* Проверяет, является ли объект текстовым блоком редактора.
|
|
5109
5174
|
*/
|
|
5110
5175
|
static _isTextbox(t) {
|
|
5111
|
-
return !!t && t instanceof
|
|
5176
|
+
return !!t && t instanceof at;
|
|
5112
5177
|
}
|
|
5113
5178
|
/**
|
|
5114
5179
|
* Вешает обработчики событий Fabric для работы с текстом.
|
|
5115
5180
|
*/
|
|
5116
5181
|
_bindEvents() {
|
|
5117
5182
|
const { canvas: t } = this;
|
|
5118
|
-
t.on("object:scaling", this._handleObjectScaling), t.on("object:resizing",
|
|
5183
|
+
t.on("object:scaling", this._handleObjectScaling), t.on("object:resizing", P._handleObjectResizing), 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);
|
|
5119
5184
|
}
|
|
5120
5185
|
/**
|
|
5121
5186
|
* Автоматически увеличивает ширину текстового объекта до ширины текста,
|
|
5122
5187
|
* но не шире монтажной области, и удерживает объект в её пределах.
|
|
5123
5188
|
*/
|
|
5124
5189
|
_autoExpandTextboxWidth(t, { anchor: e } = {}) {
|
|
5125
|
-
var
|
|
5190
|
+
var C, S, E, b, I, T, _, B, N, H, Z, $, Y;
|
|
5126
5191
|
const { montageArea: s } = this.editor;
|
|
5127
5192
|
if (!s) return !1;
|
|
5128
5193
|
const n = typeof t.text == "string" ? t.text : "";
|
|
5129
5194
|
if (!n.length) return !1;
|
|
5130
5195
|
s.setCoords();
|
|
5131
|
-
const o = s.getBoundingRect(!1, !0), i = (
|
|
5196
|
+
const o = s.getBoundingRect(!1, !0), i = (C = o.width) != null ? C : 0;
|
|
5132
5197
|
if (!Number.isFinite(i) || i <= 0) return !1;
|
|
5133
|
-
const a = e != null ? e : (S = this.editingAnchorState) == null ? void 0 : S.get(t), r = (
|
|
5198
|
+
const a = e != null ? e : (S = this.editingAnchorState) == null ? void 0 : S.get(t), r = (b = (E = a == null ? void 0 : a.originY) != null ? E : t.originY) != null ? b : "top", c = Math.abs((I = t.scaleX) != null ? I : 1) || 1, d = (T = t.paddingLeft) != null ? T : 0, l = (_ = t.paddingRight) != null ? _ : 0, u = (B = t.strokeWidth) != null ? B : 0, f = Math.max(
|
|
5134
5199
|
1,
|
|
5135
5200
|
i / c - d - l - u
|
|
5136
5201
|
);
|
|
@@ -5140,17 +5205,17 @@ class k {
|
|
|
5140
5205
|
let p = !1;
|
|
5141
5206
|
Math.abs(((N = t.width) != null ? N : 0) - f) > tt && (t.set({ width: f }), p = !0), t.initDimensions();
|
|
5142
5207
|
const { textLines: m } = t, v = Array.isArray(m) && m.length > g, w = Math.ceil(
|
|
5143
|
-
|
|
5144
|
-
), A = Math.min((
|
|
5208
|
+
P._getLongestLineWidth({ textbox: t, text: n })
|
|
5209
|
+
), A = Math.min((H = t.minWidth) != null ? H : 1, f);
|
|
5145
5210
|
let y = Math.min(
|
|
5146
5211
|
f,
|
|
5147
5212
|
Math.max(w, A)
|
|
5148
5213
|
);
|
|
5149
|
-
v && (y = f), Math.abs(((
|
|
5150
|
-
const j =
|
|
5214
|
+
v && (y = f), Math.abs(((Z = t.width) != null ? Z : 0) - y) > tt && (t.set({ width: y }), t.initDimensions(), p = !0), P._roundTextboxDimensions({ textbox: t }) && (p = !0), a && (t.setPositionByOrigin(new et(a.x, a.y), "center", r), p = !0);
|
|
5215
|
+
const j = P._clampTextboxToMontage({
|
|
5151
5216
|
textbox: t,
|
|
5152
|
-
montageLeft: (
|
|
5153
|
-
montageRight: ((
|
|
5217
|
+
montageLeft: ($ = o.left) != null ? $ : 0,
|
|
5218
|
+
montageRight: ((Y = o.left) != null ? Y : 0) + i
|
|
5154
5219
|
});
|
|
5155
5220
|
return p || j;
|
|
5156
5221
|
}
|
|
@@ -5195,7 +5260,7 @@ class k {
|
|
|
5195
5260
|
static _handleObjectResizing(t) {
|
|
5196
5261
|
var l, u, f, g, p, m;
|
|
5197
5262
|
const { target: e, transform: s } = t;
|
|
5198
|
-
if (!
|
|
5263
|
+
if (!P._isTextbox(e)) return;
|
|
5199
5264
|
const {
|
|
5200
5265
|
paddingLeft: n = 0,
|
|
5201
5266
|
paddingRight: o = 0
|
|
@@ -5206,7 +5271,7 @@ class k {
|
|
|
5206
5271
|
e.set({ width: r });
|
|
5207
5272
|
const c = (u = e.width) != null ? u : 0, d = a - c;
|
|
5208
5273
|
if (d !== 0 && s && s.corner === "ml") {
|
|
5209
|
-
const w = ((f = e.angle) != null ? f : 0) * Math.PI / 180, A = Math.cos(w), y = Math.sin(w),
|
|
5274
|
+
const w = ((f = e.angle) != null ? f : 0) * Math.PI / 180, A = Math.cos(w), y = Math.sin(w), M = (g = e.scaleX) != null ? g : 1, j = d * M;
|
|
5210
5275
|
e.set({
|
|
5211
5276
|
left: ((p = e.left) != null ? p : 0) + j * A,
|
|
5212
5277
|
top: ((m = e.top) != null ? m : 0) + j * y
|
|
@@ -5241,7 +5306,7 @@ class k {
|
|
|
5241
5306
|
textbox: t,
|
|
5242
5307
|
range: e
|
|
5243
5308
|
}) {
|
|
5244
|
-
const s =
|
|
5309
|
+
const s = P._getLineRanges({ textbox: t });
|
|
5245
5310
|
if (!s.length) return e;
|
|
5246
5311
|
let { start: n } = e, { end: o } = e;
|
|
5247
5312
|
return s.forEach(({ start: i, end: a }) => {
|
|
@@ -5326,10 +5391,10 @@ class k {
|
|
|
5326
5391
|
static _roundTextboxDimensions({
|
|
5327
5392
|
textbox: t
|
|
5328
5393
|
}) {
|
|
5329
|
-
const { width: e, height: s, calcTextWidth: n, calcTextHeight: o } = t, i = typeof n == "function" ? n.call(t) : void 0, a = typeof o == "function" ? o.call(t) : void 0, r =
|
|
5394
|
+
const { width: e, height: s, calcTextWidth: n, calcTextHeight: o } = t, i = typeof n == "function" ? n.call(t) : void 0, a = typeof o == "function" ? o.call(t) : void 0, r = P._resolveDimension({
|
|
5330
5395
|
rawValue: e,
|
|
5331
5396
|
calculatedValue: i
|
|
5332
|
-
}), c =
|
|
5397
|
+
}), c = P._resolveDimension({
|
|
5333
5398
|
rawValue: s,
|
|
5334
5399
|
calculatedValue: a
|
|
5335
5400
|
}), d = Number.isFinite(r) ? Math.round(r) : null, l = Number.isFinite(c) ? Math.round(c) : null, u = {};
|
|
@@ -5343,81 +5408,83 @@ class k {
|
|
|
5343
5408
|
snapshot: R,
|
|
5344
5409
|
entries: O
|
|
5345
5410
|
}) => {
|
|
5346
|
-
Object.entries(O).forEach(([
|
|
5347
|
-
|
|
5411
|
+
Object.entries(O).forEach(([it, X]) => {
|
|
5412
|
+
X != null && (R[it] = X);
|
|
5348
5413
|
});
|
|
5349
5414
|
}, {
|
|
5350
5415
|
id: s,
|
|
5351
5416
|
text: n,
|
|
5352
5417
|
textCaseRaw: o,
|
|
5353
5418
|
uppercase: i,
|
|
5354
|
-
|
|
5355
|
-
|
|
5356
|
-
|
|
5357
|
-
|
|
5358
|
-
|
|
5359
|
-
|
|
5360
|
-
|
|
5361
|
-
|
|
5362
|
-
|
|
5363
|
-
|
|
5364
|
-
|
|
5365
|
-
|
|
5366
|
-
|
|
5367
|
-
|
|
5368
|
-
|
|
5369
|
-
|
|
5370
|
-
|
|
5371
|
-
|
|
5372
|
-
|
|
5373
|
-
|
|
5374
|
-
|
|
5375
|
-
|
|
5376
|
-
|
|
5377
|
-
|
|
5378
|
-
|
|
5379
|
-
|
|
5380
|
-
|
|
5381
|
-
|
|
5382
|
-
|
|
5419
|
+
autoExpand: a,
|
|
5420
|
+
fontFamily: r,
|
|
5421
|
+
fontSize: c,
|
|
5422
|
+
fontWeight: d,
|
|
5423
|
+
fontStyle: l,
|
|
5424
|
+
underline: u,
|
|
5425
|
+
linethrough: f,
|
|
5426
|
+
textAlign: g,
|
|
5427
|
+
fill: p,
|
|
5428
|
+
stroke: m,
|
|
5429
|
+
strokeWidth: v,
|
|
5430
|
+
opacity: w,
|
|
5431
|
+
backgroundColor: A,
|
|
5432
|
+
backgroundOpacity: y,
|
|
5433
|
+
paddingTop: M,
|
|
5434
|
+
paddingRight: j,
|
|
5435
|
+
paddingBottom: C,
|
|
5436
|
+
paddingLeft: S,
|
|
5437
|
+
radiusTopLeft: E,
|
|
5438
|
+
radiusTopRight: b,
|
|
5439
|
+
radiusBottomRight: I,
|
|
5440
|
+
radiusBottomLeft: T,
|
|
5441
|
+
left: _,
|
|
5442
|
+
top: B,
|
|
5443
|
+
width: N,
|
|
5444
|
+
height: H,
|
|
5445
|
+
angle: Z,
|
|
5446
|
+
scaleX: $,
|
|
5447
|
+
scaleY: Y
|
|
5448
|
+
} = t, st = {
|
|
5383
5449
|
id: s,
|
|
5384
5450
|
uppercase: !!i,
|
|
5385
|
-
textAlign:
|
|
5451
|
+
textAlign: g
|
|
5386
5452
|
};
|
|
5387
5453
|
return e({
|
|
5388
|
-
snapshot:
|
|
5454
|
+
snapshot: st,
|
|
5389
5455
|
entries: {
|
|
5390
5456
|
text: n,
|
|
5391
5457
|
textCaseRaw: o,
|
|
5392
|
-
|
|
5393
|
-
|
|
5394
|
-
|
|
5395
|
-
|
|
5396
|
-
|
|
5397
|
-
|
|
5398
|
-
|
|
5399
|
-
|
|
5400
|
-
|
|
5401
|
-
|
|
5402
|
-
|
|
5403
|
-
|
|
5404
|
-
|
|
5405
|
-
|
|
5406
|
-
|
|
5407
|
-
|
|
5408
|
-
|
|
5409
|
-
|
|
5410
|
-
|
|
5411
|
-
|
|
5412
|
-
|
|
5413
|
-
|
|
5414
|
-
|
|
5415
|
-
|
|
5416
|
-
|
|
5417
|
-
|
|
5418
|
-
|
|
5458
|
+
autoExpand: a,
|
|
5459
|
+
fontFamily: r,
|
|
5460
|
+
fontSize: c,
|
|
5461
|
+
fontWeight: d,
|
|
5462
|
+
fontStyle: l,
|
|
5463
|
+
underline: u,
|
|
5464
|
+
linethrough: f,
|
|
5465
|
+
fill: p,
|
|
5466
|
+
stroke: m,
|
|
5467
|
+
strokeWidth: v,
|
|
5468
|
+
opacity: w,
|
|
5469
|
+
backgroundColor: A,
|
|
5470
|
+
backgroundOpacity: y,
|
|
5471
|
+
paddingTop: M,
|
|
5472
|
+
paddingRight: j,
|
|
5473
|
+
paddingBottom: C,
|
|
5474
|
+
paddingLeft: S,
|
|
5475
|
+
radiusTopLeft: E,
|
|
5476
|
+
radiusTopRight: b,
|
|
5477
|
+
radiusBottomRight: I,
|
|
5478
|
+
radiusBottomLeft: T,
|
|
5479
|
+
left: _,
|
|
5480
|
+
top: B,
|
|
5481
|
+
width: N,
|
|
5482
|
+
height: H,
|
|
5483
|
+
angle: Z,
|
|
5484
|
+
scaleX: $,
|
|
5485
|
+
scaleY: Y
|
|
5419
5486
|
}
|
|
5420
|
-
}),
|
|
5487
|
+
}), st;
|
|
5421
5488
|
}
|
|
5422
5489
|
/**
|
|
5423
5490
|
* Возвращает первый доступный шрифт или дефолтный Arial.
|
|
@@ -5430,7 +5497,7 @@ class k {
|
|
|
5430
5497
|
const J = ({
|
|
5431
5498
|
value: h,
|
|
5432
5499
|
fallback: t = 0
|
|
5433
|
-
}) => typeof h == "number" && Number.isFinite(h) ? h : typeof t == "number" && Number.isFinite(t) ? t : 0,
|
|
5500
|
+
}) => typeof h == "number" && Number.isFinite(h) ? h : typeof t == "number" && Number.isFinite(t) ? t : 0, de = ({
|
|
5434
5501
|
value: h,
|
|
5435
5502
|
dimension: t,
|
|
5436
5503
|
useRelativePositions: e
|
|
@@ -5447,22 +5514,22 @@ const J = ({
|
|
|
5447
5514
|
const o = h;
|
|
5448
5515
|
if (typeof o[n.x] == "number" && typeof o[n.y] == "number")
|
|
5449
5516
|
return {
|
|
5450
|
-
x:
|
|
5517
|
+
x: de({
|
|
5451
5518
|
value: o[n.x],
|
|
5452
5519
|
dimension: t,
|
|
5453
5520
|
useRelativePositions: s
|
|
5454
5521
|
}),
|
|
5455
|
-
y:
|
|
5522
|
+
y: de({
|
|
5456
5523
|
value: o[n.y],
|
|
5457
5524
|
dimension: e,
|
|
5458
5525
|
useRelativePositions: s
|
|
5459
5526
|
})
|
|
5460
5527
|
};
|
|
5461
|
-
const { left: a, top: r, width: c, height: d } = h, l =
|
|
5528
|
+
const { left: a, top: r, width: c, height: d } = h, l = de({
|
|
5462
5529
|
value: a,
|
|
5463
5530
|
dimension: t,
|
|
5464
5531
|
useRelativePositions: s
|
|
5465
|
-
}), u =
|
|
5532
|
+
}), u = de({
|
|
5466
5533
|
value: r,
|
|
5467
5534
|
dimension: e,
|
|
5468
5535
|
useRelativePositions: s
|
|
@@ -5500,7 +5567,7 @@ const J = ({
|
|
|
5500
5567
|
} catch (s) {
|
|
5501
5568
|
return null;
|
|
5502
5569
|
}
|
|
5503
|
-
},
|
|
5570
|
+
}, mt = ({
|
|
5504
5571
|
object: h
|
|
5505
5572
|
}) => {
|
|
5506
5573
|
if (!h) return null;
|
|
@@ -5564,8 +5631,8 @@ const J = ({
|
|
|
5564
5631
|
};
|
|
5565
5632
|
}
|
|
5566
5633
|
return null;
|
|
5567
|
-
},
|
|
5568
|
-
class
|
|
5634
|
+
}, Qt = "_templateCenterX", be = "_templateCenterY", le = "_templateAnchorX", Me = "_templateAnchorY";
|
|
5635
|
+
class x {
|
|
5569
5636
|
constructor({ editor: t }) {
|
|
5570
5637
|
this.editor = t;
|
|
5571
5638
|
}
|
|
@@ -5584,28 +5651,28 @@ class _ {
|
|
|
5584
5651
|
montageArea: i,
|
|
5585
5652
|
errorManager: a,
|
|
5586
5653
|
backgroundManager: r
|
|
5587
|
-
} = this.editor, c = o.getActiveObject(), d =
|
|
5654
|
+
} = this.editor, c = o.getActiveObject(), d = x._collectObjects(c), { backgroundObject: l } = r != null ? r : {}, u = n && l ? [l] : [], f = [...d, ...u];
|
|
5588
5655
|
if (!f.length)
|
|
5589
5656
|
return a.emitWarning({
|
|
5590
5657
|
origin: "TemplateManager",
|
|
5591
5658
|
method: "serializeSelection",
|
|
5592
|
-
code:
|
|
5659
|
+
code: St.TEMPLATE_MANAGER.NO_OBJECTS_SELECTED,
|
|
5593
5660
|
message: "Нет объектов для сериализации шаблона"
|
|
5594
5661
|
}), null;
|
|
5595
|
-
const g =
|
|
5596
|
-
object:
|
|
5662
|
+
const g = x._getBounds(i), p = x._getMontageSize({ montageArea: i, bounds: g }), m = p.width, v = p.height, w = f.map((M) => x._serializeObject({
|
|
5663
|
+
object: M,
|
|
5597
5664
|
bounds: g,
|
|
5598
5665
|
baseWidth: m,
|
|
5599
5666
|
baseHeight: v,
|
|
5600
5667
|
montageArea: i != null ? i : null
|
|
5601
|
-
})), A =
|
|
5668
|
+
})), A = wt(z({}, s), {
|
|
5602
5669
|
baseWidth: m,
|
|
5603
5670
|
baseHeight: v,
|
|
5604
5671
|
positionsNormalized: !0,
|
|
5605
5672
|
previewId: e != null ? e : s.previewId
|
|
5606
5673
|
});
|
|
5607
5674
|
return {
|
|
5608
|
-
id: t != null ? t : `template-${
|
|
5675
|
+
id: t != null ? t : `template-${K()}`,
|
|
5609
5676
|
meta: A,
|
|
5610
5677
|
objects: w
|
|
5611
5678
|
};
|
|
@@ -5617,7 +5684,7 @@ class _ {
|
|
|
5617
5684
|
* @param options.data - данные для заполнения текстов по customData.templateField
|
|
5618
5685
|
*/
|
|
5619
5686
|
applyTemplate(s) {
|
|
5620
|
-
return
|
|
5687
|
+
return W(this, arguments, function* ({
|
|
5621
5688
|
template: t,
|
|
5622
5689
|
data: e
|
|
5623
5690
|
}) {
|
|
@@ -5632,40 +5699,40 @@ class _ {
|
|
|
5632
5699
|
return a.emitWarning({
|
|
5633
5700
|
origin: "TemplateManager",
|
|
5634
5701
|
method: "applyTemplate",
|
|
5635
|
-
code:
|
|
5702
|
+
code: St.TEMPLATE_MANAGER.INVALID_TEMPLATE,
|
|
5636
5703
|
message: "Шаблон не содержит объектов"
|
|
5637
5704
|
}), null;
|
|
5638
|
-
const u =
|
|
5705
|
+
const u = x._getBounds(o);
|
|
5639
5706
|
if (!u)
|
|
5640
5707
|
return a.emitWarning({
|
|
5641
5708
|
origin: "TemplateManager",
|
|
5642
5709
|
method: "applyTemplate",
|
|
5643
|
-
code:
|
|
5710
|
+
code: St.TEMPLATE_MANAGER.INVALID_TARGET,
|
|
5644
5711
|
message: "Не удалось определить границы монтажной области"
|
|
5645
5712
|
}), null;
|
|
5646
|
-
const f =
|
|
5713
|
+
const f = x._getMontageSize({ montageArea: o, bounds: u }), g = x._normalizeMeta({ meta: d, fallback: f }), p = x._calculateScale({ meta: g, target: f }), m = !!g.positionsNormalized;
|
|
5647
5714
|
let v = !1, w = !1;
|
|
5648
5715
|
i.suspendHistory();
|
|
5649
5716
|
try {
|
|
5650
|
-
const A = yield
|
|
5717
|
+
const A = yield x._enlivenObjects(c);
|
|
5651
5718
|
if (!A.length)
|
|
5652
5719
|
return a.emitWarning({
|
|
5653
5720
|
origin: "TemplateManager",
|
|
5654
5721
|
method: "applyTemplate",
|
|
5655
|
-
code:
|
|
5722
|
+
code: St.TEMPLATE_MANAGER.INVALID_TEMPLATE,
|
|
5656
5723
|
message: "Не удалось создать объекты шаблона"
|
|
5657
5724
|
}), null;
|
|
5658
|
-
const { backgroundObject: y, contentObjects:
|
|
5659
|
-
y && (w = yield
|
|
5725
|
+
const { backgroundObject: y, contentObjects: M } = x._extractBackgroundObject(A);
|
|
5726
|
+
y && (w = yield x._applyBackgroundFromObject({
|
|
5660
5727
|
backgroundObject: y,
|
|
5661
5728
|
backgroundManager: r,
|
|
5662
5729
|
errorManager: a
|
|
5663
5730
|
}));
|
|
5664
|
-
const j =
|
|
5665
|
-
object:
|
|
5731
|
+
const j = M.map((C) => (this._adaptTextboxWidth({
|
|
5732
|
+
object: C,
|
|
5666
5733
|
baseWidth: g.baseWidth
|
|
5667
|
-
}),
|
|
5668
|
-
object:
|
|
5734
|
+
}), x._transformObject({
|
|
5735
|
+
object: C,
|
|
5669
5736
|
scale: p,
|
|
5670
5737
|
bounds: u,
|
|
5671
5738
|
targetSize: f,
|
|
@@ -5673,11 +5740,11 @@ class _ {
|
|
|
5673
5740
|
baseHeight: g.baseHeight,
|
|
5674
5741
|
montageArea: o,
|
|
5675
5742
|
useRelativePositions: m
|
|
5676
|
-
}),
|
|
5677
|
-
id: `${
|
|
5743
|
+
}), C.set({
|
|
5744
|
+
id: `${C.type}-${K()}`,
|
|
5678
5745
|
evented: !0
|
|
5679
|
-
}), n.add(
|
|
5680
|
-
return !j.length && !w ? null : (v = j.length > 0 || w, j.length &&
|
|
5746
|
+
}), n.add(C), C));
|
|
5747
|
+
return !j.length && !w ? null : (v = j.length > 0 || w, j.length && x._activateObjects({ canvas: n, objects: j }), n.requestRenderAll(), n.fire("editor:template-applied", {
|
|
5681
5748
|
template: t,
|
|
5682
5749
|
objects: j,
|
|
5683
5750
|
bounds: u
|
|
@@ -5686,7 +5753,7 @@ class _ {
|
|
|
5686
5753
|
return a.emitError({
|
|
5687
5754
|
origin: "TemplateManager",
|
|
5688
5755
|
method: "applyTemplate",
|
|
5689
|
-
code:
|
|
5756
|
+
code: St.TEMPLATE_MANAGER.APPLY_FAILED,
|
|
5690
5757
|
message: "Ошибка применения шаблона",
|
|
5691
5758
|
data: {
|
|
5692
5759
|
templateId: l,
|
|
@@ -5702,7 +5769,7 @@ class _ {
|
|
|
5702
5769
|
* Подготавливает объекты для сериализации.
|
|
5703
5770
|
*/
|
|
5704
5771
|
static _collectObjects(t) {
|
|
5705
|
-
return t ? t instanceof
|
|
5772
|
+
return t ? t instanceof F ? t.getObjects() : [t] : [];
|
|
5706
5773
|
}
|
|
5707
5774
|
/**
|
|
5708
5775
|
* Возвращает габариты объекта.
|
|
@@ -5726,15 +5793,15 @@ class _ {
|
|
|
5726
5793
|
* Превращает plain-описание объектов в Fabric объекты.
|
|
5727
5794
|
*/
|
|
5728
5795
|
static _enlivenObjects(t) {
|
|
5729
|
-
return
|
|
5730
|
-
return (yield Promise.all(t.map((s) =>
|
|
5731
|
-
if (
|
|
5732
|
-
const i = yield
|
|
5796
|
+
return W(this, null, function* () {
|
|
5797
|
+
return (yield Promise.all(t.map((s) => W(null, null, function* () {
|
|
5798
|
+
if (x._hasSerializedSvgMarkup(s)) {
|
|
5799
|
+
const i = yield x._reviveSvgObject(s);
|
|
5733
5800
|
if (i)
|
|
5734
|
-
return
|
|
5801
|
+
return x._restoreImageScale({ revived: i, serialized: s }), i;
|
|
5735
5802
|
}
|
|
5736
|
-
const n = yield
|
|
5737
|
-
return o ? (
|
|
5803
|
+
const n = yield ht.enlivenObjects([s]), o = n == null ? void 0 : n[0];
|
|
5804
|
+
return o ? (x._restoreImageScale({ revived: o, serialized: s }), o) : null;
|
|
5738
5805
|
})))).filter((s) => !!s);
|
|
5739
5806
|
});
|
|
5740
5807
|
}
|
|
@@ -5762,22 +5829,22 @@ class _ {
|
|
|
5762
5829
|
naturalHeight: 0,
|
|
5763
5830
|
width: 0,
|
|
5764
5831
|
height: 0
|
|
5765
|
-
}, p = J({ value: l || f || c.width, fallback: 0 }), m = J({ value: u || g || c.height, fallback: 0 }), v = J({ value: n, fallback: p }), w = J({ value: o, fallback: m }), A = J({ value: i, fallback: c.scaleX || 1 }), y = J({ value: a, fallback: c.scaleY || 1 }),
|
|
5766
|
-
if (
|
|
5767
|
-
c.set(
|
|
5832
|
+
}, p = J({ value: l || f || c.width, fallback: 0 }), m = J({ value: u || g || c.height, fallback: 0 }), v = J({ value: n, fallback: p }), w = J({ value: o, fallback: m }), A = J({ value: i, fallback: c.scaleX || 1 }), y = J({ value: a, fallback: c.scaleY || 1 }), M = v * A, j = w * y, C = p > 0, S = m > 0, E = M > 0, b = j > 0, I = x._resolveImageFit({ customData: r }), T = {};
|
|
5833
|
+
if (C && (T.width = p), S && (T.height = m), !C || !S) {
|
|
5834
|
+
c.set(T);
|
|
5768
5835
|
return;
|
|
5769
5836
|
}
|
|
5770
|
-
if (
|
|
5771
|
-
const
|
|
5772
|
-
|
|
5837
|
+
if (I === "stretch") {
|
|
5838
|
+
const B = E ? M / p : null, N = b ? j / m : null;
|
|
5839
|
+
B && B > 0 && (T.scaleX = B), N && N > 0 && (T.scaleY = N), c.set(T);
|
|
5773
5840
|
return;
|
|
5774
5841
|
}
|
|
5775
|
-
if (!
|
|
5776
|
-
c.set(
|
|
5842
|
+
if (!E || !b) {
|
|
5843
|
+
c.set(T);
|
|
5777
5844
|
return;
|
|
5778
5845
|
}
|
|
5779
|
-
const
|
|
5780
|
-
Number.isFinite(
|
|
5846
|
+
const _ = Math.min(M / p, j / m);
|
|
5847
|
+
Number.isFinite(_) && _ > 0 && (T.scaleX = _, T.scaleY = _), c.set(T);
|
|
5781
5848
|
}
|
|
5782
5849
|
/**
|
|
5783
5850
|
* Определяет режим вписывания изображения при восстановлении.
|
|
@@ -5799,12 +5866,12 @@ class _ {
|
|
|
5799
5866
|
* Восстанавливает SVG-объект из компактного описания.
|
|
5800
5867
|
*/
|
|
5801
5868
|
static _reviveSvgObject(t) {
|
|
5802
|
-
return
|
|
5869
|
+
return W(this, null, function* () {
|
|
5803
5870
|
const e = typeof t.svgMarkup == "string" ? t.svgMarkup : null;
|
|
5804
5871
|
if (!e) return null;
|
|
5805
5872
|
try {
|
|
5806
|
-
const s = yield ys(e), n =
|
|
5807
|
-
|
|
5873
|
+
const s = yield ys(e), n = ht.groupSVGElements(s.objects, s.options), o = yield ht.enlivenObjectEnlivables(
|
|
5874
|
+
x._prepareSerializableProps(t)
|
|
5808
5875
|
);
|
|
5809
5876
|
return n.set(o), n.setCoords(), n;
|
|
5810
5877
|
} catch (s) {
|
|
@@ -5816,7 +5883,7 @@ class _ {
|
|
|
5816
5883
|
* Убирает технические поля сериализации, оставляя только применимые свойства.
|
|
5817
5884
|
*/
|
|
5818
5885
|
static _prepareSerializableProps(t) {
|
|
5819
|
-
const e =
|
|
5886
|
+
const e = z({}, t);
|
|
5820
5887
|
return delete e.svgMarkup, delete e.objects, delete e.path, delete e.paths, delete e.type, delete e.version, e;
|
|
5821
5888
|
}
|
|
5822
5889
|
/**
|
|
@@ -5868,17 +5935,17 @@ class _ {
|
|
|
5868
5935
|
baseHeight: i,
|
|
5869
5936
|
useRelativePositions: r,
|
|
5870
5937
|
centerKeys: {
|
|
5871
|
-
x:
|
|
5872
|
-
y:
|
|
5938
|
+
x: Qt,
|
|
5939
|
+
y: be
|
|
5873
5940
|
}
|
|
5874
|
-
}), { scaleX: u, scaleY: f } = t, g = J({ value: u, fallback: 1 }), p = J({ value: f, fallback: 1 }), m =
|
|
5941
|
+
}), { scaleX: u, scaleY: f } = t, g = J({ value: u, fallback: 1 }), p = J({ value: f, fallback: 1 }), m = x._getPositioningBounds({
|
|
5875
5942
|
bounds: s,
|
|
5876
5943
|
baseWidth: o,
|
|
5877
5944
|
baseHeight: i,
|
|
5878
5945
|
scale: e,
|
|
5879
5946
|
useRelativePositions: r,
|
|
5880
|
-
anchorX:
|
|
5881
|
-
anchorY:
|
|
5947
|
+
anchorX: x._resolveAnchor(c, le),
|
|
5948
|
+
anchorY: x._resolveAnchor(c, Me)
|
|
5882
5949
|
}), v = hn({
|
|
5883
5950
|
normalizedX: d,
|
|
5884
5951
|
normalizedY: l,
|
|
@@ -5889,7 +5956,7 @@ class _ {
|
|
|
5889
5956
|
t.set({
|
|
5890
5957
|
scaleX: w,
|
|
5891
5958
|
scaleY: A
|
|
5892
|
-
}), t.setPositionByOrigin(v, "center", "center"), t.setCoords(), delete c[
|
|
5959
|
+
}), t.setPositionByOrigin(v, "center", "center"), t.setCoords(), delete c[Qt], delete c[be], delete c[le], delete c[Me];
|
|
5893
5960
|
}
|
|
5894
5961
|
/**
|
|
5895
5962
|
* Возвращает bounds, в которых должны позиционироваться нормализованные объекты.
|
|
@@ -5905,7 +5972,7 @@ class _ {
|
|
|
5905
5972
|
anchorY: a
|
|
5906
5973
|
}) {
|
|
5907
5974
|
if (!o) return t;
|
|
5908
|
-
const r = (e || t.width) * n, c = (s || t.height) * n, d = t.width - r, l = t.height - c, u = t.left +
|
|
5975
|
+
const r = (e || t.width) * n, c = (s || t.height) * n, d = t.width - r, l = t.height - c, u = t.left + x._calculateAnchorOffset(i, d), f = t.top + x._calculateAnchorOffset(a, l);
|
|
5909
5976
|
return {
|
|
5910
5977
|
left: u,
|
|
5911
5978
|
top: f,
|
|
@@ -5936,8 +6003,8 @@ class _ {
|
|
|
5936
6003
|
meta: t,
|
|
5937
6004
|
fallback: e
|
|
5938
6005
|
}) {
|
|
5939
|
-
const { width: s, height: n } = e, r = t || {}, { baseWidth: o = s, baseHeight: i = n } = r, a =
|
|
5940
|
-
return
|
|
6006
|
+
const { width: s, height: n } = e, r = t || {}, { baseWidth: o = s, baseHeight: i = n } = r, a = gt(r, ["baseWidth", "baseHeight"]);
|
|
6007
|
+
return z({
|
|
5941
6008
|
baseWidth: o,
|
|
5942
6009
|
baseHeight: i
|
|
5943
6010
|
}, a);
|
|
@@ -5964,7 +6031,7 @@ class _ {
|
|
|
5964
6031
|
t.setActiveObject(e[0]);
|
|
5965
6032
|
return;
|
|
5966
6033
|
}
|
|
5967
|
-
const s = new
|
|
6034
|
+
const s = new F(e, { canvas: t });
|
|
5968
6035
|
t.setActiveObject(s);
|
|
5969
6036
|
}
|
|
5970
6037
|
/**
|
|
@@ -5974,12 +6041,12 @@ class _ {
|
|
|
5974
6041
|
object: t,
|
|
5975
6042
|
baseWidth: e
|
|
5976
6043
|
}) {
|
|
5977
|
-
var
|
|
5978
|
-
if (!(t instanceof
|
|
6044
|
+
var H, Z;
|
|
6045
|
+
if (!(t instanceof at)) return;
|
|
5979
6046
|
const s = typeof t.text == "string" ? t.text : "";
|
|
5980
6047
|
if (!s) return;
|
|
5981
6048
|
const n = J({
|
|
5982
|
-
value: (
|
|
6049
|
+
value: (Z = (H = this.editor) == null ? void 0 : H.montageArea) == null ? void 0 : Z.width,
|
|
5983
6050
|
fallback: 0
|
|
5984
6051
|
}), {
|
|
5985
6052
|
width: o = 0,
|
|
@@ -5988,16 +6055,16 @@ class _ {
|
|
|
5988
6055
|
} = t, r = J({ value: e, fallback: 0 }), c = t, d = J({ value: c.paddingLeft, fallback: 0 }), l = J({ value: c.paddingRight, fallback: 0 }), u = J({ value: i, fallback: 1 }), f = J({ value: a, fallback: 0 }) * u, g = J({ value: o, fallback: 0 }), p = g * u, m = d * u, v = l * u, w = p + m + v + f;
|
|
5989
6056
|
if (!n || !g || !r) return;
|
|
5990
6057
|
t.setCoords();
|
|
5991
|
-
const A = t, y = A[
|
|
6058
|
+
const A = t, y = A[Qt], M = typeof y == "number" ? y : null, j = x._resolveAnchor(A, le), C = w / r, S = M !== null ? M - C / 2 : null, E = M !== null ? M + C / 2 : null, b = t.getCenterPoint();
|
|
5992
6059
|
t.set("width", n), t.initDimensions();
|
|
5993
|
-
const
|
|
6060
|
+
const I = x._getLongestLineWidth({
|
|
5994
6061
|
textbox: t,
|
|
5995
6062
|
text: s
|
|
5996
|
-
}),
|
|
5997
|
-
t.set("width",
|
|
5998
|
-
const
|
|
5999
|
-
let N =
|
|
6000
|
-
j === "start" && S !== null ? N = Math.max(0, S) +
|
|
6063
|
+
}), T = I > g ? I + 1 : g;
|
|
6064
|
+
t.set("width", T), t.initDimensions(), t.setPositionByOrigin(b, "center", "center"), t.setCoords();
|
|
6065
|
+
const B = (T * u + m + v + f) / r;
|
|
6066
|
+
let N = M;
|
|
6067
|
+
j === "start" && S !== null ? N = Math.max(0, S) + B / 2 : j === "end" && E !== null && (N = Math.min(1, E) - B / 2), typeof N == "number" && (A[Qt] = N);
|
|
6001
6068
|
}
|
|
6002
6069
|
/**
|
|
6003
6070
|
* Возвращает ширину самой длинной строки текстового объекта.
|
|
@@ -6027,9 +6094,9 @@ class _ {
|
|
|
6027
6094
|
baseHeight: n,
|
|
6028
6095
|
montageArea: o
|
|
6029
6096
|
}) {
|
|
6030
|
-
const i = t.toDatalessObject([...
|
|
6031
|
-
if (
|
|
6032
|
-
const y =
|
|
6097
|
+
const i = t.toDatalessObject([...os]);
|
|
6098
|
+
if (x._isSvgObject(t)) {
|
|
6099
|
+
const y = x._extractSvgMarkup(t);
|
|
6033
6100
|
y && (i.svgMarkup = y, delete i.objects, delete i.path);
|
|
6034
6101
|
}
|
|
6035
6102
|
if (!e) return i;
|
|
@@ -6049,11 +6116,11 @@ class _ {
|
|
|
6049
6116
|
y: (y.y - r) / f
|
|
6050
6117
|
};
|
|
6051
6118
|
})(), m = (l.left - a) / u, v = (l.top - r) / f, w = m + l.width / u, A = v + l.height / f;
|
|
6052
|
-
return i[
|
|
6119
|
+
return i[Qt] = p.x, i[be] = p.y, i[le] = x._detectAnchor({
|
|
6053
6120
|
center: p.x,
|
|
6054
6121
|
start: m,
|
|
6055
6122
|
end: w
|
|
6056
|
-
}), i[
|
|
6123
|
+
}), i[Me] = x._detectAnchor({
|
|
6057
6124
|
center: p.y,
|
|
6058
6125
|
start: v,
|
|
6059
6126
|
end: A
|
|
@@ -6073,13 +6140,13 @@ class _ {
|
|
|
6073
6140
|
* Применяет фоновый объект шаблона к текущему холсту через BackgroundManager.
|
|
6074
6141
|
*/
|
|
6075
6142
|
static _applyBackgroundFromObject(n) {
|
|
6076
|
-
return
|
|
6143
|
+
return W(this, arguments, function* ({
|
|
6077
6144
|
backgroundObject: t,
|
|
6078
6145
|
backgroundManager: e,
|
|
6079
6146
|
errorManager: s
|
|
6080
6147
|
}) {
|
|
6081
6148
|
try {
|
|
6082
|
-
const { fill: o, customData: i } = t, { backgroundType: a } = t, r =
|
|
6149
|
+
const { fill: o, customData: i } = t, { backgroundType: a } = t, r = x._cloneCustomData(i);
|
|
6083
6150
|
if (a === "color" && typeof o == "string")
|
|
6084
6151
|
return e.setColorBackground({
|
|
6085
6152
|
color: o,
|
|
@@ -6098,7 +6165,7 @@ class _ {
|
|
|
6098
6165
|
}), !0;
|
|
6099
6166
|
}
|
|
6100
6167
|
if (a === "image") {
|
|
6101
|
-
const c =
|
|
6168
|
+
const c = x._getImageSource(t);
|
|
6102
6169
|
if (c)
|
|
6103
6170
|
return yield e.setImageBackground({
|
|
6104
6171
|
imageSource: c,
|
|
@@ -6111,7 +6178,7 @@ class _ {
|
|
|
6111
6178
|
s.emitWarning({
|
|
6112
6179
|
origin: "TemplateManager",
|
|
6113
6180
|
method: "applyTemplate",
|
|
6114
|
-
code:
|
|
6181
|
+
code: St.TEMPLATE_MANAGER.APPLY_FAILED,
|
|
6115
6182
|
message: "Не удалось применить фон из шаблона",
|
|
6116
6183
|
data: o
|
|
6117
6184
|
});
|
|
@@ -6141,7 +6208,7 @@ class _ {
|
|
|
6141
6208
|
*/
|
|
6142
6209
|
static _cloneCustomData(t) {
|
|
6143
6210
|
if (!(!t || typeof t != "object"))
|
|
6144
|
-
return
|
|
6211
|
+
return z({}, t);
|
|
6145
6212
|
}
|
|
6146
6213
|
/**
|
|
6147
6214
|
* Извлекает src изображения из FabricImage или его исходного элемента.
|
|
@@ -6167,10 +6234,10 @@ class _ {
|
|
|
6167
6234
|
*/
|
|
6168
6235
|
// eslint-disable-next-line class-methods-use-this
|
|
6169
6236
|
enlivenObjectEnlivables(t) {
|
|
6170
|
-
return
|
|
6237
|
+
return ht.enlivenObjectEnlivables(t);
|
|
6171
6238
|
}
|
|
6172
6239
|
}
|
|
6173
|
-
const pn = 5,
|
|
6240
|
+
const pn = 5, is = "#3D8BF4", Ie = 1, he = 1, Qe = ({
|
|
6174
6241
|
anchors: h,
|
|
6175
6242
|
positions: t,
|
|
6176
6243
|
threshold: e
|
|
@@ -6190,11 +6257,11 @@ const pn = 5, os = "#3D8BF4", Ae = 1, ce = 1, Je = ({
|
|
|
6190
6257
|
threshold: t,
|
|
6191
6258
|
anchors: e
|
|
6192
6259
|
}) => {
|
|
6193
|
-
const { left: s, right: n, centerX: o, top: i, bottom: a, centerY: r } = h, c =
|
|
6260
|
+
const { left: s, right: n, centerX: o, top: i, bottom: a, centerY: r } = h, c = Qe({
|
|
6194
6261
|
anchors: e.vertical,
|
|
6195
6262
|
positions: [s, o, n],
|
|
6196
6263
|
threshold: t
|
|
6197
|
-
}), d =
|
|
6264
|
+
}), d = Qe({
|
|
6198
6265
|
anchors: e.horizontal,
|
|
6199
6266
|
positions: [i, r, a],
|
|
6200
6267
|
threshold: t
|
|
@@ -6210,7 +6277,7 @@ const pn = 5, os = "#3D8BF4", Ae = 1, ce = 1, Je = ({
|
|
|
6210
6277
|
deltaY: d.delta,
|
|
6211
6278
|
guides: l
|
|
6212
6279
|
};
|
|
6213
|
-
},
|
|
6280
|
+
}, as = ({
|
|
6214
6281
|
activeBounds: h,
|
|
6215
6282
|
aligned: t,
|
|
6216
6283
|
threshold: e,
|
|
@@ -6301,47 +6368,47 @@ const pn = 5, os = "#3D8BF4", Ae = 1, ce = 1, Je = ({
|
|
|
6301
6368
|
...c.map((y) => ({ bounds: y, isActive: !1 })),
|
|
6302
6369
|
{ bounds: h, isActive: !0 }
|
|
6303
6370
|
];
|
|
6304
|
-
d.sort((y,
|
|
6371
|
+
d.sort((y, M) => y.bounds.top - M.bounds.top);
|
|
6305
6372
|
const l = d.findIndex((y) => y.isActive);
|
|
6306
6373
|
if (l === -1)
|
|
6307
6374
|
return { delta: 0, guide: null };
|
|
6308
6375
|
const u = d[l - 1], f = d[l - 2], g = d[l + 1], p = d[l + 2], m = [], v = i - o;
|
|
6309
6376
|
if (u && f) {
|
|
6310
|
-
const { bounds: y } = u, { bounds:
|
|
6377
|
+
const { bounds: y } = u, { bounds: M } = f, j = y.top - M.bottom, C = o - y.bottom, S = Math.abs(C - j);
|
|
6311
6378
|
if (S <= e) {
|
|
6312
|
-
const
|
|
6379
|
+
const E = j - C, b = o + E, I = {
|
|
6313
6380
|
type: "vertical",
|
|
6314
6381
|
axis: n,
|
|
6315
|
-
refStart:
|
|
6382
|
+
refStart: M.bottom,
|
|
6316
6383
|
refEnd: y.top,
|
|
6317
6384
|
activeStart: y.bottom,
|
|
6318
|
-
activeEnd:
|
|
6385
|
+
activeEnd: b,
|
|
6319
6386
|
distance: j
|
|
6320
6387
|
};
|
|
6321
|
-
m.push({ delta:
|
|
6388
|
+
m.push({ delta: E, guide: I, diff: S });
|
|
6322
6389
|
}
|
|
6323
6390
|
}
|
|
6324
6391
|
if (g && p) {
|
|
6325
|
-
const { bounds: y } = g, { bounds:
|
|
6392
|
+
const { bounds: y } = g, { bounds: M } = p, j = M.top - y.bottom, C = y.top - i, S = Math.abs(C - j);
|
|
6326
6393
|
if (S <= e) {
|
|
6327
|
-
const
|
|
6394
|
+
const E = C - j, b = i + E, I = {
|
|
6328
6395
|
type: "vertical",
|
|
6329
6396
|
axis: n,
|
|
6330
6397
|
refStart: y.bottom,
|
|
6331
|
-
refEnd:
|
|
6332
|
-
activeStart:
|
|
6398
|
+
refEnd: M.top,
|
|
6399
|
+
activeStart: b,
|
|
6333
6400
|
activeEnd: y.top,
|
|
6334
6401
|
distance: j
|
|
6335
6402
|
};
|
|
6336
|
-
m.push({ delta:
|
|
6403
|
+
m.push({ delta: E, guide: I, diff: S });
|
|
6337
6404
|
}
|
|
6338
6405
|
}
|
|
6339
6406
|
if (u && g) {
|
|
6340
|
-
const { bounds: y } = u, { bounds:
|
|
6341
|
-
if (
|
|
6342
|
-
const S =
|
|
6343
|
-
if (
|
|
6344
|
-
const
|
|
6407
|
+
const { bounds: y } = u, { bounds: M } = g, C = M.top - y.bottom - v;
|
|
6408
|
+
if (C >= 0) {
|
|
6409
|
+
const S = C / 2, E = o - y.bottom, b = M.top - i, I = Math.abs(E - S), T = Math.abs(b - S), _ = Math.max(I, T);
|
|
6410
|
+
if (_ <= e) {
|
|
6411
|
+
const B = S - E, N = i + B, H = {
|
|
6345
6412
|
type: "vertical",
|
|
6346
6413
|
axis: n,
|
|
6347
6414
|
refStart: y.bottom,
|
|
@@ -6350,11 +6417,11 @@ const pn = 5, os = "#3D8BF4", Ae = 1, ce = 1, Je = ({
|
|
|
6350
6417
|
activeEnd: N + S,
|
|
6351
6418
|
distance: S
|
|
6352
6419
|
};
|
|
6353
|
-
m.push({ delta:
|
|
6420
|
+
m.push({ delta: B, guide: H, diff: _ });
|
|
6354
6421
|
}
|
|
6355
6422
|
}
|
|
6356
6423
|
}
|
|
6357
|
-
const w =
|
|
6424
|
+
const w = as({
|
|
6358
6425
|
activeBounds: h,
|
|
6359
6426
|
aligned: c,
|
|
6360
6427
|
threshold: e,
|
|
@@ -6363,7 +6430,7 @@ const pn = 5, os = "#3D8BF4", Ae = 1, ce = 1, Je = ({
|
|
|
6363
6430
|
});
|
|
6364
6431
|
if (m.push(...w), !m.length)
|
|
6365
6432
|
return { delta: 0, guide: null };
|
|
6366
|
-
const A = m.reduce((y,
|
|
6433
|
+
const A = m.reduce((y, M) => M.diff < y.diff ? M : y, m[0]);
|
|
6367
6434
|
return {
|
|
6368
6435
|
delta: A.delta,
|
|
6369
6436
|
guide: A.guide
|
|
@@ -6387,47 +6454,47 @@ const pn = 5, os = "#3D8BF4", Ae = 1, ce = 1, Je = ({
|
|
|
6387
6454
|
...c.map((y) => ({ bounds: y, isActive: !1 })),
|
|
6388
6455
|
{ bounds: h, isActive: !0 }
|
|
6389
6456
|
];
|
|
6390
|
-
d.sort((y,
|
|
6457
|
+
d.sort((y, M) => y.bounds.left - M.bounds.left);
|
|
6391
6458
|
const l = d.findIndex((y) => y.isActive);
|
|
6392
6459
|
if (l === -1)
|
|
6393
6460
|
return { delta: 0, guide: null };
|
|
6394
6461
|
const u = d[l - 1], f = d[l - 2], g = d[l + 1], p = d[l + 2], m = [], v = i - o;
|
|
6395
6462
|
if (u && f) {
|
|
6396
|
-
const { bounds: y } = u, { bounds:
|
|
6463
|
+
const { bounds: y } = u, { bounds: M } = f, j = y.left - M.right, C = o - y.right, S = Math.abs(C - j);
|
|
6397
6464
|
if (S <= e) {
|
|
6398
|
-
const
|
|
6465
|
+
const E = j - C, b = o + E, I = {
|
|
6399
6466
|
type: "horizontal",
|
|
6400
6467
|
axis: n,
|
|
6401
|
-
refStart:
|
|
6468
|
+
refStart: M.right,
|
|
6402
6469
|
refEnd: y.left,
|
|
6403
6470
|
activeStart: y.right,
|
|
6404
|
-
activeEnd:
|
|
6471
|
+
activeEnd: b,
|
|
6405
6472
|
distance: j
|
|
6406
6473
|
};
|
|
6407
|
-
m.push({ delta:
|
|
6474
|
+
m.push({ delta: E, guide: I, diff: S });
|
|
6408
6475
|
}
|
|
6409
6476
|
}
|
|
6410
6477
|
if (g && p) {
|
|
6411
|
-
const { bounds: y } = g, { bounds:
|
|
6478
|
+
const { bounds: y } = g, { bounds: M } = p, j = M.left - y.right, C = y.left - i, S = Math.abs(C - j);
|
|
6412
6479
|
if (S <= e) {
|
|
6413
|
-
const
|
|
6480
|
+
const E = C - j, b = i + E, I = {
|
|
6414
6481
|
type: "horizontal",
|
|
6415
6482
|
axis: n,
|
|
6416
6483
|
refStart: y.right,
|
|
6417
|
-
refEnd:
|
|
6418
|
-
activeStart:
|
|
6484
|
+
refEnd: M.left,
|
|
6485
|
+
activeStart: b,
|
|
6419
6486
|
activeEnd: y.left,
|
|
6420
6487
|
distance: j
|
|
6421
6488
|
};
|
|
6422
|
-
m.push({ delta:
|
|
6489
|
+
m.push({ delta: E, guide: I, diff: S });
|
|
6423
6490
|
}
|
|
6424
6491
|
}
|
|
6425
6492
|
if (u && g) {
|
|
6426
|
-
const { bounds: y } = u, { bounds:
|
|
6427
|
-
if (
|
|
6428
|
-
const S =
|
|
6429
|
-
if (
|
|
6430
|
-
const
|
|
6493
|
+
const { bounds: y } = u, { bounds: M } = g, C = M.left - y.right - v;
|
|
6494
|
+
if (C >= 0) {
|
|
6495
|
+
const S = C / 2, E = o - y.right, b = M.left - i, I = Math.abs(E - S), T = Math.abs(b - S), _ = Math.max(I, T);
|
|
6496
|
+
if (_ <= e) {
|
|
6497
|
+
const B = S - E, N = i + B, H = {
|
|
6431
6498
|
type: "horizontal",
|
|
6432
6499
|
axis: n,
|
|
6433
6500
|
refStart: y.right,
|
|
@@ -6436,11 +6503,11 @@ const pn = 5, os = "#3D8BF4", Ae = 1, ce = 1, Je = ({
|
|
|
6436
6503
|
activeEnd: N + S,
|
|
6437
6504
|
distance: S
|
|
6438
6505
|
};
|
|
6439
|
-
m.push({ delta:
|
|
6506
|
+
m.push({ delta: B, guide: H, diff: _ });
|
|
6440
6507
|
}
|
|
6441
6508
|
}
|
|
6442
6509
|
}
|
|
6443
|
-
const w =
|
|
6510
|
+
const w = as({
|
|
6444
6511
|
activeBounds: h,
|
|
6445
6512
|
aligned: c,
|
|
6446
6513
|
threshold: e,
|
|
@@ -6449,7 +6516,7 @@ const pn = 5, os = "#3D8BF4", Ae = 1, ce = 1, Je = ({
|
|
|
6449
6516
|
});
|
|
6450
6517
|
if (m.push(...w), !m.length)
|
|
6451
6518
|
return { delta: 0, guide: null };
|
|
6452
|
-
const A = m.reduce((y,
|
|
6519
|
+
const A = m.reduce((y, M) => M.diff < y.diff ? M : y, m[0]);
|
|
6453
6520
|
return {
|
|
6454
6521
|
delta: A.delta,
|
|
6455
6522
|
guide: A.guide
|
|
@@ -6486,7 +6553,7 @@ const pn = 5, os = "#3D8BF4", Ae = 1, ce = 1, Je = ({
|
|
|
6486
6553
|
}) => {
|
|
6487
6554
|
const i = Math.min(o, s / 2, n / 2);
|
|
6488
6555
|
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 + n - i), h.quadraticCurveTo(t + s, e + n, t + s - i, e + n), h.lineTo(t + i, e + n), h.quadraticCurveTo(t, e + n, t, e + n - i), h.lineTo(t, e + i), h.quadraticCurveTo(t, e, t + i, e), h.closePath();
|
|
6489
|
-
},
|
|
6556
|
+
}, Ee = ({
|
|
6490
6557
|
context: h,
|
|
6491
6558
|
type: t,
|
|
6492
6559
|
axis: e,
|
|
@@ -6503,17 +6570,17 @@ const pn = 5, os = "#3D8BF4", Ae = 1, ce = 1, Je = ({
|
|
|
6503
6570
|
offsetAlongAxis: f = 0,
|
|
6504
6571
|
offsetPerpendicular: g = 0
|
|
6505
6572
|
}) => {
|
|
6506
|
-
const p = i || 1, m = 12 / p, v = l / p, w = u / p, A = (s + n) / 2 + f, y = t === "vertical" ? e + g : A,
|
|
6573
|
+
const p = i || 1, m = 12 / p, v = l / p, w = u / p, A = (s + n) / 2 + f, y = t === "vertical" ? e + g : A, M = t === "vertical" ? A : e + g;
|
|
6507
6574
|
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";
|
|
6508
|
-
const
|
|
6575
|
+
const C = h.measureText(o).width + v * 2, S = m + v * 2, E = y - C / 2, b = M - S / 2;
|
|
6509
6576
|
h.beginPath(), Mn({
|
|
6510
6577
|
context: h,
|
|
6511
|
-
x:
|
|
6512
|
-
y:
|
|
6513
|
-
width:
|
|
6578
|
+
x: E,
|
|
6579
|
+
y: b,
|
|
6580
|
+
width: C,
|
|
6514
6581
|
height: S,
|
|
6515
6582
|
radius: w
|
|
6516
|
-
}), h.fill(), h.fillStyle = r, h.fillText(o, y,
|
|
6583
|
+
}), h.fill(), h.fillStyle = r, h.fillText(o, y, M), h.restore();
|
|
6517
6584
|
}, wn = ({
|
|
6518
6585
|
context: h,
|
|
6519
6586
|
guide: t,
|
|
@@ -6529,8 +6596,8 @@ const pn = 5, os = "#3D8BF4", Ae = 1, ce = 1, Je = ({
|
|
|
6529
6596
|
distance: c
|
|
6530
6597
|
} = t, d = Math.round(c).toString();
|
|
6531
6598
|
h.beginPath(), s === "vertical" ? (h.moveTo(n, o), h.lineTo(n, i), h.moveTo(n, a), h.lineTo(n, r)) : (h.moveTo(o, n), h.lineTo(i, n), h.moveTo(a, n), h.lineTo(r, n)), h.stroke();
|
|
6532
|
-
const l =
|
|
6533
|
-
|
|
6599
|
+
const l = is;
|
|
6600
|
+
Ee({
|
|
6534
6601
|
context: h,
|
|
6535
6602
|
type: s,
|
|
6536
6603
|
axis: n,
|
|
@@ -6539,8 +6606,8 @@ const pn = 5, os = "#3D8BF4", Ae = 1, ce = 1, Je = ({
|
|
|
6539
6606
|
text: d,
|
|
6540
6607
|
zoom: e,
|
|
6541
6608
|
color: l,
|
|
6542
|
-
lineWidth:
|
|
6543
|
-
}),
|
|
6609
|
+
lineWidth: Ie
|
|
6610
|
+
}), Ee({
|
|
6544
6611
|
context: h,
|
|
6545
6612
|
type: s,
|
|
6546
6613
|
axis: n,
|
|
@@ -6549,9 +6616,9 @@ const pn = 5, os = "#3D8BF4", Ae = 1, ce = 1, Je = ({
|
|
|
6549
6616
|
text: d,
|
|
6550
6617
|
zoom: e,
|
|
6551
6618
|
color: l,
|
|
6552
|
-
lineWidth:
|
|
6619
|
+
lineWidth: Ie
|
|
6553
6620
|
});
|
|
6554
|
-
},
|
|
6621
|
+
}, $e = ({
|
|
6555
6622
|
anchors: h,
|
|
6556
6623
|
bounds: t
|
|
6557
6624
|
}) => {
|
|
@@ -6564,7 +6631,7 @@ const pn = 5, os = "#3D8BF4", Ae = 1, ce = 1, Je = ({
|
|
|
6564
6631
|
centerY: a
|
|
6565
6632
|
} = t;
|
|
6566
6633
|
h.vertical.push(e, n, s), h.horizontal.push(o, a, i);
|
|
6567
|
-
},
|
|
6634
|
+
}, ts = ({
|
|
6568
6635
|
bounds: h,
|
|
6569
6636
|
type: t,
|
|
6570
6637
|
primaryStart: e,
|
|
@@ -6594,24 +6661,24 @@ const pn = 5, os = "#3D8BF4", Ae = 1, ce = 1, Je = ({
|
|
|
6594
6661
|
}, Sn = ({
|
|
6595
6662
|
bounds: h
|
|
6596
6663
|
}) => {
|
|
6597
|
-
const t =
|
|
6664
|
+
const t = ts({
|
|
6598
6665
|
bounds: h,
|
|
6599
6666
|
type: "vertical",
|
|
6600
6667
|
primaryStart: "top",
|
|
6601
6668
|
primaryEnd: "bottom"
|
|
6602
|
-
}), e =
|
|
6669
|
+
}), e = ts({
|
|
6603
6670
|
bounds: h,
|
|
6604
6671
|
type: "horizontal",
|
|
6605
6672
|
primaryStart: "left",
|
|
6606
6673
|
primaryEnd: "right"
|
|
6607
6674
|
});
|
|
6608
6675
|
return { vertical: t, horizontal: e };
|
|
6609
|
-
}, An = ["montage-area", "background", "interaction-blocker"],
|
|
6676
|
+
}, An = ["montage-area", "background", "interaction-blocker"], rs = ({
|
|
6610
6677
|
activeObject: h
|
|
6611
6678
|
}) => {
|
|
6612
6679
|
const t = /* @__PURE__ */ new Set();
|
|
6613
|
-
return h && (t.add(h), h instanceof
|
|
6614
|
-
},
|
|
6680
|
+
return h && (t.add(h), h instanceof F && h.getObjects().forEach((e) => t.add(e))), t;
|
|
6681
|
+
}, cs = ({
|
|
6615
6682
|
object: h,
|
|
6616
6683
|
excluded: t,
|
|
6617
6684
|
ignoredIds: e = An
|
|
@@ -6680,7 +6747,7 @@ class jn {
|
|
|
6680
6747
|
return;
|
|
6681
6748
|
}
|
|
6682
6749
|
!this.anchors.vertical.length && !this.anchors.horizontal.length && this._cacheAnchors({ activeObject: e });
|
|
6683
|
-
let o =
|
|
6750
|
+
let o = mt({ object: e });
|
|
6684
6751
|
if (!o) {
|
|
6685
6752
|
this._clearGuides();
|
|
6686
6753
|
return;
|
|
@@ -6695,9 +6762,9 @@ class jn {
|
|
|
6695
6762
|
e.set({
|
|
6696
6763
|
left: v + d,
|
|
6697
6764
|
top: w + l
|
|
6698
|
-
}), e.setCoords(), o = (p =
|
|
6765
|
+
}), e.setCoords(), o = (p = mt({ object: e })) != null ? p : o;
|
|
6699
6766
|
}
|
|
6700
|
-
const f = this.cachedTargetBounds.length ? this.cachedTargetBounds : this._collectTargets({ activeObject: e }).map((v) =>
|
|
6767
|
+
const f = this.cachedTargetBounds.length ? this.cachedTargetBounds : this._collectTargets({ activeObject: e }).map((v) => mt({ object: v })).filter((v) => !!v), g = bn({
|
|
6701
6768
|
activeBounds: o,
|
|
6702
6769
|
candidates: f,
|
|
6703
6770
|
threshold: r,
|
|
@@ -6708,7 +6775,7 @@ class jn {
|
|
|
6708
6775
|
e.set({
|
|
6709
6776
|
left: v + g.deltaX,
|
|
6710
6777
|
top: w + g.deltaY
|
|
6711
|
-
}), e.setCoords(), o = (m =
|
|
6778
|
+
}), e.setCoords(), o = (m = mt({ object: e })) != null ? m : o;
|
|
6712
6779
|
}
|
|
6713
6780
|
this._applyGuides({
|
|
6714
6781
|
guides: u,
|
|
@@ -6736,7 +6803,7 @@ class jn {
|
|
|
6736
6803
|
const { canvas: t, guideBounds: e } = this, s = t.getSelectionContext();
|
|
6737
6804
|
if (!s) return;
|
|
6738
6805
|
const n = e != null ? e : this._calculateViewportBounds(), { left: o, right: i, top: a, bottom: r } = n, { viewportTransform: c } = t, d = t.getZoom() || 1;
|
|
6739
|
-
s.save(), Array.isArray(c) && s.transform(...c), s.lineWidth =
|
|
6806
|
+
s.save(), Array.isArray(c) && s.transform(...c), s.lineWidth = Ie / d, s.strokeStyle = is, s.setLineDash([4, 4]);
|
|
6740
6807
|
for (const l of this.activeGuides)
|
|
6741
6808
|
s.beginPath(), l.type === "vertical" ? (s.moveTo(l.position, a), s.lineTo(l.position, r)) : (s.moveTo(o, l.position), s.lineTo(i, l.position)), s.stroke();
|
|
6742
6809
|
for (const l of this.activeSpacingGuides)
|
|
@@ -6776,7 +6843,7 @@ class jn {
|
|
|
6776
6843
|
* Применяет шаг перемещения, округляя координаты объекта к сетке MOVE_SNAP_STEP.
|
|
6777
6844
|
*/
|
|
6778
6845
|
_applyMovementStep({ target: t }) {
|
|
6779
|
-
const { left: e = 0, top: s = 0 } = t, n = Math.round(e /
|
|
6846
|
+
const { left: e = 0, top: s = 0 } = t, n = Math.round(e / he) * he, o = Math.round(s / he) * he;
|
|
6780
6847
|
n === e && o === s || (t.set({
|
|
6781
6848
|
left: n,
|
|
6782
6849
|
top: o
|
|
@@ -6788,12 +6855,12 @@ class jn {
|
|
|
6788
6855
|
_cacheAnchors({ activeObject: t }) {
|
|
6789
6856
|
const e = this._collectTargets({ activeObject: t }), s = { vertical: [], horizontal: [] }, n = [];
|
|
6790
6857
|
for (const a of e) {
|
|
6791
|
-
const r =
|
|
6792
|
-
r && (
|
|
6858
|
+
const r = mt({ object: a });
|
|
6859
|
+
r && ($e({ anchors: s, bounds: r }), n.push(r));
|
|
6793
6860
|
}
|
|
6794
|
-
const { montageArea: o } = this.editor, i =
|
|
6861
|
+
const { montageArea: o } = this.editor, i = mt({ object: o });
|
|
6795
6862
|
if (i) {
|
|
6796
|
-
|
|
6863
|
+
$e({ anchors: s, bounds: i });
|
|
6797
6864
|
const { left: a, right: r, top: c, bottom: d } = i;
|
|
6798
6865
|
this.guideBounds = {
|
|
6799
6866
|
left: a,
|
|
@@ -6809,9 +6876,9 @@ class jn {
|
|
|
6809
6876
|
* Собирает объекты, подходящие для прилипания, исключая активный объект и запрещённые id.
|
|
6810
6877
|
*/
|
|
6811
6878
|
_collectTargets({ activeObject: t }) {
|
|
6812
|
-
const e =
|
|
6879
|
+
const e = rs({ activeObject: t }), s = [];
|
|
6813
6880
|
return this.canvas.forEachObject((n) => {
|
|
6814
|
-
|
|
6881
|
+
cs({ object: n, excluded: e }) || s.push(n);
|
|
6815
6882
|
}), s;
|
|
6816
6883
|
}
|
|
6817
6884
|
/**
|
|
@@ -6834,8 +6901,8 @@ class jn {
|
|
|
6834
6901
|
};
|
|
6835
6902
|
}
|
|
6836
6903
|
}
|
|
6837
|
-
const
|
|
6838
|
-
class
|
|
6904
|
+
const es = "#3D8BF4", ss = 1;
|
|
6905
|
+
class Nt {
|
|
6839
6906
|
/**
|
|
6840
6907
|
* Создаёт менеджер измерений и инициализирует события.
|
|
6841
6908
|
*/
|
|
@@ -6940,15 +7007,15 @@ class Dt {
|
|
|
6940
7007
|
this._clearGuides();
|
|
6941
7008
|
return;
|
|
6942
7009
|
}
|
|
6943
|
-
const o =
|
|
7010
|
+
const o = mt({ object: n });
|
|
6944
7011
|
if (!o) {
|
|
6945
7012
|
this._clearGuides();
|
|
6946
7013
|
return;
|
|
6947
7014
|
}
|
|
6948
|
-
const i =
|
|
7015
|
+
const i = Nt._resolveTarget({
|
|
6949
7016
|
event: t,
|
|
6950
7017
|
activeObject: n
|
|
6951
|
-
}), { montageArea: a } = s, r = i != null ? i : a, c = r === a, d =
|
|
7018
|
+
}), { montageArea: a } = s, r = i != null ? i : a, c = r === a, d = mt({ object: r });
|
|
6952
7019
|
if (!d) {
|
|
6953
7020
|
this._clearGuides();
|
|
6954
7021
|
return;
|
|
@@ -6957,7 +7024,7 @@ class Dt {
|
|
|
6957
7024
|
this._clearGuides();
|
|
6958
7025
|
return;
|
|
6959
7026
|
}
|
|
6960
|
-
const u =
|
|
7027
|
+
const u = Nt._buildGuides({
|
|
6961
7028
|
activeBounds: o,
|
|
6962
7029
|
targetBounds: d,
|
|
6963
7030
|
targetIsMontageArea: c
|
|
@@ -6975,8 +7042,8 @@ class Dt {
|
|
|
6975
7042
|
event: t,
|
|
6976
7043
|
activeObject: e
|
|
6977
7044
|
}) {
|
|
6978
|
-
const { target: s } = t, n =
|
|
6979
|
-
return s && !
|
|
7045
|
+
const { target: s } = t, n = rs({ activeObject: e });
|
|
7046
|
+
return s && !cs({ object: s, excluded: n }) ? s : null;
|
|
6980
7047
|
}
|
|
6981
7048
|
/**
|
|
6982
7049
|
* Собирает вертикальные и горизонтальные направляющие расстояний.
|
|
@@ -6986,11 +7053,11 @@ class Dt {
|
|
|
6986
7053
|
targetBounds: e,
|
|
6987
7054
|
targetIsMontageArea: s
|
|
6988
7055
|
}) {
|
|
6989
|
-
const n =
|
|
7056
|
+
const n = Nt._buildHorizontalGuides({
|
|
6990
7057
|
activeBounds: t,
|
|
6991
7058
|
targetBounds: e,
|
|
6992
7059
|
targetIsMontageArea: s
|
|
6993
|
-
}), o =
|
|
7060
|
+
}), o = Nt._buildVerticalGuides({
|
|
6994
7061
|
activeBounds: t,
|
|
6995
7062
|
targetBounds: e,
|
|
6996
7063
|
targetIsMontageArea: s
|
|
@@ -7020,42 +7087,42 @@ class Dt {
|
|
|
7020
7087
|
} = e, p = Math.max(a, u), m = Math.min(r, f), w = m >= p ? (p + m) / 2 : (c + g) / 2;
|
|
7021
7088
|
if (d >= i) {
|
|
7022
7089
|
if (s) return n;
|
|
7023
|
-
const
|
|
7024
|
-
return
|
|
7090
|
+
const I = d - i;
|
|
7091
|
+
return I > 0 && n.push({
|
|
7025
7092
|
type: "horizontal",
|
|
7026
7093
|
axis: w,
|
|
7027
7094
|
start: i,
|
|
7028
7095
|
end: d,
|
|
7029
|
-
distance:
|
|
7096
|
+
distance: I
|
|
7030
7097
|
}), n;
|
|
7031
7098
|
}
|
|
7032
7099
|
if (l <= o) {
|
|
7033
7100
|
if (s) return n;
|
|
7034
|
-
const
|
|
7035
|
-
return
|
|
7101
|
+
const I = o - l;
|
|
7102
|
+
return I > 0 && n.push({
|
|
7036
7103
|
type: "horizontal",
|
|
7037
7104
|
axis: w,
|
|
7038
7105
|
start: l,
|
|
7039
7106
|
end: o,
|
|
7040
|
-
distance:
|
|
7107
|
+
distance: I
|
|
7041
7108
|
}), n;
|
|
7042
7109
|
}
|
|
7043
7110
|
if (!s) return n;
|
|
7044
|
-
const A = o < d, y = i > l,
|
|
7045
|
-
|
|
7111
|
+
const A = o < d, y = i > l, M = Math.min(o, d), j = Math.max(o, d), C = j - M;
|
|
7112
|
+
C > 0 && !A && n.push({
|
|
7046
7113
|
type: "horizontal",
|
|
7047
7114
|
axis: w,
|
|
7048
|
-
start:
|
|
7115
|
+
start: M,
|
|
7049
7116
|
end: j,
|
|
7050
|
-
distance:
|
|
7117
|
+
distance: C
|
|
7051
7118
|
});
|
|
7052
|
-
const S = Math.min(i, l),
|
|
7053
|
-
return
|
|
7119
|
+
const S = Math.min(i, l), E = Math.max(i, l), b = E - S;
|
|
7120
|
+
return b > 0 && !y && n.push({
|
|
7054
7121
|
type: "horizontal",
|
|
7055
7122
|
axis: w,
|
|
7056
7123
|
start: S,
|
|
7057
|
-
end:
|
|
7058
|
-
distance:
|
|
7124
|
+
end: E,
|
|
7125
|
+
distance: b
|
|
7059
7126
|
}), n;
|
|
7060
7127
|
}
|
|
7061
7128
|
/**
|
|
@@ -7081,42 +7148,42 @@ class Dt {
|
|
|
7081
7148
|
} = e, p = Math.max(a, u), m = Math.min(r, f), w = m >= p ? (p + m) / 2 : (c + g) / 2;
|
|
7082
7149
|
if (d >= i) {
|
|
7083
7150
|
if (s) return n;
|
|
7084
|
-
const
|
|
7085
|
-
return
|
|
7151
|
+
const I = d - i;
|
|
7152
|
+
return I > 0 && n.push({
|
|
7086
7153
|
type: "vertical",
|
|
7087
7154
|
axis: w,
|
|
7088
7155
|
start: i,
|
|
7089
7156
|
end: d,
|
|
7090
|
-
distance:
|
|
7157
|
+
distance: I
|
|
7091
7158
|
}), n;
|
|
7092
7159
|
}
|
|
7093
7160
|
if (l <= o) {
|
|
7094
7161
|
if (s) return n;
|
|
7095
|
-
const
|
|
7096
|
-
return
|
|
7162
|
+
const I = o - l;
|
|
7163
|
+
return I > 0 && n.push({
|
|
7097
7164
|
type: "vertical",
|
|
7098
7165
|
axis: w,
|
|
7099
7166
|
start: l,
|
|
7100
7167
|
end: o,
|
|
7101
|
-
distance:
|
|
7168
|
+
distance: I
|
|
7102
7169
|
}), n;
|
|
7103
7170
|
}
|
|
7104
7171
|
if (!s) return n;
|
|
7105
|
-
const A = o < d, y = i > l,
|
|
7106
|
-
|
|
7172
|
+
const A = o < d, y = i > l, M = Math.min(o, d), j = Math.max(o, d), C = j - M;
|
|
7173
|
+
C > 0 && !A && n.push({
|
|
7107
7174
|
type: "vertical",
|
|
7108
7175
|
axis: w,
|
|
7109
|
-
start:
|
|
7176
|
+
start: M,
|
|
7110
7177
|
end: j,
|
|
7111
|
-
distance:
|
|
7178
|
+
distance: C
|
|
7112
7179
|
});
|
|
7113
|
-
const S = Math.min(i, l),
|
|
7114
|
-
return
|
|
7180
|
+
const S = Math.min(i, l), E = Math.max(i, l), b = E - S;
|
|
7181
|
+
return b > 0 && !y && n.push({
|
|
7115
7182
|
type: "vertical",
|
|
7116
7183
|
axis: w,
|
|
7117
7184
|
start: S,
|
|
7118
|
-
end:
|
|
7119
|
-
distance:
|
|
7185
|
+
end: E,
|
|
7186
|
+
distance: b
|
|
7120
7187
|
}), n;
|
|
7121
7188
|
}
|
|
7122
7189
|
/**
|
|
@@ -7144,10 +7211,10 @@ class Dt {
|
|
|
7144
7211
|
const { canvas: t } = this, e = t.getSelectionContext();
|
|
7145
7212
|
if (!e) return;
|
|
7146
7213
|
const { viewportTransform: s } = t, n = t.getZoom() || 1, o = this.activeGuides.some((c) => c.type === "vertical"), i = this.activeGuides.some((c) => c.type === "horizontal"), a = o && i && !this.isTargetMontageArea, r = a ? 12 / n : 0;
|
|
7147
|
-
e.save(), Array.isArray(s) && e.transform(...s), e.lineWidth =
|
|
7214
|
+
e.save(), Array.isArray(s) && e.transform(...s), e.lineWidth = ss / n, e.strokeStyle = es, e.setLineDash([]);
|
|
7148
7215
|
for (const c of this.activeGuides) {
|
|
7149
7216
|
const { type: d, axis: l, start: u, end: f, distance: g } = c, p = Math.abs(f - u), m = u <= f ? -1 : 1, v = a ? m * (p / 2 + r) : 0, w = 0;
|
|
7150
|
-
e.beginPath(), d === "vertical" ? (e.moveTo(l, u), e.lineTo(l, f)) : (e.moveTo(u, l), e.lineTo(f, l)), e.stroke(),
|
|
7217
|
+
e.beginPath(), d === "vertical" ? (e.moveTo(l, u), e.lineTo(l, f)) : (e.moveTo(u, l), e.lineTo(f, l)), e.stroke(), Ee({
|
|
7151
7218
|
context: e,
|
|
7152
7219
|
type: d,
|
|
7153
7220
|
axis: l,
|
|
@@ -7155,8 +7222,8 @@ class Dt {
|
|
|
7155
7222
|
end: f,
|
|
7156
7223
|
text: Math.round(g).toString(),
|
|
7157
7224
|
zoom: n,
|
|
7158
|
-
color:
|
|
7159
|
-
lineWidth:
|
|
7225
|
+
color: es,
|
|
7226
|
+
lineWidth: ss,
|
|
7160
7227
|
offsetAlongAxis: v,
|
|
7161
7228
|
offsetPerpendicular: w
|
|
7162
7229
|
});
|
|
@@ -7182,14 +7249,14 @@ class Dt {
|
|
|
7182
7249
|
(e = t == null ? void 0 : t.showAfterTemporary) == null || e.call(t), this.isToolbarHidden = !1;
|
|
7183
7250
|
}
|
|
7184
7251
|
}
|
|
7185
|
-
class
|
|
7252
|
+
class xe {
|
|
7186
7253
|
/**
|
|
7187
7254
|
* Конструктор класса ImageEditor.
|
|
7188
7255
|
* @param canvasId - идентификатор канваса, в котором будет создан редактор
|
|
7189
7256
|
* @param options - опции и настройки редактора
|
|
7190
7257
|
*/
|
|
7191
7258
|
constructor(t, e) {
|
|
7192
|
-
this.options = e, this.containerId = t, this.editorId = `${t}-${
|
|
7259
|
+
this.options = e, this.containerId = t, this.editorId = `${t}-${K()}`, this.clipboard = null, this.init();
|
|
7193
7260
|
}
|
|
7194
7261
|
/**
|
|
7195
7262
|
* Инициализация редактора.
|
|
@@ -7197,7 +7264,7 @@ class Le {
|
|
|
7197
7264
|
* @fires editor:ready
|
|
7198
7265
|
*/
|
|
7199
7266
|
init() {
|
|
7200
|
-
return
|
|
7267
|
+
return W(this, null, function* () {
|
|
7201
7268
|
var u;
|
|
7202
7269
|
const {
|
|
7203
7270
|
editorContainerWidth: t,
|
|
@@ -7212,17 +7279,17 @@ class Le {
|
|
|
7212
7279
|
showRotationAngle: d,
|
|
7213
7280
|
_onReadyCallback: l
|
|
7214
7281
|
} = this.options;
|
|
7215
|
-
if (
|
|
7282
|
+
if (ot.apply(), this.canvas = new vs(this.containerId, this.options), this.moduleLoader = new As(), this.workerManager = new Cs(), this.errorManager = new te({ editor: this }), this.historyManager = new G({ editor: this }), this.toolbar = new Us({ editor: this }), this.transformManager = new Js({ editor: this }), this.zoomManager = new Qs({ editor: this }), this.canvasManager = new qs({ editor: this }), this.imageManager = new lt({ editor: this }), this.layerManager = new fe({ editor: this }), this.shapeManager = new tn({ editor: this }), this.interactionBlocker = new $s({ editor: this }), this.backgroundManager = new _t({ editor: this }), this.clipboardManager = new en({ editor: this }), this.objectLockManager = new ge({ editor: this }), this.groupingManager = new sn({ editor: this }), this.selectionManager = new nn({ editor: this }), this.deletionManager = new Re({ editor: this }), this.panConstraintManager = new on({ editor: this }), this.snappingManager = new jn({ editor: this }), this.measurementManager = new Nt({ editor: this }), this.fontManager = new Ce((u = this.options.fonts) != null ? u : []), this.textManager = new P({ editor: this }), this.templateManager = new x({ editor: this }), d && (this.angleIndicator = new De({ editor: this })), this._createMontageArea(), this._createClippingArea(), this.listeners = new $t({ editor: this, options: this.options }), this.canvasManager.setEditorContainerWidth(t), this.canvasManager.setEditorContainerHeight(e), this.canvasManager.setCanvasWrapperWidth(s), this.canvasManager.setCanvasWrapperHeight(n), this.canvasManager.setCanvasCSSWidth(o), this.canvasManager.setCanvasCSSHeight(i), this.canvasManager.updateCanvas(), this.zoomManager.calculateAndApplyDefaultZoom(), yield this.fontManager.loadFonts(), a != null && a.source) {
|
|
7216
7283
|
const f = a, {
|
|
7217
7284
|
source: g,
|
|
7218
7285
|
scale: p = `image-${c}`,
|
|
7219
7286
|
withoutSave: m = !0
|
|
7220
|
-
} = f, v =
|
|
7287
|
+
} = f, v = gt(f, [
|
|
7221
7288
|
"source",
|
|
7222
7289
|
"scale",
|
|
7223
7290
|
"withoutSave"
|
|
7224
7291
|
]);
|
|
7225
|
-
yield this.imageManager.importImage(
|
|
7292
|
+
yield this.imageManager.importImage(z({ source: g, scale: p, withoutSave: m }, v));
|
|
7226
7293
|
}
|
|
7227
7294
|
r && this.historyManager.loadStateFromFullState(r), this.historyManager.saveState(), console.log("editor:ready"), this.canvas.fire("editor:ready", this), typeof l == "function" && l(this);
|
|
7228
7295
|
});
|
|
@@ -7238,7 +7305,7 @@ class Le {
|
|
|
7238
7305
|
this.montageArea = this.shapeManager.addRectangle({
|
|
7239
7306
|
width: t,
|
|
7240
7307
|
height: e,
|
|
7241
|
-
fill:
|
|
7308
|
+
fill: xe._createMosaicPattern(),
|
|
7242
7309
|
stroke: null,
|
|
7243
7310
|
strokeWidth: 0,
|
|
7244
7311
|
selectable: !1,
|
|
@@ -7334,7 +7401,7 @@ const L = [
|
|
|
7334
7401
|
"U+A640-A69F",
|
|
7335
7402
|
"U+FE2E-FE2F",
|
|
7336
7403
|
"U+2116"
|
|
7337
|
-
].join(", "),
|
|
7404
|
+
].join(", "), Cn = [
|
|
7338
7405
|
{
|
|
7339
7406
|
family: "Arial",
|
|
7340
7407
|
source: 'local("Arial"), local("Liberation Sans"), local("DejaVu Sans")',
|
|
@@ -8124,7 +8191,7 @@ const L = [
|
|
|
8124
8191
|
unicodeRange: L
|
|
8125
8192
|
}
|
|
8126
8193
|
}
|
|
8127
|
-
],
|
|
8194
|
+
], In = {
|
|
8128
8195
|
/**
|
|
8129
8196
|
* Опции редактора
|
|
8130
8197
|
*/
|
|
@@ -8216,16 +8283,16 @@ const L = [
|
|
|
8216
8283
|
/**
|
|
8217
8284
|
* Список шрифтов, которые будут доступны в редакторе по умолчанию.
|
|
8218
8285
|
*/
|
|
8219
|
-
fonts:
|
|
8286
|
+
fonts: Cn
|
|
8220
8287
|
};
|
|
8221
8288
|
function Dn(h, t = {}) {
|
|
8222
|
-
const e =
|
|
8289
|
+
const e = z(z({}, In), t), s = document.getElementById(h);
|
|
8223
8290
|
if (!s)
|
|
8224
8291
|
return Promise.reject(new Error(`Контейнер с ID "${h}" не найден.`));
|
|
8225
8292
|
const n = document.createElement("canvas");
|
|
8226
8293
|
return n.id = `${h}-canvas`, s.appendChild(n), e.editorContainer = s, new Promise((o) => {
|
|
8227
8294
|
e._onReadyCallback = o;
|
|
8228
|
-
const i = new
|
|
8295
|
+
const i = new xe(n.id, e);
|
|
8229
8296
|
window[h] = i;
|
|
8230
8297
|
});
|
|
8231
8298
|
}
|