@anu3ev/fabric-image-editor 0.6.4 → 0.6.5
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 +1229 -1071
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
1
|
+
var Wn = Object.defineProperty, Yn = Object.defineProperties;
|
|
2
|
+
var Hn = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var de = Object.getOwnPropertySymbols;
|
|
4
|
+
var en = Object.prototype.hasOwnProperty, nn = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var Oe = Math.pow, tn = (h, t, e) => t in h ? Wn(h, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : h[t] = e, P = (h, t) => {
|
|
6
6
|
for (var e in t || (t = {}))
|
|
7
|
-
|
|
8
|
-
if (
|
|
9
|
-
for (var e of
|
|
10
|
-
|
|
7
|
+
en.call(t, e) && tn(h, e, t[e]);
|
|
8
|
+
if (de)
|
|
9
|
+
for (var e of de(t))
|
|
10
|
+
nn.call(t, e) && tn(h, e, t[e]);
|
|
11
11
|
return h;
|
|
12
|
-
}, yt = (h, t) =>
|
|
12
|
+
}, yt = (h, t) => Yn(h, Hn(t));
|
|
13
13
|
var St = (h, t) => {
|
|
14
14
|
var e = {};
|
|
15
15
|
for (var n in h)
|
|
16
|
-
|
|
17
|
-
if (h != null &&
|
|
18
|
-
for (var n of
|
|
19
|
-
t.indexOf(n) < 0 &&
|
|
16
|
+
en.call(h, n) && t.indexOf(n) < 0 && (e[n] = h[n]);
|
|
17
|
+
if (h != null && de)
|
|
18
|
+
for (var n of de(h))
|
|
19
|
+
t.indexOf(n) < 0 && nn.call(h, n) && (e[n] = h[n]);
|
|
20
20
|
return e;
|
|
21
21
|
};
|
|
22
22
|
var G = (h, t, e) => new Promise((n, s) => {
|
|
@@ -35,16 +35,16 @@ var G = (h, t, e) => new Promise((n, s) => {
|
|
|
35
35
|
}, a = (r) => r.done ? n(r.value) : Promise.resolve(r.value).then(i, o);
|
|
36
36
|
a((e = e.apply(h, t)).next());
|
|
37
37
|
});
|
|
38
|
-
import { ActiveSelection as q, Textbox as rt, util as bt, controlsUtils as
|
|
39
|
-
import { create as
|
|
40
|
-
import
|
|
41
|
-
var
|
|
38
|
+
import { ActiveSelection as q, Textbox as rt, util as bt, controlsUtils as sn, InteractiveFabricObject as on, Point as ct, FitContentLayout as an, loadSVGFromURL as Gn, FabricImage as Kt, Gradient as rn, Rect as Zn, Circle as Vn, Triangle as Xn, Group as Pt, Color as Kn, classRegistry as cn, loadSVGFromString as qn, Canvas as Jn, Pattern as $n } from "fabric";
|
|
39
|
+
import { create as Qn } from "jsondiffpatch";
|
|
40
|
+
import ts from "diff-match-patch";
|
|
41
|
+
var es = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", et = 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 += es[n[t] & 63];
|
|
44
44
|
return e;
|
|
45
45
|
};
|
|
46
|
-
const
|
|
47
|
-
class
|
|
46
|
+
const ln = 300;
|
|
47
|
+
class He {
|
|
48
48
|
/**
|
|
49
49
|
* Конструктор принимает редактор и опции.
|
|
50
50
|
* @param params
|
|
@@ -61,7 +61,7 @@ class Ye {
|
|
|
61
61
|
* @param params.options.adaptCanvasToContainerOnResize — адаптировать канвас к размерам контейнера при изменении размеров окна
|
|
62
62
|
*/
|
|
63
63
|
constructor({ editor: t, options: e = {} }) {
|
|
64
|
-
this.isDragging = !1, this.lastMouseX = 0, this.lastMouseY = 0, this.isUndoRedoKeyPressed = !1, this.isSpacePressed = !1, this.savedSelection = [], this.canvasDragging = !1, this.mouseWheelZooming = !1, this.resetObjectFitByDoubleClick = !1, this.copyObjectsByHotkey = !1, this.pasteImageFromClipboard = !1, this.undoRedoByHotKeys = !1, this.selectAllByHotkey = !1, this.deleteObjectsByHotkey = !1, this.adaptCanvasToContainerOnResize = !1, this.editor = t, this.canvas = t.canvas, this.options = e, this.handleContainerResizeBound =
|
|
64
|
+
this.isDragging = !1, this.lastMouseX = 0, this.lastMouseY = 0, this.isUndoRedoKeyPressed = !1, this.isSpacePressed = !1, this.savedSelection = [], this.canvasDragging = !1, this.mouseWheelZooming = !1, this.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 = He.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.handleResetObjectFitBound = this.handleResetObjectFit.bind(this), this.init();
|
|
65
65
|
}
|
|
66
66
|
/**
|
|
67
67
|
* Инициализация всех обработчиков согласно опциям.
|
|
@@ -87,14 +87,14 @@ class Ye {
|
|
|
87
87
|
handleObjectModifiedHistory() {
|
|
88
88
|
const { historyManager: t, textManager: e } = this.editor;
|
|
89
89
|
t.skipHistory || e.isTextEditingActive || t.scheduleSaveState({
|
|
90
|
-
delayMs:
|
|
90
|
+
delayMs: ln,
|
|
91
91
|
reason: "object-modified"
|
|
92
92
|
});
|
|
93
93
|
}
|
|
94
94
|
handleObjectRotatingHistory() {
|
|
95
95
|
const { historyManager: t, textManager: e } = this.editor;
|
|
96
96
|
t.skipHistory || e.isTextEditingActive || t.scheduleSaveState({
|
|
97
|
-
delayMs:
|
|
97
|
+
delayMs: ln,
|
|
98
98
|
reason: "object-rotating"
|
|
99
99
|
});
|
|
100
100
|
}
|
|
@@ -385,7 +385,7 @@ class Ye {
|
|
|
385
385
|
};
|
|
386
386
|
}
|
|
387
387
|
}
|
|
388
|
-
class
|
|
388
|
+
class ns {
|
|
389
389
|
/**
|
|
390
390
|
* Класс для динамической загрузки внешних модулей.
|
|
391
391
|
*/
|
|
@@ -403,7 +403,7 @@ class qn {
|
|
|
403
403
|
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}"`));
|
|
404
404
|
}
|
|
405
405
|
}
|
|
406
|
-
function
|
|
406
|
+
function ss(h) {
|
|
407
407
|
return new Worker(
|
|
408
408
|
"" + new URL("assets/worker-2TM2HcqM.js", import.meta.url).href,
|
|
409
409
|
{
|
|
@@ -411,13 +411,13 @@ function Jn(h) {
|
|
|
411
411
|
}
|
|
412
412
|
);
|
|
413
413
|
}
|
|
414
|
-
class
|
|
414
|
+
class is {
|
|
415
415
|
/**
|
|
416
416
|
* @param scriptUrl — URL скрипта воркера.
|
|
417
417
|
* По-умолчанию использует DefaultWorker из соседнего файла
|
|
418
418
|
*/
|
|
419
419
|
constructor(t) {
|
|
420
|
-
t ? this.worker = new Worker(t, { type: "module" }) : this.worker = new
|
|
420
|
+
t ? this.worker = new Worker(t, { type: "module" }) : this.worker = new ss(), this._callbacks = /* @__PURE__ */ new Map(), this.worker.onmessage = this._handleMessage.bind(this);
|
|
421
421
|
}
|
|
422
422
|
/**
|
|
423
423
|
* Обработчик сообщений от воркера
|
|
@@ -457,50 +457,50 @@ class Qn {
|
|
|
457
457
|
this.worker.terminate();
|
|
458
458
|
}
|
|
459
459
|
}
|
|
460
|
-
const wt = 12,
|
|
461
|
-
function
|
|
462
|
-
const i = wt, o =
|
|
463
|
-
h.save(), h.translate(t, e), h.rotate(bt.degreesToRadians(s.angle)), h.fillStyle =
|
|
460
|
+
const wt = 12, os = 2, Re = 8, ke = 20, as = 100, Be = 20, Ne = 8, rs = 100, pe = 32, Ge = 1, cs = "#2B2D33", Ze = "#3D8BF4", Ve = "#FFFFFF";
|
|
461
|
+
function he(h, t, e, n, s) {
|
|
462
|
+
const i = wt, o = os;
|
|
463
|
+
h.save(), h.translate(t, e), h.rotate(bt.degreesToRadians(s.angle)), h.fillStyle = Ve, h.strokeStyle = Ze, h.lineWidth = Ge, h.beginPath(), h.roundRect(-i / 2, -i / 2, i, i, o), h.fill(), h.stroke(), h.restore();
|
|
464
464
|
}
|
|
465
|
-
function
|
|
466
|
-
const i =
|
|
467
|
-
h.save(), h.translate(t, e), h.rotate(bt.degreesToRadians(s.angle)), h.fillStyle =
|
|
465
|
+
function dn(h, t, e, n, s) {
|
|
466
|
+
const i = Re, o = ke, a = as;
|
|
467
|
+
h.save(), h.translate(t, e), h.rotate(bt.degreesToRadians(s.angle)), h.fillStyle = Ve, h.strokeStyle = Ze, h.lineWidth = Ge, h.beginPath(), h.roundRect(-i / 2, -o / 2, i, o, a), h.fill(), h.stroke(), h.restore();
|
|
468
468
|
}
|
|
469
|
-
function
|
|
470
|
-
const i =
|
|
471
|
-
h.save(), h.translate(t, e), h.rotate(bt.degreesToRadians(s.angle)), h.fillStyle =
|
|
469
|
+
function hn(h, t, e, n, s) {
|
|
470
|
+
const i = Be, o = Ne, a = rs;
|
|
471
|
+
h.save(), h.translate(t, e), h.rotate(bt.degreesToRadians(s.angle)), h.fillStyle = Ve, h.strokeStyle = Ze, h.lineWidth = Ge, h.beginPath(), h.roundRect(-i / 2, -o / 2, i, o, a), h.fill(), h.stroke(), h.restore();
|
|
472
472
|
}
|
|
473
|
-
const
|
|
474
|
-
|
|
475
|
-
function
|
|
476
|
-
const o =
|
|
477
|
-
h.save(), h.translate(t, e), h.rotate(bt.degreesToRadians(s.angle)), h.fillStyle =
|
|
473
|
+
const ls = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTE4Ljc1IDQuMzc1djMuNzVhLjYyNS42MjUgMCAwIDEtLjYyNS42MjVoLTMuNzVhLjYyNS42MjUgMCAwIDEgMC0xLjI1aDIuMTRsLTIuMDc3LTEuOTAzLS4wMi0uMDE5YTYuMjUgNi4yNSAwIDEgMC0uMTMgOC45NjcuNjI2LjYyNiAwIDAgMSAuODYuOTA5QTcuNDU2IDcuNDU2IDAgMCAxIDEwIDE3LjVoLS4xMDNhNy41IDcuNSAwIDEgMSA1LjM5Ni0xMi44MTJMMTcuNSA2LjcwM1Y0LjM3NWEuNjI1LjYyNSAwIDAgMSAxLjI1IDBaIi8+PC9zdmc+", _n = new Image();
|
|
474
|
+
_n.src = ls;
|
|
475
|
+
function ds(h, t, e, n, s) {
|
|
476
|
+
const o = pe / 2;
|
|
477
|
+
h.save(), h.translate(t, e), h.rotate(bt.degreesToRadians(s.angle)), h.fillStyle = cs, h.beginPath(), h.arc(0, 0, o, 0, 2 * Math.PI), h.fill(), h.drawImage(_n, -o / 2, -o / 2, o, o), h.restore();
|
|
478
478
|
}
|
|
479
|
-
const
|
|
479
|
+
const hs = {
|
|
480
480
|
// Угловые точки
|
|
481
481
|
tl: {
|
|
482
|
-
render:
|
|
482
|
+
render: he,
|
|
483
483
|
sizeX: wt,
|
|
484
484
|
sizeY: wt,
|
|
485
485
|
offsetX: 0,
|
|
486
486
|
offsetY: 0
|
|
487
487
|
},
|
|
488
488
|
tr: {
|
|
489
|
-
render:
|
|
489
|
+
render: he,
|
|
490
490
|
sizeX: wt,
|
|
491
491
|
sizeY: wt,
|
|
492
492
|
offsetX: 0,
|
|
493
493
|
offsetY: 0
|
|
494
494
|
},
|
|
495
495
|
bl: {
|
|
496
|
-
render:
|
|
496
|
+
render: he,
|
|
497
497
|
sizeX: wt,
|
|
498
498
|
sizeY: wt,
|
|
499
499
|
offsetX: 0,
|
|
500
500
|
offsetY: 0
|
|
501
501
|
},
|
|
502
502
|
br: {
|
|
503
|
-
render:
|
|
503
|
+
render: he,
|
|
504
504
|
sizeX: wt,
|
|
505
505
|
sizeY: wt,
|
|
506
506
|
offsetX: 0,
|
|
@@ -508,41 +508,41 @@ const os = {
|
|
|
508
508
|
},
|
|
509
509
|
// Середина вертикалей
|
|
510
510
|
ml: {
|
|
511
|
-
render:
|
|
512
|
-
sizeX:
|
|
511
|
+
render: dn,
|
|
512
|
+
sizeX: Re,
|
|
513
513
|
sizeY: ke,
|
|
514
514
|
offsetX: 0,
|
|
515
515
|
offsetY: 0
|
|
516
516
|
},
|
|
517
517
|
mr: {
|
|
518
|
-
render:
|
|
519
|
-
sizeX:
|
|
518
|
+
render: dn,
|
|
519
|
+
sizeX: Re,
|
|
520
520
|
sizeY: ke,
|
|
521
521
|
offsetX: 0,
|
|
522
522
|
offsetY: 0
|
|
523
523
|
},
|
|
524
524
|
// Середина горизонталей
|
|
525
525
|
mt: {
|
|
526
|
-
render:
|
|
527
|
-
sizeX:
|
|
528
|
-
sizeY:
|
|
526
|
+
render: hn,
|
|
527
|
+
sizeX: Be,
|
|
528
|
+
sizeY: Ne,
|
|
529
529
|
offsetX: 0,
|
|
530
530
|
offsetY: 0
|
|
531
531
|
},
|
|
532
532
|
mb: {
|
|
533
|
-
render:
|
|
534
|
-
sizeX:
|
|
535
|
-
sizeY:
|
|
533
|
+
render: hn,
|
|
534
|
+
sizeX: Be,
|
|
535
|
+
sizeY: Ne,
|
|
536
536
|
offsetX: 0,
|
|
537
537
|
offsetY: 0
|
|
538
538
|
},
|
|
539
539
|
// Специальный «rotate» контрол
|
|
540
540
|
mtr: {
|
|
541
|
-
render:
|
|
542
|
-
sizeX:
|
|
543
|
-
sizeY:
|
|
541
|
+
render: ds,
|
|
542
|
+
sizeX: pe,
|
|
543
|
+
sizeY: pe,
|
|
544
544
|
offsetX: 0,
|
|
545
|
-
offsetY: -
|
|
545
|
+
offsetY: -pe
|
|
546
546
|
}
|
|
547
547
|
};
|
|
548
548
|
class ut {
|
|
@@ -561,7 +561,7 @@ class ut {
|
|
|
561
561
|
* Применяет конфигурацию контролов к набору по ключам из DEFAULT_CONTROLS.
|
|
562
562
|
*/
|
|
563
563
|
static applyControlOverrides(t) {
|
|
564
|
-
Object.entries(
|
|
564
|
+
Object.entries(hs).forEach(([e, n]) => {
|
|
565
565
|
const s = t[e];
|
|
566
566
|
s && (Object.assign(s, n), e === "mtr" && (s.cursorStyle = "grab", s.mouseDownHandler = (i, o, a, r) => {
|
|
567
567
|
var l;
|
|
@@ -574,10 +574,10 @@ class ut {
|
|
|
574
574
|
* Регистрирует контролы и настройки поведения выделений.
|
|
575
575
|
*/
|
|
576
576
|
static apply() {
|
|
577
|
-
const t =
|
|
578
|
-
ut.applyControlOverrides(t),
|
|
579
|
-
const e =
|
|
580
|
-
ut.applyControlOverrides(e), e.mt && (e.mt.visible = !1), e.mb && (e.mb.visible = !1), ut.wrapWidthControl(e.ml), ut.wrapWidthControl(e.mr), rt.ownDefaults.controls = e, ut.patchActiveSelectionBounds(),
|
|
577
|
+
const t = sn.createObjectDefaultControls();
|
|
578
|
+
ut.applyControlOverrides(t), on.ownDefaults.controls = t;
|
|
579
|
+
const e = sn.createTextboxDefaultControls();
|
|
580
|
+
ut.applyControlOverrides(e), e.mt && (e.mt.visible = !1), e.mb && (e.mb.visible = !1), ut.wrapWidthControl(e.ml), ut.wrapWidthControl(e.mr), rt.ownDefaults.controls = e, ut.patchActiveSelectionBounds(), on.ownDefaults.snapAngle = 1;
|
|
581
581
|
}
|
|
582
582
|
/**
|
|
583
583
|
* Обновляет алгоритм расчёта границ ActiveSelection, чтобы учитывать фон и отступы текстовых объектов.
|
|
@@ -624,8 +624,8 @@ class ut {
|
|
|
624
624
|
height: f
|
|
625
625
|
}), this.setPositionByOrigin(p, "center", "center"), this.setCoords(), a;
|
|
626
626
|
};
|
|
627
|
-
const s =
|
|
628
|
-
|
|
627
|
+
const s = an.prototype.calcBoundingBox;
|
|
628
|
+
an.prototype.calcBoundingBox = function(i, o) {
|
|
629
629
|
const { target: a, type: r, overrides: c } = o;
|
|
630
630
|
if (r === "imperative" && c)
|
|
631
631
|
return c;
|
|
@@ -848,8 +848,8 @@ K.registeredFontKeys = /* @__PURE__ */ new Set(), K.descriptorDefaults = {
|
|
|
848
848
|
featureSettings: "normal",
|
|
849
849
|
display: "auto"
|
|
850
850
|
};
|
|
851
|
-
let
|
|
852
|
-
const
|
|
851
|
+
let Pe = K;
|
|
852
|
+
const us = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNNi44NzUgMi41YS42MjUuNjI1IDAgMCAwLS42MjUuNjI0VjYuMjVIMy4xMjVhLjYyNS42MjUgMCAwIDAtLjYyNS42MjV2MTBjMCAuMzQ1LjI4LjYyNS42MjUuNjI1aDEwYy4zNDUgMCAuNjI1LS4yOC42MjUtLjYyNXYtMy4xMjZoMy4xMjVjLjM0NSAwIC42MjUtLjI4LjYyNS0uNjI1di0xMGEuNjI1LjYyNSAwIDAgMC0uNjI1LS42MjVoLTEwWm02Ljg3NSAxMGgyLjVWMy43NUg3LjV2Mi41aDUuNjI1Yy4zNDUgMCAuNjI1LjI4LjYyNS42MjV2NS42MjRabS0xMCAzLjc1VjcuNWg4Ljc1djguNzVIMy43NVoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjwvc3ZnPg==", fs = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMi41IDcuNWMwLS42OS41Ni0xLjI1IDEuMjUtMS4yNWgxMi41Yy42OSAwIDEuMjUuNTYgMS4yNSAxLjI1djguNzVjMCAuNjktLjU2IDEuMjUtMS4yNSAxLjI1SDMuNzVjLS42OSAwLTEuMjUtLjU2LTEuMjUtMS4yNVY3LjVabTEzLjc1IDBIMy43NXY4Ljc1aDEyLjVWNy41WiIgY2xpcC1ydWxlPSJldmVub2RkIi8+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMTAgMS44NzVhMi4xODggMi4xODggMCAwIDAtMi4xODggMi4xODh2Mi44MTJhLjYyNS42MjUgMCAxIDEtMS4yNSAwVjQuMDYyYTMuNDM3IDMuNDM3IDAgMSAxIDYuODc1IDB2Mi44MTNhLjYyNS42MjUgMCAxIDEtMS4yNSAwVjQuMDYyQTIuMTg4IDIuMTg4IDAgMCAwIDEwIDEuODc2WiIgY2xpcC1ydWxlPSJldmVub2RkIi8+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTEwIDEyLjgxM2EuOTM3LjkzNyAwIDEgMCAwLTEuODc1LjkzNy45MzcgMCAwIDAgMCAxLjg3NFoiLz48L3N2Zz4=", gs = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTE2LjI1IDYuMjVINy41VjQuMzc1YTIuNSAyLjUgMCAwIDEgMi41LTIuNWMxLjIgMCAyLjI4MS44NiAyLjUxMiAyYS42MjUuNjI1IDAgMCAwIDEuMjI2LS4yNWMtLjM1NC0xLjczOC0xLjkyNS0zLTMuNzM4LTNhMy43NTQgMy43NTQgMCAwIDAtMy43NSAzLjc1VjYuMjVoLTIuNUExLjI1IDEuMjUgMCAwIDAgMi41IDcuNXY4Ljc1YTEuMjUgMS4yNSAwIDAgMCAxLjI1IDEuMjVoMTIuNWExLjI1IDEuMjUgMCAwIDAgMS4yNS0xLjI1VjcuNWExLjI1IDEuMjUgMCAwIDAtMS4yNS0xLjI1Wm0wIDEwSDMuNzVWNy41aDEyLjV2OC43NVptLTUuMzEzLTQuMzc1YS45MzcuOTM3IDAgMSAxLTEuODc0IDAgLjkzNy45MzcgMCAwIDEgMS44NzQgMFoiLz48L3N2Zz4K", ps = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTIuNSA4LjEyNSAxMCAxMi41bDcuNS00LjM3NUwxMCAzLjc1IDIuNSA4LjEyNVoiLz48cGF0aCBmaWxsPSIjZmZmIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik05LjY4NSAzLjIxYS42MjUuNjI1IDAgMCAxIC42MyAwbDcuNSA0LjM3NWEuNjI1LjYyNSAwIDAgMSAwIDEuMDhsLTcuNSA0LjM3NWEuNjI1LjYyNSAwIDAgMS0uNjMgMGwtNy41LTQuMzc1YS42MjUuNjI1IDAgMCAxIDAtMS4wOGw3LjUtNC4zNzVaTTMuNzQgOC4xMjUgMTAgMTEuNzc2bDYuMjYtMy42NTFMMTAgNC40NzQgMy43NCA4LjEyNVoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjxwYXRoIGZpbGw9IiNmZmYiIGZpbGwtcnVsZT0iZXZlbm9kZCIgZD0iTTUuNCA5LjQ2YS42MjUuNjI1IDAgMCAxIC42MyAwTDEwIDExLjc3NmwzLjk3LTIuMzE2YS42MjUuNjI1IDAgMCAxIC42MyAwbDMuMjE1IDEuODc1YS42MjUuNjI1IDAgMCAxIDAgMS4wOGwtNy41IDQuMzc1YS42MjUuNjI1IDAgMCAxLS42MyAwbC03LjUtNC4zNzVhLjYyNS42MjUgMCAwIDEgMC0xLjA4TDUuNCA5LjQ2Wm0tMS42NiAyLjQxNUwxMCAxNS41MjZsNi4yNi0zLjY1MS0xLjk3NC0xLjE1MS0zLjk3MSAyLjMxNmEuNjI1LjYyNSAwIDAgMS0uNjMgMGwtMy45Ny0yLjMxNi0xLjk3NSAxLjE1MVoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjwvc3ZnPg==", ms = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNOS42ODUgMy4yMWEuNjI1LjYyNSAwIDAgMSAuNjMgMGw3LjUgNC4zNzVhLjYyNS42MjUgMCAwIDEgMCAxLjA4bC03LjUgNC4zNzVhLjYyNS42MjUgMCAwIDEtLjYzIDBsLTcuNS00LjM3NWEuNjI1LjYyNSAwIDAgMSAwLTEuMDhsNy41LTQuMzc1Wk0zLjc0IDguMTI1IDEwIDExLjc3Nmw2LjI2LTMuNjUxTDEwIDQuNDc0IDMuNzQgOC4xMjVaIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiLz48cGF0aCBmaWxsPSIjZmZmIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik01LjcxNCAxMCAxMCAxMi41bDQuMjg2LTIuNSAzLjIxNCAxLjg3NUwxMCAxNi4yNWwtNy41LTQuMzc1TDUuNzE0IDEwWiIgY2xpcC1ydWxlPSJldmVub2RkIi8+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNNS40IDkuNDZhLjYyNS42MjUgMCAwIDEgLjYzIDBMMTAgMTEuNzc2bDMuOTctMi4zMTZhLjYyNS42MjUgMCAwIDEgLjYzIDBsMy4yMTUgMS44NzVhLjYyNS42MjUgMCAwIDEgMCAxLjA4bC03LjUgNC4zNzVhLjYyNS42MjUgMCAwIDEtLjYzIDBsLTcuNS00LjM3NWEuNjI1LjYyNSAwIDAgMSAwLTEuMDhMNS40IDkuNDZabS0xLjY2IDIuNDE1TDEwIDE1LjUyNmw2LjI2LTMuNjUxLTEuOTc0LTEuMTUxLTMuOTcxIDIuMzE2YS42MjUuNjI1IDAgMCAxLS42MyAwbC0zLjk3LTIuMzE2LTEuOTc1IDEuMTUxWiIgY2xpcC1ydWxlPSJldmVub2RkIi8+PC9zdmc+", ys = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0ibTIuNSA2LjI1IDcuNSA0LjM3NSA3LjUtNC4zNzVMMTAgMS44NzUgMi41IDYuMjVaIi8+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNOS42ODUgMS4zMzVhLjYyNS42MjUgMCAwIDEgLjYzIDBsNy41IDQuMzc1YS42MjUuNjI1IDAgMCAxIDAgMS4wOGwtNy41IDQuMzc1YS42MjUuNjI1IDAgMCAxLS42MyAwbC03LjUtNC4zNzVhLjYyNS42MjUgMCAwIDEgMC0xLjA4bDcuNS00LjM3NVpNMy43NCA2LjI1IDEwIDkuOTAxbDYuMjYtMy42NTFMMTAgMi41OTkgMy43NCA2LjI1WiIgY2xpcC1ydWxlPSJldmVub2RkIi8+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNNS40IDExLjMzNWEuNjI1LjYyNSAwIDAgMSAuNjMgMEwxMCAxMy42NTFsMy45Ny0yLjMxNmEuNjI1LjYyNSAwIDAgMSAuNjMgMGwzLjIxNSAxLjg3NWEuNjI1LjYyNSAwIDAgMSAwIDEuMDhsLTcuNSA0LjM3NWEuNjI1LjYyNSAwIDAgMS0uNjMgMGwtNy41LTQuMzc1YS42MjUuNjI1IDAgMCAxIDAtMS4wOEw1LjQgMTEuMzM1Wk0zLjc0IDEzLjc1IDEwIDE3LjQwMWw2LjI2LTMuNjUxLTEuOTc0LTEuMTUxLTMuOTcxIDIuMzE2YS42MjUuNjI1IDAgMCAxLS42MyAwbC0zLjk3LTIuMzE2TDMuNzQgMTMuNzVaIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiLz48cGF0aCBmaWxsPSIjZmZmIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik01LjQgNy41ODVhLjYyNS42MjUgMCAwIDEgLjYzIDBMMTAgOS45MDFsMy45Ny0yLjMxNmEuNjI1LjYyNSAwIDAgMSAuNjMgMGwzLjIxNSAxLjg3NWEuNjI1LjYyNSAwIDAgMSAwIDEuMDhsLTcuNSA0LjM3NWEuNjI1LjYyNSAwIDAgMS0uNjMgMGwtNy41LTQuMzc1YS42MjUuNjI1IDAgMCAxIDAtMS4wOEw1LjQgNy41ODVaTTMuNzQgMTAgMTAgMTMuNjUxIDE2LjI2IDEwbC0xLjk3NC0xLjE1MS0zLjk3MSAyLjMxNmEuNjI1LjYyNSAwIDAgMS0uNjMgMGwtMy45Ny0yLjMxNkwzLjc0IDEwWiIgY2xpcC1ydWxlPSJldmVub2RkIi8+PC9zdmc+", bs = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMS45NiAxMy40MzVhLjYyNS42MjUgMCAwIDEgLjg1NS0uMjI1TDEwIDE3LjQwMWw3LjE4NS00LjE5YS42MjUuNjI1IDAgMCAxIC42MyAxLjA3OWwtNy41IDQuMzc1YS42MjUuNjI1IDAgMCAxLS42MyAwbC03LjUtNC4zNzVhLjYyNS42MjUgMCAwIDEtLjIyNS0uODU1Wk05LjY4NSAxLjMzNWEuNjI1LjYyNSAwIDAgMSAuNjMgMGw3LjUgNC4zNzVhLjYyNS42MjUgMCAwIDEgMCAxLjA4bC03LjUgNC4zNzVhLjYyNS42MjUgMCAwIDEtLjYzIDBsLTcuNS00LjM3NWEuNjI1LjYyNSAwIDAgMSAwLTEuMDhsNy41LTQuMzc1Wk0zLjc0IDYuMjUgMTAgOS45MDFsNi4yNi0zLjY1MUwxMCAyLjU5OSAzLjc0IDYuMjVaIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiLz48cGF0aCBmaWxsPSIjZmZmIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGQ9Im01LjcxNCAxMS44NzUgNC4yODYgMi41IDQuMjg2LTIuNUwxNy41IDEzLjc1IDEwIDE4LjEyNSAyLjUgMTMuNzVsMy4yMTQtMS44NzVaIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiLz48cGF0aCBmaWxsPSIjZmZmIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik01LjQgMTEuMzM1YS42MjUuNjI1IDAgMCAxIC42MyAwTDEwIDEzLjY1MWwzLjk3LTIuMzE2YS42MjUuNjI1IDAgMCAxIC42MyAwbDMuMjE1IDEuODc1YS42MjUuNjI1IDAgMCAxIDAgMS4wOGwtNy41IDQuMzc1YS42MjUuNjI1IDAgMCAxLS42MyAwbC03LjUtNC4zNzVhLjYyNS42MjUgMCAwIDEgMC0xLjA4TDUuNCAxMS4zMzVaTTMuNzQgMTMuNzUgMTAgMTcuNDAxbDYuMjYtMy42NTEtMS45NzQtMS4xNTEtMy45NzEgMi4zMTZhLjYyNS42MjUgMCAwIDEtLjYzIDBsLTMuOTctMi4zMTZMMy43NCAxMy43NVoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjxwYXRoIGZpbGw9IiNmZmYiIGZpbGwtcnVsZT0iZXZlbm9kZCIgZD0iTTUuNCA3LjU4NWEuNjI1LjYyNSAwIDAgMSAuNjMgMEwxMCA5LjkwMWwzLjk3LTIuMzE2YS42MjUuNjI1IDAgMCAxIC42MyAwbDMuMjE1IDEuODc1YS42MjUuNjI1IDAgMCAxIDAgMS4wOGwtNy41IDQuMzc1YS42MjUuNjI1IDAgMCAxLS42MyAwbC03LjUtNC4zNzVhLjYyNS42MjUgMCAwIDEgMC0xLjA4TDUuNCA3LjU4NVpNMy43NCAxMCAxMCAxMy42NTEgMTYuMjYgMTBsLTEuOTc0LTEuMTUxLTMuOTcxIDIuMzE2YS42MjUuNjI1IDAgMCAxLS42MyAwbC0zLjk3LTIuMzE2TDMuNzQgMTBaIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiLz48L3N2Zz4=", vs = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI0VDNEU0MCIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNOC4xMjUgMS4yNUExLjg3NSAxLjg3NSAwIDAgMCA2LjI1IDMuMTI1di42MjVIMy4xMjVhLjYyNS42MjUgMCAwIDAgMCAxLjI1aC42MjV2MTEuMjVBMS4yNSAxLjI1IDAgMCAwIDUgMTcuNWgxMGExLjI1IDEuMjUgMCAwIDAgMS4yNS0xLjI1VjVoLjYyNWEuNjI1LjYyNSAwIDAgMCAwLTEuMjVIMTMuNzV2LS42MjVhMS44NzUgMS44NzUgMCAwIDAtMS44NzUtMS44NzVoLTMuNzVabTQuMzc1IDIuNXYtLjYyNWEuNjI1LjYyNSAwIDAgMC0uNjI1LS42MjVoLTMuNzVhLjYyNS42MjUgMCAwIDAtLjYyNS42MjV2LjYyNWg1Wk01IDE2LjI1VjVoMTB2MTEuMjVINVpNOC4xMjUgNy41Yy4zNDUgMCAuNjI1LjI4LjYyNS42MjV2NWEuNjI1LjYyNSAwIDEgMS0xLjI1IDB2LTVjMC0uMzQ1LjI4LS42MjUuNjI1LS42MjVabTQuMzc1IDUuNjI1di01YS42MjUuNjI1IDAgMCAwLTEuMjUgMHY1YS42MjUuNjI1IDAgMSAwIDEuMjUgMFoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjwvc3ZnPg==", qt = {
|
|
853
853
|
style: {
|
|
854
854
|
position: "absolute",
|
|
855
855
|
display: "none",
|
|
@@ -916,14 +916,14 @@ const as = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMj
|
|
|
916
916
|
],
|
|
917
917
|
offsetTop: 50,
|
|
918
918
|
icons: {
|
|
919
|
-
copyPaste:
|
|
920
|
-
delete:
|
|
921
|
-
lock:
|
|
922
|
-
unlock:
|
|
923
|
-
bringToFront:
|
|
924
|
-
sendToBack:
|
|
925
|
-
bringForward:
|
|
926
|
-
sendBackwards:
|
|
919
|
+
copyPaste: us,
|
|
920
|
+
delete: vs,
|
|
921
|
+
lock: fs,
|
|
922
|
+
unlock: gs,
|
|
923
|
+
bringToFront: ys,
|
|
924
|
+
sendToBack: bs,
|
|
925
|
+
bringForward: ps,
|
|
926
|
+
sendBackwards: ms
|
|
927
927
|
},
|
|
928
928
|
handlers: {
|
|
929
929
|
copyPaste: (h) => G(null, null, function* () {
|
|
@@ -952,18 +952,18 @@ const as = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMj
|
|
|
952
952
|
}
|
|
953
953
|
}
|
|
954
954
|
};
|
|
955
|
-
class
|
|
955
|
+
class Ss {
|
|
956
956
|
constructor({ editor: t }) {
|
|
957
957
|
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();
|
|
958
958
|
}
|
|
959
959
|
_initToolbar() {
|
|
960
960
|
if (!this.options.showToolbar) return;
|
|
961
961
|
const t = this.options.toolbar || {};
|
|
962
|
-
this.config = yt(
|
|
963
|
-
style:
|
|
964
|
-
btnStyle:
|
|
965
|
-
icons:
|
|
966
|
-
handlers:
|
|
962
|
+
this.config = yt(P(P({}, qt), t), {
|
|
963
|
+
style: P(P({}, qt.style), t.style || {}),
|
|
964
|
+
btnStyle: P(P({}, qt.btnStyle), t.btnStyle || {}),
|
|
965
|
+
icons: P(P({}, qt.icons), t.icons || {}),
|
|
966
|
+
handlers: P(P({}, qt.handlers), t.handlers || {})
|
|
967
967
|
}), 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 = () => {
|
|
968
968
|
this.el.style.display = "none";
|
|
969
969
|
}, this._createDOM(), this._bindEvents();
|
|
@@ -1080,7 +1080,7 @@ class gs {
|
|
|
1080
1080
|
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();
|
|
1081
1081
|
}
|
|
1082
1082
|
}
|
|
1083
|
-
const
|
|
1083
|
+
const Ms = {
|
|
1084
1084
|
position: "absolute",
|
|
1085
1085
|
display: "none",
|
|
1086
1086
|
background: "#2B2D33",
|
|
@@ -1094,8 +1094,8 @@ const ps = {
|
|
|
1094
1094
|
"pointer-events": "none",
|
|
1095
1095
|
"white-space": "nowrap",
|
|
1096
1096
|
"box-shadow": "0 2px 8px rgba(0, 0, 0, 0.2)"
|
|
1097
|
-
},
|
|
1098
|
-
class
|
|
1097
|
+
}, un = 16, fn = 16, ws = "fabric-editor-angle-indicator";
|
|
1098
|
+
class Xe {
|
|
1099
1099
|
constructor({ editor: t }) {
|
|
1100
1100
|
this.isActive = !1, this.currentAngle = 0, this.editor = t, this.canvas = t.canvas, this.options = t.options, this._createDOM(), this._bindEvents();
|
|
1101
1101
|
}
|
|
@@ -1103,7 +1103,7 @@ class Ve {
|
|
|
1103
1103
|
* Создание DOM-элемента индикатора
|
|
1104
1104
|
*/
|
|
1105
1105
|
_createDOM() {
|
|
1106
|
-
this.el = document.createElement("div"), this.el.className =
|
|
1106
|
+
this.el = document.createElement("div"), this.el.className = ws, Object.entries(Ms).forEach(([t, e]) => {
|
|
1107
1107
|
this.el.style.setProperty(t, e);
|
|
1108
1108
|
}), this.canvas.wrapperEl.appendChild(this.el);
|
|
1109
1109
|
}
|
|
@@ -1123,7 +1123,7 @@ class Ve {
|
|
|
1123
1123
|
return;
|
|
1124
1124
|
}
|
|
1125
1125
|
const n = e.angle || 0;
|
|
1126
|
-
this.currentAngle =
|
|
1126
|
+
this.currentAngle = Xe._normalizeAngle(n), this.el.textContent = `${this.currentAngle}°`, this._positionIndicator(t.e), this.isActive || this._showIndicator();
|
|
1127
1127
|
}
|
|
1128
1128
|
/**
|
|
1129
1129
|
* Обработчик отпускания кнопки мыши
|
|
@@ -1154,9 +1154,9 @@ class Ve {
|
|
|
1154
1154
|
*/
|
|
1155
1155
|
_positionIndicator(t) {
|
|
1156
1156
|
const e = this.canvas.wrapperEl.getBoundingClientRect();
|
|
1157
|
-
let n = t.clientX - e.left +
|
|
1157
|
+
let n = t.clientX - e.left + un, s = t.clientY - e.top + fn;
|
|
1158
1158
|
const i = this.el.getBoundingClientRect(), o = i.width, a = i.height;
|
|
1159
|
-
n + o > e.width && (n = t.clientX - e.left - o -
|
|
1159
|
+
n + o > e.width && (n = t.clientX - e.left - o - un), s + a > e.height && (s = t.clientY - e.top - a - fn), this.el.style.left = `${n}px`, this.el.style.top = `${s}px`;
|
|
1160
1160
|
}
|
|
1161
1161
|
/**
|
|
1162
1162
|
* Показать индикатор
|
|
@@ -1187,7 +1187,7 @@ class Ve {
|
|
|
1187
1187
|
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;
|
|
1188
1188
|
}
|
|
1189
1189
|
}
|
|
1190
|
-
const
|
|
1190
|
+
const ze = [
|
|
1191
1191
|
"id",
|
|
1192
1192
|
"backgroundId",
|
|
1193
1193
|
"customData",
|
|
@@ -1226,7 +1226,7 @@ const Pe = [
|
|
|
1226
1226
|
"radiusBottomRight",
|
|
1227
1227
|
"radiusBottomLeft"
|
|
1228
1228
|
];
|
|
1229
|
-
class
|
|
1229
|
+
class $ {
|
|
1230
1230
|
constructor({ editor: t }) {
|
|
1231
1231
|
this.editor = t, this.canvas = t.canvas, this._isSavingState = !1, this._historySuspendCount = 0, this._isActionInProgress = !1, this._actionSnapshot = null, this._actionReason = null, this._pendingSaveTimeoutId = null, this._pendingSaveReason = null, this._hasDeferredSaveAfterUnblock = !1, this.baseState = null, this.patches = [], this.currentIndex = 0, this.maxHistoryLength = t.options.maxHistoryLength, this.totalChangesCount = 0, this.baseStateChangesCount = 0, this._createDiffPatcher();
|
|
1232
1232
|
}
|
|
@@ -1238,7 +1238,7 @@ class Q {
|
|
|
1238
1238
|
return this.patches[this.currentIndex - 1] || null;
|
|
1239
1239
|
}
|
|
1240
1240
|
_createDiffPatcher() {
|
|
1241
|
-
this.diffPatcher =
|
|
1241
|
+
this.diffPatcher = Qn({
|
|
1242
1242
|
objectHash(t) {
|
|
1243
1243
|
return [JSON.stringify(t)].join("-");
|
|
1244
1244
|
},
|
|
@@ -1247,7 +1247,7 @@ class Q {
|
|
|
1247
1247
|
includeValueOnMove: !1
|
|
1248
1248
|
},
|
|
1249
1249
|
textDiff: {
|
|
1250
|
-
diffMatchPatch:
|
|
1250
|
+
diffMatchPatch: ts,
|
|
1251
1251
|
minLength: 60
|
|
1252
1252
|
}
|
|
1253
1253
|
});
|
|
@@ -1342,7 +1342,7 @@ class Q {
|
|
|
1342
1342
|
*/
|
|
1343
1343
|
_serializeCanvasState() {
|
|
1344
1344
|
const { canvas: t } = this;
|
|
1345
|
-
return t.toDatalessObject([...
|
|
1345
|
+
return t.toDatalessObject([...ze]);
|
|
1346
1346
|
}
|
|
1347
1347
|
/**
|
|
1348
1348
|
* Обрабатывает срабатывание отложенного сохранения.
|
|
@@ -1407,7 +1407,7 @@ class Q {
|
|
|
1407
1407
|
this._isSavingState = !0, console.time("saveState");
|
|
1408
1408
|
try {
|
|
1409
1409
|
const t = this._withTemporaryUnlock(
|
|
1410
|
-
() => this.canvas.toDatalessObject([...
|
|
1410
|
+
() => this.canvas.toDatalessObject([...ze])
|
|
1411
1411
|
);
|
|
1412
1412
|
if (console.timeEnd("saveState"), !this.baseState) {
|
|
1413
1413
|
this.baseState = t, this.patches = [], this.currentIndex = 0, console.log("Базовое состояние сохранено.");
|
|
@@ -1416,7 +1416,7 @@ class Q {
|
|
|
1416
1416
|
const e = this.getFullState(), {
|
|
1417
1417
|
prevState: n,
|
|
1418
1418
|
nextState: s
|
|
1419
|
-
} =
|
|
1419
|
+
} = $._prepareStatesForDiff({
|
|
1420
1420
|
prevState: e,
|
|
1421
1421
|
nextState: t
|
|
1422
1422
|
}), i = this.diffPatcher.diff(n, s);
|
|
@@ -1424,7 +1424,7 @@ class Q {
|
|
|
1424
1424
|
console.log("Нет изменений для сохранения.");
|
|
1425
1425
|
return;
|
|
1426
1426
|
}
|
|
1427
|
-
if (
|
|
1427
|
+
if ($._areStatesEqual({
|
|
1428
1428
|
prevState: n,
|
|
1429
1429
|
nextState: s
|
|
1430
1430
|
})) {
|
|
@@ -1445,11 +1445,11 @@ class Q {
|
|
|
1445
1445
|
prevState: t,
|
|
1446
1446
|
nextState: e
|
|
1447
1447
|
}) {
|
|
1448
|
-
const n =
|
|
1449
|
-
return
|
|
1448
|
+
const n = $._cloneState({ state: t }), s = $._cloneState({ state: e });
|
|
1449
|
+
return $._normalizeTextBackground({ objects: n.objects }), $._normalizeTextBackground({ objects: s.objects }), $._normalizeCanvasSize({
|
|
1450
1450
|
prevState: n,
|
|
1451
1451
|
nextState: s
|
|
1452
|
-
}),
|
|
1452
|
+
}), $._normalizeTranslation({
|
|
1453
1453
|
prevState: n,
|
|
1454
1454
|
nextState: s
|
|
1455
1455
|
}), {
|
|
@@ -1473,7 +1473,7 @@ class Q {
|
|
|
1473
1473
|
prevState: t,
|
|
1474
1474
|
nextState: e
|
|
1475
1475
|
}) {
|
|
1476
|
-
const n =
|
|
1476
|
+
const n = $._stableStringify({ value: t }), s = $._stableStringify({ value: e });
|
|
1477
1477
|
return n === s;
|
|
1478
1478
|
}
|
|
1479
1479
|
/**
|
|
@@ -1528,10 +1528,10 @@ class Q {
|
|
|
1528
1528
|
const { width: n, height: s, objects: i } = t, { objects: o } = e, {
|
|
1529
1529
|
width: a,
|
|
1530
1530
|
height: r
|
|
1531
|
-
} =
|
|
1531
|
+
} = $._getMontageAreaSize({ objects: i }), {
|
|
1532
1532
|
width: c,
|
|
1533
1533
|
height: l
|
|
1534
|
-
} =
|
|
1534
|
+
} = $._getMontageAreaSize({ objects: o });
|
|
1535
1535
|
a !== c || r !== l || (e.width = n, e.height = s);
|
|
1536
1536
|
}
|
|
1537
1537
|
/**
|
|
@@ -1544,22 +1544,22 @@ class Q {
|
|
|
1544
1544
|
const { objects: n, clipPath: s } = t, { objects: i, clipPath: o } = e, {
|
|
1545
1545
|
left: a,
|
|
1546
1546
|
top: r
|
|
1547
|
-
} =
|
|
1547
|
+
} = $._getMontageAreaPosition({ objects: n }), {
|
|
1548
1548
|
left: c,
|
|
1549
1549
|
top: l
|
|
1550
|
-
} =
|
|
1550
|
+
} = $._getMontageAreaPosition({ objects: i }), d = c - a, u = l - r;
|
|
1551
1551
|
if (d === 0 && u === 0) return;
|
|
1552
|
-
const f =
|
|
1552
|
+
const f = $._getObjectById({
|
|
1553
1553
|
objects: i,
|
|
1554
1554
|
id: "montage-area"
|
|
1555
1555
|
});
|
|
1556
1556
|
f && (f.left = a, f.top = r);
|
|
1557
|
-
const p =
|
|
1557
|
+
const p = $._getClipPathPosition({ clipPath: s });
|
|
1558
1558
|
if (p && o && typeof o == "object") {
|
|
1559
1559
|
const { left: g, top: y } = p, b = o;
|
|
1560
1560
|
b.left = g, b.top = y;
|
|
1561
1561
|
}
|
|
1562
|
-
const m =
|
|
1562
|
+
const m = $._getTranslationIgnoredIds();
|
|
1563
1563
|
for (let g = 0; g < i.length; g += 1) {
|
|
1564
1564
|
const y = i[g], { id: b } = y;
|
|
1565
1565
|
b && m.has(b) || (typeof y.left == "number" && (y.left -= d), typeof y.top == "number" && (y.top -= u));
|
|
@@ -1581,7 +1581,7 @@ class Q {
|
|
|
1581
1581
|
static _getMontageAreaPosition({
|
|
1582
1582
|
objects: t
|
|
1583
1583
|
}) {
|
|
1584
|
-
const e =
|
|
1584
|
+
const e = $._getObjectById({
|
|
1585
1585
|
objects: t,
|
|
1586
1586
|
id: "montage-area"
|
|
1587
1587
|
});
|
|
@@ -1596,7 +1596,7 @@ class Q {
|
|
|
1596
1596
|
static _getMontageAreaSize({
|
|
1597
1597
|
objects: t
|
|
1598
1598
|
}) {
|
|
1599
|
-
const e =
|
|
1599
|
+
const e = $._getObjectById({
|
|
1600
1600
|
objects: t,
|
|
1601
1601
|
id: "montage-area"
|
|
1602
1602
|
});
|
|
@@ -1665,7 +1665,7 @@ class Q {
|
|
|
1665
1665
|
for (let c = 0; c < o.length; c += 1) {
|
|
1666
1666
|
const l = o[c], { id: d } = l;
|
|
1667
1667
|
let u;
|
|
1668
|
-
typeof d == "string" && (u = s.get(d)), u || (u = i.get(c)), u && (l.customData =
|
|
1668
|
+
typeof d == "string" && (u = s.get(d)), u || (u = i.get(c)), u && (l.customData = $._cloneCustomData({ customData: u }));
|
|
1669
1669
|
}
|
|
1670
1670
|
}
|
|
1671
1671
|
/**
|
|
@@ -1686,8 +1686,8 @@ class Q {
|
|
|
1686
1686
|
console.log("loadStateFromFullState fullState", t);
|
|
1687
1687
|
const { canvas: e, canvasManager: n, interactionBlocker: s, backgroundManager: i } = this.editor, { width: o, height: a } = e;
|
|
1688
1688
|
s.overlayMask = null;
|
|
1689
|
-
const r =
|
|
1690
|
-
yield e.loadFromJSON(r),
|
|
1689
|
+
const r = $._createLoadSafeState({ state: t });
|
|
1690
|
+
yield e.loadFromJSON(r), $._applyCustomDataFromState({ state: t, canvas: e });
|
|
1691
1691
|
const c = e.getObjects().find((u) => u.id === "montage-area");
|
|
1692
1692
|
c && (this.editor.montageArea = c, (o !== e.getWidth() || a !== e.getHeight()) && n.updateCanvas());
|
|
1693
1693
|
const l = e.getObjects().find((u) => u.id === "overlay-mask");
|
|
@@ -1800,7 +1800,7 @@ class Q {
|
|
|
1800
1800
|
}
|
|
1801
1801
|
}
|
|
1802
1802
|
}
|
|
1803
|
-
const
|
|
1803
|
+
const As = 0.1, js = 2, gn = 0.1, Is = 90, $t = 16, Qt = 16, zt = 4096, Ft = 4096, pn = "application/image-editor:", ue = [
|
|
1804
1804
|
"format",
|
|
1805
1805
|
"customData",
|
|
1806
1806
|
"contentType",
|
|
@@ -1818,8 +1818,8 @@ const ys = 0.1, bs = 2, hn = 0.1, vs = 90, $t = 16, te = 16, Ft = 4096, Ut = 409
|
|
|
1818
1818
|
"radiusBottomRight",
|
|
1819
1819
|
"radiusBottomLeft",
|
|
1820
1820
|
"lineFontDefaults"
|
|
1821
|
-
],
|
|
1822
|
-
class
|
|
1821
|
+
], Cs = 50;
|
|
1822
|
+
class te {
|
|
1823
1823
|
constructor({ editor: t }) {
|
|
1824
1824
|
this.editor = t, this.options = t.options, this._createdBlobUrls = [], this.acceptContentTypes = this.editor.options.acceptContentTypes, this.acceptFormats = this.getAllowedFormatsFromContentTypes();
|
|
1825
1825
|
}
|
|
@@ -1869,7 +1869,7 @@ class ee {
|
|
|
1869
1869
|
cache: e
|
|
1870
1870
|
}) {
|
|
1871
1871
|
var i;
|
|
1872
|
-
if (
|
|
1872
|
+
if (te._isBlobOrDataUrl({ src: t })) return t;
|
|
1873
1873
|
if (e.has(t))
|
|
1874
1874
|
return (i = e.get(t)) != null ? i : null;
|
|
1875
1875
|
const s = yield this._fetchAsBlobUrl({ src: t });
|
|
@@ -1946,7 +1946,7 @@ class ee {
|
|
|
1946
1946
|
}
|
|
1947
1947
|
f.suspendHistory();
|
|
1948
1948
|
try {
|
|
1949
|
-
let w,
|
|
1949
|
+
let w, v;
|
|
1950
1950
|
if (e instanceof File)
|
|
1951
1951
|
w = URL.createObjectURL(e), this._createdBlobUrls.push(w);
|
|
1952
1952
|
else if (typeof e == "string")
|
|
@@ -1971,38 +1971,38 @@ class ee {
|
|
|
1971
1971
|
}
|
|
1972
1972
|
}), f.resumeHistory(), null;
|
|
1973
1973
|
if (g === "svg") {
|
|
1974
|
-
const
|
|
1975
|
-
|
|
1974
|
+
const S = yield Gn(w);
|
|
1975
|
+
v = bt.groupSVGElements(S.objects, S.options);
|
|
1976
1976
|
} else
|
|
1977
|
-
|
|
1978
|
-
const { width:
|
|
1979
|
-
if (
|
|
1980
|
-
const
|
|
1977
|
+
v = yield Kt.fromURL(w, { crossOrigin: "anonymous" });
|
|
1978
|
+
const { width: C, height: O } = v;
|
|
1979
|
+
if (v instanceof Kt) {
|
|
1980
|
+
const S = v.getElement();
|
|
1981
1981
|
let A = "";
|
|
1982
|
-
if (
|
|
1982
|
+
if (S instanceof HTMLImageElement ? A = S.src : S instanceof HTMLCanvasElement && (A = S.toDataURL()), O > Ft || C > zt) {
|
|
1983
1983
|
const M = yield this.resizeImageToBoundaries({
|
|
1984
1984
|
dataURL: A,
|
|
1985
1985
|
sizeType: "max",
|
|
1986
1986
|
contentType: m
|
|
1987
|
-
}),
|
|
1988
|
-
this._createdBlobUrls.push(
|
|
1989
|
-
} else if (
|
|
1987
|
+
}), E = URL.createObjectURL(M);
|
|
1988
|
+
this._createdBlobUrls.push(E), v = yield Kt.fromURL(E, { crossOrigin: "anonymous" });
|
|
1989
|
+
} else if (O < Qt || C < $t) {
|
|
1990
1990
|
const M = yield this.resizeImageToBoundaries({
|
|
1991
1991
|
dataURL: A,
|
|
1992
1992
|
sizeType: "min",
|
|
1993
1993
|
contentType: m
|
|
1994
|
-
}),
|
|
1995
|
-
this._createdBlobUrls.push(
|
|
1994
|
+
}), E = URL.createObjectURL(M);
|
|
1995
|
+
this._createdBlobUrls.push(E), v = yield Kt.fromURL(E, { crossOrigin: "anonymous" });
|
|
1996
1996
|
}
|
|
1997
1997
|
}
|
|
1998
|
-
if (
|
|
1999
|
-
this.editor.canvasManager.scaleMontageAreaToImage({ object:
|
|
1998
|
+
if (v.set("id", `${v.type}-${et()}`), v.set("format", g), v.set("contentType", m), v.set("customData", c || null), n === "scale-montage")
|
|
1999
|
+
this.editor.canvasManager.scaleMontageAreaToImage({ object: v, withoutSave: !0 });
|
|
2000
2000
|
else {
|
|
2001
|
-
const { width:
|
|
2002
|
-
n === "image-contain" && M < 1 ? u.fitObject({ object:
|
|
2001
|
+
const { width: S, height: A } = d, M = this.calculateScaleFactor({ imageObject: v, scaleType: n });
|
|
2002
|
+
n === "image-contain" && M < 1 ? u.fitObject({ object: v, type: "contain", withoutSave: !0 }) : n === "image-cover" && (C > S || O > A) && u.fitObject({ object: v, type: "cover", withoutSave: !0 });
|
|
2003
2003
|
}
|
|
2004
|
-
const
|
|
2005
|
-
image:
|
|
2004
|
+
const j = {
|
|
2005
|
+
image: v,
|
|
2006
2006
|
format: g,
|
|
2007
2007
|
contentType: m,
|
|
2008
2008
|
scale: n,
|
|
@@ -2014,7 +2014,7 @@ class ee {
|
|
|
2014
2014
|
withoutAdding: r,
|
|
2015
2015
|
customData: c
|
|
2016
2016
|
};
|
|
2017
|
-
return r ? (f.resumeHistory(), l.fire("editor:image-imported",
|
|
2017
|
+
return r ? (f.resumeHistory(), l.fire("editor:image-imported", j), j) : (l.add(v), l.centerObject(v), a || l.setActiveObject(v), l.renderAll(), f.resumeHistory(), s || f.saveState(), l.fire("editor:image-imported", j), j);
|
|
2018
2018
|
} catch (w) {
|
|
2019
2019
|
return p.emitError({
|
|
2020
2020
|
origin: "ImageManager",
|
|
@@ -2061,10 +2061,10 @@ class ee {
|
|
|
2061
2061
|
sizeType: n = "max",
|
|
2062
2062
|
contentType: s = "image/png",
|
|
2063
2063
|
quality: i = 1,
|
|
2064
|
-
maxWidth: o =
|
|
2065
|
-
maxHeight: a =
|
|
2064
|
+
maxWidth: o = zt,
|
|
2065
|
+
maxHeight: a = Ft,
|
|
2066
2066
|
minWidth: r = $t,
|
|
2067
|
-
minHeight: c =
|
|
2067
|
+
minHeight: c = Qt,
|
|
2068
2068
|
asBase64: l = !1,
|
|
2069
2069
|
emitMessage: d = !0
|
|
2070
2070
|
} = t, { errorManager: u, workerManager: f } = this.editor, p = {
|
|
@@ -2125,7 +2125,7 @@ class ee {
|
|
|
2125
2125
|
y.enableRetinaScaling = !1, ["image/jpg", "image/jpeg"].includes(d) && (y.backgroundColor = "#ffffff");
|
|
2126
2126
|
const b = y.getObjects().find((M) => M.id === a.id);
|
|
2127
2127
|
if (b && (b.visible = !1), c != null && c.isBlocked) {
|
|
2128
|
-
const M = y.getObjects().find((
|
|
2128
|
+
const M = y.getObjects().find((E) => E.id === c.overlayMask.id);
|
|
2129
2129
|
M && (M.visible = !1);
|
|
2130
2130
|
}
|
|
2131
2131
|
y.viewportTransform = [1, 0, 0, 1, -f, -p], y.setDimensions({ width: m, height: g }, { backstoreOnly: !0 }), y.renderAll();
|
|
@@ -2133,8 +2133,8 @@ class ee {
|
|
|
2133
2133
|
if (u === "svg" && w) {
|
|
2134
2134
|
const M = y.toSVG();
|
|
2135
2135
|
y.dispose();
|
|
2136
|
-
const
|
|
2137
|
-
image:
|
|
2136
|
+
const I = {
|
|
2137
|
+
image: te._exportSVGStringAsFile(M, {
|
|
2138
2138
|
exportAsBase64: s,
|
|
2139
2139
|
exportAsBlob: i,
|
|
2140
2140
|
fileName: e
|
|
@@ -2143,12 +2143,12 @@ class ee {
|
|
|
2143
2143
|
contentType: "image/svg+xml",
|
|
2144
2144
|
fileName: e.replace(/\.[^/.]+$/, ".svg")
|
|
2145
2145
|
};
|
|
2146
|
-
return o.fire("editor:canvas-exported",
|
|
2146
|
+
return o.fire("editor:canvas-exported", I), I;
|
|
2147
2147
|
}
|
|
2148
|
-
const
|
|
2148
|
+
const v = yield new Promise((M, E) => {
|
|
2149
2149
|
y.getElement().toBlob(
|
|
2150
|
-
(
|
|
2151
|
-
|
|
2150
|
+
(I) => {
|
|
2151
|
+
I ? M(I) : E(new Error("Failed to create Blob from canvas"));
|
|
2152
2152
|
},
|
|
2153
2153
|
d,
|
|
2154
2154
|
1
|
|
@@ -2156,59 +2156,59 @@ class ee {
|
|
|
2156
2156
|
});
|
|
2157
2157
|
if (y.dispose(), i) {
|
|
2158
2158
|
const M = {
|
|
2159
|
-
image:
|
|
2159
|
+
image: v,
|
|
2160
2160
|
format: u,
|
|
2161
2161
|
contentType: d,
|
|
2162
2162
|
fileName: e
|
|
2163
2163
|
};
|
|
2164
2164
|
return o.fire("editor:canvas-exported", M), M;
|
|
2165
2165
|
}
|
|
2166
|
-
const
|
|
2166
|
+
const C = yield createImageBitmap(v), O = yield r.post(
|
|
2167
2167
|
"toDataURL",
|
|
2168
2168
|
{
|
|
2169
2169
|
contentType: d,
|
|
2170
2170
|
quality: 1,
|
|
2171
|
-
bitmap:
|
|
2171
|
+
bitmap: C
|
|
2172
2172
|
},
|
|
2173
|
-
[
|
|
2173
|
+
[C]
|
|
2174
2174
|
);
|
|
2175
2175
|
if (l) {
|
|
2176
|
-
const
|
|
2177
|
-
orientation:
|
|
2176
|
+
const E = m * 0.264583, I = g * 0.264583, z = (yield this.editor.moduleLoader.loadModule("jspdf")).jsPDF, F = new z({
|
|
2177
|
+
orientation: E > I ? "landscape" : "portrait",
|
|
2178
2178
|
unit: "mm",
|
|
2179
|
-
format: [
|
|
2179
|
+
format: [E, I]
|
|
2180
2180
|
});
|
|
2181
|
-
if (
|
|
2181
|
+
if (F.addImage(String(O), "JPG", 0, 0, E, I), s) {
|
|
2182
2182
|
const R = {
|
|
2183
|
-
image:
|
|
2183
|
+
image: F.output("datauristring"),
|
|
2184
2184
|
format: "pdf",
|
|
2185
2185
|
contentType: "application/pdf",
|
|
2186
2186
|
fileName: e
|
|
2187
2187
|
};
|
|
2188
2188
|
return o.fire("editor:canvas-exported", R), R;
|
|
2189
2189
|
}
|
|
2190
|
-
const
|
|
2191
|
-
image: new File([
|
|
2190
|
+
const U = F.output("blob"), B = {
|
|
2191
|
+
image: new File([U], e, { type: "application/pdf" }),
|
|
2192
2192
|
format: "pdf",
|
|
2193
2193
|
contentType: "application/pdf",
|
|
2194
2194
|
fileName: e
|
|
2195
2195
|
};
|
|
2196
|
-
return o.fire("editor:canvas-exported",
|
|
2196
|
+
return o.fire("editor:canvas-exported", B), B;
|
|
2197
2197
|
}
|
|
2198
2198
|
if (s) {
|
|
2199
2199
|
const M = {
|
|
2200
|
-
image:
|
|
2200
|
+
image: O,
|
|
2201
2201
|
format: u,
|
|
2202
2202
|
contentType: d,
|
|
2203
2203
|
fileName: e
|
|
2204
2204
|
};
|
|
2205
2205
|
return o.fire("editor:canvas-exported", M), M;
|
|
2206
2206
|
}
|
|
2207
|
-
const
|
|
2208
|
-
image: new File([
|
|
2207
|
+
const j = u === "svg" && !w ? e.replace(/\.[^/.]+$/, ".png") : e, A = {
|
|
2208
|
+
image: new File([v], j, { type: d }),
|
|
2209
2209
|
format: u,
|
|
2210
2210
|
contentType: d,
|
|
2211
|
-
fileName:
|
|
2211
|
+
fileName: j
|
|
2212
2212
|
};
|
|
2213
2213
|
return o.fire("editor:canvas-exported", A), A;
|
|
2214
2214
|
} catch (l) {
|
|
@@ -2254,31 +2254,31 @@ class ee {
|
|
|
2254
2254
|
const { contentType: f, format: p = "" } = c, m = (b = s != null ? s : f) != null ? b : "image/png", g = this.getFormatFromContentType(m) || p || "png", y = n != null ? n : `image.${g}`;
|
|
2255
2255
|
try {
|
|
2256
2256
|
if (g === "svg") {
|
|
2257
|
-
const
|
|
2257
|
+
const j = c.toSVG(), S = te._exportSVGStringAsFile(j, {
|
|
2258
2258
|
exportAsBase64: i,
|
|
2259
2259
|
exportAsBlob: o,
|
|
2260
2260
|
fileName: y
|
|
2261
2261
|
}), A = {
|
|
2262
2262
|
object: c,
|
|
2263
|
-
image:
|
|
2263
|
+
image: S,
|
|
2264
2264
|
format: g,
|
|
2265
2265
|
contentType: "image/svg+xml",
|
|
2266
2266
|
fileName: y.replace(/\.[^/.]+$/, ".svg")
|
|
2267
2267
|
};
|
|
2268
2268
|
return a.fire("editor:object-exported", A), A;
|
|
2269
2269
|
}
|
|
2270
|
-
if (i && c instanceof
|
|
2271
|
-
const
|
|
2270
|
+
if (i && c instanceof Kt) {
|
|
2271
|
+
const j = yield createImageBitmap(c.getElement()), S = yield r.post(
|
|
2272
2272
|
"toDataURL",
|
|
2273
2273
|
{
|
|
2274
2274
|
contentType: m,
|
|
2275
2275
|
quality: 1,
|
|
2276
|
-
bitmap:
|
|
2276
|
+
bitmap: j
|
|
2277
2277
|
},
|
|
2278
|
-
[
|
|
2278
|
+
[j]
|
|
2279
2279
|
), A = {
|
|
2280
2280
|
object: c,
|
|
2281
|
-
image:
|
|
2281
|
+
image: S,
|
|
2282
2282
|
format: g,
|
|
2283
2283
|
contentType: m,
|
|
2284
2284
|
fileName: y
|
|
@@ -2287,29 +2287,29 @@ class ee {
|
|
|
2287
2287
|
}
|
|
2288
2288
|
const w = c.toCanvasElement({
|
|
2289
2289
|
enableRetinaScaling: !1
|
|
2290
|
-
}),
|
|
2290
|
+
}), v = yield new Promise((j, S) => {
|
|
2291
2291
|
w.toBlob((A) => {
|
|
2292
|
-
A ?
|
|
2292
|
+
A ? j(A) : S(new Error("Failed to create Blob from canvas"));
|
|
2293
2293
|
});
|
|
2294
2294
|
});
|
|
2295
2295
|
if (o) {
|
|
2296
|
-
const
|
|
2296
|
+
const j = {
|
|
2297
2297
|
object: c,
|
|
2298
|
-
image:
|
|
2298
|
+
image: v,
|
|
2299
2299
|
format: g,
|
|
2300
2300
|
contentType: m,
|
|
2301
2301
|
fileName: y
|
|
2302
2302
|
};
|
|
2303
|
-
return a.fire("editor:object-exported",
|
|
2303
|
+
return a.fire("editor:object-exported", j), j;
|
|
2304
2304
|
}
|
|
2305
|
-
const
|
|
2305
|
+
const C = new File([v], y, { type: m }), O = {
|
|
2306
2306
|
object: c,
|
|
2307
|
-
image:
|
|
2307
|
+
image: C,
|
|
2308
2308
|
format: g,
|
|
2309
2309
|
contentType: m,
|
|
2310
2310
|
fileName: y
|
|
2311
2311
|
};
|
|
2312
|
-
return a.fire("editor:object-exported",
|
|
2312
|
+
return a.fire("editor:object-exported", O), O;
|
|
2313
2313
|
} catch (w) {
|
|
2314
2314
|
return this.editor.errorManager.emitError({
|
|
2315
2315
|
origin: "ImageManager",
|
|
@@ -2443,11 +2443,11 @@ class ee {
|
|
|
2443
2443
|
return e ? e[1] : "";
|
|
2444
2444
|
}
|
|
2445
2445
|
}
|
|
2446
|
-
const
|
|
2447
|
-
function
|
|
2446
|
+
const It = (h, t, e) => Math.max(Math.min(h, e), t), mn = (h, t) => h * t, Os = (h, t) => new ct(h / 2, t / 2);
|
|
2447
|
+
function Es(h) {
|
|
2448
2448
|
return ((h == null ? void 0 : h.type) === "image" || (h == null ? void 0 : h.format) === "svg") && typeof (h == null ? void 0 : h.width) == "number" && typeof (h == null ? void 0 : h.height) == "number";
|
|
2449
2449
|
}
|
|
2450
|
-
class
|
|
2450
|
+
class Ts {
|
|
2451
2451
|
/**
|
|
2452
2452
|
* @param options
|
|
2453
2453
|
* @param options.editor – экземпляр редактора
|
|
@@ -2467,11 +2467,11 @@ class As {
|
|
|
2467
2467
|
* Если точка находится за пределами монтажной области, она проецируется на ближайшую границу монтажной области.
|
|
2468
2468
|
*/
|
|
2469
2469
|
getVisibleCenterPoint() {
|
|
2470
|
-
const { canvas: t, montageArea: e } = this.editor, n = t.getZoom(), s = t.viewportTransform, i = t.getWidth(), o = t.getHeight(), a = (i / 2 - s[4]) / n, r = (o / 2 - s[5]) / n, c = e.width / 2, l = e.height / 2, d =
|
|
2470
|
+
const { canvas: t, montageArea: e } = this.editor, n = t.getZoom(), s = t.viewportTransform, i = t.getWidth(), o = t.getHeight(), a = (i / 2 - s[4]) / n, r = (o / 2 - s[5]) / n, c = e.width / 2, l = e.height / 2, d = It(
|
|
2471
2471
|
a,
|
|
2472
2472
|
e.left - c,
|
|
2473
2473
|
e.left + c
|
|
2474
|
-
), u =
|
|
2474
|
+
), u = It(
|
|
2475
2475
|
r,
|
|
2476
2476
|
e.top - l,
|
|
2477
2477
|
e.top + l
|
|
@@ -2494,9 +2494,9 @@ class As {
|
|
|
2494
2494
|
canvas: i,
|
|
2495
2495
|
montageArea: o,
|
|
2496
2496
|
options: { canvasBackstoreWidth: a }
|
|
2497
|
-
} = this.editor, { width: r, height: c } = o, l =
|
|
2497
|
+
} = this.editor, { width: r, height: c } = o, l = It(Number(t), $t, zt);
|
|
2498
2498
|
if (!a || a === "auto" || s ? this.adaptCanvasToContainer() : a ? this.setCanvasBackstoreWidth(Number(a)) : this.setCanvasBackstoreWidth(l), o.set({ width: l }), (p = i.clipPath) == null || p.set({ width: l }), e) {
|
|
2499
|
-
const m = l / r, g =
|
|
2499
|
+
const m = l / r, g = mn(c, m);
|
|
2500
2500
|
this.setResolutionHeight(g);
|
|
2501
2501
|
return;
|
|
2502
2502
|
}
|
|
@@ -2524,9 +2524,9 @@ class As {
|
|
|
2524
2524
|
canvas: i,
|
|
2525
2525
|
montageArea: o,
|
|
2526
2526
|
options: { canvasBackstoreHeight: a }
|
|
2527
|
-
} = this.editor, { width: r, height: c } = o, l =
|
|
2527
|
+
} = this.editor, { width: r, height: c } = o, l = It(Number(t), Qt, Ft);
|
|
2528
2528
|
if (!a || a === "auto" || s ? this.adaptCanvasToContainer() : a ? this.setCanvasBackstoreHeight(Number(a)) : this.setCanvasBackstoreHeight(l), o.set({ height: l }), (p = i.clipPath) == null || p.set({ height: l }), e) {
|
|
2529
|
-
const m = l / c, g =
|
|
2529
|
+
const m = l / c, g = mn(r, m);
|
|
2530
2530
|
this.setResolutionWidth(g);
|
|
2531
2531
|
return;
|
|
2532
2532
|
}
|
|
@@ -2544,7 +2544,7 @@ class As {
|
|
|
2544
2544
|
*/
|
|
2545
2545
|
centerMontageArea() {
|
|
2546
2546
|
var r;
|
|
2547
|
-
const { canvas: t, montageArea: e } = this.editor, n = t.getWidth(), s = t.getHeight(), i = t.getZoom(), o =
|
|
2547
|
+
const { canvas: t, montageArea: e } = this.editor, n = t.getWidth(), s = t.getHeight(), i = t.getZoom(), o = Os(n, s);
|
|
2548
2548
|
e.set({
|
|
2549
2549
|
left: n / 2,
|
|
2550
2550
|
top: s / 2
|
|
@@ -2577,7 +2577,7 @@ class As {
|
|
|
2577
2577
|
*/
|
|
2578
2578
|
setCanvasBackstoreWidth(t) {
|
|
2579
2579
|
if (!t || typeof t != "number") return;
|
|
2580
|
-
const e =
|
|
2580
|
+
const e = It(t, $t, zt);
|
|
2581
2581
|
this.editor.canvas.setDimensions({ width: e }, { backstoreOnly: !0 });
|
|
2582
2582
|
}
|
|
2583
2583
|
/**
|
|
@@ -2586,7 +2586,7 @@ class As {
|
|
|
2586
2586
|
*/
|
|
2587
2587
|
setCanvasBackstoreHeight(t) {
|
|
2588
2588
|
if (!t || typeof t != "number") return;
|
|
2589
|
-
const e =
|
|
2589
|
+
const e = It(t, Qt, Ft);
|
|
2590
2590
|
this.editor.canvas.setDimensions({ height: e }, { backstoreOnly: !0 });
|
|
2591
2591
|
}
|
|
2592
2592
|
/**
|
|
@@ -2595,7 +2595,7 @@ class As {
|
|
|
2595
2595
|
* с учётом минимальных и максимальных значений.
|
|
2596
2596
|
*/
|
|
2597
2597
|
adaptCanvasToContainer() {
|
|
2598
|
-
const { canvas: t } = this.editor, e = this.getEditorContainer(), n = e.clientWidth, s = e.clientHeight, i =
|
|
2598
|
+
const { canvas: t } = this.editor, e = this.getEditorContainer(), n = e.clientWidth, s = e.clientHeight, i = It(n, $t, zt), o = It(s, Qt, Ft);
|
|
2599
2599
|
t.setDimensions({ width: i, height: o }, { backstoreOnly: !0 });
|
|
2600
2600
|
}
|
|
2601
2601
|
/**
|
|
@@ -2795,9 +2795,9 @@ class As {
|
|
|
2795
2795
|
montageAreaHeight: r
|
|
2796
2796
|
}
|
|
2797
2797
|
} = this.editor, c = t || s.getActiveObject();
|
|
2798
|
-
if (!
|
|
2798
|
+
if (!Es(c)) return;
|
|
2799
2799
|
const { width: l, height: d } = c;
|
|
2800
|
-
let u = Math.min(l,
|
|
2800
|
+
let u = Math.min(l, zt), f = Math.min(d, Ft);
|
|
2801
2801
|
if (e) {
|
|
2802
2802
|
const {
|
|
2803
2803
|
width: p,
|
|
@@ -2855,7 +2855,7 @@ class As {
|
|
|
2855
2855
|
);
|
|
2856
2856
|
}
|
|
2857
2857
|
}
|
|
2858
|
-
class
|
|
2858
|
+
class _s {
|
|
2859
2859
|
constructor({ editor: t }) {
|
|
2860
2860
|
this.editor = t, this.options = t.options;
|
|
2861
2861
|
}
|
|
@@ -2866,7 +2866,7 @@ class js {
|
|
|
2866
2866
|
* @param options.withoutSave - Не сохранять состояние
|
|
2867
2867
|
* @fires editor:object-rotated
|
|
2868
2868
|
*/
|
|
2869
|
-
rotate(t =
|
|
2869
|
+
rotate(t = Is, { withoutSave: e } = {}) {
|
|
2870
2870
|
const { canvas: n, historyManager: s } = this.editor, i = n.getActiveObject();
|
|
2871
2871
|
if (!i) return;
|
|
2872
2872
|
const o = i.angle + t;
|
|
@@ -3021,9 +3021,9 @@ class js {
|
|
|
3021
3021
|
});
|
|
3022
3022
|
}
|
|
3023
3023
|
}
|
|
3024
|
-
class
|
|
3024
|
+
class Ds {
|
|
3025
3025
|
constructor({ editor: t }) {
|
|
3026
|
-
this.editor = t, this.options = t.options, this.minZoom = this.options.minZoom ||
|
|
3026
|
+
this.editor = t, this.options = t.options, this.minZoom = this.options.minZoom || As, this.maxZoom = this.options.maxZoom || js, this.defaultZoom = this._normalizeDefaultZoom(this.options.defaultScale);
|
|
3027
3027
|
}
|
|
3028
3028
|
/**
|
|
3029
3029
|
* Приводит значение defaultZoom к числу с двумя знаками после запятой, а также учитывает минимальное и максимальное значения.
|
|
@@ -3091,8 +3091,8 @@ class Is {
|
|
|
3091
3091
|
_calculateEmptySpaceRatio(t) {
|
|
3092
3092
|
const { canvas: e, montageArea: n } = this.editor, s = e.viewportTransform, i = e.getWidth(), o = 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, d = -s[4] / t, u = (-s[4] + i) / t, f = -s[5] / t, p = (-s[5] + o) / t, m = d < a, g = u > r, y = f < c, b = p > l;
|
|
3093
3093
|
if (!(m || g || y || b)) return 0;
|
|
3094
|
-
const
|
|
3095
|
-
return Math.max(M,
|
|
3094
|
+
const v = Math.max(0, a - d), C = Math.max(0, u - r), O = Math.max(0, c - f), j = Math.max(0, p - l), S = Math.max(v, C), A = Math.max(O, j), M = S / i, E = A / o;
|
|
3095
|
+
return Math.max(M, E);
|
|
3096
3096
|
}
|
|
3097
3097
|
/**
|
|
3098
3098
|
* Вычисляет плавный шаг перемещения viewport к центру с ускорением
|
|
@@ -3108,8 +3108,8 @@ class Is {
|
|
|
3108
3108
|
const { canvas: o, montageArea: a } = this.editor, r = o.viewportTransform, c = o.getWidth(), l = o.getHeight(), d = t.x - r[4], u = t.y - r[5], f = Math.abs(s), p = e - n;
|
|
3109
3109
|
if (Math.abs(p) / f <= 0.1)
|
|
3110
3110
|
return { x: d, y: u };
|
|
3111
|
-
const g = c / 2, y = l / 2, b = a.left, w = a.top,
|
|
3112
|
-
return { x:
|
|
3111
|
+
const g = c / 2, y = l / 2, b = a.left, w = a.top, v = g - b * n, C = y - w * n, O = (v - r[4]) / (e - n), j = (C - r[5]) / (e - n), S = O * f, A = j * f, M = S * i, E = A * i, I = Math.abs(M) > Math.abs(d) ? d : M, z = Math.abs(E) > Math.abs(u) ? u : E;
|
|
3112
|
+
return { x: I, y: z };
|
|
3113
3113
|
}
|
|
3114
3114
|
/**
|
|
3115
3115
|
* Применяет плавное центрирование viewport при приближении к defaultZoom.
|
|
@@ -3121,7 +3121,7 @@ class Is {
|
|
|
3121
3121
|
* @returns true если центрирование было применено
|
|
3122
3122
|
* @private
|
|
3123
3123
|
*/
|
|
3124
|
-
_applyViewportCentering(t, e = !1, n =
|
|
3124
|
+
_applyViewportCentering(t, e = !1, n = gn) {
|
|
3125
3125
|
const { canvas: s } = this.editor, i = this._getScaledMontageDimensions(t), o = s.getWidth(), a = s.getHeight(), r = i.width > o || i.height > a, c = this._calculateFitZoom(), l = t - c;
|
|
3126
3126
|
if (!(!r || l) && !e)
|
|
3127
3127
|
return !1;
|
|
@@ -3196,7 +3196,7 @@ class Is {
|
|
|
3196
3196
|
* @param options.pointY - Координата Y точки зума
|
|
3197
3197
|
* @fires editor:zoom-changed
|
|
3198
3198
|
*/
|
|
3199
|
-
zoom(t =
|
|
3199
|
+
zoom(t = gn, e = {}) {
|
|
3200
3200
|
var f, p;
|
|
3201
3201
|
if (!t) return;
|
|
3202
3202
|
const { minZoom: n, maxZoom: s } = this, { canvas: i } = this.editor, o = t < 0, a = i.getZoom(), r = i.getCenterPoint(), c = (f = e.pointX) != null ? f : r.x, l = (p = e.pointY) != null ? p : r.y, d = new ct(c, l);
|
|
@@ -3234,7 +3234,7 @@ class Is {
|
|
|
3234
3234
|
}), this.editor.panConstraintManager.updateBounds();
|
|
3235
3235
|
}
|
|
3236
3236
|
}
|
|
3237
|
-
class
|
|
3237
|
+
class Ls {
|
|
3238
3238
|
constructor({ editor: t }) {
|
|
3239
3239
|
this.editor = t, this.isBlocked = !1, this.overlayMask = null, this._createOverlay();
|
|
3240
3240
|
}
|
|
@@ -3291,7 +3291,7 @@ class Cs {
|
|
|
3291
3291
|
}), t.upperCanvasEl.style.pointerEvents = "", t.lowerCanvasEl.style.pointerEvents = "", this.overlayMask.visible = !1, t.requestRenderAll(), t.fire("editor:enabled"), n.resumeHistory(), n.flushDeferredSaveAfterUnblock();
|
|
3292
3292
|
}
|
|
3293
3293
|
}
|
|
3294
|
-
class
|
|
3294
|
+
class Ut {
|
|
3295
3295
|
constructor({ editor: t }) {
|
|
3296
3296
|
this.editor = t, this.backgroundObject = null;
|
|
3297
3297
|
}
|
|
@@ -3354,8 +3354,8 @@ class Wt {
|
|
|
3354
3354
|
try {
|
|
3355
3355
|
const { historyManager: o } = this.editor, { backgroundObject: a } = this;
|
|
3356
3356
|
if (o.suspendHistory(), a && a.backgroundType === "gradient") {
|
|
3357
|
-
const r =
|
|
3358
|
-
if (
|
|
3357
|
+
const r = Ut._createFabricGradient(t);
|
|
3358
|
+
if (Ut._isGradientEqual(a.fill, r)) {
|
|
3359
3359
|
o.resumeHistory();
|
|
3360
3360
|
return;
|
|
3361
3361
|
}
|
|
@@ -3538,7 +3538,7 @@ class Wt {
|
|
|
3538
3538
|
backgroundType: "gradient",
|
|
3539
3539
|
backgroundId: `background-${et()}`
|
|
3540
3540
|
}, { withoutSelection: !0 }), this.refresh();
|
|
3541
|
-
const e =
|
|
3541
|
+
const e = Ut._createFabricGradient(t);
|
|
3542
3542
|
this.backgroundObject.set("fill", e), this.editor.canvas.requestRenderAll();
|
|
3543
3543
|
}
|
|
3544
3544
|
/**
|
|
@@ -3598,8 +3598,8 @@ class Wt {
|
|
|
3598
3598
|
{ offset: 0, color: "#000000" },
|
|
3599
3599
|
{ offset: 1, color: "#ffffff" }
|
|
3600
3600
|
], t.type === "linear") {
|
|
3601
|
-
const u = t.angle * Math.PI / 180, f =
|
|
3602
|
-
return new
|
|
3601
|
+
const u = t.angle * Math.PI / 180, f = Ut._angleToCoords(u);
|
|
3602
|
+
return new rn({
|
|
3603
3603
|
type: "linear",
|
|
3604
3604
|
gradientUnits: "percentage",
|
|
3605
3605
|
coords: f,
|
|
@@ -3618,7 +3618,7 @@ class Wt {
|
|
|
3618
3618
|
r1: 0,
|
|
3619
3619
|
r2: l / 100
|
|
3620
3620
|
};
|
|
3621
|
-
return new
|
|
3621
|
+
return new rn({
|
|
3622
3622
|
type: "radial",
|
|
3623
3623
|
gradientUnits: "percentage",
|
|
3624
3624
|
coords: d,
|
|
@@ -3653,7 +3653,7 @@ class Wt {
|
|
|
3653
3653
|
}) ? !1 : t.type === "linear" && e.type === "linear" ? Math.abs(t.coords.x1 - e.coords.x1) < 1e-4 && Math.abs(t.coords.y1 - e.coords.y1) < 1e-4 && Math.abs(t.coords.x2 - e.coords.x2) < 1e-4 && Math.abs(t.coords.y2 - e.coords.y2) < 1e-4 : t.type === "radial" && e.type === "radial" ? Math.abs(t.coords.x1 - e.coords.x1) < 1e-4 && Math.abs(t.coords.y1 - e.coords.y1) < 1e-4 && Math.abs(t.coords.x2 - e.coords.x2) < 1e-4 && Math.abs(t.coords.y2 - e.coords.y2) < 1e-4 && Math.abs(t.coords.r1 - e.coords.r1) < 1e-4 && Math.abs(t.coords.r2 - e.coords.r2) < 1e-4 : !1;
|
|
3654
3654
|
}
|
|
3655
3655
|
}
|
|
3656
|
-
class
|
|
3656
|
+
class be {
|
|
3657
3657
|
constructor({ editor: t }) {
|
|
3658
3658
|
this.editor = t;
|
|
3659
3659
|
}
|
|
@@ -3686,7 +3686,7 @@ class ve {
|
|
|
3686
3686
|
const { canvas: n, historyManager: s } = this.editor;
|
|
3687
3687
|
s.suspendHistory();
|
|
3688
3688
|
const i = t || n.getActiveObject();
|
|
3689
|
-
i && (i instanceof q ?
|
|
3689
|
+
i && (i instanceof q ? be._moveSelectionForward(n, i) : n.bringObjectForward(i), n.renderAll(), s.resumeHistory(), e || s.saveState(), n.fire("editor:object-bring-forward", {
|
|
3690
3690
|
object: i,
|
|
3691
3691
|
withoutSave: e
|
|
3692
3692
|
}));
|
|
@@ -3737,7 +3737,7 @@ class ve {
|
|
|
3737
3737
|
} = this.editor;
|
|
3738
3738
|
i.suspendHistory();
|
|
3739
3739
|
const r = t || n.getActiveObject();
|
|
3740
|
-
r && (r instanceof q ?
|
|
3740
|
+
r && (r instanceof q ? be._moveSelectionBackwards(n, r) : n.sendObjectBackwards(r), a && n.sendObjectToBack(a), n.sendObjectToBack(s), o && n.sendObjectToBack(o), n.renderAll(), i.resumeHistory(), e || i.saveState(), n.fire("editor:object-send-backwards", {
|
|
3741
3741
|
object: r,
|
|
3742
3742
|
withoutSave: e
|
|
3743
3743
|
}));
|
|
@@ -3781,7 +3781,7 @@ class ve {
|
|
|
3781
3781
|
});
|
|
3782
3782
|
}
|
|
3783
3783
|
}
|
|
3784
|
-
class
|
|
3784
|
+
class xs {
|
|
3785
3785
|
/**
|
|
3786
3786
|
* Менеджер фигур для редактора.
|
|
3787
3787
|
* @param options - Опции и настройки менеджера фигур.
|
|
@@ -3821,7 +3821,7 @@ class Es {
|
|
|
3821
3821
|
"height",
|
|
3822
3822
|
"fill"
|
|
3823
3823
|
]);
|
|
3824
|
-
const { canvas: u } = this.editor, f = new
|
|
3824
|
+
const { canvas: u } = this.editor, f = new Zn(P({
|
|
3825
3825
|
id: t,
|
|
3826
3826
|
left: e,
|
|
3827
3827
|
top: n,
|
|
@@ -3861,7 +3861,7 @@ class Es {
|
|
|
3861
3861
|
"radius",
|
|
3862
3862
|
"fill"
|
|
3863
3863
|
]);
|
|
3864
|
-
const { canvas: d } = this.editor, u = new
|
|
3864
|
+
const { canvas: d } = this.editor, u = new Vn(P({
|
|
3865
3865
|
id: t,
|
|
3866
3866
|
left: e,
|
|
3867
3867
|
top: n,
|
|
@@ -3903,7 +3903,7 @@ class Es {
|
|
|
3903
3903
|
"height",
|
|
3904
3904
|
"fill"
|
|
3905
3905
|
]);
|
|
3906
|
-
const { canvas: u } = this.editor, f = new
|
|
3906
|
+
const { canvas: u } = this.editor, f = new Xn(P({
|
|
3907
3907
|
id: t,
|
|
3908
3908
|
left: e,
|
|
3909
3909
|
top: n,
|
|
@@ -3914,7 +3914,7 @@ class Es {
|
|
|
3914
3914
|
return !e && !n && u.centerObject(f), c || (u.add(f), r || u.setActiveObject(f), u.renderAll()), f;
|
|
3915
3915
|
}
|
|
3916
3916
|
}
|
|
3917
|
-
class
|
|
3917
|
+
class Rs {
|
|
3918
3918
|
/**
|
|
3919
3919
|
* @param options
|
|
3920
3920
|
* @param options.editor - экземпляр редактора с доступом к canvas
|
|
@@ -3945,7 +3945,7 @@ class Ts {
|
|
|
3945
3945
|
return G(this, null, function* () {
|
|
3946
3946
|
const { canvas: e, errorManager: n } = this.editor;
|
|
3947
3947
|
try {
|
|
3948
|
-
const s = yield t.clone(
|
|
3948
|
+
const s = yield t.clone(ue);
|
|
3949
3949
|
this.clipboard = s, e.fire("editor:object-copied", { object: s });
|
|
3950
3950
|
} catch (s) {
|
|
3951
3951
|
n.emitError({
|
|
@@ -3972,7 +3972,7 @@ class Ts {
|
|
|
3972
3972
|
message: "navigator.clipboard не поддерживается в этом браузере или отсутствует HTTPS-соединение."
|
|
3973
3973
|
}), !1;
|
|
3974
3974
|
try {
|
|
3975
|
-
const n = t.toObject(
|
|
3975
|
+
const n = t.toObject(ue), s = JSON.stringify(n);
|
|
3976
3976
|
return t.type === "image" ? this._copyImageToClipboard(t, s) : this._copyTextToClipboard(s);
|
|
3977
3977
|
} catch (n) {
|
|
3978
3978
|
return e.emitError({
|
|
@@ -4013,7 +4013,7 @@ class Ts {
|
|
|
4013
4013
|
_copyTextToClipboard(t) {
|
|
4014
4014
|
return G(this, null, function* () {
|
|
4015
4015
|
try {
|
|
4016
|
-
const e = `${
|
|
4016
|
+
const e = `${pn}${t}`;
|
|
4017
4017
|
return yield navigator.clipboard.writeText(e), console.info("Text copied to clipboard successfully"), !0;
|
|
4018
4018
|
} catch (e) {
|
|
4019
4019
|
const { errorManager: n } = this.editor;
|
|
@@ -4089,7 +4089,7 @@ class Ts {
|
|
|
4089
4089
|
importOptions: e = {}
|
|
4090
4090
|
}) {
|
|
4091
4091
|
var r;
|
|
4092
|
-
const s = yt(
|
|
4092
|
+
const s = yt(P({
|
|
4093
4093
|
source: t
|
|
4094
4094
|
}, e), {
|
|
4095
4095
|
fromClipboard: !0
|
|
@@ -4112,7 +4112,7 @@ class Ts {
|
|
|
4112
4112
|
const { canvas: e } = this.editor, n = t || e.getActiveObject();
|
|
4113
4113
|
if (!n || n.locked) return !1;
|
|
4114
4114
|
try {
|
|
4115
|
-
const s = yield n.clone(
|
|
4115
|
+
const s = yield n.clone(ue);
|
|
4116
4116
|
return s instanceof q && s.forEachObject((i) => {
|
|
4117
4117
|
i.set({
|
|
4118
4118
|
id: `${i.type}-${et()}`,
|
|
@@ -4153,7 +4153,7 @@ class Ts {
|
|
|
4153
4153
|
return;
|
|
4154
4154
|
}
|
|
4155
4155
|
const n = t.getData("text/plain");
|
|
4156
|
-
if (n && n.startsWith(
|
|
4156
|
+
if (n && n.startsWith(pn)) {
|
|
4157
4157
|
this.paste();
|
|
4158
4158
|
return;
|
|
4159
4159
|
}
|
|
@@ -4201,7 +4201,7 @@ class Ts {
|
|
|
4201
4201
|
const { canvas: t } = this.editor;
|
|
4202
4202
|
if (!this.clipboard) return !1;
|
|
4203
4203
|
try {
|
|
4204
|
-
const e = yield this.clipboard.clone(
|
|
4204
|
+
const e = yield this.clipboard.clone(ue);
|
|
4205
4205
|
return t.discardActiveObject(), e instanceof q && e.forEachObject((n) => {
|
|
4206
4206
|
n.set({
|
|
4207
4207
|
id: `${n.type}-${et()}`,
|
|
@@ -4230,7 +4230,7 @@ class Ts {
|
|
|
4230
4230
|
});
|
|
4231
4231
|
}
|
|
4232
4232
|
}
|
|
4233
|
-
class
|
|
4233
|
+
class ve {
|
|
4234
4234
|
constructor({ editor: t }) {
|
|
4235
4235
|
this.editor = t;
|
|
4236
4236
|
}
|
|
@@ -4256,7 +4256,7 @@ class Se {
|
|
|
4256
4256
|
editable: !1,
|
|
4257
4257
|
locked: !0
|
|
4258
4258
|
};
|
|
4259
|
-
o.set(a), !e &&
|
|
4259
|
+
o.set(a), !e && ve._isGroupOrSelection(o) && o.getObjects().forEach((c) => {
|
|
4260
4260
|
c.set(a);
|
|
4261
4261
|
}), o instanceof rt && o.isEditing && o.exitEditing(), s.renderAll(), n || i.saveState(), s.fire("editor:object-locked", {
|
|
4262
4262
|
object: o,
|
|
@@ -4285,7 +4285,7 @@ class Se {
|
|
|
4285
4285
|
editable: !0,
|
|
4286
4286
|
locked: !1
|
|
4287
4287
|
};
|
|
4288
|
-
i.set(o),
|
|
4288
|
+
i.set(o), ve._isGroupOrSelection(i) && i.getObjects().forEach((a) => {
|
|
4289
4289
|
a.set(o);
|
|
4290
4290
|
}), n.renderAll(), e || s.saveState(), n.fire("editor:object-unlocked", {
|
|
4291
4291
|
object: i,
|
|
@@ -4293,10 +4293,10 @@ class Se {
|
|
|
4293
4293
|
});
|
|
4294
4294
|
}
|
|
4295
4295
|
static _isGroupOrSelection(t) {
|
|
4296
|
-
return t instanceof q || t instanceof
|
|
4296
|
+
return t instanceof q || t instanceof Pt;
|
|
4297
4297
|
}
|
|
4298
4298
|
}
|
|
4299
|
-
class
|
|
4299
|
+
class ks {
|
|
4300
4300
|
constructor({ editor: t }) {
|
|
4301
4301
|
this.editor = t;
|
|
4302
4302
|
}
|
|
@@ -4316,20 +4316,20 @@ class Os {
|
|
|
4316
4316
|
*/
|
|
4317
4317
|
_getGroupsToUngroup(t) {
|
|
4318
4318
|
if (Array.isArray(t)) {
|
|
4319
|
-
const n = t.filter((s) => s instanceof
|
|
4319
|
+
const n = t.filter((s) => s instanceof Pt);
|
|
4320
4320
|
return n.length > 0 ? n : null;
|
|
4321
4321
|
}
|
|
4322
4322
|
if (t instanceof q) {
|
|
4323
|
-
const n = t.getObjects().filter((s) => s instanceof
|
|
4323
|
+
const n = t.getObjects().filter((s) => s instanceof Pt);
|
|
4324
4324
|
return n.length > 0 ? n : null;
|
|
4325
4325
|
}
|
|
4326
4326
|
const e = t || this.editor.canvas.getActiveObject();
|
|
4327
4327
|
if (!e) return null;
|
|
4328
4328
|
if (e instanceof q) {
|
|
4329
|
-
const n = e.getObjects().filter((s) => s instanceof
|
|
4329
|
+
const n = e.getObjects().filter((s) => s instanceof Pt);
|
|
4330
4330
|
return n.length > 0 ? n : null;
|
|
4331
4331
|
}
|
|
4332
|
-
return e instanceof
|
|
4332
|
+
return e instanceof Pt ? [e] : null;
|
|
4333
4333
|
}
|
|
4334
4334
|
/**
|
|
4335
4335
|
* Группировка объектов
|
|
@@ -4346,7 +4346,7 @@ class Os {
|
|
|
4346
4346
|
if (!i) return null;
|
|
4347
4347
|
try {
|
|
4348
4348
|
s.suspendHistory();
|
|
4349
|
-
const o = new
|
|
4349
|
+
const o = new Pt(i, {
|
|
4350
4350
|
id: `group-${et()}`
|
|
4351
4351
|
});
|
|
4352
4352
|
i.forEach((r) => n.remove(r)), n.add(o), n.setActiveObject(o), n.requestRenderAll();
|
|
@@ -4690,7 +4690,7 @@ class ft {
|
|
|
4690
4690
|
return e !== void 0 ? e : ["ctrlKey", "metaKey"];
|
|
4691
4691
|
}
|
|
4692
4692
|
}
|
|
4693
|
-
class
|
|
4693
|
+
class Ke {
|
|
4694
4694
|
constructor({ editor: t }) {
|
|
4695
4695
|
this.editor = t;
|
|
4696
4696
|
}
|
|
@@ -4737,7 +4737,7 @@ class Xe {
|
|
|
4737
4737
|
n || i.suspendHistory();
|
|
4738
4738
|
const r = [];
|
|
4739
4739
|
if (a.forEach((l) => {
|
|
4740
|
-
if (
|
|
4740
|
+
if (Ke._isUngroupableGroup(l)) {
|
|
4741
4741
|
const d = this._handleGroupDeletion(l);
|
|
4742
4742
|
r.push(...d);
|
|
4743
4743
|
return;
|
|
@@ -4752,7 +4752,7 @@ class Xe {
|
|
|
4752
4752
|
return s.fire("editor:objects-deleted", c), c;
|
|
4753
4753
|
}
|
|
4754
4754
|
}
|
|
4755
|
-
const
|
|
4755
|
+
const Dt = {
|
|
4756
4756
|
IMAGE_MANAGER: {
|
|
4757
4757
|
/**
|
|
4758
4758
|
* Некорректный Content-Type изображения
|
|
@@ -4865,7 +4865,7 @@ const xt = {
|
|
|
4865
4865
|
APPLY_FAILED: "TEMPLATE_APPLY_FAILED"
|
|
4866
4866
|
}
|
|
4867
4867
|
};
|
|
4868
|
-
class
|
|
4868
|
+
class ne {
|
|
4869
4869
|
constructor({ editor: t }) {
|
|
4870
4870
|
this._buffer = [], this.editor = t;
|
|
4871
4871
|
}
|
|
@@ -4892,7 +4892,7 @@ class se {
|
|
|
4892
4892
|
* @fires editor:error
|
|
4893
4893
|
*/
|
|
4894
4894
|
emitError({ origin: t = "ImageEditor", method: e = "Unknown Method", code: n, data: s, message: i }) {
|
|
4895
|
-
if (!
|
|
4895
|
+
if (!ne.isValidErrorCode(n)) {
|
|
4896
4896
|
console.warn("Неизвестный код ошибки: ", { code: n, origin: t, method: e });
|
|
4897
4897
|
return;
|
|
4898
4898
|
}
|
|
@@ -4906,7 +4906,7 @@ class se {
|
|
|
4906
4906
|
message: o,
|
|
4907
4907
|
data: s
|
|
4908
4908
|
};
|
|
4909
|
-
this._buffer.push(
|
|
4909
|
+
this._buffer.push(P({
|
|
4910
4910
|
type: "editor:error"
|
|
4911
4911
|
}, a)), this.editor.canvas.fire("editor:error", a);
|
|
4912
4912
|
}
|
|
@@ -4921,7 +4921,7 @@ class se {
|
|
|
4921
4921
|
* @fires editor:warning
|
|
4922
4922
|
*/
|
|
4923
4923
|
emitWarning({ origin: t = "ImageEditor", method: e = "Unknown Method", code: n, message: s, data: i }) {
|
|
4924
|
-
if (!
|
|
4924
|
+
if (!ne.isValidErrorCode(n)) {
|
|
4925
4925
|
console.warn("Неизвестный код предупреждения: ", { code: n, origin: t, method: e });
|
|
4926
4926
|
return;
|
|
4927
4927
|
}
|
|
@@ -4934,7 +4934,7 @@ class se {
|
|
|
4934
4934
|
message: o,
|
|
4935
4935
|
data: i
|
|
4936
4936
|
};
|
|
4937
|
-
this._buffer.push(
|
|
4937
|
+
this._buffer.push(P({
|
|
4938
4938
|
type: "editor:warning"
|
|
4939
4939
|
}, a)), this.editor.canvas.fire("editor:warning", a);
|
|
4940
4940
|
}
|
|
@@ -4944,10 +4944,10 @@ class se {
|
|
|
4944
4944
|
* @returns true, если код допустим, иначе false
|
|
4945
4945
|
*/
|
|
4946
4946
|
static isValidErrorCode(t) {
|
|
4947
|
-
return t ? Object.values(
|
|
4947
|
+
return t ? Object.values(Dt).some((e) => Object.values(e).includes(t)) : !1;
|
|
4948
4948
|
}
|
|
4949
4949
|
}
|
|
4950
|
-
class
|
|
4950
|
+
class Bs {
|
|
4951
4951
|
constructor({ editor: t }) {
|
|
4952
4952
|
this.currentBounds = null, this.editor = t;
|
|
4953
4953
|
}
|
|
@@ -5032,7 +5032,7 @@ class _s {
|
|
|
5032
5032
|
this.currentBounds = this.calculatePanBounds();
|
|
5033
5033
|
}
|
|
5034
5034
|
}
|
|
5035
|
-
const
|
|
5035
|
+
const Ns = ({ textbox: h }) => {
|
|
5036
5036
|
var n, s;
|
|
5037
5037
|
if (!h.isEditing) return null;
|
|
5038
5038
|
const t = (n = h.selectionStart) != null ? n : 0, e = (s = h.selectionEnd) != null ? s : t;
|
|
@@ -5040,16 +5040,16 @@ const Ds = ({ textbox: h }) => {
|
|
|
5040
5040
|
start: Math.min(t, e),
|
|
5041
5041
|
end: Math.max(t, e)
|
|
5042
5042
|
};
|
|
5043
|
-
},
|
|
5043
|
+
}, Ps = ({ textbox: h }) => {
|
|
5044
5044
|
var e, n;
|
|
5045
5045
|
const t = (n = (e = h.text) == null ? void 0 : e.length) != null ? n : 0;
|
|
5046
5046
|
return t <= 0 ? null : { start: 0, end: t };
|
|
5047
|
-
},
|
|
5047
|
+
}, zs = ({ textbox: h, range: t }) => {
|
|
5048
5048
|
var n, s;
|
|
5049
5049
|
if (!t) return !1;
|
|
5050
5050
|
const e = (s = (n = h.text) == null ? void 0 : n.length) != null ? s : 0;
|
|
5051
5051
|
return e <= 0 ? !1 : t.start <= 0 && t.end >= e;
|
|
5052
|
-
},
|
|
5052
|
+
}, Ee = ({
|
|
5053
5053
|
textbox: h,
|
|
5054
5054
|
styles: t,
|
|
5055
5055
|
range: e
|
|
@@ -5057,7 +5057,7 @@ const Ds = ({ textbox: h }) => {
|
|
|
5057
5057
|
if (!t || !Object.keys(t).length) return !1;
|
|
5058
5058
|
const { start: n, end: s } = e;
|
|
5059
5059
|
return s <= n ? !1 : (h.setSelectionStyles(t, n, s), !0);
|
|
5060
|
-
},
|
|
5060
|
+
}, yn = ({
|
|
5061
5061
|
textbox: h,
|
|
5062
5062
|
range: t,
|
|
5063
5063
|
property: e
|
|
@@ -5071,11 +5071,11 @@ const Ds = ({ textbox: h }) => {
|
|
|
5071
5071
|
);
|
|
5072
5072
|
if (n.length)
|
|
5073
5073
|
return (s = n[0]) == null ? void 0 : s[e];
|
|
5074
|
-
},
|
|
5074
|
+
}, Fe = ({ strokeColor: h, width: t }) => t <= 0 ? null : h != null ? h : "#000000", Ue = ({ width: h = 0 }) => h ? Math.max(0, h) : 0, Te = ({ value: h }) => typeof h == "string" ? h.toLocaleUpperCase() : "", Mt = ({
|
|
5075
5075
|
value: h,
|
|
5076
5076
|
min: t,
|
|
5077
5077
|
max: e
|
|
5078
|
-
}) => Math.min(Math.max(h, t), e),
|
|
5078
|
+
}) => Math.min(Math.max(h, t), e), Wt = class Wt extends rt {
|
|
5079
5079
|
constructor(t, e = {}) {
|
|
5080
5080
|
var n, s, i, o, a, r, c, l, d, u;
|
|
5081
5081
|
super(t, e), this.backgroundOpacity = (n = e.backgroundOpacity) != null ? n : 1, this.lineFontDefaults = (s = e.lineFontDefaults) != null ? s : void 0, this.paddingTop = (i = e.paddingTop) != null ? i : 0, this.paddingRight = (o = e.paddingRight) != null ? o : 0, this.paddingBottom = (a = e.paddingBottom) != null ? a : 0, this.paddingLeft = (r = e.paddingLeft) != null ? r : 0, this.radiusTopLeft = (c = e.radiusTopLeft) != null ? c : 0, this.radiusTopRight = (l = e.radiusTopRight) != null ? l : 0, this.radiusBottomRight = (d = e.radiusBottomRight) != null ? d : 0, this.radiusBottomLeft = (u = e.radiusBottomLeft) != null ? u : 0, this._roundDimensions();
|
|
@@ -5100,7 +5100,7 @@ const Ds = ({ textbox: h }) => {
|
|
|
5100
5100
|
}
|
|
5101
5101
|
_getTransformedDimensions(t = {}) {
|
|
5102
5102
|
const { width: e, height: n } = this._getBackgroundDimensions();
|
|
5103
|
-
return super._getTransformedDimensions(yt(
|
|
5103
|
+
return super._getTransformedDimensions(yt(P({}, t), {
|
|
5104
5104
|
width: e,
|
|
5105
5105
|
height: n
|
|
5106
5106
|
}));
|
|
@@ -5110,7 +5110,7 @@ const Ds = ({ textbox: h }) => {
|
|
|
5110
5110
|
*/
|
|
5111
5111
|
toObject(t = []) {
|
|
5112
5112
|
const e = super.toObject(t);
|
|
5113
|
-
return yt(
|
|
5113
|
+
return yt(P({}, e), {
|
|
5114
5114
|
backgroundOpacity: this.backgroundOpacity,
|
|
5115
5115
|
lineFontDefaults: this.lineFontDefaults,
|
|
5116
5116
|
paddingTop: this.paddingTop,
|
|
@@ -5128,7 +5128,7 @@ const Ds = ({ textbox: h }) => {
|
|
|
5128
5128
|
const e = this._getEffectiveBackgroundFill();
|
|
5129
5129
|
if (e && e) {
|
|
5130
5130
|
const i = this._getPadding(), o = (n = this.width) != null ? n : 0, a = (s = this.height) != null ? s : 0, r = o + i.left + i.right, c = a + i.top + i.bottom, l = this._getCornerRadii({ width: r, height: c }), d = this._getLeftOffset() - i.left, u = this._getTopOffset() - i.top;
|
|
5131
|
-
t.save(),
|
|
5131
|
+
t.save(), Wt._renderRoundedRect({
|
|
5132
5132
|
ctx: t,
|
|
5133
5133
|
height: c,
|
|
5134
5134
|
left: d,
|
|
@@ -5163,42 +5163,42 @@ const Ds = ({ textbox: h }) => {
|
|
|
5163
5163
|
l += b;
|
|
5164
5164
|
continue;
|
|
5165
5165
|
}
|
|
5166
|
-
const w = c[g],
|
|
5167
|
-
let
|
|
5168
|
-
const
|
|
5169
|
-
let
|
|
5170
|
-
for (let R = 0,
|
|
5166
|
+
const w = c[g], v = b / i, C = this._getLineLeftOffset(g);
|
|
5167
|
+
let O = 0, j = 0, S = this.getValueOfPropertyAt(g, 0, e), A = this._getDecorationColorAt(g, 0), M = this.getValueOfPropertyAt(g, 0, "textDecorationThickness"), E = S, I = A, z = M;
|
|
5168
|
+
const F = l + v * (1 - r);
|
|
5169
|
+
let U = this.getHeightOfChar(g, 0), D = this.getValueOfPropertyAt(g, 0, "deltaY");
|
|
5170
|
+
for (let R = 0, k = w.length; R < k; R += 1) {
|
|
5171
5171
|
const T = this.__charBounds[g][R];
|
|
5172
|
-
|
|
5173
|
-
const
|
|
5174
|
-
if (u &&
|
|
5175
|
-
const
|
|
5172
|
+
E = this.getValueOfPropertyAt(g, R, e), I = this._getDecorationColorAt(g, R), z = this.getValueOfPropertyAt(g, R, "textDecorationThickness");
|
|
5173
|
+
const _ = this.getHeightOfChar(g, R), x = this.getValueOfPropertyAt(g, R, "deltaY");
|
|
5174
|
+
if (u && E && I) {
|
|
5175
|
+
const L = s * z / 1e3;
|
|
5176
5176
|
t.save(), t.fillStyle = A, t.translate(T.renderLeft, T.renderTop), t.rotate(T.angle), t.fillRect(
|
|
5177
5177
|
-T.kernedWidth / 2,
|
|
5178
|
-
p *
|
|
5178
|
+
p * _ + x - m * L,
|
|
5179
5179
|
T.kernedWidth,
|
|
5180
|
-
|
|
5180
|
+
L
|
|
5181
5181
|
), t.restore();
|
|
5182
|
-
} else if ((
|
|
5183
|
-
const
|
|
5184
|
-
let V = d +
|
|
5185
|
-
n === "rtl" && (V = a - V -
|
|
5182
|
+
} else if ((E !== S || I !== A || _ !== U || z !== M || x !== D) && j > 0) {
|
|
5183
|
+
const L = s * M / 1e3;
|
|
5184
|
+
let V = d + C + O;
|
|
5185
|
+
n === "rtl" && (V = a - V - j), S && A && M && (t.fillStyle = A, t.fillRect(
|
|
5186
5186
|
V,
|
|
5187
|
-
|
|
5188
|
-
|
|
5189
|
-
|
|
5190
|
-
)),
|
|
5187
|
+
F + p * U + D - m * L,
|
|
5188
|
+
j,
|
|
5189
|
+
L
|
|
5190
|
+
)), O = T.left, j = T.width, S = E, M = z, A = I, U = _, D = x;
|
|
5191
5191
|
} else
|
|
5192
|
-
|
|
5192
|
+
j += T.kernedWidth;
|
|
5193
5193
|
}
|
|
5194
|
-
let
|
|
5195
|
-
n === "rtl" && (
|
|
5196
|
-
const
|
|
5197
|
-
|
|
5198
|
-
|
|
5199
|
-
|
|
5200
|
-
|
|
5201
|
-
|
|
5194
|
+
let B = d + C + O;
|
|
5195
|
+
n === "rtl" && (B = a - B - j), t.fillStyle = I;
|
|
5196
|
+
const N = s * z / 1e3;
|
|
5197
|
+
E && I && z && t.fillRect(
|
|
5198
|
+
B,
|
|
5199
|
+
F + p * U + D - m * N,
|
|
5200
|
+
j - f,
|
|
5201
|
+
N
|
|
5202
5202
|
), l += b;
|
|
5203
5203
|
}
|
|
5204
5204
|
this._removeShadow(t);
|
|
@@ -5207,9 +5207,9 @@ const Ds = ({ textbox: h }) => {
|
|
|
5207
5207
|
* Возвращает цвет линии декорации для символа, учитывая обводку и заливку.
|
|
5208
5208
|
*/
|
|
5209
5209
|
_getDecorationColorAt(t, e) {
|
|
5210
|
-
const n = this.getValueOfPropertyAt(t, e, "strokeWidth"), s =
|
|
5210
|
+
const n = this.getValueOfPropertyAt(t, e, "strokeWidth"), s = Ue({
|
|
5211
5211
|
width: typeof n == "number" && Number.isFinite(n) ? n : 0
|
|
5212
|
-
}), i = this.getValueOfPropertyAt(t, e, "stroke"), o = i == null ? null :
|
|
5212
|
+
}), i = this.getValueOfPropertyAt(t, e, "stroke"), o = i == null ? null : Fe({ strokeColor: i, width: s });
|
|
5213
5213
|
if (s > 0 && o != null)
|
|
5214
5214
|
return o;
|
|
5215
5215
|
const a = this.getValueOfPropertyAt(t, e, "fill");
|
|
@@ -5249,9 +5249,9 @@ const Ds = ({ textbox: h }) => {
|
|
|
5249
5249
|
const e = Mt({ value: (s = this.backgroundOpacity) != null ? s : 1, min: 0, max: 1 });
|
|
5250
5250
|
let n;
|
|
5251
5251
|
try {
|
|
5252
|
-
n = new
|
|
5252
|
+
n = new Kn(t);
|
|
5253
5253
|
} catch (i) {
|
|
5254
|
-
return
|
|
5254
|
+
return ne.emitError({
|
|
5255
5255
|
origin: "BackgroundTextbox",
|
|
5256
5256
|
method: "_getEffectiveBackgroundFill",
|
|
5257
5257
|
code: "INVALID_COLOR_VALUE",
|
|
@@ -5288,7 +5288,7 @@ const Ds = ({ textbox: h }) => {
|
|
|
5288
5288
|
n !== t && (this.width = Math.max(0, n)), s !== e && (this.height = Math.max(0, s));
|
|
5289
5289
|
}
|
|
5290
5290
|
};
|
|
5291
|
-
|
|
5291
|
+
Wt.type = "background-textbox", Wt.cacheProperties = [
|
|
5292
5292
|
...Array.isArray(rt.cacheProperties) ? rt.cacheProperties : [],
|
|
5293
5293
|
"backgroundColor",
|
|
5294
5294
|
"backgroundOpacity",
|
|
@@ -5301,7 +5301,7 @@ Yt.type = "background-textbox", Yt.cacheProperties = [
|
|
|
5301
5301
|
"radiusTopRight",
|
|
5302
5302
|
"radiusBottomRight",
|
|
5303
5303
|
"radiusBottomLeft"
|
|
5304
|
-
],
|
|
5304
|
+
], Wt.stateProperties = [
|
|
5305
5305
|
...Array.isArray(rt.stateProperties) ? rt.stateProperties : [],
|
|
5306
5306
|
"backgroundColor",
|
|
5307
5307
|
"backgroundOpacity",
|
|
@@ -5315,11 +5315,11 @@ Yt.type = "background-textbox", Yt.cacheProperties = [
|
|
|
5315
5315
|
"radiusBottomRight",
|
|
5316
5316
|
"radiusBottomLeft"
|
|
5317
5317
|
];
|
|
5318
|
-
let
|
|
5319
|
-
const
|
|
5318
|
+
let Se = Wt;
|
|
5319
|
+
const Fs = () => {
|
|
5320
5320
|
var h;
|
|
5321
|
-
(h =
|
|
5322
|
-
}, it = 0.01,
|
|
5321
|
+
(h = cn) != null && h.setClass && cn.setClass(Se, "background-textbox");
|
|
5322
|
+
}, it = 0.01, bn = ({
|
|
5323
5323
|
textbox: h,
|
|
5324
5324
|
lineIndices: t,
|
|
5325
5325
|
updates: e
|
|
@@ -5337,12 +5337,12 @@ const ks = () => {
|
|
|
5337
5337
|
for (let u = 0; u < t.length; u += 1) {
|
|
5338
5338
|
const f = t[u];
|
|
5339
5339
|
if (!Number.isFinite(f)) continue;
|
|
5340
|
-
const p = d ? c[f] : r == null ? void 0 : r[f], m = p ?
|
|
5340
|
+
const p = d ? c[f] : r == null ? void 0 : r[f], m = p ? P({}, p) : {};
|
|
5341
5341
|
let g = !1;
|
|
5342
|
-
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), i !== void 0 && (p == null ? void 0 : p.fill) !== i && (m.fill = i, g = !0), o !== void 0 && (o === null && (p == null ? void 0 : p.stroke) !== void 0 && (delete m.stroke, g = !0), o !== null && (p == null ? void 0 : p.stroke) !== o && (m.stroke = o, g = !0)), g && (d || (c =
|
|
5342
|
+
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), i !== void 0 && (p == null ? void 0 : p.fill) !== i && (m.fill = i, g = !0), o !== void 0 && (o === null && (p == null ? void 0 : p.stroke) !== void 0 && (delete m.stroke, g = !0), o !== null && (p == null ? void 0 : p.stroke) !== o && (m.stroke = o, g = !0)), g && (d || (c = P({}, c), d = !0), c[f] = m, l = !0);
|
|
5343
5343
|
}
|
|
5344
5344
|
return l && (h.lineFontDefaults = c), l;
|
|
5345
|
-
},
|
|
5345
|
+
}, Us = ({
|
|
5346
5346
|
lineText: h,
|
|
5347
5347
|
lineStyles: t,
|
|
5348
5348
|
lineDefaults: e
|
|
@@ -5365,22 +5365,22 @@ const ks = () => {
|
|
|
5365
5365
|
for (const f in t) {
|
|
5366
5366
|
if (!Object.prototype.hasOwnProperty.call(t, f)) continue;
|
|
5367
5367
|
const p = Number(f);
|
|
5368
|
-
Number.isInteger(p) && p >= 0 && p < n || (u || (l =
|
|
5368
|
+
Number.isInteger(p) && p >= 0 && p < n || (u || (l = P({}, t), u = !0), l && Object.prototype.hasOwnProperty.call(l, f) && delete l[f], d = !0);
|
|
5369
5369
|
}
|
|
5370
5370
|
for (let f = 0; f < n; f += 1) {
|
|
5371
5371
|
const p = l != null ? l : t, m = p ? p[f] : void 0;
|
|
5372
5372
|
if (!m) {
|
|
5373
|
-
l || (l = {}, u = !0), u || (l =
|
|
5373
|
+
l || (l = {}, u = !0), u || (l = P({}, l), u = !0), l[f] = P({}, c), d = !0;
|
|
5374
5374
|
continue;
|
|
5375
5375
|
}
|
|
5376
5376
|
let g = null;
|
|
5377
|
-
s !== void 0 && m.fontFamily === void 0 && (g =
|
|
5377
|
+
s !== void 0 && m.fontFamily === void 0 && (g = P({}, m), g.fontFamily = s), i !== void 0 && m.fontSize === void 0 && (g || (g = P({}, m)), g.fontSize = i), o !== void 0 && m.fill === void 0 && (g || (g = P({}, m)), g.fill = o), a !== void 0 && m.stroke === void 0 && (g || (g = P({}, m)), g.stroke = a), g && (l || (l = {}, u = !0), u || (l = P({}, l), u = !0), l[f] = g, d = !0);
|
|
5378
5378
|
}
|
|
5379
5379
|
return {
|
|
5380
5380
|
lineStyles: l,
|
|
5381
5381
|
changed: d
|
|
5382
5382
|
};
|
|
5383
|
-
},
|
|
5383
|
+
}, vn = ({
|
|
5384
5384
|
lineFontDefaults: h
|
|
5385
5385
|
}) => {
|
|
5386
5386
|
if (!h) return;
|
|
@@ -5390,10 +5390,10 @@ const ks = () => {
|
|
|
5390
5390
|
const n = Number(e);
|
|
5391
5391
|
if (!Number.isFinite(n)) continue;
|
|
5392
5392
|
const s = h[n];
|
|
5393
|
-
s && (t[n] =
|
|
5393
|
+
s && (t[n] = P({}, s));
|
|
5394
5394
|
}
|
|
5395
5395
|
return t;
|
|
5396
|
-
},
|
|
5396
|
+
}, Sn = ({
|
|
5397
5397
|
lineFontDefaults: h,
|
|
5398
5398
|
scale: t
|
|
5399
5399
|
}) => {
|
|
@@ -5406,12 +5406,12 @@ const ks = () => {
|
|
|
5406
5406
|
if (!Number.isFinite(o)) continue;
|
|
5407
5407
|
const a = h[o];
|
|
5408
5408
|
if (!a) continue;
|
|
5409
|
-
const r =
|
|
5409
|
+
const r = P({}, a);
|
|
5410
5410
|
typeof a.fontSize == "number" && (r.fontSize = Math.max(1, a.fontSize * t), s = !0), e[o] = r, n = !0;
|
|
5411
5411
|
}
|
|
5412
5412
|
if (!(!n || !s))
|
|
5413
5413
|
return e;
|
|
5414
|
-
},
|
|
5414
|
+
}, Ws = ({
|
|
5415
5415
|
textbox: h
|
|
5416
5416
|
}) => {
|
|
5417
5417
|
var i, o;
|
|
@@ -5425,7 +5425,7 @@ const ks = () => {
|
|
|
5425
5425
|
s = l + 1, n.push({ start: c, end: l });
|
|
5426
5426
|
}
|
|
5427
5427
|
return n;
|
|
5428
|
-
},
|
|
5428
|
+
}, Ys = ({
|
|
5429
5429
|
range: h,
|
|
5430
5430
|
text: t
|
|
5431
5431
|
}) => {
|
|
@@ -5434,11 +5434,11 @@ const ks = () => {
|
|
|
5434
5434
|
if (e <= 0) return null;
|
|
5435
5435
|
const { start: n, end: s } = h, i = Number.isFinite(n) ? n : 0, o = Number.isFinite(s) ? s : i, a = Math.max(0, Math.min(i, e)), r = Math.max(0, Math.min(o, e)), c = Math.min(a, r), l = Math.max(a, r);
|
|
5436
5436
|
return c === l ? null : { start: c, end: l };
|
|
5437
|
-
},
|
|
5437
|
+
}, Hs = ({
|
|
5438
5438
|
textbox: h,
|
|
5439
5439
|
range: t
|
|
5440
5440
|
}) => {
|
|
5441
|
-
const e =
|
|
5441
|
+
const e = Ws({ textbox: h });
|
|
5442
5442
|
if (!e.length) return t;
|
|
5443
5443
|
let { start: n } = t, { end: s } = t;
|
|
5444
5444
|
for (let i = 0; i < e.length; i += 1) {
|
|
@@ -5448,7 +5448,7 @@ const ks = () => {
|
|
|
5448
5448
|
t.end > a && t.start < r && (n = Math.min(n, a), s = Math.max(s, r));
|
|
5449
5449
|
}
|
|
5450
5450
|
return { start: n, end: s };
|
|
5451
|
-
},
|
|
5451
|
+
}, Gs = ({
|
|
5452
5452
|
textbox: h,
|
|
5453
5453
|
range: t
|
|
5454
5454
|
}) => {
|
|
@@ -5463,7 +5463,7 @@ const ks = () => {
|
|
|
5463
5463
|
s > u && n < f && o.push(l), a = f + 1;
|
|
5464
5464
|
}
|
|
5465
5465
|
return o;
|
|
5466
|
-
},
|
|
5466
|
+
}, Zs = ({
|
|
5467
5467
|
textbox: h,
|
|
5468
5468
|
range: t
|
|
5469
5469
|
}) => {
|
|
@@ -5478,7 +5478,7 @@ const ks = () => {
|
|
|
5478
5478
|
n <= u && s >= f && o.push(l), a = f + 1;
|
|
5479
5479
|
}
|
|
5480
5480
|
return o;
|
|
5481
|
-
},
|
|
5481
|
+
}, Vs = ({
|
|
5482
5482
|
previous: h,
|
|
5483
5483
|
next: t
|
|
5484
5484
|
}) => {
|
|
@@ -5486,7 +5486,7 @@ const ks = () => {
|
|
|
5486
5486
|
for (let n = 0; n < e; n += 1)
|
|
5487
5487
|
if (h[n] !== t[n]) return n;
|
|
5488
5488
|
return e;
|
|
5489
|
-
},
|
|
5489
|
+
}, Xs = ({
|
|
5490
5490
|
text: h,
|
|
5491
5491
|
charIndex: t
|
|
5492
5492
|
}) => {
|
|
@@ -5496,7 +5496,7 @@ const ks = () => {
|
|
|
5496
5496
|
h[s] === `
|
|
5497
5497
|
` && (n += 1);
|
|
5498
5498
|
return n;
|
|
5499
|
-
},
|
|
5499
|
+
}, Ks = ({
|
|
5500
5500
|
text: h,
|
|
5501
5501
|
lineIndex: t
|
|
5502
5502
|
}) => {
|
|
@@ -5507,7 +5507,7 @@ const ks = () => {
|
|
|
5507
5507
|
` && (e += 1, e === t))
|
|
5508
5508
|
return n + 1;
|
|
5509
5509
|
return h.length;
|
|
5510
|
-
},
|
|
5510
|
+
}, qs = ({
|
|
5511
5511
|
textbox: h,
|
|
5512
5512
|
text: t
|
|
5513
5513
|
}) => {
|
|
@@ -5519,7 +5519,7 @@ const ks = () => {
|
|
|
5519
5519
|
o > s && (s = o);
|
|
5520
5520
|
}
|
|
5521
5521
|
return s;
|
|
5522
|
-
},
|
|
5522
|
+
}, Js = ({
|
|
5523
5523
|
textbox: h,
|
|
5524
5524
|
montageLeft: t,
|
|
5525
5525
|
montageRight: e
|
|
@@ -5531,10 +5531,10 @@ const ks = () => {
|
|
|
5531
5531
|
return !1;
|
|
5532
5532
|
let a = 0;
|
|
5533
5533
|
return s < t ? a = t - s : i > e && (a = e - i), Math.abs(a) <= it ? !1 : (h.set({ left: ((d = h.left) != null ? d : 0) + a }), !0);
|
|
5534
|
-
},
|
|
5534
|
+
}, Mn = ({
|
|
5535
5535
|
rawValue: h,
|
|
5536
5536
|
calculatedValue: t
|
|
5537
|
-
}) => typeof h == "number" ? h : typeof t == "number" ? t : 0,
|
|
5537
|
+
}) => typeof h == "number" ? h : typeof t == "number" ? t : 0, wn = ({
|
|
5538
5538
|
stylesList: h
|
|
5539
5539
|
}) => {
|
|
5540
5540
|
const t = h.length;
|
|
@@ -5553,13 +5553,13 @@ const ks = () => {
|
|
|
5553
5553
|
if (s !== void 0 || i !== void 0 || o !== void 0 || a !== void 0 || r !== void 0 || c !== void 0) return !0;
|
|
5554
5554
|
}
|
|
5555
5555
|
return !1;
|
|
5556
|
-
},
|
|
5556
|
+
}, _t = ({
|
|
5557
5557
|
textbox: h
|
|
5558
5558
|
}) => {
|
|
5559
|
-
const { width: t, height: e, calcTextWidth: n, calcTextHeight: s } = h, i = typeof n == "function" ? n.call(h) : void 0, o = typeof s == "function" ? s.call(h) : void 0, a =
|
|
5559
|
+
const { width: t, height: e, calcTextWidth: n, calcTextHeight: s } = h, i = typeof n == "function" ? n.call(h) : void 0, o = typeof s == "function" ? s.call(h) : void 0, a = Mn({
|
|
5560
5560
|
rawValue: t,
|
|
5561
5561
|
calculatedValue: i
|
|
5562
|
-
}), r =
|
|
5562
|
+
}), r = Mn({
|
|
5563
5563
|
rawValue: e,
|
|
5564
5564
|
calculatedValue: o
|
|
5565
5565
|
}), c = Number.isFinite(a) ? Math.round(a) : null, l = Number.isFinite(r) ? Math.round(r) : null, d = {};
|
|
@@ -5586,7 +5586,7 @@ class at {
|
|
|
5586
5586
|
if (!at._isTextbox(s) || this.lineDefaultsSyncing.has(s)) return;
|
|
5587
5587
|
const { text: i = "", uppercase: o, autoExpand: a } = s, r = !!o, c = a !== !1, l = i.toLocaleLowerCase();
|
|
5588
5588
|
if (r) {
|
|
5589
|
-
const f =
|
|
5589
|
+
const f = Te({ value: l });
|
|
5590
5590
|
f !== i && s.set({ text: f }), s.textCaseRaw = l;
|
|
5591
5591
|
} else
|
|
5592
5592
|
s.textCaseRaw = i;
|
|
@@ -5594,7 +5594,7 @@ class at {
|
|
|
5594
5594
|
let d = !1;
|
|
5595
5595
|
c && (d = this._autoExpandTextboxWidth(s));
|
|
5596
5596
|
let u = !1;
|
|
5597
|
-
d || (u =
|
|
5597
|
+
d || (u = _t({ textbox: s })), (d || u) && (s.setCoords(), s.dirty = !0), this._syncLineFontDefaultsOnTextChanged({ textbox: s });
|
|
5598
5598
|
}, this._handleTextEditingExited = (n) => {
|
|
5599
5599
|
var c, l, d;
|
|
5600
5600
|
const { target: s } = n;
|
|
@@ -5606,13 +5606,13 @@ class at {
|
|
|
5606
5606
|
s.textCaseRaw = u;
|
|
5607
5607
|
} else
|
|
5608
5608
|
s.textCaseRaw = i;
|
|
5609
|
-
|
|
5609
|
+
_t({ textbox: s }) && (s.setCoords(), s.dirty = !0, this.canvas.requestRenderAll()), s.locked || s.set({
|
|
5610
5610
|
lockMovementX: !1,
|
|
5611
5611
|
lockMovementY: !1
|
|
5612
5612
|
});
|
|
5613
5613
|
const { historyManager: r } = this.editor;
|
|
5614
5614
|
r.endAction({ reason: "text-edit" }), r.scheduleSaveState({
|
|
5615
|
-
delayMs:
|
|
5615
|
+
delayMs: Cs,
|
|
5616
5616
|
reason: "text-edit"
|
|
5617
5617
|
});
|
|
5618
5618
|
}, this._handleObjectResizing = (n) => {
|
|
@@ -5629,10 +5629,10 @@ class at {
|
|
|
5629
5629
|
s.set({ width: m });
|
|
5630
5630
|
const { width: g = 0 } = s, y = p - g;
|
|
5631
5631
|
if (y !== 0 && i && i.corner === "ml") {
|
|
5632
|
-
const w = ((l = s.angle) != null ? l : 0) * Math.PI / 180,
|
|
5632
|
+
const w = ((l = s.angle) != null ? l : 0) * Math.PI / 180, v = Math.cos(w), C = Math.sin(w), O = (d = s.scaleX) != null ? d : 1, j = y * O;
|
|
5633
5633
|
s.set({
|
|
5634
|
-
left: ((u = s.left) != null ? u : 0) +
|
|
5635
|
-
top: ((f = s.top) != null ? f : 0) +
|
|
5634
|
+
left: ((u = s.left) != null ? u : 0) + j * v,
|
|
5635
|
+
top: ((f = s.top) != null ? f : 0) + j * C
|
|
5636
5636
|
});
|
|
5637
5637
|
}
|
|
5638
5638
|
}
|
|
@@ -5643,7 +5643,7 @@ class at {
|
|
|
5643
5643
|
event: o != null ? o : null
|
|
5644
5644
|
});
|
|
5645
5645
|
}, this._handleObjectScaling = (n) => {
|
|
5646
|
-
var
|
|
5646
|
+
var ie, je, oe, ae, re, kt, Ie, ce, Ht, Gt, Zt, Vt, Xt;
|
|
5647
5647
|
const { target: s, transform: i } = n;
|
|
5648
5648
|
if (s instanceof q || !at._isTextbox(s) || !i) return;
|
|
5649
5649
|
s.isScaling = !0;
|
|
@@ -5655,21 +5655,21 @@ class at {
|
|
|
5655
5655
|
baseRadii: d,
|
|
5656
5656
|
baseStyles: u,
|
|
5657
5657
|
baseLineFontDefaults: f
|
|
5658
|
-
} = o, p = typeof ((
|
|
5659
|
-
if (!
|
|
5660
|
-
const
|
|
5661
|
-
paddingTop:
|
|
5662
|
-
paddingRight:
|
|
5663
|
-
paddingBottom:
|
|
5664
|
-
paddingLeft:
|
|
5665
|
-
radiusTopLeft:
|
|
5666
|
-
radiusTopRight:
|
|
5658
|
+
} = o, p = typeof ((ie = i.original) == null ? void 0 : ie.width) == "number" ? i.original.width : void 0, m = typeof ((je = i.original) == null ? void 0 : je.left) == "number" ? i.original.left : void 0, g = p != null ? p : a, y = m != null ? m : r, b = (oe = i.corner) != null ? oe : "", w = (ae = i.action) != null ? ae : "", v = ["ml", "mr"].includes(b) || w === "scaleX", C = ["mt", "mb"].includes(b) || w === "scaleY", O = ["tl", "tr", "bl", "br"].includes(b) || w === "scale", j = O || C;
|
|
5659
|
+
if (!v && !C && !O) return;
|
|
5660
|
+
const S = Math.abs((kt = (re = s.scaleX) != null ? re : i.scaleX) != null ? kt : 1) || 1, A = Math.abs((ce = (Ie = s.scaleY) != null ? Ie : i.scaleY) != null ? ce : 1) || 1, M = Math.max(1, g * S), E = Math.max(1, Math.round(M)), I = Math.max(1, c * A), {
|
|
5661
|
+
paddingTop: z = 0,
|
|
5662
|
+
paddingRight: F = 0,
|
|
5663
|
+
paddingBottom: U = 0,
|
|
5664
|
+
paddingLeft: D = 0,
|
|
5665
|
+
radiusTopLeft: B = 0,
|
|
5666
|
+
radiusTopRight: N = 0,
|
|
5667
5667
|
radiusBottomRight: R = 0,
|
|
5668
|
-
radiusBottomLeft:
|
|
5668
|
+
radiusBottomLeft: k = 0,
|
|
5669
5669
|
fontSize: T,
|
|
5670
|
-
width:
|
|
5671
|
-
originX:
|
|
5672
|
-
} = s,
|
|
5670
|
+
width: _,
|
|
5671
|
+
originX: x = "left"
|
|
5672
|
+
} = s, L = O || C, V = O || C, W = L ? {
|
|
5673
5673
|
top: Math.max(0, l.top * A),
|
|
5674
5674
|
right: Math.max(0, l.right * A),
|
|
5675
5675
|
bottom: Math.max(0, l.bottom * A),
|
|
@@ -5681,31 +5681,31 @@ class at {
|
|
|
5681
5681
|
bottomLeft: Math.max(0, d.bottomLeft * A)
|
|
5682
5682
|
} : d, tt = Object.keys(u).length > 0;
|
|
5683
5683
|
let ot;
|
|
5684
|
-
if (
|
|
5685
|
-
const
|
|
5686
|
-
Object.entries(u).forEach(([
|
|
5687
|
-
if (
|
|
5684
|
+
if (j && tt) {
|
|
5685
|
+
const Bt = {};
|
|
5686
|
+
Object.entries(u).forEach(([le, Q]) => {
|
|
5687
|
+
if (!Q) return;
|
|
5688
5688
|
const st = {};
|
|
5689
|
-
Object.entries(
|
|
5690
|
-
if (!
|
|
5691
|
-
const
|
|
5692
|
-
typeof
|
|
5693
|
-
}), Object.keys(st).length && (
|
|
5694
|
-
}), Object.keys(
|
|
5689
|
+
Object.entries(Q).forEach(([Ce, Nt]) => {
|
|
5690
|
+
if (!Nt) return;
|
|
5691
|
+
const Qe = P({}, Nt);
|
|
5692
|
+
typeof Nt.fontSize == "number" && (Qe.fontSize = Math.max(1, Nt.fontSize * A)), st[Ce] = Qe;
|
|
5693
|
+
}), Object.keys(st).length && (Bt[le] = st);
|
|
5694
|
+
}), Object.keys(Bt).length && (ot = Bt);
|
|
5695
5695
|
}
|
|
5696
5696
|
let pt;
|
|
5697
|
-
|
|
5697
|
+
j && (pt = Sn({
|
|
5698
5698
|
lineFontDefaults: f,
|
|
5699
5699
|
scale: A
|
|
5700
5700
|
}));
|
|
5701
|
-
const
|
|
5702
|
-
if (!
|
|
5701
|
+
const At = (Gt = (Ht = i.originX) != null ? Ht : x) != null ? Gt : "left", dt = y + g, ht = y + g / 2, Et = _ != null ? _ : g, jt = E !== Et, Lt = Math.abs(I - (T != null ? T : c)) > it, xt = Math.abs(W.top - z) > it || Math.abs(W.right - F) > it || Math.abs(W.bottom - U) > it || Math.abs(W.left - D) > it, Rt = Math.abs(J.topLeft - B) > it || Math.abs(J.topRight - N) > it || Math.abs(J.bottomRight - R) > it || Math.abs(J.bottomLeft - k) > it;
|
|
5702
|
+
if (!jt && !Lt && !xt && !Rt) {
|
|
5703
5703
|
s.set({ scaleX: 1, scaleY: 1 }), i.scaleX = 1, i.scaleY = 1;
|
|
5704
5704
|
return;
|
|
5705
5705
|
}
|
|
5706
5706
|
ot && (s.styles = ot), pt && (s.lineFontDefaults = pt), s.set({
|
|
5707
|
-
width:
|
|
5708
|
-
fontSize:
|
|
5707
|
+
width: E,
|
|
5708
|
+
fontSize: j ? I : c,
|
|
5709
5709
|
paddingTop: W.top,
|
|
5710
5710
|
paddingRight: W.right,
|
|
5711
5711
|
paddingBottom: W.bottom,
|
|
@@ -5717,13 +5717,13 @@ class at {
|
|
|
5717
5717
|
scaleX: 1,
|
|
5718
5718
|
scaleY: 1
|
|
5719
5719
|
});
|
|
5720
|
-
const
|
|
5721
|
-
|
|
5722
|
-
const mt = (
|
|
5723
|
-
let
|
|
5724
|
-
|
|
5720
|
+
const Yt = _t({ textbox: s });
|
|
5721
|
+
Yt && (s.dirty = !0);
|
|
5722
|
+
const mt = (Zt = s.width) != null ? Zt : E, se = mt !== Et;
|
|
5723
|
+
let Tt = y;
|
|
5724
|
+
se && (v || O) && (At === "right" ? Tt = dt - mt : At === "center" && (Tt = ht - mt / 2)), s.set({ left: Tt }), o.baseLeft = Tt, i.scaleX = 1, i.scaleY = 1;
|
|
5725
5725
|
const { original: vt } = i;
|
|
5726
|
-
vt && (vt.scaleX = 1, vt.scaleY = 1, vt.width = mt, vt.height = s.height, vt.left =
|
|
5726
|
+
vt && (vt.scaleX = 1, vt.scaleY = 1, vt.width = mt, vt.height = s.height, vt.left = Tt), s.setCoords(), this.canvas.requestRenderAll(), o.baseWidth = mt, o.baseFontSize = (Vt = s.fontSize) != null ? Vt : I, o.baseStyles = JSON.parse(JSON.stringify((Xt = s.styles) != null ? Xt : {})), o.baseLineFontDefaults = vn({
|
|
5727
5727
|
lineFontDefaults: s.lineFontDefaults
|
|
5728
5728
|
}), o.basePadding = {
|
|
5729
5729
|
top: W.top,
|
|
@@ -5735,61 +5735,61 @@ class at {
|
|
|
5735
5735
|
topRight: J.topRight,
|
|
5736
5736
|
bottomRight: J.bottomRight,
|
|
5737
5737
|
bottomLeft: J.bottomLeft
|
|
5738
|
-
}, o.hasWidthChange =
|
|
5738
|
+
}, o.hasWidthChange = se || Lt || xt || Rt || Yt;
|
|
5739
5739
|
}, this._handleObjectModified = (n) => {
|
|
5740
|
-
var b, w,
|
|
5740
|
+
var b, w, v;
|
|
5741
5741
|
const { target: s } = n;
|
|
5742
5742
|
if (s instanceof q) {
|
|
5743
|
-
const
|
|
5744
|
-
if (!
|
|
5745
|
-
const { scaleX:
|
|
5746
|
-
if (Math.abs(
|
|
5747
|
-
this.canvas.discardActiveObject(),
|
|
5748
|
-
var
|
|
5743
|
+
const C = s.getObjects();
|
|
5744
|
+
if (!C.some((M) => at._isTextbox(M))) return;
|
|
5745
|
+
const { scaleX: j = 1, scaleY: S = 1 } = s;
|
|
5746
|
+
if (Math.abs(j - 1) < it && Math.abs(S - 1) < it) return;
|
|
5747
|
+
this.canvas.discardActiveObject(), C.forEach((M) => {
|
|
5748
|
+
var E, I, z, F;
|
|
5749
5749
|
if (at._isTextbox(M)) {
|
|
5750
|
-
const
|
|
5751
|
-
paddingTop:
|
|
5750
|
+
const U = (E = M.scaleX) != null ? E : 1, D = (I = M.scaleY) != null ? I : 1, B = ((z = M.fontSize) != null ? z : 16) * D, N = ((F = M.width) != null ? F : 0) * U, R = D, {
|
|
5751
|
+
paddingTop: k = 0,
|
|
5752
5752
|
paddingRight: T = 0,
|
|
5753
|
-
paddingBottom:
|
|
5754
|
-
paddingLeft:
|
|
5755
|
-
radiusTopLeft:
|
|
5753
|
+
paddingBottom: _ = 0,
|
|
5754
|
+
paddingLeft: x = 0,
|
|
5755
|
+
radiusTopLeft: L = 0,
|
|
5756
5756
|
radiusTopRight: V = 0,
|
|
5757
5757
|
radiusBottomRight: W = 0,
|
|
5758
5758
|
radiusBottomLeft: J = 0,
|
|
5759
5759
|
styles: tt
|
|
5760
5760
|
} = M, ot = {
|
|
5761
|
-
paddingTop: Math.max(0,
|
|
5761
|
+
paddingTop: Math.max(0, k * R),
|
|
5762
5762
|
paddingRight: Math.max(0, T * R),
|
|
5763
|
-
paddingBottom: Math.max(0,
|
|
5764
|
-
paddingLeft: Math.max(0,
|
|
5763
|
+
paddingBottom: Math.max(0, _ * R),
|
|
5764
|
+
paddingLeft: Math.max(0, x * R)
|
|
5765
5765
|
}, pt = {
|
|
5766
|
-
radiusTopLeft: Math.max(0,
|
|
5766
|
+
radiusTopLeft: Math.max(0, L * R),
|
|
5767
5767
|
radiusTopRight: Math.max(0, V * R),
|
|
5768
5768
|
radiusBottomRight: Math.max(0, W * R),
|
|
5769
5769
|
radiusBottomLeft: Math.max(0, J * R)
|
|
5770
5770
|
};
|
|
5771
|
-
let
|
|
5772
|
-
tt && Object.keys(tt).length > 0 && (
|
|
5773
|
-
Object.values(
|
|
5774
|
-
typeof
|
|
5771
|
+
let At = tt;
|
|
5772
|
+
tt && Object.keys(tt).length > 0 && (At = JSON.parse(JSON.stringify(tt)), Object.values(At).forEach((Et) => {
|
|
5773
|
+
Object.values(Et).forEach((jt) => {
|
|
5774
|
+
typeof jt.fontSize == "number" && (jt.fontSize = Math.max(1, jt.fontSize * R));
|
|
5775
5775
|
});
|
|
5776
5776
|
}));
|
|
5777
|
-
const dt =
|
|
5777
|
+
const dt = Sn({
|
|
5778
5778
|
lineFontDefaults: M.lineFontDefaults,
|
|
5779
5779
|
scale: R
|
|
5780
|
-
}), ht = yt(
|
|
5781
|
-
fontSize:
|
|
5782
|
-
width:
|
|
5780
|
+
}), ht = yt(P(P({
|
|
5781
|
+
fontSize: B,
|
|
5782
|
+
width: N,
|
|
5783
5783
|
scaleX: 1,
|
|
5784
5784
|
scaleY: 1
|
|
5785
5785
|
}, ot), pt), {
|
|
5786
|
-
styles:
|
|
5786
|
+
styles: At
|
|
5787
5787
|
});
|
|
5788
|
-
dt && (ht.lineFontDefaults = dt), M.set(ht),
|
|
5788
|
+
dt && (ht.lineFontDefaults = dt), M.set(ht), _t({ textbox: M });
|
|
5789
5789
|
}
|
|
5790
5790
|
M.setCoords();
|
|
5791
5791
|
});
|
|
5792
|
-
const A = new q(
|
|
5792
|
+
const A = new q(C, {
|
|
5793
5793
|
canvas: this.canvas
|
|
5794
5794
|
});
|
|
5795
5795
|
this.canvas.setActiveObject(A), this.canvas.requestRenderAll();
|
|
@@ -5799,7 +5799,7 @@ class at {
|
|
|
5799
5799
|
s.isScaling = !1;
|
|
5800
5800
|
const i = this.scalingState.get(s);
|
|
5801
5801
|
if (this.scalingState.delete(s), !(i != null && i.hasWidthChange)) return;
|
|
5802
|
-
const o = (b = s.width) != null ? b : s.calcTextWidth(), a = (
|
|
5802
|
+
const o = (b = s.width) != null ? b : s.calcTextWidth(), a = (v = (w = s.fontSize) != null ? w : i == null ? void 0 : i.baseFontSize) != null ? v : 16, r = !!(i.baseStyles && Object.keys(i.baseStyles).length), {
|
|
5803
5803
|
paddingTop: c = 0,
|
|
5804
5804
|
paddingRight: l = 0,
|
|
5805
5805
|
paddingBottom: d = 0,
|
|
@@ -5823,15 +5823,15 @@ class at {
|
|
|
5823
5823
|
target: s,
|
|
5824
5824
|
style: y
|
|
5825
5825
|
}), s.set({ scaleX: 1, scaleY: 1 }), s.setCoords();
|
|
5826
|
-
}, 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(),
|
|
5826
|
+
}, 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(), Fs();
|
|
5827
5827
|
}
|
|
5828
5828
|
/**
|
|
5829
5829
|
* Добавляет новый текстовый объект на канвас.
|
|
5830
5830
|
* @param options — настройки текста
|
|
5831
5831
|
* @param flags — флаги поведения
|
|
5832
5832
|
*/
|
|
5833
|
-
addText(
|
|
5834
|
-
var
|
|
5833
|
+
addText(F = {}, { withoutSelection: E = !1, withoutSave: I = !1, withoutAdding: z = !1 } = {}) {
|
|
5834
|
+
var U = F, {
|
|
5835
5835
|
id: t = `text-${et()}`,
|
|
5836
5836
|
text: e = "Новый текст",
|
|
5837
5837
|
autoExpand: n = !0,
|
|
@@ -5851,13 +5851,13 @@ class at {
|
|
|
5851
5851
|
backgroundOpacity: y = 1,
|
|
5852
5852
|
paddingTop: b = 0,
|
|
5853
5853
|
paddingRight: w = 0,
|
|
5854
|
-
paddingBottom:
|
|
5855
|
-
paddingLeft:
|
|
5856
|
-
radiusTopLeft:
|
|
5857
|
-
radiusTopRight:
|
|
5858
|
-
radiusBottomRight:
|
|
5854
|
+
paddingBottom: v = 0,
|
|
5855
|
+
paddingLeft: C = 0,
|
|
5856
|
+
radiusTopLeft: O = 0,
|
|
5857
|
+
radiusTopRight: j = 0,
|
|
5858
|
+
radiusBottomRight: S = 0,
|
|
5859
5859
|
radiusBottomLeft: A = 0
|
|
5860
|
-
} =
|
|
5860
|
+
} = U, M = St(U, [
|
|
5861
5861
|
"id",
|
|
5862
5862
|
"text",
|
|
5863
5863
|
"autoExpand",
|
|
@@ -5885,14 +5885,14 @@ class at {
|
|
|
5885
5885
|
"radiusBottomLeft"
|
|
5886
5886
|
]);
|
|
5887
5887
|
var V;
|
|
5888
|
-
const { historyManager:
|
|
5889
|
-
|
|
5890
|
-
const
|
|
5888
|
+
const { historyManager: D } = this.editor, { canvas: B } = this;
|
|
5889
|
+
D.suspendHistory();
|
|
5890
|
+
const N = s != null ? s : this._getDefaultFontFamily(), R = Ue({ width: p }), k = Fe({
|
|
5891
5891
|
strokeColor: f,
|
|
5892
5892
|
width: R
|
|
5893
|
-
}), T =
|
|
5893
|
+
}), T = P({
|
|
5894
5894
|
id: t,
|
|
5895
|
-
fontFamily:
|
|
5895
|
+
fontFamily: N,
|
|
5896
5896
|
fontSize: i,
|
|
5897
5897
|
fontWeight: o ? "bold" : "normal",
|
|
5898
5898
|
fontStyle: a ? "italic" : "normal",
|
|
@@ -5901,7 +5901,7 @@ class at {
|
|
|
5901
5901
|
linethrough: l,
|
|
5902
5902
|
textAlign: d,
|
|
5903
5903
|
fill: u,
|
|
5904
|
-
stroke:
|
|
5904
|
+
stroke: k,
|
|
5905
5905
|
strokeWidth: R,
|
|
5906
5906
|
strokeUniform: !0,
|
|
5907
5907
|
opacity: m,
|
|
@@ -5909,35 +5909,35 @@ class at {
|
|
|
5909
5909
|
backgroundOpacity: y,
|
|
5910
5910
|
paddingTop: b,
|
|
5911
5911
|
paddingRight: w,
|
|
5912
|
-
paddingBottom:
|
|
5913
|
-
paddingLeft:
|
|
5914
|
-
radiusTopLeft:
|
|
5915
|
-
radiusTopRight:
|
|
5916
|
-
radiusBottomRight:
|
|
5912
|
+
paddingBottom: v,
|
|
5913
|
+
paddingLeft: C,
|
|
5914
|
+
radiusTopLeft: O,
|
|
5915
|
+
radiusTopRight: j,
|
|
5916
|
+
radiusBottomRight: S,
|
|
5917
5917
|
radiusBottomLeft: A
|
|
5918
|
-
}, M),
|
|
5919
|
-
if (
|
|
5920
|
-
const W =
|
|
5921
|
-
W !==
|
|
5922
|
-
}
|
|
5923
|
-
return
|
|
5924
|
-
textbox:
|
|
5925
|
-
options: yt(
|
|
5918
|
+
}, M), _ = new Se(e, T), x = n !== !1;
|
|
5919
|
+
if (_.autoExpand = x, _.textCaseRaw = (V = _.text) != null ? V : "", c) {
|
|
5920
|
+
const W = Te({ value: _.textCaseRaw });
|
|
5921
|
+
W !== _.text && _.set({ text: W });
|
|
5922
|
+
}
|
|
5923
|
+
return _t({ textbox: _ }) && (_.dirty = !0), M.left === void 0 && M.top === void 0 && B.centerObject(_), z || B.add(_), E || B.setActiveObject(_), B.requestRenderAll(), D.resumeHistory(), I || D.saveState(), B.fire("editor:text-added", {
|
|
5924
|
+
textbox: _,
|
|
5925
|
+
options: yt(P({}, T), {
|
|
5926
5926
|
text: e,
|
|
5927
5927
|
bold: o,
|
|
5928
5928
|
italic: a,
|
|
5929
5929
|
strikethrough: l,
|
|
5930
5930
|
align: d,
|
|
5931
5931
|
color: u,
|
|
5932
|
-
strokeColor:
|
|
5932
|
+
strokeColor: k,
|
|
5933
5933
|
strokeWidth: R
|
|
5934
5934
|
}),
|
|
5935
5935
|
flags: {
|
|
5936
|
-
withoutSelection: !!
|
|
5937
|
-
withoutSave: !!
|
|
5938
|
-
withoutAdding: !!
|
|
5936
|
+
withoutSelection: !!E,
|
|
5937
|
+
withoutSave: !!I,
|
|
5938
|
+
withoutAdding: !!z
|
|
5939
5939
|
}
|
|
5940
|
-
}),
|
|
5940
|
+
}), _;
|
|
5941
5941
|
}
|
|
5942
5942
|
/**
|
|
5943
5943
|
* Обновляет текстовый объект.
|
|
@@ -5955,41 +5955,41 @@ class at {
|
|
|
5955
5955
|
skipRender: s,
|
|
5956
5956
|
selectionRange: i
|
|
5957
5957
|
} = {}) {
|
|
5958
|
-
var
|
|
5958
|
+
var Ht, Zt, Vt, Xt, Bt, le;
|
|
5959
5959
|
const o = this._resolveTextObject(t);
|
|
5960
5960
|
if (!o) return null;
|
|
5961
5961
|
const { text: a = "" } = o, { historyManager: r } = this.editor, { canvas: c } = this;
|
|
5962
5962
|
r.suspendHistory();
|
|
5963
|
-
const l = at._getSnapshot(o), d = (
|
|
5963
|
+
const l = at._getSnapshot(o), d = (Ht = o.originY) != null ? Ht : "top", u = o.getPointByOrigin("center", d), f = {
|
|
5964
5964
|
originY: d,
|
|
5965
5965
|
x: u.x,
|
|
5966
5966
|
y: u.y
|
|
5967
|
-
},
|
|
5967
|
+
}, Gt = e, {
|
|
5968
5968
|
text: p,
|
|
5969
5969
|
autoExpand: m,
|
|
5970
5970
|
fontFamily: g,
|
|
5971
5971
|
fontSize: y,
|
|
5972
5972
|
bold: b,
|
|
5973
5973
|
italic: w,
|
|
5974
|
-
underline:
|
|
5975
|
-
uppercase:
|
|
5976
|
-
strikethrough:
|
|
5977
|
-
align:
|
|
5978
|
-
color:
|
|
5974
|
+
underline: v,
|
|
5975
|
+
uppercase: C,
|
|
5976
|
+
strikethrough: O,
|
|
5977
|
+
align: j,
|
|
5978
|
+
color: S,
|
|
5979
5979
|
strokeColor: A,
|
|
5980
5980
|
strokeWidth: M,
|
|
5981
|
-
opacity:
|
|
5982
|
-
backgroundColor:
|
|
5983
|
-
backgroundOpacity:
|
|
5984
|
-
paddingTop:
|
|
5985
|
-
paddingRight:
|
|
5986
|
-
paddingBottom:
|
|
5987
|
-
paddingLeft:
|
|
5988
|
-
radiusTopLeft:
|
|
5981
|
+
opacity: E,
|
|
5982
|
+
backgroundColor: I,
|
|
5983
|
+
backgroundOpacity: z,
|
|
5984
|
+
paddingTop: F,
|
|
5985
|
+
paddingRight: U,
|
|
5986
|
+
paddingBottom: D,
|
|
5987
|
+
paddingLeft: B,
|
|
5988
|
+
radiusTopLeft: N,
|
|
5989
5989
|
radiusTopRight: R,
|
|
5990
|
-
radiusBottomRight:
|
|
5990
|
+
radiusBottomRight: k,
|
|
5991
5991
|
radiusBottomLeft: T
|
|
5992
|
-
} =
|
|
5992
|
+
} = Gt, _ = St(Gt, [
|
|
5993
5993
|
"text",
|
|
5994
5994
|
"autoExpand",
|
|
5995
5995
|
"fontFamily",
|
|
@@ -6014,45 +6014,45 @@ class at {
|
|
|
6014
6014
|
"radiusTopRight",
|
|
6015
6015
|
"radiusBottomRight",
|
|
6016
6016
|
"radiusBottomLeft"
|
|
6017
|
-
]),
|
|
6017
|
+
]), x = P({}, _), L = i !== void 0 ? Ys({
|
|
6018
6018
|
text: a,
|
|
6019
6019
|
range: i
|
|
6020
|
-
}) :
|
|
6020
|
+
}) : Ns({ textbox: o }), V = L ? Hs({ textbox: o, range: L }) : null, W = {}, J = {}, tt = {};
|
|
6021
6021
|
let ot, pt;
|
|
6022
|
-
const
|
|
6023
|
-
if (g !== void 0 && (V && (J.fontFamily = g), dt && (
|
|
6024
|
-
const
|
|
6025
|
-
|
|
6022
|
+
const At = zs({ textbox: o, range: L }), dt = !L || At, ht = !L;
|
|
6023
|
+
if (g !== void 0 && (V && (J.fontFamily = g), dt && (x.fontFamily = g, ht && (tt.fontFamily = g))), y !== void 0 && (V && (J.fontSize = y), dt && (x.fontSize = y, ht && (tt.fontSize = y))), b !== void 0) {
|
|
6024
|
+
const Q = b ? "bold" : "normal";
|
|
6025
|
+
L && (W.fontWeight = Q), dt && (x.fontWeight = Q, ht && (tt.fontWeight = Q));
|
|
6026
6026
|
}
|
|
6027
6027
|
if (w !== void 0) {
|
|
6028
|
-
const
|
|
6029
|
-
|
|
6030
|
-
}
|
|
6031
|
-
if (
|
|
6032
|
-
const
|
|
6033
|
-
pt =
|
|
6034
|
-
const
|
|
6035
|
-
ot =
|
|
6036
|
-
strokeColor:
|
|
6028
|
+
const Q = w ? "italic" : "normal";
|
|
6029
|
+
L && (W.fontStyle = Q), dt && (x.fontStyle = Q, ht && (tt.fontStyle = Q));
|
|
6030
|
+
}
|
|
6031
|
+
if (v !== void 0 && (L && (W.underline = v), dt && (x.underline = v, ht && (tt.underline = v))), O !== void 0 && (L && (W.linethrough = O), dt && (x.linethrough = O, ht && (tt.linethrough = O))), j !== void 0 && (x.textAlign = j), S !== void 0 && (L && (W.fill = S), dt && (x.fill = S, ht && (tt.fill = S))), A !== void 0 || M !== void 0) {
|
|
6032
|
+
const Q = L ? yn({ textbox: o, range: L, property: "strokeWidth" }) : void 0, st = L ? yn({ textbox: o, range: L, property: "stroke" }) : void 0, Ce = (Vt = (Zt = M != null ? M : Q) != null ? Zt : o.strokeWidth) != null ? Vt : 0;
|
|
6033
|
+
pt = Ue({ width: Ce });
|
|
6034
|
+
const Nt = (Bt = (Xt = A != null ? A : st) != null ? Xt : o.stroke) != null ? Bt : void 0;
|
|
6035
|
+
ot = Fe({
|
|
6036
|
+
strokeColor: Nt,
|
|
6037
6037
|
width: pt
|
|
6038
|
-
}),
|
|
6039
|
-
}
|
|
6040
|
-
|
|
6041
|
-
const
|
|
6042
|
-
if (Lt ||
|
|
6043
|
-
const
|
|
6044
|
-
|
|
6045
|
-
} else o.textCaseRaw === void 0 && (o.textCaseRaw =
|
|
6046
|
-
o.uppercase = Rt, o.set(
|
|
6038
|
+
}), L && (W.stroke = ot, W.strokeWidth = pt), dt && (x.stroke = ot, x.strokeWidth = pt, ht && (tt.stroke = ot, tt.strokeWidth = pt));
|
|
6039
|
+
}
|
|
6040
|
+
E !== void 0 && (x.opacity = E), I !== void 0 && (x.backgroundColor = I), z !== void 0 && (x.backgroundOpacity = z), F !== void 0 && (x.paddingTop = F), U !== void 0 && (x.paddingRight = U), D !== void 0 && (x.paddingBottom = D), B !== void 0 && (x.paddingLeft = B), N !== void 0 && (x.radiusTopLeft = N), R !== void 0 && (x.radiusTopRight = R), k !== void 0 && (x.radiusBottomRight = k), T !== void 0 && (x.radiusBottomLeft = T);
|
|
6041
|
+
const Et = (le = o.textCaseRaw) != null ? le : a, jt = !!o.uppercase, Lt = p !== void 0, xt = Lt ? p != null ? p : "" : Et, Rt = C != null ? C : jt, Yt = Rt !== jt;
|
|
6042
|
+
if (Lt || Yt) {
|
|
6043
|
+
const Q = Rt ? Te({ value: xt }) : xt;
|
|
6044
|
+
x.text = Q, o.textCaseRaw = xt;
|
|
6045
|
+
} else o.textCaseRaw === void 0 && (o.textCaseRaw = Et);
|
|
6046
|
+
o.uppercase = Rt, o.set(x);
|
|
6047
6047
|
let mt = !1;
|
|
6048
|
-
if (
|
|
6049
|
-
const
|
|
6050
|
-
mt =
|
|
6048
|
+
if (L) {
|
|
6049
|
+
const Q = Ee({ textbox: o, styles: W, range: L }), st = V ? Ee({ textbox: o, styles: J, range: V }) : !1;
|
|
6050
|
+
mt = Q || st;
|
|
6051
6051
|
} else if (Object.keys(tt).length) {
|
|
6052
|
-
const
|
|
6053
|
-
|
|
6052
|
+
const Q = Ps({ textbox: o });
|
|
6053
|
+
Q && (mt = Ee({ textbox: o, styles: tt, range: Q }));
|
|
6054
6054
|
}
|
|
6055
|
-
const
|
|
6055
|
+
const se = mt && wn({
|
|
6056
6056
|
stylesList: [
|
|
6057
6057
|
W,
|
|
6058
6058
|
J,
|
|
@@ -6060,43 +6060,43 @@ class at {
|
|
|
6060
6060
|
]
|
|
6061
6061
|
});
|
|
6062
6062
|
if (mt && (o.dirty = !0), V && (g !== void 0 || y !== void 0)) {
|
|
6063
|
-
const
|
|
6063
|
+
const Q = Gs({
|
|
6064
6064
|
textbox: o,
|
|
6065
6065
|
range: V
|
|
6066
6066
|
}), st = {};
|
|
6067
|
-
g !== void 0 && (st.fontFamily = g), y !== void 0 && (st.fontSize = y),
|
|
6067
|
+
g !== void 0 && (st.fontFamily = g), y !== void 0 && (st.fontSize = y), bn({
|
|
6068
6068
|
textbox: o,
|
|
6069
|
-
lineIndices:
|
|
6069
|
+
lineIndices: Q,
|
|
6070
6070
|
updates: st
|
|
6071
6071
|
});
|
|
6072
6072
|
}
|
|
6073
|
-
if (
|
|
6074
|
-
const
|
|
6073
|
+
if (L && (S !== void 0 || A !== void 0 || M !== void 0)) {
|
|
6074
|
+
const Q = Zs({
|
|
6075
6075
|
textbox: o,
|
|
6076
|
-
range:
|
|
6076
|
+
range: L
|
|
6077
6077
|
}), st = {};
|
|
6078
|
-
|
|
6078
|
+
S !== void 0 && (st.fill = S), (A !== void 0 || M !== void 0) && (ot === null && (st.stroke = null), ot != null && (st.stroke = ot)), bn({
|
|
6079
6079
|
textbox: o,
|
|
6080
|
-
lineIndices:
|
|
6080
|
+
lineIndices: Q,
|
|
6081
6081
|
updates: st
|
|
6082
6082
|
});
|
|
6083
6083
|
}
|
|
6084
|
-
|
|
6085
|
-
const
|
|
6084
|
+
se && (o.initDimensions(), o.dirty = !0), (I !== void 0 || z !== void 0 || F !== void 0 || U !== void 0 || D !== void 0 || B !== void 0 || N !== void 0 || R !== void 0 || k !== void 0 || T !== void 0) && (o.dirty = !0);
|
|
6085
|
+
const Tt = wn({
|
|
6086
6086
|
stylesList: [
|
|
6087
|
-
|
|
6087
|
+
x,
|
|
6088
6088
|
W,
|
|
6089
6089
|
J,
|
|
6090
6090
|
tt
|
|
6091
6091
|
]
|
|
6092
|
-
}), { autoExpand: vt } = o,
|
|
6093
|
-
|
|
6094
|
-
const
|
|
6095
|
-
let
|
|
6096
|
-
|
|
6092
|
+
}), { autoExpand: vt } = o, ie = m !== void 0, oe = (m != null ? m : vt) !== !1;
|
|
6093
|
+
ie ? o.autoExpand = m !== !1 : vt === void 0 && (o.autoExpand = !0);
|
|
6094
|
+
const ae = Object.prototype.hasOwnProperty.call(x, "width"), re = oe && !ae && (Lt || Yt || Tt);
|
|
6095
|
+
let kt = !1;
|
|
6096
|
+
re && (kt = this._autoExpandTextboxWidth(o, {
|
|
6097
6097
|
anchor: f
|
|
6098
|
-
}),
|
|
6099
|
-
const
|
|
6098
|
+
}), kt && (o.dirty = !0)), (kt ? !1 : _t({ textbox: o })) && (o.dirty = !0), o.setCoords(), s || c.requestRenderAll(), r.resumeHistory(), n || r.saveState();
|
|
6099
|
+
const ce = at._getSnapshot(o);
|
|
6100
6100
|
return c.fire("editor:text-updated", {
|
|
6101
6101
|
textbox: o,
|
|
6102
6102
|
target: t,
|
|
@@ -6105,11 +6105,11 @@ class at {
|
|
|
6105
6105
|
withoutSave: !!n,
|
|
6106
6106
|
skipRender: !!s
|
|
6107
6107
|
},
|
|
6108
|
-
updates:
|
|
6108
|
+
updates: x,
|
|
6109
6109
|
before: l,
|
|
6110
|
-
after:
|
|
6111
|
-
selectionRange:
|
|
6112
|
-
selectionStyles:
|
|
6110
|
+
after: ce,
|
|
6111
|
+
selectionRange: L != null ? L : void 0,
|
|
6112
|
+
selectionStyles: L && Object.keys(W).length ? W : void 0
|
|
6113
6113
|
}), o;
|
|
6114
6114
|
}
|
|
6115
6115
|
/**
|
|
@@ -6159,7 +6159,7 @@ class at {
|
|
|
6159
6159
|
* Синхронизирует lineFontDefaults при изменении текста и сохраняет typing style для пустых строк.
|
|
6160
6160
|
*/
|
|
6161
6161
|
_syncLineFontDefaultsOnTextChanged({ textbox: t }) {
|
|
6162
|
-
var
|
|
6162
|
+
var z, F, U;
|
|
6163
6163
|
const {
|
|
6164
6164
|
text: e = "",
|
|
6165
6165
|
lineFontDefaults: n,
|
|
@@ -6170,86 +6170,86 @@ class at {
|
|
|
6170
6170
|
stroke: r,
|
|
6171
6171
|
selectionStart: c,
|
|
6172
6172
|
isEditing: l
|
|
6173
|
-
} = t, d = e, u = (
|
|
6173
|
+
} = t, d = e, u = (z = t.__lineDefaultsPrevText) != null ? z : d, f = u.split(`
|
|
6174
6174
|
`), p = d.split(`
|
|
6175
6175
|
`), m = f.length, y = p.length - m;
|
|
6176
|
-
let b = n, w = !1,
|
|
6177
|
-
const
|
|
6176
|
+
let b = n, w = !1, v = !1;
|
|
6177
|
+
const C = typeof a == "string" ? a : void 0, O = typeof r == "string" ? r : void 0;
|
|
6178
6178
|
if (y !== 0 && n && Object.keys(n).length) {
|
|
6179
|
-
const
|
|
6179
|
+
const D = Vs({
|
|
6180
6180
|
previous: u,
|
|
6181
6181
|
next: d
|
|
6182
|
-
}),
|
|
6182
|
+
}), B = Xs({
|
|
6183
6183
|
text: u,
|
|
6184
|
-
charIndex:
|
|
6184
|
+
charIndex: D
|
|
6185
6185
|
});
|
|
6186
6186
|
if (y > 0) {
|
|
6187
|
-
const
|
|
6187
|
+
const N = Ks({
|
|
6188
6188
|
text: u,
|
|
6189
|
-
lineIndex:
|
|
6189
|
+
lineIndex: B
|
|
6190
6190
|
});
|
|
6191
|
-
let R =
|
|
6192
|
-
|
|
6193
|
-
const
|
|
6191
|
+
let R = B + 1;
|
|
6192
|
+
D === N && (R = B);
|
|
6193
|
+
const k = {};
|
|
6194
6194
|
for (const T in n) {
|
|
6195
6195
|
if (!Object.prototype.hasOwnProperty.call(n, T)) continue;
|
|
6196
|
-
const
|
|
6197
|
-
if (!Number.isFinite(
|
|
6198
|
-
const
|
|
6199
|
-
if (!
|
|
6200
|
-
const
|
|
6201
|
-
|
|
6196
|
+
const _ = Number(T);
|
|
6197
|
+
if (!Number.isFinite(_)) continue;
|
|
6198
|
+
const x = n[_];
|
|
6199
|
+
if (!x) continue;
|
|
6200
|
+
const L = _ >= R ? _ + y : _;
|
|
6201
|
+
k[L] = P({}, x);
|
|
6202
6202
|
}
|
|
6203
|
-
b =
|
|
6203
|
+
b = k, w = !0, v = !0;
|
|
6204
6204
|
}
|
|
6205
6205
|
if (y < 0) {
|
|
6206
|
-
const
|
|
6207
|
-
let R =
|
|
6208
|
-
u[
|
|
6209
|
-
` && ((
|
|
6210
|
-
const T = R +
|
|
6211
|
-
for (const
|
|
6212
|
-
if (!Object.prototype.hasOwnProperty.call(n,
|
|
6213
|
-
const
|
|
6214
|
-
if (!Number.isFinite(
|
|
6215
|
-
const V = n[
|
|
6216
|
-
V && (
|
|
6206
|
+
const N = Math.abs(y);
|
|
6207
|
+
let R = B;
|
|
6208
|
+
u[D] === `
|
|
6209
|
+
` && ((F = f[B]) != null ? F : "").length > 0 && (R = B + 1);
|
|
6210
|
+
const T = R + N - 1, _ = {};
|
|
6211
|
+
for (const x in n) {
|
|
6212
|
+
if (!Object.prototype.hasOwnProperty.call(n, x)) continue;
|
|
6213
|
+
const L = Number(x);
|
|
6214
|
+
if (!Number.isFinite(L)) continue;
|
|
6215
|
+
const V = n[L];
|
|
6216
|
+
V && (L < R && (_[L] = P({}, V)), L > T && (_[L + y] = P({}, V)));
|
|
6217
6217
|
}
|
|
6218
|
-
b =
|
|
6218
|
+
b = _, w = !0, v = !0;
|
|
6219
6219
|
}
|
|
6220
6220
|
}
|
|
6221
|
-
let
|
|
6221
|
+
let j = null;
|
|
6222
6222
|
if (l && typeof c == "number") {
|
|
6223
|
-
const
|
|
6224
|
-
Number.isFinite(
|
|
6225
|
-
}
|
|
6226
|
-
let
|
|
6227
|
-
for (let
|
|
6228
|
-
const
|
|
6229
|
-
if (
|
|
6230
|
-
if (
|
|
6231
|
-
const
|
|
6232
|
-
lineText:
|
|
6233
|
-
lineStyles:
|
|
6234
|
-
lineDefaults:
|
|
6223
|
+
const D = t.get2DCursorLocation(c), { lineIndex: B } = D;
|
|
6224
|
+
Number.isFinite(B) && (j = B);
|
|
6225
|
+
}
|
|
6226
|
+
let S = s, A = !1, M = !1, E, I = null;
|
|
6227
|
+
for (let D = 0; D < p.length; D += 1) {
|
|
6228
|
+
const B = (U = p[D]) != null ? U : "", N = b ? b[D] : void 0;
|
|
6229
|
+
if (N && (E = N), B.length !== 0) {
|
|
6230
|
+
if (N) {
|
|
6231
|
+
const L = Us({
|
|
6232
|
+
lineText: B,
|
|
6233
|
+
lineStyles: S ? S[D] : void 0,
|
|
6234
|
+
lineDefaults: N
|
|
6235
6235
|
});
|
|
6236
|
-
|
|
6236
|
+
L.changed && (S || (S = {}, M = !0), M || (S = P({}, S), M = !0), L.lineStyles && (S[D] = L.lineStyles), !L.lineStyles && S[D] && delete S[D], A = !0);
|
|
6237
6237
|
}
|
|
6238
6238
|
continue;
|
|
6239
6239
|
}
|
|
6240
|
-
const
|
|
6241
|
-
(
|
|
6242
|
-
const x = {};
|
|
6243
|
-
T.fontFamily !== void 0 && (x.fontFamily = T.fontFamily), T.fontSize !== void 0 && (x.fontSize = T.fontSize), T.fill !== void 0 && (x.fill = T.fill), T.stroke !== void 0 && (x.stroke = T.stroke);
|
|
6244
|
-
const L = Object.keys(x).length > 0;
|
|
6245
|
-
(L || v && v[_]) && (v || (v = {}, M = !0), M || (v = z({}, v), M = !0), L && (v[_] = { 0: x }), !L && v[_] && delete v[_], A = !0);
|
|
6246
|
-
}
|
|
6247
|
-
if (w && b && (t.lineFontDefaults = b), A && (t.styles = v, t.dirty = !0), O && typeof c == "number") {
|
|
6240
|
+
const k = N != null ? N : E, T = {};
|
|
6241
|
+
(k == null ? void 0 : k.fontFamily) !== void 0 ? T.fontFamily = k.fontFamily : i !== void 0 && (T.fontFamily = i), (k == null ? void 0 : k.fontSize) !== void 0 ? T.fontSize = k.fontSize : o !== void 0 && (T.fontSize = o), (k == null ? void 0 : k.fill) !== void 0 ? T.fill = k.fill : C !== void 0 && (T.fill = C), (k == null ? void 0 : k.stroke) !== void 0 ? T.stroke = k.stroke : O !== void 0 && (T.stroke = O), !N && Object.keys(T).length && (b || (b = {}, v = !0), v || (b = P({}, b), v = !0), b[D] = T, w = !0, E = T), N && (E = N), j !== null && j === D && (I = T);
|
|
6248
6242
|
const _ = {};
|
|
6249
|
-
|
|
6243
|
+
T.fontFamily !== void 0 && (_.fontFamily = T.fontFamily), T.fontSize !== void 0 && (_.fontSize = T.fontSize), T.fill !== void 0 && (_.fill = T.fill), T.stroke !== void 0 && (_.stroke = T.stroke);
|
|
6244
|
+
const x = Object.keys(_).length > 0;
|
|
6245
|
+
(x || S && S[D]) && (S || (S = {}, M = !0), M || (S = P({}, S), M = !0), x && (S[D] = { 0: _ }), !x && S[D] && delete S[D], A = !0);
|
|
6246
|
+
}
|
|
6247
|
+
if (w && b && (t.lineFontDefaults = b), A && (t.styles = S, t.dirty = !0), I && typeof c == "number") {
|
|
6248
|
+
const D = {};
|
|
6249
|
+
if (I.fontFamily !== void 0 && (D.fontFamily = I.fontFamily), I.fontSize !== void 0 && (D.fontSize = I.fontSize), I.fill !== void 0 && (D.fill = I.fill), I.stroke !== void 0 && (D.stroke = I.stroke), Object.keys(D).length) {
|
|
6250
6250
|
this.lineDefaultsSyncing.add(t);
|
|
6251
6251
|
try {
|
|
6252
|
-
t.setSelectionStyles(
|
|
6252
|
+
t.setSelectionStyles(D, c, c);
|
|
6253
6253
|
} finally {
|
|
6254
6254
|
this.lineDefaultsSyncing.delete(t);
|
|
6255
6255
|
}
|
|
@@ -6262,15 +6262,15 @@ class at {
|
|
|
6262
6262
|
* но не шире монтажной области, и удерживает объект в её пределах.
|
|
6263
6263
|
*/
|
|
6264
6264
|
_autoExpandTextboxWidth(t, { anchor: e } = {}) {
|
|
6265
|
-
var
|
|
6265
|
+
var j, S, A, M, E, I, z, F, U, D, B, N, R;
|
|
6266
6266
|
const { montageArea: n } = this.editor;
|
|
6267
6267
|
if (!n) return !1;
|
|
6268
6268
|
const s = typeof t.text == "string" ? t.text : "";
|
|
6269
6269
|
if (!s.length) return !1;
|
|
6270
6270
|
n.setCoords();
|
|
6271
|
-
const i = n.getBoundingRect(!1, !0), o = (
|
|
6271
|
+
const i = n.getBoundingRect(!1, !0), o = (j = i.width) != null ? j : 0;
|
|
6272
6272
|
if (!Number.isFinite(o) || o <= 0) return !1;
|
|
6273
|
-
const a = e != null ? e : (
|
|
6273
|
+
const a = e != null ? e : (S = this.editingAnchorState) == null ? void 0 : S.get(t), r = (M = (A = a == null ? void 0 : a.originY) != null ? A : t.originY) != null ? M : "top", c = Math.abs((E = t.scaleX) != null ? E : 1) || 1, l = (I = t.paddingLeft) != null ? I : 0, d = (z = t.paddingRight) != null ? z : 0, u = (F = t.strokeWidth) != null ? F : 0, f = Math.max(
|
|
6274
6274
|
1,
|
|
6275
6275
|
o / c - l - d - u
|
|
6276
6276
|
);
|
|
@@ -6278,21 +6278,21 @@ class at {
|
|
|
6278
6278
|
const p = s.split(`
|
|
6279
6279
|
`).length;
|
|
6280
6280
|
let m = !1;
|
|
6281
|
-
Math.abs(((
|
|
6281
|
+
Math.abs(((U = t.width) != null ? U : 0) - f) > it && (t.set({ width: f }), m = !0), t.initDimensions();
|
|
6282
6282
|
const { textLines: g } = t, y = Array.isArray(g) && g.length > p, b = Math.ceil(
|
|
6283
|
-
|
|
6284
|
-
), w = Math.min((
|
|
6285
|
-
let
|
|
6283
|
+
qs({ textbox: t, text: s })
|
|
6284
|
+
), w = Math.min((D = t.minWidth) != null ? D : 1, f);
|
|
6285
|
+
let v = Math.min(
|
|
6286
6286
|
f,
|
|
6287
6287
|
Math.max(b, w)
|
|
6288
6288
|
);
|
|
6289
|
-
y && (
|
|
6290
|
-
const
|
|
6289
|
+
y && (v = f), Math.abs(((B = t.width) != null ? B : 0) - v) > it && (t.set({ width: v }), t.initDimensions(), m = !0), _t({ textbox: t }) && (m = !0), a && (t.setPositionByOrigin(new ct(a.x, a.y), "center", r), m = !0);
|
|
6290
|
+
const O = Js({
|
|
6291
6291
|
textbox: t,
|
|
6292
|
-
montageLeft: (
|
|
6292
|
+
montageLeft: (N = i.left) != null ? N : 0,
|
|
6293
6293
|
montageRight: ((R = i.left) != null ? R : 0) + o
|
|
6294
6294
|
});
|
|
6295
|
-
return m ||
|
|
6295
|
+
return m || O;
|
|
6296
6296
|
}
|
|
6297
6297
|
/**
|
|
6298
6298
|
* Возвращает хранилище якорей редактирования, создавая его при необходимости.
|
|
@@ -6335,7 +6335,7 @@ class at {
|
|
|
6335
6335
|
bottomLeft: b
|
|
6336
6336
|
},
|
|
6337
6337
|
baseStyles: JSON.parse(JSON.stringify(c)),
|
|
6338
|
-
baseLineFontDefaults:
|
|
6338
|
+
baseLineFontDefaults: vn({ lineFontDefaults: l }),
|
|
6339
6339
|
hasWidthChange: !1
|
|
6340
6340
|
}, this.scalingState.set(t, e);
|
|
6341
6341
|
}
|
|
@@ -6347,10 +6347,10 @@ class at {
|
|
|
6347
6347
|
static _getSnapshot(t) {
|
|
6348
6348
|
const e = ({
|
|
6349
6349
|
snapshot: T,
|
|
6350
|
-
entries:
|
|
6350
|
+
entries: _
|
|
6351
6351
|
}) => {
|
|
6352
|
-
Object.entries(
|
|
6353
|
-
|
|
6352
|
+
Object.entries(_).forEach(([x, L]) => {
|
|
6353
|
+
L != null && (T[x] = L);
|
|
6354
6354
|
});
|
|
6355
6355
|
}, {
|
|
6356
6356
|
id: n,
|
|
@@ -6370,29 +6370,29 @@ class at {
|
|
|
6370
6370
|
strokeWidth: y,
|
|
6371
6371
|
opacity: b,
|
|
6372
6372
|
backgroundColor: w,
|
|
6373
|
-
backgroundOpacity:
|
|
6374
|
-
paddingTop:
|
|
6375
|
-
paddingRight:
|
|
6376
|
-
paddingBottom:
|
|
6377
|
-
paddingLeft:
|
|
6373
|
+
backgroundOpacity: v,
|
|
6374
|
+
paddingTop: C,
|
|
6375
|
+
paddingRight: O,
|
|
6376
|
+
paddingBottom: j,
|
|
6377
|
+
paddingLeft: S,
|
|
6378
6378
|
radiusTopLeft: A,
|
|
6379
6379
|
radiusTopRight: M,
|
|
6380
|
-
radiusBottomRight:
|
|
6381
|
-
radiusBottomLeft:
|
|
6382
|
-
left:
|
|
6383
|
-
top:
|
|
6384
|
-
width:
|
|
6385
|
-
height:
|
|
6386
|
-
angle:
|
|
6387
|
-
scaleX:
|
|
6380
|
+
radiusBottomRight: E,
|
|
6381
|
+
radiusBottomLeft: I,
|
|
6382
|
+
left: z,
|
|
6383
|
+
top: F,
|
|
6384
|
+
width: U,
|
|
6385
|
+
height: D,
|
|
6386
|
+
angle: B,
|
|
6387
|
+
scaleX: N,
|
|
6388
6388
|
scaleY: R
|
|
6389
|
-
} = t,
|
|
6389
|
+
} = t, k = {
|
|
6390
6390
|
id: n,
|
|
6391
6391
|
uppercase: !!o,
|
|
6392
6392
|
textAlign: p
|
|
6393
6393
|
};
|
|
6394
6394
|
return e({
|
|
6395
|
-
snapshot:
|
|
6395
|
+
snapshot: k,
|
|
6396
6396
|
entries: {
|
|
6397
6397
|
text: s,
|
|
6398
6398
|
textCaseRaw: i,
|
|
@@ -6408,24 +6408,24 @@ class at {
|
|
|
6408
6408
|
strokeWidth: y,
|
|
6409
6409
|
opacity: b,
|
|
6410
6410
|
backgroundColor: w,
|
|
6411
|
-
backgroundOpacity:
|
|
6412
|
-
paddingTop:
|
|
6413
|
-
paddingRight:
|
|
6414
|
-
paddingBottom:
|
|
6415
|
-
paddingLeft:
|
|
6411
|
+
backgroundOpacity: v,
|
|
6412
|
+
paddingTop: C,
|
|
6413
|
+
paddingRight: O,
|
|
6414
|
+
paddingBottom: j,
|
|
6415
|
+
paddingLeft: S,
|
|
6416
6416
|
radiusTopLeft: A,
|
|
6417
6417
|
radiusTopRight: M,
|
|
6418
|
-
radiusBottomRight:
|
|
6419
|
-
radiusBottomLeft:
|
|
6420
|
-
left:
|
|
6421
|
-
top:
|
|
6422
|
-
width:
|
|
6423
|
-
height:
|
|
6424
|
-
angle:
|
|
6425
|
-
scaleX:
|
|
6418
|
+
radiusBottomRight: E,
|
|
6419
|
+
radiusBottomLeft: I,
|
|
6420
|
+
left: z,
|
|
6421
|
+
top: F,
|
|
6422
|
+
width: U,
|
|
6423
|
+
height: D,
|
|
6424
|
+
angle: B,
|
|
6425
|
+
scaleX: N,
|
|
6426
6426
|
scaleY: R
|
|
6427
6427
|
}
|
|
6428
|
-
}),
|
|
6428
|
+
}), k;
|
|
6429
6429
|
}
|
|
6430
6430
|
/**
|
|
6431
6431
|
* Возвращает первый доступный шрифт или дефолтный Arial.
|
|
@@ -6438,14 +6438,14 @@ class at {
|
|
|
6438
6438
|
const nt = ({
|
|
6439
6439
|
value: h,
|
|
6440
6440
|
fallback: t = 0
|
|
6441
|
-
}) => typeof h == "number" && Number.isFinite(h) ? h : typeof t == "number" && Number.isFinite(t) ? t : 0,
|
|
6441
|
+
}) => typeof h == "number" && Number.isFinite(h) ? h : typeof t == "number" && Number.isFinite(t) ? t : 0, fe = ({
|
|
6442
6442
|
value: h,
|
|
6443
6443
|
dimension: t,
|
|
6444
6444
|
useRelativePositions: e
|
|
6445
6445
|
}) => {
|
|
6446
6446
|
const n = nt({ value: h });
|
|
6447
6447
|
return e ? n : n / (t || 1);
|
|
6448
|
-
},
|
|
6448
|
+
}, $s = ({
|
|
6449
6449
|
object: h,
|
|
6450
6450
|
baseWidth: t,
|
|
6451
6451
|
baseHeight: e,
|
|
@@ -6455,22 +6455,22 @@ const nt = ({
|
|
|
6455
6455
|
const i = h;
|
|
6456
6456
|
if (typeof i[s.x] == "number" && typeof i[s.y] == "number")
|
|
6457
6457
|
return {
|
|
6458
|
-
x:
|
|
6458
|
+
x: fe({
|
|
6459
6459
|
value: i[s.x],
|
|
6460
6460
|
dimension: t,
|
|
6461
6461
|
useRelativePositions: n
|
|
6462
6462
|
}),
|
|
6463
|
-
y:
|
|
6463
|
+
y: fe({
|
|
6464
6464
|
value: i[s.y],
|
|
6465
6465
|
dimension: e,
|
|
6466
6466
|
useRelativePositions: n
|
|
6467
6467
|
})
|
|
6468
6468
|
};
|
|
6469
|
-
const { left: a, top: r, width: c, height: l } = h, d =
|
|
6469
|
+
const { left: a, top: r, width: c, height: l } = h, d = fe({
|
|
6470
6470
|
value: a,
|
|
6471
6471
|
dimension: t,
|
|
6472
6472
|
useRelativePositions: n
|
|
6473
|
-
}), u =
|
|
6473
|
+
}), u = fe({
|
|
6474
6474
|
value: r,
|
|
6475
6475
|
dimension: e,
|
|
6476
6476
|
useRelativePositions: n
|
|
@@ -6479,7 +6479,7 @@ const nt = ({
|
|
|
6479
6479
|
x: d + f / 2,
|
|
6480
6480
|
y: u + p / 2
|
|
6481
6481
|
};
|
|
6482
|
-
},
|
|
6482
|
+
}, Qs = ({
|
|
6483
6483
|
normalizedX: h,
|
|
6484
6484
|
normalizedY: t,
|
|
6485
6485
|
bounds: e,
|
|
@@ -6493,7 +6493,7 @@ const nt = ({
|
|
|
6493
6493
|
}
|
|
6494
6494
|
const c = i + h * a, l = o + t * r;
|
|
6495
6495
|
return new ct(c, l);
|
|
6496
|
-
},
|
|
6496
|
+
}, ti = ({
|
|
6497
6497
|
object: h,
|
|
6498
6498
|
montageArea: t,
|
|
6499
6499
|
bounds: e
|
|
@@ -6531,12 +6531,12 @@ const nt = ({
|
|
|
6531
6531
|
} catch (t) {
|
|
6532
6532
|
return null;
|
|
6533
6533
|
}
|
|
6534
|
-
},
|
|
6534
|
+
}, ei = ({
|
|
6535
6535
|
x1: h,
|
|
6536
6536
|
y1: t,
|
|
6537
6537
|
x2: e,
|
|
6538
6538
|
y2: n
|
|
6539
|
-
}) => (Math.atan2(n - t, e - h) * 180 / Math.PI + 360) % 360,
|
|
6539
|
+
}) => (Math.atan2(n - t, e - h) * 180 / Math.PI + 360) % 360, ni = (h) => {
|
|
6540
6540
|
if (!h || typeof h != "object") return null;
|
|
6541
6541
|
const { type: t, coords: e, colorStops: n } = h, s = Array.isArray(n) ? n : [], i = s[0], o = s[s.length - 1], a = typeof (i == null ? void 0 : i.color) == "string" ? i.color : void 0, r = typeof (o == null ? void 0 : o.color) == "string" ? o.color : a, c = typeof (i == null ? void 0 : i.offset) == "number" ? i.offset * 100 : void 0, l = typeof (o == null ? void 0 : o.offset) == "number" ? o.offset * 100 : void 0, d = s.map((u) => ({
|
|
6542
6542
|
color: typeof u.color == "string" ? u.color : "#000000",
|
|
@@ -6548,7 +6548,7 @@ const nt = ({
|
|
|
6548
6548
|
if (typeof u == "number" && typeof f == "number" && typeof p == "number" && typeof m == "number")
|
|
6549
6549
|
return {
|
|
6550
6550
|
type: "linear",
|
|
6551
|
-
angle:
|
|
6551
|
+
angle: ei({ x1: u, y1: f, x2: p, y2: m }),
|
|
6552
6552
|
startColor: a,
|
|
6553
6553
|
endColor: r,
|
|
6554
6554
|
startPosition: c,
|
|
@@ -6572,7 +6572,7 @@ const nt = ({
|
|
|
6572
6572
|
};
|
|
6573
6573
|
}
|
|
6574
6574
|
return null;
|
|
6575
|
-
},
|
|
6575
|
+
}, Jt = "_templateCenterX", _e = "_templateCenterY", ge = "_templateAnchorX", De = "_templateAnchorY";
|
|
6576
6576
|
class Z {
|
|
6577
6577
|
constructor({ editor: t }) {
|
|
6578
6578
|
this.editor = t;
|
|
@@ -6597,16 +6597,16 @@ class Z {
|
|
|
6597
6597
|
return a.emitWarning({
|
|
6598
6598
|
origin: "TemplateManager",
|
|
6599
6599
|
method: "serializeSelection",
|
|
6600
|
-
code:
|
|
6600
|
+
code: Dt.TEMPLATE_MANAGER.NO_OBJECTS_SELECTED,
|
|
6601
6601
|
message: "Нет объектов для сериализации шаблона"
|
|
6602
6602
|
}), null;
|
|
6603
|
-
const p = Z._getBounds(o), m = Z._getMontageSize({ montageArea: o, bounds: p }), g = m.width, y = m.height, b = f.map((
|
|
6604
|
-
object:
|
|
6603
|
+
const p = Z._getBounds(o), m = Z._getMontageSize({ montageArea: o, bounds: p }), g = m.width, y = m.height, b = f.map((C) => Z._serializeObject({
|
|
6604
|
+
object: C,
|
|
6605
6605
|
bounds: p,
|
|
6606
6606
|
baseWidth: g,
|
|
6607
6607
|
baseHeight: y,
|
|
6608
6608
|
montageArea: o != null ? o : null
|
|
6609
|
-
})), w = yt(
|
|
6609
|
+
})), w = yt(P({}, n), {
|
|
6610
6610
|
baseWidth: g,
|
|
6611
6611
|
baseHeight: y,
|
|
6612
6612
|
positionsNormalized: !0,
|
|
@@ -6638,7 +6638,7 @@ class Z {
|
|
|
6638
6638
|
return o.emitWarning({
|
|
6639
6639
|
origin: "TemplateManager",
|
|
6640
6640
|
method: "applyTemplate",
|
|
6641
|
-
code:
|
|
6641
|
+
code: Dt.TEMPLATE_MANAGER.INVALID_TEMPLATE,
|
|
6642
6642
|
message: "Шаблон не содержит объектов"
|
|
6643
6643
|
}), null;
|
|
6644
6644
|
const d = Z._getBounds(s);
|
|
@@ -6646,7 +6646,7 @@ class Z {
|
|
|
6646
6646
|
return o.emitWarning({
|
|
6647
6647
|
origin: "TemplateManager",
|
|
6648
6648
|
method: "applyTemplate",
|
|
6649
|
-
code:
|
|
6649
|
+
code: Dt.TEMPLATE_MANAGER.INVALID_TARGET,
|
|
6650
6650
|
message: "Не удалось определить границы монтажной области"
|
|
6651
6651
|
}), null;
|
|
6652
6652
|
const u = Z._getMontageSize({ montageArea: s, bounds: d }), f = Z._normalizeMeta({ meta: c, fallback: u }), p = Z._calculateScale({ meta: f, target: u }), m = !!f.positionsNormalized;
|
|
@@ -6658,20 +6658,20 @@ class Z {
|
|
|
6658
6658
|
return o.emitWarning({
|
|
6659
6659
|
origin: "TemplateManager",
|
|
6660
6660
|
method: "applyTemplate",
|
|
6661
|
-
code:
|
|
6661
|
+
code: Dt.TEMPLATE_MANAGER.INVALID_TEMPLATE,
|
|
6662
6662
|
message: "Не удалось создать объекты шаблона"
|
|
6663
6663
|
}), null;
|
|
6664
|
-
const { backgroundObject: w, contentObjects:
|
|
6664
|
+
const { backgroundObject: w, contentObjects: v } = Z._extractBackgroundObject(b);
|
|
6665
6665
|
w && (y = yield Z._applyBackgroundFromObject({
|
|
6666
6666
|
backgroundObject: w,
|
|
6667
6667
|
backgroundManager: a,
|
|
6668
6668
|
errorManager: o
|
|
6669
6669
|
}));
|
|
6670
|
-
const
|
|
6671
|
-
object:
|
|
6670
|
+
const C = v.map((O) => (this._adaptTextboxWidth({
|
|
6671
|
+
object: O,
|
|
6672
6672
|
baseWidth: f.baseWidth
|
|
6673
6673
|
}), Z._transformObject({
|
|
6674
|
-
object:
|
|
6674
|
+
object: O,
|
|
6675
6675
|
scale: p,
|
|
6676
6676
|
bounds: d,
|
|
6677
6677
|
targetSize: u,
|
|
@@ -6679,20 +6679,20 @@ class Z {
|
|
|
6679
6679
|
baseHeight: f.baseHeight,
|
|
6680
6680
|
montageArea: s,
|
|
6681
6681
|
useRelativePositions: m
|
|
6682
|
-
}),
|
|
6683
|
-
id: `${
|
|
6682
|
+
}), O.set({
|
|
6683
|
+
id: `${O.type}-${et()}`,
|
|
6684
6684
|
evented: !0
|
|
6685
|
-
}), n.add(
|
|
6686
|
-
return !
|
|
6685
|
+
}), n.add(O), O));
|
|
6686
|
+
return !C.length && !y ? null : (g = C.length > 0 || y, C.length && Z._activateObjects({ canvas: n, objects: C }), n.requestRenderAll(), n.fire("editor:template-applied", {
|
|
6687
6687
|
template: t,
|
|
6688
|
-
objects:
|
|
6688
|
+
objects: C,
|
|
6689
6689
|
bounds: d
|
|
6690
|
-
}),
|
|
6690
|
+
}), C);
|
|
6691
6691
|
} catch (b) {
|
|
6692
6692
|
return o.emitError({
|
|
6693
6693
|
origin: "TemplateManager",
|
|
6694
6694
|
method: "applyTemplate",
|
|
6695
|
-
code:
|
|
6695
|
+
code: Dt.TEMPLATE_MANAGER.APPLY_FAILED,
|
|
6696
6696
|
message: "Ошибка применения шаблона",
|
|
6697
6697
|
data: {
|
|
6698
6698
|
templateId: l,
|
|
@@ -6768,22 +6768,22 @@ class Z {
|
|
|
6768
6768
|
naturalHeight: 0,
|
|
6769
6769
|
width: 0,
|
|
6770
6770
|
height: 0
|
|
6771
|
-
}, m = nt({ value: d || f || c.width, fallback: 0 }), g = nt({ value: u || p || c.height, fallback: 0 }), y = nt({ value: s, fallback: m }), b = nt({ value: i, fallback: g }), w = nt({ value: o, fallback: c.scaleX || 1 }),
|
|
6772
|
-
if (
|
|
6773
|
-
c.set(
|
|
6771
|
+
}, m = nt({ value: d || f || c.width, fallback: 0 }), g = nt({ value: u || p || c.height, fallback: 0 }), y = nt({ value: s, fallback: m }), b = nt({ value: i, fallback: g }), w = nt({ value: o, fallback: c.scaleX || 1 }), v = nt({ value: a, fallback: c.scaleY || 1 }), C = y * w, O = b * v, j = m > 0, S = g > 0, A = C > 0, M = O > 0, E = Z._resolveImageFit({ customData: r }), I = {};
|
|
6772
|
+
if (j && (I.width = m), S && (I.height = g), !j || !S) {
|
|
6773
|
+
c.set(I);
|
|
6774
6774
|
return;
|
|
6775
6775
|
}
|
|
6776
|
-
if (
|
|
6777
|
-
const
|
|
6778
|
-
|
|
6776
|
+
if (E === "stretch") {
|
|
6777
|
+
const F = A ? C / m : null, U = M ? O / g : null;
|
|
6778
|
+
F && F > 0 && (I.scaleX = F), U && U > 0 && (I.scaleY = U), c.set(I);
|
|
6779
6779
|
return;
|
|
6780
6780
|
}
|
|
6781
6781
|
if (!A || !M) {
|
|
6782
|
-
c.set(
|
|
6782
|
+
c.set(I);
|
|
6783
6783
|
return;
|
|
6784
6784
|
}
|
|
6785
|
-
const
|
|
6786
|
-
Number.isFinite(
|
|
6785
|
+
const z = Math.min(C / m, O / g);
|
|
6786
|
+
Number.isFinite(z) && z > 0 && (I.scaleX = z, I.scaleY = z), c.set(I);
|
|
6787
6787
|
}
|
|
6788
6788
|
/**
|
|
6789
6789
|
* Определяет режим вписывания изображения при восстановлении.
|
|
@@ -6809,7 +6809,7 @@ class Z {
|
|
|
6809
6809
|
const e = typeof t.svgMarkup == "string" ? t.svgMarkup : null;
|
|
6810
6810
|
if (!e) return null;
|
|
6811
6811
|
try {
|
|
6812
|
-
const n = yield
|
|
6812
|
+
const n = yield qn(e), s = bt.groupSVGElements(n.objects, n.options), i = yield bt.enlivenObjectEnlivables(
|
|
6813
6813
|
Z._prepareSerializableProps(t)
|
|
6814
6814
|
);
|
|
6815
6815
|
return s.set(i), s.setCoords(), s;
|
|
@@ -6822,7 +6822,7 @@ class Z {
|
|
|
6822
6822
|
* Убирает технические поля сериализации, оставляя только применимые свойства.
|
|
6823
6823
|
*/
|
|
6824
6824
|
static _prepareSerializableProps(t) {
|
|
6825
|
-
const e =
|
|
6825
|
+
const e = P({}, t);
|
|
6826
6826
|
return delete e.svgMarkup, delete e.objects, delete e.path, delete e.paths, delete e.type, delete e.version, e;
|
|
6827
6827
|
}
|
|
6828
6828
|
/**
|
|
@@ -6868,13 +6868,13 @@ class Z {
|
|
|
6868
6868
|
montageArea: a,
|
|
6869
6869
|
useRelativePositions: r
|
|
6870
6870
|
}) {
|
|
6871
|
-
const c = t, { x: l, y: d } =
|
|
6871
|
+
const c = t, { x: l, y: d } = $s({
|
|
6872
6872
|
object: t,
|
|
6873
6873
|
baseWidth: i,
|
|
6874
6874
|
baseHeight: o,
|
|
6875
6875
|
useRelativePositions: r,
|
|
6876
6876
|
centerKeys: {
|
|
6877
|
-
x:
|
|
6877
|
+
x: Jt,
|
|
6878
6878
|
y: _e
|
|
6879
6879
|
}
|
|
6880
6880
|
}), { scaleX: u, scaleY: f } = t, p = nt({ value: u, fallback: 1 }), m = nt({ value: f, fallback: 1 }), g = Z._getPositioningBounds({
|
|
@@ -6883,9 +6883,9 @@ class Z {
|
|
|
6883
6883
|
baseHeight: o,
|
|
6884
6884
|
scale: e,
|
|
6885
6885
|
useRelativePositions: r,
|
|
6886
|
-
anchorX: Z._resolveAnchor(c,
|
|
6886
|
+
anchorX: Z._resolveAnchor(c, ge),
|
|
6887
6887
|
anchorY: Z._resolveAnchor(c, De)
|
|
6888
|
-
}), y =
|
|
6888
|
+
}), y = Qs({
|
|
6889
6889
|
normalizedX: l,
|
|
6890
6890
|
normalizedY: d,
|
|
6891
6891
|
bounds: g,
|
|
@@ -6895,7 +6895,7 @@ class Z {
|
|
|
6895
6895
|
t.set({
|
|
6896
6896
|
scaleX: b,
|
|
6897
6897
|
scaleY: w
|
|
6898
|
-
}), t.setPositionByOrigin(y, "center", "center"), t.setCoords(), delete c[
|
|
6898
|
+
}), t.setPositionByOrigin(y, "center", "center"), t.setCoords(), delete c[Jt], delete c[_e], delete c[ge], delete c[De];
|
|
6899
6899
|
}
|
|
6900
6900
|
/**
|
|
6901
6901
|
* Возвращает bounds, в которых должны позиционироваться нормализованные объекты.
|
|
@@ -6943,7 +6943,7 @@ class Z {
|
|
|
6943
6943
|
fallback: e
|
|
6944
6944
|
}) {
|
|
6945
6945
|
const { width: n, height: s } = e, r = t || {}, { baseWidth: i = n, baseHeight: o = s } = r, a = St(r, ["baseWidth", "baseHeight"]);
|
|
6946
|
-
return
|
|
6946
|
+
return P({
|
|
6947
6947
|
baseWidth: i,
|
|
6948
6948
|
baseHeight: o
|
|
6949
6949
|
}, a);
|
|
@@ -6980,12 +6980,12 @@ class Z {
|
|
|
6980
6980
|
object: t,
|
|
6981
6981
|
baseWidth: e
|
|
6982
6982
|
}) {
|
|
6983
|
-
var
|
|
6983
|
+
var D, B;
|
|
6984
6984
|
if (!(t instanceof rt)) return;
|
|
6985
6985
|
const n = typeof t.text == "string" ? t.text : "";
|
|
6986
6986
|
if (!n) return;
|
|
6987
6987
|
const s = nt({
|
|
6988
|
-
value: (
|
|
6988
|
+
value: (B = (D = this.editor) == null ? void 0 : D.montageArea) == null ? void 0 : B.width,
|
|
6989
6989
|
fallback: 0
|
|
6990
6990
|
}), {
|
|
6991
6991
|
width: i = 0,
|
|
@@ -6994,16 +6994,16 @@ class Z {
|
|
|
6994
6994
|
} = t, r = nt({ value: e, fallback: 0 }), c = t, l = nt({ value: c.paddingLeft, fallback: 0 }), d = nt({ value: c.paddingRight, fallback: 0 }), u = nt({ value: o, fallback: 1 }), f = nt({ value: a, fallback: 0 }) * u, p = nt({ value: i, fallback: 0 }), m = p * u, g = l * u, y = d * u, b = m + g + y + f;
|
|
6995
6995
|
if (!s || !p || !r) return;
|
|
6996
6996
|
t.setCoords();
|
|
6997
|
-
const w = t,
|
|
6997
|
+
const w = t, v = w[Jt], C = typeof v == "number" ? v : null, O = Z._resolveAnchor(w, ge), j = b / r, S = C !== null ? C - j / 2 : null, A = C !== null ? C + j / 2 : null, M = t.getCenterPoint();
|
|
6998
6998
|
t.set("width", s), t.initDimensions();
|
|
6999
|
-
const
|
|
6999
|
+
const E = Z._getLongestLineWidth({
|
|
7000
7000
|
textbox: t,
|
|
7001
7001
|
text: n
|
|
7002
|
-
}),
|
|
7003
|
-
t.set("width",
|
|
7004
|
-
const
|
|
7005
|
-
let
|
|
7006
|
-
|
|
7002
|
+
}), I = E > p ? E + 1 : p;
|
|
7003
|
+
t.set("width", I), t.initDimensions(), t.setPositionByOrigin(M, "center", "center"), t.setCoords();
|
|
7004
|
+
const F = (I * u + g + y + f) / r;
|
|
7005
|
+
let U = C;
|
|
7006
|
+
O === "start" && S !== null ? U = Math.max(0, S) + F / 2 : O === "end" && A !== null && (U = Math.min(1, A) - F / 2), typeof U == "number" && (w[Jt] = U);
|
|
7007
7007
|
}
|
|
7008
7008
|
/**
|
|
7009
7009
|
* Возвращает ширину самой длинной строки текстового объекта.
|
|
@@ -7033,10 +7033,10 @@ class Z {
|
|
|
7033
7033
|
baseHeight: s,
|
|
7034
7034
|
montageArea: i
|
|
7035
7035
|
}) {
|
|
7036
|
-
const o = t.toDatalessObject([...
|
|
7036
|
+
const o = t.toDatalessObject([...ze]);
|
|
7037
7037
|
if (Z._isSvgObject(t)) {
|
|
7038
|
-
const
|
|
7039
|
-
|
|
7038
|
+
const v = Z._extractSvgMarkup(t);
|
|
7039
|
+
v && (o.svgMarkup = v, delete o.objects, delete o.path);
|
|
7040
7040
|
}
|
|
7041
7041
|
if (!e) return o;
|
|
7042
7042
|
const {
|
|
@@ -7044,18 +7044,18 @@ class Z {
|
|
|
7044
7044
|
top: r,
|
|
7045
7045
|
width: c,
|
|
7046
7046
|
height: l
|
|
7047
|
-
} = e, d = t.getBoundingRect(!1, !0), u = n || c || 1, f = s || l || 1, p =
|
|
7047
|
+
} = e, d = t.getBoundingRect(!1, !0), u = n || c || 1, f = s || l || 1, p = ti({
|
|
7048
7048
|
object: t,
|
|
7049
7049
|
montageArea: i,
|
|
7050
7050
|
bounds: e
|
|
7051
7051
|
}), m = p != null ? p : (() => {
|
|
7052
|
-
const
|
|
7052
|
+
const v = t.getCenterPoint();
|
|
7053
7053
|
return {
|
|
7054
|
-
x: (
|
|
7055
|
-
y: (
|
|
7054
|
+
x: (v.x - a) / u,
|
|
7055
|
+
y: (v.y - r) / f
|
|
7056
7056
|
};
|
|
7057
7057
|
})(), g = (d.left - a) / u, y = (d.top - r) / f, b = g + d.width / u, w = y + d.height / f;
|
|
7058
|
-
return o[
|
|
7058
|
+
return o[Jt] = m.x, o[_e] = m.y, o[ge] = Z._detectAnchor({
|
|
7059
7059
|
center: m.x,
|
|
7060
7060
|
start: g,
|
|
7061
7061
|
end: b
|
|
@@ -7094,7 +7094,7 @@ class Z {
|
|
|
7094
7094
|
withoutSave: !0
|
|
7095
7095
|
}), !0;
|
|
7096
7096
|
if (a === "gradient") {
|
|
7097
|
-
const c =
|
|
7097
|
+
const c = ni(i);
|
|
7098
7098
|
if (c)
|
|
7099
7099
|
return e.setGradientBackground({
|
|
7100
7100
|
gradient: c,
|
|
@@ -7117,7 +7117,7 @@ class Z {
|
|
|
7117
7117
|
n.emitWarning({
|
|
7118
7118
|
origin: "TemplateManager",
|
|
7119
7119
|
method: "applyTemplate",
|
|
7120
|
-
code:
|
|
7120
|
+
code: Dt.TEMPLATE_MANAGER.APPLY_FAILED,
|
|
7121
7121
|
message: "Не удалось применить фон из шаблона",
|
|
7122
7122
|
data: i
|
|
7123
7123
|
});
|
|
@@ -7147,7 +7147,7 @@ class Z {
|
|
|
7147
7147
|
*/
|
|
7148
7148
|
static _cloneCustomData(t) {
|
|
7149
7149
|
if (!(!t || typeof t != "object"))
|
|
7150
|
-
return
|
|
7150
|
+
return P({}, t);
|
|
7151
7151
|
}
|
|
7152
7152
|
/**
|
|
7153
7153
|
* Извлекает src изображения из FabricImage или его исходного элемента.
|
|
@@ -7176,35 +7176,46 @@ class Z {
|
|
|
7176
7176
|
return bt.enlivenObjectEnlivables(t);
|
|
7177
7177
|
}
|
|
7178
7178
|
}
|
|
7179
|
-
const
|
|
7179
|
+
const Le = 5, Dn = "#3D8BF4", We = 1, lt = 1, si = 0.01, Me = ({
|
|
7180
7180
|
distance: h
|
|
7181
7181
|
}) => {
|
|
7182
7182
|
if (!Number.isFinite(h)) return 0;
|
|
7183
7183
|
const t = Math.max(0, h);
|
|
7184
7184
|
return Math.floor(t + 1e-6);
|
|
7185
|
-
},
|
|
7185
|
+
}, qe = 1, Je = ({
|
|
7186
|
+
firstDistance: h,
|
|
7187
|
+
secondDistance: t
|
|
7188
|
+
}) => {
|
|
7189
|
+
const e = Me({ distance: h }), n = Me({ distance: t }), s = Math.abs(e - n), i = Math.max(e, n);
|
|
7190
|
+
return {
|
|
7191
|
+
firstDisplayDistance: e,
|
|
7192
|
+
secondDisplayDistance: n,
|
|
7193
|
+
displayDistanceDiff: s,
|
|
7194
|
+
commonDisplayDistance: i
|
|
7195
|
+
};
|
|
7196
|
+
}, Ln = ({
|
|
7186
7197
|
firstStart: h,
|
|
7187
7198
|
firstEnd: t,
|
|
7188
7199
|
secondStart: e,
|
|
7189
7200
|
secondEnd: n
|
|
7190
|
-
}) => Math.min(t, n) - Math.max(h, e),
|
|
7201
|
+
}) => Math.min(t, n) - Math.max(h, e), xn = ({
|
|
7191
7202
|
step: h
|
|
7192
7203
|
}) => {
|
|
7193
7204
|
const e = Math.abs(h).toString(), n = e.indexOf(".");
|
|
7194
7205
|
return n === -1 ? 0 : e.slice(n + 1).length;
|
|
7195
|
-
},
|
|
7206
|
+
}, Ot = ({
|
|
7196
7207
|
value: h,
|
|
7197
7208
|
step: t
|
|
7198
7209
|
}) => {
|
|
7199
|
-
const e =
|
|
7210
|
+
const e = xn({ step: t }), n = Math.round(h / t) * t;
|
|
7200
7211
|
return Number(n.toFixed(e));
|
|
7201
|
-
},
|
|
7212
|
+
}, Rn = ({
|
|
7202
7213
|
value: h,
|
|
7203
7214
|
step: t
|
|
7204
7215
|
}) => {
|
|
7205
|
-
const e =
|
|
7216
|
+
const e = Ot({ value: h, step: t }), n = xn({ step: t }), s = Oe(10, -(n + 4));
|
|
7206
7217
|
return Math.abs(e - h) <= s;
|
|
7207
|
-
},
|
|
7218
|
+
}, ee = ({
|
|
7208
7219
|
bounds: h,
|
|
7209
7220
|
axis: t
|
|
7210
7221
|
}) => {
|
|
@@ -7221,7 +7232,7 @@ const xe = 5, Tn = "#3D8BF4", Ue = 1, lt = 1, Js = 0.01, At = ({
|
|
|
7221
7232
|
start: e,
|
|
7222
7233
|
end: n
|
|
7223
7234
|
};
|
|
7224
|
-
},
|
|
7235
|
+
}, kn = ({
|
|
7225
7236
|
items: h,
|
|
7226
7237
|
axis: t
|
|
7227
7238
|
}) => {
|
|
@@ -7243,7 +7254,7 @@ const xe = 5, Tn = "#3D8BF4", Ue = 1, lt = 1, Js = 0.01, At = ({
|
|
|
7243
7254
|
}) => {
|
|
7244
7255
|
const s = h[t];
|
|
7245
7256
|
if (!s) return null;
|
|
7246
|
-
const { bounds: i } = s, { start: o, end: a } =
|
|
7257
|
+
const { bounds: i } = s, { start: o, end: a } = ee({
|
|
7247
7258
|
bounds: i,
|
|
7248
7259
|
axis: e
|
|
7249
7260
|
});
|
|
@@ -7251,7 +7262,7 @@ const xe = 5, Tn = "#3D8BF4", Ue = 1, lt = 1, Js = 0.01, At = ({
|
|
|
7251
7262
|
for (let r = t - 1; r >= 0; r -= 1) {
|
|
7252
7263
|
const c = h[r];
|
|
7253
7264
|
if (!c) continue;
|
|
7254
|
-
const { bounds: l } = c, { end: d } =
|
|
7265
|
+
const { bounds: l } = c, { end: d } = ee({
|
|
7255
7266
|
bounds: l,
|
|
7256
7267
|
axis: e
|
|
7257
7268
|
});
|
|
@@ -7262,14 +7273,14 @@ const xe = 5, Tn = "#3D8BF4", Ue = 1, lt = 1, Js = 0.01, At = ({
|
|
|
7262
7273
|
for (let r = t + 1; r < h.length; r += 1) {
|
|
7263
7274
|
const c = h[r];
|
|
7264
7275
|
if (!c) continue;
|
|
7265
|
-
const { bounds: l } = c, { start: d } =
|
|
7276
|
+
const { bounds: l } = c, { start: d } = ee({
|
|
7266
7277
|
bounds: l,
|
|
7267
7278
|
axis: e
|
|
7268
7279
|
});
|
|
7269
7280
|
if (d - a >= 0) return r;
|
|
7270
7281
|
}
|
|
7271
7282
|
return null;
|
|
7272
|
-
},
|
|
7283
|
+
}, Bn = ({
|
|
7273
7284
|
items: h
|
|
7274
7285
|
}) => {
|
|
7275
7286
|
for (let t = 0; t < h.length; t += 1) {
|
|
@@ -7277,7 +7288,7 @@ const xe = 5, Tn = "#3D8BF4", Ue = 1, lt = 1, Js = 0.01, At = ({
|
|
|
7277
7288
|
if (e) return t;
|
|
7278
7289
|
}
|
|
7279
7290
|
return -1;
|
|
7280
|
-
},
|
|
7291
|
+
}, Nn = ({
|
|
7281
7292
|
items: h,
|
|
7282
7293
|
axis: t
|
|
7283
7294
|
}) => {
|
|
@@ -7285,14 +7296,14 @@ const xe = 5, Tn = "#3D8BF4", Ue = 1, lt = 1, Js = 0.01, At = ({
|
|
|
7285
7296
|
for (let n = 0; n < h.length - 1; n += 1) {
|
|
7286
7297
|
const s = h[n];
|
|
7287
7298
|
if (!s) continue;
|
|
7288
|
-
const { bounds: i } = s, { end: o } =
|
|
7299
|
+
const { bounds: i } = s, { end: o } = ee({
|
|
7289
7300
|
bounds: i,
|
|
7290
7301
|
axis: t
|
|
7291
7302
|
});
|
|
7292
7303
|
for (let a = n + 1; a < h.length; a += 1) {
|
|
7293
7304
|
const r = h[a];
|
|
7294
7305
|
if (!r) continue;
|
|
7295
|
-
const { bounds: c } = r, { start: l } =
|
|
7306
|
+
const { bounds: c } = r, { start: l } = ee({
|
|
7296
7307
|
bounds: c,
|
|
7297
7308
|
axis: t
|
|
7298
7309
|
}), d = l - o;
|
|
@@ -7309,7 +7320,110 @@ const xe = 5, Tn = "#3D8BF4", Ue = 1, lt = 1, Js = 0.01, At = ({
|
|
|
7309
7320
|
}
|
|
7310
7321
|
}
|
|
7311
7322
|
return e;
|
|
7312
|
-
},
|
|
7323
|
+
}, Pn = ({
|
|
7324
|
+
beforeIndex: h,
|
|
7325
|
+
afterIndex: t,
|
|
7326
|
+
activeIndex: e
|
|
7327
|
+
}) => h < e && t < e, zn = ({
|
|
7328
|
+
beforeIndex: h,
|
|
7329
|
+
afterIndex: t,
|
|
7330
|
+
activeIndex: e
|
|
7331
|
+
}) => h > e && t > e, ii = ({
|
|
7332
|
+
baseOption: h,
|
|
7333
|
+
candidateOption: t
|
|
7334
|
+
}) => {
|
|
7335
|
+
const {
|
|
7336
|
+
delta: e,
|
|
7337
|
+
guide: { distance: n }
|
|
7338
|
+
} = h, {
|
|
7339
|
+
delta: s,
|
|
7340
|
+
guide: { distance: i }
|
|
7341
|
+
} = t;
|
|
7342
|
+
return e === s && n === i;
|
|
7343
|
+
}, oi = ({
|
|
7344
|
+
options: h
|
|
7345
|
+
}) => {
|
|
7346
|
+
let t = h[0];
|
|
7347
|
+
for (let e = 1; e < h.length; e += 1) {
|
|
7348
|
+
const n = h[e];
|
|
7349
|
+
if (n.diff < t.diff) {
|
|
7350
|
+
t = n;
|
|
7351
|
+
continue;
|
|
7352
|
+
}
|
|
7353
|
+
if (n.diff !== t.diff) continue;
|
|
7354
|
+
const s = Math.abs(n.delta), i = Math.abs(t.delta);
|
|
7355
|
+
s < i && (t = n);
|
|
7356
|
+
}
|
|
7357
|
+
return t;
|
|
7358
|
+
}, xe = ({
|
|
7359
|
+
options: h,
|
|
7360
|
+
side: t,
|
|
7361
|
+
baseOption: e
|
|
7362
|
+
}) => {
|
|
7363
|
+
let n = null;
|
|
7364
|
+
for (const s of h) {
|
|
7365
|
+
if (s.side !== t || !ii({
|
|
7366
|
+
baseOption: e,
|
|
7367
|
+
candidateOption: s
|
|
7368
|
+
})) continue;
|
|
7369
|
+
if (!n || s.diff < n.diff) {
|
|
7370
|
+
n = s;
|
|
7371
|
+
continue;
|
|
7372
|
+
}
|
|
7373
|
+
if (!n || s.diff !== n.diff) continue;
|
|
7374
|
+
const o = Math.abs(s.delta), a = Math.abs(n.delta);
|
|
7375
|
+
o < a && (n = s);
|
|
7376
|
+
}
|
|
7377
|
+
return n;
|
|
7378
|
+
}, ai = ({
|
|
7379
|
+
guides: h,
|
|
7380
|
+
seenGuideKeys: t,
|
|
7381
|
+
guide: e
|
|
7382
|
+
}) => {
|
|
7383
|
+
const {
|
|
7384
|
+
type: n,
|
|
7385
|
+
axis: s,
|
|
7386
|
+
refStart: i,
|
|
7387
|
+
refEnd: o,
|
|
7388
|
+
activeStart: a,
|
|
7389
|
+
activeEnd: r,
|
|
7390
|
+
distance: c
|
|
7391
|
+
} = e, l = `${n}:${s}:${i}:${o}:${a}:${r}:${c}`;
|
|
7392
|
+
t.has(l) || (t.add(l), h.push(e));
|
|
7393
|
+
}, Fn = ({
|
|
7394
|
+
options: h
|
|
7395
|
+
}) => {
|
|
7396
|
+
if (!h.length)
|
|
7397
|
+
return {
|
|
7398
|
+
delta: 0,
|
|
7399
|
+
guides: []
|
|
7400
|
+
};
|
|
7401
|
+
const t = oi({ options: h }), e = xe({
|
|
7402
|
+
options: h,
|
|
7403
|
+
side: "before",
|
|
7404
|
+
baseOption: t
|
|
7405
|
+
}), n = xe({
|
|
7406
|
+
options: h,
|
|
7407
|
+
side: "center",
|
|
7408
|
+
baseOption: t
|
|
7409
|
+
}), s = xe({
|
|
7410
|
+
options: h,
|
|
7411
|
+
side: "after",
|
|
7412
|
+
baseOption: t
|
|
7413
|
+
}), i = [];
|
|
7414
|
+
e && s ? i.push(e, s) : (i.push(t), t.side === "before" && s && i.push(s), t.side === "after" && e && i.push(e), t.side === "center" && (e && !s && i.push(e), s && !e && i.push(s))), !i.length && n && i.push(n);
|
|
7415
|
+
const o = [], a = /* @__PURE__ */ new Set();
|
|
7416
|
+
for (const r of i)
|
|
7417
|
+
ai({
|
|
7418
|
+
guides: o,
|
|
7419
|
+
seenGuideKeys: a,
|
|
7420
|
+
guide: r.guide
|
|
7421
|
+
});
|
|
7422
|
+
return {
|
|
7423
|
+
delta: t.delta,
|
|
7424
|
+
guides: o
|
|
7425
|
+
};
|
|
7426
|
+
}, Un = ({
|
|
7313
7427
|
activeStart: h,
|
|
7314
7428
|
activeEnd: t,
|
|
7315
7429
|
targetGap: e,
|
|
@@ -7318,23 +7432,27 @@ const xe = 5, Tn = "#3D8BF4", Ue = 1, lt = 1, Js = 0.01, At = ({
|
|
|
7318
7432
|
threshold: i,
|
|
7319
7433
|
step: o
|
|
7320
7434
|
}) => {
|
|
7321
|
-
const a = e - (h - n), r =
|
|
7435
|
+
const a = e - (h - n), r = Ot({ value: a, step: o }), c = Math.max(1, Math.ceil(i / Math.max(o, 1)));
|
|
7322
7436
|
let l = null;
|
|
7323
7437
|
for (let d = -c; d <= c; d += 1) {
|
|
7324
|
-
const u = r + d * o, f = h + u, p = t + u, m = f - n, g = s - p,
|
|
7325
|
-
|
|
7326
|
-
|
|
7327
|
-
|
|
7438
|
+
const u = r + d * o, f = h + u, p = t + u, m = f - n, g = s - p, {
|
|
7439
|
+
displayDistanceDiff: y,
|
|
7440
|
+
commonDisplayDistance: b
|
|
7441
|
+
} = Je({
|
|
7442
|
+
firstDistance: m,
|
|
7443
|
+
secondDistance: g
|
|
7444
|
+
});
|
|
7445
|
+
if (y > qe || Math.max(
|
|
7328
7446
|
Math.abs(m - e),
|
|
7329
7447
|
Math.abs(g - e)
|
|
7330
7448
|
) > i) continue;
|
|
7331
|
-
const
|
|
7332
|
-
(!l ||
|
|
7449
|
+
const v = Math.abs(m - g), C = Math.abs(u - a), O = v + y * 0.5 + C * 1e-3;
|
|
7450
|
+
(!l || O < l.diff) && (l = {
|
|
7333
7451
|
delta: u,
|
|
7334
|
-
distance:
|
|
7335
|
-
diff:
|
|
7452
|
+
distance: b,
|
|
7453
|
+
diff: O,
|
|
7336
7454
|
activeStart: p,
|
|
7337
|
-
activeEnd: p +
|
|
7455
|
+
activeEnd: p + b
|
|
7338
7456
|
});
|
|
7339
7457
|
}
|
|
7340
7458
|
return l;
|
|
@@ -7342,9 +7460,16 @@ const xe = 5, Tn = "#3D8BF4", Ue = 1, lt = 1, Js = 0.01, At = ({
|
|
|
7342
7460
|
currentGap: h,
|
|
7343
7461
|
referenceGap: t
|
|
7344
7462
|
}) => {
|
|
7345
|
-
const
|
|
7346
|
-
|
|
7347
|
-
|
|
7463
|
+
const {
|
|
7464
|
+
secondDisplayDistance: e,
|
|
7465
|
+
displayDistanceDiff: n,
|
|
7466
|
+
commonDisplayDistance: s
|
|
7467
|
+
} = Je({
|
|
7468
|
+
firstDistance: h,
|
|
7469
|
+
secondDistance: t
|
|
7470
|
+
});
|
|
7471
|
+
return n > qe ? e : s;
|
|
7472
|
+
}, An = ({
|
|
7348
7473
|
anchors: h,
|
|
7349
7474
|
positions: t,
|
|
7350
7475
|
threshold: e
|
|
@@ -7359,16 +7484,16 @@ const xe = 5, Tn = "#3D8BF4", Ue = 1, lt = 1, Js = 0.01, At = ({
|
|
|
7359
7484
|
delta: n,
|
|
7360
7485
|
guidePosition: i
|
|
7361
7486
|
};
|
|
7362
|
-
},
|
|
7487
|
+
}, jn = ({
|
|
7363
7488
|
activeBounds: h,
|
|
7364
7489
|
threshold: t,
|
|
7365
7490
|
anchors: e
|
|
7366
7491
|
}) => {
|
|
7367
|
-
const { left: n, right: s, centerX: i, top: o, bottom: a, centerY: r } = h, c =
|
|
7492
|
+
const { left: n, right: s, centerX: i, top: o, bottom: a, centerY: r } = h, c = An({
|
|
7368
7493
|
anchors: e.vertical,
|
|
7369
7494
|
positions: [n, i, s],
|
|
7370
7495
|
threshold: t
|
|
7371
|
-
}), l =
|
|
7496
|
+
}), l = An({
|
|
7372
7497
|
anchors: e.horizontal,
|
|
7373
7498
|
positions: [o, r, a],
|
|
7374
7499
|
threshold: t
|
|
@@ -7384,7 +7509,7 @@ const xe = 5, Tn = "#3D8BF4", Ue = 1, lt = 1, Js = 0.01, At = ({
|
|
|
7384
7509
|
deltaY: l.delta,
|
|
7385
7510
|
guides: d
|
|
7386
7511
|
};
|
|
7387
|
-
},
|
|
7512
|
+
}, ri = ({
|
|
7388
7513
|
activeBounds: h,
|
|
7389
7514
|
candidates: t,
|
|
7390
7515
|
threshold: e,
|
|
@@ -7397,27 +7522,27 @@ const xe = 5, Tn = "#3D8BF4", Ue = 1, lt = 1, Js = 0.01, At = ({
|
|
|
7397
7522
|
left: a,
|
|
7398
7523
|
right: r
|
|
7399
7524
|
} = h, c = [];
|
|
7400
|
-
for (const
|
|
7525
|
+
for (const j of t) {
|
|
7401
7526
|
const {
|
|
7402
|
-
left:
|
|
7403
|
-
right:
|
|
7404
|
-
} =
|
|
7405
|
-
|
|
7406
|
-
firstStart:
|
|
7407
|
-
firstEnd:
|
|
7527
|
+
left: S,
|
|
7528
|
+
right: A
|
|
7529
|
+
} = j;
|
|
7530
|
+
Ln({
|
|
7531
|
+
firstStart: S,
|
|
7532
|
+
firstEnd: A,
|
|
7408
7533
|
secondStart: a,
|
|
7409
7534
|
secondEnd: r
|
|
7410
|
-
}) > 0 && c.push(
|
|
7535
|
+
}) > 0 && c.push(j);
|
|
7411
7536
|
}
|
|
7412
7537
|
if (!c.length)
|
|
7413
|
-
return { delta: 0,
|
|
7538
|
+
return { delta: 0, guides: [] };
|
|
7414
7539
|
const l = [];
|
|
7415
|
-
for (const
|
|
7416
|
-
l.push({ bounds:
|
|
7417
|
-
l.push({ bounds: h, isActive: !0 }),
|
|
7418
|
-
const d =
|
|
7540
|
+
for (const j of c)
|
|
7541
|
+
l.push({ bounds: j, isActive: !1 });
|
|
7542
|
+
l.push({ bounds: h, isActive: !0 }), kn({ items: l, axis: "top" });
|
|
7543
|
+
const d = Bn({ items: l });
|
|
7419
7544
|
if (d === -1)
|
|
7420
|
-
return { delta: 0,
|
|
7545
|
+
return { delta: 0, guides: [] };
|
|
7421
7546
|
const u = [], f = o - i, p = we({
|
|
7422
7547
|
items: l,
|
|
7423
7548
|
index: d,
|
|
@@ -7430,109 +7555,122 @@ const xe = 5, Tn = "#3D8BF4", Ue = 1, lt = 1, Js = 0.01, At = ({
|
|
|
7430
7555
|
direction: "next"
|
|
7431
7556
|
}), g = p === null ? null : l[p], y = m === null ? null : l[m];
|
|
7432
7557
|
if (g && y) {
|
|
7433
|
-
const { bounds:
|
|
7434
|
-
if (
|
|
7435
|
-
const
|
|
7436
|
-
if (Math.max(
|
|
7437
|
-
const
|
|
7558
|
+
const { bounds: j } = g, { bounds: S } = y, { bottom: A } = j, { top: M } = S, I = M - A - f;
|
|
7559
|
+
if (I >= 0) {
|
|
7560
|
+
const z = I / 2, F = Ot({ value: z, step: lt }), U = i - A, D = M - o, B = Math.abs(U - F), N = Math.abs(D - F);
|
|
7561
|
+
if (Math.max(B, N) <= e) {
|
|
7562
|
+
const k = Un({
|
|
7438
7563
|
activeStart: i,
|
|
7439
7564
|
activeEnd: o,
|
|
7440
7565
|
targetGap: F,
|
|
7441
|
-
beforeEdge:
|
|
7442
|
-
afterEdge:
|
|
7566
|
+
beforeEdge: A,
|
|
7567
|
+
afterEdge: M,
|
|
7443
7568
|
threshold: e,
|
|
7444
7569
|
step: lt
|
|
7445
7570
|
});
|
|
7446
|
-
if (
|
|
7571
|
+
if (k) {
|
|
7447
7572
|
const {
|
|
7448
|
-
delta:
|
|
7449
|
-
distance:
|
|
7450
|
-
diff:
|
|
7451
|
-
activeStart:
|
|
7452
|
-
activeEnd:
|
|
7453
|
-
} =
|
|
7573
|
+
delta: T,
|
|
7574
|
+
distance: _,
|
|
7575
|
+
diff: x,
|
|
7576
|
+
activeStart: L,
|
|
7577
|
+
activeEnd: V
|
|
7578
|
+
} = k, W = {
|
|
7454
7579
|
type: "vertical",
|
|
7455
7580
|
axis: s,
|
|
7456
|
-
refStart:
|
|
7457
|
-
refEnd:
|
|
7458
|
-
activeStart:
|
|
7459
|
-
activeEnd:
|
|
7460
|
-
distance:
|
|
7581
|
+
refStart: A,
|
|
7582
|
+
refEnd: A + _,
|
|
7583
|
+
activeStart: L,
|
|
7584
|
+
activeEnd: V,
|
|
7585
|
+
distance: _
|
|
7461
7586
|
};
|
|
7462
|
-
u.push({
|
|
7587
|
+
u.push({
|
|
7588
|
+
delta: T,
|
|
7589
|
+
guide: W,
|
|
7590
|
+
diff: x,
|
|
7591
|
+
side: "center"
|
|
7592
|
+
});
|
|
7463
7593
|
}
|
|
7464
7594
|
}
|
|
7465
7595
|
}
|
|
7466
7596
|
}
|
|
7467
|
-
const b =
|
|
7468
|
-
let w = null,
|
|
7597
|
+
const b = Nn({ items: l, axis: "vertical" });
|
|
7598
|
+
let w = null, v = null, C = null, O = null;
|
|
7469
7599
|
if (g) {
|
|
7470
|
-
|
|
7471
|
-
const { bottom:
|
|
7472
|
-
|
|
7600
|
+
C = g.bounds;
|
|
7601
|
+
const { bottom: j } = C, S = i - j;
|
|
7602
|
+
S >= 0 && (w = S);
|
|
7473
7603
|
}
|
|
7474
7604
|
if (y) {
|
|
7475
|
-
|
|
7476
|
-
const { top:
|
|
7477
|
-
|
|
7605
|
+
O = y.bounds;
|
|
7606
|
+
const { top: j } = O, S = j - o;
|
|
7607
|
+
S >= 0 && (v = S);
|
|
7478
7608
|
}
|
|
7479
|
-
for (const
|
|
7609
|
+
for (const j of b) {
|
|
7480
7610
|
const {
|
|
7481
|
-
beforeIndex:
|
|
7482
|
-
afterIndex:
|
|
7483
|
-
start:
|
|
7484
|
-
end:
|
|
7485
|
-
distance:
|
|
7486
|
-
} =
|
|
7487
|
-
if (
|
|
7488
|
-
|
|
7489
|
-
|
|
7490
|
-
|
|
7491
|
-
|
|
7492
|
-
|
|
7493
|
-
|
|
7494
|
-
|
|
7495
|
-
|
|
7496
|
-
|
|
7497
|
-
|
|
7498
|
-
|
|
7499
|
-
|
|
7500
|
-
|
|
7501
|
-
|
|
7502
|
-
|
|
7503
|
-
|
|
7504
|
-
|
|
7505
|
-
|
|
7506
|
-
|
|
7507
|
-
|
|
7508
|
-
|
|
7509
|
-
|
|
7510
|
-
|
|
7511
|
-
|
|
7512
|
-
|
|
7513
|
-
|
|
7514
|
-
|
|
7515
|
-
|
|
7516
|
-
|
|
7517
|
-
|
|
7518
|
-
|
|
7519
|
-
|
|
7520
|
-
|
|
7521
|
-
|
|
7611
|
+
beforeIndex: S,
|
|
7612
|
+
afterIndex: A,
|
|
7613
|
+
start: M,
|
|
7614
|
+
end: E,
|
|
7615
|
+
distance: I
|
|
7616
|
+
} = j;
|
|
7617
|
+
if (S === d || A === d || !Rn({ value: I, step: lt })) continue;
|
|
7618
|
+
const F = Pn({
|
|
7619
|
+
beforeIndex: S,
|
|
7620
|
+
afterIndex: A,
|
|
7621
|
+
activeIndex: d
|
|
7622
|
+
}), U = zn({
|
|
7623
|
+
beforeIndex: S,
|
|
7624
|
+
afterIndex: A,
|
|
7625
|
+
activeIndex: d
|
|
7626
|
+
});
|
|
7627
|
+
if (w !== null && C && F && Math.abs(w - I) <= e) {
|
|
7628
|
+
const B = I - w, N = Ot({ value: B, step: lt }), R = i + N, { bottom: k } = C, T = R - k, _ = Math.abs(T - I);
|
|
7629
|
+
if (_ > e) continue;
|
|
7630
|
+
const x = Ae({
|
|
7631
|
+
currentGap: T,
|
|
7632
|
+
referenceGap: I
|
|
7633
|
+
}), L = {
|
|
7634
|
+
type: "vertical",
|
|
7635
|
+
axis: s,
|
|
7636
|
+
refStart: M,
|
|
7637
|
+
refEnd: E,
|
|
7638
|
+
activeStart: k,
|
|
7639
|
+
activeEnd: R,
|
|
7640
|
+
distance: x
|
|
7641
|
+
};
|
|
7642
|
+
u.push({
|
|
7643
|
+
delta: N,
|
|
7644
|
+
guide: L,
|
|
7645
|
+
diff: _,
|
|
7646
|
+
side: "before"
|
|
7647
|
+
});
|
|
7648
|
+
}
|
|
7649
|
+
if (v !== null && O && U && Math.abs(v - I) <= e) {
|
|
7650
|
+
const B = v - I, N = Ot({ value: B, step: lt }), R = o + N, { top: k } = O, T = k - R, _ = Math.abs(T - I);
|
|
7651
|
+
if (_ > e) continue;
|
|
7652
|
+
const x = Ae({
|
|
7653
|
+
currentGap: T,
|
|
7654
|
+
referenceGap: I
|
|
7655
|
+
}), L = {
|
|
7656
|
+
type: "vertical",
|
|
7657
|
+
axis: s,
|
|
7658
|
+
refStart: M,
|
|
7659
|
+
refEnd: E,
|
|
7660
|
+
activeStart: R,
|
|
7661
|
+
activeEnd: k,
|
|
7662
|
+
distance: x
|
|
7663
|
+
};
|
|
7664
|
+
u.push({
|
|
7665
|
+
delta: N,
|
|
7666
|
+
guide: L,
|
|
7667
|
+
diff: _,
|
|
7668
|
+
side: "after"
|
|
7669
|
+
});
|
|
7522
7670
|
}
|
|
7523
7671
|
}
|
|
7524
|
-
|
|
7525
|
-
|
|
7526
|
-
let I = u[0];
|
|
7527
|
-
for (let v = 1; v < u.length; v += 1) {
|
|
7528
|
-
const A = u[v];
|
|
7529
|
-
A.diff < I.diff && (I = A);
|
|
7530
|
-
}
|
|
7531
|
-
return {
|
|
7532
|
-
delta: I.delta,
|
|
7533
|
-
guide: I.guide
|
|
7534
|
-
};
|
|
7535
|
-
}, $s = ({
|
|
7672
|
+
return Fn({ options: u });
|
|
7673
|
+
}, ci = ({
|
|
7536
7674
|
activeBounds: h,
|
|
7537
7675
|
candidates: t,
|
|
7538
7676
|
threshold: e,
|
|
@@ -7545,27 +7683,27 @@ const xe = 5, Tn = "#3D8BF4", Ue = 1, lt = 1, Js = 0.01, At = ({
|
|
|
7545
7683
|
top: a,
|
|
7546
7684
|
bottom: r
|
|
7547
7685
|
} = h, c = [];
|
|
7548
|
-
for (const
|
|
7686
|
+
for (const j of t) {
|
|
7549
7687
|
const {
|
|
7550
|
-
top:
|
|
7551
|
-
bottom:
|
|
7552
|
-
} =
|
|
7553
|
-
|
|
7554
|
-
firstStart:
|
|
7555
|
-
firstEnd:
|
|
7688
|
+
top: S,
|
|
7689
|
+
bottom: A
|
|
7690
|
+
} = j;
|
|
7691
|
+
Ln({
|
|
7692
|
+
firstStart: S,
|
|
7693
|
+
firstEnd: A,
|
|
7556
7694
|
secondStart: a,
|
|
7557
7695
|
secondEnd: r
|
|
7558
|
-
}) > 0 && c.push(
|
|
7696
|
+
}) > 0 && c.push(j);
|
|
7559
7697
|
}
|
|
7560
7698
|
if (!c.length)
|
|
7561
|
-
return { delta: 0,
|
|
7699
|
+
return { delta: 0, guides: [] };
|
|
7562
7700
|
const l = [];
|
|
7563
|
-
for (const
|
|
7564
|
-
l.push({ bounds:
|
|
7565
|
-
l.push({ bounds: h, isActive: !0 }),
|
|
7566
|
-
const d =
|
|
7701
|
+
for (const j of c)
|
|
7702
|
+
l.push({ bounds: j, isActive: !1 });
|
|
7703
|
+
l.push({ bounds: h, isActive: !0 }), kn({ items: l, axis: "left" });
|
|
7704
|
+
const d = Bn({ items: l });
|
|
7567
7705
|
if (d === -1)
|
|
7568
|
-
return { delta: 0,
|
|
7706
|
+
return { delta: 0, guides: [] };
|
|
7569
7707
|
const u = [], f = o - i, p = we({
|
|
7570
7708
|
items: l,
|
|
7571
7709
|
index: d,
|
|
@@ -7578,131 +7716,148 @@ const xe = 5, Tn = "#3D8BF4", Ue = 1, lt = 1, Js = 0.01, At = ({
|
|
|
7578
7716
|
direction: "next"
|
|
7579
7717
|
}), g = p === null ? null : l[p], y = m === null ? null : l[m];
|
|
7580
7718
|
if (g && y) {
|
|
7581
|
-
const { bounds:
|
|
7582
|
-
if (
|
|
7583
|
-
const
|
|
7584
|
-
if (Math.max(
|
|
7585
|
-
const
|
|
7719
|
+
const { bounds: j } = g, { bounds: S } = y, { right: A } = j, { left: M } = S, I = M - A - f;
|
|
7720
|
+
if (I >= 0) {
|
|
7721
|
+
const z = I / 2, F = Ot({ value: z, step: lt }), U = i - A, D = M - o, B = Math.abs(U - F), N = Math.abs(D - F);
|
|
7722
|
+
if (Math.max(B, N) <= e) {
|
|
7723
|
+
const k = Un({
|
|
7586
7724
|
activeStart: i,
|
|
7587
7725
|
activeEnd: o,
|
|
7588
7726
|
targetGap: F,
|
|
7589
|
-
beforeEdge:
|
|
7590
|
-
afterEdge:
|
|
7727
|
+
beforeEdge: A,
|
|
7728
|
+
afterEdge: M,
|
|
7591
7729
|
threshold: e,
|
|
7592
7730
|
step: lt
|
|
7593
7731
|
});
|
|
7594
|
-
if (
|
|
7732
|
+
if (k) {
|
|
7595
7733
|
const {
|
|
7596
|
-
delta:
|
|
7597
|
-
distance:
|
|
7598
|
-
diff:
|
|
7599
|
-
activeStart:
|
|
7600
|
-
activeEnd:
|
|
7601
|
-
} =
|
|
7734
|
+
delta: T,
|
|
7735
|
+
distance: _,
|
|
7736
|
+
diff: x,
|
|
7737
|
+
activeStart: L,
|
|
7738
|
+
activeEnd: V
|
|
7739
|
+
} = k, W = {
|
|
7602
7740
|
type: "horizontal",
|
|
7603
7741
|
axis: s,
|
|
7604
|
-
refStart:
|
|
7605
|
-
refEnd:
|
|
7606
|
-
activeStart:
|
|
7607
|
-
activeEnd:
|
|
7608
|
-
distance:
|
|
7742
|
+
refStart: A,
|
|
7743
|
+
refEnd: A + _,
|
|
7744
|
+
activeStart: L,
|
|
7745
|
+
activeEnd: V,
|
|
7746
|
+
distance: _
|
|
7609
7747
|
};
|
|
7610
|
-
u.push({
|
|
7748
|
+
u.push({
|
|
7749
|
+
delta: T,
|
|
7750
|
+
guide: W,
|
|
7751
|
+
diff: x,
|
|
7752
|
+
side: "center"
|
|
7753
|
+
});
|
|
7611
7754
|
}
|
|
7612
7755
|
}
|
|
7613
7756
|
}
|
|
7614
7757
|
}
|
|
7615
|
-
const b =
|
|
7616
|
-
let w = null,
|
|
7758
|
+
const b = Nn({ items: l, axis: "horizontal" });
|
|
7759
|
+
let w = null, v = null, C = null, O = null;
|
|
7617
7760
|
if (g) {
|
|
7618
|
-
|
|
7619
|
-
const { right:
|
|
7620
|
-
|
|
7761
|
+
C = g.bounds;
|
|
7762
|
+
const { right: j } = C, S = i - j;
|
|
7763
|
+
S >= 0 && (w = S);
|
|
7621
7764
|
}
|
|
7622
7765
|
if (y) {
|
|
7623
|
-
|
|
7624
|
-
const { left:
|
|
7625
|
-
|
|
7766
|
+
O = y.bounds;
|
|
7767
|
+
const { left: j } = O, S = j - o;
|
|
7768
|
+
S >= 0 && (v = S);
|
|
7626
7769
|
}
|
|
7627
|
-
for (const
|
|
7770
|
+
for (const j of b) {
|
|
7628
7771
|
const {
|
|
7629
|
-
beforeIndex:
|
|
7630
|
-
afterIndex:
|
|
7631
|
-
start:
|
|
7632
|
-
end:
|
|
7633
|
-
distance:
|
|
7634
|
-
} =
|
|
7635
|
-
if (
|
|
7636
|
-
|
|
7637
|
-
|
|
7638
|
-
|
|
7639
|
-
|
|
7640
|
-
|
|
7641
|
-
|
|
7642
|
-
|
|
7643
|
-
|
|
7644
|
-
|
|
7645
|
-
|
|
7646
|
-
|
|
7647
|
-
|
|
7648
|
-
|
|
7649
|
-
|
|
7650
|
-
|
|
7651
|
-
|
|
7652
|
-
|
|
7653
|
-
|
|
7654
|
-
|
|
7655
|
-
|
|
7656
|
-
|
|
7657
|
-
|
|
7658
|
-
|
|
7659
|
-
|
|
7660
|
-
|
|
7661
|
-
|
|
7662
|
-
|
|
7663
|
-
|
|
7664
|
-
|
|
7665
|
-
|
|
7666
|
-
|
|
7667
|
-
|
|
7668
|
-
|
|
7669
|
-
|
|
7772
|
+
beforeIndex: S,
|
|
7773
|
+
afterIndex: A,
|
|
7774
|
+
start: M,
|
|
7775
|
+
end: E,
|
|
7776
|
+
distance: I
|
|
7777
|
+
} = j;
|
|
7778
|
+
if (S === d || A === d || !Rn({ value: I, step: lt })) continue;
|
|
7779
|
+
const F = Pn({
|
|
7780
|
+
beforeIndex: S,
|
|
7781
|
+
afterIndex: A,
|
|
7782
|
+
activeIndex: d
|
|
7783
|
+
}), U = zn({
|
|
7784
|
+
beforeIndex: S,
|
|
7785
|
+
afterIndex: A,
|
|
7786
|
+
activeIndex: d
|
|
7787
|
+
});
|
|
7788
|
+
if (w !== null && C && F && Math.abs(w - I) <= e) {
|
|
7789
|
+
const B = I - w, N = Ot({ value: B, step: lt }), R = i + N, { right: k } = C, T = R - k, _ = Math.abs(T - I);
|
|
7790
|
+
if (_ > e) continue;
|
|
7791
|
+
const x = Ae({
|
|
7792
|
+
currentGap: T,
|
|
7793
|
+
referenceGap: I
|
|
7794
|
+
}), L = {
|
|
7795
|
+
type: "horizontal",
|
|
7796
|
+
axis: s,
|
|
7797
|
+
refStart: M,
|
|
7798
|
+
refEnd: E,
|
|
7799
|
+
activeStart: k,
|
|
7800
|
+
activeEnd: R,
|
|
7801
|
+
distance: x
|
|
7802
|
+
};
|
|
7803
|
+
u.push({
|
|
7804
|
+
delta: N,
|
|
7805
|
+
guide: L,
|
|
7806
|
+
diff: _,
|
|
7807
|
+
side: "before"
|
|
7808
|
+
});
|
|
7809
|
+
}
|
|
7810
|
+
if (v !== null && O && U && Math.abs(v - I) <= e) {
|
|
7811
|
+
const B = v - I, N = Ot({ value: B, step: lt }), R = o + N, { left: k } = O, T = k - R, _ = Math.abs(T - I);
|
|
7812
|
+
if (_ > e) continue;
|
|
7813
|
+
const x = Ae({
|
|
7814
|
+
currentGap: T,
|
|
7815
|
+
referenceGap: I
|
|
7816
|
+
}), L = {
|
|
7817
|
+
type: "horizontal",
|
|
7818
|
+
axis: s,
|
|
7819
|
+
refStart: M,
|
|
7820
|
+
refEnd: E,
|
|
7821
|
+
activeStart: R,
|
|
7822
|
+
activeEnd: k,
|
|
7823
|
+
distance: x
|
|
7824
|
+
};
|
|
7825
|
+
u.push({
|
|
7826
|
+
delta: N,
|
|
7827
|
+
guide: L,
|
|
7828
|
+
diff: _,
|
|
7829
|
+
side: "after"
|
|
7830
|
+
});
|
|
7670
7831
|
}
|
|
7671
7832
|
}
|
|
7672
|
-
|
|
7673
|
-
|
|
7674
|
-
let I = u[0];
|
|
7675
|
-
for (let v = 1; v < u.length; v += 1) {
|
|
7676
|
-
const A = u[v];
|
|
7677
|
-
A.diff < I.diff && (I = A);
|
|
7678
|
-
}
|
|
7679
|
-
return {
|
|
7680
|
-
delta: I.delta,
|
|
7681
|
-
guide: I.guide
|
|
7682
|
-
};
|
|
7683
|
-
}, wn = ({
|
|
7833
|
+
return Fn({ options: u });
|
|
7834
|
+
}, In = ({
|
|
7684
7835
|
activeBounds: h,
|
|
7685
7836
|
candidates: t,
|
|
7686
7837
|
threshold: e,
|
|
7687
7838
|
spacingPatterns: n
|
|
7688
7839
|
}) => {
|
|
7689
|
-
const s =
|
|
7840
|
+
const s = ri({
|
|
7690
7841
|
activeBounds: h,
|
|
7691
7842
|
candidates: t,
|
|
7692
7843
|
threshold: e,
|
|
7693
7844
|
patterns: n.vertical
|
|
7694
|
-
}), i =
|
|
7845
|
+
}), i = ci({
|
|
7695
7846
|
activeBounds: h,
|
|
7696
7847
|
candidates: t,
|
|
7697
7848
|
threshold: e,
|
|
7698
7849
|
patterns: n.horizontal
|
|
7699
7850
|
}), o = [];
|
|
7700
|
-
|
|
7851
|
+
for (const a of s.guides)
|
|
7852
|
+
o.push(a);
|
|
7853
|
+
for (const a of i.guides)
|
|
7854
|
+
o.push(a);
|
|
7855
|
+
return {
|
|
7701
7856
|
deltaX: i.delta,
|
|
7702
7857
|
deltaY: s.delta,
|
|
7703
7858
|
guides: o
|
|
7704
7859
|
};
|
|
7705
|
-
},
|
|
7860
|
+
}, li = ({
|
|
7706
7861
|
context: h,
|
|
7707
7862
|
x: t,
|
|
7708
7863
|
y: e,
|
|
@@ -7712,7 +7867,7 @@ const xe = 5, Tn = "#3D8BF4", Ue = 1, lt = 1, Js = 0.01, At = ({
|
|
|
7712
7867
|
}) => {
|
|
7713
7868
|
const o = Math.min(i, n / 2, s / 2);
|
|
7714
7869
|
h.moveTo(t + o, e), h.lineTo(t + n - o, e), h.quadraticCurveTo(t + n, e, t + n, e + o), h.lineTo(t + n, e + s - o), h.quadraticCurveTo(t + n, e + s, t + n - o, e + s), h.lineTo(t + o, e + s), h.quadraticCurveTo(t, e + s, t, e + s - o), h.lineTo(t, e + o), h.quadraticCurveTo(t, e, t + o, e), h.closePath();
|
|
7715
|
-
},
|
|
7870
|
+
}, Ye = ({
|
|
7716
7871
|
context: h,
|
|
7717
7872
|
type: t,
|
|
7718
7873
|
axis: e,
|
|
@@ -7729,18 +7884,18 @@ const xe = 5, Tn = "#3D8BF4", Ue = 1, lt = 1, Js = 0.01, At = ({
|
|
|
7729
7884
|
offsetAlongAxis: f = 0,
|
|
7730
7885
|
offsetPerpendicular: p = 0
|
|
7731
7886
|
}) => {
|
|
7732
|
-
const m = o || 1, g = 12 / m, y = d / m, b = u / m, w = (n + s) / 2 + f,
|
|
7887
|
+
const m = o || 1, g = 12 / m, y = d / m, b = u / m, w = (n + s) / 2 + f, v = t === "vertical" ? e + p : w, C = t === "vertical" ? w : e + p;
|
|
7733
7888
|
h.save(), h.setLineDash([]), h.fillStyle = a, h.strokeStyle = a, h.lineWidth = l / m, h.font = `${g}px ${c}`, h.textAlign = "center", h.textBaseline = "middle";
|
|
7734
|
-
const
|
|
7735
|
-
h.beginPath(),
|
|
7889
|
+
const j = h.measureText(i).width + y * 2, S = g + y * 2, A = v - j / 2, M = C - S / 2;
|
|
7890
|
+
h.beginPath(), li({
|
|
7736
7891
|
context: h,
|
|
7737
7892
|
x: A,
|
|
7738
7893
|
y: M,
|
|
7739
|
-
width:
|
|
7740
|
-
height:
|
|
7894
|
+
width: j,
|
|
7895
|
+
height: S,
|
|
7741
7896
|
radius: b
|
|
7742
|
-
}), h.fill(), h.fillStyle = r, h.fillText(i,
|
|
7743
|
-
},
|
|
7897
|
+
}), h.fill(), h.fillStyle = r, h.fillText(i, v, C), h.restore();
|
|
7898
|
+
}, di = ({
|
|
7744
7899
|
context: h,
|
|
7745
7900
|
guide: t,
|
|
7746
7901
|
zoom: e
|
|
@@ -7753,10 +7908,10 @@ const xe = 5, Tn = "#3D8BF4", Ue = 1, lt = 1, Js = 0.01, At = ({
|
|
|
7753
7908
|
activeStart: a,
|
|
7754
7909
|
activeEnd: r,
|
|
7755
7910
|
distance: c
|
|
7756
|
-
} = t, l =
|
|
7911
|
+
} = t, l = Me({ distance: c }).toString();
|
|
7757
7912
|
h.beginPath(), n === "vertical" ? (h.moveTo(s, i), h.lineTo(s, o), h.moveTo(s, a), h.lineTo(s, r)) : (h.moveTo(i, s), h.lineTo(o, s), h.moveTo(a, s), h.lineTo(r, s)), h.stroke();
|
|
7758
|
-
const d =
|
|
7759
|
-
|
|
7913
|
+
const d = Dn;
|
|
7914
|
+
Ye({
|
|
7760
7915
|
context: h,
|
|
7761
7916
|
type: n,
|
|
7762
7917
|
axis: s,
|
|
@@ -7765,8 +7920,8 @@ const xe = 5, Tn = "#3D8BF4", Ue = 1, lt = 1, Js = 0.01, At = ({
|
|
|
7765
7920
|
text: l,
|
|
7766
7921
|
zoom: e,
|
|
7767
7922
|
color: d,
|
|
7768
|
-
lineWidth:
|
|
7769
|
-
}),
|
|
7923
|
+
lineWidth: We
|
|
7924
|
+
}), Ye({
|
|
7770
7925
|
context: h,
|
|
7771
7926
|
type: n,
|
|
7772
7927
|
axis: s,
|
|
@@ -7775,9 +7930,9 @@ const xe = 5, Tn = "#3D8BF4", Ue = 1, lt = 1, Js = 0.01, At = ({
|
|
|
7775
7930
|
text: l,
|
|
7776
7931
|
zoom: e,
|
|
7777
7932
|
color: d,
|
|
7778
|
-
lineWidth:
|
|
7933
|
+
lineWidth: We
|
|
7779
7934
|
});
|
|
7780
|
-
},
|
|
7935
|
+
}, Cn = ({
|
|
7781
7936
|
anchors: h,
|
|
7782
7937
|
bounds: t
|
|
7783
7938
|
}) => {
|
|
@@ -7790,7 +7945,7 @@ const xe = 5, Tn = "#3D8BF4", Ue = 1, lt = 1, Js = 0.01, At = ({
|
|
|
7790
7945
|
centerY: a
|
|
7791
7946
|
} = t;
|
|
7792
7947
|
h.vertical.push(e, s, n), h.horizontal.push(i, a, o);
|
|
7793
|
-
},
|
|
7948
|
+
}, On = ({
|
|
7794
7949
|
bounds: h,
|
|
7795
7950
|
type: t,
|
|
7796
7951
|
primaryStart: e,
|
|
@@ -7817,30 +7972,30 @@ const xe = 5, Tn = "#3D8BF4", Ue = 1, lt = 1, Js = 0.01, At = ({
|
|
|
7817
7972
|
});
|
|
7818
7973
|
}
|
|
7819
7974
|
return s;
|
|
7820
|
-
},
|
|
7975
|
+
}, hi = ({
|
|
7821
7976
|
bounds: h
|
|
7822
7977
|
}) => {
|
|
7823
|
-
const t =
|
|
7978
|
+
const t = On({
|
|
7824
7979
|
bounds: h,
|
|
7825
7980
|
type: "vertical",
|
|
7826
7981
|
primaryStart: "top",
|
|
7827
7982
|
primaryEnd: "bottom"
|
|
7828
|
-
}), e =
|
|
7983
|
+
}), e = On({
|
|
7829
7984
|
bounds: h,
|
|
7830
7985
|
type: "horizontal",
|
|
7831
7986
|
primaryStart: "left",
|
|
7832
7987
|
primaryEnd: "right"
|
|
7833
7988
|
});
|
|
7834
7989
|
return { vertical: t, horizontal: e };
|
|
7835
|
-
},
|
|
7990
|
+
}, ui = ["montage-area", "background", "interaction-blocker"], me = ({
|
|
7836
7991
|
activeObject: h
|
|
7837
7992
|
}) => {
|
|
7838
7993
|
const t = /* @__PURE__ */ new Set();
|
|
7839
7994
|
return h && (t.add(h), h instanceof q && h.getObjects().forEach((e) => t.add(e))), t;
|
|
7840
|
-
},
|
|
7995
|
+
}, ye = ({
|
|
7841
7996
|
object: h,
|
|
7842
7997
|
excluded: t,
|
|
7843
|
-
ignoredIds: e =
|
|
7998
|
+
ignoredIds: e = ui
|
|
7844
7999
|
}) => {
|
|
7845
8000
|
if (t.has(h)) return !0;
|
|
7846
8001
|
const { visible: n = !0 } = h;
|
|
@@ -7911,37 +8066,37 @@ class X {
|
|
|
7911
8066
|
this._clearGuides();
|
|
7912
8067
|
return;
|
|
7913
8068
|
}
|
|
7914
|
-
const { canvas: o } = this, a = o.getZoom() || 1, r =
|
|
8069
|
+
const { canvas: o } = this, a = o.getZoom() || 1, r = Le / a, c = jn({
|
|
7915
8070
|
activeBounds: i,
|
|
7916
8071
|
threshold: r,
|
|
7917
8072
|
anchors: this.anchors
|
|
7918
8073
|
}), { deltaX: l, deltaY: d } = c;
|
|
7919
8074
|
if (l !== 0 || d !== 0) {
|
|
7920
|
-
const { left:
|
|
8075
|
+
const { left: v = 0, top: C = 0 } = e;
|
|
7921
8076
|
e.set({
|
|
7922
|
-
left:
|
|
7923
|
-
top:
|
|
8077
|
+
left: v + l,
|
|
8078
|
+
top: C + d
|
|
7924
8079
|
}), e.setCoords(), i = (y = gt({ object: e })) != null ? y : i;
|
|
7925
8080
|
}
|
|
7926
|
-
const u = this.cachedTargetBounds.length ? this.cachedTargetBounds : this._collectTargets({ activeObject: e }).map((
|
|
8081
|
+
const u = this.cachedTargetBounds.length ? this.cachedTargetBounds : this._collectTargets({ activeObject: e }).map((v) => gt({ object: v })).filter((v) => !!v), f = In({
|
|
7927
8082
|
activeBounds: i,
|
|
7928
8083
|
candidates: u,
|
|
7929
8084
|
threshold: r,
|
|
7930
8085
|
spacingPatterns: this.spacingPatterns
|
|
7931
8086
|
});
|
|
7932
8087
|
if (f.deltaX !== 0 || f.deltaY !== 0) {
|
|
7933
|
-
const { left:
|
|
8088
|
+
const { left: v = 0, top: C = 0 } = e;
|
|
7934
8089
|
e.set({
|
|
7935
|
-
left:
|
|
7936
|
-
top:
|
|
8090
|
+
left: v + f.deltaX,
|
|
8091
|
+
top: C + f.deltaY
|
|
7937
8092
|
}), e.setCoords(), i = (b = gt({ object: e })) != null ? b : i;
|
|
7938
8093
|
}
|
|
7939
8094
|
X._applyMovementStep({ target: e });
|
|
7940
|
-
const p = (w = gt({ object: e })) != null ? w : i, m =
|
|
8095
|
+
const p = (w = gt({ object: e })) != null ? w : i, m = jn({
|
|
7941
8096
|
activeBounds: p,
|
|
7942
8097
|
threshold: r,
|
|
7943
8098
|
anchors: this.anchors
|
|
7944
|
-
}), g =
|
|
8099
|
+
}), g = In({
|
|
7945
8100
|
activeBounds: p,
|
|
7946
8101
|
candidates: u,
|
|
7947
8102
|
threshold: r,
|
|
@@ -7985,110 +8140,110 @@ class X {
|
|
|
7985
8140
|
this._clearGuides();
|
|
7986
8141
|
return;
|
|
7987
8142
|
}
|
|
7988
|
-
const { canvas: f } = this, p = f.getZoom() || 1, m =
|
|
8143
|
+
const { canvas: f } = this, p = f.getZoom() || 1, m = Le / p, {
|
|
7989
8144
|
originX: g,
|
|
7990
8145
|
originY: y
|
|
7991
8146
|
} = s, {
|
|
7992
8147
|
originX: b = "left",
|
|
7993
8148
|
originY: w = "top",
|
|
7994
|
-
scaleX:
|
|
7995
|
-
scaleY:
|
|
7996
|
-
} = e,
|
|
8149
|
+
scaleX: v = 1,
|
|
8150
|
+
scaleY: C = 1
|
|
8151
|
+
} = e, O = g != null ? g : b, j = y != null ? y : w, S = X._collectVerticalSnapCandidates({
|
|
7997
8152
|
bounds: u,
|
|
7998
|
-
originX:
|
|
8153
|
+
originX: O,
|
|
7999
8154
|
shouldSnapX: o
|
|
8000
8155
|
}), A = X._collectHorizontalSnapCandidates({
|
|
8001
8156
|
bounds: u,
|
|
8002
|
-
originY:
|
|
8157
|
+
originY: j,
|
|
8003
8158
|
shouldSnapY: a
|
|
8004
8159
|
}), M = X._findAxisSnapCandidate({
|
|
8005
8160
|
anchors: l,
|
|
8006
|
-
candidates:
|
|
8161
|
+
candidates: S,
|
|
8007
8162
|
threshold: m
|
|
8008
|
-
}),
|
|
8163
|
+
}), E = X._findAxisSnapCandidate({
|
|
8009
8164
|
anchors: d,
|
|
8010
8165
|
candidates: A,
|
|
8011
8166
|
threshold: m
|
|
8012
|
-
}), { guidePosition:
|
|
8013
|
-
if (!
|
|
8167
|
+
}), { guidePosition: I } = M, { guidePosition: z } = E, F = I !== null, U = z !== null;
|
|
8168
|
+
if (!F && !U) {
|
|
8014
8169
|
this._clearGuides();
|
|
8015
8170
|
return;
|
|
8016
8171
|
}
|
|
8017
|
-
const
|
|
8018
|
-
let
|
|
8172
|
+
const D = [];
|
|
8173
|
+
let B = null, N = null;
|
|
8019
8174
|
if (r) {
|
|
8020
|
-
const
|
|
8175
|
+
const k = X._resolveUniformScale({
|
|
8021
8176
|
bounds: u,
|
|
8022
|
-
originX:
|
|
8023
|
-
originY:
|
|
8177
|
+
originX: O,
|
|
8178
|
+
originY: j,
|
|
8024
8179
|
verticalSnap: M,
|
|
8025
|
-
horizontalSnap:
|
|
8180
|
+
horizontalSnap: E
|
|
8026
8181
|
});
|
|
8027
|
-
if (
|
|
8028
|
-
const { scaleFactor: T, guide:
|
|
8029
|
-
|
|
8182
|
+
if (k) {
|
|
8183
|
+
const { scaleFactor: T, guide: _ } = k;
|
|
8184
|
+
B = v * T, N = C * T, D.push(_);
|
|
8030
8185
|
}
|
|
8031
8186
|
}
|
|
8032
8187
|
if (!r) {
|
|
8033
|
-
const { angle:
|
|
8034
|
-
if (
|
|
8188
|
+
const { angle: k = 0 } = e, { width: T, height: _ } = X._resolveBaseDimensions({ target: e }), x = Math.abs(v) || 1, L = Math.abs(C) || 1;
|
|
8189
|
+
if (F) {
|
|
8035
8190
|
const V = X._resolveDesiredWidth({
|
|
8036
8191
|
bounds: u,
|
|
8037
|
-
originX:
|
|
8192
|
+
originX: O,
|
|
8038
8193
|
snap: M
|
|
8039
8194
|
});
|
|
8040
8195
|
if (V !== null) {
|
|
8041
8196
|
const W = X._resolveScaleForWidth({
|
|
8042
8197
|
desiredWidth: V,
|
|
8043
8198
|
baseWidth: T,
|
|
8044
|
-
baseHeight:
|
|
8045
|
-
scaleY:
|
|
8046
|
-
angle:
|
|
8199
|
+
baseHeight: _,
|
|
8200
|
+
scaleY: L,
|
|
8201
|
+
angle: k
|
|
8047
8202
|
});
|
|
8048
8203
|
if (W !== null) {
|
|
8049
|
-
const J =
|
|
8050
|
-
|
|
8204
|
+
const J = v < 0 ? -1 : 1;
|
|
8205
|
+
B = W * J, I !== null && D.push({
|
|
8051
8206
|
type: "vertical",
|
|
8052
|
-
position:
|
|
8207
|
+
position: I
|
|
8053
8208
|
});
|
|
8054
8209
|
}
|
|
8055
8210
|
}
|
|
8056
8211
|
}
|
|
8057
|
-
if (
|
|
8212
|
+
if (U) {
|
|
8058
8213
|
const V = X._resolveDesiredHeight({
|
|
8059
8214
|
bounds: u,
|
|
8060
|
-
originY:
|
|
8061
|
-
snap:
|
|
8215
|
+
originY: j,
|
|
8216
|
+
snap: E
|
|
8062
8217
|
});
|
|
8063
8218
|
if (V !== null) {
|
|
8064
8219
|
const W = X._resolveScaleForHeight({
|
|
8065
8220
|
desiredHeight: V,
|
|
8066
8221
|
baseWidth: T,
|
|
8067
|
-
baseHeight:
|
|
8068
|
-
scaleX:
|
|
8069
|
-
angle:
|
|
8222
|
+
baseHeight: _,
|
|
8223
|
+
scaleX: x,
|
|
8224
|
+
angle: k
|
|
8070
8225
|
});
|
|
8071
8226
|
if (W !== null) {
|
|
8072
|
-
const J =
|
|
8073
|
-
|
|
8227
|
+
const J = C < 0 ? -1 : 1;
|
|
8228
|
+
N = W * J, z !== null && D.push({
|
|
8074
8229
|
type: "horizontal",
|
|
8075
|
-
position:
|
|
8230
|
+
position: z
|
|
8076
8231
|
});
|
|
8077
8232
|
}
|
|
8078
8233
|
}
|
|
8079
8234
|
}
|
|
8080
8235
|
}
|
|
8081
|
-
const R =
|
|
8082
|
-
if (!R && !
|
|
8236
|
+
const R = B !== null || N !== null;
|
|
8237
|
+
if (!R && !D.length) {
|
|
8083
8238
|
this._clearGuides();
|
|
8084
8239
|
return;
|
|
8085
8240
|
}
|
|
8086
8241
|
if (R) {
|
|
8087
|
-
const
|
|
8088
|
-
|
|
8242
|
+
const k = e.getRelativeCenterPoint(), T = e.translateToOriginPoint(k, O, j), _ = {};
|
|
8243
|
+
B !== null && (_.scaleX = B, s.scaleX = B), N !== null && (_.scaleY = N, s.scaleY = N), Object.keys(_).length && (e.set(_), e.setPositionByOrigin(T, O, j), e.setCoords());
|
|
8089
8244
|
}
|
|
8090
8245
|
X._applyScalingStep({ target: e, transform: s }), X._applyMovementStep({ target: e }), this._applyGuides({
|
|
8091
|
-
guides:
|
|
8246
|
+
guides: D,
|
|
8092
8247
|
spacingGuides: []
|
|
8093
8248
|
});
|
|
8094
8249
|
}
|
|
@@ -8124,49 +8279,49 @@ class X {
|
|
|
8124
8279
|
this._clearGuides();
|
|
8125
8280
|
return;
|
|
8126
8281
|
}
|
|
8127
|
-
const { canvas: d } = this, u = d.getZoom() || 1, f =
|
|
8282
|
+
const { canvas: d } = this, u = d.getZoom() || 1, f = Le / u, { originX: p, originY: m } = e, {
|
|
8128
8283
|
originX: g = "left",
|
|
8129
8284
|
originY: y = "top"
|
|
8130
|
-
} = t, b = p != null ? p : g, w = m != null ? m : y,
|
|
8285
|
+
} = t, b = p != null ? p : g, w = m != null ? m : y, v = X._collectVerticalSnapCandidates({
|
|
8131
8286
|
bounds: l,
|
|
8132
8287
|
originX: b,
|
|
8133
8288
|
shouldSnapX: !0
|
|
8134
|
-
}),
|
|
8289
|
+
}), C = X._findAxisSnapCandidate({
|
|
8135
8290
|
anchors: r,
|
|
8136
|
-
candidates:
|
|
8291
|
+
candidates: v,
|
|
8137
8292
|
threshold: f
|
|
8138
|
-
}), { guidePosition:
|
|
8139
|
-
if (
|
|
8293
|
+
}), { guidePosition: O } = C;
|
|
8294
|
+
if (O === null) {
|
|
8140
8295
|
this._clearGuides();
|
|
8141
8296
|
return;
|
|
8142
8297
|
}
|
|
8143
|
-
const
|
|
8298
|
+
const j = X._resolveDesiredWidth({
|
|
8144
8299
|
bounds: l,
|
|
8145
8300
|
originX: b,
|
|
8146
|
-
snap:
|
|
8301
|
+
snap: C
|
|
8147
8302
|
});
|
|
8148
|
-
if (
|
|
8303
|
+
if (j === null) {
|
|
8149
8304
|
this._clearGuides();
|
|
8150
8305
|
return;
|
|
8151
8306
|
}
|
|
8152
|
-
const
|
|
8307
|
+
const S = X._resolveTextWidthForBounds({
|
|
8153
8308
|
target: t,
|
|
8154
|
-
boundsWidth:
|
|
8309
|
+
boundsWidth: j
|
|
8155
8310
|
});
|
|
8156
|
-
if (
|
|
8311
|
+
if (S === null) {
|
|
8157
8312
|
this._clearGuides();
|
|
8158
8313
|
return;
|
|
8159
8314
|
}
|
|
8160
8315
|
const { width: A = 0 } = t;
|
|
8161
|
-
if (
|
|
8162
|
-
const M = t.getRelativeCenterPoint(),
|
|
8163
|
-
t.set({ width:
|
|
8316
|
+
if (S !== A) {
|
|
8317
|
+
const M = t.getRelativeCenterPoint(), E = t.translateToOriginPoint(M, b, w);
|
|
8318
|
+
t.set({ width: S }), t.setPositionByOrigin(E, b, w), t.setCoords();
|
|
8164
8319
|
}
|
|
8165
8320
|
this._applyGuides({
|
|
8166
8321
|
guides: [
|
|
8167
8322
|
{
|
|
8168
8323
|
type: "vertical",
|
|
8169
|
-
position:
|
|
8324
|
+
position: O
|
|
8170
8325
|
}
|
|
8171
8326
|
],
|
|
8172
8327
|
spacingGuides: []
|
|
@@ -8193,11 +8348,11 @@ class X {
|
|
|
8193
8348
|
const { canvas: t, guideBounds: e } = this, n = t.getSelectionContext();
|
|
8194
8349
|
if (!n) return;
|
|
8195
8350
|
const s = e != null ? e : this._calculateViewportBounds(), { left: i, right: o, top: a, bottom: r } = s, { viewportTransform: c } = t, l = t.getZoom() || 1;
|
|
8196
|
-
n.save(), Array.isArray(c) && n.transform(...c), n.lineWidth =
|
|
8351
|
+
n.save(), Array.isArray(c) && n.transform(...c), n.lineWidth = We / l, n.strokeStyle = Dn, n.setLineDash([4, 4]);
|
|
8197
8352
|
for (const d of this.activeGuides)
|
|
8198
8353
|
n.beginPath(), d.type === "vertical" ? (n.moveTo(d.position, a), n.lineTo(d.position, r)) : (n.moveTo(i, d.position), n.lineTo(o, d.position)), n.stroke();
|
|
8199
8354
|
for (const d of this.activeSpacingGuides)
|
|
8200
|
-
|
|
8355
|
+
di({
|
|
8201
8356
|
context: n,
|
|
8202
8357
|
guide: d,
|
|
8203
8358
|
zoom: l
|
|
@@ -8344,8 +8499,8 @@ class X {
|
|
|
8344
8499
|
snap: s
|
|
8345
8500
|
});
|
|
8346
8501
|
if (w !== null) {
|
|
8347
|
-
const
|
|
8348
|
-
Number.isFinite(
|
|
8502
|
+
const v = w / l;
|
|
8503
|
+
Number.isFinite(v) && v > 0 && (g = v);
|
|
8349
8504
|
}
|
|
8350
8505
|
}
|
|
8351
8506
|
if (p !== null && d > 0) {
|
|
@@ -8355,14 +8510,14 @@ class X {
|
|
|
8355
8510
|
snap: i
|
|
8356
8511
|
});
|
|
8357
8512
|
if (w !== null) {
|
|
8358
|
-
const
|
|
8359
|
-
Number.isFinite(
|
|
8513
|
+
const v = w / d;
|
|
8514
|
+
Number.isFinite(v) && v > 0 && (y = v);
|
|
8360
8515
|
}
|
|
8361
8516
|
}
|
|
8362
8517
|
let b = null;
|
|
8363
8518
|
if (g !== null && y === null && (b = "x"), y !== null && g === null && (b = "y"), g !== null && y !== null) {
|
|
8364
|
-
const w = Math.abs(f),
|
|
8365
|
-
w <=
|
|
8519
|
+
const w = Math.abs(f), v = Math.abs(m);
|
|
8520
|
+
w <= v && (b = "x"), w > v && (b = "y");
|
|
8366
8521
|
}
|
|
8367
8522
|
return b === "x" && g !== null && u !== null ? {
|
|
8368
8523
|
scaleFactor: g,
|
|
@@ -8508,9 +8663,9 @@ class X {
|
|
|
8508
8663
|
* Округляет scale до шага SCALE_SNAP_STEP, не допуская нулевого масштаба.
|
|
8509
8664
|
*/
|
|
8510
8665
|
static _snapScaleToStep({ value: t }) {
|
|
8511
|
-
const e = Math.abs(
|
|
8666
|
+
const e = Math.abs(si);
|
|
8512
8667
|
if (e === 0) return t;
|
|
8513
|
-
const n = X._resolveStepPrecision({ step: e }), s =
|
|
8668
|
+
const n = X._resolveStepPrecision({ step: e }), s = Oe(10, n), i = Math.round(e * s);
|
|
8514
8669
|
if (i <= 0) return t;
|
|
8515
8670
|
const o = Math.round(t * s), r = Math.round(o / i) * i / s, c = Number(r.toFixed(n));
|
|
8516
8671
|
return c !== 0 ? c : t === 0 || t > 0 ? e : -e;
|
|
@@ -8529,11 +8684,11 @@ class X {
|
|
|
8529
8684
|
const e = this._collectTargets({ activeObject: t }), n = { vertical: [], horizontal: [] }, s = [];
|
|
8530
8685
|
for (const a of e) {
|
|
8531
8686
|
const r = gt({ object: a });
|
|
8532
|
-
r && (
|
|
8687
|
+
r && (Cn({ anchors: n, bounds: r }), s.push(r));
|
|
8533
8688
|
}
|
|
8534
8689
|
const { montageArea: i } = this.editor, o = gt({ object: i });
|
|
8535
8690
|
if (o) {
|
|
8536
|
-
|
|
8691
|
+
Cn({ anchors: n, bounds: o });
|
|
8537
8692
|
const { left: a, right: r, top: c, bottom: l } = o;
|
|
8538
8693
|
this.guideBounds = {
|
|
8539
8694
|
left: a,
|
|
@@ -8543,15 +8698,15 @@ class X {
|
|
|
8543
8698
|
};
|
|
8544
8699
|
} else
|
|
8545
8700
|
this.guideBounds = this._calculateViewportBounds();
|
|
8546
|
-
this.anchors = n, this.spacingPatterns =
|
|
8701
|
+
this.anchors = n, this.spacingPatterns = hi({ bounds: s }), this.cachedTargetBounds = s;
|
|
8547
8702
|
}
|
|
8548
8703
|
/**
|
|
8549
8704
|
* Собирает объекты, подходящие для прилипания, исключая активный объект и запрещённые id.
|
|
8550
8705
|
*/
|
|
8551
8706
|
_collectTargets({ activeObject: t }) {
|
|
8552
|
-
const e =
|
|
8707
|
+
const e = me({ activeObject: t }), n = [];
|
|
8553
8708
|
return this.canvas.forEachObject((s) => {
|
|
8554
|
-
|
|
8709
|
+
ye({ object: s, excluded: e }) || n.push(s);
|
|
8555
8710
|
}), n;
|
|
8556
8711
|
}
|
|
8557
8712
|
/**
|
|
@@ -8574,8 +8729,8 @@ class X {
|
|
|
8574
8729
|
};
|
|
8575
8730
|
}
|
|
8576
8731
|
}
|
|
8577
|
-
const
|
|
8578
|
-
class
|
|
8732
|
+
const En = "#3D8BF4", Tn = 1;
|
|
8733
|
+
class Ct {
|
|
8579
8734
|
/**
|
|
8580
8735
|
* Создаёт менеджер измерений и инициализирует события.
|
|
8581
8736
|
*/
|
|
@@ -8685,7 +8840,7 @@ class Et {
|
|
|
8685
8840
|
this._clearGuides();
|
|
8686
8841
|
return;
|
|
8687
8842
|
}
|
|
8688
|
-
const o =
|
|
8843
|
+
const o = Ct._resolveTarget({
|
|
8689
8844
|
event: t,
|
|
8690
8845
|
activeObject: s
|
|
8691
8846
|
}), { montageArea: a } = n, r = o != null ? o : a, c = r === a, l = gt({ object: r });
|
|
@@ -8697,7 +8852,7 @@ class Et {
|
|
|
8697
8852
|
this._clearGuides();
|
|
8698
8853
|
return;
|
|
8699
8854
|
}
|
|
8700
|
-
const u =
|
|
8855
|
+
const u = Ct._buildGuides({
|
|
8701
8856
|
activeBounds: i,
|
|
8702
8857
|
targetBounds: l,
|
|
8703
8858
|
targetIsMontageArea: c
|
|
@@ -8767,7 +8922,7 @@ class Et {
|
|
|
8767
8922
|
currentGap: r,
|
|
8768
8923
|
oppositeGaps: [c, l]
|
|
8769
8924
|
});
|
|
8770
|
-
return d === null ? t : yt(
|
|
8925
|
+
return d === null ? t : yt(P({}, t), {
|
|
8771
8926
|
distance: d
|
|
8772
8927
|
});
|
|
8773
8928
|
}
|
|
@@ -8800,7 +8955,7 @@ class Et {
|
|
|
8800
8955
|
currentGap: r,
|
|
8801
8956
|
oppositeGaps: [c, l]
|
|
8802
8957
|
});
|
|
8803
|
-
return d === null ? t : yt(
|
|
8958
|
+
return d === null ? t : yt(P({}, t), {
|
|
8804
8959
|
distance: d
|
|
8805
8960
|
});
|
|
8806
8961
|
}
|
|
@@ -8811,16 +8966,19 @@ class Et {
|
|
|
8811
8966
|
currentGap: t,
|
|
8812
8967
|
oppositeGaps: e
|
|
8813
8968
|
}) {
|
|
8814
|
-
|
|
8815
|
-
|
|
8816
|
-
|
|
8817
|
-
|
|
8818
|
-
|
|
8819
|
-
|
|
8820
|
-
|
|
8821
|
-
|
|
8969
|
+
let n = null, s = Number.POSITIVE_INFINITY;
|
|
8970
|
+
for (const i of e) {
|
|
8971
|
+
if (i === null) continue;
|
|
8972
|
+
const {
|
|
8973
|
+
displayDistanceDiff: o,
|
|
8974
|
+
commonDisplayDistance: a
|
|
8975
|
+
} = Je({
|
|
8976
|
+
firstDistance: t,
|
|
8977
|
+
secondDistance: i
|
|
8978
|
+
});
|
|
8979
|
+
o > qe || o >= s || (s = o, n = a);
|
|
8822
8980
|
}
|
|
8823
|
-
return
|
|
8981
|
+
return n;
|
|
8824
8982
|
}
|
|
8825
8983
|
/**
|
|
8826
8984
|
* Находит ближайший горизонтальный зазор с противоположной стороны активного объекта.
|
|
@@ -8832,12 +8990,12 @@ class Et {
|
|
|
8832
8990
|
searchRightSide: s
|
|
8833
8991
|
}) {
|
|
8834
8992
|
var r, c, l, d, u, f, p, m;
|
|
8835
|
-
const { montageArea: i } = this.editor, o =
|
|
8993
|
+
const { montageArea: i } = this.editor, o = me({ activeObject: t });
|
|
8836
8994
|
let a = Number.POSITIVE_INFINITY;
|
|
8837
8995
|
for (const g of this.canvas.getObjects()) {
|
|
8838
|
-
if (g === t || g === e || g === i ||
|
|
8996
|
+
if (g === t || g === e || g === i || ye({ object: g, excluded: o })) continue;
|
|
8839
8997
|
const y = gt({ object: g });
|
|
8840
|
-
if (!y || !
|
|
8998
|
+
if (!y || !Ct._hasVerticalOverlap({ a: n, b: y })) continue;
|
|
8841
8999
|
let b = -1;
|
|
8842
9000
|
s && ((r = y.left) != null ? r : 0) >= ((c = n.right) != null ? c : 0) && (b = ((l = y.left) != null ? l : 0) - ((d = n.right) != null ? d : 0)), !s && ((u = y.right) != null ? u : 0) <= ((f = n.left) != null ? f : 0) && (b = ((p = n.left) != null ? p : 0) - ((m = y.right) != null ? m : 0)), b > 0 && b < a && (a = b);
|
|
8843
9001
|
}
|
|
@@ -8853,12 +9011,12 @@ class Et {
|
|
|
8853
9011
|
searchBottomSide: s
|
|
8854
9012
|
}) {
|
|
8855
9013
|
var r, c, l, d, u, f, p, m;
|
|
8856
|
-
const { montageArea: i } = this.editor, o =
|
|
9014
|
+
const { montageArea: i } = this.editor, o = me({ activeObject: t });
|
|
8857
9015
|
let a = Number.POSITIVE_INFINITY;
|
|
8858
9016
|
for (const g of this.canvas.getObjects()) {
|
|
8859
|
-
if (g === t || g === e || g === i ||
|
|
9017
|
+
if (g === t || g === e || g === i || ye({ object: g, excluded: o })) continue;
|
|
8860
9018
|
const y = gt({ object: g });
|
|
8861
|
-
if (!y || !
|
|
9019
|
+
if (!y || !Ct._hasHorizontalOverlap({ a: n, b: y })) continue;
|
|
8862
9020
|
let b = -1;
|
|
8863
9021
|
s && ((r = y.top) != null ? r : 0) >= ((c = n.bottom) != null ? c : 0) && (b = ((l = y.top) != null ? l : 0) - ((d = n.bottom) != null ? d : 0)), !s && ((u = y.bottom) != null ? u : 0) <= ((f = n.top) != null ? f : 0) && (b = ((p = n.top) != null ? p : 0) - ((m = y.bottom) != null ? m : 0)), b > 0 && b < a && (a = b);
|
|
8864
9022
|
}
|
|
@@ -8873,7 +9031,7 @@ class Et {
|
|
|
8873
9031
|
}) {
|
|
8874
9032
|
var i, o, a, r;
|
|
8875
9033
|
const n = Math.max((i = t.top) != null ? i : 0, (o = e.top) != null ? o : 0);
|
|
8876
|
-
return Math.min((a = t.bottom) != null ? a : 0, (r = e.bottom) != null ? r : 0)
|
|
9034
|
+
return Math.min((a = t.bottom) != null ? a : 0, (r = e.bottom) != null ? r : 0) > n;
|
|
8877
9035
|
}
|
|
8878
9036
|
/**
|
|
8879
9037
|
* Проверяет пересечение по оси X.
|
|
@@ -8884,7 +9042,7 @@ class Et {
|
|
|
8884
9042
|
}) {
|
|
8885
9043
|
var i, o, a, r;
|
|
8886
9044
|
const n = Math.max((i = t.left) != null ? i : 0, (o = e.left) != null ? o : 0);
|
|
8887
|
-
return Math.min((a = t.right) != null ? a : 0, (r = e.right) != null ? r : 0)
|
|
9045
|
+
return Math.min((a = t.right) != null ? a : 0, (r = e.right) != null ? r : 0) > n;
|
|
8888
9046
|
}
|
|
8889
9047
|
/**
|
|
8890
9048
|
* Возвращает объект под курсором, подходящий для измерения.
|
|
@@ -8893,8 +9051,8 @@ class Et {
|
|
|
8893
9051
|
event: t,
|
|
8894
9052
|
activeObject: e
|
|
8895
9053
|
}) {
|
|
8896
|
-
const { target: n } = t, s =
|
|
8897
|
-
return n && !
|
|
9054
|
+
const { target: n } = t, s = me({ activeObject: e });
|
|
9055
|
+
return n && !ye({ object: n, excluded: s }) ? n : null;
|
|
8898
9056
|
}
|
|
8899
9057
|
/**
|
|
8900
9058
|
* Собирает вертикальные и горизонтальные направляющие расстояний.
|
|
@@ -8904,11 +9062,11 @@ class Et {
|
|
|
8904
9062
|
targetBounds: e,
|
|
8905
9063
|
targetIsMontageArea: n
|
|
8906
9064
|
}) {
|
|
8907
|
-
const s =
|
|
9065
|
+
const s = Ct._buildHorizontalGuides({
|
|
8908
9066
|
activeBounds: t,
|
|
8909
9067
|
targetBounds: e,
|
|
8910
9068
|
targetIsMontageArea: n
|
|
8911
|
-
}), i =
|
|
9069
|
+
}), i = Ct._buildVerticalGuides({
|
|
8912
9070
|
activeBounds: t,
|
|
8913
9071
|
targetBounds: e,
|
|
8914
9072
|
targetIsMontageArea: n
|
|
@@ -8938,40 +9096,40 @@ class Et {
|
|
|
8938
9096
|
} = e, m = Math.max(a, u), g = Math.min(r, f), b = g >= m ? (m + g) / 2 : (c + p) / 2;
|
|
8939
9097
|
if (l >= o) {
|
|
8940
9098
|
if (n) return s;
|
|
8941
|
-
const
|
|
8942
|
-
return
|
|
9099
|
+
const E = l - o;
|
|
9100
|
+
return E > 0 && s.push({
|
|
8943
9101
|
type: "horizontal",
|
|
8944
9102
|
axis: b,
|
|
8945
9103
|
start: o,
|
|
8946
9104
|
end: l,
|
|
8947
|
-
distance:
|
|
9105
|
+
distance: E
|
|
8948
9106
|
}), s;
|
|
8949
9107
|
}
|
|
8950
9108
|
if (d <= i) {
|
|
8951
9109
|
if (n) return s;
|
|
8952
|
-
const
|
|
8953
|
-
return
|
|
9110
|
+
const E = i - d;
|
|
9111
|
+
return E > 0 && s.push({
|
|
8954
9112
|
type: "horizontal",
|
|
8955
9113
|
axis: b,
|
|
8956
9114
|
start: d,
|
|
8957
9115
|
end: i,
|
|
8958
|
-
distance:
|
|
9116
|
+
distance: E
|
|
8959
9117
|
}), s;
|
|
8960
9118
|
}
|
|
8961
9119
|
if (!n) return s;
|
|
8962
|
-
const w = i < l,
|
|
8963
|
-
|
|
9120
|
+
const w = i < l, v = o > d, C = Math.min(i, l), O = Math.max(i, l), j = O - C;
|
|
9121
|
+
j > 0 && !w && s.push({
|
|
8964
9122
|
type: "horizontal",
|
|
8965
9123
|
axis: b,
|
|
8966
|
-
start:
|
|
8967
|
-
end:
|
|
8968
|
-
distance:
|
|
9124
|
+
start: C,
|
|
9125
|
+
end: O,
|
|
9126
|
+
distance: j
|
|
8969
9127
|
});
|
|
8970
|
-
const
|
|
8971
|
-
return M > 0 && !
|
|
9128
|
+
const S = Math.min(o, d), A = Math.max(o, d), M = A - S;
|
|
9129
|
+
return M > 0 && !v && s.push({
|
|
8972
9130
|
type: "horizontal",
|
|
8973
9131
|
axis: b,
|
|
8974
|
-
start:
|
|
9132
|
+
start: S,
|
|
8975
9133
|
end: A,
|
|
8976
9134
|
distance: M
|
|
8977
9135
|
}), s;
|
|
@@ -8999,40 +9157,40 @@ class Et {
|
|
|
8999
9157
|
} = e, m = Math.max(a, u), g = Math.min(r, f), b = g >= m ? (m + g) / 2 : (c + p) / 2;
|
|
9000
9158
|
if (l >= o) {
|
|
9001
9159
|
if (n) return s;
|
|
9002
|
-
const
|
|
9003
|
-
return
|
|
9160
|
+
const E = l - o;
|
|
9161
|
+
return E > 0 && s.push({
|
|
9004
9162
|
type: "vertical",
|
|
9005
9163
|
axis: b,
|
|
9006
9164
|
start: o,
|
|
9007
9165
|
end: l,
|
|
9008
|
-
distance:
|
|
9166
|
+
distance: E
|
|
9009
9167
|
}), s;
|
|
9010
9168
|
}
|
|
9011
9169
|
if (d <= i) {
|
|
9012
9170
|
if (n) return s;
|
|
9013
|
-
const
|
|
9014
|
-
return
|
|
9171
|
+
const E = i - d;
|
|
9172
|
+
return E > 0 && s.push({
|
|
9015
9173
|
type: "vertical",
|
|
9016
9174
|
axis: b,
|
|
9017
9175
|
start: d,
|
|
9018
9176
|
end: i,
|
|
9019
|
-
distance:
|
|
9177
|
+
distance: E
|
|
9020
9178
|
}), s;
|
|
9021
9179
|
}
|
|
9022
9180
|
if (!n) return s;
|
|
9023
|
-
const w = i < l,
|
|
9024
|
-
|
|
9181
|
+
const w = i < l, v = o > d, C = Math.min(i, l), O = Math.max(i, l), j = O - C;
|
|
9182
|
+
j > 0 && !w && s.push({
|
|
9025
9183
|
type: "vertical",
|
|
9026
9184
|
axis: b,
|
|
9027
|
-
start:
|
|
9028
|
-
end:
|
|
9029
|
-
distance:
|
|
9185
|
+
start: C,
|
|
9186
|
+
end: O,
|
|
9187
|
+
distance: j
|
|
9030
9188
|
});
|
|
9031
|
-
const
|
|
9032
|
-
return M > 0 && !
|
|
9189
|
+
const S = Math.min(o, d), A = Math.max(o, d), M = A - S;
|
|
9190
|
+
return M > 0 && !v && s.push({
|
|
9033
9191
|
type: "vertical",
|
|
9034
9192
|
axis: b,
|
|
9035
|
-
start:
|
|
9193
|
+
start: S,
|
|
9036
9194
|
end: A,
|
|
9037
9195
|
distance: M
|
|
9038
9196
|
}), s;
|
|
@@ -9062,19 +9220,19 @@ class Et {
|
|
|
9062
9220
|
const { canvas: t } = this, e = t.getSelectionContext();
|
|
9063
9221
|
if (!e) return;
|
|
9064
9222
|
const { viewportTransform: n } = t, s = t.getZoom() || 1, i = this.activeGuides.some((c) => c.type === "vertical"), o = this.activeGuides.some((c) => c.type === "horizontal"), a = i && o && !this.isTargetMontageArea, r = a ? 12 / s : 0;
|
|
9065
|
-
e.save(), Array.isArray(n) && e.transform(...n), e.lineWidth =
|
|
9223
|
+
e.save(), Array.isArray(n) && e.transform(...n), e.lineWidth = Tn / s, e.strokeStyle = En, e.setLineDash([]);
|
|
9066
9224
|
for (const c of this.activeGuides) {
|
|
9067
9225
|
const { type: l, axis: d, start: u, end: f, distance: p } = c, m = Math.abs(f - u), g = u <= f ? -1 : 1, y = a ? g * (m / 2 + r) : 0, b = 0;
|
|
9068
|
-
e.beginPath(), l === "vertical" ? (e.moveTo(d, u), e.lineTo(d, f)) : (e.moveTo(u, d), e.lineTo(f, d)), e.stroke(),
|
|
9226
|
+
e.beginPath(), l === "vertical" ? (e.moveTo(d, u), e.lineTo(d, f)) : (e.moveTo(u, d), e.lineTo(f, d)), e.stroke(), Ye({
|
|
9069
9227
|
context: e,
|
|
9070
9228
|
type: l,
|
|
9071
9229
|
axis: d,
|
|
9072
9230
|
start: u,
|
|
9073
9231
|
end: f,
|
|
9074
|
-
text:
|
|
9232
|
+
text: Me({ distance: p }).toString(),
|
|
9075
9233
|
zoom: s,
|
|
9076
|
-
color:
|
|
9077
|
-
lineWidth:
|
|
9234
|
+
color: En,
|
|
9235
|
+
lineWidth: Tn,
|
|
9078
9236
|
offsetAlongAxis: y,
|
|
9079
9237
|
offsetPerpendicular: b
|
|
9080
9238
|
});
|
|
@@ -9100,7 +9258,7 @@ class Et {
|
|
|
9100
9258
|
(e = t == null ? void 0 : t.showAfterTemporary) == null || e.call(t), this.isToolbarHidden = !1;
|
|
9101
9259
|
}
|
|
9102
9260
|
}
|
|
9103
|
-
class
|
|
9261
|
+
class $e {
|
|
9104
9262
|
/**
|
|
9105
9263
|
* Конструктор класса ImageEditor.
|
|
9106
9264
|
* @param canvasId - идентификатор канваса, в котором будет создан редактор
|
|
@@ -9130,7 +9288,7 @@ class Ke {
|
|
|
9130
9288
|
showRotationAngle: l,
|
|
9131
9289
|
_onReadyCallback: d
|
|
9132
9290
|
} = this.options;
|
|
9133
|
-
if (ut.apply(), this.canvas = new
|
|
9291
|
+
if (ut.apply(), this.canvas = new Jn(this.containerId, this.options), this.moduleLoader = new ns(), this.workerManager = new is(), this.errorManager = new ne({ editor: this }), this.historyManager = new $({ editor: this }), this.toolbar = new Ss({ editor: this }), this.transformManager = new _s({ editor: this }), this.zoomManager = new Ds({ editor: this }), this.canvasManager = new Ts({ editor: this }), this.imageManager = new te({ editor: this }), this.layerManager = new be({ editor: this }), this.shapeManager = new xs({ editor: this }), this.interactionBlocker = new Ls({ editor: this }), this.backgroundManager = new Ut({ editor: this }), this.clipboardManager = new Rs({ editor: this }), this.objectLockManager = new ve({ editor: this }), this.groupingManager = new ks({ editor: this }), this.selectionManager = new ft({ editor: this }), this.deletionManager = new Ke({ editor: this }), this.panConstraintManager = new Bs({ editor: this }), this.snappingManager = new X({ editor: this }), this.measurementManager = new Ct({ editor: this }), this.fontManager = new Pe((u = this.options.fonts) != null ? u : []), this.textManager = new at({ editor: this }), this.templateManager = new Z({ editor: this }), l && (this.angleIndicator = new Xe({ editor: this })), this._createMontageArea(), this._createClippingArea(), this.listeners = new He({ editor: this, options: this.options }), this.canvasManager.setEditorContainerWidth(t), this.canvasManager.setEditorContainerHeight(e), this.canvasManager.setCanvasWrapperWidth(n), this.canvasManager.setCanvasWrapperHeight(s), this.canvasManager.setCanvasCSSWidth(i), this.canvasManager.setCanvasCSSHeight(o), this.canvasManager.updateCanvas(), this.zoomManager.calculateAndApplyDefaultZoom(), yield this.fontManager.loadFonts(), r) {
|
|
9134
9292
|
this.historyManager.suspendHistory();
|
|
9135
9293
|
try {
|
|
9136
9294
|
const m = yield this.imageManager.prepareInitialState({
|
|
@@ -9148,7 +9306,7 @@ class Ke {
|
|
|
9148
9306
|
"scale",
|
|
9149
9307
|
"withoutSave"
|
|
9150
9308
|
]);
|
|
9151
|
-
yield this.imageManager.importImage(
|
|
9309
|
+
yield this.imageManager.importImage(P({ source: g, scale: y, withoutSave: b }, w));
|
|
9152
9310
|
}
|
|
9153
9311
|
this.errorManager.emitError({
|
|
9154
9312
|
origin: "ImageEditor",
|
|
@@ -9170,7 +9328,7 @@ class Ke {
|
|
|
9170
9328
|
"scale",
|
|
9171
9329
|
"withoutSave"
|
|
9172
9330
|
]);
|
|
9173
|
-
yield this.imageManager.importImage(
|
|
9331
|
+
yield this.imageManager.importImage(P({ source: m, scale: g, withoutSave: y }, b));
|
|
9174
9332
|
}
|
|
9175
9333
|
this.historyManager.saveState(), console.log("editor:ready"), this.canvas.fire("editor:ready", this), typeof d == "function" && d(this);
|
|
9176
9334
|
});
|
|
@@ -9186,7 +9344,7 @@ class Ke {
|
|
|
9186
9344
|
this.montageArea = this.shapeManager.addRectangle({
|
|
9187
9345
|
width: t,
|
|
9188
9346
|
height: e,
|
|
9189
|
-
fill:
|
|
9347
|
+
fill: $e._createMosaicPattern(),
|
|
9190
9348
|
stroke: null,
|
|
9191
9349
|
strokeWidth: 0,
|
|
9192
9350
|
selectable: !1,
|
|
@@ -9237,7 +9395,7 @@ class Ke {
|
|
|
9237
9395
|
const t = document.createElement("canvas");
|
|
9238
9396
|
t.width = 20, t.height = 20;
|
|
9239
9397
|
const e = t.getContext("2d");
|
|
9240
|
-
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
|
|
9398
|
+
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 $n({
|
|
9241
9399
|
source: t,
|
|
9242
9400
|
repeat: "repeat"
|
|
9243
9401
|
});
|
|
@@ -9282,7 +9440,7 @@ const Y = [
|
|
|
9282
9440
|
"U+A640-A69F",
|
|
9283
9441
|
"U+FE2E-FE2F",
|
|
9284
9442
|
"U+2116"
|
|
9285
|
-
].join(", "),
|
|
9443
|
+
].join(", "), fi = [
|
|
9286
9444
|
{
|
|
9287
9445
|
family: "Arial",
|
|
9288
9446
|
source: 'local("Arial"), local("Liberation Sans"), local("DejaVu Sans")',
|
|
@@ -10072,7 +10230,7 @@ const Y = [
|
|
|
10072
10230
|
unicodeRange: Y
|
|
10073
10231
|
}
|
|
10074
10232
|
}
|
|
10075
|
-
],
|
|
10233
|
+
], gi = {
|
|
10076
10234
|
/**
|
|
10077
10235
|
* Опции редактора
|
|
10078
10236
|
*/
|
|
@@ -10164,20 +10322,20 @@ const Y = [
|
|
|
10164
10322
|
/**
|
|
10165
10323
|
* Список шрифтов, которые будут доступны в редакторе по умолчанию.
|
|
10166
10324
|
*/
|
|
10167
|
-
fonts:
|
|
10325
|
+
fonts: fi
|
|
10168
10326
|
};
|
|
10169
|
-
function
|
|
10170
|
-
const e =
|
|
10327
|
+
function vi(h, t = {}) {
|
|
10328
|
+
const e = P(P({}, gi), t), n = document.getElementById(h);
|
|
10171
10329
|
if (!n)
|
|
10172
10330
|
return Promise.reject(new Error(`Контейнер с ID "${h}" не найден.`));
|
|
10173
10331
|
const s = document.createElement("canvas");
|
|
10174
10332
|
return s.id = `${h}-canvas`, n.appendChild(s), e.editorContainer = n, new Promise((i) => {
|
|
10175
10333
|
e._onReadyCallback = i;
|
|
10176
|
-
const o = new
|
|
10334
|
+
const o = new $e(s.id, e);
|
|
10177
10335
|
window[h] = o;
|
|
10178
10336
|
});
|
|
10179
10337
|
}
|
|
10180
10338
|
export {
|
|
10181
|
-
|
|
10339
|
+
vi as default
|
|
10182
10340
|
};
|
|
10183
10341
|
//# sourceMappingURL=main.js.map
|