@anu3ev/fabric-image-editor 0.4.1 → 0.4.2
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 +495 -437
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
1
|
+
var Re = Object.defineProperty, Ue = Object.defineProperties;
|
|
2
|
+
var ze = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var bt = Object.getOwnPropertySymbols;
|
|
4
|
+
var ve = Object.prototype.hasOwnProperty, je = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var be = (h, t, e) => t in h ? Re(h, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : h[t] = e, D = (h, t) => {
|
|
6
6
|
for (var e in t || (t = {}))
|
|
7
|
-
|
|
8
|
-
if (
|
|
9
|
-
for (var e of
|
|
10
|
-
|
|
7
|
+
ve.call(t, e) && be(h, e, t[e]);
|
|
8
|
+
if (bt)
|
|
9
|
+
for (var e of bt(t))
|
|
10
|
+
je.call(t, e) && be(h, e, t[e]);
|
|
11
11
|
return h;
|
|
12
|
-
},
|
|
13
|
-
var
|
|
12
|
+
}, Ie = (h, t) => Ue(h, ze(t));
|
|
13
|
+
var K = (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
|
+
ve.call(h, s) && t.indexOf(s) < 0 && (e[s] = h[s]);
|
|
17
|
+
if (h != null && bt)
|
|
18
|
+
for (var s of bt(h))
|
|
19
|
+
t.indexOf(s) < 0 && je.call(h, s) && (e[s] = h[s]);
|
|
20
20
|
return e;
|
|
21
21
|
};
|
|
22
22
|
var C = (h, t, e) => new Promise((s, n) => {
|
|
@@ -35,15 +35,15 @@ var C = (h, t, e) => new Promise((s, n) => {
|
|
|
35
35
|
}, i = (r) => r.done ? s(r.value) : Promise.resolve(r.value).then(o, a);
|
|
36
36
|
i((e = e.apply(h, t)).next());
|
|
37
37
|
});
|
|
38
|
-
import { ActiveSelection as
|
|
39
|
-
import { create as
|
|
40
|
-
import
|
|
41
|
-
var
|
|
38
|
+
import { ActiveSelection as T, Textbox as mt, util as Mt, controlsUtils as Ae, InteractiveFabricObject as Se, loadSVGFromURL as Ye, FabricImage as gt, Point as It, Gradient as Ce, Rect as Fe, Circle as He, Triangle as We, Group as Q, Canvas as Ze, Pattern as Pe } from "fabric";
|
|
39
|
+
import { create as Ve } from "jsondiffpatch";
|
|
40
|
+
import Ge from "diff-match-patch";
|
|
41
|
+
var Xe = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", x = 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 += Xe[s[t] & 63];
|
|
44
44
|
return e;
|
|
45
45
|
};
|
|
46
|
-
class
|
|
46
|
+
class pt {
|
|
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 = pt.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 = pt.debounce(this.handleObjectModifiedHistory.bind(this), 300), this.handleObjectRotatingHistoryBound = pt.debounce(this.handleObjectRotatingHistory.bind(this), 300), this.handleObjectAddedHistoryBound = this.handleObjectAddedHistory.bind(this), this.handleObjectRemovedHistoryBound = this.handleObjectRemovedHistory.bind(this), this.handleOverlayUpdateBound = this.handleOverlayUpdate.bind(this), this.handleBackgroundUpdateBound = this.handleBackgroundUpdate.bind(this), this.handleCanvasDragStartBound = this.handleCanvasDragStart.bind(this), this.handleCanvasDraggingBound = this.handleCanvasDragging.bind(this), this.handleCanvasDragEndBound = this.handleCanvasDragEnd.bind(this), this.handleMouseWheelZoomBound = this.handleMouseWheelZoom.bind(this), this.handleBringToFrontBound = this.handleBringToFront.bind(this), this.handleResetObjectFitBound = this.handleResetObjectFit.bind(this), this.handleLockedSelectionBound = this._filterLockedSelection.bind(this), this.init();
|
|
65
65
|
}
|
|
66
66
|
/**
|
|
67
67
|
* Инициализация всех обработчиков согласно опциям.
|
|
@@ -98,7 +98,7 @@ class ft {
|
|
|
98
98
|
if (n.length === 1)
|
|
99
99
|
this.canvas.setActiveObject(n[0]);
|
|
100
100
|
else {
|
|
101
|
-
const a = new
|
|
101
|
+
const a = new T(n, {
|
|
102
102
|
canvas: this.canvas
|
|
103
103
|
});
|
|
104
104
|
this.canvas.setActiveObject(a);
|
|
@@ -106,7 +106,7 @@ class ft {
|
|
|
106
106
|
this.canvas.requestRenderAll();
|
|
107
107
|
return;
|
|
108
108
|
}
|
|
109
|
-
const o = new
|
|
109
|
+
const o = new T(t, {
|
|
110
110
|
canvas: this.canvas
|
|
111
111
|
});
|
|
112
112
|
this.editor.objectLockManager.lockObject({
|
|
@@ -220,7 +220,7 @@ class ft {
|
|
|
220
220
|
if (n || o) return;
|
|
221
221
|
this.isSpacePressed = !0, t.preventDefault();
|
|
222
222
|
const a = e.getActiveObject() || null;
|
|
223
|
-
a instanceof
|
|
223
|
+
a instanceof T ? this.savedSelection = a.getObjects().slice() : a && (this.savedSelection = [a]), e.discardActiveObject(), e.set({
|
|
224
224
|
selection: !1,
|
|
225
225
|
defaultCursor: "grab"
|
|
226
226
|
}), e.setCursor("grab"), s.canvasManager.getObjects().forEach((i) => {
|
|
@@ -259,7 +259,7 @@ class ft {
|
|
|
259
259
|
e.setActiveObject(t[0]);
|
|
260
260
|
return;
|
|
261
261
|
}
|
|
262
|
-
const n = t.filter((a) => s.canvasManager.getObjects().includes(a)), o = new
|
|
262
|
+
const n = t.filter((a) => s.canvasManager.getObjects().includes(a)), o = new T(n, { canvas: e });
|
|
263
263
|
e.setActiveObject(o);
|
|
264
264
|
}
|
|
265
265
|
// --- Обработчики для событий canvas (Fabric) ---
|
|
@@ -330,7 +330,7 @@ class ft {
|
|
|
330
330
|
*/
|
|
331
331
|
handleResetObjectFit(t) {
|
|
332
332
|
const e = t == null ? void 0 : t.target;
|
|
333
|
-
!e || e instanceof
|
|
333
|
+
!e || e instanceof mt || this.editor.transformManager.resetObject({ object: e });
|
|
334
334
|
}
|
|
335
335
|
/**
|
|
336
336
|
* Проверяет, должно ли событие клавиатуры быть проигнорировано
|
|
@@ -391,7 +391,7 @@ class ft {
|
|
|
391
391
|
};
|
|
392
392
|
}
|
|
393
393
|
}
|
|
394
|
-
class
|
|
394
|
+
class Ke {
|
|
395
395
|
/**
|
|
396
396
|
* Класс для динамической загрузки внешних модулей.
|
|
397
397
|
*/
|
|
@@ -409,7 +409,7 @@ class Ye {
|
|
|
409
409
|
return this.loaders[t] ? (this.cache.has(t) || this.cache.set(t, this.loaders[t]()), this.cache.get(t)) : Promise.reject(new Error(`Unknown module "${t}"`));
|
|
410
410
|
}
|
|
411
411
|
}
|
|
412
|
-
function
|
|
412
|
+
function $e(h) {
|
|
413
413
|
return new Worker(
|
|
414
414
|
"" + new URL("assets/worker-CN39s7P7.js", import.meta.url).href,
|
|
415
415
|
{
|
|
@@ -417,13 +417,13 @@ function Fe(h) {
|
|
|
417
417
|
}
|
|
418
418
|
);
|
|
419
419
|
}
|
|
420
|
-
class
|
|
420
|
+
class Qe {
|
|
421
421
|
/**
|
|
422
422
|
* @param scriptUrl — URL скрипта воркера.
|
|
423
423
|
* По-умолчанию использует DefaultWorker из соседнего файла
|
|
424
424
|
*/
|
|
425
425
|
constructor(t) {
|
|
426
|
-
t ? this.worker = new Worker(t, { type: "module" }) : this.worker = new
|
|
426
|
+
t ? this.worker = new Worker(t, { type: "module" }) : this.worker = new $e(), this._callbacks = /* @__PURE__ */ new Map(), this.worker.onmessage = this._handleMessage.bind(this);
|
|
427
427
|
}
|
|
428
428
|
/**
|
|
429
429
|
* Обработчик сообщений от воркера
|
|
@@ -463,50 +463,50 @@ class He {
|
|
|
463
463
|
this.worker.terminate();
|
|
464
464
|
}
|
|
465
465
|
}
|
|
466
|
-
const F = 12,
|
|
467
|
-
function
|
|
468
|
-
const o = F, a =
|
|
469
|
-
h.save(), h.translate(t, e), h.rotate(
|
|
466
|
+
const F = 12, Je = 2, Tt = 8, Nt = 20, qe = 100, Lt = 20, kt = 8, ts = 100, At = 32, _t = 1, es = "#2B2D33", Bt = "#3D8BF4", Rt = "#FFFFFF";
|
|
467
|
+
function vt(h, t, e, s, n) {
|
|
468
|
+
const o = F, a = Je;
|
|
469
|
+
h.save(), h.translate(t, e), h.rotate(Mt.degreesToRadians(n.angle)), h.fillStyle = Rt, h.strokeStyle = Bt, h.lineWidth = _t, h.beginPath(), h.roundRect(-o / 2, -o / 2, o, o, a), h.fill(), h.stroke(), h.restore();
|
|
470
470
|
}
|
|
471
|
-
function
|
|
472
|
-
const o =
|
|
473
|
-
h.save(), h.translate(t, e), h.rotate(
|
|
471
|
+
function we(h, t, e, s, n) {
|
|
472
|
+
const o = Tt, a = Nt, i = qe;
|
|
473
|
+
h.save(), h.translate(t, e), h.rotate(Mt.degreesToRadians(n.angle)), h.fillStyle = Rt, h.strokeStyle = Bt, h.lineWidth = _t, h.beginPath(), h.roundRect(-o / 2, -a / 2, o, a, i), h.fill(), h.stroke(), h.restore();
|
|
474
474
|
}
|
|
475
|
-
function
|
|
476
|
-
const o =
|
|
477
|
-
h.save(), h.translate(t, e), h.rotate(
|
|
475
|
+
function Ee(h, t, e, s, n) {
|
|
476
|
+
const o = Lt, a = kt, i = ts;
|
|
477
|
+
h.save(), h.translate(t, e), h.rotate(Mt.degreesToRadians(n.angle)), h.fillStyle = Rt, h.strokeStyle = Bt, h.lineWidth = _t, h.beginPath(), h.roundRect(-o / 2, -a / 2, o, a, i), h.fill(), h.stroke(), h.restore();
|
|
478
478
|
}
|
|
479
|
-
const
|
|
480
|
-
|
|
481
|
-
function
|
|
482
|
-
const a =
|
|
483
|
-
h.save(), h.translate(t, e), h.rotate(
|
|
479
|
+
const ss = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTE4Ljc1IDQuMzc1djMuNzVhLjYyNS42MjUgMCAwIDEtLjYyNS42MjVoLTMuNzVhLjYyNS42MjUgMCAwIDEgMC0xLjI1aDIuMTRsLTIuMDc3LTEuOTAzLS4wMi0uMDE5YTYuMjUgNi4yNSAwIDEgMC0uMTMgOC45NjcuNjI2LjYyNiAwIDAgMSAuODYuOTA5QTcuNDU2IDcuNDU2IDAgMCAxIDEwIDE3LjVoLS4xMDNhNy41IDcuNSAwIDEgMSA1LjM5Ni0xMi44MTJMMTcuNSA2LjcwM1Y0LjM3NWEuNjI1LjYyNSAwIDAgMSAxLjI1IDBaIi8+PC9zdmc+", ke = new Image();
|
|
480
|
+
ke.src = ss;
|
|
481
|
+
function ns(h, t, e, s, n) {
|
|
482
|
+
const a = At / 2;
|
|
483
|
+
h.save(), h.translate(t, e), h.rotate(Mt.degreesToRadians(n.angle)), h.fillStyle = es, h.beginPath(), h.arc(0, 0, a, 0, 2 * Math.PI), h.fill(), h.drawImage(ke, -a / 2, -a / 2, a, a), h.restore();
|
|
484
484
|
}
|
|
485
|
-
const
|
|
485
|
+
const os = {
|
|
486
486
|
// Угловые точки
|
|
487
487
|
tl: {
|
|
488
|
-
render:
|
|
488
|
+
render: vt,
|
|
489
489
|
sizeX: F,
|
|
490
490
|
sizeY: F,
|
|
491
491
|
offsetX: 0,
|
|
492
492
|
offsetY: 0
|
|
493
493
|
},
|
|
494
494
|
tr: {
|
|
495
|
-
render:
|
|
495
|
+
render: vt,
|
|
496
496
|
sizeX: F,
|
|
497
497
|
sizeY: F,
|
|
498
498
|
offsetX: 0,
|
|
499
499
|
offsetY: 0
|
|
500
500
|
},
|
|
501
501
|
bl: {
|
|
502
|
-
render:
|
|
502
|
+
render: vt,
|
|
503
503
|
sizeX: F,
|
|
504
504
|
sizeY: F,
|
|
505
505
|
offsetX: 0,
|
|
506
506
|
offsetY: 0
|
|
507
507
|
},
|
|
508
508
|
br: {
|
|
509
|
-
render:
|
|
509
|
+
render: vt,
|
|
510
510
|
sizeX: F,
|
|
511
511
|
sizeY: F,
|
|
512
512
|
offsetX: 0,
|
|
@@ -514,46 +514,54 @@ const Ke = {
|
|
|
514
514
|
},
|
|
515
515
|
// Середина вертикалей
|
|
516
516
|
ml: {
|
|
517
|
-
render:
|
|
518
|
-
sizeX:
|
|
519
|
-
sizeY:
|
|
517
|
+
render: we,
|
|
518
|
+
sizeX: Tt,
|
|
519
|
+
sizeY: Nt,
|
|
520
520
|
offsetX: 0,
|
|
521
521
|
offsetY: 0
|
|
522
522
|
},
|
|
523
523
|
mr: {
|
|
524
|
-
render:
|
|
525
|
-
sizeX:
|
|
526
|
-
sizeY:
|
|
524
|
+
render: we,
|
|
525
|
+
sizeX: Tt,
|
|
526
|
+
sizeY: Nt,
|
|
527
527
|
offsetX: 0,
|
|
528
528
|
offsetY: 0
|
|
529
529
|
},
|
|
530
530
|
// Середина горизонталей
|
|
531
531
|
mt: {
|
|
532
|
-
render:
|
|
533
|
-
sizeX:
|
|
534
|
-
sizeY:
|
|
532
|
+
render: Ee,
|
|
533
|
+
sizeX: Lt,
|
|
534
|
+
sizeY: kt,
|
|
535
535
|
offsetX: 0,
|
|
536
536
|
offsetY: 0
|
|
537
537
|
},
|
|
538
538
|
mb: {
|
|
539
|
-
render:
|
|
540
|
-
sizeX:
|
|
541
|
-
sizeY:
|
|
539
|
+
render: Ee,
|
|
540
|
+
sizeX: Lt,
|
|
541
|
+
sizeY: kt,
|
|
542
542
|
offsetX: 0,
|
|
543
543
|
offsetY: 0
|
|
544
544
|
},
|
|
545
545
|
// Специальный «rotate» контрол
|
|
546
546
|
mtr: {
|
|
547
|
-
render:
|
|
548
|
-
sizeX:
|
|
549
|
-
sizeY:
|
|
547
|
+
render: ns,
|
|
548
|
+
sizeX: At,
|
|
549
|
+
sizeY: At,
|
|
550
550
|
offsetX: 0,
|
|
551
|
-
offsetY: -
|
|
551
|
+
offsetY: -At
|
|
552
552
|
}
|
|
553
553
|
};
|
|
554
|
-
class
|
|
554
|
+
class J {
|
|
555
|
+
static wrapWidthControl(t) {
|
|
556
|
+
if (!(t != null && t.actionHandler)) return;
|
|
557
|
+
const e = t.actionHandler;
|
|
558
|
+
t.actionHandler = (s, n, o, a) => {
|
|
559
|
+
const i = n == null ? void 0 : n.target;
|
|
560
|
+
return !i || i.locked || i.lockScalingX ? !1 : e(s, n, o, a);
|
|
561
|
+
};
|
|
562
|
+
}
|
|
555
563
|
static applyControlOverrides(t) {
|
|
556
|
-
Object.entries(
|
|
564
|
+
Object.entries(os).forEach(([e, s]) => {
|
|
557
565
|
const n = t[e];
|
|
558
566
|
n && (Object.assign(n, s), e === "mtr" && (n.cursorStyle = "grab", n.mouseDownHandler = (o, a, i, r) => {
|
|
559
567
|
var d;
|
|
@@ -563,13 +571,13 @@ class jt {
|
|
|
563
571
|
});
|
|
564
572
|
}
|
|
565
573
|
static apply() {
|
|
566
|
-
const t =
|
|
567
|
-
|
|
568
|
-
const e =
|
|
569
|
-
|
|
574
|
+
const t = Ae.createObjectDefaultControls();
|
|
575
|
+
J.applyControlOverrides(t), Se.ownDefaults.controls = t;
|
|
576
|
+
const e = Ae.createTextboxDefaultControls();
|
|
577
|
+
J.applyControlOverrides(e), e.mt && (e.mt.visible = !1), e.mb && (e.mb.visible = !1), J.wrapWidthControl(e.ml), J.wrapWidthControl(e.mr), mt.ownDefaults.controls = e, Se.ownDefaults.snapAngle = 1;
|
|
570
578
|
}
|
|
571
579
|
}
|
|
572
|
-
const
|
|
580
|
+
const A = class A {
|
|
573
581
|
constructor(t = []) {
|
|
574
582
|
this.fonts = t;
|
|
575
583
|
}
|
|
@@ -583,7 +591,7 @@ const j = class j {
|
|
|
583
591
|
if (!t.length) return;
|
|
584
592
|
const e = typeof document != "undefined" ? document : void 0;
|
|
585
593
|
if (!e) return;
|
|
586
|
-
const s = t.map((o) =>
|
|
594
|
+
const s = t.map((o) => A.loadFont(o, e));
|
|
587
595
|
yield Promise.allSettled(s);
|
|
588
596
|
});
|
|
589
597
|
}
|
|
@@ -592,21 +600,21 @@ const j = class j {
|
|
|
592
600
|
var c, d;
|
|
593
601
|
const s = typeof FontFace != "undefined", n = (c = t.family) == null ? void 0 : c.trim(), o = (d = t.source) == null ? void 0 : d.trim();
|
|
594
602
|
if (!n || !o) return;
|
|
595
|
-
const a =
|
|
596
|
-
if (!
|
|
597
|
-
if (
|
|
598
|
-
|
|
603
|
+
const a = A.normalizeFontSource(o), i = A.getDescriptorSnapshot(t.descriptors), r = A.getFontRegistrationKey(n, a, i);
|
|
604
|
+
if (!A.registeredFontKeys.has(r)) {
|
|
605
|
+
if (A.isFontFaceAlreadyApplied(e, n, i)) {
|
|
606
|
+
A.registeredFontKeys.add(r);
|
|
599
607
|
return;
|
|
600
608
|
}
|
|
601
609
|
if (s && e.fonts && typeof e.fonts.add == "function")
|
|
602
610
|
try {
|
|
603
611
|
const u = yield new FontFace(n, a, t.descriptors).load();
|
|
604
|
-
e.fonts.add(u),
|
|
612
|
+
e.fonts.add(u), A.registeredFontKeys.add(r);
|
|
605
613
|
return;
|
|
606
614
|
} catch (l) {
|
|
607
615
|
console.warn(`Не удалось загрузить шрифт "${n}" через FontFace API`, l);
|
|
608
616
|
}
|
|
609
|
-
|
|
617
|
+
A.injectFontFace({
|
|
610
618
|
font: t,
|
|
611
619
|
source: a,
|
|
612
620
|
doc: e,
|
|
@@ -626,15 +634,15 @@ const j = class j {
|
|
|
626
634
|
if (!a) return;
|
|
627
635
|
const i = s.createElement("style");
|
|
628
636
|
i.setAttribute("data-editor-font", a), i.setAttribute("data-editor-font-key", n);
|
|
629
|
-
const r =
|
|
637
|
+
const r = A.descriptorsToCss(o), c = [
|
|
630
638
|
"@font-face {",
|
|
631
|
-
` font-family: ${
|
|
639
|
+
` font-family: ${A.formatFontFamilyForCss(a)};`,
|
|
632
640
|
` src: ${e};`,
|
|
633
641
|
...r.map((l) => ` ${l}`),
|
|
634
642
|
"}"
|
|
635
643
|
];
|
|
636
644
|
i.textContent = c.join(`
|
|
637
|
-
`), s.head.appendChild(i),
|
|
645
|
+
`), s.head.appendChild(i), A.registeredFontKeys.add(n);
|
|
638
646
|
}
|
|
639
647
|
static normalizeFontSource(t) {
|
|
640
648
|
const e = t.trim();
|
|
@@ -657,15 +665,15 @@ const j = class j {
|
|
|
657
665
|
return t ? t.trim().replace(/^['"]+|['"]+$/g, "").toLowerCase() : "";
|
|
658
666
|
}
|
|
659
667
|
static getDescriptorSnapshot(t) {
|
|
660
|
-
const e =
|
|
668
|
+
const e = A.descriptorDefaults;
|
|
661
669
|
return {
|
|
662
|
-
style:
|
|
663
|
-
weight:
|
|
664
|
-
stretch:
|
|
665
|
-
unicodeRange:
|
|
666
|
-
variant:
|
|
667
|
-
featureSettings:
|
|
668
|
-
display:
|
|
670
|
+
style: A.normalizeDescriptorValue(t == null ? void 0 : t.style, e.style),
|
|
671
|
+
weight: A.normalizeDescriptorValue(t == null ? void 0 : t.weight, e.weight),
|
|
672
|
+
stretch: A.normalizeDescriptorValue(t == null ? void 0 : t.stretch, e.stretch),
|
|
673
|
+
unicodeRange: A.normalizeDescriptorValue(t == null ? void 0 : t.unicodeRange, e.unicodeRange),
|
|
674
|
+
variant: A.normalizeDescriptorValue(t == null ? void 0 : t.variant, e.variant),
|
|
675
|
+
featureSettings: A.normalizeDescriptorValue(t == null ? void 0 : t.featureSettings, e.featureSettings),
|
|
676
|
+
display: A.normalizeDescriptorValue(t == null ? void 0 : t.display, e.display)
|
|
669
677
|
};
|
|
670
678
|
}
|
|
671
679
|
static areDescriptorSnapshotsEqual(t, e) {
|
|
@@ -673,7 +681,7 @@ const j = class j {
|
|
|
673
681
|
}
|
|
674
682
|
static getFontRegistrationKey(t, e, s) {
|
|
675
683
|
return [
|
|
676
|
-
|
|
684
|
+
A.normalizeFamilyName(t),
|
|
677
685
|
e,
|
|
678
686
|
s.style,
|
|
679
687
|
s.weight,
|
|
@@ -687,12 +695,12 @@ const j = class j {
|
|
|
687
695
|
static isFontFaceAlreadyApplied(t, e, s) {
|
|
688
696
|
const n = t.fonts;
|
|
689
697
|
if (!n || typeof n.forEach != "function") return !1;
|
|
690
|
-
const o =
|
|
698
|
+
const o = A.normalizeFamilyName(e);
|
|
691
699
|
let a = !1;
|
|
692
700
|
try {
|
|
693
701
|
n.forEach((i) => {
|
|
694
|
-
if (a ||
|
|
695
|
-
const c =
|
|
702
|
+
if (a || A.normalizeFamilyName(i.family) !== o) return;
|
|
703
|
+
const c = A.getDescriptorSnapshot({
|
|
696
704
|
style: i.style,
|
|
697
705
|
weight: i.weight,
|
|
698
706
|
stretch: i.stretch,
|
|
@@ -701,7 +709,7 @@ const j = class j {
|
|
|
701
709
|
featureSettings: i.featureSettings,
|
|
702
710
|
display: i.display
|
|
703
711
|
});
|
|
704
|
-
|
|
712
|
+
A.areDescriptorSnapshotsEqual(s, c) && (a = !0);
|
|
705
713
|
});
|
|
706
714
|
} catch (i) {
|
|
707
715
|
return console.warn("Не удалось проверить, загружен ли шрифт ранее через FontFaceSet", i), !1;
|
|
@@ -728,7 +736,7 @@ const j = class j {
|
|
|
728
736
|
});
|
|
729
737
|
}
|
|
730
738
|
};
|
|
731
|
-
|
|
739
|
+
A.registeredFontKeys = /* @__PURE__ */ new Set(), A.descriptorDefaults = {
|
|
732
740
|
style: "normal",
|
|
733
741
|
weight: "normal",
|
|
734
742
|
stretch: "normal",
|
|
@@ -737,8 +745,8 @@ j.registeredFontKeys = /* @__PURE__ */ new Set(), j.descriptorDefaults = {
|
|
|
737
745
|
featureSettings: "normal",
|
|
738
746
|
display: "auto"
|
|
739
747
|
};
|
|
740
|
-
let
|
|
741
|
-
const
|
|
748
|
+
let xt = A;
|
|
749
|
+
const as = "data:image/svg+xml;base64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k3LTIuMzE2TDMuNzQgMTBaIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiLz48L3N2Zz4=", us = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI0VDNEU0MCIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNOC4xMjUgMS4yNUExLjg3NSAxLjg3NSAwIDAgMCA2LjI1IDMuMTI1di42MjVIMy4xMjVhLjYyNS42MjUgMCAwIDAgMCAxLjI1aC42MjV2MTEuMjVBMS4yNSAxLjI1IDAgMCAwIDUgMTcuNWgxMGExLjI1IDEuMjUgMCAwIDAgMS4yNS0xLjI1VjVoLjYyNWEuNjI1LjYyNSAwIDAgMCAwLTEuMjVIMTMuNzV2LS42MjVhMS44NzUgMS44NzUgMCAwIDAtMS44NzUtMS44NzVoLTMuNzVabTQuMzc1IDIuNXYtLjYyNWEuNjI1LjYyNSAwIDAgMC0uNjI1LS42MjVoLTMuNzVhLjYyNS42MjUgMCAwIDAtLjYyNS42MjV2LjYyNWg1Wk01IDE2LjI1VjVoMTB2MTEuMjVINVpNOC4xMjUgNy41Yy4zNDUgMCAuNjI1LjI4LjYyNS42MjV2NWEuNjI1LjYyNSAwIDEgMS0xLjI1IDB2LTVjMC0uMzQ1LjI4LS42MjUuNjI1LS42MjVabTQuMzc1IDUuNjI1di01YS42MjUuNjI1IDAgMCAwLTEuMjUgMHY1YS42MjUuNjI1IDAgMSAwIDEuMjUgMFoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjwvc3ZnPg==", ft = {
|
|
742
750
|
style: {
|
|
743
751
|
position: "absolute",
|
|
744
752
|
display: "none",
|
|
@@ -805,14 +813,14 @@ const $e = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMj
|
|
|
805
813
|
],
|
|
806
814
|
offsetTop: 50,
|
|
807
815
|
icons: {
|
|
808
|
-
copyPaste:
|
|
809
|
-
delete:
|
|
810
|
-
lock:
|
|
811
|
-
unlock:
|
|
812
|
-
bringToFront:
|
|
813
|
-
sendToBack:
|
|
814
|
-
bringForward:
|
|
815
|
-
sendBackwards:
|
|
816
|
+
copyPaste: as,
|
|
817
|
+
delete: us,
|
|
818
|
+
lock: is,
|
|
819
|
+
unlock: rs,
|
|
820
|
+
bringToFront: ls,
|
|
821
|
+
sendToBack: hs,
|
|
822
|
+
bringForward: cs,
|
|
823
|
+
sendBackwards: ds
|
|
816
824
|
},
|
|
817
825
|
handlers: {
|
|
818
826
|
copyPaste: (h) => C(null, null, function* () {
|
|
@@ -841,18 +849,18 @@ const $e = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMj
|
|
|
841
849
|
}
|
|
842
850
|
}
|
|
843
851
|
};
|
|
844
|
-
class
|
|
852
|
+
class gs {
|
|
845
853
|
constructor({ editor: t }) {
|
|
846
854
|
this.currentTarget = null, this.currentLocked = !1, this.isTransforming = !1, this.editor = t, this.canvas = t.canvas, this.options = t.options, this._initToolbar();
|
|
847
855
|
}
|
|
848
856
|
_initToolbar() {
|
|
849
857
|
if (!this.options.showToolbar) return;
|
|
850
858
|
const t = this.options.toolbar || {};
|
|
851
|
-
this.config =
|
|
852
|
-
style:
|
|
853
|
-
btnStyle:
|
|
854
|
-
icons:
|
|
855
|
-
handlers:
|
|
859
|
+
this.config = Ie(D(D({}, ft), t), {
|
|
860
|
+
style: D(D({}, ft.style), t.style || {}),
|
|
861
|
+
btnStyle: D(D({}, ft.btnStyle), t.btnStyle || {}),
|
|
862
|
+
icons: D(D({}, ft.icons), t.icons || {}),
|
|
863
|
+
handlers: D(D({}, ft.handlers), t.handlers || {})
|
|
856
864
|
}), this.currentTarget = null, this.currentLocked = !1, this.isTransforming = !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 = () => {
|
|
857
865
|
this.el.style.display = "none";
|
|
858
866
|
}, this._createDOM(), this._bindEvents();
|
|
@@ -957,7 +965,7 @@ class os {
|
|
|
957
965
|
this.el.removeEventListener("mouseover", this._onBtnOver), this.el.removeEventListener("mouseout", this._onBtnOut), this.canvas.off("mouse:down", this._onMouseDown), this.canvas.off("object:moving", this._onObjectMoving), this.canvas.off("object:scaling", this._onObjectScaling), this.canvas.off("object:rotating", this._onObjectRotating), this.canvas.off("mouse:up", this._onMouseUp), this.canvas.off("object:modified", this._onObjectModified), this.canvas.off("selection:created", this._onSelectionChange), this.canvas.off("selection:updated", this._onSelectionChange), this.canvas.off("after:render", this._onSelectionChange), this.canvas.off("selection:cleared", this._onSelectionClear), this.el.remove();
|
|
958
966
|
}
|
|
959
967
|
}
|
|
960
|
-
const
|
|
968
|
+
const fs = {
|
|
961
969
|
position: "absolute",
|
|
962
970
|
display: "none",
|
|
963
971
|
background: "#2B2D33",
|
|
@@ -971,8 +979,8 @@ const as = {
|
|
|
971
979
|
"pointer-events": "none",
|
|
972
980
|
"white-space": "nowrap",
|
|
973
981
|
"box-shadow": "0 2px 8px rgba(0, 0, 0, 0.2)"
|
|
974
|
-
},
|
|
975
|
-
class
|
|
982
|
+
}, De = 16, Oe = 16, ms = "fabric-editor-angle-indicator";
|
|
983
|
+
class Ut {
|
|
976
984
|
constructor({ editor: t }) {
|
|
977
985
|
this.isActive = !1, this.currentAngle = 0, this.editor = t, this.canvas = t.canvas, this.options = t.options, this._createDOM(), this._bindEvents();
|
|
978
986
|
}
|
|
@@ -980,7 +988,7 @@ class Bt {
|
|
|
980
988
|
* Создание DOM-элемента индикатора
|
|
981
989
|
*/
|
|
982
990
|
_createDOM() {
|
|
983
|
-
this.el = document.createElement("div"), this.el.className =
|
|
991
|
+
this.el = document.createElement("div"), this.el.className = ms, Object.entries(fs).forEach(([t, e]) => {
|
|
984
992
|
this.el.style.setProperty(t, e);
|
|
985
993
|
}), this.canvas.wrapperEl.appendChild(this.el);
|
|
986
994
|
}
|
|
@@ -1000,7 +1008,7 @@ class Bt {
|
|
|
1000
1008
|
return;
|
|
1001
1009
|
}
|
|
1002
1010
|
const s = e.angle || 0;
|
|
1003
|
-
this.currentAngle =
|
|
1011
|
+
this.currentAngle = Ut._normalizeAngle(s), this.el.textContent = `${this.currentAngle}°`, this._positionIndicator(t.e), this.isActive || this._showIndicator();
|
|
1004
1012
|
}
|
|
1005
1013
|
/**
|
|
1006
1014
|
* Обработчик отпускания кнопки мыши
|
|
@@ -1031,9 +1039,9 @@ class Bt {
|
|
|
1031
1039
|
*/
|
|
1032
1040
|
_positionIndicator(t) {
|
|
1033
1041
|
const e = this.canvas.wrapperEl.getBoundingClientRect();
|
|
1034
|
-
let s = t.clientX - e.left +
|
|
1042
|
+
let s = t.clientX - e.left + De, n = t.clientY - e.top + Oe;
|
|
1035
1043
|
const o = this.el.getBoundingClientRect(), a = o.width, i = o.height;
|
|
1036
|
-
s + a > e.width && (s = t.clientX - e.left - a -
|
|
1044
|
+
s + a > e.width && (s = t.clientX - e.left - a - De), n + i > e.height && (n = t.clientY - e.top - i - Oe), this.el.style.left = `${s}px`, this.el.style.top = `${n}px`;
|
|
1037
1045
|
}
|
|
1038
1046
|
/**
|
|
1039
1047
|
* Показать индикатор
|
|
@@ -1064,7 +1072,7 @@ class Bt {
|
|
|
1064
1072
|
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;
|
|
1065
1073
|
}
|
|
1066
1074
|
}
|
|
1067
|
-
const
|
|
1075
|
+
const ps = [
|
|
1068
1076
|
"selectable",
|
|
1069
1077
|
"evented",
|
|
1070
1078
|
"id",
|
|
@@ -1085,7 +1093,7 @@ const rs = [
|
|
|
1085
1093
|
"textCaseRaw",
|
|
1086
1094
|
"uppercase"
|
|
1087
1095
|
];
|
|
1088
|
-
class
|
|
1096
|
+
class St {
|
|
1089
1097
|
constructor({ editor: t }) {
|
|
1090
1098
|
this.editor = t, this.canvas = t.canvas, this._historySuspendCount = 0, this.baseState = null, this.patches = [], this.currentIndex = 0, this.maxHistoryLength = t.options.maxHistoryLength, this.totalChangesCount = 0, this.baseStateChangesCount = 0, this._createDiffPatcher();
|
|
1091
1099
|
}
|
|
@@ -1097,7 +1105,7 @@ class It {
|
|
|
1097
1105
|
return this.patches[this.currentIndex - 1] || null;
|
|
1098
1106
|
}
|
|
1099
1107
|
_createDiffPatcher() {
|
|
1100
|
-
this.diffPatcher =
|
|
1108
|
+
this.diffPatcher = Ve({
|
|
1101
1109
|
objectHash(t) {
|
|
1102
1110
|
const e = t, s = t;
|
|
1103
1111
|
return [
|
|
@@ -1133,7 +1141,7 @@ class It {
|
|
|
1133
1141
|
includeValueOnMove: !1
|
|
1134
1142
|
},
|
|
1135
1143
|
textDiff: {
|
|
1136
|
-
diffMatchPatch:
|
|
1144
|
+
diffMatchPatch: Ge,
|
|
1137
1145
|
minLength: 60
|
|
1138
1146
|
}
|
|
1139
1147
|
});
|
|
@@ -1174,7 +1182,7 @@ class It {
|
|
|
1174
1182
|
saveState() {
|
|
1175
1183
|
if (console.log("saveState"), this.skipHistory) return;
|
|
1176
1184
|
console.time("saveState");
|
|
1177
|
-
const t = this.canvas.toDatalessObject([...
|
|
1185
|
+
const t = this.canvas.toDatalessObject([...ps]);
|
|
1178
1186
|
if (console.timeEnd("saveState"), !this.baseState) {
|
|
1179
1187
|
this.baseState = t, this.patches = [], this.currentIndex = 0, console.log("Базовое состояние сохранено.");
|
|
1180
1188
|
return;
|
|
@@ -1221,8 +1229,8 @@ class It {
|
|
|
1221
1229
|
if (!t) return;
|
|
1222
1230
|
console.log("loadStateFromFullState fullState", t);
|
|
1223
1231
|
const { canvas: e, canvasManager: s, interactionBlocker: n, backgroundManager: o } = this.editor, { width: a, height: i } = e;
|
|
1224
|
-
n.overlayMask = null,
|
|
1225
|
-
|
|
1232
|
+
n.overlayMask = null, St._serializeCustomData(t), yield e.loadFromJSON(t, (l, u) => {
|
|
1233
|
+
St._deserializeCustomData(l, u);
|
|
1226
1234
|
});
|
|
1227
1235
|
const r = e.getObjects().find((l) => l.id === "montage-area");
|
|
1228
1236
|
r && (this.editor.montageArea = r, (a !== e.getWidth() || i !== e.getHeight()) && s.updateCanvas());
|
|
@@ -1314,7 +1322,7 @@ class It {
|
|
|
1314
1322
|
});
|
|
1315
1323
|
}
|
|
1316
1324
|
}
|
|
1317
|
-
const
|
|
1325
|
+
const Ms = 0.1, ys = 2, Te = 0.1, bs = 90, tt = 16, et = 16, V = 4096, G = 4096, Ne = "application/image-editor:", jt = ["format", "uppercase", "textCaseRaw"], vs = 50;
|
|
1318
1326
|
class H {
|
|
1319
1327
|
constructor({ editor: t }) {
|
|
1320
1328
|
this.editor = t, this.options = t.options, this._createdBlobUrls = [], this.acceptContentTypes = this.editor.options.acceptContentTypes, this.acceptFormats = this.getAllowedFormatsFromContentTypes();
|
|
@@ -1342,7 +1350,7 @@ class H {
|
|
|
1342
1350
|
withoutSelection: i = !1
|
|
1343
1351
|
} = t;
|
|
1344
1352
|
if (!e) return null;
|
|
1345
|
-
const { canvas: r, montageArea: c, transformManager: d, historyManager: l, errorManager: u } = this.editor, g = yield this.getContentType(e), f = H.getFormatFromContentType(g), { acceptContentTypes: m, acceptFormats:
|
|
1353
|
+
const { canvas: r, montageArea: c, transformManager: d, historyManager: l, errorManager: u } = this.editor, g = yield this.getContentType(e), f = H.getFormatFromContentType(g), { acceptContentTypes: m, acceptFormats: j } = this;
|
|
1346
1354
|
if (!this.isAllowedContentType(g)) {
|
|
1347
1355
|
const p = `Неверный contentType для изображения: ${g}. Ожидается один из: ${this.acceptContentTypes.join(", ")}.`;
|
|
1348
1356
|
return u.emitError({
|
|
@@ -1355,7 +1363,7 @@ class H {
|
|
|
1355
1363
|
format: f,
|
|
1356
1364
|
contentType: g,
|
|
1357
1365
|
acceptContentTypes: m,
|
|
1358
|
-
acceptFormats:
|
|
1366
|
+
acceptFormats: j,
|
|
1359
1367
|
fromClipboard: o,
|
|
1360
1368
|
isBackground: a,
|
|
1361
1369
|
withoutSelection: i
|
|
@@ -1368,8 +1376,8 @@ class H {
|
|
|
1368
1376
|
if (e instanceof File)
|
|
1369
1377
|
p = URL.createObjectURL(e);
|
|
1370
1378
|
else if (typeof e == "string") {
|
|
1371
|
-
const
|
|
1372
|
-
p = URL.createObjectURL(
|
|
1379
|
+
const y = yield (yield fetch(e, { mode: "cors" })).blob();
|
|
1380
|
+
p = URL.createObjectURL(y);
|
|
1373
1381
|
} else
|
|
1374
1382
|
return u.emitError({
|
|
1375
1383
|
origin: "ImageManager",
|
|
@@ -1381,37 +1389,37 @@ class H {
|
|
|
1381
1389
|
format: f,
|
|
1382
1390
|
contentType: g,
|
|
1383
1391
|
acceptContentTypes: m,
|
|
1384
|
-
acceptFormats:
|
|
1392
|
+
acceptFormats: j,
|
|
1385
1393
|
fromClipboard: o,
|
|
1386
1394
|
isBackground: a,
|
|
1387
1395
|
withoutSelection: i
|
|
1388
1396
|
}
|
|
1389
1397
|
}), null;
|
|
1390
1398
|
if (this._createdBlobUrls.push(p), f === "svg") {
|
|
1391
|
-
const
|
|
1392
|
-
M =
|
|
1399
|
+
const b = yield Ye(p);
|
|
1400
|
+
M = Mt.groupSVGElements(b.objects, b.options);
|
|
1393
1401
|
} else
|
|
1394
|
-
M = yield
|
|
1395
|
-
const { width:
|
|
1396
|
-
if (M instanceof
|
|
1397
|
-
const
|
|
1398
|
-
let
|
|
1399
|
-
if (
|
|
1400
|
-
const
|
|
1401
|
-
this._createdBlobUrls.push(
|
|
1402
|
-
} else if (
|
|
1403
|
-
const
|
|
1404
|
-
this._createdBlobUrls.push(
|
|
1402
|
+
M = yield gt.fromURL(p, { crossOrigin: "anonymous" });
|
|
1403
|
+
const { width: w, height: L } = M;
|
|
1404
|
+
if (M instanceof gt) {
|
|
1405
|
+
const b = M.getElement();
|
|
1406
|
+
let y = "";
|
|
1407
|
+
if (b instanceof HTMLImageElement ? y = b.src : b instanceof HTMLCanvasElement && (y = b.toDataURL()), L > G || w > V) {
|
|
1408
|
+
const S = yield this.resizeImageToBoundaries(y, "max"), v = URL.createObjectURL(S);
|
|
1409
|
+
this._createdBlobUrls.push(v), M = yield gt.fromURL(v, { crossOrigin: "anonymous" });
|
|
1410
|
+
} else if (L < et || w < tt) {
|
|
1411
|
+
const S = yield this.resizeImageToBoundaries(y, "min"), v = URL.createObjectURL(S);
|
|
1412
|
+
this._createdBlobUrls.push(v), M = yield gt.fromURL(v, { crossOrigin: "anonymous" });
|
|
1405
1413
|
}
|
|
1406
1414
|
}
|
|
1407
1415
|
if (M.set("id", `${M.type}-${x()}`), M.set("format", f), s === "scale-montage")
|
|
1408
1416
|
this.editor.canvasManager.scaleMontageAreaToImage({ object: M, withoutSave: !0 });
|
|
1409
1417
|
else {
|
|
1410
|
-
const { width:
|
|
1411
|
-
s === "image-contain" &&
|
|
1418
|
+
const { width: b, height: y } = c, S = this.calculateScaleFactor({ imageObject: M, scaleType: s });
|
|
1419
|
+
s === "image-contain" && S < 1 ? d.fitObject({ object: M, type: "contain", withoutSave: !0 }) : s === "image-cover" && (w > b || L > y) && d.fitObject({ object: M, type: "cover", withoutSave: !0 });
|
|
1412
1420
|
}
|
|
1413
1421
|
r.add(M), r.centerObject(M), i || r.setActiveObject(M), r.renderAll(), l.resumeHistory(), n || l.saveState();
|
|
1414
|
-
const
|
|
1422
|
+
const k = {
|
|
1415
1423
|
image: M,
|
|
1416
1424
|
format: f,
|
|
1417
1425
|
contentType: g,
|
|
@@ -1422,7 +1430,7 @@ class H {
|
|
|
1422
1430
|
isBackground: a,
|
|
1423
1431
|
withoutSelection: i
|
|
1424
1432
|
};
|
|
1425
|
-
return r.fire("editor:image-imported",
|
|
1433
|
+
return r.fire("editor:image-imported", k), k;
|
|
1426
1434
|
} catch (p) {
|
|
1427
1435
|
return u.emitError({
|
|
1428
1436
|
origin: "ImageManager",
|
|
@@ -1453,15 +1461,15 @@ class H {
|
|
|
1453
1461
|
*/
|
|
1454
1462
|
resizeImageToBoundaries(t, e = "max") {
|
|
1455
1463
|
return C(this, null, function* () {
|
|
1456
|
-
let s = `Размер изображения больше максимального размера канваса, поэтому оно будет уменьшено до максимальных размеров c сохранением пропорций: ${
|
|
1457
|
-
e === "min" && (s = `Размер изображения меньше минимального размера канваса, поэтому оно будет увеличено до минимальных размеров c сохранением пропорций: ${
|
|
1464
|
+
let s = `Размер изображения больше максимального размера канваса, поэтому оно будет уменьшено до максимальных размеров c сохранением пропорций: ${V}x${G}`;
|
|
1465
|
+
e === "min" && (s = `Размер изображения меньше минимального размера канваса, поэтому оно будет увеличено до минимальных размеров c сохранением пропорций: ${tt}x${et}`);
|
|
1458
1466
|
const n = {
|
|
1459
1467
|
dataURL: t,
|
|
1460
1468
|
sizeType: e,
|
|
1461
|
-
maxWidth:
|
|
1462
|
-
maxHeight:
|
|
1463
|
-
minWidth:
|
|
1464
|
-
minHeight:
|
|
1469
|
+
maxWidth: V,
|
|
1470
|
+
maxHeight: G,
|
|
1471
|
+
minWidth: tt,
|
|
1472
|
+
minHeight: et
|
|
1465
1473
|
};
|
|
1466
1474
|
return this.editor.errorManager.emitWarning({
|
|
1467
1475
|
origin: "ImageManager",
|
|
@@ -1494,20 +1502,20 @@ class H {
|
|
|
1494
1502
|
try {
|
|
1495
1503
|
const d = s === "application/pdf", l = d ? "image/jpg" : s, u = H.getFormatFromContentType(l);
|
|
1496
1504
|
i.setCoords();
|
|
1497
|
-
const { left: g, top: f, width: m, height:
|
|
1505
|
+
const { left: g, top: f, width: m, height: j } = i.getBoundingRect(), p = yield a.clone(["id", "format", "locked"]);
|
|
1498
1506
|
p.enableRetinaScaling = !1, ["image/jpg", "image/jpeg"].includes(l) && (p.backgroundColor = "#ffffff");
|
|
1499
|
-
const M = p.getObjects().find((
|
|
1507
|
+
const M = p.getObjects().find((I) => I.id === i.id);
|
|
1500
1508
|
if (M && (M.visible = !1), c != null && c.isBlocked) {
|
|
1501
|
-
const
|
|
1502
|
-
|
|
1509
|
+
const I = p.getObjects().find((E) => E.id === c.overlayMask.id);
|
|
1510
|
+
I && (I.visible = !1);
|
|
1503
1511
|
}
|
|
1504
|
-
p.viewportTransform = [1, 0, 0, 1, -g, -f], p.setDimensions({ width: m, height:
|
|
1505
|
-
const
|
|
1506
|
-
if (u === "svg" &&
|
|
1507
|
-
const
|
|
1512
|
+
p.viewportTransform = [1, 0, 0, 1, -g, -f], p.setDimensions({ width: m, height: j }, { backstoreOnly: !0 }), p.renderAll();
|
|
1513
|
+
const w = p.getObjects().filter((I) => I.format).every((I) => I.format === "svg");
|
|
1514
|
+
if (u === "svg" && w) {
|
|
1515
|
+
const I = p.toSVG();
|
|
1508
1516
|
p.dispose();
|
|
1509
|
-
const
|
|
1510
|
-
image: H._exportSVGStringAsFile(
|
|
1517
|
+
const N = {
|
|
1518
|
+
image: H._exportSVGStringAsFile(I, {
|
|
1511
1519
|
exportAsBase64: n,
|
|
1512
1520
|
exportAsBlob: o,
|
|
1513
1521
|
fileName: e
|
|
@@ -1516,66 +1524,66 @@ class H {
|
|
|
1516
1524
|
contentType: "image/svg+xml",
|
|
1517
1525
|
fileName: e.replace(/\.[^/.]+$/, ".svg")
|
|
1518
1526
|
};
|
|
1519
|
-
return a.fire("editor:canvas-exported",
|
|
1527
|
+
return a.fire("editor:canvas-exported", N), N;
|
|
1520
1528
|
}
|
|
1521
|
-
const
|
|
1522
|
-
p.getElement().toBlob((
|
|
1523
|
-
|
|
1529
|
+
const L = yield new Promise((I, E) => {
|
|
1530
|
+
p.getElement().toBlob((N) => {
|
|
1531
|
+
N ? I(N) : E(new Error("Failed to create Blob from canvas"));
|
|
1524
1532
|
});
|
|
1525
1533
|
});
|
|
1526
1534
|
if (p.dispose(), o) {
|
|
1527
|
-
const
|
|
1528
|
-
image:
|
|
1535
|
+
const I = {
|
|
1536
|
+
image: L,
|
|
1529
1537
|
format: u,
|
|
1530
1538
|
contentType: l,
|
|
1531
1539
|
fileName: e
|
|
1532
1540
|
};
|
|
1533
|
-
return a.fire("editor:canvas-exported",
|
|
1541
|
+
return a.fire("editor:canvas-exported", I), I;
|
|
1534
1542
|
}
|
|
1535
|
-
const
|
|
1543
|
+
const k = yield createImageBitmap(L), b = yield r.post(
|
|
1536
1544
|
"toDataURL",
|
|
1537
|
-
{ format: u, quality: 1, bitmap:
|
|
1538
|
-
[
|
|
1545
|
+
{ format: u, quality: 1, bitmap: k },
|
|
1546
|
+
[k]
|
|
1539
1547
|
);
|
|
1540
1548
|
if (d) {
|
|
1541
|
-
const
|
|
1542
|
-
orientation:
|
|
1549
|
+
const E = m * 0.264583, N = j * 0.264583, B = (yield this.editor.moduleLoader.loadModule("jspdf")).jsPDF, U = new B({
|
|
1550
|
+
orientation: E > N ? "landscape" : "portrait",
|
|
1543
1551
|
unit: "mm",
|
|
1544
|
-
format: [
|
|
1552
|
+
format: [E, N]
|
|
1545
1553
|
});
|
|
1546
|
-
if (
|
|
1547
|
-
const
|
|
1548
|
-
image:
|
|
1554
|
+
if (U.addImage(String(b), "JPG", 0, 0, E, N), n) {
|
|
1555
|
+
const Z = {
|
|
1556
|
+
image: U.output("datauristring"),
|
|
1549
1557
|
format: "pdf",
|
|
1550
1558
|
contentType: "application/pdf",
|
|
1551
1559
|
fileName: e
|
|
1552
1560
|
};
|
|
1553
|
-
return a.fire("editor:canvas-exported",
|
|
1561
|
+
return a.fire("editor:canvas-exported", Z), Z;
|
|
1554
1562
|
}
|
|
1555
|
-
const
|
|
1556
|
-
image: new File([
|
|
1563
|
+
const W = U.output("blob"), P = {
|
|
1564
|
+
image: new File([W], e, { type: "application/pdf" }),
|
|
1557
1565
|
format: "pdf",
|
|
1558
1566
|
contentType: "application/pdf",
|
|
1559
1567
|
fileName: e
|
|
1560
1568
|
};
|
|
1561
|
-
return a.fire("editor:canvas-exported",
|
|
1569
|
+
return a.fire("editor:canvas-exported", P), P;
|
|
1562
1570
|
}
|
|
1563
1571
|
if (n) {
|
|
1564
|
-
const
|
|
1565
|
-
image:
|
|
1572
|
+
const I = {
|
|
1573
|
+
image: b,
|
|
1566
1574
|
format: u,
|
|
1567
1575
|
contentType: l,
|
|
1568
1576
|
fileName: e
|
|
1569
1577
|
};
|
|
1570
|
-
return a.fire("editor:canvas-exported",
|
|
1578
|
+
return a.fire("editor:canvas-exported", I), I;
|
|
1571
1579
|
}
|
|
1572
|
-
const
|
|
1573
|
-
image: new File([
|
|
1580
|
+
const y = u === "svg" && !w ? e.replace(/\.[^/.]+$/, ".png") : e, v = {
|
|
1581
|
+
image: new File([L], y, { type: l }),
|
|
1574
1582
|
format: u,
|
|
1575
1583
|
contentType: l,
|
|
1576
|
-
fileName:
|
|
1584
|
+
fileName: y
|
|
1577
1585
|
};
|
|
1578
|
-
return a.fire("editor:canvas-exported",
|
|
1586
|
+
return a.fire("editor:canvas-exported", v), v;
|
|
1579
1587
|
} catch (d) {
|
|
1580
1588
|
return this.editor.errorManager.emitError({
|
|
1581
1589
|
origin: "ImageManager",
|
|
@@ -1618,21 +1626,21 @@ class H {
|
|
|
1618
1626
|
try {
|
|
1619
1627
|
const d = H.getFormatFromContentType(n);
|
|
1620
1628
|
if (d === "svg") {
|
|
1621
|
-
const m = c.toSVG(),
|
|
1629
|
+
const m = c.toSVG(), j = H._exportSVGStringAsFile(m, {
|
|
1622
1630
|
exportAsBase64: o,
|
|
1623
1631
|
exportAsBlob: a,
|
|
1624
1632
|
fileName: s
|
|
1625
1633
|
}), p = {
|
|
1626
1634
|
object: c,
|
|
1627
|
-
image:
|
|
1635
|
+
image: j,
|
|
1628
1636
|
format: d,
|
|
1629
1637
|
contentType: "image/svg+xml",
|
|
1630
1638
|
fileName: s.replace(/\.[^/.]+$/, ".svg")
|
|
1631
1639
|
};
|
|
1632
1640
|
return i.fire("editor:object-exported", p), p;
|
|
1633
1641
|
}
|
|
1634
|
-
if (o && c instanceof
|
|
1635
|
-
const m = yield createImageBitmap(c.getElement()),
|
|
1642
|
+
if (o && c instanceof gt) {
|
|
1643
|
+
const m = yield createImageBitmap(c.getElement()), j = yield r.post(
|
|
1636
1644
|
"toDataURL",
|
|
1637
1645
|
{
|
|
1638
1646
|
format: d,
|
|
@@ -1642,7 +1650,7 @@ class H {
|
|
|
1642
1650
|
[m]
|
|
1643
1651
|
), p = {
|
|
1644
1652
|
object: c,
|
|
1645
|
-
image:
|
|
1653
|
+
image: j,
|
|
1646
1654
|
format: d,
|
|
1647
1655
|
contentType: n,
|
|
1648
1656
|
fileName: s
|
|
@@ -1651,9 +1659,9 @@ class H {
|
|
|
1651
1659
|
}
|
|
1652
1660
|
const l = c.toCanvasElement({
|
|
1653
1661
|
enableRetinaScaling: !1
|
|
1654
|
-
}), u = yield new Promise((m,
|
|
1662
|
+
}), u = yield new Promise((m, j) => {
|
|
1655
1663
|
l.toBlob((p) => {
|
|
1656
|
-
p ? m(p) :
|
|
1664
|
+
p ? m(p) : j(new Error("Failed to create Blob from canvas"));
|
|
1657
1665
|
});
|
|
1658
1666
|
});
|
|
1659
1667
|
if (a) {
|
|
@@ -1802,11 +1810,11 @@ class H {
|
|
|
1802
1810
|
return e ? e[1] : "";
|
|
1803
1811
|
}
|
|
1804
1812
|
}
|
|
1805
|
-
const
|
|
1806
|
-
function
|
|
1813
|
+
const $ = (h, t, e) => Math.max(Math.min(h, e), t), Le = (h, t) => h * t, js = (h, t) => new It(h / 2, t / 2);
|
|
1814
|
+
function Is(h) {
|
|
1807
1815
|
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";
|
|
1808
1816
|
}
|
|
1809
|
-
class
|
|
1817
|
+
class As {
|
|
1810
1818
|
/**
|
|
1811
1819
|
* @param options
|
|
1812
1820
|
* @param options.editor – экземпляр редактора
|
|
@@ -1837,10 +1845,10 @@ class fs {
|
|
|
1837
1845
|
canvas: o,
|
|
1838
1846
|
montageArea: a,
|
|
1839
1847
|
options: { canvasBackstoreWidth: i }
|
|
1840
|
-
} = this.editor, { width: r, height: c } = a, d =
|
|
1848
|
+
} = this.editor, { width: r, height: c } = a, d = $(Number(t), tt, V);
|
|
1841
1849
|
if (!i || i === "auto" || n ? this.adaptCanvasToContainer() : i ? this.setCanvasBackstoreWidth(Number(i)) : this.setCanvasBackstoreWidth(d), a.set({ width: d }), (f = o.clipPath) == null || f.set({ width: d }), e) {
|
|
1842
|
-
const m = d / r,
|
|
1843
|
-
this.setResolutionHeight(
|
|
1850
|
+
const m = d / r, j = Le(c, m);
|
|
1851
|
+
this.setResolutionHeight(j);
|
|
1844
1852
|
return;
|
|
1845
1853
|
}
|
|
1846
1854
|
const { left: l, top: u } = this.getObjectDefaultCoords(a), g = o.getZoom();
|
|
@@ -1867,10 +1875,10 @@ class fs {
|
|
|
1867
1875
|
canvas: o,
|
|
1868
1876
|
montageArea: a,
|
|
1869
1877
|
options: { canvasBackstoreHeight: i }
|
|
1870
|
-
} = this.editor, { width: r, height: c } = a, d =
|
|
1878
|
+
} = this.editor, { width: r, height: c } = a, d = $(Number(t), et, G);
|
|
1871
1879
|
if (!i || i === "auto" || n ? this.adaptCanvasToContainer() : i ? this.setCanvasBackstoreHeight(Number(i)) : this.setCanvasBackstoreHeight(d), a.set({ height: d }), (f = o.clipPath) == null || f.set({ height: d }), e) {
|
|
1872
|
-
const m = d / c,
|
|
1873
|
-
this.setResolutionWidth(
|
|
1880
|
+
const m = d / c, j = Le(r, m);
|
|
1881
|
+
this.setResolutionWidth(j);
|
|
1874
1882
|
return;
|
|
1875
1883
|
}
|
|
1876
1884
|
const { left: l, top: u } = this.getObjectDefaultCoords(a), g = o.getZoom();
|
|
@@ -1887,7 +1895,7 @@ class fs {
|
|
|
1887
1895
|
*/
|
|
1888
1896
|
centerMontageArea() {
|
|
1889
1897
|
var r;
|
|
1890
|
-
const { canvas: t, montageArea: e } = this.editor, s = t.getWidth(), n = t.getHeight(), o = t.getZoom(), a =
|
|
1898
|
+
const { canvas: t, montageArea: e } = this.editor, s = t.getWidth(), n = t.getHeight(), o = t.getZoom(), a = js(s, n);
|
|
1891
1899
|
e.set({
|
|
1892
1900
|
left: s / 2,
|
|
1893
1901
|
top: n / 2
|
|
@@ -1920,7 +1928,7 @@ class fs {
|
|
|
1920
1928
|
*/
|
|
1921
1929
|
setCanvasBackstoreWidth(t) {
|
|
1922
1930
|
if (!t || typeof t != "number") return;
|
|
1923
|
-
const e =
|
|
1931
|
+
const e = $(t, tt, V);
|
|
1924
1932
|
this.editor.canvas.setDimensions({ width: e }, { backstoreOnly: !0 });
|
|
1925
1933
|
}
|
|
1926
1934
|
/**
|
|
@@ -1929,7 +1937,7 @@ class fs {
|
|
|
1929
1937
|
*/
|
|
1930
1938
|
setCanvasBackstoreHeight(t) {
|
|
1931
1939
|
if (!t || typeof t != "number") return;
|
|
1932
|
-
const e =
|
|
1940
|
+
const e = $(t, et, G);
|
|
1933
1941
|
this.editor.canvas.setDimensions({ height: e }, { backstoreOnly: !0 });
|
|
1934
1942
|
}
|
|
1935
1943
|
/**
|
|
@@ -1938,7 +1946,7 @@ class fs {
|
|
|
1938
1946
|
* с учётом минимальных и максимальных значений.
|
|
1939
1947
|
*/
|
|
1940
1948
|
adaptCanvasToContainer() {
|
|
1941
|
-
const { canvas: t } = this.editor, e = this.getEditorContainer(), s = e.clientWidth, n = e.clientHeight, o =
|
|
1949
|
+
const { canvas: t } = this.editor, e = this.getEditorContainer(), s = e.clientWidth, n = e.clientHeight, o = $(s, tt, V), a = $(n, et, G);
|
|
1942
1950
|
t.setDimensions({ width: o, height: a }, { backstoreOnly: !0 });
|
|
1943
1951
|
}
|
|
1944
1952
|
/**
|
|
@@ -1972,7 +1980,7 @@ class fs {
|
|
|
1972
1980
|
if (d.length === 1)
|
|
1973
1981
|
t.setActiveObject(d[0]);
|
|
1974
1982
|
else {
|
|
1975
|
-
const l = new
|
|
1983
|
+
const l = new T(d, {
|
|
1976
1984
|
canvas: t
|
|
1977
1985
|
});
|
|
1978
1986
|
t.setActiveObject(l);
|
|
@@ -2138,14 +2146,14 @@ class fs {
|
|
|
2138
2146
|
montageAreaHeight: r
|
|
2139
2147
|
}
|
|
2140
2148
|
} = this.editor, c = t || n.getActiveObject();
|
|
2141
|
-
if (!
|
|
2149
|
+
if (!Is(c)) return;
|
|
2142
2150
|
const { width: d, height: l } = c;
|
|
2143
|
-
let u = Math.min(d,
|
|
2151
|
+
let u = Math.min(d, V), g = Math.min(l, G);
|
|
2144
2152
|
if (e) {
|
|
2145
2153
|
const {
|
|
2146
2154
|
width: f,
|
|
2147
2155
|
height: m
|
|
2148
|
-
} = o,
|
|
2156
|
+
} = o, j = d / f, p = l / m, M = Math.max(j, p);
|
|
2149
2157
|
u = f * M, g = m * M;
|
|
2150
2158
|
}
|
|
2151
2159
|
this.setResolutionWidth(u, { withoutSave: !0 }), this.setResolutionHeight(g, { withoutSave: !0 }), this.editor.backgroundManager.backgroundObject && this.editor.backgroundManager.refresh(), (d > i || l > r) && this.editor.zoomManager.calculateAndApplyDefaultZoom(), a.resetObject({ object: c, withoutSave: !0 }), n.centerObject(c), n.renderAll(), s || this.editor.historyManager.saveState(), n.fire("editor:montage-area-scaled-to-image", {
|
|
@@ -2198,7 +2206,7 @@ class fs {
|
|
|
2198
2206
|
);
|
|
2199
2207
|
}
|
|
2200
2208
|
}
|
|
2201
|
-
class
|
|
2209
|
+
class Ss {
|
|
2202
2210
|
constructor({ editor: t }) {
|
|
2203
2211
|
this.editor = t, this.options = t.options;
|
|
2204
2212
|
}
|
|
@@ -2209,7 +2217,7 @@ class ms {
|
|
|
2209
2217
|
* @param options.withoutSave - Не сохранять состояние
|
|
2210
2218
|
* @fires editor:object-rotated
|
|
2211
2219
|
*/
|
|
2212
|
-
rotate(t =
|
|
2220
|
+
rotate(t = bs, { withoutSave: e } = {}) {
|
|
2213
2221
|
const { canvas: s, historyManager: n } = this.editor, o = s.getActiveObject();
|
|
2214
2222
|
if (!o) return;
|
|
2215
2223
|
const a = o.angle + t;
|
|
@@ -2259,7 +2267,7 @@ class ms {
|
|
|
2259
2267
|
withoutSave: s
|
|
2260
2268
|
} = {}) {
|
|
2261
2269
|
const { canvas: n, historyManager: o } = this.editor, a = t || n.getActiveObject();
|
|
2262
|
-
a && (a instanceof
|
|
2270
|
+
a && (a instanceof T ? a.getObjects().forEach((i) => {
|
|
2263
2271
|
i.set("opacity", e);
|
|
2264
2272
|
}) : a.set("opacity", e), n.renderAll(), s || o.saveState(), n.fire("editor:object-opacity-changed", {
|
|
2265
2273
|
object: a,
|
|
@@ -2286,12 +2294,12 @@ class ms {
|
|
|
2286
2294
|
} = {}) {
|
|
2287
2295
|
const { canvas: o, historyManager: a } = this.editor, i = t || o.getActiveObject();
|
|
2288
2296
|
if (i) {
|
|
2289
|
-
if (i instanceof
|
|
2297
|
+
if (i instanceof T && !n) {
|
|
2290
2298
|
const r = i.getObjects();
|
|
2291
2299
|
o.discardActiveObject(), r.forEach((d) => {
|
|
2292
2300
|
this._fitSingleObject(d, e);
|
|
2293
2301
|
});
|
|
2294
|
-
const c = new
|
|
2302
|
+
const c = new T(r, { canvas: o });
|
|
2295
2303
|
o.setActiveObject(c);
|
|
2296
2304
|
} else
|
|
2297
2305
|
this._fitSingleObject(i, e);
|
|
@@ -2310,11 +2318,11 @@ class ms {
|
|
|
2310
2318
|
* @private
|
|
2311
2319
|
*/
|
|
2312
2320
|
_fitSingleObject(t, e) {
|
|
2313
|
-
const { canvas: s, montageArea: n } = this.editor, { width: o, height: a, scaleX: i = 1, scaleY: r = 1, angle: c = 0 } = t, d = o * Math.abs(i), l = a * Math.abs(r), u = c * Math.PI / 180, g = Math.abs(Math.cos(u)), f = Math.abs(Math.sin(u)), m = d * g + l * f,
|
|
2314
|
-
let
|
|
2315
|
-
e === "contain" ?
|
|
2316
|
-
scaleX: i *
|
|
2317
|
-
scaleY: r *
|
|
2321
|
+
const { canvas: s, montageArea: n } = this.editor, { width: o, height: a, scaleX: i = 1, scaleY: r = 1, angle: c = 0 } = t, d = o * Math.abs(i), l = a * Math.abs(r), u = c * Math.PI / 180, g = Math.abs(Math.cos(u)), f = Math.abs(Math.sin(u)), m = d * g + l * f, j = d * f + l * g, p = n.width, M = n.height;
|
|
2322
|
+
let w;
|
|
2323
|
+
e === "contain" ? w = Math.min(p / m, M / j) : w = Math.max(p / m, M / j), t.set({
|
|
2324
|
+
scaleX: i * w,
|
|
2325
|
+
scaleY: r * w
|
|
2318
2326
|
}), s.centerObject(t);
|
|
2319
2327
|
}
|
|
2320
2328
|
/**
|
|
@@ -2364,9 +2372,9 @@ class ms {
|
|
|
2364
2372
|
});
|
|
2365
2373
|
}
|
|
2366
2374
|
}
|
|
2367
|
-
class
|
|
2375
|
+
class Cs {
|
|
2368
2376
|
constructor({ editor: t }) {
|
|
2369
|
-
this.editor = t, this.options = t.options, this.minZoom = this.options.minZoom ||
|
|
2377
|
+
this.editor = t, this.options = t.options, this.minZoom = this.options.minZoom || Ms, this.maxZoom = this.options.maxZoom || ys, this.defaultZoom = this.options.defaultScale;
|
|
2370
2378
|
}
|
|
2371
2379
|
/**
|
|
2372
2380
|
* Вспомогательный метод для вычисления размеров масштабированной монтажной области
|
|
@@ -2388,10 +2396,10 @@ class ps {
|
|
|
2388
2396
|
* @private
|
|
2389
2397
|
*/
|
|
2390
2398
|
_getClampedPointerCoordinates(t) {
|
|
2391
|
-
const { canvas: e, montageArea: s } = this.editor, n = e.getPointer(t, !0), o = e.viewportTransform, a = e.getZoom(), i = s.left - s.width / 2, r = s.left + s.width / 2, c = s.top - s.height / 2, d = s.top + s.height / 2, l = i * a + o[4], u = r * a + o[4], g = c * a + o[5], f = d * a + o[5], m = Math.max(l, Math.min(u, n.x)),
|
|
2399
|
+
const { canvas: e, montageArea: s } = this.editor, n = e.getPointer(t, !0), o = e.viewportTransform, a = e.getZoom(), i = s.left - s.width / 2, r = s.left + s.width / 2, c = s.top - s.height / 2, d = s.top + s.height / 2, l = i * a + o[4], u = r * a + o[4], g = c * a + o[5], f = d * a + o[5], m = Math.max(l, Math.min(u, n.x)), j = Math.max(g, Math.min(f, n.y));
|
|
2392
2400
|
return {
|
|
2393
2401
|
x: m,
|
|
2394
|
-
y:
|
|
2402
|
+
y: j
|
|
2395
2403
|
};
|
|
2396
2404
|
}
|
|
2397
2405
|
/**
|
|
@@ -2423,10 +2431,10 @@ class ps {
|
|
|
2423
2431
|
* @private
|
|
2424
2432
|
*/
|
|
2425
2433
|
_calculateEmptySpaceRatio(t) {
|
|
2426
|
-
const { canvas: e, montageArea: s } = this.editor, n = e.viewportTransform, o = e.getWidth(), a = e.getHeight(), i = 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, g = -n[5] / t, f = (-n[5] + a) / t, m = l < i,
|
|
2427
|
-
if (!(m ||
|
|
2428
|
-
const
|
|
2429
|
-
return Math.max(
|
|
2434
|
+
const { canvas: e, montageArea: s } = this.editor, n = e.viewportTransform, o = e.getWidth(), a = e.getHeight(), i = 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, g = -n[5] / t, f = (-n[5] + a) / t, m = l < i, j = u > r, p = g < c, M = f > d;
|
|
2435
|
+
if (!(m || j || p || M)) return 0;
|
|
2436
|
+
const L = Math.max(0, i - l), k = Math.max(0, u - r), b = Math.max(0, c - g), y = Math.max(0, f - d), S = Math.max(L, k), v = Math.max(b, y), I = S / o, E = v / a;
|
|
2437
|
+
return Math.max(I, E);
|
|
2430
2438
|
}
|
|
2431
2439
|
/**
|
|
2432
2440
|
* Вычисляет плавный шаг перемещения viewport к центру с ускорением
|
|
@@ -2442,8 +2450,8 @@ class ps {
|
|
|
2442
2450
|
const { canvas: a, montageArea: i } = this.editor, r = a.viewportTransform, c = a.getWidth(), d = a.getHeight(), l = t.x - r[4], u = t.y - r[5], g = Math.abs(n), f = e - s;
|
|
2443
2451
|
if (Math.abs(f) / g <= 0.1)
|
|
2444
2452
|
return { x: l, y: u };
|
|
2445
|
-
const
|
|
2446
|
-
return { x:
|
|
2453
|
+
const j = c / 2, p = d / 2, M = i.left, w = i.top, L = j - M * s, k = p - w * s, b = (L - r[4]) / (e - s), y = (k - r[5]) / (e - s), S = b * g, v = y * g, I = S * o, E = v * o, N = Math.abs(I) > Math.abs(l) ? l : I, B = Math.abs(E) > Math.abs(u) ? u : E;
|
|
2454
|
+
return { x: N, y: B };
|
|
2447
2455
|
}
|
|
2448
2456
|
/**
|
|
2449
2457
|
* Применяет плавное центрирование viewport при приближении к defaultZoom.
|
|
@@ -2455,7 +2463,7 @@ class ps {
|
|
|
2455
2463
|
* @returns true если центрирование было применено
|
|
2456
2464
|
* @private
|
|
2457
2465
|
*/
|
|
2458
|
-
_applyViewportCentering(t, e = !1, s =
|
|
2466
|
+
_applyViewportCentering(t, e = !1, s = Te) {
|
|
2459
2467
|
const { canvas: n } = this.editor, o = this._getScaledMontageDimensions(t), a = n.getWidth(), i = n.getHeight(), r = o.width > a || o.height > i, c = this._calculateFitZoom(), d = t - c;
|
|
2460
2468
|
if (!(!r || d) && !e)
|
|
2461
2469
|
return !1;
|
|
@@ -2530,10 +2538,10 @@ class ps {
|
|
|
2530
2538
|
* @param options.pointY - Координата Y точки зума
|
|
2531
2539
|
* @fires editor:zoom-changed
|
|
2532
2540
|
*/
|
|
2533
|
-
zoom(t =
|
|
2541
|
+
zoom(t = Te, e = {}) {
|
|
2534
2542
|
var g, f;
|
|
2535
2543
|
if (!t) return;
|
|
2536
|
-
const { minZoom: s, maxZoom: n } = this, { canvas: o } = this.editor, a = t < 0, i = o.getZoom(), r = o.getCenterPoint(), c = (g = e.pointX) != null ? g : r.x, d = (f = e.pointY) != null ? f : r.y, l = new
|
|
2544
|
+
const { minZoom: s, maxZoom: n } = this, { canvas: o } = this.editor, a = t < 0, i = o.getZoom(), r = o.getCenterPoint(), c = (g = e.pointX) != null ? g : r.x, d = (f = e.pointY) != null ? f : r.y, l = new It(c, d);
|
|
2537
2545
|
this.editor.montageArea.setCoords(), this.editor.canvas.requestRenderAll();
|
|
2538
2546
|
let u = Number((i + Number(t)).toFixed(3));
|
|
2539
2547
|
u > n && (u = n), u < s && (u = s), o.zoomToPoint(l, u), this.editor.panConstraintManager.updateBounds(), this._applyViewportCentering(u, a, t), o.fire("editor:zoom-changed", {
|
|
@@ -2548,7 +2556,7 @@ class ps {
|
|
|
2548
2556
|
* @fires editor:zoom-changed
|
|
2549
2557
|
*/
|
|
2550
2558
|
setZoom(t = this.defaultZoom) {
|
|
2551
|
-
const { minZoom: e, maxZoom: s } = this, { canvas: n } = this.editor, o = new
|
|
2559
|
+
const { minZoom: e, maxZoom: s } = this, { canvas: n } = this.editor, o = new It(n.getCenterPoint());
|
|
2552
2560
|
let a = t;
|
|
2553
2561
|
t > s && (a = s), t < e && (a = e), n.zoomToPoint(o, a), n.fire("editor:zoom-changed", {
|
|
2554
2562
|
currentZoom: n.getZoom(),
|
|
@@ -2561,14 +2569,14 @@ class ps {
|
|
|
2561
2569
|
* @fires editor:zoom-changed
|
|
2562
2570
|
*/
|
|
2563
2571
|
resetZoom() {
|
|
2564
|
-
const { canvas: t } = this.editor, e = new
|
|
2572
|
+
const { canvas: t } = this.editor, e = new It(t.getCenterPoint());
|
|
2565
2573
|
t.zoomToPoint(e, this.defaultZoom), this.editor.canvas.fire("editor:zoom-changed", {
|
|
2566
2574
|
currentZoom: t.getZoom(),
|
|
2567
2575
|
point: e
|
|
2568
2576
|
}), this.editor.panConstraintManager.updateBounds();
|
|
2569
2577
|
}
|
|
2570
2578
|
}
|
|
2571
|
-
class
|
|
2579
|
+
class ws {
|
|
2572
2580
|
constructor({ editor: t }) {
|
|
2573
2581
|
this.editor = t, this.isBlocked = !1, this.overlayMask = null, this._createOverlay();
|
|
2574
2582
|
}
|
|
@@ -2625,7 +2633,7 @@ class Ms {
|
|
|
2625
2633
|
}), t.upperCanvasEl.style.pointerEvents = "", t.lowerCanvasEl.style.pointerEvents = "", this.overlayMask.visible = !1, t.requestRenderAll(), t.fire("editor:enabled"), s.resumeHistory();
|
|
2626
2634
|
}
|
|
2627
2635
|
}
|
|
2628
|
-
class
|
|
2636
|
+
class q {
|
|
2629
2637
|
constructor({ editor: t }) {
|
|
2630
2638
|
this.editor = t, this.backgroundObject = null;
|
|
2631
2639
|
}
|
|
@@ -2680,8 +2688,8 @@ class Q {
|
|
|
2680
2688
|
try {
|
|
2681
2689
|
const { historyManager: o } = this.editor, { backgroundObject: a } = this;
|
|
2682
2690
|
if (o.suspendHistory(), a && a.backgroundType === "gradient") {
|
|
2683
|
-
const i =
|
|
2684
|
-
if (
|
|
2691
|
+
const i = q._createFabricGradient(t);
|
|
2692
|
+
if (q._isGradientEqual(a.fill, i)) {
|
|
2685
2693
|
o.resumeHistory();
|
|
2686
2694
|
return;
|
|
2687
2695
|
}
|
|
@@ -2853,7 +2861,7 @@ class Q {
|
|
|
2853
2861
|
backgroundType: "gradient",
|
|
2854
2862
|
backgroundId: `background-${x()}`
|
|
2855
2863
|
}, { withoutSelection: !0 }), this.refresh();
|
|
2856
|
-
const e =
|
|
2864
|
+
const e = q._createFabricGradient(t);
|
|
2857
2865
|
this.backgroundObject.set("fill", e), this.editor.canvas.requestRenderAll();
|
|
2858
2866
|
}
|
|
2859
2867
|
/**
|
|
@@ -2905,8 +2913,8 @@ class Q {
|
|
|
2905
2913
|
{ offset: o / 100, color: s }
|
|
2906
2914
|
];
|
|
2907
2915
|
if (t.type === "linear") {
|
|
2908
|
-
const l = t.angle * Math.PI / 180, u =
|
|
2909
|
-
return new
|
|
2916
|
+
const l = t.angle * Math.PI / 180, u = q._angleToCoords(l);
|
|
2917
|
+
return new Ce({
|
|
2910
2918
|
type: "linear",
|
|
2911
2919
|
gradientUnits: "percentage",
|
|
2912
2920
|
coords: u,
|
|
@@ -2925,7 +2933,7 @@ class Q {
|
|
|
2925
2933
|
r1: 0,
|
|
2926
2934
|
r2: c / 100
|
|
2927
2935
|
};
|
|
2928
|
-
return new
|
|
2936
|
+
return new Ce({
|
|
2929
2937
|
type: "radial",
|
|
2930
2938
|
gradientUnits: "percentage",
|
|
2931
2939
|
coords: d,
|
|
@@ -2960,7 +2968,7 @@ class Q {
|
|
|
2960
2968
|
}) ? !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;
|
|
2961
2969
|
}
|
|
2962
2970
|
}
|
|
2963
|
-
class
|
|
2971
|
+
class Ct {
|
|
2964
2972
|
constructor({ editor: t }) {
|
|
2965
2973
|
this.editor = t;
|
|
2966
2974
|
}
|
|
@@ -2975,7 +2983,7 @@ class At {
|
|
|
2975
2983
|
const { canvas: s, historyManager: n } = this.editor;
|
|
2976
2984
|
n.suspendHistory();
|
|
2977
2985
|
const o = t || s.getActiveObject();
|
|
2978
|
-
o && (o instanceof
|
|
2986
|
+
o && (o instanceof T ? o.getObjects().forEach((a) => {
|
|
2979
2987
|
s.bringObjectToFront(a);
|
|
2980
2988
|
}) : s.bringObjectToFront(o), s.renderAll(), n.resumeHistory(), e || n.saveState(), s.fire("editor:object-bring-to-front", {
|
|
2981
2989
|
object: o,
|
|
@@ -2993,7 +3001,7 @@ class At {
|
|
|
2993
3001
|
const { canvas: s, historyManager: n } = this.editor;
|
|
2994
3002
|
n.suspendHistory();
|
|
2995
3003
|
const o = t || s.getActiveObject();
|
|
2996
|
-
o && (o instanceof
|
|
3004
|
+
o && (o instanceof T ? Ct._moveSelectionForward(s, o) : s.bringObjectForward(o), s.renderAll(), n.resumeHistory(), e || n.saveState(), s.fire("editor:object-bring-forward", {
|
|
2997
3005
|
object: o,
|
|
2998
3006
|
withoutSave: e
|
|
2999
3007
|
}));
|
|
@@ -3016,7 +3024,7 @@ class At {
|
|
|
3016
3024
|
o.suspendHistory();
|
|
3017
3025
|
const r = t || s.getActiveObject();
|
|
3018
3026
|
if (r) {
|
|
3019
|
-
if (r instanceof
|
|
3027
|
+
if (r instanceof T) {
|
|
3020
3028
|
const c = r.getObjects();
|
|
3021
3029
|
for (let d = c.length - 1; d >= 0; d -= 1)
|
|
3022
3030
|
s.sendObjectToBack(c[d]);
|
|
@@ -3044,7 +3052,7 @@ class At {
|
|
|
3044
3052
|
} = this.editor;
|
|
3045
3053
|
o.suspendHistory();
|
|
3046
3054
|
const r = t || s.getActiveObject();
|
|
3047
|
-
r && (r instanceof
|
|
3055
|
+
r && (r instanceof T ? Ct._moveSelectionBackwards(s, r) : s.sendObjectBackwards(r), i && s.sendObjectToBack(i), s.sendObjectToBack(n), a && s.sendObjectToBack(a), s.renderAll(), o.resumeHistory(), e || o.saveState(), s.fire("editor:object-send-backwards", {
|
|
3048
3056
|
object: r,
|
|
3049
3057
|
withoutSave: e
|
|
3050
3058
|
}));
|
|
@@ -3088,7 +3096,7 @@ class At {
|
|
|
3088
3096
|
});
|
|
3089
3097
|
}
|
|
3090
3098
|
}
|
|
3091
|
-
class
|
|
3099
|
+
class Es {
|
|
3092
3100
|
/**
|
|
3093
3101
|
* Менеджер фигур для редактора.
|
|
3094
3102
|
* @param options - Опции и настройки менеджера фигур.
|
|
@@ -3120,7 +3128,7 @@ class ys {
|
|
|
3120
3128
|
width: n = 100,
|
|
3121
3129
|
height: o = 100,
|
|
3122
3130
|
fill: a = "blue"
|
|
3123
|
-
} = l, i =
|
|
3131
|
+
} = l, i = K(l, [
|
|
3124
3132
|
"id",
|
|
3125
3133
|
"left",
|
|
3126
3134
|
"top",
|
|
@@ -3128,7 +3136,7 @@ class ys {
|
|
|
3128
3136
|
"height",
|
|
3129
3137
|
"fill"
|
|
3130
3138
|
]);
|
|
3131
|
-
const { canvas: u } = this.editor, g = new
|
|
3139
|
+
const { canvas: u } = this.editor, g = new Fe(D({
|
|
3132
3140
|
id: t,
|
|
3133
3141
|
left: e,
|
|
3134
3142
|
top: s,
|
|
@@ -3161,14 +3169,14 @@ class ys {
|
|
|
3161
3169
|
top: s,
|
|
3162
3170
|
radius: n = 50,
|
|
3163
3171
|
fill: o = "green"
|
|
3164
|
-
} = d, a =
|
|
3172
|
+
} = d, a = K(d, [
|
|
3165
3173
|
"id",
|
|
3166
3174
|
"left",
|
|
3167
3175
|
"top",
|
|
3168
3176
|
"radius",
|
|
3169
3177
|
"fill"
|
|
3170
3178
|
]);
|
|
3171
|
-
const { canvas: l } = this.editor, u = new
|
|
3179
|
+
const { canvas: l } = this.editor, u = new He(D({
|
|
3172
3180
|
id: t,
|
|
3173
3181
|
left: e,
|
|
3174
3182
|
top: s,
|
|
@@ -3202,7 +3210,7 @@ class ys {
|
|
|
3202
3210
|
width: n = 100,
|
|
3203
3211
|
height: o = 100,
|
|
3204
3212
|
fill: a = "yellow"
|
|
3205
|
-
} = l, i =
|
|
3213
|
+
} = l, i = K(l, [
|
|
3206
3214
|
"id",
|
|
3207
3215
|
"left",
|
|
3208
3216
|
"top",
|
|
@@ -3210,7 +3218,7 @@ class ys {
|
|
|
3210
3218
|
"height",
|
|
3211
3219
|
"fill"
|
|
3212
3220
|
]);
|
|
3213
|
-
const { canvas: u } = this.editor, g = new
|
|
3221
|
+
const { canvas: u } = this.editor, g = new We(D({
|
|
3214
3222
|
id: t,
|
|
3215
3223
|
left: e,
|
|
3216
3224
|
top: s,
|
|
@@ -3221,7 +3229,7 @@ class ys {
|
|
|
3221
3229
|
return !e && !s && u.centerObject(g), c || (u.add(g), r || u.setActiveObject(g), u.renderAll()), g;
|
|
3222
3230
|
}
|
|
3223
3231
|
}
|
|
3224
|
-
class
|
|
3232
|
+
class Ds {
|
|
3225
3233
|
/**
|
|
3226
3234
|
* @param options
|
|
3227
3235
|
* @param options.editor - экземпляр редактора с доступом к canvas
|
|
@@ -3252,7 +3260,7 @@ class bs {
|
|
|
3252
3260
|
return C(this, null, function* () {
|
|
3253
3261
|
const { canvas: e, errorManager: s } = this.editor;
|
|
3254
3262
|
try {
|
|
3255
|
-
const n = yield t.clone(
|
|
3263
|
+
const n = yield t.clone(jt);
|
|
3256
3264
|
this.clipboard = n, e.fire("editor:object-copied", { object: n });
|
|
3257
3265
|
} catch (n) {
|
|
3258
3266
|
s.emitError({
|
|
@@ -3279,7 +3287,7 @@ class bs {
|
|
|
3279
3287
|
message: "navigator.clipboard не поддерживается в этом браузере или отсутствует HTTPS-соединение."
|
|
3280
3288
|
}), !1;
|
|
3281
3289
|
try {
|
|
3282
|
-
const s = t.toObject(
|
|
3290
|
+
const s = t.toObject(jt), n = JSON.stringify(s);
|
|
3283
3291
|
return t.type === "image" ? this._copyImageToClipboard(t, n) : this._copyTextToClipboard(n);
|
|
3284
3292
|
} catch (s) {
|
|
3285
3293
|
return e.emitError({
|
|
@@ -3320,7 +3328,7 @@ class bs {
|
|
|
3320
3328
|
_copyTextToClipboard(t) {
|
|
3321
3329
|
return C(this, null, function* () {
|
|
3322
3330
|
try {
|
|
3323
|
-
const e = `${
|
|
3331
|
+
const e = `${Ne}${t}`;
|
|
3324
3332
|
return yield navigator.clipboard.writeText(e), console.info("Text copied to clipboard successfully"), !0;
|
|
3325
3333
|
} catch (e) {
|
|
3326
3334
|
const { errorManager: s } = this.editor;
|
|
@@ -3340,7 +3348,7 @@ class bs {
|
|
|
3340
3348
|
*/
|
|
3341
3349
|
_addClonedObjectToCanvas(t) {
|
|
3342
3350
|
const { canvas: e, historyManager: s } = this.editor;
|
|
3343
|
-
if (e.discardActiveObject(), t instanceof
|
|
3351
|
+
if (e.discardActiveObject(), t instanceof T) {
|
|
3344
3352
|
s.suspendHistory(), t.canvas = e, t.forEachObject((n) => {
|
|
3345
3353
|
e.add(n);
|
|
3346
3354
|
}), e.setActiveObject(t), e.requestRenderAll(), s.resumeHistory(), s.saveState();
|
|
@@ -3373,8 +3381,8 @@ class bs {
|
|
|
3373
3381
|
const { canvas: e } = this.editor, s = t || e.getActiveObject();
|
|
3374
3382
|
if (!s || s.locked) return !1;
|
|
3375
3383
|
try {
|
|
3376
|
-
const n = yield s.clone(
|
|
3377
|
-
return n instanceof
|
|
3384
|
+
const n = yield s.clone(jt);
|
|
3385
|
+
return n instanceof T && n.forEachObject((o) => {
|
|
3378
3386
|
o.set({
|
|
3379
3387
|
id: `${o.type}-${x()}`,
|
|
3380
3388
|
evented: !0
|
|
@@ -3411,7 +3419,7 @@ class bs {
|
|
|
3411
3419
|
return;
|
|
3412
3420
|
}
|
|
3413
3421
|
const s = t.getData("text/plain");
|
|
3414
|
-
if (s && s.startsWith(
|
|
3422
|
+
if (s && s.startsWith(Ne)) {
|
|
3415
3423
|
this.paste();
|
|
3416
3424
|
return;
|
|
3417
3425
|
}
|
|
@@ -3459,8 +3467,8 @@ class bs {
|
|
|
3459
3467
|
const { canvas: t } = this.editor;
|
|
3460
3468
|
if (!this.clipboard) return !1;
|
|
3461
3469
|
try {
|
|
3462
|
-
const e = yield this.clipboard.clone(
|
|
3463
|
-
return t.discardActiveObject(), e instanceof
|
|
3470
|
+
const e = yield this.clipboard.clone(jt);
|
|
3471
|
+
return t.discardActiveObject(), e instanceof T && e.forEachObject((s) => {
|
|
3464
3472
|
s.set({
|
|
3465
3473
|
id: `${s.type}-${x()}`,
|
|
3466
3474
|
evented: !0
|
|
@@ -3484,7 +3492,7 @@ class bs {
|
|
|
3484
3492
|
});
|
|
3485
3493
|
}
|
|
3486
3494
|
}
|
|
3487
|
-
class
|
|
3495
|
+
class wt {
|
|
3488
3496
|
constructor({ editor: t }) {
|
|
3489
3497
|
this.editor = t;
|
|
3490
3498
|
}
|
|
@@ -3507,9 +3515,10 @@ class Ct {
|
|
|
3507
3515
|
lockScalingY: !0,
|
|
3508
3516
|
lockSkewingX: !0,
|
|
3509
3517
|
lockSkewingY: !0,
|
|
3518
|
+
editable: !1,
|
|
3510
3519
|
locked: !0
|
|
3511
3520
|
};
|
|
3512
|
-
a.set(i), !e &&
|
|
3521
|
+
a.set(i), !e && wt._isGroupOrSelection(a) && a.getObjects().forEach((c) => {
|
|
3513
3522
|
c.set(i);
|
|
3514
3523
|
}), n.renderAll(), s || o.saveState(), n.fire("editor:object-locked", {
|
|
3515
3524
|
object: a,
|
|
@@ -3535,9 +3544,10 @@ class Ct {
|
|
|
3535
3544
|
lockScalingY: !1,
|
|
3536
3545
|
lockSkewingX: !1,
|
|
3537
3546
|
lockSkewingY: !1,
|
|
3547
|
+
editable: !0,
|
|
3538
3548
|
locked: !1
|
|
3539
3549
|
};
|
|
3540
|
-
o.set(a),
|
|
3550
|
+
o.set(a), wt._isGroupOrSelection(o) && o.getObjects().forEach((i) => {
|
|
3541
3551
|
i.set(a);
|
|
3542
3552
|
}), s.renderAll(), e || n.saveState(), s.fire("editor:object-unlocked", {
|
|
3543
3553
|
object: o,
|
|
@@ -3545,10 +3555,10 @@ class Ct {
|
|
|
3545
3555
|
});
|
|
3546
3556
|
}
|
|
3547
3557
|
static _isGroupOrSelection(t) {
|
|
3548
|
-
return t instanceof
|
|
3558
|
+
return t instanceof T || t instanceof Q;
|
|
3549
3559
|
}
|
|
3550
3560
|
}
|
|
3551
|
-
class
|
|
3561
|
+
class Os {
|
|
3552
3562
|
constructor({ editor: t }) {
|
|
3553
3563
|
this.editor = t;
|
|
3554
3564
|
}
|
|
@@ -3560,7 +3570,7 @@ class vs {
|
|
|
3560
3570
|
if (Array.isArray(t))
|
|
3561
3571
|
return t.length > 0 ? t : null;
|
|
3562
3572
|
const e = t || this.editor.canvas.getActiveObject();
|
|
3563
|
-
return !e || !(e instanceof
|
|
3573
|
+
return !e || !(e instanceof T) ? null : e.getObjects();
|
|
3564
3574
|
}
|
|
3565
3575
|
/**
|
|
3566
3576
|
* Получить группы для разгруппировки
|
|
@@ -3568,20 +3578,20 @@ class vs {
|
|
|
3568
3578
|
*/
|
|
3569
3579
|
_getGroupsToUngroup(t) {
|
|
3570
3580
|
if (Array.isArray(t)) {
|
|
3571
|
-
const s = t.filter((n) => n instanceof
|
|
3581
|
+
const s = t.filter((n) => n instanceof Q);
|
|
3572
3582
|
return s.length > 0 ? s : null;
|
|
3573
3583
|
}
|
|
3574
|
-
if (t instanceof
|
|
3575
|
-
const s = t.getObjects().filter((n) => n instanceof
|
|
3584
|
+
if (t instanceof T) {
|
|
3585
|
+
const s = t.getObjects().filter((n) => n instanceof Q);
|
|
3576
3586
|
return s.length > 0 ? s : null;
|
|
3577
3587
|
}
|
|
3578
3588
|
const e = t || this.editor.canvas.getActiveObject();
|
|
3579
3589
|
if (!e) return null;
|
|
3580
|
-
if (e instanceof
|
|
3581
|
-
const s = e.getObjects().filter((n) => n instanceof
|
|
3590
|
+
if (e instanceof T) {
|
|
3591
|
+
const s = e.getObjects().filter((n) => n instanceof Q);
|
|
3582
3592
|
return s.length > 0 ? s : null;
|
|
3583
3593
|
}
|
|
3584
|
-
return e instanceof
|
|
3594
|
+
return e instanceof Q ? [e] : null;
|
|
3585
3595
|
}
|
|
3586
3596
|
/**
|
|
3587
3597
|
* Группировка объектов
|
|
@@ -3598,7 +3608,7 @@ class vs {
|
|
|
3598
3608
|
if (!o) return null;
|
|
3599
3609
|
try {
|
|
3600
3610
|
n.suspendHistory();
|
|
3601
|
-
const a = new
|
|
3611
|
+
const a = new Q(o, {
|
|
3602
3612
|
id: `group-${x()}`
|
|
3603
3613
|
});
|
|
3604
3614
|
o.forEach((r) => s.remove(r)), s.add(a), s.setActiveObject(a), s.requestRenderAll();
|
|
@@ -3634,7 +3644,7 @@ class vs {
|
|
|
3634
3644
|
s.add(l), a.push(l);
|
|
3635
3645
|
});
|
|
3636
3646
|
});
|
|
3637
|
-
const i = new
|
|
3647
|
+
const i = new T(a, {
|
|
3638
3648
|
canvas: s
|
|
3639
3649
|
});
|
|
3640
3650
|
s.setActiveObject(i), s.requestRenderAll();
|
|
@@ -3649,7 +3659,7 @@ class vs {
|
|
|
3649
3659
|
}
|
|
3650
3660
|
}
|
|
3651
3661
|
}
|
|
3652
|
-
class
|
|
3662
|
+
class Ts {
|
|
3653
3663
|
constructor({ editor: t }) {
|
|
3654
3664
|
this.editor = t;
|
|
3655
3665
|
}
|
|
@@ -3660,11 +3670,11 @@ class js {
|
|
|
3660
3670
|
selectAll() {
|
|
3661
3671
|
const { canvas: t, canvasManager: e, objectLockManager: s } = this.editor;
|
|
3662
3672
|
t.discardActiveObject();
|
|
3663
|
-
const n = e.getObjects(), o = n.some((i) => i.locked), a = n.length > 1 ? new
|
|
3673
|
+
const n = e.getObjects(), o = n.some((i) => i.locked), a = n.length > 1 ? new T(e.getObjects(), { canvas: t }) : n[0];
|
|
3664
3674
|
o && s.lockObject({ object: a, skipInnerObjects: !0, withoutSave: !0 }), t.setActiveObject(a), t.requestRenderAll(), t.fire("editor:all-objects-selected", { selected: a });
|
|
3665
3675
|
}
|
|
3666
3676
|
}
|
|
3667
|
-
class
|
|
3677
|
+
class zt {
|
|
3668
3678
|
constructor({ editor: t }) {
|
|
3669
3679
|
this.editor = t;
|
|
3670
3680
|
}
|
|
@@ -3711,7 +3721,7 @@ class Rt {
|
|
|
3711
3721
|
s || o.suspendHistory();
|
|
3712
3722
|
const r = [];
|
|
3713
3723
|
if (i.forEach((d) => {
|
|
3714
|
-
if (
|
|
3724
|
+
if (zt._isUngroupableGroup(d)) {
|
|
3715
3725
|
const l = this._handleGroupDeletion(d);
|
|
3716
3726
|
r.push(...l);
|
|
3717
3727
|
return;
|
|
@@ -3726,7 +3736,7 @@ class Rt {
|
|
|
3726
3736
|
return n.fire("editor:objects-deleted", c), c;
|
|
3727
3737
|
}
|
|
3728
3738
|
}
|
|
3729
|
-
const
|
|
3739
|
+
const Ns = {
|
|
3730
3740
|
IMAGE_MANAGER: {
|
|
3731
3741
|
/**
|
|
3732
3742
|
* Некорректный Content-Type изображения
|
|
@@ -3825,7 +3835,7 @@ const Is = {
|
|
|
3825
3835
|
INVALID_GRADIENT_FORMAT: "INVALID_GRADIENT_FORMAT"
|
|
3826
3836
|
}
|
|
3827
3837
|
};
|
|
3828
|
-
class
|
|
3838
|
+
class Et {
|
|
3829
3839
|
constructor({ editor: t }) {
|
|
3830
3840
|
this._buffer = [], this.editor = t;
|
|
3831
3841
|
}
|
|
@@ -3852,7 +3862,7 @@ class St {
|
|
|
3852
3862
|
* @fires editor:error
|
|
3853
3863
|
*/
|
|
3854
3864
|
emitError({ origin: t = "ImageEditor", method: e = "Unknown Method", code: s, data: n, message: o }) {
|
|
3855
|
-
if (!
|
|
3865
|
+
if (!Et.isValidErrorCode(s)) {
|
|
3856
3866
|
console.warn("Неизвестный код ошибки: ", { code: s, origin: t, method: e });
|
|
3857
3867
|
return;
|
|
3858
3868
|
}
|
|
@@ -3866,7 +3876,7 @@ class St {
|
|
|
3866
3876
|
message: a,
|
|
3867
3877
|
data: n
|
|
3868
3878
|
};
|
|
3869
|
-
this._buffer.push(
|
|
3879
|
+
this._buffer.push(D({
|
|
3870
3880
|
type: "editor:error"
|
|
3871
3881
|
}, i)), this.editor.canvas.fire("editor:error", i);
|
|
3872
3882
|
}
|
|
@@ -3881,7 +3891,7 @@ class St {
|
|
|
3881
3891
|
* @fires editor:warning
|
|
3882
3892
|
*/
|
|
3883
3893
|
emitWarning({ origin: t = "ImageEditor", method: e = "Unknown Method", code: s, message: n, data: o }) {
|
|
3884
|
-
if (!
|
|
3894
|
+
if (!Et.isValidErrorCode(s)) {
|
|
3885
3895
|
console.warn("Неизвестный код предупреждения: ", { code: s, origin: t, method: e });
|
|
3886
3896
|
return;
|
|
3887
3897
|
}
|
|
@@ -3894,7 +3904,7 @@ class St {
|
|
|
3894
3904
|
message: a,
|
|
3895
3905
|
data: o
|
|
3896
3906
|
};
|
|
3897
|
-
this._buffer.push(
|
|
3907
|
+
this._buffer.push(D({
|
|
3898
3908
|
type: "editor:warning"
|
|
3899
3909
|
}, i)), this.editor.canvas.fire("editor:warning", i);
|
|
3900
3910
|
}
|
|
@@ -3904,10 +3914,10 @@ class St {
|
|
|
3904
3914
|
* @returns true, если код допустим, иначе false
|
|
3905
3915
|
*/
|
|
3906
3916
|
static isValidErrorCode(t) {
|
|
3907
|
-
return t ? Object.values(
|
|
3917
|
+
return t ? Object.values(Ns).some((e) => Object.values(e).includes(t)) : !1;
|
|
3908
3918
|
}
|
|
3909
3919
|
}
|
|
3910
|
-
class
|
|
3920
|
+
class Ls {
|
|
3911
3921
|
constructor({ editor: t }) {
|
|
3912
3922
|
this.currentBounds = null, this.editor = t;
|
|
3913
3923
|
}
|
|
@@ -3992,8 +4002,8 @@ class As {
|
|
|
3992
4002
|
this.currentBounds = this.calculatePanBounds();
|
|
3993
4003
|
}
|
|
3994
4004
|
}
|
|
3995
|
-
const
|
|
3996
|
-
class
|
|
4005
|
+
const Ot = 0.01;
|
|
4006
|
+
class O {
|
|
3997
4007
|
constructor({ editor: t }) {
|
|
3998
4008
|
var e;
|
|
3999
4009
|
this._handleTextEditingEntered = () => {
|
|
@@ -4001,10 +4011,10 @@ class k {
|
|
|
4001
4011
|
}, this._handleTextChanged = (s) => {
|
|
4002
4012
|
var r, c;
|
|
4003
4013
|
const { target: n } = s;
|
|
4004
|
-
if (!
|
|
4014
|
+
if (!O._isTextbox(n)) return;
|
|
4005
4015
|
const o = (r = n.text) != null ? r : "", a = !!n.uppercase, i = (c = n.textCaseRaw) != null ? c : "";
|
|
4006
4016
|
if (a) {
|
|
4007
|
-
const d =
|
|
4017
|
+
const d = O._toUpperCase(o);
|
|
4008
4018
|
d !== o && (n.set({ text: d }), this.canvas.requestRenderAll());
|
|
4009
4019
|
const l = i.length, u = o.length;
|
|
4010
4020
|
if (u > l) {
|
|
@@ -4016,7 +4026,7 @@ class k {
|
|
|
4016
4026
|
}, this._handleTextEditingExited = (s) => {
|
|
4017
4027
|
var i, r;
|
|
4018
4028
|
const { target: n } = s;
|
|
4019
|
-
if (!
|
|
4029
|
+
if (!O._isTextbox(n)) return;
|
|
4020
4030
|
const o = (i = n.text) != null ? i : "";
|
|
4021
4031
|
if (!!n.uppercase) {
|
|
4022
4032
|
const c = (r = n.textCaseRaw) != null ? r : o.toLocaleLowerCase();
|
|
@@ -4028,34 +4038,34 @@ class k {
|
|
|
4028
4038
|
lockMovementY: !1
|
|
4029
4039
|
}), setTimeout(() => {
|
|
4030
4040
|
this.isTextEditingActive = !1, this.editor.historyManager.saveState();
|
|
4031
|
-
},
|
|
4041
|
+
}, vs);
|
|
4032
4042
|
}, this._handleObjectScaling = (s) => {
|
|
4033
|
-
var
|
|
4043
|
+
var P, X, Z, st, nt, ot, at, it, rt, ct, dt, lt, ht, ut;
|
|
4034
4044
|
const { target: n, transform: o } = s;
|
|
4035
|
-
if (!
|
|
4045
|
+
if (!O._isTextbox(n) || !o) return;
|
|
4036
4046
|
n.isScaling = !0;
|
|
4037
|
-
const a = this._ensureScalingState(n), { baseWidth: i, baseLeft: r, baseFontSize: c } = a, d = typeof ((
|
|
4038
|
-
if (!
|
|
4039
|
-
const
|
|
4040
|
-
if (!
|
|
4047
|
+
const a = this._ensureScalingState(n), { baseWidth: i, baseLeft: r, baseFontSize: c } = a, d = typeof ((P = o.original) == null ? void 0 : P.width) == "number" ? o.original.width : void 0, l = typeof ((X = o.original) == null ? void 0 : X.left) == "number" ? o.original.left : void 0, u = d != null ? d : i, g = l != null ? l : r, f = (Z = o.corner) != null ? Z : "", m = (st = o.action) != null ? st : "", j = ["ml", "mr"].includes(f) || m === "scaleX", p = ["mt", "mb"].includes(f) || m === "scaleY", M = ["tl", "tr", "bl", "br"].includes(f) || m === "scale";
|
|
4048
|
+
if (!j && !p && !M) return;
|
|
4049
|
+
const w = Math.abs((ot = (nt = n.scaleX) != null ? nt : o.scaleX) != null ? ot : 1) || 1, L = Math.abs((it = (at = n.scaleY) != null ? at : o.scaleY) != null ? it : 1) || 1, k = Math.max(1, u * w), b = Math.max(1, c * L), y = (ct = (rt = o.originX) != null ? rt : n.originX) != null ? ct : "left", S = g + u, v = g + u / 2, I = (dt = n.width) != null ? dt : u, E = Math.abs(k - I) > Ot, N = Math.abs(b - ((lt = n.fontSize) != null ? lt : c)) > Ot;
|
|
4050
|
+
if (!E && !N) {
|
|
4041
4051
|
n.set({ scaleX: 1, scaleY: 1 }), o.scaleX = 1, o.scaleY = 1;
|
|
4042
4052
|
return;
|
|
4043
4053
|
}
|
|
4044
4054
|
n.set({
|
|
4045
|
-
width:
|
|
4046
|
-
fontSize: M || p ?
|
|
4055
|
+
width: k,
|
|
4056
|
+
fontSize: M || p ? b : c,
|
|
4047
4057
|
scaleX: 1,
|
|
4048
4058
|
scaleY: 1
|
|
4049
4059
|
});
|
|
4050
|
-
const
|
|
4051
|
-
let
|
|
4052
|
-
|
|
4060
|
+
const B = (ht = n.width) != null ? ht : k, U = Math.abs(B - I) > Ot;
|
|
4061
|
+
let W = g;
|
|
4062
|
+
U && (j || M) && (y === "right" ? W = S - B : y === "center" && (W = v - B / 2)), n.set({ left: W }), a.baseLeft = W, o.scaleX = 1, o.scaleY = 1;
|
|
4053
4063
|
const { original: R } = o;
|
|
4054
|
-
R && (R.scaleX = 1, R.scaleY = 1, R.width =
|
|
4064
|
+
R && (R.scaleX = 1, R.scaleY = 1, R.width = B, R.height = n.height, R.left = W), n.setCoords(), this.canvas.requestRenderAll(), a.baseWidth = B, a.baseFontSize = (ut = n.fontSize) != null ? ut : b, a.hasWidthChange = U || N;
|
|
4055
4065
|
}, this._handleObjectModified = (s) => {
|
|
4056
4066
|
var r, c, d;
|
|
4057
4067
|
const { target: n } = s;
|
|
4058
|
-
if (!
|
|
4068
|
+
if (!O._isTextbox(n)) return;
|
|
4059
4069
|
n.isScaling = !1;
|
|
4060
4070
|
const o = this.scalingState.get(n);
|
|
4061
4071
|
if (this.scalingState.delete(n), !(o != null && o.hasWidthChange)) return;
|
|
@@ -4068,8 +4078,8 @@ class k {
|
|
|
4068
4078
|
* @param options — настройки текста
|
|
4069
4079
|
* @param flags — флаги поведения
|
|
4070
4080
|
*/
|
|
4071
|
-
addText(
|
|
4072
|
-
var
|
|
4081
|
+
addText(w = {}, { withoutSelection: j = !1, withoutSave: p = !1, withoutAdding: M = !1 } = {}) {
|
|
4082
|
+
var L = w, {
|
|
4073
4083
|
id: t = `text-${x()}`,
|
|
4074
4084
|
text: e = "Новый текст",
|
|
4075
4085
|
fontFamily: s,
|
|
@@ -4084,7 +4094,7 @@ class k {
|
|
|
4084
4094
|
strokeColor: u,
|
|
4085
4095
|
strokeWidth: g = 0,
|
|
4086
4096
|
opacity: f = 1
|
|
4087
|
-
} =
|
|
4097
|
+
} = L, m = K(L, [
|
|
4088
4098
|
"id",
|
|
4089
4099
|
"text",
|
|
4090
4100
|
"fontFamily",
|
|
@@ -4100,15 +4110,15 @@ class k {
|
|
|
4100
4110
|
"strokeWidth",
|
|
4101
4111
|
"opacity"
|
|
4102
4112
|
]);
|
|
4103
|
-
var
|
|
4104
|
-
const { historyManager:
|
|
4105
|
-
|
|
4106
|
-
const
|
|
4113
|
+
var E;
|
|
4114
|
+
const { historyManager: k } = this.editor;
|
|
4115
|
+
k.suspendHistory();
|
|
4116
|
+
const b = s != null ? s : this._getDefaultFontFamily(), y = O._resolveStrokeWidth(g), S = O._resolveStrokeColor(
|
|
4107
4117
|
u,
|
|
4108
|
-
|
|
4109
|
-
),
|
|
4118
|
+
y
|
|
4119
|
+
), v = new mt(e, D({
|
|
4110
4120
|
id: t,
|
|
4111
|
-
fontFamily:
|
|
4121
|
+
fontFamily: b,
|
|
4112
4122
|
fontSize: n,
|
|
4113
4123
|
fontWeight: o ? "bold" : "normal",
|
|
4114
4124
|
fontStyle: a ? "italic" : "normal",
|
|
@@ -4117,20 +4127,20 @@ class k {
|
|
|
4117
4127
|
linethrough: c,
|
|
4118
4128
|
textAlign: d,
|
|
4119
4129
|
fill: l,
|
|
4120
|
-
stroke:
|
|
4121
|
-
strokeWidth:
|
|
4130
|
+
stroke: S,
|
|
4131
|
+
strokeWidth: y,
|
|
4122
4132
|
strokeUniform: !0,
|
|
4123
4133
|
opacity: f
|
|
4124
4134
|
}, m));
|
|
4125
|
-
if (
|
|
4126
|
-
const
|
|
4127
|
-
|
|
4135
|
+
if (v.textCaseRaw = (E = v.text) != null ? E : "", r) {
|
|
4136
|
+
const N = O._toUpperCase(v.textCaseRaw);
|
|
4137
|
+
N !== v.text && v.set({ text: N });
|
|
4128
4138
|
}
|
|
4129
|
-
m.left === void 0 && m.top === void 0 && this.canvas.centerObject(
|
|
4130
|
-
const
|
|
4139
|
+
m.left === void 0 && m.top === void 0 && this.canvas.centerObject(v), M || this.canvas.add(v), j || this.canvas.setActiveObject(v), this.canvas.requestRenderAll(), k.resumeHistory(), p || k.saveState();
|
|
4140
|
+
const I = D({
|
|
4131
4141
|
id: t,
|
|
4132
4142
|
text: e,
|
|
4133
|
-
fontFamily:
|
|
4143
|
+
fontFamily: b,
|
|
4134
4144
|
fontSize: n,
|
|
4135
4145
|
bold: o,
|
|
4136
4146
|
italic: a,
|
|
@@ -4139,19 +4149,19 @@ class k {
|
|
|
4139
4149
|
strikethrough: c,
|
|
4140
4150
|
align: d,
|
|
4141
4151
|
color: l,
|
|
4142
|
-
strokeColor:
|
|
4143
|
-
strokeWidth:
|
|
4152
|
+
strokeColor: S,
|
|
4153
|
+
strokeWidth: y,
|
|
4144
4154
|
opacity: f
|
|
4145
4155
|
}, m);
|
|
4146
4156
|
return this.canvas.fire("editor:text-added", {
|
|
4147
|
-
textbox:
|
|
4148
|
-
options:
|
|
4157
|
+
textbox: v,
|
|
4158
|
+
options: I,
|
|
4149
4159
|
flags: {
|
|
4150
|
-
withoutSelection: !!
|
|
4160
|
+
withoutSelection: !!j,
|
|
4151
4161
|
withoutSave: !!p,
|
|
4152
4162
|
withoutAdding: !!M
|
|
4153
4163
|
}
|
|
4154
|
-
}),
|
|
4164
|
+
}), v;
|
|
4155
4165
|
}
|
|
4156
4166
|
/**
|
|
4157
4167
|
* Обновляет текстовый объект.
|
|
@@ -4162,35 +4172,35 @@ class k {
|
|
|
4162
4172
|
* @param options.skipRender — не вызывать перерисовку канваса
|
|
4163
4173
|
*/
|
|
4164
4174
|
updateText({ target: t, style: e = {}, withoutSave: s, skipRender: n } = {}) {
|
|
4165
|
-
var
|
|
4175
|
+
var X, Z, st, nt, ot, at, it, rt, ct, dt, lt, ht, ut, Ft, Ht, Wt, Zt, Pt, Vt, Xt, Kt, $t, Qt, Jt, qt, te, ee, se, ne, oe, ae, ie, re, ce, de, le, he, ue, ge, fe, me, pe, Me, ye;
|
|
4166
4176
|
const o = this._resolveTextObject(t);
|
|
4167
4177
|
if (!o) return null;
|
|
4168
4178
|
const { historyManager: a } = this.editor;
|
|
4169
4179
|
a.suspendHistory();
|
|
4170
4180
|
const i = {
|
|
4171
4181
|
id: o.id,
|
|
4172
|
-
text: (
|
|
4173
|
-
textCaseRaw: (
|
|
4182
|
+
text: (X = o.text) != null ? X : void 0,
|
|
4183
|
+
textCaseRaw: (Z = o.textCaseRaw) != null ? Z : void 0,
|
|
4174
4184
|
uppercase: !!o.uppercase,
|
|
4175
|
-
fontFamily: (
|
|
4176
|
-
fontSize: (
|
|
4177
|
-
fontWeight: (
|
|
4178
|
-
fontStyle: (
|
|
4179
|
-
underline: (
|
|
4180
|
-
linethrough: (
|
|
4185
|
+
fontFamily: (st = o.fontFamily) != null ? st : void 0,
|
|
4186
|
+
fontSize: (nt = o.fontSize) != null ? nt : void 0,
|
|
4187
|
+
fontWeight: (ot = o.fontWeight) != null ? ot : void 0,
|
|
4188
|
+
fontStyle: (at = o.fontStyle) != null ? at : void 0,
|
|
4189
|
+
underline: (it = o.underline) != null ? it : void 0,
|
|
4190
|
+
linethrough: (rt = o.linethrough) != null ? rt : void 0,
|
|
4181
4191
|
textAlign: o.textAlign,
|
|
4182
|
-
fill: (
|
|
4183
|
-
stroke: (
|
|
4184
|
-
strokeWidth: (
|
|
4185
|
-
opacity: (
|
|
4186
|
-
left: (
|
|
4187
|
-
top: (
|
|
4188
|
-
width: (
|
|
4189
|
-
height: (
|
|
4190
|
-
angle: (
|
|
4191
|
-
scaleX: (
|
|
4192
|
-
scaleY: (
|
|
4193
|
-
},
|
|
4192
|
+
fill: (ct = o.fill) != null ? ct : void 0,
|
|
4193
|
+
stroke: (dt = o.stroke) != null ? dt : void 0,
|
|
4194
|
+
strokeWidth: (lt = o.strokeWidth) != null ? lt : void 0,
|
|
4195
|
+
opacity: (ht = o.opacity) != null ? ht : void 0,
|
|
4196
|
+
left: (ut = o.left) != null ? ut : void 0,
|
|
4197
|
+
top: (Ft = o.top) != null ? Ft : void 0,
|
|
4198
|
+
width: (Ht = o.width) != null ? Ht : void 0,
|
|
4199
|
+
height: (Wt = o.height) != null ? Wt : void 0,
|
|
4200
|
+
angle: (Zt = o.angle) != null ? Zt : void 0,
|
|
4201
|
+
scaleX: (Pt = o.scaleX) != null ? Pt : void 0,
|
|
4202
|
+
scaleY: (Vt = o.scaleY) != null ? Vt : void 0
|
|
4203
|
+
}, Gt = e, {
|
|
4194
4204
|
text: r,
|
|
4195
4205
|
fontFamily: c,
|
|
4196
4206
|
fontSize: d,
|
|
@@ -4199,12 +4209,12 @@ class k {
|
|
|
4199
4209
|
underline: g,
|
|
4200
4210
|
uppercase: f,
|
|
4201
4211
|
strikethrough: m,
|
|
4202
|
-
align:
|
|
4212
|
+
align: j,
|
|
4203
4213
|
color: p,
|
|
4204
4214
|
strokeColor: M,
|
|
4205
|
-
strokeWidth:
|
|
4206
|
-
opacity:
|
|
4207
|
-
} =
|
|
4215
|
+
strokeWidth: w,
|
|
4216
|
+
opacity: L
|
|
4217
|
+
} = Gt, k = K(Gt, [
|
|
4208
4218
|
"text",
|
|
4209
4219
|
"fontFamily",
|
|
4210
4220
|
"fontSize",
|
|
@@ -4218,41 +4228,57 @@ class k {
|
|
|
4218
4228
|
"strokeColor",
|
|
4219
4229
|
"strokeWidth",
|
|
4220
4230
|
"opacity"
|
|
4221
|
-
]), y =
|
|
4222
|
-
if (c !== void 0 && (y.fontFamily = c
|
|
4223
|
-
const
|
|
4224
|
-
y.
|
|
4231
|
+
]), b = D({}, k), y = O._getSelectionRange(o), S = {}, v = {};
|
|
4232
|
+
if (c !== void 0 && (y ? S.fontFamily = c : (b.fontFamily = c, v.fontFamily = c)), d !== void 0 && (y ? S.fontSize = d : (b.fontSize = d, v.fontSize = d)), l !== void 0) {
|
|
4233
|
+
const _ = l ? "bold" : "normal";
|
|
4234
|
+
y ? S.fontWeight = _ : (b.fontWeight = _, v.fontWeight = _);
|
|
4235
|
+
}
|
|
4236
|
+
if (u !== void 0) {
|
|
4237
|
+
const _ = u ? "italic" : "normal";
|
|
4238
|
+
y ? S.fontStyle = _ : (b.fontStyle = _, v.fontStyle = _);
|
|
4225
4239
|
}
|
|
4226
|
-
|
|
4227
|
-
|
|
4228
|
-
|
|
4229
|
-
|
|
4230
|
-
|
|
4231
|
-
|
|
4232
|
-
|
|
4233
|
-
|
|
4240
|
+
if (g !== void 0 && (y ? S.underline = g : (b.underline = g, v.underline = g)), m !== void 0 && (y ? S.linethrough = m : (b.linethrough = m, v.linethrough = m)), j !== void 0 && (b.textAlign = j), p !== void 0 && (y ? S.fill = p : (b.fill = p, v.fill = p)), M !== void 0 || w !== void 0) {
|
|
4241
|
+
const _ = y ? O._getSelectionStyleValue(o, y, "strokeWidth") : void 0, xe = y ? O._getSelectionStyleValue(o, y, "stroke") : void 0, _e = (Kt = (Xt = w != null ? w : _) != null ? Xt : o.strokeWidth) != null ? Kt : 0, yt = O._resolveStrokeWidth(_e), Be = (Qt = ($t = M != null ? M : xe) != null ? $t : o.stroke) != null ? Qt : void 0, Dt = O._resolveStrokeColor(Be, yt);
|
|
4242
|
+
y ? (S.stroke = Dt, S.strokeWidth = yt) : (b.stroke = Dt, b.strokeWidth = yt, v.stroke = Dt, v.strokeWidth = yt);
|
|
4243
|
+
}
|
|
4244
|
+
L !== void 0 && (b.opacity = L);
|
|
4245
|
+
const I = (qt = o.textCaseRaw) != null ? qt : (Jt = o.text) != null ? Jt : "", E = !!o.uppercase, N = r !== void 0, B = N ? r != null ? r : "" : I, U = f != null ? f : E;
|
|
4246
|
+
if (N || U !== E) {
|
|
4247
|
+
const _ = U ? O._toUpperCase(B) : B;
|
|
4248
|
+
b.text = _, o.textCaseRaw = B;
|
|
4249
|
+
} else o.textCaseRaw === void 0 && (o.textCaseRaw = I);
|
|
4250
|
+
o.uppercase = U, o.set(b);
|
|
4251
|
+
let R = !1;
|
|
4252
|
+
if (y)
|
|
4253
|
+
R = O._applyStylesToRange(o, S, y);
|
|
4254
|
+
else if (Object.keys(v).length) {
|
|
4255
|
+
const _ = O._getFullTextRange(o);
|
|
4256
|
+
_ && (R = O._applyStylesToRange(o, v, _));
|
|
4257
|
+
}
|
|
4258
|
+
R && (o.dirty = !0), o.setCoords(), n || this.canvas.requestRenderAll(), a.resumeHistory(), s || a.saveState();
|
|
4259
|
+
const P = {
|
|
4234
4260
|
id: o.id,
|
|
4235
|
-
text: (
|
|
4236
|
-
textCaseRaw: (
|
|
4261
|
+
text: (te = o.text) != null ? te : void 0,
|
|
4262
|
+
textCaseRaw: (ee = o.textCaseRaw) != null ? ee : void 0,
|
|
4237
4263
|
uppercase: !!o.uppercase,
|
|
4238
|
-
fontFamily: (
|
|
4239
|
-
fontSize: (
|
|
4240
|
-
fontWeight: (
|
|
4241
|
-
fontStyle: (
|
|
4242
|
-
underline: (
|
|
4243
|
-
linethrough: (
|
|
4264
|
+
fontFamily: (se = o.fontFamily) != null ? se : void 0,
|
|
4265
|
+
fontSize: (ne = o.fontSize) != null ? ne : void 0,
|
|
4266
|
+
fontWeight: (oe = o.fontWeight) != null ? oe : void 0,
|
|
4267
|
+
fontStyle: (ae = o.fontStyle) != null ? ae : void 0,
|
|
4268
|
+
underline: (ie = o.underline) != null ? ie : void 0,
|
|
4269
|
+
linethrough: (re = o.linethrough) != null ? re : void 0,
|
|
4244
4270
|
textAlign: o.textAlign,
|
|
4245
|
-
fill: (
|
|
4246
|
-
stroke: (
|
|
4247
|
-
strokeWidth: (
|
|
4248
|
-
opacity: (
|
|
4249
|
-
left: (
|
|
4250
|
-
top: (
|
|
4251
|
-
width: (
|
|
4252
|
-
height: (
|
|
4253
|
-
angle: (
|
|
4254
|
-
scaleX: (
|
|
4255
|
-
scaleY: (
|
|
4271
|
+
fill: (ce = o.fill) != null ? ce : void 0,
|
|
4272
|
+
stroke: (de = o.stroke) != null ? de : void 0,
|
|
4273
|
+
strokeWidth: (le = o.strokeWidth) != null ? le : void 0,
|
|
4274
|
+
opacity: (he = o.opacity) != null ? he : void 0,
|
|
4275
|
+
left: (ue = o.left) != null ? ue : void 0,
|
|
4276
|
+
top: (ge = o.top) != null ? ge : void 0,
|
|
4277
|
+
width: (fe = o.width) != null ? fe : void 0,
|
|
4278
|
+
height: (me = o.height) != null ? me : void 0,
|
|
4279
|
+
angle: (pe = o.angle) != null ? pe : void 0,
|
|
4280
|
+
scaleX: (Me = o.scaleX) != null ? Me : void 0,
|
|
4281
|
+
scaleY: (ye = o.scaleY) != null ? ye : void 0
|
|
4256
4282
|
};
|
|
4257
4283
|
return this.canvas.fire("editor:text-updated", {
|
|
4258
4284
|
textbox: o,
|
|
@@ -4262,9 +4288,11 @@ class k {
|
|
|
4262
4288
|
withoutSave: !!s,
|
|
4263
4289
|
skipRender: !!n
|
|
4264
4290
|
},
|
|
4265
|
-
updates:
|
|
4291
|
+
updates: b,
|
|
4266
4292
|
before: i,
|
|
4267
|
-
after:
|
|
4293
|
+
after: P,
|
|
4294
|
+
selectionRange: y != null ? y : void 0,
|
|
4295
|
+
selectionStyles: y && Object.keys(S).length ? S : void 0
|
|
4268
4296
|
}), o;
|
|
4269
4297
|
}
|
|
4270
4298
|
/**
|
|
@@ -4277,19 +4305,19 @@ class k {
|
|
|
4277
4305
|
* Возвращает активный текст или ищет по id.
|
|
4278
4306
|
*/
|
|
4279
4307
|
_resolveTextObject(t) {
|
|
4280
|
-
if (t instanceof
|
|
4308
|
+
if (t instanceof mt) return t;
|
|
4281
4309
|
if (!t) {
|
|
4282
4310
|
const e = this.canvas.getActiveObject();
|
|
4283
|
-
return
|
|
4311
|
+
return O._isTextbox(e) ? e : null;
|
|
4284
4312
|
}
|
|
4285
4313
|
if (typeof t == "string") {
|
|
4286
|
-
const e = this.canvas.getObjects().find((s) =>
|
|
4314
|
+
const e = this.canvas.getObjects().find((s) => O._isTextbox(s) && s.id === t);
|
|
4287
4315
|
return e != null ? e : null;
|
|
4288
4316
|
}
|
|
4289
4317
|
return null;
|
|
4290
4318
|
}
|
|
4291
4319
|
static _isTextbox(t) {
|
|
4292
|
-
return !!t && t instanceof
|
|
4320
|
+
return !!t && t instanceof mt;
|
|
4293
4321
|
}
|
|
4294
4322
|
_bindEvents() {
|
|
4295
4323
|
this.canvas.on("object:scaling", this._handleObjectScaling), this.canvas.on("object:modified", this._handleObjectModified), this.canvas.on("text:editing:entered", this._handleTextEditingEntered), this.canvas.on("text:editing:exited", this._handleTextEditingExited), this.canvas.on("text:changed", this._handleTextChanged);
|
|
@@ -4308,6 +4336,36 @@ class k {
|
|
|
4308
4336
|
}
|
|
4309
4337
|
return e;
|
|
4310
4338
|
}
|
|
4339
|
+
static _getSelectionRange(t) {
|
|
4340
|
+
var n, o;
|
|
4341
|
+
if (!t.isEditing) return null;
|
|
4342
|
+
const e = (n = t.selectionStart) != null ? n : 0, s = (o = t.selectionEnd) != null ? o : e;
|
|
4343
|
+
return e === s ? null : {
|
|
4344
|
+
start: Math.min(e, s),
|
|
4345
|
+
end: Math.max(e, s)
|
|
4346
|
+
};
|
|
4347
|
+
}
|
|
4348
|
+
static _getFullTextRange(t) {
|
|
4349
|
+
var s, n;
|
|
4350
|
+
const e = (n = (s = t.text) == null ? void 0 : s.length) != null ? n : 0;
|
|
4351
|
+
return e <= 0 ? null : { start: 0, end: e };
|
|
4352
|
+
}
|
|
4353
|
+
static _applyStylesToRange(t, e, s) {
|
|
4354
|
+
if (!e || !Object.keys(e).length) return !1;
|
|
4355
|
+
const { start: n, end: o } = s;
|
|
4356
|
+
return o <= n ? !1 : (t.setSelectionStyles(e, n, o), !0);
|
|
4357
|
+
}
|
|
4358
|
+
static _getSelectionStyleValue(t, e, s) {
|
|
4359
|
+
var o;
|
|
4360
|
+
if (!e) return;
|
|
4361
|
+
const n = t.getSelectionStyles(
|
|
4362
|
+
e.start,
|
|
4363
|
+
e.end,
|
|
4364
|
+
!0
|
|
4365
|
+
);
|
|
4366
|
+
if (n.length)
|
|
4367
|
+
return (o = n[0]) == null ? void 0 : o[s];
|
|
4368
|
+
}
|
|
4311
4369
|
static _resolveStrokeColor(t, e) {
|
|
4312
4370
|
if (!(e <= 0))
|
|
4313
4371
|
return t != null ? t : "#000000";
|
|
@@ -4323,7 +4381,7 @@ class k {
|
|
|
4323
4381
|
return (e = (t = this.fonts[0]) == null ? void 0 : t.family) != null ? e : "Arial";
|
|
4324
4382
|
}
|
|
4325
4383
|
}
|
|
4326
|
-
class
|
|
4384
|
+
class Yt {
|
|
4327
4385
|
/**
|
|
4328
4386
|
* Конструктор класса ImageEditor.
|
|
4329
4387
|
* @param canvasId - идентификатор канваса, в котором будет создан редактор
|
|
@@ -4353,7 +4411,7 @@ class Ut {
|
|
|
4353
4411
|
showRotationAngle: d,
|
|
4354
4412
|
_onReadyCallback: l
|
|
4355
4413
|
} = this.options;
|
|
4356
|
-
if (
|
|
4414
|
+
if (J.apply(), this.canvas = new Ze(this.containerId, this.options), this.moduleLoader = new Ke(), this.workerManager = new Qe(), this.errorManager = new Et({ editor: this }), this.historyManager = new St({ editor: this }), this.toolbar = new gs({ editor: this }), this.transformManager = new Ss({ editor: this }), this.zoomManager = new Cs({ editor: this }), this.canvasManager = new As({ editor: this }), this.imageManager = new H({ editor: this }), this.layerManager = new Ct({ editor: this }), this.shapeManager = new Es({ editor: this }), this.interactionBlocker = new ws({ editor: this }), this.backgroundManager = new q({ editor: this }), this.clipboardManager = new Ds({ editor: this }), this.objectLockManager = new wt({ editor: this }), this.groupingManager = new Os({ editor: this }), this.selectionManager = new Ts({ editor: this }), this.deletionManager = new zt({ editor: this }), this.panConstraintManager = new Ls({ editor: this }), this.fontManager = new xt((u = this.options.fonts) != null ? u : []), this.textManager = new O({ editor: this }), d && (this.angleIndicator = new Ut({ editor: this })), this._createMontageArea(), this._createClippingArea(), this.listeners = new pt({ 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(a), this.canvasManager.updateCanvas(), this.zoomManager.calculateAndApplyDefaultZoom(), yield this.fontManager.loadFonts(), i != null && i.source) {
|
|
4357
4415
|
const {
|
|
4358
4416
|
source: g,
|
|
4359
4417
|
scale: f = `image-${c}`,
|
|
@@ -4375,7 +4433,7 @@ class Ut {
|
|
|
4375
4433
|
this.montageArea = this.shapeManager.addRectangle({
|
|
4376
4434
|
width: t,
|
|
4377
4435
|
height: e,
|
|
4378
|
-
fill:
|
|
4436
|
+
fill: Yt._createMosaicPattern(),
|
|
4379
4437
|
stroke: null,
|
|
4380
4438
|
strokeWidth: 0,
|
|
4381
4439
|
selectable: !1,
|
|
@@ -4426,13 +4484,13 @@ class Ut {
|
|
|
4426
4484
|
const t = document.createElement("canvas");
|
|
4427
4485
|
t.width = 20, t.height = 20;
|
|
4428
4486
|
const e = t.getContext("2d");
|
|
4429
|
-
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
|
|
4487
|
+
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 Pe({
|
|
4430
4488
|
source: t,
|
|
4431
4489
|
repeat: "repeat"
|
|
4432
4490
|
});
|
|
4433
4491
|
}
|
|
4434
4492
|
}
|
|
4435
|
-
const
|
|
4493
|
+
const z = [
|
|
4436
4494
|
"U+0000-00FF",
|
|
4437
4495
|
"U+0131",
|
|
4438
4496
|
"U+0152-0153",
|
|
@@ -4452,13 +4510,13 @@ const U = [
|
|
|
4452
4510
|
"U+2215",
|
|
4453
4511
|
"U+FEFF",
|
|
4454
4512
|
"U+FFFD"
|
|
4455
|
-
].join(", "),
|
|
4513
|
+
].join(", "), Y = [
|
|
4456
4514
|
"U+0301",
|
|
4457
4515
|
"U+0400-045F",
|
|
4458
4516
|
"U+0490-0491",
|
|
4459
4517
|
"U+04B0-04B1",
|
|
4460
4518
|
"U+2116"
|
|
4461
|
-
].join(", "),
|
|
4519
|
+
].join(", "), ks = [
|
|
4462
4520
|
{
|
|
4463
4521
|
family: "Arial",
|
|
4464
4522
|
source: 'local("Arial"), local("Liberation Sans"), local("DejaVu Sans")',
|
|
@@ -4475,7 +4533,7 @@ const U = [
|
|
|
4475
4533
|
style: "normal",
|
|
4476
4534
|
weight: "400",
|
|
4477
4535
|
display: "swap",
|
|
4478
|
-
unicodeRange:
|
|
4536
|
+
unicodeRange: Y
|
|
4479
4537
|
}
|
|
4480
4538
|
},
|
|
4481
4539
|
{
|
|
@@ -4485,7 +4543,7 @@ const U = [
|
|
|
4485
4543
|
style: "normal",
|
|
4486
4544
|
weight: "400",
|
|
4487
4545
|
display: "swap",
|
|
4488
|
-
unicodeRange:
|
|
4546
|
+
unicodeRange: z
|
|
4489
4547
|
}
|
|
4490
4548
|
},
|
|
4491
4549
|
{
|
|
@@ -4495,7 +4553,7 @@ const U = [
|
|
|
4495
4553
|
style: "normal",
|
|
4496
4554
|
weight: "700",
|
|
4497
4555
|
display: "swap",
|
|
4498
|
-
unicodeRange:
|
|
4556
|
+
unicodeRange: Y
|
|
4499
4557
|
}
|
|
4500
4558
|
},
|
|
4501
4559
|
{
|
|
@@ -4505,7 +4563,7 @@ const U = [
|
|
|
4505
4563
|
style: "normal",
|
|
4506
4564
|
weight: "700",
|
|
4507
4565
|
display: "swap",
|
|
4508
|
-
unicodeRange:
|
|
4566
|
+
unicodeRange: z
|
|
4509
4567
|
}
|
|
4510
4568
|
},
|
|
4511
4569
|
{
|
|
@@ -4515,7 +4573,7 @@ const U = [
|
|
|
4515
4573
|
style: "normal",
|
|
4516
4574
|
weight: "200 700",
|
|
4517
4575
|
display: "swap",
|
|
4518
|
-
unicodeRange:
|
|
4576
|
+
unicodeRange: Y
|
|
4519
4577
|
}
|
|
4520
4578
|
},
|
|
4521
4579
|
{
|
|
@@ -4525,7 +4583,7 @@ const U = [
|
|
|
4525
4583
|
style: "normal",
|
|
4526
4584
|
weight: "200 700",
|
|
4527
4585
|
display: "swap",
|
|
4528
|
-
unicodeRange:
|
|
4586
|
+
unicodeRange: z
|
|
4529
4587
|
}
|
|
4530
4588
|
},
|
|
4531
4589
|
{
|
|
@@ -4535,7 +4593,7 @@ const U = [
|
|
|
4535
4593
|
style: "normal",
|
|
4536
4594
|
weight: "300 900",
|
|
4537
4595
|
display: "swap",
|
|
4538
|
-
unicodeRange:
|
|
4596
|
+
unicodeRange: Y
|
|
4539
4597
|
}
|
|
4540
4598
|
},
|
|
4541
4599
|
{
|
|
@@ -4545,7 +4603,7 @@ const U = [
|
|
|
4545
4603
|
style: "normal",
|
|
4546
4604
|
weight: "300 900",
|
|
4547
4605
|
display: "swap",
|
|
4548
|
-
unicodeRange:
|
|
4606
|
+
unicodeRange: z
|
|
4549
4607
|
}
|
|
4550
4608
|
},
|
|
4551
4609
|
{
|
|
@@ -4555,7 +4613,7 @@ const U = [
|
|
|
4555
4613
|
style: "normal",
|
|
4556
4614
|
weight: "400 700",
|
|
4557
4615
|
display: "swap",
|
|
4558
|
-
unicodeRange:
|
|
4616
|
+
unicodeRange: Y
|
|
4559
4617
|
}
|
|
4560
4618
|
},
|
|
4561
4619
|
{
|
|
@@ -4565,7 +4623,7 @@ const U = [
|
|
|
4565
4623
|
style: "normal",
|
|
4566
4624
|
weight: "400 700",
|
|
4567
4625
|
display: "swap",
|
|
4568
|
-
unicodeRange:
|
|
4626
|
+
unicodeRange: z
|
|
4569
4627
|
}
|
|
4570
4628
|
},
|
|
4571
4629
|
{
|
|
@@ -4575,7 +4633,7 @@ const U = [
|
|
|
4575
4633
|
style: "normal",
|
|
4576
4634
|
weight: "300 700",
|
|
4577
4635
|
display: "swap",
|
|
4578
|
-
unicodeRange:
|
|
4636
|
+
unicodeRange: Y
|
|
4579
4637
|
}
|
|
4580
4638
|
},
|
|
4581
4639
|
{
|
|
@@ -4585,7 +4643,7 @@ const U = [
|
|
|
4585
4643
|
style: "normal",
|
|
4586
4644
|
weight: "300 700",
|
|
4587
4645
|
display: "swap",
|
|
4588
|
-
unicodeRange:
|
|
4646
|
+
unicodeRange: z
|
|
4589
4647
|
}
|
|
4590
4648
|
},
|
|
4591
4649
|
{
|
|
@@ -4595,7 +4653,7 @@ const U = [
|
|
|
4595
4653
|
style: "normal",
|
|
4596
4654
|
weight: "300 700",
|
|
4597
4655
|
display: "swap",
|
|
4598
|
-
unicodeRange:
|
|
4656
|
+
unicodeRange: Y
|
|
4599
4657
|
}
|
|
4600
4658
|
},
|
|
4601
4659
|
{
|
|
@@ -4605,7 +4663,7 @@ const U = [
|
|
|
4605
4663
|
style: "normal",
|
|
4606
4664
|
weight: "300 700",
|
|
4607
4665
|
display: "swap",
|
|
4608
|
-
unicodeRange:
|
|
4666
|
+
unicodeRange: z
|
|
4609
4667
|
}
|
|
4610
4668
|
},
|
|
4611
4669
|
{
|
|
@@ -4615,7 +4673,7 @@ const U = [
|
|
|
4615
4673
|
style: "normal",
|
|
4616
4674
|
weight: "400",
|
|
4617
4675
|
display: "swap",
|
|
4618
|
-
unicodeRange:
|
|
4676
|
+
unicodeRange: Y
|
|
4619
4677
|
}
|
|
4620
4678
|
},
|
|
4621
4679
|
{
|
|
@@ -4625,7 +4683,7 @@ const U = [
|
|
|
4625
4683
|
style: "normal",
|
|
4626
4684
|
weight: "400",
|
|
4627
4685
|
display: "swap",
|
|
4628
|
-
unicodeRange:
|
|
4686
|
+
unicodeRange: z
|
|
4629
4687
|
}
|
|
4630
4688
|
},
|
|
4631
4689
|
{
|
|
@@ -4635,7 +4693,7 @@ const U = [
|
|
|
4635
4693
|
style: "normal",
|
|
4636
4694
|
weight: "400 700",
|
|
4637
4695
|
display: "swap",
|
|
4638
|
-
unicodeRange:
|
|
4696
|
+
unicodeRange: Y
|
|
4639
4697
|
}
|
|
4640
4698
|
},
|
|
4641
4699
|
{
|
|
@@ -4645,7 +4703,7 @@ const U = [
|
|
|
4645
4703
|
style: "normal",
|
|
4646
4704
|
weight: "400 700",
|
|
4647
4705
|
display: "swap",
|
|
4648
|
-
unicodeRange:
|
|
4706
|
+
unicodeRange: z
|
|
4649
4707
|
}
|
|
4650
4708
|
},
|
|
4651
4709
|
{
|
|
@@ -4655,7 +4713,7 @@ const U = [
|
|
|
4655
4713
|
style: "normal",
|
|
4656
4714
|
weight: "100 900",
|
|
4657
4715
|
display: "swap",
|
|
4658
|
-
unicodeRange:
|
|
4716
|
+
unicodeRange: Y
|
|
4659
4717
|
}
|
|
4660
4718
|
},
|
|
4661
4719
|
{
|
|
@@ -4665,10 +4723,10 @@ const U = [
|
|
|
4665
4723
|
style: "normal",
|
|
4666
4724
|
weight: "100 900",
|
|
4667
4725
|
display: "swap",
|
|
4668
|
-
unicodeRange:
|
|
4726
|
+
unicodeRange: z
|
|
4669
4727
|
}
|
|
4670
4728
|
}
|
|
4671
|
-
],
|
|
4729
|
+
], xs = {
|
|
4672
4730
|
/**
|
|
4673
4731
|
* Опции редактора
|
|
4674
4732
|
*/
|
|
@@ -4760,20 +4818,20 @@ const U = [
|
|
|
4760
4818
|
/**
|
|
4761
4819
|
* Список шрифтов, которые будут доступны в редакторе по умолчанию.
|
|
4762
4820
|
*/
|
|
4763
|
-
fonts:
|
|
4821
|
+
fonts: ks
|
|
4764
4822
|
};
|
|
4765
|
-
function
|
|
4766
|
-
const e =
|
|
4823
|
+
function zs(h, t = {}) {
|
|
4824
|
+
const e = D(D({}, xs), t), s = document.getElementById(h);
|
|
4767
4825
|
if (!s)
|
|
4768
4826
|
return Promise.reject(new Error(`Контейнер с ID "${h}" не найден.`));
|
|
4769
4827
|
const n = document.createElement("canvas");
|
|
4770
4828
|
return n.id = `${h}-canvas`, s.appendChild(n), e.editorContainer = s, new Promise((o) => {
|
|
4771
4829
|
e._onReadyCallback = o;
|
|
4772
|
-
const a = new
|
|
4830
|
+
const a = new Yt(n.id, e);
|
|
4773
4831
|
window[h] = a;
|
|
4774
4832
|
});
|
|
4775
4833
|
}
|
|
4776
4834
|
export {
|
|
4777
|
-
|
|
4835
|
+
zs as default
|
|
4778
4836
|
};
|
|
4779
4837
|
//# sourceMappingURL=main.js.map
|