@anu3ev/fabric-image-editor 0.5.27 → 0.5.29
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 +1050 -968
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
1
|
+
var Mn = Object.defineProperty, Sn = Object.defineProperties;
|
|
2
|
+
var wn = Object.getOwnPropertyDescriptors;
|
|
3
3
|
var oe = Object.getOwnPropertySymbols;
|
|
4
|
-
var
|
|
5
|
-
var
|
|
4
|
+
var Ue = Object.prototype.hasOwnProperty, Ye = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var We = (d, t, e) => t in d ? Mn(d, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : d[t] = e, x = (d, t) => {
|
|
6
6
|
for (var e in t || (t = {}))
|
|
7
|
-
|
|
7
|
+
Ue.call(t, e) && We(d, e, t[e]);
|
|
8
8
|
if (oe)
|
|
9
9
|
for (var e of oe(t))
|
|
10
|
-
|
|
10
|
+
Ye.call(t, e) && We(d, e, t[e]);
|
|
11
11
|
return d;
|
|
12
|
-
}, It = (d, t) =>
|
|
12
|
+
}, It = (d, t) => Sn(d, wn(t));
|
|
13
13
|
var Mt = (d, t) => {
|
|
14
14
|
var e = {};
|
|
15
15
|
for (var n in d)
|
|
16
|
-
|
|
16
|
+
Ue.call(d, n) && t.indexOf(n) < 0 && (e[n] = d[n]);
|
|
17
17
|
if (d != null && oe)
|
|
18
18
|
for (var n of oe(d))
|
|
19
|
-
t.indexOf(n) < 0 &&
|
|
19
|
+
t.indexOf(n) < 0 && Ye.call(d, n) && (e[n] = d[n]);
|
|
20
20
|
return e;
|
|
21
21
|
};
|
|
22
22
|
var Z = (d, t, e) => new Promise((n, s) => {
|
|
@@ -35,16 +35,16 @@ var Z = (d, t, e) => new Promise((n, s) => {
|
|
|
35
35
|
}, a = (r) => r.done ? n(r.value) : Promise.resolve(r.value).then(o, i);
|
|
36
36
|
a((e = e.apply(d, t)).next());
|
|
37
37
|
});
|
|
38
|
-
import { ActiveSelection as X, Textbox as dt, util as
|
|
39
|
-
import { create as
|
|
40
|
-
import
|
|
41
|
-
var
|
|
38
|
+
import { ActiveSelection as X, Textbox as dt, util as ft, controlsUtils as He, InteractiveFabricObject as Ze, Point as at, FitContentLayout as Ge, loadSVGFromURL as An, FabricImage as Xt, Gradient as Ve, Rect as jn, Circle as In, Triangle as Cn, Group as Nt, Color as Tn, classRegistry as Xe, loadSVGFromString as On, Canvas as En, Pattern as Ln } from "fabric";
|
|
39
|
+
import { create as Dn } from "jsondiffpatch";
|
|
40
|
+
import _n from "diff-match-patch";
|
|
41
|
+
var xn = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", tt = function() {
|
|
42
42
|
for (var t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 21, e = "", n = crypto.getRandomValues(new Uint8Array(t |= 0)); t--; )
|
|
43
|
-
e +=
|
|
43
|
+
e += xn[n[t] & 63];
|
|
44
44
|
return e;
|
|
45
45
|
};
|
|
46
|
-
const
|
|
47
|
-
class
|
|
46
|
+
const Ke = 300;
|
|
47
|
+
class xe {
|
|
48
48
|
/**
|
|
49
49
|
* Конструктор принимает редактор и опции.
|
|
50
50
|
* @param params
|
|
@@ -62,7 +62,7 @@ class Le {
|
|
|
62
62
|
* @param params.options.adaptCanvasToContainerOnResize — адаптировать канвас к размерам контейнера при изменении размеров окна
|
|
63
63
|
*/
|
|
64
64
|
constructor({ editor: t, options: e = {} }) {
|
|
65
|
-
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 =
|
|
65
|
+
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 = xe.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 = this.handleObjectModifiedHistory.bind(this), this.handleObjectRotatingHistoryBound = this.handleObjectRotatingHistory.bind(this), this.handleObjectTransformStartBound = this.handleObjectTransformStart.bind(this), this.handleObjectTransformEndBound = this.handleObjectTransformEnd.bind(this), 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();
|
|
66
66
|
}
|
|
67
67
|
/**
|
|
68
68
|
* Инициализация всех обработчиков согласно опциям.
|
|
@@ -123,14 +123,14 @@ class Le {
|
|
|
123
123
|
handleObjectModifiedHistory() {
|
|
124
124
|
const { historyManager: t, textManager: e } = this.editor;
|
|
125
125
|
t.skipHistory || e.isTextEditingActive || t.scheduleSaveState({
|
|
126
|
-
delayMs:
|
|
126
|
+
delayMs: Ke,
|
|
127
127
|
reason: "object-modified"
|
|
128
128
|
});
|
|
129
129
|
}
|
|
130
130
|
handleObjectRotatingHistory() {
|
|
131
131
|
const { historyManager: t, textManager: e } = this.editor;
|
|
132
132
|
t.skipHistory || e.isTextEditingActive || t.scheduleSaveState({
|
|
133
|
-
delayMs:
|
|
133
|
+
delayMs: Ke,
|
|
134
134
|
reason: "object-rotating"
|
|
135
135
|
});
|
|
136
136
|
}
|
|
@@ -431,7 +431,7 @@ class Le {
|
|
|
431
431
|
};
|
|
432
432
|
}
|
|
433
433
|
}
|
|
434
|
-
class
|
|
434
|
+
class Rn {
|
|
435
435
|
/**
|
|
436
436
|
* Класс для динамической загрузки внешних модулей.
|
|
437
437
|
*/
|
|
@@ -449,7 +449,7 @@ class xn {
|
|
|
449
449
|
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}"`));
|
|
450
450
|
}
|
|
451
451
|
}
|
|
452
|
-
function
|
|
452
|
+
function kn(d) {
|
|
453
453
|
return new Worker(
|
|
454
454
|
"" + new URL("assets/worker-CN39s7P7.js", import.meta.url).href,
|
|
455
455
|
{
|
|
@@ -457,13 +457,13 @@ function Rn(d) {
|
|
|
457
457
|
}
|
|
458
458
|
);
|
|
459
459
|
}
|
|
460
|
-
class
|
|
460
|
+
class Nn {
|
|
461
461
|
/**
|
|
462
462
|
* @param scriptUrl — URL скрипта воркера.
|
|
463
463
|
* По-умолчанию использует DefaultWorker из соседнего файла
|
|
464
464
|
*/
|
|
465
465
|
constructor(t) {
|
|
466
|
-
t ? this.worker = new Worker(t, { type: "module" }) : this.worker = new
|
|
466
|
+
t ? this.worker = new Worker(t, { type: "module" }) : this.worker = new kn(), this._callbacks = /* @__PURE__ */ new Map(), this.worker.onmessage = this._handleMessage.bind(this);
|
|
467
467
|
}
|
|
468
468
|
/**
|
|
469
469
|
* Обработчик сообщений от воркера
|
|
@@ -491,7 +491,7 @@ class kn {
|
|
|
491
491
|
* @returns Promise, который будет выполнен, когда воркер вернет ответ
|
|
492
492
|
*/
|
|
493
493
|
post(t, e, n = []) {
|
|
494
|
-
const s = `${t}:${
|
|
494
|
+
const s = `${t}:${tt(8)}`;
|
|
495
495
|
return new Promise((o, i) => {
|
|
496
496
|
this._callbacks.set(s, { resolve: o, reject: i }), this.worker.postMessage({ action: t, payload: e, requestId: s }, n);
|
|
497
497
|
});
|
|
@@ -503,82 +503,82 @@ class kn {
|
|
|
503
503
|
this.worker.terminate();
|
|
504
504
|
}
|
|
505
505
|
}
|
|
506
|
-
const
|
|
506
|
+
const mt = 12, Bn = 2, Ae = 8, je = 20, zn = 100, Ie = 20, Ce = 8, Pn = 100, he = 32, Re = 1, Fn = "#2B2D33", ke = "#3D8BF4", Ne = "#FFFFFF";
|
|
507
507
|
function ae(d, t, e, n, s) {
|
|
508
|
-
const o =
|
|
509
|
-
d.save(), d.translate(t, e), d.rotate(
|
|
508
|
+
const o = mt, i = Bn;
|
|
509
|
+
d.save(), d.translate(t, e), d.rotate(ft.degreesToRadians(s.angle)), d.fillStyle = Ne, d.strokeStyle = ke, d.lineWidth = Re, d.beginPath(), d.roundRect(-o / 2, -o / 2, o, o, i), d.fill(), d.stroke(), d.restore();
|
|
510
510
|
}
|
|
511
|
-
function
|
|
512
|
-
const o =
|
|
513
|
-
d.save(), d.translate(t, e), d.rotate(
|
|
511
|
+
function qe(d, t, e, n, s) {
|
|
512
|
+
const o = Ae, i = je, a = zn;
|
|
513
|
+
d.save(), d.translate(t, e), d.rotate(ft.degreesToRadians(s.angle)), d.fillStyle = Ne, d.strokeStyle = ke, d.lineWidth = Re, d.beginPath(), d.roundRect(-o / 2, -i / 2, o, i, a), d.fill(), d.stroke(), d.restore();
|
|
514
514
|
}
|
|
515
|
-
function
|
|
516
|
-
const o =
|
|
517
|
-
d.save(), d.translate(t, e), d.rotate(
|
|
515
|
+
function Je(d, t, e, n, s) {
|
|
516
|
+
const o = Ie, i = Ce, a = Pn;
|
|
517
|
+
d.save(), d.translate(t, e), d.rotate(ft.degreesToRadians(s.angle)), d.fillStyle = Ne, d.strokeStyle = ke, d.lineWidth = Re, d.beginPath(), d.roundRect(-o / 2, -i / 2, o, i, a), d.fill(), d.stroke(), d.restore();
|
|
518
518
|
}
|
|
519
|
-
const
|
|
520
|
-
|
|
519
|
+
const Wn = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTE4Ljc1IDQuMzc1djMuNzVhLjYyNS42MjUgMCAwIDEtLjYyNS42MjVoLTMuNzVhLjYyNS42MjUgMCAwIDEgMC0xLjI1aDIuMTRsLTIuMDc3LTEuOTAzLS4wMi0uMDE5YTYuMjUgNi4yNSAwIDEgMC0uMTMgOC45NjcuNjI2LjYyNiAwIDAgMSAuODYuOTA5QTcuNDU2IDcuNDU2IDAgMCAxIDEwIDE3LjVoLS4xMDNhNy41IDcuNSAwIDEgMSA1LjM5Ni0xMi44MTJMMTcuNSA2LjcwM1Y0LjM3NWEuNjI1LjYyNSAwIDAgMSAxLjI1IDBaIi8+PC9zdmc+", pn = new Image();
|
|
520
|
+
pn.src = Wn;
|
|
521
521
|
function Un(d, t, e, n, s) {
|
|
522
522
|
const i = he / 2;
|
|
523
|
-
d.save(), d.translate(t, e), d.rotate(
|
|
523
|
+
d.save(), d.translate(t, e), d.rotate(ft.degreesToRadians(s.angle)), d.fillStyle = Fn, d.beginPath(), d.arc(0, 0, i, 0, 2 * Math.PI), d.fill(), d.drawImage(pn, -i / 2, -i / 2, i, i), d.restore();
|
|
524
524
|
}
|
|
525
|
-
const
|
|
525
|
+
const Yn = {
|
|
526
526
|
// Угловые точки
|
|
527
527
|
tl: {
|
|
528
528
|
render: ae,
|
|
529
|
-
sizeX:
|
|
530
|
-
sizeY:
|
|
529
|
+
sizeX: mt,
|
|
530
|
+
sizeY: mt,
|
|
531
531
|
offsetX: 0,
|
|
532
532
|
offsetY: 0
|
|
533
533
|
},
|
|
534
534
|
tr: {
|
|
535
535
|
render: ae,
|
|
536
|
-
sizeX:
|
|
537
|
-
sizeY:
|
|
536
|
+
sizeX: mt,
|
|
537
|
+
sizeY: mt,
|
|
538
538
|
offsetX: 0,
|
|
539
539
|
offsetY: 0
|
|
540
540
|
},
|
|
541
541
|
bl: {
|
|
542
542
|
render: ae,
|
|
543
|
-
sizeX:
|
|
544
|
-
sizeY:
|
|
543
|
+
sizeX: mt,
|
|
544
|
+
sizeY: mt,
|
|
545
545
|
offsetX: 0,
|
|
546
546
|
offsetY: 0
|
|
547
547
|
},
|
|
548
548
|
br: {
|
|
549
549
|
render: ae,
|
|
550
|
-
sizeX:
|
|
551
|
-
sizeY:
|
|
550
|
+
sizeX: mt,
|
|
551
|
+
sizeY: mt,
|
|
552
552
|
offsetX: 0,
|
|
553
553
|
offsetY: 0
|
|
554
554
|
},
|
|
555
555
|
// Середина вертикалей
|
|
556
556
|
ml: {
|
|
557
|
-
render:
|
|
558
|
-
sizeX:
|
|
559
|
-
sizeY:
|
|
557
|
+
render: qe,
|
|
558
|
+
sizeX: Ae,
|
|
559
|
+
sizeY: je,
|
|
560
560
|
offsetX: 0,
|
|
561
561
|
offsetY: 0
|
|
562
562
|
},
|
|
563
563
|
mr: {
|
|
564
|
-
render:
|
|
565
|
-
sizeX:
|
|
566
|
-
sizeY:
|
|
564
|
+
render: qe,
|
|
565
|
+
sizeX: Ae,
|
|
566
|
+
sizeY: je,
|
|
567
567
|
offsetX: 0,
|
|
568
568
|
offsetY: 0
|
|
569
569
|
},
|
|
570
570
|
// Середина горизонталей
|
|
571
571
|
mt: {
|
|
572
|
-
render:
|
|
573
|
-
sizeX:
|
|
574
|
-
sizeY:
|
|
572
|
+
render: Je,
|
|
573
|
+
sizeX: Ie,
|
|
574
|
+
sizeY: Ce,
|
|
575
575
|
offsetX: 0,
|
|
576
576
|
offsetY: 0
|
|
577
577
|
},
|
|
578
578
|
mb: {
|
|
579
|
-
render:
|
|
580
|
-
sizeX:
|
|
581
|
-
sizeY:
|
|
579
|
+
render: Je,
|
|
580
|
+
sizeX: Ie,
|
|
581
|
+
sizeY: Ce,
|
|
582
582
|
offsetX: 0,
|
|
583
583
|
offsetY: 0
|
|
584
584
|
},
|
|
@@ -607,7 +607,7 @@ class lt {
|
|
|
607
607
|
* Применяет конфигурацию контролов к набору по ключам из DEFAULT_CONTROLS.
|
|
608
608
|
*/
|
|
609
609
|
static applyControlOverrides(t) {
|
|
610
|
-
Object.entries(
|
|
610
|
+
Object.entries(Yn).forEach(([e, n]) => {
|
|
611
611
|
const s = t[e];
|
|
612
612
|
s && (Object.assign(s, n), e === "mtr" && (s.cursorStyle = "grab", s.mouseDownHandler = (o, i, a, r) => {
|
|
613
613
|
var l;
|
|
@@ -620,10 +620,10 @@ class lt {
|
|
|
620
620
|
* Регистрирует контролы и настройки поведения выделений.
|
|
621
621
|
*/
|
|
622
622
|
static apply() {
|
|
623
|
-
const t =
|
|
624
|
-
lt.applyControlOverrides(t),
|
|
625
|
-
const e =
|
|
626
|
-
lt.applyControlOverrides(e), e.mt && (e.mt.visible = !1), e.mb && (e.mb.visible = !1), lt.wrapWidthControl(e.ml), lt.wrapWidthControl(e.mr), dt.ownDefaults.controls = e, lt.patchActiveSelectionBounds(),
|
|
623
|
+
const t = He.createObjectDefaultControls();
|
|
624
|
+
lt.applyControlOverrides(t), Ze.ownDefaults.controls = t;
|
|
625
|
+
const e = He.createTextboxDefaultControls();
|
|
626
|
+
lt.applyControlOverrides(e), e.mt && (e.mt.visible = !1), e.mb && (e.mb.visible = !1), lt.wrapWidthControl(e.ml), lt.wrapWidthControl(e.mr), dt.ownDefaults.controls = e, lt.patchActiveSelectionBounds(), Ze.ownDefaults.snapAngle = 1;
|
|
627
627
|
}
|
|
628
628
|
/**
|
|
629
629
|
* Обновляет алгоритм расчёта границ ActiveSelection, чтобы учитывать фон и отступы текстовых объектов.
|
|
@@ -631,8 +631,8 @@ class lt {
|
|
|
631
631
|
static patchActiveSelectionBounds() {
|
|
632
632
|
const t = X.prototype, e = t._calcBoundsFromObjects;
|
|
633
633
|
t._calcBoundsFromObjects = function(...o) {
|
|
634
|
-
var f,
|
|
635
|
-
const i = (
|
|
634
|
+
var f, p;
|
|
635
|
+
const i = (p = (f = this.getObjects) == null ? void 0 : f.call(this)) != null ? p : [];
|
|
636
636
|
lt.applyTextSelectionScalingLock({
|
|
637
637
|
selection: this,
|
|
638
638
|
objects: i
|
|
@@ -654,8 +654,8 @@ class lt {
|
|
|
654
654
|
};
|
|
655
655
|
const n = t._onAfterObjectsChange;
|
|
656
656
|
t._onAfterObjectsChange = function(o, i) {
|
|
657
|
-
var m,
|
|
658
|
-
const a = n ? n.call(this, o, i) : void 0, r = (
|
|
657
|
+
var m, g;
|
|
658
|
+
const a = n ? n.call(this, o, i) : void 0, r = (g = (m = this.getObjects) == null ? void 0 : m.call(this)) != null ? g : [];
|
|
659
659
|
lt.applyTextSelectionScalingLock({
|
|
660
660
|
selection: this,
|
|
661
661
|
objects: r
|
|
@@ -664,14 +664,14 @@ class lt {
|
|
|
664
664
|
objects: r
|
|
665
665
|
});
|
|
666
666
|
if (!c) return a;
|
|
667
|
-
const { left: l, top: h, width: u, height: f } = c,
|
|
667
|
+
const { left: l, top: h, width: u, height: f } = c, p = new at(l + u / 2, h + f / 2);
|
|
668
668
|
return this.set({
|
|
669
669
|
width: u,
|
|
670
670
|
height: f
|
|
671
|
-
}), this.setPositionByOrigin(
|
|
671
|
+
}), this.setPositionByOrigin(p, "center", "center"), this.setCoords(), a;
|
|
672
672
|
};
|
|
673
|
-
const s =
|
|
674
|
-
|
|
673
|
+
const s = Ge.prototype.calcBoundingBox;
|
|
674
|
+
Ge.prototype.calcBoundingBox = function(o, i) {
|
|
675
675
|
const { target: a, type: r, overrides: c } = i;
|
|
676
676
|
if (r === "imperative" && c)
|
|
677
677
|
return c;
|
|
@@ -684,13 +684,13 @@ class lt {
|
|
|
684
684
|
const l = lt.calculateActiveSelectionBounds({ objects: o });
|
|
685
685
|
if (!l)
|
|
686
686
|
return s.call(this, o, i);
|
|
687
|
-
const { left: h, top: u, width: f, height:
|
|
687
|
+
const { left: h, top: u, width: f, height: p } = l, m = new at(f, p), g = new at(h + f / 2, u + p / 2);
|
|
688
688
|
return r === "initialization" ? {
|
|
689
|
-
center:
|
|
689
|
+
center: g,
|
|
690
690
|
relativeCorrection: new at(0, 0),
|
|
691
691
|
size: m
|
|
692
692
|
} : {
|
|
693
|
-
center:
|
|
693
|
+
center: g,
|
|
694
694
|
size: m
|
|
695
695
|
};
|
|
696
696
|
};
|
|
@@ -894,8 +894,8 @@ V.registeredFontKeys = /* @__PURE__ */ new Set(), V.descriptorDefaults = {
|
|
|
894
894
|
featureSettings: "normal",
|
|
895
895
|
display: "auto"
|
|
896
896
|
};
|
|
897
|
-
let
|
|
898
|
-
const
|
|
897
|
+
let Te = V;
|
|
898
|
+
const Hn = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNNi44NzUgMi41YS42MjUuNjI1IDAgMCAwLS42MjUuNjI0VjYuMjVIMy4xMjVhLjYyNS42MjUgMCAwIDAtLjYyNS42MjV2MTBjMCAuMzQ1LjI4LjYyNS42MjUuNjI1aDEwYy4zNDUgMCAuNjI1LS4yOC42MjUtLjYyNXYtMy4xMjZoMy4xMjVjLjM0NSAwIC42MjUtLjI4LjYyNS0uNjI1di0xMGEuNjI1LjYyNSAwIDAgMC0uNjI1LS42MjVoLTEwWm02Ljg3NSAxMGgyLjVWMy43NUg3LjV2Mi41aDUuNjI1Yy4zNDUgMCAuNjI1LjI4LjYyNS42MjV2NS42MjRabS0xMCAzLjc1VjcuNWg4Ljc1djguNzVIMy43NVoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjwvc3ZnPg==", Zn = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMi41IDcuNWMwLS42OS41Ni0xLjI1IDEuMjUtMS4yNWgxMi41Yy42OSAwIDEuMjUuNTYgMS4yNSAxLjI1djguNzVjMCAuNjktLjU2IDEuMjUtMS4yNSAxLjI1SDMuNzVjLS42OSAwLTEuMjUtLjU2LTEuMjUtMS4yNVY3LjVabTEzLjc1IDBIMy43NXY4Ljc1aDEyLjVWNy41WiIgY2xpcC1ydWxlPSJldmVub2RkIi8+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMTAgMS44NzVhMi4xODggMi4xODggMCAwIDAtMi4xODggMi4xODh2Mi44MTJhLjYyNS42MjUgMCAxIDEtMS4yNSAwVjQuMDYyYTMuNDM3IDMuNDM3IDAgMSAxIDYuODc1IDB2Mi44MTNhLjYyNS42MjUgMCAxIDEtMS4yNSAwVjQuMDYyQTIuMTg4IDIuMTg4IDAgMCAwIDEwIDEuODc2WiIgY2xpcC1ydWxlPSJldmVub2RkIi8+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTEwIDEyLjgxM2EuOTM3LjkzNyAwIDEgMCAwLTEuODc1LjkzNy45MzcgMCAwIDAgMCAxLjg3NFoiLz48L3N2Zz4=", Gn = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTE2LjI1IDYuMjVINy41VjQuMzc1YTIuNSAyLjUgMCAwIDEgMi41LTIuNWMxLjIgMCAyLjI4MS44NiAyLjUxMiAyYS42MjUuNjI1IDAgMCAwIDEuMjI2LS4yNWMtLjM1NC0xLjczOC0xLjkyNS0zLTMuNzM4LTNhMy43NTQgMy43NTQgMCAwIDAtMy43NSAzLjc1VjYuMjVoLTIuNUExLjI1IDEuMjUgMCAwIDAgMi41IDcuNXY4Ljc1YTEuMjUgMS4yNSAwIDAgMCAxLjI1IDEuMjVoMTIuNWExLjI1IDEuMjUgMCAwIDAgMS4yNS0xLjI1VjcuNWExLjI1IDEuMjUgMCAwIDAtMS4yNS0xLjI1Wm0wIDEwSDMuNzVWNy41aDEyLjV2OC43NVptLTUuMzEzLTQuMzc1YS45MzcuOTM3IDAgMSAxLTEuODc0IDAgLjkzNy45MzcgMCAwIDEgMS44NzQgMFoiLz48L3N2Zz4K", Vn = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTIuNSA4LjEyNSAxMCAxMi41bDcuNS00LjM3NUwxMCAzLjc1IDIuNSA4LjEyNVoiLz48cGF0aCBmaWxsPSIjZmZmIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik05LjY4NSAzLjIxYS42MjUuNjI1IDAgMCAxIC42MyAwbDcuNSA0LjM3NWEuNjI1LjYyNSAwIDAgMSAwIDEuMDhsLTcuNSA0LjM3NWEuNjI1LjYyNSAwIDAgMS0uNjMgMGwtNy41LTQuMzc1YS42MjUuNjI1IDAgMCAxIDAtMS4wOGw3LjUtNC4zNzVaTTMuNzQgOC4xMjUgMTAgMTEuNzc2bDYuMjYtMy42NTFMMTAgNC40NzQgMy43NCA4LjEyNVoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjxwYXRoIGZpbGw9IiNmZmYiIGZpbGwtcnVsZT0iZXZlbm9kZCIgZD0iTTUuNCA5LjQ2YS42MjUuNjI1IDAgMCAxIC42MyAwTDEwIDExLjc3NmwzLjk3LTIuMzE2YS42MjUuNjI1IDAgMCAxIC42MyAwbDMuMjE1IDEuODc1YS42MjUuNjI1IDAgMCAxIDAgMS4wOGwtNy41IDQuMzc1YS42MjUuNjI1IDAgMCAxLS42MyAwbC03LjUtNC4zNzVhLjYyNS42MjUgMCAwIDEgMC0xLjA4TDUuNCA5LjQ2Wm0tMS42NiAyLjQxNUwxMCAxNS41MjZsNi4yNi0zLjY1MS0xLjk3NC0xLjE1MS0zLjk3MSAyLjMxNmEuNjI1LjYyNSAwIDAgMS0uNjMgMGwtMy45Ny0yLjMxNi0xLjk3NSAxLjE1MVoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjwvc3ZnPg==", Xn = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNOS42ODUgMy4yMWEuNjI1LjYyNSAwIDAgMSAuNjMgMGw3LjUgNC4zNzVhLjYyNS42MjUgMCAwIDEgMCAxLjA4bC03LjUgNC4zNzVhLjYyNS42MjUgMCAwIDEtLjYzIDBsLTcuNS00LjM3NWEuNjI1LjYyNSAwIDAgMSAwLTEuMDhsNy41LTQuMzc1Wk0zLjc0IDguMTI1IDEwIDExLjc3Nmw2LjI2LTMuNjUxTDEwIDQuNDc0IDMuNzQgOC4xMjVaIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiLz48cGF0aCBmaWxsPSIjZmZmIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik01LjcxNCAxMCAxMCAxMi41bDQuMjg2LTIuNSAzLjIxNCAxLjg3NUwxMCAxNi4yNWwtNy41LTQuMzc1TDUuNzE0IDEwWiIgY2xpcC1ydWxlPSJldmVub2RkIi8+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNNS40IDkuNDZhLjYyNS42MjUgMCAwIDEgLjYzIDBMMTAgMTEuNzc2bDMuOTctMi4zMTZhLjYyNS42MjUgMCAwIDEgLjYzIDBsMy4yMTUgMS44NzVhLjYyNS42MjUgMCAwIDEgMCAxLjA4bC03LjUgNC4zNzVhLjYyNS42MjUgMCAwIDEtLjYzIDBsLTcuNS00LjM3NWEuNjI1LjYyNSAwIDAgMSAwLTEuMDhMNS40IDkuNDZabS0xLjY2IDIuNDE1TDEwIDE1LjUyNmw2LjI2LTMuNjUxLTEuOTc0LTEuMTUxLTMuOTcxIDIuMzE2YS42MjUuNjI1IDAgMCAxLS42MyAwbC0zLjk3LTIuMzE2LTEuOTc1IDEuMTUxWiIgY2xpcC1ydWxlPSJldmVub2RkIi8+PC9zdmc+", Kn = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0ibTIuNSA2LjI1IDcuNSA0LjM3NSA3LjUtNC4zNzVMMTAgMS44NzUgMi41IDYuMjVaIi8+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNOS42ODUgMS4zMzVhLjYyNS42MjUgMCAwIDEgLjYzIDBsNy41IDQuMzc1YS42MjUuNjI1IDAgMCAxIDAgMS4wOGwtNy41IDQuMzc1YS42MjUuNjI1IDAgMCAxLS42MyAwbC03LjUtNC4zNzVhLjYyNS42MjUgMCAwIDEgMC0xLjA4bDcuNS00LjM3NVpNMy43NCA2LjI1IDEwIDkuOTAxbDYuMjYtMy42NTFMMTAgMi41OTkgMy43NCA2LjI1WiIgY2xpcC1ydWxlPSJldmVub2RkIi8+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNNS40IDExLjMzNWEuNjI1LjYyNSAwIDAgMSAuNjMgMEwxMCAxMy42NTFsMy45Ny0yLjMxNmEuNjI1LjYyNSAwIDAgMSAuNjMgMGwzLjIxNSAxLjg3NWEuNjI1LjYyNSAwIDAgMSAwIDEuMDhsLTcuNSA0LjM3NWEuNjI1LjYyNSAwIDAgMS0uNjMgMGwtNy41LTQuMzc1YS42MjUuNjI1IDAgMCAxIDAtMS4wOEw1LjQgMTEuMzM1Wk0zLjc0IDEzLjc1IDEwIDE3LjQwMWw2LjI2LTMuNjUxLTEuOTc0LTEuMTUxLTMuOTcxIDIuMzE2YS42MjUuNjI1IDAgMCAxLS42MyAwbC0zLjk3LTIuMzE2TDMuNzQgMTMuNzVaIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiLz48cGF0aCBmaWxsPSIjZmZmIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik01LjQgNy41ODVhLjYyNS42MjUgMCAwIDEgLjYzIDBMMTAgOS45MDFsMy45Ny0yLjMxNmEuNjI1LjYyNSAwIDAgMSAuNjMgMGwzLjIxNSAxLjg3NWEuNjI1LjYyNSAwIDAgMSAwIDEuMDhsLTcuNSA0LjM3NWEuNjI1LjYyNSAwIDAgMS0uNjMgMGwtNy41LTQuMzc1YS42MjUuNjI1IDAgMCAxIDAtMS4wOEw1LjQgNy41ODVaTTMuNzQgMTAgMTAgMTMuNjUxIDE2LjI2IDEwbC0xLjk3NC0xLjE1MS0zLjk3MSAyLjMxNmEuNjI1LjYyNSAwIDAgMS0uNjMgMGwtMy45Ny0yLjMxNkwzLjc0IDEwWiIgY2xpcC1ydWxlPSJldmVub2RkIi8+PC9zdmc+", qn = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMS45NiAxMy40MzVhLjYyNS42MjUgMCAwIDEgLjg1NS0uMjI1TDEwIDE3LjQwMWw3LjE4NS00LjE5YS42MjUuNjI1IDAgMCAxIC42MyAxLjA3OWwtNy41IDQuMzc1YS42MjUuNjI1IDAgMCAxLS42MyAwbC03LjUtNC4zNzVhLjYyNS42MjUgMCAwIDEtLjIyNS0uODU1Wk05LjY4NSAxLjMzNWEuNjI1LjYyNSAwIDAgMSAuNjMgMGw3LjUgNC4zNzVhLjYyNS42MjUgMCAwIDEgMCAxLjA4bC03LjUgNC4zNzVhLjYyNS42MjUgMCAwIDEtLjYzIDBsLTcuNS00LjM3NWEuNjI1LjYyNSAwIDAgMSAwLTEuMDhsNy41LTQuMzc1Wk0zLjc0IDYuMjUgMTAgOS45MDFsNi4yNi0zLjY1MUwxMCAyLjU5OSAzLjc0IDYuMjVaIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiLz48cGF0aCBmaWxsPSIjZmZmIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGQ9Im01LjcxNCAxMS44NzUgNC4yODYgMi41IDQuMjg2LTIuNUwxNy41IDEzLjc1IDEwIDE4LjEyNSAyLjUgMTMuNzVsMy4yMTQtMS44NzVaIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiLz48cGF0aCBmaWxsPSIjZmZmIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik01LjQgMTEuMzM1YS42MjUuNjI1IDAgMCAxIC42MyAwTDEwIDEzLjY1MWwzLjk3LTIuMzE2YS42MjUuNjI1IDAgMCAxIC42MyAwbDMuMjE1IDEuODc1YS42MjUuNjI1IDAgMCAxIDAgMS4wOGwtNy41IDQuMzc1YS42MjUuNjI1IDAgMCAxLS42MyAwbC03LjUtNC4zNzVhLjYyNS42MjUgMCAwIDEgMC0xLjA4TDUuNCAxMS4zMzVaTTMuNzQgMTMuNzUgMTAgMTcuNDAxbDYuMjYtMy42NTEtMS45NzQtMS4xNTEtMy45NzEgMi4zMTZhLjYyNS42MjUgMCAwIDEtLjYzIDBsLTMuOTctMi4zMTZMMy43NCAxMy43NVoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjxwYXRoIGZpbGw9IiNmZmYiIGZpbGwtcnVsZT0iZXZlbm9kZCIgZD0iTTUuNCA3LjU4NWEuNjI1LjYyNSAwIDAgMSAuNjMgMEwxMCA5LjkwMWwzLjk3LTIuMzE2YS42MjUuNjI1IDAgMCAxIC42MyAwbDMuMjE1IDEuODc1YS42MjUuNjI1IDAgMCAxIDAgMS4wOGwtNy41IDQuMzc1YS42MjUuNjI1IDAgMCAxLS42MyAwbC03LjUtNC4zNzVhLjYyNS42MjUgMCAwIDEgMC0xLjA4TDUuNCA3LjU4NVpNMy43NCAxMCAxMCAxMy42NTEgMTYuMjYgMTBsLTEuOTc0LTEuMTUxLTMuOTcxIDIuMzE2YS42MjUuNjI1IDAgMCAxLS42MyAwbC0zLjk3LTIuMzE2TDMuNzQgMTBaIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiLz48L3N2Zz4=", Jn = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI0VDNEU0MCIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNOC4xMjUgMS4yNUExLjg3NSAxLjg3NSAwIDAgMCA2LjI1IDMuMTI1di42MjVIMy4xMjVhLjYyNS42MjUgMCAwIDAgMCAxLjI1aC42MjV2MTEuMjVBMS4yNSAxLjI1IDAgMCAwIDUgMTcuNWgxMGExLjI1IDEuMjUgMCAwIDAgMS4yNS0xLjI1VjVoLjYyNWEuNjI1LjYyNSAwIDAgMCAwLTEuMjVIMTMuNzV2LS42MjVhMS44NzUgMS44NzUgMCAwIDAtMS44NzUtMS44NzVoLTMuNzVabTQuMzc1IDIuNXYtLjYyNWEuNjI1LjYyNSAwIDAgMC0uNjI1LS42MjVoLTMuNzVhLjYyNS42MjUgMCAwIDAtLjYyNS42MjV2LjYyNWg1Wk01IDE2LjI1VjVoMTB2MTEuMjVINVpNOC4xMjUgNy41Yy4zNDUgMCAuNjI1LjI4LjYyNS42MjV2NWEuNjI1LjYyNSAwIDEgMS0xLjI1IDB2LTVjMC0uMzQ1LjI4LS42MjUuNjI1LS42MjVabTQuMzc1IDUuNjI1di01YS42MjUuNjI1IDAgMCAwLTEuMjUgMHY1YS42MjUuNjI1IDAgMSAwIDEuMjUgMFoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjwvc3ZnPg==", Kt = {
|
|
899
899
|
style: {
|
|
900
900
|
position: "absolute",
|
|
901
901
|
display: "none",
|
|
@@ -962,14 +962,14 @@ const Yn = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMj
|
|
|
962
962
|
],
|
|
963
963
|
offsetTop: 50,
|
|
964
964
|
icons: {
|
|
965
|
-
copyPaste:
|
|
966
|
-
delete:
|
|
967
|
-
lock:
|
|
968
|
-
unlock:
|
|
969
|
-
bringToFront:
|
|
970
|
-
sendToBack:
|
|
971
|
-
bringForward:
|
|
972
|
-
sendBackwards:
|
|
965
|
+
copyPaste: Hn,
|
|
966
|
+
delete: Jn,
|
|
967
|
+
lock: Zn,
|
|
968
|
+
unlock: Gn,
|
|
969
|
+
bringToFront: Kn,
|
|
970
|
+
sendToBack: qn,
|
|
971
|
+
bringForward: Vn,
|
|
972
|
+
sendBackwards: Xn
|
|
973
973
|
},
|
|
974
974
|
handlers: {
|
|
975
975
|
copyPaste: (d) => Z(null, null, function* () {
|
|
@@ -998,18 +998,18 @@ const Yn = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMj
|
|
|
998
998
|
}
|
|
999
999
|
}
|
|
1000
1000
|
};
|
|
1001
|
-
class
|
|
1001
|
+
class Qn {
|
|
1002
1002
|
constructor({ editor: t }) {
|
|
1003
1003
|
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();
|
|
1004
1004
|
}
|
|
1005
1005
|
_initToolbar() {
|
|
1006
1006
|
if (!this.options.showToolbar) return;
|
|
1007
1007
|
const t = this.options.toolbar || {};
|
|
1008
|
-
this.config = It(
|
|
1009
|
-
style:
|
|
1010
|
-
btnStyle:
|
|
1011
|
-
icons:
|
|
1012
|
-
handlers:
|
|
1008
|
+
this.config = It(x(x({}, Kt), t), {
|
|
1009
|
+
style: x(x({}, Kt.style), t.style || {}),
|
|
1010
|
+
btnStyle: x(x({}, Kt.btnStyle), t.btnStyle || {}),
|
|
1011
|
+
icons: x(x({}, Kt.icons), t.icons || {}),
|
|
1012
|
+
handlers: x(x({}, Kt.handlers), t.handlers || {})
|
|
1013
1013
|
}), 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 = () => {
|
|
1014
1014
|
this.el.style.display = "none";
|
|
1015
1015
|
}, this._createDOM(), this._bindEvents();
|
|
@@ -1112,10 +1112,10 @@ class Jn {
|
|
|
1112
1112
|
}
|
|
1113
1113
|
const { el: e, config: n, canvas: s } = this;
|
|
1114
1114
|
t.setCoords();
|
|
1115
|
-
const o = s.getZoom(), [, , , , i, a] = s.viewportTransform, { x: r } = t.getCenterPoint(), { top: c, height: l } = t.getBoundingRect(), u = r * o + i - e.offsetWidth / 2, f = n.offsetTop || 0,
|
|
1115
|
+
const o = s.getZoom(), [, , , , i, a] = s.viewportTransform, { x: r } = t.getCenterPoint(), { top: c, height: l } = t.getBoundingRect(), u = r * o + i - e.offsetWidth / 2, f = n.offsetTop || 0, p = (c + l) * o + a + f;
|
|
1116
1116
|
Object.assign(e.style, {
|
|
1117
1117
|
left: `${u}px`,
|
|
1118
|
-
top: `${
|
|
1118
|
+
top: `${p}px`,
|
|
1119
1119
|
display: "flex"
|
|
1120
1120
|
});
|
|
1121
1121
|
}
|
|
@@ -1126,7 +1126,7 @@ class Jn {
|
|
|
1126
1126
|
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();
|
|
1127
1127
|
}
|
|
1128
1128
|
}
|
|
1129
|
-
const
|
|
1129
|
+
const $n = {
|
|
1130
1130
|
position: "absolute",
|
|
1131
1131
|
display: "none",
|
|
1132
1132
|
background: "#2B2D33",
|
|
@@ -1140,8 +1140,8 @@ const Qn = {
|
|
|
1140
1140
|
"pointer-events": "none",
|
|
1141
1141
|
"white-space": "nowrap",
|
|
1142
1142
|
"box-shadow": "0 2px 8px rgba(0, 0, 0, 0.2)"
|
|
1143
|
-
},
|
|
1144
|
-
class
|
|
1143
|
+
}, Qe = 16, $e = 16, ts = "fabric-editor-angle-indicator";
|
|
1144
|
+
class Be {
|
|
1145
1145
|
constructor({ editor: t }) {
|
|
1146
1146
|
this.isActive = !1, this.currentAngle = 0, this.editor = t, this.canvas = t.canvas, this.options = t.options, this._createDOM(), this._bindEvents();
|
|
1147
1147
|
}
|
|
@@ -1149,7 +1149,7 @@ class Re {
|
|
|
1149
1149
|
* Создание DOM-элемента индикатора
|
|
1150
1150
|
*/
|
|
1151
1151
|
_createDOM() {
|
|
1152
|
-
this.el = document.createElement("div"), this.el.className =
|
|
1152
|
+
this.el = document.createElement("div"), this.el.className = ts, Object.entries($n).forEach(([t, e]) => {
|
|
1153
1153
|
this.el.style.setProperty(t, e);
|
|
1154
1154
|
}), this.canvas.wrapperEl.appendChild(this.el);
|
|
1155
1155
|
}
|
|
@@ -1169,7 +1169,7 @@ class Re {
|
|
|
1169
1169
|
return;
|
|
1170
1170
|
}
|
|
1171
1171
|
const n = e.angle || 0;
|
|
1172
|
-
this.currentAngle =
|
|
1172
|
+
this.currentAngle = Be._normalizeAngle(n), this.el.textContent = `${this.currentAngle}°`, this._positionIndicator(t.e), this.isActive || this._showIndicator();
|
|
1173
1173
|
}
|
|
1174
1174
|
/**
|
|
1175
1175
|
* Обработчик отпускания кнопки мыши
|
|
@@ -1200,9 +1200,9 @@ class Re {
|
|
|
1200
1200
|
*/
|
|
1201
1201
|
_positionIndicator(t) {
|
|
1202
1202
|
const e = this.canvas.wrapperEl.getBoundingClientRect();
|
|
1203
|
-
let n = t.clientX - e.left +
|
|
1203
|
+
let n = t.clientX - e.left + Qe, s = t.clientY - e.top + $e;
|
|
1204
1204
|
const o = this.el.getBoundingClientRect(), i = o.width, a = o.height;
|
|
1205
|
-
n + i > e.width && (n = t.clientX - e.left - i -
|
|
1205
|
+
n + i > e.width && (n = t.clientX - e.left - i - Qe), s + a > e.height && (s = t.clientY - e.top - a - $e), this.el.style.left = `${n}px`, this.el.style.top = `${s}px`;
|
|
1206
1206
|
}
|
|
1207
1207
|
/**
|
|
1208
1208
|
* Показать индикатор
|
|
@@ -1233,7 +1233,7 @@ class Re {
|
|
|
1233
1233
|
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;
|
|
1234
1234
|
}
|
|
1235
1235
|
}
|
|
1236
|
-
const
|
|
1236
|
+
const Oe = [
|
|
1237
1237
|
"id",
|
|
1238
1238
|
"backgroundId",
|
|
1239
1239
|
"customData",
|
|
@@ -1283,7 +1283,7 @@ class K {
|
|
|
1283
1283
|
return this.patches[this.currentIndex - 1] || null;
|
|
1284
1284
|
}
|
|
1285
1285
|
_createDiffPatcher() {
|
|
1286
|
-
this.diffPatcher =
|
|
1286
|
+
this.diffPatcher = Dn({
|
|
1287
1287
|
objectHash(t) {
|
|
1288
1288
|
return [JSON.stringify(t)].join("-");
|
|
1289
1289
|
},
|
|
@@ -1292,7 +1292,7 @@ class K {
|
|
|
1292
1292
|
includeValueOnMove: !1
|
|
1293
1293
|
},
|
|
1294
1294
|
textDiff: {
|
|
1295
|
-
diffMatchPatch:
|
|
1295
|
+
diffMatchPatch: _n,
|
|
1296
1296
|
minLength: 60
|
|
1297
1297
|
}
|
|
1298
1298
|
});
|
|
@@ -1368,7 +1368,7 @@ class K {
|
|
|
1368
1368
|
*/
|
|
1369
1369
|
_serializeCanvasState() {
|
|
1370
1370
|
const { canvas: t } = this;
|
|
1371
|
-
return t.toDatalessObject([...
|
|
1371
|
+
return t.toDatalessObject([...Oe]);
|
|
1372
1372
|
}
|
|
1373
1373
|
/**
|
|
1374
1374
|
* Обрабатывает срабатывание отложенного сохранения.
|
|
@@ -1429,7 +1429,7 @@ class K {
|
|
|
1429
1429
|
this._isSavingState = !0, console.time("saveState");
|
|
1430
1430
|
try {
|
|
1431
1431
|
const t = this._withTemporaryUnlock(
|
|
1432
|
-
() => this.canvas.toDatalessObject([...
|
|
1432
|
+
() => this.canvas.toDatalessObject([...Oe])
|
|
1433
1433
|
);
|
|
1434
1434
|
if (console.timeEnd("saveState"), !this.baseState) {
|
|
1435
1435
|
this.baseState = t, this.patches = [], this.currentIndex = 0, console.log("Базовое состояние сохранено.");
|
|
@@ -1453,7 +1453,7 @@ class K {
|
|
|
1453
1453
|
console.log("statesEqual. Нет изменений для сохранения.");
|
|
1454
1454
|
return;
|
|
1455
1455
|
}
|
|
1456
|
-
console.log("baseState", this.baseState), this.currentIndex < this.patches.length && this.patches.splice(this.currentIndex), console.log("diff", o), this.totalChangesCount += 1, this.patches.push({ id:
|
|
1456
|
+
console.log("baseState", this.baseState), this.currentIndex < this.patches.length && this.patches.splice(this.currentIndex), console.log("diff", o), this.totalChangesCount += 1, this.patches.push({ id: tt(), diff: o }), this.currentIndex += 1, this.patches.length > this.maxHistoryLength && (this.baseState = this.diffPatcher.patch(this.baseState, this.patches[0].diff), this.patches.shift(), this.currentIndex -= 1, this.baseStateChangesCount += 1), console.log("Состояние сохранено. Текущий индекс истории:", this.currentIndex);
|
|
1457
1457
|
} finally {
|
|
1458
1458
|
this._isSavingState = !1;
|
|
1459
1459
|
}
|
|
@@ -1576,14 +1576,14 @@ class K {
|
|
|
1576
1576
|
id: "montage-area"
|
|
1577
1577
|
});
|
|
1578
1578
|
f && (f.left = a, f.top = r);
|
|
1579
|
-
const
|
|
1580
|
-
if (
|
|
1581
|
-
const { left:
|
|
1582
|
-
M.left =
|
|
1579
|
+
const p = K._getClipPathPosition({ clipPath: s });
|
|
1580
|
+
if (p && i && typeof i == "object") {
|
|
1581
|
+
const { left: g, top: v } = p, M = i;
|
|
1582
|
+
M.left = g, M.top = v;
|
|
1583
1583
|
}
|
|
1584
1584
|
const m = K._getTranslationIgnoredIds();
|
|
1585
|
-
for (let
|
|
1586
|
-
const v = o[
|
|
1585
|
+
for (let g = 0; g < o.length; g += 1) {
|
|
1586
|
+
const v = o[g], { id: M } = v;
|
|
1587
1587
|
M && m.has(M) || (typeof v.left == "number" && (v.left -= h), typeof v.top == "number" && (v.top -= u));
|
|
1588
1588
|
}
|
|
1589
1589
|
}
|
|
@@ -1822,7 +1822,7 @@ class K {
|
|
|
1822
1822
|
}
|
|
1823
1823
|
}
|
|
1824
1824
|
}
|
|
1825
|
-
const
|
|
1825
|
+
const es = 0.1, ns = 2, tn = 0.1, ss = 90, Ft = 16, Wt = 16, Ot = 4096, Et = 4096, en = "application/image-editor:", re = [
|
|
1826
1826
|
"format",
|
|
1827
1827
|
"uppercase",
|
|
1828
1828
|
"textCaseRaw",
|
|
@@ -1837,8 +1837,8 @@ const ts = 0.1, es = 2, Je = 0.1, ns = 90, Ft = 16, Ut = 16, Ot = 4096, Et = 409
|
|
|
1837
1837
|
"radiusBottomRight",
|
|
1838
1838
|
"radiusBottomLeft",
|
|
1839
1839
|
"lineFontDefaults"
|
|
1840
|
-
],
|
|
1841
|
-
class
|
|
1840
|
+
], is = 50;
|
|
1841
|
+
class yt {
|
|
1842
1842
|
constructor({ editor: t }) {
|
|
1843
1843
|
this.editor = t, this.options = t.options, this._createdBlobUrls = [], this.acceptContentTypes = this.editor.options.acceptContentTypes, this.acceptFormats = this.getAllowedFormatsFromContentTypes();
|
|
1844
1844
|
}
|
|
@@ -1867,17 +1867,17 @@ class mt {
|
|
|
1867
1867
|
customData: c = null
|
|
1868
1868
|
} = t;
|
|
1869
1869
|
if (!e) return null;
|
|
1870
|
-
const { canvas: l, montageArea: h, transformManager: u, historyManager: f, errorManager:
|
|
1870
|
+
const { canvas: l, montageArea: h, transformManager: u, historyManager: f, errorManager: p } = this.editor, m = yield this.getContentType(e), g = yt.getFormatFromContentType(m), { acceptContentTypes: v, acceptFormats: M } = this;
|
|
1871
1871
|
if (!this.isAllowedContentType(m)) {
|
|
1872
|
-
const
|
|
1873
|
-
return
|
|
1872
|
+
const C = `Неверный contentType для изображения: ${m}. Ожидается один из: ${this.acceptContentTypes.join(", ")}.`;
|
|
1873
|
+
return p.emitError({
|
|
1874
1874
|
origin: "ImageManager",
|
|
1875
1875
|
method: "importImage",
|
|
1876
1876
|
code: "INVALID_CONTENT_TYPE",
|
|
1877
|
-
message:
|
|
1877
|
+
message: C,
|
|
1878
1878
|
data: {
|
|
1879
1879
|
source: e,
|
|
1880
|
-
format:
|
|
1880
|
+
format: g,
|
|
1881
1881
|
contentType: m,
|
|
1882
1882
|
acceptContentTypes: v,
|
|
1883
1883
|
acceptFormats: M,
|
|
@@ -1891,21 +1891,21 @@ class mt {
|
|
|
1891
1891
|
}
|
|
1892
1892
|
f.suspendHistory();
|
|
1893
1893
|
try {
|
|
1894
|
-
let
|
|
1894
|
+
let C, y;
|
|
1895
1895
|
if (e instanceof File)
|
|
1896
|
-
|
|
1896
|
+
C = URL.createObjectURL(e);
|
|
1897
1897
|
else if (typeof e == "string") {
|
|
1898
1898
|
const A = yield (yield fetch(e, { mode: "cors" })).blob();
|
|
1899
|
-
|
|
1899
|
+
C = URL.createObjectURL(A);
|
|
1900
1900
|
} else
|
|
1901
|
-
return
|
|
1901
|
+
return p.emitError({
|
|
1902
1902
|
origin: "ImageManager",
|
|
1903
1903
|
method: "importImage",
|
|
1904
1904
|
code: "INVALID_SOURCE_TYPE",
|
|
1905
1905
|
message: "Неверный тип источника изображения. Ожидается URL или объект File.",
|
|
1906
1906
|
data: {
|
|
1907
1907
|
source: e,
|
|
1908
|
-
format:
|
|
1908
|
+
format: g,
|
|
1909
1909
|
contentType: m,
|
|
1910
1910
|
acceptContentTypes: v,
|
|
1911
1911
|
acceptFormats: M,
|
|
@@ -1916,32 +1916,32 @@ class mt {
|
|
|
1916
1916
|
customData: c
|
|
1917
1917
|
}
|
|
1918
1918
|
}), null;
|
|
1919
|
-
if (this._createdBlobUrls.push(
|
|
1920
|
-
const b = yield
|
|
1921
|
-
y =
|
|
1919
|
+
if (this._createdBlobUrls.push(C), g === "svg") {
|
|
1920
|
+
const b = yield An(C);
|
|
1921
|
+
y = ft.groupSVGElements(b.objects, b.options);
|
|
1922
1922
|
} else
|
|
1923
|
-
y = yield Xt.fromURL(
|
|
1924
|
-
const { width: w, height:
|
|
1923
|
+
y = yield Xt.fromURL(C, { crossOrigin: "anonymous" });
|
|
1924
|
+
const { width: w, height: j } = y;
|
|
1925
1925
|
if (y instanceof Xt) {
|
|
1926
1926
|
const b = y.getElement();
|
|
1927
1927
|
let A = "";
|
|
1928
|
-
if (b instanceof HTMLImageElement ? A = b.src : b instanceof HTMLCanvasElement && (A = b.toDataURL()),
|
|
1929
|
-
const S = yield this.resizeImageToBoundaries(A, "max"),
|
|
1930
|
-
this._createdBlobUrls.push(
|
|
1931
|
-
} else if (
|
|
1932
|
-
const S = yield this.resizeImageToBoundaries(A, "min"),
|
|
1933
|
-
this._createdBlobUrls.push(
|
|
1928
|
+
if (b instanceof HTMLImageElement ? A = b.src : b instanceof HTMLCanvasElement && (A = b.toDataURL()), j > Et || w > Ot) {
|
|
1929
|
+
const S = yield this.resizeImageToBoundaries(A, "max"), I = URL.createObjectURL(S);
|
|
1930
|
+
this._createdBlobUrls.push(I), y = yield Xt.fromURL(I, { crossOrigin: "anonymous" });
|
|
1931
|
+
} else if (j < Wt || w < Ft) {
|
|
1932
|
+
const S = yield this.resizeImageToBoundaries(A, "min"), I = URL.createObjectURL(S);
|
|
1933
|
+
this._createdBlobUrls.push(I), y = yield Xt.fromURL(I, { crossOrigin: "anonymous" });
|
|
1934
1934
|
}
|
|
1935
1935
|
}
|
|
1936
|
-
if (y.set("id", `${y.type}-${
|
|
1936
|
+
if (y.set("id", `${y.type}-${tt()}`), y.set("format", g), y.set("customData", c || null), n === "scale-montage")
|
|
1937
1937
|
this.editor.canvasManager.scaleMontageAreaToImage({ object: y, withoutSave: !0 });
|
|
1938
1938
|
else {
|
|
1939
1939
|
const { width: b, height: A } = h, S = this.calculateScaleFactor({ imageObject: y, scaleType: n });
|
|
1940
|
-
n === "image-contain" && S < 1 ? u.fitObject({ object: y, type: "contain", withoutSave: !0 }) : n === "image-cover" && (w > b ||
|
|
1940
|
+
n === "image-contain" && S < 1 ? u.fitObject({ object: y, type: "contain", withoutSave: !0 }) : n === "image-cover" && (w > b || j > A) && u.fitObject({ object: y, type: "cover", withoutSave: !0 });
|
|
1941
1941
|
}
|
|
1942
|
-
const
|
|
1942
|
+
const T = {
|
|
1943
1943
|
image: y,
|
|
1944
|
-
format:
|
|
1944
|
+
format: g,
|
|
1945
1945
|
contentType: m,
|
|
1946
1946
|
scale: n,
|
|
1947
1947
|
withoutSave: s,
|
|
@@ -1952,16 +1952,16 @@ class mt {
|
|
|
1952
1952
|
withoutAdding: r,
|
|
1953
1953
|
customData: c
|
|
1954
1954
|
};
|
|
1955
|
-
return r ? (f.resumeHistory(), l.fire("editor:image-imported",
|
|
1956
|
-
} catch (
|
|
1957
|
-
return
|
|
1955
|
+
return r ? (f.resumeHistory(), l.fire("editor:image-imported", T), T) : (l.add(y), l.centerObject(y), a || l.setActiveObject(y), l.renderAll(), f.resumeHistory(), s || f.saveState(), l.fire("editor:image-imported", T), T);
|
|
1956
|
+
} catch (C) {
|
|
1957
|
+
return p.emitError({
|
|
1958
1958
|
origin: "ImageManager",
|
|
1959
1959
|
method: "importImage",
|
|
1960
1960
|
code: "IMPORT_FAILED",
|
|
1961
|
-
message: `Ошибка импорта изображения: ${
|
|
1961
|
+
message: `Ошибка импорта изображения: ${C.message}`,
|
|
1962
1962
|
data: {
|
|
1963
1963
|
source: e,
|
|
1964
|
-
format:
|
|
1964
|
+
format: g,
|
|
1965
1965
|
contentType: m,
|
|
1966
1966
|
scale: n,
|
|
1967
1967
|
withoutSave: s,
|
|
@@ -1986,14 +1986,14 @@ class mt {
|
|
|
1986
1986
|
resizeImageToBoundaries(t, e = "max") {
|
|
1987
1987
|
return Z(this, null, function* () {
|
|
1988
1988
|
let n = `Размер изображения больше максимального размера канваса, поэтому оно будет уменьшено до максимальных размеров c сохранением пропорций: ${Ot}x${Et}`;
|
|
1989
|
-
e === "min" && (n = `Размер изображения меньше минимального размера канваса, поэтому оно будет увеличено до минимальных размеров c сохранением пропорций: ${Ft}x${
|
|
1989
|
+
e === "min" && (n = `Размер изображения меньше минимального размера канваса, поэтому оно будет увеличено до минимальных размеров c сохранением пропорций: ${Ft}x${Wt}`);
|
|
1990
1990
|
const s = {
|
|
1991
1991
|
dataURL: t,
|
|
1992
1992
|
sizeType: e,
|
|
1993
1993
|
maxWidth: Ot,
|
|
1994
1994
|
maxHeight: Et,
|
|
1995
1995
|
minWidth: Ft,
|
|
1996
|
-
minHeight:
|
|
1996
|
+
minHeight: Wt
|
|
1997
1997
|
};
|
|
1998
1998
|
return this.editor.errorManager.emitWarning({
|
|
1999
1999
|
origin: "ImageManager",
|
|
@@ -2024,22 +2024,22 @@ class mt {
|
|
|
2024
2024
|
exportAsBlob: o = !1
|
|
2025
2025
|
} = t, { canvas: i, montageArea: a, workerManager: r, interactionBlocker: c } = this.editor;
|
|
2026
2026
|
try {
|
|
2027
|
-
const l = n === "application/pdf", h = l ? "image/jpg" : n, u =
|
|
2027
|
+
const l = n === "application/pdf", h = l ? "image/jpg" : n, u = yt.getFormatFromContentType(h);
|
|
2028
2028
|
a.setCoords();
|
|
2029
|
-
const { left: f, top:
|
|
2029
|
+
const { left: f, top: p, width: m, height: g } = a.getBoundingRect(), v = yield i.clone(["id", "format", "locked"]);
|
|
2030
2030
|
v.enableRetinaScaling = !1, ["image/jpg", "image/jpeg"].includes(h) && (v.backgroundColor = "#ffffff");
|
|
2031
2031
|
const M = v.getObjects().find((S) => S.id === a.id);
|
|
2032
2032
|
if (M && (M.visible = !1), c != null && c.isBlocked) {
|
|
2033
|
-
const S = v.getObjects().find((
|
|
2033
|
+
const S = v.getObjects().find((I) => I.id === c.overlayMask.id);
|
|
2034
2034
|
S && (S.visible = !1);
|
|
2035
2035
|
}
|
|
2036
|
-
v.viewportTransform = [1, 0, 0, 1, -f, -
|
|
2037
|
-
const
|
|
2038
|
-
if (u === "svg" &&
|
|
2036
|
+
v.viewportTransform = [1, 0, 0, 1, -f, -p], v.setDimensions({ width: m, height: g }, { backstoreOnly: !0 }), v.renderAll();
|
|
2037
|
+
const C = v.getObjects().filter((S) => S.format).every((S) => S.format === "svg");
|
|
2038
|
+
if (u === "svg" && C) {
|
|
2039
2039
|
const S = v.toSVG();
|
|
2040
2040
|
v.dispose();
|
|
2041
2041
|
const O = {
|
|
2042
|
-
image:
|
|
2042
|
+
image: yt._exportSVGStringAsFile(S, {
|
|
2043
2043
|
exportAsBase64: s,
|
|
2044
2044
|
exportAsBlob: o,
|
|
2045
2045
|
fileName: e
|
|
@@ -2050,9 +2050,9 @@ class mt {
|
|
|
2050
2050
|
};
|
|
2051
2051
|
return i.fire("editor:canvas-exported", O), O;
|
|
2052
2052
|
}
|
|
2053
|
-
const y = yield new Promise((S,
|
|
2053
|
+
const y = yield new Promise((S, I) => {
|
|
2054
2054
|
v.getElement().toBlob((O) => {
|
|
2055
|
-
O ? S(O) :
|
|
2055
|
+
O ? S(O) : I(new Error("Failed to create Blob from canvas"));
|
|
2056
2056
|
});
|
|
2057
2057
|
});
|
|
2058
2058
|
if (v.dispose(), o) {
|
|
@@ -2064,28 +2064,28 @@ class mt {
|
|
|
2064
2064
|
};
|
|
2065
2065
|
return i.fire("editor:canvas-exported", S), S;
|
|
2066
2066
|
}
|
|
2067
|
-
const w = yield createImageBitmap(y),
|
|
2067
|
+
const w = yield createImageBitmap(y), j = yield r.post(
|
|
2068
2068
|
"toDataURL",
|
|
2069
2069
|
{ format: u, quality: 1, bitmap: w },
|
|
2070
2070
|
[w]
|
|
2071
2071
|
);
|
|
2072
2072
|
if (l) {
|
|
2073
|
-
const
|
|
2074
|
-
orientation:
|
|
2073
|
+
const I = m * 0.264583, O = g * 0.264583, N = (yield this.editor.moduleLoader.loadModule("jspdf")).jsPDF, W = new N({
|
|
2074
|
+
orientation: I > O ? "landscape" : "portrait",
|
|
2075
2075
|
unit: "mm",
|
|
2076
|
-
format: [
|
|
2076
|
+
format: [I, O]
|
|
2077
2077
|
});
|
|
2078
|
-
if (
|
|
2079
|
-
const
|
|
2080
|
-
image:
|
|
2078
|
+
if (W.addImage(String(j), "JPG", 0, 0, I, O), s) {
|
|
2079
|
+
const R = {
|
|
2080
|
+
image: W.output("datauristring"),
|
|
2081
2081
|
format: "pdf",
|
|
2082
2082
|
contentType: "application/pdf",
|
|
2083
2083
|
fileName: e
|
|
2084
2084
|
};
|
|
2085
|
-
return i.fire("editor:canvas-exported",
|
|
2085
|
+
return i.fire("editor:canvas-exported", R), R;
|
|
2086
2086
|
}
|
|
2087
|
-
const
|
|
2088
|
-
image: new File([
|
|
2087
|
+
const z = W.output("blob"), B = {
|
|
2088
|
+
image: new File([z], e, { type: "application/pdf" }),
|
|
2089
2089
|
format: "pdf",
|
|
2090
2090
|
contentType: "application/pdf",
|
|
2091
2091
|
fileName: e
|
|
@@ -2094,18 +2094,18 @@ class mt {
|
|
|
2094
2094
|
}
|
|
2095
2095
|
if (s) {
|
|
2096
2096
|
const S = {
|
|
2097
|
-
image:
|
|
2097
|
+
image: j,
|
|
2098
2098
|
format: u,
|
|
2099
2099
|
contentType: h,
|
|
2100
2100
|
fileName: e
|
|
2101
2101
|
};
|
|
2102
2102
|
return i.fire("editor:canvas-exported", S), S;
|
|
2103
2103
|
}
|
|
2104
|
-
const
|
|
2105
|
-
image: new File([y],
|
|
2104
|
+
const T = u === "svg" && !C ? e.replace(/\.[^/.]+$/, ".png") : e, A = {
|
|
2105
|
+
image: new File([y], T, { type: h }),
|
|
2106
2106
|
format: u,
|
|
2107
2107
|
contentType: h,
|
|
2108
|
-
fileName:
|
|
2108
|
+
fileName: T
|
|
2109
2109
|
};
|
|
2110
2110
|
return i.fire("editor:canvas-exported", A), A;
|
|
2111
2111
|
} catch (l) {
|
|
@@ -2148,15 +2148,15 @@ class mt {
|
|
|
2148
2148
|
data: { contentType: s, fileName: n, exportAsBase64: o, exportAsBlob: i }
|
|
2149
2149
|
}), null;
|
|
2150
2150
|
try {
|
|
2151
|
-
const l =
|
|
2151
|
+
const l = yt.getFormatFromContentType(s);
|
|
2152
2152
|
if (l === "svg") {
|
|
2153
|
-
const m = c.toSVG(),
|
|
2153
|
+
const m = c.toSVG(), g = yt._exportSVGStringAsFile(m, {
|
|
2154
2154
|
exportAsBase64: o,
|
|
2155
2155
|
exportAsBlob: i,
|
|
2156
2156
|
fileName: n
|
|
2157
2157
|
}), v = {
|
|
2158
2158
|
object: c,
|
|
2159
|
-
image:
|
|
2159
|
+
image: g,
|
|
2160
2160
|
format: l,
|
|
2161
2161
|
contentType: "image/svg+xml",
|
|
2162
2162
|
fileName: n.replace(/\.[^/.]+$/, ".svg")
|
|
@@ -2164,7 +2164,7 @@ class mt {
|
|
|
2164
2164
|
return a.fire("editor:object-exported", v), v;
|
|
2165
2165
|
}
|
|
2166
2166
|
if (o && c instanceof Xt) {
|
|
2167
|
-
const m = yield createImageBitmap(c.getElement()),
|
|
2167
|
+
const m = yield createImageBitmap(c.getElement()), g = yield r.post(
|
|
2168
2168
|
"toDataURL",
|
|
2169
2169
|
{
|
|
2170
2170
|
format: l,
|
|
@@ -2174,7 +2174,7 @@ class mt {
|
|
|
2174
2174
|
[m]
|
|
2175
2175
|
), v = {
|
|
2176
2176
|
object: c,
|
|
2177
|
-
image:
|
|
2177
|
+
image: g,
|
|
2178
2178
|
format: l,
|
|
2179
2179
|
contentType: s,
|
|
2180
2180
|
fileName: n
|
|
@@ -2183,9 +2183,9 @@ class mt {
|
|
|
2183
2183
|
}
|
|
2184
2184
|
const h = c.toCanvasElement({
|
|
2185
2185
|
enableRetinaScaling: !1
|
|
2186
|
-
}), u = yield new Promise((m,
|
|
2186
|
+
}), u = yield new Promise((m, g) => {
|
|
2187
2187
|
h.toBlob((v) => {
|
|
2188
|
-
v ? m(v) :
|
|
2188
|
+
v ? m(v) : g(new Error("Failed to create Blob from canvas"));
|
|
2189
2189
|
});
|
|
2190
2190
|
});
|
|
2191
2191
|
if (i) {
|
|
@@ -2198,14 +2198,14 @@ class mt {
|
|
|
2198
2198
|
};
|
|
2199
2199
|
return a.fire("editor:object-exported", m), m;
|
|
2200
2200
|
}
|
|
2201
|
-
const f = new File([u], n, { type: s }),
|
|
2201
|
+
const f = new File([u], n, { type: s }), p = {
|
|
2202
2202
|
object: c,
|
|
2203
2203
|
image: f,
|
|
2204
2204
|
format: l,
|
|
2205
2205
|
contentType: s,
|
|
2206
2206
|
fileName: n
|
|
2207
2207
|
};
|
|
2208
|
-
return a.fire("editor:object-exported",
|
|
2208
|
+
return a.fire("editor:object-exported", p), p;
|
|
2209
2209
|
} catch (l) {
|
|
2210
2210
|
return this.editor.errorManager.emitError({
|
|
2211
2211
|
origin: "ImageManager",
|
|
@@ -2228,7 +2228,7 @@ class mt {
|
|
|
2228
2228
|
* @returns массив допустимых форматов изображений
|
|
2229
2229
|
*/
|
|
2230
2230
|
getAllowedFormatsFromContentTypes() {
|
|
2231
|
-
return this.acceptContentTypes.map((t) =>
|
|
2231
|
+
return this.acceptContentTypes.map((t) => yt.getFormatFromContentType(t)).filter((t) => t);
|
|
2232
2232
|
}
|
|
2233
2233
|
/**
|
|
2234
2234
|
* Проверяет, является ли contentType допустимым типом изображения.
|
|
@@ -2281,7 +2281,7 @@ class mt {
|
|
|
2281
2281
|
try {
|
|
2282
2282
|
const s = (e = new URL(t).pathname.split(".").pop()) == null ? void 0 : e.toLowerCase(), o = {};
|
|
2283
2283
|
return this.acceptContentTypes.forEach((i) => {
|
|
2284
|
-
const a =
|
|
2284
|
+
const a = yt.getFormatFromContentType(i);
|
|
2285
2285
|
a && (o[a] = i);
|
|
2286
2286
|
}), s && o[s] || "application/octet-stream";
|
|
2287
2287
|
} catch (n) {
|
|
@@ -2334,11 +2334,11 @@ class mt {
|
|
|
2334
2334
|
return e ? e[1] : "";
|
|
2335
2335
|
}
|
|
2336
2336
|
}
|
|
2337
|
-
const St = (d, t, e) => Math.max(Math.min(d, e), t),
|
|
2338
|
-
function
|
|
2337
|
+
const St = (d, t, e) => Math.max(Math.min(d, e), t), nn = (d, t) => d * t, os = (d, t) => new at(d / 2, t / 2);
|
|
2338
|
+
function as(d) {
|
|
2339
2339
|
return ((d == null ? void 0 : d.type) === "image" || (d == null ? void 0 : d.format) === "svg") && typeof (d == null ? void 0 : d.width) == "number" && typeof (d == null ? void 0 : d.height) == "number";
|
|
2340
2340
|
}
|
|
2341
|
-
class
|
|
2341
|
+
class rs {
|
|
2342
2342
|
/**
|
|
2343
2343
|
* @param options
|
|
2344
2344
|
* @param options.editor – экземпляр редактора
|
|
@@ -2379,16 +2379,16 @@ class as {
|
|
|
2379
2379
|
* @fires editor:resolution-width-changed
|
|
2380
2380
|
*/
|
|
2381
2381
|
setResolutionWidth(t, { preserveProportional: e, withoutSave: n, adaptCanvasToContainer: s } = {}) {
|
|
2382
|
-
var
|
|
2382
|
+
var p;
|
|
2383
2383
|
if (!t) return;
|
|
2384
2384
|
const {
|
|
2385
2385
|
canvas: o,
|
|
2386
2386
|
montageArea: i,
|
|
2387
2387
|
options: { canvasBackstoreWidth: a }
|
|
2388
2388
|
} = this.editor, { width: r, height: c } = i, l = St(Number(t), Ft, Ot);
|
|
2389
|
-
if (!a || a === "auto" || s ? this.adaptCanvasToContainer() : a ? this.setCanvasBackstoreWidth(Number(a)) : this.setCanvasBackstoreWidth(l), i.set({ width: l }), (
|
|
2390
|
-
const m = l / r,
|
|
2391
|
-
this.setResolutionHeight(
|
|
2389
|
+
if (!a || a === "auto" || s ? this.adaptCanvasToContainer() : a ? this.setCanvasBackstoreWidth(Number(a)) : this.setCanvasBackstoreWidth(l), i.set({ width: l }), (p = o.clipPath) == null || p.set({ width: l }), e) {
|
|
2390
|
+
const m = l / r, g = nn(c, m);
|
|
2391
|
+
this.setResolutionHeight(g);
|
|
2392
2392
|
return;
|
|
2393
2393
|
}
|
|
2394
2394
|
const { left: h, top: u } = this.getObjectDefaultCoords(i), f = o.getZoom();
|
|
@@ -2409,16 +2409,16 @@ class as {
|
|
|
2409
2409
|
* @fires editor:resolution-height-changed
|
|
2410
2410
|
*/
|
|
2411
2411
|
setResolutionHeight(t, { preserveProportional: e, withoutSave: n, adaptCanvasToContainer: s } = {}) {
|
|
2412
|
-
var
|
|
2412
|
+
var p;
|
|
2413
2413
|
if (!t) return;
|
|
2414
2414
|
const {
|
|
2415
2415
|
canvas: o,
|
|
2416
2416
|
montageArea: i,
|
|
2417
2417
|
options: { canvasBackstoreHeight: a }
|
|
2418
|
-
} = this.editor, { width: r, height: c } = i, l = St(Number(t),
|
|
2419
|
-
if (!a || a === "auto" || s ? this.adaptCanvasToContainer() : a ? this.setCanvasBackstoreHeight(Number(a)) : this.setCanvasBackstoreHeight(l), i.set({ height: l }), (
|
|
2420
|
-
const m = l / c,
|
|
2421
|
-
this.setResolutionWidth(
|
|
2418
|
+
} = this.editor, { width: r, height: c } = i, l = St(Number(t), Wt, Et);
|
|
2419
|
+
if (!a || a === "auto" || s ? this.adaptCanvasToContainer() : a ? this.setCanvasBackstoreHeight(Number(a)) : this.setCanvasBackstoreHeight(l), i.set({ height: l }), (p = o.clipPath) == null || p.set({ height: l }), e) {
|
|
2420
|
+
const m = l / c, g = nn(r, m);
|
|
2421
|
+
this.setResolutionWidth(g);
|
|
2422
2422
|
return;
|
|
2423
2423
|
}
|
|
2424
2424
|
const { left: h, top: u } = this.getObjectDefaultCoords(i), f = o.getZoom();
|
|
@@ -2435,7 +2435,7 @@ class as {
|
|
|
2435
2435
|
*/
|
|
2436
2436
|
centerMontageArea() {
|
|
2437
2437
|
var r;
|
|
2438
|
-
const { canvas: t, montageArea: e } = this.editor, n = t.getWidth(), s = t.getHeight(), o = t.getZoom(), i =
|
|
2438
|
+
const { canvas: t, montageArea: e } = this.editor, n = t.getWidth(), s = t.getHeight(), o = t.getZoom(), i = os(n, s);
|
|
2439
2439
|
e.set({
|
|
2440
2440
|
left: n / 2,
|
|
2441
2441
|
top: s / 2
|
|
@@ -2477,7 +2477,7 @@ class as {
|
|
|
2477
2477
|
*/
|
|
2478
2478
|
setCanvasBackstoreHeight(t) {
|
|
2479
2479
|
if (!t || typeof t != "number") return;
|
|
2480
|
-
const e = St(t,
|
|
2480
|
+
const e = St(t, Wt, Et);
|
|
2481
2481
|
this.editor.canvas.setDimensions({ height: e }, { backstoreOnly: !0 });
|
|
2482
2482
|
}
|
|
2483
2483
|
/**
|
|
@@ -2486,7 +2486,7 @@ class as {
|
|
|
2486
2486
|
* с учётом минимальных и максимальных значений.
|
|
2487
2487
|
*/
|
|
2488
2488
|
adaptCanvasToContainer() {
|
|
2489
|
-
const { canvas: t } = this.editor, e = this.getEditorContainer(), n = e.clientWidth, s = e.clientHeight, o = St(n, Ft, Ot), i = St(s,
|
|
2489
|
+
const { canvas: t } = this.editor, e = this.getEditorContainer(), n = e.clientWidth, s = e.clientHeight, o = St(n, Ft, Ot), i = St(s, Wt, Et);
|
|
2490
2490
|
t.setDimensions({ width: o, height: i }, { backstoreOnly: !0 });
|
|
2491
2491
|
}
|
|
2492
2492
|
/**
|
|
@@ -2686,15 +2686,15 @@ class as {
|
|
|
2686
2686
|
montageAreaHeight: r
|
|
2687
2687
|
}
|
|
2688
2688
|
} = this.editor, c = t || s.getActiveObject();
|
|
2689
|
-
if (!
|
|
2689
|
+
if (!as(c)) return;
|
|
2690
2690
|
const { width: l, height: h } = c;
|
|
2691
2691
|
let u = Math.min(l, Ot), f = Math.min(h, Et);
|
|
2692
2692
|
if (e) {
|
|
2693
2693
|
const {
|
|
2694
|
-
width:
|
|
2694
|
+
width: p,
|
|
2695
2695
|
height: m
|
|
2696
|
-
} = o,
|
|
2697
|
-
u =
|
|
2696
|
+
} = o, g = l / p, v = h / m, M = Math.max(g, v);
|
|
2697
|
+
u = p * M, f = m * M;
|
|
2698
2698
|
}
|
|
2699
2699
|
this.setResolutionWidth(u, { withoutSave: !0 }), this.setResolutionHeight(f, { withoutSave: !0 }), this.editor.backgroundManager.backgroundObject && this.editor.backgroundManager.refresh(), (l > a || h > r) && this.editor.zoomManager.calculateAndApplyDefaultZoom(), i.resetObject({ object: c, withoutSave: !0 }), s.centerObject(c), s.renderAll(), n || this.editor.historyManager.saveState(), s.fire("editor:montage-area-scaled-to-image", {
|
|
2700
2700
|
object: c,
|
|
@@ -2746,7 +2746,7 @@ class as {
|
|
|
2746
2746
|
);
|
|
2747
2747
|
}
|
|
2748
2748
|
}
|
|
2749
|
-
class
|
|
2749
|
+
class cs {
|
|
2750
2750
|
constructor({ editor: t }) {
|
|
2751
2751
|
this.editor = t, this.options = t.options;
|
|
2752
2752
|
}
|
|
@@ -2757,7 +2757,7 @@ class rs {
|
|
|
2757
2757
|
* @param options.withoutSave - Не сохранять состояние
|
|
2758
2758
|
* @fires editor:object-rotated
|
|
2759
2759
|
*/
|
|
2760
|
-
rotate(t =
|
|
2760
|
+
rotate(t = ss, { withoutSave: e } = {}) {
|
|
2761
2761
|
const { canvas: n, historyManager: s } = this.editor, o = n.getActiveObject();
|
|
2762
2762
|
if (!o) return;
|
|
2763
2763
|
const i = o.angle + t;
|
|
@@ -2858,11 +2858,11 @@ class rs {
|
|
|
2858
2858
|
* @private
|
|
2859
2859
|
*/
|
|
2860
2860
|
_fitSingleObject(t, e) {
|
|
2861
|
-
const { canvas: n, montageArea: s } = this.editor, { width: o, height: i, scaleX: a = 1, scaleY: r = 1, angle: c = 0 } = t, l = o * Math.abs(a), h = i * Math.abs(r), u = c * Math.PI / 180, f = Math.abs(Math.cos(u)),
|
|
2862
|
-
let
|
|
2863
|
-
e === "contain" ?
|
|
2864
|
-
scaleX: a *
|
|
2865
|
-
scaleY: r *
|
|
2861
|
+
const { canvas: n, montageArea: s } = this.editor, { width: o, height: i, scaleX: a = 1, scaleY: r = 1, angle: c = 0 } = t, l = o * Math.abs(a), h = i * Math.abs(r), u = c * Math.PI / 180, f = Math.abs(Math.cos(u)), p = Math.abs(Math.sin(u)), m = l * f + h * p, g = l * p + h * f, v = s.width, M = s.height;
|
|
2862
|
+
let C;
|
|
2863
|
+
e === "contain" ? C = Math.min(v / m, M / g) : C = Math.max(v / m, M / g), t.set({
|
|
2864
|
+
scaleX: a * C,
|
|
2865
|
+
scaleY: r * C
|
|
2866
2866
|
}), n.centerObject(t);
|
|
2867
2867
|
}
|
|
2868
2868
|
/**
|
|
@@ -2899,11 +2899,11 @@ class rs {
|
|
|
2899
2899
|
}), e)
|
|
2900
2900
|
this.fitObject({ object: c, withoutSave: !0, fitAsOneObject: !0 });
|
|
2901
2901
|
else {
|
|
2902
|
-
const { width: h, height: u } = o, { width: f, height:
|
|
2902
|
+
const { width: h, height: u } = o, { width: f, height: p } = c, m = i.calculateScaleFactor({
|
|
2903
2903
|
imageObject: c,
|
|
2904
2904
|
scaleType: r
|
|
2905
2905
|
});
|
|
2906
|
-
r === "contain" && m < 1 || r === "cover" && (f > h ||
|
|
2906
|
+
r === "contain" && m < 1 || r === "cover" && (f > h || p > u) ? this.fitObject({ object: c, withoutSave: !0, fitAsOneObject: !0 }) : c.set({ scaleX: 1, scaleY: 1 });
|
|
2907
2907
|
}
|
|
2908
2908
|
c.set({ flipX: !1, flipY: !1, angle: 0 }), s.centerObject(c), s.renderAll(), a.resumeHistory(), n || a.saveState(), s.fire("editor:object-reset", {
|
|
2909
2909
|
object: c,
|
|
@@ -2912,9 +2912,9 @@ class rs {
|
|
|
2912
2912
|
});
|
|
2913
2913
|
}
|
|
2914
2914
|
}
|
|
2915
|
-
class
|
|
2915
|
+
class ls {
|
|
2916
2916
|
constructor({ editor: t }) {
|
|
2917
|
-
this.editor = t, this.options = t.options, this.minZoom = this.options.minZoom ||
|
|
2917
|
+
this.editor = t, this.options = t.options, this.minZoom = this.options.minZoom || es, this.maxZoom = this.options.maxZoom || ns, this.defaultZoom = this._normalizeDefaultZoom(this.options.defaultScale);
|
|
2918
2918
|
}
|
|
2919
2919
|
/**
|
|
2920
2920
|
* Приводит значение defaultZoom к числу с двумя знаками после запятой, а также учитывает минимальное и максимальное значения.
|
|
@@ -2945,10 +2945,10 @@ class cs {
|
|
|
2945
2945
|
* @private
|
|
2946
2946
|
*/
|
|
2947
2947
|
_getClampedPointerCoordinates(t) {
|
|
2948
|
-
const { canvas: e, montageArea: n } = this.editor, s = e.getPointer(t, !0), o = e.viewportTransform, i = e.getZoom(), a = n.left - n.width / 2, r = n.left + n.width / 2, c = n.top - n.height / 2, l = n.top + n.height / 2, h = a * i + o[4], u = r * i + o[4], f = c * i + o[5],
|
|
2948
|
+
const { canvas: e, montageArea: n } = this.editor, s = e.getPointer(t, !0), o = e.viewportTransform, i = e.getZoom(), a = n.left - n.width / 2, r = n.left + n.width / 2, c = n.top - n.height / 2, l = n.top + n.height / 2, h = a * i + o[4], u = r * i + o[4], f = c * i + o[5], p = l * i + o[5], m = Math.max(h, Math.min(u, s.x)), g = Math.max(f, Math.min(p, s.y));
|
|
2949
2949
|
return {
|
|
2950
2950
|
x: m,
|
|
2951
|
-
y:
|
|
2951
|
+
y: g
|
|
2952
2952
|
};
|
|
2953
2953
|
}
|
|
2954
2954
|
/**
|
|
@@ -2980,10 +2980,10 @@ class cs {
|
|
|
2980
2980
|
* @private
|
|
2981
2981
|
*/
|
|
2982
2982
|
_calculateEmptySpaceRatio(t) {
|
|
2983
|
-
const { canvas: e, montageArea: n } = this.editor, s = e.viewportTransform, o = e.getWidth(), i = e.getHeight(), a = n.left - n.width / 2, r = n.left + n.width / 2, c = n.top - n.height / 2, l = n.top + n.height / 2, h = -s[4] / t, u = (-s[4] + o) / t, f = -s[5] / t,
|
|
2984
|
-
if (!(m ||
|
|
2985
|
-
const y = Math.max(0, a - h), w = Math.max(0, u - r),
|
|
2986
|
-
return Math.max(S,
|
|
2983
|
+
const { canvas: e, montageArea: n } = this.editor, s = e.viewportTransform, o = e.getWidth(), i = e.getHeight(), a = n.left - n.width / 2, r = n.left + n.width / 2, c = n.top - n.height / 2, l = n.top + n.height / 2, h = -s[4] / t, u = (-s[4] + o) / t, f = -s[5] / t, p = (-s[5] + i) / t, m = h < a, g = u > r, v = f < c, M = p > l;
|
|
2984
|
+
if (!(m || g || v || M)) return 0;
|
|
2985
|
+
const y = Math.max(0, a - h), w = Math.max(0, u - r), j = Math.max(0, c - f), T = Math.max(0, p - l), b = Math.max(y, w), A = Math.max(j, T), S = b / o, I = A / i;
|
|
2986
|
+
return Math.max(S, I);
|
|
2987
2987
|
}
|
|
2988
2988
|
/**
|
|
2989
2989
|
* Вычисляет плавный шаг перемещения viewport к центру с ускорением
|
|
@@ -2996,11 +2996,11 @@ class cs {
|
|
|
2996
2996
|
* @private
|
|
2997
2997
|
*/
|
|
2998
2998
|
_calculateSmoothCenteringStep(t, e, n, s, o) {
|
|
2999
|
-
const { canvas: i, montageArea: a } = this.editor, r = i.viewportTransform, c = i.getWidth(), l = i.getHeight(), h = t.x - r[4], u = t.y - r[5], f = Math.abs(s),
|
|
3000
|
-
if (Math.abs(
|
|
2999
|
+
const { canvas: i, montageArea: a } = this.editor, r = i.viewportTransform, c = i.getWidth(), l = i.getHeight(), h = t.x - r[4], u = t.y - r[5], f = Math.abs(s), p = e - n;
|
|
3000
|
+
if (Math.abs(p) / f <= 0.1)
|
|
3001
3001
|
return { x: h, y: u };
|
|
3002
|
-
const
|
|
3003
|
-
return { x: O, y:
|
|
3002
|
+
const g = c / 2, v = l / 2, M = a.left, C = a.top, y = g - M * n, w = v - C * n, j = (y - r[4]) / (e - n), T = (w - r[5]) / (e - n), b = j * f, A = T * f, S = b * o, I = A * o, O = Math.abs(S) > Math.abs(h) ? h : S, N = Math.abs(I) > Math.abs(u) ? u : I;
|
|
3003
|
+
return { x: O, y: N };
|
|
3004
3004
|
}
|
|
3005
3005
|
/**
|
|
3006
3006
|
* Применяет плавное центрирование viewport при приближении к defaultZoom.
|
|
@@ -3012,7 +3012,7 @@ class cs {
|
|
|
3012
3012
|
* @returns true если центрирование было применено
|
|
3013
3013
|
* @private
|
|
3014
3014
|
*/
|
|
3015
|
-
_applyViewportCentering(t, e = !1, n =
|
|
3015
|
+
_applyViewportCentering(t, e = !1, n = tn) {
|
|
3016
3016
|
const { canvas: s } = this.editor, o = this._getScaledMontageDimensions(t), i = s.getWidth(), a = s.getHeight(), r = o.width > i || o.height > a, c = this._calculateFitZoom(), l = t - c;
|
|
3017
3017
|
if (!(!r || l) && !e)
|
|
3018
3018
|
return !1;
|
|
@@ -3020,9 +3020,9 @@ class cs {
|
|
|
3020
3020
|
if (!r)
|
|
3021
3021
|
return u[4] = f.x, u[5] = f.y, s.setViewportTransform(u), !0;
|
|
3022
3022
|
if (e && !r) {
|
|
3023
|
-
const
|
|
3024
|
-
if (
|
|
3025
|
-
const m = this._calculateSmoothCenteringStep(f, t, c, n,
|
|
3023
|
+
const p = this._calculateEmptySpaceRatio(t);
|
|
3024
|
+
if (p > 0) {
|
|
3025
|
+
const m = this._calculateSmoothCenteringStep(f, t, c, n, p);
|
|
3026
3026
|
return u[4] += m.x, u[5] += m.y, s.setViewportTransform(u), !0;
|
|
3027
3027
|
}
|
|
3028
3028
|
}
|
|
@@ -3087,10 +3087,10 @@ class cs {
|
|
|
3087
3087
|
* @param options.pointY - Координата Y точки зума
|
|
3088
3088
|
* @fires editor:zoom-changed
|
|
3089
3089
|
*/
|
|
3090
|
-
zoom(t =
|
|
3091
|
-
var f,
|
|
3090
|
+
zoom(t = tn, e = {}) {
|
|
3091
|
+
var f, p;
|
|
3092
3092
|
if (!t) return;
|
|
3093
|
-
const { minZoom: n, maxZoom: s } = this, { canvas: o } = this.editor, i = t < 0, a = o.getZoom(), r = o.getCenterPoint(), c = (f = e.pointX) != null ? f : r.x, l = (
|
|
3093
|
+
const { minZoom: n, maxZoom: s } = this, { canvas: o } = this.editor, i = t < 0, a = o.getZoom(), r = o.getCenterPoint(), c = (f = e.pointX) != null ? f : r.x, l = (p = e.pointY) != null ? p : r.y, h = new at(c, l);
|
|
3094
3094
|
this.editor.montageArea.setCoords(), this.editor.canvas.requestRenderAll();
|
|
3095
3095
|
let u = Number((a + Number(t)).toFixed(2));
|
|
3096
3096
|
u > s && (u = s), u < n && (u = n), o.zoomToPoint(h, u), this.editor.panConstraintManager.updateBounds(), this._applyViewportCentering(u, i, t), o.fire("editor:zoom-changed", {
|
|
@@ -3125,7 +3125,7 @@ class cs {
|
|
|
3125
3125
|
}), this.editor.panConstraintManager.updateBounds();
|
|
3126
3126
|
}
|
|
3127
3127
|
}
|
|
3128
|
-
class
|
|
3128
|
+
class ds {
|
|
3129
3129
|
constructor({ editor: t }) {
|
|
3130
3130
|
this.editor = t, this.isBlocked = !1, this.overlayMask = null, this._createOverlay();
|
|
3131
3131
|
}
|
|
@@ -3208,7 +3208,7 @@ class Bt {
|
|
|
3208
3208
|
}
|
|
3209
3209
|
a.set({
|
|
3210
3210
|
fill: t,
|
|
3211
|
-
backgroundId: `background-${
|
|
3211
|
+
backgroundId: `background-${tt()}`
|
|
3212
3212
|
}), this.editor.canvas.requestRenderAll();
|
|
3213
3213
|
} else
|
|
3214
3214
|
this._removeCurrentBackground(), this._createColorBackground(t);
|
|
@@ -3252,7 +3252,7 @@ class Bt {
|
|
|
3252
3252
|
}
|
|
3253
3253
|
a.set({
|
|
3254
3254
|
fill: r,
|
|
3255
|
-
backgroundId: `background-${
|
|
3255
|
+
backgroundId: `background-${tt()}`
|
|
3256
3256
|
}), this.editor.canvas.requestRenderAll();
|
|
3257
3257
|
} else
|
|
3258
3258
|
this._removeCurrentBackground(), this._createGradientBackground(t);
|
|
@@ -3410,7 +3410,7 @@ class Bt {
|
|
|
3410
3410
|
hasControls: !1,
|
|
3411
3411
|
id: "background",
|
|
3412
3412
|
backgroundType: "color",
|
|
3413
|
-
backgroundId: `background-${
|
|
3413
|
+
backgroundId: `background-${tt()}`
|
|
3414
3414
|
}, { withoutSelection: !0 }), this.refresh();
|
|
3415
3415
|
}
|
|
3416
3416
|
/**
|
|
@@ -3427,7 +3427,7 @@ class Bt {
|
|
|
3427
3427
|
hasControls: !1,
|
|
3428
3428
|
id: "background",
|
|
3429
3429
|
backgroundType: "gradient",
|
|
3430
|
-
backgroundId: `background-${
|
|
3430
|
+
backgroundId: `background-${tt()}`
|
|
3431
3431
|
}, { withoutSelection: !0 }), this.refresh();
|
|
3432
3432
|
const e = Bt._createFabricGradient(t);
|
|
3433
3433
|
this.backgroundObject.set("fill", e), this.editor.canvas.requestRenderAll();
|
|
@@ -3455,7 +3455,7 @@ class Bt {
|
|
|
3455
3455
|
hasControls: !1,
|
|
3456
3456
|
id: "background",
|
|
3457
3457
|
backgroundType: "image",
|
|
3458
|
-
backgroundId: `background-${
|
|
3458
|
+
backgroundId: `background-${tt()}`,
|
|
3459
3459
|
customData: e
|
|
3460
3460
|
}), this._removeCurrentBackground(), this.backgroundObject = n, this.refresh();
|
|
3461
3461
|
});
|
|
@@ -3490,7 +3490,7 @@ class Bt {
|
|
|
3490
3490
|
{ offset: 1, color: "#ffffff" }
|
|
3491
3491
|
], t.type === "linear") {
|
|
3492
3492
|
const u = t.angle * Math.PI / 180, f = Bt._angleToCoords(u);
|
|
3493
|
-
return new
|
|
3493
|
+
return new Ve({
|
|
3494
3494
|
type: "linear",
|
|
3495
3495
|
gradientUnits: "percentage",
|
|
3496
3496
|
coords: f,
|
|
@@ -3509,7 +3509,7 @@ class Bt {
|
|
|
3509
3509
|
r1: 0,
|
|
3510
3510
|
r2: l / 100
|
|
3511
3511
|
};
|
|
3512
|
-
return new
|
|
3512
|
+
return new Ve({
|
|
3513
3513
|
type: "radial",
|
|
3514
3514
|
gradientUnits: "percentage",
|
|
3515
3515
|
coords: h,
|
|
@@ -3672,7 +3672,7 @@ class ue {
|
|
|
3672
3672
|
});
|
|
3673
3673
|
}
|
|
3674
3674
|
}
|
|
3675
|
-
class
|
|
3675
|
+
class hs {
|
|
3676
3676
|
/**
|
|
3677
3677
|
* Менеджер фигур для редактора.
|
|
3678
3678
|
* @param options - Опции и настройки менеджера фигур.
|
|
@@ -3698,7 +3698,7 @@ class ds {
|
|
|
3698
3698
|
*/
|
|
3699
3699
|
addRectangle(l = {}, { withoutSelection: r, withoutAdding: c } = {}) {
|
|
3700
3700
|
var h = l, {
|
|
3701
|
-
id: t = `rect-${
|
|
3701
|
+
id: t = `rect-${tt()}`,
|
|
3702
3702
|
left: e,
|
|
3703
3703
|
top: n,
|
|
3704
3704
|
width: s = 100,
|
|
@@ -3712,7 +3712,7 @@ class ds {
|
|
|
3712
3712
|
"height",
|
|
3713
3713
|
"fill"
|
|
3714
3714
|
]);
|
|
3715
|
-
const { canvas: u } = this.editor, f = new
|
|
3715
|
+
const { canvas: u } = this.editor, f = new jn(x({
|
|
3716
3716
|
id: t,
|
|
3717
3717
|
left: e,
|
|
3718
3718
|
top: n,
|
|
@@ -3740,7 +3740,7 @@ class ds {
|
|
|
3740
3740
|
*/
|
|
3741
3741
|
addCircle(c = {}, { withoutSelection: a, withoutAdding: r } = {}) {
|
|
3742
3742
|
var l = c, {
|
|
3743
|
-
id: t = `circle-${
|
|
3743
|
+
id: t = `circle-${tt()}`,
|
|
3744
3744
|
left: e,
|
|
3745
3745
|
top: n,
|
|
3746
3746
|
radius: s = 50,
|
|
@@ -3752,7 +3752,7 @@ class ds {
|
|
|
3752
3752
|
"radius",
|
|
3753
3753
|
"fill"
|
|
3754
3754
|
]);
|
|
3755
|
-
const { canvas: h } = this.editor, u = new
|
|
3755
|
+
const { canvas: h } = this.editor, u = new In(x({
|
|
3756
3756
|
id: t,
|
|
3757
3757
|
left: e,
|
|
3758
3758
|
top: n,
|
|
@@ -3780,7 +3780,7 @@ class ds {
|
|
|
3780
3780
|
*/
|
|
3781
3781
|
addTriangle(l = {}, { withoutSelection: r, withoutAdding: c } = {}) {
|
|
3782
3782
|
var h = l, {
|
|
3783
|
-
id: t = `triangle-${
|
|
3783
|
+
id: t = `triangle-${tt()}`,
|
|
3784
3784
|
left: e,
|
|
3785
3785
|
top: n,
|
|
3786
3786
|
width: s = 100,
|
|
@@ -3794,7 +3794,7 @@ class ds {
|
|
|
3794
3794
|
"height",
|
|
3795
3795
|
"fill"
|
|
3796
3796
|
]);
|
|
3797
|
-
const { canvas: u } = this.editor, f = new
|
|
3797
|
+
const { canvas: u } = this.editor, f = new Cn(x({
|
|
3798
3798
|
id: t,
|
|
3799
3799
|
left: e,
|
|
3800
3800
|
top: n,
|
|
@@ -3805,7 +3805,7 @@ class ds {
|
|
|
3805
3805
|
return !e && !n && u.centerObject(f), c || (u.add(f), r || u.setActiveObject(f), u.renderAll()), f;
|
|
3806
3806
|
}
|
|
3807
3807
|
}
|
|
3808
|
-
class
|
|
3808
|
+
class us {
|
|
3809
3809
|
/**
|
|
3810
3810
|
* @param options
|
|
3811
3811
|
* @param options.editor - экземпляр редактора с доступом к canvas
|
|
@@ -3904,7 +3904,7 @@ class hs {
|
|
|
3904
3904
|
_copyTextToClipboard(t) {
|
|
3905
3905
|
return Z(this, null, function* () {
|
|
3906
3906
|
try {
|
|
3907
|
-
const e = `${
|
|
3907
|
+
const e = `${en}${t}`;
|
|
3908
3908
|
return yield navigator.clipboard.writeText(e), console.info("Text copied to clipboard successfully"), !0;
|
|
3909
3909
|
} catch (e) {
|
|
3910
3910
|
const { errorManager: n } = this.editor;
|
|
@@ -3960,11 +3960,11 @@ class hs {
|
|
|
3960
3960
|
const s = yield n.clone(re);
|
|
3961
3961
|
return s instanceof X && s.forEachObject((o) => {
|
|
3962
3962
|
o.set({
|
|
3963
|
-
id: `${o.type}-${
|
|
3963
|
+
id: `${o.type}-${tt()}`,
|
|
3964
3964
|
evented: !0
|
|
3965
3965
|
});
|
|
3966
3966
|
}), s.set({
|
|
3967
|
-
id: `${s.type}-${
|
|
3967
|
+
id: `${s.type}-${tt()}`,
|
|
3968
3968
|
left: s.left + 10,
|
|
3969
3969
|
top: s.top + 10,
|
|
3970
3970
|
evented: !0
|
|
@@ -3995,7 +3995,7 @@ class hs {
|
|
|
3995
3995
|
return;
|
|
3996
3996
|
}
|
|
3997
3997
|
const n = t.getData("text/plain");
|
|
3998
|
-
if (n && n.startsWith(
|
|
3998
|
+
if (n && n.startsWith(en)) {
|
|
3999
3999
|
this.paste();
|
|
4000
4000
|
return;
|
|
4001
4001
|
}
|
|
@@ -4046,11 +4046,11 @@ class hs {
|
|
|
4046
4046
|
const e = yield this.clipboard.clone(re);
|
|
4047
4047
|
return t.discardActiveObject(), e instanceof X && e.forEachObject((n) => {
|
|
4048
4048
|
n.set({
|
|
4049
|
-
id: `${n.type}-${
|
|
4049
|
+
id: `${n.type}-${tt()}`,
|
|
4050
4050
|
evented: !0
|
|
4051
4051
|
});
|
|
4052
4052
|
}), e.set({
|
|
4053
|
-
id: `${e.type}-${
|
|
4053
|
+
id: `${e.type}-${tt()}`,
|
|
4054
4054
|
left: e.left + 10,
|
|
4055
4055
|
top: e.top + 10,
|
|
4056
4056
|
evented: !0
|
|
@@ -4134,7 +4134,7 @@ class fe {
|
|
|
4134
4134
|
return t instanceof X || t instanceof Nt;
|
|
4135
4135
|
}
|
|
4136
4136
|
}
|
|
4137
|
-
class
|
|
4137
|
+
class fs {
|
|
4138
4138
|
constructor({ editor: t }) {
|
|
4139
4139
|
this.editor = t;
|
|
4140
4140
|
}
|
|
@@ -4185,7 +4185,7 @@ class us {
|
|
|
4185
4185
|
try {
|
|
4186
4186
|
s.suspendHistory();
|
|
4187
4187
|
const i = new Nt(o, {
|
|
4188
|
-
id: `group-${
|
|
4188
|
+
id: `group-${tt()}`
|
|
4189
4189
|
});
|
|
4190
4190
|
o.forEach((r) => n.remove(r)), n.add(i), n.setActiveObject(i), n.requestRenderAll();
|
|
4191
4191
|
const a = {
|
|
@@ -4235,7 +4235,7 @@ class us {
|
|
|
4235
4235
|
}
|
|
4236
4236
|
}
|
|
4237
4237
|
}
|
|
4238
|
-
class
|
|
4238
|
+
class gs {
|
|
4239
4239
|
constructor({ editor: t }) {
|
|
4240
4240
|
this.editor = t;
|
|
4241
4241
|
}
|
|
@@ -4250,7 +4250,7 @@ class fs {
|
|
|
4250
4250
|
o && n.lockObject({ object: i, skipInnerObjects: !0, withoutSave: !0 }), t.setActiveObject(i), t.requestRenderAll(), t.fire("editor:all-objects-selected", { selected: i });
|
|
4251
4251
|
}
|
|
4252
4252
|
}
|
|
4253
|
-
class
|
|
4253
|
+
class ze {
|
|
4254
4254
|
constructor({ editor: t }) {
|
|
4255
4255
|
this.editor = t;
|
|
4256
4256
|
}
|
|
@@ -4297,7 +4297,7 @@ class ke {
|
|
|
4297
4297
|
n || o.suspendHistory();
|
|
4298
4298
|
const r = [];
|
|
4299
4299
|
if (a.forEach((l) => {
|
|
4300
|
-
if (
|
|
4300
|
+
if (ze._isUngroupableGroup(l)) {
|
|
4301
4301
|
const h = this._handleGroupDeletion(l);
|
|
4302
4302
|
r.push(...h);
|
|
4303
4303
|
return;
|
|
@@ -4458,7 +4458,7 @@ class Jt {
|
|
|
4458
4458
|
message: i,
|
|
4459
4459
|
data: s
|
|
4460
4460
|
};
|
|
4461
|
-
this._buffer.push(
|
|
4461
|
+
this._buffer.push(x({
|
|
4462
4462
|
type: "editor:error"
|
|
4463
4463
|
}, a)), this.editor.canvas.fire("editor:error", a);
|
|
4464
4464
|
}
|
|
@@ -4486,7 +4486,7 @@ class Jt {
|
|
|
4486
4486
|
message: i,
|
|
4487
4487
|
data: o
|
|
4488
4488
|
};
|
|
4489
|
-
this._buffer.push(
|
|
4489
|
+
this._buffer.push(x({
|
|
4490
4490
|
type: "editor:warning"
|
|
4491
4491
|
}, a)), this.editor.canvas.fire("editor:warning", a);
|
|
4492
4492
|
}
|
|
@@ -4499,7 +4499,7 @@ class Jt {
|
|
|
4499
4499
|
return t ? Object.values(Tt).some((e) => Object.values(e).includes(t)) : !1;
|
|
4500
4500
|
}
|
|
4501
4501
|
}
|
|
4502
|
-
class
|
|
4502
|
+
class ps {
|
|
4503
4503
|
constructor({ editor: t }) {
|
|
4504
4504
|
this.currentBounds = null, this.editor = t;
|
|
4505
4505
|
}
|
|
@@ -4555,9 +4555,9 @@ class gs {
|
|
|
4555
4555
|
), f = Math.max(
|
|
4556
4556
|
this.currentBounds.minY,
|
|
4557
4557
|
Math.min(this.currentBounds.maxY, h)
|
|
4558
|
-
),
|
|
4558
|
+
), p = u + r - i * o, m = f + c - a * o;
|
|
4559
4559
|
return {
|
|
4560
|
-
x:
|
|
4560
|
+
x: p,
|
|
4561
4561
|
y: m
|
|
4562
4562
|
};
|
|
4563
4563
|
}
|
|
@@ -4584,7 +4584,46 @@ class gs {
|
|
|
4584
4584
|
this.currentBounds = this.calculatePanBounds();
|
|
4585
4585
|
}
|
|
4586
4586
|
}
|
|
4587
|
-
const
|
|
4587
|
+
const ms = ({ textbox: d }) => {
|
|
4588
|
+
var n, s;
|
|
4589
|
+
if (!d.isEditing) return null;
|
|
4590
|
+
const t = (n = d.selectionStart) != null ? n : 0, e = (s = d.selectionEnd) != null ? s : t;
|
|
4591
|
+
return t === e ? null : {
|
|
4592
|
+
start: Math.min(t, e),
|
|
4593
|
+
end: Math.max(t, e)
|
|
4594
|
+
};
|
|
4595
|
+
}, ys = ({ textbox: d }) => {
|
|
4596
|
+
var e, n;
|
|
4597
|
+
const t = (n = (e = d.text) == null ? void 0 : e.length) != null ? n : 0;
|
|
4598
|
+
return t <= 0 ? null : { start: 0, end: t };
|
|
4599
|
+
}, vs = ({ textbox: d, range: t }) => {
|
|
4600
|
+
var n, s;
|
|
4601
|
+
if (!t) return !1;
|
|
4602
|
+
const e = (s = (n = d.text) == null ? void 0 : n.length) != null ? s : 0;
|
|
4603
|
+
return e <= 0 ? !1 : t.start <= 0 && t.end >= e;
|
|
4604
|
+
}, be = ({
|
|
4605
|
+
textbox: d,
|
|
4606
|
+
styles: t,
|
|
4607
|
+
range: e
|
|
4608
|
+
}) => {
|
|
4609
|
+
if (!t || !Object.keys(t).length) return !1;
|
|
4610
|
+
const { start: n, end: s } = e;
|
|
4611
|
+
return s <= n ? !1 : (d.setSelectionStyles(t, n, s), !0);
|
|
4612
|
+
}, sn = ({
|
|
4613
|
+
textbox: d,
|
|
4614
|
+
range: t,
|
|
4615
|
+
property: e
|
|
4616
|
+
}) => {
|
|
4617
|
+
var s;
|
|
4618
|
+
if (!t) return;
|
|
4619
|
+
const n = d.getSelectionStyles(
|
|
4620
|
+
t.start,
|
|
4621
|
+
t.end,
|
|
4622
|
+
!0
|
|
4623
|
+
);
|
|
4624
|
+
if (n.length)
|
|
4625
|
+
return (s = n[0]) == null ? void 0 : s[e];
|
|
4626
|
+
}, Ee = ({ strokeColor: d, width: t }) => t <= 0 ? null : d != null ? d : "#000000", Le = ({ width: d = 0 }) => d ? Math.max(0, d) : 0, Me = ({ value: d }) => typeof d == "string" ? d.toLocaleUpperCase() : "", pt = ({
|
|
4588
4627
|
value: d,
|
|
4589
4628
|
min: t,
|
|
4590
4629
|
max: e
|
|
@@ -4613,7 +4652,7 @@ const gt = ({
|
|
|
4613
4652
|
}
|
|
4614
4653
|
_getTransformedDimensions(t = {}) {
|
|
4615
4654
|
const { width: e, height: n } = this._getBackgroundDimensions();
|
|
4616
|
-
return super._getTransformedDimensions(It(
|
|
4655
|
+
return super._getTransformedDimensions(It(x({}, t), {
|
|
4617
4656
|
width: e,
|
|
4618
4657
|
height: n
|
|
4619
4658
|
}));
|
|
@@ -4623,7 +4662,7 @@ const gt = ({
|
|
|
4623
4662
|
*/
|
|
4624
4663
|
toObject(t = []) {
|
|
4625
4664
|
const e = super.toObject(t);
|
|
4626
|
-
return It(
|
|
4665
|
+
return It(x({}, e), {
|
|
4627
4666
|
backgroundOpacity: this.backgroundOpacity,
|
|
4628
4667
|
lineFontDefaults: this.lineFontDefaults,
|
|
4629
4668
|
paddingTop: this.paddingTop,
|
|
@@ -4651,6 +4690,83 @@ const gt = ({
|
|
|
4651
4690
|
}), t.fillStyle = e, t.fill(), t.restore();
|
|
4652
4691
|
}
|
|
4653
4692
|
}
|
|
4693
|
+
/**
|
|
4694
|
+
* Рисует линии декорации текста с учетом активной обводки или заливки.
|
|
4695
|
+
*/
|
|
4696
|
+
_renderTextDecoration(t, e) {
|
|
4697
|
+
if (!this[e] && !this.styleHas(e))
|
|
4698
|
+
return;
|
|
4699
|
+
const {
|
|
4700
|
+
direction: n,
|
|
4701
|
+
fontSize: s,
|
|
4702
|
+
lineHeight: o,
|
|
4703
|
+
offsets: i,
|
|
4704
|
+
width: a,
|
|
4705
|
+
_fontSizeFraction: r,
|
|
4706
|
+
_textLines: c
|
|
4707
|
+
} = this;
|
|
4708
|
+
let l = this._getTopOffset();
|
|
4709
|
+
const h = this._getLeftOffset(), { path: u } = this, f = this._getWidthOfCharSpacing(), p = i[e];
|
|
4710
|
+
let m = 0;
|
|
4711
|
+
e === "linethrough" ? m = 0.5 : e === "overline" && (m = 1);
|
|
4712
|
+
for (let g = 0, v = c.length; g < v; g += 1) {
|
|
4713
|
+
const M = this.getHeightOfLine(g);
|
|
4714
|
+
if (!this[e] && !this.styleHas(e, g)) {
|
|
4715
|
+
l += M;
|
|
4716
|
+
continue;
|
|
4717
|
+
}
|
|
4718
|
+
const C = c[g], y = M / o, w = this._getLineLeftOffset(g);
|
|
4719
|
+
let j = 0, T = 0, b = this.getValueOfPropertyAt(g, 0, e), A = this._getDecorationColorAt(g, 0), S = this.getValueOfPropertyAt(g, 0, "textDecorationThickness"), I = b, O = A, N = S;
|
|
4720
|
+
const W = l + y * (1 - r);
|
|
4721
|
+
let z = this.getHeightOfChar(g, 0), E = this.getValueOfPropertyAt(g, 0, "deltaY");
|
|
4722
|
+
for (let R = 0, U = C.length; R < U; R += 1) {
|
|
4723
|
+
const D = this.__charBounds[g][R];
|
|
4724
|
+
I = this.getValueOfPropertyAt(g, R, e), O = this._getDecorationColorAt(g, R), N = this.getValueOfPropertyAt(g, R, "textDecorationThickness");
|
|
4725
|
+
const k = this.getHeightOfChar(g, R), _ = this.getValueOfPropertyAt(g, R, "deltaY");
|
|
4726
|
+
if (u && I && O) {
|
|
4727
|
+
const L = s * N / 1e3;
|
|
4728
|
+
t.save(), t.fillStyle = A, t.translate(D.renderLeft, D.renderTop), t.rotate(D.angle), t.fillRect(
|
|
4729
|
+
-D.kernedWidth / 2,
|
|
4730
|
+
p * k + _ - m * L,
|
|
4731
|
+
D.kernedWidth,
|
|
4732
|
+
L
|
|
4733
|
+
), t.restore();
|
|
4734
|
+
} else if ((I !== b || O !== A || k !== z || N !== S || _ !== E) && T > 0) {
|
|
4735
|
+
const L = s * S / 1e3;
|
|
4736
|
+
let J = h + w + j;
|
|
4737
|
+
n === "rtl" && (J = a - J - T), b && A && S && (t.fillStyle = A, t.fillRect(
|
|
4738
|
+
J,
|
|
4739
|
+
W + p * z + E - m * L,
|
|
4740
|
+
T,
|
|
4741
|
+
L
|
|
4742
|
+
)), j = D.left, T = D.width, b = I, S = N, A = O, z = k, E = _;
|
|
4743
|
+
} else
|
|
4744
|
+
T += D.kernedWidth;
|
|
4745
|
+
}
|
|
4746
|
+
let B = h + w + j;
|
|
4747
|
+
n === "rtl" && (B = a - B - T), t.fillStyle = O;
|
|
4748
|
+
const Y = s * N / 1e3;
|
|
4749
|
+
I && O && N && t.fillRect(
|
|
4750
|
+
B,
|
|
4751
|
+
W + p * z + E - m * Y,
|
|
4752
|
+
T - f,
|
|
4753
|
+
Y
|
|
4754
|
+
), l += M;
|
|
4755
|
+
}
|
|
4756
|
+
this._removeShadow(t);
|
|
4757
|
+
}
|
|
4758
|
+
/**
|
|
4759
|
+
* Возвращает цвет линии декорации для символа, учитывая обводку и заливку.
|
|
4760
|
+
*/
|
|
4761
|
+
_getDecorationColorAt(t, e) {
|
|
4762
|
+
const n = this.getValueOfPropertyAt(t, e, "strokeWidth"), s = Le({
|
|
4763
|
+
width: typeof n == "number" && Number.isFinite(n) ? n : 0
|
|
4764
|
+
}), o = this.getValueOfPropertyAt(t, e, "stroke"), i = o == null ? null : Ee({ strokeColor: o, width: s });
|
|
4765
|
+
if (s > 0 && i != null)
|
|
4766
|
+
return i;
|
|
4767
|
+
const a = this.getValueOfPropertyAt(t, e, "fill");
|
|
4768
|
+
return a != null ? a : null;
|
|
4769
|
+
}
|
|
4654
4770
|
_getBackgroundDimensions() {
|
|
4655
4771
|
var s, o, i, a;
|
|
4656
4772
|
const t = (o = (s = this.width) != null ? s : this.calcTextWidth()) != null ? o : 0, e = (a = (i = this.height) != null ? i : this.calcTextHeight()) != null ? a : 0, n = this._getPadding();
|
|
@@ -4663,10 +4779,10 @@ const gt = ({
|
|
|
4663
4779
|
var i, a, r, c;
|
|
4664
4780
|
const n = t / 2, s = e / 2, o = Math.min(n, s);
|
|
4665
4781
|
return {
|
|
4666
|
-
bottomLeft:
|
|
4667
|
-
bottomRight:
|
|
4668
|
-
topLeft:
|
|
4669
|
-
topRight:
|
|
4782
|
+
bottomLeft: pt({ value: (i = this.radiusBottomLeft) != null ? i : 0, min: 0, max: o }),
|
|
4783
|
+
bottomRight: pt({ value: (a = this.radiusBottomRight) != null ? a : 0, min: 0, max: o }),
|
|
4784
|
+
topLeft: pt({ value: (r = this.radiusTopLeft) != null ? r : 0, min: 0, max: o }),
|
|
4785
|
+
topRight: pt({ value: (c = this.radiusTopRight) != null ? c : 0, min: 0, max: o })
|
|
4670
4786
|
};
|
|
4671
4787
|
}
|
|
4672
4788
|
_getPadding() {
|
|
@@ -4682,10 +4798,10 @@ const gt = ({
|
|
|
4682
4798
|
var s;
|
|
4683
4799
|
const t = this.backgroundColor;
|
|
4684
4800
|
if (!t) return null;
|
|
4685
|
-
const e =
|
|
4801
|
+
const e = pt({ value: (s = this.backgroundOpacity) != null ? s : 1, min: 0, max: 1 });
|
|
4686
4802
|
let n;
|
|
4687
4803
|
try {
|
|
4688
|
-
n = new
|
|
4804
|
+
n = new Tn(t);
|
|
4689
4805
|
} catch (o) {
|
|
4690
4806
|
return Jt.emitError({
|
|
4691
4807
|
origin: "BackgroundTextbox",
|
|
@@ -4710,8 +4826,8 @@ const gt = ({
|
|
|
4710
4826
|
topRight: l,
|
|
4711
4827
|
bottomRight: h,
|
|
4712
4828
|
bottomLeft: u
|
|
4713
|
-
} = s, f =
|
|
4714
|
-
t.beginPath(), t.moveTo(n + f, o), t.lineTo(a -
|
|
4829
|
+
} = s, f = pt({ value: c, min: 0, max: i }), p = pt({ value: l, min: 0, max: i }), m = pt({ value: h, min: 0, max: i }), g = pt({ value: u, min: 0, max: i });
|
|
4830
|
+
t.beginPath(), t.moveTo(n + f, o), t.lineTo(a - p, o), t.quadraticCurveTo(a, o, a, o + p), t.lineTo(a, r - m), t.quadraticCurveTo(a, r, a - m, r), t.lineTo(n + g, r), t.quadraticCurveTo(n, r, n, r - g), t.lineTo(n, o + f), t.quadraticCurveTo(n, o, n + f, o), t.closePath();
|
|
4715
4831
|
}
|
|
4716
4832
|
/**
|
|
4717
4833
|
* Округляет текущие значения ширины и высоты до ближайших целых.
|
|
@@ -4752,10 +4868,10 @@ Pt.type = "background-textbox", Pt.cacheProperties = [
|
|
|
4752
4868
|
"radiusBottomLeft"
|
|
4753
4869
|
];
|
|
4754
4870
|
let ge = Pt;
|
|
4755
|
-
const
|
|
4871
|
+
const bs = () => {
|
|
4756
4872
|
var d;
|
|
4757
|
-
(d =
|
|
4758
|
-
}, it = 0.01,
|
|
4873
|
+
(d = Xe) != null && d.setClass && Xe.setClass(ge, "background-textbox");
|
|
4874
|
+
}, it = 0.01, on = ({
|
|
4759
4875
|
textbox: d,
|
|
4760
4876
|
lineIndices: t,
|
|
4761
4877
|
updates: e
|
|
@@ -4773,12 +4889,12 @@ const ps = () => {
|
|
|
4773
4889
|
for (let u = 0; u < t.length; u += 1) {
|
|
4774
4890
|
const f = t[u];
|
|
4775
4891
|
if (!Number.isFinite(f)) continue;
|
|
4776
|
-
const
|
|
4777
|
-
let
|
|
4778
|
-
n !== void 0 && (
|
|
4892
|
+
const p = h ? c[f] : r == null ? void 0 : r[f], m = p ? x({}, p) : {};
|
|
4893
|
+
let g = !1;
|
|
4894
|
+
n !== void 0 && (p == null ? void 0 : p.fontFamily) !== n && (m.fontFamily = n, g = !0), s !== void 0 && (p == null ? void 0 : p.fontSize) !== s && (m.fontSize = s, g = !0), o !== void 0 && (p == null ? void 0 : p.fill) !== o && (m.fill = o, g = !0), i !== void 0 && (i === null && (p == null ? void 0 : p.stroke) !== void 0 && (delete m.stroke, g = !0), i !== null && (p == null ? void 0 : p.stroke) !== i && (m.stroke = i, g = !0)), g && (h || (c = x({}, c), h = !0), c[f] = m, l = !0);
|
|
4779
4895
|
}
|
|
4780
4896
|
return l && (d.lineFontDefaults = c), l;
|
|
4781
|
-
},
|
|
4897
|
+
}, Ms = ({
|
|
4782
4898
|
lineText: d,
|
|
4783
4899
|
lineStyles: t,
|
|
4784
4900
|
lineDefaults: e
|
|
@@ -4800,23 +4916,23 @@ const ps = () => {
|
|
|
4800
4916
|
if (t)
|
|
4801
4917
|
for (const f in t) {
|
|
4802
4918
|
if (!Object.prototype.hasOwnProperty.call(t, f)) continue;
|
|
4803
|
-
const
|
|
4804
|
-
Number.isInteger(
|
|
4919
|
+
const p = Number(f);
|
|
4920
|
+
Number.isInteger(p) && p >= 0 && p < n || (u || (l = x({}, t), u = !0), l && Object.prototype.hasOwnProperty.call(l, f) && delete l[f], h = !0);
|
|
4805
4921
|
}
|
|
4806
4922
|
for (let f = 0; f < n; f += 1) {
|
|
4807
|
-
const
|
|
4923
|
+
const p = l != null ? l : t, m = p ? p[f] : void 0;
|
|
4808
4924
|
if (!m) {
|
|
4809
|
-
l || (l = {}, u = !0), u || (l =
|
|
4925
|
+
l || (l = {}, u = !0), u || (l = x({}, l), u = !0), l[f] = x({}, c), h = !0;
|
|
4810
4926
|
continue;
|
|
4811
4927
|
}
|
|
4812
|
-
let
|
|
4813
|
-
s !== void 0 && m.fontFamily === void 0 && (
|
|
4928
|
+
let g = null;
|
|
4929
|
+
s !== void 0 && m.fontFamily === void 0 && (g = x({}, m), g.fontFamily = s), o !== void 0 && m.fontSize === void 0 && (g || (g = x({}, m)), g.fontSize = o), i !== void 0 && m.fill === void 0 && (g || (g = x({}, m)), g.fill = i), a !== void 0 && m.stroke === void 0 && (g || (g = x({}, m)), g.stroke = a), g && (l || (l = {}, u = !0), u || (l = x({}, l), u = !0), l[f] = g, h = !0);
|
|
4814
4930
|
}
|
|
4815
4931
|
return {
|
|
4816
4932
|
lineStyles: l,
|
|
4817
4933
|
changed: h
|
|
4818
4934
|
};
|
|
4819
|
-
},
|
|
4935
|
+
}, an = ({
|
|
4820
4936
|
lineFontDefaults: d
|
|
4821
4937
|
}) => {
|
|
4822
4938
|
if (!d) return;
|
|
@@ -4826,10 +4942,10 @@ const ps = () => {
|
|
|
4826
4942
|
const n = Number(e);
|
|
4827
4943
|
if (!Number.isFinite(n)) continue;
|
|
4828
4944
|
const s = d[n];
|
|
4829
|
-
s && (t[n] =
|
|
4945
|
+
s && (t[n] = x({}, s));
|
|
4830
4946
|
}
|
|
4831
4947
|
return t;
|
|
4832
|
-
},
|
|
4948
|
+
}, rn = ({
|
|
4833
4949
|
lineFontDefaults: d,
|
|
4834
4950
|
scale: t
|
|
4835
4951
|
}) => {
|
|
@@ -4842,12 +4958,12 @@ const ps = () => {
|
|
|
4842
4958
|
if (!Number.isFinite(i)) continue;
|
|
4843
4959
|
const a = d[i];
|
|
4844
4960
|
if (!a) continue;
|
|
4845
|
-
const r =
|
|
4961
|
+
const r = x({}, a);
|
|
4846
4962
|
typeof a.fontSize == "number" && (r.fontSize = Math.max(1, a.fontSize * t), s = !0), e[i] = r, n = !0;
|
|
4847
4963
|
}
|
|
4848
4964
|
if (!(!n || !s))
|
|
4849
4965
|
return e;
|
|
4850
|
-
},
|
|
4966
|
+
}, Ss = ({
|
|
4851
4967
|
textbox: d
|
|
4852
4968
|
}) => {
|
|
4853
4969
|
var o, i;
|
|
@@ -4861,7 +4977,7 @@ const ps = () => {
|
|
|
4861
4977
|
s = l + 1, n.push({ start: c, end: l });
|
|
4862
4978
|
}
|
|
4863
4979
|
return n;
|
|
4864
|
-
},
|
|
4980
|
+
}, ws = ({
|
|
4865
4981
|
range: d,
|
|
4866
4982
|
text: t
|
|
4867
4983
|
}) => {
|
|
@@ -4870,11 +4986,11 @@ const ps = () => {
|
|
|
4870
4986
|
if (e <= 0) return null;
|
|
4871
4987
|
const { start: n, end: s } = d, o = Number.isFinite(n) ? n : 0, i = Number.isFinite(s) ? s : o, a = Math.max(0, Math.min(o, e)), r = Math.max(0, Math.min(i, e)), c = Math.min(a, r), l = Math.max(a, r);
|
|
4872
4988
|
return c === l ? null : { start: c, end: l };
|
|
4873
|
-
},
|
|
4989
|
+
}, As = ({
|
|
4874
4990
|
textbox: d,
|
|
4875
4991
|
range: t
|
|
4876
4992
|
}) => {
|
|
4877
|
-
const e =
|
|
4993
|
+
const e = Ss({ textbox: d });
|
|
4878
4994
|
if (!e.length) return t;
|
|
4879
4995
|
let { start: n } = t, { end: s } = t;
|
|
4880
4996
|
for (let o = 0; o < e.length; o += 1) {
|
|
@@ -4884,7 +5000,7 @@ const ps = () => {
|
|
|
4884
5000
|
t.end > a && t.start < r && (n = Math.min(n, a), s = Math.max(s, r));
|
|
4885
5001
|
}
|
|
4886
5002
|
return { start: n, end: s };
|
|
4887
|
-
},
|
|
5003
|
+
}, js = ({
|
|
4888
5004
|
textbox: d,
|
|
4889
5005
|
range: t
|
|
4890
5006
|
}) => {
|
|
@@ -4899,7 +5015,7 @@ const ps = () => {
|
|
|
4899
5015
|
s > u && n < f && i.push(l), a = f + 1;
|
|
4900
5016
|
}
|
|
4901
5017
|
return i;
|
|
4902
|
-
},
|
|
5018
|
+
}, Is = ({
|
|
4903
5019
|
textbox: d,
|
|
4904
5020
|
range: t
|
|
4905
5021
|
}) => {
|
|
@@ -4914,7 +5030,7 @@ const ps = () => {
|
|
|
4914
5030
|
n <= u && s >= f && i.push(l), a = f + 1;
|
|
4915
5031
|
}
|
|
4916
5032
|
return i;
|
|
4917
|
-
},
|
|
5033
|
+
}, Cs = ({
|
|
4918
5034
|
previous: d,
|
|
4919
5035
|
next: t
|
|
4920
5036
|
}) => {
|
|
@@ -4922,7 +5038,7 @@ const ps = () => {
|
|
|
4922
5038
|
for (let n = 0; n < e; n += 1)
|
|
4923
5039
|
if (d[n] !== t[n]) return n;
|
|
4924
5040
|
return e;
|
|
4925
|
-
},
|
|
5041
|
+
}, Ts = ({
|
|
4926
5042
|
text: d,
|
|
4927
5043
|
charIndex: t
|
|
4928
5044
|
}) => {
|
|
@@ -4932,7 +5048,7 @@ const ps = () => {
|
|
|
4932
5048
|
d[s] === `
|
|
4933
5049
|
` && (n += 1);
|
|
4934
5050
|
return n;
|
|
4935
|
-
},
|
|
5051
|
+
}, Os = ({
|
|
4936
5052
|
text: d,
|
|
4937
5053
|
lineIndex: t
|
|
4938
5054
|
}) => {
|
|
@@ -4943,7 +5059,7 @@ const ps = () => {
|
|
|
4943
5059
|
` && (e += 1, e === t))
|
|
4944
5060
|
return n + 1;
|
|
4945
5061
|
return d.length;
|
|
4946
|
-
},
|
|
5062
|
+
}, Es = ({
|
|
4947
5063
|
textbox: d,
|
|
4948
5064
|
text: t
|
|
4949
5065
|
}) => {
|
|
@@ -4955,7 +5071,7 @@ const ps = () => {
|
|
|
4955
5071
|
i > s && (s = i);
|
|
4956
5072
|
}
|
|
4957
5073
|
return s;
|
|
4958
|
-
},
|
|
5074
|
+
}, Ls = ({
|
|
4959
5075
|
textbox: d,
|
|
4960
5076
|
montageLeft: t,
|
|
4961
5077
|
montageRight: e
|
|
@@ -4967,10 +5083,10 @@ const ps = () => {
|
|
|
4967
5083
|
return !1;
|
|
4968
5084
|
let a = 0;
|
|
4969
5085
|
return s < t ? a = t - s : o > e && (a = e - o), Math.abs(a) <= it ? !1 : (d.set({ left: ((h = d.left) != null ? h : 0) + a }), !0);
|
|
4970
|
-
},
|
|
5086
|
+
}, cn = ({
|
|
4971
5087
|
rawValue: d,
|
|
4972
5088
|
calculatedValue: t
|
|
4973
|
-
}) => typeof d == "number" ? d : typeof t == "number" ? t : 0,
|
|
5089
|
+
}) => typeof d == "number" ? d : typeof t == "number" ? t : 0, ln = ({
|
|
4974
5090
|
stylesList: d
|
|
4975
5091
|
}) => {
|
|
4976
5092
|
const t = d.length;
|
|
@@ -4992,54 +5108,15 @@ const ps = () => {
|
|
|
4992
5108
|
}, Ct = ({
|
|
4993
5109
|
textbox: d
|
|
4994
5110
|
}) => {
|
|
4995
|
-
const { width: t, height: e, calcTextWidth: n, calcTextHeight: s } = d, o = typeof n == "function" ? n.call(d) : void 0, i = typeof s == "function" ? s.call(d) : void 0, a =
|
|
5111
|
+
const { width: t, height: e, calcTextWidth: n, calcTextHeight: s } = d, o = typeof n == "function" ? n.call(d) : void 0, i = typeof s == "function" ? s.call(d) : void 0, a = cn({
|
|
4996
5112
|
rawValue: t,
|
|
4997
5113
|
calculatedValue: o
|
|
4998
|
-
}), r =
|
|
5114
|
+
}), r = cn({
|
|
4999
5115
|
rawValue: e,
|
|
5000
5116
|
calculatedValue: i
|
|
5001
5117
|
}), c = Number.isFinite(a) ? Math.round(a) : null, l = Number.isFinite(r) ? Math.round(r) : null, h = {};
|
|
5002
5118
|
return c !== null && c !== a && (h.width = Math.max(0, c)), l !== null && l !== r && (h.height = Math.max(0, l)), Object.keys(h).length ? (d.set(h), !0) : !1;
|
|
5003
|
-
}
|
|
5004
|
-
var n, s;
|
|
5005
|
-
if (!d.isEditing) return null;
|
|
5006
|
-
const t = (n = d.selectionStart) != null ? n : 0, e = (s = d.selectionEnd) != null ? s : t;
|
|
5007
|
-
return t === e ? null : {
|
|
5008
|
-
start: Math.min(t, e),
|
|
5009
|
-
end: Math.max(t, e)
|
|
5010
|
-
};
|
|
5011
|
-
}, Os = ({ textbox: d }) => {
|
|
5012
|
-
var e, n;
|
|
5013
|
-
const t = (n = (e = d.text) == null ? void 0 : e.length) != null ? n : 0;
|
|
5014
|
-
return t <= 0 ? null : { start: 0, end: t };
|
|
5015
|
-
}, Es = ({ textbox: d, range: t }) => {
|
|
5016
|
-
var n, s;
|
|
5017
|
-
if (!t) return !1;
|
|
5018
|
-
const e = (s = (n = d.text) == null ? void 0 : n.length) != null ? s : 0;
|
|
5019
|
-
return e <= 0 ? !1 : t.start <= 0 && t.end >= e;
|
|
5020
|
-
}, ve = ({
|
|
5021
|
-
textbox: d,
|
|
5022
|
-
styles: t,
|
|
5023
|
-
range: e
|
|
5024
|
-
}) => {
|
|
5025
|
-
if (!t || !Object.keys(t).length) return !1;
|
|
5026
|
-
const { start: n, end: s } = e;
|
|
5027
|
-
return s <= n ? !1 : (d.setSelectionStyles(t, n, s), !0);
|
|
5028
|
-
}, an = ({
|
|
5029
|
-
textbox: d,
|
|
5030
|
-
range: t,
|
|
5031
|
-
property: e
|
|
5032
|
-
}) => {
|
|
5033
|
-
var s;
|
|
5034
|
-
if (!t) return;
|
|
5035
|
-
const n = d.getSelectionStyles(
|
|
5036
|
-
t.start,
|
|
5037
|
-
t.end,
|
|
5038
|
-
!0
|
|
5039
|
-
);
|
|
5040
|
-
if (n.length)
|
|
5041
|
-
return (s = n[0]) == null ? void 0 : s[e];
|
|
5042
|
-
}, rn = ({ strokeColor: d, width: t }) => t <= 0 ? null : d != null ? d : "#000000", cn = ({ width: d = 0 }) => d ? Math.max(0, d) : 0, be = ({ value: d }) => typeof d == "string" ? d.toLocaleUpperCase() : "";
|
|
5119
|
+
};
|
|
5043
5120
|
class st {
|
|
5044
5121
|
constructor({ editor: t }) {
|
|
5045
5122
|
var e;
|
|
@@ -5061,7 +5138,7 @@ class st {
|
|
|
5061
5138
|
if (!st._isTextbox(s) || this.lineDefaultsSyncing.has(s)) return;
|
|
5062
5139
|
const { text: o = "", uppercase: i, autoExpand: a } = s, r = !!i, c = a !== !1, l = o.toLocaleLowerCase();
|
|
5063
5140
|
if (r) {
|
|
5064
|
-
const f =
|
|
5141
|
+
const f = Me({ value: l });
|
|
5065
5142
|
f !== o && s.set({ text: f }), s.textCaseRaw = l;
|
|
5066
5143
|
} else
|
|
5067
5144
|
s.textCaseRaw = o;
|
|
@@ -5087,11 +5164,11 @@ class st {
|
|
|
5087
5164
|
});
|
|
5088
5165
|
const { historyManager: r } = this.editor;
|
|
5089
5166
|
r.endAction({ reason: "text-edit" }), r.scheduleSaveState({
|
|
5090
|
-
delayMs:
|
|
5167
|
+
delayMs: is,
|
|
5091
5168
|
reason: "text-edit"
|
|
5092
5169
|
});
|
|
5093
5170
|
}, this._handleObjectScaling = (n) => {
|
|
5094
|
-
var $t,
|
|
5171
|
+
var $t, me, te, ee, ne, xt, ye, se, Yt, Ht, Zt, Gt, Vt;
|
|
5095
5172
|
const { target: s, transform: o } = n;
|
|
5096
5173
|
if (s instanceof X || !st._isTextbox(s) || !o) return;
|
|
5097
5174
|
s.isScaling = !0;
|
|
@@ -5103,75 +5180,75 @@ class st {
|
|
|
5103
5180
|
baseRadii: h,
|
|
5104
5181
|
baseStyles: u,
|
|
5105
5182
|
baseLineFontDefaults: f
|
|
5106
|
-
} = i,
|
|
5107
|
-
if (!y && !w && !
|
|
5108
|
-
const b = Math.abs((xt = (ne = s.scaleX) != null ? ne : o.scaleX) != null ? xt : 1) || 1, A = Math.abs((se = (
|
|
5109
|
-
paddingTop:
|
|
5110
|
-
paddingRight:
|
|
5111
|
-
paddingBottom:
|
|
5183
|
+
} = i, p = typeof (($t = o.original) == null ? void 0 : $t.width) == "number" ? o.original.width : void 0, m = typeof ((me = o.original) == null ? void 0 : me.left) == "number" ? o.original.left : void 0, g = p != null ? p : a, v = m != null ? m : r, M = (te = o.corner) != null ? te : "", C = (ee = o.action) != null ? ee : "", y = ["ml", "mr"].includes(M) || C === "scaleX", w = ["mt", "mb"].includes(M) || C === "scaleY", j = ["tl", "tr", "bl", "br"].includes(M) || C === "scale", T = j || w;
|
|
5184
|
+
if (!y && !w && !j) return;
|
|
5185
|
+
const b = Math.abs((xt = (ne = s.scaleX) != null ? ne : o.scaleX) != null ? xt : 1) || 1, A = Math.abs((se = (ye = s.scaleY) != null ? ye : o.scaleY) != null ? se : 1) || 1, S = Math.max(1, g * b), I = Math.max(1, Math.round(S)), O = Math.max(1, c * A), {
|
|
5186
|
+
paddingTop: N = 0,
|
|
5187
|
+
paddingRight: W = 0,
|
|
5188
|
+
paddingBottom: z = 0,
|
|
5112
5189
|
paddingLeft: E = 0,
|
|
5113
5190
|
radiusTopLeft: B = 0,
|
|
5114
|
-
radiusTopRight:
|
|
5115
|
-
radiusBottomRight:
|
|
5116
|
-
radiusBottomLeft:
|
|
5117
|
-
fontSize:
|
|
5118
|
-
width:
|
|
5191
|
+
radiusTopRight: Y = 0,
|
|
5192
|
+
radiusBottomRight: R = 0,
|
|
5193
|
+
radiusBottomLeft: U = 0,
|
|
5194
|
+
fontSize: D,
|
|
5195
|
+
width: k,
|
|
5119
5196
|
originX: _ = "left"
|
|
5120
|
-
} = s,
|
|
5197
|
+
} = s, L = j || w, J = j || w, G = L ? {
|
|
5121
5198
|
top: Math.max(0, l.top * A),
|
|
5122
5199
|
right: Math.max(0, l.right * A),
|
|
5123
5200
|
bottom: Math.max(0, l.bottom * A),
|
|
5124
5201
|
left: Math.max(0, l.left * A)
|
|
5125
|
-
} : l,
|
|
5202
|
+
} : l, Q = J ? {
|
|
5126
5203
|
topLeft: Math.max(0, h.topLeft * A),
|
|
5127
5204
|
topRight: Math.max(0, h.topRight * A),
|
|
5128
5205
|
bottomRight: Math.max(0, h.bottomRight * A),
|
|
5129
5206
|
bottomLeft: Math.max(0, h.bottomLeft * A)
|
|
5130
|
-
} : h,
|
|
5207
|
+
} : h, $ = Object.keys(u).length > 0;
|
|
5131
5208
|
let ot;
|
|
5132
|
-
if (
|
|
5209
|
+
if (T && $) {
|
|
5133
5210
|
const Rt = {};
|
|
5134
5211
|
Object.entries(u).forEach(([ie, q]) => {
|
|
5135
5212
|
if (!q) return;
|
|
5136
5213
|
const nt = {};
|
|
5137
|
-
Object.entries(q).forEach(([
|
|
5214
|
+
Object.entries(q).forEach(([ve, kt]) => {
|
|
5138
5215
|
if (!kt) return;
|
|
5139
|
-
const
|
|
5140
|
-
typeof kt.fontSize == "number" && (
|
|
5216
|
+
const Fe = x({}, kt);
|
|
5217
|
+
typeof kt.fontSize == "number" && (Fe.fontSize = Math.max(1, kt.fontSize * A)), nt[ve] = Fe;
|
|
5141
5218
|
}), Object.keys(nt).length && (Rt[ie] = nt);
|
|
5142
5219
|
}), Object.keys(Rt).length && (ot = Rt);
|
|
5143
5220
|
}
|
|
5144
5221
|
let ht;
|
|
5145
|
-
|
|
5222
|
+
T && (ht = rn({
|
|
5146
5223
|
lineFontDefaults: f,
|
|
5147
5224
|
scale: A
|
|
5148
5225
|
}));
|
|
5149
|
-
const vt = (Ht = (Yt = o.originX) != null ? Yt : _) != null ? Ht : "left", rt = v +
|
|
5226
|
+
const vt = (Ht = (Yt = o.originX) != null ? Yt : _) != null ? Ht : "left", rt = v + g, ct = v + g / 2, At = k != null ? k : g, bt = I !== At, Lt = Math.abs(O - (D != null ? D : c)) > it, Dt = Math.abs(G.top - N) > it || Math.abs(G.right - W) > it || Math.abs(G.bottom - z) > it || Math.abs(G.left - E) > it, _t = Math.abs(Q.topLeft - B) > it || Math.abs(Q.topRight - Y) > it || Math.abs(Q.bottomRight - R) > it || Math.abs(Q.bottomLeft - U) > it;
|
|
5150
5227
|
if (!bt && !Lt && !Dt && !_t) {
|
|
5151
5228
|
s.set({ scaleX: 1, scaleY: 1 }), o.scaleX = 1, o.scaleY = 1;
|
|
5152
5229
|
return;
|
|
5153
5230
|
}
|
|
5154
5231
|
ot && (s.styles = ot), ht && (s.lineFontDefaults = ht), s.set({
|
|
5155
|
-
width:
|
|
5156
|
-
fontSize:
|
|
5232
|
+
width: I,
|
|
5233
|
+
fontSize: T ? O : c,
|
|
5157
5234
|
paddingTop: G.top,
|
|
5158
5235
|
paddingRight: G.right,
|
|
5159
5236
|
paddingBottom: G.bottom,
|
|
5160
5237
|
paddingLeft: G.left,
|
|
5161
|
-
radiusTopLeft:
|
|
5162
|
-
radiusTopRight:
|
|
5163
|
-
radiusBottomRight:
|
|
5164
|
-
radiusBottomLeft:
|
|
5238
|
+
radiusTopLeft: Q.topLeft,
|
|
5239
|
+
radiusTopRight: Q.topRight,
|
|
5240
|
+
radiusBottomRight: Q.bottomRight,
|
|
5241
|
+
radiusBottomLeft: Q.bottomLeft,
|
|
5165
5242
|
scaleX: 1,
|
|
5166
5243
|
scaleY: 1
|
|
5167
5244
|
});
|
|
5168
|
-
const
|
|
5169
|
-
|
|
5170
|
-
const ut = (Zt = s.width) != null ? Zt :
|
|
5245
|
+
const Ut = Ct({ textbox: s });
|
|
5246
|
+
Ut && (s.dirty = !0);
|
|
5247
|
+
const ut = (Zt = s.width) != null ? Zt : I, Qt = ut !== At;
|
|
5171
5248
|
let jt = v;
|
|
5172
|
-
Qt && (y ||
|
|
5173
|
-
const { original:
|
|
5174
|
-
|
|
5249
|
+
Qt && (y || j) && (vt === "right" ? jt = rt - ut : vt === "center" && (jt = ct - ut / 2)), s.set({ left: jt }), i.baseLeft = jt, o.scaleX = 1, o.scaleY = 1;
|
|
5250
|
+
const { original: gt } = o;
|
|
5251
|
+
gt && (gt.scaleX = 1, gt.scaleY = 1, gt.width = ut, gt.height = s.height, gt.left = jt), s.setCoords(), this.canvas.requestRenderAll(), i.baseWidth = ut, i.baseFontSize = (Gt = s.fontSize) != null ? Gt : O, i.baseStyles = JSON.parse(JSON.stringify((Vt = s.styles) != null ? Vt : {})), i.baseLineFontDefaults = an({
|
|
5175
5252
|
lineFontDefaults: s.lineFontDefaults
|
|
5176
5253
|
}), i.basePadding = {
|
|
5177
5254
|
top: G.top,
|
|
@@ -5179,55 +5256,55 @@ class st {
|
|
|
5179
5256
|
bottom: G.bottom,
|
|
5180
5257
|
left: G.left
|
|
5181
5258
|
}, i.baseRadii = {
|
|
5182
|
-
topLeft:
|
|
5183
|
-
topRight:
|
|
5184
|
-
bottomRight:
|
|
5185
|
-
bottomLeft:
|
|
5186
|
-
}, i.hasWidthChange = Qt || Lt || Dt || _t ||
|
|
5259
|
+
topLeft: Q.topLeft,
|
|
5260
|
+
topRight: Q.topRight,
|
|
5261
|
+
bottomRight: Q.bottomRight,
|
|
5262
|
+
bottomLeft: Q.bottomLeft
|
|
5263
|
+
}, i.hasWidthChange = Qt || Lt || Dt || _t || Ut;
|
|
5187
5264
|
}, this._handleObjectModified = (n) => {
|
|
5188
|
-
var M,
|
|
5265
|
+
var M, C, y;
|
|
5189
5266
|
const { target: s } = n;
|
|
5190
5267
|
if (s instanceof X) {
|
|
5191
5268
|
const w = s.getObjects();
|
|
5192
5269
|
if (!w.some((S) => st._isTextbox(S))) return;
|
|
5193
|
-
const { scaleX:
|
|
5194
|
-
if (Math.abs(
|
|
5270
|
+
const { scaleX: T = 1, scaleY: b = 1 } = s;
|
|
5271
|
+
if (Math.abs(T - 1) < it && Math.abs(b - 1) < it) return;
|
|
5195
5272
|
this.canvas.discardActiveObject(), w.forEach((S) => {
|
|
5196
|
-
var
|
|
5273
|
+
var I, O, N, W;
|
|
5197
5274
|
if (st._isTextbox(S)) {
|
|
5198
|
-
const
|
|
5199
|
-
paddingTop:
|
|
5200
|
-
paddingRight:
|
|
5201
|
-
paddingBottom:
|
|
5275
|
+
const z = (I = S.scaleX) != null ? I : 1, E = (O = S.scaleY) != null ? O : 1, B = ((N = S.fontSize) != null ? N : 16) * E, Y = ((W = S.width) != null ? W : 0) * z, R = E, {
|
|
5276
|
+
paddingTop: U = 0,
|
|
5277
|
+
paddingRight: D = 0,
|
|
5278
|
+
paddingBottom: k = 0,
|
|
5202
5279
|
paddingLeft: _ = 0,
|
|
5203
|
-
radiusTopLeft:
|
|
5204
|
-
radiusTopRight:
|
|
5280
|
+
radiusTopLeft: L = 0,
|
|
5281
|
+
radiusTopRight: J = 0,
|
|
5205
5282
|
radiusBottomRight: G = 0,
|
|
5206
|
-
radiusBottomLeft:
|
|
5207
|
-
styles:
|
|
5283
|
+
radiusBottomLeft: Q = 0,
|
|
5284
|
+
styles: $
|
|
5208
5285
|
} = S, ot = {
|
|
5209
|
-
paddingTop: Math.max(0,
|
|
5210
|
-
paddingRight: Math.max(0,
|
|
5211
|
-
paddingBottom: Math.max(0,
|
|
5212
|
-
paddingLeft: Math.max(0, _ *
|
|
5286
|
+
paddingTop: Math.max(0, U * R),
|
|
5287
|
+
paddingRight: Math.max(0, D * R),
|
|
5288
|
+
paddingBottom: Math.max(0, k * R),
|
|
5289
|
+
paddingLeft: Math.max(0, _ * R)
|
|
5213
5290
|
}, ht = {
|
|
5214
|
-
radiusTopLeft: Math.max(0,
|
|
5215
|
-
radiusTopRight: Math.max(0,
|
|
5216
|
-
radiusBottomRight: Math.max(0, G *
|
|
5217
|
-
radiusBottomLeft: Math.max(0,
|
|
5291
|
+
radiusTopLeft: Math.max(0, L * R),
|
|
5292
|
+
radiusTopRight: Math.max(0, J * R),
|
|
5293
|
+
radiusBottomRight: Math.max(0, G * R),
|
|
5294
|
+
radiusBottomLeft: Math.max(0, Q * R)
|
|
5218
5295
|
};
|
|
5219
|
-
let vt =
|
|
5220
|
-
|
|
5296
|
+
let vt = $;
|
|
5297
|
+
$ && Object.keys($).length > 0 && (vt = JSON.parse(JSON.stringify($)), Object.values(vt).forEach((At) => {
|
|
5221
5298
|
Object.values(At).forEach((bt) => {
|
|
5222
|
-
typeof bt.fontSize == "number" && (bt.fontSize = Math.max(1, bt.fontSize *
|
|
5299
|
+
typeof bt.fontSize == "number" && (bt.fontSize = Math.max(1, bt.fontSize * R));
|
|
5223
5300
|
});
|
|
5224
5301
|
}));
|
|
5225
|
-
const rt =
|
|
5302
|
+
const rt = rn({
|
|
5226
5303
|
lineFontDefaults: S.lineFontDefaults,
|
|
5227
|
-
scale:
|
|
5228
|
-
}), ct = It(
|
|
5304
|
+
scale: R
|
|
5305
|
+
}), ct = It(x(x({
|
|
5229
5306
|
fontSize: B,
|
|
5230
|
-
width:
|
|
5307
|
+
width: Y,
|
|
5231
5308
|
scaleX: 1,
|
|
5232
5309
|
scaleY: 1
|
|
5233
5310
|
}, ot), ht), {
|
|
@@ -5247,15 +5324,15 @@ class st {
|
|
|
5247
5324
|
s.isScaling = !1;
|
|
5248
5325
|
const o = this.scalingState.get(s);
|
|
5249
5326
|
if (this.scalingState.delete(s), !(o != null && o.hasWidthChange)) return;
|
|
5250
|
-
const i = (M = s.width) != null ? M : s.calcTextWidth(), a = (y = (
|
|
5327
|
+
const i = (M = s.width) != null ? M : s.calcTextWidth(), a = (y = (C = s.fontSize) != null ? C : o == null ? void 0 : o.baseFontSize) != null ? y : 16, r = !!(o.baseStyles && Object.keys(o.baseStyles).length), {
|
|
5251
5328
|
paddingTop: c = 0,
|
|
5252
5329
|
paddingRight: l = 0,
|
|
5253
5330
|
paddingBottom: h = 0,
|
|
5254
5331
|
paddingLeft: u = 0,
|
|
5255
5332
|
radiusTopLeft: f = 0,
|
|
5256
|
-
radiusTopRight:
|
|
5333
|
+
radiusTopRight: p = 0,
|
|
5257
5334
|
radiusBottomRight: m = 0,
|
|
5258
|
-
radiusBottomLeft:
|
|
5335
|
+
radiusBottomLeft: g = 0
|
|
5259
5336
|
} = s, v = {
|
|
5260
5337
|
width: i,
|
|
5261
5338
|
paddingTop: c,
|
|
@@ -5263,24 +5340,24 @@ class st {
|
|
|
5263
5340
|
paddingBottom: h,
|
|
5264
5341
|
paddingLeft: u,
|
|
5265
5342
|
radiusTopLeft: f,
|
|
5266
|
-
radiusTopRight:
|
|
5343
|
+
radiusTopRight: p,
|
|
5267
5344
|
radiusBottomRight: m,
|
|
5268
|
-
radiusBottomLeft:
|
|
5345
|
+
radiusBottomLeft: g
|
|
5269
5346
|
};
|
|
5270
5347
|
r || (v.fontSize = a), this.updateText({
|
|
5271
5348
|
target: s,
|
|
5272
5349
|
style: v
|
|
5273
5350
|
}), s.set({ scaleX: 1, scaleY: 1 }), s.setCoords();
|
|
5274
|
-
}, this.editor = t, this.canvas = t.canvas, this.fonts = (e = t.options.fonts) != null ? e : [], this.scalingState = /* @__PURE__ */ new WeakMap(), this.editingAnchorState = /* @__PURE__ */ new WeakMap(), this.lineDefaultsSyncing = /* @__PURE__ */ new WeakSet(), this.isTextEditingActive = !1, this._bindEvents(),
|
|
5351
|
+
}, this.editor = t, this.canvas = t.canvas, this.fonts = (e = t.options.fonts) != null ? e : [], this.scalingState = /* @__PURE__ */ new WeakMap(), this.editingAnchorState = /* @__PURE__ */ new WeakMap(), this.lineDefaultsSyncing = /* @__PURE__ */ new WeakSet(), this.isTextEditingActive = !1, this._bindEvents(), bs();
|
|
5275
5352
|
}
|
|
5276
5353
|
/**
|
|
5277
5354
|
* Добавляет новый текстовый объект на канвас.
|
|
5278
5355
|
* @param options — настройки текста
|
|
5279
5356
|
* @param flags — флаги поведения
|
|
5280
5357
|
*/
|
|
5281
|
-
addText(
|
|
5282
|
-
var
|
|
5283
|
-
id: t = `text-${
|
|
5358
|
+
addText(W = {}, { withoutSelection: I = !1, withoutSave: O = !1, withoutAdding: N = !1 } = {}) {
|
|
5359
|
+
var z = W, {
|
|
5360
|
+
id: t = `text-${tt()}`,
|
|
5284
5361
|
text: e = "Новый текст",
|
|
5285
5362
|
autoExpand: n = !0,
|
|
5286
5363
|
fontFamily: s,
|
|
@@ -5293,19 +5370,19 @@ class st {
|
|
|
5293
5370
|
align: h = "left",
|
|
5294
5371
|
color: u = "#000000",
|
|
5295
5372
|
strokeColor: f,
|
|
5296
|
-
strokeWidth:
|
|
5373
|
+
strokeWidth: p = 0,
|
|
5297
5374
|
opacity: m = 1,
|
|
5298
|
-
backgroundColor:
|
|
5375
|
+
backgroundColor: g,
|
|
5299
5376
|
backgroundOpacity: v = 1,
|
|
5300
5377
|
paddingTop: M = 0,
|
|
5301
|
-
paddingRight:
|
|
5378
|
+
paddingRight: C = 0,
|
|
5302
5379
|
paddingBottom: y = 0,
|
|
5303
5380
|
paddingLeft: w = 0,
|
|
5304
|
-
radiusTopLeft:
|
|
5305
|
-
radiusTopRight:
|
|
5381
|
+
radiusTopLeft: j = 0,
|
|
5382
|
+
radiusTopRight: T = 0,
|
|
5306
5383
|
radiusBottomRight: b = 0,
|
|
5307
5384
|
radiusBottomLeft: A = 0
|
|
5308
|
-
} =
|
|
5385
|
+
} = z, S = Mt(z, [
|
|
5309
5386
|
"id",
|
|
5310
5387
|
"text",
|
|
5311
5388
|
"autoExpand",
|
|
@@ -5332,15 +5409,15 @@ class st {
|
|
|
5332
5409
|
"radiusBottomRight",
|
|
5333
5410
|
"radiusBottomLeft"
|
|
5334
5411
|
]);
|
|
5335
|
-
var
|
|
5412
|
+
var J;
|
|
5336
5413
|
const { historyManager: E } = this.editor, { canvas: B } = this;
|
|
5337
5414
|
E.suspendHistory();
|
|
5338
|
-
const
|
|
5415
|
+
const Y = s != null ? s : this._getDefaultFontFamily(), R = Le({ width: p }), U = Ee({
|
|
5339
5416
|
strokeColor: f,
|
|
5340
|
-
width:
|
|
5341
|
-
}),
|
|
5417
|
+
width: R
|
|
5418
|
+
}), D = x({
|
|
5342
5419
|
id: t,
|
|
5343
|
-
fontFamily:
|
|
5420
|
+
fontFamily: Y,
|
|
5344
5421
|
fontSize: o,
|
|
5345
5422
|
fontWeight: i ? "bold" : "normal",
|
|
5346
5423
|
fontStyle: a ? "italic" : "normal",
|
|
@@ -5349,43 +5426,43 @@ class st {
|
|
|
5349
5426
|
linethrough: l,
|
|
5350
5427
|
textAlign: h,
|
|
5351
5428
|
fill: u,
|
|
5352
|
-
stroke:
|
|
5353
|
-
strokeWidth:
|
|
5429
|
+
stroke: U,
|
|
5430
|
+
strokeWidth: R,
|
|
5354
5431
|
strokeUniform: !0,
|
|
5355
5432
|
opacity: m,
|
|
5356
|
-
backgroundColor:
|
|
5433
|
+
backgroundColor: g,
|
|
5357
5434
|
backgroundOpacity: v,
|
|
5358
5435
|
paddingTop: M,
|
|
5359
|
-
paddingRight:
|
|
5436
|
+
paddingRight: C,
|
|
5360
5437
|
paddingBottom: y,
|
|
5361
5438
|
paddingLeft: w,
|
|
5362
|
-
radiusTopLeft:
|
|
5363
|
-
radiusTopRight:
|
|
5439
|
+
radiusTopLeft: j,
|
|
5440
|
+
radiusTopRight: T,
|
|
5364
5441
|
radiusBottomRight: b,
|
|
5365
5442
|
radiusBottomLeft: A
|
|
5366
|
-
}, S),
|
|
5367
|
-
if (
|
|
5368
|
-
const G =
|
|
5369
|
-
G !==
|
|
5370
|
-
}
|
|
5371
|
-
return Ct({ textbox:
|
|
5372
|
-
textbox:
|
|
5373
|
-
options: It(
|
|
5443
|
+
}, S), k = new ge(e, D), _ = n !== !1;
|
|
5444
|
+
if (k.autoExpand = _, k.textCaseRaw = (J = k.text) != null ? J : "", c) {
|
|
5445
|
+
const G = Me({ value: k.textCaseRaw });
|
|
5446
|
+
G !== k.text && k.set({ text: G });
|
|
5447
|
+
}
|
|
5448
|
+
return Ct({ textbox: k }) && (k.dirty = !0), S.left === void 0 && S.top === void 0 && B.centerObject(k), N || B.add(k), I || B.setActiveObject(k), B.requestRenderAll(), E.resumeHistory(), O || E.saveState(), B.fire("editor:text-added", {
|
|
5449
|
+
textbox: k,
|
|
5450
|
+
options: It(x({}, D), {
|
|
5374
5451
|
text: e,
|
|
5375
5452
|
bold: i,
|
|
5376
5453
|
italic: a,
|
|
5377
5454
|
strikethrough: l,
|
|
5378
5455
|
align: h,
|
|
5379
5456
|
color: u,
|
|
5380
|
-
strokeColor:
|
|
5381
|
-
strokeWidth:
|
|
5457
|
+
strokeColor: U,
|
|
5458
|
+
strokeWidth: R
|
|
5382
5459
|
}),
|
|
5383
5460
|
flags: {
|
|
5384
|
-
withoutSelection: !!
|
|
5461
|
+
withoutSelection: !!I,
|
|
5385
5462
|
withoutSave: !!O,
|
|
5386
|
-
withoutAdding: !!
|
|
5463
|
+
withoutAdding: !!N
|
|
5387
5464
|
}
|
|
5388
|
-
}),
|
|
5465
|
+
}), k;
|
|
5389
5466
|
}
|
|
5390
5467
|
/**
|
|
5391
5468
|
* Обновляет текстовый объект.
|
|
@@ -5413,31 +5490,31 @@ class st {
|
|
|
5413
5490
|
x: u.x,
|
|
5414
5491
|
y: u.y
|
|
5415
5492
|
}, Ht = e, {
|
|
5416
|
-
text:
|
|
5493
|
+
text: p,
|
|
5417
5494
|
autoExpand: m,
|
|
5418
|
-
fontFamily:
|
|
5495
|
+
fontFamily: g,
|
|
5419
5496
|
fontSize: v,
|
|
5420
5497
|
bold: M,
|
|
5421
|
-
italic:
|
|
5498
|
+
italic: C,
|
|
5422
5499
|
underline: y,
|
|
5423
5500
|
uppercase: w,
|
|
5424
|
-
strikethrough:
|
|
5425
|
-
align:
|
|
5501
|
+
strikethrough: j,
|
|
5502
|
+
align: T,
|
|
5426
5503
|
color: b,
|
|
5427
5504
|
strokeColor: A,
|
|
5428
5505
|
strokeWidth: S,
|
|
5429
|
-
opacity:
|
|
5506
|
+
opacity: I,
|
|
5430
5507
|
backgroundColor: O,
|
|
5431
|
-
backgroundOpacity:
|
|
5432
|
-
paddingTop:
|
|
5433
|
-
paddingRight:
|
|
5508
|
+
backgroundOpacity: N,
|
|
5509
|
+
paddingTop: W,
|
|
5510
|
+
paddingRight: z,
|
|
5434
5511
|
paddingBottom: E,
|
|
5435
5512
|
paddingLeft: B,
|
|
5436
|
-
radiusTopLeft:
|
|
5437
|
-
radiusTopRight:
|
|
5438
|
-
radiusBottomRight:
|
|
5439
|
-
radiusBottomLeft:
|
|
5440
|
-
} = Ht,
|
|
5513
|
+
radiusTopLeft: Y,
|
|
5514
|
+
radiusTopRight: R,
|
|
5515
|
+
radiusBottomRight: U,
|
|
5516
|
+
radiusBottomLeft: D
|
|
5517
|
+
} = Ht, k = Mt(Ht, [
|
|
5441
5518
|
"text",
|
|
5442
5519
|
"autoExpand",
|
|
5443
5520
|
"fontFamily",
|
|
@@ -5462,84 +5539,84 @@ class st {
|
|
|
5462
5539
|
"radiusTopRight",
|
|
5463
5540
|
"radiusBottomRight",
|
|
5464
5541
|
"radiusBottomLeft"
|
|
5465
|
-
]), _ =
|
|
5542
|
+
]), _ = x({}, k), L = o !== void 0 ? ws({
|
|
5466
5543
|
text: a,
|
|
5467
5544
|
range: o
|
|
5468
|
-
}) :
|
|
5545
|
+
}) : ms({ textbox: i }), J = L ? As({ textbox: i, range: L }) : null, G = {}, Q = {}, $ = {};
|
|
5469
5546
|
let ot, ht;
|
|
5470
|
-
const vt =
|
|
5471
|
-
if (
|
|
5547
|
+
const vt = vs({ textbox: i, range: L }), rt = !L || vt, ct = !L;
|
|
5548
|
+
if (g !== void 0 && (J && (Q.fontFamily = g), rt && (_.fontFamily = g, ct && ($.fontFamily = g))), v !== void 0 && (J && (Q.fontSize = v), rt && (_.fontSize = v, ct && ($.fontSize = v))), M !== void 0) {
|
|
5472
5549
|
const q = M ? "bold" : "normal";
|
|
5473
|
-
|
|
5550
|
+
L && (G.fontWeight = q), rt && (_.fontWeight = q, ct && ($.fontWeight = q));
|
|
5474
5551
|
}
|
|
5475
|
-
if (
|
|
5476
|
-
const q =
|
|
5477
|
-
|
|
5552
|
+
if (C !== void 0) {
|
|
5553
|
+
const q = C ? "italic" : "normal";
|
|
5554
|
+
L && (G.fontStyle = q), rt && (_.fontStyle = q, ct && ($.fontStyle = q));
|
|
5478
5555
|
}
|
|
5479
|
-
if (y !== void 0 && (
|
|
5480
|
-
const q =
|
|
5481
|
-
ht =
|
|
5556
|
+
if (y !== void 0 && (L && (G.underline = y), rt && (_.underline = y, ct && ($.underline = y))), j !== void 0 && (L && (G.linethrough = j), rt && (_.linethrough = j, ct && ($.linethrough = j))), T !== void 0 && (_.textAlign = T), b !== void 0 && (L && (G.fill = b), rt && (_.fill = b, ct && ($.fill = b))), A !== void 0 || S !== void 0) {
|
|
5557
|
+
const q = L ? sn({ textbox: i, range: L, property: "strokeWidth" }) : void 0, nt = L ? sn({ textbox: i, range: L, property: "stroke" }) : void 0, ve = (Gt = (Zt = S != null ? S : q) != null ? Zt : i.strokeWidth) != null ? Gt : 0;
|
|
5558
|
+
ht = Le({ width: ve });
|
|
5482
5559
|
const kt = (Rt = (Vt = A != null ? A : nt) != null ? Vt : i.stroke) != null ? Rt : void 0;
|
|
5483
|
-
ot =
|
|
5560
|
+
ot = Ee({
|
|
5484
5561
|
strokeColor: kt,
|
|
5485
5562
|
width: ht
|
|
5486
|
-
}),
|
|
5563
|
+
}), L && (G.stroke = ot, G.strokeWidth = ht), rt && (_.stroke = ot, _.strokeWidth = ht, ct && ($.stroke = ot, $.strokeWidth = ht));
|
|
5487
5564
|
}
|
|
5488
|
-
|
|
5489
|
-
const At = (ie = i.textCaseRaw) != null ? ie : a, bt = !!i.uppercase, Lt =
|
|
5490
|
-
if (Lt ||
|
|
5491
|
-
const q = _t ?
|
|
5565
|
+
I !== void 0 && (_.opacity = I), O !== void 0 && (_.backgroundColor = O), N !== void 0 && (_.backgroundOpacity = N), W !== void 0 && (_.paddingTop = W), z !== void 0 && (_.paddingRight = z), E !== void 0 && (_.paddingBottom = E), B !== void 0 && (_.paddingLeft = B), Y !== void 0 && (_.radiusTopLeft = Y), R !== void 0 && (_.radiusTopRight = R), U !== void 0 && (_.radiusBottomRight = U), D !== void 0 && (_.radiusBottomLeft = D);
|
|
5566
|
+
const At = (ie = i.textCaseRaw) != null ? ie : a, bt = !!i.uppercase, Lt = p !== void 0, Dt = Lt ? p != null ? p : "" : At, _t = w != null ? w : bt, Ut = _t !== bt;
|
|
5567
|
+
if (Lt || Ut) {
|
|
5568
|
+
const q = _t ? Me({ value: Dt }) : Dt;
|
|
5492
5569
|
_.text = q, i.textCaseRaw = Dt;
|
|
5493
5570
|
} else i.textCaseRaw === void 0 && (i.textCaseRaw = At);
|
|
5494
5571
|
i.uppercase = _t, i.set(_);
|
|
5495
5572
|
let ut = !1;
|
|
5496
|
-
if (
|
|
5497
|
-
const q =
|
|
5573
|
+
if (L) {
|
|
5574
|
+
const q = be({ textbox: i, styles: G, range: L }), nt = J ? be({ textbox: i, styles: Q, range: J }) : !1;
|
|
5498
5575
|
ut = q || nt;
|
|
5499
|
-
} else if (Object.keys(
|
|
5500
|
-
const q =
|
|
5501
|
-
q && (ut =
|
|
5576
|
+
} else if (Object.keys($).length) {
|
|
5577
|
+
const q = ys({ textbox: i });
|
|
5578
|
+
q && (ut = be({ textbox: i, styles: $, range: q }));
|
|
5502
5579
|
}
|
|
5503
|
-
const Qt = ut &&
|
|
5580
|
+
const Qt = ut && ln({
|
|
5504
5581
|
stylesList: [
|
|
5505
5582
|
G,
|
|
5506
|
-
|
|
5507
|
-
|
|
5583
|
+
Q,
|
|
5584
|
+
$
|
|
5508
5585
|
]
|
|
5509
5586
|
});
|
|
5510
|
-
if (ut && (i.dirty = !0),
|
|
5511
|
-
const q =
|
|
5587
|
+
if (ut && (i.dirty = !0), J && (g !== void 0 || v !== void 0)) {
|
|
5588
|
+
const q = js({
|
|
5512
5589
|
textbox: i,
|
|
5513
|
-
range:
|
|
5590
|
+
range: J
|
|
5514
5591
|
}), nt = {};
|
|
5515
|
-
|
|
5592
|
+
g !== void 0 && (nt.fontFamily = g), v !== void 0 && (nt.fontSize = v), on({
|
|
5516
5593
|
textbox: i,
|
|
5517
5594
|
lineIndices: q,
|
|
5518
5595
|
updates: nt
|
|
5519
5596
|
});
|
|
5520
5597
|
}
|
|
5521
|
-
if (
|
|
5522
|
-
const q =
|
|
5598
|
+
if (L && (b !== void 0 || A !== void 0 || S !== void 0)) {
|
|
5599
|
+
const q = Is({
|
|
5523
5600
|
textbox: i,
|
|
5524
|
-
range:
|
|
5601
|
+
range: L
|
|
5525
5602
|
}), nt = {};
|
|
5526
|
-
b !== void 0 && (nt.fill = b), (A !== void 0 || S !== void 0) && (ot === null && (nt.stroke = null), ot != null && (nt.stroke = ot)),
|
|
5603
|
+
b !== void 0 && (nt.fill = b), (A !== void 0 || S !== void 0) && (ot === null && (nt.stroke = null), ot != null && (nt.stroke = ot)), on({
|
|
5527
5604
|
textbox: i,
|
|
5528
5605
|
lineIndices: q,
|
|
5529
5606
|
updates: nt
|
|
5530
5607
|
});
|
|
5531
5608
|
}
|
|
5532
|
-
Qt && (i.initDimensions(), i.dirty = !0), (O !== void 0 ||
|
|
5533
|
-
const jt =
|
|
5609
|
+
Qt && (i.initDimensions(), i.dirty = !0), (O !== void 0 || N !== void 0 || W !== void 0 || z !== void 0 || E !== void 0 || B !== void 0 || Y !== void 0 || R !== void 0 || U !== void 0 || D !== void 0) && (i.dirty = !0);
|
|
5610
|
+
const jt = ln({
|
|
5534
5611
|
stylesList: [
|
|
5535
5612
|
_,
|
|
5536
5613
|
G,
|
|
5537
|
-
|
|
5538
|
-
|
|
5614
|
+
Q,
|
|
5615
|
+
$
|
|
5539
5616
|
]
|
|
5540
|
-
}), { autoExpand:
|
|
5541
|
-
$t ? i.autoExpand = m !== !1 :
|
|
5542
|
-
const ee = Object.prototype.hasOwnProperty.call(_, "width"), ne = te && !ee && (Lt ||
|
|
5617
|
+
}), { autoExpand: gt } = i, $t = m !== void 0, te = (m != null ? m : gt) !== !1;
|
|
5618
|
+
$t ? i.autoExpand = m !== !1 : gt === void 0 && (i.autoExpand = !0);
|
|
5619
|
+
const ee = Object.prototype.hasOwnProperty.call(_, "width"), ne = te && !ee && (Lt || Ut || jt);
|
|
5543
5620
|
let xt = !1;
|
|
5544
5621
|
ne && (xt = this._autoExpandTextboxWidth(i, {
|
|
5545
5622
|
anchor: f
|
|
@@ -5556,10 +5633,17 @@ class st {
|
|
|
5556
5633
|
updates: _,
|
|
5557
5634
|
before: l,
|
|
5558
5635
|
after: se,
|
|
5559
|
-
selectionRange:
|
|
5560
|
-
selectionStyles:
|
|
5636
|
+
selectionRange: L != null ? L : void 0,
|
|
5637
|
+
selectionStyles: L && Object.keys(G).length ? G : void 0
|
|
5561
5638
|
}), i;
|
|
5562
5639
|
}
|
|
5640
|
+
/**
|
|
5641
|
+
* Преобразует стили из массивного формата Fabric в объектный.
|
|
5642
|
+
*/
|
|
5643
|
+
// eslint-disable-next-line class-methods-use-this
|
|
5644
|
+
stylesFromArray(t, e) {
|
|
5645
|
+
return ft.stylesFromArray(t, e);
|
|
5646
|
+
}
|
|
5563
5647
|
/**
|
|
5564
5648
|
* Уничтожает менеджер и снимает слушатели.
|
|
5565
5649
|
*/
|
|
@@ -5600,7 +5684,7 @@ class st {
|
|
|
5600
5684
|
* Синхронизирует lineFontDefaults при изменении текста и сохраняет typing style для пустых строк.
|
|
5601
5685
|
*/
|
|
5602
5686
|
_syncLineFontDefaultsOnTextChanged({ textbox: t }) {
|
|
5603
|
-
var
|
|
5687
|
+
var N, W, z;
|
|
5604
5688
|
const {
|
|
5605
5689
|
text: e = "",
|
|
5606
5690
|
lineFontDefaults: n,
|
|
@@ -5611,81 +5695,81 @@ class st {
|
|
|
5611
5695
|
stroke: r,
|
|
5612
5696
|
selectionStart: c,
|
|
5613
5697
|
isEditing: l
|
|
5614
|
-
} = t, h = e, u = (
|
|
5615
|
-
`),
|
|
5616
|
-
`), m = f.length, v =
|
|
5617
|
-
let M = n,
|
|
5618
|
-
const w = typeof a == "string" ? a : void 0,
|
|
5698
|
+
} = t, h = e, u = (N = t.__lineDefaultsPrevText) != null ? N : h, f = u.split(`
|
|
5699
|
+
`), p = h.split(`
|
|
5700
|
+
`), m = f.length, v = p.length - m;
|
|
5701
|
+
let M = n, C = !1, y = !1;
|
|
5702
|
+
const w = typeof a == "string" ? a : void 0, j = typeof r == "string" ? r : void 0;
|
|
5619
5703
|
if (v !== 0 && n && Object.keys(n).length) {
|
|
5620
|
-
const E =
|
|
5704
|
+
const E = Cs({
|
|
5621
5705
|
previous: u,
|
|
5622
5706
|
next: h
|
|
5623
|
-
}), B =
|
|
5707
|
+
}), B = Ts({
|
|
5624
5708
|
text: u,
|
|
5625
5709
|
charIndex: E
|
|
5626
5710
|
});
|
|
5627
5711
|
if (v > 0) {
|
|
5628
|
-
const
|
|
5712
|
+
const Y = Os({
|
|
5629
5713
|
text: u,
|
|
5630
5714
|
lineIndex: B
|
|
5631
5715
|
});
|
|
5632
|
-
let
|
|
5633
|
-
E ===
|
|
5634
|
-
const
|
|
5635
|
-
for (const
|
|
5636
|
-
if (!Object.prototype.hasOwnProperty.call(n,
|
|
5637
|
-
const
|
|
5638
|
-
if (!Number.isFinite(
|
|
5639
|
-
const _ = n[
|
|
5716
|
+
let R = B + 1;
|
|
5717
|
+
E === Y && (R = B);
|
|
5718
|
+
const U = {};
|
|
5719
|
+
for (const D in n) {
|
|
5720
|
+
if (!Object.prototype.hasOwnProperty.call(n, D)) continue;
|
|
5721
|
+
const k = Number(D);
|
|
5722
|
+
if (!Number.isFinite(k)) continue;
|
|
5723
|
+
const _ = n[k];
|
|
5640
5724
|
if (!_) continue;
|
|
5641
|
-
const
|
|
5642
|
-
|
|
5725
|
+
const L = k >= R ? k + v : k;
|
|
5726
|
+
U[L] = x({}, _);
|
|
5643
5727
|
}
|
|
5644
|
-
M =
|
|
5728
|
+
M = U, C = !0, y = !0;
|
|
5645
5729
|
}
|
|
5646
5730
|
if (v < 0) {
|
|
5647
|
-
const
|
|
5648
|
-
let
|
|
5731
|
+
const Y = Math.abs(v);
|
|
5732
|
+
let R = B;
|
|
5649
5733
|
u[E] === `
|
|
5650
|
-
` && ((
|
|
5651
|
-
const
|
|
5734
|
+
` && ((W = f[B]) != null ? W : "").length > 0 && (R = B + 1);
|
|
5735
|
+
const D = R + Y - 1, k = {};
|
|
5652
5736
|
for (const _ in n) {
|
|
5653
5737
|
if (!Object.prototype.hasOwnProperty.call(n, _)) continue;
|
|
5654
|
-
const
|
|
5655
|
-
if (!Number.isFinite(
|
|
5656
|
-
const
|
|
5657
|
-
|
|
5738
|
+
const L = Number(_);
|
|
5739
|
+
if (!Number.isFinite(L)) continue;
|
|
5740
|
+
const J = n[L];
|
|
5741
|
+
J && (L < R && (k[L] = x({}, J)), L > D && (k[L + v] = x({}, J)));
|
|
5658
5742
|
}
|
|
5659
|
-
M =
|
|
5743
|
+
M = k, C = !0, y = !0;
|
|
5660
5744
|
}
|
|
5661
5745
|
}
|
|
5662
|
-
let
|
|
5746
|
+
let T = null;
|
|
5663
5747
|
if (l && typeof c == "number") {
|
|
5664
5748
|
const E = t.get2DCursorLocation(c), { lineIndex: B } = E;
|
|
5665
|
-
Number.isFinite(B) && (
|
|
5666
|
-
}
|
|
5667
|
-
let b = s, A = !1, S = !1,
|
|
5668
|
-
for (let E = 0; E <
|
|
5669
|
-
const B = (
|
|
5670
|
-
if (
|
|
5671
|
-
if (
|
|
5672
|
-
const
|
|
5749
|
+
Number.isFinite(B) && (T = B);
|
|
5750
|
+
}
|
|
5751
|
+
let b = s, A = !1, S = !1, I, O = null;
|
|
5752
|
+
for (let E = 0; E < p.length; E += 1) {
|
|
5753
|
+
const B = (z = p[E]) != null ? z : "", Y = M ? M[E] : void 0;
|
|
5754
|
+
if (Y && (I = Y), B.length !== 0) {
|
|
5755
|
+
if (Y) {
|
|
5756
|
+
const L = Ms({
|
|
5673
5757
|
lineText: B,
|
|
5674
5758
|
lineStyles: b ? b[E] : void 0,
|
|
5675
|
-
lineDefaults:
|
|
5759
|
+
lineDefaults: Y
|
|
5676
5760
|
});
|
|
5677
|
-
|
|
5761
|
+
L.changed && (b || (b = {}, S = !0), S || (b = x({}, b), S = !0), L.lineStyles && (b[E] = L.lineStyles), !L.lineStyles && b[E] && delete b[E], A = !0);
|
|
5678
5762
|
}
|
|
5679
5763
|
continue;
|
|
5680
5764
|
}
|
|
5681
|
-
const
|
|
5682
|
-
(
|
|
5683
|
-
const
|
|
5684
|
-
|
|
5685
|
-
const _ = Object.keys(
|
|
5686
|
-
(_ || b && b[E]) && (b || (b = {}, S = !0), S || (b =
|
|
5687
|
-
}
|
|
5688
|
-
if (
|
|
5765
|
+
const U = Y != null ? Y : I, D = {};
|
|
5766
|
+
(U == null ? void 0 : U.fontFamily) !== void 0 ? D.fontFamily = U.fontFamily : o !== void 0 && (D.fontFamily = o), (U == null ? void 0 : U.fontSize) !== void 0 ? D.fontSize = U.fontSize : i !== void 0 && (D.fontSize = i), (U == null ? void 0 : U.fill) !== void 0 ? D.fill = U.fill : w !== void 0 && (D.fill = w), (U == null ? void 0 : U.stroke) !== void 0 ? D.stroke = U.stroke : j !== void 0 && (D.stroke = j), !Y && Object.keys(D).length && (M || (M = {}, y = !0), y || (M = x({}, M), y = !0), M[E] = D, C = !0, I = D), Y && (I = Y), T !== null && T === E && (O = D);
|
|
5767
|
+
const k = {};
|
|
5768
|
+
D.fontFamily !== void 0 && (k.fontFamily = D.fontFamily), D.fontSize !== void 0 && (k.fontSize = D.fontSize), D.fill !== void 0 && (k.fill = D.fill), D.stroke !== void 0 && (k.stroke = D.stroke);
|
|
5769
|
+
const _ = Object.keys(k).length > 0;
|
|
5770
|
+
(_ || b && b[E]) && (b || (b = {}, S = !0), S || (b = x({}, b), S = !0), _ && (b[E] = { 0: k }), !_ && b[E] && delete b[E], A = !0);
|
|
5771
|
+
}
|
|
5772
|
+
if (C && M && (t.lineFontDefaults = M), A && (t.styles = b, t.dirty = !0), O && typeof c == "number") {
|
|
5689
5773
|
const E = {};
|
|
5690
5774
|
if (O.fontFamily !== void 0 && (E.fontFamily = O.fontFamily), O.fontSize !== void 0 && (E.fontSize = O.fontSize), O.fill !== void 0 && (E.fill = O.fill), O.stroke !== void 0 && (E.stroke = O.stroke), Object.keys(E).length) {
|
|
5691
5775
|
this.lineDefaultsSyncing.add(t);
|
|
@@ -5703,37 +5787,37 @@ class st {
|
|
|
5703
5787
|
* но не шире монтажной области, и удерживает объект в её пределах.
|
|
5704
5788
|
*/
|
|
5705
5789
|
_autoExpandTextboxWidth(t, { anchor: e } = {}) {
|
|
5706
|
-
var
|
|
5790
|
+
var T, b, A, S, I, O, N, W, z, E, B, Y, R;
|
|
5707
5791
|
const { montageArea: n } = this.editor;
|
|
5708
5792
|
if (!n) return !1;
|
|
5709
5793
|
const s = typeof t.text == "string" ? t.text : "";
|
|
5710
5794
|
if (!s.length) return !1;
|
|
5711
5795
|
n.setCoords();
|
|
5712
|
-
const o = n.getBoundingRect(!1, !0), i = (
|
|
5796
|
+
const o = n.getBoundingRect(!1, !0), i = (T = o.width) != null ? T : 0;
|
|
5713
5797
|
if (!Number.isFinite(i) || i <= 0) return !1;
|
|
5714
|
-
const a = e != null ? e : (b = this.editingAnchorState) == null ? void 0 : b.get(t), r = (S = (A = a == null ? void 0 : a.originY) != null ? A : t.originY) != null ? S : "top", c = Math.abs((
|
|
5798
|
+
const a = e != null ? e : (b = this.editingAnchorState) == null ? void 0 : b.get(t), r = (S = (A = a == null ? void 0 : a.originY) != null ? A : t.originY) != null ? S : "top", c = Math.abs((I = t.scaleX) != null ? I : 1) || 1, l = (O = t.paddingLeft) != null ? O : 0, h = (N = t.paddingRight) != null ? N : 0, u = (W = t.strokeWidth) != null ? W : 0, f = Math.max(
|
|
5715
5799
|
1,
|
|
5716
5800
|
i / c - l - h - u
|
|
5717
5801
|
);
|
|
5718
5802
|
if (!Number.isFinite(f) || f <= 0) return !1;
|
|
5719
|
-
const
|
|
5803
|
+
const p = s.split(`
|
|
5720
5804
|
`).length;
|
|
5721
5805
|
let m = !1;
|
|
5722
|
-
Math.abs(((
|
|
5723
|
-
const { textLines:
|
|
5724
|
-
|
|
5725
|
-
),
|
|
5806
|
+
Math.abs(((z = t.width) != null ? z : 0) - f) > it && (t.set({ width: f }), m = !0), t.initDimensions();
|
|
5807
|
+
const { textLines: g } = t, v = Array.isArray(g) && g.length > p, M = Math.ceil(
|
|
5808
|
+
Es({ textbox: t, text: s })
|
|
5809
|
+
), C = Math.min((E = t.minWidth) != null ? E : 1, f);
|
|
5726
5810
|
let y = Math.min(
|
|
5727
5811
|
f,
|
|
5728
|
-
Math.max(M,
|
|
5812
|
+
Math.max(M, C)
|
|
5729
5813
|
);
|
|
5730
5814
|
v && (y = f), Math.abs(((B = t.width) != null ? B : 0) - y) > it && (t.set({ width: y }), t.initDimensions(), m = !0), Ct({ textbox: t }) && (m = !0), a && (t.setPositionByOrigin(new at(a.x, a.y), "center", r), m = !0);
|
|
5731
|
-
const
|
|
5815
|
+
const j = Ls({
|
|
5732
5816
|
textbox: t,
|
|
5733
|
-
montageLeft: (
|
|
5734
|
-
montageRight: ((
|
|
5817
|
+
montageLeft: (Y = o.left) != null ? Y : 0,
|
|
5818
|
+
montageRight: ((R = o.left) != null ? R : 0) + i
|
|
5735
5819
|
});
|
|
5736
|
-
return m ||
|
|
5820
|
+
return m || j;
|
|
5737
5821
|
}
|
|
5738
5822
|
/**
|
|
5739
5823
|
* Обрабатывает изменение ширины текстового объекта (resizing).
|
|
@@ -5742,7 +5826,7 @@ class st {
|
|
|
5742
5826
|
* Также корректирует позицию при ресайзе слева, чтобы компенсировать смещение.
|
|
5743
5827
|
*/
|
|
5744
5828
|
static _handleObjectResizing(t) {
|
|
5745
|
-
var h, u, f,
|
|
5829
|
+
var h, u, f, p, m, g;
|
|
5746
5830
|
const { target: e, transform: n } = t;
|
|
5747
5831
|
if (!st._isTextbox(e)) return;
|
|
5748
5832
|
const {
|
|
@@ -5755,10 +5839,10 @@ class st {
|
|
|
5755
5839
|
e.set({ width: r });
|
|
5756
5840
|
const c = (u = e.width) != null ? u : 0, l = a - c;
|
|
5757
5841
|
if (l !== 0 && n && n.corner === "ml") {
|
|
5758
|
-
const M = ((f = e.angle) != null ? f : 0) * Math.PI / 180,
|
|
5842
|
+
const M = ((f = e.angle) != null ? f : 0) * Math.PI / 180, C = Math.cos(M), y = Math.sin(M), w = (p = e.scaleX) != null ? p : 1, j = l * w;
|
|
5759
5843
|
e.set({
|
|
5760
|
-
left: ((m = e.left) != null ? m : 0) +
|
|
5761
|
-
top: ((
|
|
5844
|
+
left: ((m = e.left) != null ? m : 0) + j * C,
|
|
5845
|
+
top: ((g = e.top) != null ? g : 0) + j * y
|
|
5762
5846
|
});
|
|
5763
5847
|
}
|
|
5764
5848
|
}
|
|
@@ -5779,10 +5863,10 @@ class st {
|
|
|
5779
5863
|
paddingTop: h = 0,
|
|
5780
5864
|
paddingRight: u = 0,
|
|
5781
5865
|
paddingBottom: f = 0,
|
|
5782
|
-
paddingLeft:
|
|
5866
|
+
paddingLeft: p = 0
|
|
5783
5867
|
} = t, {
|
|
5784
5868
|
radiusTopLeft: m = 0,
|
|
5785
|
-
radiusTopRight:
|
|
5869
|
+
radiusTopRight: g = 0,
|
|
5786
5870
|
radiusBottomRight: v = 0,
|
|
5787
5871
|
radiusBottomLeft: M = 0
|
|
5788
5872
|
} = t;
|
|
@@ -5794,16 +5878,16 @@ class st {
|
|
|
5794
5878
|
top: h,
|
|
5795
5879
|
right: u,
|
|
5796
5880
|
bottom: f,
|
|
5797
|
-
left:
|
|
5881
|
+
left: p
|
|
5798
5882
|
},
|
|
5799
5883
|
baseRadii: {
|
|
5800
5884
|
topLeft: m,
|
|
5801
|
-
topRight:
|
|
5885
|
+
topRight: g,
|
|
5802
5886
|
bottomRight: v,
|
|
5803
5887
|
bottomLeft: M
|
|
5804
5888
|
},
|
|
5805
5889
|
baseStyles: JSON.parse(JSON.stringify(c)),
|
|
5806
|
-
baseLineFontDefaults:
|
|
5890
|
+
baseLineFontDefaults: an({ lineFontDefaults: l }),
|
|
5807
5891
|
hasWidthChange: !1
|
|
5808
5892
|
}, this.scalingState.set(t, e);
|
|
5809
5893
|
}
|
|
@@ -5814,11 +5898,11 @@ class st {
|
|
|
5814
5898
|
*/
|
|
5815
5899
|
static _getSnapshot(t) {
|
|
5816
5900
|
const e = ({
|
|
5817
|
-
snapshot:
|
|
5818
|
-
entries:
|
|
5901
|
+
snapshot: D,
|
|
5902
|
+
entries: k
|
|
5819
5903
|
}) => {
|
|
5820
|
-
Object.entries(
|
|
5821
|
-
|
|
5904
|
+
Object.entries(k).forEach(([_, L]) => {
|
|
5905
|
+
L != null && (D[_] = L);
|
|
5822
5906
|
});
|
|
5823
5907
|
}, {
|
|
5824
5908
|
id: n,
|
|
@@ -5832,35 +5916,35 @@ class st {
|
|
|
5832
5916
|
fontStyle: h,
|
|
5833
5917
|
underline: u,
|
|
5834
5918
|
linethrough: f,
|
|
5835
|
-
textAlign:
|
|
5919
|
+
textAlign: p,
|
|
5836
5920
|
fill: m,
|
|
5837
|
-
stroke:
|
|
5921
|
+
stroke: g,
|
|
5838
5922
|
strokeWidth: v,
|
|
5839
5923
|
opacity: M,
|
|
5840
|
-
backgroundColor:
|
|
5924
|
+
backgroundColor: C,
|
|
5841
5925
|
backgroundOpacity: y,
|
|
5842
5926
|
paddingTop: w,
|
|
5843
|
-
paddingRight:
|
|
5844
|
-
paddingBottom:
|
|
5927
|
+
paddingRight: j,
|
|
5928
|
+
paddingBottom: T,
|
|
5845
5929
|
paddingLeft: b,
|
|
5846
5930
|
radiusTopLeft: A,
|
|
5847
5931
|
radiusTopRight: S,
|
|
5848
|
-
radiusBottomRight:
|
|
5932
|
+
radiusBottomRight: I,
|
|
5849
5933
|
radiusBottomLeft: O,
|
|
5850
|
-
left:
|
|
5851
|
-
top:
|
|
5852
|
-
width:
|
|
5934
|
+
left: N,
|
|
5935
|
+
top: W,
|
|
5936
|
+
width: z,
|
|
5853
5937
|
height: E,
|
|
5854
5938
|
angle: B,
|
|
5855
|
-
scaleX:
|
|
5856
|
-
scaleY:
|
|
5857
|
-
} = t,
|
|
5939
|
+
scaleX: Y,
|
|
5940
|
+
scaleY: R
|
|
5941
|
+
} = t, U = {
|
|
5858
5942
|
id: n,
|
|
5859
5943
|
uppercase: !!i,
|
|
5860
|
-
textAlign:
|
|
5944
|
+
textAlign: p
|
|
5861
5945
|
};
|
|
5862
5946
|
return e({
|
|
5863
|
-
snapshot:
|
|
5947
|
+
snapshot: U,
|
|
5864
5948
|
entries: {
|
|
5865
5949
|
text: s,
|
|
5866
5950
|
textCaseRaw: o,
|
|
@@ -5872,28 +5956,28 @@ class st {
|
|
|
5872
5956
|
underline: u,
|
|
5873
5957
|
linethrough: f,
|
|
5874
5958
|
fill: m,
|
|
5875
|
-
stroke:
|
|
5959
|
+
stroke: g,
|
|
5876
5960
|
strokeWidth: v,
|
|
5877
5961
|
opacity: M,
|
|
5878
|
-
backgroundColor:
|
|
5962
|
+
backgroundColor: C,
|
|
5879
5963
|
backgroundOpacity: y,
|
|
5880
5964
|
paddingTop: w,
|
|
5881
|
-
paddingRight:
|
|
5882
|
-
paddingBottom:
|
|
5965
|
+
paddingRight: j,
|
|
5966
|
+
paddingBottom: T,
|
|
5883
5967
|
paddingLeft: b,
|
|
5884
5968
|
radiusTopLeft: A,
|
|
5885
5969
|
radiusTopRight: S,
|
|
5886
|
-
radiusBottomRight:
|
|
5970
|
+
radiusBottomRight: I,
|
|
5887
5971
|
radiusBottomLeft: O,
|
|
5888
|
-
left:
|
|
5889
|
-
top:
|
|
5890
|
-
width:
|
|
5972
|
+
left: N,
|
|
5973
|
+
top: W,
|
|
5974
|
+
width: z,
|
|
5891
5975
|
height: E,
|
|
5892
5976
|
angle: B,
|
|
5893
|
-
scaleX:
|
|
5894
|
-
scaleY:
|
|
5977
|
+
scaleX: Y,
|
|
5978
|
+
scaleY: R
|
|
5895
5979
|
}
|
|
5896
|
-
}),
|
|
5980
|
+
}), U;
|
|
5897
5981
|
}
|
|
5898
5982
|
/**
|
|
5899
5983
|
* Возвращает первый доступный шрифт или дефолтный Arial.
|
|
@@ -5903,7 +5987,7 @@ class st {
|
|
|
5903
5987
|
return (e = (t = this.fonts[0]) == null ? void 0 : t.family) != null ? e : "Arial";
|
|
5904
5988
|
}
|
|
5905
5989
|
}
|
|
5906
|
-
const
|
|
5990
|
+
const et = ({
|
|
5907
5991
|
value: d,
|
|
5908
5992
|
fallback: t = 0
|
|
5909
5993
|
}) => typeof d == "number" && Number.isFinite(d) ? d : typeof t == "number" && Number.isFinite(t) ? t : 0, ce = ({
|
|
@@ -5911,9 +5995,9 @@ const tt = ({
|
|
|
5911
5995
|
dimension: t,
|
|
5912
5996
|
useRelativePositions: e
|
|
5913
5997
|
}) => {
|
|
5914
|
-
const n =
|
|
5998
|
+
const n = et({ value: d });
|
|
5915
5999
|
return e ? n : n / (t || 1);
|
|
5916
|
-
},
|
|
6000
|
+
}, Ds = ({
|
|
5917
6001
|
object: d,
|
|
5918
6002
|
baseWidth: t,
|
|
5919
6003
|
baseHeight: e,
|
|
@@ -5942,12 +6026,12 @@ const tt = ({
|
|
|
5942
6026
|
value: r,
|
|
5943
6027
|
dimension: e,
|
|
5944
6028
|
useRelativePositions: n
|
|
5945
|
-
}), f =
|
|
6029
|
+
}), f = et({ value: c }) / (t || 1), p = et({ value: l }) / (e || 1);
|
|
5946
6030
|
return {
|
|
5947
6031
|
x: h + f / 2,
|
|
5948
|
-
y: u +
|
|
6032
|
+
y: u + p / 2
|
|
5949
6033
|
};
|
|
5950
|
-
},
|
|
6034
|
+
}, _s = ({
|
|
5951
6035
|
normalizedX: d,
|
|
5952
6036
|
normalizedY: t,
|
|
5953
6037
|
bounds: e,
|
|
@@ -5956,12 +6040,12 @@ const tt = ({
|
|
|
5956
6040
|
}) => {
|
|
5957
6041
|
const { left: o, top: i, width: a, height: r } = e;
|
|
5958
6042
|
if (!s) {
|
|
5959
|
-
const { width: h, height: u } = n, f = o + d * (h || a),
|
|
5960
|
-
return new at(f,
|
|
6043
|
+
const { width: h, height: u } = n, f = o + d * (h || a), p = i + t * (u || r);
|
|
6044
|
+
return new at(f, p);
|
|
5961
6045
|
}
|
|
5962
6046
|
const c = o + d * a, l = i + t * r;
|
|
5963
6047
|
return new at(c, l);
|
|
5964
|
-
},
|
|
6048
|
+
}, xs = ({
|
|
5965
6049
|
object: d,
|
|
5966
6050
|
montageArea: t,
|
|
5967
6051
|
bounds: e
|
|
@@ -5999,12 +6083,12 @@ const tt = ({
|
|
|
5999
6083
|
} catch (t) {
|
|
6000
6084
|
return null;
|
|
6001
6085
|
}
|
|
6002
|
-
},
|
|
6086
|
+
}, Rs = ({
|
|
6003
6087
|
x1: d,
|
|
6004
6088
|
y1: t,
|
|
6005
6089
|
x2: e,
|
|
6006
6090
|
y2: n
|
|
6007
|
-
}) => (Math.atan2(n - t, e - d) * 180 / Math.PI + 360) % 360,
|
|
6091
|
+
}) => (Math.atan2(n - t, e - d) * 180 / Math.PI + 360) % 360, ks = (d) => {
|
|
6008
6092
|
if (!d || typeof d != "object") return null;
|
|
6009
6093
|
const { type: t, coords: e, colorStops: n } = d, s = Array.isArray(n) ? n : [], o = s[0], i = s[s.length - 1], a = typeof (o == null ? void 0 : o.color) == "string" ? o.color : void 0, r = typeof (i == null ? void 0 : i.color) == "string" ? i.color : a, c = typeof (o == null ? void 0 : o.offset) == "number" ? o.offset * 100 : void 0, l = typeof (i == null ? void 0 : i.offset) == "number" ? i.offset * 100 : void 0, h = s.map((u) => ({
|
|
6010
6094
|
color: typeof u.color == "string" ? u.color : "#000000",
|
|
@@ -6012,11 +6096,11 @@ const tt = ({
|
|
|
6012
6096
|
}));
|
|
6013
6097
|
if (!a || !r || !e) return null;
|
|
6014
6098
|
if (t === "linear") {
|
|
6015
|
-
const { x1: u, y1: f, x2:
|
|
6016
|
-
if (typeof u == "number" && typeof f == "number" && typeof
|
|
6099
|
+
const { x1: u, y1: f, x2: p, y2: m } = e;
|
|
6100
|
+
if (typeof u == "number" && typeof f == "number" && typeof p == "number" && typeof m == "number")
|
|
6017
6101
|
return {
|
|
6018
6102
|
type: "linear",
|
|
6019
|
-
angle:
|
|
6103
|
+
angle: Rs({ x1: u, y1: f, x2: p, y2: m }),
|
|
6020
6104
|
startColor: a,
|
|
6021
6105
|
endColor: r,
|
|
6022
6106
|
startPosition: c,
|
|
@@ -6025,13 +6109,13 @@ const tt = ({
|
|
|
6025
6109
|
};
|
|
6026
6110
|
}
|
|
6027
6111
|
if (t === "radial") {
|
|
6028
|
-
const { x1: u, y1: f, r2:
|
|
6029
|
-
if (typeof u == "number" && typeof f == "number" && typeof
|
|
6112
|
+
const { x1: u, y1: f, r2: p } = e;
|
|
6113
|
+
if (typeof u == "number" && typeof f == "number" && typeof p == "number")
|
|
6030
6114
|
return {
|
|
6031
6115
|
type: "radial",
|
|
6032
6116
|
centerX: u * 100,
|
|
6033
6117
|
centerY: f * 100,
|
|
6034
|
-
radius:
|
|
6118
|
+
radius: p * 100,
|
|
6035
6119
|
startColor: a,
|
|
6036
6120
|
endColor: r,
|
|
6037
6121
|
startPosition: c,
|
|
@@ -6040,8 +6124,8 @@ const tt = ({
|
|
|
6040
6124
|
};
|
|
6041
6125
|
}
|
|
6042
6126
|
return null;
|
|
6043
|
-
}, qt = "_templateCenterX",
|
|
6044
|
-
class
|
|
6127
|
+
}, qt = "_templateCenterX", Se = "_templateCenterY", le = "_templateAnchorX", we = "_templateAnchorY";
|
|
6128
|
+
class H {
|
|
6045
6129
|
constructor({ editor: t }) {
|
|
6046
6130
|
this.editor = t;
|
|
6047
6131
|
}
|
|
@@ -6060,7 +6144,7 @@ class Y {
|
|
|
6060
6144
|
montageArea: i,
|
|
6061
6145
|
errorManager: a,
|
|
6062
6146
|
backgroundManager: r
|
|
6063
|
-
} = this.editor, c = o.getActiveObject(), l =
|
|
6147
|
+
} = this.editor, c = o.getActiveObject(), l = H._collectObjects(c), { backgroundObject: h } = r != null ? r : {}, u = s && h ? [h] : [], f = [...l, ...u];
|
|
6064
6148
|
if (!f.length)
|
|
6065
6149
|
return a.emitWarning({
|
|
6066
6150
|
origin: "TemplateManager",
|
|
@@ -6068,21 +6152,21 @@ class Y {
|
|
|
6068
6152
|
code: Tt.TEMPLATE_MANAGER.NO_OBJECTS_SELECTED,
|
|
6069
6153
|
message: "Нет объектов для сериализации шаблона"
|
|
6070
6154
|
}), null;
|
|
6071
|
-
const
|
|
6155
|
+
const p = H._getBounds(i), m = H._getMontageSize({ montageArea: i, bounds: p }), g = m.width, v = m.height, M = f.map((w) => H._serializeObject({
|
|
6072
6156
|
object: w,
|
|
6073
|
-
bounds:
|
|
6074
|
-
baseWidth:
|
|
6157
|
+
bounds: p,
|
|
6158
|
+
baseWidth: g,
|
|
6075
6159
|
baseHeight: v,
|
|
6076
6160
|
montageArea: i != null ? i : null
|
|
6077
|
-
})),
|
|
6078
|
-
baseWidth:
|
|
6161
|
+
})), C = It(x({}, n), {
|
|
6162
|
+
baseWidth: g,
|
|
6079
6163
|
baseHeight: v,
|
|
6080
6164
|
positionsNormalized: !0,
|
|
6081
6165
|
previewId: e != null ? e : n.previewId
|
|
6082
6166
|
});
|
|
6083
6167
|
return {
|
|
6084
|
-
id: t != null ? t : `template-${
|
|
6085
|
-
meta:
|
|
6168
|
+
id: t != null ? t : `template-${tt()}`,
|
|
6169
|
+
meta: C,
|
|
6086
6170
|
objects: M
|
|
6087
6171
|
};
|
|
6088
6172
|
}
|
|
@@ -6090,87 +6174,85 @@ class Y {
|
|
|
6090
6174
|
* Применяет шаблон к монтажной области без очистки текущих объектов.
|
|
6091
6175
|
* @param options
|
|
6092
6176
|
* @param options.template - описание шаблона
|
|
6093
|
-
* @param options.data - данные для заполнения текстов по customData.templateField
|
|
6094
6177
|
*/
|
|
6095
|
-
applyTemplate(
|
|
6178
|
+
applyTemplate(e) {
|
|
6096
6179
|
return Z(this, arguments, function* ({
|
|
6097
|
-
template: t
|
|
6098
|
-
data: e
|
|
6180
|
+
template: t
|
|
6099
6181
|
}) {
|
|
6100
6182
|
const {
|
|
6101
|
-
canvas:
|
|
6102
|
-
montageArea:
|
|
6103
|
-
historyManager:
|
|
6104
|
-
errorManager:
|
|
6105
|
-
backgroundManager:
|
|
6106
|
-
} = this.editor, { objects:
|
|
6107
|
-
if (!(
|
|
6108
|
-
return
|
|
6183
|
+
canvas: n,
|
|
6184
|
+
montageArea: s,
|
|
6185
|
+
historyManager: o,
|
|
6186
|
+
errorManager: i,
|
|
6187
|
+
backgroundManager: a
|
|
6188
|
+
} = this.editor, { objects: r, meta: c, id: l } = t != null ? t : {};
|
|
6189
|
+
if (!(r != null && r.length))
|
|
6190
|
+
return i.emitWarning({
|
|
6109
6191
|
origin: "TemplateManager",
|
|
6110
6192
|
method: "applyTemplate",
|
|
6111
6193
|
code: Tt.TEMPLATE_MANAGER.INVALID_TEMPLATE,
|
|
6112
6194
|
message: "Шаблон не содержит объектов"
|
|
6113
6195
|
}), null;
|
|
6114
|
-
const
|
|
6115
|
-
if (!
|
|
6116
|
-
return
|
|
6196
|
+
const h = H._getBounds(s);
|
|
6197
|
+
if (!h)
|
|
6198
|
+
return i.emitWarning({
|
|
6117
6199
|
origin: "TemplateManager",
|
|
6118
6200
|
method: "applyTemplate",
|
|
6119
6201
|
code: Tt.TEMPLATE_MANAGER.INVALID_TARGET,
|
|
6120
6202
|
message: "Не удалось определить границы монтажной области"
|
|
6121
6203
|
}), null;
|
|
6122
|
-
const
|
|
6123
|
-
let
|
|
6124
|
-
|
|
6204
|
+
const u = H._getMontageSize({ montageArea: s, bounds: h }), f = H._normalizeMeta({ meta: c, fallback: u }), p = H._calculateScale({ meta: f, target: u }), m = !!f.positionsNormalized;
|
|
6205
|
+
let g = !1, v = !1;
|
|
6206
|
+
o.suspendHistory();
|
|
6125
6207
|
try {
|
|
6126
|
-
const
|
|
6127
|
-
if (!
|
|
6128
|
-
return
|
|
6208
|
+
const M = yield H._enlivenObjects(r);
|
|
6209
|
+
if (!M.length)
|
|
6210
|
+
return i.emitWarning({
|
|
6129
6211
|
origin: "TemplateManager",
|
|
6130
6212
|
method: "applyTemplate",
|
|
6131
6213
|
code: Tt.TEMPLATE_MANAGER.INVALID_TEMPLATE,
|
|
6132
6214
|
message: "Не удалось создать объекты шаблона"
|
|
6133
6215
|
}), null;
|
|
6134
|
-
const { backgroundObject:
|
|
6135
|
-
|
|
6136
|
-
backgroundObject:
|
|
6137
|
-
backgroundManager:
|
|
6138
|
-
errorManager:
|
|
6216
|
+
const { backgroundObject: C, contentObjects: y } = H._extractBackgroundObject(M);
|
|
6217
|
+
C && (v = yield H._applyBackgroundFromObject({
|
|
6218
|
+
backgroundObject: C,
|
|
6219
|
+
backgroundManager: a,
|
|
6220
|
+
errorManager: i
|
|
6139
6221
|
}));
|
|
6140
|
-
const
|
|
6141
|
-
object:
|
|
6142
|
-
baseWidth:
|
|
6143
|
-
}),
|
|
6144
|
-
object:
|
|
6145
|
-
scale:
|
|
6146
|
-
bounds:
|
|
6147
|
-
targetSize:
|
|
6148
|
-
baseWidth:
|
|
6149
|
-
baseHeight:
|
|
6150
|
-
montageArea:
|
|
6151
|
-
useRelativePositions:
|
|
6152
|
-
}),
|
|
6153
|
-
id: `${
|
|
6222
|
+
const w = y.map((j) => (this._adaptTextboxWidth({
|
|
6223
|
+
object: j,
|
|
6224
|
+
baseWidth: f.baseWidth
|
|
6225
|
+
}), H._transformObject({
|
|
6226
|
+
object: j,
|
|
6227
|
+
scale: p,
|
|
6228
|
+
bounds: h,
|
|
6229
|
+
targetSize: u,
|
|
6230
|
+
baseWidth: f.baseWidth,
|
|
6231
|
+
baseHeight: f.baseHeight,
|
|
6232
|
+
montageArea: s,
|
|
6233
|
+
useRelativePositions: m
|
|
6234
|
+
}), j.set({
|
|
6235
|
+
id: `${j.type}-${tt()}`,
|
|
6154
6236
|
evented: !0
|
|
6155
|
-
}),
|
|
6156
|
-
return !
|
|
6237
|
+
}), n.add(j), j));
|
|
6238
|
+
return !w.length && !v ? null : (g = w.length > 0 || v, w.length && H._activateObjects({ canvas: n, objects: w }), n.requestRenderAll(), n.fire("editor:template-applied", {
|
|
6157
6239
|
template: t,
|
|
6158
|
-
objects:
|
|
6159
|
-
bounds:
|
|
6160
|
-
}),
|
|
6161
|
-
} catch (
|
|
6162
|
-
return
|
|
6240
|
+
objects: w,
|
|
6241
|
+
bounds: h
|
|
6242
|
+
}), w);
|
|
6243
|
+
} catch (M) {
|
|
6244
|
+
return i.emitError({
|
|
6163
6245
|
origin: "TemplateManager",
|
|
6164
6246
|
method: "applyTemplate",
|
|
6165
6247
|
code: Tt.TEMPLATE_MANAGER.APPLY_FAILED,
|
|
6166
6248
|
message: "Ошибка применения шаблона",
|
|
6167
6249
|
data: {
|
|
6168
|
-
templateId:
|
|
6169
|
-
error:
|
|
6250
|
+
templateId: l,
|
|
6251
|
+
error: M
|
|
6170
6252
|
}
|
|
6171
6253
|
}), null;
|
|
6172
6254
|
} finally {
|
|
6173
|
-
|
|
6255
|
+
o.resumeHistory(), g && o.saveState();
|
|
6174
6256
|
}
|
|
6175
6257
|
});
|
|
6176
6258
|
}
|
|
@@ -6204,13 +6286,13 @@ class Y {
|
|
|
6204
6286
|
static _enlivenObjects(t) {
|
|
6205
6287
|
return Z(this, null, function* () {
|
|
6206
6288
|
return (yield Promise.all(t.map((n) => Z(null, null, function* () {
|
|
6207
|
-
if (
|
|
6208
|
-
const i = yield
|
|
6289
|
+
if (H._hasSerializedSvgMarkup(n)) {
|
|
6290
|
+
const i = yield H._reviveSvgObject(n);
|
|
6209
6291
|
if (i)
|
|
6210
|
-
return
|
|
6292
|
+
return H._restoreImageScale({ revived: i, serialized: n }), i;
|
|
6211
6293
|
}
|
|
6212
|
-
const s = yield
|
|
6213
|
-
return o ? (
|
|
6294
|
+
const s = yield ft.enlivenObjects([n]), o = s == null ? void 0 : s[0];
|
|
6295
|
+
return o ? (H._restoreImageScale({ revived: o, serialized: n }), o) : null;
|
|
6214
6296
|
})))).filter((n) => !!n);
|
|
6215
6297
|
});
|
|
6216
6298
|
}
|
|
@@ -6232,28 +6314,28 @@ class Y {
|
|
|
6232
6314
|
naturalWidth: h = 0,
|
|
6233
6315
|
naturalHeight: u = 0,
|
|
6234
6316
|
width: f = 0,
|
|
6235
|
-
height:
|
|
6317
|
+
height: p = 0
|
|
6236
6318
|
} = l instanceof HTMLImageElement ? l : {
|
|
6237
6319
|
naturalWidth: 0,
|
|
6238
6320
|
naturalHeight: 0,
|
|
6239
6321
|
width: 0,
|
|
6240
6322
|
height: 0
|
|
6241
|
-
}, m =
|
|
6242
|
-
if (
|
|
6323
|
+
}, m = et({ value: h || f || c.width, fallback: 0 }), g = et({ value: u || p || c.height, fallback: 0 }), v = et({ value: s, fallback: m }), M = et({ value: o, fallback: g }), C = et({ value: i, fallback: c.scaleX || 1 }), y = et({ value: a, fallback: c.scaleY || 1 }), w = v * C, j = M * y, T = m > 0, b = g > 0, A = w > 0, S = j > 0, I = H._resolveImageFit({ customData: r }), O = {};
|
|
6324
|
+
if (T && (O.width = m), b && (O.height = g), !T || !b) {
|
|
6243
6325
|
c.set(O);
|
|
6244
6326
|
return;
|
|
6245
6327
|
}
|
|
6246
|
-
if (
|
|
6247
|
-
const
|
|
6248
|
-
|
|
6328
|
+
if (I === "stretch") {
|
|
6329
|
+
const W = A ? w / m : null, z = S ? j / g : null;
|
|
6330
|
+
W && W > 0 && (O.scaleX = W), z && z > 0 && (O.scaleY = z), c.set(O);
|
|
6249
6331
|
return;
|
|
6250
6332
|
}
|
|
6251
6333
|
if (!A || !S) {
|
|
6252
6334
|
c.set(O);
|
|
6253
6335
|
return;
|
|
6254
6336
|
}
|
|
6255
|
-
const
|
|
6256
|
-
Number.isFinite(
|
|
6337
|
+
const N = Math.min(w / m, j / g);
|
|
6338
|
+
Number.isFinite(N) && N > 0 && (O.scaleX = N, O.scaleY = N), c.set(O);
|
|
6257
6339
|
}
|
|
6258
6340
|
/**
|
|
6259
6341
|
* Определяет режим вписывания изображения при восстановлении.
|
|
@@ -6279,8 +6361,8 @@ class Y {
|
|
|
6279
6361
|
const e = typeof t.svgMarkup == "string" ? t.svgMarkup : null;
|
|
6280
6362
|
if (!e) return null;
|
|
6281
6363
|
try {
|
|
6282
|
-
const n = yield
|
|
6283
|
-
|
|
6364
|
+
const n = yield On(e), s = ft.groupSVGElements(n.objects, n.options), o = yield ft.enlivenObjectEnlivables(
|
|
6365
|
+
H._prepareSerializableProps(t)
|
|
6284
6366
|
);
|
|
6285
6367
|
return s.set(o), s.setCoords(), s;
|
|
6286
6368
|
} catch (n) {
|
|
@@ -6292,7 +6374,7 @@ class Y {
|
|
|
6292
6374
|
* Убирает технические поля сериализации, оставляя только применимые свойства.
|
|
6293
6375
|
*/
|
|
6294
6376
|
static _prepareSerializableProps(t) {
|
|
6295
|
-
const e =
|
|
6377
|
+
const e = x({}, t);
|
|
6296
6378
|
return delete e.svgMarkup, delete e.objects, delete e.path, delete e.paths, delete e.type, delete e.version, e;
|
|
6297
6379
|
}
|
|
6298
6380
|
/**
|
|
@@ -6338,34 +6420,34 @@ class Y {
|
|
|
6338
6420
|
montageArea: a,
|
|
6339
6421
|
useRelativePositions: r
|
|
6340
6422
|
}) {
|
|
6341
|
-
const c = t, { x: l, y: h } =
|
|
6423
|
+
const c = t, { x: l, y: h } = Ds({
|
|
6342
6424
|
object: t,
|
|
6343
6425
|
baseWidth: o,
|
|
6344
6426
|
baseHeight: i,
|
|
6345
6427
|
useRelativePositions: r,
|
|
6346
6428
|
centerKeys: {
|
|
6347
6429
|
x: qt,
|
|
6348
|
-
y:
|
|
6430
|
+
y: Se
|
|
6349
6431
|
}
|
|
6350
|
-
}), { scaleX: u, scaleY: f } = t,
|
|
6432
|
+
}), { scaleX: u, scaleY: f } = t, p = et({ value: u, fallback: 1 }), m = et({ value: f, fallback: 1 }), g = H._getPositioningBounds({
|
|
6351
6433
|
bounds: n,
|
|
6352
6434
|
baseWidth: o,
|
|
6353
6435
|
baseHeight: i,
|
|
6354
6436
|
scale: e,
|
|
6355
6437
|
useRelativePositions: r,
|
|
6356
|
-
anchorX:
|
|
6357
|
-
anchorY:
|
|
6358
|
-
}), v =
|
|
6438
|
+
anchorX: H._resolveAnchor(c, le),
|
|
6439
|
+
anchorY: H._resolveAnchor(c, we)
|
|
6440
|
+
}), v = _s({
|
|
6359
6441
|
normalizedX: l,
|
|
6360
6442
|
normalizedY: h,
|
|
6361
|
-
bounds:
|
|
6443
|
+
bounds: g,
|
|
6362
6444
|
targetSize: s,
|
|
6363
6445
|
montageArea: a
|
|
6364
|
-
}), M =
|
|
6446
|
+
}), M = p * e, C = m * e;
|
|
6365
6447
|
t.set({
|
|
6366
6448
|
scaleX: M,
|
|
6367
|
-
scaleY:
|
|
6368
|
-
}), t.setPositionByOrigin(v, "center", "center"), t.setCoords(), delete c[qt], delete c[
|
|
6449
|
+
scaleY: C
|
|
6450
|
+
}), t.setPositionByOrigin(v, "center", "center"), t.setCoords(), delete c[qt], delete c[Se], delete c[le], delete c[we];
|
|
6369
6451
|
}
|
|
6370
6452
|
/**
|
|
6371
6453
|
* Возвращает bounds, в которых должны позиционироваться нормализованные объекты.
|
|
@@ -6381,7 +6463,7 @@ class Y {
|
|
|
6381
6463
|
anchorY: a
|
|
6382
6464
|
}) {
|
|
6383
6465
|
if (!o) return t;
|
|
6384
|
-
const r = (e || t.width) * s, c = (n || t.height) * s, l = t.width - r, h = t.height - c, u = t.left +
|
|
6466
|
+
const r = (e || t.width) * s, c = (n || t.height) * s, l = t.width - r, h = t.height - c, u = t.left + H._calculateAnchorOffset(i, l), f = t.top + H._calculateAnchorOffset(a, h);
|
|
6385
6467
|
return {
|
|
6386
6468
|
left: u,
|
|
6387
6469
|
top: f,
|
|
@@ -6413,7 +6495,7 @@ class Y {
|
|
|
6413
6495
|
fallback: e
|
|
6414
6496
|
}) {
|
|
6415
6497
|
const { width: n, height: s } = e, r = t || {}, { baseWidth: o = n, baseHeight: i = s } = r, a = Mt(r, ["baseWidth", "baseHeight"]);
|
|
6416
|
-
return
|
|
6498
|
+
return x({
|
|
6417
6499
|
baseWidth: o,
|
|
6418
6500
|
baseHeight: i
|
|
6419
6501
|
}, a);
|
|
@@ -6454,26 +6536,26 @@ class Y {
|
|
|
6454
6536
|
if (!(t instanceof dt)) return;
|
|
6455
6537
|
const n = typeof t.text == "string" ? t.text : "";
|
|
6456
6538
|
if (!n) return;
|
|
6457
|
-
const s =
|
|
6539
|
+
const s = et({
|
|
6458
6540
|
value: (B = (E = this.editor) == null ? void 0 : E.montageArea) == null ? void 0 : B.width,
|
|
6459
6541
|
fallback: 0
|
|
6460
6542
|
}), {
|
|
6461
6543
|
width: o = 0,
|
|
6462
6544
|
scaleX: i = 1,
|
|
6463
6545
|
strokeWidth: a = 0
|
|
6464
|
-
} = t, r =
|
|
6465
|
-
if (!s || !
|
|
6546
|
+
} = t, r = et({ value: e, fallback: 0 }), c = t, l = et({ value: c.paddingLeft, fallback: 0 }), h = et({ value: c.paddingRight, fallback: 0 }), u = et({ value: i, fallback: 1 }), f = et({ value: a, fallback: 0 }) * u, p = et({ value: o, fallback: 0 }), m = p * u, g = l * u, v = h * u, M = m + g + v + f;
|
|
6547
|
+
if (!s || !p || !r) return;
|
|
6466
6548
|
t.setCoords();
|
|
6467
|
-
const
|
|
6549
|
+
const C = t, y = C[qt], w = typeof y == "number" ? y : null, j = H._resolveAnchor(C, le), T = M / r, b = w !== null ? w - T / 2 : null, A = w !== null ? w + T / 2 : null, S = t.getCenterPoint();
|
|
6468
6550
|
t.set("width", s), t.initDimensions();
|
|
6469
|
-
const
|
|
6551
|
+
const I = H._getLongestLineWidth({
|
|
6470
6552
|
textbox: t,
|
|
6471
6553
|
text: n
|
|
6472
|
-
}), O =
|
|
6554
|
+
}), O = I > p ? I + 1 : p;
|
|
6473
6555
|
t.set("width", O), t.initDimensions(), t.setPositionByOrigin(S, "center", "center"), t.setCoords();
|
|
6474
|
-
const
|
|
6475
|
-
let
|
|
6476
|
-
|
|
6556
|
+
const W = (O * u + g + v + f) / r;
|
|
6557
|
+
let z = w;
|
|
6558
|
+
j === "start" && b !== null ? z = Math.max(0, b) + W / 2 : j === "end" && A !== null && (z = Math.min(1, A) - W / 2), typeof z == "number" && (C[qt] = z);
|
|
6477
6559
|
}
|
|
6478
6560
|
/**
|
|
6479
6561
|
* Возвращает ширину самой длинной строки текстового объекта.
|
|
@@ -6503,9 +6585,9 @@ class Y {
|
|
|
6503
6585
|
baseHeight: s,
|
|
6504
6586
|
montageArea: o
|
|
6505
6587
|
}) {
|
|
6506
|
-
const i = t.toDatalessObject([...
|
|
6507
|
-
if (
|
|
6508
|
-
const y =
|
|
6588
|
+
const i = t.toDatalessObject([...Oe]);
|
|
6589
|
+
if (H._isSvgObject(t)) {
|
|
6590
|
+
const y = H._extractSvgMarkup(t);
|
|
6509
6591
|
y && (i.svgMarkup = y, delete i.objects, delete i.path);
|
|
6510
6592
|
}
|
|
6511
6593
|
if (!e) return i;
|
|
@@ -6514,26 +6596,26 @@ class Y {
|
|
|
6514
6596
|
top: r,
|
|
6515
6597
|
width: c,
|
|
6516
6598
|
height: l
|
|
6517
|
-
} = e, h = t.getBoundingRect(!1, !0), u = n || c || 1, f = s || l || 1,
|
|
6599
|
+
} = e, h = t.getBoundingRect(!1, !0), u = n || c || 1, f = s || l || 1, p = xs({
|
|
6518
6600
|
object: t,
|
|
6519
6601
|
montageArea: o,
|
|
6520
6602
|
bounds: e
|
|
6521
|
-
}), m =
|
|
6603
|
+
}), m = p != null ? p : (() => {
|
|
6522
6604
|
const y = t.getCenterPoint();
|
|
6523
6605
|
return {
|
|
6524
6606
|
x: (y.x - a) / u,
|
|
6525
6607
|
y: (y.y - r) / f
|
|
6526
6608
|
};
|
|
6527
|
-
})(),
|
|
6528
|
-
return i[qt] = m.x, i[
|
|
6609
|
+
})(), g = (h.left - a) / u, v = (h.top - r) / f, M = g + h.width / u, C = v + h.height / f;
|
|
6610
|
+
return i[qt] = m.x, i[Se] = m.y, i[le] = H._detectAnchor({
|
|
6529
6611
|
center: m.x,
|
|
6530
|
-
start:
|
|
6612
|
+
start: g,
|
|
6531
6613
|
end: M
|
|
6532
|
-
}), i[
|
|
6614
|
+
}), i[we] = H._detectAnchor({
|
|
6533
6615
|
center: m.y,
|
|
6534
6616
|
start: v,
|
|
6535
|
-
end:
|
|
6536
|
-
}), i.left =
|
|
6617
|
+
end: C
|
|
6618
|
+
}), i.left = g, i.top = v, i;
|
|
6537
6619
|
}
|
|
6538
6620
|
/**
|
|
6539
6621
|
* Делит список объектов на фон и контент по id === 'background'.
|
|
@@ -6555,7 +6637,7 @@ class Y {
|
|
|
6555
6637
|
errorManager: n
|
|
6556
6638
|
}) {
|
|
6557
6639
|
try {
|
|
6558
|
-
const { fill: o, customData: i } = t, { backgroundType: a } = t, r =
|
|
6640
|
+
const { fill: o, customData: i } = t, { backgroundType: a } = t, r = H._cloneCustomData(i);
|
|
6559
6641
|
if (a === "color" && typeof o == "string")
|
|
6560
6642
|
return e.setColorBackground({
|
|
6561
6643
|
color: o,
|
|
@@ -6564,7 +6646,7 @@ class Y {
|
|
|
6564
6646
|
withoutSave: !0
|
|
6565
6647
|
}), !0;
|
|
6566
6648
|
if (a === "gradient") {
|
|
6567
|
-
const c =
|
|
6649
|
+
const c = ks(o);
|
|
6568
6650
|
if (c)
|
|
6569
6651
|
return e.setGradientBackground({
|
|
6570
6652
|
gradient: c,
|
|
@@ -6574,7 +6656,7 @@ class Y {
|
|
|
6574
6656
|
}), !0;
|
|
6575
6657
|
}
|
|
6576
6658
|
if (a === "image") {
|
|
6577
|
-
const c =
|
|
6659
|
+
const c = H._getImageSource(t);
|
|
6578
6660
|
if (c)
|
|
6579
6661
|
return yield e.setImageBackground({
|
|
6580
6662
|
imageSource: c,
|
|
@@ -6617,7 +6699,7 @@ class Y {
|
|
|
6617
6699
|
*/
|
|
6618
6700
|
static _cloneCustomData(t) {
|
|
6619
6701
|
if (!(!t || typeof t != "object"))
|
|
6620
|
-
return
|
|
6702
|
+
return x({}, t);
|
|
6621
6703
|
}
|
|
6622
6704
|
/**
|
|
6623
6705
|
* Извлекает src изображения из FabricImage или его исходного элемента.
|
|
@@ -6643,10 +6725,10 @@ class Y {
|
|
|
6643
6725
|
*/
|
|
6644
6726
|
// eslint-disable-next-line class-methods-use-this
|
|
6645
6727
|
enlivenObjectEnlivables(t) {
|
|
6646
|
-
return
|
|
6728
|
+
return ft.enlivenObjectEnlivables(t);
|
|
6647
6729
|
}
|
|
6648
6730
|
}
|
|
6649
|
-
const
|
|
6731
|
+
const Ns = 5, mn = "#3D8BF4", De = 1, de = 1, dn = ({
|
|
6650
6732
|
anchors: d,
|
|
6651
6733
|
positions: t,
|
|
6652
6734
|
threshold: e
|
|
@@ -6661,16 +6743,16 @@ const ks = 5, pn = "#3D8BF4", Oe = 1, de = 1, ln = ({
|
|
|
6661
6743
|
delta: n,
|
|
6662
6744
|
guidePosition: o
|
|
6663
6745
|
};
|
|
6664
|
-
},
|
|
6746
|
+
}, Bs = ({
|
|
6665
6747
|
activeBounds: d,
|
|
6666
6748
|
threshold: t,
|
|
6667
6749
|
anchors: e
|
|
6668
6750
|
}) => {
|
|
6669
|
-
const { left: n, right: s, centerX: o, top: i, bottom: a, centerY: r } = d, c =
|
|
6751
|
+
const { left: n, right: s, centerX: o, top: i, bottom: a, centerY: r } = d, c = dn({
|
|
6670
6752
|
anchors: e.vertical,
|
|
6671
6753
|
positions: [n, o, s],
|
|
6672
6754
|
threshold: t
|
|
6673
|
-
}), l =
|
|
6755
|
+
}), l = dn({
|
|
6674
6756
|
anchors: e.horizontal,
|
|
6675
6757
|
positions: [i, r, a],
|
|
6676
6758
|
threshold: t
|
|
@@ -6686,7 +6768,7 @@ const ks = 5, pn = "#3D8BF4", Oe = 1, de = 1, ln = ({
|
|
|
6686
6768
|
deltaY: l.delta,
|
|
6687
6769
|
guides: h
|
|
6688
6770
|
};
|
|
6689
|
-
},
|
|
6771
|
+
}, yn = ({
|
|
6690
6772
|
activeBounds: d,
|
|
6691
6773
|
aligned: t,
|
|
6692
6774
|
threshold: e,
|
|
@@ -6705,7 +6787,7 @@ const ks = 5, pn = "#3D8BF4", Oe = 1, de = 1, ln = ({
|
|
|
6705
6787
|
if (s === "vertical") {
|
|
6706
6788
|
const u = o - h.bottom, f = Math.abs(u - l.distance);
|
|
6707
6789
|
if (f <= e) {
|
|
6708
|
-
const
|
|
6790
|
+
const g = l.distance - u, v = {
|
|
6709
6791
|
type: s,
|
|
6710
6792
|
axis: l.axis,
|
|
6711
6793
|
refStart: l.start,
|
|
@@ -6714,11 +6796,11 @@ const ks = 5, pn = "#3D8BF4", Oe = 1, de = 1, ln = ({
|
|
|
6714
6796
|
activeEnd: h.bottom + l.distance,
|
|
6715
6797
|
distance: l.distance
|
|
6716
6798
|
};
|
|
6717
|
-
c.push({ delta:
|
|
6799
|
+
c.push({ delta: g, guide: v, diff: f });
|
|
6718
6800
|
}
|
|
6719
|
-
const
|
|
6801
|
+
const p = h.top - i, m = Math.abs(p - l.distance);
|
|
6720
6802
|
if (m <= e) {
|
|
6721
|
-
const
|
|
6803
|
+
const g = l.distance - p, v = {
|
|
6722
6804
|
type: s,
|
|
6723
6805
|
axis: l.axis,
|
|
6724
6806
|
refStart: l.start,
|
|
@@ -6727,12 +6809,12 @@ const ks = 5, pn = "#3D8BF4", Oe = 1, de = 1, ln = ({
|
|
|
6727
6809
|
activeEnd: h.top,
|
|
6728
6810
|
distance: l.distance
|
|
6729
6811
|
};
|
|
6730
|
-
c.push({ delta:
|
|
6812
|
+
c.push({ delta: g, guide: v, diff: m });
|
|
6731
6813
|
}
|
|
6732
6814
|
} else {
|
|
6733
6815
|
const u = a - h.right, f = Math.abs(u - l.distance);
|
|
6734
6816
|
if (f <= e) {
|
|
6735
|
-
const
|
|
6817
|
+
const g = l.distance - u, v = {
|
|
6736
6818
|
type: s,
|
|
6737
6819
|
axis: l.axis,
|
|
6738
6820
|
refStart: l.start,
|
|
@@ -6741,11 +6823,11 @@ const ks = 5, pn = "#3D8BF4", Oe = 1, de = 1, ln = ({
|
|
|
6741
6823
|
activeEnd: h.right + l.distance,
|
|
6742
6824
|
distance: l.distance
|
|
6743
6825
|
};
|
|
6744
|
-
c.push({ delta:
|
|
6826
|
+
c.push({ delta: g, guide: v, diff: f });
|
|
6745
6827
|
}
|
|
6746
|
-
const
|
|
6828
|
+
const p = h.left - r, m = Math.abs(p - l.distance);
|
|
6747
6829
|
if (m <= e) {
|
|
6748
|
-
const
|
|
6830
|
+
const g = l.distance - p, v = {
|
|
6749
6831
|
type: s,
|
|
6750
6832
|
axis: l.axis,
|
|
6751
6833
|
refStart: l.start,
|
|
@@ -6754,11 +6836,11 @@ const ks = 5, pn = "#3D8BF4", Oe = 1, de = 1, ln = ({
|
|
|
6754
6836
|
activeEnd: h.left,
|
|
6755
6837
|
distance: l.distance
|
|
6756
6838
|
};
|
|
6757
|
-
c.push({ delta:
|
|
6839
|
+
c.push({ delta: g, guide: v, diff: m });
|
|
6758
6840
|
}
|
|
6759
6841
|
}
|
|
6760
6842
|
return c;
|
|
6761
|
-
},
|
|
6843
|
+
}, zs = ({
|
|
6762
6844
|
activeBounds: d,
|
|
6763
6845
|
candidates: t,
|
|
6764
6846
|
threshold: e,
|
|
@@ -6781,70 +6863,70 @@ const ks = 5, pn = "#3D8BF4", Oe = 1, de = 1, ln = ({
|
|
|
6781
6863
|
const h = l.findIndex((y) => y.isActive);
|
|
6782
6864
|
if (h === -1)
|
|
6783
6865
|
return { delta: 0, guide: null };
|
|
6784
|
-
const u = l[h - 1], f = l[h - 2],
|
|
6866
|
+
const u = l[h - 1], f = l[h - 2], p = l[h + 1], m = l[h + 2], g = [], v = i - o;
|
|
6785
6867
|
if (u && f) {
|
|
6786
|
-
const { bounds: y } = u, { bounds: w } = f,
|
|
6868
|
+
const { bounds: y } = u, { bounds: w } = f, j = y.top - w.bottom, T = o - y.bottom, b = Math.abs(T - j);
|
|
6787
6869
|
if (b <= e) {
|
|
6788
|
-
const A =
|
|
6870
|
+
const A = j - T, S = o + A, I = {
|
|
6789
6871
|
type: "vertical",
|
|
6790
6872
|
axis: s,
|
|
6791
6873
|
refStart: w.bottom,
|
|
6792
6874
|
refEnd: y.top,
|
|
6793
6875
|
activeStart: y.bottom,
|
|
6794
6876
|
activeEnd: S,
|
|
6795
|
-
distance:
|
|
6877
|
+
distance: j
|
|
6796
6878
|
};
|
|
6797
|
-
|
|
6879
|
+
g.push({ delta: A, guide: I, diff: b });
|
|
6798
6880
|
}
|
|
6799
6881
|
}
|
|
6800
|
-
if (
|
|
6801
|
-
const { bounds: y } =
|
|
6882
|
+
if (p && m) {
|
|
6883
|
+
const { bounds: y } = p, { bounds: w } = m, j = w.top - y.bottom, T = y.top - i, b = Math.abs(T - j);
|
|
6802
6884
|
if (b <= e) {
|
|
6803
|
-
const A =
|
|
6885
|
+
const A = T - j, S = i + A, I = {
|
|
6804
6886
|
type: "vertical",
|
|
6805
6887
|
axis: s,
|
|
6806
6888
|
refStart: y.bottom,
|
|
6807
6889
|
refEnd: w.top,
|
|
6808
6890
|
activeStart: S,
|
|
6809
6891
|
activeEnd: y.top,
|
|
6810
|
-
distance:
|
|
6892
|
+
distance: j
|
|
6811
6893
|
};
|
|
6812
|
-
|
|
6894
|
+
g.push({ delta: A, guide: I, diff: b });
|
|
6813
6895
|
}
|
|
6814
6896
|
}
|
|
6815
|
-
if (u &&
|
|
6816
|
-
const { bounds: y } = u, { bounds: w } =
|
|
6817
|
-
if (
|
|
6818
|
-
const b =
|
|
6819
|
-
if (
|
|
6820
|
-
const
|
|
6897
|
+
if (u && p) {
|
|
6898
|
+
const { bounds: y } = u, { bounds: w } = p, T = w.top - y.bottom - v;
|
|
6899
|
+
if (T >= 0) {
|
|
6900
|
+
const b = T / 2, A = o - y.bottom, S = w.top - i, I = Math.abs(A - b), O = Math.abs(S - b), N = Math.max(I, O);
|
|
6901
|
+
if (N <= e) {
|
|
6902
|
+
const W = b - A, z = i + W, E = {
|
|
6821
6903
|
type: "vertical",
|
|
6822
6904
|
axis: s,
|
|
6823
6905
|
refStart: y.bottom,
|
|
6824
6906
|
refEnd: y.bottom + b,
|
|
6825
|
-
activeStart:
|
|
6826
|
-
activeEnd:
|
|
6907
|
+
activeStart: z,
|
|
6908
|
+
activeEnd: z + b,
|
|
6827
6909
|
distance: b
|
|
6828
6910
|
};
|
|
6829
|
-
|
|
6911
|
+
g.push({ delta: W, guide: E, diff: N });
|
|
6830
6912
|
}
|
|
6831
6913
|
}
|
|
6832
6914
|
}
|
|
6833
|
-
const M =
|
|
6915
|
+
const M = yn({
|
|
6834
6916
|
activeBounds: d,
|
|
6835
6917
|
aligned: c,
|
|
6836
6918
|
threshold: e,
|
|
6837
6919
|
patterns: n,
|
|
6838
6920
|
type: "vertical"
|
|
6839
6921
|
});
|
|
6840
|
-
if (
|
|
6922
|
+
if (g.push(...M), !g.length)
|
|
6841
6923
|
return { delta: 0, guide: null };
|
|
6842
|
-
const
|
|
6924
|
+
const C = g.reduce((y, w) => w.diff < y.diff ? w : y, g[0]);
|
|
6843
6925
|
return {
|
|
6844
|
-
delta:
|
|
6845
|
-
guide:
|
|
6926
|
+
delta: C.delta,
|
|
6927
|
+
guide: C.guide
|
|
6846
6928
|
};
|
|
6847
|
-
},
|
|
6929
|
+
}, Ps = ({
|
|
6848
6930
|
activeBounds: d,
|
|
6849
6931
|
candidates: t,
|
|
6850
6932
|
threshold: e,
|
|
@@ -6867,81 +6949,81 @@ const ks = 5, pn = "#3D8BF4", Oe = 1, de = 1, ln = ({
|
|
|
6867
6949
|
const h = l.findIndex((y) => y.isActive);
|
|
6868
6950
|
if (h === -1)
|
|
6869
6951
|
return { delta: 0, guide: null };
|
|
6870
|
-
const u = l[h - 1], f = l[h - 2],
|
|
6952
|
+
const u = l[h - 1], f = l[h - 2], p = l[h + 1], m = l[h + 2], g = [], v = i - o;
|
|
6871
6953
|
if (u && f) {
|
|
6872
|
-
const { bounds: y } = u, { bounds: w } = f,
|
|
6954
|
+
const { bounds: y } = u, { bounds: w } = f, j = y.left - w.right, T = o - y.right, b = Math.abs(T - j);
|
|
6873
6955
|
if (b <= e) {
|
|
6874
|
-
const A =
|
|
6956
|
+
const A = j - T, S = o + A, I = {
|
|
6875
6957
|
type: "horizontal",
|
|
6876
6958
|
axis: s,
|
|
6877
6959
|
refStart: w.right,
|
|
6878
6960
|
refEnd: y.left,
|
|
6879
6961
|
activeStart: y.right,
|
|
6880
6962
|
activeEnd: S,
|
|
6881
|
-
distance:
|
|
6963
|
+
distance: j
|
|
6882
6964
|
};
|
|
6883
|
-
|
|
6965
|
+
g.push({ delta: A, guide: I, diff: b });
|
|
6884
6966
|
}
|
|
6885
6967
|
}
|
|
6886
|
-
if (
|
|
6887
|
-
const { bounds: y } =
|
|
6968
|
+
if (p && m) {
|
|
6969
|
+
const { bounds: y } = p, { bounds: w } = m, j = w.left - y.right, T = y.left - i, b = Math.abs(T - j);
|
|
6888
6970
|
if (b <= e) {
|
|
6889
|
-
const A =
|
|
6971
|
+
const A = T - j, S = i + A, I = {
|
|
6890
6972
|
type: "horizontal",
|
|
6891
6973
|
axis: s,
|
|
6892
6974
|
refStart: y.right,
|
|
6893
6975
|
refEnd: w.left,
|
|
6894
6976
|
activeStart: S,
|
|
6895
6977
|
activeEnd: y.left,
|
|
6896
|
-
distance:
|
|
6978
|
+
distance: j
|
|
6897
6979
|
};
|
|
6898
|
-
|
|
6980
|
+
g.push({ delta: A, guide: I, diff: b });
|
|
6899
6981
|
}
|
|
6900
6982
|
}
|
|
6901
|
-
if (u &&
|
|
6902
|
-
const { bounds: y } = u, { bounds: w } =
|
|
6903
|
-
if (
|
|
6904
|
-
const b =
|
|
6905
|
-
if (
|
|
6906
|
-
const
|
|
6983
|
+
if (u && p) {
|
|
6984
|
+
const { bounds: y } = u, { bounds: w } = p, T = w.left - y.right - v;
|
|
6985
|
+
if (T >= 0) {
|
|
6986
|
+
const b = T / 2, A = o - y.right, S = w.left - i, I = Math.abs(A - b), O = Math.abs(S - b), N = Math.max(I, O);
|
|
6987
|
+
if (N <= e) {
|
|
6988
|
+
const W = b - A, z = i + W, E = {
|
|
6907
6989
|
type: "horizontal",
|
|
6908
6990
|
axis: s,
|
|
6909
6991
|
refStart: y.right,
|
|
6910
6992
|
refEnd: y.right + b,
|
|
6911
|
-
activeStart:
|
|
6912
|
-
activeEnd:
|
|
6993
|
+
activeStart: z,
|
|
6994
|
+
activeEnd: z + b,
|
|
6913
6995
|
distance: b
|
|
6914
6996
|
};
|
|
6915
|
-
|
|
6997
|
+
g.push({ delta: W, guide: E, diff: N });
|
|
6916
6998
|
}
|
|
6917
6999
|
}
|
|
6918
7000
|
}
|
|
6919
|
-
const M =
|
|
7001
|
+
const M = yn({
|
|
6920
7002
|
activeBounds: d,
|
|
6921
7003
|
aligned: c,
|
|
6922
7004
|
threshold: e,
|
|
6923
7005
|
patterns: n,
|
|
6924
7006
|
type: "horizontal"
|
|
6925
7007
|
});
|
|
6926
|
-
if (
|
|
7008
|
+
if (g.push(...M), !g.length)
|
|
6927
7009
|
return { delta: 0, guide: null };
|
|
6928
|
-
const
|
|
7010
|
+
const C = g.reduce((y, w) => w.diff < y.diff ? w : y, g[0]);
|
|
6929
7011
|
return {
|
|
6930
|
-
delta:
|
|
6931
|
-
guide:
|
|
7012
|
+
delta: C.delta,
|
|
7013
|
+
guide: C.guide
|
|
6932
7014
|
};
|
|
6933
|
-
},
|
|
7015
|
+
}, Fs = ({
|
|
6934
7016
|
activeBounds: d,
|
|
6935
7017
|
candidates: t,
|
|
6936
7018
|
threshold: e,
|
|
6937
7019
|
spacingPatterns: n
|
|
6938
7020
|
}) => {
|
|
6939
|
-
const s =
|
|
7021
|
+
const s = zs({
|
|
6940
7022
|
activeBounds: d,
|
|
6941
7023
|
candidates: t,
|
|
6942
7024
|
threshold: e,
|
|
6943
7025
|
patterns: n.vertical
|
|
6944
|
-
}), o =
|
|
7026
|
+
}), o = Ps({
|
|
6945
7027
|
activeBounds: d,
|
|
6946
7028
|
candidates: t,
|
|
6947
7029
|
threshold: e,
|
|
@@ -6952,7 +7034,7 @@ const ks = 5, pn = "#3D8BF4", Oe = 1, de = 1, ln = ({
|
|
|
6952
7034
|
deltaY: s.delta,
|
|
6953
7035
|
guides: i
|
|
6954
7036
|
};
|
|
6955
|
-
},
|
|
7037
|
+
}, Ws = ({
|
|
6956
7038
|
context: d,
|
|
6957
7039
|
x: t,
|
|
6958
7040
|
y: e,
|
|
@@ -6962,7 +7044,7 @@ const ks = 5, pn = "#3D8BF4", Oe = 1, de = 1, ln = ({
|
|
|
6962
7044
|
}) => {
|
|
6963
7045
|
const i = Math.min(o, n / 2, s / 2);
|
|
6964
7046
|
d.moveTo(t + i, e), d.lineTo(t + n - i, e), d.quadraticCurveTo(t + n, e, t + n, e + i), d.lineTo(t + n, e + s - i), d.quadraticCurveTo(t + n, e + s, t + n - i, e + s), d.lineTo(t + i, e + s), d.quadraticCurveTo(t, e + s, t, e + s - i), d.lineTo(t, e + i), d.quadraticCurveTo(t, e, t + i, e), d.closePath();
|
|
6965
|
-
},
|
|
7047
|
+
}, _e = ({
|
|
6966
7048
|
context: d,
|
|
6967
7049
|
type: t,
|
|
6968
7050
|
axis: e,
|
|
@@ -6977,16 +7059,16 @@ const ks = 5, pn = "#3D8BF4", Oe = 1, de = 1, ln = ({
|
|
|
6977
7059
|
padding: h = 4,
|
|
6978
7060
|
radius: u = 4,
|
|
6979
7061
|
offsetAlongAxis: f = 0,
|
|
6980
|
-
offsetPerpendicular:
|
|
7062
|
+
offsetPerpendicular: p = 0
|
|
6981
7063
|
}) => {
|
|
6982
|
-
const m = i || 1,
|
|
6983
|
-
d.save(), d.setLineDash([]), d.fillStyle = a, d.strokeStyle = a, d.lineWidth = l / m, d.font = `${
|
|
6984
|
-
const
|
|
6985
|
-
d.beginPath(),
|
|
7064
|
+
const m = i || 1, g = 12 / m, v = h / m, M = u / m, C = (n + s) / 2 + f, y = t === "vertical" ? e + p : C, w = t === "vertical" ? C : e + p;
|
|
7065
|
+
d.save(), d.setLineDash([]), d.fillStyle = a, d.strokeStyle = a, d.lineWidth = l / m, d.font = `${g}px ${c}`, d.textAlign = "center", d.textBaseline = "middle";
|
|
7066
|
+
const T = d.measureText(o).width + v * 2, b = g + v * 2, A = y - T / 2, S = w - b / 2;
|
|
7067
|
+
d.beginPath(), Ws({
|
|
6986
7068
|
context: d,
|
|
6987
7069
|
x: A,
|
|
6988
7070
|
y: S,
|
|
6989
|
-
width:
|
|
7071
|
+
width: T,
|
|
6990
7072
|
height: b,
|
|
6991
7073
|
radius: M
|
|
6992
7074
|
}), d.fill(), d.fillStyle = r, d.fillText(o, y, w), d.restore();
|
|
@@ -7005,8 +7087,8 @@ const ks = 5, pn = "#3D8BF4", Oe = 1, de = 1, ln = ({
|
|
|
7005
7087
|
distance: c
|
|
7006
7088
|
} = t, l = Math.round(c).toString();
|
|
7007
7089
|
d.beginPath(), n === "vertical" ? (d.moveTo(s, o), d.lineTo(s, i), d.moveTo(s, a), d.lineTo(s, r)) : (d.moveTo(o, s), d.lineTo(i, s), d.moveTo(a, s), d.lineTo(r, s)), d.stroke();
|
|
7008
|
-
const h =
|
|
7009
|
-
|
|
7090
|
+
const h = mn;
|
|
7091
|
+
_e({
|
|
7010
7092
|
context: d,
|
|
7011
7093
|
type: n,
|
|
7012
7094
|
axis: s,
|
|
@@ -7015,8 +7097,8 @@ const ks = 5, pn = "#3D8BF4", Oe = 1, de = 1, ln = ({
|
|
|
7015
7097
|
text: l,
|
|
7016
7098
|
zoom: e,
|
|
7017
7099
|
color: h,
|
|
7018
|
-
lineWidth:
|
|
7019
|
-
}),
|
|
7100
|
+
lineWidth: De
|
|
7101
|
+
}), _e({
|
|
7020
7102
|
context: d,
|
|
7021
7103
|
type: n,
|
|
7022
7104
|
axis: s,
|
|
@@ -7025,9 +7107,9 @@ const ks = 5, pn = "#3D8BF4", Oe = 1, de = 1, ln = ({
|
|
|
7025
7107
|
text: l,
|
|
7026
7108
|
zoom: e,
|
|
7027
7109
|
color: h,
|
|
7028
|
-
lineWidth:
|
|
7110
|
+
lineWidth: De
|
|
7029
7111
|
});
|
|
7030
|
-
},
|
|
7112
|
+
}, hn = ({
|
|
7031
7113
|
anchors: d,
|
|
7032
7114
|
bounds: t
|
|
7033
7115
|
}) => {
|
|
@@ -7040,7 +7122,7 @@ const ks = 5, pn = "#3D8BF4", Oe = 1, de = 1, ln = ({
|
|
|
7040
7122
|
centerY: a
|
|
7041
7123
|
} = t;
|
|
7042
7124
|
d.vertical.push(e, s, n), d.horizontal.push(o, a, i);
|
|
7043
|
-
},
|
|
7125
|
+
}, un = ({
|
|
7044
7126
|
bounds: d,
|
|
7045
7127
|
type: t,
|
|
7046
7128
|
primaryStart: e,
|
|
@@ -7051,46 +7133,46 @@ const ks = 5, pn = "#3D8BF4", Oe = 1, de = 1, ln = ({
|
|
|
7051
7133
|
const c = a[r];
|
|
7052
7134
|
let l = null, h = Number.POSITIVE_INFINITY;
|
|
7053
7135
|
for (let m = r + 1; m < a.length; m += 1) {
|
|
7054
|
-
const
|
|
7055
|
-
if (Math.min(c[i],
|
|
7056
|
-
const M =
|
|
7057
|
-
M < 0 || M < h && (h = M, l =
|
|
7136
|
+
const g = a[m];
|
|
7137
|
+
if (Math.min(c[i], g[i]) - Math.max(c[o], g[o]) < 0) continue;
|
|
7138
|
+
const M = g[e] - c[n];
|
|
7139
|
+
M < 0 || M < h && (h = M, l = g);
|
|
7058
7140
|
}
|
|
7059
7141
|
if (!l || h === Number.POSITIVE_INFINITY) continue;
|
|
7060
|
-
const u = Math.max(c[o], l[o]), f = Math.min(c[i], l[i]),
|
|
7142
|
+
const u = Math.max(c[o], l[o]), f = Math.min(c[i], l[i]), p = (u + f) / 2;
|
|
7061
7143
|
s.push({
|
|
7062
7144
|
type: t,
|
|
7063
|
-
axis:
|
|
7145
|
+
axis: p,
|
|
7064
7146
|
start: c[n],
|
|
7065
7147
|
end: l[e],
|
|
7066
7148
|
distance: l[e] - c[n]
|
|
7067
7149
|
});
|
|
7068
7150
|
}
|
|
7069
7151
|
return s;
|
|
7070
|
-
},
|
|
7152
|
+
}, Ys = ({
|
|
7071
7153
|
bounds: d
|
|
7072
7154
|
}) => {
|
|
7073
|
-
const t =
|
|
7155
|
+
const t = un({
|
|
7074
7156
|
bounds: d,
|
|
7075
7157
|
type: "vertical",
|
|
7076
7158
|
primaryStart: "top",
|
|
7077
7159
|
primaryEnd: "bottom"
|
|
7078
|
-
}), e =
|
|
7160
|
+
}), e = un({
|
|
7079
7161
|
bounds: d,
|
|
7080
7162
|
type: "horizontal",
|
|
7081
7163
|
primaryStart: "left",
|
|
7082
7164
|
primaryEnd: "right"
|
|
7083
7165
|
});
|
|
7084
7166
|
return { vertical: t, horizontal: e };
|
|
7085
|
-
},
|
|
7167
|
+
}, Hs = ["montage-area", "background", "interaction-blocker"], vn = ({
|
|
7086
7168
|
activeObject: d
|
|
7087
7169
|
}) => {
|
|
7088
7170
|
const t = /* @__PURE__ */ new Set();
|
|
7089
7171
|
return d && (t.add(d), d instanceof X && d.getObjects().forEach((e) => t.add(e))), t;
|
|
7090
|
-
},
|
|
7172
|
+
}, bn = ({
|
|
7091
7173
|
object: d,
|
|
7092
7174
|
excluded: t,
|
|
7093
|
-
ignoredIds: e =
|
|
7175
|
+
ignoredIds: e = Hs
|
|
7094
7176
|
}) => {
|
|
7095
7177
|
if (t.has(d)) return !0;
|
|
7096
7178
|
const { visible: n = !0 } = d;
|
|
@@ -7098,7 +7180,7 @@ const ks = 5, pn = "#3D8BF4", Oe = 1, de = 1, ln = ({
|
|
|
7098
7180
|
const { id: s } = d;
|
|
7099
7181
|
return !!(s && e.includes(s));
|
|
7100
7182
|
};
|
|
7101
|
-
class
|
|
7183
|
+
class pe {
|
|
7102
7184
|
/**
|
|
7103
7185
|
* Создаёт менеджер прилипания и инициализирует слушатели событий.
|
|
7104
7186
|
*/
|
|
@@ -7145,14 +7227,14 @@ class Hs {
|
|
|
7145
7227
|
* Выполняет привязку объекта к ближайшим линиям при его перемещении.
|
|
7146
7228
|
*/
|
|
7147
7229
|
_handleObjectMoving(t) {
|
|
7148
|
-
var m,
|
|
7230
|
+
var m, g;
|
|
7149
7231
|
const { target: e, e: n } = t;
|
|
7150
7232
|
if (!e) {
|
|
7151
7233
|
this._clearGuides();
|
|
7152
7234
|
return;
|
|
7153
7235
|
}
|
|
7154
7236
|
if (!!(n != null && n.ctrlKey)) {
|
|
7155
|
-
this._clearGuides(),
|
|
7237
|
+
this._clearGuides(), pe._applyMovementStep({ target: e });
|
|
7156
7238
|
return;
|
|
7157
7239
|
}
|
|
7158
7240
|
!this.anchors.vertical.length && !this.anchors.horizontal.length && this._cacheAnchors({ activeObject: e });
|
|
@@ -7161,7 +7243,7 @@ class Hs {
|
|
|
7161
7243
|
this._clearGuides();
|
|
7162
7244
|
return;
|
|
7163
7245
|
}
|
|
7164
|
-
const { canvas: i } = this, a = i.getZoom() || 1, r =
|
|
7246
|
+
const { canvas: i } = this, a = i.getZoom() || 1, r = Ns / a, c = Bs({
|
|
7165
7247
|
activeBounds: o,
|
|
7166
7248
|
threshold: r,
|
|
7167
7249
|
anchors: this.anchors
|
|
@@ -7173,23 +7255,23 @@ class Hs {
|
|
|
7173
7255
|
top: M + h
|
|
7174
7256
|
}), e.setCoords(), o = (m = wt({ object: e })) != null ? m : o;
|
|
7175
7257
|
}
|
|
7176
|
-
const f = this.cachedTargetBounds.length ? this.cachedTargetBounds : this._collectTargets({ activeObject: e }).map((v) => wt({ object: v })).filter((v) => !!v),
|
|
7258
|
+
const f = this.cachedTargetBounds.length ? this.cachedTargetBounds : this._collectTargets({ activeObject: e }).map((v) => wt({ object: v })).filter((v) => !!v), p = Fs({
|
|
7177
7259
|
activeBounds: o,
|
|
7178
7260
|
candidates: f,
|
|
7179
7261
|
threshold: r,
|
|
7180
7262
|
spacingPatterns: this.spacingPatterns
|
|
7181
7263
|
});
|
|
7182
|
-
if (
|
|
7264
|
+
if (p.deltaX !== 0 || p.deltaY !== 0) {
|
|
7183
7265
|
const { left: v = 0, top: M = 0 } = e;
|
|
7184
7266
|
e.set({
|
|
7185
|
-
left: v +
|
|
7186
|
-
top: M +
|
|
7187
|
-
}), e.setCoords(), o = (
|
|
7267
|
+
left: v + p.deltaX,
|
|
7268
|
+
top: M + p.deltaY
|
|
7269
|
+
}), e.setCoords(), o = (g = wt({ object: e })) != null ? g : o;
|
|
7188
7270
|
}
|
|
7189
7271
|
this._applyGuides({
|
|
7190
7272
|
guides: u,
|
|
7191
|
-
spacingGuides:
|
|
7192
|
-
}),
|
|
7273
|
+
spacingGuides: p.guides
|
|
7274
|
+
}), pe._applyMovementStep({ target: e });
|
|
7193
7275
|
}
|
|
7194
7276
|
/**
|
|
7195
7277
|
* Очищает направляющие и кеш после окончания перетаскивания.
|
|
@@ -7212,7 +7294,7 @@ class Hs {
|
|
|
7212
7294
|
const { canvas: t, guideBounds: e } = this, n = t.getSelectionContext();
|
|
7213
7295
|
if (!n) return;
|
|
7214
7296
|
const s = e != null ? e : this._calculateViewportBounds(), { left: o, right: i, top: a, bottom: r } = s, { viewportTransform: c } = t, l = t.getZoom() || 1;
|
|
7215
|
-
n.save(), Array.isArray(c) && n.transform(...c), n.lineWidth =
|
|
7297
|
+
n.save(), Array.isArray(c) && n.transform(...c), n.lineWidth = De / l, n.strokeStyle = mn, n.setLineDash([4, 4]);
|
|
7216
7298
|
for (const h of this.activeGuides)
|
|
7217
7299
|
n.beginPath(), h.type === "vertical" ? (n.moveTo(h.position, a), n.lineTo(h.position, r)) : (n.moveTo(o, h.position), n.lineTo(i, h.position)), n.stroke();
|
|
7218
7300
|
for (const h of this.activeSpacingGuides)
|
|
@@ -7251,7 +7333,7 @@ class Hs {
|
|
|
7251
7333
|
/**
|
|
7252
7334
|
* Применяет шаг перемещения, округляя координаты объекта к сетке MOVE_SNAP_STEP.
|
|
7253
7335
|
*/
|
|
7254
|
-
_applyMovementStep({ target: t }) {
|
|
7336
|
+
static _applyMovementStep({ target: t }) {
|
|
7255
7337
|
const { left: e = 0, top: n = 0 } = t, s = Math.round(e / de) * de, o = Math.round(n / de) * de;
|
|
7256
7338
|
s === e && o === n || (t.set({
|
|
7257
7339
|
left: s,
|
|
@@ -7265,11 +7347,11 @@ class Hs {
|
|
|
7265
7347
|
const e = this._collectTargets({ activeObject: t }), n = { vertical: [], horizontal: [] }, s = [];
|
|
7266
7348
|
for (const a of e) {
|
|
7267
7349
|
const r = wt({ object: a });
|
|
7268
|
-
r && (
|
|
7350
|
+
r && (hn({ anchors: n, bounds: r }), s.push(r));
|
|
7269
7351
|
}
|
|
7270
7352
|
const { montageArea: o } = this.editor, i = wt({ object: o });
|
|
7271
7353
|
if (i) {
|
|
7272
|
-
|
|
7354
|
+
hn({ anchors: n, bounds: i });
|
|
7273
7355
|
const { left: a, right: r, top: c, bottom: l } = i;
|
|
7274
7356
|
this.guideBounds = {
|
|
7275
7357
|
left: a,
|
|
@@ -7279,15 +7361,15 @@ class Hs {
|
|
|
7279
7361
|
};
|
|
7280
7362
|
} else
|
|
7281
7363
|
this.guideBounds = this._calculateViewportBounds();
|
|
7282
|
-
this.anchors = n, this.spacingPatterns =
|
|
7364
|
+
this.anchors = n, this.spacingPatterns = Ys({ bounds: s }), this.cachedTargetBounds = s;
|
|
7283
7365
|
}
|
|
7284
7366
|
/**
|
|
7285
7367
|
* Собирает объекты, подходящие для прилипания, исключая активный объект и запрещённые id.
|
|
7286
7368
|
*/
|
|
7287
7369
|
_collectTargets({ activeObject: t }) {
|
|
7288
|
-
const e =
|
|
7370
|
+
const e = vn({ activeObject: t }), n = [];
|
|
7289
7371
|
return this.canvas.forEachObject((s) => {
|
|
7290
|
-
|
|
7372
|
+
bn({ object: s, excluded: e }) || n.push(s);
|
|
7291
7373
|
}), n;
|
|
7292
7374
|
}
|
|
7293
7375
|
/**
|
|
@@ -7310,7 +7392,7 @@ class Hs {
|
|
|
7310
7392
|
};
|
|
7311
7393
|
}
|
|
7312
7394
|
}
|
|
7313
|
-
const
|
|
7395
|
+
const fn = "#3D8BF4", gn = 1;
|
|
7314
7396
|
class zt {
|
|
7315
7397
|
/**
|
|
7316
7398
|
* Создаёт менеджер измерений и инициализирует события.
|
|
@@ -7451,8 +7533,8 @@ class zt {
|
|
|
7451
7533
|
event: t,
|
|
7452
7534
|
activeObject: e
|
|
7453
7535
|
}) {
|
|
7454
|
-
const { target: n } = t, s =
|
|
7455
|
-
return n && !
|
|
7536
|
+
const { target: n } = t, s = vn({ activeObject: e });
|
|
7537
|
+
return n && !bn({ object: n, excluded: s }) ? n : null;
|
|
7456
7538
|
}
|
|
7457
7539
|
/**
|
|
7458
7540
|
* Собирает вертикальные и горизонтальные направляющие расстояний.
|
|
@@ -7492,38 +7574,38 @@ class zt {
|
|
|
7492
7574
|
right: h = 0,
|
|
7493
7575
|
top: u = 0,
|
|
7494
7576
|
bottom: f = 0,
|
|
7495
|
-
centerY:
|
|
7496
|
-
} = e, m = Math.max(a, u),
|
|
7577
|
+
centerY: p = 0
|
|
7578
|
+
} = e, m = Math.max(a, u), g = Math.min(r, f), M = g >= m ? (m + g) / 2 : (c + p) / 2;
|
|
7497
7579
|
if (l >= i) {
|
|
7498
7580
|
if (n) return s;
|
|
7499
|
-
const
|
|
7500
|
-
return
|
|
7581
|
+
const I = l - i;
|
|
7582
|
+
return I > 0 && s.push({
|
|
7501
7583
|
type: "horizontal",
|
|
7502
7584
|
axis: M,
|
|
7503
7585
|
start: i,
|
|
7504
7586
|
end: l,
|
|
7505
|
-
distance:
|
|
7587
|
+
distance: I
|
|
7506
7588
|
}), s;
|
|
7507
7589
|
}
|
|
7508
7590
|
if (h <= o) {
|
|
7509
7591
|
if (n) return s;
|
|
7510
|
-
const
|
|
7511
|
-
return
|
|
7592
|
+
const I = o - h;
|
|
7593
|
+
return I > 0 && s.push({
|
|
7512
7594
|
type: "horizontal",
|
|
7513
7595
|
axis: M,
|
|
7514
7596
|
start: h,
|
|
7515
7597
|
end: o,
|
|
7516
|
-
distance:
|
|
7598
|
+
distance: I
|
|
7517
7599
|
}), s;
|
|
7518
7600
|
}
|
|
7519
7601
|
if (!n) return s;
|
|
7520
|
-
const
|
|
7521
|
-
|
|
7602
|
+
const C = o < l, y = i > h, w = Math.min(o, l), j = Math.max(o, l), T = j - w;
|
|
7603
|
+
T > 0 && !C && s.push({
|
|
7522
7604
|
type: "horizontal",
|
|
7523
7605
|
axis: M,
|
|
7524
7606
|
start: w,
|
|
7525
|
-
end:
|
|
7526
|
-
distance:
|
|
7607
|
+
end: j,
|
|
7608
|
+
distance: T
|
|
7527
7609
|
});
|
|
7528
7610
|
const b = Math.min(i, h), A = Math.max(i, h), S = A - b;
|
|
7529
7611
|
return S > 0 && !y && s.push({
|
|
@@ -7553,38 +7635,38 @@ class zt {
|
|
|
7553
7635
|
bottom: h = 0,
|
|
7554
7636
|
left: u = 0,
|
|
7555
7637
|
right: f = 0,
|
|
7556
|
-
centerX:
|
|
7557
|
-
} = e, m = Math.max(a, u),
|
|
7638
|
+
centerX: p = 0
|
|
7639
|
+
} = e, m = Math.max(a, u), g = Math.min(r, f), M = g >= m ? (m + g) / 2 : (c + p) / 2;
|
|
7558
7640
|
if (l >= i) {
|
|
7559
7641
|
if (n) return s;
|
|
7560
|
-
const
|
|
7561
|
-
return
|
|
7642
|
+
const I = l - i;
|
|
7643
|
+
return I > 0 && s.push({
|
|
7562
7644
|
type: "vertical",
|
|
7563
7645
|
axis: M,
|
|
7564
7646
|
start: i,
|
|
7565
7647
|
end: l,
|
|
7566
|
-
distance:
|
|
7648
|
+
distance: I
|
|
7567
7649
|
}), s;
|
|
7568
7650
|
}
|
|
7569
7651
|
if (h <= o) {
|
|
7570
7652
|
if (n) return s;
|
|
7571
|
-
const
|
|
7572
|
-
return
|
|
7653
|
+
const I = o - h;
|
|
7654
|
+
return I > 0 && s.push({
|
|
7573
7655
|
type: "vertical",
|
|
7574
7656
|
axis: M,
|
|
7575
7657
|
start: h,
|
|
7576
7658
|
end: o,
|
|
7577
|
-
distance:
|
|
7659
|
+
distance: I
|
|
7578
7660
|
}), s;
|
|
7579
7661
|
}
|
|
7580
7662
|
if (!n) return s;
|
|
7581
|
-
const
|
|
7582
|
-
|
|
7663
|
+
const C = o < l, y = i > h, w = Math.min(o, l), j = Math.max(o, l), T = j - w;
|
|
7664
|
+
T > 0 && !C && s.push({
|
|
7583
7665
|
type: "vertical",
|
|
7584
7666
|
axis: M,
|
|
7585
7667
|
start: w,
|
|
7586
|
-
end:
|
|
7587
|
-
distance:
|
|
7668
|
+
end: j,
|
|
7669
|
+
distance: T
|
|
7588
7670
|
});
|
|
7589
7671
|
const b = Math.min(i, h), A = Math.max(i, h), S = A - b;
|
|
7590
7672
|
return S > 0 && !y && s.push({
|
|
@@ -7620,19 +7702,19 @@ class zt {
|
|
|
7620
7702
|
const { canvas: t } = this, e = t.getSelectionContext();
|
|
7621
7703
|
if (!e) return;
|
|
7622
7704
|
const { viewportTransform: n } = t, s = t.getZoom() || 1, o = this.activeGuides.some((c) => c.type === "vertical"), i = this.activeGuides.some((c) => c.type === "horizontal"), a = o && i && !this.isTargetMontageArea, r = a ? 12 / s : 0;
|
|
7623
|
-
e.save(), Array.isArray(n) && e.transform(...n), e.lineWidth =
|
|
7705
|
+
e.save(), Array.isArray(n) && e.transform(...n), e.lineWidth = gn / s, e.strokeStyle = fn, e.setLineDash([]);
|
|
7624
7706
|
for (const c of this.activeGuides) {
|
|
7625
|
-
const { type: l, axis: h, start: u, end: f, distance:
|
|
7626
|
-
e.beginPath(), l === "vertical" ? (e.moveTo(h, u), e.lineTo(h, f)) : (e.moveTo(u, h), e.lineTo(f, h)), e.stroke(),
|
|
7707
|
+
const { type: l, axis: h, start: u, end: f, distance: p } = c, m = Math.abs(f - u), g = u <= f ? -1 : 1, v = a ? g * (m / 2 + r) : 0, M = 0;
|
|
7708
|
+
e.beginPath(), l === "vertical" ? (e.moveTo(h, u), e.lineTo(h, f)) : (e.moveTo(u, h), e.lineTo(f, h)), e.stroke(), _e({
|
|
7627
7709
|
context: e,
|
|
7628
7710
|
type: l,
|
|
7629
7711
|
axis: h,
|
|
7630
7712
|
start: u,
|
|
7631
7713
|
end: f,
|
|
7632
|
-
text: Math.round(
|
|
7714
|
+
text: Math.round(p).toString(),
|
|
7633
7715
|
zoom: s,
|
|
7634
|
-
color:
|
|
7635
|
-
lineWidth:
|
|
7716
|
+
color: fn,
|
|
7717
|
+
lineWidth: gn,
|
|
7636
7718
|
offsetAlongAxis: v,
|
|
7637
7719
|
offsetPerpendicular: M
|
|
7638
7720
|
});
|
|
@@ -7658,14 +7740,14 @@ class zt {
|
|
|
7658
7740
|
(e = t == null ? void 0 : t.showAfterTemporary) == null || e.call(t), this.isToolbarHidden = !1;
|
|
7659
7741
|
}
|
|
7660
7742
|
}
|
|
7661
|
-
class
|
|
7743
|
+
class Pe {
|
|
7662
7744
|
/**
|
|
7663
7745
|
* Конструктор класса ImageEditor.
|
|
7664
7746
|
* @param canvasId - идентификатор канваса, в котором будет создан редактор
|
|
7665
7747
|
* @param options - опции и настройки редактора
|
|
7666
7748
|
*/
|
|
7667
7749
|
constructor(t, e) {
|
|
7668
|
-
this.options = e, this.containerId = t, this.editorId = `${t}-${
|
|
7750
|
+
this.options = e, this.containerId = t, this.editorId = `${t}-${tt()}`, this.clipboard = null, this.init();
|
|
7669
7751
|
}
|
|
7670
7752
|
/**
|
|
7671
7753
|
* Инициализация редактора.
|
|
@@ -7688,17 +7770,17 @@ class Ne {
|
|
|
7688
7770
|
showRotationAngle: l,
|
|
7689
7771
|
_onReadyCallback: h
|
|
7690
7772
|
} = this.options;
|
|
7691
|
-
if (lt.apply(), this.canvas = new
|
|
7773
|
+
if (lt.apply(), this.canvas = new En(this.containerId, this.options), this.moduleLoader = new Rn(), this.workerManager = new Nn(), this.errorManager = new Jt({ editor: this }), this.historyManager = new K({ editor: this }), this.toolbar = new Qn({ editor: this }), this.transformManager = new cs({ editor: this }), this.zoomManager = new ls({ editor: this }), this.canvasManager = new rs({ editor: this }), this.imageManager = new yt({ editor: this }), this.layerManager = new ue({ editor: this }), this.shapeManager = new hs({ editor: this }), this.interactionBlocker = new ds({ editor: this }), this.backgroundManager = new Bt({ editor: this }), this.clipboardManager = new us({ editor: this }), this.objectLockManager = new fe({ editor: this }), this.groupingManager = new fs({ editor: this }), this.selectionManager = new gs({ editor: this }), this.deletionManager = new ze({ editor: this }), this.panConstraintManager = new ps({ editor: this }), this.snappingManager = new pe({ editor: this }), this.measurementManager = new zt({ editor: this }), this.fontManager = new Te((u = this.options.fonts) != null ? u : []), this.textManager = new st({ editor: this }), this.templateManager = new H({ editor: this }), l && (this.angleIndicator = new Be({ editor: this })), this._createMontageArea(), this._createClippingArea(), this.listeners = new xe({ editor: this, options: this.options }), this.canvasManager.setEditorContainerWidth(t), this.canvasManager.setEditorContainerHeight(e), this.canvasManager.setCanvasWrapperWidth(n), this.canvasManager.setCanvasWrapperHeight(s), this.canvasManager.setCanvasCSSWidth(o), this.canvasManager.setCanvasCSSHeight(i), this.canvasManager.updateCanvas(), this.zoomManager.calculateAndApplyDefaultZoom(), yield this.fontManager.loadFonts(), a != null && a.source) {
|
|
7692
7774
|
const f = a, {
|
|
7693
|
-
source:
|
|
7775
|
+
source: p,
|
|
7694
7776
|
scale: m = `image-${c}`,
|
|
7695
|
-
withoutSave:
|
|
7777
|
+
withoutSave: g = !0
|
|
7696
7778
|
} = f, v = Mt(f, [
|
|
7697
7779
|
"source",
|
|
7698
7780
|
"scale",
|
|
7699
7781
|
"withoutSave"
|
|
7700
7782
|
]);
|
|
7701
|
-
yield this.imageManager.importImage(
|
|
7783
|
+
yield this.imageManager.importImage(x({ source: p, scale: m, withoutSave: g }, v));
|
|
7702
7784
|
}
|
|
7703
7785
|
r && this.historyManager.loadStateFromFullState(r), this.historyManager.saveState(), console.log("editor:ready"), this.canvas.fire("editor:ready", this), typeof h == "function" && h(this);
|
|
7704
7786
|
});
|
|
@@ -7714,7 +7796,7 @@ class Ne {
|
|
|
7714
7796
|
this.montageArea = this.shapeManager.addRectangle({
|
|
7715
7797
|
width: t,
|
|
7716
7798
|
height: e,
|
|
7717
|
-
fill:
|
|
7799
|
+
fill: Pe._createMosaicPattern(),
|
|
7718
7800
|
stroke: null,
|
|
7719
7801
|
strokeWidth: 0,
|
|
7720
7802
|
selectable: !1,
|
|
@@ -7765,13 +7847,13 @@ class Ne {
|
|
|
7765
7847
|
const t = document.createElement("canvas");
|
|
7766
7848
|
t.width = 20, t.height = 20;
|
|
7767
7849
|
const e = t.getContext("2d");
|
|
7768
|
-
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
|
|
7850
|
+
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 Ln({
|
|
7769
7851
|
source: t,
|
|
7770
7852
|
repeat: "repeat"
|
|
7771
7853
|
});
|
|
7772
7854
|
}
|
|
7773
7855
|
}
|
|
7774
|
-
const
|
|
7856
|
+
const P = [
|
|
7775
7857
|
"U+0000-00FF",
|
|
7776
7858
|
"U+0100-02BA",
|
|
7777
7859
|
"U+02BB-02BC",
|
|
@@ -7801,7 +7883,7 @@ const k = [
|
|
|
7801
7883
|
"U+A720-A7FF",
|
|
7802
7884
|
"U+FEFF",
|
|
7803
7885
|
"U+FFFD"
|
|
7804
|
-
].join(", "),
|
|
7886
|
+
].join(", "), F = [
|
|
7805
7887
|
"U+0301",
|
|
7806
7888
|
"U+0400-052F",
|
|
7807
7889
|
"U+1C80-1C8A",
|
|
@@ -7827,7 +7909,7 @@ const k = [
|
|
|
7827
7909
|
style: "normal",
|
|
7828
7910
|
weight: "400",
|
|
7829
7911
|
display: "swap",
|
|
7830
|
-
unicodeRange:
|
|
7912
|
+
unicodeRange: F
|
|
7831
7913
|
}
|
|
7832
7914
|
},
|
|
7833
7915
|
{
|
|
@@ -7837,7 +7919,7 @@ const k = [
|
|
|
7837
7919
|
style: "normal",
|
|
7838
7920
|
weight: "400",
|
|
7839
7921
|
display: "swap",
|
|
7840
|
-
unicodeRange:
|
|
7922
|
+
unicodeRange: P
|
|
7841
7923
|
}
|
|
7842
7924
|
},
|
|
7843
7925
|
{
|
|
@@ -7847,7 +7929,7 @@ const k = [
|
|
|
7847
7929
|
style: "normal",
|
|
7848
7930
|
weight: "700",
|
|
7849
7931
|
display: "swap",
|
|
7850
|
-
unicodeRange:
|
|
7932
|
+
unicodeRange: F
|
|
7851
7933
|
}
|
|
7852
7934
|
},
|
|
7853
7935
|
{
|
|
@@ -7857,7 +7939,7 @@ const k = [
|
|
|
7857
7939
|
style: "normal",
|
|
7858
7940
|
weight: "700",
|
|
7859
7941
|
display: "swap",
|
|
7860
|
-
unicodeRange:
|
|
7942
|
+
unicodeRange: P
|
|
7861
7943
|
}
|
|
7862
7944
|
},
|
|
7863
7945
|
{
|
|
@@ -7867,7 +7949,7 @@ const k = [
|
|
|
7867
7949
|
style: "normal",
|
|
7868
7950
|
weight: "200 700",
|
|
7869
7951
|
display: "swap",
|
|
7870
|
-
unicodeRange:
|
|
7952
|
+
unicodeRange: F
|
|
7871
7953
|
}
|
|
7872
7954
|
},
|
|
7873
7955
|
{
|
|
@@ -7877,7 +7959,7 @@ const k = [
|
|
|
7877
7959
|
style: "normal",
|
|
7878
7960
|
weight: "200 700",
|
|
7879
7961
|
display: "swap",
|
|
7880
|
-
unicodeRange:
|
|
7962
|
+
unicodeRange: P
|
|
7881
7963
|
}
|
|
7882
7964
|
},
|
|
7883
7965
|
{
|
|
@@ -7887,7 +7969,7 @@ const k = [
|
|
|
7887
7969
|
style: "normal",
|
|
7888
7970
|
weight: "300 900",
|
|
7889
7971
|
display: "swap",
|
|
7890
|
-
unicodeRange:
|
|
7972
|
+
unicodeRange: F
|
|
7891
7973
|
}
|
|
7892
7974
|
},
|
|
7893
7975
|
{
|
|
@@ -7897,7 +7979,7 @@ const k = [
|
|
|
7897
7979
|
style: "normal",
|
|
7898
7980
|
weight: "300 900",
|
|
7899
7981
|
display: "swap",
|
|
7900
|
-
unicodeRange:
|
|
7982
|
+
unicodeRange: P
|
|
7901
7983
|
}
|
|
7902
7984
|
},
|
|
7903
7985
|
{
|
|
@@ -7907,7 +7989,7 @@ const k = [
|
|
|
7907
7989
|
style: "normal",
|
|
7908
7990
|
weight: "400 700",
|
|
7909
7991
|
display: "swap",
|
|
7910
|
-
unicodeRange:
|
|
7992
|
+
unicodeRange: F
|
|
7911
7993
|
}
|
|
7912
7994
|
},
|
|
7913
7995
|
{
|
|
@@ -7917,7 +7999,7 @@ const k = [
|
|
|
7917
7999
|
style: "normal",
|
|
7918
8000
|
weight: "400 700",
|
|
7919
8001
|
display: "swap",
|
|
7920
|
-
unicodeRange:
|
|
8002
|
+
unicodeRange: P
|
|
7921
8003
|
}
|
|
7922
8004
|
},
|
|
7923
8005
|
{
|
|
@@ -7927,7 +8009,7 @@ const k = [
|
|
|
7927
8009
|
style: "normal",
|
|
7928
8010
|
weight: "300 700",
|
|
7929
8011
|
display: "swap",
|
|
7930
|
-
unicodeRange:
|
|
8012
|
+
unicodeRange: F
|
|
7931
8013
|
}
|
|
7932
8014
|
},
|
|
7933
8015
|
{
|
|
@@ -7937,7 +8019,7 @@ const k = [
|
|
|
7937
8019
|
style: "normal",
|
|
7938
8020
|
weight: "300 700",
|
|
7939
8021
|
display: "swap",
|
|
7940
|
-
unicodeRange:
|
|
8022
|
+
unicodeRange: P
|
|
7941
8023
|
}
|
|
7942
8024
|
},
|
|
7943
8025
|
{
|
|
@@ -7947,7 +8029,7 @@ const k = [
|
|
|
7947
8029
|
style: "normal",
|
|
7948
8030
|
weight: "300 700",
|
|
7949
8031
|
display: "swap",
|
|
7950
|
-
unicodeRange:
|
|
8032
|
+
unicodeRange: F
|
|
7951
8033
|
}
|
|
7952
8034
|
},
|
|
7953
8035
|
{
|
|
@@ -7957,7 +8039,7 @@ const k = [
|
|
|
7957
8039
|
style: "normal",
|
|
7958
8040
|
weight: "300 700",
|
|
7959
8041
|
display: "swap",
|
|
7960
|
-
unicodeRange:
|
|
8042
|
+
unicodeRange: P
|
|
7961
8043
|
}
|
|
7962
8044
|
},
|
|
7963
8045
|
{
|
|
@@ -7967,7 +8049,7 @@ const k = [
|
|
|
7967
8049
|
style: "normal",
|
|
7968
8050
|
weight: "400",
|
|
7969
8051
|
display: "swap",
|
|
7970
|
-
unicodeRange:
|
|
8052
|
+
unicodeRange: F
|
|
7971
8053
|
}
|
|
7972
8054
|
},
|
|
7973
8055
|
{
|
|
@@ -7977,7 +8059,7 @@ const k = [
|
|
|
7977
8059
|
style: "normal",
|
|
7978
8060
|
weight: "400",
|
|
7979
8061
|
display: "swap",
|
|
7980
|
-
unicodeRange:
|
|
8062
|
+
unicodeRange: P
|
|
7981
8063
|
}
|
|
7982
8064
|
},
|
|
7983
8065
|
{
|
|
@@ -7987,7 +8069,7 @@ const k = [
|
|
|
7987
8069
|
style: "normal",
|
|
7988
8070
|
weight: "400 700",
|
|
7989
8071
|
display: "swap",
|
|
7990
|
-
unicodeRange:
|
|
8072
|
+
unicodeRange: F
|
|
7991
8073
|
}
|
|
7992
8074
|
},
|
|
7993
8075
|
{
|
|
@@ -7997,7 +8079,7 @@ const k = [
|
|
|
7997
8079
|
style: "normal",
|
|
7998
8080
|
weight: "400 700",
|
|
7999
8081
|
display: "swap",
|
|
8000
|
-
unicodeRange:
|
|
8082
|
+
unicodeRange: P
|
|
8001
8083
|
}
|
|
8002
8084
|
},
|
|
8003
8085
|
{
|
|
@@ -8007,7 +8089,7 @@ const k = [
|
|
|
8007
8089
|
style: "normal",
|
|
8008
8090
|
weight: "100 900",
|
|
8009
8091
|
display: "swap",
|
|
8010
|
-
unicodeRange:
|
|
8092
|
+
unicodeRange: F
|
|
8011
8093
|
}
|
|
8012
8094
|
},
|
|
8013
8095
|
{
|
|
@@ -8017,7 +8099,7 @@ const k = [
|
|
|
8017
8099
|
style: "normal",
|
|
8018
8100
|
weight: "100 900",
|
|
8019
8101
|
display: "swap",
|
|
8020
|
-
unicodeRange:
|
|
8102
|
+
unicodeRange: P
|
|
8021
8103
|
}
|
|
8022
8104
|
},
|
|
8023
8105
|
{
|
|
@@ -8027,7 +8109,7 @@ const k = [
|
|
|
8027
8109
|
style: "normal",
|
|
8028
8110
|
weight: "400",
|
|
8029
8111
|
display: "swap",
|
|
8030
|
-
unicodeRange:
|
|
8112
|
+
unicodeRange: F
|
|
8031
8113
|
}
|
|
8032
8114
|
},
|
|
8033
8115
|
{
|
|
@@ -8037,7 +8119,7 @@ const k = [
|
|
|
8037
8119
|
style: "normal",
|
|
8038
8120
|
weight: "400",
|
|
8039
8121
|
display: "swap",
|
|
8040
|
-
unicodeRange:
|
|
8122
|
+
unicodeRange: P
|
|
8041
8123
|
}
|
|
8042
8124
|
},
|
|
8043
8125
|
{
|
|
@@ -8047,7 +8129,7 @@ const k = [
|
|
|
8047
8129
|
style: "normal",
|
|
8048
8130
|
weight: "700",
|
|
8049
8131
|
display: "swap",
|
|
8050
|
-
unicodeRange:
|
|
8132
|
+
unicodeRange: F
|
|
8051
8133
|
}
|
|
8052
8134
|
},
|
|
8053
8135
|
{
|
|
@@ -8057,7 +8139,7 @@ const k = [
|
|
|
8057
8139
|
style: "normal",
|
|
8058
8140
|
weight: "700",
|
|
8059
8141
|
display: "swap",
|
|
8060
|
-
unicodeRange:
|
|
8142
|
+
unicodeRange: P
|
|
8061
8143
|
}
|
|
8062
8144
|
},
|
|
8063
8145
|
{
|
|
@@ -8067,7 +8149,7 @@ const k = [
|
|
|
8067
8149
|
style: "normal",
|
|
8068
8150
|
weight: "400 700",
|
|
8069
8151
|
display: "swap",
|
|
8070
|
-
unicodeRange:
|
|
8152
|
+
unicodeRange: F
|
|
8071
8153
|
}
|
|
8072
8154
|
},
|
|
8073
8155
|
{
|
|
@@ -8077,7 +8159,7 @@ const k = [
|
|
|
8077
8159
|
style: "normal",
|
|
8078
8160
|
weight: "400 700",
|
|
8079
8161
|
display: "swap",
|
|
8080
|
-
unicodeRange:
|
|
8162
|
+
unicodeRange: P
|
|
8081
8163
|
}
|
|
8082
8164
|
},
|
|
8083
8165
|
{
|
|
@@ -8087,7 +8169,7 @@ const k = [
|
|
|
8087
8169
|
style: "normal",
|
|
8088
8170
|
weight: "100 900",
|
|
8089
8171
|
display: "swap",
|
|
8090
|
-
unicodeRange:
|
|
8172
|
+
unicodeRange: F
|
|
8091
8173
|
}
|
|
8092
8174
|
},
|
|
8093
8175
|
{
|
|
@@ -8097,7 +8179,7 @@ const k = [
|
|
|
8097
8179
|
style: "normal",
|
|
8098
8180
|
weight: "100 900",
|
|
8099
8181
|
display: "swap",
|
|
8100
|
-
unicodeRange:
|
|
8182
|
+
unicodeRange: P
|
|
8101
8183
|
}
|
|
8102
8184
|
},
|
|
8103
8185
|
{
|
|
@@ -8107,7 +8189,7 @@ const k = [
|
|
|
8107
8189
|
style: "normal",
|
|
8108
8190
|
weight: "100",
|
|
8109
8191
|
display: "swap",
|
|
8110
|
-
unicodeRange:
|
|
8192
|
+
unicodeRange: F
|
|
8111
8193
|
}
|
|
8112
8194
|
},
|
|
8113
8195
|
{
|
|
@@ -8117,7 +8199,7 @@ const k = [
|
|
|
8117
8199
|
style: "normal",
|
|
8118
8200
|
weight: "100",
|
|
8119
8201
|
display: "swap",
|
|
8120
|
-
unicodeRange:
|
|
8202
|
+
unicodeRange: P
|
|
8121
8203
|
}
|
|
8122
8204
|
},
|
|
8123
8205
|
{
|
|
@@ -8127,7 +8209,7 @@ const k = [
|
|
|
8127
8209
|
style: "normal",
|
|
8128
8210
|
weight: "200",
|
|
8129
8211
|
display: "swap",
|
|
8130
|
-
unicodeRange:
|
|
8212
|
+
unicodeRange: F
|
|
8131
8213
|
}
|
|
8132
8214
|
},
|
|
8133
8215
|
{
|
|
@@ -8137,7 +8219,7 @@ const k = [
|
|
|
8137
8219
|
style: "normal",
|
|
8138
8220
|
weight: "200",
|
|
8139
8221
|
display: "swap",
|
|
8140
|
-
unicodeRange:
|
|
8222
|
+
unicodeRange: P
|
|
8141
8223
|
}
|
|
8142
8224
|
},
|
|
8143
8225
|
{
|
|
@@ -8147,7 +8229,7 @@ const k = [
|
|
|
8147
8229
|
style: "normal",
|
|
8148
8230
|
weight: "300",
|
|
8149
8231
|
display: "swap",
|
|
8150
|
-
unicodeRange:
|
|
8232
|
+
unicodeRange: F
|
|
8151
8233
|
}
|
|
8152
8234
|
},
|
|
8153
8235
|
{
|
|
@@ -8157,7 +8239,7 @@ const k = [
|
|
|
8157
8239
|
style: "normal",
|
|
8158
8240
|
weight: "300",
|
|
8159
8241
|
display: "swap",
|
|
8160
|
-
unicodeRange:
|
|
8242
|
+
unicodeRange: P
|
|
8161
8243
|
}
|
|
8162
8244
|
},
|
|
8163
8245
|
{
|
|
@@ -8167,7 +8249,7 @@ const k = [
|
|
|
8167
8249
|
style: "normal",
|
|
8168
8250
|
weight: "400",
|
|
8169
8251
|
display: "swap",
|
|
8170
|
-
unicodeRange:
|
|
8252
|
+
unicodeRange: F
|
|
8171
8253
|
}
|
|
8172
8254
|
},
|
|
8173
8255
|
{
|
|
@@ -8177,7 +8259,7 @@ const k = [
|
|
|
8177
8259
|
style: "normal",
|
|
8178
8260
|
weight: "400",
|
|
8179
8261
|
display: "swap",
|
|
8180
|
-
unicodeRange:
|
|
8262
|
+
unicodeRange: P
|
|
8181
8263
|
}
|
|
8182
8264
|
},
|
|
8183
8265
|
{
|
|
@@ -8187,7 +8269,7 @@ const k = [
|
|
|
8187
8269
|
style: "normal",
|
|
8188
8270
|
weight: "500",
|
|
8189
8271
|
display: "swap",
|
|
8190
|
-
unicodeRange:
|
|
8272
|
+
unicodeRange: F
|
|
8191
8273
|
}
|
|
8192
8274
|
},
|
|
8193
8275
|
{
|
|
@@ -8197,7 +8279,7 @@ const k = [
|
|
|
8197
8279
|
style: "normal",
|
|
8198
8280
|
weight: "500",
|
|
8199
8281
|
display: "swap",
|
|
8200
|
-
unicodeRange:
|
|
8282
|
+
unicodeRange: P
|
|
8201
8283
|
}
|
|
8202
8284
|
},
|
|
8203
8285
|
{
|
|
@@ -8207,7 +8289,7 @@ const k = [
|
|
|
8207
8289
|
style: "normal",
|
|
8208
8290
|
weight: "600",
|
|
8209
8291
|
display: "swap",
|
|
8210
|
-
unicodeRange:
|
|
8292
|
+
unicodeRange: F
|
|
8211
8293
|
}
|
|
8212
8294
|
},
|
|
8213
8295
|
{
|
|
@@ -8217,7 +8299,7 @@ const k = [
|
|
|
8217
8299
|
style: "normal",
|
|
8218
8300
|
weight: "600",
|
|
8219
8301
|
display: "swap",
|
|
8220
|
-
unicodeRange:
|
|
8302
|
+
unicodeRange: P
|
|
8221
8303
|
}
|
|
8222
8304
|
},
|
|
8223
8305
|
{
|
|
@@ -8227,7 +8309,7 @@ const k = [
|
|
|
8227
8309
|
style: "normal",
|
|
8228
8310
|
weight: "700",
|
|
8229
8311
|
display: "swap",
|
|
8230
|
-
unicodeRange:
|
|
8312
|
+
unicodeRange: F
|
|
8231
8313
|
}
|
|
8232
8314
|
},
|
|
8233
8315
|
{
|
|
@@ -8237,7 +8319,7 @@ const k = [
|
|
|
8237
8319
|
style: "normal",
|
|
8238
8320
|
weight: "700",
|
|
8239
8321
|
display: "swap",
|
|
8240
|
-
unicodeRange:
|
|
8322
|
+
unicodeRange: P
|
|
8241
8323
|
}
|
|
8242
8324
|
},
|
|
8243
8325
|
{
|
|
@@ -8247,7 +8329,7 @@ const k = [
|
|
|
8247
8329
|
style: "normal",
|
|
8248
8330
|
weight: "800",
|
|
8249
8331
|
display: "swap",
|
|
8250
|
-
unicodeRange:
|
|
8332
|
+
unicodeRange: F
|
|
8251
8333
|
}
|
|
8252
8334
|
},
|
|
8253
8335
|
{
|
|
@@ -8257,7 +8339,7 @@ const k = [
|
|
|
8257
8339
|
style: "normal",
|
|
8258
8340
|
weight: "800",
|
|
8259
8341
|
display: "swap",
|
|
8260
|
-
unicodeRange:
|
|
8342
|
+
unicodeRange: P
|
|
8261
8343
|
}
|
|
8262
8344
|
},
|
|
8263
8345
|
{
|
|
@@ -8267,7 +8349,7 @@ const k = [
|
|
|
8267
8349
|
style: "normal",
|
|
8268
8350
|
weight: "900",
|
|
8269
8351
|
display: "swap",
|
|
8270
|
-
unicodeRange:
|
|
8352
|
+
unicodeRange: F
|
|
8271
8353
|
}
|
|
8272
8354
|
},
|
|
8273
8355
|
{
|
|
@@ -8277,7 +8359,7 @@ const k = [
|
|
|
8277
8359
|
style: "normal",
|
|
8278
8360
|
weight: "900",
|
|
8279
8361
|
display: "swap",
|
|
8280
|
-
unicodeRange:
|
|
8362
|
+
unicodeRange: P
|
|
8281
8363
|
}
|
|
8282
8364
|
},
|
|
8283
8365
|
{
|
|
@@ -8287,7 +8369,7 @@ const k = [
|
|
|
8287
8369
|
style: "normal",
|
|
8288
8370
|
weight: "400",
|
|
8289
8371
|
display: "swap",
|
|
8290
|
-
unicodeRange:
|
|
8372
|
+
unicodeRange: F
|
|
8291
8373
|
}
|
|
8292
8374
|
},
|
|
8293
8375
|
{
|
|
@@ -8297,7 +8379,7 @@ const k = [
|
|
|
8297
8379
|
style: "normal",
|
|
8298
8380
|
weight: "400",
|
|
8299
8381
|
display: "swap",
|
|
8300
|
-
unicodeRange:
|
|
8382
|
+
unicodeRange: P
|
|
8301
8383
|
}
|
|
8302
8384
|
},
|
|
8303
8385
|
{
|
|
@@ -8307,7 +8389,7 @@ const k = [
|
|
|
8307
8389
|
style: "normal",
|
|
8308
8390
|
weight: "700",
|
|
8309
8391
|
display: "swap",
|
|
8310
|
-
unicodeRange:
|
|
8392
|
+
unicodeRange: F
|
|
8311
8393
|
}
|
|
8312
8394
|
},
|
|
8313
8395
|
{
|
|
@@ -8317,7 +8399,7 @@ const k = [
|
|
|
8317
8399
|
style: "normal",
|
|
8318
8400
|
weight: "700",
|
|
8319
8401
|
display: "swap",
|
|
8320
|
-
unicodeRange:
|
|
8402
|
+
unicodeRange: P
|
|
8321
8403
|
}
|
|
8322
8404
|
},
|
|
8323
8405
|
{
|
|
@@ -8327,7 +8409,7 @@ const k = [
|
|
|
8327
8409
|
style: "normal",
|
|
8328
8410
|
weight: "100 900",
|
|
8329
8411
|
display: "swap",
|
|
8330
|
-
unicodeRange:
|
|
8412
|
+
unicodeRange: F
|
|
8331
8413
|
}
|
|
8332
8414
|
},
|
|
8333
8415
|
{
|
|
@@ -8337,7 +8419,7 @@ const k = [
|
|
|
8337
8419
|
style: "normal",
|
|
8338
8420
|
weight: "100 900",
|
|
8339
8421
|
display: "swap",
|
|
8340
|
-
unicodeRange:
|
|
8422
|
+
unicodeRange: P
|
|
8341
8423
|
}
|
|
8342
8424
|
},
|
|
8343
8425
|
{
|
|
@@ -8347,7 +8429,7 @@ const k = [
|
|
|
8347
8429
|
style: "normal",
|
|
8348
8430
|
weight: "300 700",
|
|
8349
8431
|
display: "swap",
|
|
8350
|
-
unicodeRange:
|
|
8432
|
+
unicodeRange: F
|
|
8351
8433
|
}
|
|
8352
8434
|
},
|
|
8353
8435
|
{
|
|
@@ -8357,7 +8439,7 @@ const k = [
|
|
|
8357
8439
|
style: "normal",
|
|
8358
8440
|
weight: "300 700",
|
|
8359
8441
|
display: "swap",
|
|
8360
|
-
unicodeRange:
|
|
8442
|
+
unicodeRange: P
|
|
8361
8443
|
}
|
|
8362
8444
|
},
|
|
8363
8445
|
{
|
|
@@ -8367,7 +8449,7 @@ const k = [
|
|
|
8367
8449
|
style: "normal",
|
|
8368
8450
|
weight: "400",
|
|
8369
8451
|
display: "swap",
|
|
8370
|
-
unicodeRange:
|
|
8452
|
+
unicodeRange: F
|
|
8371
8453
|
}
|
|
8372
8454
|
},
|
|
8373
8455
|
{
|
|
@@ -8377,7 +8459,7 @@ const k = [
|
|
|
8377
8459
|
style: "normal",
|
|
8378
8460
|
weight: "400",
|
|
8379
8461
|
display: "swap",
|
|
8380
|
-
unicodeRange:
|
|
8462
|
+
unicodeRange: P
|
|
8381
8463
|
}
|
|
8382
8464
|
},
|
|
8383
8465
|
{
|
|
@@ -8387,7 +8469,7 @@ const k = [
|
|
|
8387
8469
|
style: "normal",
|
|
8388
8470
|
weight: "200 800",
|
|
8389
8471
|
display: "swap",
|
|
8390
|
-
unicodeRange:
|
|
8472
|
+
unicodeRange: F
|
|
8391
8473
|
}
|
|
8392
8474
|
},
|
|
8393
8475
|
{
|
|
@@ -8397,7 +8479,7 @@ const k = [
|
|
|
8397
8479
|
style: "normal",
|
|
8398
8480
|
weight: "200 800",
|
|
8399
8481
|
display: "swap",
|
|
8400
|
-
unicodeRange:
|
|
8482
|
+
unicodeRange: P
|
|
8401
8483
|
}
|
|
8402
8484
|
},
|
|
8403
8485
|
{
|
|
@@ -8407,7 +8489,7 @@ const k = [
|
|
|
8407
8489
|
style: "normal",
|
|
8408
8490
|
weight: "100 900",
|
|
8409
8491
|
display: "swap",
|
|
8410
|
-
unicodeRange:
|
|
8492
|
+
unicodeRange: F
|
|
8411
8493
|
}
|
|
8412
8494
|
},
|
|
8413
8495
|
{
|
|
@@ -8417,7 +8499,7 @@ const k = [
|
|
|
8417
8499
|
style: "normal",
|
|
8418
8500
|
weight: "100 900",
|
|
8419
8501
|
display: "swap",
|
|
8420
|
-
unicodeRange:
|
|
8502
|
+
unicodeRange: P
|
|
8421
8503
|
}
|
|
8422
8504
|
},
|
|
8423
8505
|
{
|
|
@@ -8427,7 +8509,7 @@ const k = [
|
|
|
8427
8509
|
style: "normal",
|
|
8428
8510
|
weight: "400",
|
|
8429
8511
|
display: "swap",
|
|
8430
|
-
unicodeRange:
|
|
8512
|
+
unicodeRange: F
|
|
8431
8513
|
}
|
|
8432
8514
|
},
|
|
8433
8515
|
{
|
|
@@ -8437,7 +8519,7 @@ const k = [
|
|
|
8437
8519
|
style: "normal",
|
|
8438
8520
|
weight: "400",
|
|
8439
8521
|
display: "swap",
|
|
8440
|
-
unicodeRange:
|
|
8522
|
+
unicodeRange: P
|
|
8441
8523
|
}
|
|
8442
8524
|
},
|
|
8443
8525
|
{
|
|
@@ -8447,7 +8529,7 @@ const k = [
|
|
|
8447
8529
|
style: "normal",
|
|
8448
8530
|
weight: "100 900",
|
|
8449
8531
|
display: "swap",
|
|
8450
|
-
unicodeRange:
|
|
8532
|
+
unicodeRange: F
|
|
8451
8533
|
}
|
|
8452
8534
|
},
|
|
8453
8535
|
{
|
|
@@ -8457,7 +8539,7 @@ const k = [
|
|
|
8457
8539
|
style: "normal",
|
|
8458
8540
|
weight: "100 900",
|
|
8459
8541
|
display: "swap",
|
|
8460
|
-
unicodeRange:
|
|
8542
|
+
unicodeRange: P
|
|
8461
8543
|
}
|
|
8462
8544
|
},
|
|
8463
8545
|
{
|
|
@@ -8467,7 +8549,7 @@ const k = [
|
|
|
8467
8549
|
style: "normal",
|
|
8468
8550
|
weight: "300 800",
|
|
8469
8551
|
display: "swap",
|
|
8470
|
-
unicodeRange:
|
|
8552
|
+
unicodeRange: F
|
|
8471
8553
|
}
|
|
8472
8554
|
},
|
|
8473
8555
|
{
|
|
@@ -8477,7 +8559,7 @@ const k = [
|
|
|
8477
8559
|
style: "normal",
|
|
8478
8560
|
weight: "300 800",
|
|
8479
8561
|
display: "swap",
|
|
8480
|
-
unicodeRange:
|
|
8562
|
+
unicodeRange: P
|
|
8481
8563
|
}
|
|
8482
8564
|
},
|
|
8483
8565
|
{
|
|
@@ -8487,7 +8569,7 @@ const k = [
|
|
|
8487
8569
|
style: "normal",
|
|
8488
8570
|
weight: "400",
|
|
8489
8571
|
display: "swap",
|
|
8490
|
-
unicodeRange:
|
|
8572
|
+
unicodeRange: F
|
|
8491
8573
|
}
|
|
8492
8574
|
},
|
|
8493
8575
|
{
|
|
@@ -8497,7 +8579,7 @@ const k = [
|
|
|
8497
8579
|
style: "normal",
|
|
8498
8580
|
weight: "400",
|
|
8499
8581
|
display: "swap",
|
|
8500
|
-
unicodeRange:
|
|
8582
|
+
unicodeRange: P
|
|
8501
8583
|
}
|
|
8502
8584
|
},
|
|
8503
8585
|
{
|
|
@@ -8507,7 +8589,7 @@ const k = [
|
|
|
8507
8589
|
style: "normal",
|
|
8508
8590
|
weight: "700",
|
|
8509
8591
|
display: "swap",
|
|
8510
|
-
unicodeRange:
|
|
8592
|
+
unicodeRange: F
|
|
8511
8593
|
}
|
|
8512
8594
|
},
|
|
8513
8595
|
{
|
|
@@ -8517,7 +8599,7 @@ const k = [
|
|
|
8517
8599
|
style: "normal",
|
|
8518
8600
|
weight: "700",
|
|
8519
8601
|
display: "swap",
|
|
8520
|
-
unicodeRange:
|
|
8602
|
+
unicodeRange: P
|
|
8521
8603
|
}
|
|
8522
8604
|
},
|
|
8523
8605
|
{
|
|
@@ -8527,7 +8609,7 @@ const k = [
|
|
|
8527
8609
|
style: "normal",
|
|
8528
8610
|
weight: "300 900",
|
|
8529
8611
|
display: "swap",
|
|
8530
|
-
unicodeRange:
|
|
8612
|
+
unicodeRange: F
|
|
8531
8613
|
}
|
|
8532
8614
|
},
|
|
8533
8615
|
{
|
|
@@ -8537,7 +8619,7 @@ const k = [
|
|
|
8537
8619
|
style: "normal",
|
|
8538
8620
|
weight: "300 900",
|
|
8539
8621
|
display: "swap",
|
|
8540
|
-
unicodeRange:
|
|
8622
|
+
unicodeRange: P
|
|
8541
8623
|
}
|
|
8542
8624
|
},
|
|
8543
8625
|
{
|
|
@@ -8547,7 +8629,7 @@ const k = [
|
|
|
8547
8629
|
style: "normal",
|
|
8548
8630
|
weight: "400",
|
|
8549
8631
|
display: "swap",
|
|
8550
|
-
unicodeRange:
|
|
8632
|
+
unicodeRange: F
|
|
8551
8633
|
}
|
|
8552
8634
|
},
|
|
8553
8635
|
{
|
|
@@ -8557,7 +8639,7 @@ const k = [
|
|
|
8557
8639
|
style: "normal",
|
|
8558
8640
|
weight: "400",
|
|
8559
8641
|
display: "swap",
|
|
8560
|
-
unicodeRange:
|
|
8642
|
+
unicodeRange: P
|
|
8561
8643
|
}
|
|
8562
8644
|
},
|
|
8563
8645
|
{
|
|
@@ -8567,7 +8649,7 @@ const k = [
|
|
|
8567
8649
|
style: "normal",
|
|
8568
8650
|
weight: "100 900",
|
|
8569
8651
|
display: "swap",
|
|
8570
|
-
unicodeRange:
|
|
8652
|
+
unicodeRange: F
|
|
8571
8653
|
}
|
|
8572
8654
|
},
|
|
8573
8655
|
{
|
|
@@ -8577,7 +8659,7 @@ const k = [
|
|
|
8577
8659
|
style: "normal",
|
|
8578
8660
|
weight: "100 900",
|
|
8579
8661
|
display: "swap",
|
|
8580
|
-
unicodeRange:
|
|
8662
|
+
unicodeRange: P
|
|
8581
8663
|
}
|
|
8582
8664
|
},
|
|
8583
8665
|
{
|
|
@@ -8587,7 +8669,7 @@ const k = [
|
|
|
8587
8669
|
style: "normal",
|
|
8588
8670
|
weight: "100 900",
|
|
8589
8671
|
display: "swap",
|
|
8590
|
-
unicodeRange:
|
|
8672
|
+
unicodeRange: F
|
|
8591
8673
|
}
|
|
8592
8674
|
},
|
|
8593
8675
|
{
|
|
@@ -8597,7 +8679,7 @@ const k = [
|
|
|
8597
8679
|
style: "normal",
|
|
8598
8680
|
weight: "100 900",
|
|
8599
8681
|
display: "swap",
|
|
8600
|
-
unicodeRange:
|
|
8682
|
+
unicodeRange: P
|
|
8601
8683
|
}
|
|
8602
8684
|
}
|
|
8603
8685
|
], Gs = {
|
|
@@ -8695,13 +8777,13 @@ const k = [
|
|
|
8695
8777
|
fonts: Zs
|
|
8696
8778
|
};
|
|
8697
8779
|
function Js(d, t = {}) {
|
|
8698
|
-
const e =
|
|
8780
|
+
const e = x(x({}, Gs), t), n = document.getElementById(d);
|
|
8699
8781
|
if (!n)
|
|
8700
8782
|
return Promise.reject(new Error(`Контейнер с ID "${d}" не найден.`));
|
|
8701
8783
|
const s = document.createElement("canvas");
|
|
8702
8784
|
return s.id = `${d}-canvas`, n.appendChild(s), e.editorContainer = n, new Promise((o) => {
|
|
8703
8785
|
e._onReadyCallback = o;
|
|
8704
|
-
const i = new
|
|
8786
|
+
const i = new Pe(s.id, e);
|
|
8705
8787
|
window[d] = i;
|
|
8706
8788
|
});
|
|
8707
8789
|
}
|