@anu3ev/fabric-image-editor 0.5.20 → 0.5.22
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 +1096 -934
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
1
|
+
var ds = Object.defineProperty, ls = Object.defineProperties;
|
|
2
|
+
var hs = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var ne = Object.getOwnPropertySymbols;
|
|
4
|
+
var Ne = Object.prototype.hasOwnProperty, xe = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var _e = (h, t, e) => t in h ? ds(h, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : h[t] = e, B = (h, t) => {
|
|
6
6
|
for (var e in t || (t = {}))
|
|
7
|
-
|
|
8
|
-
if (
|
|
9
|
-
for (var e of
|
|
10
|
-
|
|
7
|
+
Ne.call(t, e) && _e(h, e, t[e]);
|
|
8
|
+
if (ne)
|
|
9
|
+
for (var e of ne(t))
|
|
10
|
+
xe.call(t, e) && _e(h, e, t[e]);
|
|
11
11
|
return h;
|
|
12
|
-
},
|
|
13
|
-
var
|
|
12
|
+
}, wt = (h, t) => ls(h, hs(t));
|
|
13
|
+
var gt = (h, t) => {
|
|
14
14
|
var e = {};
|
|
15
15
|
for (var s in h)
|
|
16
|
-
|
|
17
|
-
if (h != null &&
|
|
18
|
-
for (var s of
|
|
19
|
-
t.indexOf(s) < 0 &&
|
|
16
|
+
Ne.call(h, s) && t.indexOf(s) < 0 && (e[s] = h[s]);
|
|
17
|
+
if (h != null && ne)
|
|
18
|
+
for (var s of ne(h))
|
|
19
|
+
t.indexOf(s) < 0 && xe.call(h, s) && (e[s] = h[s]);
|
|
20
20
|
return e;
|
|
21
21
|
};
|
|
22
|
-
var
|
|
22
|
+
var z = (h, t, e) => new Promise((s, n) => {
|
|
23
23
|
var o = (r) => {
|
|
24
24
|
try {
|
|
25
25
|
a(e.next(r));
|
|
@@ -35,15 +35,15 @@ var k = (h, t, e) => new Promise((s, n) => {
|
|
|
35
35
|
}, a = (r) => r.done ? s(r.value) : Promise.resolve(r.value).then(o, i);
|
|
36
36
|
a((e = e.apply(h, t)).next());
|
|
37
37
|
});
|
|
38
|
-
import { ActiveSelection as U, Textbox as
|
|
39
|
-
import { create as
|
|
40
|
-
import
|
|
41
|
-
var
|
|
38
|
+
import { ActiveSelection as U, Textbox as ot, util as ut, controlsUtils as Be, InteractiveFabricObject as ke, Point as tt, FitContentLayout as We, loadSVGFromURL as us, FabricImage as Zt, Gradient as ze, Rect as fs, Circle as gs, Triangle as ps, Group as Et, Color as ms, classRegistry as Pe, loadSVGFromString as ys, Canvas as vs, Pattern as bs } from "fabric";
|
|
39
|
+
import { create as Ms } from "jsondiffpatch";
|
|
40
|
+
import ws from "diff-match-patch";
|
|
41
|
+
var Ss = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", V = function() {
|
|
42
42
|
for (var t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 21, e = "", s = crypto.getRandomValues(new Uint8Array(t |= 0)); t--; )
|
|
43
|
-
e +=
|
|
43
|
+
e += Ss[s[t] & 63];
|
|
44
44
|
return e;
|
|
45
45
|
};
|
|
46
|
-
class
|
|
46
|
+
class Xt {
|
|
47
47
|
/**
|
|
48
48
|
* Конструктор принимает редактор и опции.
|
|
49
49
|
* @param params
|
|
@@ -61,7 +61,7 @@ class Ft {
|
|
|
61
61
|
* @param params.options.adaptCanvasToContainerOnResize — адаптировать канвас к размерам контейнера при изменении размеров окна
|
|
62
62
|
*/
|
|
63
63
|
constructor({ editor: t, options: e = {} }) {
|
|
64
|
-
this.isDragging = !1, this.lastMouseX = 0, this.lastMouseY = 0, this.isUndoRedoKeyPressed = !1, this.isSpacePressed = !1, this.savedSelection = [], this.canvasDragging = !1, this.mouseWheelZooming = !1, this.bringToFrontOnSelection = !1, this.resetObjectFitByDoubleClick = !1, this.copyObjectsByHotkey = !1, this.pasteImageFromClipboard = !1, this.undoRedoByHotKeys = !1, this.selectAllByHotkey = !1, this.deleteObjectsByHotkey = !1, this.adaptCanvasToContainerOnResize = !1, this.editor = t, this.canvas = t.canvas, this.options = e, this.handleContainerResizeBound =
|
|
64
|
+
this.isDragging = !1, this.lastMouseX = 0, this.lastMouseY = 0, this.isUndoRedoKeyPressed = !1, this.isSpacePressed = !1, this.savedSelection = [], this.canvasDragging = !1, this.mouseWheelZooming = !1, this.bringToFrontOnSelection = !1, this.resetObjectFitByDoubleClick = !1, this.copyObjectsByHotkey = !1, this.pasteImageFromClipboard = !1, this.undoRedoByHotKeys = !1, this.selectAllByHotkey = !1, this.deleteObjectsByHotkey = !1, this.adaptCanvasToContainerOnResize = !1, this.editor = t, this.canvas = t.canvas, this.options = e, this.handleContainerResizeBound = Xt.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 = Xt.debounce(this.handleObjectModifiedHistory.bind(this), 300), this.handleObjectRotatingHistoryBound = Xt.debounce(this.handleObjectRotatingHistory.bind(this), 300), this.handleObjectAddedHistoryBound = this.handleObjectAddedHistory.bind(this), this.handleObjectRemovedHistoryBound = this.handleObjectRemovedHistory.bind(this), this.handleOverlayUpdateBound = this.handleOverlayUpdate.bind(this), this.handleBackgroundUpdateBound = this.handleBackgroundUpdate.bind(this), this.handleCanvasDragStartBound = this.handleCanvasDragStart.bind(this), this.handleCanvasDraggingBound = this.handleCanvasDragging.bind(this), this.handleCanvasDragEndBound = this.handleCanvasDragEnd.bind(this), this.handleMouseWheelZoomBound = this.handleMouseWheelZoom.bind(this), this.handleBringToFrontBound = this.handleBringToFront.bind(this), this.handleResetObjectFitBound = this.handleResetObjectFit.bind(this), this.handleLockedSelectionBound = this._filterLockedSelection.bind(this), this.init();
|
|
65
65
|
}
|
|
66
66
|
/**
|
|
67
67
|
* Инициализация всех обработчиков согласно опциям.
|
|
@@ -175,7 +175,7 @@ class Ft {
|
|
|
175
175
|
* @param event.code — код клавиши
|
|
176
176
|
*/
|
|
177
177
|
handleUndoRedoEvent(t) {
|
|
178
|
-
return
|
|
178
|
+
return z(this, null, function* () {
|
|
179
179
|
const { ctrlKey: e, metaKey: s, code: n, repeat: o } = t;
|
|
180
180
|
this._shouldIgnoreKeyboardEvent(t) || !e && !s || o || !/Mac/i.test(navigator.userAgent) && this.isUndoRedoKeyPressed || (n === "KeyZ" ? (t.preventDefault(), this.isUndoRedoKeyPressed = !0, yield this.editor.historyManager.undo()) : n === "KeyY" && (t.preventDefault(), this.isUndoRedoKeyPressed = !0, yield this.editor.historyManager.redo()));
|
|
181
181
|
});
|
|
@@ -223,7 +223,7 @@ class Ft {
|
|
|
223
223
|
}
|
|
224
224
|
const { canvas: s, editor: n, isSpacePressed: o, isDragging: i } = this;
|
|
225
225
|
if (o || i) return;
|
|
226
|
-
this.isSpacePressed = !0, t.preventDefault();
|
|
226
|
+
n.historyManager.skipHistory || n.historyManager.saveState(), n.historyManager.suspendHistory(), this.isSpacePressed = !0, t.preventDefault();
|
|
227
227
|
const a = s.getActiveObject() || null;
|
|
228
228
|
a instanceof U ? this.savedSelection = a.getObjects().slice() : a && (this.savedSelection = [a]), s.discardActiveObject(), s.set({
|
|
229
229
|
selection: !1,
|
|
@@ -244,7 +244,7 @@ class Ft {
|
|
|
244
244
|
*/
|
|
245
245
|
handleSpaceKeyUp(t) {
|
|
246
246
|
const { code: e } = t;
|
|
247
|
-
e
|
|
247
|
+
e === "Space" && (this._shouldIgnoreKeyboardEvent(t) && !this.isSpacePressed || this.isSpacePressed && (this.isSpacePressed = !1, this.isDragging && this.handleCanvasDragEnd(), this.canvas.set({
|
|
248
248
|
defaultCursor: "default",
|
|
249
249
|
selection: !0
|
|
250
250
|
}), this.canvas.setCursor("default"), this.editor.canvasManager.getObjects().forEach((s) => {
|
|
@@ -252,7 +252,7 @@ class Ft {
|
|
|
252
252
|
selectable: !0,
|
|
253
253
|
evented: !0
|
|
254
254
|
});
|
|
255
|
-
}), this._restoreSelection(this.savedSelection), this.savedSelection = [], this.canvas.requestRenderAll());
|
|
255
|
+
}), this._restoreSelection(this.savedSelection), this.savedSelection = [], this.editor.historyManager.resumeHistory(), this.canvas.requestRenderAll()));
|
|
256
256
|
}
|
|
257
257
|
/**
|
|
258
258
|
* Восстанавливает выделение с проверкой корректности объектов
|
|
@@ -347,7 +347,7 @@ class Ft {
|
|
|
347
347
|
*/
|
|
348
348
|
handleResetObjectFit(t) {
|
|
349
349
|
const e = t == null ? void 0 : t.target;
|
|
350
|
-
!e || e instanceof
|
|
350
|
+
!e || e instanceof ot || this.editor.transformManager.resetObject({ object: e });
|
|
351
351
|
}
|
|
352
352
|
/**
|
|
353
353
|
* Проверяет, должно ли событие клавиатуры быть проигнорировано
|
|
@@ -408,7 +408,7 @@ class Ft {
|
|
|
408
408
|
};
|
|
409
409
|
}
|
|
410
410
|
}
|
|
411
|
-
class
|
|
411
|
+
class As {
|
|
412
412
|
/**
|
|
413
413
|
* Класс для динамической загрузки внешних модулей.
|
|
414
414
|
*/
|
|
@@ -426,7 +426,7 @@ class Ss {
|
|
|
426
426
|
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}"`));
|
|
427
427
|
}
|
|
428
428
|
}
|
|
429
|
-
function
|
|
429
|
+
function js(h) {
|
|
430
430
|
return new Worker(
|
|
431
431
|
"" + new URL("assets/worker-CN39s7P7.js", import.meta.url).href,
|
|
432
432
|
{
|
|
@@ -434,13 +434,13 @@ function As(h) {
|
|
|
434
434
|
}
|
|
435
435
|
);
|
|
436
436
|
}
|
|
437
|
-
class
|
|
437
|
+
class Is {
|
|
438
438
|
/**
|
|
439
439
|
* @param scriptUrl — URL скрипта воркера.
|
|
440
440
|
* По-умолчанию использует DefaultWorker из соседнего файла
|
|
441
441
|
*/
|
|
442
442
|
constructor(t) {
|
|
443
|
-
t ? this.worker = new Worker(t, { type: "module" }) : this.worker = new
|
|
443
|
+
t ? this.worker = new Worker(t, { type: "module" }) : this.worker = new js(), this._callbacks = /* @__PURE__ */ new Map(), this.worker.onmessage = this._handleMessage.bind(this);
|
|
444
444
|
}
|
|
445
445
|
/**
|
|
446
446
|
* Обработчик сообщений от воркера
|
|
@@ -480,95 +480,95 @@ class js {
|
|
|
480
480
|
this.worker.terminate();
|
|
481
481
|
}
|
|
482
482
|
}
|
|
483
|
-
const
|
|
484
|
-
function
|
|
485
|
-
const o =
|
|
486
|
-
h.save(), h.translate(t, e), h.rotate(
|
|
483
|
+
const lt = 12, Cs = 2, ve = 8, be = 20, Ts = 100, Me = 20, we = 8, Es = 100, de = 32, Ie = 1, Os = "#2B2D33", Ce = "#3D8BF4", Te = "#FFFFFF";
|
|
484
|
+
function oe(h, t, e, s, n) {
|
|
485
|
+
const o = lt, i = Cs;
|
|
486
|
+
h.save(), h.translate(t, e), h.rotate(ut.degreesToRadians(n.angle)), h.fillStyle = Te, h.strokeStyle = Ce, h.lineWidth = Ie, h.beginPath(), h.roundRect(-o / 2, -o / 2, o, o, i), h.fill(), h.stroke(), h.restore();
|
|
487
487
|
}
|
|
488
488
|
function Ue(h, t, e, s, n) {
|
|
489
|
-
const o =
|
|
490
|
-
h.save(), h.translate(t, e), h.rotate(
|
|
489
|
+
const o = ve, i = be, a = Ts;
|
|
490
|
+
h.save(), h.translate(t, e), h.rotate(ut.degreesToRadians(n.angle)), h.fillStyle = Te, h.strokeStyle = Ce, h.lineWidth = Ie, h.beginPath(), h.roundRect(-o / 2, -i / 2, o, i, a), h.fill(), h.stroke(), h.restore();
|
|
491
491
|
}
|
|
492
|
-
function
|
|
493
|
-
const o =
|
|
494
|
-
h.save(), h.translate(t, e), h.rotate(
|
|
492
|
+
function Fe(h, t, e, s, n) {
|
|
493
|
+
const o = Me, i = we, a = Es;
|
|
494
|
+
h.save(), h.translate(t, e), h.rotate(ut.degreesToRadians(n.angle)), h.fillStyle = Te, h.strokeStyle = Ce, h.lineWidth = Ie, h.beginPath(), h.roundRect(-o / 2, -i / 2, o, i, a), h.fill(), h.stroke(), h.restore();
|
|
495
495
|
}
|
|
496
|
-
const
|
|
497
|
-
|
|
498
|
-
function
|
|
499
|
-
const i =
|
|
500
|
-
h.save(), h.translate(t, e), h.rotate(
|
|
496
|
+
const Ls = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTE4Ljc1IDQuMzc1djMuNzVhLjYyNS42MjUgMCAwIDEtLjYyNS42MjVoLTMuNzVhLjYyNS42MjUgMCAwIDEgMC0xLjI1aDIuMTRsLTIuMDc3LTEuOTAzLS4wMi0uMDE5YTYuMjUgNi4yNSAwIDEgMC0uMTMgOC45NjcuNjI2LjYyNiAwIDAgMSAuODYuOTA5QTcuNDU2IDcuNDU2IDAgMCAxIDEwIDE3LjVoLS4xMDNhNy41IDcuNSAwIDEgMSA1LjM5Ni0xMi44MTJMMTcuNSA2LjcwM1Y0LjM3NWEuNjI1LjYyNSAwIDAgMSAxLjI1IDBaIi8+PC9zdmc+", ss = new Image();
|
|
497
|
+
ss.src = Ls;
|
|
498
|
+
function Ds(h, t, e, s, n) {
|
|
499
|
+
const i = de / 2;
|
|
500
|
+
h.save(), h.translate(t, e), h.rotate(ut.degreesToRadians(n.angle)), h.fillStyle = Os, h.beginPath(), h.arc(0, 0, i, 0, 2 * Math.PI), h.fill(), h.drawImage(ss, -i / 2, -i / 2, i, i), h.restore();
|
|
501
501
|
}
|
|
502
|
-
const
|
|
502
|
+
const Rs = {
|
|
503
503
|
// Угловые точки
|
|
504
504
|
tl: {
|
|
505
|
-
render:
|
|
506
|
-
sizeX:
|
|
507
|
-
sizeY:
|
|
505
|
+
render: oe,
|
|
506
|
+
sizeX: lt,
|
|
507
|
+
sizeY: lt,
|
|
508
508
|
offsetX: 0,
|
|
509
509
|
offsetY: 0
|
|
510
510
|
},
|
|
511
511
|
tr: {
|
|
512
|
-
render:
|
|
513
|
-
sizeX:
|
|
514
|
-
sizeY:
|
|
512
|
+
render: oe,
|
|
513
|
+
sizeX: lt,
|
|
514
|
+
sizeY: lt,
|
|
515
515
|
offsetX: 0,
|
|
516
516
|
offsetY: 0
|
|
517
517
|
},
|
|
518
518
|
bl: {
|
|
519
|
-
render:
|
|
520
|
-
sizeX:
|
|
521
|
-
sizeY:
|
|
519
|
+
render: oe,
|
|
520
|
+
sizeX: lt,
|
|
521
|
+
sizeY: lt,
|
|
522
522
|
offsetX: 0,
|
|
523
523
|
offsetY: 0
|
|
524
524
|
},
|
|
525
525
|
br: {
|
|
526
|
-
render:
|
|
527
|
-
sizeX:
|
|
528
|
-
sizeY:
|
|
526
|
+
render: oe,
|
|
527
|
+
sizeX: lt,
|
|
528
|
+
sizeY: lt,
|
|
529
529
|
offsetX: 0,
|
|
530
530
|
offsetY: 0
|
|
531
531
|
},
|
|
532
532
|
// Середина вертикалей
|
|
533
533
|
ml: {
|
|
534
534
|
render: Ue,
|
|
535
|
-
sizeX:
|
|
536
|
-
sizeY:
|
|
535
|
+
sizeX: ve,
|
|
536
|
+
sizeY: be,
|
|
537
537
|
offsetX: 0,
|
|
538
538
|
offsetY: 0
|
|
539
539
|
},
|
|
540
540
|
mr: {
|
|
541
541
|
render: Ue,
|
|
542
|
-
sizeX:
|
|
543
|
-
sizeY:
|
|
542
|
+
sizeX: ve,
|
|
543
|
+
sizeY: be,
|
|
544
544
|
offsetX: 0,
|
|
545
545
|
offsetY: 0
|
|
546
546
|
},
|
|
547
547
|
// Середина горизонталей
|
|
548
548
|
mt: {
|
|
549
|
-
render:
|
|
550
|
-
sizeX:
|
|
551
|
-
sizeY:
|
|
549
|
+
render: Fe,
|
|
550
|
+
sizeX: Me,
|
|
551
|
+
sizeY: we,
|
|
552
552
|
offsetX: 0,
|
|
553
553
|
offsetY: 0
|
|
554
554
|
},
|
|
555
555
|
mb: {
|
|
556
|
-
render:
|
|
557
|
-
sizeX:
|
|
558
|
-
sizeY:
|
|
556
|
+
render: Fe,
|
|
557
|
+
sizeX: Me,
|
|
558
|
+
sizeY: we,
|
|
559
559
|
offsetX: 0,
|
|
560
560
|
offsetY: 0
|
|
561
561
|
},
|
|
562
562
|
// Специальный «rotate» контрол
|
|
563
563
|
mtr: {
|
|
564
|
-
render:
|
|
565
|
-
sizeX:
|
|
566
|
-
sizeY:
|
|
564
|
+
render: Ds,
|
|
565
|
+
sizeX: de,
|
|
566
|
+
sizeY: de,
|
|
567
567
|
offsetX: 0,
|
|
568
|
-
offsetY:
|
|
568
|
+
offsetY: -de
|
|
569
569
|
}
|
|
570
570
|
};
|
|
571
|
-
class
|
|
571
|
+
class et {
|
|
572
572
|
/**
|
|
573
573
|
* Отключает изменение ширины по оси X для заблокированных объектов, сохраняя поведение остального хэндлера.
|
|
574
574
|
*/
|
|
@@ -584,7 +584,7 @@ class $ {
|
|
|
584
584
|
* Применяет конфигурацию контролов к набору по ключам из DEFAULT_CONTROLS.
|
|
585
585
|
*/
|
|
586
586
|
static applyControlOverrides(t) {
|
|
587
|
-
Object.entries(
|
|
587
|
+
Object.entries(Rs).forEach(([e, s]) => {
|
|
588
588
|
const n = t[e];
|
|
589
589
|
n && (Object.assign(n, s), e === "mtr" && (n.cursorStyle = "grab", n.mouseDownHandler = (o, i, a, r) => {
|
|
590
590
|
var d;
|
|
@@ -597,10 +597,10 @@ class $ {
|
|
|
597
597
|
* Регистрирует контролы и настройки поведения выделений.
|
|
598
598
|
*/
|
|
599
599
|
static apply() {
|
|
600
|
-
const t =
|
|
601
|
-
|
|
602
|
-
const e =
|
|
603
|
-
|
|
600
|
+
const t = Be.createObjectDefaultControls();
|
|
601
|
+
et.applyControlOverrides(t), ke.ownDefaults.controls = t;
|
|
602
|
+
const e = Be.createTextboxDefaultControls();
|
|
603
|
+
et.applyControlOverrides(e), e.mt && (e.mt.visible = !1), e.mb && (e.mb.visible = !1), et.wrapWidthControl(e.ml), et.wrapWidthControl(e.mr), ot.ownDefaults.controls = e, et.patchActiveSelectionBounds(), ke.ownDefaults.snapAngle = 1;
|
|
604
604
|
}
|
|
605
605
|
/**
|
|
606
606
|
* Обновляет алгоритм расчёта границ ActiveSelection, чтобы учитывать фон и отступы текстовых объектов.
|
|
@@ -610,11 +610,11 @@ class $ {
|
|
|
610
610
|
t._calcBoundsFromObjects = function(...o) {
|
|
611
611
|
var f, g;
|
|
612
612
|
const i = (g = (f = this.getObjects) == null ? void 0 : f.call(this)) != null ? g : [];
|
|
613
|
-
|
|
613
|
+
et.applyTextSelectionScalingLock({
|
|
614
614
|
selection: this,
|
|
615
615
|
objects: i
|
|
616
616
|
});
|
|
617
|
-
const a =
|
|
617
|
+
const a = et.calculateActiveSelectionBounds({
|
|
618
618
|
objects: i
|
|
619
619
|
});
|
|
620
620
|
if (!a)
|
|
@@ -633,11 +633,11 @@ class $ {
|
|
|
633
633
|
t._onAfterObjectsChange = function(o, i) {
|
|
634
634
|
var p, m;
|
|
635
635
|
const a = s ? s.call(this, o, i) : void 0, r = (m = (p = this.getObjects) == null ? void 0 : p.call(this)) != null ? m : [];
|
|
636
|
-
|
|
636
|
+
et.applyTextSelectionScalingLock({
|
|
637
637
|
selection: this,
|
|
638
638
|
objects: r
|
|
639
639
|
});
|
|
640
|
-
const c =
|
|
640
|
+
const c = et.calculateActiveSelectionBounds({
|
|
641
641
|
objects: r
|
|
642
642
|
});
|
|
643
643
|
if (!c) return a;
|
|
@@ -647,18 +647,18 @@ class $ {
|
|
|
647
647
|
height: f
|
|
648
648
|
}), this.setPositionByOrigin(g, "center", "center"), this.setCoords(), a;
|
|
649
649
|
};
|
|
650
|
-
const n =
|
|
651
|
-
|
|
650
|
+
const n = We.prototype.calcBoundingBox;
|
|
651
|
+
We.prototype.calcBoundingBox = function(o, i) {
|
|
652
652
|
const { target: a, type: r, overrides: c } = i;
|
|
653
653
|
if (r === "imperative" && c)
|
|
654
654
|
return c;
|
|
655
655
|
if (!(a instanceof U))
|
|
656
656
|
return n.call(this, o, i);
|
|
657
|
-
|
|
657
|
+
et.applyTextSelectionScalingLock({
|
|
658
658
|
selection: a,
|
|
659
659
|
objects: o
|
|
660
660
|
});
|
|
661
|
-
const d =
|
|
661
|
+
const d = et.calculateActiveSelectionBounds({ objects: o });
|
|
662
662
|
if (!d)
|
|
663
663
|
return n.call(this, o, i);
|
|
664
664
|
const { left: l, top: u, width: f, height: g } = d, p = new tt(f, g), m = new tt(l + f / 2, u + g / 2);
|
|
@@ -694,7 +694,7 @@ class $ {
|
|
|
694
694
|
selection: t,
|
|
695
695
|
objects: e
|
|
696
696
|
}) {
|
|
697
|
-
const s = e.some((n) => n instanceof
|
|
697
|
+
const s = e.some((n) => n instanceof ot);
|
|
698
698
|
t.setControlsVisibility({
|
|
699
699
|
mt: !s,
|
|
700
700
|
mb: !s,
|
|
@@ -703,7 +703,7 @@ class $ {
|
|
|
703
703
|
});
|
|
704
704
|
}
|
|
705
705
|
}
|
|
706
|
-
const
|
|
706
|
+
const P = class P {
|
|
707
707
|
constructor(t = []) {
|
|
708
708
|
this.fonts = t;
|
|
709
709
|
}
|
|
@@ -711,36 +711,36 @@ const z = class z {
|
|
|
711
711
|
this.fonts = t;
|
|
712
712
|
}
|
|
713
713
|
loadFonts() {
|
|
714
|
-
return
|
|
714
|
+
return z(this, null, function* () {
|
|
715
715
|
var n;
|
|
716
716
|
const t = (n = this.fonts) != null ? n : [];
|
|
717
717
|
if (!t.length) return;
|
|
718
718
|
const e = typeof document != "undefined" ? document : void 0;
|
|
719
719
|
if (!e) return;
|
|
720
|
-
const s = t.map((o) =>
|
|
720
|
+
const s = t.map((o) => P.loadFont(o, e));
|
|
721
721
|
yield Promise.allSettled(s);
|
|
722
722
|
});
|
|
723
723
|
}
|
|
724
724
|
static loadFont(t, e) {
|
|
725
|
-
return
|
|
725
|
+
return z(this, null, function* () {
|
|
726
726
|
var c, d;
|
|
727
727
|
const s = typeof FontFace != "undefined", n = (c = t.family) == null ? void 0 : c.trim(), o = (d = t.source) == null ? void 0 : d.trim();
|
|
728
728
|
if (!n || !o) return;
|
|
729
|
-
const i =
|
|
730
|
-
if (!
|
|
731
|
-
if (
|
|
732
|
-
|
|
729
|
+
const i = P.normalizeFontSource(o), a = P.getDescriptorSnapshot(t.descriptors), r = P.getFontRegistrationKey(n, i, a);
|
|
730
|
+
if (!P.registeredFontKeys.has(r)) {
|
|
731
|
+
if (P.isFontFaceAlreadyApplied(e, n, a)) {
|
|
732
|
+
P.registeredFontKeys.add(r);
|
|
733
733
|
return;
|
|
734
734
|
}
|
|
735
735
|
if (s && e.fonts && typeof e.fonts.add == "function")
|
|
736
736
|
try {
|
|
737
737
|
const u = yield new FontFace(n, i, t.descriptors).load();
|
|
738
|
-
e.fonts.add(u),
|
|
738
|
+
e.fonts.add(u), P.registeredFontKeys.add(r);
|
|
739
739
|
return;
|
|
740
740
|
} catch (l) {
|
|
741
741
|
console.warn(`Не удалось загрузить шрифт "${n}" через FontFace API`, l);
|
|
742
742
|
}
|
|
743
|
-
|
|
743
|
+
P.injectFontFace({
|
|
744
744
|
font: t,
|
|
745
745
|
source: i,
|
|
746
746
|
doc: e,
|
|
@@ -760,15 +760,15 @@ const z = class z {
|
|
|
760
760
|
if (!i) return;
|
|
761
761
|
const a = s.createElement("style");
|
|
762
762
|
a.setAttribute("data-editor-font", i), a.setAttribute("data-editor-font-key", n);
|
|
763
|
-
const r =
|
|
763
|
+
const r = P.descriptorsToCss(o), c = [
|
|
764
764
|
"@font-face {",
|
|
765
|
-
` font-family: ${
|
|
765
|
+
` font-family: ${P.formatFontFamilyForCss(i)};`,
|
|
766
766
|
` src: ${e};`,
|
|
767
767
|
...r.map((l) => ` ${l}`),
|
|
768
768
|
"}"
|
|
769
769
|
];
|
|
770
770
|
a.textContent = c.join(`
|
|
771
|
-
`), s.head.appendChild(a),
|
|
771
|
+
`), s.head.appendChild(a), P.registeredFontKeys.add(n);
|
|
772
772
|
}
|
|
773
773
|
static normalizeFontSource(t) {
|
|
774
774
|
const e = t.trim();
|
|
@@ -791,15 +791,15 @@ const z = class z {
|
|
|
791
791
|
return t ? t.trim().replace(/^['"]+|['"]+$/g, "").toLowerCase() : "";
|
|
792
792
|
}
|
|
793
793
|
static getDescriptorSnapshot(t) {
|
|
794
|
-
const e =
|
|
794
|
+
const e = P.descriptorDefaults;
|
|
795
795
|
return {
|
|
796
|
-
style:
|
|
797
|
-
weight:
|
|
798
|
-
stretch:
|
|
799
|
-
unicodeRange:
|
|
800
|
-
variant:
|
|
801
|
-
featureSettings:
|
|
802
|
-
display:
|
|
796
|
+
style: P.normalizeDescriptorValue(t == null ? void 0 : t.style, e.style),
|
|
797
|
+
weight: P.normalizeDescriptorValue(t == null ? void 0 : t.weight, e.weight),
|
|
798
|
+
stretch: P.normalizeDescriptorValue(t == null ? void 0 : t.stretch, e.stretch),
|
|
799
|
+
unicodeRange: P.normalizeDescriptorValue(t == null ? void 0 : t.unicodeRange, e.unicodeRange),
|
|
800
|
+
variant: P.normalizeDescriptorValue(t == null ? void 0 : t.variant, e.variant),
|
|
801
|
+
featureSettings: P.normalizeDescriptorValue(t == null ? void 0 : t.featureSettings, e.featureSettings),
|
|
802
|
+
display: P.normalizeDescriptorValue(t == null ? void 0 : t.display, e.display)
|
|
803
803
|
};
|
|
804
804
|
}
|
|
805
805
|
static areDescriptorSnapshotsEqual(t, e) {
|
|
@@ -807,7 +807,7 @@ const z = class z {
|
|
|
807
807
|
}
|
|
808
808
|
static getFontRegistrationKey(t, e, s) {
|
|
809
809
|
return [
|
|
810
|
-
|
|
810
|
+
P.normalizeFamilyName(t),
|
|
811
811
|
e,
|
|
812
812
|
s.style,
|
|
813
813
|
s.weight,
|
|
@@ -821,12 +821,12 @@ const z = class z {
|
|
|
821
821
|
static isFontFaceAlreadyApplied(t, e, s) {
|
|
822
822
|
const n = t.fonts;
|
|
823
823
|
if (!n || typeof n.forEach != "function") return !1;
|
|
824
|
-
const o =
|
|
824
|
+
const o = P.normalizeFamilyName(e);
|
|
825
825
|
let i = !1;
|
|
826
826
|
try {
|
|
827
827
|
n.forEach((a) => {
|
|
828
|
-
if (i ||
|
|
829
|
-
const c =
|
|
828
|
+
if (i || P.normalizeFamilyName(a.family) !== o) return;
|
|
829
|
+
const c = P.getDescriptorSnapshot({
|
|
830
830
|
style: a.style,
|
|
831
831
|
weight: a.weight,
|
|
832
832
|
stretch: a.stretch,
|
|
@@ -835,7 +835,7 @@ const z = class z {
|
|
|
835
835
|
featureSettings: a.featureSettings,
|
|
836
836
|
display: a.display
|
|
837
837
|
});
|
|
838
|
-
|
|
838
|
+
P.areDescriptorSnapshotsEqual(s, c) && (i = !0);
|
|
839
839
|
});
|
|
840
840
|
} catch (a) {
|
|
841
841
|
return console.warn("Не удалось проверить, загружен ли шрифт ранее через FontFaceSet", a), !1;
|
|
@@ -862,7 +862,7 @@ const z = class z {
|
|
|
862
862
|
});
|
|
863
863
|
}
|
|
864
864
|
};
|
|
865
|
-
|
|
865
|
+
P.registeredFontKeys = /* @__PURE__ */ new Set(), P.descriptorDefaults = {
|
|
866
866
|
style: "normal",
|
|
867
867
|
weight: "normal",
|
|
868
868
|
stretch: "normal",
|
|
@@ -871,8 +871,8 @@ z.registeredFontKeys = /* @__PURE__ */ new Set(), z.descriptorDefaults = {
|
|
|
871
871
|
featureSettings: "normal",
|
|
872
872
|
display: "auto"
|
|
873
873
|
};
|
|
874
|
-
let
|
|
875
|
-
const
|
|
874
|
+
let Se = P;
|
|
875
|
+
const _s = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNNi44NzUgMi41YS42MjUuNjI1IDAgMCAwLS42MjUuNjI0VjYuMjVIMy4xMjVhLjYyNS42MjUgMCAwIDAtLjYyNS42MjV2MTBjMCAuMzQ1LjI4LjYyNS42MjUuNjI1aDEwYy4zNDUgMCAuNjI1LS4yOC42MjUtLjYyNXYtMy4xMjZoMy4xMjVjLjM0NSAwIC42MjUtLjI4LjYyNS0uNjI1di0xMGEuNjI1LjYyNSAwIDAgMC0uNjI1LS42MjVoLTEwWm02Ljg3NSAxMGgyLjVWMy43NUg3LjV2Mi41aDUuNjI1Yy4zNDUgMCAuNjI1LjI4LjYyNS42MjV2NS42MjRabS0xMCAzLjc1VjcuNWg4Ljc1djguNzVIMy43NVoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjwvc3ZnPg==", Ns = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMi41IDcuNWMwLS42OS41Ni0xLjI1IDEuMjUtMS4yNWgxMi41Yy42OSAwIDEuMjUuNTYgMS4yNSAxLjI1djguNzVjMCAuNjktLjU2IDEuMjUtMS4yNSAxLjI1SDMuNzVjLS42OSAwLTEuMjUtLjU2LTEuMjUtMS4yNVY3LjVabTEzLjc1IDBIMy43NXY4Ljc1aDEyLjVWNy41WiIgY2xpcC1ydWxlPSJldmVub2RkIi8+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMTAgMS44NzVhMi4xODggMi4xODggMCAwIDAtMi4xODggMi4xODh2Mi44MTJhLjYyNS42MjUgMCAxIDEtMS4yNSAwVjQuMDYyYTMuNDM3IDMuNDM3IDAgMSAxIDYuODc1IDB2Mi44MTNhLjYyNS42MjUgMCAxIDEtMS4yNSAwVjQuMDYyQTIuMTg4IDIuMTg4IDAgMCAwIDEwIDEuODc2WiIgY2xpcC1ydWxlPSJldmVub2RkIi8+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTEwIDEyLjgxM2EuOTM3LjkzNyAwIDEgMCAwLTEuODc1LjkzNy45MzcgMCAwIDAgMCAxLjg3NFoiLz48L3N2Zz4=", xs = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTE2LjI1IDYuMjVINy41VjQuMzc1YTIuNSAyLjUgMCAwIDEgMi41LTIuNWMxLjIgMCAyLjI4MS44NiAyLjUxMiAyYS42MjUuNjI1IDAgMCAwIDEuMjI2LS4yNWMtLjM1NC0xLjczOC0xLjkyNS0zLTMuNzM4LTNhMy43NTQgMy43NTQgMCAwIDAtMy43NSAzLjc1VjYuMjVoLTIuNUExLjI1IDEuMjUgMCAwIDAgMi41IDcuNXY4Ljc1YTEuMjUgMS4yNSAwIDAgMCAxLjI1IDEuMjVoMTIuNWExLjI1IDEuMjUgMCAwIDAgMS4yNS0xLjI1VjcuNWExLjI1IDEuMjUgMCAwIDAtMS4yNS0xLjI1Wm0wIDEwSDMuNzVWNy41aDEyLjV2OC43NVptLTUuMzEzLTQuMzc1YS45MzcuOTM3IDAgMSAxLTEuODc0IDAgLjkzNy45MzcgMCAwIDEgMS44NzQgMFoiLz48L3N2Zz4K", Bs = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTIuNSA4LjEyNSAxMCAxMi41bDcuNS00LjM3NUwxMCAzLjc1IDIuNSA4LjEyNVoiLz48cGF0aCBmaWxsPSIjZmZmIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik05LjY4NSAzLjIxYS42MjUuNjI1IDAgMCAxIC42MyAwbDcuNSA0LjM3NWEuNjI1LjYyNSAwIDAgMSAwIDEuMDhsLTcuNSA0LjM3NWEuNjI1LjYyNSAwIDAgMS0uNjMgMGwtNy41LTQuMzc1YS42MjUuNjI1IDAgMCAxIDAtMS4wOGw3LjUtNC4zNzVaTTMuNzQgOC4xMjUgMTAgMTEuNzc2bDYuMjYtMy42NTFMMTAgNC40NzQgMy43NCA4LjEyNVoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjxwYXRoIGZpbGw9IiNmZmYiIGZpbGwtcnVsZT0iZXZlbm9kZCIgZD0iTTUuNCA5LjQ2YS42MjUuNjI1IDAgMCAxIC42MyAwTDEwIDExLjc3NmwzLjk3LTIuMzE2YS42MjUuNjI1IDAgMCAxIC42MyAwbDMuMjE1IDEuODc1YS42MjUuNjI1IDAgMCAxIDAgMS4wOGwtNy41IDQuMzc1YS42MjUuNjI1IDAgMCAxLS42MyAwbC03LjUtNC4zNzVhLjYyNS42MjUgMCAwIDEgMC0xLjA4TDUuNCA5LjQ2Wm0tMS42NiAyLjQxNUwxMCAxNS41MjZsNi4yNi0zLjY1MS0xLjk3NC0xLjE1MS0zLjk3MSAyLjMxNmEuNjI1LjYyNSAwIDAgMS0uNjMgMGwtMy45Ny0yLjMxNi0xLjk3NSAxLjE1MVoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjwvc3ZnPg==", ks = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNOS42ODUgMy4yMWEuNjI1LjYyNSAwIDAgMSAuNjMgMGw3LjUgNC4zNzVhLjYyNS42MjUgMCAwIDEgMCAxLjA4bC03LjUgNC4zNzVhLjYyNS42MjUgMCAwIDEtLjYzIDBsLTcuNS00LjM3NWEuNjI1LjYyNSAwIDAgMSAwLTEuMDhsNy41LTQuMzc1Wk0zLjc0IDguMTI1IDEwIDExLjc3Nmw2LjI2LTMuNjUxTDEwIDQuNDc0IDMuNzQgOC4xMjVaIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiLz48cGF0aCBmaWxsPSIjZmZmIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik01LjcxNCAxMCAxMCAxMi41bDQuMjg2LTIuNSAzLjIxNCAxLjg3NUwxMCAxNi4yNWwtNy41LTQuMzc1TDUuNzE0IDEwWiIgY2xpcC1ydWxlPSJldmVub2RkIi8+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNNS40IDkuNDZhLjYyNS42MjUgMCAwIDEgLjYzIDBMMTAgMTEuNzc2bDMuOTctMi4zMTZhLjYyNS42MjUgMCAwIDEgLjYzIDBsMy4yMTUgMS44NzVhLjYyNS42MjUgMCAwIDEgMCAxLjA4bC03LjUgNC4zNzVhLjYyNS42MjUgMCAwIDEtLjYzIDBsLTcuNS00LjM3NWEuNjI1LjYyNSAwIDAgMSAwLTEuMDhMNS40IDkuNDZabS0xLjY2IDIuNDE1TDEwIDE1LjUyNmw2LjI2LTMuNjUxLTEuOTc0LTEuMTUxLTMuOTcxIDIuMzE2YS42MjUuNjI1IDAgMCAxLS42MyAwbC0zLjk3LTIuMzE2LTEuOTc1IDEuMTUxWiIgY2xpcC1ydWxlPSJldmVub2RkIi8+PC9zdmc+", Ws = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0ibTIuNSA2LjI1IDcuNSA0LjM3NSA3LjUtNC4zNzVMMTAgMS44NzUgMi41IDYuMjVaIi8+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNOS42ODUgMS4zMzVhLjYyNS42MjUgMCAwIDEgLjYzIDBsNy41IDQuMzc1YS42MjUuNjI1IDAgMCAxIDAgMS4wOGwtNy41IDQuMzc1YS42MjUuNjI1IDAgMCAxLS42MyAwbC03LjUtNC4zNzVhLjYyNS42MjUgMCAwIDEgMC0xLjA4bDcuNS00LjM3NVpNMy43NCA2LjI1IDEwIDkuOTAxbDYuMjYtMy42NTFMMTAgMi41OTkgMy43NCA2LjI1WiIgY2xpcC1ydWxlPSJldmVub2RkIi8+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNNS40IDExLjMzNWEuNjI1LjYyNSAwIDAgMSAuNjMgMEwxMCAxMy42NTFsMy45Ny0yLjMxNmEuNjI1LjYyNSAwIDAgMSAuNjMgMGwzLjIxNSAxLjg3NWEuNjI1LjYyNSAwIDAgMSAwIDEuMDhsLTcuNSA0LjM3NWEuNjI1LjYyNSAwIDAgMS0uNjMgMGwtNy41LTQuMzc1YS42MjUuNjI1IDAgMCAxIDAtMS4wOEw1LjQgMTEuMzM1Wk0zLjc0IDEzLjc1IDEwIDE3LjQwMWw2LjI2LTMuNjUxLTEuOTc0LTEuMTUxLTMuOTcxIDIuMzE2YS42MjUuNjI1IDAgMCAxLS42MyAwbC0zLjk3LTIuMzE2TDMuNzQgMTMuNzVaIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiLz48cGF0aCBmaWxsPSIjZmZmIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik01LjQgNy41ODVhLjYyNS42MjUgMCAwIDEgLjYzIDBMMTAgOS45MDFsMy45Ny0yLjMxNmEuNjI1LjYyNSAwIDAgMSAuNjMgMGwzLjIxNSAxLjg3NWEuNjI1LjYyNSAwIDAgMSAwIDEuMDhsLTcuNSA0LjM3NWEuNjI1LjYyNSAwIDAgMS0uNjMgMGwtNy41LTQuMzc1YS42MjUuNjI1IDAgMCAxIDAtMS4wOEw1LjQgNy41ODVaTTMuNzQgMTAgMTAgMTMuNjUxIDE2LjI2IDEwbC0xLjk3NC0xLjE1MS0zLjk3MSAyLjMxNmEuNjI1LjYyNSAwIDAgMS0uNjMgMGwtMy45Ny0yLjMxNkwzLjc0IDEwWiIgY2xpcC1ydWxlPSJldmVub2RkIi8+PC9zdmc+", zs = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMS45NiAxMy40MzVhLjYyNS42MjUgMCAwIDEgLjg1NS0uMjI1TDEwIDE3LjQwMWw3LjE4NS00LjE5YS42MjUuNjI1IDAgMCAxIC42MyAxLjA3OWwtNy41IDQuMzc1YS42MjUuNjI1IDAgMCAxLS42MyAwbC03LjUtNC4zNzVhLjYyNS42MjUgMCAwIDEtLjIyNS0uODU1Wk05LjY4NSAxLjMzNWEuNjI1LjYyNSAwIDAgMSAuNjMgMGw3LjUgNC4zNzVhLjYyNS42MjUgMCAwIDEgMCAxLjA4bC03LjUgNC4zNzVhLjYyNS42MjUgMCAwIDEtLjYzIDBsLTcuNS00LjM3NWEuNjI1LjYyNSAwIDAgMSAwLTEuMDhsNy41LTQuMzc1Wk0zLjc0IDYuMjUgMTAgOS45MDFsNi4yNi0zLjY1MUwxMCAyLjU5OSAzLjc0IDYuMjVaIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiLz48cGF0aCBmaWxsPSIjZmZmIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGQ9Im01LjcxNCAxMS44NzUgNC4yODYgMi41IDQuMjg2LTIuNUwxNy41IDEzLjc1IDEwIDE4LjEyNSAyLjUgMTMuNzVsMy4yMTQtMS44NzVaIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiLz48cGF0aCBmaWxsPSIjZmZmIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik01LjQgMTEuMzM1YS42MjUuNjI1IDAgMCAxIC42MyAwTDEwIDEzLjY1MWwzLjk3LTIuMzE2YS42MjUuNjI1IDAgMCAxIC42MyAwbDMuMjE1IDEuODc1YS42MjUuNjI1IDAgMCAxIDAgMS4wOGwtNy41IDQuMzc1YS42MjUuNjI1IDAgMCAxLS42MyAwbC03LjUtNC4zNzVhLjYyNS42MjUgMCAwIDEgMC0xLjA4TDUuNCAxMS4zMzVaTTMuNzQgMTMuNzUgMTAgMTcuNDAxbDYuMjYtMy42NTEtMS45NzQtMS4xNTEtMy45NzEgMi4zMTZhLjYyNS42MjUgMCAwIDEtLjYzIDBsLTMuOTctMi4zMTZMMy43NCAxMy43NVoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjxwYXRoIGZpbGw9IiNmZmYiIGZpbGwtcnVsZT0iZXZlbm9kZCIgZD0iTTUuNCA3LjU4NWEuNjI1LjYyNSAwIDAgMSAuNjMgMEwxMCA5LjkwMWwzLjk3LTIuMzE2YS42MjUuNjI1IDAgMCAxIC42MyAwbDMuMjE1IDEuODc1YS42MjUuNjI1IDAgMCAxIDAgMS4wOGwtNy41IDQuMzc1YS42MjUuNjI1IDAgMCAxLS42MyAwbC03LjUtNC4zNzVhLjYyNS42MjUgMCAwIDEgMC0xLjA4TDUuNCA3LjU4NVpNMy43NCAxMCAxMCAxMy42NTEgMTYuMjYgMTBsLTEuOTc0LTEuMTUxLTMuOTcxIDIuMzE2YS42MjUuNjI1IDAgMCAxLS42MyAwbC0zLjk3LTIuMzE2TDMuNzQgMTBaIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiLz48L3N2Zz4=", Ps = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI0VDNEU0MCIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNOC4xMjUgMS4yNUExLjg3NSAxLjg3NSAwIDAgMCA2LjI1IDMuMTI1di42MjVIMy4xMjVhLjYyNS42MjUgMCAwIDAgMCAxLjI1aC42MjV2MTEuMjVBMS4yNSAxLjI1IDAgMCAwIDUgMTcuNWgxMGExLjI1IDEuMjUgMCAwIDAgMS4yNS0xLjI1VjVoLjYyNWEuNjI1LjYyNSAwIDAgMCAwLTEuMjVIMTMuNzV2LS42MjVhMS44NzUgMS44NzUgMCAwIDAtMS44NzUtMS44NzVoLTMuNzVabTQuMzc1IDIuNXYtLjYyNWEuNjI1LjYyNSAwIDAgMC0uNjI1LS42MjVoLTMuNzVhLjYyNS42MjUgMCAwIDAtLjYyNS42MjV2LjYyNWg1Wk01IDE2LjI1VjVoMTB2MTEuMjVINVpNOC4xMjUgNy41Yy4zNDUgMCAuNjI1LjI4LjYyNS42MjV2NWEuNjI1LjYyNSAwIDEgMS0xLjI1IDB2LTVjMC0uMzQ1LjI4LS42MjUuNjI1LS42MjVabTQuMzc1IDUuNjI1di01YS42MjUuNjI1IDAgMCAwLTEuMjUgMHY1YS42MjUuNjI1IDAgMSAwIDEuMjUgMFoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjwvc3ZnPg==", Gt = {
|
|
876
876
|
style: {
|
|
877
877
|
position: "absolute",
|
|
878
878
|
display: "none",
|
|
@@ -939,17 +939,17 @@ const Rs = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMj
|
|
|
939
939
|
],
|
|
940
940
|
offsetTop: 50,
|
|
941
941
|
icons: {
|
|
942
|
-
copyPaste:
|
|
943
|
-
delete:
|
|
944
|
-
lock:
|
|
942
|
+
copyPaste: _s,
|
|
943
|
+
delete: Ps,
|
|
944
|
+
lock: Ns,
|
|
945
945
|
unlock: xs,
|
|
946
|
-
bringToFront:
|
|
946
|
+
bringToFront: Ws,
|
|
947
947
|
sendToBack: zs,
|
|
948
|
-
bringForward:
|
|
949
|
-
sendBackwards:
|
|
948
|
+
bringForward: Bs,
|
|
949
|
+
sendBackwards: ks
|
|
950
950
|
},
|
|
951
951
|
handlers: {
|
|
952
|
-
copyPaste: (h) =>
|
|
952
|
+
copyPaste: (h) => z(null, null, function* () {
|
|
953
953
|
h.clipboardManager.copyPaste();
|
|
954
954
|
}),
|
|
955
955
|
delete: (h) => {
|
|
@@ -975,18 +975,18 @@ const Rs = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMj
|
|
|
975
975
|
}
|
|
976
976
|
}
|
|
977
977
|
};
|
|
978
|
-
class
|
|
978
|
+
class Us {
|
|
979
979
|
constructor({ editor: t }) {
|
|
980
980
|
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();
|
|
981
981
|
}
|
|
982
982
|
_initToolbar() {
|
|
983
983
|
if (!this.options.showToolbar) return;
|
|
984
984
|
const t = this.options.toolbar || {};
|
|
985
|
-
this.config =
|
|
986
|
-
style: B(B({},
|
|
987
|
-
btnStyle: B(B({},
|
|
988
|
-
icons: B(B({},
|
|
989
|
-
handlers: B(B({},
|
|
985
|
+
this.config = wt(B(B({}, Gt), t), {
|
|
986
|
+
style: B(B({}, Gt.style), t.style || {}),
|
|
987
|
+
btnStyle: B(B({}, Gt.btnStyle), t.btnStyle || {}),
|
|
988
|
+
icons: B(B({}, Gt.icons), t.icons || {}),
|
|
989
|
+
handlers: B(B({}, Gt.handlers), t.handlers || {})
|
|
990
990
|
}), this.currentTarget = null, this.currentLocked = !1, this.isTransforming = !1, this.isTemporarilyHidden = !1, this._onMouseDown = this._handleMouseDown.bind(this), this._onObjectMoving = this._startTransform.bind(this), this._onObjectScaling = this._startTransform.bind(this), this._onObjectRotating = this._startTransform.bind(this), this._onMouseUp = this._endTransform.bind(this), this._onObjectModified = this._endTransform.bind(this), this._onSelectionChange = this._updateToolbar.bind(this), this._onSelectionClear = () => {
|
|
991
991
|
this.el.style.display = "none";
|
|
992
992
|
}, this._createDOM(), this._bindEvents();
|
|
@@ -1117,8 +1117,8 @@ const Fs = {
|
|
|
1117
1117
|
"pointer-events": "none",
|
|
1118
1118
|
"white-space": "nowrap",
|
|
1119
1119
|
"box-shadow": "0 2px 8px rgba(0, 0, 0, 0.2)"
|
|
1120
|
-
},
|
|
1121
|
-
class
|
|
1120
|
+
}, Ye = 16, He = 16, Ys = "fabric-editor-angle-indicator";
|
|
1121
|
+
class Ee {
|
|
1122
1122
|
constructor({ editor: t }) {
|
|
1123
1123
|
this.isActive = !1, this.currentAngle = 0, this.editor = t, this.canvas = t.canvas, this.options = t.options, this._createDOM(), this._bindEvents();
|
|
1124
1124
|
}
|
|
@@ -1126,7 +1126,7 @@ class Me {
|
|
|
1126
1126
|
* Создание DOM-элемента индикатора
|
|
1127
1127
|
*/
|
|
1128
1128
|
_createDOM() {
|
|
1129
|
-
this.el = document.createElement("div"), this.el.className =
|
|
1129
|
+
this.el = document.createElement("div"), this.el.className = Ys, Object.entries(Fs).forEach(([t, e]) => {
|
|
1130
1130
|
this.el.style.setProperty(t, e);
|
|
1131
1131
|
}), this.canvas.wrapperEl.appendChild(this.el);
|
|
1132
1132
|
}
|
|
@@ -1146,7 +1146,7 @@ class Me {
|
|
|
1146
1146
|
return;
|
|
1147
1147
|
}
|
|
1148
1148
|
const s = e.angle || 0;
|
|
1149
|
-
this.currentAngle =
|
|
1149
|
+
this.currentAngle = Ee._normalizeAngle(s), this.el.textContent = `${this.currentAngle}°`, this._positionIndicator(t.e), this.isActive || this._showIndicator();
|
|
1150
1150
|
}
|
|
1151
1151
|
/**
|
|
1152
1152
|
* Обработчик отпускания кнопки мыши
|
|
@@ -1177,9 +1177,9 @@ class Me {
|
|
|
1177
1177
|
*/
|
|
1178
1178
|
_positionIndicator(t) {
|
|
1179
1179
|
const e = this.canvas.wrapperEl.getBoundingClientRect();
|
|
1180
|
-
let s = t.clientX - e.left +
|
|
1180
|
+
let s = t.clientX - e.left + Ye, n = t.clientY - e.top + He;
|
|
1181
1181
|
const o = this.el.getBoundingClientRect(), i = o.width, a = o.height;
|
|
1182
|
-
s + i > e.width && (s = t.clientX - e.left - i -
|
|
1182
|
+
s + i > e.width && (s = t.clientX - e.left - i - Ye), n + a > e.height && (n = t.clientY - e.top - a - He), this.el.style.left = `${s}px`, this.el.style.top = `${n}px`;
|
|
1183
1183
|
}
|
|
1184
1184
|
/**
|
|
1185
1185
|
* Показать индикатор
|
|
@@ -1210,7 +1210,7 @@ class Me {
|
|
|
1210
1210
|
this.canvas && (this.canvas.off("object:rotating", this._onObjectRotating), this.canvas.off("mouse:up", this._onMouseUp), this.canvas.off("object:modified", this._onObjectModified), this.canvas.off("selection:cleared", this._onSelectionCleared)), (t = this.el) != null && t.parentNode && this.el.parentNode.removeChild(this.el), this.el = null, this.editor = null, this.canvas = null, this.options = null;
|
|
1211
1211
|
}
|
|
1212
1212
|
}
|
|
1213
|
-
const
|
|
1213
|
+
const ns = [
|
|
1214
1214
|
"selectable",
|
|
1215
1215
|
"evented",
|
|
1216
1216
|
"id",
|
|
@@ -1246,7 +1246,7 @@ const es = [
|
|
|
1246
1246
|
"radiusBottomRight",
|
|
1247
1247
|
"radiusBottomLeft"
|
|
1248
1248
|
];
|
|
1249
|
-
class
|
|
1249
|
+
class Kt {
|
|
1250
1250
|
constructor({ editor: t }) {
|
|
1251
1251
|
this.editor = t, this.canvas = t.canvas, this._isSavingState = !1, this._historySuspendCount = 0, this.baseState = null, this.patches = [], this.currentIndex = 0, this.maxHistoryLength = t.options.maxHistoryLength, this.totalChangesCount = 0, this.baseStateChangesCount = 0, this._createDiffPatcher();
|
|
1252
1252
|
}
|
|
@@ -1258,7 +1258,7 @@ class Ys {
|
|
|
1258
1258
|
return this.patches[this.currentIndex - 1] || null;
|
|
1259
1259
|
}
|
|
1260
1260
|
_createDiffPatcher() {
|
|
1261
|
-
this.diffPatcher =
|
|
1261
|
+
this.diffPatcher = Ms({
|
|
1262
1262
|
objectHash(t) {
|
|
1263
1263
|
const e = t, s = t, n = s.styles ? JSON.stringify(s.styles) : "", o = e.customData ? JSON.stringify(e.customData) : "";
|
|
1264
1264
|
return [
|
|
@@ -1308,7 +1308,7 @@ class Ys {
|
|
|
1308
1308
|
includeValueOnMove: !1
|
|
1309
1309
|
},
|
|
1310
1310
|
textDiff: {
|
|
1311
|
-
diffMatchPatch:
|
|
1311
|
+
diffMatchPatch: ws,
|
|
1312
1312
|
minLength: 60
|
|
1313
1313
|
}
|
|
1314
1314
|
});
|
|
@@ -1351,13 +1351,15 @@ class Ys {
|
|
|
1351
1351
|
this._isSavingState = !0, console.time("saveState");
|
|
1352
1352
|
try {
|
|
1353
1353
|
const t = this._withTemporaryUnlock(
|
|
1354
|
-
() => this.canvas.toDatalessObject([...
|
|
1354
|
+
() => this.canvas.toDatalessObject([...ns])
|
|
1355
1355
|
);
|
|
1356
1356
|
if (console.timeEnd("saveState"), !this.baseState) {
|
|
1357
1357
|
this.baseState = t, this.patches = [], this.currentIndex = 0, console.log("Базовое состояние сохранено.");
|
|
1358
1358
|
return;
|
|
1359
1359
|
}
|
|
1360
|
-
const e = this.getFullState()
|
|
1360
|
+
const e = this.getFullState();
|
|
1361
|
+
console.log("prevState", e);
|
|
1362
|
+
const s = this.diffPatcher.diff(e, t);
|
|
1361
1363
|
if (!s) {
|
|
1362
1364
|
console.log("Нет изменений для сохранения.");
|
|
1363
1365
|
return;
|
|
@@ -1368,23 +1370,76 @@ class Ys {
|
|
|
1368
1370
|
}
|
|
1369
1371
|
}
|
|
1370
1372
|
}
|
|
1373
|
+
/**
|
|
1374
|
+
* Создаёт безопасную копию состояния для загрузки в canvas.
|
|
1375
|
+
* customData сериализуется, чтобы Fabric не обрабатывал её как параметры объекта.
|
|
1376
|
+
*
|
|
1377
|
+
* @param state - полное состояние канваса
|
|
1378
|
+
*/
|
|
1379
|
+
static _createLoadSafeState({ state: t }) {
|
|
1380
|
+
const e = JSON.parse(JSON.stringify(t)), { objects: s = [] } = e;
|
|
1381
|
+
for (let n = 0; n < s.length; n += 1) {
|
|
1382
|
+
const o = s[n], { customData: i } = o;
|
|
1383
|
+
!i || typeof i != "object" || (o.customData = JSON.stringify(i));
|
|
1384
|
+
}
|
|
1385
|
+
return e;
|
|
1386
|
+
}
|
|
1387
|
+
/**
|
|
1388
|
+
* Восстанавливает customData на объектах канваса из состояния истории.
|
|
1389
|
+
* Нужна, чтобы в истории всегда сохранялся объект, а не строка.
|
|
1390
|
+
*
|
|
1391
|
+
* @param state - исходное состояние с object customData
|
|
1392
|
+
* @param canvas - канвас, в который загружены объекты
|
|
1393
|
+
*/
|
|
1394
|
+
static _applyCustomDataFromState({
|
|
1395
|
+
state: t,
|
|
1396
|
+
canvas: e
|
|
1397
|
+
}) {
|
|
1398
|
+
var a, r;
|
|
1399
|
+
const { objects: s = [] } = t, n = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map();
|
|
1400
|
+
for (let c = 0; c < s.length; c += 1) {
|
|
1401
|
+
const d = s[c], { customData: l, id: u } = d;
|
|
1402
|
+
if (!(!l || typeof l != "object")) {
|
|
1403
|
+
if (typeof u == "string") {
|
|
1404
|
+
n.set(u, l);
|
|
1405
|
+
continue;
|
|
1406
|
+
}
|
|
1407
|
+
o.set(c, l);
|
|
1408
|
+
}
|
|
1409
|
+
}
|
|
1410
|
+
const i = (r = (a = e.getObjects) == null ? void 0 : a.call(e)) != null ? r : [];
|
|
1411
|
+
for (let c = 0; c < i.length; c += 1) {
|
|
1412
|
+
const d = i[c], { id: l } = d;
|
|
1413
|
+
let u;
|
|
1414
|
+
typeof l == "string" && (u = n.get(l)), u || (u = o.get(c)), u && (d.customData = Kt._cloneCustomData({ customData: u }));
|
|
1415
|
+
}
|
|
1416
|
+
}
|
|
1417
|
+
/**
|
|
1418
|
+
* Делает глубокую копию customData, чтобы избежать общих ссылок со state.
|
|
1419
|
+
* @param customData - пользовательские данные объекта
|
|
1420
|
+
*/
|
|
1421
|
+
static _cloneCustomData({ customData: t }) {
|
|
1422
|
+
return JSON.parse(JSON.stringify(t));
|
|
1423
|
+
}
|
|
1371
1424
|
/**
|
|
1372
1425
|
* Функция загрузки состояния в канвас.
|
|
1373
1426
|
* @param fullState - полное состояние канваса
|
|
1374
1427
|
* @fires editor:history-state-loaded
|
|
1375
1428
|
*/
|
|
1376
1429
|
loadStateFromFullState(t) {
|
|
1377
|
-
return
|
|
1430
|
+
return z(this, null, function* () {
|
|
1378
1431
|
if (!t) return;
|
|
1379
1432
|
console.log("loadStateFromFullState fullState", t);
|
|
1380
1433
|
const { canvas: e, canvasManager: s, interactionBlocker: n, backgroundManager: o } = this.editor, { width: i, height: a } = e;
|
|
1381
|
-
n.overlayMask = null
|
|
1382
|
-
const r =
|
|
1383
|
-
|
|
1384
|
-
const c = e.getObjects().find((
|
|
1385
|
-
c && (
|
|
1386
|
-
const d = e.getObjects().find((
|
|
1387
|
-
d
|
|
1434
|
+
n.overlayMask = null;
|
|
1435
|
+
const r = Kt._createLoadSafeState({ state: t });
|
|
1436
|
+
yield e.loadFromJSON(r), Kt._applyCustomDataFromState({ state: t, canvas: e });
|
|
1437
|
+
const c = e.getObjects().find((u) => u.id === "montage-area");
|
|
1438
|
+
c && (this.editor.montageArea = c, (i !== e.getWidth() || a !== e.getHeight()) && s.updateCanvas());
|
|
1439
|
+
const d = e.getObjects().find((u) => u.id === "overlay-mask");
|
|
1440
|
+
d && (n.overlayMask = d, n.overlayMask.visible = !1);
|
|
1441
|
+
const l = e.getObjects().find((u) => u.id === "background");
|
|
1442
|
+
l ? (o.backgroundObject = l, o.refresh()) : o.removeBackground({ withoutSave: !0 }), e.renderAll(), e.fire("editor:history-state-loaded", {
|
|
1388
1443
|
fullState: t,
|
|
1389
1444
|
currentIndex: this.currentIndex,
|
|
1390
1445
|
totalChangesCount: this.totalChangesCount,
|
|
@@ -1399,7 +1454,7 @@ class Ys {
|
|
|
1399
1454
|
* @fires editor:undo
|
|
1400
1455
|
*/
|
|
1401
1456
|
undo() {
|
|
1402
|
-
return
|
|
1457
|
+
return z(this, null, function* () {
|
|
1403
1458
|
if (!this.skipHistory) {
|
|
1404
1459
|
if (this.saveState(), this.currentIndex <= 0) {
|
|
1405
1460
|
console.log("Нет предыдущих состояний для отмены.");
|
|
@@ -1436,7 +1491,7 @@ class Ys {
|
|
|
1436
1491
|
* @fires editor:redo
|
|
1437
1492
|
*/
|
|
1438
1493
|
redo() {
|
|
1439
|
-
return
|
|
1494
|
+
return z(this, null, function* () {
|
|
1440
1495
|
if (!this.skipHistory) {
|
|
1441
1496
|
if (this.saveState(), this.currentIndex >= this.patches.length) {
|
|
1442
1497
|
console.log("Нет состояний для повтора.");
|
|
@@ -1491,7 +1546,7 @@ class Ys {
|
|
|
1491
1546
|
}
|
|
1492
1547
|
}
|
|
1493
1548
|
}
|
|
1494
|
-
const Hs = 0.1, Zs = 2,
|
|
1549
|
+
const Hs = 0.1, Zs = 2, Ze = 0.1, Gs = 90, Rt = 16, _t = 16, At = 4096, jt = 4096, Ge = "application/image-editor:", ie = [
|
|
1495
1550
|
"format",
|
|
1496
1551
|
"uppercase",
|
|
1497
1552
|
"textCaseRaw",
|
|
@@ -1506,7 +1561,7 @@ const Hs = 0.1, Zs = 2, Ye = 0.1, Gs = 90, Rt = 16, _t = 16, St = 4096, At = 409
|
|
|
1506
1561
|
"radiusBottomRight",
|
|
1507
1562
|
"radiusBottomLeft"
|
|
1508
1563
|
], Vs = 50;
|
|
1509
|
-
class
|
|
1564
|
+
class ht {
|
|
1510
1565
|
constructor({ editor: t }) {
|
|
1511
1566
|
this.editor = t, this.options = t.options, this._createdBlobUrls = [], this.acceptContentTypes = this.editor.options.acceptContentTypes, this.acceptFormats = this.getAllowedFormatsFromContentTypes();
|
|
1512
1567
|
}
|
|
@@ -1523,7 +1578,7 @@ class dt {
|
|
|
1523
1578
|
* @returns возвращает Promise с объектом изображения или null в случае ошибки
|
|
1524
1579
|
*/
|
|
1525
1580
|
importImage(t) {
|
|
1526
|
-
return
|
|
1581
|
+
return z(this, null, function* () {
|
|
1527
1582
|
const {
|
|
1528
1583
|
source: e,
|
|
1529
1584
|
scale: s = `image-${this.options.scaleType}`,
|
|
@@ -1531,110 +1586,115 @@ class dt {
|
|
|
1531
1586
|
fromClipboard: o = !1,
|
|
1532
1587
|
isBackground: i = !1,
|
|
1533
1588
|
withoutSelection: a = !1,
|
|
1534
|
-
withoutAdding: r = !1
|
|
1589
|
+
withoutAdding: r = !1,
|
|
1590
|
+
customData: c = null
|
|
1535
1591
|
} = t;
|
|
1536
1592
|
if (!e) return null;
|
|
1537
|
-
const { canvas:
|
|
1538
|
-
if (!this.isAllowedContentType(
|
|
1539
|
-
const
|
|
1540
|
-
return
|
|
1593
|
+
const { canvas: d, montageArea: l, transformManager: u, historyManager: f, errorManager: g } = this.editor, p = yield this.getContentType(e), m = ht.getFormatFromContentType(p), { acceptContentTypes: v, acceptFormats: S } = this;
|
|
1594
|
+
if (!this.isAllowedContentType(p)) {
|
|
1595
|
+
const A = `Неверный contentType для изображения: ${p}. Ожидается один из: ${this.acceptContentTypes.join(", ")}.`;
|
|
1596
|
+
return g.emitError({
|
|
1541
1597
|
origin: "ImageManager",
|
|
1542
1598
|
method: "importImage",
|
|
1543
1599
|
code: "INVALID_CONTENT_TYPE",
|
|
1544
|
-
message:
|
|
1600
|
+
message: A,
|
|
1545
1601
|
data: {
|
|
1546
1602
|
source: e,
|
|
1547
|
-
format:
|
|
1548
|
-
contentType:
|
|
1549
|
-
acceptContentTypes:
|
|
1550
|
-
acceptFormats:
|
|
1603
|
+
format: m,
|
|
1604
|
+
contentType: p,
|
|
1605
|
+
acceptContentTypes: v,
|
|
1606
|
+
acceptFormats: S,
|
|
1551
1607
|
fromClipboard: o,
|
|
1552
1608
|
isBackground: i,
|
|
1553
1609
|
withoutSelection: a,
|
|
1554
|
-
withoutAdding: r
|
|
1610
|
+
withoutAdding: r,
|
|
1611
|
+
customData: c
|
|
1555
1612
|
}
|
|
1556
1613
|
}), null;
|
|
1557
1614
|
}
|
|
1558
|
-
|
|
1615
|
+
f.suspendHistory();
|
|
1559
1616
|
try {
|
|
1560
|
-
let
|
|
1617
|
+
let A, y;
|
|
1561
1618
|
if (e instanceof File)
|
|
1562
|
-
|
|
1619
|
+
A = URL.createObjectURL(e);
|
|
1563
1620
|
else if (typeof e == "string") {
|
|
1564
|
-
const
|
|
1565
|
-
|
|
1621
|
+
const T = yield (yield fetch(e, { mode: "cors" })).blob();
|
|
1622
|
+
A = URL.createObjectURL(T);
|
|
1566
1623
|
} else
|
|
1567
|
-
return
|
|
1624
|
+
return g.emitError({
|
|
1568
1625
|
origin: "ImageManager",
|
|
1569
1626
|
method: "importImage",
|
|
1570
1627
|
code: "INVALID_SOURCE_TYPE",
|
|
1571
1628
|
message: "Неверный тип источника изображения. Ожидается URL или объект File.",
|
|
1572
1629
|
data: {
|
|
1573
1630
|
source: e,
|
|
1574
|
-
format:
|
|
1575
|
-
contentType:
|
|
1576
|
-
acceptContentTypes:
|
|
1577
|
-
acceptFormats:
|
|
1631
|
+
format: m,
|
|
1632
|
+
contentType: p,
|
|
1633
|
+
acceptContentTypes: v,
|
|
1634
|
+
acceptFormats: S,
|
|
1578
1635
|
fromClipboard: o,
|
|
1579
1636
|
isBackground: i,
|
|
1580
1637
|
withoutSelection: a,
|
|
1581
|
-
withoutAdding: r
|
|
1638
|
+
withoutAdding: r,
|
|
1639
|
+
customData: c
|
|
1582
1640
|
}
|
|
1583
1641
|
}), null;
|
|
1584
|
-
if (this._createdBlobUrls.push(
|
|
1585
|
-
const
|
|
1586
|
-
|
|
1642
|
+
if (this._createdBlobUrls.push(A), m === "svg") {
|
|
1643
|
+
const w = yield us(A);
|
|
1644
|
+
y = ut.groupSVGElements(w.objects, w.options);
|
|
1587
1645
|
} else
|
|
1588
|
-
|
|
1589
|
-
const { width:
|
|
1590
|
-
if (
|
|
1591
|
-
const
|
|
1592
|
-
let
|
|
1593
|
-
if (
|
|
1594
|
-
const
|
|
1595
|
-
this._createdBlobUrls.push(
|
|
1596
|
-
} else if (
|
|
1597
|
-
const
|
|
1598
|
-
this._createdBlobUrls.push(
|
|
1646
|
+
y = yield Zt.fromURL(A, { crossOrigin: "anonymous" });
|
|
1647
|
+
const { width: b, height: j } = y;
|
|
1648
|
+
if (y instanceof Zt) {
|
|
1649
|
+
const w = y.getElement();
|
|
1650
|
+
let T = "";
|
|
1651
|
+
if (w instanceof HTMLImageElement ? T = w.src : w instanceof HTMLCanvasElement && (T = w.toDataURL()), j > jt || b > At) {
|
|
1652
|
+
const M = yield this.resizeImageToBoundaries(T, "max"), C = URL.createObjectURL(M);
|
|
1653
|
+
this._createdBlobUrls.push(C), y = yield Zt.fromURL(C, { crossOrigin: "anonymous" });
|
|
1654
|
+
} else if (j < _t || b < Rt) {
|
|
1655
|
+
const M = yield this.resizeImageToBoundaries(T, "min"), C = URL.createObjectURL(M);
|
|
1656
|
+
this._createdBlobUrls.push(C), y = yield Zt.fromURL(C, { crossOrigin: "anonymous" });
|
|
1599
1657
|
}
|
|
1600
1658
|
}
|
|
1601
|
-
if (
|
|
1602
|
-
this.editor.canvasManager.scaleMontageAreaToImage({ object:
|
|
1659
|
+
if (y.set("id", `${y.type}-${V()}`), y.set("format", m), y.set("customData", c || null), s === "scale-montage")
|
|
1660
|
+
this.editor.canvasManager.scaleMontageAreaToImage({ object: y, withoutSave: !0 });
|
|
1603
1661
|
else {
|
|
1604
|
-
const { width:
|
|
1605
|
-
s === "image-contain" &&
|
|
1662
|
+
const { width: w, height: T } = l, M = this.calculateScaleFactor({ imageObject: y, scaleType: s });
|
|
1663
|
+
s === "image-contain" && M < 1 ? u.fitObject({ object: y, type: "contain", withoutSave: !0 }) : s === "image-cover" && (b > w || j > T) && u.fitObject({ object: y, type: "cover", withoutSave: !0 });
|
|
1606
1664
|
}
|
|
1607
1665
|
const I = {
|
|
1608
|
-
image:
|
|
1609
|
-
format:
|
|
1610
|
-
contentType:
|
|
1666
|
+
image: y,
|
|
1667
|
+
format: m,
|
|
1668
|
+
contentType: p,
|
|
1611
1669
|
scale: s,
|
|
1612
1670
|
withoutSave: n,
|
|
1613
1671
|
source: e,
|
|
1614
1672
|
fromClipboard: o,
|
|
1615
1673
|
isBackground: i,
|
|
1616
1674
|
withoutSelection: a,
|
|
1617
|
-
withoutAdding: r
|
|
1675
|
+
withoutAdding: r,
|
|
1676
|
+
customData: c
|
|
1618
1677
|
};
|
|
1619
|
-
return r ? (
|
|
1620
|
-
} catch (
|
|
1621
|
-
return
|
|
1678
|
+
return r ? (f.resumeHistory(), d.fire("editor:image-imported", I), I) : (d.add(y), d.centerObject(y), a || d.setActiveObject(y), d.renderAll(), f.resumeHistory(), n || f.saveState(), d.fire("editor:image-imported", I), I);
|
|
1679
|
+
} catch (A) {
|
|
1680
|
+
return g.emitError({
|
|
1622
1681
|
origin: "ImageManager",
|
|
1623
1682
|
method: "importImage",
|
|
1624
1683
|
code: "IMPORT_FAILED",
|
|
1625
|
-
message: `Ошибка импорта изображения: ${
|
|
1684
|
+
message: `Ошибка импорта изображения: ${A.message}`,
|
|
1626
1685
|
data: {
|
|
1627
1686
|
source: e,
|
|
1628
|
-
format:
|
|
1629
|
-
contentType:
|
|
1687
|
+
format: m,
|
|
1688
|
+
contentType: p,
|
|
1630
1689
|
scale: s,
|
|
1631
1690
|
withoutSave: n,
|
|
1632
1691
|
fromClipboard: o,
|
|
1633
1692
|
isBackground: i,
|
|
1634
1693
|
withoutSelection: a,
|
|
1635
|
-
withoutAdding: r
|
|
1694
|
+
withoutAdding: r,
|
|
1695
|
+
customData: c
|
|
1636
1696
|
}
|
|
1637
|
-
}),
|
|
1697
|
+
}), f.resumeHistory(), null;
|
|
1638
1698
|
}
|
|
1639
1699
|
});
|
|
1640
1700
|
}
|
|
@@ -1647,14 +1707,14 @@ class dt {
|
|
|
1647
1707
|
* @returns возвращает Promise с Blob-объектом уменьшенного изображения
|
|
1648
1708
|
*/
|
|
1649
1709
|
resizeImageToBoundaries(t, e = "max") {
|
|
1650
|
-
return
|
|
1651
|
-
let s = `Размер изображения больше максимального размера канваса, поэтому оно будет уменьшено до максимальных размеров c сохранением пропорций: ${
|
|
1710
|
+
return z(this, null, function* () {
|
|
1711
|
+
let s = `Размер изображения больше максимального размера канваса, поэтому оно будет уменьшено до максимальных размеров c сохранением пропорций: ${At}x${jt}`;
|
|
1652
1712
|
e === "min" && (s = `Размер изображения меньше минимального размера канваса, поэтому оно будет увеличено до минимальных размеров c сохранением пропорций: ${Rt}x${_t}`);
|
|
1653
1713
|
const n = {
|
|
1654
1714
|
dataURL: t,
|
|
1655
1715
|
sizeType: e,
|
|
1656
|
-
maxWidth:
|
|
1657
|
-
maxHeight:
|
|
1716
|
+
maxWidth: At,
|
|
1717
|
+
maxHeight: jt,
|
|
1658
1718
|
minWidth: Rt,
|
|
1659
1719
|
minHeight: _t
|
|
1660
1720
|
};
|
|
@@ -1679,7 +1739,7 @@ class dt {
|
|
|
1679
1739
|
* @fires editor:canvas-exported
|
|
1680
1740
|
*/
|
|
1681
1741
|
exportCanvasAsImageFile() {
|
|
1682
|
-
return
|
|
1742
|
+
return z(this, arguments, function* (t = {}) {
|
|
1683
1743
|
const {
|
|
1684
1744
|
fileName: e = "image.png",
|
|
1685
1745
|
contentType: s = "image/png",
|
|
@@ -1687,22 +1747,22 @@ class dt {
|
|
|
1687
1747
|
exportAsBlob: o = !1
|
|
1688
1748
|
} = t, { canvas: i, montageArea: a, workerManager: r, interactionBlocker: c } = this.editor;
|
|
1689
1749
|
try {
|
|
1690
|
-
const d = s === "application/pdf", l = d ? "image/jpg" : s, u =
|
|
1750
|
+
const d = s === "application/pdf", l = d ? "image/jpg" : s, u = ht.getFormatFromContentType(l);
|
|
1691
1751
|
a.setCoords();
|
|
1692
1752
|
const { left: f, top: g, width: p, height: m } = a.getBoundingRect(), v = yield i.clone(["id", "format", "locked"]);
|
|
1693
1753
|
v.enableRetinaScaling = !1, ["image/jpg", "image/jpeg"].includes(l) && (v.backgroundColor = "#ffffff");
|
|
1694
|
-
const
|
|
1695
|
-
if (
|
|
1696
|
-
const
|
|
1697
|
-
|
|
1754
|
+
const S = v.getObjects().find((M) => M.id === a.id);
|
|
1755
|
+
if (S && (S.visible = !1), c != null && c.isBlocked) {
|
|
1756
|
+
const M = v.getObjects().find((C) => C.id === c.overlayMask.id);
|
|
1757
|
+
M && (M.visible = !1);
|
|
1698
1758
|
}
|
|
1699
1759
|
v.viewportTransform = [1, 0, 0, 1, -f, -g], v.setDimensions({ width: p, height: m }, { backstoreOnly: !0 }), v.renderAll();
|
|
1700
|
-
const
|
|
1701
|
-
if (u === "svg" &&
|
|
1702
|
-
const
|
|
1760
|
+
const A = v.getObjects().filter((M) => M.format).every((M) => M.format === "svg");
|
|
1761
|
+
if (u === "svg" && A) {
|
|
1762
|
+
const M = v.toSVG();
|
|
1703
1763
|
v.dispose();
|
|
1704
1764
|
const E = {
|
|
1705
|
-
image:
|
|
1765
|
+
image: ht._exportSVGStringAsFile(M, {
|
|
1706
1766
|
exportAsBase64: n,
|
|
1707
1767
|
exportAsBlob: o,
|
|
1708
1768
|
fileName: e
|
|
@@ -1713,64 +1773,64 @@ class dt {
|
|
|
1713
1773
|
};
|
|
1714
1774
|
return i.fire("editor:canvas-exported", E), E;
|
|
1715
1775
|
}
|
|
1716
|
-
const y = yield new Promise((
|
|
1776
|
+
const y = yield new Promise((M, C) => {
|
|
1717
1777
|
v.getElement().toBlob((E) => {
|
|
1718
|
-
E ?
|
|
1778
|
+
E ? M(E) : C(new Error("Failed to create Blob from canvas"));
|
|
1719
1779
|
});
|
|
1720
1780
|
});
|
|
1721
1781
|
if (v.dispose(), o) {
|
|
1722
|
-
const
|
|
1782
|
+
const M = {
|
|
1723
1783
|
image: y,
|
|
1724
1784
|
format: u,
|
|
1725
1785
|
contentType: l,
|
|
1726
1786
|
fileName: e
|
|
1727
1787
|
};
|
|
1728
|
-
return i.fire("editor:canvas-exported",
|
|
1788
|
+
return i.fire("editor:canvas-exported", M), M;
|
|
1729
1789
|
}
|
|
1730
|
-
const b = yield createImageBitmap(y),
|
|
1790
|
+
const b = yield createImageBitmap(y), j = yield r.post(
|
|
1731
1791
|
"toDataURL",
|
|
1732
1792
|
{ format: u, quality: 1, bitmap: b },
|
|
1733
1793
|
[b]
|
|
1734
1794
|
);
|
|
1735
1795
|
if (d) {
|
|
1736
|
-
const
|
|
1737
|
-
orientation:
|
|
1796
|
+
const C = p * 0.264583, E = m * 0.264583, W = (yield this.editor.moduleLoader.loadModule("jspdf")).jsPDF, N = new W({
|
|
1797
|
+
orientation: C > E ? "landscape" : "portrait",
|
|
1738
1798
|
unit: "mm",
|
|
1739
|
-
format: [
|
|
1799
|
+
format: [C, E]
|
|
1740
1800
|
});
|
|
1741
|
-
if (
|
|
1742
|
-
const
|
|
1743
|
-
image:
|
|
1801
|
+
if (N.addImage(String(j), "JPG", 0, 0, C, E), n) {
|
|
1802
|
+
const H = {
|
|
1803
|
+
image: N.output("datauristring"),
|
|
1744
1804
|
format: "pdf",
|
|
1745
1805
|
contentType: "application/pdf",
|
|
1746
1806
|
fileName: e
|
|
1747
1807
|
};
|
|
1748
|
-
return i.fire("editor:canvas-exported",
|
|
1808
|
+
return i.fire("editor:canvas-exported", H), H;
|
|
1749
1809
|
}
|
|
1750
|
-
const
|
|
1751
|
-
image: new File([
|
|
1810
|
+
const x = N.output("blob"), G = {
|
|
1811
|
+
image: new File([x], e, { type: "application/pdf" }),
|
|
1752
1812
|
format: "pdf",
|
|
1753
1813
|
contentType: "application/pdf",
|
|
1754
1814
|
fileName: e
|
|
1755
1815
|
};
|
|
1756
|
-
return i.fire("editor:canvas-exported",
|
|
1816
|
+
return i.fire("editor:canvas-exported", G), G;
|
|
1757
1817
|
}
|
|
1758
1818
|
if (n) {
|
|
1759
|
-
const
|
|
1760
|
-
image:
|
|
1819
|
+
const M = {
|
|
1820
|
+
image: j,
|
|
1761
1821
|
format: u,
|
|
1762
1822
|
contentType: l,
|
|
1763
1823
|
fileName: e
|
|
1764
1824
|
};
|
|
1765
|
-
return i.fire("editor:canvas-exported",
|
|
1825
|
+
return i.fire("editor:canvas-exported", M), M;
|
|
1766
1826
|
}
|
|
1767
|
-
const
|
|
1768
|
-
image: new File([y],
|
|
1827
|
+
const I = u === "svg" && !A ? e.replace(/\.[^/.]+$/, ".png") : e, T = {
|
|
1828
|
+
image: new File([y], I, { type: l }),
|
|
1769
1829
|
format: u,
|
|
1770
1830
|
contentType: l,
|
|
1771
|
-
fileName:
|
|
1831
|
+
fileName: I
|
|
1772
1832
|
};
|
|
1773
|
-
return i.fire("editor:canvas-exported",
|
|
1833
|
+
return i.fire("editor:canvas-exported", T), T;
|
|
1774
1834
|
} catch (d) {
|
|
1775
1835
|
return this.editor.errorManager.emitError({
|
|
1776
1836
|
origin: "ImageManager",
|
|
@@ -1794,7 +1854,7 @@ class dt {
|
|
|
1794
1854
|
* @fires editor:object-exported
|
|
1795
1855
|
*/
|
|
1796
1856
|
exportObjectAsImageFile() {
|
|
1797
|
-
return
|
|
1857
|
+
return z(this, arguments, function* (t = {}) {
|
|
1798
1858
|
const {
|
|
1799
1859
|
object: e,
|
|
1800
1860
|
fileName: s = "image.png",
|
|
@@ -1811,9 +1871,9 @@ class dt {
|
|
|
1811
1871
|
data: { contentType: n, fileName: s, exportAsBase64: o, exportAsBlob: i }
|
|
1812
1872
|
}), null;
|
|
1813
1873
|
try {
|
|
1814
|
-
const d =
|
|
1874
|
+
const d = ht.getFormatFromContentType(n);
|
|
1815
1875
|
if (d === "svg") {
|
|
1816
|
-
const p = c.toSVG(), m =
|
|
1876
|
+
const p = c.toSVG(), m = ht._exportSVGStringAsFile(p, {
|
|
1817
1877
|
exportAsBase64: o,
|
|
1818
1878
|
exportAsBlob: i,
|
|
1819
1879
|
fileName: s
|
|
@@ -1826,7 +1886,7 @@ class dt {
|
|
|
1826
1886
|
};
|
|
1827
1887
|
return a.fire("editor:object-exported", v), v;
|
|
1828
1888
|
}
|
|
1829
|
-
if (o && c instanceof
|
|
1889
|
+
if (o && c instanceof Zt) {
|
|
1830
1890
|
const p = yield createImageBitmap(c.getElement()), m = yield r.post(
|
|
1831
1891
|
"toDataURL",
|
|
1832
1892
|
{
|
|
@@ -1891,7 +1951,7 @@ class dt {
|
|
|
1891
1951
|
* @returns массив допустимых форматов изображений
|
|
1892
1952
|
*/
|
|
1893
1953
|
getAllowedFormatsFromContentTypes() {
|
|
1894
|
-
return this.acceptContentTypes.map((t) =>
|
|
1954
|
+
return this.acceptContentTypes.map((t) => ht.getFormatFromContentType(t)).filter((t) => t);
|
|
1895
1955
|
}
|
|
1896
1956
|
/**
|
|
1897
1957
|
* Проверяет, является ли contentType допустимым типом изображения.
|
|
@@ -1907,7 +1967,7 @@ class dt {
|
|
|
1907
1967
|
* @public
|
|
1908
1968
|
*/
|
|
1909
1969
|
getContentType(t) {
|
|
1910
|
-
return
|
|
1970
|
+
return z(this, null, function* () {
|
|
1911
1971
|
return typeof t == "string" ? this.getContentTypeFromUrl(t) : t.type || "application/octet-stream";
|
|
1912
1972
|
});
|
|
1913
1973
|
}
|
|
@@ -1918,7 +1978,7 @@ class dt {
|
|
|
1918
1978
|
* @public
|
|
1919
1979
|
*/
|
|
1920
1980
|
getContentTypeFromUrl(t) {
|
|
1921
|
-
return
|
|
1981
|
+
return z(this, null, function* () {
|
|
1922
1982
|
if (t.startsWith("data:")) {
|
|
1923
1983
|
const e = t.match(/^data:([^;]+)/);
|
|
1924
1984
|
return e ? e[1] : "application/octet-stream";
|
|
@@ -1944,7 +2004,7 @@ class dt {
|
|
|
1944
2004
|
try {
|
|
1945
2005
|
const n = (e = new URL(t).pathname.split(".").pop()) == null ? void 0 : e.toLowerCase(), o = {};
|
|
1946
2006
|
return this.acceptContentTypes.forEach((i) => {
|
|
1947
|
-
const a =
|
|
2007
|
+
const a = ht.getFormatFromContentType(i);
|
|
1948
2008
|
a && (o[a] = i);
|
|
1949
2009
|
}), n && o[n] || "application/octet-stream";
|
|
1950
2010
|
} catch (s) {
|
|
@@ -1997,7 +2057,7 @@ class dt {
|
|
|
1997
2057
|
return e ? e[1] : "";
|
|
1998
2058
|
}
|
|
1999
2059
|
}
|
|
2000
|
-
const
|
|
2060
|
+
const pt = (h, t, e) => Math.max(Math.min(h, e), t), Ve = (h, t) => h * t, Xs = (h, t) => new tt(h / 2, t / 2);
|
|
2001
2061
|
function Ks(h) {
|
|
2002
2062
|
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";
|
|
2003
2063
|
}
|
|
@@ -2021,11 +2081,11 @@ class Qs {
|
|
|
2021
2081
|
* Если точка находится за пределами монтажной области, она проецируется на ближайшую границу монтажной области.
|
|
2022
2082
|
*/
|
|
2023
2083
|
getVisibleCenterPoint() {
|
|
2024
|
-
const { canvas: t, montageArea: e } = this.editor, s = t.getZoom(), n = t.viewportTransform, o = t.getWidth(), i = t.getHeight(), a = (o / 2 - n[4]) / s, r = (i / 2 - n[5]) / s, c = e.width / 2, d = e.height / 2, l =
|
|
2084
|
+
const { canvas: t, montageArea: e } = this.editor, s = t.getZoom(), n = t.viewportTransform, o = t.getWidth(), i = t.getHeight(), a = (o / 2 - n[4]) / s, r = (i / 2 - n[5]) / s, c = e.width / 2, d = e.height / 2, l = pt(
|
|
2025
2085
|
a,
|
|
2026
2086
|
e.left - c,
|
|
2027
2087
|
e.left + c
|
|
2028
|
-
), u =
|
|
2088
|
+
), u = pt(
|
|
2029
2089
|
r,
|
|
2030
2090
|
e.top - d,
|
|
2031
2091
|
e.top + d
|
|
@@ -2048,9 +2108,9 @@ class Qs {
|
|
|
2048
2108
|
canvas: o,
|
|
2049
2109
|
montageArea: i,
|
|
2050
2110
|
options: { canvasBackstoreWidth: a }
|
|
2051
|
-
} = this.editor, { width: r, height: c } = i, d =
|
|
2111
|
+
} = this.editor, { width: r, height: c } = i, d = pt(Number(t), Rt, At);
|
|
2052
2112
|
if (!a || a === "auto" || n ? this.adaptCanvasToContainer() : a ? this.setCanvasBackstoreWidth(Number(a)) : this.setCanvasBackstoreWidth(d), i.set({ width: d }), (g = o.clipPath) == null || g.set({ width: d }), e) {
|
|
2053
|
-
const p = d / r, m =
|
|
2113
|
+
const p = d / r, m = Ve(c, p);
|
|
2054
2114
|
this.setResolutionHeight(m);
|
|
2055
2115
|
return;
|
|
2056
2116
|
}
|
|
@@ -2078,9 +2138,9 @@ class Qs {
|
|
|
2078
2138
|
canvas: o,
|
|
2079
2139
|
montageArea: i,
|
|
2080
2140
|
options: { canvasBackstoreHeight: a }
|
|
2081
|
-
} = this.editor, { width: r, height: c } = i, d =
|
|
2141
|
+
} = this.editor, { width: r, height: c } = i, d = pt(Number(t), _t, jt);
|
|
2082
2142
|
if (!a || a === "auto" || n ? this.adaptCanvasToContainer() : a ? this.setCanvasBackstoreHeight(Number(a)) : this.setCanvasBackstoreHeight(d), i.set({ height: d }), (g = o.clipPath) == null || g.set({ height: d }), e) {
|
|
2083
|
-
const p = d / c, m =
|
|
2143
|
+
const p = d / c, m = Ve(r, p);
|
|
2084
2144
|
this.setResolutionWidth(m);
|
|
2085
2145
|
return;
|
|
2086
2146
|
}
|
|
@@ -2131,7 +2191,7 @@ class Qs {
|
|
|
2131
2191
|
*/
|
|
2132
2192
|
setCanvasBackstoreWidth(t) {
|
|
2133
2193
|
if (!t || typeof t != "number") return;
|
|
2134
|
-
const e =
|
|
2194
|
+
const e = pt(t, Rt, At);
|
|
2135
2195
|
this.editor.canvas.setDimensions({ width: e }, { backstoreOnly: !0 });
|
|
2136
2196
|
}
|
|
2137
2197
|
/**
|
|
@@ -2140,7 +2200,7 @@ class Qs {
|
|
|
2140
2200
|
*/
|
|
2141
2201
|
setCanvasBackstoreHeight(t) {
|
|
2142
2202
|
if (!t || typeof t != "number") return;
|
|
2143
|
-
const e =
|
|
2203
|
+
const e = pt(t, _t, jt);
|
|
2144
2204
|
this.editor.canvas.setDimensions({ height: e }, { backstoreOnly: !0 });
|
|
2145
2205
|
}
|
|
2146
2206
|
/**
|
|
@@ -2149,7 +2209,7 @@ class Qs {
|
|
|
2149
2209
|
* с учётом минимальных и максимальных значений.
|
|
2150
2210
|
*/
|
|
2151
2211
|
adaptCanvasToContainer() {
|
|
2152
|
-
const { canvas: t } = this.editor, e = this.getEditorContainer(), s = e.clientWidth, n = e.clientHeight, o =
|
|
2212
|
+
const { canvas: t } = this.editor, e = this.getEditorContainer(), s = e.clientWidth, n = e.clientHeight, o = pt(s, Rt, At), i = pt(n, _t, jt);
|
|
2153
2213
|
t.setDimensions({ width: o, height: i }, { backstoreOnly: !0 });
|
|
2154
2214
|
}
|
|
2155
2215
|
/**
|
|
@@ -2351,13 +2411,13 @@ class Qs {
|
|
|
2351
2411
|
} = this.editor, c = t || n.getActiveObject();
|
|
2352
2412
|
if (!Ks(c)) return;
|
|
2353
2413
|
const { width: d, height: l } = c;
|
|
2354
|
-
let u = Math.min(d,
|
|
2414
|
+
let u = Math.min(d, At), f = Math.min(l, jt);
|
|
2355
2415
|
if (e) {
|
|
2356
2416
|
const {
|
|
2357
2417
|
width: g,
|
|
2358
2418
|
height: p
|
|
2359
|
-
} = o, m = d / g, v = l / p,
|
|
2360
|
-
u = g *
|
|
2419
|
+
} = o, m = d / g, v = l / p, S = Math.max(m, v);
|
|
2420
|
+
u = g * S, f = p * S;
|
|
2361
2421
|
}
|
|
2362
2422
|
this.setResolutionWidth(u, { withoutSave: !0 }), this.setResolutionHeight(f, { withoutSave: !0 }), this.editor.backgroundManager.backgroundObject && this.editor.backgroundManager.refresh(), (d > a || l > r) && this.editor.zoomManager.calculateAndApplyDefaultZoom(), i.resetObject({ object: c, withoutSave: !0 }), n.centerObject(c), n.renderAll(), s || this.editor.historyManager.saveState(), n.fire("editor:montage-area-scaled-to-image", {
|
|
2363
2423
|
object: c,
|
|
@@ -2409,7 +2469,7 @@ class Qs {
|
|
|
2409
2469
|
);
|
|
2410
2470
|
}
|
|
2411
2471
|
}
|
|
2412
|
-
class
|
|
2472
|
+
class Js {
|
|
2413
2473
|
constructor({ editor: t }) {
|
|
2414
2474
|
this.editor = t, this.options = t.options;
|
|
2415
2475
|
}
|
|
@@ -2521,11 +2581,11 @@ class qs {
|
|
|
2521
2581
|
* @private
|
|
2522
2582
|
*/
|
|
2523
2583
|
_fitSingleObject(t, e) {
|
|
2524
|
-
const { canvas: s, montageArea: n } = this.editor, { width: o, height: i, scaleX: a = 1, scaleY: r = 1, angle: c = 0 } = t, d = o * Math.abs(a), l = i * Math.abs(r), u = c * Math.PI / 180, f = Math.abs(Math.cos(u)), g = Math.abs(Math.sin(u)), p = d * f + l * g, m = d * g + l * f, v = n.width,
|
|
2525
|
-
let
|
|
2526
|
-
e === "contain" ?
|
|
2527
|
-
scaleX: a *
|
|
2528
|
-
scaleY: r *
|
|
2584
|
+
const { canvas: s, montageArea: n } = this.editor, { width: o, height: i, scaleX: a = 1, scaleY: r = 1, angle: c = 0 } = t, d = o * Math.abs(a), l = i * Math.abs(r), u = c * Math.PI / 180, f = Math.abs(Math.cos(u)), g = Math.abs(Math.sin(u)), p = d * f + l * g, m = d * g + l * f, v = n.width, S = n.height;
|
|
2585
|
+
let A;
|
|
2586
|
+
e === "contain" ? A = Math.min(v / p, S / m) : A = Math.max(v / p, S / m), t.set({
|
|
2587
|
+
scaleX: a * A,
|
|
2588
|
+
scaleY: r * A
|
|
2529
2589
|
}), s.centerObject(t);
|
|
2530
2590
|
}
|
|
2531
2591
|
/**
|
|
@@ -2575,7 +2635,7 @@ class qs {
|
|
|
2575
2635
|
});
|
|
2576
2636
|
}
|
|
2577
2637
|
}
|
|
2578
|
-
class
|
|
2638
|
+
class qs {
|
|
2579
2639
|
constructor({ editor: t }) {
|
|
2580
2640
|
this.editor = t, this.options = t.options, this.minZoom = this.options.minZoom || Hs, this.maxZoom = this.options.maxZoom || Zs, this.defaultZoom = this._normalizeDefaultZoom(this.options.defaultScale);
|
|
2581
2641
|
}
|
|
@@ -2643,10 +2703,10 @@ class Js {
|
|
|
2643
2703
|
* @private
|
|
2644
2704
|
*/
|
|
2645
2705
|
_calculateEmptySpaceRatio(t) {
|
|
2646
|
-
const { canvas: e, montageArea: s } = this.editor, n = e.viewportTransform, o = e.getWidth(), i = e.getHeight(), a = s.left - s.width / 2, r = s.left + s.width / 2, c = s.top - s.height / 2, d = s.top + s.height / 2, l = -n[4] / t, u = (-n[4] + o) / t, f = -n[5] / t, g = (-n[5] + i) / t, p = l < a, m = u > r, v = f < c,
|
|
2647
|
-
if (!(p || m || v ||
|
|
2648
|
-
const y = Math.max(0, a - l), b = Math.max(0, u - r),
|
|
2649
|
-
return Math.max(
|
|
2706
|
+
const { canvas: e, montageArea: s } = this.editor, n = e.viewportTransform, o = e.getWidth(), i = e.getHeight(), a = s.left - s.width / 2, r = s.left + s.width / 2, c = s.top - s.height / 2, d = s.top + s.height / 2, l = -n[4] / t, u = (-n[4] + o) / t, f = -n[5] / t, g = (-n[5] + i) / t, p = l < a, m = u > r, v = f < c, S = g > d;
|
|
2707
|
+
if (!(p || m || v || S)) return 0;
|
|
2708
|
+
const y = Math.max(0, a - l), b = Math.max(0, u - r), j = Math.max(0, c - f), I = Math.max(0, g - d), w = Math.max(y, b), T = Math.max(j, I), M = w / o, C = T / i;
|
|
2709
|
+
return Math.max(M, C);
|
|
2650
2710
|
}
|
|
2651
2711
|
/**
|
|
2652
2712
|
* Вычисляет плавный шаг перемещения viewport к центру с ускорением
|
|
@@ -2662,8 +2722,8 @@ class Js {
|
|
|
2662
2722
|
const { canvas: i, montageArea: a } = this.editor, r = i.viewportTransform, c = i.getWidth(), d = i.getHeight(), l = t.x - r[4], u = t.y - r[5], f = Math.abs(n), g = e - s;
|
|
2663
2723
|
if (Math.abs(g) / f <= 0.1)
|
|
2664
2724
|
return { x: l, y: u };
|
|
2665
|
-
const m = c / 2, v = d / 2,
|
|
2666
|
-
return { x: E, y:
|
|
2725
|
+
const m = c / 2, v = d / 2, S = a.left, A = a.top, y = m - S * s, b = v - A * s, j = (y - r[4]) / (e - s), I = (b - r[5]) / (e - s), w = j * f, T = I * f, M = w * o, C = T * o, E = Math.abs(M) > Math.abs(l) ? l : M, W = Math.abs(C) > Math.abs(u) ? u : C;
|
|
2726
|
+
return { x: E, y: W };
|
|
2667
2727
|
}
|
|
2668
2728
|
/**
|
|
2669
2729
|
* Применяет плавное центрирование viewport при приближении к defaultZoom.
|
|
@@ -2675,7 +2735,7 @@ class Js {
|
|
|
2675
2735
|
* @returns true если центрирование было применено
|
|
2676
2736
|
* @private
|
|
2677
2737
|
*/
|
|
2678
|
-
_applyViewportCentering(t, e = !1, s =
|
|
2738
|
+
_applyViewportCentering(t, e = !1, s = Ze) {
|
|
2679
2739
|
const { canvas: n } = this.editor, o = this._getScaledMontageDimensions(t), i = n.getWidth(), a = n.getHeight(), r = o.width > i || o.height > a, c = this._calculateFitZoom(), d = t - c;
|
|
2680
2740
|
if (!(!r || d) && !e)
|
|
2681
2741
|
return !1;
|
|
@@ -2750,7 +2810,7 @@ class Js {
|
|
|
2750
2810
|
* @param options.pointY - Координата Y точки зума
|
|
2751
2811
|
* @fires editor:zoom-changed
|
|
2752
2812
|
*/
|
|
2753
|
-
zoom(t =
|
|
2813
|
+
zoom(t = Ze, e = {}) {
|
|
2754
2814
|
var f, g;
|
|
2755
2815
|
if (!t) return;
|
|
2756
2816
|
const { minZoom: s, maxZoom: n } = this, { canvas: o } = this.editor, i = t < 0, a = o.getZoom(), r = o.getCenterPoint(), c = (f = e.pointX) != null ? f : r.x, d = (g = e.pointY) != null ? g : r.y, l = new tt(c, d);
|
|
@@ -3003,7 +3063,7 @@ class Ot {
|
|
|
3003
3063
|
* @param options.withoutSave - Если true, не сохранять состояние в историю
|
|
3004
3064
|
*/
|
|
3005
3065
|
setImageBackground(o) {
|
|
3006
|
-
return
|
|
3066
|
+
return z(this, arguments, function* ({
|
|
3007
3067
|
imageSource: t,
|
|
3008
3068
|
customData: e = {},
|
|
3009
3069
|
fromTemplate: s = !1,
|
|
@@ -3100,7 +3160,7 @@ class Ot {
|
|
|
3100
3160
|
* @param source - источник изображения (URL или File)
|
|
3101
3161
|
*/
|
|
3102
3162
|
_createImageBackground(t, e) {
|
|
3103
|
-
return
|
|
3163
|
+
return z(this, null, function* () {
|
|
3104
3164
|
var n;
|
|
3105
3165
|
const { image: s } = (n = yield this.editor.imageManager.importImage({
|
|
3106
3166
|
source: t,
|
|
@@ -3153,7 +3213,7 @@ class Ot {
|
|
|
3153
3213
|
{ offset: 1, color: "#ffffff" }
|
|
3154
3214
|
], t.type === "linear") {
|
|
3155
3215
|
const u = t.angle * Math.PI / 180, f = Ot._angleToCoords(u);
|
|
3156
|
-
return new
|
|
3216
|
+
return new ze({
|
|
3157
3217
|
type: "linear",
|
|
3158
3218
|
gradientUnits: "percentage",
|
|
3159
3219
|
coords: f,
|
|
@@ -3172,7 +3232,7 @@ class Ot {
|
|
|
3172
3232
|
r1: 0,
|
|
3173
3233
|
r2: d / 100
|
|
3174
3234
|
};
|
|
3175
|
-
return new
|
|
3235
|
+
return new ze({
|
|
3176
3236
|
type: "radial",
|
|
3177
3237
|
gradientUnits: "percentage",
|
|
3178
3238
|
coords: l,
|
|
@@ -3207,7 +3267,7 @@ class Ot {
|
|
|
3207
3267
|
}) ? !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;
|
|
3208
3268
|
}
|
|
3209
3269
|
}
|
|
3210
|
-
class
|
|
3270
|
+
class le {
|
|
3211
3271
|
constructor({ editor: t }) {
|
|
3212
3272
|
this.editor = t;
|
|
3213
3273
|
}
|
|
@@ -3240,7 +3300,7 @@ class te {
|
|
|
3240
3300
|
const { canvas: s, historyManager: n } = this.editor;
|
|
3241
3301
|
n.suspendHistory();
|
|
3242
3302
|
const o = t || s.getActiveObject();
|
|
3243
|
-
o && (o instanceof U ?
|
|
3303
|
+
o && (o instanceof U ? le._moveSelectionForward(s, o) : s.bringObjectForward(o), s.renderAll(), n.resumeHistory(), e || n.saveState(), s.fire("editor:object-bring-forward", {
|
|
3244
3304
|
object: o,
|
|
3245
3305
|
withoutSave: e
|
|
3246
3306
|
}));
|
|
@@ -3291,7 +3351,7 @@ class te {
|
|
|
3291
3351
|
} = this.editor;
|
|
3292
3352
|
o.suspendHistory();
|
|
3293
3353
|
const r = t || s.getActiveObject();
|
|
3294
|
-
r && (r instanceof U ?
|
|
3354
|
+
r && (r instanceof U ? le._moveSelectionBackwards(s, r) : s.sendObjectBackwards(r), a && s.sendObjectToBack(a), s.sendObjectToBack(n), i && s.sendObjectToBack(i), s.renderAll(), o.resumeHistory(), e || o.saveState(), s.fire("editor:object-send-backwards", {
|
|
3295
3355
|
object: r,
|
|
3296
3356
|
withoutSave: e
|
|
3297
3357
|
}));
|
|
@@ -3367,7 +3427,7 @@ class tn {
|
|
|
3367
3427
|
width: n = 100,
|
|
3368
3428
|
height: o = 100,
|
|
3369
3429
|
fill: i = "blue"
|
|
3370
|
-
} = l, a =
|
|
3430
|
+
} = l, a = gt(l, [
|
|
3371
3431
|
"id",
|
|
3372
3432
|
"left",
|
|
3373
3433
|
"top",
|
|
@@ -3375,7 +3435,7 @@ class tn {
|
|
|
3375
3435
|
"height",
|
|
3376
3436
|
"fill"
|
|
3377
3437
|
]);
|
|
3378
|
-
const { canvas: u } = this.editor, f = new
|
|
3438
|
+
const { canvas: u } = this.editor, f = new fs(B({
|
|
3379
3439
|
id: t,
|
|
3380
3440
|
left: e,
|
|
3381
3441
|
top: s,
|
|
@@ -3408,14 +3468,14 @@ class tn {
|
|
|
3408
3468
|
top: s,
|
|
3409
3469
|
radius: n = 50,
|
|
3410
3470
|
fill: o = "green"
|
|
3411
|
-
} = d, i =
|
|
3471
|
+
} = d, i = gt(d, [
|
|
3412
3472
|
"id",
|
|
3413
3473
|
"left",
|
|
3414
3474
|
"top",
|
|
3415
3475
|
"radius",
|
|
3416
3476
|
"fill"
|
|
3417
3477
|
]);
|
|
3418
|
-
const { canvas: l } = this.editor, u = new
|
|
3478
|
+
const { canvas: l } = this.editor, u = new gs(B({
|
|
3419
3479
|
id: t,
|
|
3420
3480
|
left: e,
|
|
3421
3481
|
top: s,
|
|
@@ -3449,7 +3509,7 @@ class tn {
|
|
|
3449
3509
|
width: n = 100,
|
|
3450
3510
|
height: o = 100,
|
|
3451
3511
|
fill: i = "yellow"
|
|
3452
|
-
} = l, a =
|
|
3512
|
+
} = l, a = gt(l, [
|
|
3453
3513
|
"id",
|
|
3454
3514
|
"left",
|
|
3455
3515
|
"top",
|
|
@@ -3457,7 +3517,7 @@ class tn {
|
|
|
3457
3517
|
"height",
|
|
3458
3518
|
"fill"
|
|
3459
3519
|
]);
|
|
3460
|
-
const { canvas: u } = this.editor, f = new
|
|
3520
|
+
const { canvas: u } = this.editor, f = new ps(B({
|
|
3461
3521
|
id: t,
|
|
3462
3522
|
left: e,
|
|
3463
3523
|
top: s,
|
|
@@ -3496,10 +3556,10 @@ class en {
|
|
|
3496
3556
|
* Асинхронное клонирование для внутреннего буфера
|
|
3497
3557
|
*/
|
|
3498
3558
|
_cloneToInternalClipboard(t) {
|
|
3499
|
-
return
|
|
3559
|
+
return z(this, null, function* () {
|
|
3500
3560
|
const { canvas: e, errorManager: s } = this.editor;
|
|
3501
3561
|
try {
|
|
3502
|
-
const n = yield t.clone(
|
|
3562
|
+
const n = yield t.clone(ie);
|
|
3503
3563
|
this.clipboard = n, e.fire("editor:object-copied", { object: n });
|
|
3504
3564
|
} catch (n) {
|
|
3505
3565
|
s.emitError({
|
|
@@ -3516,7 +3576,7 @@ class en {
|
|
|
3516
3576
|
* Копирование в системный буфер обмена
|
|
3517
3577
|
*/
|
|
3518
3578
|
_copyToSystemClipboard(t) {
|
|
3519
|
-
return
|
|
3579
|
+
return z(this, null, function* () {
|
|
3520
3580
|
const { errorManager: e } = this.editor;
|
|
3521
3581
|
if (typeof ClipboardItem == "undefined" || !navigator.clipboard)
|
|
3522
3582
|
return e.emitWarning({
|
|
@@ -3526,7 +3586,7 @@ class en {
|
|
|
3526
3586
|
message: "navigator.clipboard не поддерживается в этом браузере или отсутствует HTTPS-соединение."
|
|
3527
3587
|
}), !1;
|
|
3528
3588
|
try {
|
|
3529
|
-
const s = t.toObject(
|
|
3589
|
+
const s = t.toObject(ie), n = JSON.stringify(s);
|
|
3530
3590
|
return t.type === "image" ? this._copyImageToClipboard(t, n) : this._copyTextToClipboard(n);
|
|
3531
3591
|
} catch (s) {
|
|
3532
3592
|
return e.emitError({
|
|
@@ -3543,7 +3603,7 @@ class en {
|
|
|
3543
3603
|
* Копирование изображения в буфер обмена
|
|
3544
3604
|
*/
|
|
3545
3605
|
_copyImageToClipboard(t, e) {
|
|
3546
|
-
return
|
|
3606
|
+
return z(this, null, function* () {
|
|
3547
3607
|
try {
|
|
3548
3608
|
const n = t.toCanvasElement({ enableRetinaScaling: !1 }).toDataURL(), o = n.slice(5).split(";")[0], i = n.split(",")[1], a = atob(i), r = new Uint8Array(a.length);
|
|
3549
3609
|
for (let l = 0; l < a.length; l += 1)
|
|
@@ -3565,9 +3625,9 @@ class en {
|
|
|
3565
3625
|
* Копирование текста в буфер обмена
|
|
3566
3626
|
*/
|
|
3567
3627
|
_copyTextToClipboard(t) {
|
|
3568
|
-
return
|
|
3628
|
+
return z(this, null, function* () {
|
|
3569
3629
|
try {
|
|
3570
|
-
const e = `${
|
|
3630
|
+
const e = `${Ge}${t}`;
|
|
3571
3631
|
return yield navigator.clipboard.writeText(e), console.info("Text copied to clipboard successfully"), !0;
|
|
3572
3632
|
} catch (e) {
|
|
3573
3633
|
const { errorManager: s } = this.editor;
|
|
@@ -3600,7 +3660,7 @@ class en {
|
|
|
3600
3660
|
* @param source - источник изображения (data URL или URL)
|
|
3601
3661
|
*/
|
|
3602
3662
|
_handleImageImport(t) {
|
|
3603
|
-
return
|
|
3663
|
+
return z(this, null, function* () {
|
|
3604
3664
|
var s;
|
|
3605
3665
|
const { image: e } = (s = yield this.editor.imageManager.importImage({
|
|
3606
3666
|
source: t,
|
|
@@ -3616,11 +3676,11 @@ class en {
|
|
|
3616
3676
|
* @fires editor:object-pasted
|
|
3617
3677
|
*/
|
|
3618
3678
|
copyPaste(t) {
|
|
3619
|
-
return
|
|
3679
|
+
return z(this, null, function* () {
|
|
3620
3680
|
const { canvas: e } = this.editor, s = t || e.getActiveObject();
|
|
3621
3681
|
if (!s || s.locked) return !1;
|
|
3622
3682
|
try {
|
|
3623
|
-
const n = yield s.clone(
|
|
3683
|
+
const n = yield s.clone(ie);
|
|
3624
3684
|
return n instanceof U && n.forEachObject((o) => {
|
|
3625
3685
|
o.set({
|
|
3626
3686
|
id: `${o.type}-${V()}`,
|
|
@@ -3651,14 +3711,14 @@ class en {
|
|
|
3651
3711
|
* @param event.clipboardData.items — элементы буфера обмена
|
|
3652
3712
|
*/
|
|
3653
3713
|
handlePasteEvent(e) {
|
|
3654
|
-
return
|
|
3714
|
+
return z(this, arguments, function* ({ clipboardData: t }) {
|
|
3655
3715
|
var r;
|
|
3656
3716
|
if (!((r = t == null ? void 0 : t.items) != null && r.length)) {
|
|
3657
3717
|
this.paste();
|
|
3658
3718
|
return;
|
|
3659
3719
|
}
|
|
3660
3720
|
const s = t.getData("text/plain");
|
|
3661
|
-
if (s && s.startsWith(
|
|
3721
|
+
if (s && s.startsWith(Ge)) {
|
|
3662
3722
|
this.paste();
|
|
3663
3723
|
return;
|
|
3664
3724
|
}
|
|
@@ -3702,11 +3762,11 @@ class en {
|
|
|
3702
3762
|
* @fires editor:object-pasted
|
|
3703
3763
|
*/
|
|
3704
3764
|
paste() {
|
|
3705
|
-
return
|
|
3765
|
+
return z(this, null, function* () {
|
|
3706
3766
|
const { canvas: t } = this.editor;
|
|
3707
3767
|
if (!this.clipboard) return !1;
|
|
3708
3768
|
try {
|
|
3709
|
-
const e = yield this.clipboard.clone(
|
|
3769
|
+
const e = yield this.clipboard.clone(ie);
|
|
3710
3770
|
return t.discardActiveObject(), e instanceof U && e.forEachObject((s) => {
|
|
3711
3771
|
s.set({
|
|
3712
3772
|
id: `${s.type}-${V()}`,
|
|
@@ -3731,7 +3791,7 @@ class en {
|
|
|
3731
3791
|
});
|
|
3732
3792
|
}
|
|
3733
3793
|
}
|
|
3734
|
-
class
|
|
3794
|
+
class he {
|
|
3735
3795
|
constructor({ editor: t }) {
|
|
3736
3796
|
this.editor = t;
|
|
3737
3797
|
}
|
|
@@ -3757,9 +3817,9 @@ class ee {
|
|
|
3757
3817
|
editable: !1,
|
|
3758
3818
|
locked: !0
|
|
3759
3819
|
};
|
|
3760
|
-
i.set(a), !e &&
|
|
3820
|
+
i.set(a), !e && he._isGroupOrSelection(i) && i.getObjects().forEach((c) => {
|
|
3761
3821
|
c.set(a);
|
|
3762
|
-
}), i instanceof
|
|
3822
|
+
}), i instanceof ot && i.isEditing && i.exitEditing(), n.renderAll(), s || o.saveState(), n.fire("editor:object-locked", {
|
|
3763
3823
|
object: i,
|
|
3764
3824
|
skipInnerObjects: e,
|
|
3765
3825
|
withoutSave: s
|
|
@@ -3786,7 +3846,7 @@ class ee {
|
|
|
3786
3846
|
editable: !0,
|
|
3787
3847
|
locked: !1
|
|
3788
3848
|
};
|
|
3789
|
-
o.set(i),
|
|
3849
|
+
o.set(i), he._isGroupOrSelection(o) && o.getObjects().forEach((a) => {
|
|
3790
3850
|
a.set(i);
|
|
3791
3851
|
}), s.renderAll(), e || n.saveState(), s.fire("editor:object-unlocked", {
|
|
3792
3852
|
object: o,
|
|
@@ -3913,7 +3973,7 @@ class nn {
|
|
|
3913
3973
|
o && s.lockObject({ object: i, skipInnerObjects: !0, withoutSave: !0 }), t.setActiveObject(i), t.requestRenderAll(), t.fire("editor:all-objects-selected", { selected: i });
|
|
3914
3974
|
}
|
|
3915
3975
|
}
|
|
3916
|
-
class
|
|
3976
|
+
class Oe {
|
|
3917
3977
|
constructor({ editor: t }) {
|
|
3918
3978
|
this.editor = t;
|
|
3919
3979
|
}
|
|
@@ -3960,7 +4020,7 @@ class we {
|
|
|
3960
4020
|
s || o.suspendHistory();
|
|
3961
4021
|
const r = [];
|
|
3962
4022
|
if (a.forEach((d) => {
|
|
3963
|
-
if (
|
|
4023
|
+
if (Oe._isUngroupableGroup(d)) {
|
|
3964
4024
|
const l = this._handleGroupDeletion(d);
|
|
3965
4025
|
r.push(...l);
|
|
3966
4026
|
return;
|
|
@@ -3975,7 +4035,7 @@ class we {
|
|
|
3975
4035
|
return n.fire("editor:objects-deleted", c), c;
|
|
3976
4036
|
}
|
|
3977
4037
|
}
|
|
3978
|
-
const
|
|
4038
|
+
const St = {
|
|
3979
4039
|
IMAGE_MANAGER: {
|
|
3980
4040
|
/**
|
|
3981
4041
|
* Некорректный Content-Type изображения
|
|
@@ -4080,7 +4140,7 @@ const wt = {
|
|
|
4080
4140
|
APPLY_FAILED: "TEMPLATE_APPLY_FAILED"
|
|
4081
4141
|
}
|
|
4082
4142
|
};
|
|
4083
|
-
class
|
|
4143
|
+
class Qt {
|
|
4084
4144
|
constructor({ editor: t }) {
|
|
4085
4145
|
this._buffer = [], this.editor = t;
|
|
4086
4146
|
}
|
|
@@ -4107,7 +4167,7 @@ class Wt {
|
|
|
4107
4167
|
* @fires editor:error
|
|
4108
4168
|
*/
|
|
4109
4169
|
emitError({ origin: t = "ImageEditor", method: e = "Unknown Method", code: s, data: n, message: o }) {
|
|
4110
|
-
if (!
|
|
4170
|
+
if (!Qt.isValidErrorCode(s)) {
|
|
4111
4171
|
console.warn("Неизвестный код ошибки: ", { code: s, origin: t, method: e });
|
|
4112
4172
|
return;
|
|
4113
4173
|
}
|
|
@@ -4136,7 +4196,7 @@ class Wt {
|
|
|
4136
4196
|
* @fires editor:warning
|
|
4137
4197
|
*/
|
|
4138
4198
|
emitWarning({ origin: t = "ImageEditor", method: e = "Unknown Method", code: s, message: n, data: o }) {
|
|
4139
|
-
if (!
|
|
4199
|
+
if (!Qt.isValidErrorCode(s)) {
|
|
4140
4200
|
console.warn("Неизвестный код предупреждения: ", { code: s, origin: t, method: e });
|
|
4141
4201
|
return;
|
|
4142
4202
|
}
|
|
@@ -4159,7 +4219,7 @@ class Wt {
|
|
|
4159
4219
|
* @returns true, если код допустим, иначе false
|
|
4160
4220
|
*/
|
|
4161
4221
|
static isValidErrorCode(t) {
|
|
4162
|
-
return t ? Object.values(
|
|
4222
|
+
return t ? Object.values(St).some((e) => Object.values(e).includes(t)) : !1;
|
|
4163
4223
|
}
|
|
4164
4224
|
}
|
|
4165
4225
|
class on {
|
|
@@ -4247,11 +4307,11 @@ class on {
|
|
|
4247
4307
|
this.currentBounds = this.calculatePanBounds();
|
|
4248
4308
|
}
|
|
4249
4309
|
}
|
|
4250
|
-
const
|
|
4310
|
+
const dt = ({
|
|
4251
4311
|
value: h,
|
|
4252
4312
|
min: t,
|
|
4253
4313
|
max: e
|
|
4254
|
-
}) => Math.min(Math.max(h, t), e), Dt = class Dt extends
|
|
4314
|
+
}) => Math.min(Math.max(h, t), e), Dt = class Dt extends ot {
|
|
4255
4315
|
constructor(t, e = {}) {
|
|
4256
4316
|
var s, n, o, i, a, r, c, d, l;
|
|
4257
4317
|
super(t, e), this.backgroundOpacity = (s = e.backgroundOpacity) != null ? s : 1, this.paddingTop = (n = e.paddingTop) != null ? n : 0, this.paddingRight = (o = e.paddingRight) != null ? o : 0, this.paddingBottom = (i = e.paddingBottom) != null ? i : 0, this.paddingLeft = (a = e.paddingLeft) != null ? a : 0, this.radiusTopLeft = (r = e.radiusTopLeft) != null ? r : 0, this.radiusTopRight = (c = e.radiusTopRight) != null ? c : 0, this.radiusBottomRight = (d = e.radiusBottomRight) != null ? d : 0, this.radiusBottomLeft = (l = e.radiusBottomLeft) != null ? l : 0, this._roundDimensions();
|
|
@@ -4276,7 +4336,7 @@ const rt = ({
|
|
|
4276
4336
|
}
|
|
4277
4337
|
_getTransformedDimensions(t = {}) {
|
|
4278
4338
|
const { width: e, height: s } = this._getBackgroundDimensions();
|
|
4279
|
-
return super._getTransformedDimensions(
|
|
4339
|
+
return super._getTransformedDimensions(wt(B({}, t), {
|
|
4280
4340
|
width: e,
|
|
4281
4341
|
height: s
|
|
4282
4342
|
}));
|
|
@@ -4286,7 +4346,7 @@ const rt = ({
|
|
|
4286
4346
|
*/
|
|
4287
4347
|
toObject(t = []) {
|
|
4288
4348
|
const e = super.toObject(t);
|
|
4289
|
-
return
|
|
4349
|
+
return wt(B({}, e), {
|
|
4290
4350
|
backgroundOpacity: this.backgroundOpacity,
|
|
4291
4351
|
paddingTop: this.paddingTop,
|
|
4292
4352
|
paddingRight: this.paddingRight,
|
|
@@ -4325,10 +4385,10 @@ const rt = ({
|
|
|
4325
4385
|
var i, a, r, c;
|
|
4326
4386
|
const s = t / 2, n = e / 2, o = Math.min(s, n);
|
|
4327
4387
|
return {
|
|
4328
|
-
bottomLeft:
|
|
4329
|
-
bottomRight:
|
|
4330
|
-
topLeft:
|
|
4331
|
-
topRight:
|
|
4388
|
+
bottomLeft: dt({ value: (i = this.radiusBottomLeft) != null ? i : 0, min: 0, max: o }),
|
|
4389
|
+
bottomRight: dt({ value: (a = this.radiusBottomRight) != null ? a : 0, min: 0, max: o }),
|
|
4390
|
+
topLeft: dt({ value: (r = this.radiusTopLeft) != null ? r : 0, min: 0, max: o }),
|
|
4391
|
+
topRight: dt({ value: (c = this.radiusTopRight) != null ? c : 0, min: 0, max: o })
|
|
4332
4392
|
};
|
|
4333
4393
|
}
|
|
4334
4394
|
_getPadding() {
|
|
@@ -4344,12 +4404,12 @@ const rt = ({
|
|
|
4344
4404
|
var n;
|
|
4345
4405
|
const t = this.backgroundColor;
|
|
4346
4406
|
if (!t) return null;
|
|
4347
|
-
const e =
|
|
4407
|
+
const e = dt({ value: (n = this.backgroundOpacity) != null ? n : 1, min: 0, max: 1 });
|
|
4348
4408
|
let s;
|
|
4349
4409
|
try {
|
|
4350
|
-
s = new
|
|
4410
|
+
s = new ms(t);
|
|
4351
4411
|
} catch (o) {
|
|
4352
|
-
return
|
|
4412
|
+
return Qt.emitError({
|
|
4353
4413
|
origin: "BackgroundTextbox",
|
|
4354
4414
|
method: "_getEffectiveBackgroundFill",
|
|
4355
4415
|
code: "INVALID_COLOR_VALUE",
|
|
@@ -4372,7 +4432,7 @@ const rt = ({
|
|
|
4372
4432
|
topRight: d,
|
|
4373
4433
|
bottomRight: l,
|
|
4374
4434
|
bottomLeft: u
|
|
4375
|
-
} = n, f =
|
|
4435
|
+
} = n, f = dt({ value: c, min: 0, max: i }), g = dt({ value: d, min: 0, max: i }), p = dt({ value: l, min: 0, max: i }), m = dt({ value: u, min: 0, max: i });
|
|
4376
4436
|
t.beginPath(), t.moveTo(s + f, o), t.lineTo(a - g, o), t.quadraticCurveTo(a, o, a, o + g), t.lineTo(a, r - p), t.quadraticCurveTo(a, r, a - p, r), t.lineTo(s + m, r), t.quadraticCurveTo(s, r, s, r - m), t.lineTo(s, o + f), t.quadraticCurveTo(s, o, s + f, o), t.closePath();
|
|
4377
4437
|
}
|
|
4378
4438
|
/**
|
|
@@ -4387,7 +4447,7 @@ const rt = ({
|
|
|
4387
4447
|
}
|
|
4388
4448
|
};
|
|
4389
4449
|
Dt.type = "background-textbox", Dt.cacheProperties = [
|
|
4390
|
-
...Array.isArray(
|
|
4450
|
+
...Array.isArray(ot.cacheProperties) ? ot.cacheProperties : [],
|
|
4391
4451
|
"backgroundColor",
|
|
4392
4452
|
"backgroundOpacity",
|
|
4393
4453
|
"paddingTop",
|
|
@@ -4399,7 +4459,7 @@ Dt.type = "background-textbox", Dt.cacheProperties = [
|
|
|
4399
4459
|
"radiusBottomRight",
|
|
4400
4460
|
"radiusBottomLeft"
|
|
4401
4461
|
], Dt.stateProperties = [
|
|
4402
|
-
...Array.isArray(
|
|
4462
|
+
...Array.isArray(ot.stateProperties) ? ot.stateProperties : [],
|
|
4403
4463
|
"backgroundColor",
|
|
4404
4464
|
"backgroundOpacity",
|
|
4405
4465
|
"paddingTop",
|
|
@@ -4411,10 +4471,10 @@ Dt.type = "background-textbox", Dt.cacheProperties = [
|
|
|
4411
4471
|
"radiusBottomRight",
|
|
4412
4472
|
"radiusBottomLeft"
|
|
4413
4473
|
];
|
|
4414
|
-
let
|
|
4474
|
+
let ue = Dt;
|
|
4415
4475
|
const an = () => {
|
|
4416
4476
|
var h;
|
|
4417
|
-
(h =
|
|
4477
|
+
(h = Pe) != null && h.setClass && Pe.setClass(ue, "background-textbox");
|
|
4418
4478
|
}, rn = ({ textbox: h }) => {
|
|
4419
4479
|
var s, n;
|
|
4420
4480
|
if (!h.isEditing) return null;
|
|
@@ -4432,7 +4492,7 @@ const an = () => {
|
|
|
4432
4492
|
if (!t) return !1;
|
|
4433
4493
|
const e = (n = (s = h.text) == null ? void 0 : s.length) != null ? n : 0;
|
|
4434
4494
|
return e <= 0 ? !1 : t.start <= 0 && t.end >= e;
|
|
4435
|
-
},
|
|
4495
|
+
}, ge = ({
|
|
4436
4496
|
textbox: h,
|
|
4437
4497
|
styles: t,
|
|
4438
4498
|
range: e
|
|
@@ -4440,7 +4500,7 @@ const an = () => {
|
|
|
4440
4500
|
if (!t || !Object.keys(t).length) return !1;
|
|
4441
4501
|
const { start: s, end: n } = e;
|
|
4442
4502
|
return n <= s ? !1 : (h.setSelectionStyles(t, s, n), !0);
|
|
4443
|
-
},
|
|
4503
|
+
}, Xe = ({
|
|
4444
4504
|
textbox: h,
|
|
4445
4505
|
range: t,
|
|
4446
4506
|
property: e
|
|
@@ -4454,32 +4514,53 @@ const an = () => {
|
|
|
4454
4514
|
);
|
|
4455
4515
|
if (s.length)
|
|
4456
4516
|
return (n = s[0]) == null ? void 0 : n[e];
|
|
4457
|
-
},
|
|
4458
|
-
class
|
|
4517
|
+
}, Ke = ({ strokeColor: h, width: t }) => t <= 0 ? null : h != null ? h : "#000000", Qe = ({ width: h = 0 }) => h ? Math.max(0, h) : 0, pe = ({ value: h }) => typeof h == "string" ? h.toLocaleUpperCase() : "", $ = 0.01;
|
|
4518
|
+
class k {
|
|
4459
4519
|
constructor({ editor: t }) {
|
|
4460
4520
|
var e;
|
|
4461
|
-
this._handleTextEditingEntered = () => {
|
|
4521
|
+
this._handleTextEditingEntered = (s) => {
|
|
4522
|
+
var r;
|
|
4462
4523
|
this.isTextEditingActive = !0;
|
|
4524
|
+
const { target: n } = s;
|
|
4525
|
+
if (!k._isTextbox(n)) return;
|
|
4526
|
+
const o = (r = n.originY) != null ? r : "top", i = n.getPointByOrigin("center", o);
|
|
4527
|
+
this._ensureEditingAnchorState().set(n, {
|
|
4528
|
+
originY: o,
|
|
4529
|
+
x: i.x,
|
|
4530
|
+
y: i.y
|
|
4531
|
+
});
|
|
4532
|
+
}, this._handleTextChanged = (s) => {
|
|
4533
|
+
const { target: n } = s;
|
|
4534
|
+
if (!k._isTextbox(n)) return;
|
|
4535
|
+
const { text: o = "", uppercase: i } = n, a = !!i, r = o.toLocaleLowerCase();
|
|
4536
|
+
if (a) {
|
|
4537
|
+
const l = pe({ value: r });
|
|
4538
|
+
l !== o && n.set({ text: l }), n.textCaseRaw = r;
|
|
4539
|
+
} else
|
|
4540
|
+
n.textCaseRaw = o;
|
|
4541
|
+
const c = this._autoExpandTextboxWidth(n), d = c ? !1 : k._roundTextboxDimensions({ textbox: n });
|
|
4542
|
+
(c || d) && (n.setCoords(), n.dirty = !0);
|
|
4463
4543
|
}, this._handleTextEditingExited = (s) => {
|
|
4464
|
-
var r, c;
|
|
4544
|
+
var r, c, d;
|
|
4465
4545
|
const { target: n } = s;
|
|
4466
|
-
if (!
|
|
4467
|
-
|
|
4546
|
+
if (!k._isTextbox(n)) return;
|
|
4547
|
+
(r = this.editingAnchorState) == null || r.delete(n);
|
|
4548
|
+
const o = (c = n.text) != null ? c : "";
|
|
4468
4549
|
if (!!n.uppercase) {
|
|
4469
|
-
const
|
|
4470
|
-
n.textCaseRaw =
|
|
4550
|
+
const l = (d = n.textCaseRaw) != null ? d : o.toLocaleLowerCase();
|
|
4551
|
+
n.textCaseRaw = l;
|
|
4471
4552
|
} else
|
|
4472
4553
|
n.textCaseRaw = o;
|
|
4473
|
-
|
|
4554
|
+
k._roundTextboxDimensions({ textbox: n }) && (n.setCoords(), n.dirty = !0, this.canvas.requestRenderAll()), n.locked || n.set({
|
|
4474
4555
|
lockMovementX: !1,
|
|
4475
4556
|
lockMovementY: !1
|
|
4476
4557
|
}), setTimeout(() => {
|
|
4477
4558
|
this.isTextEditingActive = !1, this.editor.historyManager.saveState();
|
|
4478
4559
|
}, Vs);
|
|
4479
4560
|
}, this._handleObjectScaling = (s) => {
|
|
4480
|
-
var
|
|
4561
|
+
var te, xt, Bt, kt, Wt, zt, Pt, Ut, Ft, X, Tt, ee, Mt;
|
|
4481
4562
|
const { target: n, transform: o } = s;
|
|
4482
|
-
if (n instanceof U || !
|
|
4563
|
+
if (n instanceof U || !k._isTextbox(n) || !o) return;
|
|
4483
4564
|
n.isScaling = !0;
|
|
4484
4565
|
const i = this._ensureScalingState(n), {
|
|
4485
4566
|
baseWidth: a,
|
|
@@ -4488,56 +4569,56 @@ class P {
|
|
|
4488
4569
|
basePadding: d,
|
|
4489
4570
|
baseRadii: l,
|
|
4490
4571
|
baseStyles: u
|
|
4491
|
-
} = i, f = typeof ((
|
|
4492
|
-
if (!
|
|
4493
|
-
const
|
|
4572
|
+
} = i, f = typeof ((te = o.original) == null ? void 0 : te.width) == "number" ? o.original.width : void 0, g = typeof ((xt = o.original) == null ? void 0 : xt.left) == "number" ? o.original.left : void 0, p = f != null ? f : a, m = g != null ? g : r, v = (Bt = o.corner) != null ? Bt : "", S = (kt = o.action) != null ? kt : "", A = ["ml", "mr"].includes(v) || S === "scaleX", y = ["mt", "mb"].includes(v) || S === "scaleY", b = ["tl", "tr", "bl", "br"].includes(v) || S === "scale", j = b || y;
|
|
4573
|
+
if (!A && !y && !b) return;
|
|
4574
|
+
const I = Math.abs((zt = (Wt = n.scaleX) != null ? Wt : o.scaleX) != null ? zt : 1) || 1, w = Math.abs((Ut = (Pt = n.scaleY) != null ? Pt : o.scaleY) != null ? Ut : 1) || 1, T = Math.max(1, p * I), M = Math.max(1, Math.round(T)), C = Math.max(1, c * w), {
|
|
4494
4575
|
paddingTop: E = 0,
|
|
4495
|
-
paddingRight:
|
|
4496
|
-
paddingBottom:
|
|
4497
|
-
paddingLeft:
|
|
4498
|
-
radiusTopLeft:
|
|
4499
|
-
radiusTopRight:
|
|
4500
|
-
radiusBottomRight:
|
|
4501
|
-
radiusBottomLeft:
|
|
4502
|
-
fontSize:
|
|
4503
|
-
width:
|
|
4504
|
-
originX:
|
|
4505
|
-
} = n,
|
|
4506
|
-
top: Math.max(0, d.top *
|
|
4507
|
-
right: Math.max(0, d.right *
|
|
4508
|
-
bottom: Math.max(0, d.bottom *
|
|
4509
|
-
left: Math.max(0, d.left *
|
|
4510
|
-
} : d, q =
|
|
4511
|
-
topLeft: Math.max(0, l.topLeft *
|
|
4512
|
-
topRight: Math.max(0, l.topRight *
|
|
4513
|
-
bottomRight: Math.max(0, l.bottomRight *
|
|
4514
|
-
bottomLeft: Math.max(0, l.bottomLeft *
|
|
4515
|
-
} : l,
|
|
4516
|
-
let
|
|
4517
|
-
if (
|
|
4518
|
-
const
|
|
4519
|
-
Object.entries(u).forEach(([
|
|
4520
|
-
if (!
|
|
4521
|
-
const
|
|
4522
|
-
Object.entries(
|
|
4523
|
-
if (!
|
|
4524
|
-
const
|
|
4525
|
-
typeof
|
|
4526
|
-
}), Object.keys(
|
|
4527
|
-
}), Object.keys(
|
|
4576
|
+
paddingRight: W = 0,
|
|
4577
|
+
paddingBottom: N = 0,
|
|
4578
|
+
paddingLeft: x = 0,
|
|
4579
|
+
radiusTopLeft: Y = 0,
|
|
4580
|
+
radiusTopRight: G = 0,
|
|
4581
|
+
radiusBottomRight: K = 0,
|
|
4582
|
+
radiusBottomLeft: H = 0,
|
|
4583
|
+
fontSize: R,
|
|
4584
|
+
width: O,
|
|
4585
|
+
originX: it = "left"
|
|
4586
|
+
} = n, Z = b || y, st = b || y, F = Z ? {
|
|
4587
|
+
top: Math.max(0, d.top * w),
|
|
4588
|
+
right: Math.max(0, d.right * w),
|
|
4589
|
+
bottom: Math.max(0, d.bottom * w),
|
|
4590
|
+
left: Math.max(0, d.left * w)
|
|
4591
|
+
} : d, q = st ? {
|
|
4592
|
+
topLeft: Math.max(0, l.topLeft * w),
|
|
4593
|
+
topRight: Math.max(0, l.topRight * w),
|
|
4594
|
+
bottomRight: Math.max(0, l.bottomRight * w),
|
|
4595
|
+
bottomLeft: Math.max(0, l.bottomLeft * w)
|
|
4596
|
+
} : l, nt = Object.keys(u).length > 0;
|
|
4597
|
+
let J;
|
|
4598
|
+
if (j && nt) {
|
|
4599
|
+
const Yt = {};
|
|
4600
|
+
Object.entries(u).forEach(([Ht, De]) => {
|
|
4601
|
+
if (!De) return;
|
|
4602
|
+
const fe = {};
|
|
4603
|
+
Object.entries(De).forEach(([cs, se]) => {
|
|
4604
|
+
if (!se) return;
|
|
4605
|
+
const Re = B({}, se);
|
|
4606
|
+
typeof se.fontSize == "number" && (Re.fontSize = Math.max(1, se.fontSize * w)), fe[cs] = Re;
|
|
4607
|
+
}), Object.keys(fe).length && (Yt[Ht] = fe);
|
|
4608
|
+
}), Object.keys(Yt).length && (J = Yt);
|
|
4528
4609
|
}
|
|
4529
|
-
const
|
|
4530
|
-
if (!
|
|
4610
|
+
const yt = (X = (Ft = o.originX) != null ? Ft : it) != null ? X : "left", It = m + p, at = m + p / 2, ft = O != null ? O : p, rt = M !== ft, Nt = Math.abs(C - (R != null ? R : c)) > $, vt = Math.abs(F.top - E) > $ || Math.abs(F.right - W) > $ || Math.abs(F.bottom - N) > $ || Math.abs(F.left - x) > $, Jt = Math.abs(q.topLeft - Y) > $ || Math.abs(q.topRight - G) > $ || Math.abs(q.bottomRight - K) > $ || Math.abs(q.bottomLeft - H) > $;
|
|
4611
|
+
if (!rt && !Nt && !vt && !Jt) {
|
|
4531
4612
|
n.set({ scaleX: 1, scaleY: 1 }), o.scaleX = 1, o.scaleY = 1;
|
|
4532
4613
|
return;
|
|
4533
4614
|
}
|
|
4534
|
-
|
|
4535
|
-
width:
|
|
4536
|
-
fontSize:
|
|
4537
|
-
paddingTop:
|
|
4538
|
-
paddingRight:
|
|
4539
|
-
paddingBottom:
|
|
4540
|
-
paddingLeft:
|
|
4615
|
+
J && (n.styles = J), n.set({
|
|
4616
|
+
width: M,
|
|
4617
|
+
fontSize: j ? C : c,
|
|
4618
|
+
paddingTop: F.top,
|
|
4619
|
+
paddingRight: F.right,
|
|
4620
|
+
paddingBottom: F.bottom,
|
|
4621
|
+
paddingLeft: F.left,
|
|
4541
4622
|
radiusTopLeft: q.topLeft,
|
|
4542
4623
|
radiusTopRight: q.topRight,
|
|
4543
4624
|
radiusBottomRight: q.bottomRight,
|
|
@@ -4545,82 +4626,82 @@ class P {
|
|
|
4545
4626
|
scaleX: 1,
|
|
4546
4627
|
scaleY: 1
|
|
4547
4628
|
});
|
|
4548
|
-
const
|
|
4549
|
-
|
|
4550
|
-
const
|
|
4551
|
-
let
|
|
4552
|
-
|
|
4553
|
-
const { original:
|
|
4554
|
-
|
|
4555
|
-
top:
|
|
4556
|
-
right:
|
|
4557
|
-
bottom:
|
|
4558
|
-
left:
|
|
4629
|
+
const qt = k._roundTextboxDimensions({ textbox: n });
|
|
4630
|
+
qt && (n.dirty = !0);
|
|
4631
|
+
const Ct = (Tt = n.width) != null ? Tt : M, $t = Ct !== ft;
|
|
4632
|
+
let ct = m;
|
|
4633
|
+
$t && (A || b) && (yt === "right" ? ct = It - Ct : yt === "center" && (ct = at - Ct / 2)), n.set({ left: ct }), i.baseLeft = ct, o.scaleX = 1, o.scaleY = 1;
|
|
4634
|
+
const { original: bt } = o;
|
|
4635
|
+
bt && (bt.scaleX = 1, bt.scaleY = 1, bt.width = Ct, bt.height = n.height, bt.left = ct), n.setCoords(), this.canvas.requestRenderAll(), i.baseWidth = Ct, i.baseFontSize = (ee = n.fontSize) != null ? ee : C, i.baseStyles = JSON.parse(JSON.stringify((Mt = n.styles) != null ? Mt : {})), i.basePadding = {
|
|
4636
|
+
top: F.top,
|
|
4637
|
+
right: F.right,
|
|
4638
|
+
bottom: F.bottom,
|
|
4639
|
+
left: F.left
|
|
4559
4640
|
}, i.baseRadii = {
|
|
4560
4641
|
topLeft: q.topLeft,
|
|
4561
4642
|
topRight: q.topRight,
|
|
4562
4643
|
bottomRight: q.bottomRight,
|
|
4563
4644
|
bottomLeft: q.bottomLeft
|
|
4564
|
-
}, i.hasWidthChange =
|
|
4645
|
+
}, i.hasWidthChange = $t || Nt || vt || Jt || qt;
|
|
4565
4646
|
}, this._handleObjectModified = (s) => {
|
|
4566
|
-
var
|
|
4647
|
+
var S, A, y;
|
|
4567
4648
|
const { target: n } = s;
|
|
4568
4649
|
if (n instanceof U) {
|
|
4569
4650
|
const b = n.getObjects();
|
|
4570
|
-
if (!b.some((
|
|
4571
|
-
const { scaleX:
|
|
4572
|
-
if (Math.abs(
|
|
4573
|
-
this.canvas.discardActiveObject(), b.forEach((
|
|
4574
|
-
var
|
|
4575
|
-
if (
|
|
4576
|
-
const
|
|
4577
|
-
paddingTop:
|
|
4578
|
-
paddingRight:
|
|
4579
|
-
paddingBottom:
|
|
4580
|
-
paddingLeft:
|
|
4581
|
-
radiusTopLeft:
|
|
4582
|
-
radiusTopRight:
|
|
4651
|
+
if (!b.some((M) => k._isTextbox(M))) return;
|
|
4652
|
+
const { scaleX: I = 1, scaleY: w = 1 } = n;
|
|
4653
|
+
if (Math.abs(I - 1) < $ && Math.abs(w - 1) < $) return;
|
|
4654
|
+
this.canvas.discardActiveObject(), b.forEach((M) => {
|
|
4655
|
+
var C, E, W, N;
|
|
4656
|
+
if (k._isTextbox(M)) {
|
|
4657
|
+
const x = (C = M.scaleX) != null ? C : 1, Y = (E = M.scaleY) != null ? E : 1, G = ((W = M.fontSize) != null ? W : 16) * Y, K = ((N = M.width) != null ? N : 0) * x, H = Y, {
|
|
4658
|
+
paddingTop: R = 0,
|
|
4659
|
+
paddingRight: O = 0,
|
|
4660
|
+
paddingBottom: it = 0,
|
|
4661
|
+
paddingLeft: Z = 0,
|
|
4662
|
+
radiusTopLeft: st = 0,
|
|
4663
|
+
radiusTopRight: F = 0,
|
|
4583
4664
|
radiusBottomRight: q = 0,
|
|
4584
|
-
radiusBottomLeft:
|
|
4585
|
-
styles:
|
|
4586
|
-
} =
|
|
4587
|
-
paddingTop: Math.max(0,
|
|
4588
|
-
paddingRight: Math.max(0,
|
|
4589
|
-
paddingBottom: Math.max(0,
|
|
4590
|
-
paddingLeft: Math.max(0,
|
|
4591
|
-
},
|
|
4592
|
-
radiusTopLeft: Math.max(0,
|
|
4593
|
-
radiusTopRight: Math.max(0,
|
|
4594
|
-
radiusBottomRight: Math.max(0, q *
|
|
4595
|
-
radiusBottomLeft: Math.max(0,
|
|
4665
|
+
radiusBottomLeft: nt = 0,
|
|
4666
|
+
styles: J
|
|
4667
|
+
} = M, yt = {
|
|
4668
|
+
paddingTop: Math.max(0, R * H),
|
|
4669
|
+
paddingRight: Math.max(0, O * H),
|
|
4670
|
+
paddingBottom: Math.max(0, it * H),
|
|
4671
|
+
paddingLeft: Math.max(0, Z * H)
|
|
4672
|
+
}, It = {
|
|
4673
|
+
radiusTopLeft: Math.max(0, st * H),
|
|
4674
|
+
radiusTopRight: Math.max(0, F * H),
|
|
4675
|
+
radiusBottomRight: Math.max(0, q * H),
|
|
4676
|
+
radiusBottomLeft: Math.max(0, nt * H)
|
|
4596
4677
|
};
|
|
4597
|
-
let
|
|
4598
|
-
|
|
4599
|
-
Object.values(
|
|
4600
|
-
typeof
|
|
4678
|
+
let at = J;
|
|
4679
|
+
J && Object.keys(J).length > 0 && (at = JSON.parse(JSON.stringify(J)), Object.values(at).forEach((ft) => {
|
|
4680
|
+
Object.values(ft).forEach((rt) => {
|
|
4681
|
+
typeof rt.fontSize == "number" && (rt.fontSize = Math.max(1, rt.fontSize * H));
|
|
4601
4682
|
});
|
|
4602
|
-
})),
|
|
4603
|
-
fontSize:
|
|
4604
|
-
width:
|
|
4683
|
+
})), M.set(wt(B(B({
|
|
4684
|
+
fontSize: G,
|
|
4685
|
+
width: K,
|
|
4605
4686
|
scaleX: 1,
|
|
4606
4687
|
scaleY: 1
|
|
4607
|
-
},
|
|
4608
|
-
styles:
|
|
4609
|
-
})),
|
|
4688
|
+
}, yt), It), {
|
|
4689
|
+
styles: at
|
|
4690
|
+
})), k._roundTextboxDimensions({ textbox: M });
|
|
4610
4691
|
}
|
|
4611
|
-
|
|
4692
|
+
M.setCoords();
|
|
4612
4693
|
});
|
|
4613
|
-
const
|
|
4694
|
+
const T = new U(b, {
|
|
4614
4695
|
canvas: this.canvas
|
|
4615
4696
|
});
|
|
4616
|
-
this.canvas.setActiveObject(
|
|
4697
|
+
this.canvas.setActiveObject(T), this.canvas.requestRenderAll();
|
|
4617
4698
|
return;
|
|
4618
4699
|
}
|
|
4619
|
-
if (!
|
|
4700
|
+
if (!k._isTextbox(n)) return;
|
|
4620
4701
|
n.isScaling = !1;
|
|
4621
4702
|
const o = this.scalingState.get(n);
|
|
4622
4703
|
if (this.scalingState.delete(n), !(o != null && o.hasWidthChange)) return;
|
|
4623
|
-
const i = (
|
|
4704
|
+
const i = (S = n.width) != null ? S : n.calcTextWidth(), a = (y = (A = n.fontSize) != null ? A : o == null ? void 0 : o.baseFontSize) != null ? y : 16, r = !!(o.baseStyles && Object.keys(o.baseStyles).length), {
|
|
4624
4705
|
paddingTop: c = 0,
|
|
4625
4706
|
paddingRight: d = 0,
|
|
4626
4707
|
paddingBottom: l = 0,
|
|
@@ -4644,15 +4725,15 @@ class P {
|
|
|
4644
4725
|
target: n,
|
|
4645
4726
|
style: v
|
|
4646
4727
|
}), n.set({ scaleX: 1, scaleY: 1 }), n.setCoords();
|
|
4647
|
-
}, this.editor = t, this.canvas = t.canvas, this.fonts = (e = t.options.fonts) != null ? e : [], this.scalingState = /* @__PURE__ */ new WeakMap(), this.isTextEditingActive = !1, this._bindEvents(), an();
|
|
4728
|
+
}, 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.isTextEditingActive = !1, this._bindEvents(), an();
|
|
4648
4729
|
}
|
|
4649
4730
|
/**
|
|
4650
4731
|
* Добавляет новый текстовый объект на канвас.
|
|
4651
4732
|
* @param options — настройки текста
|
|
4652
4733
|
* @param flags — флаги поведения
|
|
4653
4734
|
*/
|
|
4654
|
-
addText(
|
|
4655
|
-
var
|
|
4735
|
+
addText(W = {}, { withoutSelection: M = !1, withoutSave: C = !1, withoutAdding: E = !1 } = {}) {
|
|
4736
|
+
var N = W, {
|
|
4656
4737
|
id: t = `text-${V()}`,
|
|
4657
4738
|
text: e = "Новый текст",
|
|
4658
4739
|
fontFamily: s,
|
|
@@ -4670,14 +4751,14 @@ class P {
|
|
|
4670
4751
|
backgroundColor: p,
|
|
4671
4752
|
backgroundOpacity: m = 1,
|
|
4672
4753
|
paddingTop: v = 0,
|
|
4673
|
-
paddingRight:
|
|
4674
|
-
paddingBottom:
|
|
4754
|
+
paddingRight: S = 0,
|
|
4755
|
+
paddingBottom: A = 0,
|
|
4675
4756
|
paddingLeft: y = 0,
|
|
4676
4757
|
radiusTopLeft: b = 0,
|
|
4677
|
-
radiusTopRight:
|
|
4678
|
-
radiusBottomRight:
|
|
4679
|
-
radiusBottomLeft:
|
|
4680
|
-
} =
|
|
4758
|
+
radiusTopRight: j = 0,
|
|
4759
|
+
radiusBottomRight: I = 0,
|
|
4760
|
+
radiusBottomLeft: w = 0
|
|
4761
|
+
} = N, T = gt(N, [
|
|
4681
4762
|
"id",
|
|
4682
4763
|
"text",
|
|
4683
4764
|
"fontFamily",
|
|
@@ -4703,15 +4784,15 @@ class P {
|
|
|
4703
4784
|
"radiusBottomRight",
|
|
4704
4785
|
"radiusBottomLeft"
|
|
4705
4786
|
]);
|
|
4706
|
-
var
|
|
4707
|
-
const { historyManager:
|
|
4708
|
-
|
|
4709
|
-
const
|
|
4787
|
+
var Z;
|
|
4788
|
+
const { historyManager: x } = this.editor, { canvas: Y } = this;
|
|
4789
|
+
x.suspendHistory();
|
|
4790
|
+
const G = s != null ? s : this._getDefaultFontFamily(), K = Qe({ width: f }), H = Ke({
|
|
4710
4791
|
strokeColor: u,
|
|
4711
|
-
width:
|
|
4712
|
-
}),
|
|
4792
|
+
width: K
|
|
4793
|
+
}), R = B({
|
|
4713
4794
|
id: t,
|
|
4714
|
-
fontFamily:
|
|
4795
|
+
fontFamily: G,
|
|
4715
4796
|
fontSize: n,
|
|
4716
4797
|
fontWeight: o ? "bold" : "normal",
|
|
4717
4798
|
fontStyle: i ? "italic" : "normal",
|
|
@@ -4720,43 +4801,43 @@ class P {
|
|
|
4720
4801
|
linethrough: c,
|
|
4721
4802
|
textAlign: d,
|
|
4722
4803
|
fill: l,
|
|
4723
|
-
stroke:
|
|
4724
|
-
strokeWidth:
|
|
4804
|
+
stroke: H,
|
|
4805
|
+
strokeWidth: K,
|
|
4725
4806
|
strokeUniform: !0,
|
|
4726
4807
|
opacity: g,
|
|
4727
4808
|
backgroundColor: p,
|
|
4728
4809
|
backgroundOpacity: m,
|
|
4729
4810
|
paddingTop: v,
|
|
4730
|
-
paddingRight:
|
|
4731
|
-
paddingBottom:
|
|
4811
|
+
paddingRight: S,
|
|
4812
|
+
paddingBottom: A,
|
|
4732
4813
|
paddingLeft: y,
|
|
4733
4814
|
radiusTopLeft: b,
|
|
4734
|
-
radiusTopRight:
|
|
4735
|
-
radiusBottomRight:
|
|
4736
|
-
radiusBottomLeft:
|
|
4737
|
-
},
|
|
4738
|
-
if (
|
|
4739
|
-
const
|
|
4740
|
-
|
|
4741
|
-
}
|
|
4742
|
-
return
|
|
4743
|
-
textbox:
|
|
4744
|
-
options:
|
|
4815
|
+
radiusTopRight: j,
|
|
4816
|
+
radiusBottomRight: I,
|
|
4817
|
+
radiusBottomLeft: w
|
|
4818
|
+
}, T), O = new ue(e, R);
|
|
4819
|
+
if (O.textCaseRaw = (Z = O.text) != null ? Z : "", r) {
|
|
4820
|
+
const st = pe({ value: O.textCaseRaw });
|
|
4821
|
+
st !== O.text && O.set({ text: st });
|
|
4822
|
+
}
|
|
4823
|
+
return k._roundTextboxDimensions({ textbox: O }) && (O.dirty = !0), T.left === void 0 && T.top === void 0 && Y.centerObject(O), E || Y.add(O), M || Y.setActiveObject(O), Y.requestRenderAll(), x.resumeHistory(), C || x.saveState(), Y.fire("editor:text-added", {
|
|
4824
|
+
textbox: O,
|
|
4825
|
+
options: wt(B({}, R), {
|
|
4745
4826
|
text: e,
|
|
4746
4827
|
bold: o,
|
|
4747
4828
|
italic: i,
|
|
4748
4829
|
strikethrough: c,
|
|
4749
4830
|
align: d,
|
|
4750
4831
|
color: l,
|
|
4751
|
-
strokeColor:
|
|
4752
|
-
strokeWidth:
|
|
4832
|
+
strokeColor: H,
|
|
4833
|
+
strokeWidth: K
|
|
4753
4834
|
}),
|
|
4754
4835
|
flags: {
|
|
4755
|
-
withoutSelection: !!
|
|
4756
|
-
withoutSave: !!
|
|
4836
|
+
withoutSelection: !!M,
|
|
4837
|
+
withoutSave: !!C,
|
|
4757
4838
|
withoutAdding: !!E
|
|
4758
4839
|
}
|
|
4759
|
-
}),
|
|
4840
|
+
}), O;
|
|
4760
4841
|
}
|
|
4761
4842
|
/**
|
|
4762
4843
|
* Обновляет текстовый объект.
|
|
@@ -4767,36 +4848,40 @@ class P {
|
|
|
4767
4848
|
* @param options.skipRender — не вызывать перерисовку канваса
|
|
4768
4849
|
*/
|
|
4769
4850
|
updateText({ target: t, style: e = {}, withoutSave: s, skipRender: n } = {}) {
|
|
4770
|
-
var
|
|
4851
|
+
var xt, kt, Wt, zt, Pt, Ut, Ft;
|
|
4771
4852
|
const o = this._resolveTextObject(t);
|
|
4772
4853
|
if (!o) return null;
|
|
4773
4854
|
const { historyManager: i } = this.editor, { canvas: a } = this;
|
|
4774
4855
|
i.suspendHistory();
|
|
4775
|
-
const r =
|
|
4776
|
-
|
|
4777
|
-
|
|
4778
|
-
|
|
4779
|
-
|
|
4780
|
-
|
|
4781
|
-
|
|
4782
|
-
|
|
4783
|
-
|
|
4784
|
-
|
|
4785
|
-
|
|
4786
|
-
|
|
4787
|
-
|
|
4788
|
-
|
|
4789
|
-
|
|
4790
|
-
|
|
4791
|
-
|
|
4792
|
-
|
|
4793
|
-
|
|
4794
|
-
|
|
4795
|
-
|
|
4796
|
-
|
|
4797
|
-
|
|
4798
|
-
|
|
4799
|
-
|
|
4856
|
+
const r = k._getSnapshot(o), c = (xt = o.originY) != null ? xt : "top", d = o.getPointByOrigin("center", c), l = {
|
|
4857
|
+
originY: c,
|
|
4858
|
+
x: d.x,
|
|
4859
|
+
y: d.y
|
|
4860
|
+
}, Bt = e, {
|
|
4861
|
+
text: u,
|
|
4862
|
+
fontFamily: f,
|
|
4863
|
+
fontSize: g,
|
|
4864
|
+
bold: p,
|
|
4865
|
+
italic: m,
|
|
4866
|
+
underline: v,
|
|
4867
|
+
uppercase: S,
|
|
4868
|
+
strikethrough: A,
|
|
4869
|
+
align: y,
|
|
4870
|
+
color: b,
|
|
4871
|
+
strokeColor: j,
|
|
4872
|
+
strokeWidth: I,
|
|
4873
|
+
opacity: w,
|
|
4874
|
+
backgroundColor: T,
|
|
4875
|
+
backgroundOpacity: M,
|
|
4876
|
+
paddingTop: C,
|
|
4877
|
+
paddingRight: E,
|
|
4878
|
+
paddingBottom: W,
|
|
4879
|
+
paddingLeft: N,
|
|
4880
|
+
radiusTopLeft: x,
|
|
4881
|
+
radiusTopRight: Y,
|
|
4882
|
+
radiusBottomRight: G,
|
|
4883
|
+
radiusBottomLeft: K
|
|
4884
|
+
} = Bt, H = gt(Bt, [
|
|
4800
4885
|
"text",
|
|
4801
4886
|
"fontFamily",
|
|
4802
4887
|
"fontSize",
|
|
@@ -4820,46 +4905,58 @@ class P {
|
|
|
4820
4905
|
"radiusTopRight",
|
|
4821
4906
|
"radiusBottomRight",
|
|
4822
4907
|
"radiusBottomLeft"
|
|
4823
|
-
]),
|
|
4824
|
-
if (
|
|
4825
|
-
const
|
|
4826
|
-
|
|
4827
|
-
}
|
|
4828
|
-
if (
|
|
4829
|
-
const
|
|
4830
|
-
|
|
4831
|
-
}
|
|
4832
|
-
if (
|
|
4833
|
-
const
|
|
4834
|
-
strokeColor:
|
|
4835
|
-
width:
|
|
4908
|
+
]), R = B({}, H), O = rn({ textbox: o }), it = O ? k._expandRangeToFullLines({ textbox: o, range: O }) : null, Z = {}, st = {}, F = {}, q = dn({ textbox: o, range: O }), nt = !O || q, J = !O;
|
|
4909
|
+
if (f !== void 0 && (it && (st.fontFamily = f), nt && (R.fontFamily = f, J && (F.fontFamily = f))), g !== void 0 && (it && (st.fontSize = g), nt && (R.fontSize = g, J && (F.fontSize = g))), p !== void 0) {
|
|
4910
|
+
const X = p ? "bold" : "normal";
|
|
4911
|
+
O && (Z.fontWeight = X), nt && (R.fontWeight = X, J && (F.fontWeight = X));
|
|
4912
|
+
}
|
|
4913
|
+
if (m !== void 0) {
|
|
4914
|
+
const X = m ? "italic" : "normal";
|
|
4915
|
+
O && (Z.fontStyle = X), nt && (R.fontStyle = X, J && (F.fontStyle = X));
|
|
4916
|
+
}
|
|
4917
|
+
if (v !== void 0 && (O && (Z.underline = v), nt && (R.underline = v, J && (F.underline = v))), A !== void 0 && (O && (Z.linethrough = A), nt && (R.linethrough = A, J && (F.linethrough = A))), y !== void 0 && (R.textAlign = y), b !== void 0 && (O && (Z.fill = b), nt && (R.fill = b, J && (F.fill = b))), j !== void 0 || I !== void 0) {
|
|
4918
|
+
const X = O ? Xe({ textbox: o, range: O, property: "strokeWidth" }) : void 0, Tt = O ? Xe({ textbox: o, range: O, property: "stroke" }) : void 0, ee = (Wt = (kt = I != null ? I : X) != null ? kt : o.strokeWidth) != null ? Wt : 0, Mt = Qe({ width: ee }), Yt = (Pt = (zt = j != null ? j : Tt) != null ? zt : o.stroke) != null ? Pt : void 0, Ht = Ke({
|
|
4919
|
+
strokeColor: Yt,
|
|
4920
|
+
width: Mt
|
|
4836
4921
|
});
|
|
4837
|
-
|
|
4838
|
-
}
|
|
4839
|
-
|
|
4840
|
-
const
|
|
4841
|
-
if (
|
|
4842
|
-
const
|
|
4843
|
-
|
|
4844
|
-
} else o.textCaseRaw === void 0 && (o.textCaseRaw =
|
|
4845
|
-
o.uppercase =
|
|
4846
|
-
let
|
|
4847
|
-
if (
|
|
4848
|
-
const
|
|
4849
|
-
|
|
4850
|
-
} else if (Object.keys(
|
|
4851
|
-
const
|
|
4852
|
-
|
|
4853
|
-
}
|
|
4854
|
-
const
|
|
4922
|
+
O && (Z.stroke = Ht, Z.strokeWidth = Mt), nt && (R.stroke = Ht, R.strokeWidth = Mt, J && (F.stroke = Ht, F.strokeWidth = Mt));
|
|
4923
|
+
}
|
|
4924
|
+
w !== void 0 && (R.opacity = w), T !== void 0 && (R.backgroundColor = T), M !== void 0 && (R.backgroundOpacity = M), C !== void 0 && (R.paddingTop = C), E !== void 0 && (R.paddingRight = E), W !== void 0 && (R.paddingBottom = W), N !== void 0 && (R.paddingLeft = N), x !== void 0 && (R.radiusTopLeft = x), Y !== void 0 && (R.radiusTopRight = Y), G !== void 0 && (R.radiusBottomRight = G), K !== void 0 && (R.radiusBottomLeft = K);
|
|
4925
|
+
const yt = (Ft = o.textCaseRaw) != null ? Ft : (Ut = o.text) != null ? Ut : "", It = !!o.uppercase, at = u !== void 0, ft = at ? u != null ? u : "" : yt, rt = S != null ? S : It, Nt = rt !== It;
|
|
4926
|
+
if (at || Nt) {
|
|
4927
|
+
const X = rt ? pe({ value: ft }) : ft;
|
|
4928
|
+
R.text = X, o.textCaseRaw = ft;
|
|
4929
|
+
} else o.textCaseRaw === void 0 && (o.textCaseRaw = yt);
|
|
4930
|
+
o.uppercase = rt, o.set(R);
|
|
4931
|
+
let vt = !1;
|
|
4932
|
+
if (O) {
|
|
4933
|
+
const X = ge({ textbox: o, styles: Z, range: O }), Tt = it ? ge({ textbox: o, styles: st, range: it }) : !1;
|
|
4934
|
+
vt = X || Tt;
|
|
4935
|
+
} else if (Object.keys(F).length) {
|
|
4936
|
+
const X = cn({ textbox: o });
|
|
4937
|
+
X && (vt = ge({ textbox: o, styles: F, range: X }));
|
|
4938
|
+
}
|
|
4939
|
+
const Jt = vt && k._hasLayoutAffectingStyles({
|
|
4855
4940
|
stylesList: [
|
|
4856
|
-
|
|
4857
|
-
|
|
4858
|
-
|
|
4941
|
+
Z,
|
|
4942
|
+
st,
|
|
4943
|
+
F
|
|
4859
4944
|
]
|
|
4860
4945
|
});
|
|
4861
|
-
|
|
4862
|
-
const
|
|
4946
|
+
vt && (o.dirty = !0), Jt && (o.initDimensions(), o.dirty = !0), (T !== void 0 || M !== void 0 || C !== void 0 || E !== void 0 || W !== void 0 || N !== void 0 || x !== void 0 || Y !== void 0 || G !== void 0 || K !== void 0) && (o.dirty = !0);
|
|
4947
|
+
const qt = k._hasLayoutAffectingStyles({
|
|
4948
|
+
stylesList: [
|
|
4949
|
+
R,
|
|
4950
|
+
Z,
|
|
4951
|
+
st,
|
|
4952
|
+
F
|
|
4953
|
+
]
|
|
4954
|
+
}), $t = !Object.prototype.hasOwnProperty.call(R, "width") && (at || Nt || qt);
|
|
4955
|
+
let ct = !1;
|
|
4956
|
+
$t && (ct = this._autoExpandTextboxWidth(o, {
|
|
4957
|
+
anchor: l
|
|
4958
|
+
}), ct && (o.dirty = !0)), (ct ? !1 : k._roundTextboxDimensions({ textbox: o })) && (o.dirty = !0), o.setCoords(), n || a.requestRenderAll(), i.resumeHistory(), s || i.saveState();
|
|
4959
|
+
const te = k._getSnapshot(o);
|
|
4863
4960
|
return a.fire("editor:text-updated", {
|
|
4864
4961
|
textbox: o,
|
|
4865
4962
|
target: t,
|
|
@@ -4868,11 +4965,11 @@ class P {
|
|
|
4868
4965
|
withoutSave: !!s,
|
|
4869
4966
|
skipRender: !!n
|
|
4870
4967
|
},
|
|
4871
|
-
updates:
|
|
4968
|
+
updates: R,
|
|
4872
4969
|
before: r,
|
|
4873
|
-
after:
|
|
4874
|
-
selectionRange:
|
|
4875
|
-
selectionStyles:
|
|
4970
|
+
after: te,
|
|
4971
|
+
selectionRange: O != null ? O : void 0,
|
|
4972
|
+
selectionStyles: O && Object.keys(Z).length ? Z : void 0
|
|
4876
4973
|
}), o;
|
|
4877
4974
|
}
|
|
4878
4975
|
/**
|
|
@@ -4880,20 +4977,20 @@ class P {
|
|
|
4880
4977
|
*/
|
|
4881
4978
|
destroy() {
|
|
4882
4979
|
const { canvas: t } = this;
|
|
4883
|
-
t.off("object:scaling", this._handleObjectScaling), t.off("object:resizing",
|
|
4980
|
+
t.off("object:scaling", this._handleObjectScaling), t.off("object:resizing", k._handleObjectResizing), t.off("object:modified", this._handleObjectModified), t.off("text:editing:exited", this._handleTextEditingExited), t.off("text:editing:entered", this._handleTextEditingEntered), t.off("text:changed", this._handleTextChanged);
|
|
4884
4981
|
}
|
|
4885
4982
|
/**
|
|
4886
4983
|
* Возвращает активный текст или ищет по id.
|
|
4887
4984
|
*/
|
|
4888
4985
|
_resolveTextObject(t) {
|
|
4889
|
-
if (t instanceof
|
|
4986
|
+
if (t instanceof ot) return t;
|
|
4890
4987
|
const { canvas: e } = this;
|
|
4891
4988
|
if (!t) {
|
|
4892
4989
|
const s = e.getActiveObject();
|
|
4893
|
-
return
|
|
4990
|
+
return k._isTextbox(s) ? s : null;
|
|
4894
4991
|
}
|
|
4895
4992
|
if (typeof t == "string") {
|
|
4896
|
-
const s = e.getObjects().find((n) =>
|
|
4993
|
+
const s = e.getObjects().find((n) => k._isTextbox(n) && n.id === t);
|
|
4897
4994
|
return s != null ? s : null;
|
|
4898
4995
|
}
|
|
4899
4996
|
return null;
|
|
@@ -4902,28 +4999,83 @@ class P {
|
|
|
4902
4999
|
* Проверяет, является ли объект текстовым блоком редактора.
|
|
4903
5000
|
*/
|
|
4904
5001
|
static _isTextbox(t) {
|
|
4905
|
-
return !!t && t instanceof
|
|
5002
|
+
return !!t && t instanceof ot;
|
|
4906
5003
|
}
|
|
4907
5004
|
/**
|
|
4908
5005
|
* Вешает обработчики событий Fabric для работы с текстом.
|
|
4909
5006
|
*/
|
|
4910
5007
|
_bindEvents() {
|
|
4911
5008
|
const { canvas: t } = this;
|
|
4912
|
-
t.on("object:scaling", this._handleObjectScaling), t.on("object:resizing",
|
|
5009
|
+
t.on("object:scaling", this._handleObjectScaling), t.on("object:resizing", k._handleObjectResizing), t.on("object:modified", this._handleObjectModified), t.on("text:editing:entered", this._handleTextEditingEntered), t.on("text:editing:exited", this._handleTextEditingExited), t.on("text:changed", this._handleTextChanged);
|
|
4913
5010
|
}
|
|
4914
5011
|
/**
|
|
4915
|
-
*
|
|
5012
|
+
* Автоматически увеличивает ширину текстового объекта до ширины текста,
|
|
5013
|
+
* но не шире монтажной области, и удерживает объект в её пределах.
|
|
4916
5014
|
*/
|
|
4917
|
-
|
|
4918
|
-
|
|
4919
|
-
|
|
4920
|
-
|
|
4921
|
-
|
|
4922
|
-
|
|
4923
|
-
|
|
4924
|
-
|
|
4925
|
-
|
|
4926
|
-
|
|
5015
|
+
_autoExpandTextboxWidth(t, { anchor: e } = {}) {
|
|
5016
|
+
var I, w, T, M, C, E, W, N, x, Y, G, K, H;
|
|
5017
|
+
const { montageArea: s } = this.editor;
|
|
5018
|
+
if (!s) return !1;
|
|
5019
|
+
const n = typeof t.text == "string" ? t.text : "";
|
|
5020
|
+
if (!n.length) return !1;
|
|
5021
|
+
s.setCoords();
|
|
5022
|
+
const o = s.getBoundingRect(!1, !0), i = (I = o.width) != null ? I : 0;
|
|
5023
|
+
if (!Number.isFinite(i) || i <= 0) return !1;
|
|
5024
|
+
const a = e != null ? e : (w = this.editingAnchorState) == null ? void 0 : w.get(t), r = (M = (T = a == null ? void 0 : a.originY) != null ? T : t.originY) != null ? M : "top", c = Math.abs((C = t.scaleX) != null ? C : 1) || 1, d = (E = t.paddingLeft) != null ? E : 0, l = (W = t.paddingRight) != null ? W : 0, u = (N = t.strokeWidth) != null ? N : 0, f = Math.max(
|
|
5025
|
+
1,
|
|
5026
|
+
i / c - d - l - u
|
|
5027
|
+
);
|
|
5028
|
+
if (!Number.isFinite(f) || f <= 0) return !1;
|
|
5029
|
+
const g = n.split(`
|
|
5030
|
+
`).length;
|
|
5031
|
+
let p = !1;
|
|
5032
|
+
Math.abs(((x = t.width) != null ? x : 0) - f) > $ && (t.set({ width: f }), p = !0), t.initDimensions();
|
|
5033
|
+
const { textLines: m } = t, v = Array.isArray(m) && m.length > g, S = Math.ceil(
|
|
5034
|
+
k._getLongestLineWidth({ textbox: t, text: n })
|
|
5035
|
+
), A = Math.min((Y = t.minWidth) != null ? Y : 1, f);
|
|
5036
|
+
let y = Math.min(
|
|
5037
|
+
f,
|
|
5038
|
+
Math.max(S, A)
|
|
5039
|
+
);
|
|
5040
|
+
v && (y = f), Math.abs(((G = t.width) != null ? G : 0) - y) > $ && (t.set({ width: y }), t.initDimensions(), p = !0), k._roundTextboxDimensions({ textbox: t }) && (p = !0), a && (t.setPositionByOrigin(new tt(a.x, a.y), "center", r), p = !0);
|
|
5041
|
+
const j = k._clampTextboxToMontage({
|
|
5042
|
+
textbox: t,
|
|
5043
|
+
montageLeft: (K = o.left) != null ? K : 0,
|
|
5044
|
+
montageRight: ((H = o.left) != null ? H : 0) + i
|
|
5045
|
+
});
|
|
5046
|
+
return p || j;
|
|
5047
|
+
}
|
|
5048
|
+
/**
|
|
5049
|
+
* Возвращает ширину самой длинной строки текстового объекта.
|
|
5050
|
+
*/
|
|
5051
|
+
static _getLongestLineWidth({
|
|
5052
|
+
textbox: t,
|
|
5053
|
+
text: e
|
|
5054
|
+
}) {
|
|
5055
|
+
const { textLines: s } = t, n = Array.isArray(s) && s.length > 0 ? s.length : Math.max(e.split(`
|
|
5056
|
+
`).length, 1);
|
|
5057
|
+
let o = 0;
|
|
5058
|
+
for (let i = 0; i < n; i += 1) {
|
|
5059
|
+
const a = t.getLineWidth(i);
|
|
5060
|
+
a > o && (o = a);
|
|
5061
|
+
}
|
|
5062
|
+
return o;
|
|
5063
|
+
}
|
|
5064
|
+
/**
|
|
5065
|
+
* Сдвигает текстовый объект по X, чтобы он не выходил за пределы монтажной области.
|
|
5066
|
+
*/
|
|
5067
|
+
static _clampTextboxToMontage({
|
|
5068
|
+
textbox: t,
|
|
5069
|
+
montageLeft: e,
|
|
5070
|
+
montageRight: s
|
|
5071
|
+
}) {
|
|
5072
|
+
var c, d, l, u;
|
|
5073
|
+
t.setCoords();
|
|
5074
|
+
const n = t.getBoundingRect(!1, !0), o = (c = n.left) != null ? c : 0, i = o + ((d = n.width) != null ? d : 0), a = s - e;
|
|
5075
|
+
if (a > 0 && ((l = n.width) != null ? l : 0) >= a - $)
|
|
5076
|
+
return !1;
|
|
5077
|
+
let r = 0;
|
|
5078
|
+
return o < e ? r = e - o : i > s && (r = s - i), Math.abs(r) <= $ ? !1 : (t.set({ left: ((u = t.left) != null ? u : 0) + r }), !0);
|
|
4927
5079
|
}
|
|
4928
5080
|
/**
|
|
4929
5081
|
* Обрабатывает изменение ширины текстового объекта (resizing).
|
|
@@ -4934,7 +5086,7 @@ class P {
|
|
|
4934
5086
|
static _handleObjectResizing(t) {
|
|
4935
5087
|
var l, u, f, g, p, m;
|
|
4936
5088
|
const { target: e, transform: s } = t;
|
|
4937
|
-
if (!
|
|
5089
|
+
if (!k._isTextbox(e)) return;
|
|
4938
5090
|
const {
|
|
4939
5091
|
paddingLeft: n = 0,
|
|
4940
5092
|
paddingRight: o = 0
|
|
@@ -4945,13 +5097,19 @@ class P {
|
|
|
4945
5097
|
e.set({ width: r });
|
|
4946
5098
|
const c = (u = e.width) != null ? u : 0, d = a - c;
|
|
4947
5099
|
if (d !== 0 && s && s.corner === "ml") {
|
|
4948
|
-
const
|
|
5100
|
+
const S = ((f = e.angle) != null ? f : 0) * Math.PI / 180, A = Math.cos(S), y = Math.sin(S), b = (g = e.scaleX) != null ? g : 1, j = d * b;
|
|
4949
5101
|
e.set({
|
|
4950
|
-
left: ((p = e.left) != null ? p : 0) +
|
|
4951
|
-
top: ((m = e.top) != null ? m : 0) +
|
|
5102
|
+
left: ((p = e.left) != null ? p : 0) + j * A,
|
|
5103
|
+
top: ((m = e.top) != null ? m : 0) + j * y
|
|
4952
5104
|
});
|
|
4953
5105
|
}
|
|
4954
5106
|
}
|
|
5107
|
+
/**
|
|
5108
|
+
* Возвращает хранилище якорей редактирования, создавая его при необходимости.
|
|
5109
|
+
*/
|
|
5110
|
+
_ensureEditingAnchorState() {
|
|
5111
|
+
return this.editingAnchorState || (this.editingAnchorState = /* @__PURE__ */ new WeakMap()), this.editingAnchorState;
|
|
5112
|
+
}
|
|
4955
5113
|
/**
|
|
4956
5114
|
* Возвращает диапазоны символов для каждой строки текста без учёта символов переноса.
|
|
4957
5115
|
*/
|
|
@@ -4974,7 +5132,7 @@ class P {
|
|
|
4974
5132
|
textbox: t,
|
|
4975
5133
|
range: e
|
|
4976
5134
|
}) {
|
|
4977
|
-
const s =
|
|
5135
|
+
const s = k._getLineRanges({ textbox: t });
|
|
4978
5136
|
if (!s.length) return e;
|
|
4979
5137
|
let { start: n } = e, { end: o } = e;
|
|
4980
5138
|
return s.forEach(({ start: i, end: a }) => {
|
|
@@ -5059,10 +5217,10 @@ class P {
|
|
|
5059
5217
|
static _roundTextboxDimensions({
|
|
5060
5218
|
textbox: t
|
|
5061
5219
|
}) {
|
|
5062
|
-
const { width: e, height: s, calcTextWidth: n, calcTextHeight: o } = t, i = typeof n == "function" ? n.call(t) : void 0, a = typeof o == "function" ? o.call(t) : void 0, r =
|
|
5220
|
+
const { width: e, height: s, calcTextWidth: n, calcTextHeight: o } = t, i = typeof n == "function" ? n.call(t) : void 0, a = typeof o == "function" ? o.call(t) : void 0, r = k._resolveDimension({
|
|
5063
5221
|
rawValue: e,
|
|
5064
5222
|
calculatedValue: i
|
|
5065
|
-
}), c =
|
|
5223
|
+
}), c = k._resolveDimension({
|
|
5066
5224
|
rawValue: s,
|
|
5067
5225
|
calculatedValue: a
|
|
5068
5226
|
}), d = Number.isFinite(r) ? Math.round(r) : null, l = Number.isFinite(c) ? Math.round(c) : null, u = {};
|
|
@@ -5073,11 +5231,11 @@ class P {
|
|
|
5073
5231
|
*/
|
|
5074
5232
|
static _getSnapshot(t) {
|
|
5075
5233
|
const e = ({
|
|
5076
|
-
snapshot:
|
|
5077
|
-
entries:
|
|
5234
|
+
snapshot: R,
|
|
5235
|
+
entries: O
|
|
5078
5236
|
}) => {
|
|
5079
|
-
Object.entries(
|
|
5080
|
-
|
|
5237
|
+
Object.entries(O).forEach(([it, Z]) => {
|
|
5238
|
+
Z != null && (R[it] = Z);
|
|
5081
5239
|
});
|
|
5082
5240
|
}, {
|
|
5083
5241
|
id: s,
|
|
@@ -5095,30 +5253,30 @@ class P {
|
|
|
5095
5253
|
stroke: p,
|
|
5096
5254
|
strokeWidth: m,
|
|
5097
5255
|
opacity: v,
|
|
5098
|
-
backgroundColor:
|
|
5099
|
-
backgroundOpacity:
|
|
5256
|
+
backgroundColor: S,
|
|
5257
|
+
backgroundOpacity: A,
|
|
5100
5258
|
paddingTop: y,
|
|
5101
5259
|
paddingRight: b,
|
|
5102
|
-
paddingBottom:
|
|
5103
|
-
paddingLeft:
|
|
5104
|
-
radiusTopLeft:
|
|
5105
|
-
radiusTopRight:
|
|
5106
|
-
radiusBottomRight:
|
|
5107
|
-
radiusBottomLeft:
|
|
5260
|
+
paddingBottom: j,
|
|
5261
|
+
paddingLeft: I,
|
|
5262
|
+
radiusTopLeft: w,
|
|
5263
|
+
radiusTopRight: T,
|
|
5264
|
+
radiusBottomRight: M,
|
|
5265
|
+
radiusBottomLeft: C,
|
|
5108
5266
|
left: E,
|
|
5109
|
-
top:
|
|
5110
|
-
width:
|
|
5111
|
-
height:
|
|
5112
|
-
angle:
|
|
5113
|
-
scaleX:
|
|
5114
|
-
scaleY:
|
|
5115
|
-
} = t,
|
|
5267
|
+
top: W,
|
|
5268
|
+
width: N,
|
|
5269
|
+
height: x,
|
|
5270
|
+
angle: Y,
|
|
5271
|
+
scaleX: G,
|
|
5272
|
+
scaleY: K
|
|
5273
|
+
} = t, H = {
|
|
5116
5274
|
id: s,
|
|
5117
5275
|
uppercase: !!i,
|
|
5118
5276
|
textAlign: f
|
|
5119
5277
|
};
|
|
5120
5278
|
return e({
|
|
5121
|
-
snapshot:
|
|
5279
|
+
snapshot: H,
|
|
5122
5280
|
entries: {
|
|
5123
5281
|
text: n,
|
|
5124
5282
|
textCaseRaw: o,
|
|
@@ -5132,25 +5290,25 @@ class P {
|
|
|
5132
5290
|
stroke: p,
|
|
5133
5291
|
strokeWidth: m,
|
|
5134
5292
|
opacity: v,
|
|
5135
|
-
backgroundColor:
|
|
5136
|
-
backgroundOpacity:
|
|
5293
|
+
backgroundColor: S,
|
|
5294
|
+
backgroundOpacity: A,
|
|
5137
5295
|
paddingTop: y,
|
|
5138
5296
|
paddingRight: b,
|
|
5139
|
-
paddingBottom:
|
|
5140
|
-
paddingLeft:
|
|
5141
|
-
radiusTopLeft:
|
|
5142
|
-
radiusTopRight:
|
|
5143
|
-
radiusBottomRight:
|
|
5144
|
-
radiusBottomLeft:
|
|
5297
|
+
paddingBottom: j,
|
|
5298
|
+
paddingLeft: I,
|
|
5299
|
+
radiusTopLeft: w,
|
|
5300
|
+
radiusTopRight: T,
|
|
5301
|
+
radiusBottomRight: M,
|
|
5302
|
+
radiusBottomLeft: C,
|
|
5145
5303
|
left: E,
|
|
5146
|
-
top:
|
|
5147
|
-
width:
|
|
5148
|
-
height:
|
|
5149
|
-
angle:
|
|
5150
|
-
scaleX:
|
|
5151
|
-
scaleY:
|
|
5304
|
+
top: W,
|
|
5305
|
+
width: N,
|
|
5306
|
+
height: x,
|
|
5307
|
+
angle: Y,
|
|
5308
|
+
scaleX: G,
|
|
5309
|
+
scaleY: K
|
|
5152
5310
|
}
|
|
5153
|
-
}),
|
|
5311
|
+
}), H;
|
|
5154
5312
|
}
|
|
5155
5313
|
/**
|
|
5156
5314
|
* Возвращает первый доступный шрифт или дефолтный Arial.
|
|
@@ -5163,7 +5321,7 @@ class P {
|
|
|
5163
5321
|
const Q = ({
|
|
5164
5322
|
value: h,
|
|
5165
5323
|
fallback: t = 0
|
|
5166
|
-
}) => typeof h == "number" && Number.isFinite(h) ? h : typeof t == "number" && Number.isFinite(t) ? t : 0,
|
|
5324
|
+
}) => typeof h == "number" && Number.isFinite(h) ? h : typeof t == "number" && Number.isFinite(t) ? t : 0, ae = ({
|
|
5167
5325
|
value: h,
|
|
5168
5326
|
dimension: t,
|
|
5169
5327
|
useRelativePositions: e
|
|
@@ -5180,22 +5338,22 @@ const Q = ({
|
|
|
5180
5338
|
const o = h;
|
|
5181
5339
|
if (typeof o[n.x] == "number" && typeof o[n.y] == "number")
|
|
5182
5340
|
return {
|
|
5183
|
-
x:
|
|
5341
|
+
x: ae({
|
|
5184
5342
|
value: o[n.x],
|
|
5185
5343
|
dimension: t,
|
|
5186
5344
|
useRelativePositions: s
|
|
5187
5345
|
}),
|
|
5188
|
-
y:
|
|
5346
|
+
y: ae({
|
|
5189
5347
|
value: o[n.y],
|
|
5190
5348
|
dimension: e,
|
|
5191
5349
|
useRelativePositions: s
|
|
5192
5350
|
})
|
|
5193
5351
|
};
|
|
5194
|
-
const { left: a, top: r, width: c, height: d } = h, l =
|
|
5352
|
+
const { left: a, top: r, width: c, height: d } = h, l = ae({
|
|
5195
5353
|
value: a,
|
|
5196
5354
|
dimension: t,
|
|
5197
5355
|
useRelativePositions: s
|
|
5198
|
-
}), u =
|
|
5356
|
+
}), u = ae({
|
|
5199
5357
|
value: r,
|
|
5200
5358
|
dimension: e,
|
|
5201
5359
|
useRelativePositions: s
|
|
@@ -5233,7 +5391,7 @@ const Q = ({
|
|
|
5233
5391
|
} catch (s) {
|
|
5234
5392
|
return null;
|
|
5235
5393
|
}
|
|
5236
|
-
},
|
|
5394
|
+
}, mt = ({
|
|
5237
5395
|
object: h
|
|
5238
5396
|
}) => {
|
|
5239
5397
|
if (!h) return null;
|
|
@@ -5297,8 +5455,8 @@ const Q = ({
|
|
|
5297
5455
|
};
|
|
5298
5456
|
}
|
|
5299
5457
|
return null;
|
|
5300
|
-
},
|
|
5301
|
-
class
|
|
5458
|
+
}, Vt = "_templateCenterX", me = "_templateCenterY", re = "_templateAnchorX", ye = "_templateAnchorY";
|
|
5459
|
+
class _ {
|
|
5302
5460
|
constructor({ editor: t }) {
|
|
5303
5461
|
this.editor = t;
|
|
5304
5462
|
}
|
|
@@ -5317,21 +5475,21 @@ class R {
|
|
|
5317
5475
|
montageArea: i,
|
|
5318
5476
|
errorManager: a,
|
|
5319
5477
|
backgroundManager: r
|
|
5320
|
-
} = this.editor, c = o.getActiveObject(), d =
|
|
5478
|
+
} = this.editor, c = o.getActiveObject(), d = _._collectObjects(c), { backgroundObject: l } = r != null ? r : {}, u = n && l ? [l] : [], f = [...d, ...u];
|
|
5321
5479
|
if (!f.length)
|
|
5322
5480
|
return a.emitWarning({
|
|
5323
5481
|
origin: "TemplateManager",
|
|
5324
5482
|
method: "serializeSelection",
|
|
5325
|
-
code:
|
|
5483
|
+
code: St.TEMPLATE_MANAGER.NO_OBJECTS_SELECTED,
|
|
5326
5484
|
message: "Нет объектов для сериализации шаблона"
|
|
5327
5485
|
}), null;
|
|
5328
|
-
const g =
|
|
5486
|
+
const g = _._getBounds(i), p = _._getMontageSize({ montageArea: i, bounds: g }), m = p.width, v = p.height, S = f.map((b) => _._serializeObject({
|
|
5329
5487
|
object: b,
|
|
5330
5488
|
bounds: g,
|
|
5331
5489
|
baseWidth: m,
|
|
5332
5490
|
baseHeight: v,
|
|
5333
5491
|
montageArea: i != null ? i : null
|
|
5334
|
-
})),
|
|
5492
|
+
})), A = wt(B({}, s), {
|
|
5335
5493
|
baseWidth: m,
|
|
5336
5494
|
baseHeight: v,
|
|
5337
5495
|
positionsNormalized: !0,
|
|
@@ -5339,8 +5497,8 @@ class R {
|
|
|
5339
5497
|
});
|
|
5340
5498
|
return {
|
|
5341
5499
|
id: t != null ? t : `template-${V()}`,
|
|
5342
|
-
meta:
|
|
5343
|
-
objects:
|
|
5500
|
+
meta: A,
|
|
5501
|
+
objects: S
|
|
5344
5502
|
};
|
|
5345
5503
|
}
|
|
5346
5504
|
/**
|
|
@@ -5350,7 +5508,7 @@ class R {
|
|
|
5350
5508
|
* @param options.data - данные для заполнения текстов по customData.templateField
|
|
5351
5509
|
*/
|
|
5352
5510
|
applyTemplate(s) {
|
|
5353
|
-
return
|
|
5511
|
+
return z(this, arguments, function* ({
|
|
5354
5512
|
template: t,
|
|
5355
5513
|
data: e
|
|
5356
5514
|
}) {
|
|
@@ -5365,40 +5523,40 @@ class R {
|
|
|
5365
5523
|
return a.emitWarning({
|
|
5366
5524
|
origin: "TemplateManager",
|
|
5367
5525
|
method: "applyTemplate",
|
|
5368
|
-
code:
|
|
5526
|
+
code: St.TEMPLATE_MANAGER.INVALID_TEMPLATE,
|
|
5369
5527
|
message: "Шаблон не содержит объектов"
|
|
5370
5528
|
}), null;
|
|
5371
|
-
const u =
|
|
5529
|
+
const u = _._getBounds(o);
|
|
5372
5530
|
if (!u)
|
|
5373
5531
|
return a.emitWarning({
|
|
5374
5532
|
origin: "TemplateManager",
|
|
5375
5533
|
method: "applyTemplate",
|
|
5376
|
-
code:
|
|
5534
|
+
code: St.TEMPLATE_MANAGER.INVALID_TARGET,
|
|
5377
5535
|
message: "Не удалось определить границы монтажной области"
|
|
5378
5536
|
}), null;
|
|
5379
|
-
const f =
|
|
5380
|
-
let v = !1,
|
|
5537
|
+
const f = _._getMontageSize({ montageArea: o, bounds: u }), g = _._normalizeMeta({ meta: d, fallback: f }), p = _._calculateScale({ meta: g, target: f }), m = !!g.positionsNormalized;
|
|
5538
|
+
let v = !1, S = !1;
|
|
5381
5539
|
i.suspendHistory();
|
|
5382
5540
|
try {
|
|
5383
|
-
const
|
|
5384
|
-
if (!
|
|
5541
|
+
const A = yield _._enlivenObjects(c);
|
|
5542
|
+
if (!A.length)
|
|
5385
5543
|
return a.emitWarning({
|
|
5386
5544
|
origin: "TemplateManager",
|
|
5387
5545
|
method: "applyTemplate",
|
|
5388
|
-
code:
|
|
5546
|
+
code: St.TEMPLATE_MANAGER.INVALID_TEMPLATE,
|
|
5389
5547
|
message: "Не удалось создать объекты шаблона"
|
|
5390
5548
|
}), null;
|
|
5391
|
-
const { backgroundObject: y, contentObjects: b } =
|
|
5392
|
-
y && (
|
|
5549
|
+
const { backgroundObject: y, contentObjects: b } = _._extractBackgroundObject(A);
|
|
5550
|
+
y && (S = yield _._applyBackgroundFromObject({
|
|
5393
5551
|
backgroundObject: y,
|
|
5394
5552
|
backgroundManager: r,
|
|
5395
5553
|
errorManager: a
|
|
5396
5554
|
}));
|
|
5397
|
-
const
|
|
5398
|
-
object:
|
|
5555
|
+
const j = b.map((I) => (this._adaptTextboxWidth({
|
|
5556
|
+
object: I,
|
|
5399
5557
|
baseWidth: g.baseWidth
|
|
5400
|
-
}),
|
|
5401
|
-
object:
|
|
5558
|
+
}), _._transformObject({
|
|
5559
|
+
object: I,
|
|
5402
5560
|
scale: p,
|
|
5403
5561
|
bounds: u,
|
|
5404
5562
|
targetSize: f,
|
|
@@ -5406,24 +5564,24 @@ class R {
|
|
|
5406
5564
|
baseHeight: g.baseHeight,
|
|
5407
5565
|
montageArea: o,
|
|
5408
5566
|
useRelativePositions: m
|
|
5409
|
-
}),
|
|
5410
|
-
id: `${
|
|
5567
|
+
}), I.set({
|
|
5568
|
+
id: `${I.type}-${V()}`,
|
|
5411
5569
|
evented: !0
|
|
5412
|
-
}), n.add(
|
|
5413
|
-
return !
|
|
5570
|
+
}), n.add(I), I));
|
|
5571
|
+
return !j.length && !S ? null : (v = j.length > 0 || S, j.length && _._activateObjects({ canvas: n, objects: j }), n.requestRenderAll(), n.fire("editor:template-applied", {
|
|
5414
5572
|
template: t,
|
|
5415
|
-
objects:
|
|
5573
|
+
objects: j,
|
|
5416
5574
|
bounds: u
|
|
5417
|
-
}),
|
|
5418
|
-
} catch (
|
|
5575
|
+
}), j);
|
|
5576
|
+
} catch (A) {
|
|
5419
5577
|
return a.emitError({
|
|
5420
5578
|
origin: "TemplateManager",
|
|
5421
5579
|
method: "applyTemplate",
|
|
5422
|
-
code:
|
|
5580
|
+
code: St.TEMPLATE_MANAGER.APPLY_FAILED,
|
|
5423
5581
|
message: "Ошибка применения шаблона",
|
|
5424
5582
|
data: {
|
|
5425
5583
|
templateId: l,
|
|
5426
|
-
error:
|
|
5584
|
+
error: A
|
|
5427
5585
|
}
|
|
5428
5586
|
}), null;
|
|
5429
5587
|
} finally {
|
|
@@ -5459,15 +5617,15 @@ class R {
|
|
|
5459
5617
|
* Превращает plain-описание объектов в Fabric объекты.
|
|
5460
5618
|
*/
|
|
5461
5619
|
static _enlivenObjects(t) {
|
|
5462
|
-
return
|
|
5463
|
-
return (yield Promise.all(t.map((s) =>
|
|
5464
|
-
if (
|
|
5465
|
-
const i = yield
|
|
5620
|
+
return z(this, null, function* () {
|
|
5621
|
+
return (yield Promise.all(t.map((s) => z(null, null, function* () {
|
|
5622
|
+
if (_._hasSerializedSvgMarkup(s)) {
|
|
5623
|
+
const i = yield _._reviveSvgObject(s);
|
|
5466
5624
|
if (i)
|
|
5467
|
-
return
|
|
5625
|
+
return _._restoreImageScale({ revived: i, serialized: s }), i;
|
|
5468
5626
|
}
|
|
5469
|
-
const n = yield
|
|
5470
|
-
return o ? (
|
|
5627
|
+
const n = yield ut.enlivenObjects([s]), o = n == null ? void 0 : n[0];
|
|
5628
|
+
return o ? (_._restoreImageScale({ revived: o, serialized: s }), o) : null;
|
|
5471
5629
|
})))).filter((s) => !!s);
|
|
5472
5630
|
});
|
|
5473
5631
|
}
|
|
@@ -5495,22 +5653,22 @@ class R {
|
|
|
5495
5653
|
naturalHeight: 0,
|
|
5496
5654
|
width: 0,
|
|
5497
5655
|
height: 0
|
|
5498
|
-
}, p = Q({ value: l || f || c.width, fallback: 0 }), m = Q({ value: u || g || c.height, fallback: 0 }), v = Q({ value: n, fallback: p }),
|
|
5499
|
-
if (
|
|
5656
|
+
}, p = Q({ value: l || f || c.width, fallback: 0 }), m = Q({ value: u || g || c.height, fallback: 0 }), v = Q({ value: n, fallback: p }), S = Q({ value: o, fallback: m }), A = Q({ value: i, fallback: c.scaleX || 1 }), y = Q({ value: a, fallback: c.scaleY || 1 }), b = v * A, j = S * y, I = p > 0, w = m > 0, T = b > 0, M = j > 0, C = _._resolveImageFit({ customData: r }), E = {};
|
|
5657
|
+
if (I && (E.width = p), w && (E.height = m), !I || !w) {
|
|
5500
5658
|
c.set(E);
|
|
5501
5659
|
return;
|
|
5502
5660
|
}
|
|
5503
|
-
if (
|
|
5504
|
-
const
|
|
5505
|
-
|
|
5661
|
+
if (C === "stretch") {
|
|
5662
|
+
const N = T ? b / p : null, x = M ? j / m : null;
|
|
5663
|
+
N && N > 0 && (E.scaleX = N), x && x > 0 && (E.scaleY = x), c.set(E);
|
|
5506
5664
|
return;
|
|
5507
5665
|
}
|
|
5508
|
-
if (!
|
|
5666
|
+
if (!T || !M) {
|
|
5509
5667
|
c.set(E);
|
|
5510
5668
|
return;
|
|
5511
5669
|
}
|
|
5512
|
-
const
|
|
5513
|
-
Number.isFinite(
|
|
5670
|
+
const W = Math.min(b / p, j / m);
|
|
5671
|
+
Number.isFinite(W) && W > 0 && (E.scaleX = W, E.scaleY = W), c.set(E);
|
|
5514
5672
|
}
|
|
5515
5673
|
/**
|
|
5516
5674
|
* Определяет режим вписывания изображения при восстановлении.
|
|
@@ -5532,12 +5690,12 @@ class R {
|
|
|
5532
5690
|
* Восстанавливает SVG-объект из компактного описания.
|
|
5533
5691
|
*/
|
|
5534
5692
|
static _reviveSvgObject(t) {
|
|
5535
|
-
return
|
|
5693
|
+
return z(this, null, function* () {
|
|
5536
5694
|
const e = typeof t.svgMarkup == "string" ? t.svgMarkup : null;
|
|
5537
5695
|
if (!e) return null;
|
|
5538
5696
|
try {
|
|
5539
|
-
const s = yield
|
|
5540
|
-
|
|
5697
|
+
const s = yield ys(e), n = ut.groupSVGElements(s.objects, s.options), o = yield ut.enlivenObjectEnlivables(
|
|
5698
|
+
_._prepareSerializableProps(t)
|
|
5541
5699
|
);
|
|
5542
5700
|
return n.set(o), n.setCoords(), n;
|
|
5543
5701
|
} catch (s) {
|
|
@@ -5601,28 +5759,28 @@ class R {
|
|
|
5601
5759
|
baseHeight: i,
|
|
5602
5760
|
useRelativePositions: r,
|
|
5603
5761
|
centerKeys: {
|
|
5604
|
-
x:
|
|
5605
|
-
y:
|
|
5762
|
+
x: Vt,
|
|
5763
|
+
y: me
|
|
5606
5764
|
}
|
|
5607
|
-
}), { scaleX: u, scaleY: f } = t, g = Q({ value: u, fallback: 1 }), p = Q({ value: f, fallback: 1 }), m =
|
|
5765
|
+
}), { scaleX: u, scaleY: f } = t, g = Q({ value: u, fallback: 1 }), p = Q({ value: f, fallback: 1 }), m = _._getPositioningBounds({
|
|
5608
5766
|
bounds: s,
|
|
5609
5767
|
baseWidth: o,
|
|
5610
5768
|
baseHeight: i,
|
|
5611
5769
|
scale: e,
|
|
5612
5770
|
useRelativePositions: r,
|
|
5613
|
-
anchorX:
|
|
5614
|
-
anchorY:
|
|
5771
|
+
anchorX: _._resolveAnchor(c, re),
|
|
5772
|
+
anchorY: _._resolveAnchor(c, ye)
|
|
5615
5773
|
}), v = hn({
|
|
5616
5774
|
normalizedX: d,
|
|
5617
5775
|
normalizedY: l,
|
|
5618
5776
|
bounds: m,
|
|
5619
5777
|
targetSize: n,
|
|
5620
5778
|
montageArea: a
|
|
5621
|
-
}),
|
|
5779
|
+
}), S = g * e, A = p * e;
|
|
5622
5780
|
t.set({
|
|
5623
|
-
scaleX:
|
|
5624
|
-
scaleY:
|
|
5625
|
-
}), t.setPositionByOrigin(v, "center", "center"), t.setCoords(), delete c[
|
|
5781
|
+
scaleX: S,
|
|
5782
|
+
scaleY: A
|
|
5783
|
+
}), t.setPositionByOrigin(v, "center", "center"), t.setCoords(), delete c[Vt], delete c[me], delete c[re], delete c[ye];
|
|
5626
5784
|
}
|
|
5627
5785
|
/**
|
|
5628
5786
|
* Возвращает bounds, в которых должны позиционироваться нормализованные объекты.
|
|
@@ -5638,7 +5796,7 @@ class R {
|
|
|
5638
5796
|
anchorY: a
|
|
5639
5797
|
}) {
|
|
5640
5798
|
if (!o) return t;
|
|
5641
|
-
const r = (e || t.width) * n, c = (s || t.height) * n, d = t.width - r, l = t.height - c, u = t.left +
|
|
5799
|
+
const r = (e || t.width) * n, c = (s || t.height) * n, d = t.width - r, l = t.height - c, u = t.left + _._calculateAnchorOffset(i, d), f = t.top + _._calculateAnchorOffset(a, l);
|
|
5642
5800
|
return {
|
|
5643
5801
|
left: u,
|
|
5644
5802
|
top: f,
|
|
@@ -5669,7 +5827,7 @@ class R {
|
|
|
5669
5827
|
meta: t,
|
|
5670
5828
|
fallback: e
|
|
5671
5829
|
}) {
|
|
5672
|
-
const { width: s, height: n } = e, r = t || {}, { baseWidth: o = s, baseHeight: i = n } = r, a =
|
|
5830
|
+
const { width: s, height: n } = e, r = t || {}, { baseWidth: o = s, baseHeight: i = n } = r, a = gt(r, ["baseWidth", "baseHeight"]);
|
|
5673
5831
|
return B({
|
|
5674
5832
|
baseWidth: o,
|
|
5675
5833
|
baseHeight: i
|
|
@@ -5707,30 +5865,30 @@ class R {
|
|
|
5707
5865
|
object: t,
|
|
5708
5866
|
baseWidth: e
|
|
5709
5867
|
}) {
|
|
5710
|
-
var
|
|
5711
|
-
if (!(t instanceof
|
|
5868
|
+
var Y, G;
|
|
5869
|
+
if (!(t instanceof ot)) return;
|
|
5712
5870
|
const s = typeof t.text == "string" ? t.text : "";
|
|
5713
5871
|
if (!s) return;
|
|
5714
5872
|
const n = Q({
|
|
5715
|
-
value: (
|
|
5873
|
+
value: (G = (Y = this.editor) == null ? void 0 : Y.montageArea) == null ? void 0 : G.width,
|
|
5716
5874
|
fallback: 0
|
|
5717
5875
|
}), {
|
|
5718
5876
|
width: o = 0,
|
|
5719
5877
|
scaleX: i = 1,
|
|
5720
5878
|
strokeWidth: a = 0
|
|
5721
|
-
} = t, r = Q({ value: e, fallback: 0 }), c = t, d = Q({ value: c.paddingLeft, fallback: 0 }), l = Q({ value: c.paddingRight, fallback: 0 }), u = Q({ value: i, fallback: 1 }), f = Q({ value: a, fallback: 0 }) * u, g = Q({ value: o, fallback: 0 }), p = g * u, m = d * u, v = l * u,
|
|
5879
|
+
} = t, r = Q({ value: e, fallback: 0 }), c = t, d = Q({ value: c.paddingLeft, fallback: 0 }), l = Q({ value: c.paddingRight, fallback: 0 }), u = Q({ value: i, fallback: 1 }), f = Q({ value: a, fallback: 0 }) * u, g = Q({ value: o, fallback: 0 }), p = g * u, m = d * u, v = l * u, S = p + m + v + f;
|
|
5722
5880
|
if (!n || !g || !r) return;
|
|
5723
5881
|
t.setCoords();
|
|
5724
|
-
const
|
|
5882
|
+
const A = t, y = A[Vt], b = typeof y == "number" ? y : null, j = _._resolveAnchor(A, re), I = S / r, w = b !== null ? b - I / 2 : null, T = b !== null ? b + I / 2 : null, M = t.getCenterPoint();
|
|
5725
5883
|
t.set("width", n), t.initDimensions();
|
|
5726
|
-
const
|
|
5884
|
+
const C = _._getLongestLineWidth({
|
|
5727
5885
|
textbox: t,
|
|
5728
5886
|
text: s
|
|
5729
|
-
}), E =
|
|
5730
|
-
t.set("width", E), t.initDimensions(), t.setPositionByOrigin(
|
|
5731
|
-
const
|
|
5732
|
-
let
|
|
5733
|
-
|
|
5887
|
+
}), E = C > g ? C + 1 : g;
|
|
5888
|
+
t.set("width", E), t.initDimensions(), t.setPositionByOrigin(M, "center", "center"), t.setCoords();
|
|
5889
|
+
const N = (E * u + m + v + f) / r;
|
|
5890
|
+
let x = b;
|
|
5891
|
+
j === "start" && w !== null ? x = Math.max(0, w) + N / 2 : j === "end" && T !== null && (x = Math.min(1, T) - N / 2), typeof x == "number" && (A[Vt] = x);
|
|
5734
5892
|
}
|
|
5735
5893
|
/**
|
|
5736
5894
|
* Возвращает ширину самой длинной строки текстового объекта.
|
|
@@ -5760,9 +5918,9 @@ class R {
|
|
|
5760
5918
|
baseHeight: n,
|
|
5761
5919
|
montageArea: o
|
|
5762
5920
|
}) {
|
|
5763
|
-
const i = t.toDatalessObject([...
|
|
5764
|
-
if (
|
|
5765
|
-
const y =
|
|
5921
|
+
const i = t.toDatalessObject([...ns]);
|
|
5922
|
+
if (_._isSvgObject(t)) {
|
|
5923
|
+
const y = _._extractSvgMarkup(t);
|
|
5766
5924
|
y && (i.svgMarkup = y, delete i.objects, delete i.path);
|
|
5767
5925
|
}
|
|
5768
5926
|
if (!e) return i;
|
|
@@ -5781,15 +5939,15 @@ class R {
|
|
|
5781
5939
|
x: (y.x - a) / u,
|
|
5782
5940
|
y: (y.y - r) / f
|
|
5783
5941
|
};
|
|
5784
|
-
})(), m = (l.left - a) / u, v = (l.top - r) / f,
|
|
5785
|
-
return i[
|
|
5942
|
+
})(), m = (l.left - a) / u, v = (l.top - r) / f, S = m + l.width / u, A = v + l.height / f;
|
|
5943
|
+
return i[Vt] = p.x, i[me] = p.y, i[re] = _._detectAnchor({
|
|
5786
5944
|
center: p.x,
|
|
5787
5945
|
start: m,
|
|
5788
|
-
end:
|
|
5789
|
-
}), i[
|
|
5946
|
+
end: S
|
|
5947
|
+
}), i[ye] = _._detectAnchor({
|
|
5790
5948
|
center: p.y,
|
|
5791
5949
|
start: v,
|
|
5792
|
-
end:
|
|
5950
|
+
end: A
|
|
5793
5951
|
}), i.left = m, i.top = v, i;
|
|
5794
5952
|
}
|
|
5795
5953
|
/**
|
|
@@ -5806,13 +5964,13 @@ class R {
|
|
|
5806
5964
|
* Применяет фоновый объект шаблона к текущему холсту через BackgroundManager.
|
|
5807
5965
|
*/
|
|
5808
5966
|
static _applyBackgroundFromObject(n) {
|
|
5809
|
-
return
|
|
5967
|
+
return z(this, arguments, function* ({
|
|
5810
5968
|
backgroundObject: t,
|
|
5811
5969
|
backgroundManager: e,
|
|
5812
5970
|
errorManager: s
|
|
5813
5971
|
}) {
|
|
5814
5972
|
try {
|
|
5815
|
-
const { fill: o, customData: i } = t, { backgroundType: a } = t, r =
|
|
5973
|
+
const { fill: o, customData: i } = t, { backgroundType: a } = t, r = _._cloneCustomData(i);
|
|
5816
5974
|
if (a === "color" && typeof o == "string")
|
|
5817
5975
|
return e.setColorBackground({
|
|
5818
5976
|
color: o,
|
|
@@ -5831,7 +5989,7 @@ class R {
|
|
|
5831
5989
|
}), !0;
|
|
5832
5990
|
}
|
|
5833
5991
|
if (a === "image") {
|
|
5834
|
-
const c =
|
|
5992
|
+
const c = _._getImageSource(t);
|
|
5835
5993
|
if (c)
|
|
5836
5994
|
return yield e.setImageBackground({
|
|
5837
5995
|
imageSource: c,
|
|
@@ -5844,7 +6002,7 @@ class R {
|
|
|
5844
6002
|
s.emitWarning({
|
|
5845
6003
|
origin: "TemplateManager",
|
|
5846
6004
|
method: "applyTemplate",
|
|
5847
|
-
code:
|
|
6005
|
+
code: St.TEMPLATE_MANAGER.APPLY_FAILED,
|
|
5848
6006
|
message: "Не удалось применить фон из шаблона",
|
|
5849
6007
|
data: o
|
|
5850
6008
|
});
|
|
@@ -5900,10 +6058,10 @@ class R {
|
|
|
5900
6058
|
*/
|
|
5901
6059
|
// eslint-disable-next-line class-methods-use-this
|
|
5902
6060
|
enlivenObjectEnlivables(t) {
|
|
5903
|
-
return
|
|
6061
|
+
return ut.enlivenObjectEnlivables(t);
|
|
5904
6062
|
}
|
|
5905
6063
|
}
|
|
5906
|
-
const pn = 5,
|
|
6064
|
+
const pn = 5, os = "#3D8BF4", Ae = 1, ce = 1, Je = ({
|
|
5907
6065
|
anchors: h,
|
|
5908
6066
|
positions: t,
|
|
5909
6067
|
threshold: e
|
|
@@ -5923,11 +6081,11 @@ const pn = 5, ss = "#3D8BF4", pe = 1, Jt = 1, Ke = ({
|
|
|
5923
6081
|
threshold: t,
|
|
5924
6082
|
anchors: e
|
|
5925
6083
|
}) => {
|
|
5926
|
-
const { left: s, right: n, centerX: o, top: i, bottom: a, centerY: r } = h, c =
|
|
6084
|
+
const { left: s, right: n, centerX: o, top: i, bottom: a, centerY: r } = h, c = Je({
|
|
5927
6085
|
anchors: e.vertical,
|
|
5928
6086
|
positions: [s, o, n],
|
|
5929
6087
|
threshold: t
|
|
5930
|
-
}), d =
|
|
6088
|
+
}), d = Je({
|
|
5931
6089
|
anchors: e.horizontal,
|
|
5932
6090
|
positions: [i, r, a],
|
|
5933
6091
|
threshold: t
|
|
@@ -5943,7 +6101,7 @@ const pn = 5, ss = "#3D8BF4", pe = 1, Jt = 1, Ke = ({
|
|
|
5943
6101
|
deltaY: d.delta,
|
|
5944
6102
|
guides: l
|
|
5945
6103
|
};
|
|
5946
|
-
},
|
|
6104
|
+
}, is = ({
|
|
5947
6105
|
activeBounds: h,
|
|
5948
6106
|
aligned: t,
|
|
5949
6107
|
threshold: e,
|
|
@@ -6040,66 +6198,66 @@ const pn = 5, ss = "#3D8BF4", pe = 1, Jt = 1, Ke = ({
|
|
|
6040
6198
|
return { delta: 0, guide: null };
|
|
6041
6199
|
const u = d[l - 1], f = d[l - 2], g = d[l + 1], p = d[l + 2], m = [], v = i - o;
|
|
6042
6200
|
if (u && f) {
|
|
6043
|
-
const { bounds: y } = u, { bounds: b } = f,
|
|
6044
|
-
if (
|
|
6045
|
-
const
|
|
6201
|
+
const { bounds: y } = u, { bounds: b } = f, j = y.top - b.bottom, I = o - y.bottom, w = Math.abs(I - j);
|
|
6202
|
+
if (w <= e) {
|
|
6203
|
+
const T = j - I, M = o + T, C = {
|
|
6046
6204
|
type: "vertical",
|
|
6047
6205
|
axis: n,
|
|
6048
6206
|
refStart: b.bottom,
|
|
6049
6207
|
refEnd: y.top,
|
|
6050
6208
|
activeStart: y.bottom,
|
|
6051
|
-
activeEnd:
|
|
6052
|
-
distance:
|
|
6209
|
+
activeEnd: M,
|
|
6210
|
+
distance: j
|
|
6053
6211
|
};
|
|
6054
|
-
m.push({ delta:
|
|
6212
|
+
m.push({ delta: T, guide: C, diff: w });
|
|
6055
6213
|
}
|
|
6056
6214
|
}
|
|
6057
6215
|
if (g && p) {
|
|
6058
|
-
const { bounds: y } = g, { bounds: b } = p,
|
|
6059
|
-
if (
|
|
6060
|
-
const
|
|
6216
|
+
const { bounds: y } = g, { bounds: b } = p, j = b.top - y.bottom, I = y.top - i, w = Math.abs(I - j);
|
|
6217
|
+
if (w <= e) {
|
|
6218
|
+
const T = I - j, M = i + T, C = {
|
|
6061
6219
|
type: "vertical",
|
|
6062
6220
|
axis: n,
|
|
6063
6221
|
refStart: y.bottom,
|
|
6064
6222
|
refEnd: b.top,
|
|
6065
|
-
activeStart:
|
|
6223
|
+
activeStart: M,
|
|
6066
6224
|
activeEnd: y.top,
|
|
6067
|
-
distance:
|
|
6225
|
+
distance: j
|
|
6068
6226
|
};
|
|
6069
|
-
m.push({ delta:
|
|
6227
|
+
m.push({ delta: T, guide: C, diff: w });
|
|
6070
6228
|
}
|
|
6071
6229
|
}
|
|
6072
6230
|
if (u && g) {
|
|
6073
|
-
const { bounds: y } = u, { bounds: b } = g,
|
|
6074
|
-
if (
|
|
6075
|
-
const
|
|
6076
|
-
if (
|
|
6077
|
-
const
|
|
6231
|
+
const { bounds: y } = u, { bounds: b } = g, I = b.top - y.bottom - v;
|
|
6232
|
+
if (I >= 0) {
|
|
6233
|
+
const w = I / 2, T = o - y.bottom, M = b.top - i, C = Math.abs(T - w), E = Math.abs(M - w), W = Math.max(C, E);
|
|
6234
|
+
if (W <= e) {
|
|
6235
|
+
const N = w - T, x = i + N, Y = {
|
|
6078
6236
|
type: "vertical",
|
|
6079
6237
|
axis: n,
|
|
6080
6238
|
refStart: y.bottom,
|
|
6081
|
-
refEnd: y.bottom +
|
|
6082
|
-
activeStart:
|
|
6083
|
-
activeEnd:
|
|
6084
|
-
distance:
|
|
6239
|
+
refEnd: y.bottom + w,
|
|
6240
|
+
activeStart: x,
|
|
6241
|
+
activeEnd: x + w,
|
|
6242
|
+
distance: w
|
|
6085
6243
|
};
|
|
6086
|
-
m.push({ delta:
|
|
6244
|
+
m.push({ delta: N, guide: Y, diff: W });
|
|
6087
6245
|
}
|
|
6088
6246
|
}
|
|
6089
6247
|
}
|
|
6090
|
-
const
|
|
6248
|
+
const S = is({
|
|
6091
6249
|
activeBounds: h,
|
|
6092
6250
|
aligned: c,
|
|
6093
6251
|
threshold: e,
|
|
6094
6252
|
patterns: s,
|
|
6095
6253
|
type: "vertical"
|
|
6096
6254
|
});
|
|
6097
|
-
if (m.push(...
|
|
6255
|
+
if (m.push(...S), !m.length)
|
|
6098
6256
|
return { delta: 0, guide: null };
|
|
6099
|
-
const
|
|
6257
|
+
const A = m.reduce((y, b) => b.diff < y.diff ? b : y, m[0]);
|
|
6100
6258
|
return {
|
|
6101
|
-
delta:
|
|
6102
|
-
guide:
|
|
6259
|
+
delta: A.delta,
|
|
6260
|
+
guide: A.guide
|
|
6103
6261
|
};
|
|
6104
6262
|
}, vn = ({
|
|
6105
6263
|
activeBounds: h,
|
|
@@ -6126,66 +6284,66 @@ const pn = 5, ss = "#3D8BF4", pe = 1, Jt = 1, Ke = ({
|
|
|
6126
6284
|
return { delta: 0, guide: null };
|
|
6127
6285
|
const u = d[l - 1], f = d[l - 2], g = d[l + 1], p = d[l + 2], m = [], v = i - o;
|
|
6128
6286
|
if (u && f) {
|
|
6129
|
-
const { bounds: y } = u, { bounds: b } = f,
|
|
6130
|
-
if (
|
|
6131
|
-
const
|
|
6287
|
+
const { bounds: y } = u, { bounds: b } = f, j = y.left - b.right, I = o - y.right, w = Math.abs(I - j);
|
|
6288
|
+
if (w <= e) {
|
|
6289
|
+
const T = j - I, M = o + T, C = {
|
|
6132
6290
|
type: "horizontal",
|
|
6133
6291
|
axis: n,
|
|
6134
6292
|
refStart: b.right,
|
|
6135
6293
|
refEnd: y.left,
|
|
6136
6294
|
activeStart: y.right,
|
|
6137
|
-
activeEnd:
|
|
6138
|
-
distance:
|
|
6295
|
+
activeEnd: M,
|
|
6296
|
+
distance: j
|
|
6139
6297
|
};
|
|
6140
|
-
m.push({ delta:
|
|
6298
|
+
m.push({ delta: T, guide: C, diff: w });
|
|
6141
6299
|
}
|
|
6142
6300
|
}
|
|
6143
6301
|
if (g && p) {
|
|
6144
|
-
const { bounds: y } = g, { bounds: b } = p,
|
|
6145
|
-
if (
|
|
6146
|
-
const
|
|
6302
|
+
const { bounds: y } = g, { bounds: b } = p, j = b.left - y.right, I = y.left - i, w = Math.abs(I - j);
|
|
6303
|
+
if (w <= e) {
|
|
6304
|
+
const T = I - j, M = i + T, C = {
|
|
6147
6305
|
type: "horizontal",
|
|
6148
6306
|
axis: n,
|
|
6149
6307
|
refStart: y.right,
|
|
6150
6308
|
refEnd: b.left,
|
|
6151
|
-
activeStart:
|
|
6309
|
+
activeStart: M,
|
|
6152
6310
|
activeEnd: y.left,
|
|
6153
|
-
distance:
|
|
6311
|
+
distance: j
|
|
6154
6312
|
};
|
|
6155
|
-
m.push({ delta:
|
|
6313
|
+
m.push({ delta: T, guide: C, diff: w });
|
|
6156
6314
|
}
|
|
6157
6315
|
}
|
|
6158
6316
|
if (u && g) {
|
|
6159
|
-
const { bounds: y } = u, { bounds: b } = g,
|
|
6160
|
-
if (
|
|
6161
|
-
const
|
|
6162
|
-
if (
|
|
6163
|
-
const
|
|
6317
|
+
const { bounds: y } = u, { bounds: b } = g, I = b.left - y.right - v;
|
|
6318
|
+
if (I >= 0) {
|
|
6319
|
+
const w = I / 2, T = o - y.right, M = b.left - i, C = Math.abs(T - w), E = Math.abs(M - w), W = Math.max(C, E);
|
|
6320
|
+
if (W <= e) {
|
|
6321
|
+
const N = w - T, x = i + N, Y = {
|
|
6164
6322
|
type: "horizontal",
|
|
6165
6323
|
axis: n,
|
|
6166
6324
|
refStart: y.right,
|
|
6167
|
-
refEnd: y.right +
|
|
6168
|
-
activeStart:
|
|
6169
|
-
activeEnd:
|
|
6170
|
-
distance:
|
|
6325
|
+
refEnd: y.right + w,
|
|
6326
|
+
activeStart: x,
|
|
6327
|
+
activeEnd: x + w,
|
|
6328
|
+
distance: w
|
|
6171
6329
|
};
|
|
6172
|
-
m.push({ delta:
|
|
6330
|
+
m.push({ delta: N, guide: Y, diff: W });
|
|
6173
6331
|
}
|
|
6174
6332
|
}
|
|
6175
6333
|
}
|
|
6176
|
-
const
|
|
6334
|
+
const S = is({
|
|
6177
6335
|
activeBounds: h,
|
|
6178
6336
|
aligned: c,
|
|
6179
6337
|
threshold: e,
|
|
6180
6338
|
patterns: s,
|
|
6181
6339
|
type: "horizontal"
|
|
6182
6340
|
});
|
|
6183
|
-
if (m.push(...
|
|
6341
|
+
if (m.push(...S), !m.length)
|
|
6184
6342
|
return { delta: 0, guide: null };
|
|
6185
|
-
const
|
|
6343
|
+
const A = m.reduce((y, b) => b.diff < y.diff ? b : y, m[0]);
|
|
6186
6344
|
return {
|
|
6187
|
-
delta:
|
|
6188
|
-
guide:
|
|
6345
|
+
delta: A.delta,
|
|
6346
|
+
guide: A.guide
|
|
6189
6347
|
};
|
|
6190
6348
|
}, bn = ({
|
|
6191
6349
|
activeBounds: h,
|
|
@@ -6219,7 +6377,7 @@ const pn = 5, ss = "#3D8BF4", pe = 1, Jt = 1, Ke = ({
|
|
|
6219
6377
|
}) => {
|
|
6220
6378
|
const i = Math.min(o, s / 2, n / 2);
|
|
6221
6379
|
h.moveTo(t + i, e), h.lineTo(t + s - i, e), h.quadraticCurveTo(t + s, e, t + s, e + i), h.lineTo(t + s, e + n - i), h.quadraticCurveTo(t + s, e + n, t + s - i, e + n), h.lineTo(t + i, e + n), h.quadraticCurveTo(t, e + n, t, e + n - i), h.lineTo(t, e + i), h.quadraticCurveTo(t, e, t + i, e), h.closePath();
|
|
6222
|
-
},
|
|
6380
|
+
}, je = ({
|
|
6223
6381
|
context: h,
|
|
6224
6382
|
type: t,
|
|
6225
6383
|
axis: e,
|
|
@@ -6236,16 +6394,16 @@ const pn = 5, ss = "#3D8BF4", pe = 1, Jt = 1, Ke = ({
|
|
|
6236
6394
|
offsetAlongAxis: f = 0,
|
|
6237
6395
|
offsetPerpendicular: g = 0
|
|
6238
6396
|
}) => {
|
|
6239
|
-
const p = i || 1, m = 12 / p, v = l / p,
|
|
6397
|
+
const p = i || 1, m = 12 / p, v = l / p, S = u / p, A = (s + n) / 2 + f, y = t === "vertical" ? e + g : A, b = t === "vertical" ? A : e + g;
|
|
6240
6398
|
h.save(), h.setLineDash([]), h.fillStyle = a, h.strokeStyle = a, h.lineWidth = d / p, h.font = `${m}px ${c}`, h.textAlign = "center", h.textBaseline = "middle";
|
|
6241
|
-
const
|
|
6399
|
+
const I = h.measureText(o).width + v * 2, w = m + v * 2, T = y - I / 2, M = b - w / 2;
|
|
6242
6400
|
h.beginPath(), Mn({
|
|
6243
6401
|
context: h,
|
|
6244
|
-
x:
|
|
6245
|
-
y:
|
|
6246
|
-
width:
|
|
6247
|
-
height:
|
|
6248
|
-
radius:
|
|
6402
|
+
x: T,
|
|
6403
|
+
y: M,
|
|
6404
|
+
width: I,
|
|
6405
|
+
height: w,
|
|
6406
|
+
radius: S
|
|
6249
6407
|
}), h.fill(), h.fillStyle = r, h.fillText(o, y, b), h.restore();
|
|
6250
6408
|
}, wn = ({
|
|
6251
6409
|
context: h,
|
|
@@ -6262,8 +6420,8 @@ const pn = 5, ss = "#3D8BF4", pe = 1, Jt = 1, Ke = ({
|
|
|
6262
6420
|
distance: c
|
|
6263
6421
|
} = t, d = Math.round(c).toString();
|
|
6264
6422
|
h.beginPath(), s === "vertical" ? (h.moveTo(n, o), h.lineTo(n, i), h.moveTo(n, a), h.lineTo(n, r)) : (h.moveTo(o, n), h.lineTo(i, n), h.moveTo(a, n), h.lineTo(r, n)), h.stroke();
|
|
6265
|
-
const l =
|
|
6266
|
-
|
|
6423
|
+
const l = os;
|
|
6424
|
+
je({
|
|
6267
6425
|
context: h,
|
|
6268
6426
|
type: s,
|
|
6269
6427
|
axis: n,
|
|
@@ -6272,8 +6430,8 @@ const pn = 5, ss = "#3D8BF4", pe = 1, Jt = 1, Ke = ({
|
|
|
6272
6430
|
text: d,
|
|
6273
6431
|
zoom: e,
|
|
6274
6432
|
color: l,
|
|
6275
|
-
lineWidth:
|
|
6276
|
-
}),
|
|
6433
|
+
lineWidth: Ae
|
|
6434
|
+
}), je({
|
|
6277
6435
|
context: h,
|
|
6278
6436
|
type: s,
|
|
6279
6437
|
axis: n,
|
|
@@ -6282,9 +6440,9 @@ const pn = 5, ss = "#3D8BF4", pe = 1, Jt = 1, Ke = ({
|
|
|
6282
6440
|
text: d,
|
|
6283
6441
|
zoom: e,
|
|
6284
6442
|
color: l,
|
|
6285
|
-
lineWidth:
|
|
6443
|
+
lineWidth: Ae
|
|
6286
6444
|
});
|
|
6287
|
-
},
|
|
6445
|
+
}, qe = ({
|
|
6288
6446
|
anchors: h,
|
|
6289
6447
|
bounds: t
|
|
6290
6448
|
}) => {
|
|
@@ -6297,7 +6455,7 @@ const pn = 5, ss = "#3D8BF4", pe = 1, Jt = 1, Ke = ({
|
|
|
6297
6455
|
centerY: a
|
|
6298
6456
|
} = t;
|
|
6299
6457
|
h.vertical.push(e, n, s), h.horizontal.push(o, a, i);
|
|
6300
|
-
},
|
|
6458
|
+
}, $e = ({
|
|
6301
6459
|
bounds: h,
|
|
6302
6460
|
type: t,
|
|
6303
6461
|
primaryStart: e,
|
|
@@ -6310,8 +6468,8 @@ const pn = 5, ss = "#3D8BF4", pe = 1, Jt = 1, Ke = ({
|
|
|
6310
6468
|
for (let p = r + 1; p < a.length; p += 1) {
|
|
6311
6469
|
const m = a[p];
|
|
6312
6470
|
if (Math.min(c[i], m[i]) - Math.max(c[o], m[o]) < 0) continue;
|
|
6313
|
-
const
|
|
6314
|
-
|
|
6471
|
+
const S = m[e] - c[s];
|
|
6472
|
+
S < 0 || S < l && (l = S, d = m);
|
|
6315
6473
|
}
|
|
6316
6474
|
if (!d || l === Number.POSITIVE_INFINITY) continue;
|
|
6317
6475
|
const u = Math.max(c[o], d[o]), f = Math.min(c[i], d[i]), g = (u + f) / 2;
|
|
@@ -6327,24 +6485,24 @@ const pn = 5, ss = "#3D8BF4", pe = 1, Jt = 1, Ke = ({
|
|
|
6327
6485
|
}, Sn = ({
|
|
6328
6486
|
bounds: h
|
|
6329
6487
|
}) => {
|
|
6330
|
-
const t =
|
|
6488
|
+
const t = $e({
|
|
6331
6489
|
bounds: h,
|
|
6332
6490
|
type: "vertical",
|
|
6333
6491
|
primaryStart: "top",
|
|
6334
6492
|
primaryEnd: "bottom"
|
|
6335
|
-
}), e =
|
|
6493
|
+
}), e = $e({
|
|
6336
6494
|
bounds: h,
|
|
6337
6495
|
type: "horizontal",
|
|
6338
6496
|
primaryStart: "left",
|
|
6339
6497
|
primaryEnd: "right"
|
|
6340
6498
|
});
|
|
6341
6499
|
return { vertical: t, horizontal: e };
|
|
6342
|
-
}, An = ["montage-area", "background", "interaction-blocker"],
|
|
6500
|
+
}, An = ["montage-area", "background", "interaction-blocker"], as = ({
|
|
6343
6501
|
activeObject: h
|
|
6344
6502
|
}) => {
|
|
6345
6503
|
const t = /* @__PURE__ */ new Set();
|
|
6346
6504
|
return h && (t.add(h), h instanceof U && h.getObjects().forEach((e) => t.add(e))), t;
|
|
6347
|
-
},
|
|
6505
|
+
}, rs = ({
|
|
6348
6506
|
object: h,
|
|
6349
6507
|
excluded: t,
|
|
6350
6508
|
ignoredIds: e = An
|
|
@@ -6413,7 +6571,7 @@ class jn {
|
|
|
6413
6571
|
return;
|
|
6414
6572
|
}
|
|
6415
6573
|
!this.anchors.vertical.length && !this.anchors.horizontal.length && this._cacheAnchors({ activeObject: e });
|
|
6416
|
-
let o =
|
|
6574
|
+
let o = mt({ object: e });
|
|
6417
6575
|
if (!o) {
|
|
6418
6576
|
this._clearGuides();
|
|
6419
6577
|
return;
|
|
@@ -6424,24 +6582,24 @@ class jn {
|
|
|
6424
6582
|
anchors: this.anchors
|
|
6425
6583
|
}), { deltaX: d, deltaY: l, guides: u } = c;
|
|
6426
6584
|
if (d !== 0 || l !== 0) {
|
|
6427
|
-
const { left: v = 0, top:
|
|
6585
|
+
const { left: v = 0, top: S = 0 } = e;
|
|
6428
6586
|
e.set({
|
|
6429
6587
|
left: v + d,
|
|
6430
|
-
top:
|
|
6431
|
-
}), e.setCoords(), o = (p =
|
|
6588
|
+
top: S + l
|
|
6589
|
+
}), e.setCoords(), o = (p = mt({ object: e })) != null ? p : o;
|
|
6432
6590
|
}
|
|
6433
|
-
const f = this.cachedTargetBounds.length ? this.cachedTargetBounds : this._collectTargets({ activeObject: e }).map((v) =>
|
|
6591
|
+
const f = this.cachedTargetBounds.length ? this.cachedTargetBounds : this._collectTargets({ activeObject: e }).map((v) => mt({ object: v })).filter((v) => !!v), g = bn({
|
|
6434
6592
|
activeBounds: o,
|
|
6435
6593
|
candidates: f,
|
|
6436
6594
|
threshold: r,
|
|
6437
6595
|
spacingPatterns: this.spacingPatterns
|
|
6438
6596
|
});
|
|
6439
6597
|
if (g.deltaX !== 0 || g.deltaY !== 0) {
|
|
6440
|
-
const { left: v = 0, top:
|
|
6598
|
+
const { left: v = 0, top: S = 0 } = e;
|
|
6441
6599
|
e.set({
|
|
6442
6600
|
left: v + g.deltaX,
|
|
6443
|
-
top:
|
|
6444
|
-
}), e.setCoords(), o = (m =
|
|
6601
|
+
top: S + g.deltaY
|
|
6602
|
+
}), e.setCoords(), o = (m = mt({ object: e })) != null ? m : o;
|
|
6445
6603
|
}
|
|
6446
6604
|
this._applyGuides({
|
|
6447
6605
|
guides: u,
|
|
@@ -6469,7 +6627,7 @@ class jn {
|
|
|
6469
6627
|
const { canvas: t, guideBounds: e } = this, s = t.getSelectionContext();
|
|
6470
6628
|
if (!s) return;
|
|
6471
6629
|
const n = e != null ? e : this._calculateViewportBounds(), { left: o, right: i, top: a, bottom: r } = n, { viewportTransform: c } = t, d = t.getZoom() || 1;
|
|
6472
|
-
s.save(), Array.isArray(c) && s.transform(...c), s.lineWidth =
|
|
6630
|
+
s.save(), Array.isArray(c) && s.transform(...c), s.lineWidth = Ae / d, s.strokeStyle = os, s.setLineDash([4, 4]);
|
|
6473
6631
|
for (const l of this.activeGuides)
|
|
6474
6632
|
s.beginPath(), l.type === "vertical" ? (s.moveTo(l.position, a), s.lineTo(l.position, r)) : (s.moveTo(o, l.position), s.lineTo(i, l.position)), s.stroke();
|
|
6475
6633
|
for (const l of this.activeSpacingGuides)
|
|
@@ -6509,7 +6667,7 @@ class jn {
|
|
|
6509
6667
|
* Применяет шаг перемещения, округляя координаты объекта к сетке MOVE_SNAP_STEP.
|
|
6510
6668
|
*/
|
|
6511
6669
|
_applyMovementStep({ target: t }) {
|
|
6512
|
-
const { left: e = 0, top: s = 0 } = t, n = Math.round(e /
|
|
6670
|
+
const { left: e = 0, top: s = 0 } = t, n = Math.round(e / ce) * ce, o = Math.round(s / ce) * ce;
|
|
6513
6671
|
n === e && o === s || (t.set({
|
|
6514
6672
|
left: n,
|
|
6515
6673
|
top: o
|
|
@@ -6521,12 +6679,12 @@ class jn {
|
|
|
6521
6679
|
_cacheAnchors({ activeObject: t }) {
|
|
6522
6680
|
const e = this._collectTargets({ activeObject: t }), s = { vertical: [], horizontal: [] }, n = [];
|
|
6523
6681
|
for (const a of e) {
|
|
6524
|
-
const r =
|
|
6525
|
-
r && (
|
|
6682
|
+
const r = mt({ object: a });
|
|
6683
|
+
r && (qe({ anchors: s, bounds: r }), n.push(r));
|
|
6526
6684
|
}
|
|
6527
|
-
const { montageArea: o } = this.editor, i =
|
|
6685
|
+
const { montageArea: o } = this.editor, i = mt({ object: o });
|
|
6528
6686
|
if (i) {
|
|
6529
|
-
|
|
6687
|
+
qe({ anchors: s, bounds: i });
|
|
6530
6688
|
const { left: a, right: r, top: c, bottom: d } = i;
|
|
6531
6689
|
this.guideBounds = {
|
|
6532
6690
|
left: a,
|
|
@@ -6542,9 +6700,9 @@ class jn {
|
|
|
6542
6700
|
* Собирает объекты, подходящие для прилипания, исключая активный объект и запрещённые id.
|
|
6543
6701
|
*/
|
|
6544
6702
|
_collectTargets({ activeObject: t }) {
|
|
6545
|
-
const e =
|
|
6703
|
+
const e = as({ activeObject: t }), s = [];
|
|
6546
6704
|
return this.canvas.forEachObject((n) => {
|
|
6547
|
-
|
|
6705
|
+
rs({ object: n, excluded: e }) || s.push(n);
|
|
6548
6706
|
}), s;
|
|
6549
6707
|
}
|
|
6550
6708
|
/**
|
|
@@ -6567,7 +6725,7 @@ class jn {
|
|
|
6567
6725
|
};
|
|
6568
6726
|
}
|
|
6569
6727
|
}
|
|
6570
|
-
const
|
|
6728
|
+
const ts = "#3D8BF4", es = 1;
|
|
6571
6729
|
class Lt {
|
|
6572
6730
|
/**
|
|
6573
6731
|
* Создаёт менеджер измерений и инициализирует события.
|
|
@@ -6673,7 +6831,7 @@ class Lt {
|
|
|
6673
6831
|
this._clearGuides();
|
|
6674
6832
|
return;
|
|
6675
6833
|
}
|
|
6676
|
-
const o =
|
|
6834
|
+
const o = mt({ object: n });
|
|
6677
6835
|
if (!o) {
|
|
6678
6836
|
this._clearGuides();
|
|
6679
6837
|
return;
|
|
@@ -6681,7 +6839,7 @@ class Lt {
|
|
|
6681
6839
|
const i = Lt._resolveTarget({
|
|
6682
6840
|
event: t,
|
|
6683
6841
|
activeObject: n
|
|
6684
|
-
}), { montageArea: a } = s, r = i != null ? i : a, c = r === a, d =
|
|
6842
|
+
}), { montageArea: a } = s, r = i != null ? i : a, c = r === a, d = mt({ object: r });
|
|
6685
6843
|
if (!d) {
|
|
6686
6844
|
this._clearGuides();
|
|
6687
6845
|
return;
|
|
@@ -6708,8 +6866,8 @@ class Lt {
|
|
|
6708
6866
|
event: t,
|
|
6709
6867
|
activeObject: e
|
|
6710
6868
|
}) {
|
|
6711
|
-
const { target: s } = t, n =
|
|
6712
|
-
return s && !
|
|
6869
|
+
const { target: s } = t, n = as({ activeObject: e });
|
|
6870
|
+
return s && !rs({ object: s, excluded: n }) ? s : null;
|
|
6713
6871
|
}
|
|
6714
6872
|
/**
|
|
6715
6873
|
* Собирает вертикальные и горизонтальные направляющие расстояний.
|
|
@@ -6750,45 +6908,45 @@ class Lt {
|
|
|
6750
6908
|
top: u = 0,
|
|
6751
6909
|
bottom: f = 0,
|
|
6752
6910
|
centerY: g = 0
|
|
6753
|
-
} = e, p = Math.max(a, u), m = Math.min(r, f),
|
|
6911
|
+
} = e, p = Math.max(a, u), m = Math.min(r, f), S = m >= p ? (p + m) / 2 : (c + g) / 2;
|
|
6754
6912
|
if (d >= i) {
|
|
6755
6913
|
if (s) return n;
|
|
6756
|
-
const
|
|
6757
|
-
return
|
|
6914
|
+
const C = d - i;
|
|
6915
|
+
return C > 0 && n.push({
|
|
6758
6916
|
type: "horizontal",
|
|
6759
|
-
axis:
|
|
6917
|
+
axis: S,
|
|
6760
6918
|
start: i,
|
|
6761
6919
|
end: d,
|
|
6762
|
-
distance:
|
|
6920
|
+
distance: C
|
|
6763
6921
|
}), n;
|
|
6764
6922
|
}
|
|
6765
6923
|
if (l <= o) {
|
|
6766
6924
|
if (s) return n;
|
|
6767
|
-
const
|
|
6768
|
-
return
|
|
6925
|
+
const C = o - l;
|
|
6926
|
+
return C > 0 && n.push({
|
|
6769
6927
|
type: "horizontal",
|
|
6770
|
-
axis:
|
|
6928
|
+
axis: S,
|
|
6771
6929
|
start: l,
|
|
6772
6930
|
end: o,
|
|
6773
|
-
distance:
|
|
6931
|
+
distance: C
|
|
6774
6932
|
}), n;
|
|
6775
6933
|
}
|
|
6776
6934
|
if (!s) return n;
|
|
6777
|
-
const
|
|
6778
|
-
|
|
6935
|
+
const A = o < d, y = i > l, b = Math.min(o, d), j = Math.max(o, d), I = j - b;
|
|
6936
|
+
I > 0 && !A && n.push({
|
|
6779
6937
|
type: "horizontal",
|
|
6780
|
-
axis:
|
|
6938
|
+
axis: S,
|
|
6781
6939
|
start: b,
|
|
6782
|
-
end:
|
|
6783
|
-
distance:
|
|
6940
|
+
end: j,
|
|
6941
|
+
distance: I
|
|
6784
6942
|
});
|
|
6785
|
-
const
|
|
6786
|
-
return
|
|
6943
|
+
const w = Math.min(i, l), T = Math.max(i, l), M = T - w;
|
|
6944
|
+
return M > 0 && !y && n.push({
|
|
6787
6945
|
type: "horizontal",
|
|
6788
|
-
axis:
|
|
6789
|
-
start:
|
|
6790
|
-
end:
|
|
6791
|
-
distance:
|
|
6946
|
+
axis: S,
|
|
6947
|
+
start: w,
|
|
6948
|
+
end: T,
|
|
6949
|
+
distance: M
|
|
6792
6950
|
}), n;
|
|
6793
6951
|
}
|
|
6794
6952
|
/**
|
|
@@ -6811,45 +6969,45 @@ class Lt {
|
|
|
6811
6969
|
left: u = 0,
|
|
6812
6970
|
right: f = 0,
|
|
6813
6971
|
centerX: g = 0
|
|
6814
|
-
} = e, p = Math.max(a, u), m = Math.min(r, f),
|
|
6972
|
+
} = e, p = Math.max(a, u), m = Math.min(r, f), S = m >= p ? (p + m) / 2 : (c + g) / 2;
|
|
6815
6973
|
if (d >= i) {
|
|
6816
6974
|
if (s) return n;
|
|
6817
|
-
const
|
|
6818
|
-
return
|
|
6975
|
+
const C = d - i;
|
|
6976
|
+
return C > 0 && n.push({
|
|
6819
6977
|
type: "vertical",
|
|
6820
|
-
axis:
|
|
6978
|
+
axis: S,
|
|
6821
6979
|
start: i,
|
|
6822
6980
|
end: d,
|
|
6823
|
-
distance:
|
|
6981
|
+
distance: C
|
|
6824
6982
|
}), n;
|
|
6825
6983
|
}
|
|
6826
6984
|
if (l <= o) {
|
|
6827
6985
|
if (s) return n;
|
|
6828
|
-
const
|
|
6829
|
-
return
|
|
6986
|
+
const C = o - l;
|
|
6987
|
+
return C > 0 && n.push({
|
|
6830
6988
|
type: "vertical",
|
|
6831
|
-
axis:
|
|
6989
|
+
axis: S,
|
|
6832
6990
|
start: l,
|
|
6833
6991
|
end: o,
|
|
6834
|
-
distance:
|
|
6992
|
+
distance: C
|
|
6835
6993
|
}), n;
|
|
6836
6994
|
}
|
|
6837
6995
|
if (!s) return n;
|
|
6838
|
-
const
|
|
6839
|
-
|
|
6996
|
+
const A = o < d, y = i > l, b = Math.min(o, d), j = Math.max(o, d), I = j - b;
|
|
6997
|
+
I > 0 && !A && n.push({
|
|
6840
6998
|
type: "vertical",
|
|
6841
|
-
axis:
|
|
6999
|
+
axis: S,
|
|
6842
7000
|
start: b,
|
|
6843
|
-
end:
|
|
6844
|
-
distance:
|
|
7001
|
+
end: j,
|
|
7002
|
+
distance: I
|
|
6845
7003
|
});
|
|
6846
|
-
const
|
|
6847
|
-
return
|
|
7004
|
+
const w = Math.min(i, l), T = Math.max(i, l), M = T - w;
|
|
7005
|
+
return M > 0 && !y && n.push({
|
|
6848
7006
|
type: "vertical",
|
|
6849
|
-
axis:
|
|
6850
|
-
start:
|
|
6851
|
-
end:
|
|
6852
|
-
distance:
|
|
7007
|
+
axis: S,
|
|
7008
|
+
start: w,
|
|
7009
|
+
end: T,
|
|
7010
|
+
distance: M
|
|
6853
7011
|
}), n;
|
|
6854
7012
|
}
|
|
6855
7013
|
/**
|
|
@@ -6877,10 +7035,10 @@ class Lt {
|
|
|
6877
7035
|
const { canvas: t } = this, e = t.getSelectionContext();
|
|
6878
7036
|
if (!e) return;
|
|
6879
7037
|
const { viewportTransform: s } = t, n = t.getZoom() || 1, o = this.activeGuides.some((c) => c.type === "vertical"), i = this.activeGuides.some((c) => c.type === "horizontal"), a = o && i && !this.isTargetMontageArea, r = a ? 12 / n : 0;
|
|
6880
|
-
e.save(), Array.isArray(s) && e.transform(...s), e.lineWidth =
|
|
7038
|
+
e.save(), Array.isArray(s) && e.transform(...s), e.lineWidth = es / n, e.strokeStyle = ts, e.setLineDash([]);
|
|
6881
7039
|
for (const c of this.activeGuides) {
|
|
6882
|
-
const { type: d, axis: l, start: u, end: f, distance: g } = c, p = Math.abs(f - u), m = u <= f ? -1 : 1, v = a ? m * (p / 2 + r) : 0,
|
|
6883
|
-
e.beginPath(), d === "vertical" ? (e.moveTo(l, u), e.lineTo(l, f)) : (e.moveTo(u, l), e.lineTo(f, l)), e.stroke(),
|
|
7040
|
+
const { type: d, axis: l, start: u, end: f, distance: g } = c, p = Math.abs(f - u), m = u <= f ? -1 : 1, v = a ? m * (p / 2 + r) : 0, S = 0;
|
|
7041
|
+
e.beginPath(), d === "vertical" ? (e.moveTo(l, u), e.lineTo(l, f)) : (e.moveTo(u, l), e.lineTo(f, l)), e.stroke(), je({
|
|
6884
7042
|
context: e,
|
|
6885
7043
|
type: d,
|
|
6886
7044
|
axis: l,
|
|
@@ -6888,10 +7046,10 @@ class Lt {
|
|
|
6888
7046
|
end: f,
|
|
6889
7047
|
text: Math.round(g).toString(),
|
|
6890
7048
|
zoom: n,
|
|
6891
|
-
color:
|
|
6892
|
-
lineWidth:
|
|
7049
|
+
color: ts,
|
|
7050
|
+
lineWidth: es,
|
|
6893
7051
|
offsetAlongAxis: v,
|
|
6894
|
-
offsetPerpendicular:
|
|
7052
|
+
offsetPerpendicular: S
|
|
6895
7053
|
});
|
|
6896
7054
|
}
|
|
6897
7055
|
e.restore();
|
|
@@ -6915,7 +7073,7 @@ class Lt {
|
|
|
6915
7073
|
(e = t == null ? void 0 : t.showAfterTemporary) == null || e.call(t), this.isToolbarHidden = !1;
|
|
6916
7074
|
}
|
|
6917
7075
|
}
|
|
6918
|
-
class
|
|
7076
|
+
class Le {
|
|
6919
7077
|
/**
|
|
6920
7078
|
* Конструктор класса ImageEditor.
|
|
6921
7079
|
* @param canvasId - идентификатор канваса, в котором будет создан редактор
|
|
@@ -6930,7 +7088,7 @@ class Se {
|
|
|
6930
7088
|
* @fires editor:ready
|
|
6931
7089
|
*/
|
|
6932
7090
|
init() {
|
|
6933
|
-
return
|
|
7091
|
+
return z(this, null, function* () {
|
|
6934
7092
|
var u;
|
|
6935
7093
|
const {
|
|
6936
7094
|
editorContainerWidth: t,
|
|
@@ -6945,13 +7103,17 @@ class Se {
|
|
|
6945
7103
|
showRotationAngle: d,
|
|
6946
7104
|
_onReadyCallback: l
|
|
6947
7105
|
} = this.options;
|
|
6948
|
-
if (
|
|
6949
|
-
const {
|
|
6950
|
-
source:
|
|
6951
|
-
scale:
|
|
6952
|
-
withoutSave:
|
|
6953
|
-
} =
|
|
6954
|
-
|
|
7106
|
+
if (et.apply(), this.canvas = new vs(this.containerId, this.options), this.moduleLoader = new As(), this.workerManager = new Is(), this.errorManager = new Qt({ editor: this }), this.historyManager = new Kt({ editor: this }), this.toolbar = new Us({ editor: this }), this.transformManager = new Js({ editor: this }), this.zoomManager = new qs({ editor: this }), this.canvasManager = new Qs({ editor: this }), this.imageManager = new ht({ editor: this }), this.layerManager = new le({ editor: this }), this.shapeManager = new tn({ editor: this }), this.interactionBlocker = new $s({ editor: this }), this.backgroundManager = new Ot({ editor: this }), this.clipboardManager = new en({ editor: this }), this.objectLockManager = new he({ editor: this }), this.groupingManager = new sn({ editor: this }), this.selectionManager = new nn({ editor: this }), this.deletionManager = new Oe({ editor: this }), this.panConstraintManager = new on({ editor: this }), this.snappingManager = new jn({ editor: this }), this.measurementManager = new Lt({ editor: this }), this.fontManager = new Se((u = this.options.fonts) != null ? u : []), this.textManager = new k({ editor: this }), this.templateManager = new _({ editor: this }), d && (this.angleIndicator = new Ee({ editor: this })), this._createMontageArea(), this._createClippingArea(), this.listeners = new Xt({ editor: this, options: this.options }), this.canvasManager.setEditorContainerWidth(t), this.canvasManager.setEditorContainerHeight(e), this.canvasManager.setCanvasWrapperWidth(s), this.canvasManager.setCanvasWrapperHeight(n), this.canvasManager.setCanvasCSSWidth(o), this.canvasManager.setCanvasCSSHeight(i), this.canvasManager.updateCanvas(), this.zoomManager.calculateAndApplyDefaultZoom(), yield this.fontManager.loadFonts(), a != null && a.source) {
|
|
7107
|
+
const f = a, {
|
|
7108
|
+
source: g,
|
|
7109
|
+
scale: p = `image-${c}`,
|
|
7110
|
+
withoutSave: m = !0
|
|
7111
|
+
} = f, v = gt(f, [
|
|
7112
|
+
"source",
|
|
7113
|
+
"scale",
|
|
7114
|
+
"withoutSave"
|
|
7115
|
+
]);
|
|
7116
|
+
yield this.imageManager.importImage(B({ source: g, scale: p, withoutSave: m }, v));
|
|
6955
7117
|
}
|
|
6956
7118
|
r && this.historyManager.loadStateFromFullState(r), this.historyManager.saveState(), console.log("editor:ready"), this.canvas.fire("editor:ready", this), typeof l == "function" && l(this);
|
|
6957
7119
|
});
|
|
@@ -6967,7 +7129,7 @@ class Se {
|
|
|
6967
7129
|
this.montageArea = this.shapeManager.addRectangle({
|
|
6968
7130
|
width: t,
|
|
6969
7131
|
height: e,
|
|
6970
|
-
fill:
|
|
7132
|
+
fill: Le._createMosaicPattern(),
|
|
6971
7133
|
stroke: null,
|
|
6972
7134
|
strokeWidth: 0,
|
|
6973
7135
|
selectable: !1,
|
|
@@ -7018,13 +7180,13 @@ class Se {
|
|
|
7018
7180
|
const t = document.createElement("canvas");
|
|
7019
7181
|
t.width = 20, t.height = 20;
|
|
7020
7182
|
const e = t.getContext("2d");
|
|
7021
|
-
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
|
|
7183
|
+
return e.fillStyle = "#ddd", e.fillRect(0, 0, 40, 40), e.fillStyle = "#ccc", e.fillRect(0, 0, 10, 10), e.fillRect(10, 10, 10, 10), new bs({
|
|
7022
7184
|
source: t,
|
|
7023
7185
|
repeat: "repeat"
|
|
7024
7186
|
});
|
|
7025
7187
|
}
|
|
7026
7188
|
}
|
|
7027
|
-
const
|
|
7189
|
+
const L = [
|
|
7028
7190
|
"U+0000-00FF",
|
|
7029
7191
|
"U+0100-02BA",
|
|
7030
7192
|
"U+02BB-02BC",
|
|
@@ -7054,7 +7216,7 @@ const O = [
|
|
|
7054
7216
|
"U+A720-A7FF",
|
|
7055
7217
|
"U+FEFF",
|
|
7056
7218
|
"U+FFFD"
|
|
7057
|
-
].join(", "),
|
|
7219
|
+
].join(", "), D = [
|
|
7058
7220
|
"U+0301",
|
|
7059
7221
|
"U+0400-052F",
|
|
7060
7222
|
"U+1C80-1C8A",
|
|
@@ -7080,7 +7242,7 @@ const O = [
|
|
|
7080
7242
|
style: "normal",
|
|
7081
7243
|
weight: "400",
|
|
7082
7244
|
display: "swap",
|
|
7083
|
-
unicodeRange:
|
|
7245
|
+
unicodeRange: D
|
|
7084
7246
|
}
|
|
7085
7247
|
},
|
|
7086
7248
|
{
|
|
@@ -7090,7 +7252,7 @@ const O = [
|
|
|
7090
7252
|
style: "normal",
|
|
7091
7253
|
weight: "400",
|
|
7092
7254
|
display: "swap",
|
|
7093
|
-
unicodeRange:
|
|
7255
|
+
unicodeRange: L
|
|
7094
7256
|
}
|
|
7095
7257
|
},
|
|
7096
7258
|
{
|
|
@@ -7100,7 +7262,7 @@ const O = [
|
|
|
7100
7262
|
style: "normal",
|
|
7101
7263
|
weight: "700",
|
|
7102
7264
|
display: "swap",
|
|
7103
|
-
unicodeRange:
|
|
7265
|
+
unicodeRange: D
|
|
7104
7266
|
}
|
|
7105
7267
|
},
|
|
7106
7268
|
{
|
|
@@ -7110,7 +7272,7 @@ const O = [
|
|
|
7110
7272
|
style: "normal",
|
|
7111
7273
|
weight: "700",
|
|
7112
7274
|
display: "swap",
|
|
7113
|
-
unicodeRange:
|
|
7275
|
+
unicodeRange: L
|
|
7114
7276
|
}
|
|
7115
7277
|
},
|
|
7116
7278
|
{
|
|
@@ -7120,7 +7282,7 @@ const O = [
|
|
|
7120
7282
|
style: "normal",
|
|
7121
7283
|
weight: "200 700",
|
|
7122
7284
|
display: "swap",
|
|
7123
|
-
unicodeRange:
|
|
7285
|
+
unicodeRange: D
|
|
7124
7286
|
}
|
|
7125
7287
|
},
|
|
7126
7288
|
{
|
|
@@ -7130,7 +7292,7 @@ const O = [
|
|
|
7130
7292
|
style: "normal",
|
|
7131
7293
|
weight: "200 700",
|
|
7132
7294
|
display: "swap",
|
|
7133
|
-
unicodeRange:
|
|
7295
|
+
unicodeRange: L
|
|
7134
7296
|
}
|
|
7135
7297
|
},
|
|
7136
7298
|
{
|
|
@@ -7140,7 +7302,7 @@ const O = [
|
|
|
7140
7302
|
style: "normal",
|
|
7141
7303
|
weight: "300 900",
|
|
7142
7304
|
display: "swap",
|
|
7143
|
-
unicodeRange:
|
|
7305
|
+
unicodeRange: D
|
|
7144
7306
|
}
|
|
7145
7307
|
},
|
|
7146
7308
|
{
|
|
@@ -7150,7 +7312,7 @@ const O = [
|
|
|
7150
7312
|
style: "normal",
|
|
7151
7313
|
weight: "300 900",
|
|
7152
7314
|
display: "swap",
|
|
7153
|
-
unicodeRange:
|
|
7315
|
+
unicodeRange: L
|
|
7154
7316
|
}
|
|
7155
7317
|
},
|
|
7156
7318
|
{
|
|
@@ -7160,7 +7322,7 @@ const O = [
|
|
|
7160
7322
|
style: "normal",
|
|
7161
7323
|
weight: "400 700",
|
|
7162
7324
|
display: "swap",
|
|
7163
|
-
unicodeRange:
|
|
7325
|
+
unicodeRange: D
|
|
7164
7326
|
}
|
|
7165
7327
|
},
|
|
7166
7328
|
{
|
|
@@ -7170,7 +7332,7 @@ const O = [
|
|
|
7170
7332
|
style: "normal",
|
|
7171
7333
|
weight: "400 700",
|
|
7172
7334
|
display: "swap",
|
|
7173
|
-
unicodeRange:
|
|
7335
|
+
unicodeRange: L
|
|
7174
7336
|
}
|
|
7175
7337
|
},
|
|
7176
7338
|
{
|
|
@@ -7180,7 +7342,7 @@ const O = [
|
|
|
7180
7342
|
style: "normal",
|
|
7181
7343
|
weight: "300 700",
|
|
7182
7344
|
display: "swap",
|
|
7183
|
-
unicodeRange:
|
|
7345
|
+
unicodeRange: D
|
|
7184
7346
|
}
|
|
7185
7347
|
},
|
|
7186
7348
|
{
|
|
@@ -7190,7 +7352,7 @@ const O = [
|
|
|
7190
7352
|
style: "normal",
|
|
7191
7353
|
weight: "300 700",
|
|
7192
7354
|
display: "swap",
|
|
7193
|
-
unicodeRange:
|
|
7355
|
+
unicodeRange: L
|
|
7194
7356
|
}
|
|
7195
7357
|
},
|
|
7196
7358
|
{
|
|
@@ -7200,7 +7362,7 @@ const O = [
|
|
|
7200
7362
|
style: "normal",
|
|
7201
7363
|
weight: "300 700",
|
|
7202
7364
|
display: "swap",
|
|
7203
|
-
unicodeRange:
|
|
7365
|
+
unicodeRange: D
|
|
7204
7366
|
}
|
|
7205
7367
|
},
|
|
7206
7368
|
{
|
|
@@ -7210,7 +7372,7 @@ const O = [
|
|
|
7210
7372
|
style: "normal",
|
|
7211
7373
|
weight: "300 700",
|
|
7212
7374
|
display: "swap",
|
|
7213
|
-
unicodeRange:
|
|
7375
|
+
unicodeRange: L
|
|
7214
7376
|
}
|
|
7215
7377
|
},
|
|
7216
7378
|
{
|
|
@@ -7220,7 +7382,7 @@ const O = [
|
|
|
7220
7382
|
style: "normal",
|
|
7221
7383
|
weight: "400",
|
|
7222
7384
|
display: "swap",
|
|
7223
|
-
unicodeRange:
|
|
7385
|
+
unicodeRange: D
|
|
7224
7386
|
}
|
|
7225
7387
|
},
|
|
7226
7388
|
{
|
|
@@ -7230,7 +7392,7 @@ const O = [
|
|
|
7230
7392
|
style: "normal",
|
|
7231
7393
|
weight: "400",
|
|
7232
7394
|
display: "swap",
|
|
7233
|
-
unicodeRange:
|
|
7395
|
+
unicodeRange: L
|
|
7234
7396
|
}
|
|
7235
7397
|
},
|
|
7236
7398
|
{
|
|
@@ -7240,7 +7402,7 @@ const O = [
|
|
|
7240
7402
|
style: "normal",
|
|
7241
7403
|
weight: "400 700",
|
|
7242
7404
|
display: "swap",
|
|
7243
|
-
unicodeRange:
|
|
7405
|
+
unicodeRange: D
|
|
7244
7406
|
}
|
|
7245
7407
|
},
|
|
7246
7408
|
{
|
|
@@ -7250,7 +7412,7 @@ const O = [
|
|
|
7250
7412
|
style: "normal",
|
|
7251
7413
|
weight: "400 700",
|
|
7252
7414
|
display: "swap",
|
|
7253
|
-
unicodeRange:
|
|
7415
|
+
unicodeRange: L
|
|
7254
7416
|
}
|
|
7255
7417
|
},
|
|
7256
7418
|
{
|
|
@@ -7260,7 +7422,7 @@ const O = [
|
|
|
7260
7422
|
style: "normal",
|
|
7261
7423
|
weight: "100 900",
|
|
7262
7424
|
display: "swap",
|
|
7263
|
-
unicodeRange:
|
|
7425
|
+
unicodeRange: D
|
|
7264
7426
|
}
|
|
7265
7427
|
},
|
|
7266
7428
|
{
|
|
@@ -7270,7 +7432,7 @@ const O = [
|
|
|
7270
7432
|
style: "normal",
|
|
7271
7433
|
weight: "100 900",
|
|
7272
7434
|
display: "swap",
|
|
7273
|
-
unicodeRange:
|
|
7435
|
+
unicodeRange: L
|
|
7274
7436
|
}
|
|
7275
7437
|
},
|
|
7276
7438
|
{
|
|
@@ -7280,7 +7442,7 @@ const O = [
|
|
|
7280
7442
|
style: "normal",
|
|
7281
7443
|
weight: "400",
|
|
7282
7444
|
display: "swap",
|
|
7283
|
-
unicodeRange:
|
|
7445
|
+
unicodeRange: D
|
|
7284
7446
|
}
|
|
7285
7447
|
},
|
|
7286
7448
|
{
|
|
@@ -7290,7 +7452,7 @@ const O = [
|
|
|
7290
7452
|
style: "normal",
|
|
7291
7453
|
weight: "400",
|
|
7292
7454
|
display: "swap",
|
|
7293
|
-
unicodeRange:
|
|
7455
|
+
unicodeRange: L
|
|
7294
7456
|
}
|
|
7295
7457
|
},
|
|
7296
7458
|
{
|
|
@@ -7300,7 +7462,7 @@ const O = [
|
|
|
7300
7462
|
style: "normal",
|
|
7301
7463
|
weight: "700",
|
|
7302
7464
|
display: "swap",
|
|
7303
|
-
unicodeRange:
|
|
7465
|
+
unicodeRange: D
|
|
7304
7466
|
}
|
|
7305
7467
|
},
|
|
7306
7468
|
{
|
|
@@ -7310,7 +7472,7 @@ const O = [
|
|
|
7310
7472
|
style: "normal",
|
|
7311
7473
|
weight: "700",
|
|
7312
7474
|
display: "swap",
|
|
7313
|
-
unicodeRange:
|
|
7475
|
+
unicodeRange: L
|
|
7314
7476
|
}
|
|
7315
7477
|
},
|
|
7316
7478
|
{
|
|
@@ -7320,7 +7482,7 @@ const O = [
|
|
|
7320
7482
|
style: "normal",
|
|
7321
7483
|
weight: "400 700",
|
|
7322
7484
|
display: "swap",
|
|
7323
|
-
unicodeRange:
|
|
7485
|
+
unicodeRange: D
|
|
7324
7486
|
}
|
|
7325
7487
|
},
|
|
7326
7488
|
{
|
|
@@ -7330,7 +7492,7 @@ const O = [
|
|
|
7330
7492
|
style: "normal",
|
|
7331
7493
|
weight: "400 700",
|
|
7332
7494
|
display: "swap",
|
|
7333
|
-
unicodeRange:
|
|
7495
|
+
unicodeRange: L
|
|
7334
7496
|
}
|
|
7335
7497
|
},
|
|
7336
7498
|
{
|
|
@@ -7340,7 +7502,7 @@ const O = [
|
|
|
7340
7502
|
style: "normal",
|
|
7341
7503
|
weight: "100 900",
|
|
7342
7504
|
display: "swap",
|
|
7343
|
-
unicodeRange:
|
|
7505
|
+
unicodeRange: D
|
|
7344
7506
|
}
|
|
7345
7507
|
},
|
|
7346
7508
|
{
|
|
@@ -7350,7 +7512,7 @@ const O = [
|
|
|
7350
7512
|
style: "normal",
|
|
7351
7513
|
weight: "100 900",
|
|
7352
7514
|
display: "swap",
|
|
7353
|
-
unicodeRange:
|
|
7515
|
+
unicodeRange: L
|
|
7354
7516
|
}
|
|
7355
7517
|
},
|
|
7356
7518
|
{
|
|
@@ -7360,7 +7522,7 @@ const O = [
|
|
|
7360
7522
|
style: "normal",
|
|
7361
7523
|
weight: "100",
|
|
7362
7524
|
display: "swap",
|
|
7363
|
-
unicodeRange:
|
|
7525
|
+
unicodeRange: D
|
|
7364
7526
|
}
|
|
7365
7527
|
},
|
|
7366
7528
|
{
|
|
@@ -7370,7 +7532,7 @@ const O = [
|
|
|
7370
7532
|
style: "normal",
|
|
7371
7533
|
weight: "100",
|
|
7372
7534
|
display: "swap",
|
|
7373
|
-
unicodeRange:
|
|
7535
|
+
unicodeRange: L
|
|
7374
7536
|
}
|
|
7375
7537
|
},
|
|
7376
7538
|
{
|
|
@@ -7380,7 +7542,7 @@ const O = [
|
|
|
7380
7542
|
style: "normal",
|
|
7381
7543
|
weight: "200",
|
|
7382
7544
|
display: "swap",
|
|
7383
|
-
unicodeRange:
|
|
7545
|
+
unicodeRange: D
|
|
7384
7546
|
}
|
|
7385
7547
|
},
|
|
7386
7548
|
{
|
|
@@ -7390,7 +7552,7 @@ const O = [
|
|
|
7390
7552
|
style: "normal",
|
|
7391
7553
|
weight: "200",
|
|
7392
7554
|
display: "swap",
|
|
7393
|
-
unicodeRange:
|
|
7555
|
+
unicodeRange: L
|
|
7394
7556
|
}
|
|
7395
7557
|
},
|
|
7396
7558
|
{
|
|
@@ -7400,7 +7562,7 @@ const O = [
|
|
|
7400
7562
|
style: "normal",
|
|
7401
7563
|
weight: "300",
|
|
7402
7564
|
display: "swap",
|
|
7403
|
-
unicodeRange:
|
|
7565
|
+
unicodeRange: D
|
|
7404
7566
|
}
|
|
7405
7567
|
},
|
|
7406
7568
|
{
|
|
@@ -7410,7 +7572,7 @@ const O = [
|
|
|
7410
7572
|
style: "normal",
|
|
7411
7573
|
weight: "300",
|
|
7412
7574
|
display: "swap",
|
|
7413
|
-
unicodeRange:
|
|
7575
|
+
unicodeRange: L
|
|
7414
7576
|
}
|
|
7415
7577
|
},
|
|
7416
7578
|
{
|
|
@@ -7420,7 +7582,7 @@ const O = [
|
|
|
7420
7582
|
style: "normal",
|
|
7421
7583
|
weight: "400",
|
|
7422
7584
|
display: "swap",
|
|
7423
|
-
unicodeRange:
|
|
7585
|
+
unicodeRange: D
|
|
7424
7586
|
}
|
|
7425
7587
|
},
|
|
7426
7588
|
{
|
|
@@ -7430,7 +7592,7 @@ const O = [
|
|
|
7430
7592
|
style: "normal",
|
|
7431
7593
|
weight: "400",
|
|
7432
7594
|
display: "swap",
|
|
7433
|
-
unicodeRange:
|
|
7595
|
+
unicodeRange: L
|
|
7434
7596
|
}
|
|
7435
7597
|
},
|
|
7436
7598
|
{
|
|
@@ -7440,7 +7602,7 @@ const O = [
|
|
|
7440
7602
|
style: "normal",
|
|
7441
7603
|
weight: "500",
|
|
7442
7604
|
display: "swap",
|
|
7443
|
-
unicodeRange:
|
|
7605
|
+
unicodeRange: D
|
|
7444
7606
|
}
|
|
7445
7607
|
},
|
|
7446
7608
|
{
|
|
@@ -7450,7 +7612,7 @@ const O = [
|
|
|
7450
7612
|
style: "normal",
|
|
7451
7613
|
weight: "500",
|
|
7452
7614
|
display: "swap",
|
|
7453
|
-
unicodeRange:
|
|
7615
|
+
unicodeRange: L
|
|
7454
7616
|
}
|
|
7455
7617
|
},
|
|
7456
7618
|
{
|
|
@@ -7460,7 +7622,7 @@ const O = [
|
|
|
7460
7622
|
style: "normal",
|
|
7461
7623
|
weight: "600",
|
|
7462
7624
|
display: "swap",
|
|
7463
|
-
unicodeRange:
|
|
7625
|
+
unicodeRange: D
|
|
7464
7626
|
}
|
|
7465
7627
|
},
|
|
7466
7628
|
{
|
|
@@ -7470,7 +7632,7 @@ const O = [
|
|
|
7470
7632
|
style: "normal",
|
|
7471
7633
|
weight: "600",
|
|
7472
7634
|
display: "swap",
|
|
7473
|
-
unicodeRange:
|
|
7635
|
+
unicodeRange: L
|
|
7474
7636
|
}
|
|
7475
7637
|
},
|
|
7476
7638
|
{
|
|
@@ -7480,7 +7642,7 @@ const O = [
|
|
|
7480
7642
|
style: "normal",
|
|
7481
7643
|
weight: "700",
|
|
7482
7644
|
display: "swap",
|
|
7483
|
-
unicodeRange:
|
|
7645
|
+
unicodeRange: D
|
|
7484
7646
|
}
|
|
7485
7647
|
},
|
|
7486
7648
|
{
|
|
@@ -7490,7 +7652,7 @@ const O = [
|
|
|
7490
7652
|
style: "normal",
|
|
7491
7653
|
weight: "700",
|
|
7492
7654
|
display: "swap",
|
|
7493
|
-
unicodeRange:
|
|
7655
|
+
unicodeRange: L
|
|
7494
7656
|
}
|
|
7495
7657
|
},
|
|
7496
7658
|
{
|
|
@@ -7500,7 +7662,7 @@ const O = [
|
|
|
7500
7662
|
style: "normal",
|
|
7501
7663
|
weight: "800",
|
|
7502
7664
|
display: "swap",
|
|
7503
|
-
unicodeRange:
|
|
7665
|
+
unicodeRange: D
|
|
7504
7666
|
}
|
|
7505
7667
|
},
|
|
7506
7668
|
{
|
|
@@ -7510,7 +7672,7 @@ const O = [
|
|
|
7510
7672
|
style: "normal",
|
|
7511
7673
|
weight: "800",
|
|
7512
7674
|
display: "swap",
|
|
7513
|
-
unicodeRange:
|
|
7675
|
+
unicodeRange: L
|
|
7514
7676
|
}
|
|
7515
7677
|
},
|
|
7516
7678
|
{
|
|
@@ -7520,7 +7682,7 @@ const O = [
|
|
|
7520
7682
|
style: "normal",
|
|
7521
7683
|
weight: "900",
|
|
7522
7684
|
display: "swap",
|
|
7523
|
-
unicodeRange:
|
|
7685
|
+
unicodeRange: D
|
|
7524
7686
|
}
|
|
7525
7687
|
},
|
|
7526
7688
|
{
|
|
@@ -7530,7 +7692,7 @@ const O = [
|
|
|
7530
7692
|
style: "normal",
|
|
7531
7693
|
weight: "900",
|
|
7532
7694
|
display: "swap",
|
|
7533
|
-
unicodeRange:
|
|
7695
|
+
unicodeRange: L
|
|
7534
7696
|
}
|
|
7535
7697
|
},
|
|
7536
7698
|
{
|
|
@@ -7540,7 +7702,7 @@ const O = [
|
|
|
7540
7702
|
style: "normal",
|
|
7541
7703
|
weight: "400",
|
|
7542
7704
|
display: "swap",
|
|
7543
|
-
unicodeRange:
|
|
7705
|
+
unicodeRange: D
|
|
7544
7706
|
}
|
|
7545
7707
|
},
|
|
7546
7708
|
{
|
|
@@ -7550,7 +7712,7 @@ const O = [
|
|
|
7550
7712
|
style: "normal",
|
|
7551
7713
|
weight: "400",
|
|
7552
7714
|
display: "swap",
|
|
7553
|
-
unicodeRange:
|
|
7715
|
+
unicodeRange: L
|
|
7554
7716
|
}
|
|
7555
7717
|
},
|
|
7556
7718
|
{
|
|
@@ -7560,7 +7722,7 @@ const O = [
|
|
|
7560
7722
|
style: "normal",
|
|
7561
7723
|
weight: "700",
|
|
7562
7724
|
display: "swap",
|
|
7563
|
-
unicodeRange:
|
|
7725
|
+
unicodeRange: D
|
|
7564
7726
|
}
|
|
7565
7727
|
},
|
|
7566
7728
|
{
|
|
@@ -7570,7 +7732,7 @@ const O = [
|
|
|
7570
7732
|
style: "normal",
|
|
7571
7733
|
weight: "700",
|
|
7572
7734
|
display: "swap",
|
|
7573
|
-
unicodeRange:
|
|
7735
|
+
unicodeRange: L
|
|
7574
7736
|
}
|
|
7575
7737
|
},
|
|
7576
7738
|
{
|
|
@@ -7580,7 +7742,7 @@ const O = [
|
|
|
7580
7742
|
style: "normal",
|
|
7581
7743
|
weight: "100 900",
|
|
7582
7744
|
display: "swap",
|
|
7583
|
-
unicodeRange:
|
|
7745
|
+
unicodeRange: D
|
|
7584
7746
|
}
|
|
7585
7747
|
},
|
|
7586
7748
|
{
|
|
@@ -7590,7 +7752,7 @@ const O = [
|
|
|
7590
7752
|
style: "normal",
|
|
7591
7753
|
weight: "100 900",
|
|
7592
7754
|
display: "swap",
|
|
7593
|
-
unicodeRange:
|
|
7755
|
+
unicodeRange: L
|
|
7594
7756
|
}
|
|
7595
7757
|
},
|
|
7596
7758
|
{
|
|
@@ -7600,7 +7762,7 @@ const O = [
|
|
|
7600
7762
|
style: "normal",
|
|
7601
7763
|
weight: "300 700",
|
|
7602
7764
|
display: "swap",
|
|
7603
|
-
unicodeRange:
|
|
7765
|
+
unicodeRange: D
|
|
7604
7766
|
}
|
|
7605
7767
|
},
|
|
7606
7768
|
{
|
|
@@ -7610,7 +7772,7 @@ const O = [
|
|
|
7610
7772
|
style: "normal",
|
|
7611
7773
|
weight: "300 700",
|
|
7612
7774
|
display: "swap",
|
|
7613
|
-
unicodeRange:
|
|
7775
|
+
unicodeRange: L
|
|
7614
7776
|
}
|
|
7615
7777
|
},
|
|
7616
7778
|
{
|
|
@@ -7620,7 +7782,7 @@ const O = [
|
|
|
7620
7782
|
style: "normal",
|
|
7621
7783
|
weight: "400",
|
|
7622
7784
|
display: "swap",
|
|
7623
|
-
unicodeRange:
|
|
7785
|
+
unicodeRange: D
|
|
7624
7786
|
}
|
|
7625
7787
|
},
|
|
7626
7788
|
{
|
|
@@ -7630,7 +7792,7 @@ const O = [
|
|
|
7630
7792
|
style: "normal",
|
|
7631
7793
|
weight: "400",
|
|
7632
7794
|
display: "swap",
|
|
7633
|
-
unicodeRange:
|
|
7795
|
+
unicodeRange: L
|
|
7634
7796
|
}
|
|
7635
7797
|
},
|
|
7636
7798
|
{
|
|
@@ -7640,7 +7802,7 @@ const O = [
|
|
|
7640
7802
|
style: "normal",
|
|
7641
7803
|
weight: "200 800",
|
|
7642
7804
|
display: "swap",
|
|
7643
|
-
unicodeRange:
|
|
7805
|
+
unicodeRange: D
|
|
7644
7806
|
}
|
|
7645
7807
|
},
|
|
7646
7808
|
{
|
|
@@ -7650,7 +7812,7 @@ const O = [
|
|
|
7650
7812
|
style: "normal",
|
|
7651
7813
|
weight: "200 800",
|
|
7652
7814
|
display: "swap",
|
|
7653
|
-
unicodeRange:
|
|
7815
|
+
unicodeRange: L
|
|
7654
7816
|
}
|
|
7655
7817
|
},
|
|
7656
7818
|
{
|
|
@@ -7660,7 +7822,7 @@ const O = [
|
|
|
7660
7822
|
style: "normal",
|
|
7661
7823
|
weight: "100 900",
|
|
7662
7824
|
display: "swap",
|
|
7663
|
-
unicodeRange:
|
|
7825
|
+
unicodeRange: D
|
|
7664
7826
|
}
|
|
7665
7827
|
},
|
|
7666
7828
|
{
|
|
@@ -7670,7 +7832,7 @@ const O = [
|
|
|
7670
7832
|
style: "normal",
|
|
7671
7833
|
weight: "100 900",
|
|
7672
7834
|
display: "swap",
|
|
7673
|
-
unicodeRange:
|
|
7835
|
+
unicodeRange: L
|
|
7674
7836
|
}
|
|
7675
7837
|
},
|
|
7676
7838
|
{
|
|
@@ -7680,7 +7842,7 @@ const O = [
|
|
|
7680
7842
|
style: "normal",
|
|
7681
7843
|
weight: "400",
|
|
7682
7844
|
display: "swap",
|
|
7683
|
-
unicodeRange:
|
|
7845
|
+
unicodeRange: D
|
|
7684
7846
|
}
|
|
7685
7847
|
},
|
|
7686
7848
|
{
|
|
@@ -7690,7 +7852,7 @@ const O = [
|
|
|
7690
7852
|
style: "normal",
|
|
7691
7853
|
weight: "400",
|
|
7692
7854
|
display: "swap",
|
|
7693
|
-
unicodeRange:
|
|
7855
|
+
unicodeRange: L
|
|
7694
7856
|
}
|
|
7695
7857
|
},
|
|
7696
7858
|
{
|
|
@@ -7700,7 +7862,7 @@ const O = [
|
|
|
7700
7862
|
style: "normal",
|
|
7701
7863
|
weight: "100 900",
|
|
7702
7864
|
display: "swap",
|
|
7703
|
-
unicodeRange:
|
|
7865
|
+
unicodeRange: D
|
|
7704
7866
|
}
|
|
7705
7867
|
},
|
|
7706
7868
|
{
|
|
@@ -7710,7 +7872,7 @@ const O = [
|
|
|
7710
7872
|
style: "normal",
|
|
7711
7873
|
weight: "100 900",
|
|
7712
7874
|
display: "swap",
|
|
7713
|
-
unicodeRange:
|
|
7875
|
+
unicodeRange: L
|
|
7714
7876
|
}
|
|
7715
7877
|
},
|
|
7716
7878
|
{
|
|
@@ -7720,7 +7882,7 @@ const O = [
|
|
|
7720
7882
|
style: "normal",
|
|
7721
7883
|
weight: "300 800",
|
|
7722
7884
|
display: "swap",
|
|
7723
|
-
unicodeRange:
|
|
7885
|
+
unicodeRange: D
|
|
7724
7886
|
}
|
|
7725
7887
|
},
|
|
7726
7888
|
{
|
|
@@ -7730,7 +7892,7 @@ const O = [
|
|
|
7730
7892
|
style: "normal",
|
|
7731
7893
|
weight: "300 800",
|
|
7732
7894
|
display: "swap",
|
|
7733
|
-
unicodeRange:
|
|
7895
|
+
unicodeRange: L
|
|
7734
7896
|
}
|
|
7735
7897
|
},
|
|
7736
7898
|
{
|
|
@@ -7740,7 +7902,7 @@ const O = [
|
|
|
7740
7902
|
style: "normal",
|
|
7741
7903
|
weight: "400",
|
|
7742
7904
|
display: "swap",
|
|
7743
|
-
unicodeRange:
|
|
7905
|
+
unicodeRange: D
|
|
7744
7906
|
}
|
|
7745
7907
|
},
|
|
7746
7908
|
{
|
|
@@ -7750,7 +7912,7 @@ const O = [
|
|
|
7750
7912
|
style: "normal",
|
|
7751
7913
|
weight: "400",
|
|
7752
7914
|
display: "swap",
|
|
7753
|
-
unicodeRange:
|
|
7915
|
+
unicodeRange: L
|
|
7754
7916
|
}
|
|
7755
7917
|
},
|
|
7756
7918
|
{
|
|
@@ -7760,7 +7922,7 @@ const O = [
|
|
|
7760
7922
|
style: "normal",
|
|
7761
7923
|
weight: "700",
|
|
7762
7924
|
display: "swap",
|
|
7763
|
-
unicodeRange:
|
|
7925
|
+
unicodeRange: D
|
|
7764
7926
|
}
|
|
7765
7927
|
},
|
|
7766
7928
|
{
|
|
@@ -7770,7 +7932,7 @@ const O = [
|
|
|
7770
7932
|
style: "normal",
|
|
7771
7933
|
weight: "700",
|
|
7772
7934
|
display: "swap",
|
|
7773
|
-
unicodeRange:
|
|
7935
|
+
unicodeRange: L
|
|
7774
7936
|
}
|
|
7775
7937
|
},
|
|
7776
7938
|
{
|
|
@@ -7780,7 +7942,7 @@ const O = [
|
|
|
7780
7942
|
style: "normal",
|
|
7781
7943
|
weight: "300 900",
|
|
7782
7944
|
display: "swap",
|
|
7783
|
-
unicodeRange:
|
|
7945
|
+
unicodeRange: D
|
|
7784
7946
|
}
|
|
7785
7947
|
},
|
|
7786
7948
|
{
|
|
@@ -7790,7 +7952,7 @@ const O = [
|
|
|
7790
7952
|
style: "normal",
|
|
7791
7953
|
weight: "300 900",
|
|
7792
7954
|
display: "swap",
|
|
7793
|
-
unicodeRange:
|
|
7955
|
+
unicodeRange: L
|
|
7794
7956
|
}
|
|
7795
7957
|
},
|
|
7796
7958
|
{
|
|
@@ -7800,7 +7962,7 @@ const O = [
|
|
|
7800
7962
|
style: "normal",
|
|
7801
7963
|
weight: "400",
|
|
7802
7964
|
display: "swap",
|
|
7803
|
-
unicodeRange:
|
|
7965
|
+
unicodeRange: D
|
|
7804
7966
|
}
|
|
7805
7967
|
},
|
|
7806
7968
|
{
|
|
@@ -7810,7 +7972,7 @@ const O = [
|
|
|
7810
7972
|
style: "normal",
|
|
7811
7973
|
weight: "400",
|
|
7812
7974
|
display: "swap",
|
|
7813
|
-
unicodeRange:
|
|
7975
|
+
unicodeRange: L
|
|
7814
7976
|
}
|
|
7815
7977
|
},
|
|
7816
7978
|
{
|
|
@@ -7820,7 +7982,7 @@ const O = [
|
|
|
7820
7982
|
style: "normal",
|
|
7821
7983
|
weight: "100 900",
|
|
7822
7984
|
display: "swap",
|
|
7823
|
-
unicodeRange:
|
|
7985
|
+
unicodeRange: D
|
|
7824
7986
|
}
|
|
7825
7987
|
},
|
|
7826
7988
|
{
|
|
@@ -7830,7 +7992,7 @@ const O = [
|
|
|
7830
7992
|
style: "normal",
|
|
7831
7993
|
weight: "100 900",
|
|
7832
7994
|
display: "swap",
|
|
7833
|
-
unicodeRange:
|
|
7995
|
+
unicodeRange: L
|
|
7834
7996
|
}
|
|
7835
7997
|
},
|
|
7836
7998
|
{
|
|
@@ -7840,7 +8002,7 @@ const O = [
|
|
|
7840
8002
|
style: "normal",
|
|
7841
8003
|
weight: "100 900",
|
|
7842
8004
|
display: "swap",
|
|
7843
|
-
unicodeRange:
|
|
8005
|
+
unicodeRange: D
|
|
7844
8006
|
}
|
|
7845
8007
|
},
|
|
7846
8008
|
{
|
|
@@ -7850,7 +8012,7 @@ const O = [
|
|
|
7850
8012
|
style: "normal",
|
|
7851
8013
|
weight: "100 900",
|
|
7852
8014
|
display: "swap",
|
|
7853
|
-
unicodeRange:
|
|
8015
|
+
unicodeRange: L
|
|
7854
8016
|
}
|
|
7855
8017
|
}
|
|
7856
8018
|
], Cn = {
|
|
@@ -7954,7 +8116,7 @@ function Dn(h, t = {}) {
|
|
|
7954
8116
|
const n = document.createElement("canvas");
|
|
7955
8117
|
return n.id = `${h}-canvas`, s.appendChild(n), e.editorContainer = s, new Promise((o) => {
|
|
7956
8118
|
e._onReadyCallback = o;
|
|
7957
|
-
const i = new
|
|
8119
|
+
const i = new Le(n.id, e);
|
|
7958
8120
|
window[h] = i;
|
|
7959
8121
|
});
|
|
7960
8122
|
}
|