@anu3ev/fabric-image-editor 0.5.24 → 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 +861 -844
- 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
|
* Проверяет, должно ли событие клавиатуры быть проигнорировано
|
|
@@ -468,7 +468,7 @@ class Cs {
|
|
|
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 Cs {
|
|
|
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 = Ie, h.lineWidth = Ce, 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",
|
|
@@ -1246,7 +1247,7 @@ const ns = [
|
|
|
1246
1247
|
"radiusBottomRight",
|
|
1247
1248
|
"radiusBottomLeft"
|
|
1248
1249
|
];
|
|
1249
|
-
class
|
|
1250
|
+
class G {
|
|
1250
1251
|
constructor({ editor: t }) {
|
|
1251
1252
|
this.editor = t, this.canvas = t.canvas, this._isSavingState = !1, this._historySuspendCount = 0, this.baseState = null, this.patches = [], this.currentIndex = 0, this.maxHistoryLength = t.options.maxHistoryLength, this.totalChangesCount = 0, this.baseStateChangesCount = 0, this._createDiffPatcher();
|
|
1252
1253
|
}
|
|
@@ -1310,7 +1311,7 @@ class Z {
|
|
|
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("Базовое состояние сохранено.");
|
|
@@ -1321,7 +1322,7 @@ class Z {
|
|
|
1321
1322
|
const {
|
|
1322
1323
|
prevState: s,
|
|
1323
1324
|
nextState: n
|
|
1324
|
-
} =
|
|
1325
|
+
} = G._prepareStatesForDiff({
|
|
1325
1326
|
prevState: e,
|
|
1326
1327
|
nextState: t
|
|
1327
1328
|
}), o = this.diffPatcher.diff(s, n);
|
|
@@ -1329,14 +1330,14 @@ class Z {
|
|
|
1329
1330
|
console.log("Нет изменений для сохранения.");
|
|
1330
1331
|
return;
|
|
1331
1332
|
}
|
|
1332
|
-
if (
|
|
1333
|
+
if (G._areStatesEqual({
|
|
1333
1334
|
prevState: s,
|
|
1334
1335
|
nextState: n
|
|
1335
1336
|
})) {
|
|
1336
1337
|
console.log("statesEqual. Нет изменений для сохранения.");
|
|
1337
1338
|
return;
|
|
1338
1339
|
}
|
|
1339
|
-
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:
|
|
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);
|
|
1340
1341
|
} finally {
|
|
1341
1342
|
this._isSavingState = !1;
|
|
1342
1343
|
}
|
|
@@ -1350,11 +1351,11 @@ class Z {
|
|
|
1350
1351
|
prevState: t,
|
|
1351
1352
|
nextState: e
|
|
1352
1353
|
}) {
|
|
1353
|
-
const s =
|
|
1354
|
-
return
|
|
1354
|
+
const s = G._cloneState({ state: t }), n = G._cloneState({ state: e });
|
|
1355
|
+
return G._normalizeTextBackground({ objects: s.objects }), G._normalizeTextBackground({ objects: n.objects }), G._normalizeCanvasSize({
|
|
1355
1356
|
prevState: s,
|
|
1356
1357
|
nextState: n
|
|
1357
|
-
}),
|
|
1358
|
+
}), G._normalizeTranslation({
|
|
1358
1359
|
prevState: s,
|
|
1359
1360
|
nextState: n
|
|
1360
1361
|
}), {
|
|
@@ -1378,7 +1379,7 @@ class Z {
|
|
|
1378
1379
|
prevState: t,
|
|
1379
1380
|
nextState: e
|
|
1380
1381
|
}) {
|
|
1381
|
-
const s =
|
|
1382
|
+
const s = G._stableStringify({ value: t }), n = G._stableStringify({ value: e });
|
|
1382
1383
|
return s === n;
|
|
1383
1384
|
}
|
|
1384
1385
|
/**
|
|
@@ -1433,10 +1434,10 @@ class Z {
|
|
|
1433
1434
|
const { width: s, height: n, objects: o } = t, { objects: i } = e, {
|
|
1434
1435
|
width: a,
|
|
1435
1436
|
height: r
|
|
1436
|
-
} =
|
|
1437
|
+
} = G._getMontageAreaSize({ objects: o }), {
|
|
1437
1438
|
width: c,
|
|
1438
1439
|
height: d
|
|
1439
|
-
} =
|
|
1440
|
+
} = G._getMontageAreaSize({ objects: i });
|
|
1440
1441
|
a !== c || r !== d || (e.width = s, e.height = n);
|
|
1441
1442
|
}
|
|
1442
1443
|
/**
|
|
@@ -1449,22 +1450,22 @@ class Z {
|
|
|
1449
1450
|
const { objects: s, clipPath: n } = t, { objects: o, clipPath: i } = e, {
|
|
1450
1451
|
left: a,
|
|
1451
1452
|
top: r
|
|
1452
|
-
} =
|
|
1453
|
+
} = G._getMontageAreaPosition({ objects: s }), {
|
|
1453
1454
|
left: c,
|
|
1454
1455
|
top: d
|
|
1455
|
-
} =
|
|
1456
|
+
} = G._getMontageAreaPosition({ objects: o }), l = c - a, u = d - r;
|
|
1456
1457
|
if (l === 0 && u === 0) return;
|
|
1457
|
-
const f =
|
|
1458
|
+
const f = G._getObjectById({
|
|
1458
1459
|
objects: o,
|
|
1459
1460
|
id: "montage-area"
|
|
1460
1461
|
});
|
|
1461
1462
|
f && (f.left = a, f.top = r);
|
|
1462
|
-
const g =
|
|
1463
|
+
const g = G._getClipPathPosition({ clipPath: n });
|
|
1463
1464
|
if (g && i && typeof i == "object") {
|
|
1464
1465
|
const { left: m, top: v } = g, w = i;
|
|
1465
1466
|
w.left = m, w.top = v;
|
|
1466
1467
|
}
|
|
1467
|
-
const p =
|
|
1468
|
+
const p = G._getTranslationIgnoredIds();
|
|
1468
1469
|
for (let m = 0; m < o.length; m += 1) {
|
|
1469
1470
|
const v = o[m], { id: w } = v;
|
|
1470
1471
|
w && p.has(w) || (typeof v.left == "number" && (v.left -= l), typeof v.top == "number" && (v.top -= u));
|
|
@@ -1486,7 +1487,7 @@ class Z {
|
|
|
1486
1487
|
static _getMontageAreaPosition({
|
|
1487
1488
|
objects: t
|
|
1488
1489
|
}) {
|
|
1489
|
-
const e =
|
|
1490
|
+
const e = G._getObjectById({
|
|
1490
1491
|
objects: t,
|
|
1491
1492
|
id: "montage-area"
|
|
1492
1493
|
});
|
|
@@ -1501,7 +1502,7 @@ class Z {
|
|
|
1501
1502
|
static _getMontageAreaSize({
|
|
1502
1503
|
objects: t
|
|
1503
1504
|
}) {
|
|
1504
|
-
const e =
|
|
1505
|
+
const e = G._getObjectById({
|
|
1505
1506
|
objects: t,
|
|
1506
1507
|
id: "montage-area"
|
|
1507
1508
|
});
|
|
@@ -1570,7 +1571,7 @@ class Z {
|
|
|
1570
1571
|
for (let c = 0; c < i.length; c += 1) {
|
|
1571
1572
|
const d = i[c], { id: l } = d;
|
|
1572
1573
|
let u;
|
|
1573
|
-
typeof l == "string" && (u = n.get(l)), u || (u = o.get(c)), u && (d.customData =
|
|
1574
|
+
typeof l == "string" && (u = n.get(l)), u || (u = o.get(c)), u && (d.customData = G._cloneCustomData({ customData: u }));
|
|
1574
1575
|
}
|
|
1575
1576
|
}
|
|
1576
1577
|
/**
|
|
@@ -1586,13 +1587,13 @@ class Z {
|
|
|
1586
1587
|
* @fires editor:history-state-loaded
|
|
1587
1588
|
*/
|
|
1588
1589
|
loadStateFromFullState(t) {
|
|
1589
|
-
return
|
|
1590
|
+
return W(this, null, function* () {
|
|
1590
1591
|
if (!t) return;
|
|
1591
1592
|
console.log("loadStateFromFullState fullState", t);
|
|
1592
1593
|
const { canvas: e, canvasManager: s, interactionBlocker: n, backgroundManager: o } = this.editor, { width: i, height: a } = e;
|
|
1593
1594
|
n.overlayMask = null;
|
|
1594
|
-
const r =
|
|
1595
|
-
yield e.loadFromJSON(r),
|
|
1595
|
+
const r = G._createLoadSafeState({ state: t });
|
|
1596
|
+
yield e.loadFromJSON(r), G._applyCustomDataFromState({ state: t, canvas: e });
|
|
1596
1597
|
const c = e.getObjects().find((u) => u.id === "montage-area");
|
|
1597
1598
|
c && (this.editor.montageArea = c, (i !== e.getWidth() || a !== e.getHeight()) && s.updateCanvas());
|
|
1598
1599
|
const d = e.getObjects().find((u) => u.id === "overlay-mask");
|
|
@@ -1613,7 +1614,7 @@ class Z {
|
|
|
1613
1614
|
* @fires editor:undo
|
|
1614
1615
|
*/
|
|
1615
1616
|
undo() {
|
|
1616
|
-
return
|
|
1617
|
+
return W(this, null, function* () {
|
|
1617
1618
|
if (!this.skipHistory) {
|
|
1618
1619
|
if (this.saveState(), this.currentIndex <= 0) {
|
|
1619
1620
|
console.log("Нет предыдущих состояний для отмены.");
|
|
@@ -1650,7 +1651,7 @@ class Z {
|
|
|
1650
1651
|
* @fires editor:redo
|
|
1651
1652
|
*/
|
|
1652
1653
|
redo() {
|
|
1653
|
-
return
|
|
1654
|
+
return W(this, null, function* () {
|
|
1654
1655
|
if (!this.skipHistory) {
|
|
1655
1656
|
if (this.currentIndex >= this.patches.length) {
|
|
1656
1657
|
console.log("Нет состояний для повтора.");
|
|
@@ -1705,7 +1706,7 @@ class Z {
|
|
|
1705
1706
|
}
|
|
1706
1707
|
}
|
|
1707
1708
|
}
|
|
1708
|
-
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 = [
|
|
1709
1710
|
"format",
|
|
1710
1711
|
"uppercase",
|
|
1711
1712
|
"textCaseRaw",
|
|
@@ -1720,7 +1721,7 @@ const Hs = 0.1, Zs = 2, Ze = 0.1, Gs = 90, _t = 16, xt = 16, jt = 4096, Ct = 409
|
|
|
1720
1721
|
"radiusBottomRight",
|
|
1721
1722
|
"radiusBottomLeft"
|
|
1722
1723
|
], Vs = 50;
|
|
1723
|
-
class
|
|
1724
|
+
class lt {
|
|
1724
1725
|
constructor({ editor: t }) {
|
|
1725
1726
|
this.editor = t, this.options = t.options, this._createdBlobUrls = [], this.acceptContentTypes = this.editor.options.acceptContentTypes, this.acceptFormats = this.getAllowedFormatsFromContentTypes();
|
|
1726
1727
|
}
|
|
@@ -1737,7 +1738,7 @@ class ut {
|
|
|
1737
1738
|
* @returns возвращает Promise с объектом изображения или null в случае ошибки
|
|
1738
1739
|
*/
|
|
1739
1740
|
importImage(t) {
|
|
1740
|
-
return
|
|
1741
|
+
return W(this, null, function* () {
|
|
1741
1742
|
const {
|
|
1742
1743
|
source: e,
|
|
1743
1744
|
scale: s = `image-${this.options.scaleType}`,
|
|
@@ -1749,7 +1750,7 @@ class ut {
|
|
|
1749
1750
|
customData: c = null
|
|
1750
1751
|
} = t;
|
|
1751
1752
|
if (!e) return null;
|
|
1752
|
-
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;
|
|
1753
1754
|
if (!this.isAllowedContentType(p)) {
|
|
1754
1755
|
const A = `Неверный contentType для изображения: ${p}. Ожидается один из: ${this.acceptContentTypes.join(", ")}.`;
|
|
1755
1756
|
return g.emitError({
|
|
@@ -1777,8 +1778,8 @@ class ut {
|
|
|
1777
1778
|
if (e instanceof File)
|
|
1778
1779
|
A = URL.createObjectURL(e);
|
|
1779
1780
|
else if (typeof e == "string") {
|
|
1780
|
-
const
|
|
1781
|
-
A = URL.createObjectURL(
|
|
1781
|
+
const E = yield (yield fetch(e, { mode: "cors" })).blob();
|
|
1782
|
+
A = URL.createObjectURL(E);
|
|
1782
1783
|
} else
|
|
1783
1784
|
return g.emitError({
|
|
1784
1785
|
origin: "ImageManager",
|
|
@@ -1800,26 +1801,26 @@ class ut {
|
|
|
1800
1801
|
}), null;
|
|
1801
1802
|
if (this._createdBlobUrls.push(A), m === "svg") {
|
|
1802
1803
|
const S = yield us(A);
|
|
1803
|
-
y =
|
|
1804
|
+
y = ht.groupSVGElements(S.objects, S.options);
|
|
1804
1805
|
} else
|
|
1805
|
-
y = yield
|
|
1806
|
-
const { width:
|
|
1807
|
-
if (y instanceof
|
|
1806
|
+
y = yield qt.fromURL(A, { crossOrigin: "anonymous" });
|
|
1807
|
+
const { width: M, height: j } = y;
|
|
1808
|
+
if (y instanceof qt) {
|
|
1808
1809
|
const S = y.getElement();
|
|
1809
|
-
let
|
|
1810
|
-
if (S instanceof HTMLImageElement ?
|
|
1811
|
-
const
|
|
1812
|
-
this._createdBlobUrls.push(I), y = yield
|
|
1813
|
-
} else if (j <
|
|
1814
|
-
const
|
|
1815
|
-
this._createdBlobUrls.push(I), y = yield
|
|
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" });
|
|
1816
1817
|
}
|
|
1817
1818
|
}
|
|
1818
|
-
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")
|
|
1819
1820
|
this.editor.canvasManager.scaleMontageAreaToImage({ object: y, withoutSave: !0 });
|
|
1820
1821
|
else {
|
|
1821
|
-
const { width: S, height:
|
|
1822
|
-
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 });
|
|
1823
1824
|
}
|
|
1824
1825
|
const C = {
|
|
1825
1826
|
image: y,
|
|
@@ -1866,16 +1867,16 @@ class ut {
|
|
|
1866
1867
|
* @returns возвращает Promise с Blob-объектом уменьшенного изображения
|
|
1867
1868
|
*/
|
|
1868
1869
|
resizeImageToBoundaries(t, e = "max") {
|
|
1869
|
-
return
|
|
1870
|
-
let s = `Размер изображения больше максимального размера канваса, поэтому оно будет уменьшено до максимальных размеров c сохранением пропорций: ${
|
|
1871
|
-
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}`);
|
|
1872
1873
|
const n = {
|
|
1873
1874
|
dataURL: t,
|
|
1874
1875
|
sizeType: e,
|
|
1875
|
-
maxWidth:
|
|
1876
|
-
maxHeight:
|
|
1877
|
-
minWidth:
|
|
1878
|
-
minHeight:
|
|
1876
|
+
maxWidth: At,
|
|
1877
|
+
maxHeight: jt,
|
|
1878
|
+
minWidth: kt,
|
|
1879
|
+
minHeight: zt
|
|
1879
1880
|
};
|
|
1880
1881
|
return this.editor.errorManager.emitWarning({
|
|
1881
1882
|
origin: "ImageManager",
|
|
@@ -1898,7 +1899,7 @@ class ut {
|
|
|
1898
1899
|
* @fires editor:canvas-exported
|
|
1899
1900
|
*/
|
|
1900
1901
|
exportCanvasAsImageFile() {
|
|
1901
|
-
return
|
|
1902
|
+
return W(this, arguments, function* (t = {}) {
|
|
1902
1903
|
const {
|
|
1903
1904
|
fileName: e = "image.png",
|
|
1904
1905
|
contentType: s = "image/png",
|
|
@@ -1906,22 +1907,22 @@ class ut {
|
|
|
1906
1907
|
exportAsBlob: o = !1
|
|
1907
1908
|
} = t, { canvas: i, montageArea: a, workerManager: r, interactionBlocker: c } = this.editor;
|
|
1908
1909
|
try {
|
|
1909
|
-
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);
|
|
1910
1911
|
a.setCoords();
|
|
1911
1912
|
const { left: f, top: g, width: p, height: m } = a.getBoundingRect(), v = yield i.clone(["id", "format", "locked"]);
|
|
1912
1913
|
v.enableRetinaScaling = !1, ["image/jpg", "image/jpeg"].includes(l) && (v.backgroundColor = "#ffffff");
|
|
1913
|
-
const w = v.getObjects().find((
|
|
1914
|
+
const w = v.getObjects().find((b) => b.id === a.id);
|
|
1914
1915
|
if (w && (w.visible = !1), c != null && c.isBlocked) {
|
|
1915
|
-
const
|
|
1916
|
-
|
|
1916
|
+
const b = v.getObjects().find((I) => I.id === c.overlayMask.id);
|
|
1917
|
+
b && (b.visible = !1);
|
|
1917
1918
|
}
|
|
1918
1919
|
v.viewportTransform = [1, 0, 0, 1, -f, -g], v.setDimensions({ width: p, height: m }, { backstoreOnly: !0 }), v.renderAll();
|
|
1919
|
-
const A = v.getObjects().filter((
|
|
1920
|
+
const A = v.getObjects().filter((b) => b.format).every((b) => b.format === "svg");
|
|
1920
1921
|
if (u === "svg" && A) {
|
|
1921
|
-
const
|
|
1922
|
+
const b = v.toSVG();
|
|
1922
1923
|
v.dispose();
|
|
1923
|
-
const
|
|
1924
|
-
image:
|
|
1924
|
+
const T = {
|
|
1925
|
+
image: lt._exportSVGStringAsFile(b, {
|
|
1925
1926
|
exportAsBase64: n,
|
|
1926
1927
|
exportAsBlob: o,
|
|
1927
1928
|
fileName: e
|
|
@@ -1930,66 +1931,66 @@ class ut {
|
|
|
1930
1931
|
contentType: "image/svg+xml",
|
|
1931
1932
|
fileName: e.replace(/\.[^/.]+$/, ".svg")
|
|
1932
1933
|
};
|
|
1933
|
-
return i.fire("editor:canvas-exported",
|
|
1934
|
+
return i.fire("editor:canvas-exported", T), T;
|
|
1934
1935
|
}
|
|
1935
|
-
const y = yield new Promise((
|
|
1936
|
-
v.getElement().toBlob((
|
|
1937
|
-
|
|
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"));
|
|
1938
1939
|
});
|
|
1939
1940
|
});
|
|
1940
1941
|
if (v.dispose(), o) {
|
|
1941
|
-
const
|
|
1942
|
+
const b = {
|
|
1942
1943
|
image: y,
|
|
1943
1944
|
format: u,
|
|
1944
1945
|
contentType: l,
|
|
1945
1946
|
fileName: e
|
|
1946
1947
|
};
|
|
1947
|
-
return i.fire("editor:canvas-exported",
|
|
1948
|
+
return i.fire("editor:canvas-exported", b), b;
|
|
1948
1949
|
}
|
|
1949
|
-
const
|
|
1950
|
+
const M = yield createImageBitmap(y), j = yield r.post(
|
|
1950
1951
|
"toDataURL",
|
|
1951
|
-
{ format: u, quality: 1, bitmap:
|
|
1952
|
-
[
|
|
1952
|
+
{ format: u, quality: 1, bitmap: M },
|
|
1953
|
+
[M]
|
|
1953
1954
|
);
|
|
1954
1955
|
if (d) {
|
|
1955
|
-
const I = p * 0.264583,
|
|
1956
|
-
orientation: I >
|
|
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",
|
|
1957
1958
|
unit: "mm",
|
|
1958
|
-
format: [I,
|
|
1959
|
+
format: [I, T]
|
|
1959
1960
|
});
|
|
1960
|
-
if (
|
|
1961
|
-
const
|
|
1962
|
-
image:
|
|
1961
|
+
if (B.addImage(String(j), "JPG", 0, 0, I, T), n) {
|
|
1962
|
+
const Y = {
|
|
1963
|
+
image: B.output("datauristring"),
|
|
1963
1964
|
format: "pdf",
|
|
1964
1965
|
contentType: "application/pdf",
|
|
1965
1966
|
fileName: e
|
|
1966
1967
|
};
|
|
1967
|
-
return i.fire("editor:canvas-exported",
|
|
1968
|
+
return i.fire("editor:canvas-exported", Y), Y;
|
|
1968
1969
|
}
|
|
1969
|
-
const N =
|
|
1970
|
+
const N = B.output("blob"), Z = {
|
|
1970
1971
|
image: new File([N], e, { type: "application/pdf" }),
|
|
1971
1972
|
format: "pdf",
|
|
1972
1973
|
contentType: "application/pdf",
|
|
1973
1974
|
fileName: e
|
|
1974
1975
|
};
|
|
1975
|
-
return i.fire("editor:canvas-exported",
|
|
1976
|
+
return i.fire("editor:canvas-exported", Z), Z;
|
|
1976
1977
|
}
|
|
1977
1978
|
if (n) {
|
|
1978
|
-
const
|
|
1979
|
+
const b = {
|
|
1979
1980
|
image: j,
|
|
1980
1981
|
format: u,
|
|
1981
1982
|
contentType: l,
|
|
1982
1983
|
fileName: e
|
|
1983
1984
|
};
|
|
1984
|
-
return i.fire("editor:canvas-exported",
|
|
1985
|
+
return i.fire("editor:canvas-exported", b), b;
|
|
1985
1986
|
}
|
|
1986
|
-
const C = u === "svg" && !A ? e.replace(/\.[^/.]+$/, ".png") : e,
|
|
1987
|
+
const C = u === "svg" && !A ? e.replace(/\.[^/.]+$/, ".png") : e, E = {
|
|
1987
1988
|
image: new File([y], C, { type: l }),
|
|
1988
1989
|
format: u,
|
|
1989
1990
|
contentType: l,
|
|
1990
1991
|
fileName: C
|
|
1991
1992
|
};
|
|
1992
|
-
return i.fire("editor:canvas-exported",
|
|
1993
|
+
return i.fire("editor:canvas-exported", E), E;
|
|
1993
1994
|
} catch (d) {
|
|
1994
1995
|
return this.editor.errorManager.emitError({
|
|
1995
1996
|
origin: "ImageManager",
|
|
@@ -2013,7 +2014,7 @@ class ut {
|
|
|
2013
2014
|
* @fires editor:object-exported
|
|
2014
2015
|
*/
|
|
2015
2016
|
exportObjectAsImageFile() {
|
|
2016
|
-
return
|
|
2017
|
+
return W(this, arguments, function* (t = {}) {
|
|
2017
2018
|
const {
|
|
2018
2019
|
object: e,
|
|
2019
2020
|
fileName: s = "image.png",
|
|
@@ -2030,9 +2031,9 @@ class ut {
|
|
|
2030
2031
|
data: { contentType: n, fileName: s, exportAsBase64: o, exportAsBlob: i }
|
|
2031
2032
|
}), null;
|
|
2032
2033
|
try {
|
|
2033
|
-
const d =
|
|
2034
|
+
const d = lt.getFormatFromContentType(n);
|
|
2034
2035
|
if (d === "svg") {
|
|
2035
|
-
const p = c.toSVG(), m =
|
|
2036
|
+
const p = c.toSVG(), m = lt._exportSVGStringAsFile(p, {
|
|
2036
2037
|
exportAsBase64: o,
|
|
2037
2038
|
exportAsBlob: i,
|
|
2038
2039
|
fileName: s
|
|
@@ -2045,7 +2046,7 @@ class ut {
|
|
|
2045
2046
|
};
|
|
2046
2047
|
return a.fire("editor:object-exported", v), v;
|
|
2047
2048
|
}
|
|
2048
|
-
if (o && c instanceof
|
|
2049
|
+
if (o && c instanceof qt) {
|
|
2049
2050
|
const p = yield createImageBitmap(c.getElement()), m = yield r.post(
|
|
2050
2051
|
"toDataURL",
|
|
2051
2052
|
{
|
|
@@ -2110,7 +2111,7 @@ class ut {
|
|
|
2110
2111
|
* @returns массив допустимых форматов изображений
|
|
2111
2112
|
*/
|
|
2112
2113
|
getAllowedFormatsFromContentTypes() {
|
|
2113
|
-
return this.acceptContentTypes.map((t) =>
|
|
2114
|
+
return this.acceptContentTypes.map((t) => lt.getFormatFromContentType(t)).filter((t) => t);
|
|
2114
2115
|
}
|
|
2115
2116
|
/**
|
|
2116
2117
|
* Проверяет, является ли contentType допустимым типом изображения.
|
|
@@ -2126,7 +2127,7 @@ class ut {
|
|
|
2126
2127
|
* @public
|
|
2127
2128
|
*/
|
|
2128
2129
|
getContentType(t) {
|
|
2129
|
-
return
|
|
2130
|
+
return W(this, null, function* () {
|
|
2130
2131
|
return typeof t == "string" ? this.getContentTypeFromUrl(t) : t.type || "application/octet-stream";
|
|
2131
2132
|
});
|
|
2132
2133
|
}
|
|
@@ -2137,7 +2138,7 @@ class ut {
|
|
|
2137
2138
|
* @public
|
|
2138
2139
|
*/
|
|
2139
2140
|
getContentTypeFromUrl(t) {
|
|
2140
|
-
return
|
|
2141
|
+
return W(this, null, function* () {
|
|
2141
2142
|
if (t.startsWith("data:")) {
|
|
2142
2143
|
const e = t.match(/^data:([^;]+)/);
|
|
2143
2144
|
return e ? e[1] : "application/octet-stream";
|
|
@@ -2163,7 +2164,7 @@ class ut {
|
|
|
2163
2164
|
try {
|
|
2164
2165
|
const n = (e = new URL(t).pathname.split(".").pop()) == null ? void 0 : e.toLowerCase(), o = {};
|
|
2165
2166
|
return this.acceptContentTypes.forEach((i) => {
|
|
2166
|
-
const a =
|
|
2167
|
+
const a = lt.getFormatFromContentType(i);
|
|
2167
2168
|
a && (o[a] = i);
|
|
2168
2169
|
}), n && o[n] || "application/octet-stream";
|
|
2169
2170
|
} catch (s) {
|
|
@@ -2216,7 +2217,7 @@ class ut {
|
|
|
2216
2217
|
return e ? e[1] : "";
|
|
2217
2218
|
}
|
|
2218
2219
|
}
|
|
2219
|
-
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);
|
|
2220
2221
|
function Ks(h) {
|
|
2221
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";
|
|
2222
2223
|
}
|
|
@@ -2240,11 +2241,11 @@ class qs {
|
|
|
2240
2241
|
* Если точка находится за пределами монтажной области, она проецируется на ближайшую границу монтажной области.
|
|
2241
2242
|
*/
|
|
2242
2243
|
getVisibleCenterPoint() {
|
|
2243
|
-
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(
|
|
2244
2245
|
a,
|
|
2245
2246
|
e.left - c,
|
|
2246
2247
|
e.left + c
|
|
2247
|
-
), u =
|
|
2248
|
+
), u = pt(
|
|
2248
2249
|
r,
|
|
2249
2250
|
e.top - d,
|
|
2250
2251
|
e.top + d
|
|
@@ -2267,9 +2268,9 @@ class qs {
|
|
|
2267
2268
|
canvas: o,
|
|
2268
2269
|
montageArea: i,
|
|
2269
2270
|
options: { canvasBackstoreWidth: a }
|
|
2270
|
-
} = this.editor, { width: r, height: c } = i, d =
|
|
2271
|
+
} = this.editor, { width: r, height: c } = i, d = pt(Number(t), kt, At);
|
|
2271
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) {
|
|
2272
|
-
const p = d / r, m =
|
|
2273
|
+
const p = d / r, m = Xe(c, p);
|
|
2273
2274
|
this.setResolutionHeight(m);
|
|
2274
2275
|
return;
|
|
2275
2276
|
}
|
|
@@ -2297,9 +2298,9 @@ class qs {
|
|
|
2297
2298
|
canvas: o,
|
|
2298
2299
|
montageArea: i,
|
|
2299
2300
|
options: { canvasBackstoreHeight: a }
|
|
2300
|
-
} = this.editor, { width: r, height: c } = i, d =
|
|
2301
|
+
} = this.editor, { width: r, height: c } = i, d = pt(Number(t), zt, jt);
|
|
2301
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) {
|
|
2302
|
-
const p = d / c, m =
|
|
2303
|
+
const p = d / c, m = Xe(r, p);
|
|
2303
2304
|
this.setResolutionWidth(m);
|
|
2304
2305
|
return;
|
|
2305
2306
|
}
|
|
@@ -2350,7 +2351,7 @@ class qs {
|
|
|
2350
2351
|
*/
|
|
2351
2352
|
setCanvasBackstoreWidth(t) {
|
|
2352
2353
|
if (!t || typeof t != "number") return;
|
|
2353
|
-
const e =
|
|
2354
|
+
const e = pt(t, kt, At);
|
|
2354
2355
|
this.editor.canvas.setDimensions({ width: e }, { backstoreOnly: !0 });
|
|
2355
2356
|
}
|
|
2356
2357
|
/**
|
|
@@ -2359,7 +2360,7 @@ class qs {
|
|
|
2359
2360
|
*/
|
|
2360
2361
|
setCanvasBackstoreHeight(t) {
|
|
2361
2362
|
if (!t || typeof t != "number") return;
|
|
2362
|
-
const e =
|
|
2363
|
+
const e = pt(t, zt, jt);
|
|
2363
2364
|
this.editor.canvas.setDimensions({ height: e }, { backstoreOnly: !0 });
|
|
2364
2365
|
}
|
|
2365
2366
|
/**
|
|
@@ -2368,7 +2369,7 @@ class qs {
|
|
|
2368
2369
|
* с учётом минимальных и максимальных значений.
|
|
2369
2370
|
*/
|
|
2370
2371
|
adaptCanvasToContainer() {
|
|
2371
|
-
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);
|
|
2372
2373
|
t.setDimensions({ width: o, height: i }, { backstoreOnly: !0 });
|
|
2373
2374
|
}
|
|
2374
2375
|
/**
|
|
@@ -2402,7 +2403,7 @@ class qs {
|
|
|
2402
2403
|
if (d.length === 1)
|
|
2403
2404
|
t.setActiveObject(d[0]);
|
|
2404
2405
|
else {
|
|
2405
|
-
const l = new
|
|
2406
|
+
const l = new F(d, {
|
|
2406
2407
|
canvas: t
|
|
2407
2408
|
});
|
|
2408
2409
|
t.setActiveObject(l);
|
|
@@ -2570,7 +2571,7 @@ class qs {
|
|
|
2570
2571
|
} = this.editor, c = t || n.getActiveObject();
|
|
2571
2572
|
if (!Ks(c)) return;
|
|
2572
2573
|
const { width: d, height: l } = c;
|
|
2573
|
-
let u = Math.min(d,
|
|
2574
|
+
let u = Math.min(d, At), f = Math.min(l, jt);
|
|
2574
2575
|
if (e) {
|
|
2575
2576
|
const {
|
|
2576
2577
|
width: g,
|
|
@@ -2689,7 +2690,7 @@ class Js {
|
|
|
2689
2690
|
withoutSave: s
|
|
2690
2691
|
} = {}) {
|
|
2691
2692
|
const { canvas: n, historyManager: o } = this.editor, i = t || n.getActiveObject();
|
|
2692
|
-
i && (i instanceof
|
|
2693
|
+
i && (i instanceof F ? i.getObjects().forEach((a) => {
|
|
2693
2694
|
a.set("opacity", e);
|
|
2694
2695
|
}) : i.set("opacity", e), n.renderAll(), s || o.saveState(), n.fire("editor:object-opacity-changed", {
|
|
2695
2696
|
object: i,
|
|
@@ -2716,12 +2717,12 @@ class Js {
|
|
|
2716
2717
|
} = {}) {
|
|
2717
2718
|
const { canvas: o, historyManager: i } = this.editor, a = t || o.getActiveObject();
|
|
2718
2719
|
if (a) {
|
|
2719
|
-
if (a instanceof
|
|
2720
|
+
if (a instanceof F && !n) {
|
|
2720
2721
|
const r = a.getObjects();
|
|
2721
2722
|
o.discardActiveObject(), r.forEach((d) => {
|
|
2722
2723
|
this._fitSingleObject(d, e);
|
|
2723
2724
|
});
|
|
2724
|
-
const c = new
|
|
2725
|
+
const c = new F(r, { canvas: o });
|
|
2725
2726
|
o.setActiveObject(c);
|
|
2726
2727
|
} else
|
|
2727
2728
|
this._fitSingleObject(a, e);
|
|
@@ -2864,8 +2865,8 @@ class Qs {
|
|
|
2864
2865
|
_calculateEmptySpaceRatio(t) {
|
|
2865
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;
|
|
2866
2867
|
if (!(p || m || v || w)) return 0;
|
|
2867
|
-
const y = Math.max(0, a - l),
|
|
2868
|
-
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);
|
|
2869
2870
|
}
|
|
2870
2871
|
/**
|
|
2871
2872
|
* Вычисляет плавный шаг перемещения viewport к центру с ускорением
|
|
@@ -2881,8 +2882,8 @@ class Qs {
|
|
|
2881
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;
|
|
2882
2883
|
if (Math.abs(g) / f <= 0.1)
|
|
2883
2884
|
return { x: l, y: u };
|
|
2884
|
-
const m = c / 2, v = d / 2, w = a.left, A = a.top, y = m - w * s,
|
|
2885
|
-
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: _ };
|
|
2886
2887
|
}
|
|
2887
2888
|
/**
|
|
2888
2889
|
* Применяет плавное центрирование viewport при приближении к defaultZoom.
|
|
@@ -2894,7 +2895,7 @@ class Qs {
|
|
|
2894
2895
|
* @returns true если центрирование было применено
|
|
2895
2896
|
* @private
|
|
2896
2897
|
*/
|
|
2897
|
-
_applyViewportCentering(t, e = !1, s =
|
|
2898
|
+
_applyViewportCentering(t, e = !1, s = Ge) {
|
|
2898
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;
|
|
2899
2900
|
if (!(!r || d) && !e)
|
|
2900
2901
|
return !1;
|
|
@@ -2969,7 +2970,7 @@ class Qs {
|
|
|
2969
2970
|
* @param options.pointY - Координата Y точки зума
|
|
2970
2971
|
* @fires editor:zoom-changed
|
|
2971
2972
|
*/
|
|
2972
|
-
zoom(t =
|
|
2973
|
+
zoom(t = Ge, e = {}) {
|
|
2973
2974
|
var f, g;
|
|
2974
2975
|
if (!t) return;
|
|
2975
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);
|
|
@@ -3064,7 +3065,7 @@ class $s {
|
|
|
3064
3065
|
}), t.upperCanvasEl.style.pointerEvents = "", t.lowerCanvasEl.style.pointerEvents = "", this.overlayMask.visible = !1, t.requestRenderAll(), t.fire("editor:enabled"), s.resumeHistory();
|
|
3065
3066
|
}
|
|
3066
3067
|
}
|
|
3067
|
-
class
|
|
3068
|
+
class _t {
|
|
3068
3069
|
constructor({ editor: t }) {
|
|
3069
3070
|
this.editor = t, this.backgroundObject = null;
|
|
3070
3071
|
}
|
|
@@ -3090,7 +3091,7 @@ class Lt {
|
|
|
3090
3091
|
}
|
|
3091
3092
|
a.set({
|
|
3092
3093
|
fill: t,
|
|
3093
|
-
backgroundId: `background-${
|
|
3094
|
+
backgroundId: `background-${K()}`
|
|
3094
3095
|
}), this.editor.canvas.requestRenderAll();
|
|
3095
3096
|
} else
|
|
3096
3097
|
this._removeCurrentBackground(), this._createColorBackground(t);
|
|
@@ -3127,14 +3128,14 @@ class Lt {
|
|
|
3127
3128
|
try {
|
|
3128
3129
|
const { historyManager: i } = this.editor, { backgroundObject: a } = this;
|
|
3129
3130
|
if (i.suspendHistory(), a && a.backgroundType === "gradient") {
|
|
3130
|
-
const r =
|
|
3131
|
-
if (
|
|
3131
|
+
const r = _t._createFabricGradient(t);
|
|
3132
|
+
if (_t._isGradientEqual(a.fill, r)) {
|
|
3132
3133
|
i.resumeHistory();
|
|
3133
3134
|
return;
|
|
3134
3135
|
}
|
|
3135
3136
|
a.set({
|
|
3136
3137
|
fill: r,
|
|
3137
|
-
backgroundId: `background-${
|
|
3138
|
+
backgroundId: `background-${K()}`
|
|
3138
3139
|
}), this.editor.canvas.requestRenderAll();
|
|
3139
3140
|
} else
|
|
3140
3141
|
this._removeCurrentBackground(), this._createGradientBackground(t);
|
|
@@ -3222,7 +3223,7 @@ class Lt {
|
|
|
3222
3223
|
* @param options.withoutSave - Если true, не сохранять состояние в историю
|
|
3223
3224
|
*/
|
|
3224
3225
|
setImageBackground(o) {
|
|
3225
|
-
return
|
|
3226
|
+
return W(this, arguments, function* ({
|
|
3226
3227
|
imageSource: t,
|
|
3227
3228
|
customData: e = {},
|
|
3228
3229
|
fromTemplate: s = !1,
|
|
@@ -3292,7 +3293,7 @@ class Lt {
|
|
|
3292
3293
|
hasControls: !1,
|
|
3293
3294
|
id: "background",
|
|
3294
3295
|
backgroundType: "color",
|
|
3295
|
-
backgroundId: `background-${
|
|
3296
|
+
backgroundId: `background-${K()}`
|
|
3296
3297
|
}, { withoutSelection: !0 }), this.refresh();
|
|
3297
3298
|
}
|
|
3298
3299
|
/**
|
|
@@ -3309,9 +3310,9 @@ class Lt {
|
|
|
3309
3310
|
hasControls: !1,
|
|
3310
3311
|
id: "background",
|
|
3311
3312
|
backgroundType: "gradient",
|
|
3312
|
-
backgroundId: `background-${
|
|
3313
|
+
backgroundId: `background-${K()}`
|
|
3313
3314
|
}, { withoutSelection: !0 }), this.refresh();
|
|
3314
|
-
const e =
|
|
3315
|
+
const e = _t._createFabricGradient(t);
|
|
3315
3316
|
this.backgroundObject.set("fill", e), this.editor.canvas.requestRenderAll();
|
|
3316
3317
|
}
|
|
3317
3318
|
/**
|
|
@@ -3319,7 +3320,7 @@ class Lt {
|
|
|
3319
3320
|
* @param source - источник изображения (URL или File)
|
|
3320
3321
|
*/
|
|
3321
3322
|
_createImageBackground(t, e) {
|
|
3322
|
-
return
|
|
3323
|
+
return W(this, null, function* () {
|
|
3323
3324
|
var n;
|
|
3324
3325
|
const { image: s } = (n = yield this.editor.imageManager.importImage({
|
|
3325
3326
|
source: t,
|
|
@@ -3337,7 +3338,7 @@ class Lt {
|
|
|
3337
3338
|
hasControls: !1,
|
|
3338
3339
|
id: "background",
|
|
3339
3340
|
backgroundType: "image",
|
|
3340
|
-
backgroundId: `background-${
|
|
3341
|
+
backgroundId: `background-${K()}`,
|
|
3341
3342
|
customData: e
|
|
3342
3343
|
}), this._removeCurrentBackground(), this.backgroundObject = s, this.refresh();
|
|
3343
3344
|
});
|
|
@@ -3371,8 +3372,8 @@ class Lt {
|
|
|
3371
3372
|
{ offset: 0, color: "#000000" },
|
|
3372
3373
|
{ offset: 1, color: "#ffffff" }
|
|
3373
3374
|
], t.type === "linear") {
|
|
3374
|
-
const u = t.angle * Math.PI / 180, f =
|
|
3375
|
-
return new
|
|
3375
|
+
const u = t.angle * Math.PI / 180, f = _t._angleToCoords(u);
|
|
3376
|
+
return new We({
|
|
3376
3377
|
type: "linear",
|
|
3377
3378
|
gradientUnits: "percentage",
|
|
3378
3379
|
coords: f,
|
|
@@ -3391,7 +3392,7 @@ class Lt {
|
|
|
3391
3392
|
r1: 0,
|
|
3392
3393
|
r2: d / 100
|
|
3393
3394
|
};
|
|
3394
|
-
return new
|
|
3395
|
+
return new We({
|
|
3395
3396
|
type: "radial",
|
|
3396
3397
|
gradientUnits: "percentage",
|
|
3397
3398
|
coords: l,
|
|
@@ -3426,7 +3427,7 @@ class Lt {
|
|
|
3426
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;
|
|
3427
3428
|
}
|
|
3428
3429
|
}
|
|
3429
|
-
class
|
|
3430
|
+
class fe {
|
|
3430
3431
|
constructor({ editor: t }) {
|
|
3431
3432
|
this.editor = t;
|
|
3432
3433
|
}
|
|
@@ -3441,7 +3442,7 @@ class le {
|
|
|
3441
3442
|
const { canvas: s, historyManager: n } = this.editor;
|
|
3442
3443
|
n.suspendHistory();
|
|
3443
3444
|
const o = t || s.getActiveObject();
|
|
3444
|
-
o && (o instanceof
|
|
3445
|
+
o && (o instanceof F ? o.getObjects().forEach((i) => {
|
|
3445
3446
|
s.bringObjectToFront(i);
|
|
3446
3447
|
}) : s.bringObjectToFront(o), s.renderAll(), n.resumeHistory(), e || n.saveState(), s.fire("editor:object-bring-to-front", {
|
|
3447
3448
|
object: o,
|
|
@@ -3459,7 +3460,7 @@ class le {
|
|
|
3459
3460
|
const { canvas: s, historyManager: n } = this.editor;
|
|
3460
3461
|
n.suspendHistory();
|
|
3461
3462
|
const o = t || s.getActiveObject();
|
|
3462
|
-
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", {
|
|
3463
3464
|
object: o,
|
|
3464
3465
|
withoutSave: e
|
|
3465
3466
|
}));
|
|
@@ -3482,7 +3483,7 @@ class le {
|
|
|
3482
3483
|
o.suspendHistory();
|
|
3483
3484
|
const r = t || s.getActiveObject();
|
|
3484
3485
|
if (r) {
|
|
3485
|
-
if (r instanceof
|
|
3486
|
+
if (r instanceof F) {
|
|
3486
3487
|
const c = r.getObjects();
|
|
3487
3488
|
for (let d = c.length - 1; d >= 0; d -= 1)
|
|
3488
3489
|
s.sendObjectToBack(c[d]);
|
|
@@ -3510,7 +3511,7 @@ class le {
|
|
|
3510
3511
|
} = this.editor;
|
|
3511
3512
|
o.suspendHistory();
|
|
3512
3513
|
const r = t || s.getActiveObject();
|
|
3513
|
-
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", {
|
|
3514
3515
|
object: r,
|
|
3515
3516
|
withoutSave: e
|
|
3516
3517
|
}));
|
|
@@ -3580,13 +3581,13 @@ class tn {
|
|
|
3580
3581
|
*/
|
|
3581
3582
|
addRectangle(d = {}, { withoutSelection: r, withoutAdding: c } = {}) {
|
|
3582
3583
|
var l = d, {
|
|
3583
|
-
id: t = `rect-${
|
|
3584
|
+
id: t = `rect-${K()}`,
|
|
3584
3585
|
left: e,
|
|
3585
3586
|
top: s,
|
|
3586
3587
|
width: n = 100,
|
|
3587
3588
|
height: o = 100,
|
|
3588
3589
|
fill: i = "blue"
|
|
3589
|
-
} = l, a =
|
|
3590
|
+
} = l, a = gt(l, [
|
|
3590
3591
|
"id",
|
|
3591
3592
|
"left",
|
|
3592
3593
|
"top",
|
|
@@ -3594,7 +3595,7 @@ class tn {
|
|
|
3594
3595
|
"height",
|
|
3595
3596
|
"fill"
|
|
3596
3597
|
]);
|
|
3597
|
-
const { canvas: u } = this.editor, f = new fs(
|
|
3598
|
+
const { canvas: u } = this.editor, f = new fs(z({
|
|
3598
3599
|
id: t,
|
|
3599
3600
|
left: e,
|
|
3600
3601
|
top: s,
|
|
@@ -3622,19 +3623,19 @@ class tn {
|
|
|
3622
3623
|
*/
|
|
3623
3624
|
addCircle(c = {}, { withoutSelection: a, withoutAdding: r } = {}) {
|
|
3624
3625
|
var d = c, {
|
|
3625
|
-
id: t = `circle-${
|
|
3626
|
+
id: t = `circle-${K()}`,
|
|
3626
3627
|
left: e,
|
|
3627
3628
|
top: s,
|
|
3628
3629
|
radius: n = 50,
|
|
3629
3630
|
fill: o = "green"
|
|
3630
|
-
} = d, i =
|
|
3631
|
+
} = d, i = gt(d, [
|
|
3631
3632
|
"id",
|
|
3632
3633
|
"left",
|
|
3633
3634
|
"top",
|
|
3634
3635
|
"radius",
|
|
3635
3636
|
"fill"
|
|
3636
3637
|
]);
|
|
3637
|
-
const { canvas: l } = this.editor, u = new gs(
|
|
3638
|
+
const { canvas: l } = this.editor, u = new gs(z({
|
|
3638
3639
|
id: t,
|
|
3639
3640
|
left: e,
|
|
3640
3641
|
top: s,
|
|
@@ -3662,13 +3663,13 @@ class tn {
|
|
|
3662
3663
|
*/
|
|
3663
3664
|
addTriangle(d = {}, { withoutSelection: r, withoutAdding: c } = {}) {
|
|
3664
3665
|
var l = d, {
|
|
3665
|
-
id: t = `triangle-${
|
|
3666
|
+
id: t = `triangle-${K()}`,
|
|
3666
3667
|
left: e,
|
|
3667
3668
|
top: s,
|
|
3668
3669
|
width: n = 100,
|
|
3669
3670
|
height: o = 100,
|
|
3670
3671
|
fill: i = "yellow"
|
|
3671
|
-
} = l, a =
|
|
3672
|
+
} = l, a = gt(l, [
|
|
3672
3673
|
"id",
|
|
3673
3674
|
"left",
|
|
3674
3675
|
"top",
|
|
@@ -3676,7 +3677,7 @@ class tn {
|
|
|
3676
3677
|
"height",
|
|
3677
3678
|
"fill"
|
|
3678
3679
|
]);
|
|
3679
|
-
const { canvas: u } = this.editor, f = new ps(
|
|
3680
|
+
const { canvas: u } = this.editor, f = new ps(z({
|
|
3680
3681
|
id: t,
|
|
3681
3682
|
left: e,
|
|
3682
3683
|
top: s,
|
|
@@ -3715,10 +3716,10 @@ class en {
|
|
|
3715
3716
|
* Асинхронное клонирование для внутреннего буфера
|
|
3716
3717
|
*/
|
|
3717
3718
|
_cloneToInternalClipboard(t) {
|
|
3718
|
-
return
|
|
3719
|
+
return W(this, null, function* () {
|
|
3719
3720
|
const { canvas: e, errorManager: s } = this.editor;
|
|
3720
3721
|
try {
|
|
3721
|
-
const n = yield t.clone(
|
|
3722
|
+
const n = yield t.clone(ce);
|
|
3722
3723
|
this.clipboard = n, e.fire("editor:object-copied", { object: n });
|
|
3723
3724
|
} catch (n) {
|
|
3724
3725
|
s.emitError({
|
|
@@ -3735,7 +3736,7 @@ class en {
|
|
|
3735
3736
|
* Копирование в системный буфер обмена
|
|
3736
3737
|
*/
|
|
3737
3738
|
_copyToSystemClipboard(t) {
|
|
3738
|
-
return
|
|
3739
|
+
return W(this, null, function* () {
|
|
3739
3740
|
const { errorManager: e } = this.editor;
|
|
3740
3741
|
if (typeof ClipboardItem == "undefined" || !navigator.clipboard)
|
|
3741
3742
|
return e.emitWarning({
|
|
@@ -3745,7 +3746,7 @@ class en {
|
|
|
3745
3746
|
message: "navigator.clipboard не поддерживается в этом браузере или отсутствует HTTPS-соединение."
|
|
3746
3747
|
}), !1;
|
|
3747
3748
|
try {
|
|
3748
|
-
const s = t.toObject(
|
|
3749
|
+
const s = t.toObject(ce), n = JSON.stringify(s);
|
|
3749
3750
|
return t.type === "image" ? this._copyImageToClipboard(t, n) : this._copyTextToClipboard(n);
|
|
3750
3751
|
} catch (s) {
|
|
3751
3752
|
return e.emitError({
|
|
@@ -3762,7 +3763,7 @@ class en {
|
|
|
3762
3763
|
* Копирование изображения в буфер обмена
|
|
3763
3764
|
*/
|
|
3764
3765
|
_copyImageToClipboard(t, e) {
|
|
3765
|
-
return
|
|
3766
|
+
return W(this, null, function* () {
|
|
3766
3767
|
try {
|
|
3767
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);
|
|
3768
3769
|
for (let l = 0; l < a.length; l += 1)
|
|
@@ -3784,9 +3785,9 @@ class en {
|
|
|
3784
3785
|
* Копирование текста в буфер обмена
|
|
3785
3786
|
*/
|
|
3786
3787
|
_copyTextToClipboard(t) {
|
|
3787
|
-
return
|
|
3788
|
+
return W(this, null, function* () {
|
|
3788
3789
|
try {
|
|
3789
|
-
const e = `${
|
|
3790
|
+
const e = `${Ve}${t}`;
|
|
3790
3791
|
return yield navigator.clipboard.writeText(e), console.info("Text copied to clipboard successfully"), !0;
|
|
3791
3792
|
} catch (e) {
|
|
3792
3793
|
const { errorManager: s } = this.editor;
|
|
@@ -3806,7 +3807,7 @@ class en {
|
|
|
3806
3807
|
*/
|
|
3807
3808
|
_addClonedObjectToCanvas(t) {
|
|
3808
3809
|
const { canvas: e, historyManager: s } = this.editor;
|
|
3809
|
-
if (e.discardActiveObject(), t instanceof
|
|
3810
|
+
if (e.discardActiveObject(), t instanceof F) {
|
|
3810
3811
|
s.suspendHistory(), t.canvas = e, t.forEachObject((n) => {
|
|
3811
3812
|
e.add(n);
|
|
3812
3813
|
}), e.setActiveObject(t), e.requestRenderAll(), s.resumeHistory(), s.saveState();
|
|
@@ -3819,7 +3820,7 @@ class en {
|
|
|
3819
3820
|
* @param source - источник изображения (data URL или URL)
|
|
3820
3821
|
*/
|
|
3821
3822
|
_handleImageImport(t) {
|
|
3822
|
-
return
|
|
3823
|
+
return W(this, null, function* () {
|
|
3823
3824
|
var s;
|
|
3824
3825
|
const { image: e } = (s = yield this.editor.imageManager.importImage({
|
|
3825
3826
|
source: t,
|
|
@@ -3835,18 +3836,18 @@ class en {
|
|
|
3835
3836
|
* @fires editor:object-pasted
|
|
3836
3837
|
*/
|
|
3837
3838
|
copyPaste(t) {
|
|
3838
|
-
return
|
|
3839
|
+
return W(this, null, function* () {
|
|
3839
3840
|
const { canvas: e } = this.editor, s = t || e.getActiveObject();
|
|
3840
3841
|
if (!s || s.locked) return !1;
|
|
3841
3842
|
try {
|
|
3842
|
-
const n = yield s.clone(
|
|
3843
|
-
return n instanceof
|
|
3843
|
+
const n = yield s.clone(ce);
|
|
3844
|
+
return n instanceof F && n.forEachObject((o) => {
|
|
3844
3845
|
o.set({
|
|
3845
|
-
id: `${o.type}-${
|
|
3846
|
+
id: `${o.type}-${K()}`,
|
|
3846
3847
|
evented: !0
|
|
3847
3848
|
});
|
|
3848
3849
|
}), n.set({
|
|
3849
|
-
id: `${n.type}-${
|
|
3850
|
+
id: `${n.type}-${K()}`,
|
|
3850
3851
|
left: n.left + 10,
|
|
3851
3852
|
top: n.top + 10,
|
|
3852
3853
|
evented: !0
|
|
@@ -3870,14 +3871,14 @@ class en {
|
|
|
3870
3871
|
* @param event.clipboardData.items — элементы буфера обмена
|
|
3871
3872
|
*/
|
|
3872
3873
|
handlePasteEvent(e) {
|
|
3873
|
-
return
|
|
3874
|
+
return W(this, arguments, function* ({ clipboardData: t }) {
|
|
3874
3875
|
var r;
|
|
3875
3876
|
if (!((r = t == null ? void 0 : t.items) != null && r.length)) {
|
|
3876
3877
|
this.paste();
|
|
3877
3878
|
return;
|
|
3878
3879
|
}
|
|
3879
3880
|
const s = t.getData("text/plain");
|
|
3880
|
-
if (s && s.startsWith(
|
|
3881
|
+
if (s && s.startsWith(Ve)) {
|
|
3881
3882
|
this.paste();
|
|
3882
3883
|
return;
|
|
3883
3884
|
}
|
|
@@ -3921,18 +3922,18 @@ class en {
|
|
|
3921
3922
|
* @fires editor:object-pasted
|
|
3922
3923
|
*/
|
|
3923
3924
|
paste() {
|
|
3924
|
-
return
|
|
3925
|
+
return W(this, null, function* () {
|
|
3925
3926
|
const { canvas: t } = this.editor;
|
|
3926
3927
|
if (!this.clipboard) return !1;
|
|
3927
3928
|
try {
|
|
3928
|
-
const e = yield this.clipboard.clone(
|
|
3929
|
-
return t.discardActiveObject(), e instanceof
|
|
3929
|
+
const e = yield this.clipboard.clone(ce);
|
|
3930
|
+
return t.discardActiveObject(), e instanceof F && e.forEachObject((s) => {
|
|
3930
3931
|
s.set({
|
|
3931
|
-
id: `${s.type}-${
|
|
3932
|
+
id: `${s.type}-${K()}`,
|
|
3932
3933
|
evented: !0
|
|
3933
3934
|
});
|
|
3934
3935
|
}), e.set({
|
|
3935
|
-
id: `${e.type}-${
|
|
3936
|
+
id: `${e.type}-${K()}`,
|
|
3936
3937
|
left: e.left + 10,
|
|
3937
3938
|
top: e.top + 10,
|
|
3938
3939
|
evented: !0
|
|
@@ -3950,7 +3951,7 @@ class en {
|
|
|
3950
3951
|
});
|
|
3951
3952
|
}
|
|
3952
3953
|
}
|
|
3953
|
-
class
|
|
3954
|
+
class ge {
|
|
3954
3955
|
constructor({ editor: t }) {
|
|
3955
3956
|
this.editor = t;
|
|
3956
3957
|
}
|
|
@@ -3976,9 +3977,9 @@ class he {
|
|
|
3976
3977
|
editable: !1,
|
|
3977
3978
|
locked: !0
|
|
3978
3979
|
};
|
|
3979
|
-
i.set(a), !e &&
|
|
3980
|
+
i.set(a), !e && ge._isGroupOrSelection(i) && i.getObjects().forEach((c) => {
|
|
3980
3981
|
c.set(a);
|
|
3981
|
-
}), i instanceof
|
|
3982
|
+
}), i instanceof at && i.isEditing && i.exitEditing(), n.renderAll(), s || o.saveState(), n.fire("editor:object-locked", {
|
|
3982
3983
|
object: i,
|
|
3983
3984
|
skipInnerObjects: e,
|
|
3984
3985
|
withoutSave: s
|
|
@@ -4005,7 +4006,7 @@ class he {
|
|
|
4005
4006
|
editable: !0,
|
|
4006
4007
|
locked: !1
|
|
4007
4008
|
};
|
|
4008
|
-
o.set(i),
|
|
4009
|
+
o.set(i), ge._isGroupOrSelection(o) && o.getObjects().forEach((a) => {
|
|
4009
4010
|
a.set(i);
|
|
4010
4011
|
}), s.renderAll(), e || n.saveState(), s.fire("editor:object-unlocked", {
|
|
4011
4012
|
object: o,
|
|
@@ -4013,7 +4014,7 @@ class he {
|
|
|
4013
4014
|
});
|
|
4014
4015
|
}
|
|
4015
4016
|
static _isGroupOrSelection(t) {
|
|
4016
|
-
return t instanceof
|
|
4017
|
+
return t instanceof F || t instanceof xt;
|
|
4017
4018
|
}
|
|
4018
4019
|
}
|
|
4019
4020
|
class sn {
|
|
@@ -4028,7 +4029,7 @@ class sn {
|
|
|
4028
4029
|
if (Array.isArray(t))
|
|
4029
4030
|
return t.length > 0 ? t : null;
|
|
4030
4031
|
const e = t || this.editor.canvas.getActiveObject();
|
|
4031
|
-
return !e || !(e instanceof
|
|
4032
|
+
return !e || !(e instanceof F) ? null : e.getObjects();
|
|
4032
4033
|
}
|
|
4033
4034
|
/**
|
|
4034
4035
|
* Получить группы для разгруппировки
|
|
@@ -4036,20 +4037,20 @@ class sn {
|
|
|
4036
4037
|
*/
|
|
4037
4038
|
_getGroupsToUngroup(t) {
|
|
4038
4039
|
if (Array.isArray(t)) {
|
|
4039
|
-
const s = t.filter((n) => n instanceof
|
|
4040
|
+
const s = t.filter((n) => n instanceof xt);
|
|
4040
4041
|
return s.length > 0 ? s : null;
|
|
4041
4042
|
}
|
|
4042
|
-
if (t instanceof
|
|
4043
|
-
const s = t.getObjects().filter((n) => n instanceof
|
|
4043
|
+
if (t instanceof F) {
|
|
4044
|
+
const s = t.getObjects().filter((n) => n instanceof xt);
|
|
4044
4045
|
return s.length > 0 ? s : null;
|
|
4045
4046
|
}
|
|
4046
4047
|
const e = t || this.editor.canvas.getActiveObject();
|
|
4047
4048
|
if (!e) return null;
|
|
4048
|
-
if (e instanceof
|
|
4049
|
-
const s = e.getObjects().filter((n) => n instanceof
|
|
4049
|
+
if (e instanceof F) {
|
|
4050
|
+
const s = e.getObjects().filter((n) => n instanceof xt);
|
|
4050
4051
|
return s.length > 0 ? s : null;
|
|
4051
4052
|
}
|
|
4052
|
-
return e instanceof
|
|
4053
|
+
return e instanceof xt ? [e] : null;
|
|
4053
4054
|
}
|
|
4054
4055
|
/**
|
|
4055
4056
|
* Группировка объектов
|
|
@@ -4066,8 +4067,8 @@ class sn {
|
|
|
4066
4067
|
if (!o) return null;
|
|
4067
4068
|
try {
|
|
4068
4069
|
n.suspendHistory();
|
|
4069
|
-
const i = new
|
|
4070
|
-
id: `group-${
|
|
4070
|
+
const i = new xt(o, {
|
|
4071
|
+
id: `group-${K()}`
|
|
4071
4072
|
});
|
|
4072
4073
|
o.forEach((r) => s.remove(r)), s.add(i), s.setActiveObject(i), s.requestRenderAll();
|
|
4073
4074
|
const a = {
|
|
@@ -4102,7 +4103,7 @@ class sn {
|
|
|
4102
4103
|
s.add(l), i.push(l);
|
|
4103
4104
|
});
|
|
4104
4105
|
});
|
|
4105
|
-
const a = new
|
|
4106
|
+
const a = new F(i, {
|
|
4106
4107
|
canvas: s
|
|
4107
4108
|
});
|
|
4108
4109
|
s.setActiveObject(a), s.requestRenderAll();
|
|
@@ -4128,11 +4129,11 @@ class nn {
|
|
|
4128
4129
|
selectAll() {
|
|
4129
4130
|
const { canvas: t, canvasManager: e, objectLockManager: s } = this.editor;
|
|
4130
4131
|
t.discardActiveObject();
|
|
4131
|
-
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];
|
|
4132
4133
|
o && s.lockObject({ object: i, skipInnerObjects: !0, withoutSave: !0 }), t.setActiveObject(i), t.requestRenderAll(), t.fire("editor:all-objects-selected", { selected: i });
|
|
4133
4134
|
}
|
|
4134
4135
|
}
|
|
4135
|
-
class
|
|
4136
|
+
class Re {
|
|
4136
4137
|
constructor({ editor: t }) {
|
|
4137
4138
|
this.editor = t;
|
|
4138
4139
|
}
|
|
@@ -4179,7 +4180,7 @@ class Oe {
|
|
|
4179
4180
|
s || o.suspendHistory();
|
|
4180
4181
|
const r = [];
|
|
4181
4182
|
if (a.forEach((d) => {
|
|
4182
|
-
if (
|
|
4183
|
+
if (Re._isUngroupableGroup(d)) {
|
|
4183
4184
|
const l = this._handleGroupDeletion(d);
|
|
4184
4185
|
r.push(...l);
|
|
4185
4186
|
return;
|
|
@@ -4194,7 +4195,7 @@ class Oe {
|
|
|
4194
4195
|
return n.fire("editor:objects-deleted", c), c;
|
|
4195
4196
|
}
|
|
4196
4197
|
}
|
|
4197
|
-
const
|
|
4198
|
+
const St = {
|
|
4198
4199
|
IMAGE_MANAGER: {
|
|
4199
4200
|
/**
|
|
4200
4201
|
* Некорректный Content-Type изображения
|
|
@@ -4299,7 +4300,7 @@ const At = {
|
|
|
4299
4300
|
APPLY_FAILED: "TEMPLATE_APPLY_FAILED"
|
|
4300
4301
|
}
|
|
4301
4302
|
};
|
|
4302
|
-
class
|
|
4303
|
+
class te {
|
|
4303
4304
|
constructor({ editor: t }) {
|
|
4304
4305
|
this._buffer = [], this.editor = t;
|
|
4305
4306
|
}
|
|
@@ -4326,7 +4327,7 @@ class qt {
|
|
|
4326
4327
|
* @fires editor:error
|
|
4327
4328
|
*/
|
|
4328
4329
|
emitError({ origin: t = "ImageEditor", method: e = "Unknown Method", code: s, data: n, message: o }) {
|
|
4329
|
-
if (!
|
|
4330
|
+
if (!te.isValidErrorCode(s)) {
|
|
4330
4331
|
console.warn("Неизвестный код ошибки: ", { code: s, origin: t, method: e });
|
|
4331
4332
|
return;
|
|
4332
4333
|
}
|
|
@@ -4340,7 +4341,7 @@ class qt {
|
|
|
4340
4341
|
message: i,
|
|
4341
4342
|
data: n
|
|
4342
4343
|
};
|
|
4343
|
-
this._buffer.push(
|
|
4344
|
+
this._buffer.push(z({
|
|
4344
4345
|
type: "editor:error"
|
|
4345
4346
|
}, a)), this.editor.canvas.fire("editor:error", a);
|
|
4346
4347
|
}
|
|
@@ -4355,7 +4356,7 @@ class qt {
|
|
|
4355
4356
|
* @fires editor:warning
|
|
4356
4357
|
*/
|
|
4357
4358
|
emitWarning({ origin: t = "ImageEditor", method: e = "Unknown Method", code: s, message: n, data: o }) {
|
|
4358
|
-
if (!
|
|
4359
|
+
if (!te.isValidErrorCode(s)) {
|
|
4359
4360
|
console.warn("Неизвестный код предупреждения: ", { code: s, origin: t, method: e });
|
|
4360
4361
|
return;
|
|
4361
4362
|
}
|
|
@@ -4368,7 +4369,7 @@ class qt {
|
|
|
4368
4369
|
message: i,
|
|
4369
4370
|
data: o
|
|
4370
4371
|
};
|
|
4371
|
-
this._buffer.push(
|
|
4372
|
+
this._buffer.push(z({
|
|
4372
4373
|
type: "editor:warning"
|
|
4373
4374
|
}, a)), this.editor.canvas.fire("editor:warning", a);
|
|
4374
4375
|
}
|
|
@@ -4378,7 +4379,7 @@ class qt {
|
|
|
4378
4379
|
* @returns true, если код допустим, иначе false
|
|
4379
4380
|
*/
|
|
4380
4381
|
static isValidErrorCode(t) {
|
|
4381
|
-
return t ? Object.values(
|
|
4382
|
+
return t ? Object.values(St).some((e) => Object.values(e).includes(t)) : !1;
|
|
4382
4383
|
}
|
|
4383
4384
|
}
|
|
4384
4385
|
class on {
|
|
@@ -4466,11 +4467,11 @@ class on {
|
|
|
4466
4467
|
this.currentBounds = this.calculatePanBounds();
|
|
4467
4468
|
}
|
|
4468
4469
|
}
|
|
4469
|
-
const
|
|
4470
|
+
const ct = ({
|
|
4470
4471
|
value: h,
|
|
4471
4472
|
min: t,
|
|
4472
4473
|
max: e
|
|
4473
|
-
}) => Math.min(Math.max(h, t), e),
|
|
4474
|
+
}) => Math.min(Math.max(h, t), e), Bt = class Bt extends at {
|
|
4474
4475
|
constructor(t, e = {}) {
|
|
4475
4476
|
var s, n, o, i, a, r, c, d, l;
|
|
4476
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();
|
|
@@ -4495,7 +4496,7 @@ const lt = ({
|
|
|
4495
4496
|
}
|
|
4496
4497
|
_getTransformedDimensions(t = {}) {
|
|
4497
4498
|
const { width: e, height: s } = this._getBackgroundDimensions();
|
|
4498
|
-
return super._getTransformedDimensions(
|
|
4499
|
+
return super._getTransformedDimensions(wt(z({}, t), {
|
|
4499
4500
|
width: e,
|
|
4500
4501
|
height: s
|
|
4501
4502
|
}));
|
|
@@ -4505,7 +4506,7 @@ const lt = ({
|
|
|
4505
4506
|
*/
|
|
4506
4507
|
toObject(t = []) {
|
|
4507
4508
|
const e = super.toObject(t);
|
|
4508
|
-
return
|
|
4509
|
+
return wt(z({}, e), {
|
|
4509
4510
|
backgroundOpacity: this.backgroundOpacity,
|
|
4510
4511
|
paddingTop: this.paddingTop,
|
|
4511
4512
|
paddingRight: this.paddingRight,
|
|
@@ -4522,7 +4523,7 @@ const lt = ({
|
|
|
4522
4523
|
const e = this._getEffectiveBackgroundFill();
|
|
4523
4524
|
if (e && e) {
|
|
4524
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;
|
|
4525
|
-
t.save(),
|
|
4526
|
+
t.save(), Bt._renderRoundedRect({
|
|
4526
4527
|
ctx: t,
|
|
4527
4528
|
height: c,
|
|
4528
4529
|
left: l,
|
|
@@ -4544,10 +4545,10 @@ const lt = ({
|
|
|
4544
4545
|
var i, a, r, c;
|
|
4545
4546
|
const s = t / 2, n = e / 2, o = Math.min(s, n);
|
|
4546
4547
|
return {
|
|
4547
|
-
bottomLeft:
|
|
4548
|
-
bottomRight:
|
|
4549
|
-
topLeft:
|
|
4550
|
-
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 })
|
|
4551
4552
|
};
|
|
4552
4553
|
}
|
|
4553
4554
|
_getPadding() {
|
|
@@ -4563,12 +4564,12 @@ const lt = ({
|
|
|
4563
4564
|
var n;
|
|
4564
4565
|
const t = this.backgroundColor;
|
|
4565
4566
|
if (!t) return null;
|
|
4566
|
-
const e =
|
|
4567
|
+
const e = ct({ value: (n = this.backgroundOpacity) != null ? n : 1, min: 0, max: 1 });
|
|
4567
4568
|
let s;
|
|
4568
4569
|
try {
|
|
4569
4570
|
s = new ms(t);
|
|
4570
4571
|
} catch (o) {
|
|
4571
|
-
return
|
|
4572
|
+
return te.emitError({
|
|
4572
4573
|
origin: "BackgroundTextbox",
|
|
4573
4574
|
method: "_getEffectiveBackgroundFill",
|
|
4574
4575
|
code: "INVALID_COLOR_VALUE",
|
|
@@ -4591,7 +4592,7 @@ const lt = ({
|
|
|
4591
4592
|
topRight: d,
|
|
4592
4593
|
bottomRight: l,
|
|
4593
4594
|
bottomLeft: u
|
|
4594
|
-
} = 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 });
|
|
4595
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();
|
|
4596
4597
|
}
|
|
4597
4598
|
/**
|
|
@@ -4605,8 +4606,8 @@ const lt = ({
|
|
|
4605
4606
|
s !== t && (this.width = Math.max(0, s)), n !== e && (this.height = Math.max(0, n));
|
|
4606
4607
|
}
|
|
4607
4608
|
};
|
|
4608
|
-
|
|
4609
|
-
...Array.isArray(
|
|
4609
|
+
Bt.type = "background-textbox", Bt.cacheProperties = [
|
|
4610
|
+
...Array.isArray(at.cacheProperties) ? at.cacheProperties : [],
|
|
4610
4611
|
"backgroundColor",
|
|
4611
4612
|
"backgroundOpacity",
|
|
4612
4613
|
"paddingTop",
|
|
@@ -4617,8 +4618,8 @@ Rt.type = "background-textbox", Rt.cacheProperties = [
|
|
|
4617
4618
|
"radiusTopRight",
|
|
4618
4619
|
"radiusBottomRight",
|
|
4619
4620
|
"radiusBottomLeft"
|
|
4620
|
-
],
|
|
4621
|
-
...Array.isArray(
|
|
4621
|
+
], Bt.stateProperties = [
|
|
4622
|
+
...Array.isArray(at.stateProperties) ? at.stateProperties : [],
|
|
4622
4623
|
"backgroundColor",
|
|
4623
4624
|
"backgroundOpacity",
|
|
4624
4625
|
"paddingTop",
|
|
@@ -4630,10 +4631,10 @@ Rt.type = "background-textbox", Rt.cacheProperties = [
|
|
|
4630
4631
|
"radiusBottomRight",
|
|
4631
4632
|
"radiusBottomLeft"
|
|
4632
4633
|
];
|
|
4633
|
-
let
|
|
4634
|
+
let pe = Bt;
|
|
4634
4635
|
const an = () => {
|
|
4635
4636
|
var h;
|
|
4636
|
-
(h =
|
|
4637
|
+
(h = Ue) != null && h.setClass && Ue.setClass(pe, "background-textbox");
|
|
4637
4638
|
}, rn = ({ textbox: h }) => {
|
|
4638
4639
|
var s, n;
|
|
4639
4640
|
if (!h.isEditing) return null;
|
|
@@ -4651,7 +4652,7 @@ const an = () => {
|
|
|
4651
4652
|
if (!t) return !1;
|
|
4652
4653
|
const e = (n = (s = h.text) == null ? void 0 : s.length) != null ? n : 0;
|
|
4653
4654
|
return e <= 0 ? !1 : t.start <= 0 && t.end >= e;
|
|
4654
|
-
},
|
|
4655
|
+
}, ye = ({
|
|
4655
4656
|
textbox: h,
|
|
4656
4657
|
styles: t,
|
|
4657
4658
|
range: e
|
|
@@ -4659,7 +4660,7 @@ const an = () => {
|
|
|
4659
4660
|
if (!t || !Object.keys(t).length) return !1;
|
|
4660
4661
|
const { start: s, end: n } = e;
|
|
4661
4662
|
return n <= s ? !1 : (h.setSelectionStyles(t, s, n), !0);
|
|
4662
|
-
},
|
|
4663
|
+
}, Ke = ({
|
|
4663
4664
|
textbox: h,
|
|
4664
4665
|
range: t,
|
|
4665
4666
|
property: e
|
|
@@ -4673,15 +4674,15 @@ const an = () => {
|
|
|
4673
4674
|
);
|
|
4674
4675
|
if (s.length)
|
|
4675
4676
|
return (n = s[0]) == null ? void 0 : n[e];
|
|
4676
|
-
},
|
|
4677
|
-
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 {
|
|
4678
4679
|
constructor({ editor: t }) {
|
|
4679
4680
|
var e;
|
|
4680
4681
|
this._handleTextEditingEntered = (s) => {
|
|
4681
4682
|
var r;
|
|
4682
4683
|
this.isTextEditingActive = !0;
|
|
4683
4684
|
const { target: n } = s;
|
|
4684
|
-
if (!
|
|
4685
|
+
if (!P._isTextbox(n)) return;
|
|
4685
4686
|
const o = (r = n.originY) != null ? r : "top", i = n.getPointByOrigin("center", o);
|
|
4686
4687
|
this._ensureEditingAnchorState().set(n, {
|
|
4687
4688
|
originY: o,
|
|
@@ -4690,19 +4691,22 @@ class k {
|
|
|
4690
4691
|
});
|
|
4691
4692
|
}, this._handleTextChanged = (s) => {
|
|
4692
4693
|
const { target: n } = s;
|
|
4693
|
-
if (!
|
|
4694
|
-
const { text: o = "", uppercase: i } = n,
|
|
4695
|
-
if (
|
|
4696
|
-
const
|
|
4697
|
-
|
|
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;
|
|
4698
4699
|
} else
|
|
4699
4700
|
n.textCaseRaw = o;
|
|
4700
|
-
|
|
4701
|
-
|
|
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);
|
|
4702
4706
|
}, this._handleTextEditingExited = (s) => {
|
|
4703
4707
|
var r, c, d;
|
|
4704
4708
|
const { target: n } = s;
|
|
4705
|
-
if (!
|
|
4709
|
+
if (!P._isTextbox(n)) return;
|
|
4706
4710
|
(r = this.editingAnchorState) == null || r.delete(n);
|
|
4707
4711
|
const o = (c = n.text) != null ? c : "";
|
|
4708
4712
|
if (!!n.uppercase) {
|
|
@@ -4710,16 +4714,16 @@ class k {
|
|
|
4710
4714
|
n.textCaseRaw = l;
|
|
4711
4715
|
} else
|
|
4712
4716
|
n.textCaseRaw = o;
|
|
4713
|
-
|
|
4717
|
+
P._roundTextboxDimensions({ textbox: n }) && (n.setCoords(), n.dirty = !0, this.canvas.requestRenderAll()), n.locked || n.set({
|
|
4714
4718
|
lockMovementX: !1,
|
|
4715
4719
|
lockMovementY: !1
|
|
4716
4720
|
}), setTimeout(() => {
|
|
4717
4721
|
this.isTextEditingActive = !1, this.editor.historyManager.saveState();
|
|
4718
4722
|
}, Vs);
|
|
4719
4723
|
}, this._handleObjectScaling = (s) => {
|
|
4720
|
-
var
|
|
4724
|
+
var se, ne, oe, Et, me, ie, Ft, Yt, Ht, Zt, Gt, Vt, Xt;
|
|
4721
4725
|
const { target: n, transform: o } = s;
|
|
4722
|
-
if (n instanceof
|
|
4726
|
+
if (n instanceof F || !P._isTextbox(n) || !o) return;
|
|
4723
4727
|
n.isScaling = !0;
|
|
4724
4728
|
const i = this._ensureScalingState(n), {
|
|
4725
4729
|
baseWidth: a,
|
|
@@ -4728,135 +4732,135 @@ class k {
|
|
|
4728
4732
|
basePadding: d,
|
|
4729
4733
|
baseRadii: l,
|
|
4730
4734
|
baseStyles: u
|
|
4731
|
-
} = i, f = typeof ((
|
|
4732
|
-
if (!A && !y && !
|
|
4733
|
-
const C = Math.abs((
|
|
4734
|
-
paddingTop:
|
|
4735
|
-
paddingRight:
|
|
4736
|
-
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,
|
|
4737
4741
|
paddingLeft: N = 0,
|
|
4738
|
-
radiusTopLeft:
|
|
4739
|
-
radiusTopRight:
|
|
4740
|
-
radiusBottomRight:
|
|
4741
|
-
radiusBottomLeft:
|
|
4742
|
-
fontSize:
|
|
4743
|
-
width:
|
|
4744
|
-
originX:
|
|
4745
|
-
} = 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 ? {
|
|
4746
4750
|
top: Math.max(0, d.top * S),
|
|
4747
4751
|
right: Math.max(0, d.right * S),
|
|
4748
4752
|
bottom: Math.max(0, d.bottom * S),
|
|
4749
4753
|
left: Math.max(0, d.left * S)
|
|
4750
|
-
} : d,
|
|
4754
|
+
} : d, k = X ? {
|
|
4751
4755
|
topLeft: Math.max(0, l.topLeft * S),
|
|
4752
4756
|
topRight: Math.max(0, l.topRight * S),
|
|
4753
4757
|
bottomRight: Math.max(0, l.bottomRight * S),
|
|
4754
4758
|
bottomLeft: Math.max(0, l.bottomLeft * S)
|
|
4755
|
-
} : l,
|
|
4759
|
+
} : l, Pt = Object.keys(u).length > 0;
|
|
4756
4760
|
let Q;
|
|
4757
|
-
if (j &&
|
|
4758
|
-
const
|
|
4759
|
-
Object.entries(u).forEach(([
|
|
4760
|
-
if (!
|
|
4761
|
-
const
|
|
4762
|
-
Object.entries(
|
|
4763
|
-
if (!
|
|
4764
|
-
const
|
|
4765
|
-
typeof
|
|
4766
|
-
}), Object.keys(
|
|
4767
|
-
}), Object.keys(
|
|
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);
|
|
4768
4772
|
}
|
|
4769
|
-
const
|
|
4770
|
-
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) {
|
|
4771
4775
|
n.set({ scaleX: 1, scaleY: 1 }), o.scaleX = 1, o.scaleY = 1;
|
|
4772
4776
|
return;
|
|
4773
4777
|
}
|
|
4774
4778
|
Q && (n.styles = Q), n.set({
|
|
4775
|
-
width:
|
|
4779
|
+
width: b,
|
|
4776
4780
|
fontSize: j ? I : c,
|
|
4777
|
-
paddingTop:
|
|
4778
|
-
paddingRight:
|
|
4779
|
-
paddingBottom:
|
|
4780
|
-
paddingLeft:
|
|
4781
|
-
radiusTopLeft:
|
|
4782
|
-
radiusTopRight:
|
|
4783
|
-
radiusBottomRight:
|
|
4784
|
-
radiusBottomLeft:
|
|
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,
|
|
4785
4789
|
scaleX: 1,
|
|
4786
4790
|
scaleY: 1
|
|
4787
4791
|
});
|
|
4788
|
-
const
|
|
4789
|
-
|
|
4790
|
-
const
|
|
4791
|
-
let
|
|
4792
|
-
|
|
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;
|
|
4793
4797
|
const { original: Mt } = o;
|
|
4794
|
-
Mt && (Mt.scaleX = 1, Mt.scaleY = 1, Mt.width =
|
|
4795
|
-
top:
|
|
4796
|
-
right:
|
|
4797
|
-
bottom:
|
|
4798
|
-
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
|
|
4799
4803
|
}, i.baseRadii = {
|
|
4800
|
-
topLeft:
|
|
4801
|
-
topRight:
|
|
4802
|
-
bottomRight:
|
|
4803
|
-
bottomLeft:
|
|
4804
|
-
}, 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;
|
|
4805
4809
|
}, this._handleObjectModified = (s) => {
|
|
4806
4810
|
var w, A, y;
|
|
4807
4811
|
const { target: n } = s;
|
|
4808
|
-
if (n instanceof
|
|
4809
|
-
const
|
|
4810
|
-
if (!
|
|
4812
|
+
if (n instanceof F) {
|
|
4813
|
+
const M = n.getObjects();
|
|
4814
|
+
if (!M.some((b) => P._isTextbox(b))) return;
|
|
4811
4815
|
const { scaleX: C = 1, scaleY: S = 1 } = n;
|
|
4812
4816
|
if (Math.abs(C - 1) < tt && Math.abs(S - 1) < tt) return;
|
|
4813
|
-
this.canvas.discardActiveObject(),
|
|
4814
|
-
var I,
|
|
4815
|
-
if (
|
|
4816
|
-
const N = (I =
|
|
4817
|
-
paddingTop:
|
|
4818
|
-
paddingRight:
|
|
4819
|
-
paddingBottom:
|
|
4820
|
-
paddingLeft:
|
|
4821
|
-
radiusTopLeft:
|
|
4822
|
-
radiusTopRight:
|
|
4823
|
-
radiusBottomRight:
|
|
4824
|
-
radiusBottomLeft:
|
|
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,
|
|
4825
4829
|
styles: Q
|
|
4826
|
-
} =
|
|
4827
|
-
paddingTop: Math.max(0,
|
|
4828
|
-
paddingRight: Math.max(0,
|
|
4829
|
-
paddingBottom: Math.max(0,
|
|
4830
|
-
paddingLeft: Math.max(0,
|
|
4831
|
-
},
|
|
4832
|
-
radiusTopLeft: Math.max(0,
|
|
4833
|
-
radiusTopRight: Math.max(0,
|
|
4834
|
-
radiusBottomRight: Math.max(0,
|
|
4835
|
-
radiusBottomLeft: Math.max(0,
|
|
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)
|
|
4835
|
+
}, Ct = {
|
|
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)
|
|
4836
4840
|
};
|
|
4837
|
-
let
|
|
4838
|
-
Q && Object.keys(Q).length > 0 && (
|
|
4839
|
-
Object.values(
|
|
4840
|
-
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));
|
|
4841
4845
|
});
|
|
4842
|
-
})),
|
|
4843
|
-
fontSize:
|
|
4844
|
-
width:
|
|
4846
|
+
})), b.set(wt(z(z({
|
|
4847
|
+
fontSize: Z,
|
|
4848
|
+
width: $,
|
|
4845
4849
|
scaleX: 1,
|
|
4846
4850
|
scaleY: 1
|
|
4847
|
-
},
|
|
4848
|
-
styles:
|
|
4849
|
-
})),
|
|
4851
|
+
}, nt), Ct), {
|
|
4852
|
+
styles: ut
|
|
4853
|
+
})), P._roundTextboxDimensions({ textbox: b });
|
|
4850
4854
|
}
|
|
4851
|
-
|
|
4855
|
+
b.setCoords();
|
|
4852
4856
|
});
|
|
4853
|
-
const
|
|
4857
|
+
const E = new F(M, {
|
|
4854
4858
|
canvas: this.canvas
|
|
4855
4859
|
});
|
|
4856
|
-
this.canvas.setActiveObject(
|
|
4860
|
+
this.canvas.setActiveObject(E), this.canvas.requestRenderAll();
|
|
4857
4861
|
return;
|
|
4858
4862
|
}
|
|
4859
|
-
if (!
|
|
4863
|
+
if (!P._isTextbox(n)) return;
|
|
4860
4864
|
n.isScaling = !1;
|
|
4861
4865
|
const o = this.scalingState.get(n);
|
|
4862
4866
|
if (this.scalingState.delete(n), !(o != null && o.hasWidthChange)) return;
|
|
@@ -4891,35 +4895,37 @@ class k {
|
|
|
4891
4895
|
* @param options — настройки текста
|
|
4892
4896
|
* @param flags — флаги поведения
|
|
4893
4897
|
*/
|
|
4894
|
-
addText(
|
|
4895
|
-
var
|
|
4896
|
-
id: t = `text-${
|
|
4898
|
+
addText(B = {}, { withoutSelection: I = !1, withoutSave: T = !1, withoutAdding: _ = !1 } = {}) {
|
|
4899
|
+
var N = B, {
|
|
4900
|
+
id: t = `text-${K()}`,
|
|
4897
4901
|
text: e = "Новый текст",
|
|
4898
|
-
|
|
4899
|
-
|
|
4900
|
-
|
|
4901
|
-
|
|
4902
|
-
|
|
4903
|
-
|
|
4904
|
-
|
|
4905
|
-
|
|
4906
|
-
|
|
4907
|
-
|
|
4908
|
-
|
|
4909
|
-
|
|
4910
|
-
|
|
4911
|
-
|
|
4912
|
-
|
|
4913
|
-
|
|
4914
|
-
|
|
4915
|
-
|
|
4916
|
-
|
|
4917
|
-
|
|
4918
|
-
|
|
4919
|
-
|
|
4920
|
-
|
|
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, [
|
|
4921
4926
|
"id",
|
|
4922
4927
|
"text",
|
|
4928
|
+
"autoExpand",
|
|
4923
4929
|
"fontFamily",
|
|
4924
4930
|
"fontSize",
|
|
4925
4931
|
"bold",
|
|
@@ -4943,58 +4949,58 @@ class k {
|
|
|
4943
4949
|
"radiusBottomRight",
|
|
4944
4950
|
"radiusBottomLeft"
|
|
4945
4951
|
]);
|
|
4946
|
-
var
|
|
4947
|
-
const { historyManager:
|
|
4948
|
-
|
|
4949
|
-
const
|
|
4950
|
-
strokeColor:
|
|
4951
|
-
width:
|
|
4952
|
-
}), 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({
|
|
4953
4959
|
id: t,
|
|
4954
|
-
fontFamily:
|
|
4955
|
-
fontSize:
|
|
4956
|
-
fontWeight:
|
|
4957
|
-
fontStyle:
|
|
4958
|
-
underline:
|
|
4959
|
-
uppercase:
|
|
4960
|
-
linethrough:
|
|
4961
|
-
textAlign:
|
|
4962
|
-
fill:
|
|
4963
|
-
stroke:
|
|
4964
|
-
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,
|
|
4965
4971
|
strokeUniform: !0,
|
|
4966
|
-
opacity:
|
|
4967
|
-
backgroundColor:
|
|
4968
|
-
backgroundOpacity:
|
|
4969
|
-
paddingTop:
|
|
4970
|
-
paddingRight:
|
|
4971
|
-
paddingBottom:
|
|
4972
|
-
paddingLeft:
|
|
4973
|
-
radiusTopLeft:
|
|
4974
|
-
radiusTopRight:
|
|
4975
|
-
radiusBottomRight:
|
|
4976
|
-
radiusBottomLeft:
|
|
4977
|
-
},
|
|
4978
|
-
if (O.textCaseRaw = (
|
|
4979
|
-
const
|
|
4980
|
-
|
|
4981
|
-
}
|
|
4982
|
-
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", {
|
|
4983
4989
|
textbox: O,
|
|
4984
|
-
options:
|
|
4990
|
+
options: wt(z({}, R), {
|
|
4985
4991
|
text: e,
|
|
4986
|
-
bold:
|
|
4987
|
-
italic:
|
|
4988
|
-
strikethrough:
|
|
4989
|
-
align:
|
|
4990
|
-
color:
|
|
4991
|
-
strokeColor:
|
|
4992
|
-
strokeWidth:
|
|
4992
|
+
bold: i,
|
|
4993
|
+
italic: a,
|
|
4994
|
+
strikethrough: d,
|
|
4995
|
+
align: l,
|
|
4996
|
+
color: u,
|
|
4997
|
+
strokeColor: st,
|
|
4998
|
+
strokeWidth: Y
|
|
4993
4999
|
}),
|
|
4994
5000
|
flags: {
|
|
4995
|
-
withoutSelection: !!
|
|
4996
|
-
withoutSave: !!
|
|
4997
|
-
withoutAdding: !!
|
|
5001
|
+
withoutSelection: !!I,
|
|
5002
|
+
withoutSave: !!T,
|
|
5003
|
+
withoutAdding: !!_
|
|
4998
5004
|
}
|
|
4999
5005
|
}), O;
|
|
5000
5006
|
}
|
|
@@ -5006,42 +5012,49 @@ class k {
|
|
|
5006
5012
|
* @param options.withoutSave — не сохранять состояние в историю
|
|
5007
5013
|
* @param options.skipRender — не вызывать перерисовку канваса
|
|
5008
5014
|
*/
|
|
5009
|
-
updateText({
|
|
5010
|
-
|
|
5015
|
+
updateText({
|
|
5016
|
+
target: t,
|
|
5017
|
+
style: e = {},
|
|
5018
|
+
withoutSave: s,
|
|
5019
|
+
skipRender: n
|
|
5020
|
+
} = {}) {
|
|
5021
|
+
var Ft, Ht, Zt, Gt, Vt, Xt, Tt;
|
|
5011
5022
|
const o = this._resolveTextObject(t);
|
|
5012
5023
|
if (!o) return null;
|
|
5013
5024
|
const { historyManager: i } = this.editor, { canvas: a } = this;
|
|
5014
5025
|
i.suspendHistory();
|
|
5015
|
-
const r =
|
|
5026
|
+
const r = P._getSnapshot(o), c = (Ft = o.originY) != null ? Ft : "top", d = o.getPointByOrigin("center", c), l = {
|
|
5016
5027
|
originY: c,
|
|
5017
5028
|
x: d.x,
|
|
5018
5029
|
y: d.y
|
|
5019
|
-
},
|
|
5030
|
+
}, Yt = e, {
|
|
5020
5031
|
text: u,
|
|
5021
|
-
|
|
5022
|
-
|
|
5023
|
-
|
|
5024
|
-
|
|
5025
|
-
|
|
5026
|
-
|
|
5027
|
-
|
|
5028
|
-
|
|
5029
|
-
|
|
5030
|
-
|
|
5031
|
-
|
|
5032
|
-
|
|
5033
|
-
|
|
5034
|
-
|
|
5035
|
-
|
|
5036
|
-
|
|
5037
|
-
|
|
5038
|
-
|
|
5039
|
-
|
|
5040
|
-
|
|
5041
|
-
|
|
5042
|
-
|
|
5043
|
-
|
|
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, [
|
|
5044
5056
|
"text",
|
|
5057
|
+
"autoExpand",
|
|
5045
5058
|
"fontFamily",
|
|
5046
5059
|
"fontSize",
|
|
5047
5060
|
"bold",
|
|
@@ -5064,58 +5077,60 @@ class k {
|
|
|
5064
5077
|
"radiusTopRight",
|
|
5065
5078
|
"radiusBottomRight",
|
|
5066
5079
|
"radiusBottomLeft"
|
|
5067
|
-
]), R =
|
|
5068
|
-
if (
|
|
5069
|
-
const
|
|
5070
|
-
O && (
|
|
5071
|
-
}
|
|
5072
|
-
if (
|
|
5073
|
-
const
|
|
5074
|
-
O && (
|
|
5075
|
-
}
|
|
5076
|
-
if (
|
|
5077
|
-
const
|
|
5078
|
-
strokeColor:
|
|
5079
|
-
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
|
|
5080
5093
|
});
|
|
5081
|
-
O && (
|
|
5082
|
-
}
|
|
5083
|
-
|
|
5084
|
-
const
|
|
5085
|
-
if (
|
|
5086
|
-
const
|
|
5087
|
-
R.text =
|
|
5088
|
-
} else o.textCaseRaw === void 0 && (o.textCaseRaw =
|
|
5089
|
-
o.uppercase =
|
|
5090
|
-
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;
|
|
5091
5104
|
if (O) {
|
|
5092
|
-
const
|
|
5093
|
-
|
|
5094
|
-
} else if (Object.keys(
|
|
5095
|
-
const
|
|
5096
|
-
|
|
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 }));
|
|
5097
5110
|
}
|
|
5098
|
-
const
|
|
5111
|
+
const ee = yt && P._hasLayoutAffectingStyles({
|
|
5099
5112
|
stylesList: [
|
|
5100
|
-
|
|
5101
|
-
|
|
5102
|
-
|
|
5113
|
+
X,
|
|
5114
|
+
V,
|
|
5115
|
+
k
|
|
5103
5116
|
]
|
|
5104
5117
|
});
|
|
5105
|
-
|
|
5106
|
-
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({
|
|
5107
5120
|
stylesList: [
|
|
5108
5121
|
R,
|
|
5109
|
-
|
|
5110
|
-
|
|
5111
|
-
|
|
5122
|
+
X,
|
|
5123
|
+
V,
|
|
5124
|
+
k
|
|
5112
5125
|
]
|
|
5113
|
-
}),
|
|
5114
|
-
|
|
5115
|
-
|
|
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, {
|
|
5116
5131
|
anchor: l
|
|
5117
|
-
}),
|
|
5118
|
-
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);
|
|
5119
5134
|
return a.fire("editor:text-updated", {
|
|
5120
5135
|
textbox: o,
|
|
5121
5136
|
target: t,
|
|
@@ -5126,9 +5141,9 @@ class k {
|
|
|
5126
5141
|
},
|
|
5127
5142
|
updates: R,
|
|
5128
5143
|
before: r,
|
|
5129
|
-
after:
|
|
5144
|
+
after: ie,
|
|
5130
5145
|
selectionRange: O != null ? O : void 0,
|
|
5131
|
-
selectionStyles: O && Object.keys(
|
|
5146
|
+
selectionStyles: O && Object.keys(X).length ? X : void 0
|
|
5132
5147
|
}), o;
|
|
5133
5148
|
}
|
|
5134
5149
|
/**
|
|
@@ -5136,20 +5151,20 @@ class k {
|
|
|
5136
5151
|
*/
|
|
5137
5152
|
destroy() {
|
|
5138
5153
|
const { canvas: t } = this;
|
|
5139
|
-
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);
|
|
5140
5155
|
}
|
|
5141
5156
|
/**
|
|
5142
5157
|
* Возвращает активный текст или ищет по id.
|
|
5143
5158
|
*/
|
|
5144
5159
|
_resolveTextObject(t) {
|
|
5145
|
-
if (t instanceof
|
|
5160
|
+
if (t instanceof at) return t;
|
|
5146
5161
|
const { canvas: e } = this;
|
|
5147
5162
|
if (!t) {
|
|
5148
5163
|
const s = e.getActiveObject();
|
|
5149
|
-
return
|
|
5164
|
+
return P._isTextbox(s) ? s : null;
|
|
5150
5165
|
}
|
|
5151
5166
|
if (typeof t == "string") {
|
|
5152
|
-
const s = e.getObjects().find((n) =>
|
|
5167
|
+
const s = e.getObjects().find((n) => P._isTextbox(n) && n.id === t);
|
|
5153
5168
|
return s != null ? s : null;
|
|
5154
5169
|
}
|
|
5155
5170
|
return null;
|
|
@@ -5158,21 +5173,21 @@ class k {
|
|
|
5158
5173
|
* Проверяет, является ли объект текстовым блоком редактора.
|
|
5159
5174
|
*/
|
|
5160
5175
|
static _isTextbox(t) {
|
|
5161
|
-
return !!t && t instanceof
|
|
5176
|
+
return !!t && t instanceof at;
|
|
5162
5177
|
}
|
|
5163
5178
|
/**
|
|
5164
5179
|
* Вешает обработчики событий Fabric для работы с текстом.
|
|
5165
5180
|
*/
|
|
5166
5181
|
_bindEvents() {
|
|
5167
5182
|
const { canvas: t } = this;
|
|
5168
|
-
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);
|
|
5169
5184
|
}
|
|
5170
5185
|
/**
|
|
5171
5186
|
* Автоматически увеличивает ширину текстового объекта до ширины текста,
|
|
5172
5187
|
* но не шире монтажной области, и удерживает объект в её пределах.
|
|
5173
5188
|
*/
|
|
5174
5189
|
_autoExpandTextboxWidth(t, { anchor: e } = {}) {
|
|
5175
|
-
var C, S,
|
|
5190
|
+
var C, S, E, b, I, T, _, B, N, H, Z, $, Y;
|
|
5176
5191
|
const { montageArea: s } = this.editor;
|
|
5177
5192
|
if (!s) return !1;
|
|
5178
5193
|
const n = typeof t.text == "string" ? t.text : "";
|
|
@@ -5180,7 +5195,7 @@ class k {
|
|
|
5180
5195
|
s.setCoords();
|
|
5181
5196
|
const o = s.getBoundingRect(!1, !0), i = (C = o.width) != null ? C : 0;
|
|
5182
5197
|
if (!Number.isFinite(i) || i <= 0) return !1;
|
|
5183
|
-
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(
|
|
5184
5199
|
1,
|
|
5185
5200
|
i / c - d - l - u
|
|
5186
5201
|
);
|
|
@@ -5190,17 +5205,17 @@ class k {
|
|
|
5190
5205
|
let p = !1;
|
|
5191
5206
|
Math.abs(((N = t.width) != null ? N : 0) - f) > tt && (t.set({ width: f }), p = !0), t.initDimensions();
|
|
5192
5207
|
const { textLines: m } = t, v = Array.isArray(m) && m.length > g, w = Math.ceil(
|
|
5193
|
-
|
|
5194
|
-
), A = Math.min((
|
|
5208
|
+
P._getLongestLineWidth({ textbox: t, text: n })
|
|
5209
|
+
), A = Math.min((H = t.minWidth) != null ? H : 1, f);
|
|
5195
5210
|
let y = Math.min(
|
|
5196
5211
|
f,
|
|
5197
5212
|
Math.max(w, A)
|
|
5198
5213
|
);
|
|
5199
|
-
v && (y = f), Math.abs(((
|
|
5200
|
-
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({
|
|
5201
5216
|
textbox: t,
|
|
5202
|
-
montageLeft: (
|
|
5203
|
-
montageRight: ((
|
|
5217
|
+
montageLeft: ($ = o.left) != null ? $ : 0,
|
|
5218
|
+
montageRight: ((Y = o.left) != null ? Y : 0) + i
|
|
5204
5219
|
});
|
|
5205
5220
|
return p || j;
|
|
5206
5221
|
}
|
|
@@ -5245,7 +5260,7 @@ class k {
|
|
|
5245
5260
|
static _handleObjectResizing(t) {
|
|
5246
5261
|
var l, u, f, g, p, m;
|
|
5247
5262
|
const { target: e, transform: s } = t;
|
|
5248
|
-
if (!
|
|
5263
|
+
if (!P._isTextbox(e)) return;
|
|
5249
5264
|
const {
|
|
5250
5265
|
paddingLeft: n = 0,
|
|
5251
5266
|
paddingRight: o = 0
|
|
@@ -5256,7 +5271,7 @@ class k {
|
|
|
5256
5271
|
e.set({ width: r });
|
|
5257
5272
|
const c = (u = e.width) != null ? u : 0, d = a - c;
|
|
5258
5273
|
if (d !== 0 && s && s.corner === "ml") {
|
|
5259
|
-
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;
|
|
5260
5275
|
e.set({
|
|
5261
5276
|
left: ((p = e.left) != null ? p : 0) + j * A,
|
|
5262
5277
|
top: ((m = e.top) != null ? m : 0) + j * y
|
|
@@ -5291,7 +5306,7 @@ class k {
|
|
|
5291
5306
|
textbox: t,
|
|
5292
5307
|
range: e
|
|
5293
5308
|
}) {
|
|
5294
|
-
const s =
|
|
5309
|
+
const s = P._getLineRanges({ textbox: t });
|
|
5295
5310
|
if (!s.length) return e;
|
|
5296
5311
|
let { start: n } = e, { end: o } = e;
|
|
5297
5312
|
return s.forEach(({ start: i, end: a }) => {
|
|
@@ -5376,10 +5391,10 @@ class k {
|
|
|
5376
5391
|
static _roundTextboxDimensions({
|
|
5377
5392
|
textbox: t
|
|
5378
5393
|
}) {
|
|
5379
|
-
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({
|
|
5380
5395
|
rawValue: e,
|
|
5381
5396
|
calculatedValue: i
|
|
5382
|
-
}), c =
|
|
5397
|
+
}), c = P._resolveDimension({
|
|
5383
5398
|
rawValue: s,
|
|
5384
5399
|
calculatedValue: a
|
|
5385
5400
|
}), d = Number.isFinite(r) ? Math.round(r) : null, l = Number.isFinite(c) ? Math.round(c) : null, u = {};
|
|
@@ -5393,81 +5408,83 @@ class k {
|
|
|
5393
5408
|
snapshot: R,
|
|
5394
5409
|
entries: O
|
|
5395
5410
|
}) => {
|
|
5396
|
-
Object.entries(O).forEach(([
|
|
5397
|
-
|
|
5411
|
+
Object.entries(O).forEach(([it, X]) => {
|
|
5412
|
+
X != null && (R[it] = X);
|
|
5398
5413
|
});
|
|
5399
5414
|
}, {
|
|
5400
5415
|
id: s,
|
|
5401
5416
|
text: n,
|
|
5402
5417
|
textCaseRaw: o,
|
|
5403
5418
|
uppercase: i,
|
|
5404
|
-
|
|
5405
|
-
|
|
5406
|
-
|
|
5407
|
-
|
|
5408
|
-
|
|
5409
|
-
|
|
5410
|
-
|
|
5411
|
-
|
|
5412
|
-
|
|
5413
|
-
|
|
5414
|
-
|
|
5415
|
-
|
|
5416
|
-
|
|
5417
|
-
|
|
5418
|
-
|
|
5419
|
-
|
|
5420
|
-
|
|
5421
|
-
|
|
5422
|
-
|
|
5423
|
-
|
|
5424
|
-
|
|
5425
|
-
|
|
5426
|
-
|
|
5427
|
-
|
|
5428
|
-
|
|
5429
|
-
|
|
5430
|
-
|
|
5431
|
-
|
|
5432
|
-
|
|
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 = {
|
|
5433
5449
|
id: s,
|
|
5434
5450
|
uppercase: !!i,
|
|
5435
|
-
textAlign:
|
|
5451
|
+
textAlign: g
|
|
5436
5452
|
};
|
|
5437
5453
|
return e({
|
|
5438
|
-
snapshot:
|
|
5454
|
+
snapshot: st,
|
|
5439
5455
|
entries: {
|
|
5440
5456
|
text: n,
|
|
5441
5457
|
textCaseRaw: o,
|
|
5442
|
-
|
|
5443
|
-
|
|
5444
|
-
|
|
5445
|
-
|
|
5446
|
-
|
|
5447
|
-
|
|
5448
|
-
|
|
5449
|
-
|
|
5450
|
-
|
|
5451
|
-
|
|
5452
|
-
|
|
5453
|
-
|
|
5454
|
-
|
|
5455
|
-
|
|
5456
|
-
|
|
5457
|
-
|
|
5458
|
-
|
|
5459
|
-
|
|
5460
|
-
|
|
5461
|
-
|
|
5462
|
-
|
|
5463
|
-
|
|
5464
|
-
|
|
5465
|
-
|
|
5466
|
-
|
|
5467
|
-
|
|
5468
|
-
|
|
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
|
|
5469
5486
|
}
|
|
5470
|
-
}),
|
|
5487
|
+
}), st;
|
|
5471
5488
|
}
|
|
5472
5489
|
/**
|
|
5473
5490
|
* Возвращает первый доступный шрифт или дефолтный Arial.
|
|
@@ -5480,7 +5497,7 @@ class k {
|
|
|
5480
5497
|
const J = ({
|
|
5481
5498
|
value: h,
|
|
5482
5499
|
fallback: t = 0
|
|
5483
|
-
}) => 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 = ({
|
|
5484
5501
|
value: h,
|
|
5485
5502
|
dimension: t,
|
|
5486
5503
|
useRelativePositions: e
|
|
@@ -5497,22 +5514,22 @@ const J = ({
|
|
|
5497
5514
|
const o = h;
|
|
5498
5515
|
if (typeof o[n.x] == "number" && typeof o[n.y] == "number")
|
|
5499
5516
|
return {
|
|
5500
|
-
x:
|
|
5517
|
+
x: de({
|
|
5501
5518
|
value: o[n.x],
|
|
5502
5519
|
dimension: t,
|
|
5503
5520
|
useRelativePositions: s
|
|
5504
5521
|
}),
|
|
5505
|
-
y:
|
|
5522
|
+
y: de({
|
|
5506
5523
|
value: o[n.y],
|
|
5507
5524
|
dimension: e,
|
|
5508
5525
|
useRelativePositions: s
|
|
5509
5526
|
})
|
|
5510
5527
|
};
|
|
5511
|
-
const { left: a, top: r, width: c, height: d } = h, l =
|
|
5528
|
+
const { left: a, top: r, width: c, height: d } = h, l = de({
|
|
5512
5529
|
value: a,
|
|
5513
5530
|
dimension: t,
|
|
5514
5531
|
useRelativePositions: s
|
|
5515
|
-
}), u =
|
|
5532
|
+
}), u = de({
|
|
5516
5533
|
value: r,
|
|
5517
5534
|
dimension: e,
|
|
5518
5535
|
useRelativePositions: s
|
|
@@ -5550,7 +5567,7 @@ const J = ({
|
|
|
5550
5567
|
} catch (s) {
|
|
5551
5568
|
return null;
|
|
5552
5569
|
}
|
|
5553
|
-
},
|
|
5570
|
+
}, mt = ({
|
|
5554
5571
|
object: h
|
|
5555
5572
|
}) => {
|
|
5556
5573
|
if (!h) return null;
|
|
@@ -5614,8 +5631,8 @@ const J = ({
|
|
|
5614
5631
|
};
|
|
5615
5632
|
}
|
|
5616
5633
|
return null;
|
|
5617
|
-
},
|
|
5618
|
-
class
|
|
5634
|
+
}, Qt = "_templateCenterX", be = "_templateCenterY", le = "_templateAnchorX", Me = "_templateAnchorY";
|
|
5635
|
+
class x {
|
|
5619
5636
|
constructor({ editor: t }) {
|
|
5620
5637
|
this.editor = t;
|
|
5621
5638
|
}
|
|
@@ -5634,28 +5651,28 @@ class _ {
|
|
|
5634
5651
|
montageArea: i,
|
|
5635
5652
|
errorManager: a,
|
|
5636
5653
|
backgroundManager: r
|
|
5637
|
-
} = 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];
|
|
5638
5655
|
if (!f.length)
|
|
5639
5656
|
return a.emitWarning({
|
|
5640
5657
|
origin: "TemplateManager",
|
|
5641
5658
|
method: "serializeSelection",
|
|
5642
|
-
code:
|
|
5659
|
+
code: St.TEMPLATE_MANAGER.NO_OBJECTS_SELECTED,
|
|
5643
5660
|
message: "Нет объектов для сериализации шаблона"
|
|
5644
5661
|
}), null;
|
|
5645
|
-
const g =
|
|
5646
|
-
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,
|
|
5647
5664
|
bounds: g,
|
|
5648
5665
|
baseWidth: m,
|
|
5649
5666
|
baseHeight: v,
|
|
5650
5667
|
montageArea: i != null ? i : null
|
|
5651
|
-
})), A =
|
|
5668
|
+
})), A = wt(z({}, s), {
|
|
5652
5669
|
baseWidth: m,
|
|
5653
5670
|
baseHeight: v,
|
|
5654
5671
|
positionsNormalized: !0,
|
|
5655
5672
|
previewId: e != null ? e : s.previewId
|
|
5656
5673
|
});
|
|
5657
5674
|
return {
|
|
5658
|
-
id: t != null ? t : `template-${
|
|
5675
|
+
id: t != null ? t : `template-${K()}`,
|
|
5659
5676
|
meta: A,
|
|
5660
5677
|
objects: w
|
|
5661
5678
|
};
|
|
@@ -5667,7 +5684,7 @@ class _ {
|
|
|
5667
5684
|
* @param options.data - данные для заполнения текстов по customData.templateField
|
|
5668
5685
|
*/
|
|
5669
5686
|
applyTemplate(s) {
|
|
5670
|
-
return
|
|
5687
|
+
return W(this, arguments, function* ({
|
|
5671
5688
|
template: t,
|
|
5672
5689
|
data: e
|
|
5673
5690
|
}) {
|
|
@@ -5682,39 +5699,39 @@ class _ {
|
|
|
5682
5699
|
return a.emitWarning({
|
|
5683
5700
|
origin: "TemplateManager",
|
|
5684
5701
|
method: "applyTemplate",
|
|
5685
|
-
code:
|
|
5702
|
+
code: St.TEMPLATE_MANAGER.INVALID_TEMPLATE,
|
|
5686
5703
|
message: "Шаблон не содержит объектов"
|
|
5687
5704
|
}), null;
|
|
5688
|
-
const u =
|
|
5705
|
+
const u = x._getBounds(o);
|
|
5689
5706
|
if (!u)
|
|
5690
5707
|
return a.emitWarning({
|
|
5691
5708
|
origin: "TemplateManager",
|
|
5692
5709
|
method: "applyTemplate",
|
|
5693
|
-
code:
|
|
5710
|
+
code: St.TEMPLATE_MANAGER.INVALID_TARGET,
|
|
5694
5711
|
message: "Не удалось определить границы монтажной области"
|
|
5695
5712
|
}), null;
|
|
5696
|
-
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;
|
|
5697
5714
|
let v = !1, w = !1;
|
|
5698
5715
|
i.suspendHistory();
|
|
5699
5716
|
try {
|
|
5700
|
-
const A = yield
|
|
5717
|
+
const A = yield x._enlivenObjects(c);
|
|
5701
5718
|
if (!A.length)
|
|
5702
5719
|
return a.emitWarning({
|
|
5703
5720
|
origin: "TemplateManager",
|
|
5704
5721
|
method: "applyTemplate",
|
|
5705
|
-
code:
|
|
5722
|
+
code: St.TEMPLATE_MANAGER.INVALID_TEMPLATE,
|
|
5706
5723
|
message: "Не удалось создать объекты шаблона"
|
|
5707
5724
|
}), null;
|
|
5708
|
-
const { backgroundObject: y, contentObjects:
|
|
5709
|
-
y && (w = yield
|
|
5725
|
+
const { backgroundObject: y, contentObjects: M } = x._extractBackgroundObject(A);
|
|
5726
|
+
y && (w = yield x._applyBackgroundFromObject({
|
|
5710
5727
|
backgroundObject: y,
|
|
5711
5728
|
backgroundManager: r,
|
|
5712
5729
|
errorManager: a
|
|
5713
5730
|
}));
|
|
5714
|
-
const j =
|
|
5731
|
+
const j = M.map((C) => (this._adaptTextboxWidth({
|
|
5715
5732
|
object: C,
|
|
5716
5733
|
baseWidth: g.baseWidth
|
|
5717
|
-
}),
|
|
5734
|
+
}), x._transformObject({
|
|
5718
5735
|
object: C,
|
|
5719
5736
|
scale: p,
|
|
5720
5737
|
bounds: u,
|
|
@@ -5724,10 +5741,10 @@ class _ {
|
|
|
5724
5741
|
montageArea: o,
|
|
5725
5742
|
useRelativePositions: m
|
|
5726
5743
|
}), C.set({
|
|
5727
|
-
id: `${C.type}-${
|
|
5744
|
+
id: `${C.type}-${K()}`,
|
|
5728
5745
|
evented: !0
|
|
5729
5746
|
}), n.add(C), C));
|
|
5730
|
-
return !j.length && !w ? null : (v = j.length > 0 || w, j.length &&
|
|
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", {
|
|
5731
5748
|
template: t,
|
|
5732
5749
|
objects: j,
|
|
5733
5750
|
bounds: u
|
|
@@ -5736,7 +5753,7 @@ class _ {
|
|
|
5736
5753
|
return a.emitError({
|
|
5737
5754
|
origin: "TemplateManager",
|
|
5738
5755
|
method: "applyTemplate",
|
|
5739
|
-
code:
|
|
5756
|
+
code: St.TEMPLATE_MANAGER.APPLY_FAILED,
|
|
5740
5757
|
message: "Ошибка применения шаблона",
|
|
5741
5758
|
data: {
|
|
5742
5759
|
templateId: l,
|
|
@@ -5752,7 +5769,7 @@ class _ {
|
|
|
5752
5769
|
* Подготавливает объекты для сериализации.
|
|
5753
5770
|
*/
|
|
5754
5771
|
static _collectObjects(t) {
|
|
5755
|
-
return t ? t instanceof
|
|
5772
|
+
return t ? t instanceof F ? t.getObjects() : [t] : [];
|
|
5756
5773
|
}
|
|
5757
5774
|
/**
|
|
5758
5775
|
* Возвращает габариты объекта.
|
|
@@ -5776,15 +5793,15 @@ class _ {
|
|
|
5776
5793
|
* Превращает plain-описание объектов в Fabric объекты.
|
|
5777
5794
|
*/
|
|
5778
5795
|
static _enlivenObjects(t) {
|
|
5779
|
-
return
|
|
5780
|
-
return (yield Promise.all(t.map((s) =>
|
|
5781
|
-
if (
|
|
5782
|
-
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);
|
|
5783
5800
|
if (i)
|
|
5784
|
-
return
|
|
5801
|
+
return x._restoreImageScale({ revived: i, serialized: s }), i;
|
|
5785
5802
|
}
|
|
5786
|
-
const n = yield
|
|
5787
|
-
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;
|
|
5788
5805
|
})))).filter((s) => !!s);
|
|
5789
5806
|
});
|
|
5790
5807
|
}
|
|
@@ -5812,22 +5829,22 @@ class _ {
|
|
|
5812
5829
|
naturalHeight: 0,
|
|
5813
5830
|
width: 0,
|
|
5814
5831
|
height: 0
|
|
5815
|
-
}, 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 }),
|
|
5816
|
-
if (C && (
|
|
5817
|
-
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);
|
|
5818
5835
|
return;
|
|
5819
5836
|
}
|
|
5820
5837
|
if (I === "stretch") {
|
|
5821
|
-
const
|
|
5822
|
-
|
|
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);
|
|
5823
5840
|
return;
|
|
5824
5841
|
}
|
|
5825
|
-
if (!
|
|
5826
|
-
c.set(
|
|
5842
|
+
if (!E || !b) {
|
|
5843
|
+
c.set(T);
|
|
5827
5844
|
return;
|
|
5828
5845
|
}
|
|
5829
|
-
const
|
|
5830
|
-
Number.isFinite(
|
|
5846
|
+
const _ = Math.min(M / p, j / m);
|
|
5847
|
+
Number.isFinite(_) && _ > 0 && (T.scaleX = _, T.scaleY = _), c.set(T);
|
|
5831
5848
|
}
|
|
5832
5849
|
/**
|
|
5833
5850
|
* Определяет режим вписывания изображения при восстановлении.
|
|
@@ -5849,12 +5866,12 @@ class _ {
|
|
|
5849
5866
|
* Восстанавливает SVG-объект из компактного описания.
|
|
5850
5867
|
*/
|
|
5851
5868
|
static _reviveSvgObject(t) {
|
|
5852
|
-
return
|
|
5869
|
+
return W(this, null, function* () {
|
|
5853
5870
|
const e = typeof t.svgMarkup == "string" ? t.svgMarkup : null;
|
|
5854
5871
|
if (!e) return null;
|
|
5855
5872
|
try {
|
|
5856
|
-
const s = yield ys(e), n =
|
|
5857
|
-
|
|
5873
|
+
const s = yield ys(e), n = ht.groupSVGElements(s.objects, s.options), o = yield ht.enlivenObjectEnlivables(
|
|
5874
|
+
x._prepareSerializableProps(t)
|
|
5858
5875
|
);
|
|
5859
5876
|
return n.set(o), n.setCoords(), n;
|
|
5860
5877
|
} catch (s) {
|
|
@@ -5866,7 +5883,7 @@ class _ {
|
|
|
5866
5883
|
* Убирает технические поля сериализации, оставляя только применимые свойства.
|
|
5867
5884
|
*/
|
|
5868
5885
|
static _prepareSerializableProps(t) {
|
|
5869
|
-
const e =
|
|
5886
|
+
const e = z({}, t);
|
|
5870
5887
|
return delete e.svgMarkup, delete e.objects, delete e.path, delete e.paths, delete e.type, delete e.version, e;
|
|
5871
5888
|
}
|
|
5872
5889
|
/**
|
|
@@ -5918,17 +5935,17 @@ class _ {
|
|
|
5918
5935
|
baseHeight: i,
|
|
5919
5936
|
useRelativePositions: r,
|
|
5920
5937
|
centerKeys: {
|
|
5921
|
-
x:
|
|
5922
|
-
y:
|
|
5938
|
+
x: Qt,
|
|
5939
|
+
y: be
|
|
5923
5940
|
}
|
|
5924
|
-
}), { 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({
|
|
5925
5942
|
bounds: s,
|
|
5926
5943
|
baseWidth: o,
|
|
5927
5944
|
baseHeight: i,
|
|
5928
5945
|
scale: e,
|
|
5929
5946
|
useRelativePositions: r,
|
|
5930
|
-
anchorX:
|
|
5931
|
-
anchorY:
|
|
5947
|
+
anchorX: x._resolveAnchor(c, le),
|
|
5948
|
+
anchorY: x._resolveAnchor(c, Me)
|
|
5932
5949
|
}), v = hn({
|
|
5933
5950
|
normalizedX: d,
|
|
5934
5951
|
normalizedY: l,
|
|
@@ -5939,7 +5956,7 @@ class _ {
|
|
|
5939
5956
|
t.set({
|
|
5940
5957
|
scaleX: w,
|
|
5941
5958
|
scaleY: A
|
|
5942
|
-
}), 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];
|
|
5943
5960
|
}
|
|
5944
5961
|
/**
|
|
5945
5962
|
* Возвращает bounds, в которых должны позиционироваться нормализованные объекты.
|
|
@@ -5955,7 +5972,7 @@ class _ {
|
|
|
5955
5972
|
anchorY: a
|
|
5956
5973
|
}) {
|
|
5957
5974
|
if (!o) return t;
|
|
5958
|
-
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);
|
|
5959
5976
|
return {
|
|
5960
5977
|
left: u,
|
|
5961
5978
|
top: f,
|
|
@@ -5986,8 +6003,8 @@ class _ {
|
|
|
5986
6003
|
meta: t,
|
|
5987
6004
|
fallback: e
|
|
5988
6005
|
}) {
|
|
5989
|
-
const { width: s, height: n } = e, r = t || {}, { baseWidth: o = s, baseHeight: i = n } = r, a =
|
|
5990
|
-
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({
|
|
5991
6008
|
baseWidth: o,
|
|
5992
6009
|
baseHeight: i
|
|
5993
6010
|
}, a);
|
|
@@ -6014,7 +6031,7 @@ class _ {
|
|
|
6014
6031
|
t.setActiveObject(e[0]);
|
|
6015
6032
|
return;
|
|
6016
6033
|
}
|
|
6017
|
-
const s = new
|
|
6034
|
+
const s = new F(e, { canvas: t });
|
|
6018
6035
|
t.setActiveObject(s);
|
|
6019
6036
|
}
|
|
6020
6037
|
/**
|
|
@@ -6024,12 +6041,12 @@ class _ {
|
|
|
6024
6041
|
object: t,
|
|
6025
6042
|
baseWidth: e
|
|
6026
6043
|
}) {
|
|
6027
|
-
var
|
|
6028
|
-
if (!(t instanceof
|
|
6044
|
+
var H, Z;
|
|
6045
|
+
if (!(t instanceof at)) return;
|
|
6029
6046
|
const s = typeof t.text == "string" ? t.text : "";
|
|
6030
6047
|
if (!s) return;
|
|
6031
6048
|
const n = J({
|
|
6032
|
-
value: (
|
|
6049
|
+
value: (Z = (H = this.editor) == null ? void 0 : H.montageArea) == null ? void 0 : Z.width,
|
|
6033
6050
|
fallback: 0
|
|
6034
6051
|
}), {
|
|
6035
6052
|
width: o = 0,
|
|
@@ -6038,16 +6055,16 @@ class _ {
|
|
|
6038
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;
|
|
6039
6056
|
if (!n || !g || !r) return;
|
|
6040
6057
|
t.setCoords();
|
|
6041
|
-
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();
|
|
6042
6059
|
t.set("width", n), t.initDimensions();
|
|
6043
|
-
const I =
|
|
6060
|
+
const I = x._getLongestLineWidth({
|
|
6044
6061
|
textbox: t,
|
|
6045
6062
|
text: s
|
|
6046
|
-
}),
|
|
6047
|
-
t.set("width",
|
|
6048
|
-
const
|
|
6049
|
-
let N =
|
|
6050
|
-
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);
|
|
6051
6068
|
}
|
|
6052
6069
|
/**
|
|
6053
6070
|
* Возвращает ширину самой длинной строки текстового объекта.
|
|
@@ -6077,9 +6094,9 @@ class _ {
|
|
|
6077
6094
|
baseHeight: n,
|
|
6078
6095
|
montageArea: o
|
|
6079
6096
|
}) {
|
|
6080
|
-
const i = t.toDatalessObject([...
|
|
6081
|
-
if (
|
|
6082
|
-
const y =
|
|
6097
|
+
const i = t.toDatalessObject([...os]);
|
|
6098
|
+
if (x._isSvgObject(t)) {
|
|
6099
|
+
const y = x._extractSvgMarkup(t);
|
|
6083
6100
|
y && (i.svgMarkup = y, delete i.objects, delete i.path);
|
|
6084
6101
|
}
|
|
6085
6102
|
if (!e) return i;
|
|
@@ -6099,11 +6116,11 @@ class _ {
|
|
|
6099
6116
|
y: (y.y - r) / f
|
|
6100
6117
|
};
|
|
6101
6118
|
})(), m = (l.left - a) / u, v = (l.top - r) / f, w = m + l.width / u, A = v + l.height / f;
|
|
6102
|
-
return i[
|
|
6119
|
+
return i[Qt] = p.x, i[be] = p.y, i[le] = x._detectAnchor({
|
|
6103
6120
|
center: p.x,
|
|
6104
6121
|
start: m,
|
|
6105
6122
|
end: w
|
|
6106
|
-
}), i[
|
|
6123
|
+
}), i[Me] = x._detectAnchor({
|
|
6107
6124
|
center: p.y,
|
|
6108
6125
|
start: v,
|
|
6109
6126
|
end: A
|
|
@@ -6123,13 +6140,13 @@ class _ {
|
|
|
6123
6140
|
* Применяет фоновый объект шаблона к текущему холсту через BackgroundManager.
|
|
6124
6141
|
*/
|
|
6125
6142
|
static _applyBackgroundFromObject(n) {
|
|
6126
|
-
return
|
|
6143
|
+
return W(this, arguments, function* ({
|
|
6127
6144
|
backgroundObject: t,
|
|
6128
6145
|
backgroundManager: e,
|
|
6129
6146
|
errorManager: s
|
|
6130
6147
|
}) {
|
|
6131
6148
|
try {
|
|
6132
|
-
const { fill: o, customData: i } = t, { backgroundType: a } = t, r =
|
|
6149
|
+
const { fill: o, customData: i } = t, { backgroundType: a } = t, r = x._cloneCustomData(i);
|
|
6133
6150
|
if (a === "color" && typeof o == "string")
|
|
6134
6151
|
return e.setColorBackground({
|
|
6135
6152
|
color: o,
|
|
@@ -6148,7 +6165,7 @@ class _ {
|
|
|
6148
6165
|
}), !0;
|
|
6149
6166
|
}
|
|
6150
6167
|
if (a === "image") {
|
|
6151
|
-
const c =
|
|
6168
|
+
const c = x._getImageSource(t);
|
|
6152
6169
|
if (c)
|
|
6153
6170
|
return yield e.setImageBackground({
|
|
6154
6171
|
imageSource: c,
|
|
@@ -6161,7 +6178,7 @@ class _ {
|
|
|
6161
6178
|
s.emitWarning({
|
|
6162
6179
|
origin: "TemplateManager",
|
|
6163
6180
|
method: "applyTemplate",
|
|
6164
|
-
code:
|
|
6181
|
+
code: St.TEMPLATE_MANAGER.APPLY_FAILED,
|
|
6165
6182
|
message: "Не удалось применить фон из шаблона",
|
|
6166
6183
|
data: o
|
|
6167
6184
|
});
|
|
@@ -6191,7 +6208,7 @@ class _ {
|
|
|
6191
6208
|
*/
|
|
6192
6209
|
static _cloneCustomData(t) {
|
|
6193
6210
|
if (!(!t || typeof t != "object"))
|
|
6194
|
-
return
|
|
6211
|
+
return z({}, t);
|
|
6195
6212
|
}
|
|
6196
6213
|
/**
|
|
6197
6214
|
* Извлекает src изображения из FabricImage или его исходного элемента.
|
|
@@ -6217,10 +6234,10 @@ class _ {
|
|
|
6217
6234
|
*/
|
|
6218
6235
|
// eslint-disable-next-line class-methods-use-this
|
|
6219
6236
|
enlivenObjectEnlivables(t) {
|
|
6220
|
-
return
|
|
6237
|
+
return ht.enlivenObjectEnlivables(t);
|
|
6221
6238
|
}
|
|
6222
6239
|
}
|
|
6223
|
-
const pn = 5,
|
|
6240
|
+
const pn = 5, is = "#3D8BF4", Ie = 1, he = 1, Qe = ({
|
|
6224
6241
|
anchors: h,
|
|
6225
6242
|
positions: t,
|
|
6226
6243
|
threshold: e
|
|
@@ -6240,11 +6257,11 @@ const pn = 5, os = "#3D8BF4", Ae = 1, ce = 1, Je = ({
|
|
|
6240
6257
|
threshold: t,
|
|
6241
6258
|
anchors: e
|
|
6242
6259
|
}) => {
|
|
6243
|
-
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({
|
|
6244
6261
|
anchors: e.vertical,
|
|
6245
6262
|
positions: [s, o, n],
|
|
6246
6263
|
threshold: t
|
|
6247
|
-
}), d =
|
|
6264
|
+
}), d = Qe({
|
|
6248
6265
|
anchors: e.horizontal,
|
|
6249
6266
|
positions: [i, r, a],
|
|
6250
6267
|
threshold: t
|
|
@@ -6260,7 +6277,7 @@ const pn = 5, os = "#3D8BF4", Ae = 1, ce = 1, Je = ({
|
|
|
6260
6277
|
deltaY: d.delta,
|
|
6261
6278
|
guides: l
|
|
6262
6279
|
};
|
|
6263
|
-
},
|
|
6280
|
+
}, as = ({
|
|
6264
6281
|
activeBounds: h,
|
|
6265
6282
|
aligned: t,
|
|
6266
6283
|
threshold: e,
|
|
@@ -6351,47 +6368,47 @@ const pn = 5, os = "#3D8BF4", Ae = 1, ce = 1, Je = ({
|
|
|
6351
6368
|
...c.map((y) => ({ bounds: y, isActive: !1 })),
|
|
6352
6369
|
{ bounds: h, isActive: !0 }
|
|
6353
6370
|
];
|
|
6354
|
-
d.sort((y,
|
|
6371
|
+
d.sort((y, M) => y.bounds.top - M.bounds.top);
|
|
6355
6372
|
const l = d.findIndex((y) => y.isActive);
|
|
6356
6373
|
if (l === -1)
|
|
6357
6374
|
return { delta: 0, guide: null };
|
|
6358
6375
|
const u = d[l - 1], f = d[l - 2], g = d[l + 1], p = d[l + 2], m = [], v = i - o;
|
|
6359
6376
|
if (u && f) {
|
|
6360
|
-
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);
|
|
6361
6378
|
if (S <= e) {
|
|
6362
|
-
const
|
|
6379
|
+
const E = j - C, b = o + E, I = {
|
|
6363
6380
|
type: "vertical",
|
|
6364
6381
|
axis: n,
|
|
6365
|
-
refStart:
|
|
6382
|
+
refStart: M.bottom,
|
|
6366
6383
|
refEnd: y.top,
|
|
6367
6384
|
activeStart: y.bottom,
|
|
6368
|
-
activeEnd:
|
|
6385
|
+
activeEnd: b,
|
|
6369
6386
|
distance: j
|
|
6370
6387
|
};
|
|
6371
|
-
m.push({ delta:
|
|
6388
|
+
m.push({ delta: E, guide: I, diff: S });
|
|
6372
6389
|
}
|
|
6373
6390
|
}
|
|
6374
6391
|
if (g && p) {
|
|
6375
|
-
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);
|
|
6376
6393
|
if (S <= e) {
|
|
6377
|
-
const
|
|
6394
|
+
const E = C - j, b = i + E, I = {
|
|
6378
6395
|
type: "vertical",
|
|
6379
6396
|
axis: n,
|
|
6380
6397
|
refStart: y.bottom,
|
|
6381
|
-
refEnd:
|
|
6382
|
-
activeStart:
|
|
6398
|
+
refEnd: M.top,
|
|
6399
|
+
activeStart: b,
|
|
6383
6400
|
activeEnd: y.top,
|
|
6384
6401
|
distance: j
|
|
6385
6402
|
};
|
|
6386
|
-
m.push({ delta:
|
|
6403
|
+
m.push({ delta: E, guide: I, diff: S });
|
|
6387
6404
|
}
|
|
6388
6405
|
}
|
|
6389
6406
|
if (u && g) {
|
|
6390
|
-
const { bounds: y } = u, { bounds:
|
|
6407
|
+
const { bounds: y } = u, { bounds: M } = g, C = M.top - y.bottom - v;
|
|
6391
6408
|
if (C >= 0) {
|
|
6392
|
-
const S = C / 2,
|
|
6393
|
-
if (
|
|
6394
|
-
const
|
|
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 = {
|
|
6395
6412
|
type: "vertical",
|
|
6396
6413
|
axis: n,
|
|
6397
6414
|
refStart: y.bottom,
|
|
@@ -6400,11 +6417,11 @@ const pn = 5, os = "#3D8BF4", Ae = 1, ce = 1, Je = ({
|
|
|
6400
6417
|
activeEnd: N + S,
|
|
6401
6418
|
distance: S
|
|
6402
6419
|
};
|
|
6403
|
-
m.push({ delta:
|
|
6420
|
+
m.push({ delta: B, guide: H, diff: _ });
|
|
6404
6421
|
}
|
|
6405
6422
|
}
|
|
6406
6423
|
}
|
|
6407
|
-
const w =
|
|
6424
|
+
const w = as({
|
|
6408
6425
|
activeBounds: h,
|
|
6409
6426
|
aligned: c,
|
|
6410
6427
|
threshold: e,
|
|
@@ -6413,7 +6430,7 @@ const pn = 5, os = "#3D8BF4", Ae = 1, ce = 1, Je = ({
|
|
|
6413
6430
|
});
|
|
6414
6431
|
if (m.push(...w), !m.length)
|
|
6415
6432
|
return { delta: 0, guide: null };
|
|
6416
|
-
const A = m.reduce((y,
|
|
6433
|
+
const A = m.reduce((y, M) => M.diff < y.diff ? M : y, m[0]);
|
|
6417
6434
|
return {
|
|
6418
6435
|
delta: A.delta,
|
|
6419
6436
|
guide: A.guide
|
|
@@ -6437,47 +6454,47 @@ const pn = 5, os = "#3D8BF4", Ae = 1, ce = 1, Je = ({
|
|
|
6437
6454
|
...c.map((y) => ({ bounds: y, isActive: !1 })),
|
|
6438
6455
|
{ bounds: h, isActive: !0 }
|
|
6439
6456
|
];
|
|
6440
|
-
d.sort((y,
|
|
6457
|
+
d.sort((y, M) => y.bounds.left - M.bounds.left);
|
|
6441
6458
|
const l = d.findIndex((y) => y.isActive);
|
|
6442
6459
|
if (l === -1)
|
|
6443
6460
|
return { delta: 0, guide: null };
|
|
6444
6461
|
const u = d[l - 1], f = d[l - 2], g = d[l + 1], p = d[l + 2], m = [], v = i - o;
|
|
6445
6462
|
if (u && f) {
|
|
6446
|
-
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);
|
|
6447
6464
|
if (S <= e) {
|
|
6448
|
-
const
|
|
6465
|
+
const E = j - C, b = o + E, I = {
|
|
6449
6466
|
type: "horizontal",
|
|
6450
6467
|
axis: n,
|
|
6451
|
-
refStart:
|
|
6468
|
+
refStart: M.right,
|
|
6452
6469
|
refEnd: y.left,
|
|
6453
6470
|
activeStart: y.right,
|
|
6454
|
-
activeEnd:
|
|
6471
|
+
activeEnd: b,
|
|
6455
6472
|
distance: j
|
|
6456
6473
|
};
|
|
6457
|
-
m.push({ delta:
|
|
6474
|
+
m.push({ delta: E, guide: I, diff: S });
|
|
6458
6475
|
}
|
|
6459
6476
|
}
|
|
6460
6477
|
if (g && p) {
|
|
6461
|
-
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);
|
|
6462
6479
|
if (S <= e) {
|
|
6463
|
-
const
|
|
6480
|
+
const E = C - j, b = i + E, I = {
|
|
6464
6481
|
type: "horizontal",
|
|
6465
6482
|
axis: n,
|
|
6466
6483
|
refStart: y.right,
|
|
6467
|
-
refEnd:
|
|
6468
|
-
activeStart:
|
|
6484
|
+
refEnd: M.left,
|
|
6485
|
+
activeStart: b,
|
|
6469
6486
|
activeEnd: y.left,
|
|
6470
6487
|
distance: j
|
|
6471
6488
|
};
|
|
6472
|
-
m.push({ delta:
|
|
6489
|
+
m.push({ delta: E, guide: I, diff: S });
|
|
6473
6490
|
}
|
|
6474
6491
|
}
|
|
6475
6492
|
if (u && g) {
|
|
6476
|
-
const { bounds: y } = u, { bounds:
|
|
6493
|
+
const { bounds: y } = u, { bounds: M } = g, C = M.left - y.right - v;
|
|
6477
6494
|
if (C >= 0) {
|
|
6478
|
-
const S = C / 2,
|
|
6479
|
-
if (
|
|
6480
|
-
const
|
|
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 = {
|
|
6481
6498
|
type: "horizontal",
|
|
6482
6499
|
axis: n,
|
|
6483
6500
|
refStart: y.right,
|
|
@@ -6486,11 +6503,11 @@ const pn = 5, os = "#3D8BF4", Ae = 1, ce = 1, Je = ({
|
|
|
6486
6503
|
activeEnd: N + S,
|
|
6487
6504
|
distance: S
|
|
6488
6505
|
};
|
|
6489
|
-
m.push({ delta:
|
|
6506
|
+
m.push({ delta: B, guide: H, diff: _ });
|
|
6490
6507
|
}
|
|
6491
6508
|
}
|
|
6492
6509
|
}
|
|
6493
|
-
const w =
|
|
6510
|
+
const w = as({
|
|
6494
6511
|
activeBounds: h,
|
|
6495
6512
|
aligned: c,
|
|
6496
6513
|
threshold: e,
|
|
@@ -6499,7 +6516,7 @@ const pn = 5, os = "#3D8BF4", Ae = 1, ce = 1, Je = ({
|
|
|
6499
6516
|
});
|
|
6500
6517
|
if (m.push(...w), !m.length)
|
|
6501
6518
|
return { delta: 0, guide: null };
|
|
6502
|
-
const A = m.reduce((y,
|
|
6519
|
+
const A = m.reduce((y, M) => M.diff < y.diff ? M : y, m[0]);
|
|
6503
6520
|
return {
|
|
6504
6521
|
delta: A.delta,
|
|
6505
6522
|
guide: A.guide
|
|
@@ -6536,7 +6553,7 @@ const pn = 5, os = "#3D8BF4", Ae = 1, ce = 1, Je = ({
|
|
|
6536
6553
|
}) => {
|
|
6537
6554
|
const i = Math.min(o, s / 2, n / 2);
|
|
6538
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();
|
|
6539
|
-
},
|
|
6556
|
+
}, Ee = ({
|
|
6540
6557
|
context: h,
|
|
6541
6558
|
type: t,
|
|
6542
6559
|
axis: e,
|
|
@@ -6553,17 +6570,17 @@ const pn = 5, os = "#3D8BF4", Ae = 1, ce = 1, Je = ({
|
|
|
6553
6570
|
offsetAlongAxis: f = 0,
|
|
6554
6571
|
offsetPerpendicular: g = 0
|
|
6555
6572
|
}) => {
|
|
6556
|
-
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;
|
|
6557
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";
|
|
6558
|
-
const C = h.measureText(o).width + v * 2, S = m + v * 2,
|
|
6575
|
+
const C = h.measureText(o).width + v * 2, S = m + v * 2, E = y - C / 2, b = M - S / 2;
|
|
6559
6576
|
h.beginPath(), Mn({
|
|
6560
6577
|
context: h,
|
|
6561
|
-
x:
|
|
6562
|
-
y:
|
|
6578
|
+
x: E,
|
|
6579
|
+
y: b,
|
|
6563
6580
|
width: C,
|
|
6564
6581
|
height: S,
|
|
6565
6582
|
radius: w
|
|
6566
|
-
}), h.fill(), h.fillStyle = r, h.fillText(o, y,
|
|
6583
|
+
}), h.fill(), h.fillStyle = r, h.fillText(o, y, M), h.restore();
|
|
6567
6584
|
}, wn = ({
|
|
6568
6585
|
context: h,
|
|
6569
6586
|
guide: t,
|
|
@@ -6579,8 +6596,8 @@ const pn = 5, os = "#3D8BF4", Ae = 1, ce = 1, Je = ({
|
|
|
6579
6596
|
distance: c
|
|
6580
6597
|
} = t, d = Math.round(c).toString();
|
|
6581
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();
|
|
6582
|
-
const l =
|
|
6583
|
-
|
|
6599
|
+
const l = is;
|
|
6600
|
+
Ee({
|
|
6584
6601
|
context: h,
|
|
6585
6602
|
type: s,
|
|
6586
6603
|
axis: n,
|
|
@@ -6589,8 +6606,8 @@ const pn = 5, os = "#3D8BF4", Ae = 1, ce = 1, Je = ({
|
|
|
6589
6606
|
text: d,
|
|
6590
6607
|
zoom: e,
|
|
6591
6608
|
color: l,
|
|
6592
|
-
lineWidth:
|
|
6593
|
-
}),
|
|
6609
|
+
lineWidth: Ie
|
|
6610
|
+
}), Ee({
|
|
6594
6611
|
context: h,
|
|
6595
6612
|
type: s,
|
|
6596
6613
|
axis: n,
|
|
@@ -6599,9 +6616,9 @@ const pn = 5, os = "#3D8BF4", Ae = 1, ce = 1, Je = ({
|
|
|
6599
6616
|
text: d,
|
|
6600
6617
|
zoom: e,
|
|
6601
6618
|
color: l,
|
|
6602
|
-
lineWidth:
|
|
6619
|
+
lineWidth: Ie
|
|
6603
6620
|
});
|
|
6604
|
-
},
|
|
6621
|
+
}, $e = ({
|
|
6605
6622
|
anchors: h,
|
|
6606
6623
|
bounds: t
|
|
6607
6624
|
}) => {
|
|
@@ -6614,7 +6631,7 @@ const pn = 5, os = "#3D8BF4", Ae = 1, ce = 1, Je = ({
|
|
|
6614
6631
|
centerY: a
|
|
6615
6632
|
} = t;
|
|
6616
6633
|
h.vertical.push(e, n, s), h.horizontal.push(o, a, i);
|
|
6617
|
-
},
|
|
6634
|
+
}, ts = ({
|
|
6618
6635
|
bounds: h,
|
|
6619
6636
|
type: t,
|
|
6620
6637
|
primaryStart: e,
|
|
@@ -6644,24 +6661,24 @@ const pn = 5, os = "#3D8BF4", Ae = 1, ce = 1, Je = ({
|
|
|
6644
6661
|
}, Sn = ({
|
|
6645
6662
|
bounds: h
|
|
6646
6663
|
}) => {
|
|
6647
|
-
const t =
|
|
6664
|
+
const t = ts({
|
|
6648
6665
|
bounds: h,
|
|
6649
6666
|
type: "vertical",
|
|
6650
6667
|
primaryStart: "top",
|
|
6651
6668
|
primaryEnd: "bottom"
|
|
6652
|
-
}), e =
|
|
6669
|
+
}), e = ts({
|
|
6653
6670
|
bounds: h,
|
|
6654
6671
|
type: "horizontal",
|
|
6655
6672
|
primaryStart: "left",
|
|
6656
6673
|
primaryEnd: "right"
|
|
6657
6674
|
});
|
|
6658
6675
|
return { vertical: t, horizontal: e };
|
|
6659
|
-
}, An = ["montage-area", "background", "interaction-blocker"],
|
|
6676
|
+
}, An = ["montage-area", "background", "interaction-blocker"], rs = ({
|
|
6660
6677
|
activeObject: h
|
|
6661
6678
|
}) => {
|
|
6662
6679
|
const t = /* @__PURE__ */ new Set();
|
|
6663
|
-
return h && (t.add(h), h instanceof
|
|
6664
|
-
},
|
|
6680
|
+
return h && (t.add(h), h instanceof F && h.getObjects().forEach((e) => t.add(e))), t;
|
|
6681
|
+
}, cs = ({
|
|
6665
6682
|
object: h,
|
|
6666
6683
|
excluded: t,
|
|
6667
6684
|
ignoredIds: e = An
|
|
@@ -6730,7 +6747,7 @@ class jn {
|
|
|
6730
6747
|
return;
|
|
6731
6748
|
}
|
|
6732
6749
|
!this.anchors.vertical.length && !this.anchors.horizontal.length && this._cacheAnchors({ activeObject: e });
|
|
6733
|
-
let o =
|
|
6750
|
+
let o = mt({ object: e });
|
|
6734
6751
|
if (!o) {
|
|
6735
6752
|
this._clearGuides();
|
|
6736
6753
|
return;
|
|
@@ -6745,9 +6762,9 @@ class jn {
|
|
|
6745
6762
|
e.set({
|
|
6746
6763
|
left: v + d,
|
|
6747
6764
|
top: w + l
|
|
6748
|
-
}), e.setCoords(), o = (p =
|
|
6765
|
+
}), e.setCoords(), o = (p = mt({ object: e })) != null ? p : o;
|
|
6749
6766
|
}
|
|
6750
|
-
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({
|
|
6751
6768
|
activeBounds: o,
|
|
6752
6769
|
candidates: f,
|
|
6753
6770
|
threshold: r,
|
|
@@ -6758,7 +6775,7 @@ class jn {
|
|
|
6758
6775
|
e.set({
|
|
6759
6776
|
left: v + g.deltaX,
|
|
6760
6777
|
top: w + g.deltaY
|
|
6761
|
-
}), e.setCoords(), o = (m =
|
|
6778
|
+
}), e.setCoords(), o = (m = mt({ object: e })) != null ? m : o;
|
|
6762
6779
|
}
|
|
6763
6780
|
this._applyGuides({
|
|
6764
6781
|
guides: u,
|
|
@@ -6786,7 +6803,7 @@ class jn {
|
|
|
6786
6803
|
const { canvas: t, guideBounds: e } = this, s = t.getSelectionContext();
|
|
6787
6804
|
if (!s) return;
|
|
6788
6805
|
const n = e != null ? e : this._calculateViewportBounds(), { left: o, right: i, top: a, bottom: r } = n, { viewportTransform: c } = t, d = t.getZoom() || 1;
|
|
6789
|
-
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]);
|
|
6790
6807
|
for (const l of this.activeGuides)
|
|
6791
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();
|
|
6792
6809
|
for (const l of this.activeSpacingGuides)
|
|
@@ -6826,7 +6843,7 @@ class jn {
|
|
|
6826
6843
|
* Применяет шаг перемещения, округляя координаты объекта к сетке MOVE_SNAP_STEP.
|
|
6827
6844
|
*/
|
|
6828
6845
|
_applyMovementStep({ target: t }) {
|
|
6829
|
-
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;
|
|
6830
6847
|
n === e && o === s || (t.set({
|
|
6831
6848
|
left: n,
|
|
6832
6849
|
top: o
|
|
@@ -6838,12 +6855,12 @@ class jn {
|
|
|
6838
6855
|
_cacheAnchors({ activeObject: t }) {
|
|
6839
6856
|
const e = this._collectTargets({ activeObject: t }), s = { vertical: [], horizontal: [] }, n = [];
|
|
6840
6857
|
for (const a of e) {
|
|
6841
|
-
const r =
|
|
6842
|
-
r && (
|
|
6858
|
+
const r = mt({ object: a });
|
|
6859
|
+
r && ($e({ anchors: s, bounds: r }), n.push(r));
|
|
6843
6860
|
}
|
|
6844
|
-
const { montageArea: o } = this.editor, i =
|
|
6861
|
+
const { montageArea: o } = this.editor, i = mt({ object: o });
|
|
6845
6862
|
if (i) {
|
|
6846
|
-
|
|
6863
|
+
$e({ anchors: s, bounds: i });
|
|
6847
6864
|
const { left: a, right: r, top: c, bottom: d } = i;
|
|
6848
6865
|
this.guideBounds = {
|
|
6849
6866
|
left: a,
|
|
@@ -6859,9 +6876,9 @@ class jn {
|
|
|
6859
6876
|
* Собирает объекты, подходящие для прилипания, исключая активный объект и запрещённые id.
|
|
6860
6877
|
*/
|
|
6861
6878
|
_collectTargets({ activeObject: t }) {
|
|
6862
|
-
const e =
|
|
6879
|
+
const e = rs({ activeObject: t }), s = [];
|
|
6863
6880
|
return this.canvas.forEachObject((n) => {
|
|
6864
|
-
|
|
6881
|
+
cs({ object: n, excluded: e }) || s.push(n);
|
|
6865
6882
|
}), s;
|
|
6866
6883
|
}
|
|
6867
6884
|
/**
|
|
@@ -6884,8 +6901,8 @@ class jn {
|
|
|
6884
6901
|
};
|
|
6885
6902
|
}
|
|
6886
6903
|
}
|
|
6887
|
-
const
|
|
6888
|
-
class
|
|
6904
|
+
const es = "#3D8BF4", ss = 1;
|
|
6905
|
+
class Nt {
|
|
6889
6906
|
/**
|
|
6890
6907
|
* Создаёт менеджер измерений и инициализирует события.
|
|
6891
6908
|
*/
|
|
@@ -6990,15 +7007,15 @@ class Dt {
|
|
|
6990
7007
|
this._clearGuides();
|
|
6991
7008
|
return;
|
|
6992
7009
|
}
|
|
6993
|
-
const o =
|
|
7010
|
+
const o = mt({ object: n });
|
|
6994
7011
|
if (!o) {
|
|
6995
7012
|
this._clearGuides();
|
|
6996
7013
|
return;
|
|
6997
7014
|
}
|
|
6998
|
-
const i =
|
|
7015
|
+
const i = Nt._resolveTarget({
|
|
6999
7016
|
event: t,
|
|
7000
7017
|
activeObject: n
|
|
7001
|
-
}), { 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 });
|
|
7002
7019
|
if (!d) {
|
|
7003
7020
|
this._clearGuides();
|
|
7004
7021
|
return;
|
|
@@ -7007,7 +7024,7 @@ class Dt {
|
|
|
7007
7024
|
this._clearGuides();
|
|
7008
7025
|
return;
|
|
7009
7026
|
}
|
|
7010
|
-
const u =
|
|
7027
|
+
const u = Nt._buildGuides({
|
|
7011
7028
|
activeBounds: o,
|
|
7012
7029
|
targetBounds: d,
|
|
7013
7030
|
targetIsMontageArea: c
|
|
@@ -7025,8 +7042,8 @@ class Dt {
|
|
|
7025
7042
|
event: t,
|
|
7026
7043
|
activeObject: e
|
|
7027
7044
|
}) {
|
|
7028
|
-
const { target: s } = t, n =
|
|
7029
|
-
return s && !
|
|
7045
|
+
const { target: s } = t, n = rs({ activeObject: e });
|
|
7046
|
+
return s && !cs({ object: s, excluded: n }) ? s : null;
|
|
7030
7047
|
}
|
|
7031
7048
|
/**
|
|
7032
7049
|
* Собирает вертикальные и горизонтальные направляющие расстояний.
|
|
@@ -7036,11 +7053,11 @@ class Dt {
|
|
|
7036
7053
|
targetBounds: e,
|
|
7037
7054
|
targetIsMontageArea: s
|
|
7038
7055
|
}) {
|
|
7039
|
-
const n =
|
|
7056
|
+
const n = Nt._buildHorizontalGuides({
|
|
7040
7057
|
activeBounds: t,
|
|
7041
7058
|
targetBounds: e,
|
|
7042
7059
|
targetIsMontageArea: s
|
|
7043
|
-
}), o =
|
|
7060
|
+
}), o = Nt._buildVerticalGuides({
|
|
7044
7061
|
activeBounds: t,
|
|
7045
7062
|
targetBounds: e,
|
|
7046
7063
|
targetIsMontageArea: s
|
|
@@ -7091,21 +7108,21 @@ class Dt {
|
|
|
7091
7108
|
}), n;
|
|
7092
7109
|
}
|
|
7093
7110
|
if (!s) return n;
|
|
7094
|
-
const A = o < d, y = i > l,
|
|
7111
|
+
const A = o < d, y = i > l, M = Math.min(o, d), j = Math.max(o, d), C = j - M;
|
|
7095
7112
|
C > 0 && !A && n.push({
|
|
7096
7113
|
type: "horizontal",
|
|
7097
7114
|
axis: w,
|
|
7098
|
-
start:
|
|
7115
|
+
start: M,
|
|
7099
7116
|
end: j,
|
|
7100
7117
|
distance: C
|
|
7101
7118
|
});
|
|
7102
|
-
const S = Math.min(i, l),
|
|
7103
|
-
return
|
|
7119
|
+
const S = Math.min(i, l), E = Math.max(i, l), b = E - S;
|
|
7120
|
+
return b > 0 && !y && n.push({
|
|
7104
7121
|
type: "horizontal",
|
|
7105
7122
|
axis: w,
|
|
7106
7123
|
start: S,
|
|
7107
|
-
end:
|
|
7108
|
-
distance:
|
|
7124
|
+
end: E,
|
|
7125
|
+
distance: b
|
|
7109
7126
|
}), n;
|
|
7110
7127
|
}
|
|
7111
7128
|
/**
|
|
@@ -7152,21 +7169,21 @@ class Dt {
|
|
|
7152
7169
|
}), n;
|
|
7153
7170
|
}
|
|
7154
7171
|
if (!s) return n;
|
|
7155
|
-
const A = o < d, y = i > l,
|
|
7172
|
+
const A = o < d, y = i > l, M = Math.min(o, d), j = Math.max(o, d), C = j - M;
|
|
7156
7173
|
C > 0 && !A && n.push({
|
|
7157
7174
|
type: "vertical",
|
|
7158
7175
|
axis: w,
|
|
7159
|
-
start:
|
|
7176
|
+
start: M,
|
|
7160
7177
|
end: j,
|
|
7161
7178
|
distance: C
|
|
7162
7179
|
});
|
|
7163
|
-
const S = Math.min(i, l),
|
|
7164
|
-
return
|
|
7180
|
+
const S = Math.min(i, l), E = Math.max(i, l), b = E - S;
|
|
7181
|
+
return b > 0 && !y && n.push({
|
|
7165
7182
|
type: "vertical",
|
|
7166
7183
|
axis: w,
|
|
7167
7184
|
start: S,
|
|
7168
|
-
end:
|
|
7169
|
-
distance:
|
|
7185
|
+
end: E,
|
|
7186
|
+
distance: b
|
|
7170
7187
|
}), n;
|
|
7171
7188
|
}
|
|
7172
7189
|
/**
|
|
@@ -7194,10 +7211,10 @@ class Dt {
|
|
|
7194
7211
|
const { canvas: t } = this, e = t.getSelectionContext();
|
|
7195
7212
|
if (!e) return;
|
|
7196
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;
|
|
7197
|
-
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([]);
|
|
7198
7215
|
for (const c of this.activeGuides) {
|
|
7199
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;
|
|
7200
|
-
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({
|
|
7201
7218
|
context: e,
|
|
7202
7219
|
type: d,
|
|
7203
7220
|
axis: l,
|
|
@@ -7205,8 +7222,8 @@ class Dt {
|
|
|
7205
7222
|
end: f,
|
|
7206
7223
|
text: Math.round(g).toString(),
|
|
7207
7224
|
zoom: n,
|
|
7208
|
-
color:
|
|
7209
|
-
lineWidth:
|
|
7225
|
+
color: es,
|
|
7226
|
+
lineWidth: ss,
|
|
7210
7227
|
offsetAlongAxis: v,
|
|
7211
7228
|
offsetPerpendicular: w
|
|
7212
7229
|
});
|
|
@@ -7232,14 +7249,14 @@ class Dt {
|
|
|
7232
7249
|
(e = t == null ? void 0 : t.showAfterTemporary) == null || e.call(t), this.isToolbarHidden = !1;
|
|
7233
7250
|
}
|
|
7234
7251
|
}
|
|
7235
|
-
class
|
|
7252
|
+
class xe {
|
|
7236
7253
|
/**
|
|
7237
7254
|
* Конструктор класса ImageEditor.
|
|
7238
7255
|
* @param canvasId - идентификатор канваса, в котором будет создан редактор
|
|
7239
7256
|
* @param options - опции и настройки редактора
|
|
7240
7257
|
*/
|
|
7241
7258
|
constructor(t, e) {
|
|
7242
|
-
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();
|
|
7243
7260
|
}
|
|
7244
7261
|
/**
|
|
7245
7262
|
* Инициализация редактора.
|
|
@@ -7247,7 +7264,7 @@ class Le {
|
|
|
7247
7264
|
* @fires editor:ready
|
|
7248
7265
|
*/
|
|
7249
7266
|
init() {
|
|
7250
|
-
return
|
|
7267
|
+
return W(this, null, function* () {
|
|
7251
7268
|
var u;
|
|
7252
7269
|
const {
|
|
7253
7270
|
editorContainerWidth: t,
|
|
@@ -7262,17 +7279,17 @@ class Le {
|
|
|
7262
7279
|
showRotationAngle: d,
|
|
7263
7280
|
_onReadyCallback: l
|
|
7264
7281
|
} = this.options;
|
|
7265
|
-
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) {
|
|
7266
7283
|
const f = a, {
|
|
7267
7284
|
source: g,
|
|
7268
7285
|
scale: p = `image-${c}`,
|
|
7269
7286
|
withoutSave: m = !0
|
|
7270
|
-
} = f, v =
|
|
7287
|
+
} = f, v = gt(f, [
|
|
7271
7288
|
"source",
|
|
7272
7289
|
"scale",
|
|
7273
7290
|
"withoutSave"
|
|
7274
7291
|
]);
|
|
7275
|
-
yield this.imageManager.importImage(
|
|
7292
|
+
yield this.imageManager.importImage(z({ source: g, scale: p, withoutSave: m }, v));
|
|
7276
7293
|
}
|
|
7277
7294
|
r && this.historyManager.loadStateFromFullState(r), this.historyManager.saveState(), console.log("editor:ready"), this.canvas.fire("editor:ready", this), typeof l == "function" && l(this);
|
|
7278
7295
|
});
|
|
@@ -7288,7 +7305,7 @@ class Le {
|
|
|
7288
7305
|
this.montageArea = this.shapeManager.addRectangle({
|
|
7289
7306
|
width: t,
|
|
7290
7307
|
height: e,
|
|
7291
|
-
fill:
|
|
7308
|
+
fill: xe._createMosaicPattern(),
|
|
7292
7309
|
stroke: null,
|
|
7293
7310
|
strokeWidth: 0,
|
|
7294
7311
|
selectable: !1,
|
|
@@ -8269,13 +8286,13 @@ const L = [
|
|
|
8269
8286
|
fonts: Cn
|
|
8270
8287
|
};
|
|
8271
8288
|
function Dn(h, t = {}) {
|
|
8272
|
-
const e =
|
|
8289
|
+
const e = z(z({}, In), t), s = document.getElementById(h);
|
|
8273
8290
|
if (!s)
|
|
8274
8291
|
return Promise.reject(new Error(`Контейнер с ID "${h}" не найден.`));
|
|
8275
8292
|
const n = document.createElement("canvas");
|
|
8276
8293
|
return n.id = `${h}-canvas`, s.appendChild(n), e.editorContainer = s, new Promise((o) => {
|
|
8277
8294
|
e._onReadyCallback = o;
|
|
8278
|
-
const i = new
|
|
8295
|
+
const i = new xe(n.id, e);
|
|
8279
8296
|
window[h] = i;
|
|
8280
8297
|
});
|
|
8281
8298
|
}
|