@anu3ev/fabric-image-editor 0.5.10 → 0.5.13
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 +771 -738
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
1
|
+
var cs = Object.defineProperty, ds = Object.defineProperties;
|
|
2
|
+
var ls = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var Vt = Object.getOwnPropertySymbols;
|
|
4
|
+
var Re = Object.prototype.hasOwnProperty, _e = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var De = (h, t, e) => t in h ? cs(h, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : h[t] = e, B = (h, t) => {
|
|
6
6
|
for (var e in t || (t = {}))
|
|
7
|
-
|
|
8
|
-
if (
|
|
9
|
-
for (var e of
|
|
10
|
-
|
|
7
|
+
Re.call(t, e) && De(h, e, t[e]);
|
|
8
|
+
if (Vt)
|
|
9
|
+
for (var e of Vt(t))
|
|
10
|
+
_e.call(t, e) && De(h, e, t[e]);
|
|
11
11
|
return h;
|
|
12
|
-
}, yt = (h, t) =>
|
|
12
|
+
}, yt = (h, t) => ds(h, ls(t));
|
|
13
13
|
var vt = (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
|
+
Re.call(h, s) && t.indexOf(s) < 0 && (e[s] = h[s]);
|
|
17
|
+
if (h != null && Vt)
|
|
18
|
+
for (var s of Vt(h))
|
|
19
|
+
t.indexOf(s) < 0 && _e.call(h, s) && (e[s] = h[s]);
|
|
20
20
|
return e;
|
|
21
21
|
};
|
|
22
|
-
var
|
|
22
|
+
var k = (h, t, e) => new Promise((s, o) => {
|
|
23
23
|
var n = (r) => {
|
|
24
24
|
try {
|
|
25
25
|
a(e.next(r));
|
|
@@ -35,15 +35,15 @@ var x = (h, t, e) => new Promise((s, o) => {
|
|
|
35
35
|
}, a = (r) => r.done ? s(r.value) : Promise.resolve(r.value).then(n, i);
|
|
36
36
|
a((e = e.apply(h, t)).next());
|
|
37
37
|
});
|
|
38
|
-
import { ActiveSelection as
|
|
39
|
-
import { create as
|
|
40
|
-
import
|
|
41
|
-
var
|
|
38
|
+
import { ActiveSelection as U, Textbox as nt, util as dt, controlsUtils as xe, InteractiveFabricObject as Ne, Point as et, FitContentLayout as Be, loadSVGFromURL as hs, FabricImage as zt, Gradient as ke, Rect as us, Circle as gs, Triangle as fs, Group as Et, Color as ps, classRegistry as ze, loadSVGFromString as ms, Canvas as ys, Pattern as vs } from "fabric";
|
|
39
|
+
import { create as bs } from "jsondiffpatch";
|
|
40
|
+
import Ms from "diff-match-patch";
|
|
41
|
+
var ws = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", V = 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
|
-
e +=
|
|
43
|
+
e += ws[s[t] & 63];
|
|
44
44
|
return e;
|
|
45
45
|
};
|
|
46
|
-
class
|
|
46
|
+
class Ft {
|
|
47
47
|
/**
|
|
48
48
|
* Конструктор принимает редактор и опции.
|
|
49
49
|
* @param params
|
|
@@ -61,7 +61,7 @@ class Ut {
|
|
|
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 = Ft.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 = Ft.debounce(this.handleObjectModifiedHistory.bind(this), 300), this.handleObjectRotatingHistoryBound = Ft.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 Ut {
|
|
|
98
98
|
if (o.length === 1)
|
|
99
99
|
this.canvas.setActiveObject(o[0]);
|
|
100
100
|
else {
|
|
101
|
-
const i = new
|
|
101
|
+
const i = new U(o, {
|
|
102
102
|
canvas: this.canvas
|
|
103
103
|
});
|
|
104
104
|
this.canvas.setActiveObject(i);
|
|
@@ -106,7 +106,7 @@ class Ut {
|
|
|
106
106
|
this.canvas.requestRenderAll();
|
|
107
107
|
return;
|
|
108
108
|
}
|
|
109
|
-
const n = new
|
|
109
|
+
const n = new U(t, {
|
|
110
110
|
canvas: this.canvas
|
|
111
111
|
});
|
|
112
112
|
this.editor.objectLockManager.lockObject({
|
|
@@ -175,7 +175,7 @@ class Ut {
|
|
|
175
175
|
* @param event.code — код клавиши
|
|
176
176
|
*/
|
|
177
177
|
handleUndoRedoEvent(t) {
|
|
178
|
-
return
|
|
178
|
+
return k(this, null, function* () {
|
|
179
179
|
const { ctrlKey: e, metaKey: s, code: o, repeat: n } = t;
|
|
180
180
|
this._shouldIgnoreKeyboardEvent(t) || !e && !s || n || !/Mac/i.test(navigator.userAgent) && this.isUndoRedoKeyPressed || (o === "KeyZ" ? (t.preventDefault(), this.isUndoRedoKeyPressed = !0, yield this.editor.historyManager.undo()) : o === "KeyY" && (t.preventDefault(), this.isUndoRedoKeyPressed = !0, yield this.editor.historyManager.redo()));
|
|
181
181
|
});
|
|
@@ -220,7 +220,7 @@ class Ut {
|
|
|
220
220
|
if (o || n) return;
|
|
221
221
|
this.isSpacePressed = !0, t.preventDefault();
|
|
222
222
|
const i = e.getActiveObject() || null;
|
|
223
|
-
i instanceof
|
|
223
|
+
i instanceof U ? this.savedSelection = i.getObjects().slice() : i && (this.savedSelection = [i]), e.discardActiveObject(), e.set({
|
|
224
224
|
selection: !1,
|
|
225
225
|
defaultCursor: "grab"
|
|
226
226
|
}), e.setCursor("grab"), s.canvasManager.getObjects().forEach((a) => {
|
|
@@ -259,7 +259,7 @@ class Ut {
|
|
|
259
259
|
e.setActiveObject(t[0]);
|
|
260
260
|
return;
|
|
261
261
|
}
|
|
262
|
-
const o = t.filter((i) => s.canvasManager.getObjects().includes(i)), n = new
|
|
262
|
+
const o = t.filter((i) => s.canvasManager.getObjects().includes(i)), n = new U(o, { canvas: e });
|
|
263
263
|
e.setActiveObject(n);
|
|
264
264
|
}
|
|
265
265
|
// --- Обработчики для событий canvas (Fabric) ---
|
|
@@ -391,7 +391,7 @@ class Ut {
|
|
|
391
391
|
};
|
|
392
392
|
}
|
|
393
393
|
}
|
|
394
|
-
class
|
|
394
|
+
class Ss {
|
|
395
395
|
/**
|
|
396
396
|
* Класс для динамической загрузки внешних модулей.
|
|
397
397
|
*/
|
|
@@ -409,7 +409,7 @@ class As {
|
|
|
409
409
|
return this.loaders[t] ? (this.cache.has(t) || this.cache.set(t, this.loaders[t]()), this.cache.get(t)) : Promise.reject(new Error(`Unknown module "${t}"`));
|
|
410
410
|
}
|
|
411
411
|
}
|
|
412
|
-
function
|
|
412
|
+
function As(h) {
|
|
413
413
|
return new Worker(
|
|
414
414
|
"" + new URL("assets/worker-CN39s7P7.js", import.meta.url).href,
|
|
415
415
|
{
|
|
@@ -417,13 +417,13 @@ function js(h) {
|
|
|
417
417
|
}
|
|
418
418
|
);
|
|
419
419
|
}
|
|
420
|
-
class
|
|
420
|
+
class js {
|
|
421
421
|
/**
|
|
422
422
|
* @param scriptUrl — URL скрипта воркера.
|
|
423
423
|
* По-умолчанию использует DefaultWorker из соседнего файла
|
|
424
424
|
*/
|
|
425
425
|
constructor(t) {
|
|
426
|
-
t ? this.worker = new Worker(t, { type: "module" }) : this.worker = new
|
|
426
|
+
t ? this.worker = new Worker(t, { type: "module" }) : this.worker = new As(), this._callbacks = /* @__PURE__ */ new Map(), this.worker.onmessage = this._handleMessage.bind(this);
|
|
427
427
|
}
|
|
428
428
|
/**
|
|
429
429
|
* Обработчик сообщений от воркера
|
|
@@ -451,7 +451,7 @@ class Is {
|
|
|
451
451
|
* @returns Promise, который будет выполнен, когда воркер вернет ответ
|
|
452
452
|
*/
|
|
453
453
|
post(t, e, s = []) {
|
|
454
|
-
const o = `${t}:${
|
|
454
|
+
const o = `${t}:${V(8)}`;
|
|
455
455
|
return new Promise((n, i) => {
|
|
456
456
|
this._callbacks.set(o, { resolve: n, reject: i }), this.worker.postMessage({ action: t, payload: e, requestId: o }, s);
|
|
457
457
|
});
|
|
@@ -463,50 +463,50 @@ class Is {
|
|
|
463
463
|
this.worker.terminate();
|
|
464
464
|
}
|
|
465
465
|
}
|
|
466
|
-
const rt = 12,
|
|
467
|
-
function
|
|
468
|
-
const n = rt, i =
|
|
469
|
-
h.save(), h.translate(t, e), h.rotate(dt.degreesToRadians(o.angle)), h.fillStyle =
|
|
466
|
+
const rt = 12, Is = 2, de = 8, le = 20, Cs = 100, he = 20, ue = 8, Ts = 100, $t = 32, me = 1, Es = "#2B2D33", ye = "#3D8BF4", ve = "#FFFFFF";
|
|
467
|
+
function Xt(h, t, e, s, o) {
|
|
468
|
+
const n = rt, i = Is;
|
|
469
|
+
h.save(), h.translate(t, e), h.rotate(dt.degreesToRadians(o.angle)), h.fillStyle = ve, h.strokeStyle = ye, h.lineWidth = me, h.beginPath(), h.roundRect(-n / 2, -n / 2, n, n, i), h.fill(), h.stroke(), h.restore();
|
|
470
470
|
}
|
|
471
471
|
function Ue(h, t, e, s, o) {
|
|
472
|
-
const n =
|
|
473
|
-
h.save(), h.translate(t, e), h.rotate(dt.degreesToRadians(o.angle)), h.fillStyle =
|
|
472
|
+
const n = de, i = le, a = Cs;
|
|
473
|
+
h.save(), h.translate(t, e), h.rotate(dt.degreesToRadians(o.angle)), h.fillStyle = ve, h.strokeStyle = ye, h.lineWidth = me, h.beginPath(), h.roundRect(-n / 2, -i / 2, n, i, a), h.fill(), h.stroke(), h.restore();
|
|
474
474
|
}
|
|
475
|
-
function
|
|
476
|
-
const n =
|
|
477
|
-
h.save(), h.translate(t, e), h.rotate(dt.degreesToRadians(o.angle)), h.fillStyle =
|
|
475
|
+
function Pe(h, t, e, s, o) {
|
|
476
|
+
const n = he, i = ue, a = Ts;
|
|
477
|
+
h.save(), h.translate(t, e), h.rotate(dt.degreesToRadians(o.angle)), h.fillStyle = ve, h.strokeStyle = ye, h.lineWidth = me, h.beginPath(), h.roundRect(-n / 2, -i / 2, n, i, a), h.fill(), h.stroke(), h.restore();
|
|
478
478
|
}
|
|
479
|
-
const
|
|
480
|
-
|
|
481
|
-
function
|
|
482
|
-
const i =
|
|
483
|
-
h.save(), h.translate(t, e), h.rotate(dt.degreesToRadians(o.angle)), h.fillStyle =
|
|
479
|
+
const Os = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTE4Ljc1IDQuMzc1djMuNzVhLjYyNS42MjUgMCAwIDEtLjYyNS42MjVoLTMuNzVhLjYyNS42MjUgMCAwIDEgMC0xLjI1aDIuMTRsLTIuMDc3LTEuOTAzLS4wMi0uMDE5YTYuMjUgNi4yNSAwIDEgMC0uMTMgOC45NjcuNjI2LjYyNiAwIDAgMSAuODYuOTA5QTcuNDU2IDcuNDU2IDAgMCAxIDEwIDE3LjVoLS4xMDNhNy41IDcuNSAwIDEgMSA1LjM5Ni0xMi44MTJMMTcuNSA2LjcwM1Y0LjM3NWEuNjI1LjYyNSAwIDAgMSAxLjI1IDBaIi8+PC9zdmc+", ts = new Image();
|
|
480
|
+
ts.src = Os;
|
|
481
|
+
function Ls(h, t, e, s, o) {
|
|
482
|
+
const i = $t / 2;
|
|
483
|
+
h.save(), h.translate(t, e), h.rotate(dt.degreesToRadians(o.angle)), h.fillStyle = Es, h.beginPath(), h.arc(0, 0, i, 0, 2 * Math.PI), h.fill(), h.drawImage(ts, -i / 2, -i / 2, i, i), h.restore();
|
|
484
484
|
}
|
|
485
|
-
const
|
|
485
|
+
const Ds = {
|
|
486
486
|
// Угловые точки
|
|
487
487
|
tl: {
|
|
488
|
-
render:
|
|
488
|
+
render: Xt,
|
|
489
489
|
sizeX: rt,
|
|
490
490
|
sizeY: rt,
|
|
491
491
|
offsetX: 0,
|
|
492
492
|
offsetY: 0
|
|
493
493
|
},
|
|
494
494
|
tr: {
|
|
495
|
-
render:
|
|
495
|
+
render: Xt,
|
|
496
496
|
sizeX: rt,
|
|
497
497
|
sizeY: rt,
|
|
498
498
|
offsetX: 0,
|
|
499
499
|
offsetY: 0
|
|
500
500
|
},
|
|
501
501
|
bl: {
|
|
502
|
-
render:
|
|
502
|
+
render: Xt,
|
|
503
503
|
sizeX: rt,
|
|
504
504
|
sizeY: rt,
|
|
505
505
|
offsetX: 0,
|
|
506
506
|
offsetY: 0
|
|
507
507
|
},
|
|
508
508
|
br: {
|
|
509
|
-
render:
|
|
509
|
+
render: Xt,
|
|
510
510
|
sizeX: rt,
|
|
511
511
|
sizeY: rt,
|
|
512
512
|
offsetX: 0,
|
|
@@ -515,43 +515,43 @@ const Rs = {
|
|
|
515
515
|
// Середина вертикалей
|
|
516
516
|
ml: {
|
|
517
517
|
render: Ue,
|
|
518
|
-
sizeX:
|
|
519
|
-
sizeY:
|
|
518
|
+
sizeX: de,
|
|
519
|
+
sizeY: le,
|
|
520
520
|
offsetX: 0,
|
|
521
521
|
offsetY: 0
|
|
522
522
|
},
|
|
523
523
|
mr: {
|
|
524
524
|
render: Ue,
|
|
525
|
-
sizeX:
|
|
526
|
-
sizeY:
|
|
525
|
+
sizeX: de,
|
|
526
|
+
sizeY: le,
|
|
527
527
|
offsetX: 0,
|
|
528
528
|
offsetY: 0
|
|
529
529
|
},
|
|
530
530
|
// Середина горизонталей
|
|
531
531
|
mt: {
|
|
532
|
-
render:
|
|
533
|
-
sizeX:
|
|
534
|
-
sizeY:
|
|
532
|
+
render: Pe,
|
|
533
|
+
sizeX: he,
|
|
534
|
+
sizeY: ue,
|
|
535
535
|
offsetX: 0,
|
|
536
536
|
offsetY: 0
|
|
537
537
|
},
|
|
538
538
|
mb: {
|
|
539
|
-
render:
|
|
540
|
-
sizeX:
|
|
541
|
-
sizeY:
|
|
539
|
+
render: Pe,
|
|
540
|
+
sizeX: he,
|
|
541
|
+
sizeY: ue,
|
|
542
542
|
offsetX: 0,
|
|
543
543
|
offsetY: 0
|
|
544
544
|
},
|
|
545
545
|
// Специальный «rotate» контрол
|
|
546
546
|
mtr: {
|
|
547
|
-
render:
|
|
548
|
-
sizeX:
|
|
549
|
-
sizeY:
|
|
547
|
+
render: Ls,
|
|
548
|
+
sizeX: $t,
|
|
549
|
+
sizeY: $t,
|
|
550
550
|
offsetX: 0,
|
|
551
|
-
offsetY:
|
|
551
|
+
offsetY: -$t
|
|
552
552
|
}
|
|
553
553
|
};
|
|
554
|
-
class
|
|
554
|
+
class $ {
|
|
555
555
|
/**
|
|
556
556
|
* Отключает изменение ширины по оси X для заблокированных объектов, сохраняя поведение остального хэндлера.
|
|
557
557
|
*/
|
|
@@ -567,7 +567,7 @@ class J {
|
|
|
567
567
|
* Применяет конфигурацию контролов к набору по ключам из DEFAULT_CONTROLS.
|
|
568
568
|
*/
|
|
569
569
|
static applyControlOverrides(t) {
|
|
570
|
-
Object.entries(
|
|
570
|
+
Object.entries(Ds).forEach(([e, s]) => {
|
|
571
571
|
const o = t[e];
|
|
572
572
|
o && (Object.assign(o, s), e === "mtr" && (o.cursorStyle = "grab", o.mouseDownHandler = (n, i, a, r) => {
|
|
573
573
|
var d;
|
|
@@ -581,23 +581,23 @@ class J {
|
|
|
581
581
|
*/
|
|
582
582
|
static apply() {
|
|
583
583
|
const t = xe.createObjectDefaultControls();
|
|
584
|
-
|
|
584
|
+
$.applyControlOverrides(t), Ne.ownDefaults.controls = t;
|
|
585
585
|
const e = xe.createTextboxDefaultControls();
|
|
586
|
-
|
|
586
|
+
$.applyControlOverrides(e), e.mt && (e.mt.visible = !1), e.mb && (e.mb.visible = !1), $.wrapWidthControl(e.ml), $.wrapWidthControl(e.mr), nt.ownDefaults.controls = e, $.patchActiveSelectionBounds(), Ne.ownDefaults.snapAngle = 1;
|
|
587
587
|
}
|
|
588
588
|
/**
|
|
589
589
|
* Обновляет алгоритм расчёта границ ActiveSelection, чтобы учитывать фон и отступы текстовых объектов.
|
|
590
590
|
*/
|
|
591
591
|
static patchActiveSelectionBounds() {
|
|
592
|
-
const t =
|
|
592
|
+
const t = U.prototype, e = t._calcBoundsFromObjects;
|
|
593
593
|
t._calcBoundsFromObjects = function(...n) {
|
|
594
594
|
var g, f;
|
|
595
595
|
const i = (f = (g = this.getObjects) == null ? void 0 : g.call(this)) != null ? f : [];
|
|
596
|
-
|
|
596
|
+
$.applyTextSelectionScalingLock({
|
|
597
597
|
selection: this,
|
|
598
598
|
objects: i
|
|
599
599
|
});
|
|
600
|
-
const a =
|
|
600
|
+
const a = $.calculateActiveSelectionBounds({
|
|
601
601
|
objects: i
|
|
602
602
|
});
|
|
603
603
|
if (!a)
|
|
@@ -609,45 +609,45 @@ class J {
|
|
|
609
609
|
width: d,
|
|
610
610
|
height: l
|
|
611
611
|
});
|
|
612
|
-
const u = new
|
|
612
|
+
const u = new et(r + d / 2, c + l / 2);
|
|
613
613
|
return this.setPositionByOrigin(u, "center", "center"), a;
|
|
614
614
|
};
|
|
615
615
|
const s = t._onAfterObjectsChange;
|
|
616
616
|
t._onAfterObjectsChange = function(n, i) {
|
|
617
617
|
var p, m;
|
|
618
618
|
const a = s ? s.call(this, n, i) : void 0, r = (m = (p = this.getObjects) == null ? void 0 : p.call(this)) != null ? m : [];
|
|
619
|
-
|
|
619
|
+
$.applyTextSelectionScalingLock({
|
|
620
620
|
selection: this,
|
|
621
621
|
objects: r
|
|
622
622
|
});
|
|
623
|
-
const c =
|
|
623
|
+
const c = $.calculateActiveSelectionBounds({
|
|
624
624
|
objects: r
|
|
625
625
|
});
|
|
626
626
|
if (!c) return a;
|
|
627
|
-
const { left: d, top: l, width: u, height: g } = c, f = new
|
|
627
|
+
const { left: d, top: l, width: u, height: g } = c, f = new et(d + u / 2, l + g / 2);
|
|
628
628
|
return this.set({
|
|
629
629
|
width: u,
|
|
630
630
|
height: g
|
|
631
631
|
}), this.setPositionByOrigin(f, "center", "center"), this.setCoords(), a;
|
|
632
632
|
};
|
|
633
|
-
const o =
|
|
634
|
-
|
|
633
|
+
const o = Be.prototype.calcBoundingBox;
|
|
634
|
+
Be.prototype.calcBoundingBox = function(n, i) {
|
|
635
635
|
const { target: a, type: r, overrides: c } = i;
|
|
636
636
|
if (r === "imperative" && c)
|
|
637
637
|
return c;
|
|
638
|
-
if (!(a instanceof
|
|
638
|
+
if (!(a instanceof U))
|
|
639
639
|
return o.call(this, n, i);
|
|
640
|
-
|
|
640
|
+
$.applyTextSelectionScalingLock({
|
|
641
641
|
selection: a,
|
|
642
642
|
objects: n
|
|
643
643
|
});
|
|
644
|
-
const d =
|
|
644
|
+
const d = $.calculateActiveSelectionBounds({ objects: n });
|
|
645
645
|
if (!d)
|
|
646
646
|
return o.call(this, n, i);
|
|
647
|
-
const { left: l, top: u, width: g, height: f } = d, p = new
|
|
647
|
+
const { left: l, top: u, width: g, height: f } = d, p = new et(g, f), m = new et(l + g / 2, u + f / 2);
|
|
648
648
|
return r === "initialization" ? {
|
|
649
649
|
center: m,
|
|
650
|
-
relativeCorrection: new
|
|
650
|
+
relativeCorrection: new et(0, 0),
|
|
651
651
|
size: p
|
|
652
652
|
} : {
|
|
653
653
|
center: m,
|
|
@@ -686,7 +686,7 @@ class J {
|
|
|
686
686
|
});
|
|
687
687
|
}
|
|
688
688
|
}
|
|
689
|
-
const
|
|
689
|
+
const z = class z {
|
|
690
690
|
constructor(t = []) {
|
|
691
691
|
this.fonts = t;
|
|
692
692
|
}
|
|
@@ -694,36 +694,36 @@ const B = class B {
|
|
|
694
694
|
this.fonts = t;
|
|
695
695
|
}
|
|
696
696
|
loadFonts() {
|
|
697
|
-
return
|
|
697
|
+
return k(this, null, function* () {
|
|
698
698
|
var o;
|
|
699
699
|
const t = (o = this.fonts) != null ? o : [];
|
|
700
700
|
if (!t.length) return;
|
|
701
701
|
const e = typeof document != "undefined" ? document : void 0;
|
|
702
702
|
if (!e) return;
|
|
703
|
-
const s = t.map((n) =>
|
|
703
|
+
const s = t.map((n) => z.loadFont(n, e));
|
|
704
704
|
yield Promise.allSettled(s);
|
|
705
705
|
});
|
|
706
706
|
}
|
|
707
707
|
static loadFont(t, e) {
|
|
708
|
-
return
|
|
708
|
+
return k(this, null, function* () {
|
|
709
709
|
var c, d;
|
|
710
710
|
const s = typeof FontFace != "undefined", o = (c = t.family) == null ? void 0 : c.trim(), n = (d = t.source) == null ? void 0 : d.trim();
|
|
711
711
|
if (!o || !n) return;
|
|
712
|
-
const i =
|
|
713
|
-
if (!
|
|
714
|
-
if (
|
|
715
|
-
|
|
712
|
+
const i = z.normalizeFontSource(n), a = z.getDescriptorSnapshot(t.descriptors), r = z.getFontRegistrationKey(o, i, a);
|
|
713
|
+
if (!z.registeredFontKeys.has(r)) {
|
|
714
|
+
if (z.isFontFaceAlreadyApplied(e, o, a)) {
|
|
715
|
+
z.registeredFontKeys.add(r);
|
|
716
716
|
return;
|
|
717
717
|
}
|
|
718
718
|
if (s && e.fonts && typeof e.fonts.add == "function")
|
|
719
719
|
try {
|
|
720
720
|
const u = yield new FontFace(o, i, t.descriptors).load();
|
|
721
|
-
e.fonts.add(u),
|
|
721
|
+
e.fonts.add(u), z.registeredFontKeys.add(r);
|
|
722
722
|
return;
|
|
723
723
|
} catch (l) {
|
|
724
724
|
console.warn(`Не удалось загрузить шрифт "${o}" через FontFace API`, l);
|
|
725
725
|
}
|
|
726
|
-
|
|
726
|
+
z.injectFontFace({
|
|
727
727
|
font: t,
|
|
728
728
|
source: i,
|
|
729
729
|
doc: e,
|
|
@@ -743,15 +743,15 @@ const B = class B {
|
|
|
743
743
|
if (!i) return;
|
|
744
744
|
const a = s.createElement("style");
|
|
745
745
|
a.setAttribute("data-editor-font", i), a.setAttribute("data-editor-font-key", o);
|
|
746
|
-
const r =
|
|
746
|
+
const r = z.descriptorsToCss(n), c = [
|
|
747
747
|
"@font-face {",
|
|
748
|
-
` font-family: ${
|
|
748
|
+
` font-family: ${z.formatFontFamilyForCss(i)};`,
|
|
749
749
|
` src: ${e};`,
|
|
750
750
|
...r.map((l) => ` ${l}`),
|
|
751
751
|
"}"
|
|
752
752
|
];
|
|
753
753
|
a.textContent = c.join(`
|
|
754
|
-
`), s.head.appendChild(a),
|
|
754
|
+
`), s.head.appendChild(a), z.registeredFontKeys.add(o);
|
|
755
755
|
}
|
|
756
756
|
static normalizeFontSource(t) {
|
|
757
757
|
const e = t.trim();
|
|
@@ -774,15 +774,15 @@ const B = class B {
|
|
|
774
774
|
return t ? t.trim().replace(/^['"]+|['"]+$/g, "").toLowerCase() : "";
|
|
775
775
|
}
|
|
776
776
|
static getDescriptorSnapshot(t) {
|
|
777
|
-
const e =
|
|
777
|
+
const e = z.descriptorDefaults;
|
|
778
778
|
return {
|
|
779
|
-
style:
|
|
780
|
-
weight:
|
|
781
|
-
stretch:
|
|
782
|
-
unicodeRange:
|
|
783
|
-
variant:
|
|
784
|
-
featureSettings:
|
|
785
|
-
display:
|
|
779
|
+
style: z.normalizeDescriptorValue(t == null ? void 0 : t.style, e.style),
|
|
780
|
+
weight: z.normalizeDescriptorValue(t == null ? void 0 : t.weight, e.weight),
|
|
781
|
+
stretch: z.normalizeDescriptorValue(t == null ? void 0 : t.stretch, e.stretch),
|
|
782
|
+
unicodeRange: z.normalizeDescriptorValue(t == null ? void 0 : t.unicodeRange, e.unicodeRange),
|
|
783
|
+
variant: z.normalizeDescriptorValue(t == null ? void 0 : t.variant, e.variant),
|
|
784
|
+
featureSettings: z.normalizeDescriptorValue(t == null ? void 0 : t.featureSettings, e.featureSettings),
|
|
785
|
+
display: z.normalizeDescriptorValue(t == null ? void 0 : t.display, e.display)
|
|
786
786
|
};
|
|
787
787
|
}
|
|
788
788
|
static areDescriptorSnapshotsEqual(t, e) {
|
|
@@ -790,7 +790,7 @@ const B = class B {
|
|
|
790
790
|
}
|
|
791
791
|
static getFontRegistrationKey(t, e, s) {
|
|
792
792
|
return [
|
|
793
|
-
|
|
793
|
+
z.normalizeFamilyName(t),
|
|
794
794
|
e,
|
|
795
795
|
s.style,
|
|
796
796
|
s.weight,
|
|
@@ -804,12 +804,12 @@ const B = class B {
|
|
|
804
804
|
static isFontFaceAlreadyApplied(t, e, s) {
|
|
805
805
|
const o = t.fonts;
|
|
806
806
|
if (!o || typeof o.forEach != "function") return !1;
|
|
807
|
-
const n =
|
|
807
|
+
const n = z.normalizeFamilyName(e);
|
|
808
808
|
let i = !1;
|
|
809
809
|
try {
|
|
810
810
|
o.forEach((a) => {
|
|
811
|
-
if (i ||
|
|
812
|
-
const c =
|
|
811
|
+
if (i || z.normalizeFamilyName(a.family) !== n) return;
|
|
812
|
+
const c = z.getDescriptorSnapshot({
|
|
813
813
|
style: a.style,
|
|
814
814
|
weight: a.weight,
|
|
815
815
|
stretch: a.stretch,
|
|
@@ -818,7 +818,7 @@ const B = class B {
|
|
|
818
818
|
featureSettings: a.featureSettings,
|
|
819
819
|
display: a.display
|
|
820
820
|
});
|
|
821
|
-
|
|
821
|
+
z.areDescriptorSnapshotsEqual(s, c) && (i = !0);
|
|
822
822
|
});
|
|
823
823
|
} catch (a) {
|
|
824
824
|
return console.warn("Не удалось проверить, загружен ли шрифт ранее через FontFaceSet", a), !1;
|
|
@@ -845,7 +845,7 @@ const B = class B {
|
|
|
845
845
|
});
|
|
846
846
|
}
|
|
847
847
|
};
|
|
848
|
-
|
|
848
|
+
z.registeredFontKeys = /* @__PURE__ */ new Set(), z.descriptorDefaults = {
|
|
849
849
|
style: "normal",
|
|
850
850
|
weight: "normal",
|
|
851
851
|
stretch: "normal",
|
|
@@ -854,8 +854,8 @@ B.registeredFontKeys = /* @__PURE__ */ new Set(), B.descriptorDefaults = {
|
|
|
854
854
|
featureSettings: "normal",
|
|
855
855
|
display: "auto"
|
|
856
856
|
};
|
|
857
|
-
let
|
|
858
|
-
const
|
|
857
|
+
let ge = z;
|
|
858
|
+
const Rs = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNNi44NzUgMi41YS42MjUuNjI1IDAgMCAwLS42MjUuNjI0VjYuMjVIMy4xMjVhLjYyNS42MjUgMCAwIDAtLjYyNS42MjV2MTBjMCAuMzQ1LjI4LjYyNS42MjUuNjI1aDEwYy4zNDUgMCAuNjI1LS4yOC42MjUtLjYyNXYtMy4xMjZoMy4xMjVjLjM0NSAwIC42MjUtLjI4LjYyNS0uNjI1di0xMGEuNjI1LjYyNSAwIDAgMC0uNjI1LS42MjVoLTEwWm02Ljg3NSAxMGgyLjVWMy43NUg3LjV2Mi41aDUuNjI1Yy4zNDUgMCAuNjI1LjI4LjYyNS42MjV2NS42MjRabS0xMCAzLjc1VjcuNWg4Ljc1djguNzVIMy43NVoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjwvc3ZnPg==", _s = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMi41IDcuNWMwLS42OS41Ni0xLjI1IDEuMjUtMS4yNWgxMi41Yy42OSAwIDEuMjUuNTYgMS4yNSAxLjI1djguNzVjMCAuNjktLjU2IDEuMjUtMS4yNSAxLjI1SDMuNzVjLS42OSAwLTEuMjUtLjU2LTEuMjUtMS4yNVY3LjVabTEzLjc1IDBIMy43NXY4Ljc1aDEyLjVWNy41WiIgY2xpcC1ydWxlPSJldmVub2RkIi8+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMTAgMS44NzVhMi4xODggMi4xODggMCAwIDAtMi4xODggMi4xODh2Mi44MTJhLjYyNS42MjUgMCAxIDEtMS4yNSAwVjQuMDYyYTMuNDM3IDMuNDM3IDAgMSAxIDYuODc1IDB2Mi44MTNhLjYyNS42MjUgMCAxIDEtMS4yNSAwVjQuMDYyQTIuMTg4IDIuMTg4IDAgMCAwIDEwIDEuODc2WiIgY2xpcC1ydWxlPSJldmVub2RkIi8+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTEwIDEyLjgxM2EuOTM3LjkzNyAwIDEgMCAwLTEuODc1LjkzNy45MzcgMCAwIDAgMCAxLjg3NFoiLz48L3N2Zz4=", xs = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTE2LjI1IDYuMjVINy41VjQuMzc1YTIuNSAyLjUgMCAwIDEgMi41LTIuNWMxLjIgMCAyLjI4MS44NiAyLjUxMiAyYS42MjUuNjI1IDAgMCAwIDEuMjI2LS4yNWMtLjM1NC0xLjczOC0xLjkyNS0zLTMuNzM4LTNhMy43NTQgMy43NTQgMCAwIDAtMy43NSAzLjc1VjYuMjVoLTIuNUExLjI1IDEuMjUgMCAwIDAgMi41IDcuNXY4Ljc1YTEuMjUgMS4yNSAwIDAgMCAxLjI1IDEuMjVoMTIuNWExLjI1IDEuMjUgMCAwIDAgMS4yNS0xLjI1VjcuNWExLjI1IDEuMjUgMCAwIDAtMS4yNS0xLjI1Wm0wIDEwSDMuNzVWNy41aDEyLjV2OC43NVptLTUuMzEzLTQuMzc1YS45MzcuOTM3IDAgMSAxLTEuODc0IDAgLjkzNy45MzcgMCAwIDEgMS44NzQgMFoiLz48L3N2Zz4K", Ns = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTIuNSA4LjEyNSAxMCAxMi41bDcuNS00LjM3NUwxMCAzLjc1IDIuNSA4LjEyNVoiLz48cGF0aCBmaWxsPSIjZmZmIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik05LjY4NSAzLjIxYS42MjUuNjI1IDAgMCAxIC42MyAwbDcuNSA0LjM3NWEuNjI1LjYyNSAwIDAgMSAwIDEuMDhsLTcuNSA0LjM3NWEuNjI1LjYyNSAwIDAgMS0uNjMgMGwtNy41LTQuMzc1YS42MjUuNjI1IDAgMCAxIDAtMS4wOGw3LjUtNC4zNzVaTTMuNzQgOC4xMjUgMTAgMTEuNzc2bDYuMjYtMy42NTFMMTAgNC40NzQgMy43NCA4LjEyNVoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjxwYXRoIGZpbGw9IiNmZmYiIGZpbGwtcnVsZT0iZXZlbm9kZCIgZD0iTTUuNCA5LjQ2YS42MjUuNjI1IDAgMCAxIC42MyAwTDEwIDExLjc3NmwzLjk3LTIuMzE2YS42MjUuNjI1IDAgMCAxIC42MyAwbDMuMjE1IDEuODc1YS42MjUuNjI1IDAgMCAxIDAgMS4wOGwtNy41IDQuMzc1YS42MjUuNjI1IDAgMCAxLS42MyAwbC03LjUtNC4zNzVhLjYyNS42MjUgMCAwIDEgMC0xLjA4TDUuNCA5LjQ2Wm0tMS42NiAyLjQxNUwxMCAxNS41MjZsNi4yNi0zLjY1MS0xLjk3NC0xLjE1MS0zLjk3MSAyLjMxNmEuNjI1LjYyNSAwIDAgMS0uNjMgMGwtMy45Ny0yLjMxNi0xLjk3NSAxLjE1MVoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjwvc3ZnPg==", Bs = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNOS42ODUgMy4yMWEuNjI1LjYyNSAwIDAgMSAuNjMgMGw3LjUgNC4zNzVhLjYyNS42MjUgMCAwIDEgMCAxLjA4bC03LjUgNC4zNzVhLjYyNS42MjUgMCAwIDEtLjYzIDBsLTcuNS00LjM3NWEuNjI1LjYyNSAwIDAgMSAwLTEuMDhsNy41LTQuMzc1Wk0zLjc0IDguMTI1IDEwIDExLjc3Nmw2LjI2LTMuNjUxTDEwIDQuNDc0IDMuNzQgOC4xMjVaIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiLz48cGF0aCBmaWxsPSIjZmZmIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik01LjcxNCAxMCAxMCAxMi41bDQuMjg2LTIuNSAzLjIxNCAxLjg3NUwxMCAxNi4yNWwtNy41LTQuMzc1TDUuNzE0IDEwWiIgY2xpcC1ydWxlPSJldmVub2RkIi8+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNNS40IDkuNDZhLjYyNS42MjUgMCAwIDEgLjYzIDBMMTAgMTEuNzc2bDMuOTctMi4zMTZhLjYyNS42MjUgMCAwIDEgLjYzIDBsMy4yMTUgMS44NzVhLjYyNS42MjUgMCAwIDEgMCAxLjA4bC03LjUgNC4zNzVhLjYyNS42MjUgMCAwIDEtLjYzIDBsLTcuNS00LjM3NWEuNjI1LjYyNSAwIDAgMSAwLTEuMDhMNS40IDkuNDZabS0xLjY2IDIuNDE1TDEwIDE1LjUyNmw2LjI2LTMuNjUxLTEuOTc0LTEuMTUxLTMuOTcxIDIuMzE2YS42MjUuNjI1IDAgMCAxLS42MyAwbC0zLjk3LTIuMzE2LTEuOTc1IDEuMTUxWiIgY2xpcC1ydWxlPSJldmVub2RkIi8+PC9zdmc+", ks = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0ibTIuNSA2LjI1IDcuNSA0LjM3NSA3LjUtNC4zNzVMMTAgMS44NzUgMi41IDYuMjVaIi8+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNOS42ODUgMS4zMzVhLjYyNS42MjUgMCAwIDEgLjYzIDBsNy41IDQuMzc1YS42MjUuNjI1IDAgMCAxIDAgMS4wOGwtNy41IDQuMzc1YS42MjUuNjI1IDAgMCAxLS42MyAwbC03LjUtNC4zNzVhLjYyNS42MjUgMCAwIDEgMC0xLjA4bDcuNS00LjM3NVpNMy43NCA2LjI1IDEwIDkuOTAxbDYuMjYtMy42NTFMMTAgMi41OTkgMy43NCA2LjI1WiIgY2xpcC1ydWxlPSJldmVub2RkIi8+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNNS40IDExLjMzNWEuNjI1LjYyNSAwIDAgMSAuNjMgMEwxMCAxMy42NTFsMy45Ny0yLjMxNmEuNjI1LjYyNSAwIDAgMSAuNjMgMGwzLjIxNSAxLjg3NWEuNjI1LjYyNSAwIDAgMSAwIDEuMDhsLTcuNSA0LjM3NWEuNjI1LjYyNSAwIDAgMS0uNjMgMGwtNy41LTQuMzc1YS42MjUuNjI1IDAgMCAxIDAtMS4wOEw1LjQgMTEuMzM1Wk0zLjc0IDEzLjc1IDEwIDE3LjQwMWw2LjI2LTMuNjUxLTEuOTc0LTEuMTUxLTMuOTcxIDIuMzE2YS42MjUuNjI1IDAgMCAxLS42MyAwbC0zLjk3LTIuMzE2TDMuNzQgMTMuNzVaIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiLz48cGF0aCBmaWxsPSIjZmZmIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik01LjQgNy41ODVhLjYyNS42MjUgMCAwIDEgLjYzIDBMMTAgOS45MDFsMy45Ny0yLjMxNmEuNjI1LjYyNSAwIDAgMSAuNjMgMGwzLjIxNSAxLjg3NWEuNjI1LjYyNSAwIDAgMSAwIDEuMDhsLTcuNSA0LjM3NWEuNjI1LjYyNSAwIDAgMS0uNjMgMGwtNy41LTQuMzc1YS42MjUuNjI1IDAgMCAxIDAtMS4wOEw1LjQgNy41ODVaTTMuNzQgMTAgMTAgMTMuNjUxIDE2LjI2IDEwbC0xLjk3NC0xLjE1MS0zLjk3MSAyLjMxNmEuNjI1LjYyNSAwIDAgMS0uNjMgMGwtMy45Ny0yLjMxNkwzLjc0IDEwWiIgY2xpcC1ydWxlPSJldmVub2RkIi8+PC9zdmc+", zs = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMS45NiAxMy40MzVhLjYyNS42MjUgMCAwIDEgLjg1NS0uMjI1TDEwIDE3LjQwMWw3LjE4NS00LjE5YS42MjUuNjI1IDAgMCAxIC42MyAxLjA3OWwtNy41IDQuMzc1YS42MjUuNjI1IDAgMCAxLS42MyAwbC03LjUtNC4zNzVhLjYyNS42MjUgMCAwIDEtLjIyNS0uODU1Wk05LjY4NSAxLjMzNWEuNjI1LjYyNSAwIDAgMSAuNjMgMGw3LjUgNC4zNzVhLjYyNS42MjUgMCAwIDEgMCAxLjA4bC03LjUgNC4zNzVhLjYyNS42MjUgMCAwIDEtLjYzIDBsLTcuNS00LjM3NWEuNjI1LjYyNSAwIDAgMSAwLTEuMDhsNy41LTQuMzc1Wk0zLjc0IDYuMjUgMTAgOS45MDFsNi4yNi0zLjY1MUwxMCAyLjU5OSAzLjc0IDYuMjVaIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiLz48cGF0aCBmaWxsPSIjZmZmIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGQ9Im01LjcxNCAxMS44NzUgNC4yODYgMi41IDQuMjg2LTIuNUwxNy41IDEzLjc1IDEwIDE4LjEyNSAyLjUgMTMuNzVsMy4yMTQtMS44NzVaIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiLz48cGF0aCBmaWxsPSIjZmZmIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik01LjQgMTEuMzM1YS42MjUuNjI1IDAgMCAxIC42MyAwTDEwIDEzLjY1MWwzLjk3LTIuMzE2YS42MjUuNjI1IDAgMCAxIC42MyAwbDMuMjE1IDEuODc1YS42MjUuNjI1IDAgMCAxIDAgMS4wOGwtNy41IDQuMzc1YS42MjUuNjI1IDAgMCAxLS42MyAwbC03LjUtNC4zNzVhLjYyNS42MjUgMCAwIDEgMC0xLjA4TDUuNCAxMS4zMzVaTTMuNzQgMTMuNzUgMTAgMTcuNDAxbDYuMjYtMy42NTEtMS45NzQtMS4xNTEtMy45NzEgMi4zMTZhLjYyNS42MjUgMCAwIDEtLjYzIDBsLTMuOTctMi4zMTZMMy43NCAxMy43NVoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjxwYXRoIGZpbGw9IiNmZmYiIGZpbGwtcnVsZT0iZXZlbm9kZCIgZD0iTTUuNCA3LjU4NWEuNjI1LjYyNSAwIDAgMSAuNjMgMEwxMCA5LjkwMWwzLjk3LTIuMzE2YS42MjUuNjI1IDAgMCAxIC42MyAwbDMuMjE1IDEuODc1YS42MjUuNjI1IDAgMCAxIDAgMS4wOGwtNy41IDQuMzc1YS42MjUuNjI1IDAgMCAxLS42MyAwbC03LjUtNC4zNzVhLjYyNS42MjUgMCAwIDEgMC0xLjA4TDUuNCA3LjU4NVpNMy43NCAxMCAxMCAxMy42NTEgMTYuMjYgMTBsLTEuOTc0LTEuMTUxLTMuOTcxIDIuMzE2YS42MjUuNjI1IDAgMCAxLS42MyAwbC0zLjk3LTIuMzE2TDMuNzQgMTBaIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiLz48L3N2Zz4=", Us = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI0VDNEU0MCIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNOC4xMjUgMS4yNUExLjg3NSAxLjg3NSAwIDAgMCA2LjI1IDMuMTI1di42MjVIMy4xMjVhLjYyNS42MjUgMCAwIDAgMCAxLjI1aC42MjV2MTEuMjVBMS4yNSAxLjI1IDAgMCAwIDUgMTcuNWgxMGExLjI1IDEuMjUgMCAwIDAgMS4yNS0xLjI1VjVoLjYyNWEuNjI1LjYyNSAwIDAgMCAwLTEuMjVIMTMuNzV2LS42MjVhMS44NzUgMS44NzUgMCAwIDAtMS44NzUtMS44NzVoLTMuNzVabTQuMzc1IDIuNXYtLjYyNWEuNjI1LjYyNSAwIDAgMC0uNjI1LS42MjVoLTMuNzVhLjYyNS42MjUgMCAwIDAtLjYyNS42MjV2LjYyNWg1Wk01IDE2LjI1VjVoMTB2MTEuMjVINVpNOC4xMjUgNy41Yy4zNDUgMCAuNjI1LjI4LjYyNS42MjV2NWEuNjI1LjYyNSAwIDEgMS0xLjI1IDB2LTVjMC0uMzQ1LjI4LS42MjUuNjI1LS42MjVabTQuMzc1IDUuNjI1di01YS42MjUuNjI1IDAgMCAwLTEuMjUgMHY1YS42MjUuNjI1IDAgMSAwIDEuMjUgMFoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjwvc3ZnPg==", Ut = {
|
|
859
859
|
style: {
|
|
860
860
|
position: "absolute",
|
|
861
861
|
display: "none",
|
|
@@ -922,17 +922,17 @@ const _s = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMj
|
|
|
922
922
|
],
|
|
923
923
|
offsetTop: 50,
|
|
924
924
|
icons: {
|
|
925
|
-
copyPaste:
|
|
925
|
+
copyPaste: Rs,
|
|
926
926
|
delete: Us,
|
|
927
|
-
lock:
|
|
927
|
+
lock: _s,
|
|
928
928
|
unlock: xs,
|
|
929
|
-
bringToFront:
|
|
930
|
-
sendToBack:
|
|
931
|
-
bringForward:
|
|
932
|
-
sendBackwards:
|
|
929
|
+
bringToFront: ks,
|
|
930
|
+
sendToBack: zs,
|
|
931
|
+
bringForward: Ns,
|
|
932
|
+
sendBackwards: Bs
|
|
933
933
|
},
|
|
934
934
|
handlers: {
|
|
935
|
-
copyPaste: (h) =>
|
|
935
|
+
copyPaste: (h) => k(null, null, function* () {
|
|
936
936
|
h.clipboardManager.copyPaste();
|
|
937
937
|
}),
|
|
938
938
|
delete: (h) => {
|
|
@@ -958,18 +958,18 @@ const _s = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMj
|
|
|
958
958
|
}
|
|
959
959
|
}
|
|
960
960
|
};
|
|
961
|
-
class
|
|
961
|
+
class Ps {
|
|
962
962
|
constructor({ editor: t }) {
|
|
963
963
|
this.currentTarget = null, this.currentLocked = !1, this.isTransforming = !1, this.isTemporarilyHidden = !1, this.editor = t, this.canvas = t.canvas, this.options = t.options, this._initToolbar();
|
|
964
964
|
}
|
|
965
965
|
_initToolbar() {
|
|
966
966
|
if (!this.options.showToolbar) return;
|
|
967
967
|
const t = this.options.toolbar || {};
|
|
968
|
-
this.config = yt(
|
|
969
|
-
style:
|
|
970
|
-
btnStyle:
|
|
971
|
-
icons:
|
|
972
|
-
handlers:
|
|
968
|
+
this.config = yt(B(B({}, Ut), t), {
|
|
969
|
+
style: B(B({}, Ut.style), t.style || {}),
|
|
970
|
+
btnStyle: B(B({}, Ut.btnStyle), t.btnStyle || {}),
|
|
971
|
+
icons: B(B({}, Ut.icons), t.icons || {}),
|
|
972
|
+
handlers: B(B({}, Ut.handlers), t.handlers || {})
|
|
973
973
|
}), this.currentTarget = null, this.currentLocked = !1, this.isTransforming = !1, this.isTemporarilyHidden = !1, this._onMouseDown = this._handleMouseDown.bind(this), this._onObjectMoving = this._startTransform.bind(this), this._onObjectScaling = this._startTransform.bind(this), this._onObjectRotating = this._startTransform.bind(this), this._onMouseUp = this._endTransform.bind(this), this._onObjectModified = this._endTransform.bind(this), this._onSelectionChange = this._updateToolbar.bind(this), this._onSelectionClear = () => {
|
|
974
974
|
this.el.style.display = "none";
|
|
975
975
|
}, this._createDOM(), this._bindEvents();
|
|
@@ -1101,7 +1101,7 @@ const Fs = {
|
|
|
1101
1101
|
"white-space": "nowrap",
|
|
1102
1102
|
"box-shadow": "0 2px 8px rgba(0, 0, 0, 0.2)"
|
|
1103
1103
|
}, Fe = 16, We = 16, Ws = "fabric-editor-angle-indicator";
|
|
1104
|
-
class
|
|
1104
|
+
class be {
|
|
1105
1105
|
constructor({ editor: t }) {
|
|
1106
1106
|
this.isActive = !1, this.currentAngle = 0, this.editor = t, this.canvas = t.canvas, this.options = t.options, this._createDOM(), this._bindEvents();
|
|
1107
1107
|
}
|
|
@@ -1129,7 +1129,7 @@ class Me {
|
|
|
1129
1129
|
return;
|
|
1130
1130
|
}
|
|
1131
1131
|
const s = e.angle || 0;
|
|
1132
|
-
this.currentAngle =
|
|
1132
|
+
this.currentAngle = be._normalizeAngle(s), this.el.textContent = `${this.currentAngle}°`, this._positionIndicator(t.e), this.isActive || this._showIndicator();
|
|
1133
1133
|
}
|
|
1134
1134
|
/**
|
|
1135
1135
|
* Обработчик отпускания кнопки мыши
|
|
@@ -1193,7 +1193,7 @@ class Me {
|
|
|
1193
1193
|
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;
|
|
1194
1194
|
}
|
|
1195
1195
|
}
|
|
1196
|
-
const
|
|
1196
|
+
const es = [
|
|
1197
1197
|
"selectable",
|
|
1198
1198
|
"evented",
|
|
1199
1199
|
"id",
|
|
@@ -1218,7 +1218,6 @@ const ss = [
|
|
|
1218
1218
|
"underline",
|
|
1219
1219
|
"fontStyle",
|
|
1220
1220
|
"fontWeight",
|
|
1221
|
-
"backgroundColor",
|
|
1222
1221
|
"backgroundOpacity",
|
|
1223
1222
|
"paddingTop",
|
|
1224
1223
|
"paddingRight",
|
|
@@ -1229,25 +1228,24 @@ const ss = [
|
|
|
1229
1228
|
"radiusBottomRight",
|
|
1230
1229
|
"radiusBottomLeft"
|
|
1231
1230
|
];
|
|
1232
|
-
class
|
|
1231
|
+
class Ys {
|
|
1233
1232
|
constructor({ editor: t }) {
|
|
1234
|
-
this.editor = t, this.canvas = t.canvas, this._historySuspendCount = 0, this.baseState = null, this.patches = [], this.currentIndex = 0, this.maxHistoryLength = t.options.maxHistoryLength, this.totalChangesCount = 0, this.baseStateChangesCount = 0, this._createDiffPatcher();
|
|
1233
|
+
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();
|
|
1235
1234
|
}
|
|
1236
1235
|
/** Проверка, нужно ли пропускать сохранение истории */
|
|
1237
1236
|
get skipHistory() {
|
|
1238
|
-
return this._historySuspendCount > 0;
|
|
1237
|
+
return this._historySuspendCount > 0 || this._isSavingState;
|
|
1239
1238
|
}
|
|
1240
1239
|
get lastPatch() {
|
|
1241
1240
|
return this.patches[this.currentIndex - 1] || null;
|
|
1242
1241
|
}
|
|
1243
1242
|
_createDiffPatcher() {
|
|
1244
|
-
this.diffPatcher =
|
|
1243
|
+
this.diffPatcher = bs({
|
|
1245
1244
|
objectHash(t) {
|
|
1246
|
-
const e = t, s = t, o = s.styles ? JSON.stringify(s.styles) : "";
|
|
1245
|
+
const e = t, s = t, o = s.styles ? JSON.stringify(s.styles) : "", n = e.customData ? JSON.stringify(e.customData) : "";
|
|
1247
1246
|
return [
|
|
1248
1247
|
e.id,
|
|
1249
1248
|
e.backgroundId,
|
|
1250
|
-
e.customData,
|
|
1251
1249
|
e.format,
|
|
1252
1250
|
e.locked,
|
|
1253
1251
|
e.left,
|
|
@@ -1260,6 +1258,7 @@ class Jt {
|
|
|
1260
1258
|
e.scaleY,
|
|
1261
1259
|
e.angle,
|
|
1262
1260
|
e.opacity,
|
|
1261
|
+
n,
|
|
1263
1262
|
s.text,
|
|
1264
1263
|
s.textCaseRaw,
|
|
1265
1264
|
s.uppercase,
|
|
@@ -1291,7 +1290,7 @@ class Jt {
|
|
|
1291
1290
|
includeValueOnMove: !1
|
|
1292
1291
|
},
|
|
1293
1292
|
textDiff: {
|
|
1294
|
-
diffMatchPatch:
|
|
1293
|
+
diffMatchPatch: Ms,
|
|
1295
1294
|
minLength: 60
|
|
1296
1295
|
}
|
|
1297
1296
|
});
|
|
@@ -1330,46 +1329,26 @@ class Jt {
|
|
|
1330
1329
|
* Сохраняем текущее состояние в виде диффа от последнего сохранённого полного состояния.
|
|
1331
1330
|
*/
|
|
1332
1331
|
saveState() {
|
|
1333
|
-
if (console.log("saveState"), this.skipHistory)
|
|
1334
|
-
|
|
1335
|
-
const t = this._withTemporaryUnlock(
|
|
1336
|
-
() => this.canvas.toDatalessObject([...ss])
|
|
1337
|
-
);
|
|
1338
|
-
if (console.timeEnd("saveState"), !this.baseState) {
|
|
1339
|
-
this.baseState = t, this.patches = [], this.currentIndex = 0, console.log("Базовое состояние сохранено.");
|
|
1340
|
-
return;
|
|
1341
|
-
}
|
|
1342
|
-
const e = this.getFullState(), s = this.diffPatcher.diff(e, t);
|
|
1343
|
-
if (!s) {
|
|
1344
|
-
console.log("Нет изменений для сохранения.");
|
|
1345
|
-
return;
|
|
1346
|
-
}
|
|
1347
|
-
console.log("baseState", this.baseState), this.currentIndex < this.patches.length && this.patches.splice(this.currentIndex), console.log("diff", s), this.totalChangesCount += 1, this.patches.push({ id: G(), diff: s }), this.currentIndex += 1, this.patches.length > this.maxHistoryLength && (this.baseState = this.diffPatcher.patch(this.baseState, this.patches[0].diff), this.patches.shift(), this.currentIndex -= 1, this.baseStateChangesCount += 1), console.log("Состояние сохранено. Текущий индекс истории:", this.currentIndex);
|
|
1348
|
-
}
|
|
1349
|
-
/**
|
|
1350
|
-
* Сериализует customData объектов в строку. Это необходимо чтобы при вызове loadFromJSON fabricjs не пытался обрабатывать свойства внутри customData, как свойства FabricObject, если их названия совпадают с зарезервированными.
|
|
1351
|
-
*
|
|
1352
|
-
* @param state - состояние канваса для сериализации
|
|
1353
|
-
*/
|
|
1354
|
-
static _serializeCustomData(t) {
|
|
1355
|
-
t.objects && t.objects.forEach((e) => {
|
|
1356
|
-
e.customData && typeof e.customData == "object" && (e._serializedCustomData = JSON.stringify(e.customData), delete e.customData);
|
|
1357
|
-
});
|
|
1358
|
-
}
|
|
1359
|
-
/**
|
|
1360
|
-
* Десериализует customData из строки обратно в объект
|
|
1361
|
-
* @param serializedObj - сериализованный объект из JSON
|
|
1362
|
-
* @param fabricObject - объект Fabric, в который нужно записать customData
|
|
1363
|
-
*/
|
|
1364
|
-
static _deserializeCustomData(t, e) {
|
|
1365
|
-
if (!(!t._serializedCustomData || !e))
|
|
1332
|
+
if (console.log("saveState"), !this.skipHistory) {
|
|
1333
|
+
this._isSavingState = !0, console.time("saveState");
|
|
1366
1334
|
try {
|
|
1367
|
-
|
|
1368
|
-
|
|
1335
|
+
const t = this._withTemporaryUnlock(
|
|
1336
|
+
() => this.canvas.toDatalessObject([...es])
|
|
1369
1337
|
);
|
|
1370
|
-
|
|
1371
|
-
|
|
1338
|
+
if (console.timeEnd("saveState"), !this.baseState) {
|
|
1339
|
+
this.baseState = t, this.patches = [], this.currentIndex = 0, console.log("Базовое состояние сохранено.");
|
|
1340
|
+
return;
|
|
1341
|
+
}
|
|
1342
|
+
const e = this.getFullState(), s = this.diffPatcher.diff(e, t);
|
|
1343
|
+
if (!s) {
|
|
1344
|
+
console.log("Нет изменений для сохранения.");
|
|
1345
|
+
return;
|
|
1346
|
+
}
|
|
1347
|
+
console.log("baseState", this.baseState), this.currentIndex < this.patches.length && this.patches.splice(this.currentIndex), console.log("diff", s), this.totalChangesCount += 1, this.patches.push({ id: V(), diff: s }), this.currentIndex += 1, this.patches.length > this.maxHistoryLength && (this.baseState = this.diffPatcher.patch(this.baseState, this.patches[0].diff), this.patches.shift(), this.currentIndex -= 1, this.baseStateChangesCount += 1), console.log("Состояние сохранено. Текущий индекс истории:", this.currentIndex);
|
|
1348
|
+
} finally {
|
|
1349
|
+
this._isSavingState = !1;
|
|
1372
1350
|
}
|
|
1351
|
+
}
|
|
1373
1352
|
}
|
|
1374
1353
|
/**
|
|
1375
1354
|
* Функция загрузки состояния в канвас.
|
|
@@ -1377,13 +1356,11 @@ class Jt {
|
|
|
1377
1356
|
* @fires editor:history-state-loaded
|
|
1378
1357
|
*/
|
|
1379
1358
|
loadStateFromFullState(t) {
|
|
1380
|
-
return
|
|
1359
|
+
return k(this, null, function* () {
|
|
1381
1360
|
if (!t) return;
|
|
1382
1361
|
console.log("loadStateFromFullState fullState", t);
|
|
1383
1362
|
const { canvas: e, canvasManager: s, interactionBlocker: o, backgroundManager: n } = this.editor, { width: i, height: a } = e;
|
|
1384
|
-
o.overlayMask = null,
|
|
1385
|
-
Jt._deserializeCustomData(l, u);
|
|
1386
|
-
});
|
|
1363
|
+
o.overlayMask = null, yield e.loadFromJSON(t);
|
|
1387
1364
|
const r = e.getObjects().find((l) => l.id === "montage-area");
|
|
1388
1365
|
r && (this.editor.montageArea = r, (i !== e.getWidth() || a !== e.getHeight()) && s.updateCanvas());
|
|
1389
1366
|
const c = e.getObjects().find((l) => l.id === "overlay-mask");
|
|
@@ -1404,9 +1381,9 @@ class Jt {
|
|
|
1404
1381
|
* @fires editor:undo
|
|
1405
1382
|
*/
|
|
1406
1383
|
undo() {
|
|
1407
|
-
return
|
|
1384
|
+
return k(this, null, function* () {
|
|
1408
1385
|
if (!this.skipHistory) {
|
|
1409
|
-
if (this.currentIndex <= 0) {
|
|
1386
|
+
if (this.saveState(), this.currentIndex <= 0) {
|
|
1410
1387
|
console.log("Нет предыдущих состояний для отмены.");
|
|
1411
1388
|
return;
|
|
1412
1389
|
}
|
|
@@ -1441,9 +1418,9 @@ class Jt {
|
|
|
1441
1418
|
* @fires editor:redo
|
|
1442
1419
|
*/
|
|
1443
1420
|
redo() {
|
|
1444
|
-
return
|
|
1421
|
+
return k(this, null, function* () {
|
|
1445
1422
|
if (!this.skipHistory) {
|
|
1446
|
-
if (this.currentIndex >= this.patches.length) {
|
|
1423
|
+
if (this.saveState(), this.currentIndex >= this.patches.length) {
|
|
1447
1424
|
console.log("Нет состояний для повтора.");
|
|
1448
1425
|
return;
|
|
1449
1426
|
}
|
|
@@ -1496,7 +1473,7 @@ class Jt {
|
|
|
1496
1473
|
}
|
|
1497
1474
|
}
|
|
1498
1475
|
}
|
|
1499
|
-
const Hs = 0.1, Zs = 2,
|
|
1476
|
+
const Hs = 0.1, Zs = 2, Ye = 0.1, Gs = 90, Rt = 16, _t = 16, Mt = 4096, wt = 4096, He = "application/image-editor:", Kt = [
|
|
1500
1477
|
"format",
|
|
1501
1478
|
"uppercase",
|
|
1502
1479
|
"textCaseRaw",
|
|
@@ -1528,114 +1505,118 @@ class ct {
|
|
|
1528
1505
|
* @returns возвращает Promise с объектом изображения или null в случае ошибки
|
|
1529
1506
|
*/
|
|
1530
1507
|
importImage(t) {
|
|
1531
|
-
return
|
|
1508
|
+
return k(this, null, function* () {
|
|
1532
1509
|
const {
|
|
1533
1510
|
source: e,
|
|
1534
1511
|
scale: s = `image-${this.options.scaleType}`,
|
|
1535
1512
|
withoutSave: o = !1,
|
|
1536
1513
|
fromClipboard: n = !1,
|
|
1537
1514
|
isBackground: i = !1,
|
|
1538
|
-
withoutSelection: a = !1
|
|
1515
|
+
withoutSelection: a = !1,
|
|
1516
|
+
withoutAdding: r = !1
|
|
1539
1517
|
} = t;
|
|
1540
1518
|
if (!e) return null;
|
|
1541
|
-
const { canvas:
|
|
1542
|
-
if (!this.isAllowedContentType(
|
|
1543
|
-
const
|
|
1544
|
-
return
|
|
1519
|
+
const { canvas: c, montageArea: d, transformManager: l, historyManager: u, errorManager: g } = this.editor, f = yield this.getContentType(e), p = ct.getFormatFromContentType(f), { acceptContentTypes: m, acceptFormats: v } = this;
|
|
1520
|
+
if (!this.isAllowedContentType(f)) {
|
|
1521
|
+
const M = `Неверный contentType для изображения: ${f}. Ожидается один из: ${this.acceptContentTypes.join(", ")}.`;
|
|
1522
|
+
return g.emitError({
|
|
1545
1523
|
origin: "ImageManager",
|
|
1546
1524
|
method: "importImage",
|
|
1547
1525
|
code: "INVALID_CONTENT_TYPE",
|
|
1548
|
-
message:
|
|
1526
|
+
message: M,
|
|
1549
1527
|
data: {
|
|
1550
1528
|
source: e,
|
|
1551
|
-
format:
|
|
1552
|
-
contentType:
|
|
1553
|
-
acceptContentTypes:
|
|
1554
|
-
acceptFormats:
|
|
1529
|
+
format: p,
|
|
1530
|
+
contentType: f,
|
|
1531
|
+
acceptContentTypes: m,
|
|
1532
|
+
acceptFormats: v,
|
|
1555
1533
|
fromClipboard: n,
|
|
1556
1534
|
isBackground: i,
|
|
1557
|
-
withoutSelection: a
|
|
1535
|
+
withoutSelection: a,
|
|
1536
|
+
withoutAdding: r
|
|
1558
1537
|
}
|
|
1559
1538
|
}), null;
|
|
1560
1539
|
}
|
|
1561
|
-
|
|
1540
|
+
u.suspendHistory();
|
|
1562
1541
|
try {
|
|
1563
|
-
let
|
|
1542
|
+
let M, S;
|
|
1564
1543
|
if (e instanceof File)
|
|
1565
|
-
|
|
1544
|
+
M = URL.createObjectURL(e);
|
|
1566
1545
|
else if (typeof e == "string") {
|
|
1567
|
-
const
|
|
1568
|
-
|
|
1546
|
+
const A = yield (yield fetch(e, { mode: "cors" })).blob();
|
|
1547
|
+
M = URL.createObjectURL(A);
|
|
1569
1548
|
} else
|
|
1570
|
-
return
|
|
1549
|
+
return g.emitError({
|
|
1571
1550
|
origin: "ImageManager",
|
|
1572
1551
|
method: "importImage",
|
|
1573
1552
|
code: "INVALID_SOURCE_TYPE",
|
|
1574
1553
|
message: "Неверный тип источника изображения. Ожидается URL или объект File.",
|
|
1575
1554
|
data: {
|
|
1576
1555
|
source: e,
|
|
1577
|
-
format:
|
|
1578
|
-
contentType:
|
|
1579
|
-
acceptContentTypes:
|
|
1580
|
-
acceptFormats:
|
|
1556
|
+
format: p,
|
|
1557
|
+
contentType: f,
|
|
1558
|
+
acceptContentTypes: m,
|
|
1559
|
+
acceptFormats: v,
|
|
1581
1560
|
fromClipboard: n,
|
|
1582
1561
|
isBackground: i,
|
|
1583
|
-
withoutSelection: a
|
|
1562
|
+
withoutSelection: a,
|
|
1563
|
+
withoutAdding: r
|
|
1584
1564
|
}
|
|
1585
1565
|
}), null;
|
|
1586
|
-
if (this._createdBlobUrls.push(
|
|
1587
|
-
const
|
|
1588
|
-
|
|
1566
|
+
if (this._createdBlobUrls.push(M), p === "svg") {
|
|
1567
|
+
const j = yield hs(M);
|
|
1568
|
+
S = dt.groupSVGElements(j.objects, j.options);
|
|
1589
1569
|
} else
|
|
1590
|
-
|
|
1591
|
-
const { width:
|
|
1592
|
-
if (
|
|
1593
|
-
const
|
|
1594
|
-
let
|
|
1595
|
-
if (
|
|
1596
|
-
const
|
|
1597
|
-
this._createdBlobUrls.push(
|
|
1598
|
-
} else if (
|
|
1599
|
-
const
|
|
1600
|
-
this._createdBlobUrls.push(
|
|
1570
|
+
S = yield zt.fromURL(M, { crossOrigin: "anonymous" });
|
|
1571
|
+
const { width: y, height: b } = S;
|
|
1572
|
+
if (S instanceof zt) {
|
|
1573
|
+
const j = S.getElement();
|
|
1574
|
+
let A = "";
|
|
1575
|
+
if (j instanceof HTMLImageElement ? A = j.src : j instanceof HTMLCanvasElement && (A = j.toDataURL()), b > wt || y > Mt) {
|
|
1576
|
+
const C = yield this.resizeImageToBoundaries(A, "max"), w = URL.createObjectURL(C);
|
|
1577
|
+
this._createdBlobUrls.push(w), S = yield zt.fromURL(w, { crossOrigin: "anonymous" });
|
|
1578
|
+
} else if (b < _t || y < Rt) {
|
|
1579
|
+
const C = yield this.resizeImageToBoundaries(A, "min"), w = URL.createObjectURL(C);
|
|
1580
|
+
this._createdBlobUrls.push(w), S = yield zt.fromURL(w, { crossOrigin: "anonymous" });
|
|
1601
1581
|
}
|
|
1602
1582
|
}
|
|
1603
|
-
if (
|
|
1604
|
-
this.editor.canvasManager.scaleMontageAreaToImage({ object:
|
|
1583
|
+
if (S.set("id", `${S.type}-${V()}`), S.set("format", p), s === "scale-montage")
|
|
1584
|
+
this.editor.canvasManager.scaleMontageAreaToImage({ object: S, withoutSave: !0 });
|
|
1605
1585
|
else {
|
|
1606
|
-
const { width:
|
|
1607
|
-
s === "image-contain" &&
|
|
1586
|
+
const { width: j, height: A } = d, C = this.calculateScaleFactor({ imageObject: S, scaleType: s });
|
|
1587
|
+
s === "image-contain" && C < 1 ? l.fitObject({ object: S, type: "contain", withoutSave: !0 }) : s === "image-cover" && (y > j || b > A) && l.fitObject({ object: S, type: "cover", withoutSave: !0 });
|
|
1608
1588
|
}
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
contentType: g,
|
|
1589
|
+
const I = {
|
|
1590
|
+
image: S,
|
|
1591
|
+
format: p,
|
|
1592
|
+
contentType: f,
|
|
1614
1593
|
scale: s,
|
|
1615
1594
|
withoutSave: o,
|
|
1616
1595
|
source: e,
|
|
1617
1596
|
fromClipboard: n,
|
|
1618
1597
|
isBackground: i,
|
|
1619
|
-
withoutSelection: a
|
|
1598
|
+
withoutSelection: a,
|
|
1599
|
+
withoutAdding: r
|
|
1620
1600
|
};
|
|
1621
|
-
return r.fire("editor:image-imported",
|
|
1622
|
-
} catch (
|
|
1623
|
-
return
|
|
1601
|
+
return r ? (u.resumeHistory(), c.fire("editor:image-imported", I), I) : (c.add(S), c.centerObject(S), a || c.setActiveObject(S), c.renderAll(), u.resumeHistory(), o || u.saveState(), c.fire("editor:image-imported", I), I);
|
|
1602
|
+
} catch (M) {
|
|
1603
|
+
return g.emitError({
|
|
1624
1604
|
origin: "ImageManager",
|
|
1625
1605
|
method: "importImage",
|
|
1626
1606
|
code: "IMPORT_FAILED",
|
|
1627
|
-
message: `Ошибка импорта изображения: ${
|
|
1607
|
+
message: `Ошибка импорта изображения: ${M.message}`,
|
|
1628
1608
|
data: {
|
|
1629
1609
|
source: e,
|
|
1630
|
-
format:
|
|
1631
|
-
contentType:
|
|
1610
|
+
format: p,
|
|
1611
|
+
contentType: f,
|
|
1632
1612
|
scale: s,
|
|
1633
1613
|
withoutSave: o,
|
|
1634
1614
|
fromClipboard: n,
|
|
1635
1615
|
isBackground: i,
|
|
1636
|
-
withoutSelection: a
|
|
1616
|
+
withoutSelection: a,
|
|
1617
|
+
withoutAdding: r
|
|
1637
1618
|
}
|
|
1638
|
-
}),
|
|
1619
|
+
}), u.resumeHistory(), null;
|
|
1639
1620
|
}
|
|
1640
1621
|
});
|
|
1641
1622
|
}
|
|
@@ -1648,7 +1629,7 @@ class ct {
|
|
|
1648
1629
|
* @returns возвращает Promise с Blob-объектом уменьшенного изображения
|
|
1649
1630
|
*/
|
|
1650
1631
|
resizeImageToBoundaries(t, e = "max") {
|
|
1651
|
-
return
|
|
1632
|
+
return k(this, null, function* () {
|
|
1652
1633
|
let s = `Размер изображения больше максимального размера канваса, поэтому оно будет уменьшено до максимальных размеров c сохранением пропорций: ${Mt}x${wt}`;
|
|
1653
1634
|
e === "min" && (s = `Размер изображения меньше минимального размера канваса, поэтому оно будет увеличено до минимальных размеров c сохранением пропорций: ${Rt}x${_t}`);
|
|
1654
1635
|
const o = {
|
|
@@ -1680,7 +1661,7 @@ class ct {
|
|
|
1680
1661
|
* @fires editor:canvas-exported
|
|
1681
1662
|
*/
|
|
1682
1663
|
exportCanvasAsImageFile() {
|
|
1683
|
-
return
|
|
1664
|
+
return k(this, arguments, function* (t = {}) {
|
|
1684
1665
|
const {
|
|
1685
1666
|
fileName: e = "image.png",
|
|
1686
1667
|
contentType: s = "image/png",
|
|
@@ -1692,14 +1673,14 @@ class ct {
|
|
|
1692
1673
|
a.setCoords();
|
|
1693
1674
|
const { left: g, top: f, width: p, height: m } = a.getBoundingRect(), v = yield i.clone(["id", "format", "locked"]);
|
|
1694
1675
|
v.enableRetinaScaling = !1, ["image/jpg", "image/jpeg"].includes(l) && (v.backgroundColor = "#ffffff");
|
|
1695
|
-
const
|
|
1696
|
-
if (
|
|
1676
|
+
const M = v.getObjects().find((w) => w.id === a.id);
|
|
1677
|
+
if (M && (M.visible = !1), c != null && c.isBlocked) {
|
|
1697
1678
|
const w = v.getObjects().find((T) => T.id === c.overlayMask.id);
|
|
1698
1679
|
w && (w.visible = !1);
|
|
1699
1680
|
}
|
|
1700
1681
|
v.viewportTransform = [1, 0, 0, 1, -g, -f], v.setDimensions({ width: p, height: m }, { backstoreOnly: !0 }), v.renderAll();
|
|
1701
|
-
const
|
|
1702
|
-
if (u === "svg" &&
|
|
1682
|
+
const S = v.getObjects().filter((w) => w.format).every((w) => w.format === "svg");
|
|
1683
|
+
if (u === "svg" && S) {
|
|
1703
1684
|
const w = v.toSVG();
|
|
1704
1685
|
v.dispose();
|
|
1705
1686
|
const E = {
|
|
@@ -1728,28 +1709,28 @@ class ct {
|
|
|
1728
1709
|
};
|
|
1729
1710
|
return i.fire("editor:canvas-exported", w), w;
|
|
1730
1711
|
}
|
|
1731
|
-
const
|
|
1712
|
+
const b = yield createImageBitmap(y), I = yield r.post(
|
|
1732
1713
|
"toDataURL",
|
|
1733
|
-
{ format: u, quality: 1, bitmap:
|
|
1734
|
-
[
|
|
1714
|
+
{ format: u, quality: 1, bitmap: b },
|
|
1715
|
+
[b]
|
|
1735
1716
|
);
|
|
1736
1717
|
if (d) {
|
|
1737
|
-
const T = p * 0.264583, E = m * 0.264583,
|
|
1718
|
+
const T = p * 0.264583, E = m * 0.264583, P = (yield this.editor.moduleLoader.loadModule("jspdf")).jsPDF, x = new P({
|
|
1738
1719
|
orientation: T > E ? "landscape" : "portrait",
|
|
1739
1720
|
unit: "mm",
|
|
1740
1721
|
format: [T, E]
|
|
1741
1722
|
});
|
|
1742
|
-
if (
|
|
1743
|
-
const
|
|
1744
|
-
image:
|
|
1723
|
+
if (x.addImage(String(I), "JPG", 0, 0, T, E), o) {
|
|
1724
|
+
const W = {
|
|
1725
|
+
image: x.output("datauristring"),
|
|
1745
1726
|
format: "pdf",
|
|
1746
1727
|
contentType: "application/pdf",
|
|
1747
1728
|
fileName: e
|
|
1748
1729
|
};
|
|
1749
|
-
return i.fire("editor:canvas-exported",
|
|
1730
|
+
return i.fire("editor:canvas-exported", W), W;
|
|
1750
1731
|
}
|
|
1751
|
-
const
|
|
1752
|
-
image: new File([
|
|
1732
|
+
const N = x.output("blob"), D = {
|
|
1733
|
+
image: new File([N], e, { type: "application/pdf" }),
|
|
1753
1734
|
format: "pdf",
|
|
1754
1735
|
contentType: "application/pdf",
|
|
1755
1736
|
fileName: e
|
|
@@ -1758,14 +1739,14 @@ class ct {
|
|
|
1758
1739
|
}
|
|
1759
1740
|
if (o) {
|
|
1760
1741
|
const w = {
|
|
1761
|
-
image:
|
|
1742
|
+
image: I,
|
|
1762
1743
|
format: u,
|
|
1763
1744
|
contentType: l,
|
|
1764
1745
|
fileName: e
|
|
1765
1746
|
};
|
|
1766
1747
|
return i.fire("editor:canvas-exported", w), w;
|
|
1767
1748
|
}
|
|
1768
|
-
const j = u === "svg" && !
|
|
1749
|
+
const j = u === "svg" && !S ? e.replace(/\.[^/.]+$/, ".png") : e, C = {
|
|
1769
1750
|
image: new File([y], j, { type: l }),
|
|
1770
1751
|
format: u,
|
|
1771
1752
|
contentType: l,
|
|
@@ -1795,7 +1776,7 @@ class ct {
|
|
|
1795
1776
|
* @fires editor:object-exported
|
|
1796
1777
|
*/
|
|
1797
1778
|
exportObjectAsImageFile() {
|
|
1798
|
-
return
|
|
1779
|
+
return k(this, arguments, function* (t = {}) {
|
|
1799
1780
|
const {
|
|
1800
1781
|
object: e,
|
|
1801
1782
|
fileName: s = "image.png",
|
|
@@ -1908,7 +1889,7 @@ class ct {
|
|
|
1908
1889
|
* @public
|
|
1909
1890
|
*/
|
|
1910
1891
|
getContentType(t) {
|
|
1911
|
-
return
|
|
1892
|
+
return k(this, null, function* () {
|
|
1912
1893
|
return typeof t == "string" ? this.getContentTypeFromUrl(t) : t.type || "application/octet-stream";
|
|
1913
1894
|
});
|
|
1914
1895
|
}
|
|
@@ -1919,7 +1900,7 @@ class ct {
|
|
|
1919
1900
|
* @public
|
|
1920
1901
|
*/
|
|
1921
1902
|
getContentTypeFromUrl(t) {
|
|
1922
|
-
return
|
|
1903
|
+
return k(this, null, function* () {
|
|
1923
1904
|
if (t.startsWith("data:")) {
|
|
1924
1905
|
const e = t.match(/^data:([^;]+)/);
|
|
1925
1906
|
return e ? e[1] : "application/octet-stream";
|
|
@@ -1998,7 +1979,7 @@ class ct {
|
|
|
1998
1979
|
return e ? e[1] : "";
|
|
1999
1980
|
}
|
|
2000
1981
|
}
|
|
2001
|
-
const Tt = (h, t, e) => Math.max(Math.min(h, e), t),
|
|
1982
|
+
const Tt = (h, t, e) => Math.max(Math.min(h, e), t), Ze = (h, t) => h * t, Xs = (h, t) => new et(h / 2, t / 2);
|
|
2002
1983
|
function Ks(h) {
|
|
2003
1984
|
return ((h == null ? void 0 : h.type) === "image" || (h == null ? void 0 : h.format) === "svg") && typeof (h == null ? void 0 : h.width) == "number" && typeof (h == null ? void 0 : h.height) == "number";
|
|
2004
1985
|
}
|
|
@@ -2035,7 +2016,7 @@ class Qs {
|
|
|
2035
2016
|
options: { canvasBackstoreWidth: a }
|
|
2036
2017
|
} = this.editor, { width: r, height: c } = i, d = Tt(Number(t), Rt, Mt);
|
|
2037
2018
|
if (!a || a === "auto" || o ? this.adaptCanvasToContainer() : a ? this.setCanvasBackstoreWidth(Number(a)) : this.setCanvasBackstoreWidth(d), i.set({ width: d }), (f = n.clipPath) == null || f.set({ width: d }), e) {
|
|
2038
|
-
const p = d / r, m =
|
|
2019
|
+
const p = d / r, m = Ze(c, p);
|
|
2039
2020
|
this.setResolutionHeight(m);
|
|
2040
2021
|
return;
|
|
2041
2022
|
}
|
|
@@ -2065,7 +2046,7 @@ class Qs {
|
|
|
2065
2046
|
options: { canvasBackstoreHeight: a }
|
|
2066
2047
|
} = this.editor, { width: r, height: c } = i, d = Tt(Number(t), _t, wt);
|
|
2067
2048
|
if (!a || a === "auto" || o ? this.adaptCanvasToContainer() : a ? this.setCanvasBackstoreHeight(Number(a)) : this.setCanvasBackstoreHeight(d), i.set({ height: d }), (f = n.clipPath) == null || f.set({ height: d }), e) {
|
|
2068
|
-
const p = d / c, m =
|
|
2049
|
+
const p = d / c, m = Ze(r, p);
|
|
2069
2050
|
this.setResolutionWidth(m);
|
|
2070
2051
|
return;
|
|
2071
2052
|
}
|
|
@@ -2168,7 +2149,7 @@ class Qs {
|
|
|
2168
2149
|
if (d.length === 1)
|
|
2169
2150
|
t.setActiveObject(d[0]);
|
|
2170
2151
|
else {
|
|
2171
|
-
const l = new
|
|
2152
|
+
const l = new U(d, {
|
|
2172
2153
|
canvas: t
|
|
2173
2154
|
});
|
|
2174
2155
|
t.setActiveObject(l);
|
|
@@ -2341,8 +2322,8 @@ class Qs {
|
|
|
2341
2322
|
const {
|
|
2342
2323
|
width: f,
|
|
2343
2324
|
height: p
|
|
2344
|
-
} = n, m = d / f, v = l / p,
|
|
2345
|
-
u = f *
|
|
2325
|
+
} = n, m = d / f, v = l / p, M = Math.max(m, v);
|
|
2326
|
+
u = f * M, g = p * M;
|
|
2346
2327
|
}
|
|
2347
2328
|
this.setResolutionWidth(u, { withoutSave: !0 }), this.setResolutionHeight(g, { withoutSave: !0 }), this.editor.backgroundManager.backgroundObject && this.editor.backgroundManager.refresh(), (d > a || l > r) && this.editor.zoomManager.calculateAndApplyDefaultZoom(), i.resetObject({ object: c, withoutSave: !0 }), o.centerObject(c), o.renderAll(), s || this.editor.historyManager.saveState(), o.fire("editor:montage-area-scaled-to-image", {
|
|
2348
2329
|
object: c,
|
|
@@ -2455,7 +2436,7 @@ class qs {
|
|
|
2455
2436
|
withoutSave: s
|
|
2456
2437
|
} = {}) {
|
|
2457
2438
|
const { canvas: o, historyManager: n } = this.editor, i = t || o.getActiveObject();
|
|
2458
|
-
i && (i instanceof
|
|
2439
|
+
i && (i instanceof U ? i.getObjects().forEach((a) => {
|
|
2459
2440
|
a.set("opacity", e);
|
|
2460
2441
|
}) : i.set("opacity", e), o.renderAll(), s || n.saveState(), o.fire("editor:object-opacity-changed", {
|
|
2461
2442
|
object: i,
|
|
@@ -2482,12 +2463,12 @@ class qs {
|
|
|
2482
2463
|
} = {}) {
|
|
2483
2464
|
const { canvas: n, historyManager: i } = this.editor, a = t || n.getActiveObject();
|
|
2484
2465
|
if (a) {
|
|
2485
|
-
if (a instanceof
|
|
2466
|
+
if (a instanceof U && !o) {
|
|
2486
2467
|
const r = a.getObjects();
|
|
2487
2468
|
n.discardActiveObject(), r.forEach((d) => {
|
|
2488
2469
|
this._fitSingleObject(d, e);
|
|
2489
2470
|
});
|
|
2490
|
-
const c = new
|
|
2471
|
+
const c = new U(r, { canvas: n });
|
|
2491
2472
|
n.setActiveObject(c);
|
|
2492
2473
|
} else
|
|
2493
2474
|
this._fitSingleObject(a, e);
|
|
@@ -2506,11 +2487,11 @@ class qs {
|
|
|
2506
2487
|
* @private
|
|
2507
2488
|
*/
|
|
2508
2489
|
_fitSingleObject(t, e) {
|
|
2509
|
-
const { canvas: s, montageArea: o } = this.editor, { width: n, height: i, scaleX: a = 1, scaleY: r = 1, angle: c = 0 } = t, d = n * Math.abs(a), l = i * Math.abs(r), u = c * Math.PI / 180, g = Math.abs(Math.cos(u)), f = Math.abs(Math.sin(u)), p = d * g + l * f, m = d * f + l * g, v = o.width,
|
|
2510
|
-
let
|
|
2511
|
-
e === "contain" ?
|
|
2512
|
-
scaleX: a *
|
|
2513
|
-
scaleY: r *
|
|
2490
|
+
const { canvas: s, montageArea: o } = this.editor, { width: n, height: i, scaleX: a = 1, scaleY: r = 1, angle: c = 0 } = t, d = n * Math.abs(a), l = i * Math.abs(r), u = c * Math.PI / 180, g = Math.abs(Math.cos(u)), f = Math.abs(Math.sin(u)), p = d * g + l * f, m = d * f + l * g, v = o.width, M = o.height;
|
|
2491
|
+
let S;
|
|
2492
|
+
e === "contain" ? S = Math.min(v / p, M / m) : S = Math.max(v / p, M / m), t.set({
|
|
2493
|
+
scaleX: a * S,
|
|
2494
|
+
scaleY: r * S
|
|
2514
2495
|
}), s.centerObject(t);
|
|
2515
2496
|
}
|
|
2516
2497
|
/**
|
|
@@ -2619,9 +2600,9 @@ class Js {
|
|
|
2619
2600
|
* @private
|
|
2620
2601
|
*/
|
|
2621
2602
|
_calculateEmptySpaceRatio(t) {
|
|
2622
|
-
const { canvas: e, montageArea: s } = this.editor, o = e.viewportTransform, n = e.getWidth(), i = e.getHeight(), a = s.left - s.width / 2, r = s.left + s.width / 2, c = s.top - s.height / 2, d = s.top + s.height / 2, l = -o[4] / t, u = (-o[4] + n) / t, g = -o[5] / t, f = (-o[5] + i) / t, p = l < a, m = u > r, v = g < c,
|
|
2623
|
-
if (!(p || m || v ||
|
|
2624
|
-
const y = Math.max(0, a - l),
|
|
2603
|
+
const { canvas: e, montageArea: s } = this.editor, o = e.viewportTransform, n = e.getWidth(), i = e.getHeight(), a = s.left - s.width / 2, r = s.left + s.width / 2, c = s.top - s.height / 2, d = s.top + s.height / 2, l = -o[4] / t, u = (-o[4] + n) / t, g = -o[5] / t, f = (-o[5] + i) / t, p = l < a, m = u > r, v = g < c, M = f > d;
|
|
2604
|
+
if (!(p || m || v || M)) return 0;
|
|
2605
|
+
const y = Math.max(0, a - l), b = Math.max(0, u - r), I = Math.max(0, c - g), j = Math.max(0, f - d), A = Math.max(y, b), C = Math.max(I, j), w = A / n, T = C / i;
|
|
2625
2606
|
return Math.max(w, T);
|
|
2626
2607
|
}
|
|
2627
2608
|
/**
|
|
@@ -2638,8 +2619,8 @@ class Js {
|
|
|
2638
2619
|
const { canvas: i, montageArea: a } = this.editor, r = i.viewportTransform, c = i.getWidth(), d = i.getHeight(), l = t.x - r[4], u = t.y - r[5], g = Math.abs(o), f = e - s;
|
|
2639
2620
|
if (Math.abs(f) / g <= 0.1)
|
|
2640
2621
|
return { x: l, y: u };
|
|
2641
|
-
const m = c / 2, v = d / 2,
|
|
2642
|
-
return { x: E, y:
|
|
2622
|
+
const m = c / 2, v = d / 2, M = a.left, S = a.top, y = m - M * s, b = v - S * s, I = (y - r[4]) / (e - s), j = (b - r[5]) / (e - s), A = I * g, C = j * g, w = A * n, T = C * n, E = Math.abs(w) > Math.abs(l) ? l : w, P = Math.abs(T) > Math.abs(u) ? u : T;
|
|
2623
|
+
return { x: E, y: P };
|
|
2643
2624
|
}
|
|
2644
2625
|
/**
|
|
2645
2626
|
* Применяет плавное центрирование viewport при приближении к defaultZoom.
|
|
@@ -2651,7 +2632,7 @@ class Js {
|
|
|
2651
2632
|
* @returns true если центрирование было применено
|
|
2652
2633
|
* @private
|
|
2653
2634
|
*/
|
|
2654
|
-
_applyViewportCentering(t, e = !1, s =
|
|
2635
|
+
_applyViewportCentering(t, e = !1, s = Ye) {
|
|
2655
2636
|
const { canvas: o } = this.editor, n = this._getScaledMontageDimensions(t), i = o.getWidth(), a = o.getHeight(), r = n.width > i || n.height > a, c = this._calculateFitZoom(), d = t - c;
|
|
2656
2637
|
if (!(!r || d) && !e)
|
|
2657
2638
|
return !1;
|
|
@@ -2726,10 +2707,10 @@ class Js {
|
|
|
2726
2707
|
* @param options.pointY - Координата Y точки зума
|
|
2727
2708
|
* @fires editor:zoom-changed
|
|
2728
2709
|
*/
|
|
2729
|
-
zoom(t =
|
|
2710
|
+
zoom(t = Ye, e = {}) {
|
|
2730
2711
|
var g, f;
|
|
2731
2712
|
if (!t) return;
|
|
2732
|
-
const { minZoom: s, maxZoom: o } = this, { canvas: n } = this.editor, i = t < 0, a = n.getZoom(), r = n.getCenterPoint(), c = (g = e.pointX) != null ? g : r.x, d = (f = e.pointY) != null ? f : r.y, l = new
|
|
2713
|
+
const { minZoom: s, maxZoom: o } = this, { canvas: n } = this.editor, i = t < 0, a = n.getZoom(), r = n.getCenterPoint(), c = (g = e.pointX) != null ? g : r.x, d = (f = e.pointY) != null ? f : r.y, l = new et(c, d);
|
|
2733
2714
|
this.editor.montageArea.setCoords(), this.editor.canvas.requestRenderAll();
|
|
2734
2715
|
let u = Number((a + Number(t)).toFixed(3));
|
|
2735
2716
|
u > o && (u = o), u < s && (u = s), n.zoomToPoint(l, u), this.editor.panConstraintManager.updateBounds(), this._applyViewportCentering(u, i, t), n.fire("editor:zoom-changed", {
|
|
@@ -2744,7 +2725,7 @@ class Js {
|
|
|
2744
2725
|
* @fires editor:zoom-changed
|
|
2745
2726
|
*/
|
|
2746
2727
|
setZoom(t = this.defaultZoom) {
|
|
2747
|
-
const { minZoom: e, maxZoom: s } = this, { canvas: o } = this.editor, n = new
|
|
2728
|
+
const { minZoom: e, maxZoom: s } = this, { canvas: o } = this.editor, n = new et(o.getCenterPoint());
|
|
2748
2729
|
let i = t;
|
|
2749
2730
|
t > s && (i = s), t < e && (i = e), o.zoomToPoint(n, i), o.fire("editor:zoom-changed", {
|
|
2750
2731
|
currentZoom: o.getZoom(),
|
|
@@ -2757,7 +2738,7 @@ class Js {
|
|
|
2757
2738
|
* @fires editor:zoom-changed
|
|
2758
2739
|
*/
|
|
2759
2740
|
resetZoom() {
|
|
2760
|
-
const { canvas: t } = this.editor, e = new
|
|
2741
|
+
const { canvas: t } = this.editor, e = new et(t.getCenterPoint());
|
|
2761
2742
|
t.zoomToPoint(e, this.defaultZoom), this.editor.canvas.fire("editor:zoom-changed", {
|
|
2762
2743
|
currentZoom: t.getZoom(),
|
|
2763
2744
|
point: e
|
|
@@ -2846,7 +2827,7 @@ class Ot {
|
|
|
2846
2827
|
}
|
|
2847
2828
|
i.set({
|
|
2848
2829
|
fill: t,
|
|
2849
|
-
backgroundId: `background-${
|
|
2830
|
+
backgroundId: `background-${V()}`
|
|
2850
2831
|
}), this.editor.canvas.requestRenderAll();
|
|
2851
2832
|
} else
|
|
2852
2833
|
this._removeCurrentBackground(), this._createColorBackground(t);
|
|
@@ -2883,7 +2864,7 @@ class Ot {
|
|
|
2883
2864
|
}
|
|
2884
2865
|
i.set({
|
|
2885
2866
|
fill: a,
|
|
2886
|
-
backgroundId: `background-${
|
|
2867
|
+
backgroundId: `background-${V()}`
|
|
2887
2868
|
}), this.editor.canvas.requestRenderAll();
|
|
2888
2869
|
} else
|
|
2889
2870
|
this._removeCurrentBackground(), this._createGradientBackground(t);
|
|
@@ -2968,7 +2949,7 @@ class Ot {
|
|
|
2968
2949
|
* @param options.withoutSave - Если true, не сохранять состояние в историю
|
|
2969
2950
|
*/
|
|
2970
2951
|
setImageBackground(o) {
|
|
2971
|
-
return
|
|
2952
|
+
return k(this, arguments, function* ({
|
|
2972
2953
|
imageSource: t,
|
|
2973
2954
|
customData: e = {},
|
|
2974
2955
|
withoutSave: s = !1
|
|
@@ -3034,7 +3015,7 @@ class Ot {
|
|
|
3034
3015
|
hasControls: !1,
|
|
3035
3016
|
id: "background",
|
|
3036
3017
|
backgroundType: "color",
|
|
3037
|
-
backgroundId: `background-${
|
|
3018
|
+
backgroundId: `background-${V()}`
|
|
3038
3019
|
}, { withoutSelection: !0 }), this.refresh();
|
|
3039
3020
|
}
|
|
3040
3021
|
/**
|
|
@@ -3051,7 +3032,7 @@ class Ot {
|
|
|
3051
3032
|
hasControls: !1,
|
|
3052
3033
|
id: "background",
|
|
3053
3034
|
backgroundType: "gradient",
|
|
3054
|
-
backgroundId: `background-${
|
|
3035
|
+
backgroundId: `background-${V()}`
|
|
3055
3036
|
}, { withoutSelection: !0 }), this.refresh();
|
|
3056
3037
|
const e = Ot._createFabricGradient(t);
|
|
3057
3038
|
this.backgroundObject.set("fill", e), this.editor.canvas.requestRenderAll();
|
|
@@ -3061,7 +3042,7 @@ class Ot {
|
|
|
3061
3042
|
* @param source - источник изображения (URL или File)
|
|
3062
3043
|
*/
|
|
3063
3044
|
_createImageBackground(t, e) {
|
|
3064
|
-
return
|
|
3045
|
+
return k(this, null, function* () {
|
|
3065
3046
|
var o;
|
|
3066
3047
|
const { image: s } = (o = yield this.editor.imageManager.importImage({
|
|
3067
3048
|
source: t,
|
|
@@ -3079,7 +3060,7 @@ class Ot {
|
|
|
3079
3060
|
hasControls: !1,
|
|
3080
3061
|
id: "background",
|
|
3081
3062
|
backgroundType: "image",
|
|
3082
|
-
backgroundId: `background-${
|
|
3063
|
+
backgroundId: `background-${V()}`,
|
|
3083
3064
|
customData: e
|
|
3084
3065
|
}), this._removeCurrentBackground(), this.backgroundObject = s, this.refresh();
|
|
3085
3066
|
});
|
|
@@ -3114,7 +3095,7 @@ class Ot {
|
|
|
3114
3095
|
{ offset: 1, color: "#ffffff" }
|
|
3115
3096
|
], t.type === "linear") {
|
|
3116
3097
|
const u = t.angle * Math.PI / 180, g = Ot._angleToCoords(u);
|
|
3117
|
-
return new
|
|
3098
|
+
return new ke({
|
|
3118
3099
|
type: "linear",
|
|
3119
3100
|
gradientUnits: "percentage",
|
|
3120
3101
|
coords: g,
|
|
@@ -3133,7 +3114,7 @@ class Ot {
|
|
|
3133
3114
|
r1: 0,
|
|
3134
3115
|
r2: d / 100
|
|
3135
3116
|
};
|
|
3136
|
-
return new
|
|
3117
|
+
return new ke({
|
|
3137
3118
|
type: "radial",
|
|
3138
3119
|
gradientUnits: "percentage",
|
|
3139
3120
|
coords: l,
|
|
@@ -3168,7 +3149,7 @@ class Ot {
|
|
|
3168
3149
|
}) ? !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;
|
|
3169
3150
|
}
|
|
3170
3151
|
}
|
|
3171
|
-
class
|
|
3152
|
+
class te {
|
|
3172
3153
|
constructor({ editor: t }) {
|
|
3173
3154
|
this.editor = t;
|
|
3174
3155
|
}
|
|
@@ -3183,7 +3164,7 @@ class $t {
|
|
|
3183
3164
|
const { canvas: s, historyManager: o } = this.editor;
|
|
3184
3165
|
o.suspendHistory();
|
|
3185
3166
|
const n = t || s.getActiveObject();
|
|
3186
|
-
n && (n instanceof
|
|
3167
|
+
n && (n instanceof U ? n.getObjects().forEach((i) => {
|
|
3187
3168
|
s.bringObjectToFront(i);
|
|
3188
3169
|
}) : s.bringObjectToFront(n), s.renderAll(), o.resumeHistory(), e || o.saveState(), s.fire("editor:object-bring-to-front", {
|
|
3189
3170
|
object: n,
|
|
@@ -3201,7 +3182,7 @@ class $t {
|
|
|
3201
3182
|
const { canvas: s, historyManager: o } = this.editor;
|
|
3202
3183
|
o.suspendHistory();
|
|
3203
3184
|
const n = t || s.getActiveObject();
|
|
3204
|
-
n && (n instanceof
|
|
3185
|
+
n && (n instanceof U ? te._moveSelectionForward(s, n) : s.bringObjectForward(n), s.renderAll(), o.resumeHistory(), e || o.saveState(), s.fire("editor:object-bring-forward", {
|
|
3205
3186
|
object: n,
|
|
3206
3187
|
withoutSave: e
|
|
3207
3188
|
}));
|
|
@@ -3224,7 +3205,7 @@ class $t {
|
|
|
3224
3205
|
n.suspendHistory();
|
|
3225
3206
|
const r = t || s.getActiveObject();
|
|
3226
3207
|
if (r) {
|
|
3227
|
-
if (r instanceof
|
|
3208
|
+
if (r instanceof U) {
|
|
3228
3209
|
const c = r.getObjects();
|
|
3229
3210
|
for (let d = c.length - 1; d >= 0; d -= 1)
|
|
3230
3211
|
s.sendObjectToBack(c[d]);
|
|
@@ -3252,7 +3233,7 @@ class $t {
|
|
|
3252
3233
|
} = this.editor;
|
|
3253
3234
|
n.suspendHistory();
|
|
3254
3235
|
const r = t || s.getActiveObject();
|
|
3255
|
-
r && (r instanceof
|
|
3236
|
+
r && (r instanceof U ? te._moveSelectionBackwards(s, r) : s.sendObjectBackwards(r), a && s.sendObjectToBack(a), s.sendObjectToBack(o), i && s.sendObjectToBack(i), s.renderAll(), n.resumeHistory(), e || n.saveState(), s.fire("editor:object-send-backwards", {
|
|
3256
3237
|
object: r,
|
|
3257
3238
|
withoutSave: e
|
|
3258
3239
|
}));
|
|
@@ -3322,7 +3303,7 @@ class to {
|
|
|
3322
3303
|
*/
|
|
3323
3304
|
addRectangle(d = {}, { withoutSelection: r, withoutAdding: c } = {}) {
|
|
3324
3305
|
var l = d, {
|
|
3325
|
-
id: t = `rect-${
|
|
3306
|
+
id: t = `rect-${V()}`,
|
|
3326
3307
|
left: e,
|
|
3327
3308
|
top: s,
|
|
3328
3309
|
width: o = 100,
|
|
@@ -3336,7 +3317,7 @@ class to {
|
|
|
3336
3317
|
"height",
|
|
3337
3318
|
"fill"
|
|
3338
3319
|
]);
|
|
3339
|
-
const { canvas: u } = this.editor, g = new
|
|
3320
|
+
const { canvas: u } = this.editor, g = new us(B({
|
|
3340
3321
|
id: t,
|
|
3341
3322
|
left: e,
|
|
3342
3323
|
top: s,
|
|
@@ -3364,7 +3345,7 @@ class to {
|
|
|
3364
3345
|
*/
|
|
3365
3346
|
addCircle(c = {}, { withoutSelection: a, withoutAdding: r } = {}) {
|
|
3366
3347
|
var d = c, {
|
|
3367
|
-
id: t = `circle-${
|
|
3348
|
+
id: t = `circle-${V()}`,
|
|
3368
3349
|
left: e,
|
|
3369
3350
|
top: s,
|
|
3370
3351
|
radius: o = 50,
|
|
@@ -3376,7 +3357,7 @@ class to {
|
|
|
3376
3357
|
"radius",
|
|
3377
3358
|
"fill"
|
|
3378
3359
|
]);
|
|
3379
|
-
const { canvas: l } = this.editor, u = new
|
|
3360
|
+
const { canvas: l } = this.editor, u = new gs(B({
|
|
3380
3361
|
id: t,
|
|
3381
3362
|
left: e,
|
|
3382
3363
|
top: s,
|
|
@@ -3404,7 +3385,7 @@ class to {
|
|
|
3404
3385
|
*/
|
|
3405
3386
|
addTriangle(d = {}, { withoutSelection: r, withoutAdding: c } = {}) {
|
|
3406
3387
|
var l = d, {
|
|
3407
|
-
id: t = `triangle-${
|
|
3388
|
+
id: t = `triangle-${V()}`,
|
|
3408
3389
|
left: e,
|
|
3409
3390
|
top: s,
|
|
3410
3391
|
width: o = 100,
|
|
@@ -3418,7 +3399,7 @@ class to {
|
|
|
3418
3399
|
"height",
|
|
3419
3400
|
"fill"
|
|
3420
3401
|
]);
|
|
3421
|
-
const { canvas: u } = this.editor, g = new
|
|
3402
|
+
const { canvas: u } = this.editor, g = new fs(B({
|
|
3422
3403
|
id: t,
|
|
3423
3404
|
left: e,
|
|
3424
3405
|
top: s,
|
|
@@ -3457,10 +3438,10 @@ class eo {
|
|
|
3457
3438
|
* Асинхронное клонирование для внутреннего буфера
|
|
3458
3439
|
*/
|
|
3459
3440
|
_cloneToInternalClipboard(t) {
|
|
3460
|
-
return
|
|
3441
|
+
return k(this, null, function* () {
|
|
3461
3442
|
const { canvas: e, errorManager: s } = this.editor;
|
|
3462
3443
|
try {
|
|
3463
|
-
const o = yield t.clone(
|
|
3444
|
+
const o = yield t.clone(Kt);
|
|
3464
3445
|
this.clipboard = o, e.fire("editor:object-copied", { object: o });
|
|
3465
3446
|
} catch (o) {
|
|
3466
3447
|
s.emitError({
|
|
@@ -3477,7 +3458,7 @@ class eo {
|
|
|
3477
3458
|
* Копирование в системный буфер обмена
|
|
3478
3459
|
*/
|
|
3479
3460
|
_copyToSystemClipboard(t) {
|
|
3480
|
-
return
|
|
3461
|
+
return k(this, null, function* () {
|
|
3481
3462
|
const { errorManager: e } = this.editor;
|
|
3482
3463
|
if (typeof ClipboardItem == "undefined" || !navigator.clipboard)
|
|
3483
3464
|
return e.emitWarning({
|
|
@@ -3487,7 +3468,7 @@ class eo {
|
|
|
3487
3468
|
message: "navigator.clipboard не поддерживается в этом браузере или отсутствует HTTPS-соединение."
|
|
3488
3469
|
}), !1;
|
|
3489
3470
|
try {
|
|
3490
|
-
const s = t.toObject(
|
|
3471
|
+
const s = t.toObject(Kt), o = JSON.stringify(s);
|
|
3491
3472
|
return t.type === "image" ? this._copyImageToClipboard(t, o) : this._copyTextToClipboard(o);
|
|
3492
3473
|
} catch (s) {
|
|
3493
3474
|
return e.emitError({
|
|
@@ -3504,7 +3485,7 @@ class eo {
|
|
|
3504
3485
|
* Копирование изображения в буфер обмена
|
|
3505
3486
|
*/
|
|
3506
3487
|
_copyImageToClipboard(t, e) {
|
|
3507
|
-
return
|
|
3488
|
+
return k(this, null, function* () {
|
|
3508
3489
|
try {
|
|
3509
3490
|
const o = t.toCanvasElement({ enableRetinaScaling: !1 }).toDataURL(), n = o.slice(5).split(";")[0], i = o.split(",")[1], a = atob(i), r = new Uint8Array(a.length);
|
|
3510
3491
|
for (let l = 0; l < a.length; l += 1)
|
|
@@ -3526,9 +3507,9 @@ class eo {
|
|
|
3526
3507
|
* Копирование текста в буфер обмена
|
|
3527
3508
|
*/
|
|
3528
3509
|
_copyTextToClipboard(t) {
|
|
3529
|
-
return
|
|
3510
|
+
return k(this, null, function* () {
|
|
3530
3511
|
try {
|
|
3531
|
-
const e = `${
|
|
3512
|
+
const e = `${He}${t}`;
|
|
3532
3513
|
return yield navigator.clipboard.writeText(e), console.info("Text copied to clipboard successfully"), !0;
|
|
3533
3514
|
} catch (e) {
|
|
3534
3515
|
const { errorManager: s } = this.editor;
|
|
@@ -3548,7 +3529,7 @@ class eo {
|
|
|
3548
3529
|
*/
|
|
3549
3530
|
_addClonedObjectToCanvas(t) {
|
|
3550
3531
|
const { canvas: e, historyManager: s } = this.editor;
|
|
3551
|
-
if (e.discardActiveObject(), t instanceof
|
|
3532
|
+
if (e.discardActiveObject(), t instanceof U) {
|
|
3552
3533
|
s.suspendHistory(), t.canvas = e, t.forEachObject((o) => {
|
|
3553
3534
|
e.add(o);
|
|
3554
3535
|
}), e.setActiveObject(t), e.requestRenderAll(), s.resumeHistory(), s.saveState();
|
|
@@ -3561,7 +3542,7 @@ class eo {
|
|
|
3561
3542
|
* @param source - источник изображения (data URL или URL)
|
|
3562
3543
|
*/
|
|
3563
3544
|
_handleImageImport(t) {
|
|
3564
|
-
return
|
|
3545
|
+
return k(this, null, function* () {
|
|
3565
3546
|
var s;
|
|
3566
3547
|
const { image: e } = (s = yield this.editor.imageManager.importImage({
|
|
3567
3548
|
source: t,
|
|
@@ -3577,18 +3558,18 @@ class eo {
|
|
|
3577
3558
|
* @fires editor:object-pasted
|
|
3578
3559
|
*/
|
|
3579
3560
|
copyPaste(t) {
|
|
3580
|
-
return
|
|
3561
|
+
return k(this, null, function* () {
|
|
3581
3562
|
const { canvas: e } = this.editor, s = t || e.getActiveObject();
|
|
3582
3563
|
if (!s || s.locked) return !1;
|
|
3583
3564
|
try {
|
|
3584
|
-
const o = yield s.clone(
|
|
3585
|
-
return o instanceof
|
|
3565
|
+
const o = yield s.clone(Kt);
|
|
3566
|
+
return o instanceof U && o.forEachObject((n) => {
|
|
3586
3567
|
n.set({
|
|
3587
|
-
id: `${n.type}-${
|
|
3568
|
+
id: `${n.type}-${V()}`,
|
|
3588
3569
|
evented: !0
|
|
3589
3570
|
});
|
|
3590
3571
|
}), o.set({
|
|
3591
|
-
id: `${o.type}-${
|
|
3572
|
+
id: `${o.type}-${V()}`,
|
|
3592
3573
|
left: o.left + 10,
|
|
3593
3574
|
top: o.top + 10,
|
|
3594
3575
|
evented: !0
|
|
@@ -3612,14 +3593,14 @@ class eo {
|
|
|
3612
3593
|
* @param event.clipboardData.items — элементы буфера обмена
|
|
3613
3594
|
*/
|
|
3614
3595
|
handlePasteEvent(e) {
|
|
3615
|
-
return
|
|
3596
|
+
return k(this, arguments, function* ({ clipboardData: t }) {
|
|
3616
3597
|
var r;
|
|
3617
3598
|
if (!((r = t == null ? void 0 : t.items) != null && r.length)) {
|
|
3618
3599
|
this.paste();
|
|
3619
3600
|
return;
|
|
3620
3601
|
}
|
|
3621
3602
|
const s = t.getData("text/plain");
|
|
3622
|
-
if (s && s.startsWith(
|
|
3603
|
+
if (s && s.startsWith(He)) {
|
|
3623
3604
|
this.paste();
|
|
3624
3605
|
return;
|
|
3625
3606
|
}
|
|
@@ -3663,18 +3644,18 @@ class eo {
|
|
|
3663
3644
|
* @fires editor:object-pasted
|
|
3664
3645
|
*/
|
|
3665
3646
|
paste() {
|
|
3666
|
-
return
|
|
3647
|
+
return k(this, null, function* () {
|
|
3667
3648
|
const { canvas: t } = this.editor;
|
|
3668
3649
|
if (!this.clipboard) return !1;
|
|
3669
3650
|
try {
|
|
3670
|
-
const e = yield this.clipboard.clone(
|
|
3671
|
-
return t.discardActiveObject(), e instanceof
|
|
3651
|
+
const e = yield this.clipboard.clone(Kt);
|
|
3652
|
+
return t.discardActiveObject(), e instanceof U && e.forEachObject((s) => {
|
|
3672
3653
|
s.set({
|
|
3673
|
-
id: `${s.type}-${
|
|
3654
|
+
id: `${s.type}-${V()}`,
|
|
3674
3655
|
evented: !0
|
|
3675
3656
|
});
|
|
3676
3657
|
}), e.set({
|
|
3677
|
-
id: `${e.type}-${
|
|
3658
|
+
id: `${e.type}-${V()}`,
|
|
3678
3659
|
left: e.left + 10,
|
|
3679
3660
|
top: e.top + 10,
|
|
3680
3661
|
evented: !0
|
|
@@ -3692,7 +3673,7 @@ class eo {
|
|
|
3692
3673
|
});
|
|
3693
3674
|
}
|
|
3694
3675
|
}
|
|
3695
|
-
class
|
|
3676
|
+
class ee {
|
|
3696
3677
|
constructor({ editor: t }) {
|
|
3697
3678
|
this.editor = t;
|
|
3698
3679
|
}
|
|
@@ -3718,7 +3699,7 @@ class te {
|
|
|
3718
3699
|
editable: !1,
|
|
3719
3700
|
locked: !0
|
|
3720
3701
|
};
|
|
3721
|
-
i.set(a), !e &&
|
|
3702
|
+
i.set(a), !e && ee._isGroupOrSelection(i) && i.getObjects().forEach((c) => {
|
|
3722
3703
|
c.set(a);
|
|
3723
3704
|
}), o.renderAll(), s || n.saveState(), o.fire("editor:object-locked", {
|
|
3724
3705
|
object: i,
|
|
@@ -3747,7 +3728,7 @@ class te {
|
|
|
3747
3728
|
editable: !0,
|
|
3748
3729
|
locked: !1
|
|
3749
3730
|
};
|
|
3750
|
-
n.set(i),
|
|
3731
|
+
n.set(i), ee._isGroupOrSelection(n) && n.getObjects().forEach((a) => {
|
|
3751
3732
|
a.set(i);
|
|
3752
3733
|
}), s.renderAll(), e || o.saveState(), s.fire("editor:object-unlocked", {
|
|
3753
3734
|
object: n,
|
|
@@ -3755,7 +3736,7 @@ class te {
|
|
|
3755
3736
|
});
|
|
3756
3737
|
}
|
|
3757
3738
|
static _isGroupOrSelection(t) {
|
|
3758
|
-
return t instanceof
|
|
3739
|
+
return t instanceof U || t instanceof Et;
|
|
3759
3740
|
}
|
|
3760
3741
|
}
|
|
3761
3742
|
class so {
|
|
@@ -3770,7 +3751,7 @@ class so {
|
|
|
3770
3751
|
if (Array.isArray(t))
|
|
3771
3752
|
return t.length > 0 ? t : null;
|
|
3772
3753
|
const e = t || this.editor.canvas.getActiveObject();
|
|
3773
|
-
return !e || !(e instanceof
|
|
3754
|
+
return !e || !(e instanceof U) ? null : e.getObjects();
|
|
3774
3755
|
}
|
|
3775
3756
|
/**
|
|
3776
3757
|
* Получить группы для разгруппировки
|
|
@@ -3781,13 +3762,13 @@ class so {
|
|
|
3781
3762
|
const s = t.filter((o) => o instanceof Et);
|
|
3782
3763
|
return s.length > 0 ? s : null;
|
|
3783
3764
|
}
|
|
3784
|
-
if (t instanceof
|
|
3765
|
+
if (t instanceof U) {
|
|
3785
3766
|
const s = t.getObjects().filter((o) => o instanceof Et);
|
|
3786
3767
|
return s.length > 0 ? s : null;
|
|
3787
3768
|
}
|
|
3788
3769
|
const e = t || this.editor.canvas.getActiveObject();
|
|
3789
3770
|
if (!e) return null;
|
|
3790
|
-
if (e instanceof
|
|
3771
|
+
if (e instanceof U) {
|
|
3791
3772
|
const s = e.getObjects().filter((o) => o instanceof Et);
|
|
3792
3773
|
return s.length > 0 ? s : null;
|
|
3793
3774
|
}
|
|
@@ -3809,7 +3790,7 @@ class so {
|
|
|
3809
3790
|
try {
|
|
3810
3791
|
o.suspendHistory();
|
|
3811
3792
|
const i = new Et(n, {
|
|
3812
|
-
id: `group-${
|
|
3793
|
+
id: `group-${V()}`
|
|
3813
3794
|
});
|
|
3814
3795
|
n.forEach((r) => s.remove(r)), s.add(i), s.setActiveObject(i), s.requestRenderAll();
|
|
3815
3796
|
const a = {
|
|
@@ -3844,7 +3825,7 @@ class so {
|
|
|
3844
3825
|
s.add(l), i.push(l);
|
|
3845
3826
|
});
|
|
3846
3827
|
});
|
|
3847
|
-
const a = new
|
|
3828
|
+
const a = new U(i, {
|
|
3848
3829
|
canvas: s
|
|
3849
3830
|
});
|
|
3850
3831
|
s.setActiveObject(a), s.requestRenderAll();
|
|
@@ -3870,11 +3851,11 @@ class oo {
|
|
|
3870
3851
|
selectAll() {
|
|
3871
3852
|
const { canvas: t, canvasManager: e, objectLockManager: s } = this.editor;
|
|
3872
3853
|
t.discardActiveObject();
|
|
3873
|
-
const o = e.getObjects(), n = o.some((a) => a.locked), i = o.length > 1 ? new
|
|
3854
|
+
const o = e.getObjects(), n = o.some((a) => a.locked), i = o.length > 1 ? new U(e.getObjects(), { canvas: t }) : o[0];
|
|
3874
3855
|
n && s.lockObject({ object: i, skipInnerObjects: !0, withoutSave: !0 }), t.setActiveObject(i), t.requestRenderAll(), t.fire("editor:all-objects-selected", { selected: i });
|
|
3875
3856
|
}
|
|
3876
3857
|
}
|
|
3877
|
-
class
|
|
3858
|
+
class Me {
|
|
3878
3859
|
constructor({ editor: t }) {
|
|
3879
3860
|
this.editor = t;
|
|
3880
3861
|
}
|
|
@@ -3921,7 +3902,7 @@ class we {
|
|
|
3921
3902
|
s || n.suspendHistory();
|
|
3922
3903
|
const r = [];
|
|
3923
3904
|
if (a.forEach((d) => {
|
|
3924
|
-
if (
|
|
3905
|
+
if (Me._isUngroupableGroup(d)) {
|
|
3925
3906
|
const l = this._handleGroupDeletion(d);
|
|
3926
3907
|
r.push(...l);
|
|
3927
3908
|
return;
|
|
@@ -4041,7 +4022,7 @@ const bt = {
|
|
|
4041
4022
|
APPLY_FAILED: "TEMPLATE_APPLY_FAILED"
|
|
4042
4023
|
}
|
|
4043
4024
|
};
|
|
4044
|
-
class
|
|
4025
|
+
class Wt {
|
|
4045
4026
|
constructor({ editor: t }) {
|
|
4046
4027
|
this._buffer = [], this.editor = t;
|
|
4047
4028
|
}
|
|
@@ -4068,7 +4049,7 @@ class Yt {
|
|
|
4068
4049
|
* @fires editor:error
|
|
4069
4050
|
*/
|
|
4070
4051
|
emitError({ origin: t = "ImageEditor", method: e = "Unknown Method", code: s, data: o, message: n }) {
|
|
4071
|
-
if (!
|
|
4052
|
+
if (!Wt.isValidErrorCode(s)) {
|
|
4072
4053
|
console.warn("Неизвестный код ошибки: ", { code: s, origin: t, method: e });
|
|
4073
4054
|
return;
|
|
4074
4055
|
}
|
|
@@ -4082,7 +4063,7 @@ class Yt {
|
|
|
4082
4063
|
message: i,
|
|
4083
4064
|
data: o
|
|
4084
4065
|
};
|
|
4085
|
-
this._buffer.push(
|
|
4066
|
+
this._buffer.push(B({
|
|
4086
4067
|
type: "editor:error"
|
|
4087
4068
|
}, a)), this.editor.canvas.fire("editor:error", a);
|
|
4088
4069
|
}
|
|
@@ -4097,7 +4078,7 @@ class Yt {
|
|
|
4097
4078
|
* @fires editor:warning
|
|
4098
4079
|
*/
|
|
4099
4080
|
emitWarning({ origin: t = "ImageEditor", method: e = "Unknown Method", code: s, message: o, data: n }) {
|
|
4100
|
-
if (!
|
|
4081
|
+
if (!Wt.isValidErrorCode(s)) {
|
|
4101
4082
|
console.warn("Неизвестный код предупреждения: ", { code: s, origin: t, method: e });
|
|
4102
4083
|
return;
|
|
4103
4084
|
}
|
|
@@ -4110,7 +4091,7 @@ class Yt {
|
|
|
4110
4091
|
message: i,
|
|
4111
4092
|
data: n
|
|
4112
4093
|
};
|
|
4113
|
-
this._buffer.push(
|
|
4094
|
+
this._buffer.push(B({
|
|
4114
4095
|
type: "editor:warning"
|
|
4115
4096
|
}, a)), this.editor.canvas.fire("editor:warning", a);
|
|
4116
4097
|
}
|
|
@@ -4233,11 +4214,11 @@ const at = ({
|
|
|
4233
4214
|
}
|
|
4234
4215
|
_getNonTransformedDimensions() {
|
|
4235
4216
|
const { width: t, height: e } = this._getBackgroundDimensions();
|
|
4236
|
-
return new
|
|
4217
|
+
return new et(t, e).scalarAdd(this.strokeWidth);
|
|
4237
4218
|
}
|
|
4238
4219
|
_getTransformedDimensions(t = {}) {
|
|
4239
4220
|
const { width: e, height: s } = this._getBackgroundDimensions();
|
|
4240
|
-
return super._getTransformedDimensions(yt(
|
|
4221
|
+
return super._getTransformedDimensions(yt(B({}, t), {
|
|
4241
4222
|
width: e,
|
|
4242
4223
|
height: s
|
|
4243
4224
|
}));
|
|
@@ -4247,7 +4228,7 @@ const at = ({
|
|
|
4247
4228
|
*/
|
|
4248
4229
|
toObject(t = []) {
|
|
4249
4230
|
const e = super.toObject(t);
|
|
4250
|
-
return yt(
|
|
4231
|
+
return yt(B({}, e), {
|
|
4251
4232
|
backgroundOpacity: this.backgroundOpacity,
|
|
4252
4233
|
paddingTop: this.paddingTop,
|
|
4253
4234
|
paddingRight: this.paddingRight,
|
|
@@ -4308,9 +4289,9 @@ const at = ({
|
|
|
4308
4289
|
const e = at({ value: (o = this.backgroundOpacity) != null ? o : 1, min: 0, max: 1 });
|
|
4309
4290
|
let s;
|
|
4310
4291
|
try {
|
|
4311
|
-
s = new
|
|
4292
|
+
s = new ps(t);
|
|
4312
4293
|
} catch (n) {
|
|
4313
|
-
return
|
|
4294
|
+
return Wt.emitError({
|
|
4314
4295
|
origin: "BackgroundTextbox",
|
|
4315
4296
|
method: "_getEffectiveBackgroundFill",
|
|
4316
4297
|
code: "INVALID_COLOR_VALUE",
|
|
@@ -4372,10 +4353,10 @@ Dt.type = "background-textbox", Dt.cacheProperties = [
|
|
|
4372
4353
|
"radiusBottomRight",
|
|
4373
4354
|
"radiusBottomLeft"
|
|
4374
4355
|
];
|
|
4375
|
-
let
|
|
4356
|
+
let se = Dt;
|
|
4376
4357
|
const io = () => {
|
|
4377
4358
|
var h;
|
|
4378
|
-
(h =
|
|
4359
|
+
(h = ze) != null && h.setClass && ze.setClass(se, "background-textbox");
|
|
4379
4360
|
}, ao = ({ textbox: h }) => {
|
|
4380
4361
|
var s, o;
|
|
4381
4362
|
if (!h.isEditing) return null;
|
|
@@ -4393,7 +4374,7 @@ const io = () => {
|
|
|
4393
4374
|
if (!t) return !1;
|
|
4394
4375
|
const e = (o = (s = h.text) == null ? void 0 : s.length) != null ? o : 0;
|
|
4395
4376
|
return e <= 0 ? !1 : t.start <= 0 && t.end >= e;
|
|
4396
|
-
},
|
|
4377
|
+
}, ie = ({
|
|
4397
4378
|
textbox: h,
|
|
4398
4379
|
styles: t,
|
|
4399
4380
|
range: e
|
|
@@ -4401,7 +4382,7 @@ const io = () => {
|
|
|
4401
4382
|
if (!t || !Object.keys(t).length) return !1;
|
|
4402
4383
|
const { start: s, end: o } = e;
|
|
4403
4384
|
return o <= s ? !1 : (h.setSelectionStyles(t, s, o), !0);
|
|
4404
|
-
},
|
|
4385
|
+
}, Ge = ({
|
|
4405
4386
|
textbox: h,
|
|
4406
4387
|
range: t,
|
|
4407
4388
|
property: e
|
|
@@ -4415,11 +4396,8 @@ const io = () => {
|
|
|
4415
4396
|
);
|
|
4416
4397
|
if (s.length)
|
|
4417
4398
|
return (o = s[0]) == null ? void 0 : o[e];
|
|
4418
|
-
},
|
|
4419
|
-
|
|
4420
|
-
return h != null ? h : "#000000";
|
|
4421
|
-
}, Ke = ({ width: h = 0 }) => h ? Math.max(0, h) : 0, ie = ({ value: h }) => typeof h == "string" ? h.toLocaleUpperCase() : "", st = 0.01;
|
|
4422
|
-
class P {
|
|
4399
|
+
}, Ve = ({ strokeColor: h, width: t }) => t <= 0 ? null : h != null ? h : "#000000", Xe = ({ width: h = 0 }) => h ? Math.max(0, h) : 0, ae = ({ value: h }) => typeof h == "string" ? h.toLocaleUpperCase() : "", ot = 0.01;
|
|
4400
|
+
class F {
|
|
4423
4401
|
constructor({ editor: t }) {
|
|
4424
4402
|
var e;
|
|
4425
4403
|
this._handleTextEditingEntered = () => {
|
|
@@ -4427,23 +4405,23 @@ class P {
|
|
|
4427
4405
|
}, this._handleTextEditingExited = (s) => {
|
|
4428
4406
|
var r, c;
|
|
4429
4407
|
const { target: o } = s;
|
|
4430
|
-
if (!
|
|
4408
|
+
if (!F._isTextbox(o)) return;
|
|
4431
4409
|
const n = (r = o.text) != null ? r : "";
|
|
4432
4410
|
if (!!o.uppercase) {
|
|
4433
4411
|
const d = (c = o.textCaseRaw) != null ? c : n.toLocaleLowerCase();
|
|
4434
4412
|
o.textCaseRaw = d;
|
|
4435
4413
|
} else
|
|
4436
4414
|
o.textCaseRaw = n;
|
|
4437
|
-
|
|
4415
|
+
F._roundTextboxDimensions({ textbox: o }) && (o.setCoords(), o.dirty = !0, this.canvas.requestRenderAll()), o.locked || o.set({
|
|
4438
4416
|
lockMovementX: !1,
|
|
4439
4417
|
lockMovementY: !1
|
|
4440
4418
|
}), setTimeout(() => {
|
|
4441
4419
|
this.isTextEditingActive = !1, this.editor.historyManager.saveState();
|
|
4442
4420
|
}, Vs);
|
|
4443
4421
|
}, this._handleObjectScaling = (s) => {
|
|
4444
|
-
var X, It,
|
|
4422
|
+
var X, It, Ht, mt, Zt, Ct, Se, Ae, je, Ie, Ce, Te, Ee;
|
|
4445
4423
|
const { target: o, transform: n } = s;
|
|
4446
|
-
if (o instanceof
|
|
4424
|
+
if (o instanceof U || !F._isTextbox(o) || !n) return;
|
|
4447
4425
|
o.isScaling = !0;
|
|
4448
4426
|
const i = this._ensureScalingState(o), {
|
|
4449
4427
|
baseWidth: a,
|
|
@@ -4452,139 +4430,139 @@ class P {
|
|
|
4452
4430
|
basePadding: d,
|
|
4453
4431
|
baseRadii: l,
|
|
4454
4432
|
baseStyles: u
|
|
4455
|
-
} = i, g = typeof ((X = n.original) == null ? void 0 : X.width) == "number" ? n.original.width : void 0, f = typeof ((It = n.original) == null ? void 0 : It.left) == "number" ? n.original.left : void 0, p = g != null ? g : a, m = f != null ? f : r, v = (
|
|
4456
|
-
if (!
|
|
4457
|
-
const j = Math.abs((Ct = (
|
|
4433
|
+
} = i, g = typeof ((X = n.original) == null ? void 0 : X.width) == "number" ? n.original.width : void 0, f = typeof ((It = n.original) == null ? void 0 : It.left) == "number" ? n.original.left : void 0, p = g != null ? g : a, m = f != null ? f : r, v = (Ht = n.corner) != null ? Ht : "", M = (mt = n.action) != null ? mt : "", S = ["ml", "mr"].includes(v) || M === "scaleX", y = ["mt", "mb"].includes(v) || M === "scaleY", b = ["tl", "tr", "bl", "br"].includes(v) || M === "scale", I = b || y;
|
|
4434
|
+
if (!S && !y && !b) return;
|
|
4435
|
+
const j = Math.abs((Ct = (Zt = o.scaleX) != null ? Zt : n.scaleX) != null ? Ct : 1) || 1, A = Math.abs((Ae = (Se = o.scaleY) != null ? Se : n.scaleY) != null ? Ae : 1) || 1, C = Math.max(1, p * j), w = Math.max(1, Math.round(C)), T = Math.max(1, c * A), {
|
|
4458
4436
|
paddingTop: E = 0,
|
|
4459
|
-
paddingRight:
|
|
4460
|
-
paddingBottom:
|
|
4461
|
-
paddingLeft:
|
|
4462
|
-
radiusTopLeft:
|
|
4437
|
+
paddingRight: P = 0,
|
|
4438
|
+
paddingBottom: x = 0,
|
|
4439
|
+
paddingLeft: N = 0,
|
|
4440
|
+
radiusTopLeft: Z = 0,
|
|
4463
4441
|
radiusTopRight: D = 0,
|
|
4464
4442
|
radiusBottomRight: _ = 0,
|
|
4465
|
-
radiusBottomLeft:
|
|
4466
|
-
fontSize:
|
|
4467
|
-
width:
|
|
4443
|
+
radiusBottomLeft: W = 0,
|
|
4444
|
+
fontSize: G,
|
|
4445
|
+
width: Y,
|
|
4468
4446
|
originX: K = "left"
|
|
4469
|
-
} = o,
|
|
4470
|
-
top: Math.max(0, d.top *
|
|
4471
|
-
right: Math.max(0, d.right *
|
|
4472
|
-
bottom: Math.max(0, d.bottom *
|
|
4473
|
-
left: Math.max(0, d.left *
|
|
4474
|
-
} : d,
|
|
4475
|
-
topLeft: Math.max(0, l.topLeft *
|
|
4476
|
-
topRight: Math.max(0, l.topRight *
|
|
4477
|
-
bottomRight: Math.max(0, l.bottomRight *
|
|
4478
|
-
bottomLeft: Math.max(0, l.bottomLeft *
|
|
4447
|
+
} = o, tt = b || y, J = b || y, H = tt ? {
|
|
4448
|
+
top: Math.max(0, d.top * A),
|
|
4449
|
+
right: Math.max(0, d.right * A),
|
|
4450
|
+
bottom: Math.max(0, d.bottom * A),
|
|
4451
|
+
left: Math.max(0, d.left * A)
|
|
4452
|
+
} : d, q = J ? {
|
|
4453
|
+
topLeft: Math.max(0, l.topLeft * A),
|
|
4454
|
+
topRight: Math.max(0, l.topRight * A),
|
|
4455
|
+
bottomRight: Math.max(0, l.bottomRight * A),
|
|
4456
|
+
bottomLeft: Math.max(0, l.bottomLeft * A)
|
|
4479
4457
|
} : l, St = Object.keys(u).length > 0;
|
|
4480
|
-
let
|
|
4481
|
-
if (
|
|
4482
|
-
const
|
|
4483
|
-
Object.entries(u).forEach(([
|
|
4484
|
-
if (!
|
|
4485
|
-
const
|
|
4486
|
-
Object.entries(
|
|
4487
|
-
if (!
|
|
4488
|
-
const
|
|
4489
|
-
typeof
|
|
4490
|
-
}), Object.keys(
|
|
4491
|
-
}), Object.keys(
|
|
4458
|
+
let st;
|
|
4459
|
+
if (I && St) {
|
|
4460
|
+
const oe = {};
|
|
4461
|
+
Object.entries(u).forEach(([as, Oe]) => {
|
|
4462
|
+
if (!Oe) return;
|
|
4463
|
+
const ne = {};
|
|
4464
|
+
Object.entries(Oe).forEach(([rs, Gt]) => {
|
|
4465
|
+
if (!Gt) return;
|
|
4466
|
+
const Le = B({}, Gt);
|
|
4467
|
+
typeof Gt.fontSize == "number" && (Le.fontSize = Math.max(1, Gt.fontSize * A)), ne[rs] = Le;
|
|
4468
|
+
}), Object.keys(ne).length && (oe[as] = ne);
|
|
4469
|
+
}), Object.keys(oe).length && (st = oe);
|
|
4492
4470
|
}
|
|
4493
|
-
const lt = (
|
|
4494
|
-
if (!jt && !
|
|
4471
|
+
const lt = (Ie = (je = n.originX) != null ? je : K) != null ? Ie : "left", pt = m + p, At = m + p / 2, ht = Y != null ? Y : p, jt = w !== ht, Yt = Math.abs(T - (G != null ? G : c)) > ot, xt = Math.abs(H.top - E) > ot || Math.abs(H.right - P) > ot || Math.abs(H.bottom - x) > ot || Math.abs(H.left - N) > ot, Nt = Math.abs(q.topLeft - Z) > ot || Math.abs(q.topRight - D) > ot || Math.abs(q.bottomRight - _) > ot || Math.abs(q.bottomLeft - W) > ot;
|
|
4472
|
+
if (!jt && !Yt && !xt && !Nt) {
|
|
4495
4473
|
o.set({ scaleX: 1, scaleY: 1 }), n.scaleX = 1, n.scaleY = 1;
|
|
4496
4474
|
return;
|
|
4497
4475
|
}
|
|
4498
|
-
|
|
4476
|
+
st && (o.styles = st), o.set({
|
|
4499
4477
|
width: w,
|
|
4500
|
-
fontSize:
|
|
4478
|
+
fontSize: I ? T : c,
|
|
4501
4479
|
paddingTop: H.top,
|
|
4502
4480
|
paddingRight: H.right,
|
|
4503
4481
|
paddingBottom: H.bottom,
|
|
4504
4482
|
paddingLeft: H.left,
|
|
4505
|
-
radiusTopLeft:
|
|
4506
|
-
radiusTopRight:
|
|
4507
|
-
radiusBottomRight:
|
|
4508
|
-
radiusBottomLeft:
|
|
4483
|
+
radiusTopLeft: q.topLeft,
|
|
4484
|
+
radiusTopRight: q.topRight,
|
|
4485
|
+
radiusBottomRight: q.bottomRight,
|
|
4486
|
+
radiusBottomLeft: q.bottomLeft,
|
|
4509
4487
|
scaleX: 1,
|
|
4510
4488
|
scaleY: 1
|
|
4511
4489
|
});
|
|
4512
|
-
const Bt =
|
|
4490
|
+
const Bt = F._roundTextboxDimensions({ textbox: o });
|
|
4513
4491
|
Bt && (o.dirty = !0);
|
|
4514
|
-
const ut = (
|
|
4492
|
+
const ut = (Ce = o.width) != null ? Ce : w, kt = ut !== ht;
|
|
4515
4493
|
let gt = m;
|
|
4516
|
-
kt && (
|
|
4494
|
+
kt && (S || b) && (lt === "right" ? gt = pt - ut : lt === "center" && (gt = At - ut / 2)), o.set({ left: gt }), i.baseLeft = gt, n.scaleX = 1, n.scaleY = 1;
|
|
4517
4495
|
const { original: it } = n;
|
|
4518
|
-
it && (it.scaleX = 1, it.scaleY = 1, it.width = ut, it.height = o.height, it.left = gt), o.setCoords(), this.canvas.requestRenderAll(), i.baseWidth = ut, i.baseFontSize = (
|
|
4496
|
+
it && (it.scaleX = 1, it.scaleY = 1, it.width = ut, it.height = o.height, it.left = gt), o.setCoords(), this.canvas.requestRenderAll(), i.baseWidth = ut, i.baseFontSize = (Te = o.fontSize) != null ? Te : T, i.baseStyles = JSON.parse(JSON.stringify((Ee = o.styles) != null ? Ee : {})), i.basePadding = {
|
|
4519
4497
|
top: H.top,
|
|
4520
4498
|
right: H.right,
|
|
4521
4499
|
bottom: H.bottom,
|
|
4522
4500
|
left: H.left
|
|
4523
4501
|
}, i.baseRadii = {
|
|
4524
|
-
topLeft:
|
|
4525
|
-
topRight:
|
|
4526
|
-
bottomRight:
|
|
4527
|
-
bottomLeft:
|
|
4528
|
-
}, i.hasWidthChange = kt ||
|
|
4502
|
+
topLeft: q.topLeft,
|
|
4503
|
+
topRight: q.topRight,
|
|
4504
|
+
bottomRight: q.bottomRight,
|
|
4505
|
+
bottomLeft: q.bottomLeft
|
|
4506
|
+
}, i.hasWidthChange = kt || Yt || xt || Nt || Bt;
|
|
4529
4507
|
}, this._handleObjectModified = (s) => {
|
|
4530
|
-
var
|
|
4508
|
+
var M, S, y;
|
|
4531
4509
|
const { target: o } = s;
|
|
4532
|
-
if (o instanceof
|
|
4533
|
-
const
|
|
4534
|
-
if (!
|
|
4535
|
-
const { scaleX: j = 1, scaleY:
|
|
4536
|
-
if (Math.abs(j - 1) <
|
|
4537
|
-
this.canvas.discardActiveObject(),
|
|
4538
|
-
var T, E,
|
|
4539
|
-
if (
|
|
4540
|
-
const
|
|
4541
|
-
paddingTop:
|
|
4542
|
-
paddingRight:
|
|
4510
|
+
if (o instanceof U) {
|
|
4511
|
+
const b = o.getObjects();
|
|
4512
|
+
if (!b.some((w) => F._isTextbox(w))) return;
|
|
4513
|
+
const { scaleX: j = 1, scaleY: A = 1 } = o;
|
|
4514
|
+
if (Math.abs(j - 1) < ot && Math.abs(A - 1) < ot) return;
|
|
4515
|
+
this.canvas.discardActiveObject(), b.forEach((w) => {
|
|
4516
|
+
var T, E, P, x;
|
|
4517
|
+
if (F._isTextbox(w)) {
|
|
4518
|
+
const N = (T = w.scaleX) != null ? T : 1, Z = (E = w.scaleY) != null ? E : 1, D = ((P = w.fontSize) != null ? P : 16) * Z, _ = ((x = w.width) != null ? x : 0) * N, W = Z, {
|
|
4519
|
+
paddingTop: G = 0,
|
|
4520
|
+
paddingRight: Y = 0,
|
|
4543
4521
|
paddingBottom: K = 0,
|
|
4544
|
-
paddingLeft:
|
|
4545
|
-
radiusTopLeft:
|
|
4522
|
+
paddingLeft: tt = 0,
|
|
4523
|
+
radiusTopLeft: J = 0,
|
|
4546
4524
|
radiusTopRight: H = 0,
|
|
4547
|
-
radiusBottomRight:
|
|
4525
|
+
radiusBottomRight: q = 0,
|
|
4548
4526
|
radiusBottomLeft: St = 0,
|
|
4549
|
-
styles:
|
|
4527
|
+
styles: st
|
|
4550
4528
|
} = w, lt = {
|
|
4551
|
-
paddingTop: Math.max(0,
|
|
4552
|
-
paddingRight: Math.max(0,
|
|
4553
|
-
paddingBottom: Math.max(0, K *
|
|
4554
|
-
paddingLeft: Math.max(0,
|
|
4529
|
+
paddingTop: Math.max(0, G * W),
|
|
4530
|
+
paddingRight: Math.max(0, Y * W),
|
|
4531
|
+
paddingBottom: Math.max(0, K * W),
|
|
4532
|
+
paddingLeft: Math.max(0, tt * W)
|
|
4555
4533
|
}, pt = {
|
|
4556
|
-
radiusTopLeft: Math.max(0,
|
|
4557
|
-
radiusTopRight: Math.max(0, H *
|
|
4558
|
-
radiusBottomRight: Math.max(0,
|
|
4559
|
-
radiusBottomLeft: Math.max(0, St *
|
|
4534
|
+
radiusTopLeft: Math.max(0, J * W),
|
|
4535
|
+
radiusTopRight: Math.max(0, H * W),
|
|
4536
|
+
radiusBottomRight: Math.max(0, q * W),
|
|
4537
|
+
radiusBottomLeft: Math.max(0, St * W)
|
|
4560
4538
|
};
|
|
4561
|
-
let At =
|
|
4562
|
-
|
|
4539
|
+
let At = st;
|
|
4540
|
+
st && Object.keys(st).length > 0 && (At = JSON.parse(JSON.stringify(st)), Object.values(At).forEach((ht) => {
|
|
4563
4541
|
Object.values(ht).forEach((jt) => {
|
|
4564
|
-
typeof jt.fontSize == "number" && (jt.fontSize = Math.max(1, jt.fontSize *
|
|
4542
|
+
typeof jt.fontSize == "number" && (jt.fontSize = Math.max(1, jt.fontSize * W));
|
|
4565
4543
|
});
|
|
4566
|
-
})), w.set(yt(
|
|
4544
|
+
})), w.set(yt(B(B({
|
|
4567
4545
|
fontSize: D,
|
|
4568
4546
|
width: _,
|
|
4569
4547
|
scaleX: 1,
|
|
4570
4548
|
scaleY: 1
|
|
4571
4549
|
}, lt), pt), {
|
|
4572
4550
|
styles: At
|
|
4573
|
-
})),
|
|
4551
|
+
})), F._roundTextboxDimensions({ textbox: w });
|
|
4574
4552
|
}
|
|
4575
4553
|
w.setCoords();
|
|
4576
4554
|
});
|
|
4577
|
-
const C = new
|
|
4555
|
+
const C = new U(b, {
|
|
4578
4556
|
canvas: this.canvas
|
|
4579
4557
|
});
|
|
4580
4558
|
this.canvas.setActiveObject(C), this.canvas.requestRenderAll();
|
|
4581
4559
|
return;
|
|
4582
4560
|
}
|
|
4583
|
-
if (!
|
|
4561
|
+
if (!F._isTextbox(o)) return;
|
|
4584
4562
|
o.isScaling = !1;
|
|
4585
4563
|
const n = this.scalingState.get(o);
|
|
4586
4564
|
if (this.scalingState.delete(o), !(n != null && n.hasWidthChange)) return;
|
|
4587
|
-
const i = (
|
|
4565
|
+
const i = (M = o.width) != null ? M : o.calcTextWidth(), a = (y = (S = o.fontSize) != null ? S : n == null ? void 0 : n.baseFontSize) != null ? y : 16, r = !!(n.baseStyles && Object.keys(n.baseStyles).length), {
|
|
4588
4566
|
paddingTop: c = 0,
|
|
4589
4567
|
paddingRight: d = 0,
|
|
4590
4568
|
paddingBottom: l = 0,
|
|
@@ -4615,9 +4593,9 @@ class P {
|
|
|
4615
4593
|
* @param options — настройки текста
|
|
4616
4594
|
* @param flags — флаги поведения
|
|
4617
4595
|
*/
|
|
4618
|
-
addText(
|
|
4619
|
-
var
|
|
4620
|
-
id: t = `text-${
|
|
4596
|
+
addText(P = {}, { withoutSelection: w = !1, withoutSave: T = !1, withoutAdding: E = !1 } = {}) {
|
|
4597
|
+
var x = P, {
|
|
4598
|
+
id: t = `text-${V()}`,
|
|
4621
4599
|
text: e = "Новый текст",
|
|
4622
4600
|
fontFamily: s,
|
|
4623
4601
|
fontSize: o = 48,
|
|
@@ -4634,14 +4612,14 @@ class P {
|
|
|
4634
4612
|
backgroundColor: p,
|
|
4635
4613
|
backgroundOpacity: m = 1,
|
|
4636
4614
|
paddingTop: v = 0,
|
|
4637
|
-
paddingRight:
|
|
4638
|
-
paddingBottom:
|
|
4615
|
+
paddingRight: M = 0,
|
|
4616
|
+
paddingBottom: S = 0,
|
|
4639
4617
|
paddingLeft: y = 0,
|
|
4640
|
-
radiusTopLeft:
|
|
4641
|
-
radiusTopRight:
|
|
4618
|
+
radiusTopLeft: b = 0,
|
|
4619
|
+
radiusTopRight: I = 0,
|
|
4642
4620
|
radiusBottomRight: j = 0,
|
|
4643
|
-
radiusBottomLeft:
|
|
4644
|
-
} =
|
|
4621
|
+
radiusBottomLeft: A = 0
|
|
4622
|
+
} = x, C = vt(x, [
|
|
4645
4623
|
"id",
|
|
4646
4624
|
"text",
|
|
4647
4625
|
"fontFamily",
|
|
@@ -4667,13 +4645,13 @@ class P {
|
|
|
4667
4645
|
"radiusBottomRight",
|
|
4668
4646
|
"radiusBottomLeft"
|
|
4669
4647
|
]);
|
|
4670
|
-
var
|
|
4671
|
-
const { historyManager:
|
|
4672
|
-
|
|
4673
|
-
const D = s != null ? s : this._getDefaultFontFamily(), _ =
|
|
4648
|
+
var tt;
|
|
4649
|
+
const { historyManager: N } = this.editor, { canvas: Z } = this;
|
|
4650
|
+
N.suspendHistory();
|
|
4651
|
+
const D = s != null ? s : this._getDefaultFontFamily(), _ = Xe({ width: g }), W = Ve({
|
|
4674
4652
|
strokeColor: u,
|
|
4675
4653
|
width: _
|
|
4676
|
-
}),
|
|
4654
|
+
}), G = B({
|
|
4677
4655
|
id: t,
|
|
4678
4656
|
fontFamily: D,
|
|
4679
4657
|
fontSize: o,
|
|
@@ -4684,35 +4662,35 @@ class P {
|
|
|
4684
4662
|
linethrough: c,
|
|
4685
4663
|
textAlign: d,
|
|
4686
4664
|
fill: l,
|
|
4687
|
-
stroke:
|
|
4665
|
+
stroke: W,
|
|
4688
4666
|
strokeWidth: _,
|
|
4689
4667
|
strokeUniform: !0,
|
|
4690
4668
|
opacity: f,
|
|
4691
4669
|
backgroundColor: p,
|
|
4692
4670
|
backgroundOpacity: m,
|
|
4693
4671
|
paddingTop: v,
|
|
4694
|
-
paddingRight:
|
|
4695
|
-
paddingBottom:
|
|
4672
|
+
paddingRight: M,
|
|
4673
|
+
paddingBottom: S,
|
|
4696
4674
|
paddingLeft: y,
|
|
4697
|
-
radiusTopLeft:
|
|
4698
|
-
radiusTopRight:
|
|
4675
|
+
radiusTopLeft: b,
|
|
4676
|
+
radiusTopRight: I,
|
|
4699
4677
|
radiusBottomRight: j,
|
|
4700
|
-
radiusBottomLeft:
|
|
4701
|
-
}, C),
|
|
4702
|
-
if (
|
|
4703
|
-
const
|
|
4704
|
-
|
|
4705
|
-
}
|
|
4706
|
-
return
|
|
4707
|
-
textbox:
|
|
4708
|
-
options: yt(
|
|
4678
|
+
radiusBottomLeft: A
|
|
4679
|
+
}, C), Y = new se(e, G);
|
|
4680
|
+
if (Y.textCaseRaw = (tt = Y.text) != null ? tt : "", r) {
|
|
4681
|
+
const J = ae({ value: Y.textCaseRaw });
|
|
4682
|
+
J !== Y.text && Y.set({ text: J });
|
|
4683
|
+
}
|
|
4684
|
+
return F._roundTextboxDimensions({ textbox: Y }) && (Y.dirty = !0), C.left === void 0 && C.top === void 0 && Z.centerObject(Y), E || Z.add(Y), w || Z.setActiveObject(Y), Z.requestRenderAll(), N.resumeHistory(), T || N.saveState(), Z.fire("editor:text-added", {
|
|
4685
|
+
textbox: Y,
|
|
4686
|
+
options: yt(B({}, G), {
|
|
4709
4687
|
text: e,
|
|
4710
4688
|
bold: n,
|
|
4711
4689
|
italic: i,
|
|
4712
4690
|
strikethrough: c,
|
|
4713
4691
|
align: d,
|
|
4714
4692
|
color: l,
|
|
4715
|
-
strokeColor:
|
|
4693
|
+
strokeColor: W,
|
|
4716
4694
|
strokeWidth: _
|
|
4717
4695
|
}),
|
|
4718
4696
|
flags: {
|
|
@@ -4720,7 +4698,7 @@ class P {
|
|
|
4720
4698
|
withoutSave: !!T,
|
|
4721
4699
|
withoutAdding: !!E
|
|
4722
4700
|
}
|
|
4723
|
-
}),
|
|
4701
|
+
}), Y;
|
|
4724
4702
|
}
|
|
4725
4703
|
/**
|
|
4726
4704
|
* Обновляет текстовый объект.
|
|
@@ -4731,12 +4709,12 @@ class P {
|
|
|
4731
4709
|
* @param options.skipRender — не вызывать перерисовку канваса
|
|
4732
4710
|
*/
|
|
4733
4711
|
updateText({ target: t, style: e = {}, withoutSave: s, skipRender: o } = {}) {
|
|
4734
|
-
var
|
|
4712
|
+
var Nt, Bt, ut, kt, gt, it;
|
|
4735
4713
|
const n = this._resolveTextObject(t);
|
|
4736
4714
|
if (!n) return null;
|
|
4737
4715
|
const { historyManager: i } = this.editor, { canvas: a } = this;
|
|
4738
4716
|
i.suspendHistory();
|
|
4739
|
-
const r =
|
|
4717
|
+
const r = F._getSnapshot(n), xt = e, {
|
|
4740
4718
|
text: c,
|
|
4741
4719
|
fontFamily: d,
|
|
4742
4720
|
fontSize: l,
|
|
@@ -4746,21 +4724,21 @@ class P {
|
|
|
4746
4724
|
uppercase: p,
|
|
4747
4725
|
strikethrough: m,
|
|
4748
4726
|
align: v,
|
|
4749
|
-
color:
|
|
4750
|
-
strokeColor:
|
|
4727
|
+
color: M,
|
|
4728
|
+
strokeColor: S,
|
|
4751
4729
|
strokeWidth: y,
|
|
4752
|
-
opacity:
|
|
4753
|
-
backgroundColor:
|
|
4730
|
+
opacity: b,
|
|
4731
|
+
backgroundColor: I,
|
|
4754
4732
|
backgroundOpacity: j,
|
|
4755
|
-
paddingTop:
|
|
4733
|
+
paddingTop: A,
|
|
4756
4734
|
paddingRight: C,
|
|
4757
4735
|
paddingBottom: w,
|
|
4758
4736
|
paddingLeft: T,
|
|
4759
4737
|
radiusTopLeft: E,
|
|
4760
|
-
radiusTopRight:
|
|
4761
|
-
radiusBottomRight:
|
|
4762
|
-
radiusBottomLeft:
|
|
4763
|
-
} =
|
|
4738
|
+
radiusTopRight: P,
|
|
4739
|
+
radiusBottomRight: x,
|
|
4740
|
+
radiusBottomLeft: N
|
|
4741
|
+
} = xt, Z = vt(xt, [
|
|
4764
4742
|
"text",
|
|
4765
4743
|
"fontFamily",
|
|
4766
4744
|
"fontSize",
|
|
@@ -4784,39 +4762,39 @@ class P {
|
|
|
4784
4762
|
"radiusTopRight",
|
|
4785
4763
|
"radiusBottomRight",
|
|
4786
4764
|
"radiusBottomLeft"
|
|
4787
|
-
]), D =
|
|
4788
|
-
if (d !== void 0 && (
|
|
4765
|
+
]), D = B({}, Z), _ = ao({ textbox: n }), W = _ ? F._expandRangeToFullLines({ textbox: n, range: _ }) : null, G = {}, Y = {}, K = {}, tt = co({ textbox: n, range: _ }), J = !_ || tt, H = !_;
|
|
4766
|
+
if (d !== void 0 && (W && (Y.fontFamily = d), J && (D.fontFamily = d, H && (K.fontFamily = d))), l !== void 0 && (W && (Y.fontSize = l), J && (D.fontSize = l, H && (K.fontSize = l))), u !== void 0) {
|
|
4789
4767
|
const X = u ? "bold" : "normal";
|
|
4790
|
-
_ && (
|
|
4768
|
+
_ && (G.fontWeight = X), J && (D.fontWeight = X, H && (K.fontWeight = X));
|
|
4791
4769
|
}
|
|
4792
4770
|
if (g !== void 0) {
|
|
4793
4771
|
const X = g ? "italic" : "normal";
|
|
4794
|
-
_ && (
|
|
4772
|
+
_ && (G.fontStyle = X), J && (D.fontStyle = X, H && (K.fontStyle = X));
|
|
4795
4773
|
}
|
|
4796
|
-
if (f !== void 0 && (_ && (
|
|
4797
|
-
const X = _ ?
|
|
4798
|
-
strokeColor:
|
|
4774
|
+
if (f !== void 0 && (_ && (G.underline = f), J && (D.underline = f, H && (K.underline = f))), m !== void 0 && (_ && (G.linethrough = m), J && (D.linethrough = m, H && (K.linethrough = m))), v !== void 0 && (D.textAlign = v), M !== void 0 && (_ && (G.fill = M), J && (D.fill = M, H && (K.fill = M))), S !== void 0 || y !== void 0) {
|
|
4775
|
+
const X = _ ? Ge({ textbox: n, range: _, property: "strokeWidth" }) : void 0, It = _ ? Ge({ textbox: n, range: _, property: "stroke" }) : void 0, Ht = (Bt = (Nt = y != null ? y : X) != null ? Nt : n.strokeWidth) != null ? Bt : 0, mt = Xe({ width: Ht }), Zt = (kt = (ut = S != null ? S : It) != null ? ut : n.stroke) != null ? kt : void 0, Ct = Ve({
|
|
4776
|
+
strokeColor: Zt,
|
|
4799
4777
|
width: mt
|
|
4800
4778
|
});
|
|
4801
|
-
_ && (
|
|
4779
|
+
_ && (G.stroke = Ct, G.strokeWidth = mt), J && (D.stroke = Ct, D.strokeWidth = mt, H && (K.stroke = Ct, K.strokeWidth = mt));
|
|
4802
4780
|
}
|
|
4803
|
-
|
|
4804
|
-
const
|
|
4805
|
-
if (
|
|
4806
|
-
const X = pt ?
|
|
4781
|
+
b !== void 0 && (D.opacity = b), I !== void 0 && (D.backgroundColor = I), j !== void 0 && (D.backgroundOpacity = j), A !== void 0 && (D.paddingTop = A), C !== void 0 && (D.paddingRight = C), w !== void 0 && (D.paddingBottom = w), T !== void 0 && (D.paddingLeft = T), E !== void 0 && (D.radiusTopLeft = E), P !== void 0 && (D.radiusTopRight = P), x !== void 0 && (D.radiusBottomRight = x), N !== void 0 && (D.radiusBottomLeft = N);
|
|
4782
|
+
const q = (it = n.textCaseRaw) != null ? it : (gt = n.text) != null ? gt : "", St = !!n.uppercase, st = c !== void 0, lt = st ? c != null ? c : "" : q, pt = p != null ? p : St;
|
|
4783
|
+
if (st || pt !== St) {
|
|
4784
|
+
const X = pt ? ae({ value: lt }) : lt;
|
|
4807
4785
|
D.text = X, n.textCaseRaw = lt;
|
|
4808
|
-
} else n.textCaseRaw === void 0 && (n.textCaseRaw =
|
|
4786
|
+
} else n.textCaseRaw === void 0 && (n.textCaseRaw = q);
|
|
4809
4787
|
n.uppercase = pt, n.set(D);
|
|
4810
4788
|
let ht = !1;
|
|
4811
4789
|
if (_) {
|
|
4812
|
-
const X =
|
|
4790
|
+
const X = ie({ textbox: n, styles: G, range: _ }), It = W ? ie({ textbox: n, styles: Y, range: W }) : !1;
|
|
4813
4791
|
ht = X || It;
|
|
4814
4792
|
} else if (Object.keys(K).length) {
|
|
4815
4793
|
const X = ro({ textbox: n });
|
|
4816
|
-
X && (ht =
|
|
4794
|
+
X && (ht = ie({ textbox: n, styles: K, range: X }));
|
|
4817
4795
|
}
|
|
4818
|
-
ht && (n.dirty = !0), (
|
|
4819
|
-
const
|
|
4796
|
+
ht && (n.dirty = !0), (I !== void 0 || j !== void 0 || A !== void 0 || C !== void 0 || w !== void 0 || T !== void 0 || E !== void 0 || P !== void 0 || x !== void 0 || N !== void 0) && (n.dirty = !0), F._roundTextboxDimensions({ textbox: n }) && (n.dirty = !0), n.setCoords(), o || a.requestRenderAll(), i.resumeHistory(), s || i.saveState();
|
|
4797
|
+
const Yt = F._getSnapshot(n);
|
|
4820
4798
|
return a.fire("editor:text-updated", {
|
|
4821
4799
|
textbox: n,
|
|
4822
4800
|
target: t,
|
|
@@ -4827,9 +4805,9 @@ class P {
|
|
|
4827
4805
|
},
|
|
4828
4806
|
updates: D,
|
|
4829
4807
|
before: r,
|
|
4830
|
-
after:
|
|
4808
|
+
after: Yt,
|
|
4831
4809
|
selectionRange: _ != null ? _ : void 0,
|
|
4832
|
-
selectionStyles: _ && Object.keys(
|
|
4810
|
+
selectionStyles: _ && Object.keys(G).length ? G : void 0
|
|
4833
4811
|
}), n;
|
|
4834
4812
|
}
|
|
4835
4813
|
/**
|
|
@@ -4837,7 +4815,7 @@ class P {
|
|
|
4837
4815
|
*/
|
|
4838
4816
|
destroy() {
|
|
4839
4817
|
const { canvas: t } = this;
|
|
4840
|
-
t.off("object:scaling", this._handleObjectScaling), t.off("object:resizing",
|
|
4818
|
+
t.off("object:scaling", this._handleObjectScaling), t.off("object:resizing", F._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", F._handleTextChanged);
|
|
4841
4819
|
}
|
|
4842
4820
|
/**
|
|
4843
4821
|
* Возвращает активный текст или ищет по id.
|
|
@@ -4847,10 +4825,10 @@ class P {
|
|
|
4847
4825
|
const { canvas: e } = this;
|
|
4848
4826
|
if (!t) {
|
|
4849
4827
|
const s = e.getActiveObject();
|
|
4850
|
-
return
|
|
4828
|
+
return F._isTextbox(s) ? s : null;
|
|
4851
4829
|
}
|
|
4852
4830
|
if (typeof t == "string") {
|
|
4853
|
-
const s = e.getObjects().find((o) =>
|
|
4831
|
+
const s = e.getObjects().find((o) => F._isTextbox(o) && o.id === t);
|
|
4854
4832
|
return s != null ? s : null;
|
|
4855
4833
|
}
|
|
4856
4834
|
return null;
|
|
@@ -4866,21 +4844,21 @@ class P {
|
|
|
4866
4844
|
*/
|
|
4867
4845
|
_bindEvents() {
|
|
4868
4846
|
const { canvas: t } = this;
|
|
4869
|
-
t.on("object:scaling", this._handleObjectScaling), t.on("object:resizing",
|
|
4847
|
+
t.on("object:scaling", this._handleObjectScaling), t.on("object:resizing", F._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", F._handleTextChanged);
|
|
4870
4848
|
}
|
|
4871
4849
|
/**
|
|
4872
4850
|
* Реагирует на изменение текста в режиме редактирования: синхронизирует textCaseRaw и uppercase.
|
|
4873
4851
|
*/
|
|
4874
4852
|
static _handleTextChanged(t) {
|
|
4875
4853
|
const { target: e } = t;
|
|
4876
|
-
if (!
|
|
4854
|
+
if (!F._isTextbox(e)) return;
|
|
4877
4855
|
const { text: s = "", uppercase: o } = e, n = !!o, i = s.toLocaleLowerCase();
|
|
4878
4856
|
if (n) {
|
|
4879
|
-
const r =
|
|
4857
|
+
const r = ae({ value: i });
|
|
4880
4858
|
r !== s && e.set({ text: r }), e.textCaseRaw = i;
|
|
4881
4859
|
} else
|
|
4882
4860
|
e.textCaseRaw = s;
|
|
4883
|
-
|
|
4861
|
+
F._roundTextboxDimensions({ textbox: e }) && (e.setCoords(), e.dirty = !0);
|
|
4884
4862
|
}
|
|
4885
4863
|
/**
|
|
4886
4864
|
* Обрабатывает изменение ширины текстового объекта (resizing).
|
|
@@ -4891,7 +4869,7 @@ class P {
|
|
|
4891
4869
|
static _handleObjectResizing(t) {
|
|
4892
4870
|
var l, u, g, f, p, m;
|
|
4893
4871
|
const { target: e, transform: s } = t;
|
|
4894
|
-
if (!
|
|
4872
|
+
if (!F._isTextbox(e)) return;
|
|
4895
4873
|
const {
|
|
4896
4874
|
paddingLeft: o = 0,
|
|
4897
4875
|
paddingRight: n = 0
|
|
@@ -4902,10 +4880,10 @@ class P {
|
|
|
4902
4880
|
e.set({ width: r });
|
|
4903
4881
|
const c = (u = e.width) != null ? u : 0, d = a - c;
|
|
4904
4882
|
if (d !== 0 && s && s.corner === "ml") {
|
|
4905
|
-
const
|
|
4883
|
+
const M = ((g = e.angle) != null ? g : 0) * Math.PI / 180, S = Math.cos(M), y = Math.sin(M), b = (f = e.scaleX) != null ? f : 1, I = d * b;
|
|
4906
4884
|
e.set({
|
|
4907
|
-
left: ((p = e.left) != null ? p : 0) +
|
|
4908
|
-
top: ((m = e.top) != null ? m : 0) +
|
|
4885
|
+
left: ((p = e.left) != null ? p : 0) + I * S,
|
|
4886
|
+
top: ((m = e.top) != null ? m : 0) + I * y
|
|
4909
4887
|
});
|
|
4910
4888
|
}
|
|
4911
4889
|
}
|
|
@@ -4931,7 +4909,7 @@ class P {
|
|
|
4931
4909
|
textbox: t,
|
|
4932
4910
|
range: e
|
|
4933
4911
|
}) {
|
|
4934
|
-
const s =
|
|
4912
|
+
const s = F._getLineRanges({ textbox: t });
|
|
4935
4913
|
if (!s.length) return e;
|
|
4936
4914
|
let { start: o } = e, { end: n } = e;
|
|
4937
4915
|
return s.forEach(({ start: i, end: a }) => {
|
|
@@ -4993,10 +4971,10 @@ class P {
|
|
|
4993
4971
|
static _roundTextboxDimensions({
|
|
4994
4972
|
textbox: t
|
|
4995
4973
|
}) {
|
|
4996
|
-
const { width: e, height: s, calcTextWidth: o, calcTextHeight: n } = t, i = typeof o == "function" ? o.call(t) : void 0, a = typeof n == "function" ? n.call(t) : void 0, r =
|
|
4974
|
+
const { width: e, height: s, calcTextWidth: o, calcTextHeight: n } = t, i = typeof o == "function" ? o.call(t) : void 0, a = typeof n == "function" ? n.call(t) : void 0, r = F._resolveDimension({
|
|
4997
4975
|
rawValue: e,
|
|
4998
4976
|
calculatedValue: i
|
|
4999
|
-
}), c =
|
|
4977
|
+
}), c = F._resolveDimension({
|
|
5000
4978
|
rawValue: s,
|
|
5001
4979
|
calculatedValue: a
|
|
5002
4980
|
}), d = Number.isFinite(r) ? Math.round(r) : null, l = Number.isFinite(c) ? Math.round(c) : null, u = {};
|
|
@@ -5007,11 +4985,11 @@ class P {
|
|
|
5007
4985
|
*/
|
|
5008
4986
|
static _getSnapshot(t) {
|
|
5009
4987
|
const e = ({
|
|
5010
|
-
snapshot:
|
|
5011
|
-
entries:
|
|
4988
|
+
snapshot: G,
|
|
4989
|
+
entries: Y
|
|
5012
4990
|
}) => {
|
|
5013
|
-
Object.entries(
|
|
5014
|
-
|
|
4991
|
+
Object.entries(Y).forEach(([K, tt]) => {
|
|
4992
|
+
tt != null && (G[K] = tt);
|
|
5015
4993
|
});
|
|
5016
4994
|
}, {
|
|
5017
4995
|
id: s,
|
|
@@ -5029,30 +5007,30 @@ class P {
|
|
|
5029
5007
|
stroke: p,
|
|
5030
5008
|
strokeWidth: m,
|
|
5031
5009
|
opacity: v,
|
|
5032
|
-
backgroundColor:
|
|
5033
|
-
backgroundOpacity:
|
|
5010
|
+
backgroundColor: M,
|
|
5011
|
+
backgroundOpacity: S,
|
|
5034
5012
|
paddingTop: y,
|
|
5035
|
-
paddingRight:
|
|
5036
|
-
paddingBottom:
|
|
5013
|
+
paddingRight: b,
|
|
5014
|
+
paddingBottom: I,
|
|
5037
5015
|
paddingLeft: j,
|
|
5038
|
-
radiusTopLeft:
|
|
5016
|
+
radiusTopLeft: A,
|
|
5039
5017
|
radiusTopRight: C,
|
|
5040
5018
|
radiusBottomRight: w,
|
|
5041
5019
|
radiusBottomLeft: T,
|
|
5042
5020
|
left: E,
|
|
5043
|
-
top:
|
|
5044
|
-
width:
|
|
5045
|
-
height:
|
|
5046
|
-
angle:
|
|
5021
|
+
top: P,
|
|
5022
|
+
width: x,
|
|
5023
|
+
height: N,
|
|
5024
|
+
angle: Z,
|
|
5047
5025
|
scaleX: D,
|
|
5048
5026
|
scaleY: _
|
|
5049
|
-
} = t,
|
|
5027
|
+
} = t, W = {
|
|
5050
5028
|
id: s,
|
|
5051
5029
|
uppercase: !!i,
|
|
5052
5030
|
textAlign: g
|
|
5053
5031
|
};
|
|
5054
5032
|
return e({
|
|
5055
|
-
snapshot:
|
|
5033
|
+
snapshot: W,
|
|
5056
5034
|
entries: {
|
|
5057
5035
|
text: o,
|
|
5058
5036
|
textCaseRaw: n,
|
|
@@ -5066,25 +5044,25 @@ class P {
|
|
|
5066
5044
|
stroke: p,
|
|
5067
5045
|
strokeWidth: m,
|
|
5068
5046
|
opacity: v,
|
|
5069
|
-
backgroundColor:
|
|
5070
|
-
backgroundOpacity:
|
|
5047
|
+
backgroundColor: M,
|
|
5048
|
+
backgroundOpacity: S,
|
|
5071
5049
|
paddingTop: y,
|
|
5072
|
-
paddingRight:
|
|
5073
|
-
paddingBottom:
|
|
5050
|
+
paddingRight: b,
|
|
5051
|
+
paddingBottom: I,
|
|
5074
5052
|
paddingLeft: j,
|
|
5075
|
-
radiusTopLeft:
|
|
5053
|
+
radiusTopLeft: A,
|
|
5076
5054
|
radiusTopRight: C,
|
|
5077
5055
|
radiusBottomRight: w,
|
|
5078
5056
|
radiusBottomLeft: T,
|
|
5079
5057
|
left: E,
|
|
5080
|
-
top:
|
|
5081
|
-
width:
|
|
5082
|
-
height:
|
|
5083
|
-
angle:
|
|
5058
|
+
top: P,
|
|
5059
|
+
width: x,
|
|
5060
|
+
height: N,
|
|
5061
|
+
angle: Z,
|
|
5084
5062
|
scaleX: D,
|
|
5085
5063
|
scaleY: _
|
|
5086
5064
|
}
|
|
5087
|
-
}),
|
|
5065
|
+
}), W;
|
|
5088
5066
|
}
|
|
5089
5067
|
/**
|
|
5090
5068
|
* Возвращает первый доступный шрифт или дефолтный Arial.
|
|
@@ -5094,15 +5072,15 @@ class P {
|
|
|
5094
5072
|
return (e = (t = this.fonts[0]) == null ? void 0 : t.family) != null ? e : "Arial";
|
|
5095
5073
|
}
|
|
5096
5074
|
}
|
|
5097
|
-
const
|
|
5075
|
+
const Q = ({
|
|
5098
5076
|
value: h,
|
|
5099
5077
|
fallback: t = 0
|
|
5100
|
-
}) => typeof h == "number" && Number.isFinite(h) ? h : typeof t == "number" && Number.isFinite(t) ? t : 0,
|
|
5078
|
+
}) => typeof h == "number" && Number.isFinite(h) ? h : typeof t == "number" && Number.isFinite(t) ? t : 0, Qt = ({
|
|
5101
5079
|
value: h,
|
|
5102
5080
|
dimension: t,
|
|
5103
5081
|
useRelativePositions: e
|
|
5104
5082
|
}) => {
|
|
5105
|
-
const s =
|
|
5083
|
+
const s = Q({ value: h });
|
|
5106
5084
|
return e ? s : s / (t || 1);
|
|
5107
5085
|
}, lo = ({
|
|
5108
5086
|
object: h,
|
|
@@ -5114,26 +5092,26 @@ const ot = ({
|
|
|
5114
5092
|
const n = h;
|
|
5115
5093
|
if (typeof n[o.x] == "number" && typeof n[o.y] == "number")
|
|
5116
5094
|
return {
|
|
5117
|
-
x:
|
|
5095
|
+
x: Qt({
|
|
5118
5096
|
value: n[o.x],
|
|
5119
5097
|
dimension: t,
|
|
5120
5098
|
useRelativePositions: s
|
|
5121
5099
|
}),
|
|
5122
|
-
y:
|
|
5100
|
+
y: Qt({
|
|
5123
5101
|
value: n[o.y],
|
|
5124
5102
|
dimension: e,
|
|
5125
5103
|
useRelativePositions: s
|
|
5126
5104
|
})
|
|
5127
5105
|
};
|
|
5128
|
-
const { left: a, top: r, width: c, height: d } = h, l =
|
|
5106
|
+
const { left: a, top: r, width: c, height: d } = h, l = Qt({
|
|
5129
5107
|
value: a,
|
|
5130
5108
|
dimension: t,
|
|
5131
5109
|
useRelativePositions: s
|
|
5132
|
-
}), u =
|
|
5110
|
+
}), u = Qt({
|
|
5133
5111
|
value: r,
|
|
5134
5112
|
dimension: e,
|
|
5135
5113
|
useRelativePositions: s
|
|
5136
|
-
}), g =
|
|
5114
|
+
}), g = Q({ value: c }) / (t || 1), f = Q({ value: d }) / (e || 1);
|
|
5137
5115
|
return {
|
|
5138
5116
|
x: l + g / 2,
|
|
5139
5117
|
y: u + f / 2
|
|
@@ -5148,10 +5126,10 @@ const ot = ({
|
|
|
5148
5126
|
const { left: n, top: i, width: a, height: r } = e;
|
|
5149
5127
|
if (!o) {
|
|
5150
5128
|
const { width: l, height: u } = s, g = n + h * (l || a), f = i + t * (u || r);
|
|
5151
|
-
return new
|
|
5129
|
+
return new et(g, f);
|
|
5152
5130
|
}
|
|
5153
5131
|
const c = n + h * a, d = i + t * r;
|
|
5154
|
-
return new
|
|
5132
|
+
return new et(c, d);
|
|
5155
5133
|
}, uo = ({
|
|
5156
5134
|
object: h,
|
|
5157
5135
|
montageArea: t,
|
|
@@ -5231,7 +5209,7 @@ const ot = ({
|
|
|
5231
5209
|
};
|
|
5232
5210
|
}
|
|
5233
5211
|
return null;
|
|
5234
|
-
},
|
|
5212
|
+
}, Pt = "_templateCenterX", re = "_templateCenterY", qt = "_templateAnchorX", ce = "_templateAnchorY";
|
|
5235
5213
|
class R {
|
|
5236
5214
|
constructor({ editor: t }) {
|
|
5237
5215
|
this.editor = t;
|
|
@@ -5259,22 +5237,22 @@ class R {
|
|
|
5259
5237
|
code: bt.TEMPLATE_MANAGER.NO_OBJECTS_SELECTED,
|
|
5260
5238
|
message: "Нет объектов для сериализации шаблона"
|
|
5261
5239
|
}), null;
|
|
5262
|
-
const f = R._getBounds(i), p = R._getMontageSize({ montageArea: i, bounds: f }), m = p.width, v = p.height,
|
|
5263
|
-
object:
|
|
5240
|
+
const f = R._getBounds(i), p = R._getMontageSize({ montageArea: i, bounds: f }), m = p.width, v = p.height, M = g.map((b) => R._serializeObject({
|
|
5241
|
+
object: b,
|
|
5264
5242
|
bounds: f,
|
|
5265
5243
|
baseWidth: m,
|
|
5266
5244
|
baseHeight: v,
|
|
5267
5245
|
montageArea: i != null ? i : null
|
|
5268
|
-
})),
|
|
5246
|
+
})), S = yt(B({}, s), {
|
|
5269
5247
|
baseWidth: m,
|
|
5270
5248
|
baseHeight: v,
|
|
5271
5249
|
positionsNormalized: !0,
|
|
5272
5250
|
previewId: e != null ? e : s.previewId
|
|
5273
5251
|
});
|
|
5274
5252
|
return {
|
|
5275
|
-
id: t != null ? t : `template-${
|
|
5276
|
-
meta:
|
|
5277
|
-
objects:
|
|
5253
|
+
id: t != null ? t : `template-${V()}`,
|
|
5254
|
+
meta: S,
|
|
5255
|
+
objects: M
|
|
5278
5256
|
};
|
|
5279
5257
|
}
|
|
5280
5258
|
/**
|
|
@@ -5284,7 +5262,7 @@ class R {
|
|
|
5284
5262
|
* @param options.data - данные для заполнения текстов по customData.templateField
|
|
5285
5263
|
*/
|
|
5286
5264
|
applyTemplate(s) {
|
|
5287
|
-
return
|
|
5265
|
+
return k(this, arguments, function* ({
|
|
5288
5266
|
template: t,
|
|
5289
5267
|
data: e
|
|
5290
5268
|
}) {
|
|
@@ -5311,24 +5289,27 @@ class R {
|
|
|
5311
5289
|
message: "Не удалось определить границы монтажной области"
|
|
5312
5290
|
}), null;
|
|
5313
5291
|
const g = R._getMontageSize({ montageArea: n, bounds: u }), f = R._normalizeMeta({ meta: d, fallback: g }), p = R._calculateScale({ meta: f, target: g }), m = !!f.positionsNormalized;
|
|
5314
|
-
let v = !1,
|
|
5292
|
+
let v = !1, M = !1;
|
|
5315
5293
|
i.suspendHistory();
|
|
5316
5294
|
try {
|
|
5317
|
-
const
|
|
5318
|
-
if (!
|
|
5295
|
+
const S = yield R._enlivenObjects(c);
|
|
5296
|
+
if (!S.length)
|
|
5319
5297
|
return a.emitWarning({
|
|
5320
5298
|
origin: "TemplateManager",
|
|
5321
5299
|
method: "applyTemplate",
|
|
5322
5300
|
code: bt.TEMPLATE_MANAGER.INVALID_TEMPLATE,
|
|
5323
5301
|
message: "Не удалось создать объекты шаблона"
|
|
5324
5302
|
}), null;
|
|
5325
|
-
const { backgroundObject: y, contentObjects:
|
|
5326
|
-
y && (
|
|
5303
|
+
const { backgroundObject: y, contentObjects: b } = R._extractBackgroundObject(S);
|
|
5304
|
+
y && (M = yield R._applyBackgroundFromObject({
|
|
5327
5305
|
backgroundObject: y,
|
|
5328
5306
|
backgroundManager: r,
|
|
5329
5307
|
errorManager: a
|
|
5330
5308
|
}));
|
|
5331
|
-
const
|
|
5309
|
+
const I = b.map((j) => (this._adaptTextboxWidth({
|
|
5310
|
+
object: j,
|
|
5311
|
+
baseWidth: f.baseWidth
|
|
5312
|
+
}), R._transformObject({
|
|
5332
5313
|
object: j,
|
|
5333
5314
|
scale: p,
|
|
5334
5315
|
bounds: u,
|
|
@@ -5338,15 +5319,15 @@ class R {
|
|
|
5338
5319
|
montageArea: n,
|
|
5339
5320
|
useRelativePositions: m
|
|
5340
5321
|
}), j.set({
|
|
5341
|
-
id: `${j.type}-${
|
|
5322
|
+
id: `${j.type}-${V()}`,
|
|
5342
5323
|
evented: !0
|
|
5343
5324
|
}), o.add(j), j));
|
|
5344
|
-
return !
|
|
5325
|
+
return !I.length && !M ? null : (v = I.length > 0 || M, I.length && R._activateObjects({ canvas: o, objects: I }), o.requestRenderAll(), o.fire("editor:template-applied", {
|
|
5345
5326
|
template: t,
|
|
5346
|
-
objects:
|
|
5327
|
+
objects: I,
|
|
5347
5328
|
bounds: u
|
|
5348
|
-
}),
|
|
5349
|
-
} catch (
|
|
5329
|
+
}), I);
|
|
5330
|
+
} catch (S) {
|
|
5350
5331
|
return a.emitError({
|
|
5351
5332
|
origin: "TemplateManager",
|
|
5352
5333
|
method: "applyTemplate",
|
|
@@ -5354,7 +5335,7 @@ class R {
|
|
|
5354
5335
|
message: "Ошибка применения шаблона",
|
|
5355
5336
|
data: {
|
|
5356
5337
|
templateId: l,
|
|
5357
|
-
error:
|
|
5338
|
+
error: S
|
|
5358
5339
|
}
|
|
5359
5340
|
}), null;
|
|
5360
5341
|
} finally {
|
|
@@ -5366,7 +5347,7 @@ class R {
|
|
|
5366
5347
|
* Подготавливает объекты для сериализации.
|
|
5367
5348
|
*/
|
|
5368
5349
|
static _collectObjects(t) {
|
|
5369
|
-
return t ? t instanceof
|
|
5350
|
+
return t ? t instanceof U ? t.getObjects() : [t] : [];
|
|
5370
5351
|
}
|
|
5371
5352
|
/**
|
|
5372
5353
|
* Возвращает габариты объекта.
|
|
@@ -5390,8 +5371,8 @@ class R {
|
|
|
5390
5371
|
* Превращает plain-описание объектов в Fabric объекты.
|
|
5391
5372
|
*/
|
|
5392
5373
|
static _enlivenObjects(t) {
|
|
5393
|
-
return
|
|
5394
|
-
return (yield Promise.all(t.map((s) =>
|
|
5374
|
+
return k(this, null, function* () {
|
|
5375
|
+
return (yield Promise.all(t.map((s) => k(null, null, function* () {
|
|
5395
5376
|
if (R._hasSerializedSvgMarkup(s)) {
|
|
5396
5377
|
const i = yield R._reviveSvgObject(s);
|
|
5397
5378
|
if (i)
|
|
@@ -5426,22 +5407,22 @@ class R {
|
|
|
5426
5407
|
naturalHeight: 0,
|
|
5427
5408
|
width: 0,
|
|
5428
5409
|
height: 0
|
|
5429
|
-
}, p =
|
|
5430
|
-
if (j && (E.width = p),
|
|
5410
|
+
}, p = Q({ value: l || g || c.width, fallback: 0 }), m = Q({ value: u || f || c.height, fallback: 0 }), v = Q({ value: o, fallback: p }), M = Q({ value: n, fallback: m }), S = Q({ value: i, fallback: c.scaleX || 1 }), y = Q({ value: a, fallback: c.scaleY || 1 }), b = v * S, I = M * y, j = p > 0, A = m > 0, C = b > 0, w = I > 0, T = R._resolveImageFit({ customData: r }), E = {};
|
|
5411
|
+
if (j && (E.width = p), A && (E.height = m), !j || !A) {
|
|
5431
5412
|
c.set(E);
|
|
5432
5413
|
return;
|
|
5433
5414
|
}
|
|
5434
5415
|
if (T === "stretch") {
|
|
5435
|
-
const
|
|
5436
|
-
|
|
5416
|
+
const x = C ? b / p : null, N = w ? I / m : null;
|
|
5417
|
+
x && x > 0 && (E.scaleX = x), N && N > 0 && (E.scaleY = N), c.set(E);
|
|
5437
5418
|
return;
|
|
5438
5419
|
}
|
|
5439
5420
|
if (!C || !w) {
|
|
5440
5421
|
c.set(E);
|
|
5441
5422
|
return;
|
|
5442
5423
|
}
|
|
5443
|
-
const
|
|
5444
|
-
Number.isFinite(
|
|
5424
|
+
const P = Math.min(b / p, I / m);
|
|
5425
|
+
Number.isFinite(P) && P > 0 && (E.scaleX = P, E.scaleY = P), c.set(E);
|
|
5445
5426
|
}
|
|
5446
5427
|
/**
|
|
5447
5428
|
* Определяет режим вписывания изображения при восстановлении.
|
|
@@ -5463,11 +5444,11 @@ class R {
|
|
|
5463
5444
|
* Восстанавливает SVG-объект из компактного описания.
|
|
5464
5445
|
*/
|
|
5465
5446
|
static _reviveSvgObject(t) {
|
|
5466
|
-
return
|
|
5447
|
+
return k(this, null, function* () {
|
|
5467
5448
|
const e = typeof t.svgMarkup == "string" ? t.svgMarkup : null;
|
|
5468
5449
|
if (!e) return null;
|
|
5469
5450
|
try {
|
|
5470
|
-
const s = yield
|
|
5451
|
+
const s = yield ms(e), o = dt.groupSVGElements(s.objects, s.options), n = yield dt.enlivenObjectEnlivables(
|
|
5471
5452
|
R._prepareSerializableProps(t)
|
|
5472
5453
|
);
|
|
5473
5454
|
return o.set(n), o.setCoords(), o;
|
|
@@ -5480,7 +5461,7 @@ class R {
|
|
|
5480
5461
|
* Убирает технические поля сериализации, оставляя только применимые свойства.
|
|
5481
5462
|
*/
|
|
5482
5463
|
static _prepareSerializableProps(t) {
|
|
5483
|
-
const e =
|
|
5464
|
+
const e = B({}, t);
|
|
5484
5465
|
return delete e.svgMarkup, delete e.objects, delete e.path, delete e.paths, delete e.type, delete e.version, e;
|
|
5485
5466
|
}
|
|
5486
5467
|
/**
|
|
@@ -5532,28 +5513,28 @@ class R {
|
|
|
5532
5513
|
baseHeight: i,
|
|
5533
5514
|
useRelativePositions: r,
|
|
5534
5515
|
centerKeys: {
|
|
5535
|
-
x:
|
|
5516
|
+
x: Pt,
|
|
5536
5517
|
y: re
|
|
5537
5518
|
}
|
|
5538
|
-
}), { scaleX: u, scaleY: g } = t, f =
|
|
5519
|
+
}), { scaleX: u, scaleY: g } = t, f = Q({ value: u, fallback: 1 }), p = Q({ value: g, fallback: 1 }), m = R._getPositioningBounds({
|
|
5539
5520
|
bounds: s,
|
|
5540
5521
|
baseWidth: n,
|
|
5541
5522
|
baseHeight: i,
|
|
5542
5523
|
scale: e,
|
|
5543
5524
|
useRelativePositions: r,
|
|
5544
|
-
anchorX: R._resolveAnchor(c,
|
|
5545
|
-
anchorY: R._resolveAnchor(c,
|
|
5525
|
+
anchorX: R._resolveAnchor(c, qt),
|
|
5526
|
+
anchorY: R._resolveAnchor(c, ce)
|
|
5546
5527
|
}), v = ho({
|
|
5547
5528
|
normalizedX: d,
|
|
5548
5529
|
normalizedY: l,
|
|
5549
5530
|
bounds: m,
|
|
5550
5531
|
targetSize: o,
|
|
5551
5532
|
montageArea: a
|
|
5552
|
-
}),
|
|
5533
|
+
}), M = f * e, S = p * e;
|
|
5553
5534
|
t.set({
|
|
5554
|
-
scaleX:
|
|
5555
|
-
scaleY:
|
|
5556
|
-
}), t.setPositionByOrigin(v, "center", "center"), t.setCoords(), delete c[
|
|
5535
|
+
scaleX: M,
|
|
5536
|
+
scaleY: S
|
|
5537
|
+
}), t.setPositionByOrigin(v, "center", "center"), t.setCoords(), delete c[Pt], delete c[re], delete c[qt], delete c[ce];
|
|
5557
5538
|
}
|
|
5558
5539
|
/**
|
|
5559
5540
|
* Возвращает bounds, в которых должны позиционироваться нормализованные объекты.
|
|
@@ -5601,7 +5582,7 @@ class R {
|
|
|
5601
5582
|
fallback: e
|
|
5602
5583
|
}) {
|
|
5603
5584
|
const { width: s, height: o } = e, r = t || {}, { baseWidth: n = s, baseHeight: i = o } = r, a = vt(r, ["baseWidth", "baseHeight"]);
|
|
5604
|
-
return
|
|
5585
|
+
return B({
|
|
5605
5586
|
baseWidth: n,
|
|
5606
5587
|
baseHeight: i
|
|
5607
5588
|
}, a);
|
|
@@ -5628,19 +5609,58 @@ class R {
|
|
|
5628
5609
|
t.setActiveObject(e[0]);
|
|
5629
5610
|
return;
|
|
5630
5611
|
}
|
|
5631
|
-
const s = new
|
|
5612
|
+
const s = new U(e, { canvas: t });
|
|
5632
5613
|
t.setActiveObject(s);
|
|
5633
5614
|
}
|
|
5634
5615
|
/**
|
|
5635
|
-
*
|
|
5616
|
+
* Подгоняет ширину текстового объекта под фактическую длину строк, сохраняя выравнивание по якорю.
|
|
5636
5617
|
*/
|
|
5637
|
-
|
|
5618
|
+
_adaptTextboxWidth({
|
|
5638
5619
|
object: t,
|
|
5639
|
-
|
|
5620
|
+
baseWidth: e
|
|
5640
5621
|
}) {
|
|
5641
|
-
|
|
5642
|
-
|
|
5643
|
-
typeof
|
|
5622
|
+
var Z, D;
|
|
5623
|
+
if (!(t instanceof nt)) return;
|
|
5624
|
+
const s = typeof t.text == "string" ? t.text : "";
|
|
5625
|
+
if (!s) return;
|
|
5626
|
+
const o = Q({
|
|
5627
|
+
value: (D = (Z = this.editor) == null ? void 0 : Z.montageArea) == null ? void 0 : D.width,
|
|
5628
|
+
fallback: 0
|
|
5629
|
+
}), {
|
|
5630
|
+
width: n = 0,
|
|
5631
|
+
scaleX: i = 1,
|
|
5632
|
+
strokeWidth: a = 0
|
|
5633
|
+
} = t, r = Q({ value: e, fallback: 0 }), c = t, d = Q({ value: c.paddingLeft, fallback: 0 }), l = Q({ value: c.paddingRight, fallback: 0 }), u = Q({ value: i, fallback: 1 }), g = Q({ value: a, fallback: 0 }) * u, f = Q({ value: n, fallback: 0 }), p = f * u, m = d * u, v = l * u, M = p + m + v + g;
|
|
5634
|
+
if (!o || !f || !r) return;
|
|
5635
|
+
t.setCoords();
|
|
5636
|
+
const S = t, y = S[Pt], b = typeof y == "number" ? y : null, I = R._resolveAnchor(S, qt), j = M / r, A = b !== null ? b - j / 2 : null, C = b !== null ? b + j / 2 : null, w = t.getCenterPoint();
|
|
5637
|
+
t.set("width", o), t.initDimensions();
|
|
5638
|
+
const T = R._getLongestLineWidth({
|
|
5639
|
+
textbox: t,
|
|
5640
|
+
text: s
|
|
5641
|
+
}), E = T > f ? T + 1 : f;
|
|
5642
|
+
t.set("width", E), t.initDimensions(), t.setPositionByOrigin(w, "center", "center"), t.setCoords();
|
|
5643
|
+
const x = (E * u + m + v + g) / r;
|
|
5644
|
+
let N = b;
|
|
5645
|
+
I === "start" && A !== null ? N = Math.max(0, A) + x / 2 : I === "end" && C !== null && (N = Math.min(1, C) - x / 2), typeof N == "number" && (S[Pt] = N);
|
|
5646
|
+
}
|
|
5647
|
+
/**
|
|
5648
|
+
* Возвращает ширину самой длинной строки текстового объекта.
|
|
5649
|
+
*/
|
|
5650
|
+
static _getLongestLineWidth({
|
|
5651
|
+
textbox: t,
|
|
5652
|
+
text: e
|
|
5653
|
+
}) {
|
|
5654
|
+
const {
|
|
5655
|
+
textLines: s
|
|
5656
|
+
} = t, o = Array.isArray(s) && s.length > 0 ? s.length : Math.max(e.split(`
|
|
5657
|
+
`).length, 1);
|
|
5658
|
+
let n = 0;
|
|
5659
|
+
for (let i = 0; i < o; i += 1) {
|
|
5660
|
+
const a = t.getLineWidth(i);
|
|
5661
|
+
a > n && (n = a);
|
|
5662
|
+
}
|
|
5663
|
+
return n;
|
|
5644
5664
|
}
|
|
5645
5665
|
/**
|
|
5646
5666
|
* Сериализует объект относительно монтажной области.
|
|
@@ -5652,7 +5672,7 @@ class R {
|
|
|
5652
5672
|
baseHeight: o,
|
|
5653
5673
|
montageArea: n
|
|
5654
5674
|
}) {
|
|
5655
|
-
const i = t.toDatalessObject([...
|
|
5675
|
+
const i = t.toDatalessObject([...es]);
|
|
5656
5676
|
if (R._isSvgObject(t)) {
|
|
5657
5677
|
const y = R._extractSvgMarkup(t);
|
|
5658
5678
|
y && (i.svgMarkup = y, delete i.objects, delete i.path);
|
|
@@ -5673,15 +5693,15 @@ class R {
|
|
|
5673
5693
|
x: (y.x - a) / u,
|
|
5674
5694
|
y: (y.y - r) / g
|
|
5675
5695
|
};
|
|
5676
|
-
})(), m = (l.left - a) / u, v = (l.top - r) / g,
|
|
5677
|
-
return i[
|
|
5696
|
+
})(), m = (l.left - a) / u, v = (l.top - r) / g, M = m + l.width / u, S = v + l.height / g;
|
|
5697
|
+
return i[Pt] = p.x, i[re] = p.y, i[qt] = R._detectAnchor({
|
|
5678
5698
|
center: p.x,
|
|
5679
5699
|
start: m,
|
|
5680
|
-
end:
|
|
5681
|
-
}), i[
|
|
5700
|
+
end: M
|
|
5701
|
+
}), i[ce] = R._detectAnchor({
|
|
5682
5702
|
center: p.y,
|
|
5683
5703
|
start: v,
|
|
5684
|
-
end:
|
|
5704
|
+
end: S
|
|
5685
5705
|
}), i.left = m, i.top = v, i;
|
|
5686
5706
|
}
|
|
5687
5707
|
/**
|
|
@@ -5698,7 +5718,7 @@ class R {
|
|
|
5698
5718
|
* Применяет фоновый объект шаблона к текущему холсту через BackgroundManager.
|
|
5699
5719
|
*/
|
|
5700
5720
|
static _applyBackgroundFromObject(o) {
|
|
5701
|
-
return
|
|
5721
|
+
return k(this, arguments, function* ({
|
|
5702
5722
|
backgroundObject: t,
|
|
5703
5723
|
backgroundManager: e,
|
|
5704
5724
|
errorManager: s
|
|
@@ -5763,7 +5783,7 @@ class R {
|
|
|
5763
5783
|
*/
|
|
5764
5784
|
static _cloneCustomData(t) {
|
|
5765
5785
|
if (!(!t || typeof t != "object"))
|
|
5766
|
-
return
|
|
5786
|
+
return B({}, t);
|
|
5767
5787
|
}
|
|
5768
5788
|
/**
|
|
5769
5789
|
* Извлекает src изображения из FabricImage или его исходного элемента.
|
|
@@ -5792,7 +5812,7 @@ class R {
|
|
|
5792
5812
|
return dt.enlivenObjectEnlivables(t);
|
|
5793
5813
|
}
|
|
5794
5814
|
}
|
|
5795
|
-
const po = 5,
|
|
5815
|
+
const po = 5, ss = "#3D8BF4", fe = 1, Jt = 1, Ke = ({
|
|
5796
5816
|
anchors: h,
|
|
5797
5817
|
positions: t,
|
|
5798
5818
|
threshold: e
|
|
@@ -5812,11 +5832,11 @@ const po = 5, os = "#3D8BF4", pe = 1, Qt = 1, Qe = ({
|
|
|
5812
5832
|
threshold: t,
|
|
5813
5833
|
anchors: e
|
|
5814
5834
|
}) => {
|
|
5815
|
-
const { left: s, right: o, centerX: n, top: i, bottom: a, centerY: r } = h, c =
|
|
5835
|
+
const { left: s, right: o, centerX: n, top: i, bottom: a, centerY: r } = h, c = Ke({
|
|
5816
5836
|
anchors: e.vertical,
|
|
5817
5837
|
positions: [s, n, o],
|
|
5818
5838
|
threshold: t
|
|
5819
|
-
}), d =
|
|
5839
|
+
}), d = Ke({
|
|
5820
5840
|
anchors: e.horizontal,
|
|
5821
5841
|
positions: [i, r, a],
|
|
5822
5842
|
threshold: t
|
|
@@ -5832,7 +5852,7 @@ const po = 5, os = "#3D8BF4", pe = 1, Qt = 1, Qe = ({
|
|
|
5832
5852
|
deltaY: d.delta,
|
|
5833
5853
|
guides: l
|
|
5834
5854
|
};
|
|
5835
|
-
},
|
|
5855
|
+
}, os = ({
|
|
5836
5856
|
activeBounds: h,
|
|
5837
5857
|
aligned: t,
|
|
5838
5858
|
threshold: e,
|
|
@@ -5923,72 +5943,72 @@ const po = 5, os = "#3D8BF4", pe = 1, Qt = 1, Qe = ({
|
|
|
5923
5943
|
...c.map((y) => ({ bounds: y, isActive: !1 })),
|
|
5924
5944
|
{ bounds: h, isActive: !0 }
|
|
5925
5945
|
];
|
|
5926
|
-
d.sort((y,
|
|
5946
|
+
d.sort((y, b) => y.bounds.top - b.bounds.top);
|
|
5927
5947
|
const l = d.findIndex((y) => y.isActive);
|
|
5928
5948
|
if (l === -1)
|
|
5929
5949
|
return { delta: 0, guide: null };
|
|
5930
5950
|
const u = d[l - 1], g = d[l - 2], f = d[l + 1], p = d[l + 2], m = [], v = i - n;
|
|
5931
5951
|
if (u && g) {
|
|
5932
|
-
const { bounds: y } = u, { bounds:
|
|
5933
|
-
if (
|
|
5934
|
-
const C =
|
|
5952
|
+
const { bounds: y } = u, { bounds: b } = g, I = y.top - b.bottom, j = n - y.bottom, A = Math.abs(j - I);
|
|
5953
|
+
if (A <= e) {
|
|
5954
|
+
const C = I - j, w = n + C, T = {
|
|
5935
5955
|
type: "vertical",
|
|
5936
5956
|
axis: o,
|
|
5937
|
-
refStart:
|
|
5957
|
+
refStart: b.bottom,
|
|
5938
5958
|
refEnd: y.top,
|
|
5939
5959
|
activeStart: y.bottom,
|
|
5940
5960
|
activeEnd: w,
|
|
5941
|
-
distance:
|
|
5961
|
+
distance: I
|
|
5942
5962
|
};
|
|
5943
|
-
m.push({ delta: C, guide: T, diff:
|
|
5963
|
+
m.push({ delta: C, guide: T, diff: A });
|
|
5944
5964
|
}
|
|
5945
5965
|
}
|
|
5946
5966
|
if (f && p) {
|
|
5947
|
-
const { bounds: y } = f, { bounds:
|
|
5948
|
-
if (
|
|
5949
|
-
const C = j -
|
|
5967
|
+
const { bounds: y } = f, { bounds: b } = p, I = b.top - y.bottom, j = y.top - i, A = Math.abs(j - I);
|
|
5968
|
+
if (A <= e) {
|
|
5969
|
+
const C = j - I, w = i + C, T = {
|
|
5950
5970
|
type: "vertical",
|
|
5951
5971
|
axis: o,
|
|
5952
5972
|
refStart: y.bottom,
|
|
5953
|
-
refEnd:
|
|
5973
|
+
refEnd: b.top,
|
|
5954
5974
|
activeStart: w,
|
|
5955
5975
|
activeEnd: y.top,
|
|
5956
|
-
distance:
|
|
5976
|
+
distance: I
|
|
5957
5977
|
};
|
|
5958
|
-
m.push({ delta: C, guide: T, diff:
|
|
5978
|
+
m.push({ delta: C, guide: T, diff: A });
|
|
5959
5979
|
}
|
|
5960
5980
|
}
|
|
5961
5981
|
if (u && f) {
|
|
5962
|
-
const { bounds: y } = u, { bounds:
|
|
5982
|
+
const { bounds: y } = u, { bounds: b } = f, j = b.top - y.bottom - v;
|
|
5963
5983
|
if (j >= 0) {
|
|
5964
|
-
const
|
|
5965
|
-
if (
|
|
5966
|
-
const
|
|
5984
|
+
const A = j / 2, C = n - y.bottom, w = b.top - i, T = Math.abs(C - A), E = Math.abs(w - A), P = Math.max(T, E);
|
|
5985
|
+
if (P <= e) {
|
|
5986
|
+
const x = A - C, N = i + x, Z = {
|
|
5967
5987
|
type: "vertical",
|
|
5968
5988
|
axis: o,
|
|
5969
5989
|
refStart: y.bottom,
|
|
5970
|
-
refEnd: y.bottom +
|
|
5971
|
-
activeStart:
|
|
5972
|
-
activeEnd:
|
|
5973
|
-
distance:
|
|
5990
|
+
refEnd: y.bottom + A,
|
|
5991
|
+
activeStart: N,
|
|
5992
|
+
activeEnd: N + A,
|
|
5993
|
+
distance: A
|
|
5974
5994
|
};
|
|
5975
|
-
m.push({ delta:
|
|
5995
|
+
m.push({ delta: x, guide: Z, diff: P });
|
|
5976
5996
|
}
|
|
5977
5997
|
}
|
|
5978
5998
|
}
|
|
5979
|
-
const
|
|
5999
|
+
const M = os({
|
|
5980
6000
|
activeBounds: h,
|
|
5981
6001
|
aligned: c,
|
|
5982
6002
|
threshold: e,
|
|
5983
6003
|
patterns: s,
|
|
5984
6004
|
type: "vertical"
|
|
5985
6005
|
});
|
|
5986
|
-
if (m.push(...
|
|
6006
|
+
if (m.push(...M), !m.length)
|
|
5987
6007
|
return { delta: 0, guide: null };
|
|
5988
|
-
const
|
|
6008
|
+
const S = m.reduce((y, b) => b.diff < y.diff ? b : y, m[0]);
|
|
5989
6009
|
return {
|
|
5990
|
-
delta:
|
|
5991
|
-
guide:
|
|
6010
|
+
delta: S.delta,
|
|
6011
|
+
guide: S.guide
|
|
5992
6012
|
};
|
|
5993
6013
|
}, vo = ({
|
|
5994
6014
|
activeBounds: h,
|
|
@@ -6009,72 +6029,72 @@ const po = 5, os = "#3D8BF4", pe = 1, Qt = 1, Qe = ({
|
|
|
6009
6029
|
...c.map((y) => ({ bounds: y, isActive: !1 })),
|
|
6010
6030
|
{ bounds: h, isActive: !0 }
|
|
6011
6031
|
];
|
|
6012
|
-
d.sort((y,
|
|
6032
|
+
d.sort((y, b) => y.bounds.left - b.bounds.left);
|
|
6013
6033
|
const l = d.findIndex((y) => y.isActive);
|
|
6014
6034
|
if (l === -1)
|
|
6015
6035
|
return { delta: 0, guide: null };
|
|
6016
6036
|
const u = d[l - 1], g = d[l - 2], f = d[l + 1], p = d[l + 2], m = [], v = i - n;
|
|
6017
6037
|
if (u && g) {
|
|
6018
|
-
const { bounds: y } = u, { bounds:
|
|
6019
|
-
if (
|
|
6020
|
-
const C =
|
|
6038
|
+
const { bounds: y } = u, { bounds: b } = g, I = y.left - b.right, j = n - y.right, A = Math.abs(j - I);
|
|
6039
|
+
if (A <= e) {
|
|
6040
|
+
const C = I - j, w = n + C, T = {
|
|
6021
6041
|
type: "horizontal",
|
|
6022
6042
|
axis: o,
|
|
6023
|
-
refStart:
|
|
6043
|
+
refStart: b.right,
|
|
6024
6044
|
refEnd: y.left,
|
|
6025
6045
|
activeStart: y.right,
|
|
6026
6046
|
activeEnd: w,
|
|
6027
|
-
distance:
|
|
6047
|
+
distance: I
|
|
6028
6048
|
};
|
|
6029
|
-
m.push({ delta: C, guide: T, diff:
|
|
6049
|
+
m.push({ delta: C, guide: T, diff: A });
|
|
6030
6050
|
}
|
|
6031
6051
|
}
|
|
6032
6052
|
if (f && p) {
|
|
6033
|
-
const { bounds: y } = f, { bounds:
|
|
6034
|
-
if (
|
|
6035
|
-
const C = j -
|
|
6053
|
+
const { bounds: y } = f, { bounds: b } = p, I = b.left - y.right, j = y.left - i, A = Math.abs(j - I);
|
|
6054
|
+
if (A <= e) {
|
|
6055
|
+
const C = j - I, w = i + C, T = {
|
|
6036
6056
|
type: "horizontal",
|
|
6037
6057
|
axis: o,
|
|
6038
6058
|
refStart: y.right,
|
|
6039
|
-
refEnd:
|
|
6059
|
+
refEnd: b.left,
|
|
6040
6060
|
activeStart: w,
|
|
6041
6061
|
activeEnd: y.left,
|
|
6042
|
-
distance:
|
|
6062
|
+
distance: I
|
|
6043
6063
|
};
|
|
6044
|
-
m.push({ delta: C, guide: T, diff:
|
|
6064
|
+
m.push({ delta: C, guide: T, diff: A });
|
|
6045
6065
|
}
|
|
6046
6066
|
}
|
|
6047
6067
|
if (u && f) {
|
|
6048
|
-
const { bounds: y } = u, { bounds:
|
|
6068
|
+
const { bounds: y } = u, { bounds: b } = f, j = b.left - y.right - v;
|
|
6049
6069
|
if (j >= 0) {
|
|
6050
|
-
const
|
|
6051
|
-
if (
|
|
6052
|
-
const
|
|
6070
|
+
const A = j / 2, C = n - y.right, w = b.left - i, T = Math.abs(C - A), E = Math.abs(w - A), P = Math.max(T, E);
|
|
6071
|
+
if (P <= e) {
|
|
6072
|
+
const x = A - C, N = i + x, Z = {
|
|
6053
6073
|
type: "horizontal",
|
|
6054
6074
|
axis: o,
|
|
6055
6075
|
refStart: y.right,
|
|
6056
|
-
refEnd: y.right +
|
|
6057
|
-
activeStart:
|
|
6058
|
-
activeEnd:
|
|
6059
|
-
distance:
|
|
6076
|
+
refEnd: y.right + A,
|
|
6077
|
+
activeStart: N,
|
|
6078
|
+
activeEnd: N + A,
|
|
6079
|
+
distance: A
|
|
6060
6080
|
};
|
|
6061
|
-
m.push({ delta:
|
|
6081
|
+
m.push({ delta: x, guide: Z, diff: P });
|
|
6062
6082
|
}
|
|
6063
6083
|
}
|
|
6064
6084
|
}
|
|
6065
|
-
const
|
|
6085
|
+
const M = os({
|
|
6066
6086
|
activeBounds: h,
|
|
6067
6087
|
aligned: c,
|
|
6068
6088
|
threshold: e,
|
|
6069
6089
|
patterns: s,
|
|
6070
6090
|
type: "horizontal"
|
|
6071
6091
|
});
|
|
6072
|
-
if (m.push(...
|
|
6092
|
+
if (m.push(...M), !m.length)
|
|
6073
6093
|
return { delta: 0, guide: null };
|
|
6074
|
-
const
|
|
6094
|
+
const S = m.reduce((y, b) => b.diff < y.diff ? b : y, m[0]);
|
|
6075
6095
|
return {
|
|
6076
|
-
delta:
|
|
6077
|
-
guide:
|
|
6096
|
+
delta: S.delta,
|
|
6097
|
+
guide: S.guide
|
|
6078
6098
|
};
|
|
6079
6099
|
}, bo = ({
|
|
6080
6100
|
activeBounds: h,
|
|
@@ -6108,7 +6128,7 @@ const po = 5, os = "#3D8BF4", pe = 1, Qt = 1, Qe = ({
|
|
|
6108
6128
|
}) => {
|
|
6109
6129
|
const i = Math.min(n, s / 2, o / 2);
|
|
6110
6130
|
h.moveTo(t + i, e), h.lineTo(t + s - i, e), h.quadraticCurveTo(t + s, e, t + s, e + i), h.lineTo(t + s, e + o - i), h.quadraticCurveTo(t + s, e + o, t + s - i, e + o), h.lineTo(t + i, e + o), h.quadraticCurveTo(t, e + o, t, e + o - i), h.lineTo(t, e + i), h.quadraticCurveTo(t, e, t + i, e), h.closePath();
|
|
6111
|
-
},
|
|
6131
|
+
}, pe = ({
|
|
6112
6132
|
context: h,
|
|
6113
6133
|
type: t,
|
|
6114
6134
|
axis: e,
|
|
@@ -6125,17 +6145,17 @@ const po = 5, os = "#3D8BF4", pe = 1, Qt = 1, Qe = ({
|
|
|
6125
6145
|
offsetAlongAxis: g = 0,
|
|
6126
6146
|
offsetPerpendicular: f = 0
|
|
6127
6147
|
}) => {
|
|
6128
|
-
const p = i || 1, m = 12 / p, v = l / p,
|
|
6148
|
+
const p = i || 1, m = 12 / p, v = l / p, M = u / p, S = (s + o) / 2 + g, y = t === "vertical" ? e + f : S, b = t === "vertical" ? S : e + f;
|
|
6129
6149
|
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";
|
|
6130
|
-
const j = h.measureText(n).width + v * 2,
|
|
6150
|
+
const j = h.measureText(n).width + v * 2, A = m + v * 2, C = y - j / 2, w = b - A / 2;
|
|
6131
6151
|
h.beginPath(), Mo({
|
|
6132
6152
|
context: h,
|
|
6133
6153
|
x: C,
|
|
6134
6154
|
y: w,
|
|
6135
6155
|
width: j,
|
|
6136
|
-
height:
|
|
6137
|
-
radius:
|
|
6138
|
-
}), h.fill(), h.fillStyle = r, h.fillText(n, y,
|
|
6156
|
+
height: A,
|
|
6157
|
+
radius: M
|
|
6158
|
+
}), h.fill(), h.fillStyle = r, h.fillText(n, y, b), h.restore();
|
|
6139
6159
|
}, wo = ({
|
|
6140
6160
|
context: h,
|
|
6141
6161
|
guide: t,
|
|
@@ -6151,8 +6171,8 @@ const po = 5, os = "#3D8BF4", pe = 1, Qt = 1, Qe = ({
|
|
|
6151
6171
|
distance: c
|
|
6152
6172
|
} = t, d = Math.round(c).toString();
|
|
6153
6173
|
h.beginPath(), s === "vertical" ? (h.moveTo(o, n), h.lineTo(o, i), h.moveTo(o, a), h.lineTo(o, r)) : (h.moveTo(n, o), h.lineTo(i, o), h.moveTo(a, o), h.lineTo(r, o)), h.stroke();
|
|
6154
|
-
const l =
|
|
6155
|
-
|
|
6174
|
+
const l = ss;
|
|
6175
|
+
pe({
|
|
6156
6176
|
context: h,
|
|
6157
6177
|
type: s,
|
|
6158
6178
|
axis: o,
|
|
@@ -6161,8 +6181,8 @@ const po = 5, os = "#3D8BF4", pe = 1, Qt = 1, Qe = ({
|
|
|
6161
6181
|
text: d,
|
|
6162
6182
|
zoom: e,
|
|
6163
6183
|
color: l,
|
|
6164
|
-
lineWidth:
|
|
6165
|
-
}),
|
|
6184
|
+
lineWidth: fe
|
|
6185
|
+
}), pe({
|
|
6166
6186
|
context: h,
|
|
6167
6187
|
type: s,
|
|
6168
6188
|
axis: o,
|
|
@@ -6171,9 +6191,9 @@ const po = 5, os = "#3D8BF4", pe = 1, Qt = 1, Qe = ({
|
|
|
6171
6191
|
text: d,
|
|
6172
6192
|
zoom: e,
|
|
6173
6193
|
color: l,
|
|
6174
|
-
lineWidth:
|
|
6194
|
+
lineWidth: fe
|
|
6175
6195
|
});
|
|
6176
|
-
},
|
|
6196
|
+
}, Qe = ({
|
|
6177
6197
|
anchors: h,
|
|
6178
6198
|
bounds: t
|
|
6179
6199
|
}) => {
|
|
@@ -6186,7 +6206,7 @@ const po = 5, os = "#3D8BF4", pe = 1, Qt = 1, Qe = ({
|
|
|
6186
6206
|
centerY: a
|
|
6187
6207
|
} = t;
|
|
6188
6208
|
h.vertical.push(e, o, s), h.horizontal.push(n, a, i);
|
|
6189
|
-
},
|
|
6209
|
+
}, qe = ({
|
|
6190
6210
|
bounds: h,
|
|
6191
6211
|
type: t,
|
|
6192
6212
|
primaryStart: e,
|
|
@@ -6199,8 +6219,8 @@ const po = 5, os = "#3D8BF4", pe = 1, Qt = 1, Qe = ({
|
|
|
6199
6219
|
for (let p = r + 1; p < a.length; p += 1) {
|
|
6200
6220
|
const m = a[p];
|
|
6201
6221
|
if (Math.min(c[i], m[i]) - Math.max(c[n], m[n]) < 0) continue;
|
|
6202
|
-
const
|
|
6203
|
-
|
|
6222
|
+
const M = m[e] - c[s];
|
|
6223
|
+
M < 0 || M < l && (l = M, d = m);
|
|
6204
6224
|
}
|
|
6205
6225
|
if (!d || l === Number.POSITIVE_INFINITY) continue;
|
|
6206
6226
|
const u = Math.max(c[n], d[n]), g = Math.min(c[i], d[i]), f = (u + g) / 2;
|
|
@@ -6216,24 +6236,24 @@ const po = 5, os = "#3D8BF4", pe = 1, Qt = 1, Qe = ({
|
|
|
6216
6236
|
}, So = ({
|
|
6217
6237
|
bounds: h
|
|
6218
6238
|
}) => {
|
|
6219
|
-
const t =
|
|
6239
|
+
const t = qe({
|
|
6220
6240
|
bounds: h,
|
|
6221
6241
|
type: "vertical",
|
|
6222
6242
|
primaryStart: "top",
|
|
6223
6243
|
primaryEnd: "bottom"
|
|
6224
|
-
}), e =
|
|
6244
|
+
}), e = qe({
|
|
6225
6245
|
bounds: h,
|
|
6226
6246
|
type: "horizontal",
|
|
6227
6247
|
primaryStart: "left",
|
|
6228
6248
|
primaryEnd: "right"
|
|
6229
6249
|
});
|
|
6230
6250
|
return { vertical: t, horizontal: e };
|
|
6231
|
-
}, Ao = ["montage-area", "background", "interaction-blocker"],
|
|
6251
|
+
}, Ao = ["montage-area", "background", "interaction-blocker"], ns = ({
|
|
6232
6252
|
activeObject: h
|
|
6233
6253
|
}) => {
|
|
6234
6254
|
const t = /* @__PURE__ */ new Set();
|
|
6235
|
-
return h && (t.add(h), h instanceof
|
|
6236
|
-
},
|
|
6255
|
+
return h && (t.add(h), h instanceof U && h.getObjects().forEach((e) => t.add(e))), t;
|
|
6256
|
+
}, is = ({
|
|
6237
6257
|
object: h,
|
|
6238
6258
|
excluded: t,
|
|
6239
6259
|
ignoredIds: e = Ao
|
|
@@ -6313,10 +6333,10 @@ class jo {
|
|
|
6313
6333
|
anchors: this.anchors
|
|
6314
6334
|
}), { deltaX: d, deltaY: l, guides: u } = c;
|
|
6315
6335
|
if (d !== 0 || l !== 0) {
|
|
6316
|
-
const { left: v = 0, top:
|
|
6336
|
+
const { left: v = 0, top: M = 0 } = e;
|
|
6317
6337
|
e.set({
|
|
6318
6338
|
left: v + d,
|
|
6319
|
-
top:
|
|
6339
|
+
top: M + l
|
|
6320
6340
|
}), e.setCoords(), n = (p = ft({ object: e })) != null ? p : n;
|
|
6321
6341
|
}
|
|
6322
6342
|
const g = this.cachedTargetBounds.length ? this.cachedTargetBounds : this._collectTargets({ activeObject: e }).map((v) => ft({ object: v })).filter((v) => !!v), f = bo({
|
|
@@ -6326,10 +6346,10 @@ class jo {
|
|
|
6326
6346
|
spacingPatterns: this.spacingPatterns
|
|
6327
6347
|
});
|
|
6328
6348
|
if (f.deltaX !== 0 || f.deltaY !== 0) {
|
|
6329
|
-
const { left: v = 0, top:
|
|
6349
|
+
const { left: v = 0, top: M = 0 } = e;
|
|
6330
6350
|
e.set({
|
|
6331
6351
|
left: v + f.deltaX,
|
|
6332
|
-
top:
|
|
6352
|
+
top: M + f.deltaY
|
|
6333
6353
|
}), e.setCoords(), n = (m = ft({ object: e })) != null ? m : n;
|
|
6334
6354
|
}
|
|
6335
6355
|
this._applyGuides({
|
|
@@ -6358,7 +6378,7 @@ class jo {
|
|
|
6358
6378
|
const { canvas: t, guideBounds: e } = this, s = t.getSelectionContext();
|
|
6359
6379
|
if (!s) return;
|
|
6360
6380
|
const o = e != null ? e : this._calculateViewportBounds(), { left: n, right: i, top: a, bottom: r } = o, { viewportTransform: c } = t, d = t.getZoom() || 1;
|
|
6361
|
-
s.save(), Array.isArray(c) && s.transform(...c), s.lineWidth =
|
|
6381
|
+
s.save(), Array.isArray(c) && s.transform(...c), s.lineWidth = fe / d, s.strokeStyle = ss, s.setLineDash([4, 4]);
|
|
6362
6382
|
for (const l of this.activeGuides)
|
|
6363
6383
|
s.beginPath(), l.type === "vertical" ? (s.moveTo(l.position, a), s.lineTo(l.position, r)) : (s.moveTo(n, l.position), s.lineTo(i, l.position)), s.stroke();
|
|
6364
6384
|
for (const l of this.activeSpacingGuides)
|
|
@@ -6398,7 +6418,7 @@ class jo {
|
|
|
6398
6418
|
* Применяет шаг перемещения, округляя координаты объекта к сетке MOVE_SNAP_STEP.
|
|
6399
6419
|
*/
|
|
6400
6420
|
_applyMovementStep({ target: t }) {
|
|
6401
|
-
const { left: e = 0, top: s = 0 } = t, o = Math.round(e /
|
|
6421
|
+
const { left: e = 0, top: s = 0 } = t, o = Math.round(e / Jt) * Jt, n = Math.round(s / Jt) * Jt;
|
|
6402
6422
|
o === e && n === s || (t.set({
|
|
6403
6423
|
left: o,
|
|
6404
6424
|
top: n
|
|
@@ -6411,11 +6431,11 @@ class jo {
|
|
|
6411
6431
|
const e = this._collectTargets({ activeObject: t }), s = { vertical: [], horizontal: [] }, o = [];
|
|
6412
6432
|
for (const a of e) {
|
|
6413
6433
|
const r = ft({ object: a });
|
|
6414
|
-
r && (
|
|
6434
|
+
r && (Qe({ anchors: s, bounds: r }), o.push(r));
|
|
6415
6435
|
}
|
|
6416
6436
|
const { montageArea: n } = this.editor, i = ft({ object: n });
|
|
6417
6437
|
if (i) {
|
|
6418
|
-
|
|
6438
|
+
Qe({ anchors: s, bounds: i });
|
|
6419
6439
|
const { left: a, right: r, top: c, bottom: d } = i;
|
|
6420
6440
|
this.guideBounds = {
|
|
6421
6441
|
left: a,
|
|
@@ -6431,9 +6451,9 @@ class jo {
|
|
|
6431
6451
|
* Собирает объекты, подходящие для прилипания, исключая активный объект и запрещённые id.
|
|
6432
6452
|
*/
|
|
6433
6453
|
_collectTargets({ activeObject: t }) {
|
|
6434
|
-
const e =
|
|
6454
|
+
const e = ns({ activeObject: t }), s = [];
|
|
6435
6455
|
return this.canvas.forEachObject((o) => {
|
|
6436
|
-
|
|
6456
|
+
is({ object: o, excluded: e }) || s.push(o);
|
|
6437
6457
|
}), s;
|
|
6438
6458
|
}
|
|
6439
6459
|
/**
|
|
@@ -6456,7 +6476,7 @@ class jo {
|
|
|
6456
6476
|
};
|
|
6457
6477
|
}
|
|
6458
6478
|
}
|
|
6459
|
-
const
|
|
6479
|
+
const Je = "#3D8BF4", $e = 1;
|
|
6460
6480
|
class Lt {
|
|
6461
6481
|
/**
|
|
6462
6482
|
* Создаёт менеджер измерений и инициализирует события.
|
|
@@ -6597,8 +6617,8 @@ class Lt {
|
|
|
6597
6617
|
event: t,
|
|
6598
6618
|
activeObject: e
|
|
6599
6619
|
}) {
|
|
6600
|
-
const { target: s } = t, o =
|
|
6601
|
-
return s && !
|
|
6620
|
+
const { target: s } = t, o = ns({ activeObject: e });
|
|
6621
|
+
return s && !is({ object: s, excluded: o }) ? s : null;
|
|
6602
6622
|
}
|
|
6603
6623
|
/**
|
|
6604
6624
|
* Собирает вертикальные и горизонтальные направляющие расстояний.
|
|
@@ -6639,13 +6659,13 @@ class Lt {
|
|
|
6639
6659
|
top: u = 0,
|
|
6640
6660
|
bottom: g = 0,
|
|
6641
6661
|
centerY: f = 0
|
|
6642
|
-
} = e, p = Math.max(a, u), m = Math.min(r, g),
|
|
6662
|
+
} = e, p = Math.max(a, u), m = Math.min(r, g), M = m >= p ? (p + m) / 2 : (c + f) / 2;
|
|
6643
6663
|
if (d >= i) {
|
|
6644
6664
|
if (s) return o;
|
|
6645
6665
|
const T = d - i;
|
|
6646
6666
|
return T > 0 && o.push({
|
|
6647
6667
|
type: "horizontal",
|
|
6648
|
-
axis:
|
|
6668
|
+
axis: M,
|
|
6649
6669
|
start: i,
|
|
6650
6670
|
end: d,
|
|
6651
6671
|
distance: T
|
|
@@ -6656,26 +6676,26 @@ class Lt {
|
|
|
6656
6676
|
const T = n - l;
|
|
6657
6677
|
return T > 0 && o.push({
|
|
6658
6678
|
type: "horizontal",
|
|
6659
|
-
axis:
|
|
6679
|
+
axis: M,
|
|
6660
6680
|
start: l,
|
|
6661
6681
|
end: n,
|
|
6662
6682
|
distance: T
|
|
6663
6683
|
}), o;
|
|
6664
6684
|
}
|
|
6665
6685
|
if (!s) return o;
|
|
6666
|
-
const
|
|
6667
|
-
j > 0 && !
|
|
6686
|
+
const S = n < d, y = i > l, b = Math.min(n, d), I = Math.max(n, d), j = I - b;
|
|
6687
|
+
j > 0 && !S && o.push({
|
|
6668
6688
|
type: "horizontal",
|
|
6669
|
-
axis:
|
|
6670
|
-
start:
|
|
6671
|
-
end:
|
|
6689
|
+
axis: M,
|
|
6690
|
+
start: b,
|
|
6691
|
+
end: I,
|
|
6672
6692
|
distance: j
|
|
6673
6693
|
});
|
|
6674
|
-
const
|
|
6694
|
+
const A = Math.min(i, l), C = Math.max(i, l), w = C - A;
|
|
6675
6695
|
return w > 0 && !y && o.push({
|
|
6676
6696
|
type: "horizontal",
|
|
6677
|
-
axis:
|
|
6678
|
-
start:
|
|
6697
|
+
axis: M,
|
|
6698
|
+
start: A,
|
|
6679
6699
|
end: C,
|
|
6680
6700
|
distance: w
|
|
6681
6701
|
}), o;
|
|
@@ -6700,13 +6720,13 @@ class Lt {
|
|
|
6700
6720
|
left: u = 0,
|
|
6701
6721
|
right: g = 0,
|
|
6702
6722
|
centerX: f = 0
|
|
6703
|
-
} = e, p = Math.max(a, u), m = Math.min(r, g),
|
|
6723
|
+
} = e, p = Math.max(a, u), m = Math.min(r, g), M = m >= p ? (p + m) / 2 : (c + f) / 2;
|
|
6704
6724
|
if (d >= i) {
|
|
6705
6725
|
if (s) return o;
|
|
6706
6726
|
const T = d - i;
|
|
6707
6727
|
return T > 0 && o.push({
|
|
6708
6728
|
type: "vertical",
|
|
6709
|
-
axis:
|
|
6729
|
+
axis: M,
|
|
6710
6730
|
start: i,
|
|
6711
6731
|
end: d,
|
|
6712
6732
|
distance: T
|
|
@@ -6717,26 +6737,26 @@ class Lt {
|
|
|
6717
6737
|
const T = n - l;
|
|
6718
6738
|
return T > 0 && o.push({
|
|
6719
6739
|
type: "vertical",
|
|
6720
|
-
axis:
|
|
6740
|
+
axis: M,
|
|
6721
6741
|
start: l,
|
|
6722
6742
|
end: n,
|
|
6723
6743
|
distance: T
|
|
6724
6744
|
}), o;
|
|
6725
6745
|
}
|
|
6726
6746
|
if (!s) return o;
|
|
6727
|
-
const
|
|
6728
|
-
j > 0 && !
|
|
6747
|
+
const S = n < d, y = i > l, b = Math.min(n, d), I = Math.max(n, d), j = I - b;
|
|
6748
|
+
j > 0 && !S && o.push({
|
|
6729
6749
|
type: "vertical",
|
|
6730
|
-
axis:
|
|
6731
|
-
start:
|
|
6732
|
-
end:
|
|
6750
|
+
axis: M,
|
|
6751
|
+
start: b,
|
|
6752
|
+
end: I,
|
|
6733
6753
|
distance: j
|
|
6734
6754
|
});
|
|
6735
|
-
const
|
|
6755
|
+
const A = Math.min(i, l), C = Math.max(i, l), w = C - A;
|
|
6736
6756
|
return w > 0 && !y && o.push({
|
|
6737
6757
|
type: "vertical",
|
|
6738
|
-
axis:
|
|
6739
|
-
start:
|
|
6758
|
+
axis: M,
|
|
6759
|
+
start: A,
|
|
6740
6760
|
end: C,
|
|
6741
6761
|
distance: w
|
|
6742
6762
|
}), o;
|
|
@@ -6766,10 +6786,10 @@ class Lt {
|
|
|
6766
6786
|
const { canvas: t } = this, e = t.getSelectionContext();
|
|
6767
6787
|
if (!e) return;
|
|
6768
6788
|
const { viewportTransform: s } = t, o = t.getZoom() || 1, n = this.activeGuides.some((c) => c.type === "vertical"), i = this.activeGuides.some((c) => c.type === "horizontal"), a = n && i && !this.isTargetMontageArea, r = a ? 12 / o : 0;
|
|
6769
|
-
e.save(), Array.isArray(s) && e.transform(...s), e.lineWidth =
|
|
6789
|
+
e.save(), Array.isArray(s) && e.transform(...s), e.lineWidth = $e / o, e.strokeStyle = Je, e.setLineDash([]);
|
|
6770
6790
|
for (const c of this.activeGuides) {
|
|
6771
|
-
const { type: d, axis: l, start: u, end: g, distance: f } = c, p = Math.abs(g - u), m = u <= g ? -1 : 1, v = a ? m * (p / 2 + r) : 0,
|
|
6772
|
-
e.beginPath(), d === "vertical" ? (e.moveTo(l, u), e.lineTo(l, g)) : (e.moveTo(u, l), e.lineTo(g, l)), e.stroke(),
|
|
6791
|
+
const { type: d, axis: l, start: u, end: g, distance: f } = c, p = Math.abs(g - u), m = u <= g ? -1 : 1, v = a ? m * (p / 2 + r) : 0, M = 0;
|
|
6792
|
+
e.beginPath(), d === "vertical" ? (e.moveTo(l, u), e.lineTo(l, g)) : (e.moveTo(u, l), e.lineTo(g, l)), e.stroke(), pe({
|
|
6773
6793
|
context: e,
|
|
6774
6794
|
type: d,
|
|
6775
6795
|
axis: l,
|
|
@@ -6777,10 +6797,10 @@ class Lt {
|
|
|
6777
6797
|
end: g,
|
|
6778
6798
|
text: Math.round(f).toString(),
|
|
6779
6799
|
zoom: o,
|
|
6780
|
-
color:
|
|
6781
|
-
lineWidth:
|
|
6800
|
+
color: Je,
|
|
6801
|
+
lineWidth: $e,
|
|
6782
6802
|
offsetAlongAxis: v,
|
|
6783
|
-
offsetPerpendicular:
|
|
6803
|
+
offsetPerpendicular: M
|
|
6784
6804
|
});
|
|
6785
6805
|
}
|
|
6786
6806
|
e.restore();
|
|
@@ -6804,14 +6824,14 @@ class Lt {
|
|
|
6804
6824
|
(e = t == null ? void 0 : t.showAfterTemporary) == null || e.call(t), this.isToolbarHidden = !1;
|
|
6805
6825
|
}
|
|
6806
6826
|
}
|
|
6807
|
-
class
|
|
6827
|
+
class we {
|
|
6808
6828
|
/**
|
|
6809
6829
|
* Конструктор класса ImageEditor.
|
|
6810
6830
|
* @param canvasId - идентификатор канваса, в котором будет создан редактор
|
|
6811
6831
|
* @param options - опции и настройки редактора
|
|
6812
6832
|
*/
|
|
6813
6833
|
constructor(t, e) {
|
|
6814
|
-
this.options = e, this.containerId = t, this.editorId = `${t}-${
|
|
6834
|
+
this.options = e, this.containerId = t, this.editorId = `${t}-${V()}`, this.clipboard = null, this.init();
|
|
6815
6835
|
}
|
|
6816
6836
|
/**
|
|
6817
6837
|
* Инициализация редактора.
|
|
@@ -6819,7 +6839,7 @@ class Se {
|
|
|
6819
6839
|
* @fires editor:ready
|
|
6820
6840
|
*/
|
|
6821
6841
|
init() {
|
|
6822
|
-
return
|
|
6842
|
+
return k(this, null, function* () {
|
|
6823
6843
|
var u;
|
|
6824
6844
|
const {
|
|
6825
6845
|
editorContainerWidth: t,
|
|
@@ -6834,7 +6854,7 @@ class Se {
|
|
|
6834
6854
|
showRotationAngle: d,
|
|
6835
6855
|
_onReadyCallback: l
|
|
6836
6856
|
} = this.options;
|
|
6837
|
-
if (
|
|
6857
|
+
if ($.apply(), this.canvas = new ys(this.containerId, this.options), this.moduleLoader = new Ss(), this.workerManager = new js(), this.errorManager = new Wt({ editor: this }), this.historyManager = new Ys({ editor: this }), this.toolbar = new Ps({ editor: this }), this.transformManager = new qs({ editor: this }), this.zoomManager = new Js({ editor: this }), this.canvasManager = new Qs({ editor: this }), this.imageManager = new ct({ editor: this }), this.layerManager = new te({ editor: this }), this.shapeManager = new to({ editor: this }), this.interactionBlocker = new $s({ editor: this }), this.backgroundManager = new Ot({ editor: this }), this.clipboardManager = new eo({ editor: this }), this.objectLockManager = new ee({ editor: this }), this.groupingManager = new so({ editor: this }), this.selectionManager = new oo({ editor: this }), this.deletionManager = new Me({ editor: this }), this.panConstraintManager = new no({ editor: this }), this.snappingManager = new jo({ editor: this }), this.measurementManager = new Lt({ editor: this }), this.fontManager = new ge((u = this.options.fonts) != null ? u : []), this.textManager = new F({ editor: this }), this.templateManager = new R({ editor: this }), d && (this.angleIndicator = new be({ editor: this })), this._createMontageArea(), this._createClippingArea(), this.listeners = new Ft({ editor: this, options: this.options }), this.canvasManager.setEditorContainerWidth(t), this.canvasManager.setEditorContainerHeight(e), this.canvasManager.setCanvasWrapperWidth(s), this.canvasManager.setCanvasWrapperHeight(o), this.canvasManager.setCanvasCSSWidth(n), this.canvasManager.setCanvasCSSHeight(i), this.canvasManager.updateCanvas(), this.zoomManager.calculateAndApplyDefaultZoom(), yield this.fontManager.loadFonts(), a != null && a.source) {
|
|
6838
6858
|
const {
|
|
6839
6859
|
source: g,
|
|
6840
6860
|
scale: f = `image-${c}`,
|
|
@@ -6856,7 +6876,7 @@ class Se {
|
|
|
6856
6876
|
this.montageArea = this.shapeManager.addRectangle({
|
|
6857
6877
|
width: t,
|
|
6858
6878
|
height: e,
|
|
6859
|
-
fill:
|
|
6879
|
+
fill: we._createMosaicPattern(),
|
|
6860
6880
|
stroke: null,
|
|
6861
6881
|
strokeWidth: 0,
|
|
6862
6882
|
selectable: !1,
|
|
@@ -6907,7 +6927,7 @@ class Se {
|
|
|
6907
6927
|
const t = document.createElement("canvas");
|
|
6908
6928
|
t.width = 20, t.height = 20;
|
|
6909
6929
|
const e = t.getContext("2d");
|
|
6910
|
-
return e.fillStyle = "#ddd", e.fillRect(0, 0, 40, 40), e.fillStyle = "#ccc", e.fillRect(0, 0, 10, 10), e.fillRect(10, 10, 10, 10), new
|
|
6930
|
+
return e.fillStyle = "#ddd", e.fillRect(0, 0, 40, 40), e.fillStyle = "#ccc", e.fillRect(0, 0, 10, 10), e.fillRect(10, 10, 10, 10), new vs({
|
|
6911
6931
|
source: t,
|
|
6912
6932
|
repeat: "repeat"
|
|
6913
6933
|
});
|
|
@@ -6915,29 +6935,42 @@ class Se {
|
|
|
6915
6935
|
}
|
|
6916
6936
|
const O = [
|
|
6917
6937
|
"U+0000-00FF",
|
|
6918
|
-
"U+
|
|
6919
|
-
"U+0152-0153",
|
|
6938
|
+
"U+0100-02BA",
|
|
6920
6939
|
"U+02BB-02BC",
|
|
6940
|
+
"U+02BD-02C5",
|
|
6941
|
+
"U+02C7-02CC",
|
|
6942
|
+
"U+02CE-02D7",
|
|
6943
|
+
"U+02DD-02FF",
|
|
6921
6944
|
"U+02C6",
|
|
6922
|
-
"U+02DA",
|
|
6923
6945
|
"U+02DC",
|
|
6924
6946
|
"U+0304",
|
|
6925
6947
|
"U+0308",
|
|
6926
6948
|
"U+0329",
|
|
6949
|
+
"U+1D00-1DBF",
|
|
6950
|
+
"U+1E00-1E9F",
|
|
6951
|
+
"U+1EF2-1EFF",
|
|
6927
6952
|
"U+2000-206F",
|
|
6928
|
-
"U+
|
|
6953
|
+
"U+2020",
|
|
6954
|
+
"U+20A0-20AB",
|
|
6955
|
+
"U+20AD-20C0",
|
|
6956
|
+
"U+2113",
|
|
6929
6957
|
"U+2122",
|
|
6930
6958
|
"U+2191",
|
|
6931
6959
|
"U+2193",
|
|
6932
6960
|
"U+2212",
|
|
6933
6961
|
"U+2215",
|
|
6962
|
+
"U+2C60-2C7F",
|
|
6963
|
+
"U+A720-A7FF",
|
|
6934
6964
|
"U+FEFF",
|
|
6935
6965
|
"U+FFFD"
|
|
6936
6966
|
].join(", "), L = [
|
|
6937
6967
|
"U+0301",
|
|
6938
|
-
"U+0400-
|
|
6939
|
-
"U+
|
|
6940
|
-
"U+
|
|
6968
|
+
"U+0400-052F",
|
|
6969
|
+
"U+1C80-1C8A",
|
|
6970
|
+
"U+20B4",
|
|
6971
|
+
"U+2DE0-2DFF",
|
|
6972
|
+
"U+A640-A69F",
|
|
6973
|
+
"U+FE2E-FE2F",
|
|
6941
6974
|
"U+2116"
|
|
6942
6975
|
].join(", "), Io = [
|
|
6943
6976
|
{
|
|
@@ -7824,13 +7857,13 @@ const O = [
|
|
|
7824
7857
|
fonts: Io
|
|
7825
7858
|
};
|
|
7826
7859
|
function Do(h, t = {}) {
|
|
7827
|
-
const e =
|
|
7860
|
+
const e = B(B({}, Co), t), s = document.getElementById(h);
|
|
7828
7861
|
if (!s)
|
|
7829
7862
|
return Promise.reject(new Error(`Контейнер с ID "${h}" не найден.`));
|
|
7830
7863
|
const o = document.createElement("canvas");
|
|
7831
7864
|
return o.id = `${h}-canvas`, s.appendChild(o), e.editorContainer = s, new Promise((n) => {
|
|
7832
7865
|
e._onReadyCallback = n;
|
|
7833
|
-
const i = new
|
|
7866
|
+
const i = new we(o.id, e);
|
|
7834
7867
|
window[h] = i;
|
|
7835
7868
|
});
|
|
7836
7869
|
}
|