@anu3ev/fabric-image-editor 0.5.2 → 0.5.4
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 +619 -572
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
1
|
+
var ds = Object.defineProperty, ls = Object.defineProperties;
|
|
2
|
+
var hs = Object.getOwnPropertyDescriptors;
|
|
3
3
|
var Wt = Object.getOwnPropertySymbols;
|
|
4
|
-
var
|
|
5
|
-
var
|
|
4
|
+
var _e = Object.prototype.hasOwnProperty, Ne = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var Re = (h, t, e) => t in h ? ds(h, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : h[t] = e, x = (h, t) => {
|
|
6
6
|
for (var e in t || (t = {}))
|
|
7
|
-
|
|
7
|
+
_e.call(t, e) && Re(h, e, t[e]);
|
|
8
8
|
if (Wt)
|
|
9
9
|
for (var e of Wt(t))
|
|
10
|
-
|
|
10
|
+
Ne.call(t, e) && Re(h, e, t[e]);
|
|
11
11
|
return h;
|
|
12
|
-
},
|
|
13
|
-
var
|
|
12
|
+
}, St = (h, t) => ls(h, hs(t));
|
|
13
|
+
var gt = (h, t) => {
|
|
14
14
|
var e = {};
|
|
15
15
|
for (var s in h)
|
|
16
|
-
|
|
16
|
+
_e.call(h, s) && t.indexOf(s) < 0 && (e[s] = h[s]);
|
|
17
17
|
if (h != null && Wt)
|
|
18
18
|
for (var s of Wt(h))
|
|
19
|
-
t.indexOf(s) < 0 &&
|
|
19
|
+
t.indexOf(s) < 0 && Ne.call(h, s) && (e[s] = h[s]);
|
|
20
20
|
return e;
|
|
21
21
|
};
|
|
22
22
|
var _ = (h, t, e) => new Promise((s, o) => {
|
|
@@ -35,15 +35,15 @@ var _ = (h, t, e) => new Promise((s, o) => {
|
|
|
35
35
|
}, a = (r) => r.done ? s(r.value) : Promise.resolve(r.value).then(n, i);
|
|
36
36
|
a((e = e.apply(h, t)).next());
|
|
37
37
|
});
|
|
38
|
-
import { ActiveSelection as
|
|
39
|
-
import { create as
|
|
40
|
-
import
|
|
41
|
-
var
|
|
38
|
+
import { ActiveSelection as k, Textbox as st, util as ct, controlsUtils as xe, InteractiveFabricObject as ke, Point as J, FitContentLayout as Be, loadSVGFromURL as us, FabricImage as xt, Gradient as ze, Rect as gs, Circle as fs, Triangle as ps, Group as jt, Color as ms, classRegistry as Pe, loadSVGFromString as ys, Canvas as vs, Pattern as bs } from "fabric";
|
|
39
|
+
import { create as Ms } from "jsondiffpatch";
|
|
40
|
+
import ws from "diff-match-patch";
|
|
41
|
+
var Ss = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", F = 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 += Ss[s[t] & 63];
|
|
44
44
|
return e;
|
|
45
45
|
};
|
|
46
|
-
class
|
|
46
|
+
class Bt {
|
|
47
47
|
/**
|
|
48
48
|
* Конструктор принимает редактор и опции.
|
|
49
49
|
* @param params
|
|
@@ -61,7 +61,7 @@ class xt {
|
|
|
61
61
|
* @param params.options.adaptCanvasToContainerOnResize — адаптировать канвас к размерам контейнера при изменении размеров окна
|
|
62
62
|
*/
|
|
63
63
|
constructor({ editor: t, options: e = {} }) {
|
|
64
|
-
this.isDragging = !1, this.lastMouseX = 0, this.lastMouseY = 0, this.isUndoRedoKeyPressed = !1, this.isSpacePressed = !1, this.savedSelection = [], this.canvasDragging = !1, this.mouseWheelZooming = !1, this.bringToFrontOnSelection = !1, this.resetObjectFitByDoubleClick = !1, this.copyObjectsByHotkey = !1, this.pasteImageFromClipboard = !1, this.undoRedoByHotKeys = !1, this.selectAllByHotkey = !1, this.deleteObjectsByHotkey = !1, this.adaptCanvasToContainerOnResize = !1, this.editor = t, this.canvas = t.canvas, this.options = e, this.handleContainerResizeBound =
|
|
64
|
+
this.isDragging = !1, this.lastMouseX = 0, this.lastMouseY = 0, this.isUndoRedoKeyPressed = !1, this.isSpacePressed = !1, this.savedSelection = [], this.canvasDragging = !1, this.mouseWheelZooming = !1, this.bringToFrontOnSelection = !1, this.resetObjectFitByDoubleClick = !1, this.copyObjectsByHotkey = !1, this.pasteImageFromClipboard = !1, this.undoRedoByHotKeys = !1, this.selectAllByHotkey = !1, this.deleteObjectsByHotkey = !1, this.adaptCanvasToContainerOnResize = !1, this.editor = t, this.canvas = t.canvas, this.options = e, this.handleContainerResizeBound = Bt.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 = Bt.debounce(this.handleObjectModifiedHistory.bind(this), 300), this.handleObjectRotatingHistoryBound = Bt.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 xt {
|
|
|
98
98
|
if (o.length === 1)
|
|
99
99
|
this.canvas.setActiveObject(o[0]);
|
|
100
100
|
else {
|
|
101
|
-
const i = new
|
|
101
|
+
const i = new k(o, {
|
|
102
102
|
canvas: this.canvas
|
|
103
103
|
});
|
|
104
104
|
this.canvas.setActiveObject(i);
|
|
@@ -106,7 +106,7 @@ class xt {
|
|
|
106
106
|
this.canvas.requestRenderAll();
|
|
107
107
|
return;
|
|
108
108
|
}
|
|
109
|
-
const n = new
|
|
109
|
+
const n = new k(t, {
|
|
110
110
|
canvas: this.canvas
|
|
111
111
|
});
|
|
112
112
|
this.editor.objectLockManager.lockObject({
|
|
@@ -220,7 +220,7 @@ class xt {
|
|
|
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 k ? 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 xt {
|
|
|
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 k(o, { canvas: e });
|
|
263
263
|
e.setActiveObject(n);
|
|
264
264
|
}
|
|
265
265
|
// --- Обработчики для событий canvas (Fabric) ---
|
|
@@ -391,7 +391,7 @@ class xt {
|
|
|
391
391
|
};
|
|
392
392
|
}
|
|
393
393
|
}
|
|
394
|
-
class
|
|
394
|
+
class As {
|
|
395
395
|
/**
|
|
396
396
|
* Класс для динамической загрузки внешних модулей.
|
|
397
397
|
*/
|
|
@@ -409,7 +409,7 @@ class Ms {
|
|
|
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 js(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 ws(h) {
|
|
|
417
417
|
}
|
|
418
418
|
);
|
|
419
419
|
}
|
|
420
|
-
class
|
|
420
|
+
class Is {
|
|
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 js(), this._callbacks = /* @__PURE__ */ new Map(), this.worker.onmessage = this._handleMessage.bind(this);
|
|
427
427
|
}
|
|
428
428
|
/**
|
|
429
429
|
* Обработчик сообщений от воркера
|
|
@@ -451,7 +451,7 @@ class Ss {
|
|
|
451
451
|
* @returns Promise, который будет выполнен, когда воркер вернет ответ
|
|
452
452
|
*/
|
|
453
453
|
post(t, e, s = []) {
|
|
454
|
-
const o = `${t}:${
|
|
454
|
+
const o = `${t}:${F(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,65 +463,65 @@ class Ss {
|
|
|
463
463
|
this.worker.terminate();
|
|
464
464
|
}
|
|
465
465
|
}
|
|
466
|
-
const
|
|
466
|
+
const at = 12, Cs = 2, ce = 8, de = 20, Ts = 100, le = 20, he = 8, Es = 100, Kt = 32, pe = 1, Os = "#2B2D33", me = "#3D8BF4", ye = "#FFFFFF";
|
|
467
467
|
function Zt(h, t, e, s, o) {
|
|
468
|
-
const n =
|
|
469
|
-
h.save(), h.translate(t, e), h.rotate(
|
|
468
|
+
const n = at, i = Cs;
|
|
469
|
+
h.save(), h.translate(t, e), h.rotate(ct.degreesToRadians(o.angle)), h.fillStyle = ye, h.strokeStyle = me, h.lineWidth = pe, h.beginPath(), h.roundRect(-n / 2, -n / 2, n, n, i), h.fill(), h.stroke(), h.restore();
|
|
470
470
|
}
|
|
471
|
-
function
|
|
472
|
-
const n = ce, i = de, a =
|
|
473
|
-
h.save(), h.translate(t, e), h.rotate(
|
|
471
|
+
function Ue(h, t, e, s, o) {
|
|
472
|
+
const n = ce, i = de, a = Ts;
|
|
473
|
+
h.save(), h.translate(t, e), h.rotate(ct.degreesToRadians(o.angle)), h.fillStyle = ye, h.strokeStyle = me, h.lineWidth = pe, h.beginPath(), h.roundRect(-n / 2, -i / 2, n, i, a), h.fill(), h.stroke(), h.restore();
|
|
474
474
|
}
|
|
475
|
-
function
|
|
476
|
-
const n = le, i = he, a =
|
|
477
|
-
h.save(), h.translate(t, e), h.rotate(
|
|
475
|
+
function Ye(h, t, e, s, o) {
|
|
476
|
+
const n = le, i = he, a = Es;
|
|
477
|
+
h.save(), h.translate(t, e), h.rotate(ct.degreesToRadians(o.angle)), h.fillStyle = ye, h.strokeStyle = me, h.lineWidth = pe, 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(
|
|
479
|
+
const Ds = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTE4Ljc1IDQuMzc1djMuNzVhLjYyNS42MjUgMCAwIDEtLjYyNS42MjVoLTMuNzVhLjYyNS42MjUgMCAwIDEgMC0xLjI1aDIuMTRsLTIuMDc3LTEuOTAzLS4wMi0uMDE5YTYuMjUgNi4yNSAwIDEgMC0uMTMgOC45NjcuNjI2LjYyNiAwIDAgMSAuODYuOTA5QTcuNDU2IDcuNDU2IDAgMCAxIDEwIDE3LjVoLS4xMDNhNy41IDcuNSAwIDEgMSA1LjM5Ni0xMi44MTJMMTcuNSA2LjcwM1Y0LjM3NWEuNjI1LjYyNSAwIDAgMSAxLjI1IDBaIi8+PC9zdmc+", es = new Image();
|
|
480
|
+
es.src = Ds;
|
|
481
|
+
function Ls(h, t, e, s, o) {
|
|
482
|
+
const i = Kt / 2;
|
|
483
|
+
h.save(), h.translate(t, e), h.rotate(ct.degreesToRadians(o.angle)), h.fillStyle = Os, h.beginPath(), h.arc(0, 0, i, 0, 2 * Math.PI), h.fill(), h.drawImage(es, -i / 2, -i / 2, i, i), h.restore();
|
|
484
484
|
}
|
|
485
|
-
const
|
|
485
|
+
const Rs = {
|
|
486
486
|
// Угловые точки
|
|
487
487
|
tl: {
|
|
488
488
|
render: Zt,
|
|
489
|
-
sizeX:
|
|
490
|
-
sizeY:
|
|
489
|
+
sizeX: at,
|
|
490
|
+
sizeY: at,
|
|
491
491
|
offsetX: 0,
|
|
492
492
|
offsetY: 0
|
|
493
493
|
},
|
|
494
494
|
tr: {
|
|
495
495
|
render: Zt,
|
|
496
|
-
sizeX:
|
|
497
|
-
sizeY:
|
|
496
|
+
sizeX: at,
|
|
497
|
+
sizeY: at,
|
|
498
498
|
offsetX: 0,
|
|
499
499
|
offsetY: 0
|
|
500
500
|
},
|
|
501
501
|
bl: {
|
|
502
502
|
render: Zt,
|
|
503
|
-
sizeX:
|
|
504
|
-
sizeY:
|
|
503
|
+
sizeX: at,
|
|
504
|
+
sizeY: at,
|
|
505
505
|
offsetX: 0,
|
|
506
506
|
offsetY: 0
|
|
507
507
|
},
|
|
508
508
|
br: {
|
|
509
509
|
render: Zt,
|
|
510
|
-
sizeX:
|
|
511
|
-
sizeY:
|
|
510
|
+
sizeX: at,
|
|
511
|
+
sizeY: at,
|
|
512
512
|
offsetX: 0,
|
|
513
513
|
offsetY: 0
|
|
514
514
|
},
|
|
515
515
|
// Середина вертикалей
|
|
516
516
|
ml: {
|
|
517
|
-
render:
|
|
517
|
+
render: Ue,
|
|
518
518
|
sizeX: ce,
|
|
519
519
|
sizeY: de,
|
|
520
520
|
offsetX: 0,
|
|
521
521
|
offsetY: 0
|
|
522
522
|
},
|
|
523
523
|
mr: {
|
|
524
|
-
render:
|
|
524
|
+
render: Ue,
|
|
525
525
|
sizeX: ce,
|
|
526
526
|
sizeY: de,
|
|
527
527
|
offsetX: 0,
|
|
@@ -529,14 +529,14 @@ const Os = {
|
|
|
529
529
|
},
|
|
530
530
|
// Середина горизонталей
|
|
531
531
|
mt: {
|
|
532
|
-
render:
|
|
532
|
+
render: Ye,
|
|
533
533
|
sizeX: le,
|
|
534
534
|
sizeY: he,
|
|
535
535
|
offsetX: 0,
|
|
536
536
|
offsetY: 0
|
|
537
537
|
},
|
|
538
538
|
mb: {
|
|
539
|
-
render:
|
|
539
|
+
render: Ye,
|
|
540
540
|
sizeX: le,
|
|
541
541
|
sizeY: he,
|
|
542
542
|
offsetX: 0,
|
|
@@ -544,14 +544,14 @@ const Os = {
|
|
|
544
544
|
},
|
|
545
545
|
// Специальный «rotate» контрол
|
|
546
546
|
mtr: {
|
|
547
|
-
render:
|
|
548
|
-
sizeX:
|
|
549
|
-
sizeY:
|
|
547
|
+
render: Ls,
|
|
548
|
+
sizeX: Kt,
|
|
549
|
+
sizeY: Kt,
|
|
550
550
|
offsetX: 0,
|
|
551
|
-
offsetY: -
|
|
551
|
+
offsetY: -Kt
|
|
552
552
|
}
|
|
553
553
|
};
|
|
554
|
-
class
|
|
554
|
+
class $ {
|
|
555
555
|
/**
|
|
556
556
|
* Отключает изменение ширины по оси X для заблокированных объектов, сохраняя поведение остального хэндлера.
|
|
557
557
|
*/
|
|
@@ -567,7 +567,7 @@ class Q {
|
|
|
567
567
|
* Применяет конфигурацию контролов к набору по ключам из DEFAULT_CONTROLS.
|
|
568
568
|
*/
|
|
569
569
|
static applyControlOverrides(t) {
|
|
570
|
-
Object.entries(
|
|
570
|
+
Object.entries(Rs).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;
|
|
@@ -580,24 +580,24 @@ class Q {
|
|
|
580
580
|
* Регистрирует контролы и настройки поведения выделений.
|
|
581
581
|
*/
|
|
582
582
|
static apply() {
|
|
583
|
-
const t =
|
|
584
|
-
|
|
585
|
-
const e =
|
|
586
|
-
|
|
583
|
+
const t = xe.createObjectDefaultControls();
|
|
584
|
+
$.applyControlOverrides(t), ke.ownDefaults.controls = t;
|
|
585
|
+
const e = xe.createTextboxDefaultControls();
|
|
586
|
+
$.applyControlOverrides(e), e.mt && (e.mt.visible = !1), e.mb && (e.mb.visible = !1), $.wrapWidthControl(e.ml), $.wrapWidthControl(e.mr), st.ownDefaults.controls = e, $.patchActiveSelectionBounds(), ke.ownDefaults.snapAngle = 1;
|
|
587
587
|
}
|
|
588
588
|
/**
|
|
589
589
|
* Обновляет алгоритм расчёта границ ActiveSelection, чтобы учитывать фон и отступы текстовых объектов.
|
|
590
590
|
*/
|
|
591
591
|
static patchActiveSelectionBounds() {
|
|
592
|
-
const t =
|
|
592
|
+
const t = k.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 Q {
|
|
|
609
609
|
width: d,
|
|
610
610
|
height: l
|
|
611
611
|
});
|
|
612
|
-
const u = new
|
|
612
|
+
const u = new J(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 J(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 k))
|
|
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 J(g, f), m = new J(l + g / 2, u + f / 2);
|
|
648
648
|
return r === "initialization" ? {
|
|
649
649
|
center: m,
|
|
650
|
-
relativeCorrection: new
|
|
650
|
+
relativeCorrection: new J(0, 0),
|
|
651
651
|
size: p
|
|
652
652
|
} : {
|
|
653
653
|
center: m,
|
|
@@ -855,7 +855,7 @@ N.registeredFontKeys = /* @__PURE__ */ new Set(), N.descriptorDefaults = {
|
|
|
855
855
|
display: "auto"
|
|
856
856
|
};
|
|
857
857
|
let ue = N;
|
|
858
|
-
const
|
|
858
|
+
const _s = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNNi44NzUgMi41YS42MjUuNjI1IDAgMCAwLS42MjUuNjI0VjYuMjVIMy4xMjVhLjYyNS42MjUgMCAwIDAtLjYyNS42MjV2MTBjMCAuMzQ1LjI4LjYyNS42MjUuNjI1aDEwYy4zNDUgMCAuNjI1LS4yOC42MjUtLjYyNXYtMy4xMjZoMy4xMjVjLjM0NSAwIC42MjUtLjI4LjYyNS0uNjI1di0xMGEuNjI1LjYyNSAwIDAgMC0uNjI1LS42MjVoLTEwWm02Ljg3NSAxMGgyLjVWMy43NUg3LjV2Mi41aDUuNjI1Yy4zNDUgMCAuNjI1LjI4LjYyNS42MjV2NS42MjRabS0xMCAzLjc1VjcuNWg4Ljc1djguNzVIMy43NVoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjwvc3ZnPg==", Ns = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMi41IDcuNWMwLS42OS41Ni0xLjI1IDEuMjUtMS4yNWgxMi41Yy42OSAwIDEuMjUuNTYgMS4yNSAxLjI1djguNzVjMCAuNjktLjU2IDEuMjUtMS4yNSAxLjI1SDMuNzVjLS42OSAwLTEuMjUtLjU2LTEuMjUtMS4yNVY3LjVabTEzLjc1IDBIMy43NXY4Ljc1aDEyLjVWNy41WiIgY2xpcC1ydWxlPSJldmVub2RkIi8+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMTAgMS44NzVhMi4xODggMi4xODggMCAwIDAtMi4xODggMi4xODh2Mi44MTJhLjYyNS42MjUgMCAxIDEtMS4yNSAwVjQuMDYyYTMuNDM3IDMuNDM3IDAgMSAxIDYuODc1IDB2Mi44MTNhLjYyNS42MjUgMCAxIDEtMS4yNSAwVjQuMDYyQTIuMTg4IDIuMTg4IDAgMCAwIDEwIDEuODc2WiIgY2xpcC1ydWxlPSJldmVub2RkIi8+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTEwIDEyLjgxM2EuOTM3LjkzNyAwIDEgMCAwLTEuODc1LjkzNy45MzcgMCAwIDAgMCAxLjg3NFoiLz48L3N2Zz4=", xs = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTE2LjI1IDYuMjVINy41VjQuMzc1YTIuNSAyLjUgMCAwIDEgMi41LTIuNWMxLjIgMCAyLjI4MS44NiAyLjUxMiAyYS42MjUuNjI1IDAgMCAwIDEuMjI2LS4yNWMtLjM1NC0xLjczOC0xLjkyNS0zLTMuNzM4LTNhMy43NTQgMy43NTQgMCAwIDAtMy43NSAzLjc1VjYuMjVoLTIuNUExLjI1IDEuMjUgMCAwIDAgMi41IDcuNXY4Ljc1YTEuMjUgMS4yNSAwIDAgMCAxLjI1IDEuMjVoMTIuNWExLjI1IDEuMjUgMCAwIDAgMS4yNS0xLjI1VjcuNWExLjI1IDEuMjUgMCAwIDAtMS4yNS0xLjI1Wm0wIDEwSDMuNzVWNy41aDEyLjV2OC43NVptLTUuMzEzLTQuMzc1YS45MzcuOTM3IDAgMSAxLTEuODc0IDAgLjkzNy45MzcgMCAwIDEgMS44NzQgMFoiLz48L3N2Zz4K", ks = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTIuNSA4LjEyNSAxMCAxMi41bDcuNS00LjM3NUwxMCAzLjc1IDIuNSA4LjEyNVoiLz48cGF0aCBmaWxsPSIjZmZmIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik05LjY4NSAzLjIxYS42MjUuNjI1IDAgMCAxIC42MyAwbDcuNSA0LjM3NWEuNjI1LjYyNSAwIDAgMSAwIDEuMDhsLTcuNSA0LjM3NWEuNjI1LjYyNSAwIDAgMS0uNjMgMGwtNy41LTQuMzc1YS42MjUuNjI1IDAgMCAxIDAtMS4wOGw3LjUtNC4zNzVaTTMuNzQgOC4xMjUgMTAgMTEuNzc2bDYuMjYtMy42NTFMMTAgNC40NzQgMy43NCA4LjEyNVoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjxwYXRoIGZpbGw9IiNmZmYiIGZpbGwtcnVsZT0iZXZlbm9kZCIgZD0iTTUuNCA5LjQ2YS42MjUuNjI1IDAgMCAxIC42MyAwTDEwIDExLjc3NmwzLjk3LTIuMzE2YS42MjUuNjI1IDAgMCAxIC42MyAwbDMuMjE1IDEuODc1YS42MjUuNjI1IDAgMCAxIDAgMS4wOGwtNy41IDQuMzc1YS42MjUuNjI1IDAgMCAxLS42MyAwbC03LjUtNC4zNzVhLjYyNS42MjUgMCAwIDEgMC0xLjA4TDUuNCA5LjQ2Wm0tMS42NiAyLjQxNUwxMCAxNS41MjZsNi4yNi0zLjY1MS0xLjk3NC0xLjE1MS0zLjk3MSAyLjMxNmEuNjI1LjYyNSAwIDAgMS0uNjMgMGwtMy45Ny0yLjMxNi0xLjk3NSAxLjE1MVoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjwvc3ZnPg==", Bs = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNOS42ODUgMy4yMWEuNjI1LjYyNSAwIDAgMSAuNjMgMGw3LjUgNC4zNzVhLjYyNS42MjUgMCAwIDEgMCAxLjA4bC03LjUgNC4zNzVhLjYyNS42MjUgMCAwIDEtLjYzIDBsLTcuNS00LjM3NWEuNjI1LjYyNSAwIDAgMSAwLTEuMDhsNy41LTQuMzc1Wk0zLjc0IDguMTI1IDEwIDExLjc3Nmw2LjI2LTMuNjUxTDEwIDQuNDc0IDMuNzQgOC4xMjVaIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiLz48cGF0aCBmaWxsPSIjZmZmIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik01LjcxNCAxMCAxMCAxMi41bDQuMjg2LTIuNSAzLjIxNCAxLjg3NUwxMCAxNi4yNWwtNy41LTQuMzc1TDUuNzE0IDEwWiIgY2xpcC1ydWxlPSJldmVub2RkIi8+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNNS40IDkuNDZhLjYyNS42MjUgMCAwIDEgLjYzIDBMMTAgMTEuNzc2bDMuOTctMi4zMTZhLjYyNS42MjUgMCAwIDEgLjYzIDBsMy4yMTUgMS44NzVhLjYyNS42MjUgMCAwIDEgMCAxLjA4bC03LjUgNC4zNzVhLjYyNS42MjUgMCAwIDEtLjYzIDBsLTcuNS00LjM3NWEuNjI1LjYyNSAwIDAgMSAwLTEuMDhMNS40IDkuNDZabS0xLjY2IDIuNDE1TDEwIDE1LjUyNmw2LjI2LTMuNjUxLTEuOTc0LTEuMTUxLTMuOTcxIDIuMzE2YS42MjUuNjI1IDAgMCAxLS42MyAwbC0zLjk3LTIuMzE2LTEuOTc1IDEuMTUxWiIgY2xpcC1ydWxlPSJldmVub2RkIi8+PC9zdmc+", zs = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0ibTIuNSA2LjI1IDcuNSA0LjM3NSA3LjUtNC4zNzVMMTAgMS44NzUgMi41IDYuMjVaIi8+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNOS42ODUgMS4zMzVhLjYyNS42MjUgMCAwIDEgLjYzIDBsNy41IDQuMzc1YS42MjUuNjI1IDAgMCAxIDAgMS4wOGwtNy41IDQuMzc1YS42MjUuNjI1IDAgMCAxLS42MyAwbC03LjUtNC4zNzVhLjYyNS42MjUgMCAwIDEgMC0xLjA4bDcuNS00LjM3NVpNMy43NCA2LjI1IDEwIDkuOTAxbDYuMjYtMy42NTFMMTAgMi41OTkgMy43NCA2LjI1WiIgY2xpcC1ydWxlPSJldmVub2RkIi8+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNNS40IDExLjMzNWEuNjI1LjYyNSAwIDAgMSAuNjMgMEwxMCAxMy42NTFsMy45Ny0yLjMxNmEuNjI1LjYyNSAwIDAgMSAuNjMgMGwzLjIxNSAxLjg3NWEuNjI1LjYyNSAwIDAgMSAwIDEuMDhsLTcuNSA0LjM3NWEuNjI1LjYyNSAwIDAgMS0uNjMgMGwtNy41LTQuMzc1YS42MjUuNjI1IDAgMCAxIDAtMS4wOEw1LjQgMTEuMzM1Wk0zLjc0IDEzLjc1IDEwIDE3LjQwMWw2LjI2LTMuNjUxLTEuOTc0LTEuMTUxLTMuOTcxIDIuMzE2YS42MjUuNjI1IDAgMCAxLS42MyAwbC0zLjk3LTIuMzE2TDMuNzQgMTMuNzVaIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiLz48cGF0aCBmaWxsPSIjZmZmIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik01LjQgNy41ODVhLjYyNS42MjUgMCAwIDEgLjYzIDBMMTAgOS45MDFsMy45Ny0yLjMxNmEuNjI1LjYyNSAwIDAgMSAuNjMgMGwzLjIxNSAxLjg3NWEuNjI1LjYyNSAwIDAgMSAwIDEuMDhsLTcuNSA0LjM3NWEuNjI1LjYyNSAwIDAgMS0uNjMgMGwtNy41LTQuMzc1YS42MjUuNjI1IDAgMCAxIDAtMS4wOEw1LjQgNy41ODVaTTMuNzQgMTAgMTAgMTMuNjUxIDE2LjI2IDEwbC0xLjk3NC0xLjE1MS0zLjk3MSAyLjMxNmEuNjI1LjYyNSAwIDAgMS0uNjMgMGwtMy45Ny0yLjMxNkwzLjc0IDEwWiIgY2xpcC1ydWxlPSJldmVub2RkIi8+PC9zdmc+", Ps = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMS45NiAxMy40MzVhLjYyNS42MjUgMCAwIDEgLjg1NS0uMjI1TDEwIDE3LjQwMWw3LjE4NS00LjE5YS42MjUuNjI1IDAgMCAxIC42MyAxLjA3OWwtNy41IDQuMzc1YS42MjUuNjI1IDAgMCAxLS42MyAwbC03LjUtNC4zNzVhLjYyNS42MjUgMCAwIDEtLjIyNS0uODU1Wk05LjY4NSAxLjMzNWEuNjI1LjYyNSAwIDAgMSAuNjMgMGw3LjUgNC4zNzVhLjYyNS42MjUgMCAwIDEgMCAxLjA4bC03LjUgNC4zNzVhLjYyNS42MjUgMCAwIDEtLjYzIDBsLTcuNS00LjM3NWEuNjI1LjYyNSAwIDAgMSAwLTEuMDhsNy41LTQuMzc1Wk0zLjc0IDYuMjUgMTAgOS45MDFsNi4yNi0zLjY1MUwxMCAyLjU5OSAzLjc0IDYuMjVaIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiLz48cGF0aCBmaWxsPSIjZmZmIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGQ9Im01LjcxNCAxMS44NzUgNC4yODYgMi41IDQuMjg2LTIuNUwxNy41IDEzLjc1IDEwIDE4LjEyNSAyLjUgMTMuNzVsMy4yMTQtMS44NzVaIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiLz48cGF0aCBmaWxsPSIjZmZmIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik01LjQgMTEuMzM1YS42MjUuNjI1IDAgMCAxIC42MyAwTDEwIDEzLjY1MWwzLjk3LTIuMzE2YS42MjUuNjI1IDAgMCAxIC42MyAwbDMuMjE1IDEuODc1YS42MjUuNjI1IDAgMCAxIDAgMS4wOGwtNy41IDQuMzc1YS42MjUuNjI1IDAgMCAxLS42MyAwbC03LjUtNC4zNzVhLjYyNS42MjUgMCAwIDEgMC0xLjA4TDUuNCAxMS4zMzVaTTMuNzQgMTMuNzUgMTAgMTcuNDAxbDYuMjYtMy42NTEtMS45NzQtMS4xNTEtMy45NzEgMi4zMTZhLjYyNS42MjUgMCAwIDEtLjYzIDBsLTMuOTctMi4zMTZMMy43NCAxMy43NVoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjxwYXRoIGZpbGw9IiNmZmYiIGZpbGwtcnVsZT0iZXZlbm9kZCIgZD0iTTUuNCA3LjU4NWEuNjI1LjYyNSAwIDAgMSAuNjMgMEwxMCA5LjkwMWwzLjk3LTIuMzE2YS42MjUuNjI1IDAgMCAxIC42MyAwbDMuMjE1IDEuODc1YS42MjUuNjI1IDAgMCAxIDAgMS4wOGwtNy41IDQuMzc1YS42MjUuNjI1IDAgMCAxLS42MyAwbC03LjUtNC4zNzVhLjYyNS42MjUgMCAwIDEgMC0xLjA4TDUuNCA3LjU4NVpNMy43NCAxMCAxMCAxMy42NTEgMTYuMjYgMTBsLTEuOTc0LTEuMTUxLTMuOTcxIDIuMzE2YS42MjUuNjI1IDAgMCAxLS42MyAwbC0zLjk3LTIuMzE2TDMuNzQgMTBaIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiLz48L3N2Zz4=", Us = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI0VDNEU0MCIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNOC4xMjUgMS4yNUExLjg3NSAxLjg3NSAwIDAgMCA2LjI1IDMuMTI1di42MjVIMy4xMjVhLjYyNS42MjUgMCAwIDAgMCAxLjI1aC42MjV2MTEuMjVBMS4yNSAxLjI1IDAgMCAwIDUgMTcuNWgxMGExLjI1IDEuMjUgMCAwIDAgMS4yNS0xLjI1VjVoLjYyNWEuNjI1LjYyNSAwIDAgMCAwLTEuMjVIMTMuNzV2LS42MjVhMS44NzUgMS44NzUgMCAwIDAtMS44NzUtMS44NzVoLTMuNzVabTQuMzc1IDIuNXYtLjYyNWEuNjI1LjYyNSAwIDAgMC0uNjI1LS42MjVoLTMuNzVhLjYyNS42MjUgMCAwIDAtLjYyNS42MjV2LjYyNWg1Wk01IDE2LjI1VjVoMTB2MTEuMjVINVpNOC4xMjUgNy41Yy4zNDUgMCAuNjI1LjI4LjYyNS42MjV2NWEuNjI1LjYyNSAwIDEgMS0xLjI1IDB2LTVjMC0uMzQ1LjI4LS42MjUuNjI1LS42MjVabTQuMzc1IDUuNjI1di01YS42MjUuNjI1IDAgMCAwLTEuMjUgMHY1YS42MjUuNjI1IDAgMSAwIDEuMjUgMFoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjwvc3ZnPg==", kt = {
|
|
859
859
|
style: {
|
|
860
860
|
position: "absolute",
|
|
861
861
|
display: "none",
|
|
@@ -922,14 +922,14 @@ const Ls = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMj
|
|
|
922
922
|
],
|
|
923
923
|
offsetTop: 50,
|
|
924
924
|
icons: {
|
|
925
|
-
copyPaste:
|
|
926
|
-
delete:
|
|
927
|
-
lock:
|
|
928
|
-
unlock:
|
|
929
|
-
bringToFront:
|
|
930
|
-
sendToBack:
|
|
931
|
-
bringForward:
|
|
932
|
-
sendBackwards:
|
|
925
|
+
copyPaste: _s,
|
|
926
|
+
delete: Us,
|
|
927
|
+
lock: Ns,
|
|
928
|
+
unlock: xs,
|
|
929
|
+
bringToFront: zs,
|
|
930
|
+
sendToBack: Ps,
|
|
931
|
+
bringForward: ks,
|
|
932
|
+
sendBackwards: Bs
|
|
933
933
|
},
|
|
934
934
|
handlers: {
|
|
935
935
|
copyPaste: (h) => _(null, null, function* () {
|
|
@@ -958,18 +958,18 @@ const Ls = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMj
|
|
|
958
958
|
}
|
|
959
959
|
}
|
|
960
960
|
};
|
|
961
|
-
class
|
|
961
|
+
class Ys {
|
|
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 =
|
|
969
|
-
style:
|
|
970
|
-
btnStyle:
|
|
971
|
-
icons:
|
|
972
|
-
handlers:
|
|
968
|
+
this.config = St(x(x({}, kt), t), {
|
|
969
|
+
style: x(x({}, kt.style), t.style || {}),
|
|
970
|
+
btnStyle: x(x({}, kt.btnStyle), t.btnStyle || {}),
|
|
971
|
+
icons: x(x({}, kt.icons), t.icons || {}),
|
|
972
|
+
handlers: x(x({}, kt.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();
|
|
@@ -1086,7 +1086,7 @@ class zs {
|
|
|
1086
1086
|
this.el.removeEventListener("mouseover", this._onBtnOver), this.el.removeEventListener("mouseout", this._onBtnOut), this.canvas.off("mouse:down", this._onMouseDown), this.canvas.off("object:moving", this._onObjectMoving), this.canvas.off("object:scaling", this._onObjectScaling), 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:created", this._onSelectionChange), this.canvas.off("selection:updated", this._onSelectionChange), this.canvas.off("after:render", this._onSelectionChange), this.canvas.off("selection:cleared", this._onSelectionClear), this.el.remove();
|
|
1087
1087
|
}
|
|
1088
1088
|
}
|
|
1089
|
-
const
|
|
1089
|
+
const Fs = {
|
|
1090
1090
|
position: "absolute",
|
|
1091
1091
|
display: "none",
|
|
1092
1092
|
background: "#2B2D33",
|
|
@@ -1100,7 +1100,7 @@ const Us = {
|
|
|
1100
1100
|
"pointer-events": "none",
|
|
1101
1101
|
"white-space": "nowrap",
|
|
1102
1102
|
"box-shadow": "0 2px 8px rgba(0, 0, 0, 0.2)"
|
|
1103
|
-
},
|
|
1103
|
+
}, Fe = 16, He = 16, Hs = "fabric-editor-angle-indicator";
|
|
1104
1104
|
class ve {
|
|
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();
|
|
@@ -1109,7 +1109,7 @@ class ve {
|
|
|
1109
1109
|
* Создание DOM-элемента индикатора
|
|
1110
1110
|
*/
|
|
1111
1111
|
_createDOM() {
|
|
1112
|
-
this.el = document.createElement("div"), this.el.className =
|
|
1112
|
+
this.el = document.createElement("div"), this.el.className = Hs, Object.entries(Fs).forEach(([t, e]) => {
|
|
1113
1113
|
this.el.style.setProperty(t, e);
|
|
1114
1114
|
}), this.canvas.wrapperEl.appendChild(this.el);
|
|
1115
1115
|
}
|
|
@@ -1160,9 +1160,9 @@ class ve {
|
|
|
1160
1160
|
*/
|
|
1161
1161
|
_positionIndicator(t) {
|
|
1162
1162
|
const e = this.canvas.wrapperEl.getBoundingClientRect();
|
|
1163
|
-
let s = t.clientX - e.left +
|
|
1163
|
+
let s = t.clientX - e.left + Fe, o = t.clientY - e.top + He;
|
|
1164
1164
|
const n = this.el.getBoundingClientRect(), i = n.width, a = n.height;
|
|
1165
|
-
s + i > e.width && (s = t.clientX - e.left - i -
|
|
1165
|
+
s + i > e.width && (s = t.clientX - e.left - i - Fe), o + a > e.height && (o = t.clientY - e.top - a - He), this.el.style.left = `${s}px`, this.el.style.top = `${o}px`;
|
|
1166
1166
|
}
|
|
1167
1167
|
/**
|
|
1168
1168
|
* Показать индикатор
|
|
@@ -1193,7 +1193,7 @@ class ve {
|
|
|
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 ss = [
|
|
1197
1197
|
"selectable",
|
|
1198
1198
|
"evented",
|
|
1199
1199
|
"id",
|
|
@@ -1229,7 +1229,7 @@ const Je = [
|
|
|
1229
1229
|
"radiusBottomRight",
|
|
1230
1230
|
"radiusBottomLeft"
|
|
1231
1231
|
];
|
|
1232
|
-
class
|
|
1232
|
+
class Qt {
|
|
1233
1233
|
constructor({ editor: t }) {
|
|
1234
1234
|
this.editor = t, this.canvas = t.canvas, this._historySuspendCount = 0, this.baseState = null, this.patches = [], this.currentIndex = 0, this.maxHistoryLength = t.options.maxHistoryLength, this.totalChangesCount = 0, this.baseStateChangesCount = 0, this._createDiffPatcher();
|
|
1235
1235
|
}
|
|
@@ -1241,7 +1241,7 @@ class Kt {
|
|
|
1241
1241
|
return this.patches[this.currentIndex - 1] || null;
|
|
1242
1242
|
}
|
|
1243
1243
|
_createDiffPatcher() {
|
|
1244
|
-
this.diffPatcher =
|
|
1244
|
+
this.diffPatcher = Ms({
|
|
1245
1245
|
objectHash(t) {
|
|
1246
1246
|
const e = t, s = t, o = s.styles ? JSON.stringify(s.styles) : "";
|
|
1247
1247
|
return [
|
|
@@ -1291,7 +1291,7 @@ class Kt {
|
|
|
1291
1291
|
includeValueOnMove: !1
|
|
1292
1292
|
},
|
|
1293
1293
|
textDiff: {
|
|
1294
|
-
diffMatchPatch:
|
|
1294
|
+
diffMatchPatch: ws,
|
|
1295
1295
|
minLength: 60
|
|
1296
1296
|
}
|
|
1297
1297
|
});
|
|
@@ -1333,7 +1333,7 @@ class Kt {
|
|
|
1333
1333
|
if (console.log("saveState"), this.skipHistory) return;
|
|
1334
1334
|
console.time("saveState");
|
|
1335
1335
|
const t = this._withTemporaryUnlock(
|
|
1336
|
-
() => this.canvas.toDatalessObject([...
|
|
1336
|
+
() => this.canvas.toDatalessObject([...ss])
|
|
1337
1337
|
);
|
|
1338
1338
|
if (console.timeEnd("saveState"), !this.baseState) {
|
|
1339
1339
|
this.baseState = t, this.patches = [], this.currentIndex = 0, console.log("Базовое состояние сохранено.");
|
|
@@ -1344,7 +1344,7 @@ class Kt {
|
|
|
1344
1344
|
console.log("Нет изменений для сохранения.");
|
|
1345
1345
|
return;
|
|
1346
1346
|
}
|
|
1347
|
-
console.log("baseState", this.baseState), this.currentIndex < this.patches.length && this.patches.splice(this.currentIndex), console.log("diff", s), this.totalChangesCount += 1, this.patches.push({ id:
|
|
1347
|
+
console.log("baseState", this.baseState), this.currentIndex < this.patches.length && this.patches.splice(this.currentIndex), console.log("diff", s), this.totalChangesCount += 1, this.patches.push({ id: F(), diff: s }), this.currentIndex += 1, this.patches.length > this.maxHistoryLength && (this.baseState = this.diffPatcher.patch(this.baseState, this.patches[0].diff), this.patches.shift(), this.currentIndex -= 1, this.baseStateChangesCount += 1), console.log("Состояние сохранено. Текущий индекс истории:", this.currentIndex);
|
|
1348
1348
|
}
|
|
1349
1349
|
/**
|
|
1350
1350
|
* Сериализует customData объектов в строку. Это необходимо чтобы при вызове loadFromJSON fabricjs не пытался обрабатывать свойства внутри customData, как свойства FabricObject, если их названия совпадают с зарезервированными.
|
|
@@ -1381,8 +1381,8 @@ class Kt {
|
|
|
1381
1381
|
if (!t) return;
|
|
1382
1382
|
console.log("loadStateFromFullState fullState", t);
|
|
1383
1383
|
const { canvas: e, canvasManager: s, interactionBlocker: o, backgroundManager: n } = this.editor, { width: i, height: a } = e;
|
|
1384
|
-
o.overlayMask = null,
|
|
1385
|
-
|
|
1384
|
+
o.overlayMask = null, Qt._serializeCustomData(t), yield e.loadFromJSON(t, (l, u) => {
|
|
1385
|
+
Qt._deserializeCustomData(l, u);
|
|
1386
1386
|
});
|
|
1387
1387
|
const r = e.getObjects().find((l) => l.id === "montage-area");
|
|
1388
1388
|
r && (this.editor.montageArea = r, (i !== e.getWidth() || a !== e.getHeight()) && s.updateCanvas());
|
|
@@ -1496,7 +1496,7 @@ class Kt {
|
|
|
1496
1496
|
}
|
|
1497
1497
|
}
|
|
1498
1498
|
}
|
|
1499
|
-
const
|
|
1499
|
+
const Ws = 0.1, Zs = 2, We = 0.1, Gs = 90, Et = 16, Ot = 16, pt = 4096, mt = 4096, Ze = "application/image-editor:", Gt = [
|
|
1500
1500
|
"format",
|
|
1501
1501
|
"uppercase",
|
|
1502
1502
|
"textCaseRaw",
|
|
@@ -1510,8 +1510,8 @@ const Ys = 0.1, Fs = 2, Ye = 0.1, Hs = 90, It = 16, Ct = 16, ft = 4096, pt = 409
|
|
|
1510
1510
|
"radiusTopRight",
|
|
1511
1511
|
"radiusBottomRight",
|
|
1512
1512
|
"radiusBottomLeft"
|
|
1513
|
-
],
|
|
1514
|
-
class
|
|
1513
|
+
], Vs = 50;
|
|
1514
|
+
class rt {
|
|
1515
1515
|
constructor({ editor: t }) {
|
|
1516
1516
|
this.editor = t, this.options = t.options, this._createdBlobUrls = [], this.acceptContentTypes = this.editor.options.acceptContentTypes, this.acceptFormats = this.getAllowedFormatsFromContentTypes();
|
|
1517
1517
|
}
|
|
@@ -1538,7 +1538,7 @@ class at {
|
|
|
1538
1538
|
withoutSelection: a = !1
|
|
1539
1539
|
} = t;
|
|
1540
1540
|
if (!e) return null;
|
|
1541
|
-
const { canvas: r, montageArea: c, transformManager: d, historyManager: l, errorManager: u } = this.editor, g = yield this.getContentType(e), f =
|
|
1541
|
+
const { canvas: r, montageArea: c, transformManager: d, historyManager: l, errorManager: u } = this.editor, g = yield this.getContentType(e), f = rt.getFormatFromContentType(g), { acceptContentTypes: p, acceptFormats: m } = this;
|
|
1542
1542
|
if (!this.isAllowedContentType(g)) {
|
|
1543
1543
|
const v = `Неверный contentType для изображения: ${g}. Ожидается один из: ${this.acceptContentTypes.join(", ")}.`;
|
|
1544
1544
|
return u.emitError({
|
|
@@ -1584,23 +1584,23 @@ class at {
|
|
|
1584
1584
|
}
|
|
1585
1585
|
}), null;
|
|
1586
1586
|
if (this._createdBlobUrls.push(v), f === "svg") {
|
|
1587
|
-
const S = yield
|
|
1588
|
-
b =
|
|
1587
|
+
const S = yield us(v);
|
|
1588
|
+
b = ct.groupSVGElements(S.objects, S.options);
|
|
1589
1589
|
} else
|
|
1590
|
-
b = yield
|
|
1590
|
+
b = yield xt.fromURL(v, { crossOrigin: "anonymous" });
|
|
1591
1591
|
const { width: I, height: y } = b;
|
|
1592
|
-
if (b instanceof
|
|
1592
|
+
if (b instanceof xt) {
|
|
1593
1593
|
const S = b.getElement();
|
|
1594
1594
|
let A = "";
|
|
1595
|
-
if (S instanceof HTMLImageElement ? A = S.src : S instanceof HTMLCanvasElement && (A = S.toDataURL()), y >
|
|
1595
|
+
if (S instanceof HTMLImageElement ? A = S.src : S instanceof HTMLCanvasElement && (A = S.toDataURL()), y > mt || I > pt) {
|
|
1596
1596
|
const M = yield this.resizeImageToBoundaries(A, "max"), C = URL.createObjectURL(M);
|
|
1597
|
-
this._createdBlobUrls.push(C), b = yield
|
|
1598
|
-
} else if (y <
|
|
1597
|
+
this._createdBlobUrls.push(C), b = yield xt.fromURL(C, { crossOrigin: "anonymous" });
|
|
1598
|
+
} else if (y < Ot || I < Et) {
|
|
1599
1599
|
const M = yield this.resizeImageToBoundaries(A, "min"), C = URL.createObjectURL(M);
|
|
1600
|
-
this._createdBlobUrls.push(C), b = yield
|
|
1600
|
+
this._createdBlobUrls.push(C), b = yield xt.fromURL(C, { crossOrigin: "anonymous" });
|
|
1601
1601
|
}
|
|
1602
1602
|
}
|
|
1603
|
-
if (b.set("id", `${b.type}-${
|
|
1603
|
+
if (b.set("id", `${b.type}-${F()}`), b.set("format", f), s === "scale-montage")
|
|
1604
1604
|
this.editor.canvasManager.scaleMontageAreaToImage({ object: b, withoutSave: !0 });
|
|
1605
1605
|
else {
|
|
1606
1606
|
const { width: S, height: A } = c, M = this.calculateScaleFactor({ imageObject: b, scaleType: s });
|
|
@@ -1649,15 +1649,15 @@ class at {
|
|
|
1649
1649
|
*/
|
|
1650
1650
|
resizeImageToBoundaries(t, e = "max") {
|
|
1651
1651
|
return _(this, null, function* () {
|
|
1652
|
-
let s = `Размер изображения больше максимального размера канваса, поэтому оно будет уменьшено до максимальных размеров c сохранением пропорций: ${
|
|
1653
|
-
e === "min" && (s = `Размер изображения меньше минимального размера канваса, поэтому оно будет увеличено до минимальных размеров c сохранением пропорций: ${
|
|
1652
|
+
let s = `Размер изображения больше максимального размера канваса, поэтому оно будет уменьшено до максимальных размеров c сохранением пропорций: ${pt}x${mt}`;
|
|
1653
|
+
e === "min" && (s = `Размер изображения меньше минимального размера канваса, поэтому оно будет увеличено до минимальных размеров c сохранением пропорций: ${Et}x${Ot}`);
|
|
1654
1654
|
const o = {
|
|
1655
1655
|
dataURL: t,
|
|
1656
1656
|
sizeType: e,
|
|
1657
|
-
maxWidth:
|
|
1658
|
-
maxHeight:
|
|
1659
|
-
minWidth:
|
|
1660
|
-
minHeight:
|
|
1657
|
+
maxWidth: pt,
|
|
1658
|
+
maxHeight: mt,
|
|
1659
|
+
minWidth: Et,
|
|
1660
|
+
minHeight: Ot
|
|
1661
1661
|
};
|
|
1662
1662
|
return this.editor.errorManager.emitWarning({
|
|
1663
1663
|
origin: "ImageManager",
|
|
@@ -1688,7 +1688,7 @@ class at {
|
|
|
1688
1688
|
exportAsBlob: n = !1
|
|
1689
1689
|
} = t, { canvas: i, montageArea: a, workerManager: r, interactionBlocker: c } = this.editor;
|
|
1690
1690
|
try {
|
|
1691
|
-
const d = s === "application/pdf", l = d ? "image/jpg" : s, u =
|
|
1691
|
+
const d = s === "application/pdf", l = d ? "image/jpg" : s, u = rt.getFormatFromContentType(l);
|
|
1692
1692
|
a.setCoords();
|
|
1693
1693
|
const { left: g, top: f, width: p, height: m } = a.getBoundingRect(), v = yield i.clone(["id", "format", "locked"]);
|
|
1694
1694
|
v.enableRetinaScaling = !1, ["image/jpg", "image/jpeg"].includes(l) && (v.backgroundColor = "#ffffff");
|
|
@@ -1702,8 +1702,8 @@ class at {
|
|
|
1702
1702
|
if (u === "svg" && I) {
|
|
1703
1703
|
const j = v.toSVG();
|
|
1704
1704
|
v.dispose();
|
|
1705
|
-
const
|
|
1706
|
-
image:
|
|
1705
|
+
const B = {
|
|
1706
|
+
image: rt._exportSVGStringAsFile(j, {
|
|
1707
1707
|
exportAsBase64: o,
|
|
1708
1708
|
exportAsBlob: n,
|
|
1709
1709
|
fileName: e
|
|
@@ -1712,11 +1712,11 @@ class at {
|
|
|
1712
1712
|
contentType: "image/svg+xml",
|
|
1713
1713
|
fileName: e.replace(/\.[^/.]+$/, ".svg")
|
|
1714
1714
|
};
|
|
1715
|
-
return i.fire("editor:canvas-exported",
|
|
1715
|
+
return i.fire("editor:canvas-exported", B), B;
|
|
1716
1716
|
}
|
|
1717
1717
|
const y = yield new Promise((j, T) => {
|
|
1718
|
-
v.getElement().toBlob((
|
|
1719
|
-
|
|
1718
|
+
v.getElement().toBlob((B) => {
|
|
1719
|
+
B ? j(B) : T(new Error("Failed to create Blob from canvas"));
|
|
1720
1720
|
});
|
|
1721
1721
|
});
|
|
1722
1722
|
if (v.dispose(), n) {
|
|
@@ -1734,27 +1734,27 @@ class at {
|
|
|
1734
1734
|
[w]
|
|
1735
1735
|
);
|
|
1736
1736
|
if (d) {
|
|
1737
|
-
const T = p * 0.264583,
|
|
1738
|
-
orientation: T >
|
|
1737
|
+
const T = p * 0.264583, B = m * 0.264583, G = (yield this.editor.moduleLoader.loadModule("jspdf")).jsPDF, Y = new G({
|
|
1738
|
+
orientation: T > B ? "landscape" : "portrait",
|
|
1739
1739
|
unit: "mm",
|
|
1740
|
-
format: [T,
|
|
1740
|
+
format: [T, B]
|
|
1741
1741
|
});
|
|
1742
|
-
if (
|
|
1743
|
-
const
|
|
1744
|
-
image:
|
|
1742
|
+
if (Y.addImage(String(S), "JPG", 0, 0, T, B), o) {
|
|
1743
|
+
const K = {
|
|
1744
|
+
image: Y.output("datauristring"),
|
|
1745
1745
|
format: "pdf",
|
|
1746
1746
|
contentType: "application/pdf",
|
|
1747
1747
|
fileName: e
|
|
1748
1748
|
};
|
|
1749
|
-
return i.fire("editor:canvas-exported",
|
|
1749
|
+
return i.fire("editor:canvas-exported", K), K;
|
|
1750
1750
|
}
|
|
1751
|
-
const
|
|
1752
|
-
image: new File([
|
|
1751
|
+
const H = Y.output("blob"), D = {
|
|
1752
|
+
image: new File([H], e, { type: "application/pdf" }),
|
|
1753
1753
|
format: "pdf",
|
|
1754
1754
|
contentType: "application/pdf",
|
|
1755
1755
|
fileName: e
|
|
1756
1756
|
};
|
|
1757
|
-
return i.fire("editor:canvas-exported",
|
|
1757
|
+
return i.fire("editor:canvas-exported", D), D;
|
|
1758
1758
|
}
|
|
1759
1759
|
if (o) {
|
|
1760
1760
|
const j = {
|
|
@@ -1812,9 +1812,9 @@ class at {
|
|
|
1812
1812
|
data: { contentType: o, fileName: s, exportAsBase64: n, exportAsBlob: i }
|
|
1813
1813
|
}), null;
|
|
1814
1814
|
try {
|
|
1815
|
-
const d =
|
|
1815
|
+
const d = rt.getFormatFromContentType(o);
|
|
1816
1816
|
if (d === "svg") {
|
|
1817
|
-
const p = c.toSVG(), m =
|
|
1817
|
+
const p = c.toSVG(), m = rt._exportSVGStringAsFile(p, {
|
|
1818
1818
|
exportAsBase64: n,
|
|
1819
1819
|
exportAsBlob: i,
|
|
1820
1820
|
fileName: s
|
|
@@ -1827,7 +1827,7 @@ class at {
|
|
|
1827
1827
|
};
|
|
1828
1828
|
return a.fire("editor:object-exported", v), v;
|
|
1829
1829
|
}
|
|
1830
|
-
if (n && c instanceof
|
|
1830
|
+
if (n && c instanceof xt) {
|
|
1831
1831
|
const p = yield createImageBitmap(c.getElement()), m = yield r.post(
|
|
1832
1832
|
"toDataURL",
|
|
1833
1833
|
{
|
|
@@ -1892,7 +1892,7 @@ class at {
|
|
|
1892
1892
|
* @returns массив допустимых форматов изображений
|
|
1893
1893
|
*/
|
|
1894
1894
|
getAllowedFormatsFromContentTypes() {
|
|
1895
|
-
return this.acceptContentTypes.map((t) =>
|
|
1895
|
+
return this.acceptContentTypes.map((t) => rt.getFormatFromContentType(t)).filter((t) => t);
|
|
1896
1896
|
}
|
|
1897
1897
|
/**
|
|
1898
1898
|
* Проверяет, является ли contentType допустимым типом изображения.
|
|
@@ -1945,7 +1945,7 @@ class at {
|
|
|
1945
1945
|
try {
|
|
1946
1946
|
const o = (e = new URL(t).pathname.split(".").pop()) == null ? void 0 : e.toLowerCase(), n = {};
|
|
1947
1947
|
return this.acceptContentTypes.forEach((i) => {
|
|
1948
|
-
const a =
|
|
1948
|
+
const a = rt.getFormatFromContentType(i);
|
|
1949
1949
|
a && (n[a] = i);
|
|
1950
1950
|
}), o && n[o] || "application/octet-stream";
|
|
1951
1951
|
} catch (s) {
|
|
@@ -1998,11 +1998,11 @@ class at {
|
|
|
1998
1998
|
return e ? e[1] : "";
|
|
1999
1999
|
}
|
|
2000
2000
|
}
|
|
2001
|
-
const
|
|
2002
|
-
function
|
|
2001
|
+
const At = (h, t, e) => Math.max(Math.min(h, e), t), Ge = (h, t) => h * t, Xs = (h, t) => new J(h / 2, t / 2);
|
|
2002
|
+
function Ks(h) {
|
|
2003
2003
|
return ((h == null ? void 0 : h.type) === "image" || (h == null ? void 0 : h.format) === "svg") && typeof (h == null ? void 0 : h.width) == "number" && typeof (h == null ? void 0 : h.height) == "number";
|
|
2004
2004
|
}
|
|
2005
|
-
class
|
|
2005
|
+
class Qs {
|
|
2006
2006
|
/**
|
|
2007
2007
|
* @param options
|
|
2008
2008
|
* @param options.editor – экземпляр редактора
|
|
@@ -2033,9 +2033,9 @@ class Vs {
|
|
|
2033
2033
|
canvas: n,
|
|
2034
2034
|
montageArea: i,
|
|
2035
2035
|
options: { canvasBackstoreWidth: a }
|
|
2036
|
-
} = this.editor, { width: r, height: c } = i, d =
|
|
2036
|
+
} = this.editor, { width: r, height: c } = i, d = At(Number(t), Et, pt);
|
|
2037
2037
|
if (!a || a === "auto" || o ? this.adaptCanvasToContainer() : a ? this.setCanvasBackstoreWidth(Number(a)) : this.setCanvasBackstoreWidth(d), i.set({ width: d }), (f = n.clipPath) == null || f.set({ width: d }), e) {
|
|
2038
|
-
const p = d / r, m =
|
|
2038
|
+
const p = d / r, m = Ge(c, p);
|
|
2039
2039
|
this.setResolutionHeight(m);
|
|
2040
2040
|
return;
|
|
2041
2041
|
}
|
|
@@ -2063,9 +2063,9 @@ class Vs {
|
|
|
2063
2063
|
canvas: n,
|
|
2064
2064
|
montageArea: i,
|
|
2065
2065
|
options: { canvasBackstoreHeight: a }
|
|
2066
|
-
} = this.editor, { width: r, height: c } = i, d =
|
|
2066
|
+
} = this.editor, { width: r, height: c } = i, d = At(Number(t), Ot, mt);
|
|
2067
2067
|
if (!a || a === "auto" || o ? this.adaptCanvasToContainer() : a ? this.setCanvasBackstoreHeight(Number(a)) : this.setCanvasBackstoreHeight(d), i.set({ height: d }), (f = n.clipPath) == null || f.set({ height: d }), e) {
|
|
2068
|
-
const p = d / c, m =
|
|
2068
|
+
const p = d / c, m = Ge(r, p);
|
|
2069
2069
|
this.setResolutionWidth(m);
|
|
2070
2070
|
return;
|
|
2071
2071
|
}
|
|
@@ -2083,7 +2083,7 @@ class Vs {
|
|
|
2083
2083
|
*/
|
|
2084
2084
|
centerMontageArea() {
|
|
2085
2085
|
var r;
|
|
2086
|
-
const { canvas: t, montageArea: e } = this.editor, s = t.getWidth(), o = t.getHeight(), n = t.getZoom(), i =
|
|
2086
|
+
const { canvas: t, montageArea: e } = this.editor, s = t.getWidth(), o = t.getHeight(), n = t.getZoom(), i = Xs(s, o);
|
|
2087
2087
|
e.set({
|
|
2088
2088
|
left: s / 2,
|
|
2089
2089
|
top: o / 2
|
|
@@ -2116,7 +2116,7 @@ class Vs {
|
|
|
2116
2116
|
*/
|
|
2117
2117
|
setCanvasBackstoreWidth(t) {
|
|
2118
2118
|
if (!t || typeof t != "number") return;
|
|
2119
|
-
const e =
|
|
2119
|
+
const e = At(t, Et, pt);
|
|
2120
2120
|
this.editor.canvas.setDimensions({ width: e }, { backstoreOnly: !0 });
|
|
2121
2121
|
}
|
|
2122
2122
|
/**
|
|
@@ -2125,7 +2125,7 @@ class Vs {
|
|
|
2125
2125
|
*/
|
|
2126
2126
|
setCanvasBackstoreHeight(t) {
|
|
2127
2127
|
if (!t || typeof t != "number") return;
|
|
2128
|
-
const e =
|
|
2128
|
+
const e = At(t, Ot, mt);
|
|
2129
2129
|
this.editor.canvas.setDimensions({ height: e }, { backstoreOnly: !0 });
|
|
2130
2130
|
}
|
|
2131
2131
|
/**
|
|
@@ -2134,7 +2134,7 @@ class Vs {
|
|
|
2134
2134
|
* с учётом минимальных и максимальных значений.
|
|
2135
2135
|
*/
|
|
2136
2136
|
adaptCanvasToContainer() {
|
|
2137
|
-
const { canvas: t } = this.editor, e = this.getEditorContainer(), s = e.clientWidth, o = e.clientHeight, n =
|
|
2137
|
+
const { canvas: t } = this.editor, e = this.getEditorContainer(), s = e.clientWidth, o = e.clientHeight, n = At(s, Et, pt), i = At(o, Ot, mt);
|
|
2138
2138
|
t.setDimensions({ width: n, height: i }, { backstoreOnly: !0 });
|
|
2139
2139
|
}
|
|
2140
2140
|
/**
|
|
@@ -2168,7 +2168,7 @@ class Vs {
|
|
|
2168
2168
|
if (d.length === 1)
|
|
2169
2169
|
t.setActiveObject(d[0]);
|
|
2170
2170
|
else {
|
|
2171
|
-
const l = new
|
|
2171
|
+
const l = new k(d, {
|
|
2172
2172
|
canvas: t
|
|
2173
2173
|
});
|
|
2174
2174
|
t.setActiveObject(l);
|
|
@@ -2334,9 +2334,9 @@ class Vs {
|
|
|
2334
2334
|
montageAreaHeight: r
|
|
2335
2335
|
}
|
|
2336
2336
|
} = this.editor, c = t || o.getActiveObject();
|
|
2337
|
-
if (!
|
|
2337
|
+
if (!Ks(c)) return;
|
|
2338
2338
|
const { width: d, height: l } = c;
|
|
2339
|
-
let u = Math.min(d,
|
|
2339
|
+
let u = Math.min(d, pt), g = Math.min(l, mt);
|
|
2340
2340
|
if (e) {
|
|
2341
2341
|
const {
|
|
2342
2342
|
width: f,
|
|
@@ -2394,7 +2394,7 @@ class Vs {
|
|
|
2394
2394
|
);
|
|
2395
2395
|
}
|
|
2396
2396
|
}
|
|
2397
|
-
class
|
|
2397
|
+
class qs {
|
|
2398
2398
|
constructor({ editor: t }) {
|
|
2399
2399
|
this.editor = t, this.options = t.options;
|
|
2400
2400
|
}
|
|
@@ -2405,7 +2405,7 @@ class Xs {
|
|
|
2405
2405
|
* @param options.withoutSave - Не сохранять состояние
|
|
2406
2406
|
* @fires editor:object-rotated
|
|
2407
2407
|
*/
|
|
2408
|
-
rotate(t =
|
|
2408
|
+
rotate(t = Gs, { withoutSave: e } = {}) {
|
|
2409
2409
|
const { canvas: s, historyManager: o } = this.editor, n = s.getActiveObject();
|
|
2410
2410
|
if (!n) return;
|
|
2411
2411
|
const i = n.angle + t;
|
|
@@ -2455,7 +2455,7 @@ class Xs {
|
|
|
2455
2455
|
withoutSave: s
|
|
2456
2456
|
} = {}) {
|
|
2457
2457
|
const { canvas: o, historyManager: n } = this.editor, i = t || o.getActiveObject();
|
|
2458
|
-
i && (i instanceof
|
|
2458
|
+
i && (i instanceof k ? i.getObjects().forEach((a) => {
|
|
2459
2459
|
a.set("opacity", e);
|
|
2460
2460
|
}) : i.set("opacity", e), o.renderAll(), s || n.saveState(), o.fire("editor:object-opacity-changed", {
|
|
2461
2461
|
object: i,
|
|
@@ -2482,12 +2482,12 @@ class Xs {
|
|
|
2482
2482
|
} = {}) {
|
|
2483
2483
|
const { canvas: n, historyManager: i } = this.editor, a = t || n.getActiveObject();
|
|
2484
2484
|
if (a) {
|
|
2485
|
-
if (a instanceof
|
|
2485
|
+
if (a instanceof k && !o) {
|
|
2486
2486
|
const r = a.getObjects();
|
|
2487
2487
|
n.discardActiveObject(), r.forEach((d) => {
|
|
2488
2488
|
this._fitSingleObject(d, e);
|
|
2489
2489
|
});
|
|
2490
|
-
const c = new
|
|
2490
|
+
const c = new k(r, { canvas: n });
|
|
2491
2491
|
n.setActiveObject(c);
|
|
2492
2492
|
} else
|
|
2493
2493
|
this._fitSingleObject(a, e);
|
|
@@ -2560,9 +2560,9 @@ class Xs {
|
|
|
2560
2560
|
});
|
|
2561
2561
|
}
|
|
2562
2562
|
}
|
|
2563
|
-
class
|
|
2563
|
+
class $s {
|
|
2564
2564
|
constructor({ editor: t }) {
|
|
2565
|
-
this.editor = t, this.options = t.options, this.minZoom = this.options.minZoom ||
|
|
2565
|
+
this.editor = t, this.options = t.options, this.minZoom = this.options.minZoom || Ws, this.maxZoom = this.options.maxZoom || Zs, this.defaultZoom = this.options.defaultScale;
|
|
2566
2566
|
}
|
|
2567
2567
|
/**
|
|
2568
2568
|
* Вспомогательный метод для вычисления размеров масштабированной монтажной области
|
|
@@ -2638,8 +2638,8 @@ class Ks {
|
|
|
2638
2638
|
const { canvas: i, montageArea: a } = this.editor, r = i.viewportTransform, c = i.getWidth(), d = i.getHeight(), l = t.x - r[4], u = t.y - r[5], g = Math.abs(o), f = e - s;
|
|
2639
2639
|
if (Math.abs(f) / g <= 0.1)
|
|
2640
2640
|
return { x: l, y: u };
|
|
2641
|
-
const m = c / 2, v = d / 2, b = a.left, I = a.top, y = m - b * s, w = v - I * s, S = (y - r[4]) / (e - s), A = (w - r[5]) / (e - s), M = S * g, C = A * g, j = M * n, T = C * n,
|
|
2642
|
-
return { x, y:
|
|
2641
|
+
const m = c / 2, v = d / 2, b = a.left, I = a.top, y = m - b * s, w = v - I * s, S = (y - r[4]) / (e - s), A = (w - r[5]) / (e - s), M = S * g, C = A * g, j = M * n, T = C * n, B = Math.abs(j) > Math.abs(l) ? l : j, G = Math.abs(T) > Math.abs(u) ? u : T;
|
|
2642
|
+
return { x: B, y: G };
|
|
2643
2643
|
}
|
|
2644
2644
|
/**
|
|
2645
2645
|
* Применяет плавное центрирование viewport при приближении к defaultZoom.
|
|
@@ -2651,7 +2651,7 @@ class Ks {
|
|
|
2651
2651
|
* @returns true если центрирование было применено
|
|
2652
2652
|
* @private
|
|
2653
2653
|
*/
|
|
2654
|
-
_applyViewportCentering(t, e = !1, s =
|
|
2654
|
+
_applyViewportCentering(t, e = !1, s = We) {
|
|
2655
2655
|
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
2656
|
if (!(!r || d) && !e)
|
|
2657
2657
|
return !1;
|
|
@@ -2726,10 +2726,10 @@ class Ks {
|
|
|
2726
2726
|
* @param options.pointY - Координата Y точки зума
|
|
2727
2727
|
* @fires editor:zoom-changed
|
|
2728
2728
|
*/
|
|
2729
|
-
zoom(t =
|
|
2729
|
+
zoom(t = We, e = {}) {
|
|
2730
2730
|
var g, f;
|
|
2731
2731
|
if (!t) return;
|
|
2732
|
-
const { minZoom: s, maxZoom: o } = this, { canvas: n } = this.editor, i = t < 0, a = n.getZoom(), r = n.getCenterPoint(), c = (g = e.pointX) != null ? g : r.x, d = (f = e.pointY) != null ? f : r.y, l = new
|
|
2732
|
+
const { minZoom: s, maxZoom: o } = this, { canvas: n } = this.editor, i = t < 0, a = n.getZoom(), r = n.getCenterPoint(), c = (g = e.pointX) != null ? g : r.x, d = (f = e.pointY) != null ? f : r.y, l = new J(c, d);
|
|
2733
2733
|
this.editor.montageArea.setCoords(), this.editor.canvas.requestRenderAll();
|
|
2734
2734
|
let u = Number((a + Number(t)).toFixed(3));
|
|
2735
2735
|
u > o && (u = o), u < s && (u = s), n.zoomToPoint(l, u), this.editor.panConstraintManager.updateBounds(), this._applyViewportCentering(u, i, t), n.fire("editor:zoom-changed", {
|
|
@@ -2744,7 +2744,7 @@ class Ks {
|
|
|
2744
2744
|
* @fires editor:zoom-changed
|
|
2745
2745
|
*/
|
|
2746
2746
|
setZoom(t = this.defaultZoom) {
|
|
2747
|
-
const { minZoom: e, maxZoom: s } = this, { canvas: o } = this.editor, n = new
|
|
2747
|
+
const { minZoom: e, maxZoom: s } = this, { canvas: o } = this.editor, n = new J(o.getCenterPoint());
|
|
2748
2748
|
let i = t;
|
|
2749
2749
|
t > s && (i = s), t < e && (i = e), o.zoomToPoint(n, i), o.fire("editor:zoom-changed", {
|
|
2750
2750
|
currentZoom: o.getZoom(),
|
|
@@ -2757,14 +2757,14 @@ class Ks {
|
|
|
2757
2757
|
* @fires editor:zoom-changed
|
|
2758
2758
|
*/
|
|
2759
2759
|
resetZoom() {
|
|
2760
|
-
const { canvas: t } = this.editor, e = new
|
|
2760
|
+
const { canvas: t } = this.editor, e = new J(t.getCenterPoint());
|
|
2761
2761
|
t.zoomToPoint(e, this.defaultZoom), this.editor.canvas.fire("editor:zoom-changed", {
|
|
2762
2762
|
currentZoom: t.getZoom(),
|
|
2763
2763
|
point: e
|
|
2764
2764
|
}), this.editor.panConstraintManager.updateBounds();
|
|
2765
2765
|
}
|
|
2766
2766
|
}
|
|
2767
|
-
class
|
|
2767
|
+
class Js {
|
|
2768
2768
|
constructor({ editor: t }) {
|
|
2769
2769
|
this.editor = t, this.isBlocked = !1, this.overlayMask = null, this._createOverlay();
|
|
2770
2770
|
}
|
|
@@ -2821,7 +2821,7 @@ class Qs {
|
|
|
2821
2821
|
}), t.upperCanvasEl.style.pointerEvents = "", t.lowerCanvasEl.style.pointerEvents = "", this.overlayMask.visible = !1, t.requestRenderAll(), t.fire("editor:enabled"), s.resumeHistory();
|
|
2822
2822
|
}
|
|
2823
2823
|
}
|
|
2824
|
-
class
|
|
2824
|
+
class It {
|
|
2825
2825
|
constructor({ editor: t }) {
|
|
2826
2826
|
this.editor = t, this.backgroundObject = null;
|
|
2827
2827
|
}
|
|
@@ -2846,7 +2846,7 @@ class St {
|
|
|
2846
2846
|
}
|
|
2847
2847
|
i.set({
|
|
2848
2848
|
fill: t,
|
|
2849
|
-
backgroundId: `background-${
|
|
2849
|
+
backgroundId: `background-${F()}`
|
|
2850
2850
|
}), this.editor.canvas.requestRenderAll();
|
|
2851
2851
|
} else
|
|
2852
2852
|
this._removeCurrentBackground(), this._createColorBackground(t);
|
|
@@ -2876,14 +2876,14 @@ class St {
|
|
|
2876
2876
|
try {
|
|
2877
2877
|
const { historyManager: n } = this.editor, { backgroundObject: i } = this;
|
|
2878
2878
|
if (n.suspendHistory(), i && i.backgroundType === "gradient") {
|
|
2879
|
-
const a =
|
|
2880
|
-
if (
|
|
2879
|
+
const a = It._createFabricGradient(t);
|
|
2880
|
+
if (It._isGradientEqual(i.fill, a)) {
|
|
2881
2881
|
n.resumeHistory();
|
|
2882
2882
|
return;
|
|
2883
2883
|
}
|
|
2884
2884
|
i.set({
|
|
2885
2885
|
fill: a,
|
|
2886
|
-
backgroundId: `background-${
|
|
2886
|
+
backgroundId: `background-${F()}`
|
|
2887
2887
|
}), this.editor.canvas.requestRenderAll();
|
|
2888
2888
|
} else
|
|
2889
2889
|
this._removeCurrentBackground(), this._createGradientBackground(t);
|
|
@@ -3030,7 +3030,7 @@ class St {
|
|
|
3030
3030
|
hasControls: !1,
|
|
3031
3031
|
id: "background",
|
|
3032
3032
|
backgroundType: "color",
|
|
3033
|
-
backgroundId: `background-${
|
|
3033
|
+
backgroundId: `background-${F()}`
|
|
3034
3034
|
}, { withoutSelection: !0 }), this.refresh();
|
|
3035
3035
|
}
|
|
3036
3036
|
/**
|
|
@@ -3047,9 +3047,9 @@ class St {
|
|
|
3047
3047
|
hasControls: !1,
|
|
3048
3048
|
id: "background",
|
|
3049
3049
|
backgroundType: "gradient",
|
|
3050
|
-
backgroundId: `background-${
|
|
3050
|
+
backgroundId: `background-${F()}`
|
|
3051
3051
|
}, { withoutSelection: !0 }), this.refresh();
|
|
3052
|
-
const e =
|
|
3052
|
+
const e = It._createFabricGradient(t);
|
|
3053
3053
|
this.backgroundObject.set("fill", e), this.editor.canvas.requestRenderAll();
|
|
3054
3054
|
}
|
|
3055
3055
|
/**
|
|
@@ -3075,7 +3075,7 @@ class St {
|
|
|
3075
3075
|
hasControls: !1,
|
|
3076
3076
|
id: "background",
|
|
3077
3077
|
backgroundType: "image",
|
|
3078
|
-
backgroundId: `background-${
|
|
3078
|
+
backgroundId: `background-${F()}`,
|
|
3079
3079
|
customData: e
|
|
3080
3080
|
}), this._removeCurrentBackground(), this.backgroundObject = s, this.refresh();
|
|
3081
3081
|
});
|
|
@@ -3101,8 +3101,8 @@ class St {
|
|
|
3101
3101
|
{ offset: n / 100, color: s }
|
|
3102
3102
|
];
|
|
3103
3103
|
if (t.type === "linear") {
|
|
3104
|
-
const l = t.angle * Math.PI / 180, u =
|
|
3105
|
-
return new
|
|
3104
|
+
const l = t.angle * Math.PI / 180, u = It._angleToCoords(l);
|
|
3105
|
+
return new ze({
|
|
3106
3106
|
type: "linear",
|
|
3107
3107
|
gradientUnits: "percentage",
|
|
3108
3108
|
coords: u,
|
|
@@ -3121,7 +3121,7 @@ class St {
|
|
|
3121
3121
|
r1: 0,
|
|
3122
3122
|
r2: c / 100
|
|
3123
3123
|
};
|
|
3124
|
-
return new
|
|
3124
|
+
return new ze({
|
|
3125
3125
|
type: "radial",
|
|
3126
3126
|
gradientUnits: "percentage",
|
|
3127
3127
|
coords: d,
|
|
@@ -3156,7 +3156,7 @@ class St {
|
|
|
3156
3156
|
}) ? !1 : t.type === "linear" && e.type === "linear" ? Math.abs(t.coords.x1 - e.coords.x1) < 1e-4 && Math.abs(t.coords.y1 - e.coords.y1) < 1e-4 && Math.abs(t.coords.x2 - e.coords.x2) < 1e-4 && Math.abs(t.coords.y2 - e.coords.y2) < 1e-4 : t.type === "radial" && e.type === "radial" ? Math.abs(t.coords.x1 - e.coords.x1) < 1e-4 && Math.abs(t.coords.y1 - e.coords.y1) < 1e-4 && Math.abs(t.coords.x2 - e.coords.x2) < 1e-4 && Math.abs(t.coords.y2 - e.coords.y2) < 1e-4 && Math.abs(t.coords.r1 - e.coords.r1) < 1e-4 && Math.abs(t.coords.r2 - e.coords.r2) < 1e-4 : !1;
|
|
3157
3157
|
}
|
|
3158
3158
|
}
|
|
3159
|
-
class
|
|
3159
|
+
class qt {
|
|
3160
3160
|
constructor({ editor: t }) {
|
|
3161
3161
|
this.editor = t;
|
|
3162
3162
|
}
|
|
@@ -3171,7 +3171,7 @@ class Qt {
|
|
|
3171
3171
|
const { canvas: s, historyManager: o } = this.editor;
|
|
3172
3172
|
o.suspendHistory();
|
|
3173
3173
|
const n = t || s.getActiveObject();
|
|
3174
|
-
n && (n instanceof
|
|
3174
|
+
n && (n instanceof k ? n.getObjects().forEach((i) => {
|
|
3175
3175
|
s.bringObjectToFront(i);
|
|
3176
3176
|
}) : s.bringObjectToFront(n), s.renderAll(), o.resumeHistory(), e || o.saveState(), s.fire("editor:object-bring-to-front", {
|
|
3177
3177
|
object: n,
|
|
@@ -3189,7 +3189,7 @@ class Qt {
|
|
|
3189
3189
|
const { canvas: s, historyManager: o } = this.editor;
|
|
3190
3190
|
o.suspendHistory();
|
|
3191
3191
|
const n = t || s.getActiveObject();
|
|
3192
|
-
n && (n instanceof
|
|
3192
|
+
n && (n instanceof k ? qt._moveSelectionForward(s, n) : s.bringObjectForward(n), s.renderAll(), o.resumeHistory(), e || o.saveState(), s.fire("editor:object-bring-forward", {
|
|
3193
3193
|
object: n,
|
|
3194
3194
|
withoutSave: e
|
|
3195
3195
|
}));
|
|
@@ -3212,7 +3212,7 @@ class Qt {
|
|
|
3212
3212
|
n.suspendHistory();
|
|
3213
3213
|
const r = t || s.getActiveObject();
|
|
3214
3214
|
if (r) {
|
|
3215
|
-
if (r instanceof
|
|
3215
|
+
if (r instanceof k) {
|
|
3216
3216
|
const c = r.getObjects();
|
|
3217
3217
|
for (let d = c.length - 1; d >= 0; d -= 1)
|
|
3218
3218
|
s.sendObjectToBack(c[d]);
|
|
@@ -3240,7 +3240,7 @@ class Qt {
|
|
|
3240
3240
|
} = this.editor;
|
|
3241
3241
|
n.suspendHistory();
|
|
3242
3242
|
const r = t || s.getActiveObject();
|
|
3243
|
-
r && (r instanceof
|
|
3243
|
+
r && (r instanceof k ? qt._moveSelectionBackwards(s, r) : s.sendObjectBackwards(r), a && s.sendObjectToBack(a), s.sendObjectToBack(o), i && s.sendObjectToBack(i), s.renderAll(), n.resumeHistory(), e || n.saveState(), s.fire("editor:object-send-backwards", {
|
|
3244
3244
|
object: r,
|
|
3245
3245
|
withoutSave: e
|
|
3246
3246
|
}));
|
|
@@ -3284,7 +3284,7 @@ class Qt {
|
|
|
3284
3284
|
});
|
|
3285
3285
|
}
|
|
3286
3286
|
}
|
|
3287
|
-
class
|
|
3287
|
+
class to {
|
|
3288
3288
|
/**
|
|
3289
3289
|
* Менеджер фигур для редактора.
|
|
3290
3290
|
* @param options - Опции и настройки менеджера фигур.
|
|
@@ -3310,13 +3310,13 @@ class qs {
|
|
|
3310
3310
|
*/
|
|
3311
3311
|
addRectangle(d = {}, { withoutSelection: r, withoutAdding: c } = {}) {
|
|
3312
3312
|
var l = d, {
|
|
3313
|
-
id: t = `rect-${
|
|
3313
|
+
id: t = `rect-${F()}`,
|
|
3314
3314
|
left: e,
|
|
3315
3315
|
top: s,
|
|
3316
3316
|
width: o = 100,
|
|
3317
3317
|
height: n = 100,
|
|
3318
3318
|
fill: i = "blue"
|
|
3319
|
-
} = l, a =
|
|
3319
|
+
} = l, a = gt(l, [
|
|
3320
3320
|
"id",
|
|
3321
3321
|
"left",
|
|
3322
3322
|
"top",
|
|
@@ -3324,7 +3324,7 @@ class qs {
|
|
|
3324
3324
|
"height",
|
|
3325
3325
|
"fill"
|
|
3326
3326
|
]);
|
|
3327
|
-
const { canvas: u } = this.editor, g = new
|
|
3327
|
+
const { canvas: u } = this.editor, g = new gs(x({
|
|
3328
3328
|
id: t,
|
|
3329
3329
|
left: e,
|
|
3330
3330
|
top: s,
|
|
@@ -3352,19 +3352,19 @@ class qs {
|
|
|
3352
3352
|
*/
|
|
3353
3353
|
addCircle(c = {}, { withoutSelection: a, withoutAdding: r } = {}) {
|
|
3354
3354
|
var d = c, {
|
|
3355
|
-
id: t = `circle-${
|
|
3355
|
+
id: t = `circle-${F()}`,
|
|
3356
3356
|
left: e,
|
|
3357
3357
|
top: s,
|
|
3358
3358
|
radius: o = 50,
|
|
3359
3359
|
fill: n = "green"
|
|
3360
|
-
} = d, i =
|
|
3360
|
+
} = d, i = gt(d, [
|
|
3361
3361
|
"id",
|
|
3362
3362
|
"left",
|
|
3363
3363
|
"top",
|
|
3364
3364
|
"radius",
|
|
3365
3365
|
"fill"
|
|
3366
3366
|
]);
|
|
3367
|
-
const { canvas: l } = this.editor, u = new
|
|
3367
|
+
const { canvas: l } = this.editor, u = new fs(x({
|
|
3368
3368
|
id: t,
|
|
3369
3369
|
left: e,
|
|
3370
3370
|
top: s,
|
|
@@ -3392,13 +3392,13 @@ class qs {
|
|
|
3392
3392
|
*/
|
|
3393
3393
|
addTriangle(d = {}, { withoutSelection: r, withoutAdding: c } = {}) {
|
|
3394
3394
|
var l = d, {
|
|
3395
|
-
id: t = `triangle-${
|
|
3395
|
+
id: t = `triangle-${F()}`,
|
|
3396
3396
|
left: e,
|
|
3397
3397
|
top: s,
|
|
3398
3398
|
width: o = 100,
|
|
3399
3399
|
height: n = 100,
|
|
3400
3400
|
fill: i = "yellow"
|
|
3401
|
-
} = l, a =
|
|
3401
|
+
} = l, a = gt(l, [
|
|
3402
3402
|
"id",
|
|
3403
3403
|
"left",
|
|
3404
3404
|
"top",
|
|
@@ -3406,7 +3406,7 @@ class qs {
|
|
|
3406
3406
|
"height",
|
|
3407
3407
|
"fill"
|
|
3408
3408
|
]);
|
|
3409
|
-
const { canvas: u } = this.editor, g = new
|
|
3409
|
+
const { canvas: u } = this.editor, g = new ps(x({
|
|
3410
3410
|
id: t,
|
|
3411
3411
|
left: e,
|
|
3412
3412
|
top: s,
|
|
@@ -3417,7 +3417,7 @@ class qs {
|
|
|
3417
3417
|
return !e && !s && u.centerObject(g), c || (u.add(g), r || u.setActiveObject(g), u.renderAll()), g;
|
|
3418
3418
|
}
|
|
3419
3419
|
}
|
|
3420
|
-
class
|
|
3420
|
+
class eo {
|
|
3421
3421
|
/**
|
|
3422
3422
|
* @param options
|
|
3423
3423
|
* @param options.editor - экземпляр редактора с доступом к canvas
|
|
@@ -3516,7 +3516,7 @@ class $s {
|
|
|
3516
3516
|
_copyTextToClipboard(t) {
|
|
3517
3517
|
return _(this, null, function* () {
|
|
3518
3518
|
try {
|
|
3519
|
-
const e = `${
|
|
3519
|
+
const e = `${Ze}${t}`;
|
|
3520
3520
|
return yield navigator.clipboard.writeText(e), console.info("Text copied to clipboard successfully"), !0;
|
|
3521
3521
|
} catch (e) {
|
|
3522
3522
|
const { errorManager: s } = this.editor;
|
|
@@ -3536,7 +3536,7 @@ class $s {
|
|
|
3536
3536
|
*/
|
|
3537
3537
|
_addClonedObjectToCanvas(t) {
|
|
3538
3538
|
const { canvas: e, historyManager: s } = this.editor;
|
|
3539
|
-
if (e.discardActiveObject(), t instanceof
|
|
3539
|
+
if (e.discardActiveObject(), t instanceof k) {
|
|
3540
3540
|
s.suspendHistory(), t.canvas = e, t.forEachObject((o) => {
|
|
3541
3541
|
e.add(o);
|
|
3542
3542
|
}), e.setActiveObject(t), e.requestRenderAll(), s.resumeHistory(), s.saveState();
|
|
@@ -3570,13 +3570,13 @@ class $s {
|
|
|
3570
3570
|
if (!s || s.locked) return !1;
|
|
3571
3571
|
try {
|
|
3572
3572
|
const o = yield s.clone(Gt);
|
|
3573
|
-
return o instanceof
|
|
3573
|
+
return o instanceof k && o.forEachObject((n) => {
|
|
3574
3574
|
n.set({
|
|
3575
|
-
id: `${n.type}-${
|
|
3575
|
+
id: `${n.type}-${F()}`,
|
|
3576
3576
|
evented: !0
|
|
3577
3577
|
});
|
|
3578
3578
|
}), o.set({
|
|
3579
|
-
id: `${o.type}-${
|
|
3579
|
+
id: `${o.type}-${F()}`,
|
|
3580
3580
|
left: o.left + 10,
|
|
3581
3581
|
top: o.top + 10,
|
|
3582
3582
|
evented: !0
|
|
@@ -3607,7 +3607,7 @@ class $s {
|
|
|
3607
3607
|
return;
|
|
3608
3608
|
}
|
|
3609
3609
|
const s = t.getData("text/plain");
|
|
3610
|
-
if (s && s.startsWith(
|
|
3610
|
+
if (s && s.startsWith(Ze)) {
|
|
3611
3611
|
this.paste();
|
|
3612
3612
|
return;
|
|
3613
3613
|
}
|
|
@@ -3656,13 +3656,13 @@ class $s {
|
|
|
3656
3656
|
if (!this.clipboard) return !1;
|
|
3657
3657
|
try {
|
|
3658
3658
|
const e = yield this.clipboard.clone(Gt);
|
|
3659
|
-
return t.discardActiveObject(), e instanceof
|
|
3659
|
+
return t.discardActiveObject(), e instanceof k && e.forEachObject((s) => {
|
|
3660
3660
|
s.set({
|
|
3661
|
-
id: `${s.type}-${
|
|
3661
|
+
id: `${s.type}-${F()}`,
|
|
3662
3662
|
evented: !0
|
|
3663
3663
|
});
|
|
3664
3664
|
}), e.set({
|
|
3665
|
-
id: `${e.type}-${
|
|
3665
|
+
id: `${e.type}-${F()}`,
|
|
3666
3666
|
left: e.left + 10,
|
|
3667
3667
|
top: e.top + 10,
|
|
3668
3668
|
evented: !0
|
|
@@ -3680,7 +3680,7 @@ class $s {
|
|
|
3680
3680
|
});
|
|
3681
3681
|
}
|
|
3682
3682
|
}
|
|
3683
|
-
class
|
|
3683
|
+
class $t {
|
|
3684
3684
|
constructor({ editor: t }) {
|
|
3685
3685
|
this.editor = t;
|
|
3686
3686
|
}
|
|
@@ -3706,7 +3706,7 @@ class qt {
|
|
|
3706
3706
|
editable: !1,
|
|
3707
3707
|
locked: !0
|
|
3708
3708
|
};
|
|
3709
|
-
i.set(a), !e &&
|
|
3709
|
+
i.set(a), !e && $t._isGroupOrSelection(i) && i.getObjects().forEach((c) => {
|
|
3710
3710
|
c.set(a);
|
|
3711
3711
|
}), o.renderAll(), s || n.saveState(), o.fire("editor:object-locked", {
|
|
3712
3712
|
object: i,
|
|
@@ -3735,7 +3735,7 @@ class qt {
|
|
|
3735
3735
|
editable: !0,
|
|
3736
3736
|
locked: !1
|
|
3737
3737
|
};
|
|
3738
|
-
n.set(i),
|
|
3738
|
+
n.set(i), $t._isGroupOrSelection(n) && n.getObjects().forEach((a) => {
|
|
3739
3739
|
a.set(i);
|
|
3740
3740
|
}), s.renderAll(), e || o.saveState(), s.fire("editor:object-unlocked", {
|
|
3741
3741
|
object: n,
|
|
@@ -3743,10 +3743,10 @@ class qt {
|
|
|
3743
3743
|
});
|
|
3744
3744
|
}
|
|
3745
3745
|
static _isGroupOrSelection(t) {
|
|
3746
|
-
return t instanceof
|
|
3746
|
+
return t instanceof k || t instanceof jt;
|
|
3747
3747
|
}
|
|
3748
3748
|
}
|
|
3749
|
-
class
|
|
3749
|
+
class so {
|
|
3750
3750
|
constructor({ editor: t }) {
|
|
3751
3751
|
this.editor = t;
|
|
3752
3752
|
}
|
|
@@ -3758,7 +3758,7 @@ class Js {
|
|
|
3758
3758
|
if (Array.isArray(t))
|
|
3759
3759
|
return t.length > 0 ? t : null;
|
|
3760
3760
|
const e = t || this.editor.canvas.getActiveObject();
|
|
3761
|
-
return !e || !(e instanceof
|
|
3761
|
+
return !e || !(e instanceof k) ? null : e.getObjects();
|
|
3762
3762
|
}
|
|
3763
3763
|
/**
|
|
3764
3764
|
* Получить группы для разгруппировки
|
|
@@ -3766,20 +3766,20 @@ class Js {
|
|
|
3766
3766
|
*/
|
|
3767
3767
|
_getGroupsToUngroup(t) {
|
|
3768
3768
|
if (Array.isArray(t)) {
|
|
3769
|
-
const s = t.filter((o) => o instanceof
|
|
3769
|
+
const s = t.filter((o) => o instanceof jt);
|
|
3770
3770
|
return s.length > 0 ? s : null;
|
|
3771
3771
|
}
|
|
3772
|
-
if (t instanceof
|
|
3773
|
-
const s = t.getObjects().filter((o) => o instanceof
|
|
3772
|
+
if (t instanceof k) {
|
|
3773
|
+
const s = t.getObjects().filter((o) => o instanceof jt);
|
|
3774
3774
|
return s.length > 0 ? s : null;
|
|
3775
3775
|
}
|
|
3776
3776
|
const e = t || this.editor.canvas.getActiveObject();
|
|
3777
3777
|
if (!e) return null;
|
|
3778
|
-
if (e instanceof
|
|
3779
|
-
const s = e.getObjects().filter((o) => o instanceof
|
|
3778
|
+
if (e instanceof k) {
|
|
3779
|
+
const s = e.getObjects().filter((o) => o instanceof jt);
|
|
3780
3780
|
return s.length > 0 ? s : null;
|
|
3781
3781
|
}
|
|
3782
|
-
return e instanceof
|
|
3782
|
+
return e instanceof jt ? [e] : null;
|
|
3783
3783
|
}
|
|
3784
3784
|
/**
|
|
3785
3785
|
* Группировка объектов
|
|
@@ -3796,8 +3796,8 @@ class Js {
|
|
|
3796
3796
|
if (!n) return null;
|
|
3797
3797
|
try {
|
|
3798
3798
|
o.suspendHistory();
|
|
3799
|
-
const i = new
|
|
3800
|
-
id: `group-${
|
|
3799
|
+
const i = new jt(n, {
|
|
3800
|
+
id: `group-${F()}`
|
|
3801
3801
|
});
|
|
3802
3802
|
n.forEach((r) => s.remove(r)), s.add(i), s.setActiveObject(i), s.requestRenderAll();
|
|
3803
3803
|
const a = {
|
|
@@ -3832,7 +3832,7 @@ class Js {
|
|
|
3832
3832
|
s.add(l), i.push(l);
|
|
3833
3833
|
});
|
|
3834
3834
|
});
|
|
3835
|
-
const a = new
|
|
3835
|
+
const a = new k(i, {
|
|
3836
3836
|
canvas: s
|
|
3837
3837
|
});
|
|
3838
3838
|
s.setActiveObject(a), s.requestRenderAll();
|
|
@@ -3847,7 +3847,7 @@ class Js {
|
|
|
3847
3847
|
}
|
|
3848
3848
|
}
|
|
3849
3849
|
}
|
|
3850
|
-
class
|
|
3850
|
+
class oo {
|
|
3851
3851
|
constructor({ editor: t }) {
|
|
3852
3852
|
this.editor = t;
|
|
3853
3853
|
}
|
|
@@ -3858,7 +3858,7 @@ class to {
|
|
|
3858
3858
|
selectAll() {
|
|
3859
3859
|
const { canvas: t, canvasManager: e, objectLockManager: s } = this.editor;
|
|
3860
3860
|
t.discardActiveObject();
|
|
3861
|
-
const o = e.getObjects(), n = o.some((a) => a.locked), i = o.length > 1 ? new
|
|
3861
|
+
const o = e.getObjects(), n = o.some((a) => a.locked), i = o.length > 1 ? new k(e.getObjects(), { canvas: t }) : o[0];
|
|
3862
3862
|
n && s.lockObject({ object: i, skipInnerObjects: !0, withoutSave: !0 }), t.setActiveObject(i), t.requestRenderAll(), t.fire("editor:all-objects-selected", { selected: i });
|
|
3863
3863
|
}
|
|
3864
3864
|
}
|
|
@@ -3924,7 +3924,7 @@ class be {
|
|
|
3924
3924
|
return o.fire("editor:objects-deleted", c), c;
|
|
3925
3925
|
}
|
|
3926
3926
|
}
|
|
3927
|
-
const
|
|
3927
|
+
const ft = {
|
|
3928
3928
|
IMAGE_MANAGER: {
|
|
3929
3929
|
/**
|
|
3930
3930
|
* Некорректный Content-Type изображения
|
|
@@ -4070,7 +4070,7 @@ class zt {
|
|
|
4070
4070
|
message: i,
|
|
4071
4071
|
data: o
|
|
4072
4072
|
};
|
|
4073
|
-
this._buffer.push(
|
|
4073
|
+
this._buffer.push(x({
|
|
4074
4074
|
type: "editor:error"
|
|
4075
4075
|
}, a)), this.editor.canvas.fire("editor:error", a);
|
|
4076
4076
|
}
|
|
@@ -4098,7 +4098,7 @@ class zt {
|
|
|
4098
4098
|
message: i,
|
|
4099
4099
|
data: n
|
|
4100
4100
|
};
|
|
4101
|
-
this._buffer.push(
|
|
4101
|
+
this._buffer.push(x({
|
|
4102
4102
|
type: "editor:warning"
|
|
4103
4103
|
}, a)), this.editor.canvas.fire("editor:warning", a);
|
|
4104
4104
|
}
|
|
@@ -4108,10 +4108,10 @@ class zt {
|
|
|
4108
4108
|
* @returns true, если код допустим, иначе false
|
|
4109
4109
|
*/
|
|
4110
4110
|
static isValidErrorCode(t) {
|
|
4111
|
-
return t ? Object.values(
|
|
4111
|
+
return t ? Object.values(ft).some((e) => Object.values(e).includes(t)) : !1;
|
|
4112
4112
|
}
|
|
4113
4113
|
}
|
|
4114
|
-
class
|
|
4114
|
+
class no {
|
|
4115
4115
|
constructor({ editor: t }) {
|
|
4116
4116
|
this.currentBounds = null, this.editor = t;
|
|
4117
4117
|
}
|
|
@@ -4200,10 +4200,16 @@ const nt = ({
|
|
|
4200
4200
|
value: h,
|
|
4201
4201
|
min: t,
|
|
4202
4202
|
max: e
|
|
4203
|
-
}) => Math.min(Math.max(h, t), e),
|
|
4203
|
+
}) => Math.min(Math.max(h, t), e), Tt = class Tt extends st {
|
|
4204
4204
|
constructor(t, e = {}) {
|
|
4205
4205
|
var s, o, n, i, a, r, c, d, l;
|
|
4206
|
-
super(t, e), this.backgroundOpacity = (s = e.backgroundOpacity) != null ? s : 1, this.paddingTop = (o = e.paddingTop) != null ? o : 0, this.paddingRight = (n = e.paddingRight) != null ? n : 0, this.paddingBottom = (i = e.paddingBottom) != null ? i : 0, this.paddingLeft = (a = e.paddingLeft) != null ? a : 0, this.radiusTopLeft = (r = e.radiusTopLeft) != null ? r : 0, this.radiusTopRight = (c = e.radiusTopRight) != null ? c : 0, this.radiusBottomRight = (d = e.radiusBottomRight) != null ? d : 0, this.radiusBottomLeft = (l = e.radiusBottomLeft) != null ? l : 0;
|
|
4206
|
+
super(t, e), this.backgroundOpacity = (s = e.backgroundOpacity) != null ? s : 1, this.paddingTop = (o = e.paddingTop) != null ? o : 0, this.paddingRight = (n = e.paddingRight) != null ? n : 0, this.paddingBottom = (i = e.paddingBottom) != null ? i : 0, this.paddingLeft = (a = e.paddingLeft) != null ? a : 0, this.radiusTopLeft = (r = e.radiusTopLeft) != null ? r : 0, this.radiusTopRight = (c = e.radiusTopRight) != null ? c : 0, this.radiusBottomRight = (d = e.radiusBottomRight) != null ? d : 0, this.radiusBottomLeft = (l = e.radiusBottomLeft) != null ? l : 0, this._roundDimensions();
|
|
4207
|
+
}
|
|
4208
|
+
/**
|
|
4209
|
+
* Пересчитывает размеры текста и округляет их до целых значений.
|
|
4210
|
+
*/
|
|
4211
|
+
initDimensions() {
|
|
4212
|
+
super.initDimensions(), this._roundDimensions();
|
|
4207
4213
|
}
|
|
4208
4214
|
_getLeftOffset() {
|
|
4209
4215
|
const { width: t } = this._getBackgroundDimensions(), { left: e } = this._getPadding();
|
|
@@ -4215,11 +4221,11 @@ const nt = ({
|
|
|
4215
4221
|
}
|
|
4216
4222
|
_getNonTransformedDimensions() {
|
|
4217
4223
|
const { width: t, height: e } = this._getBackgroundDimensions();
|
|
4218
|
-
return new
|
|
4224
|
+
return new J(t, e).scalarAdd(this.strokeWidth);
|
|
4219
4225
|
}
|
|
4220
4226
|
_getTransformedDimensions(t = {}) {
|
|
4221
4227
|
const { width: e, height: s } = this._getBackgroundDimensions();
|
|
4222
|
-
return super._getTransformedDimensions(
|
|
4228
|
+
return super._getTransformedDimensions(St(x({}, t), {
|
|
4223
4229
|
width: e,
|
|
4224
4230
|
height: s
|
|
4225
4231
|
}));
|
|
@@ -4229,7 +4235,7 @@ const nt = ({
|
|
|
4229
4235
|
*/
|
|
4230
4236
|
toObject(t = []) {
|
|
4231
4237
|
const e = super.toObject(t);
|
|
4232
|
-
return
|
|
4238
|
+
return St(x({}, e), {
|
|
4233
4239
|
backgroundOpacity: this.backgroundOpacity,
|
|
4234
4240
|
paddingTop: this.paddingTop,
|
|
4235
4241
|
paddingRight: this.paddingRight,
|
|
@@ -4246,7 +4252,7 @@ const nt = ({
|
|
|
4246
4252
|
const e = this._getEffectiveBackgroundFill();
|
|
4247
4253
|
if (e && e) {
|
|
4248
4254
|
const n = this._getPadding(), i = (s = this.width) != null ? s : 0, a = (o = this.height) != null ? o : 0, r = i + n.left + n.right, c = a + n.top + n.bottom, d = this._getCornerRadii({ width: r, height: c }), l = this._getLeftOffset() - n.left, u = this._getTopOffset() - n.top;
|
|
4249
|
-
t.save(),
|
|
4255
|
+
t.save(), Tt._renderRoundedRect({
|
|
4250
4256
|
ctx: t,
|
|
4251
4257
|
height: c,
|
|
4252
4258
|
left: l,
|
|
@@ -4290,7 +4296,7 @@ const nt = ({
|
|
|
4290
4296
|
const e = nt({ value: (o = this.backgroundOpacity) != null ? o : 1, min: 0, max: 1 });
|
|
4291
4297
|
let s;
|
|
4292
4298
|
try {
|
|
4293
|
-
s = new
|
|
4299
|
+
s = new ms(t);
|
|
4294
4300
|
} catch (n) {
|
|
4295
4301
|
return zt.emitError({
|
|
4296
4302
|
origin: "BackgroundTextbox",
|
|
@@ -4318,8 +4324,18 @@ const nt = ({
|
|
|
4318
4324
|
} = o, g = nt({ value: c, min: 0, max: i }), f = nt({ value: d, min: 0, max: i }), p = nt({ value: l, min: 0, max: i }), m = nt({ value: u, min: 0, max: i });
|
|
4319
4325
|
t.beginPath(), t.moveTo(s + g, n), t.lineTo(a - f, n), t.quadraticCurveTo(a, n, a, n + f), t.lineTo(a, r - p), t.quadraticCurveTo(a, r, a - p, r), t.lineTo(s + m, r), t.quadraticCurveTo(s, r, s, r - m), t.lineTo(s, n + g), t.quadraticCurveTo(s, n, s + g, n), t.closePath();
|
|
4320
4326
|
}
|
|
4327
|
+
/**
|
|
4328
|
+
* Округляет текущие значения ширины и высоты до ближайших целых.
|
|
4329
|
+
*/
|
|
4330
|
+
_roundDimensions() {
|
|
4331
|
+
const {
|
|
4332
|
+
width: t = 0,
|
|
4333
|
+
height: e = 0
|
|
4334
|
+
} = this, s = Math.round(t), o = Math.round(e);
|
|
4335
|
+
s !== t && (this.width = Math.max(0, s)), o !== e && (this.height = Math.max(0, o));
|
|
4336
|
+
}
|
|
4321
4337
|
};
|
|
4322
|
-
|
|
4338
|
+
Tt.type = "background-textbox", Tt.cacheProperties = [
|
|
4323
4339
|
...Array.isArray(st.cacheProperties) ? st.cacheProperties : [],
|
|
4324
4340
|
"backgroundColor",
|
|
4325
4341
|
"backgroundOpacity",
|
|
@@ -4331,7 +4347,7 @@ jt.type = "background-textbox", jt.cacheProperties = [
|
|
|
4331
4347
|
"radiusTopRight",
|
|
4332
4348
|
"radiusBottomRight",
|
|
4333
4349
|
"radiusBottomLeft"
|
|
4334
|
-
],
|
|
4350
|
+
], Tt.stateProperties = [
|
|
4335
4351
|
...Array.isArray(st.stateProperties) ? st.stateProperties : [],
|
|
4336
4352
|
"backgroundColor",
|
|
4337
4353
|
"backgroundOpacity",
|
|
@@ -4344,11 +4360,11 @@ jt.type = "background-textbox", jt.cacheProperties = [
|
|
|
4344
4360
|
"radiusBottomRight",
|
|
4345
4361
|
"radiusBottomLeft"
|
|
4346
4362
|
];
|
|
4347
|
-
let
|
|
4348
|
-
const
|
|
4363
|
+
let Jt = Tt;
|
|
4364
|
+
const io = () => {
|
|
4349
4365
|
var h;
|
|
4350
|
-
(h =
|
|
4351
|
-
},
|
|
4366
|
+
(h = Pe) != null && h.setClass && Pe.setClass(Jt, "background-textbox");
|
|
4367
|
+
}, ao = ({ textbox: h }) => {
|
|
4352
4368
|
var s, o;
|
|
4353
4369
|
if (!h.isEditing) return null;
|
|
4354
4370
|
const t = (s = h.selectionStart) != null ? s : 0, e = (o = h.selectionEnd) != null ? o : t;
|
|
@@ -4356,11 +4372,11 @@ const so = () => {
|
|
|
4356
4372
|
start: Math.min(t, e),
|
|
4357
4373
|
end: Math.max(t, e)
|
|
4358
4374
|
};
|
|
4359
|
-
},
|
|
4375
|
+
}, ro = ({ textbox: h }) => {
|
|
4360
4376
|
var e, s;
|
|
4361
4377
|
const t = (s = (e = h.text) == null ? void 0 : e.length) != null ? s : 0;
|
|
4362
4378
|
return t <= 0 ? null : { start: 0, end: t };
|
|
4363
|
-
},
|
|
4379
|
+
}, co = ({ textbox: h, range: t }) => {
|
|
4364
4380
|
var s, o;
|
|
4365
4381
|
if (!t) return !1;
|
|
4366
4382
|
const e = (o = (s = h.text) == null ? void 0 : s.length) != null ? o : 0;
|
|
@@ -4373,7 +4389,7 @@ const so = () => {
|
|
|
4373
4389
|
if (!t || !Object.keys(t).length) return !1;
|
|
4374
4390
|
const { start: s, end: o } = e;
|
|
4375
4391
|
return o <= s ? !1 : (h.setSelectionStyles(t, s, o), !0);
|
|
4376
|
-
},
|
|
4392
|
+
}, Ve = ({
|
|
4377
4393
|
textbox: h,
|
|
4378
4394
|
range: t,
|
|
4379
4395
|
property: e
|
|
@@ -4387,42 +4403,52 @@ const so = () => {
|
|
|
4387
4403
|
);
|
|
4388
4404
|
if (s.length)
|
|
4389
4405
|
return (o = s[0]) == null ? void 0 : o[e];
|
|
4390
|
-
},
|
|
4406
|
+
}, Xe = ({ strokeColor: h, width: t }) => {
|
|
4391
4407
|
if (!(t <= 0))
|
|
4392
4408
|
return h != null ? h : "#000000";
|
|
4393
|
-
},
|
|
4394
|
-
class
|
|
4409
|
+
}, Ke = ({ width: h = 0 }) => h ? Math.max(0, h) : 0, oe = ({ value: h }) => typeof h == "string" ? h.toLocaleUpperCase() : "", it = 0.01;
|
|
4410
|
+
class U {
|
|
4395
4411
|
constructor({ editor: t }) {
|
|
4396
4412
|
var e;
|
|
4397
4413
|
this._handleTextEditingEntered = () => {
|
|
4398
4414
|
this.isTextEditingActive = !0;
|
|
4415
|
+
}, this._handleTextChanged = (s) => {
|
|
4416
|
+
const { target: o } = s;
|
|
4417
|
+
if (!U._isTextbox(o)) return;
|
|
4418
|
+
const { text: n = "", uppercase: i } = o, a = !!i, r = n.toLocaleLowerCase();
|
|
4419
|
+
if (a) {
|
|
4420
|
+
const d = oe({ value: r });
|
|
4421
|
+
d !== n && o.set({ text: d }), o.textCaseRaw = r;
|
|
4422
|
+
} else
|
|
4423
|
+
o.textCaseRaw = n;
|
|
4424
|
+
U._roundTextboxDimensions({ textbox: o }) && (o.setCoords(), o.dirty = !0);
|
|
4399
4425
|
}, this._handleTextEditingExited = (s) => {
|
|
4400
|
-
var
|
|
4426
|
+
var r, c;
|
|
4401
4427
|
const { target: o } = s;
|
|
4402
|
-
if (!
|
|
4403
|
-
const n = (
|
|
4428
|
+
if (!U._isTextbox(o)) return;
|
|
4429
|
+
const n = (r = o.text) != null ? r : "";
|
|
4404
4430
|
if (!!o.uppercase) {
|
|
4405
|
-
const
|
|
4406
|
-
o.textCaseRaw =
|
|
4431
|
+
const d = (c = o.textCaseRaw) != null ? c : n.toLocaleLowerCase();
|
|
4432
|
+
o.textCaseRaw = d;
|
|
4407
4433
|
} else
|
|
4408
4434
|
o.textCaseRaw = n;
|
|
4409
|
-
o.locked || o.set({
|
|
4435
|
+
U._roundTextboxDimensions({ textbox: o }) && (o.setCoords(), o.dirty = !0, this.canvas.requestRenderAll()), o.locked || o.set({
|
|
4410
4436
|
lockMovementX: !1,
|
|
4411
4437
|
lockMovementY: !1
|
|
4412
4438
|
}), setTimeout(() => {
|
|
4413
4439
|
this.isTextEditingActive = !1, this.editor.historyManager.saveState();
|
|
4414
|
-
},
|
|
4440
|
+
}, Vs);
|
|
4415
4441
|
}, this._handleObjectScaling = (s) => {
|
|
4416
|
-
var
|
|
4442
|
+
var Z, Mt, Yt, ut, Ft, wt, Ae, je, Ie, Ce, Te, Ee, Oe;
|
|
4417
4443
|
const { target: o, transform: n } = s;
|
|
4418
|
-
if (o instanceof
|
|
4444
|
+
if (o instanceof k) {
|
|
4419
4445
|
this._handleActiveSelectionScaling({
|
|
4420
4446
|
selection: o,
|
|
4421
4447
|
transform: n
|
|
4422
4448
|
});
|
|
4423
4449
|
return;
|
|
4424
4450
|
}
|
|
4425
|
-
if (!
|
|
4451
|
+
if (!U._isTextbox(o) || !n) return;
|
|
4426
4452
|
o.isScaling = !0;
|
|
4427
4453
|
const i = this._ensureScalingState(o), {
|
|
4428
4454
|
baseWidth: a,
|
|
@@ -4431,88 +4457,90 @@ class q {
|
|
|
4431
4457
|
basePadding: d,
|
|
4432
4458
|
baseRadii: l,
|
|
4433
4459
|
baseStyles: u
|
|
4434
|
-
} = i, g = typeof ((
|
|
4460
|
+
} = i, g = typeof ((Z = n.original) == null ? void 0 : Z.width) == "number" ? n.original.width : void 0, f = typeof ((Mt = n.original) == null ? void 0 : Mt.left) == "number" ? n.original.left : void 0, p = g != null ? g : a, m = f != null ? f : r, v = (Yt = n.corner) != null ? Yt : "", b = (ut = n.action) != null ? ut : "", I = ["ml", "mr"].includes(v) || b === "scaleX", y = ["mt", "mb"].includes(v) || b === "scaleY", w = ["tl", "tr", "bl", "br"].includes(v) || b === "scale", S = w || y;
|
|
4435
4461
|
if (!I && !y && !w) return;
|
|
4436
|
-
const A = Math.abs((
|
|
4437
|
-
paddingTop:
|
|
4438
|
-
paddingRight:
|
|
4439
|
-
paddingBottom:
|
|
4440
|
-
paddingLeft:
|
|
4441
|
-
radiusTopLeft:
|
|
4442
|
-
radiusTopRight:
|
|
4443
|
-
radiusBottomRight:
|
|
4444
|
-
radiusBottomLeft:
|
|
4445
|
-
fontSize:
|
|
4446
|
-
width:
|
|
4447
|
-
originX:
|
|
4448
|
-
} = o,
|
|
4462
|
+
const A = Math.abs((wt = (Ft = o.scaleX) != null ? Ft : n.scaleX) != null ? wt : 1) || 1, M = Math.abs((je = (Ae = o.scaleY) != null ? Ae : n.scaleY) != null ? je : 1) || 1, C = Math.max(1, p * A), j = Math.max(1, Math.round(C)), T = Math.max(1, c * M), {
|
|
4463
|
+
paddingTop: B = 0,
|
|
4464
|
+
paddingRight: G = 0,
|
|
4465
|
+
paddingBottom: Y = 0,
|
|
4466
|
+
paddingLeft: H = 0,
|
|
4467
|
+
radiusTopLeft: V = 0,
|
|
4468
|
+
radiusTopRight: D = 0,
|
|
4469
|
+
radiusBottomRight: R = 0,
|
|
4470
|
+
radiusBottomLeft: K = 0,
|
|
4471
|
+
fontSize: W,
|
|
4472
|
+
width: z,
|
|
4473
|
+
originX: X = "left"
|
|
4474
|
+
} = o, et = w || y, q = w || y, P = et ? {
|
|
4449
4475
|
top: Math.max(0, d.top * M),
|
|
4450
4476
|
right: Math.max(0, d.right * M),
|
|
4451
4477
|
bottom: Math.max(0, d.bottom * M),
|
|
4452
4478
|
left: Math.max(0, d.left * M)
|
|
4453
|
-
} : d,
|
|
4479
|
+
} : d, Q = q ? {
|
|
4454
4480
|
topLeft: Math.max(0, l.topLeft * M),
|
|
4455
4481
|
topRight: Math.max(0, l.topRight * M),
|
|
4456
4482
|
bottomRight: Math.max(0, l.bottomRight * M),
|
|
4457
4483
|
bottomLeft: Math.max(0, l.bottomLeft * M)
|
|
4458
|
-
} : l,
|
|
4459
|
-
let
|
|
4460
|
-
if (S &&
|
|
4484
|
+
} : l, Pt = Object.keys(u).length > 0;
|
|
4485
|
+
let yt;
|
|
4486
|
+
if (S && Pt) {
|
|
4461
4487
|
const te = {};
|
|
4462
|
-
Object.entries(u).forEach(([
|
|
4463
|
-
if (!
|
|
4488
|
+
Object.entries(u).forEach(([rs, De]) => {
|
|
4489
|
+
if (!De) return;
|
|
4464
4490
|
const ee = {};
|
|
4465
|
-
Object.entries(
|
|
4491
|
+
Object.entries(De).forEach(([cs, Ht]) => {
|
|
4466
4492
|
if (!Ht) return;
|
|
4467
|
-
const
|
|
4468
|
-
typeof Ht.fontSize == "number" && (
|
|
4469
|
-
}), Object.keys(ee).length && (te[
|
|
4470
|
-
}), Object.keys(te).length && (
|
|
4493
|
+
const Le = x({}, Ht);
|
|
4494
|
+
typeof Ht.fontSize == "number" && (Le.fontSize = Math.max(1, Ht.fontSize * M)), ee[cs] = Le;
|
|
4495
|
+
}), Object.keys(ee).length && (te[rs] = ee);
|
|
4496
|
+
}), Object.keys(te).length && (yt = te);
|
|
4471
4497
|
}
|
|
4472
|
-
const
|
|
4473
|
-
if (!
|
|
4498
|
+
const vt = (Ce = (Ie = n.originX) != null ? Ie : X) != null ? Ce : "left", Dt = m + p, we = m + p / 2, bt = z != null ? z : p, Se = j !== bt, Ut = Math.abs(T - (W != null ? W : c)) > it, Lt = Math.abs(P.top - B) > it || Math.abs(P.right - G) > it || Math.abs(P.bottom - Y) > it || Math.abs(P.left - H) > it, Rt = Math.abs(Q.topLeft - V) > it || Math.abs(Q.topRight - D) > it || Math.abs(Q.bottomRight - R) > it || Math.abs(Q.bottomLeft - K) > it;
|
|
4499
|
+
if (!Se && !Ut && !Lt && !Rt) {
|
|
4474
4500
|
o.set({ scaleX: 1, scaleY: 1 }), n.scaleX = 1, n.scaleY = 1;
|
|
4475
4501
|
return;
|
|
4476
4502
|
}
|
|
4477
|
-
|
|
4478
|
-
width:
|
|
4479
|
-
fontSize: S ?
|
|
4480
|
-
paddingTop:
|
|
4481
|
-
paddingRight:
|
|
4482
|
-
paddingBottom:
|
|
4483
|
-
paddingLeft:
|
|
4484
|
-
radiusTopLeft:
|
|
4485
|
-
radiusTopRight:
|
|
4486
|
-
radiusBottomRight:
|
|
4487
|
-
radiusBottomLeft:
|
|
4503
|
+
yt && (o.styles = yt), o.set({
|
|
4504
|
+
width: j,
|
|
4505
|
+
fontSize: S ? T : c,
|
|
4506
|
+
paddingTop: P.top,
|
|
4507
|
+
paddingRight: P.right,
|
|
4508
|
+
paddingBottom: P.bottom,
|
|
4509
|
+
paddingLeft: P.left,
|
|
4510
|
+
radiusTopLeft: Q.topLeft,
|
|
4511
|
+
radiusTopRight: Q.topRight,
|
|
4512
|
+
radiusBottomRight: Q.bottomRight,
|
|
4513
|
+
radiusBottomLeft: Q.bottomLeft,
|
|
4488
4514
|
scaleX: 1,
|
|
4489
4515
|
scaleY: 1
|
|
4490
4516
|
});
|
|
4491
|
-
const
|
|
4492
|
-
|
|
4493
|
-
|
|
4517
|
+
const _t = U._roundTextboxDimensions({ textbox: o });
|
|
4518
|
+
_t && (o.dirty = !0);
|
|
4519
|
+
const dt = (Te = o.width) != null ? Te : j, Nt = dt !== bt;
|
|
4520
|
+
let lt = m;
|
|
4521
|
+
Nt && (I || w) && (vt === "right" ? lt = Dt - dt : vt === "center" && (lt = we - dt / 2)), o.set({ left: lt }), i.baseLeft = lt, n.scaleX = 1, n.scaleY = 1;
|
|
4494
4522
|
const { original: ot } = n;
|
|
4495
|
-
ot && (ot.scaleX = 1, ot.scaleY = 1, ot.width =
|
|
4496
|
-
top:
|
|
4497
|
-
right:
|
|
4498
|
-
bottom:
|
|
4499
|
-
left:
|
|
4523
|
+
ot && (ot.scaleX = 1, ot.scaleY = 1, ot.width = dt, ot.height = o.height, ot.left = lt), o.setCoords(), this.canvas.requestRenderAll(), i.baseWidth = dt, i.baseFontSize = (Ee = o.fontSize) != null ? Ee : T, i.baseStyles = JSON.parse(JSON.stringify((Oe = o.styles) != null ? Oe : {})), i.basePadding = {
|
|
4524
|
+
top: P.top,
|
|
4525
|
+
right: P.right,
|
|
4526
|
+
bottom: P.bottom,
|
|
4527
|
+
left: P.left
|
|
4500
4528
|
}, i.baseRadii = {
|
|
4501
|
-
topLeft:
|
|
4502
|
-
topRight:
|
|
4503
|
-
bottomRight:
|
|
4504
|
-
bottomLeft:
|
|
4505
|
-
}, i.hasWidthChange =
|
|
4529
|
+
topLeft: Q.topLeft,
|
|
4530
|
+
topRight: Q.topRight,
|
|
4531
|
+
bottomRight: Q.bottomRight,
|
|
4532
|
+
bottomLeft: Q.bottomLeft
|
|
4533
|
+
}, i.hasWidthChange = Nt || Ut || Lt || Rt || _t;
|
|
4506
4534
|
}, this._handleObjectModified = (s) => {
|
|
4507
4535
|
var b, I, y;
|
|
4508
4536
|
const { target: o } = s;
|
|
4509
|
-
if (o instanceof
|
|
4537
|
+
if (o instanceof k) {
|
|
4510
4538
|
this._finalizeActiveSelectionScaling({
|
|
4511
4539
|
selection: o
|
|
4512
4540
|
});
|
|
4513
4541
|
return;
|
|
4514
4542
|
}
|
|
4515
|
-
if (!
|
|
4543
|
+
if (!U._isTextbox(o)) return;
|
|
4516
4544
|
o.isScaling = !1;
|
|
4517
4545
|
const n = this.scalingState.get(o);
|
|
4518
4546
|
if (this.scalingState.delete(o), !(n != null && n.hasWidthChange)) return;
|
|
@@ -4540,16 +4568,16 @@ class q {
|
|
|
4540
4568
|
target: o,
|
|
4541
4569
|
style: v
|
|
4542
4570
|
}), o.set({ scaleX: 1, scaleY: 1 }), o.setCoords();
|
|
4543
|
-
}, this.editor = t, this.canvas = t.canvas, this.fonts = (e = t.options.fonts) != null ? e : [], this.scalingState = /* @__PURE__ */ new WeakMap(), this.isTextEditingActive = !1, this._bindEvents(),
|
|
4571
|
+
}, this.editor = t, this.canvas = t.canvas, this.fonts = (e = t.options.fonts) != null ? e : [], this.scalingState = /* @__PURE__ */ new WeakMap(), this.isTextEditingActive = !1, this._bindEvents(), io();
|
|
4544
4572
|
}
|
|
4545
4573
|
/**
|
|
4546
4574
|
* Добавляет новый текстовый объект на канвас.
|
|
4547
4575
|
* @param options — настройки текста
|
|
4548
4576
|
* @param flags — флаги поведения
|
|
4549
4577
|
*/
|
|
4550
|
-
addText(
|
|
4551
|
-
var
|
|
4552
|
-
id: t = `text-${
|
|
4578
|
+
addText(G = {}, { withoutSelection: j = !1, withoutSave: T = !1, withoutAdding: B = !1 } = {}) {
|
|
4579
|
+
var Y = G, {
|
|
4580
|
+
id: t = `text-${F()}`,
|
|
4553
4581
|
text: e = "Новый текст",
|
|
4554
4582
|
fontFamily: s,
|
|
4555
4583
|
fontSize: o = 48,
|
|
@@ -4573,7 +4601,7 @@ class q {
|
|
|
4573
4601
|
radiusTopRight: S = 0,
|
|
4574
4602
|
radiusBottomRight: A = 0,
|
|
4575
4603
|
radiusBottomLeft: M = 0
|
|
4576
|
-
} =
|
|
4604
|
+
} = Y, C = gt(Y, [
|
|
4577
4605
|
"id",
|
|
4578
4606
|
"text",
|
|
4579
4607
|
"fontFamily",
|
|
@@ -4599,15 +4627,15 @@ class q {
|
|
|
4599
4627
|
"radiusBottomRight",
|
|
4600
4628
|
"radiusBottomLeft"
|
|
4601
4629
|
]);
|
|
4602
|
-
var
|
|
4603
|
-
const { historyManager:
|
|
4604
|
-
|
|
4605
|
-
const
|
|
4630
|
+
var et;
|
|
4631
|
+
const { historyManager: H } = this.editor, { canvas: V } = this;
|
|
4632
|
+
H.suspendHistory();
|
|
4633
|
+
const D = s != null ? s : this._getDefaultFontFamily(), R = Ke({ width: g }), K = Xe({
|
|
4606
4634
|
strokeColor: u,
|
|
4607
4635
|
width: R
|
|
4608
|
-
}),
|
|
4636
|
+
}), W = x({
|
|
4609
4637
|
id: t,
|
|
4610
|
-
fontFamily:
|
|
4638
|
+
fontFamily: D,
|
|
4611
4639
|
fontSize: o,
|
|
4612
4640
|
fontWeight: n ? "bold" : "normal",
|
|
4613
4641
|
fontStyle: i ? "italic" : "normal",
|
|
@@ -4616,7 +4644,7 @@ class q {
|
|
|
4616
4644
|
linethrough: c,
|
|
4617
4645
|
textAlign: d,
|
|
4618
4646
|
fill: l,
|
|
4619
|
-
stroke:
|
|
4647
|
+
stroke: K,
|
|
4620
4648
|
strokeWidth: R,
|
|
4621
4649
|
strokeUniform: !0,
|
|
4622
4650
|
opacity: f,
|
|
@@ -4630,29 +4658,29 @@ class q {
|
|
|
4630
4658
|
radiusTopRight: S,
|
|
4631
4659
|
radiusBottomRight: A,
|
|
4632
4660
|
radiusBottomLeft: M
|
|
4633
|
-
}, C),
|
|
4634
|
-
if (
|
|
4635
|
-
const
|
|
4636
|
-
|
|
4637
|
-
}
|
|
4638
|
-
return C.left === void 0 && C.top === void 0 &&
|
|
4639
|
-
textbox:
|
|
4640
|
-
options:
|
|
4661
|
+
}, C), z = new Jt(e, W);
|
|
4662
|
+
if (z.textCaseRaw = (et = z.text) != null ? et : "", r) {
|
|
4663
|
+
const q = oe({ value: z.textCaseRaw });
|
|
4664
|
+
q !== z.text && z.set({ text: q });
|
|
4665
|
+
}
|
|
4666
|
+
return U._roundTextboxDimensions({ textbox: z }) && (z.dirty = !0), C.left === void 0 && C.top === void 0 && V.centerObject(z), B || V.add(z), j || V.setActiveObject(z), V.requestRenderAll(), H.resumeHistory(), T || H.saveState(), V.fire("editor:text-added", {
|
|
4667
|
+
textbox: z,
|
|
4668
|
+
options: St(x({}, W), {
|
|
4641
4669
|
text: e,
|
|
4642
4670
|
bold: n,
|
|
4643
4671
|
italic: i,
|
|
4644
4672
|
strikethrough: c,
|
|
4645
4673
|
align: d,
|
|
4646
4674
|
color: l,
|
|
4647
|
-
strokeColor:
|
|
4675
|
+
strokeColor: K,
|
|
4648
4676
|
strokeWidth: R
|
|
4649
4677
|
}),
|
|
4650
4678
|
flags: {
|
|
4651
4679
|
withoutSelection: !!j,
|
|
4652
4680
|
withoutSave: !!T,
|
|
4653
|
-
withoutAdding: !!
|
|
4681
|
+
withoutAdding: !!B
|
|
4654
4682
|
}
|
|
4655
|
-
}),
|
|
4683
|
+
}), z;
|
|
4656
4684
|
}
|
|
4657
4685
|
/**
|
|
4658
4686
|
* Обновляет текстовый объект.
|
|
@@ -4663,12 +4691,12 @@ class q {
|
|
|
4663
4691
|
* @param options.skipRender — не вызывать перерисовку канваса
|
|
4664
4692
|
*/
|
|
4665
4693
|
updateText({ target: t, style: e = {}, withoutSave: s, skipRender: o } = {}) {
|
|
4666
|
-
var Rt,
|
|
4694
|
+
var Rt, _t, dt, Nt, lt, ot;
|
|
4667
4695
|
const n = this._resolveTextObject(t);
|
|
4668
4696
|
if (!n) return null;
|
|
4669
4697
|
const { historyManager: i } = this.editor, { canvas: a } = this;
|
|
4670
4698
|
i.suspendHistory();
|
|
4671
|
-
const r =
|
|
4699
|
+
const r = U._getSnapshot(n), Lt = e, {
|
|
4672
4700
|
text: c,
|
|
4673
4701
|
fontFamily: d,
|
|
4674
4702
|
fontSize: l,
|
|
@@ -4688,11 +4716,11 @@ class q {
|
|
|
4688
4716
|
paddingRight: C,
|
|
4689
4717
|
paddingBottom: j,
|
|
4690
4718
|
paddingLeft: T,
|
|
4691
|
-
radiusTopLeft:
|
|
4692
|
-
radiusTopRight:
|
|
4693
|
-
radiusBottomRight:
|
|
4694
|
-
radiusBottomLeft:
|
|
4695
|
-
} =
|
|
4719
|
+
radiusTopLeft: B,
|
|
4720
|
+
radiusTopRight: G,
|
|
4721
|
+
radiusBottomRight: Y,
|
|
4722
|
+
radiusBottomLeft: H
|
|
4723
|
+
} = Lt, V = gt(Lt, [
|
|
4696
4724
|
"text",
|
|
4697
4725
|
"fontFamily",
|
|
4698
4726
|
"fontSize",
|
|
@@ -4716,39 +4744,39 @@ class q {
|
|
|
4716
4744
|
"radiusTopRight",
|
|
4717
4745
|
"radiusBottomRight",
|
|
4718
4746
|
"radiusBottomLeft"
|
|
4719
|
-
]),
|
|
4720
|
-
if (d !== void 0 && (
|
|
4721
|
-
const
|
|
4722
|
-
R && (
|
|
4747
|
+
]), D = x({}, V), R = ao({ textbox: n }), K = R ? this._expandRangeToFullLines({ textbox: n, range: R }) : null, W = {}, z = {}, X = {}, et = co({ textbox: n, range: R }), q = !R || et, P = !R;
|
|
4748
|
+
if (d !== void 0 && (K && (z.fontFamily = d), q && (D.fontFamily = d, P && (X.fontFamily = d))), l !== void 0 && (K && (z.fontSize = l), q && (D.fontSize = l, P && (X.fontSize = l))), u !== void 0) {
|
|
4749
|
+
const Z = u ? "bold" : "normal";
|
|
4750
|
+
R && (W.fontWeight = Z), q && (D.fontWeight = Z, P && (X.fontWeight = Z));
|
|
4723
4751
|
}
|
|
4724
4752
|
if (g !== void 0) {
|
|
4725
|
-
const
|
|
4726
|
-
R && (
|
|
4753
|
+
const Z = g ? "italic" : "normal";
|
|
4754
|
+
R && (W.fontStyle = Z), q && (D.fontStyle = Z, P && (X.fontStyle = Z));
|
|
4727
4755
|
}
|
|
4728
|
-
if (f !== void 0 && (R && (
|
|
4729
|
-
const
|
|
4756
|
+
if (f !== void 0 && (R && (W.underline = f), q && (D.underline = f, P && (X.underline = f))), m !== void 0 && (R && (W.linethrough = m), q && (D.linethrough = m, P && (X.linethrough = m))), v !== void 0 && (D.textAlign = v), b !== void 0 && (R && (W.fill = b), q && (D.fill = b, P && (X.fill = b))), I !== void 0 || y !== void 0) {
|
|
4757
|
+
const Z = R ? Ve({ textbox: n, range: R, property: "strokeWidth" }) : void 0, Mt = R ? Ve({ textbox: n, range: R, property: "stroke" }) : void 0, Yt = (_t = (Rt = y != null ? y : Z) != null ? Rt : n.strokeWidth) != null ? _t : 0, ut = Ke({ width: Yt }), Ft = (Nt = (dt = I != null ? I : Mt) != null ? dt : n.stroke) != null ? Nt : void 0, wt = Xe({
|
|
4730
4758
|
strokeColor: Ft,
|
|
4731
|
-
width:
|
|
4759
|
+
width: ut
|
|
4732
4760
|
});
|
|
4733
|
-
R && (
|
|
4734
|
-
}
|
|
4735
|
-
w !== void 0 && (
|
|
4736
|
-
const
|
|
4737
|
-
if (
|
|
4738
|
-
const
|
|
4739
|
-
|
|
4740
|
-
} else n.textCaseRaw === void 0 && (n.textCaseRaw =
|
|
4741
|
-
n.uppercase =
|
|
4742
|
-
let
|
|
4761
|
+
R && (W.stroke = wt, W.strokeWidth = ut), q && (D.stroke = wt, D.strokeWidth = ut, P && (X.stroke = wt, X.strokeWidth = ut));
|
|
4762
|
+
}
|
|
4763
|
+
w !== void 0 && (D.opacity = w), S !== void 0 && (D.backgroundColor = S), A !== void 0 && (D.backgroundOpacity = A), M !== void 0 && (D.paddingTop = M), C !== void 0 && (D.paddingRight = C), j !== void 0 && (D.paddingBottom = j), T !== void 0 && (D.paddingLeft = T), B !== void 0 && (D.radiusTopLeft = B), G !== void 0 && (D.radiusTopRight = G), Y !== void 0 && (D.radiusBottomRight = Y), H !== void 0 && (D.radiusBottomLeft = H);
|
|
4764
|
+
const Q = (ot = n.textCaseRaw) != null ? ot : (lt = n.text) != null ? lt : "", Pt = !!n.uppercase, yt = c !== void 0, vt = yt ? c != null ? c : "" : Q, Dt = p != null ? p : Pt;
|
|
4765
|
+
if (yt || Dt !== Pt) {
|
|
4766
|
+
const Z = Dt ? oe({ value: vt }) : vt;
|
|
4767
|
+
D.text = Z, n.textCaseRaw = vt;
|
|
4768
|
+
} else n.textCaseRaw === void 0 && (n.textCaseRaw = Q);
|
|
4769
|
+
n.uppercase = Dt, n.set(D);
|
|
4770
|
+
let bt = !1;
|
|
4743
4771
|
if (R) {
|
|
4744
|
-
const
|
|
4745
|
-
|
|
4746
|
-
} else if (Object.keys(
|
|
4747
|
-
const
|
|
4748
|
-
|
|
4749
|
-
}
|
|
4750
|
-
|
|
4751
|
-
const
|
|
4772
|
+
const Z = se({ textbox: n, styles: W, range: R }), Mt = K ? se({ textbox: n, styles: z, range: K }) : !1;
|
|
4773
|
+
bt = Z || Mt;
|
|
4774
|
+
} else if (Object.keys(X).length) {
|
|
4775
|
+
const Z = ro({ textbox: n });
|
|
4776
|
+
Z && (bt = se({ textbox: n, styles: X, range: Z }));
|
|
4777
|
+
}
|
|
4778
|
+
bt && (n.dirty = !0), (S !== void 0 || A !== void 0 || M !== void 0 || C !== void 0 || j !== void 0 || T !== void 0 || B !== void 0 || G !== void 0 || Y !== void 0 || H !== void 0) && (n.dirty = !0), U._roundTextboxDimensions({ textbox: n }) && (n.dirty = !0), n.setCoords(), o || a.requestRenderAll(), i.resumeHistory(), s || i.saveState();
|
|
4779
|
+
const Ut = U._getSnapshot(n);
|
|
4752
4780
|
return a.fire("editor:text-updated", {
|
|
4753
4781
|
textbox: n,
|
|
4754
4782
|
target: t,
|
|
@@ -4757,11 +4785,11 @@ class q {
|
|
|
4757
4785
|
withoutSave: !!s,
|
|
4758
4786
|
skipRender: !!o
|
|
4759
4787
|
},
|
|
4760
|
-
updates:
|
|
4788
|
+
updates: D,
|
|
4761
4789
|
before: r,
|
|
4762
|
-
after:
|
|
4790
|
+
after: Ut,
|
|
4763
4791
|
selectionRange: R != null ? R : void 0,
|
|
4764
|
-
selectionStyles: R && Object.keys(
|
|
4792
|
+
selectionStyles: R && Object.keys(W).length ? W : void 0
|
|
4765
4793
|
}), n;
|
|
4766
4794
|
}
|
|
4767
4795
|
/**
|
|
@@ -4779,10 +4807,10 @@ class q {
|
|
|
4779
4807
|
const { canvas: e } = this;
|
|
4780
4808
|
if (!t) {
|
|
4781
4809
|
const s = e.getActiveObject();
|
|
4782
|
-
return
|
|
4810
|
+
return U._isTextbox(s) ? s : null;
|
|
4783
4811
|
}
|
|
4784
4812
|
if (typeof t == "string") {
|
|
4785
|
-
const s = e.getObjects().find((o) =>
|
|
4813
|
+
const s = e.getObjects().find((o) => U._isTextbox(o) && o.id === t);
|
|
4786
4814
|
return s != null ? s : null;
|
|
4787
4815
|
}
|
|
4788
4816
|
return null;
|
|
@@ -4798,22 +4826,7 @@ class q {
|
|
|
4798
4826
|
*/
|
|
4799
4827
|
_bindEvents() {
|
|
4800
4828
|
const { canvas: t } = this;
|
|
4801
|
-
t.on("object:scaling", this._handleObjectScaling), t.on("object:modified", this._handleObjectModified), t.on("text:editing:entered", this._handleTextEditingEntered), t.on("text:editing:exited", this._handleTextEditingExited), t.on("text:changed",
|
|
4802
|
-
}
|
|
4803
|
-
/**
|
|
4804
|
-
* Реагирует на изменение текста в режиме редактирования: синхронизирует textCaseRaw и uppercase.
|
|
4805
|
-
*/
|
|
4806
|
-
static _handleTextChanged(t) {
|
|
4807
|
-
var i;
|
|
4808
|
-
const { target: e } = t;
|
|
4809
|
-
if (!q._isTextbox(e)) return;
|
|
4810
|
-
const s = (i = e.text) != null ? i : "", o = !!e.uppercase, n = s.toLocaleLowerCase();
|
|
4811
|
-
if (o) {
|
|
4812
|
-
const a = oe({ value: n });
|
|
4813
|
-
a !== s && e.set({ text: a }), e.textCaseRaw = n;
|
|
4814
|
-
return;
|
|
4815
|
-
}
|
|
4816
|
-
e.textCaseRaw = s;
|
|
4829
|
+
t.on("object:scaling", this._handleObjectScaling), t.on("object:modified", this._handleObjectModified), t.on("text:editing:entered", this._handleTextEditingEntered), t.on("text:editing:exited", this._handleTextEditingExited), t.on("text:changed", this._handleTextChanged);
|
|
4817
4830
|
}
|
|
4818
4831
|
/**
|
|
4819
4832
|
* Обрабатывает горизонтальное масштабирование ActiveSelection: расширяет текстовые блоки по ширине без растяжения шрифта.
|
|
@@ -4827,13 +4840,13 @@ class q {
|
|
|
4827
4840
|
if (!(["ml", "mr", "tl", "tr", "bl", "br"].includes(s) || o === "scaleX" || o === "scale")) return;
|
|
4828
4841
|
const i = Math.abs((l = (d = t.scaleX) != null ? d : e == null ? void 0 : e.scaleX) != null ? l : 1) || 1, a = i === 0 ? 1 : 1 / i;
|
|
4829
4842
|
t.getObjects().forEach((u) => {
|
|
4830
|
-
if (!
|
|
4831
|
-
const g = this._ensureScalingState(u), f = Math.max(1, g.baseWidth * i);
|
|
4843
|
+
if (!U._isTextbox(u)) return;
|
|
4844
|
+
const g = this._ensureScalingState(u), f = Math.max(1, Math.round(g.baseWidth * i));
|
|
4832
4845
|
u.set({
|
|
4833
4846
|
width: f,
|
|
4834
4847
|
scaleX: a,
|
|
4835
4848
|
scaleY: 1
|
|
4836
|
-
}), u.setCoords(), u.dirty = !0;
|
|
4849
|
+
}), U._roundTextboxDimensions({ textbox: u }), u.setCoords(), u.dirty = !0;
|
|
4837
4850
|
}), t.setCoords(), this.canvas.requestRenderAll();
|
|
4838
4851
|
}
|
|
4839
4852
|
/**
|
|
@@ -4843,14 +4856,14 @@ class q {
|
|
|
4843
4856
|
selection: t
|
|
4844
4857
|
}) {
|
|
4845
4858
|
var o;
|
|
4846
|
-
const e = Math.abs((o = t.scaleX) != null ? o : 1) || 1, s = t.getObjects().filter((n) =>
|
|
4859
|
+
const e = Math.abs((o = t.scaleX) != null ? o : 1) || 1, s = t.getObjects().filter((n) => U._isTextbox(n));
|
|
4847
4860
|
s.length && (s.forEach((n) => {
|
|
4848
|
-
const i = this._ensureScalingState(n), a = Math.max(1, i.baseWidth * e);
|
|
4861
|
+
const i = this._ensureScalingState(n), a = Math.max(1, Math.round(i.baseWidth * e));
|
|
4849
4862
|
n.set({
|
|
4850
4863
|
width: a,
|
|
4851
4864
|
scaleX: 1,
|
|
4852
4865
|
scaleY: 1
|
|
4853
|
-
}), n.setCoords(), n.dirty = !0, this.scalingState.delete(n);
|
|
4866
|
+
}), U._roundTextboxDimensions({ textbox: n }), n.setCoords(), n.dirty = !0, this.scalingState.delete(n);
|
|
4854
4867
|
}), t.set({
|
|
4855
4868
|
scaleX: 1
|
|
4856
4869
|
}), t.setCoords(), this.canvas.requestRenderAll());
|
|
@@ -4879,7 +4892,7 @@ class q {
|
|
|
4879
4892
|
}) {
|
|
4880
4893
|
const s = this._getLineRanges({ textbox: t });
|
|
4881
4894
|
if (!s.length) return e;
|
|
4882
|
-
let o = e
|
|
4895
|
+
let { start: o } = e, { end: n } = e;
|
|
4883
4896
|
return s.forEach(({ start: i, end: a }) => {
|
|
4884
4897
|
e.end > i && e.start < a && (o = Math.min(o, i), n = Math.max(n, a));
|
|
4885
4898
|
}), { start: o, end: n };
|
|
@@ -4924,16 +4937,40 @@ class q {
|
|
|
4924
4937
|
}
|
|
4925
4938
|
return e;
|
|
4926
4939
|
}
|
|
4940
|
+
/**
|
|
4941
|
+
* Возвращает числовое значение размера, используя исходное значение или заранее вычисленное.
|
|
4942
|
+
*/
|
|
4943
|
+
static _resolveDimension({
|
|
4944
|
+
rawValue: t,
|
|
4945
|
+
calculatedValue: e
|
|
4946
|
+
}) {
|
|
4947
|
+
return typeof t == "number" ? t : typeof e == "number" ? e : 0;
|
|
4948
|
+
}
|
|
4949
|
+
/**
|
|
4950
|
+
* Округляет ширину и высоту текстового блока до ближайших целых значений.
|
|
4951
|
+
*/
|
|
4952
|
+
static _roundTextboxDimensions({
|
|
4953
|
+
textbox: t
|
|
4954
|
+
}) {
|
|
4955
|
+
const { width: e, height: s, calcTextWidth: o, calcTextHeight: n } = t, i = typeof o == "function" ? o.call(t) : void 0, a = typeof n == "function" ? n.call(t) : void 0, r = U._resolveDimension({
|
|
4956
|
+
rawValue: e,
|
|
4957
|
+
calculatedValue: i
|
|
4958
|
+
}), c = U._resolveDimension({
|
|
4959
|
+
rawValue: s,
|
|
4960
|
+
calculatedValue: a
|
|
4961
|
+
}), d = Number.isFinite(r) ? Math.round(r) : null, l = Number.isFinite(c) ? Math.round(c) : null, u = {};
|
|
4962
|
+
return d !== null && d !== r && (u.width = Math.max(0, d)), l !== null && l !== c && (u.height = Math.max(0, l)), Object.keys(u).length ? (t.set(u), !0) : !1;
|
|
4963
|
+
}
|
|
4927
4964
|
/**
|
|
4928
4965
|
* Формирует снимок текущих свойств текстового объекта для истории и событий.
|
|
4929
4966
|
*/
|
|
4930
4967
|
static _getSnapshot(t) {
|
|
4931
4968
|
const e = ({
|
|
4932
|
-
snapshot:
|
|
4933
|
-
entries:
|
|
4969
|
+
snapshot: W,
|
|
4970
|
+
entries: z
|
|
4934
4971
|
}) => {
|
|
4935
|
-
Object.entries(
|
|
4936
|
-
et != null && (
|
|
4972
|
+
Object.entries(z).forEach(([X, et]) => {
|
|
4973
|
+
et != null && (W[X] = et);
|
|
4937
4974
|
});
|
|
4938
4975
|
}, {
|
|
4939
4976
|
id: s,
|
|
@@ -4961,20 +4998,20 @@ class q {
|
|
|
4961
4998
|
radiusTopRight: C,
|
|
4962
4999
|
radiusBottomRight: j,
|
|
4963
5000
|
radiusBottomLeft: T,
|
|
4964
|
-
left:
|
|
4965
|
-
top:
|
|
4966
|
-
width:
|
|
4967
|
-
height:
|
|
4968
|
-
angle:
|
|
4969
|
-
scaleX:
|
|
5001
|
+
left: B,
|
|
5002
|
+
top: G,
|
|
5003
|
+
width: Y,
|
|
5004
|
+
height: H,
|
|
5005
|
+
angle: V,
|
|
5006
|
+
scaleX: D,
|
|
4970
5007
|
scaleY: R
|
|
4971
|
-
} = t,
|
|
5008
|
+
} = t, K = {
|
|
4972
5009
|
id: s,
|
|
4973
5010
|
uppercase: !!i,
|
|
4974
5011
|
textAlign: g
|
|
4975
5012
|
};
|
|
4976
5013
|
return e({
|
|
4977
|
-
snapshot:
|
|
5014
|
+
snapshot: K,
|
|
4978
5015
|
entries: {
|
|
4979
5016
|
text: o,
|
|
4980
5017
|
textCaseRaw: n,
|
|
@@ -4998,15 +5035,15 @@ class q {
|
|
|
4998
5035
|
radiusTopRight: C,
|
|
4999
5036
|
radiusBottomRight: j,
|
|
5000
5037
|
radiusBottomLeft: T,
|
|
5001
|
-
left:
|
|
5002
|
-
top:
|
|
5003
|
-
width:
|
|
5004
|
-
height:
|
|
5005
|
-
angle:
|
|
5006
|
-
scaleX:
|
|
5038
|
+
left: B,
|
|
5039
|
+
top: G,
|
|
5040
|
+
width: Y,
|
|
5041
|
+
height: H,
|
|
5042
|
+
angle: V,
|
|
5043
|
+
scaleX: D,
|
|
5007
5044
|
scaleY: R
|
|
5008
5045
|
}
|
|
5009
|
-
}),
|
|
5046
|
+
}), K;
|
|
5010
5047
|
}
|
|
5011
5048
|
/**
|
|
5012
5049
|
* Возвращает первый доступный шрифт или дефолтный Arial.
|
|
@@ -5026,7 +5063,7 @@ const tt = ({
|
|
|
5026
5063
|
}) => {
|
|
5027
5064
|
const s = tt({ value: h });
|
|
5028
5065
|
return e ? s : s / (t || 1);
|
|
5029
|
-
},
|
|
5066
|
+
}, lo = ({
|
|
5030
5067
|
object: h,
|
|
5031
5068
|
baseWidth: t,
|
|
5032
5069
|
baseHeight: e,
|
|
@@ -5060,7 +5097,7 @@ const tt = ({
|
|
|
5060
5097
|
x: l + g / 2,
|
|
5061
5098
|
y: u + f / 2
|
|
5062
5099
|
};
|
|
5063
|
-
},
|
|
5100
|
+
}, ho = ({
|
|
5064
5101
|
normalizedX: h,
|
|
5065
5102
|
normalizedY: t,
|
|
5066
5103
|
bounds: e,
|
|
@@ -5070,11 +5107,11 @@ const tt = ({
|
|
|
5070
5107
|
const { left: n, top: i, width: a, height: r } = e;
|
|
5071
5108
|
if (!o) {
|
|
5072
5109
|
const { width: l, height: u } = s, g = n + h * (l || a), f = i + t * (u || r);
|
|
5073
|
-
return new
|
|
5110
|
+
return new J(g, f);
|
|
5074
5111
|
}
|
|
5075
5112
|
const c = n + h * a, d = i + t * r;
|
|
5076
|
-
return new
|
|
5077
|
-
},
|
|
5113
|
+
return new J(c, d);
|
|
5114
|
+
}, uo = ({
|
|
5078
5115
|
object: h,
|
|
5079
5116
|
montageArea: t,
|
|
5080
5117
|
bounds: e
|
|
@@ -5089,7 +5126,7 @@ const tt = ({
|
|
|
5089
5126
|
} catch (s) {
|
|
5090
5127
|
return null;
|
|
5091
5128
|
}
|
|
5092
|
-
},
|
|
5129
|
+
}, ht = ({
|
|
5093
5130
|
object: h
|
|
5094
5131
|
}) => {
|
|
5095
5132
|
if (!h) return null;
|
|
@@ -5112,12 +5149,12 @@ const tt = ({
|
|
|
5112
5149
|
} catch (t) {
|
|
5113
5150
|
return null;
|
|
5114
5151
|
}
|
|
5115
|
-
},
|
|
5152
|
+
}, go = ({
|
|
5116
5153
|
x1: h,
|
|
5117
5154
|
y1: t,
|
|
5118
5155
|
x2: e,
|
|
5119
5156
|
y2: s
|
|
5120
|
-
}) => (Math.atan2(s - t, e - h) * 180 / Math.PI + 360) % 360,
|
|
5157
|
+
}) => (Math.atan2(s - t, e - h) * 180 / Math.PI + 360) % 360, fo = (h) => {
|
|
5121
5158
|
if (!h || typeof h != "object") return null;
|
|
5122
5159
|
const { type: t, coords: e, colorStops: s } = h, o = Array.isArray(s) ? s : [], n = o[0], i = o[o.length - 1], a = typeof (n == null ? void 0 : n.color) == "string" ? n.color : void 0, r = typeof (i == null ? void 0 : i.color) == "string" ? i.color : a, c = typeof (n == null ? void 0 : n.offset) == "number" ? n.offset * 100 : void 0, d = typeof (i == null ? void 0 : i.offset) == "number" ? i.offset * 100 : void 0;
|
|
5123
5160
|
if (!a || !r || !e) return null;
|
|
@@ -5126,7 +5163,7 @@ const tt = ({
|
|
|
5126
5163
|
if (typeof l == "number" && typeof u == "number" && typeof g == "number" && typeof f == "number")
|
|
5127
5164
|
return {
|
|
5128
5165
|
type: "linear",
|
|
5129
|
-
angle:
|
|
5166
|
+
angle: go({ x1: l, y1: u, x2: g, y2: f }),
|
|
5130
5167
|
startColor: a,
|
|
5131
5168
|
endColor: r,
|
|
5132
5169
|
startPosition: c,
|
|
@@ -5149,7 +5186,7 @@ const tt = ({
|
|
|
5149
5186
|
}
|
|
5150
5187
|
return null;
|
|
5151
5188
|
}, ne = "_templateCenterX", ie = "_templateCenterY", ae = "_templateAnchorX", re = "_templateAnchorY";
|
|
5152
|
-
class
|
|
5189
|
+
class L {
|
|
5153
5190
|
constructor({ editor: t }) {
|
|
5154
5191
|
this.editor = t;
|
|
5155
5192
|
}
|
|
@@ -5168,28 +5205,28 @@ class D {
|
|
|
5168
5205
|
montageArea: i,
|
|
5169
5206
|
errorManager: a,
|
|
5170
5207
|
backgroundManager: r
|
|
5171
|
-
} = this.editor, c = n.getActiveObject(), d =
|
|
5208
|
+
} = this.editor, c = n.getActiveObject(), d = L._collectObjects(c), { backgroundObject: l } = r != null ? r : {}, u = o && l ? [l] : [], g = [...d, ...u];
|
|
5172
5209
|
if (!g.length)
|
|
5173
5210
|
return a.emitWarning({
|
|
5174
5211
|
origin: "TemplateManager",
|
|
5175
5212
|
method: "serializeSelection",
|
|
5176
|
-
code:
|
|
5213
|
+
code: ft.TEMPLATE_MANAGER.NO_OBJECTS_SELECTED,
|
|
5177
5214
|
message: "Нет объектов для сериализации шаблона"
|
|
5178
5215
|
}), null;
|
|
5179
|
-
const f =
|
|
5216
|
+
const f = L._getBounds(i), p = L._getMontageSize({ montageArea: i, bounds: f }), m = p.width, v = p.height, b = g.map((w) => L._serializeObject({
|
|
5180
5217
|
object: w,
|
|
5181
5218
|
bounds: f,
|
|
5182
5219
|
baseWidth: m,
|
|
5183
5220
|
baseHeight: v,
|
|
5184
5221
|
montageArea: i != null ? i : null
|
|
5185
|
-
})), I =
|
|
5222
|
+
})), I = St(x({}, s), {
|
|
5186
5223
|
baseWidth: m,
|
|
5187
5224
|
baseHeight: v,
|
|
5188
5225
|
positionsNormalized: !0,
|
|
5189
5226
|
previewId: e != null ? e : s.previewId
|
|
5190
5227
|
});
|
|
5191
5228
|
return {
|
|
5192
|
-
id: t != null ? t : `template-${
|
|
5229
|
+
id: t != null ? t : `template-${F()}`,
|
|
5193
5230
|
meta: I,
|
|
5194
5231
|
objects: b
|
|
5195
5232
|
};
|
|
@@ -5216,36 +5253,36 @@ class D {
|
|
|
5216
5253
|
return a.emitWarning({
|
|
5217
5254
|
origin: "TemplateManager",
|
|
5218
5255
|
method: "applyTemplate",
|
|
5219
|
-
code:
|
|
5256
|
+
code: ft.TEMPLATE_MANAGER.INVALID_TEMPLATE,
|
|
5220
5257
|
message: "Шаблон не содержит объектов"
|
|
5221
5258
|
}), null;
|
|
5222
|
-
const u =
|
|
5259
|
+
const u = L._getBounds(n);
|
|
5223
5260
|
if (!u)
|
|
5224
5261
|
return a.emitWarning({
|
|
5225
5262
|
origin: "TemplateManager",
|
|
5226
5263
|
method: "applyTemplate",
|
|
5227
|
-
code:
|
|
5264
|
+
code: ft.TEMPLATE_MANAGER.INVALID_TARGET,
|
|
5228
5265
|
message: "Не удалось определить границы монтажной области"
|
|
5229
5266
|
}), null;
|
|
5230
|
-
const g =
|
|
5267
|
+
const g = L._getMontageSize({ montageArea: n, bounds: u }), f = L._normalizeMeta({ meta: d, fallback: g }), p = L._calculateScale({ meta: f, target: g }), m = !!f.positionsNormalized;
|
|
5231
5268
|
let v = !1, b = !1;
|
|
5232
5269
|
i.suspendHistory();
|
|
5233
5270
|
try {
|
|
5234
|
-
const I = yield
|
|
5271
|
+
const I = yield L._enlivenObjects(c);
|
|
5235
5272
|
if (!I.length)
|
|
5236
5273
|
return a.emitWarning({
|
|
5237
5274
|
origin: "TemplateManager",
|
|
5238
5275
|
method: "applyTemplate",
|
|
5239
|
-
code:
|
|
5276
|
+
code: ft.TEMPLATE_MANAGER.INVALID_TEMPLATE,
|
|
5240
5277
|
message: "Не удалось создать объекты шаблона"
|
|
5241
5278
|
}), null;
|
|
5242
|
-
const { backgroundObject: y, contentObjects: w } =
|
|
5243
|
-
y && (b = yield
|
|
5279
|
+
const { backgroundObject: y, contentObjects: w } = L._extractBackgroundObject(I);
|
|
5280
|
+
y && (b = yield L._applyBackgroundFromObject({
|
|
5244
5281
|
backgroundObject: y,
|
|
5245
5282
|
backgroundManager: r,
|
|
5246
5283
|
errorManager: a
|
|
5247
5284
|
}));
|
|
5248
|
-
const S = w.map((A) => (
|
|
5285
|
+
const S = w.map((A) => (L._applyTextOverrides({ object: A, data: e }), L._transformObject({
|
|
5249
5286
|
object: A,
|
|
5250
5287
|
scale: p,
|
|
5251
5288
|
bounds: u,
|
|
@@ -5255,10 +5292,10 @@ class D {
|
|
|
5255
5292
|
montageArea: n,
|
|
5256
5293
|
useRelativePositions: m
|
|
5257
5294
|
}), A.set({
|
|
5258
|
-
id: `${A.type}-${
|
|
5295
|
+
id: `${A.type}-${F()}`,
|
|
5259
5296
|
evented: !0
|
|
5260
5297
|
}), o.add(A), A));
|
|
5261
|
-
return !S.length && !b ? null : (v = S.length > 0 || b, S.length &&
|
|
5298
|
+
return !S.length && !b ? null : (v = S.length > 0 || b, S.length && L._activateObjects({ canvas: o, objects: S }), o.requestRenderAll(), o.fire("editor:template-applied", {
|
|
5262
5299
|
template: t,
|
|
5263
5300
|
objects: S,
|
|
5264
5301
|
bounds: u
|
|
@@ -5267,7 +5304,7 @@ class D {
|
|
|
5267
5304
|
return a.emitError({
|
|
5268
5305
|
origin: "TemplateManager",
|
|
5269
5306
|
method: "applyTemplate",
|
|
5270
|
-
code:
|
|
5307
|
+
code: ft.TEMPLATE_MANAGER.APPLY_FAILED,
|
|
5271
5308
|
message: "Ошибка применения шаблона",
|
|
5272
5309
|
data: {
|
|
5273
5310
|
templateId: l,
|
|
@@ -5283,7 +5320,7 @@ class D {
|
|
|
5283
5320
|
* Подготавливает объекты для сериализации.
|
|
5284
5321
|
*/
|
|
5285
5322
|
static _collectObjects(t) {
|
|
5286
|
-
return t ? t instanceof
|
|
5323
|
+
return t ? t instanceof k ? t.getObjects() : [t] : [];
|
|
5287
5324
|
}
|
|
5288
5325
|
/**
|
|
5289
5326
|
* Возвращает габариты объекта.
|
|
@@ -5309,13 +5346,13 @@ class D {
|
|
|
5309
5346
|
static _enlivenObjects(t) {
|
|
5310
5347
|
return _(this, null, function* () {
|
|
5311
5348
|
return (yield Promise.all(t.map((s) => _(null, null, function* () {
|
|
5312
|
-
if (
|
|
5313
|
-
const i = yield
|
|
5349
|
+
if (L._hasSerializedSvgMarkup(s)) {
|
|
5350
|
+
const i = yield L._reviveSvgObject(s);
|
|
5314
5351
|
if (i)
|
|
5315
|
-
return
|
|
5352
|
+
return L._restoreImageScale({ revived: i, serialized: s }), i;
|
|
5316
5353
|
}
|
|
5317
|
-
const o = yield
|
|
5318
|
-
return n ? (
|
|
5354
|
+
const o = yield ct.enlivenObjects([s]), n = o == null ? void 0 : o[0];
|
|
5355
|
+
return n ? (L._restoreImageScale({ revived: n, serialized: s }), n) : null;
|
|
5319
5356
|
})))).filter((s) => !!s);
|
|
5320
5357
|
});
|
|
5321
5358
|
}
|
|
@@ -5359,8 +5396,8 @@ class D {
|
|
|
5359
5396
|
const e = typeof t.svgMarkup == "string" ? t.svgMarkup : null;
|
|
5360
5397
|
if (!e) return null;
|
|
5361
5398
|
try {
|
|
5362
|
-
const s = yield
|
|
5363
|
-
|
|
5399
|
+
const s = yield ys(e), o = ct.groupSVGElements(s.objects, s.options), n = yield ct.enlivenObjectEnlivables(
|
|
5400
|
+
L._prepareSerializableProps(t)
|
|
5364
5401
|
);
|
|
5365
5402
|
return o.set(n), o.setCoords(), o;
|
|
5366
5403
|
} catch (s) {
|
|
@@ -5372,7 +5409,7 @@ class D {
|
|
|
5372
5409
|
* Убирает технические поля сериализации, оставляя только применимые свойства.
|
|
5373
5410
|
*/
|
|
5374
5411
|
static _prepareSerializableProps(t) {
|
|
5375
|
-
const e =
|
|
5412
|
+
const e = x({}, t);
|
|
5376
5413
|
return delete e.svgMarkup, delete e.objects, delete e.path, delete e.paths, delete e.type, delete e.version, e;
|
|
5377
5414
|
}
|
|
5378
5415
|
/**
|
|
@@ -5418,7 +5455,7 @@ class D {
|
|
|
5418
5455
|
montageArea: a,
|
|
5419
5456
|
useRelativePositions: r
|
|
5420
5457
|
}) {
|
|
5421
|
-
const c = t, { x: d, y: l } =
|
|
5458
|
+
const c = t, { x: d, y: l } = lo({
|
|
5422
5459
|
object: t,
|
|
5423
5460
|
baseWidth: n,
|
|
5424
5461
|
baseHeight: i,
|
|
@@ -5427,15 +5464,15 @@ class D {
|
|
|
5427
5464
|
x: ne,
|
|
5428
5465
|
y: ie
|
|
5429
5466
|
}
|
|
5430
|
-
}), { scaleX: u, scaleY: g } = t, f = tt({ value: u, fallback: 1 }), p = tt({ value: g, fallback: 1 }), m =
|
|
5467
|
+
}), { scaleX: u, scaleY: g } = t, f = tt({ value: u, fallback: 1 }), p = tt({ value: g, fallback: 1 }), m = L._getPositioningBounds({
|
|
5431
5468
|
bounds: s,
|
|
5432
5469
|
baseWidth: n,
|
|
5433
5470
|
baseHeight: i,
|
|
5434
5471
|
scale: e,
|
|
5435
5472
|
useRelativePositions: r,
|
|
5436
|
-
anchorX:
|
|
5437
|
-
anchorY:
|
|
5438
|
-
}), v =
|
|
5473
|
+
anchorX: L._resolveAnchor(c, ae),
|
|
5474
|
+
anchorY: L._resolveAnchor(c, re)
|
|
5475
|
+
}), v = ho({
|
|
5439
5476
|
normalizedX: d,
|
|
5440
5477
|
normalizedY: l,
|
|
5441
5478
|
bounds: m,
|
|
@@ -5461,7 +5498,7 @@ class D {
|
|
|
5461
5498
|
anchorY: a
|
|
5462
5499
|
}) {
|
|
5463
5500
|
if (!n) return t;
|
|
5464
|
-
const r = (e || t.width) * o, c = (s || t.height) * o, d = t.width - r, l = t.height - c, u = t.left +
|
|
5501
|
+
const r = (e || t.width) * o, c = (s || t.height) * o, d = t.width - r, l = t.height - c, u = t.left + L._calculateAnchorOffset(i, d), g = t.top + L._calculateAnchorOffset(a, l);
|
|
5465
5502
|
return {
|
|
5466
5503
|
left: u,
|
|
5467
5504
|
top: g,
|
|
@@ -5495,8 +5532,8 @@ class D {
|
|
|
5495
5532
|
meta: t,
|
|
5496
5533
|
fallback: e
|
|
5497
5534
|
}) {
|
|
5498
|
-
const { width: s, height: o } = e, r = t || {}, { baseWidth: n = s, baseHeight: i = o } = r, a =
|
|
5499
|
-
return
|
|
5535
|
+
const { width: s, height: o } = e, r = t || {}, { baseWidth: n = s, baseHeight: i = o } = r, a = gt(r, ["baseWidth", "baseHeight"]);
|
|
5536
|
+
return x({
|
|
5500
5537
|
baseWidth: n,
|
|
5501
5538
|
baseHeight: i
|
|
5502
5539
|
}, a);
|
|
@@ -5523,7 +5560,7 @@ class D {
|
|
|
5523
5560
|
t.setActiveObject(e[0]);
|
|
5524
5561
|
return;
|
|
5525
5562
|
}
|
|
5526
|
-
const s = new
|
|
5563
|
+
const s = new k(e, { canvas: t });
|
|
5527
5564
|
t.setActiveObject(s);
|
|
5528
5565
|
}
|
|
5529
5566
|
/**
|
|
@@ -5547,9 +5584,9 @@ class D {
|
|
|
5547
5584
|
baseHeight: o,
|
|
5548
5585
|
montageArea: n
|
|
5549
5586
|
}) {
|
|
5550
|
-
const i = t.toDatalessObject([...
|
|
5551
|
-
if (
|
|
5552
|
-
const y =
|
|
5587
|
+
const i = t.toDatalessObject([...ss]);
|
|
5588
|
+
if (L._isSvgObject(t)) {
|
|
5589
|
+
const y = L._extractSvgMarkup(t);
|
|
5553
5590
|
y && (i.svgMarkup = y, delete i.objects, delete i.path);
|
|
5554
5591
|
}
|
|
5555
5592
|
if (!e) return i;
|
|
@@ -5558,7 +5595,7 @@ class D {
|
|
|
5558
5595
|
top: r,
|
|
5559
5596
|
width: c,
|
|
5560
5597
|
height: d
|
|
5561
|
-
} = e, l = t.getBoundingRect(!1, !0), u = s || c || 1, g = o || d || 1, f =
|
|
5598
|
+
} = e, l = t.getBoundingRect(!1, !0), u = s || c || 1, g = o || d || 1, f = uo({
|
|
5562
5599
|
object: t,
|
|
5563
5600
|
montageArea: n,
|
|
5564
5601
|
bounds: e
|
|
@@ -5569,11 +5606,11 @@ class D {
|
|
|
5569
5606
|
y: (y.y - r) / g
|
|
5570
5607
|
};
|
|
5571
5608
|
})(), m = (l.left - a) / u, v = (l.top - r) / g, b = m + l.width / u, I = v + l.height / g;
|
|
5572
|
-
return i[ne] = p.x, i[ie] = p.y, i[ae] =
|
|
5609
|
+
return i[ne] = p.x, i[ie] = p.y, i[ae] = L._detectAnchor({
|
|
5573
5610
|
center: p.x,
|
|
5574
5611
|
start: m,
|
|
5575
5612
|
end: b
|
|
5576
|
-
}), i[re] =
|
|
5613
|
+
}), i[re] = L._detectAnchor({
|
|
5577
5614
|
center: p.y,
|
|
5578
5615
|
start: v,
|
|
5579
5616
|
end: I
|
|
@@ -5599,7 +5636,7 @@ class D {
|
|
|
5599
5636
|
errorManager: s
|
|
5600
5637
|
}) {
|
|
5601
5638
|
try {
|
|
5602
|
-
const { fill: n, customData: i } = t, { backgroundType: a } = t, r =
|
|
5639
|
+
const { fill: n, customData: i } = t, { backgroundType: a } = t, r = L._cloneCustomData(i);
|
|
5603
5640
|
if (a === "color" && typeof n == "string")
|
|
5604
5641
|
return e.setColorBackground({
|
|
5605
5642
|
color: n,
|
|
@@ -5607,7 +5644,7 @@ class D {
|
|
|
5607
5644
|
withoutSave: !0
|
|
5608
5645
|
}), !0;
|
|
5609
5646
|
if (a === "gradient") {
|
|
5610
|
-
const c =
|
|
5647
|
+
const c = fo(n);
|
|
5611
5648
|
if (c)
|
|
5612
5649
|
return e.setGradientBackground({
|
|
5613
5650
|
gradient: c,
|
|
@@ -5616,7 +5653,7 @@ class D {
|
|
|
5616
5653
|
}), !0;
|
|
5617
5654
|
}
|
|
5618
5655
|
if (a === "image") {
|
|
5619
|
-
const c =
|
|
5656
|
+
const c = L._getImageSource(t);
|
|
5620
5657
|
if (c)
|
|
5621
5658
|
return yield e.setImageBackground({
|
|
5622
5659
|
imageSource: c,
|
|
@@ -5628,7 +5665,7 @@ class D {
|
|
|
5628
5665
|
s.emitWarning({
|
|
5629
5666
|
origin: "TemplateManager",
|
|
5630
5667
|
method: "applyTemplate",
|
|
5631
|
-
code:
|
|
5668
|
+
code: ft.TEMPLATE_MANAGER.APPLY_FAILED,
|
|
5632
5669
|
message: "Не удалось применить фон из шаблона",
|
|
5633
5670
|
data: n
|
|
5634
5671
|
});
|
|
@@ -5658,7 +5695,7 @@ class D {
|
|
|
5658
5695
|
*/
|
|
5659
5696
|
static _cloneCustomData(t) {
|
|
5660
5697
|
if (!(!t || typeof t != "object"))
|
|
5661
|
-
return
|
|
5698
|
+
return x({}, t);
|
|
5662
5699
|
}
|
|
5663
5700
|
/**
|
|
5664
5701
|
* Извлекает src изображения из FabricImage или его исходного элемента.
|
|
@@ -5684,10 +5721,10 @@ class D {
|
|
|
5684
5721
|
*/
|
|
5685
5722
|
// eslint-disable-next-line class-methods-use-this
|
|
5686
5723
|
enlivenObjectEnlivables(t) {
|
|
5687
|
-
return
|
|
5724
|
+
return ct.enlivenObjectEnlivables(t);
|
|
5688
5725
|
}
|
|
5689
5726
|
}
|
|
5690
|
-
const
|
|
5727
|
+
const po = 5, os = "#3D8BF4", ge = 1, Xt = 1, Qe = ({
|
|
5691
5728
|
anchors: h,
|
|
5692
5729
|
positions: t,
|
|
5693
5730
|
threshold: e
|
|
@@ -5702,16 +5739,16 @@ const uo = 5, ts = "#3D8BF4", ge = 1, Ve = ({
|
|
|
5702
5739
|
delta: s,
|
|
5703
5740
|
guidePosition: n
|
|
5704
5741
|
};
|
|
5705
|
-
},
|
|
5742
|
+
}, mo = ({
|
|
5706
5743
|
activeBounds: h,
|
|
5707
5744
|
threshold: t,
|
|
5708
5745
|
anchors: e
|
|
5709
5746
|
}) => {
|
|
5710
|
-
const { left: s, right: o, centerX: n, top: i, bottom: a, centerY: r } = h, c =
|
|
5747
|
+
const { left: s, right: o, centerX: n, top: i, bottom: a, centerY: r } = h, c = Qe({
|
|
5711
5748
|
anchors: e.vertical,
|
|
5712
5749
|
positions: [s, n, o],
|
|
5713
5750
|
threshold: t
|
|
5714
|
-
}), d =
|
|
5751
|
+
}), d = Qe({
|
|
5715
5752
|
anchors: e.horizontal,
|
|
5716
5753
|
positions: [i, r, a],
|
|
5717
5754
|
threshold: t
|
|
@@ -5727,7 +5764,7 @@ const uo = 5, ts = "#3D8BF4", ge = 1, Ve = ({
|
|
|
5727
5764
|
deltaY: d.delta,
|
|
5728
5765
|
guides: l
|
|
5729
5766
|
};
|
|
5730
|
-
},
|
|
5767
|
+
}, ns = ({
|
|
5731
5768
|
activeBounds: h,
|
|
5732
5769
|
aligned: t,
|
|
5733
5770
|
threshold: e,
|
|
@@ -5799,7 +5836,7 @@ const uo = 5, ts = "#3D8BF4", ge = 1, Ve = ({
|
|
|
5799
5836
|
}
|
|
5800
5837
|
}
|
|
5801
5838
|
return c;
|
|
5802
|
-
},
|
|
5839
|
+
}, yo = ({
|
|
5803
5840
|
activeBounds: h,
|
|
5804
5841
|
candidates: t,
|
|
5805
5842
|
threshold: e,
|
|
@@ -5856,22 +5893,22 @@ const uo = 5, ts = "#3D8BF4", ge = 1, Ve = ({
|
|
|
5856
5893
|
if (u && f) {
|
|
5857
5894
|
const { bounds: y } = u, { bounds: w } = f, A = w.top - y.bottom - v;
|
|
5858
5895
|
if (A >= 0) {
|
|
5859
|
-
const M = A / 2, C = n - y.bottom, j = w.top - i, T = Math.abs(C - M),
|
|
5860
|
-
if (
|
|
5861
|
-
const
|
|
5896
|
+
const M = A / 2, C = n - y.bottom, j = w.top - i, T = Math.abs(C - M), B = Math.abs(j - M), G = Math.max(T, B);
|
|
5897
|
+
if (G <= e) {
|
|
5898
|
+
const Y = M - C, H = i + Y, V = {
|
|
5862
5899
|
type: "vertical",
|
|
5863
5900
|
axis: o,
|
|
5864
5901
|
refStart: y.bottom,
|
|
5865
5902
|
refEnd: y.bottom + M,
|
|
5866
|
-
activeStart:
|
|
5867
|
-
activeEnd:
|
|
5903
|
+
activeStart: H,
|
|
5904
|
+
activeEnd: H + M,
|
|
5868
5905
|
distance: M
|
|
5869
5906
|
};
|
|
5870
|
-
m.push({ delta:
|
|
5907
|
+
m.push({ delta: Y, guide: V, diff: G });
|
|
5871
5908
|
}
|
|
5872
5909
|
}
|
|
5873
5910
|
}
|
|
5874
|
-
const b =
|
|
5911
|
+
const b = ns({
|
|
5875
5912
|
activeBounds: h,
|
|
5876
5913
|
aligned: c,
|
|
5877
5914
|
threshold: e,
|
|
@@ -5885,7 +5922,7 @@ const uo = 5, ts = "#3D8BF4", ge = 1, Ve = ({
|
|
|
5885
5922
|
delta: I.delta,
|
|
5886
5923
|
guide: I.guide
|
|
5887
5924
|
};
|
|
5888
|
-
},
|
|
5925
|
+
}, vo = ({
|
|
5889
5926
|
activeBounds: h,
|
|
5890
5927
|
candidates: t,
|
|
5891
5928
|
threshold: e,
|
|
@@ -5942,22 +5979,22 @@ const uo = 5, ts = "#3D8BF4", ge = 1, Ve = ({
|
|
|
5942
5979
|
if (u && f) {
|
|
5943
5980
|
const { bounds: y } = u, { bounds: w } = f, A = w.left - y.right - v;
|
|
5944
5981
|
if (A >= 0) {
|
|
5945
|
-
const M = A / 2, C = n - y.right, j = w.left - i, T = Math.abs(C - M),
|
|
5946
|
-
if (
|
|
5947
|
-
const
|
|
5982
|
+
const M = A / 2, C = n - y.right, j = w.left - i, T = Math.abs(C - M), B = Math.abs(j - M), G = Math.max(T, B);
|
|
5983
|
+
if (G <= e) {
|
|
5984
|
+
const Y = M - C, H = i + Y, V = {
|
|
5948
5985
|
type: "horizontal",
|
|
5949
5986
|
axis: o,
|
|
5950
5987
|
refStart: y.right,
|
|
5951
5988
|
refEnd: y.right + M,
|
|
5952
|
-
activeStart:
|
|
5953
|
-
activeEnd:
|
|
5989
|
+
activeStart: H,
|
|
5990
|
+
activeEnd: H + M,
|
|
5954
5991
|
distance: M
|
|
5955
5992
|
};
|
|
5956
|
-
m.push({ delta:
|
|
5993
|
+
m.push({ delta: Y, guide: V, diff: G });
|
|
5957
5994
|
}
|
|
5958
5995
|
}
|
|
5959
5996
|
}
|
|
5960
|
-
const b =
|
|
5997
|
+
const b = ns({
|
|
5961
5998
|
activeBounds: h,
|
|
5962
5999
|
aligned: c,
|
|
5963
6000
|
threshold: e,
|
|
@@ -5971,18 +6008,18 @@ const uo = 5, ts = "#3D8BF4", ge = 1, Ve = ({
|
|
|
5971
6008
|
delta: I.delta,
|
|
5972
6009
|
guide: I.guide
|
|
5973
6010
|
};
|
|
5974
|
-
},
|
|
6011
|
+
}, bo = ({
|
|
5975
6012
|
activeBounds: h,
|
|
5976
6013
|
candidates: t,
|
|
5977
6014
|
threshold: e,
|
|
5978
6015
|
spacingPatterns: s
|
|
5979
6016
|
}) => {
|
|
5980
|
-
const o =
|
|
6017
|
+
const o = yo({
|
|
5981
6018
|
activeBounds: h,
|
|
5982
6019
|
candidates: t,
|
|
5983
6020
|
threshold: e,
|
|
5984
6021
|
patterns: s.vertical
|
|
5985
|
-
}), n =
|
|
6022
|
+
}), n = vo({
|
|
5986
6023
|
activeBounds: h,
|
|
5987
6024
|
candidates: t,
|
|
5988
6025
|
threshold: e,
|
|
@@ -5993,7 +6030,7 @@ const uo = 5, ts = "#3D8BF4", ge = 1, Ve = ({
|
|
|
5993
6030
|
deltaY: o.delta,
|
|
5994
6031
|
guides: i
|
|
5995
6032
|
};
|
|
5996
|
-
},
|
|
6033
|
+
}, Mo = ({
|
|
5997
6034
|
context: h,
|
|
5998
6035
|
x: t,
|
|
5999
6036
|
y: e,
|
|
@@ -6023,7 +6060,7 @@ const uo = 5, ts = "#3D8BF4", ge = 1, Ve = ({
|
|
|
6023
6060
|
const p = i || 1, m = 12 / p, v = l / p, b = u / p, I = (s + o) / 2 + g, y = t === "vertical" ? e + f : I, w = t === "vertical" ? I : e + f;
|
|
6024
6061
|
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";
|
|
6025
6062
|
const A = h.measureText(n).width + v * 2, M = m + v * 2, C = y - A / 2, j = w - M / 2;
|
|
6026
|
-
h.beginPath(),
|
|
6063
|
+
h.beginPath(), Mo({
|
|
6027
6064
|
context: h,
|
|
6028
6065
|
x: C,
|
|
6029
6066
|
y: j,
|
|
@@ -6031,7 +6068,7 @@ const uo = 5, ts = "#3D8BF4", ge = 1, Ve = ({
|
|
|
6031
6068
|
height: M,
|
|
6032
6069
|
radius: b
|
|
6033
6070
|
}), h.fill(), h.fillStyle = r, h.fillText(n, y, w), h.restore();
|
|
6034
|
-
},
|
|
6071
|
+
}, wo = ({
|
|
6035
6072
|
context: h,
|
|
6036
6073
|
guide: t,
|
|
6037
6074
|
zoom: e
|
|
@@ -6046,7 +6083,7 @@ const uo = 5, ts = "#3D8BF4", ge = 1, Ve = ({
|
|
|
6046
6083
|
distance: c
|
|
6047
6084
|
} = t, d = Math.round(c).toString();
|
|
6048
6085
|
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();
|
|
6049
|
-
const l =
|
|
6086
|
+
const l = os;
|
|
6050
6087
|
fe({
|
|
6051
6088
|
context: h,
|
|
6052
6089
|
type: s,
|
|
@@ -6068,7 +6105,7 @@ const uo = 5, ts = "#3D8BF4", ge = 1, Ve = ({
|
|
|
6068
6105
|
color: l,
|
|
6069
6106
|
lineWidth: ge
|
|
6070
6107
|
});
|
|
6071
|
-
},
|
|
6108
|
+
}, qe = ({
|
|
6072
6109
|
anchors: h,
|
|
6073
6110
|
bounds: t
|
|
6074
6111
|
}) => {
|
|
@@ -6081,7 +6118,7 @@ const uo = 5, ts = "#3D8BF4", ge = 1, Ve = ({
|
|
|
6081
6118
|
centerY: a
|
|
6082
6119
|
} = t;
|
|
6083
6120
|
h.vertical.push(e, o, s), h.horizontal.push(n, a, i);
|
|
6084
|
-
},
|
|
6121
|
+
}, $e = ({
|
|
6085
6122
|
bounds: h,
|
|
6086
6123
|
type: t,
|
|
6087
6124
|
primaryStart: e,
|
|
@@ -6108,30 +6145,30 @@ const uo = 5, ts = "#3D8BF4", ge = 1, Ve = ({
|
|
|
6108
6145
|
});
|
|
6109
6146
|
}
|
|
6110
6147
|
return o;
|
|
6111
|
-
},
|
|
6148
|
+
}, So = ({
|
|
6112
6149
|
bounds: h
|
|
6113
6150
|
}) => {
|
|
6114
|
-
const t =
|
|
6151
|
+
const t = $e({
|
|
6115
6152
|
bounds: h,
|
|
6116
6153
|
type: "vertical",
|
|
6117
6154
|
primaryStart: "top",
|
|
6118
6155
|
primaryEnd: "bottom"
|
|
6119
|
-
}), e =
|
|
6156
|
+
}), e = $e({
|
|
6120
6157
|
bounds: h,
|
|
6121
6158
|
type: "horizontal",
|
|
6122
6159
|
primaryStart: "left",
|
|
6123
6160
|
primaryEnd: "right"
|
|
6124
6161
|
});
|
|
6125
6162
|
return { vertical: t, horizontal: e };
|
|
6126
|
-
},
|
|
6163
|
+
}, Ao = ["montage-area", "background", "interaction-blocker"], is = ({
|
|
6127
6164
|
activeObject: h
|
|
6128
6165
|
}) => {
|
|
6129
6166
|
const t = /* @__PURE__ */ new Set();
|
|
6130
|
-
return h && (t.add(h), h instanceof
|
|
6131
|
-
},
|
|
6167
|
+
return h && (t.add(h), h instanceof k && h.getObjects().forEach((e) => t.add(e))), t;
|
|
6168
|
+
}, as = ({
|
|
6132
6169
|
object: h,
|
|
6133
6170
|
excluded: t,
|
|
6134
|
-
ignoredIds: e =
|
|
6171
|
+
ignoredIds: e = Ao
|
|
6135
6172
|
}) => {
|
|
6136
6173
|
if (t.has(h)) return !0;
|
|
6137
6174
|
const { visible: s = !0 } = h;
|
|
@@ -6139,7 +6176,7 @@ const uo = 5, ts = "#3D8BF4", ge = 1, Ve = ({
|
|
|
6139
6176
|
const { id: o } = h;
|
|
6140
6177
|
return !!(o && e.includes(o));
|
|
6141
6178
|
};
|
|
6142
|
-
class
|
|
6179
|
+
class jo {
|
|
6143
6180
|
/**
|
|
6144
6181
|
* Создаёт менеджер прилипания и инициализирует слушатели событий.
|
|
6145
6182
|
*/
|
|
@@ -6186,51 +6223,51 @@ class wo {
|
|
|
6186
6223
|
* Выполняет привязку объекта к ближайшим линиям при его перемещении.
|
|
6187
6224
|
*/
|
|
6188
6225
|
_handleObjectMoving(t) {
|
|
6189
|
-
var
|
|
6226
|
+
var p, m;
|
|
6190
6227
|
const { target: e, e: s } = t;
|
|
6191
6228
|
if (!e) {
|
|
6192
6229
|
this._clearGuides();
|
|
6193
6230
|
return;
|
|
6194
6231
|
}
|
|
6195
|
-
if (s != null && s.ctrlKey) {
|
|
6196
|
-
this._clearGuides();
|
|
6232
|
+
if (!!(s != null && s.ctrlKey)) {
|
|
6233
|
+
this._clearGuides(), this._applyMovementStep({ target: e });
|
|
6197
6234
|
return;
|
|
6198
6235
|
}
|
|
6199
6236
|
!this.anchors.vertical.length && !this.anchors.horizontal.length && this._cacheAnchors({ activeObject: e });
|
|
6200
|
-
let
|
|
6201
|
-
if (!
|
|
6237
|
+
let n = ht({ object: e });
|
|
6238
|
+
if (!n) {
|
|
6202
6239
|
this._clearGuides();
|
|
6203
6240
|
return;
|
|
6204
6241
|
}
|
|
6205
|
-
const { canvas:
|
|
6206
|
-
activeBounds:
|
|
6207
|
-
threshold:
|
|
6242
|
+
const { canvas: i } = this, a = i.getZoom() || 1, r = po / a, c = mo({
|
|
6243
|
+
activeBounds: n,
|
|
6244
|
+
threshold: r,
|
|
6208
6245
|
anchors: this.anchors
|
|
6209
|
-
}), { deltaX:
|
|
6210
|
-
if (
|
|
6211
|
-
const { left:
|
|
6246
|
+
}), { deltaX: d, deltaY: l, guides: u } = c;
|
|
6247
|
+
if (d !== 0 || l !== 0) {
|
|
6248
|
+
const { left: v = 0, top: b = 0 } = e;
|
|
6212
6249
|
e.set({
|
|
6213
|
-
left:
|
|
6214
|
-
top:
|
|
6215
|
-
}), e.setCoords(),
|
|
6216
|
-
}
|
|
6217
|
-
const
|
|
6218
|
-
activeBounds:
|
|
6219
|
-
candidates:
|
|
6220
|
-
threshold:
|
|
6250
|
+
left: v + d,
|
|
6251
|
+
top: b + l
|
|
6252
|
+
}), e.setCoords(), n = (p = ht({ object: e })) != null ? p : n;
|
|
6253
|
+
}
|
|
6254
|
+
const g = this.cachedTargetBounds.length ? this.cachedTargetBounds : this._collectTargets({ activeObject: e }).map((v) => ht({ object: v })).filter((v) => !!v), f = bo({
|
|
6255
|
+
activeBounds: n,
|
|
6256
|
+
candidates: g,
|
|
6257
|
+
threshold: r,
|
|
6221
6258
|
spacingPatterns: this.spacingPatterns
|
|
6222
6259
|
});
|
|
6223
|
-
if (
|
|
6224
|
-
const { left:
|
|
6260
|
+
if (f.deltaX !== 0 || f.deltaY !== 0) {
|
|
6261
|
+
const { left: v = 0, top: b = 0 } = e;
|
|
6225
6262
|
e.set({
|
|
6226
|
-
left:
|
|
6227
|
-
top:
|
|
6228
|
-
}), e.setCoords(),
|
|
6263
|
+
left: v + f.deltaX,
|
|
6264
|
+
top: b + f.deltaY
|
|
6265
|
+
}), e.setCoords(), n = (m = ht({ object: e })) != null ? m : n;
|
|
6229
6266
|
}
|
|
6230
6267
|
this._applyGuides({
|
|
6231
|
-
guides:
|
|
6232
|
-
spacingGuides:
|
|
6233
|
-
});
|
|
6268
|
+
guides: u,
|
|
6269
|
+
spacingGuides: f.guides
|
|
6270
|
+
}), this._applyMovementStep({ target: e });
|
|
6234
6271
|
}
|
|
6235
6272
|
/**
|
|
6236
6273
|
* Очищает направляющие и кеш после окончания перетаскивания.
|
|
@@ -6253,11 +6290,11 @@ class wo {
|
|
|
6253
6290
|
const { canvas: t, guideBounds: e } = this, s = t.getSelectionContext();
|
|
6254
6291
|
if (!s) return;
|
|
6255
6292
|
const o = e != null ? e : this._calculateViewportBounds(), { left: n, right: i, top: a, bottom: r } = o, { viewportTransform: c } = t, d = t.getZoom() || 1;
|
|
6256
|
-
s.save(), Array.isArray(c) && s.transform(...c), s.lineWidth = ge / d, s.strokeStyle =
|
|
6293
|
+
s.save(), Array.isArray(c) && s.transform(...c), s.lineWidth = ge / d, s.strokeStyle = os, s.setLineDash([4, 4]);
|
|
6257
6294
|
for (const l of this.activeGuides)
|
|
6258
6295
|
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();
|
|
6259
6296
|
for (const l of this.activeSpacingGuides)
|
|
6260
|
-
|
|
6297
|
+
wo({
|
|
6261
6298
|
context: s,
|
|
6262
6299
|
guide: l,
|
|
6263
6300
|
zoom: d
|
|
@@ -6289,18 +6326,28 @@ class wo {
|
|
|
6289
6326
|
_clearAnchors() {
|
|
6290
6327
|
this.anchors = { vertical: [], horizontal: [] }, this.spacingPatterns = { vertical: [], horizontal: [] }, this.cachedTargetBounds = [];
|
|
6291
6328
|
}
|
|
6329
|
+
/**
|
|
6330
|
+
* Применяет шаг перемещения, округляя координаты объекта к сетке MOVE_SNAP_STEP.
|
|
6331
|
+
*/
|
|
6332
|
+
_applyMovementStep({ target: t }) {
|
|
6333
|
+
const { left: e = 0, top: s = 0 } = t, o = Math.round(e / Xt) * Xt, n = Math.round(s / Xt) * Xt;
|
|
6334
|
+
o === e && n === s || (t.set({
|
|
6335
|
+
left: o,
|
|
6336
|
+
top: n
|
|
6337
|
+
}), t.setCoords());
|
|
6338
|
+
}
|
|
6292
6339
|
/**
|
|
6293
6340
|
* Сохраняет линии для прилипания от всех доступных объектов и монтажной области.
|
|
6294
6341
|
*/
|
|
6295
6342
|
_cacheAnchors({ activeObject: t }) {
|
|
6296
6343
|
const e = this._collectTargets({ activeObject: t }), s = { vertical: [], horizontal: [] }, o = [];
|
|
6297
6344
|
for (const a of e) {
|
|
6298
|
-
const r =
|
|
6299
|
-
r && (
|
|
6345
|
+
const r = ht({ object: a });
|
|
6346
|
+
r && (qe({ anchors: s, bounds: r }), o.push(r));
|
|
6300
6347
|
}
|
|
6301
|
-
const { montageArea: n } = this.editor, i =
|
|
6348
|
+
const { montageArea: n } = this.editor, i = ht({ object: n });
|
|
6302
6349
|
if (i) {
|
|
6303
|
-
|
|
6350
|
+
qe({ anchors: s, bounds: i });
|
|
6304
6351
|
const { left: a, right: r, top: c, bottom: d } = i;
|
|
6305
6352
|
this.guideBounds = {
|
|
6306
6353
|
left: a,
|
|
@@ -6310,15 +6357,15 @@ class wo {
|
|
|
6310
6357
|
};
|
|
6311
6358
|
} else
|
|
6312
6359
|
this.guideBounds = this._calculateViewportBounds();
|
|
6313
|
-
this.anchors = s, this.spacingPatterns =
|
|
6360
|
+
this.anchors = s, this.spacingPatterns = So({ bounds: o }), this.cachedTargetBounds = o;
|
|
6314
6361
|
}
|
|
6315
6362
|
/**
|
|
6316
6363
|
* Собирает объекты, подходящие для прилипания, исключая активный объект и запрещённые id.
|
|
6317
6364
|
*/
|
|
6318
6365
|
_collectTargets({ activeObject: t }) {
|
|
6319
|
-
const e =
|
|
6366
|
+
const e = is({ activeObject: t }), s = [];
|
|
6320
6367
|
return this.canvas.forEachObject((o) => {
|
|
6321
|
-
|
|
6368
|
+
as({ object: o, excluded: e }) || s.push(o);
|
|
6322
6369
|
}), s;
|
|
6323
6370
|
}
|
|
6324
6371
|
/**
|
|
@@ -6341,8 +6388,8 @@ class wo {
|
|
|
6341
6388
|
};
|
|
6342
6389
|
}
|
|
6343
6390
|
}
|
|
6344
|
-
const
|
|
6345
|
-
class
|
|
6391
|
+
const Je = "#3D8BF4", ts = 1;
|
|
6392
|
+
class Ct {
|
|
6346
6393
|
/**
|
|
6347
6394
|
* Создаёт менеджер измерений и инициализирует события.
|
|
6348
6395
|
*/
|
|
@@ -6447,15 +6494,15 @@ class At {
|
|
|
6447
6494
|
this._clearGuides();
|
|
6448
6495
|
return;
|
|
6449
6496
|
}
|
|
6450
|
-
const n =
|
|
6497
|
+
const n = ht({ object: o });
|
|
6451
6498
|
if (!n) {
|
|
6452
6499
|
this._clearGuides();
|
|
6453
6500
|
return;
|
|
6454
6501
|
}
|
|
6455
|
-
const i =
|
|
6502
|
+
const i = Ct._resolveTarget({
|
|
6456
6503
|
event: t,
|
|
6457
6504
|
activeObject: o
|
|
6458
|
-
}), { montageArea: a } = s, r = i != null ? i : a, c = r === a, d =
|
|
6505
|
+
}), { montageArea: a } = s, r = i != null ? i : a, c = r === a, d = ht({ object: r });
|
|
6459
6506
|
if (!d) {
|
|
6460
6507
|
this._clearGuides();
|
|
6461
6508
|
return;
|
|
@@ -6464,7 +6511,7 @@ class At {
|
|
|
6464
6511
|
this._clearGuides();
|
|
6465
6512
|
return;
|
|
6466
6513
|
}
|
|
6467
|
-
const u =
|
|
6514
|
+
const u = Ct._buildGuides({
|
|
6468
6515
|
activeBounds: n,
|
|
6469
6516
|
targetBounds: d,
|
|
6470
6517
|
targetIsMontageArea: c
|
|
@@ -6482,8 +6529,8 @@ class At {
|
|
|
6482
6529
|
event: t,
|
|
6483
6530
|
activeObject: e
|
|
6484
6531
|
}) {
|
|
6485
|
-
const { target: s } = t, o =
|
|
6486
|
-
return s && !
|
|
6532
|
+
const { target: s } = t, o = is({ activeObject: e });
|
|
6533
|
+
return s && !as({ object: s, excluded: o }) ? s : null;
|
|
6487
6534
|
}
|
|
6488
6535
|
/**
|
|
6489
6536
|
* Собирает вертикальные и горизонтальные направляющие расстояний.
|
|
@@ -6493,11 +6540,11 @@ class At {
|
|
|
6493
6540
|
targetBounds: e,
|
|
6494
6541
|
targetIsMontageArea: s
|
|
6495
6542
|
}) {
|
|
6496
|
-
const o =
|
|
6543
|
+
const o = Ct._buildHorizontalGuides({
|
|
6497
6544
|
activeBounds: t,
|
|
6498
6545
|
targetBounds: e,
|
|
6499
6546
|
targetIsMontageArea: s
|
|
6500
|
-
}), n =
|
|
6547
|
+
}), n = Ct._buildVerticalGuides({
|
|
6501
6548
|
activeBounds: t,
|
|
6502
6549
|
targetBounds: e,
|
|
6503
6550
|
targetIsMontageArea: s
|
|
@@ -6651,7 +6698,7 @@ class At {
|
|
|
6651
6698
|
const { canvas: t } = this, e = t.getSelectionContext();
|
|
6652
6699
|
if (!e) return;
|
|
6653
6700
|
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;
|
|
6654
|
-
e.save(), Array.isArray(s) && e.transform(...s), e.lineWidth =
|
|
6701
|
+
e.save(), Array.isArray(s) && e.transform(...s), e.lineWidth = ts / o, e.strokeStyle = Je, e.setLineDash([]);
|
|
6655
6702
|
for (const c of this.activeGuides) {
|
|
6656
6703
|
const { type: d, axis: l, start: u, end: g, distance: f } = c, p = Math.abs(g - u), m = u <= g ? -1 : 1, v = a ? m * (p / 2 + r) : 0, b = 0;
|
|
6657
6704
|
e.beginPath(), d === "vertical" ? (e.moveTo(l, u), e.lineTo(l, g)) : (e.moveTo(u, l), e.lineTo(g, l)), e.stroke(), fe({
|
|
@@ -6662,8 +6709,8 @@ class At {
|
|
|
6662
6709
|
end: g,
|
|
6663
6710
|
text: Math.round(f).toString(),
|
|
6664
6711
|
zoom: o,
|
|
6665
|
-
color:
|
|
6666
|
-
lineWidth:
|
|
6712
|
+
color: Je,
|
|
6713
|
+
lineWidth: ts,
|
|
6667
6714
|
offsetAlongAxis: v,
|
|
6668
6715
|
offsetPerpendicular: b
|
|
6669
6716
|
});
|
|
@@ -6696,7 +6743,7 @@ class Me {
|
|
|
6696
6743
|
* @param options - опции и настройки редактора
|
|
6697
6744
|
*/
|
|
6698
6745
|
constructor(t, e) {
|
|
6699
|
-
this.options = e, this.containerId = t, this.editorId = `${t}-${
|
|
6746
|
+
this.options = e, this.containerId = t, this.editorId = `${t}-${F()}`, this.clipboard = null, this.init();
|
|
6700
6747
|
}
|
|
6701
6748
|
/**
|
|
6702
6749
|
* Инициализация редактора.
|
|
@@ -6719,7 +6766,7 @@ class Me {
|
|
|
6719
6766
|
showRotationAngle: d,
|
|
6720
6767
|
_onReadyCallback: l
|
|
6721
6768
|
} = this.options;
|
|
6722
|
-
if (
|
|
6769
|
+
if ($.apply(), this.canvas = new vs(this.containerId, this.options), this.moduleLoader = new As(), this.workerManager = new Is(), this.errorManager = new zt({ editor: this }), this.historyManager = new Qt({ editor: this }), this.toolbar = new Ys({ editor: this }), this.transformManager = new qs({ editor: this }), this.zoomManager = new $s({ editor: this }), this.canvasManager = new Qs({ editor: this }), this.imageManager = new rt({ editor: this }), this.layerManager = new qt({ editor: this }), this.shapeManager = new to({ editor: this }), this.interactionBlocker = new Js({ editor: this }), this.backgroundManager = new It({ editor: this }), this.clipboardManager = new eo({ editor: this }), this.objectLockManager = new $t({ editor: this }), this.groupingManager = new so({ editor: this }), this.selectionManager = new oo({ editor: this }), this.deletionManager = new be({ editor: this }), this.panConstraintManager = new no({ editor: this }), this.snappingManager = new jo({ editor: this }), this.measurementManager = new Ct({ editor: this }), this.fontManager = new ue((u = this.options.fonts) != null ? u : []), this.textManager = new U({ editor: this }), this.templateManager = new L({ editor: this }), d && (this.angleIndicator = new ve({ editor: this })), this._createMontageArea(), this._createClippingArea(), this.listeners = new Bt({ 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) {
|
|
6723
6770
|
const {
|
|
6724
6771
|
source: g,
|
|
6725
6772
|
scale: f = `image-${c}`,
|
|
@@ -6792,7 +6839,7 @@ class Me {
|
|
|
6792
6839
|
const t = document.createElement("canvas");
|
|
6793
6840
|
t.width = 20, t.height = 20;
|
|
6794
6841
|
const e = t.getContext("2d");
|
|
6795
|
-
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
|
|
6842
|
+
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 bs({
|
|
6796
6843
|
source: t,
|
|
6797
6844
|
repeat: "repeat"
|
|
6798
6845
|
});
|
|
@@ -6824,7 +6871,7 @@ const E = [
|
|
|
6824
6871
|
"U+0490-0491",
|
|
6825
6872
|
"U+04B0-04B1",
|
|
6826
6873
|
"U+2116"
|
|
6827
|
-
].join(", "),
|
|
6874
|
+
].join(", "), Io = [
|
|
6828
6875
|
{
|
|
6829
6876
|
family: "Arial",
|
|
6830
6877
|
source: 'local("Arial"), local("Liberation Sans"), local("DejaVu Sans")',
|
|
@@ -7614,7 +7661,7 @@ const E = [
|
|
|
7614
7661
|
unicodeRange: E
|
|
7615
7662
|
}
|
|
7616
7663
|
}
|
|
7617
|
-
],
|
|
7664
|
+
], Co = {
|
|
7618
7665
|
/**
|
|
7619
7666
|
* Опции редактора
|
|
7620
7667
|
*/
|
|
@@ -7706,10 +7753,10 @@ const E = [
|
|
|
7706
7753
|
/**
|
|
7707
7754
|
* Список шрифтов, которые будут доступны в редакторе по умолчанию.
|
|
7708
7755
|
*/
|
|
7709
|
-
fonts:
|
|
7756
|
+
fonts: Io
|
|
7710
7757
|
};
|
|
7711
|
-
function
|
|
7712
|
-
const e =
|
|
7758
|
+
function Lo(h, t = {}) {
|
|
7759
|
+
const e = x(x({}, Co), t), s = document.getElementById(h);
|
|
7713
7760
|
if (!s)
|
|
7714
7761
|
return Promise.reject(new Error(`Контейнер с ID "${h}" не найден.`));
|
|
7715
7762
|
const o = document.createElement("canvas");
|
|
@@ -7720,6 +7767,6 @@ function Eo(h, t = {}) {
|
|
|
7720
7767
|
});
|
|
7721
7768
|
}
|
|
7722
7769
|
export {
|
|
7723
|
-
|
|
7770
|
+
Lo as default
|
|
7724
7771
|
};
|
|
7725
7772
|
//# sourceMappingURL=main.js.map
|