@anu3ev/fabric-image-editor 0.1.28 → 0.1.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.js +605 -421
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { ActiveSelection as
|
|
2
|
-
import { create as
|
|
3
|
-
var
|
|
1
|
+
import { ActiveSelection as P, util as U, controlsUtils as Ee, InteractiveFabricObject as Te, loadSVGFromURL as ke, FabricImage as le, Point as xe, Rect as Be, Circle as Ze, Triangle as ze, Group as Pe, Pattern as Ue, Canvas as Ye } from "fabric";
|
|
2
|
+
import { create as He } from "jsondiffpatch";
|
|
3
|
+
var _e = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", w = function() {
|
|
4
4
|
for (var e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 21, t = "", a = crypto.getRandomValues(new Uint8Array(e |= 0)); e--; )
|
|
5
|
-
t +=
|
|
5
|
+
t += _e[a[e] & 63];
|
|
6
6
|
return t;
|
|
7
7
|
};
|
|
8
|
-
function
|
|
8
|
+
function he(o, e, t, a, r, n, i) {
|
|
9
9
|
try {
|
|
10
10
|
var s = o[n](i), c = s.value;
|
|
11
11
|
} catch (u) {
|
|
@@ -13,22 +13,22 @@ function le(o, e, t, a, r, n, i) {
|
|
|
13
13
|
}
|
|
14
14
|
s.done ? e(c) : Promise.resolve(c).then(a, r);
|
|
15
15
|
}
|
|
16
|
-
function
|
|
16
|
+
function Re(o) {
|
|
17
17
|
return function() {
|
|
18
18
|
var e = this, t = arguments;
|
|
19
19
|
return new Promise(function(a, r) {
|
|
20
20
|
var n = o.apply(e, t);
|
|
21
21
|
function i(c) {
|
|
22
|
-
|
|
22
|
+
he(n, a, r, i, s, "next", c);
|
|
23
23
|
}
|
|
24
24
|
function s(c) {
|
|
25
|
-
|
|
25
|
+
he(n, a, r, i, s, "throw", c);
|
|
26
26
|
}
|
|
27
27
|
i(void 0);
|
|
28
28
|
});
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
|
-
class
|
|
31
|
+
class z {
|
|
32
32
|
/**
|
|
33
33
|
* Конструктор принимает редактор и опции.
|
|
34
34
|
* @param {Object} params
|
|
@@ -49,7 +49,7 @@ class Z {
|
|
|
49
49
|
editor: t,
|
|
50
50
|
options: a = {}
|
|
51
51
|
} = e;
|
|
52
|
-
this.editor = t, this.canvas = t.canvas, this.options = a, this.isUndoRedoKeyPressed = !1, this.handleAdaptCanvasToContainerBound =
|
|
52
|
+
this.editor = t, this.canvas = t.canvas, this.options = a, this.isUndoRedoKeyPressed = !1, this.handleAdaptCanvasToContainerBound = z.debounce(this.handleAdaptCanvasToContainer.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.handleObjectModifiedHistoryBound = z.debounce(this.handleObjectModifiedHistory.bind(this), 300), this.handleObjectRotatingHistoryBound = z.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.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();
|
|
53
53
|
}
|
|
54
54
|
/**
|
|
55
55
|
* Инициализация всех обработчиков согласно опциям.
|
|
@@ -103,7 +103,7 @@ class Z {
|
|
|
103
103
|
this.canvas.setActiveObject(n[0]);
|
|
104
104
|
return;
|
|
105
105
|
}
|
|
106
|
-
var i = new
|
|
106
|
+
var i = new P(n, {
|
|
107
107
|
canvas: this.canvas
|
|
108
108
|
});
|
|
109
109
|
this.canvas.setActiveObject(i), this.canvas.requestRenderAll();
|
|
@@ -222,7 +222,7 @@ class Z {
|
|
|
222
222
|
*/
|
|
223
223
|
handleUndoRedoEvent(e) {
|
|
224
224
|
var t = this;
|
|
225
|
-
return
|
|
225
|
+
return Re(function* () {
|
|
226
226
|
var {
|
|
227
227
|
ctrlKey: a,
|
|
228
228
|
metaKey: r,
|
|
@@ -367,7 +367,7 @@ class Z {
|
|
|
367
367
|
};
|
|
368
368
|
}
|
|
369
369
|
}
|
|
370
|
-
class
|
|
370
|
+
class We {
|
|
371
371
|
/**
|
|
372
372
|
* @description Класс для динамической загрузки внешних модулей.
|
|
373
373
|
*/
|
|
@@ -385,7 +385,7 @@ class _e {
|
|
|
385
385
|
return this.loaders[e] ? (this.cache.has(e) || this.cache.set(e, this.loaders[e]()), this.cache.get(e)) : Promise.reject(new Error('Unknown module "'.concat(e, '"')));
|
|
386
386
|
}
|
|
387
387
|
}
|
|
388
|
-
class
|
|
388
|
+
class Fe {
|
|
389
389
|
/**
|
|
390
390
|
* @param {string|URL} [scriptUrl] — URL скрипта воркера.
|
|
391
391
|
* По-умолчанию использует файл рядом с этим модулем
|
|
@@ -425,7 +425,7 @@ class Re {
|
|
|
425
425
|
* @returns {Promise<any>}
|
|
426
426
|
*/
|
|
427
427
|
post(e, t) {
|
|
428
|
-
var a = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : [], r = "".concat(e, ":").concat(
|
|
428
|
+
var a = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : [], r = "".concat(e, ":").concat(w(8));
|
|
429
429
|
return new Promise((n, i) => {
|
|
430
430
|
this._callbacks.set(r, {
|
|
431
431
|
resolve: n,
|
|
@@ -444,98 +444,98 @@ class Re {
|
|
|
444
444
|
this.worker.terminate();
|
|
445
445
|
}
|
|
446
446
|
}
|
|
447
|
-
var
|
|
448
|
-
function
|
|
449
|
-
var n =
|
|
450
|
-
o.save(), o.translate(e, t), o.rotate(U.degreesToRadians(r.angle)), o.fillStyle =
|
|
451
|
-
}
|
|
452
|
-
function he(o, e, t, a, r) {
|
|
453
|
-
var n = X, i = Q, s = Fe;
|
|
454
|
-
o.save(), o.translate(e, t), o.rotate(U.degreesToRadians(r.angle)), o.fillStyle = te, o.strokeStyle = ee, o.lineWidth = q, o.beginPath(), o.roundRect(-8 / 2, -20 / 2, n, i, s), o.fill(), o.stroke(), o.restore();
|
|
447
|
+
var I = 12, Ve = 2, K = 8, $ = 20, Ge = 100, q = 20, ee = 8, Xe = 100, te = 32, ae = 1, Qe = "#2B2D33", re = "#3D8BF4", ne = "#FFFFFF";
|
|
448
|
+
function R(o, e, t, a, r) {
|
|
449
|
+
var n = I, i = Ve;
|
|
450
|
+
o.save(), o.translate(e, t), o.rotate(U.degreesToRadians(r.angle)), o.fillStyle = ne, o.strokeStyle = re, o.lineWidth = ae, o.beginPath(), o.roundRect(-12 / 2, -12 / 2, n, n, i), o.fill(), o.stroke(), o.restore();
|
|
455
451
|
}
|
|
456
452
|
function ge(o, e, t, a, r) {
|
|
457
|
-
var n =
|
|
458
|
-
o.save(), o.translate(e, t), o.rotate(U.degreesToRadians(r.angle)), o.fillStyle =
|
|
453
|
+
var n = K, i = $, s = Ge;
|
|
454
|
+
o.save(), o.translate(e, t), o.rotate(U.degreesToRadians(r.angle)), o.fillStyle = ne, o.strokeStyle = re, o.lineWidth = ae, o.beginPath(), o.roundRect(-8 / 2, -20 / 2, n, i, s), o.fill(), o.stroke(), o.restore();
|
|
455
|
+
}
|
|
456
|
+
function ve(o, e, t, a, r) {
|
|
457
|
+
var n = q, i = ee, s = Xe;
|
|
458
|
+
o.save(), o.translate(e, t), o.rotate(U.degreesToRadians(r.angle)), o.fillStyle = ne, o.strokeStyle = re, o.lineWidth = ae, o.beginPath(), o.roundRect(-20 / 2, -8 / 2, n, i, s), o.fill(), o.stroke(), o.restore();
|
|
459
459
|
}
|
|
460
|
-
var
|
|
461
|
-
|
|
462
|
-
function
|
|
463
|
-
var n =
|
|
464
|
-
o.save(), o.translate(e, t), o.rotate(U.degreesToRadians(r.angle)), o.fillStyle =
|
|
460
|
+
var Je = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTE4Ljc1IDQuMzc1djMuNzVhLjYyNS42MjUgMCAwIDEtLjYyNS42MjVoLTMuNzVhLjYyNS42MjUgMCAwIDEgMC0xLjI1aDIuMTRsLTIuMDc3LTEuOTAzLS4wMi0uMDE5YTYuMjUgNi4yNSAwIDEgMC0uMTMgOC45NjcuNjI2LjYyNiAwIDAgMSAuODYuOTA5QTcuNDU2IDcuNDU2IDAgMCAxIDEwIDE3LjVoLS4xMDNhNy41IDcuNSAwIDEgMSA1LjM5Ni0xMi44MTJMMTcuNSA2LjcwM1Y0LjM3NWEuNjI1LjYyNSAwIDAgMSAxLjI1IDBaIi8+PC9zdmc+", we = new Image();
|
|
461
|
+
we.src = Je;
|
|
462
|
+
function Ke(o, e, t, a, r) {
|
|
463
|
+
var n = te, i = n / 2;
|
|
464
|
+
o.save(), o.translate(e, t), o.rotate(U.degreesToRadians(r.angle)), o.fillStyle = Qe, o.beginPath(), o.arc(0, 0, i, 0, 2 * Math.PI), o.fill(), o.drawImage(we, -16 / 2, -16 / 2, i, i), o.restore();
|
|
465
465
|
}
|
|
466
|
-
var
|
|
466
|
+
var $e = {
|
|
467
467
|
// Угловые точки
|
|
468
468
|
tl: {
|
|
469
|
-
render:
|
|
470
|
-
sizeX:
|
|
471
|
-
sizeY:
|
|
469
|
+
render: R,
|
|
470
|
+
sizeX: I,
|
|
471
|
+
sizeY: I,
|
|
472
472
|
offsetX: 0,
|
|
473
473
|
offsetY: 0
|
|
474
474
|
},
|
|
475
475
|
tr: {
|
|
476
|
-
render:
|
|
477
|
-
sizeX:
|
|
478
|
-
sizeY:
|
|
476
|
+
render: R,
|
|
477
|
+
sizeX: I,
|
|
478
|
+
sizeY: I,
|
|
479
479
|
offsetX: 0,
|
|
480
480
|
offsetY: 0
|
|
481
481
|
},
|
|
482
482
|
bl: {
|
|
483
|
-
render:
|
|
484
|
-
sizeX:
|
|
485
|
-
sizeY:
|
|
483
|
+
render: R,
|
|
484
|
+
sizeX: I,
|
|
485
|
+
sizeY: I,
|
|
486
486
|
offsetX: 0,
|
|
487
487
|
offsetY: 0
|
|
488
488
|
},
|
|
489
489
|
br: {
|
|
490
|
-
render:
|
|
491
|
-
sizeX:
|
|
492
|
-
sizeY:
|
|
490
|
+
render: R,
|
|
491
|
+
sizeX: I,
|
|
492
|
+
sizeY: I,
|
|
493
493
|
offsetX: 0,
|
|
494
494
|
offsetY: 0
|
|
495
495
|
},
|
|
496
496
|
// Середина вертикалей
|
|
497
497
|
ml: {
|
|
498
|
-
render:
|
|
499
|
-
sizeX:
|
|
500
|
-
sizeY:
|
|
498
|
+
render: ge,
|
|
499
|
+
sizeX: K,
|
|
500
|
+
sizeY: $,
|
|
501
501
|
offsetX: 0,
|
|
502
502
|
offsetY: 0
|
|
503
503
|
},
|
|
504
504
|
mr: {
|
|
505
|
-
render:
|
|
506
|
-
sizeX:
|
|
507
|
-
sizeY:
|
|
505
|
+
render: ge,
|
|
506
|
+
sizeX: K,
|
|
507
|
+
sizeY: $,
|
|
508
508
|
offsetX: 0,
|
|
509
509
|
offsetY: 0
|
|
510
510
|
},
|
|
511
511
|
// Середина горизонталей
|
|
512
512
|
mt: {
|
|
513
|
-
render:
|
|
514
|
-
sizeX:
|
|
515
|
-
sizeY:
|
|
513
|
+
render: ve,
|
|
514
|
+
sizeX: q,
|
|
515
|
+
sizeY: ee,
|
|
516
516
|
offsetX: 0,
|
|
517
517
|
offsetY: 0
|
|
518
518
|
},
|
|
519
519
|
mb: {
|
|
520
|
-
render:
|
|
521
|
-
sizeX:
|
|
522
|
-
sizeY:
|
|
520
|
+
render: ve,
|
|
521
|
+
sizeX: q,
|
|
522
|
+
sizeY: ee,
|
|
523
523
|
offsetX: 0,
|
|
524
524
|
offsetY: 0
|
|
525
525
|
},
|
|
526
526
|
// Специальный «rotate» контрол
|
|
527
527
|
mtr: {
|
|
528
|
-
render:
|
|
529
|
-
sizeX:
|
|
530
|
-
sizeY:
|
|
528
|
+
render: Ke,
|
|
529
|
+
sizeX: te,
|
|
530
|
+
sizeY: te,
|
|
531
531
|
offsetX: 0,
|
|
532
532
|
offsetY: -32
|
|
533
533
|
}
|
|
534
534
|
};
|
|
535
|
-
class
|
|
535
|
+
class qe {
|
|
536
536
|
static apply() {
|
|
537
|
-
var e =
|
|
538
|
-
Object.entries(
|
|
537
|
+
var e = Ee.createObjectDefaultControls();
|
|
538
|
+
Object.entries($e).forEach((t) => {
|
|
539
539
|
var [a, r] = t;
|
|
540
540
|
Object.assign(e[a], {
|
|
541
541
|
render: r.render,
|
|
@@ -547,8 +547,8 @@ class $e {
|
|
|
547
547
|
}), Te.ownDefaults.controls = e;
|
|
548
548
|
}
|
|
549
549
|
}
|
|
550
|
-
var
|
|
551
|
-
function
|
|
550
|
+
var et = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNNi44NzUgMi41YS42MjUuNjI1IDAgMCAwLS42MjUuNjI0VjYuMjVIMy4xMjVhLjYyNS42M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PSJldmVub2RkIiBkPSJNOC4xMjUgMS4yNUExLjg3NSAxLjg3NSAwIDAgMCA2LjI1IDMuMTI1di42MjVIMy4xMjVhLjYyNS42MjUgMCAwIDAgMCAxLjI1aC42MjV2MTEuMjVBMS4yNSAxLjI1IDAgMCAwIDUgMTcuNWgxMGExLjI1IDEuMjUgMCAwIDAgMS4yNS0xLjI1VjVoLjYyNWEuNjI1LjYyNSAwIDAgMCAwLTEuMjVIMTMuNzV2LS42MjVhMS44NzUgMS44NzUgMCAwIDAtMS44NzUtMS44NzVoLTMuNzVabTQuMzc1IDIuNXYtLjYyNWEuNjI1LjYyNSAwIDAgMC0uNjI1LS42MjVoLTMuNzVhLjYyNS42MjUgMCAwIDAtLjYyNS42MjV2LjYyNWg1Wk01IDE2LjI1VjVoMTB2MTEuMjVINVpNOC4xMjUgNy41Yy4zNDUgMCAuNjI1LjI4LjYyNS42MjV2NWEuNjI1LjYyNSAwIDEgMS0xLjI1IDB2LTVjMC0uMzQ1LjI4LS42MjUuNjI1LS42MjVabTQuMzc1IDUuNjI1di01YS42MjUuNjI1IDAgMCAwLTEuMjUgMHY1YS42MjUuNjI1IDAgMSAwIDEuMjUgMFoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjwvc3ZnPg==";
|
|
551
|
+
function me(o, e, t, a, r, n, i) {
|
|
552
552
|
try {
|
|
553
553
|
var s = o[n](i), c = s.value;
|
|
554
554
|
} catch (u) {
|
|
@@ -556,22 +556,22 @@ function ve(o, e, t, a, r, n, i) {
|
|
|
556
556
|
}
|
|
557
557
|
s.done ? e(c) : Promise.resolve(c).then(a, r);
|
|
558
558
|
}
|
|
559
|
-
function
|
|
559
|
+
function ct(o) {
|
|
560
560
|
return function() {
|
|
561
561
|
var e = this, t = arguments;
|
|
562
562
|
return new Promise(function(a, r) {
|
|
563
563
|
var n = o.apply(e, t);
|
|
564
564
|
function i(c) {
|
|
565
|
-
|
|
565
|
+
me(n, a, r, i, s, "next", c);
|
|
566
566
|
}
|
|
567
567
|
function s(c) {
|
|
568
|
-
|
|
568
|
+
me(n, a, r, i, s, "throw", c);
|
|
569
569
|
}
|
|
570
570
|
i(void 0);
|
|
571
571
|
});
|
|
572
572
|
};
|
|
573
573
|
}
|
|
574
|
-
const
|
|
574
|
+
const x = {
|
|
575
575
|
style: {
|
|
576
576
|
position: "absolute",
|
|
577
577
|
display: "none",
|
|
@@ -630,18 +630,18 @@ const k = {
|
|
|
630
630
|
}],
|
|
631
631
|
offsetTop: 50,
|
|
632
632
|
icons: {
|
|
633
|
-
copyPaste:
|
|
634
|
-
delete:
|
|
635
|
-
lock:
|
|
636
|
-
unlock:
|
|
637
|
-
bringToFront:
|
|
638
|
-
sendToBack:
|
|
639
|
-
bringForward:
|
|
640
|
-
sendBackwards:
|
|
633
|
+
copyPaste: et,
|
|
634
|
+
delete: st,
|
|
635
|
+
lock: tt,
|
|
636
|
+
unlock: at,
|
|
637
|
+
bringToFront: it,
|
|
638
|
+
sendToBack: ot,
|
|
639
|
+
bringForward: rt,
|
|
640
|
+
sendBackwards: nt
|
|
641
641
|
},
|
|
642
642
|
handlers: {
|
|
643
643
|
copyPaste: function() {
|
|
644
|
-
var o =
|
|
644
|
+
var o = ct(function* (t) {
|
|
645
645
|
yield t.clipboardManager.copy(), yield t.clipboardManager.paste();
|
|
646
646
|
});
|
|
647
647
|
function e(t) {
|
|
@@ -672,7 +672,7 @@ const k = {
|
|
|
672
672
|
}
|
|
673
673
|
}
|
|
674
674
|
};
|
|
675
|
-
function
|
|
675
|
+
function fe(o, e) {
|
|
676
676
|
var t = Object.keys(o);
|
|
677
677
|
if (Object.getOwnPropertySymbols) {
|
|
678
678
|
var a = Object.getOwnPropertySymbols(o);
|
|
@@ -682,25 +682,25 @@ function me(o, e) {
|
|
|
682
682
|
}
|
|
683
683
|
return t;
|
|
684
684
|
}
|
|
685
|
-
function
|
|
685
|
+
function y(o) {
|
|
686
686
|
for (var e = 1; e < arguments.length; e++) {
|
|
687
687
|
var t = arguments[e] != null ? arguments[e] : {};
|
|
688
|
-
e % 2 ?
|
|
689
|
-
|
|
690
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(o, Object.getOwnPropertyDescriptors(t)) :
|
|
688
|
+
e % 2 ? fe(Object(t), !0).forEach(function(a) {
|
|
689
|
+
ut(o, a, t[a]);
|
|
690
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(o, Object.getOwnPropertyDescriptors(t)) : fe(Object(t)).forEach(function(a) {
|
|
691
691
|
Object.defineProperty(o, a, Object.getOwnPropertyDescriptor(t, a));
|
|
692
692
|
});
|
|
693
693
|
}
|
|
694
694
|
return o;
|
|
695
695
|
}
|
|
696
|
-
function
|
|
697
|
-
return (e =
|
|
696
|
+
function ut(o, e, t) {
|
|
697
|
+
return (e = dt(e)) in o ? Object.defineProperty(o, e, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : o[e] = t, o;
|
|
698
698
|
}
|
|
699
|
-
function
|
|
700
|
-
var e =
|
|
699
|
+
function dt(o) {
|
|
700
|
+
var e = lt(o, "string");
|
|
701
701
|
return typeof e == "symbol" ? e : e + "";
|
|
702
702
|
}
|
|
703
|
-
function
|
|
703
|
+
function lt(o, e) {
|
|
704
704
|
if (typeof o != "object" || !o) return o;
|
|
705
705
|
var t = o[Symbol.toPrimitive];
|
|
706
706
|
if (t !== void 0) {
|
|
@@ -710,7 +710,7 @@ function dt(o, e) {
|
|
|
710
710
|
}
|
|
711
711
|
return (e === "string" ? String : Number)(o);
|
|
712
712
|
}
|
|
713
|
-
class
|
|
713
|
+
class ht {
|
|
714
714
|
/**
|
|
715
715
|
* @param {object} options
|
|
716
716
|
* @param {ImageEditor} options.editor - экземпляр редактора с доступом к canvas
|
|
@@ -722,11 +722,11 @@ class lt {
|
|
|
722
722
|
if (this.options = t.options, !!this.options.showToolbar) {
|
|
723
723
|
this.editor = t, this.canvas = t.canvas;
|
|
724
724
|
var a = this.options.toolbar || {};
|
|
725
|
-
this.config =
|
|
726
|
-
style:
|
|
727
|
-
btnStyle:
|
|
728
|
-
icons:
|
|
729
|
-
handlers:
|
|
725
|
+
this.config = y(y(y({}, x), a), {}, {
|
|
726
|
+
style: y(y({}, x.style), a.style || {}),
|
|
727
|
+
btnStyle: y(y({}, x.btnStyle), a.btnStyle || {}),
|
|
728
|
+
icons: y(y({}, x.icons), a.icons || {}),
|
|
729
|
+
handlers: y(y({}, x.handlers), a.handlers || {})
|
|
730
730
|
}), this.currentTarget = null, this.currentLocked = null, 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 = () => {
|
|
731
731
|
this.el.style.display = "none";
|
|
732
732
|
}, this._createDOM(), this._bindEvents();
|
|
@@ -862,7 +862,7 @@ class lt {
|
|
|
862
862
|
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("selection:changed", this._onSelectionChange), this.canvas.off("after:render", this._onSelectionChange), this.canvas.off("selection:cleared", this._onSelectionClear), this.el.remove();
|
|
863
863
|
}
|
|
864
864
|
}
|
|
865
|
-
function
|
|
865
|
+
function Me(o, e, t, a, r, n, i) {
|
|
866
866
|
try {
|
|
867
867
|
var s = o[n](i), c = s.value;
|
|
868
868
|
} catch (u) {
|
|
@@ -870,22 +870,22 @@ function fe(o, e, t, a, r, n, i) {
|
|
|
870
870
|
}
|
|
871
871
|
s.done ? e(c) : Promise.resolve(c).then(a, r);
|
|
872
872
|
}
|
|
873
|
-
function
|
|
873
|
+
function X(o) {
|
|
874
874
|
return function() {
|
|
875
875
|
var e = this, t = arguments;
|
|
876
876
|
return new Promise(function(a, r) {
|
|
877
877
|
var n = o.apply(e, t);
|
|
878
878
|
function i(c) {
|
|
879
|
-
|
|
879
|
+
Me(n, a, r, i, s, "next", c);
|
|
880
880
|
}
|
|
881
881
|
function s(c) {
|
|
882
|
-
|
|
882
|
+
Me(n, a, r, i, s, "throw", c);
|
|
883
883
|
}
|
|
884
884
|
i(void 0);
|
|
885
885
|
});
|
|
886
886
|
};
|
|
887
887
|
}
|
|
888
|
-
class
|
|
888
|
+
class gt {
|
|
889
889
|
/**
|
|
890
890
|
* @param {object} options
|
|
891
891
|
* @param {ImageEditor} options.editor - экземпляр редактора с доступом к canvas
|
|
@@ -901,7 +901,7 @@ class ht {
|
|
|
901
901
|
return this._historySuspendCount > 0;
|
|
902
902
|
}
|
|
903
903
|
_createDiffPatcher() {
|
|
904
|
-
this.diffPatcher =
|
|
904
|
+
this.diffPatcher = He({
|
|
905
905
|
objectHash(e) {
|
|
906
906
|
return [e.id, e.format, e.locked, e.left, e.top, e.width, e.height, e.flipX, e.flipY, e.scaleX, e.scaleY, e.angle, e.opacity].join("-");
|
|
907
907
|
},
|
|
@@ -974,7 +974,7 @@ class ht {
|
|
|
974
974
|
*/
|
|
975
975
|
loadStateFromFullState(e) {
|
|
976
976
|
var t = this;
|
|
977
|
-
return
|
|
977
|
+
return X(function* () {
|
|
978
978
|
if (e) {
|
|
979
979
|
console.log("loadStateFromFullState fullState", e), yield t.canvas.loadFromJSON(e);
|
|
980
980
|
var a = t.canvas.getObjects().find((n) => n.id === "montage-area");
|
|
@@ -990,7 +990,7 @@ class ht {
|
|
|
990
990
|
*/
|
|
991
991
|
undo() {
|
|
992
992
|
var e = this;
|
|
993
|
-
return
|
|
993
|
+
return X(function* () {
|
|
994
994
|
if (!e.skipHistory) {
|
|
995
995
|
if (e.currentIndex <= 0) {
|
|
996
996
|
console.log("Нет предыдущих состояний для отмены.");
|
|
@@ -1017,7 +1017,7 @@ class ht {
|
|
|
1017
1017
|
*/
|
|
1018
1018
|
redo() {
|
|
1019
1019
|
var e = this;
|
|
1020
|
-
return
|
|
1020
|
+
return X(function* () {
|
|
1021
1021
|
if (!e.skipHistory) {
|
|
1022
1022
|
if (e.currentIndex >= e.patches.length) {
|
|
1023
1023
|
console.log("Нет состояний для повтора.");
|
|
@@ -1039,8 +1039,8 @@ class ht {
|
|
|
1039
1039
|
})();
|
|
1040
1040
|
}
|
|
1041
1041
|
}
|
|
1042
|
-
var
|
|
1043
|
-
function
|
|
1042
|
+
var vt = 0.1, mt = 2, ft = 0.1, Mt = 90, B = 16, Z = 16, D = 4096, L = 4096;
|
|
1043
|
+
function je(o, e, t, a, r, n, i) {
|
|
1044
1044
|
try {
|
|
1045
1045
|
var s = o[n](i), c = s.value;
|
|
1046
1046
|
} catch (u) {
|
|
@@ -1048,22 +1048,22 @@ function Me(o, e, t, a, r, n, i) {
|
|
|
1048
1048
|
}
|
|
1049
1049
|
s.done ? e(c) : Promise.resolve(c).then(a, r);
|
|
1050
1050
|
}
|
|
1051
|
-
function
|
|
1051
|
+
function E(o) {
|
|
1052
1052
|
return function() {
|
|
1053
1053
|
var e = this, t = arguments;
|
|
1054
1054
|
return new Promise(function(a, r) {
|
|
1055
1055
|
var n = o.apply(e, t);
|
|
1056
1056
|
function i(c) {
|
|
1057
|
-
|
|
1057
|
+
je(n, a, r, i, s, "next", c);
|
|
1058
1058
|
}
|
|
1059
1059
|
function s(c) {
|
|
1060
|
-
|
|
1060
|
+
je(n, a, r, i, s, "throw", c);
|
|
1061
1061
|
}
|
|
1062
1062
|
i(void 0);
|
|
1063
1063
|
});
|
|
1064
1064
|
};
|
|
1065
1065
|
}
|
|
1066
|
-
class
|
|
1066
|
+
class S {
|
|
1067
1067
|
/**
|
|
1068
1068
|
* @param {object} options
|
|
1069
1069
|
* @param {ImageEditor} options.editor - экземпляр редактора с доступом к canvas
|
|
@@ -1072,7 +1072,7 @@ class C {
|
|
|
1072
1072
|
var {
|
|
1073
1073
|
editor: t
|
|
1074
1074
|
} = e;
|
|
1075
|
-
this.editor = t, this.options = t.options, this._createdBlobUrls = [];
|
|
1075
|
+
this.editor = t, this.options = t.options, this._createdBlobUrls = [], this.acceptContentTypes = this.editor.options.acceptContentTypes, this.acceptFormats = this.getAllowedFormatsFromContentTypes();
|
|
1076
1076
|
}
|
|
1077
1077
|
/**
|
|
1078
1078
|
* Импорт изображения
|
|
@@ -1087,89 +1087,123 @@ class C {
|
|
|
1087
1087
|
*/
|
|
1088
1088
|
importImage(e) {
|
|
1089
1089
|
var t = this;
|
|
1090
|
-
return
|
|
1090
|
+
return E(function* () {
|
|
1091
1091
|
var {
|
|
1092
1092
|
source: a,
|
|
1093
1093
|
scale: r = "image-".concat(t.options.scaleType),
|
|
1094
1094
|
withoutSave: n = !1
|
|
1095
1095
|
} = e;
|
|
1096
1096
|
if (a) {
|
|
1097
|
-
var
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1097
|
+
var {
|
|
1098
|
+
canvas: i,
|
|
1099
|
+
montageArea: s,
|
|
1100
|
+
transformManager: c,
|
|
1101
|
+
historyManager: u,
|
|
1102
|
+
errorManager: l
|
|
1103
|
+
} = t.editor, d = yield t.getContentType(a), {
|
|
1104
|
+
acceptContentTypes: h,
|
|
1105
|
+
acceptFormats: g
|
|
1106
|
+
} = t;
|
|
1107
|
+
if (!t.isAllowedContentType(d)) {
|
|
1108
|
+
var f = "Неверный contentType для изображения: ".concat(d, ". Ожидается один из: ").concat(t.acceptContentTypes.join(", "), ".");
|
|
1109
|
+
l.emitError({
|
|
1110
|
+
origin: "ImageManager",
|
|
1111
|
+
method: "importImage",
|
|
1112
|
+
code: "INVALID_CONTENT_TYPE",
|
|
1113
|
+
message: f,
|
|
1114
|
+
data: {
|
|
1115
|
+
contentType: d,
|
|
1116
|
+
source: a,
|
|
1117
|
+
acceptContentTypes: h,
|
|
1118
|
+
acceptFormats: g
|
|
1119
|
+
}
|
|
1102
1120
|
});
|
|
1103
1121
|
return;
|
|
1104
1122
|
}
|
|
1105
|
-
|
|
1106
|
-
canvas: c,
|
|
1107
|
-
montageArea: u,
|
|
1108
|
-
transformManager: l,
|
|
1109
|
-
historyManager: d
|
|
1110
|
-
} = t.editor;
|
|
1111
|
-
d.suspendHistory();
|
|
1123
|
+
u.suspendHistory();
|
|
1112
1124
|
try {
|
|
1113
|
-
var
|
|
1125
|
+
var m, v;
|
|
1114
1126
|
if (a instanceof File)
|
|
1115
|
-
|
|
1127
|
+
m = URL.createObjectURL(a);
|
|
1116
1128
|
else if (typeof a == "string") {
|
|
1117
|
-
var
|
|
1129
|
+
var M = yield fetch(a, {
|
|
1118
1130
|
mode: "cors"
|
|
1119
|
-
}),
|
|
1120
|
-
type:
|
|
1131
|
+
}), C = yield M.blob({
|
|
1132
|
+
type: d,
|
|
1121
1133
|
quality: 1
|
|
1122
1134
|
});
|
|
1123
|
-
|
|
1124
|
-
} else
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1135
|
+
m = URL.createObjectURL(C);
|
|
1136
|
+
} else {
|
|
1137
|
+
l.emitError({
|
|
1138
|
+
origin: "ImageManager",
|
|
1139
|
+
method: "importImage",
|
|
1140
|
+
code: "INVALID_SOURCE_TYPE",
|
|
1141
|
+
message: "Неверный тип источника изображения. Ожидается URL или объект File.",
|
|
1142
|
+
data: {
|
|
1143
|
+
source: a,
|
|
1144
|
+
contentType: d,
|
|
1145
|
+
acceptContentTypes: h,
|
|
1146
|
+
acceptFormats: g
|
|
1147
|
+
}
|
|
1148
|
+
});
|
|
1149
|
+
return;
|
|
1150
|
+
}
|
|
1151
|
+
t._createdBlobUrls.push(m);
|
|
1152
|
+
var j = S.getFormatFromContentType(d);
|
|
1153
|
+
if (j === "svg") {
|
|
1154
|
+
var N = yield ke(m);
|
|
1155
|
+
v = U.groupSVGElements(N.objects, N.options);
|
|
1131
1156
|
} else
|
|
1132
|
-
|
|
1157
|
+
v = yield le.fromURL(m, {
|
|
1133
1158
|
crossOrigin: "anonymous"
|
|
1134
1159
|
});
|
|
1135
1160
|
var {
|
|
1136
|
-
width:
|
|
1137
|
-
height:
|
|
1138
|
-
} =
|
|
1139
|
-
if (
|
|
1140
|
-
var
|
|
1141
|
-
t._createdBlobUrls.push(
|
|
1161
|
+
width: O,
|
|
1162
|
+
height: A
|
|
1163
|
+
} = v;
|
|
1164
|
+
if (A > L || O > D) {
|
|
1165
|
+
var p = yield t.resizeImageToBoundaries(v._element.src, "max"), T = URL.createObjectURL(p);
|
|
1166
|
+
t._createdBlobUrls.push(T), v = yield le.fromURL(T, {
|
|
1142
1167
|
crossOrigin: "anonymous"
|
|
1143
1168
|
});
|
|
1144
1169
|
}
|
|
1145
|
-
if (
|
|
1170
|
+
if (v.set("id", "".concat(v.type, "-").concat(w())), v.set("format", j), r === "scale-montage")
|
|
1146
1171
|
t.editor.canvasManager.scaleMontageAreaToImage({
|
|
1147
|
-
object:
|
|
1172
|
+
object: v,
|
|
1148
1173
|
withoutSave: !0
|
|
1149
1174
|
});
|
|
1150
1175
|
else {
|
|
1151
1176
|
var {
|
|
1152
|
-
width:
|
|
1153
|
-
height:
|
|
1154
|
-
} =
|
|
1155
|
-
imageObject:
|
|
1177
|
+
width: Y,
|
|
1178
|
+
height: H
|
|
1179
|
+
} = s, _ = t.calculateScaleFactor({
|
|
1180
|
+
imageObject: v,
|
|
1156
1181
|
scaleType: r
|
|
1157
1182
|
});
|
|
1158
|
-
r === "image-contain" &&
|
|
1159
|
-
object:
|
|
1183
|
+
r === "image-contain" && _ < 1 ? c.fitObject({
|
|
1184
|
+
object: v,
|
|
1160
1185
|
type: "contain",
|
|
1161
1186
|
withoutSave: !0
|
|
1162
|
-
}) : r === "image-cover" && (
|
|
1163
|
-
object:
|
|
1187
|
+
}) : r === "image-cover" && (O > Y || A > H) && c.fitObject({
|
|
1188
|
+
object: v,
|
|
1164
1189
|
type: "cover",
|
|
1165
1190
|
withoutSave: !0
|
|
1166
1191
|
});
|
|
1167
1192
|
}
|
|
1168
|
-
|
|
1169
|
-
} catch (
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1193
|
+
i.add(v), i.centerObject(v), i.setActiveObject(v), i.renderAll(), u.resumeHistory(), n || u.saveState();
|
|
1194
|
+
} catch (k) {
|
|
1195
|
+
l.emitError({
|
|
1196
|
+
origin: "ImageManager",
|
|
1197
|
+
method: "importImage",
|
|
1198
|
+
code: "IMPORT_FAILED",
|
|
1199
|
+
message: "Ошибка импорта изображения: ".concat(k.message),
|
|
1200
|
+
data: {
|
|
1201
|
+
source: a,
|
|
1202
|
+
contentType: d,
|
|
1203
|
+
scale: r,
|
|
1204
|
+
withoutSave: n
|
|
1205
|
+
}
|
|
1206
|
+
}), u.resumeHistory();
|
|
1173
1207
|
}
|
|
1174
1208
|
}
|
|
1175
1209
|
})();
|
|
@@ -1184,15 +1218,22 @@ class C {
|
|
|
1184
1218
|
*/
|
|
1185
1219
|
resizeImageToBoundaries(e) {
|
|
1186
1220
|
var t = arguments, a = this;
|
|
1187
|
-
return
|
|
1188
|
-
var r = t.length > 1 && t[1] !== void 0 ? t[1] : "max", n = "Размер изображения больше максимального размера канваса, поэтому оно будет уменьшено до максимальных размеров: ".concat(D, "x").concat(
|
|
1189
|
-
|
|
1190
|
-
|
|
1221
|
+
return E(function* () {
|
|
1222
|
+
var r = t.length > 1 && t[1] !== void 0 ? t[1] : "max", n = "Размер изображения больше максимального размера канваса, поэтому оно будет уменьшено до максимальных размеров: ".concat(D, "x").concat(L);
|
|
1223
|
+
a.editor.errorManager.emitWarning({
|
|
1224
|
+
origin: "ImageManager",
|
|
1225
|
+
method: "resizeImageToBoundaries",
|
|
1226
|
+
code: "IMAGE_RESIZE_WARNING",
|
|
1227
|
+
message: n,
|
|
1228
|
+
data: {
|
|
1229
|
+
dataURL: e,
|
|
1230
|
+
size: r
|
|
1231
|
+
}
|
|
1191
1232
|
});
|
|
1192
1233
|
var i = yield a.editor.workerManager.post("resizeImage", {
|
|
1193
1234
|
dataURL: e,
|
|
1194
1235
|
maxWidth: D,
|
|
1195
|
-
maxHeight:
|
|
1236
|
+
maxHeight: L,
|
|
1196
1237
|
sizeType: r
|
|
1197
1238
|
});
|
|
1198
1239
|
return i;
|
|
@@ -1211,7 +1252,7 @@ class C {
|
|
|
1211
1252
|
*/
|
|
1212
1253
|
exportCanvasAsImageFile() {
|
|
1213
1254
|
var e = arguments, t = this;
|
|
1214
|
-
return
|
|
1255
|
+
return E(function* () {
|
|
1215
1256
|
var {
|
|
1216
1257
|
fileName: a = "image.png",
|
|
1217
1258
|
contentType: r = "image/png",
|
|
@@ -1221,98 +1262,114 @@ class C {
|
|
|
1221
1262
|
canvas: s,
|
|
1222
1263
|
montageArea: c,
|
|
1223
1264
|
workerManager: u
|
|
1224
|
-
} = t.editor
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
var
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
var P = {
|
|
1261
|
-
image: A,
|
|
1262
|
-
format: h,
|
|
1263
|
-
contentType: d,
|
|
1264
|
-
fileName: a
|
|
1265
|
-
};
|
|
1266
|
-
return s.fire("editor:canvas-exported", P), P;
|
|
1267
|
-
}
|
|
1268
|
-
var E = yield createImageBitmap(A), re = yield u.post("toDataURL", {
|
|
1269
|
-
format: h,
|
|
1270
|
-
quality: 1,
|
|
1271
|
-
bitmap: E
|
|
1272
|
-
}, [E]);
|
|
1273
|
-
if (l) {
|
|
1274
|
-
var ne = 0.264583, W = f * ne, _ = y * ne, we = (yield t.editor.moduleLoader.loadModule("jspdf")).jsPDF, R = new we({
|
|
1275
|
-
orientation: W > _ ? "landscape" : "portrait",
|
|
1276
|
-
unit: "mm",
|
|
1277
|
-
format: [W, _]
|
|
1265
|
+
} = t.editor;
|
|
1266
|
+
try {
|
|
1267
|
+
var l = r === "application/pdf", d = l ? "image/jpg" : r, h = S.getFormatFromContentType(d);
|
|
1268
|
+
c.setCoords();
|
|
1269
|
+
var {
|
|
1270
|
+
left: g,
|
|
1271
|
+
top: f,
|
|
1272
|
+
width: m,
|
|
1273
|
+
height: v
|
|
1274
|
+
} = c.getBoundingRect(), M = yield s.clone(["id", "format", "locked"]);
|
|
1275
|
+
["image/jpg", "image/jpeg"].includes(d) && (M.backgroundColor = "#ffffff");
|
|
1276
|
+
var C = M.getObjects().find((b) => b.id === c.id);
|
|
1277
|
+
C.visible = !1, M.viewportTransform = [1, 0, 0, 1, -g, -f], M.setDimensions({
|
|
1278
|
+
width: m,
|
|
1279
|
+
height: v
|
|
1280
|
+
}, {
|
|
1281
|
+
backstoreOnly: !0
|
|
1282
|
+
}), M.renderAll();
|
|
1283
|
+
var j = M.getObjects().filter((b) => b.format).every((b) => b.format === "svg");
|
|
1284
|
+
if (h === "svg" && j) {
|
|
1285
|
+
var N = M.toSVG();
|
|
1286
|
+
M.dispose();
|
|
1287
|
+
var O = S._exportSVGStringAsFile(N, {
|
|
1288
|
+
exportAsBase64: n,
|
|
1289
|
+
exportAsBlob: i,
|
|
1290
|
+
fileName: a
|
|
1291
|
+
}), A = {
|
|
1292
|
+
image: O,
|
|
1293
|
+
format: "svg",
|
|
1294
|
+
contentType: "image/svg+xml",
|
|
1295
|
+
fileName: a.replace(/\.[^/.]+$/, ".svg")
|
|
1296
|
+
};
|
|
1297
|
+
return s.fire("editor:canvas-exported", A), A;
|
|
1298
|
+
}
|
|
1299
|
+
var p = yield new Promise((b) => {
|
|
1300
|
+
M.getElement().toBlob(b);
|
|
1278
1301
|
});
|
|
1279
|
-
if (
|
|
1280
|
-
var
|
|
1281
|
-
image:
|
|
1302
|
+
if (M.dispose(), i) {
|
|
1303
|
+
var T = {
|
|
1304
|
+
image: p,
|
|
1305
|
+
format: h,
|
|
1306
|
+
contentType: d,
|
|
1307
|
+
fileName: a
|
|
1308
|
+
};
|
|
1309
|
+
return s.fire("editor:canvas-exported", T), T;
|
|
1310
|
+
}
|
|
1311
|
+
var Y = yield createImageBitmap(p), H = yield u.post("toDataURL", {
|
|
1312
|
+
format: h,
|
|
1313
|
+
quality: 1,
|
|
1314
|
+
bitmap: Y
|
|
1315
|
+
}, [Y]);
|
|
1316
|
+
if (l) {
|
|
1317
|
+
var _ = 0.264583, k = m * _, V = v * _, Ce = (yield t.editor.moduleLoader.loadModule("jspdf")).jsPDF, G = new Ce({
|
|
1318
|
+
orientation: k > V ? "landscape" : "portrait",
|
|
1319
|
+
unit: "mm",
|
|
1320
|
+
format: [k, V]
|
|
1321
|
+
});
|
|
1322
|
+
if (G.addImage(H, "JPG", 0, 0, k, V), n) {
|
|
1323
|
+
var Ne = G.output("datauristring"), oe = {
|
|
1324
|
+
image: Ne,
|
|
1325
|
+
format: "pdf",
|
|
1326
|
+
contentType: "application/pdf",
|
|
1327
|
+
fileName: a
|
|
1328
|
+
};
|
|
1329
|
+
return s.fire("editor:canvas-exported", oe), oe;
|
|
1330
|
+
}
|
|
1331
|
+
var De = G.output("blob"), Le = new File([De], a, {
|
|
1332
|
+
type: "application/pdf"
|
|
1333
|
+
}), se = {
|
|
1334
|
+
image: Le,
|
|
1282
1335
|
format: "pdf",
|
|
1283
1336
|
contentType: "application/pdf",
|
|
1284
1337
|
fileName: a
|
|
1285
1338
|
};
|
|
1286
|
-
return s.fire("editor:canvas-exported",
|
|
1339
|
+
return s.fire("editor:canvas-exported", se), se;
|
|
1287
1340
|
}
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
image:
|
|
1341
|
+
if (n) {
|
|
1342
|
+
var ce = {
|
|
1343
|
+
image: H,
|
|
1344
|
+
format: h,
|
|
1345
|
+
contentType: d,
|
|
1346
|
+
fileName: a
|
|
1347
|
+
};
|
|
1348
|
+
return s.fire("editor:canvas-exported", ce), ce;
|
|
1349
|
+
}
|
|
1350
|
+
var ue = h === "svg" && !j ? a.replace(/\.[^/.]+$/, ".png") : a, Oe = new File([p], ue, {
|
|
1351
|
+
type: d
|
|
1352
|
+
}), de = {
|
|
1353
|
+
image: Oe,
|
|
1301
1354
|
format: h,
|
|
1302
1355
|
contentType: d,
|
|
1303
|
-
fileName:
|
|
1356
|
+
fileName: ue
|
|
1304
1357
|
};
|
|
1305
|
-
return s.fire("editor:canvas-exported",
|
|
1358
|
+
return s.fire("editor:canvas-exported", de), de;
|
|
1359
|
+
} catch (b) {
|
|
1360
|
+
return t.editor.errorManager.emitError({
|
|
1361
|
+
origin: "ImageManager",
|
|
1362
|
+
method: "exportCanvasAsImageFile",
|
|
1363
|
+
code: "IMAGE_EXPORT_FAILED",
|
|
1364
|
+
message: "Ошибка экспорта изображения: ".concat(b.message),
|
|
1365
|
+
data: {
|
|
1366
|
+
contentType: r,
|
|
1367
|
+
fileName: a,
|
|
1368
|
+
exportAsBase64: n,
|
|
1369
|
+
exportAsBlob: i
|
|
1370
|
+
}
|
|
1371
|
+
}), "";
|
|
1306
1372
|
}
|
|
1307
|
-
var ce = h === "svg" && !M ? a.replace(/\.[^/.]+$/, ".png") : a, Le = new File([A], ce, {
|
|
1308
|
-
type: d
|
|
1309
|
-
}), ue = {
|
|
1310
|
-
image: Le,
|
|
1311
|
-
format: h,
|
|
1312
|
-
contentType: d,
|
|
1313
|
-
fileName: ce
|
|
1314
|
-
};
|
|
1315
|
-
return s.fire("editor:canvas-exported", ue), ue;
|
|
1316
1373
|
})();
|
|
1317
1374
|
}
|
|
1318
1375
|
/**
|
|
@@ -1328,7 +1385,7 @@ class C {
|
|
|
1328
1385
|
*/
|
|
1329
1386
|
exportObjectAsImageFile() {
|
|
1330
1387
|
var e = arguments, t = this;
|
|
1331
|
-
return
|
|
1388
|
+
return E(function* () {
|
|
1332
1389
|
var {
|
|
1333
1390
|
object: a,
|
|
1334
1391
|
fileName: r = "image.png",
|
|
@@ -1340,57 +1397,81 @@ class C {
|
|
|
1340
1397
|
workerManager: u
|
|
1341
1398
|
} = t.editor, l = a || c.getActiveObject();
|
|
1342
1399
|
if (!l)
|
|
1343
|
-
return
|
|
1344
|
-
|
|
1400
|
+
return t.editor.errorManager.emitError({
|
|
1401
|
+
origin: "ImageManager",
|
|
1402
|
+
method: "exportObjectAsImageFile",
|
|
1403
|
+
code: "NO_OBJECT_SELECTED",
|
|
1404
|
+
message: "Не выбран объект для экспорта",
|
|
1405
|
+
data: {
|
|
1406
|
+
contentType: n,
|
|
1407
|
+
fileName: r,
|
|
1408
|
+
exportAsBase64: i,
|
|
1409
|
+
exportAsBlob: s
|
|
1410
|
+
}
|
|
1345
1411
|
}), "";
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1412
|
+
try {
|
|
1413
|
+
var d = S.getFormatFromContentType(n);
|
|
1414
|
+
if (d === "svg") {
|
|
1415
|
+
var h = l.toSVG(), g = t._exportSVGStringAsFile(h, {
|
|
1416
|
+
exportAsBase64: i,
|
|
1417
|
+
exportAsBlob: s,
|
|
1418
|
+
fileName: r
|
|
1419
|
+
}), f = {
|
|
1420
|
+
image: g,
|
|
1421
|
+
format: d,
|
|
1422
|
+
contentType: "image/svg+xml",
|
|
1423
|
+
fileName: r.replace(/\.[^/.]+$/, ".svg")
|
|
1424
|
+
};
|
|
1425
|
+
return c.fire("editor:object-exported", f), f;
|
|
1426
|
+
}
|
|
1427
|
+
if (i) {
|
|
1428
|
+
var m = yield createImageBitmap(l._element), v = yield u.post("toDataURL", {
|
|
1429
|
+
format: d,
|
|
1430
|
+
quality: 1,
|
|
1431
|
+
bitmap: m
|
|
1432
|
+
}, [m]), M = {
|
|
1433
|
+
image: v,
|
|
1434
|
+
format: d,
|
|
1435
|
+
contentType: n,
|
|
1436
|
+
fileName: r
|
|
1437
|
+
};
|
|
1438
|
+
return c.fire("editor:object-exported", M), M;
|
|
1439
|
+
}
|
|
1440
|
+
var C = l.toCanvasElement(), j = yield new Promise((p) => {
|
|
1441
|
+
C.toBlob(p);
|
|
1442
|
+
});
|
|
1443
|
+
if (s) {
|
|
1444
|
+
var N = {
|
|
1445
|
+
image: j,
|
|
1446
|
+
format: d,
|
|
1447
|
+
contentType: n,
|
|
1448
|
+
fileName: r
|
|
1449
|
+
};
|
|
1450
|
+
return c.fire("editor:object-exported", N), N;
|
|
1451
|
+
}
|
|
1452
|
+
var O = new File([j], r, {
|
|
1453
|
+
type: n
|
|
1454
|
+
}), A = {
|
|
1455
|
+
image: O,
|
|
1379
1456
|
format: d,
|
|
1380
1457
|
contentType: n,
|
|
1381
1458
|
fileName: r
|
|
1382
1459
|
};
|
|
1383
|
-
return c.fire("editor:object-exported",
|
|
1460
|
+
return c.fire("editor:object-exported", A), A;
|
|
1461
|
+
} catch (p) {
|
|
1462
|
+
return t.editor.errorManager.emitError({
|
|
1463
|
+
origin: "ImageManager",
|
|
1464
|
+
method: "exportObjectAsImageFile",
|
|
1465
|
+
code: "IMAGE_EXPORT_FAILED",
|
|
1466
|
+
message: "Ошибка экспорта объекта: ".concat(p.message),
|
|
1467
|
+
data: {
|
|
1468
|
+
contentType: n,
|
|
1469
|
+
fileName: r,
|
|
1470
|
+
exportAsBase64: i,
|
|
1471
|
+
exportAsBlob: s
|
|
1472
|
+
}
|
|
1473
|
+
}), "";
|
|
1384
1474
|
}
|
|
1385
|
-
var O = new File([M], r, {
|
|
1386
|
-
type: n
|
|
1387
|
-
}), S = {
|
|
1388
|
-
image: O,
|
|
1389
|
-
format: d,
|
|
1390
|
-
contentType: n,
|
|
1391
|
-
fileName: r
|
|
1392
|
-
};
|
|
1393
|
-
return c.fire("editor:object-exported", S), S;
|
|
1394
1475
|
})();
|
|
1395
1476
|
}
|
|
1396
1477
|
/**
|
|
@@ -1423,6 +1504,13 @@ class C {
|
|
|
1423
1504
|
type: "image/svg+xml"
|
|
1424
1505
|
});
|
|
1425
1506
|
}
|
|
1507
|
+
/**
|
|
1508
|
+
* Получает список допустимых форматов изображений
|
|
1509
|
+
* @returns {string[]} - массив допустимых форматов изображений
|
|
1510
|
+
*/
|
|
1511
|
+
getAllowedFormatsFromContentTypes() {
|
|
1512
|
+
return this.acceptContentTypes.map((e) => S.getFormatFromContentType(e)).filter((e) => e);
|
|
1513
|
+
}
|
|
1426
1514
|
/**
|
|
1427
1515
|
* Извлекает чистый формат (subtype) из contentType,
|
|
1428
1516
|
* отбросив любую часть после «+» или «;»
|
|
@@ -1440,21 +1528,8 @@ class C {
|
|
|
1440
1528
|
* @returns {boolean} true, если contentType допустим, иначе false
|
|
1441
1529
|
*/
|
|
1442
1530
|
isAllowedContentType() {
|
|
1443
|
-
var e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : ""
|
|
1444
|
-
|
|
1445
|
-
} = this.editor.options;
|
|
1446
|
-
return t.includes(e);
|
|
1447
|
-
}
|
|
1448
|
-
/**
|
|
1449
|
-
* Проверяет, является ли формат допустимым.
|
|
1450
|
-
* @param {string} format - формат изображения, например 'png', 'jpeg', 'svg'
|
|
1451
|
-
* @returns {boolean} true, если формат допустим, иначе false
|
|
1452
|
-
*/
|
|
1453
|
-
isAllowedFormat() {
|
|
1454
|
-
var e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "", {
|
|
1455
|
-
acceptContentTypes: t
|
|
1456
|
-
} = this.editor.options, a = "image/".concat(e);
|
|
1457
|
-
return t.includes(a);
|
|
1531
|
+
var e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "";
|
|
1532
|
+
return this.acceptContentTypes.includes(e);
|
|
1458
1533
|
}
|
|
1459
1534
|
/**
|
|
1460
1535
|
* Получает contentType изображения из источника
|
|
@@ -1464,7 +1539,7 @@ class C {
|
|
|
1464
1539
|
*/
|
|
1465
1540
|
getContentType(e) {
|
|
1466
1541
|
var t = this;
|
|
1467
|
-
return
|
|
1542
|
+
return E(function* () {
|
|
1468
1543
|
return typeof e == "string" ? t.getContentTypeFromUrl(e) : e.type || "application/octet-stream";
|
|
1469
1544
|
})();
|
|
1470
1545
|
}
|
|
@@ -1476,7 +1551,7 @@ class C {
|
|
|
1476
1551
|
*/
|
|
1477
1552
|
getContentTypeFromUrl(e) {
|
|
1478
1553
|
var t = this;
|
|
1479
|
-
return
|
|
1554
|
+
return E(function* () {
|
|
1480
1555
|
if (e.startsWith("data:")) {
|
|
1481
1556
|
var a = e.match(/^data:([^;]+)/);
|
|
1482
1557
|
return a ? a[1] : "application/octet-stream";
|
|
@@ -1501,15 +1576,13 @@ class C {
|
|
|
1501
1576
|
*/
|
|
1502
1577
|
getContentTypeFromExtension(e) {
|
|
1503
1578
|
try {
|
|
1504
|
-
var t, {
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
} catch (s) {
|
|
1512
|
-
return console.warn("Не удалось определить расширение из URL:", e, s), "application/octet-stream";
|
|
1579
|
+
var t, a = new URL(e), r = (t = a.pathname.split(".").pop()) === null || t === void 0 ? void 0 : t.toLowerCase(), n = {};
|
|
1580
|
+
return this.acceptContentTypes.forEach((i) => {
|
|
1581
|
+
var s = S.getFormatFromContentType(i);
|
|
1582
|
+
s && (n[s] = i);
|
|
1583
|
+
}), n[r] || "application/octet-stream";
|
|
1584
|
+
} catch (i) {
|
|
1585
|
+
return console.warn("Не удалось определить расширение из URL:", e, i), "application/octet-stream";
|
|
1513
1586
|
}
|
|
1514
1587
|
}
|
|
1515
1588
|
/**
|
|
@@ -1533,7 +1606,7 @@ class C {
|
|
|
1533
1606
|
return a === "contain" || a === "image-contain" ? Math.min(n / s, i / c) : a === "cover" || a === "image-cover" ? Math.max(n / s, i / c) : 1;
|
|
1534
1607
|
}
|
|
1535
1608
|
}
|
|
1536
|
-
class
|
|
1609
|
+
class jt {
|
|
1537
1610
|
/**
|
|
1538
1611
|
* @param {object} options
|
|
1539
1612
|
* @param {ImageEditor} options.editor – экземпляр редактора
|
|
@@ -1568,7 +1641,7 @@ class Mt {
|
|
|
1568
1641
|
} = this.editor, {
|
|
1569
1642
|
width: c,
|
|
1570
1643
|
height: u
|
|
1571
|
-
} = i, l = Number(Math.max(Math.min(e, D),
|
|
1644
|
+
} = i, l = Number(Math.max(Math.min(e, D), B));
|
|
1572
1645
|
if (!s || s === "auto" || r ? this.adaptCanvasToContainer() : s ? this.setCanvasBackstoreWidth(s) : this.setCanvasBackstoreWidth(l), i.set({
|
|
1573
1646
|
width: l
|
|
1574
1647
|
}), n.clipPath.set({
|
|
@@ -1580,9 +1653,9 @@ class Mt {
|
|
|
1580
1653
|
}
|
|
1581
1654
|
var {
|
|
1582
1655
|
left: g,
|
|
1583
|
-
top:
|
|
1584
|
-
} = this.getObjectDefaultCoords(i),
|
|
1585
|
-
n.setViewportTransform([
|
|
1656
|
+
top: f
|
|
1657
|
+
} = this.getObjectDefaultCoords(i), m = n.getZoom();
|
|
1658
|
+
n.setViewportTransform([m, 0, 0, m, g, f]), this.centerMontageArea(), a || this.editor.historyManager.saveState(), n == null || n.fire("editor:resolution-width-changed", {
|
|
1586
1659
|
width: e
|
|
1587
1660
|
});
|
|
1588
1661
|
}
|
|
@@ -1611,7 +1684,7 @@ class Mt {
|
|
|
1611
1684
|
} = this.editor, {
|
|
1612
1685
|
width: c,
|
|
1613
1686
|
height: u
|
|
1614
|
-
} = i, l = Number(Math.max(Math.min(e,
|
|
1687
|
+
} = i, l = Number(Math.max(Math.min(e, L), Z));
|
|
1615
1688
|
if (!s || s === "auto" || r ? this.adaptCanvasToContainer() : s ? this.setCanvasBackstoreHeight(s) : this.setCanvasBackstoreHeight(l), i.set({
|
|
1616
1689
|
height: l
|
|
1617
1690
|
}), n.clipPath.set({
|
|
@@ -1623,9 +1696,9 @@ class Mt {
|
|
|
1623
1696
|
}
|
|
1624
1697
|
var {
|
|
1625
1698
|
left: g,
|
|
1626
|
-
top:
|
|
1627
|
-
} = this.getObjectDefaultCoords(i),
|
|
1628
|
-
n.setViewportTransform([
|
|
1699
|
+
top: f
|
|
1700
|
+
} = this.getObjectDefaultCoords(i), m = n.getZoom();
|
|
1701
|
+
n.setViewportTransform([m, 0, 0, m, g, f]), this.centerMontageArea(), a || this.editor.historyManager.saveState(), n == null || n.fire("editor:resolution-height-changed", {
|
|
1629
1702
|
height: e
|
|
1630
1703
|
});
|
|
1631
1704
|
}
|
|
@@ -1638,7 +1711,7 @@ class Mt {
|
|
|
1638
1711
|
var {
|
|
1639
1712
|
canvas: e,
|
|
1640
1713
|
montageArea: t
|
|
1641
|
-
} = this.editor, a = e.getWidth(), r = e.getHeight(), n = e.getZoom(), i = new
|
|
1714
|
+
} = this.editor, a = e.getWidth(), r = e.getHeight(), n = e.getZoom(), i = new xe(a / 2, r / 2);
|
|
1642
1715
|
t.set({
|
|
1643
1716
|
left: a / 2,
|
|
1644
1717
|
top: r / 2
|
|
@@ -1673,7 +1746,7 @@ class Mt {
|
|
|
1673
1746
|
}
|
|
1674
1747
|
setCanvasBackstoreWidth(e) {
|
|
1675
1748
|
if (!(!e || typeof e != "number")) {
|
|
1676
|
-
var t = Math.max(Math.min(e, D),
|
|
1749
|
+
var t = Math.max(Math.min(e, D), B);
|
|
1677
1750
|
this.editor.canvas.setDimensions({
|
|
1678
1751
|
width: t
|
|
1679
1752
|
}, {
|
|
@@ -1683,7 +1756,7 @@ class Mt {
|
|
|
1683
1756
|
}
|
|
1684
1757
|
setCanvasBackstoreHeight(e) {
|
|
1685
1758
|
if (!(!e || typeof e != "number")) {
|
|
1686
|
-
var t = Math.max(Math.min(e,
|
|
1759
|
+
var t = Math.max(Math.min(e, L), Z);
|
|
1687
1760
|
this.editor.canvas.setDimensions({
|
|
1688
1761
|
height: t
|
|
1689
1762
|
}, {
|
|
@@ -1694,7 +1767,7 @@ class Mt {
|
|
|
1694
1767
|
adaptCanvasToContainer() {
|
|
1695
1768
|
var {
|
|
1696
1769
|
canvas: e
|
|
1697
|
-
} = this.editor, t = e.editorContainer, a = t.clientWidth, r = t.clientHeight, n = Math.max(Math.min(a, D),
|
|
1770
|
+
} = this.editor, t = e.editorContainer, a = t.clientWidth, r = t.clientHeight, n = Math.max(Math.min(a, D), B), i = Math.max(Math.min(r, L), Z);
|
|
1698
1771
|
console.log("adaptCanvasToContainer newWidth", n), console.log("adaptCanvasToContainer newHeight", i), e.setDimensions({
|
|
1699
1772
|
width: n,
|
|
1700
1773
|
height: i
|
|
@@ -1855,29 +1928,29 @@ class Mt {
|
|
|
1855
1928
|
width: l,
|
|
1856
1929
|
height: d
|
|
1857
1930
|
} = u;
|
|
1858
|
-
if (l <
|
|
1859
|
-
var h = "Размер изображения меньше минимального размера канваса, поэтому оно будет растянуто до минимальных размеров: ".concat(
|
|
1931
|
+
if (l < B || d < Z) {
|
|
1932
|
+
var h = "Размер изображения меньше минимального размера канваса, поэтому оно будет растянуто до минимальных размеров: ".concat(B, "x").concat(Z);
|
|
1860
1933
|
console.warn("scaleMontageAreaToImage. ".concat(h)), r.fire("editor:warning", {
|
|
1861
1934
|
message: h
|
|
1862
1935
|
});
|
|
1863
1936
|
}
|
|
1864
|
-
var g = Math.min(l, D),
|
|
1937
|
+
var g = Math.min(l, D), f = Math.min(d, L);
|
|
1865
1938
|
if (t) {
|
|
1866
1939
|
var {
|
|
1867
|
-
width:
|
|
1868
|
-
height:
|
|
1869
|
-
} = n,
|
|
1870
|
-
g =
|
|
1940
|
+
width: m,
|
|
1941
|
+
height: v
|
|
1942
|
+
} = n, M = l / m, C = d / v, j = Math.max(M, C);
|
|
1943
|
+
g = m * j, f = v * j;
|
|
1871
1944
|
}
|
|
1872
1945
|
this.setResolutionWidth(g, {
|
|
1873
1946
|
withoutSave: !0
|
|
1874
|
-
}), this.setResolutionHeight(
|
|
1947
|
+
}), this.setResolutionHeight(f, {
|
|
1875
1948
|
withoutSave: !0
|
|
1876
1949
|
}), (l > s || d > c) && i.calculateAndApplyDefaultZoom(s, c), i.resetObject(u, {
|
|
1877
1950
|
withoutSave: !0
|
|
1878
1951
|
}), r.centerObject(u), r.renderAll(), a || this.editor.historyManager.saveState(), r.fire("editor:canvas-scaled", {
|
|
1879
1952
|
width: g,
|
|
1880
|
-
height:
|
|
1953
|
+
height: f
|
|
1881
1954
|
});
|
|
1882
1955
|
}
|
|
1883
1956
|
}
|
|
@@ -1932,7 +2005,7 @@ class Mt {
|
|
|
1932
2005
|
return r.filter((n) => n.id !== t.id && n.id !== a.id);
|
|
1933
2006
|
}
|
|
1934
2007
|
}
|
|
1935
|
-
class
|
|
2008
|
+
class yt {
|
|
1936
2009
|
/**
|
|
1937
2010
|
* @param {object} options
|
|
1938
2011
|
* @param {ImageEditor} options.editor - экземпляр редактора с доступом к canvas
|
|
@@ -1971,7 +2044,7 @@ class jt {
|
|
|
1971
2044
|
* Если передавать координаты курсора, то нужно быть аккуратнее, так как юзер может выйти за пределы рабочей области
|
|
1972
2045
|
*/
|
|
1973
2046
|
zoom() {
|
|
1974
|
-
var e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] :
|
|
2047
|
+
var e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : ft, t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
1975
2048
|
if (e) {
|
|
1976
2049
|
var {
|
|
1977
2050
|
canvas: a,
|
|
@@ -2043,7 +2116,7 @@ class jt {
|
|
|
2043
2116
|
* @fires editor:object-rotated
|
|
2044
2117
|
*/
|
|
2045
2118
|
rotate() {
|
|
2046
|
-
var e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] :
|
|
2119
|
+
var e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : Mt, {
|
|
2047
2120
|
withoutSave: t
|
|
2048
2121
|
} = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, {
|
|
2049
2122
|
canvas: a,
|
|
@@ -2136,7 +2209,7 @@ class jt {
|
|
|
2136
2209
|
});
|
|
2137
2210
|
h.scale(g), n.centerObject(h);
|
|
2138
2211
|
});
|
|
2139
|
-
var l = new
|
|
2212
|
+
var l = new P(u, {
|
|
2140
2213
|
canvas: n
|
|
2141
2214
|
});
|
|
2142
2215
|
n.setActiveObject(l);
|
|
@@ -2199,11 +2272,11 @@ class jt {
|
|
|
2199
2272
|
} = n, {
|
|
2200
2273
|
width: h,
|
|
2201
2274
|
height: g
|
|
2202
|
-
} = u,
|
|
2275
|
+
} = u, f = i.calculateScaleFactor({
|
|
2203
2276
|
imageObject: u,
|
|
2204
2277
|
scaleType: c
|
|
2205
2278
|
});
|
|
2206
|
-
c === "contain" &&
|
|
2279
|
+
c === "contain" && f < 1 || c === "cover" && (h > l || g > d) ? this.fitObject({
|
|
2207
2280
|
object: u,
|
|
2208
2281
|
withoutSave: !0
|
|
2209
2282
|
}) : u.set({
|
|
@@ -2219,7 +2292,7 @@ class jt {
|
|
|
2219
2292
|
}
|
|
2220
2293
|
}
|
|
2221
2294
|
}
|
|
2222
|
-
class
|
|
2295
|
+
class pt {
|
|
2223
2296
|
/**
|
|
2224
2297
|
* @param {object} options
|
|
2225
2298
|
* @param {ImageEditor} options.editor – экземпляр редактора
|
|
@@ -2319,7 +2392,7 @@ class yt {
|
|
|
2319
2392
|
}
|
|
2320
2393
|
}
|
|
2321
2394
|
}
|
|
2322
|
-
class
|
|
2395
|
+
class W {
|
|
2323
2396
|
/**
|
|
2324
2397
|
* @param {object} options
|
|
2325
2398
|
* @param {ImageEditor} options.editor - экземпляр редактора с доступом к canvas
|
|
@@ -2366,7 +2439,7 @@ class H {
|
|
|
2366
2439
|
} = this.editor;
|
|
2367
2440
|
r.suspendHistory();
|
|
2368
2441
|
var n = e || a.getActiveObject();
|
|
2369
|
-
n && (n.type === "activeselection" ?
|
|
2442
|
+
n && (n.type === "activeselection" ? W._moveSelectionForward(a, n) : a.bringObjectForward(n), a.renderAll(), r.resumeHistory(), t || r.saveState(), a.fire("editor:object-bring-forward"));
|
|
2370
2443
|
}
|
|
2371
2444
|
/**
|
|
2372
2445
|
* Отправить объект на задний план по оси Z
|
|
@@ -2416,7 +2489,7 @@ class H {
|
|
|
2416
2489
|
} = this.editor;
|
|
2417
2490
|
n.suspendHistory();
|
|
2418
2491
|
var s = e || a.getActiveObject();
|
|
2419
|
-
s && (s.type === "activeselection" ?
|
|
2492
|
+
s && (s.type === "activeselection" ? W._moveSelectionBackwards(a, s) : a.sendObjectBackwards(s), a.sendObjectToBack(r), a.sendObjectToBack(i), a.renderAll(), n.resumeHistory(), t || n.saveState(), a.fire("editor:object-send-backwards"));
|
|
2420
2493
|
}
|
|
2421
2494
|
/**
|
|
2422
2495
|
* Сдвигает выделенные объекты на один уровень вверх относительно ближайшего верхнего объекта
|
|
@@ -2455,8 +2528,8 @@ class H {
|
|
|
2455
2528
|
e.moveObjectTo(r[i], n - 1);
|
|
2456
2529
|
}
|
|
2457
2530
|
}
|
|
2458
|
-
var
|
|
2459
|
-
function
|
|
2531
|
+
var bt = ["id", "left", "top", "width", "height", "fill"], It = ["id", "left", "top", "radius", "fill"], At = ["id", "left", "top", "width", "height", "fill"];
|
|
2532
|
+
function ye(o, e) {
|
|
2460
2533
|
var t = Object.keys(o);
|
|
2461
2534
|
if (Object.getOwnPropertySymbols) {
|
|
2462
2535
|
var a = Object.getOwnPropertySymbols(o);
|
|
@@ -2466,25 +2539,25 @@ function je(o, e) {
|
|
|
2466
2539
|
}
|
|
2467
2540
|
return t;
|
|
2468
2541
|
}
|
|
2469
|
-
function
|
|
2542
|
+
function Q(o) {
|
|
2470
2543
|
for (var e = 1; e < arguments.length; e++) {
|
|
2471
2544
|
var t = arguments[e] != null ? arguments[e] : {};
|
|
2472
|
-
e % 2 ?
|
|
2545
|
+
e % 2 ? ye(Object(t), !0).forEach(function(a) {
|
|
2473
2546
|
St(o, a, t[a]);
|
|
2474
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(o, Object.getOwnPropertyDescriptors(t)) :
|
|
2547
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(o, Object.getOwnPropertyDescriptors(t)) : ye(Object(t)).forEach(function(a) {
|
|
2475
2548
|
Object.defineProperty(o, a, Object.getOwnPropertyDescriptor(t, a));
|
|
2476
2549
|
});
|
|
2477
2550
|
}
|
|
2478
2551
|
return o;
|
|
2479
2552
|
}
|
|
2480
2553
|
function St(o, e, t) {
|
|
2481
|
-
return (e =
|
|
2554
|
+
return (e = wt(e)) in o ? Object.defineProperty(o, e, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : o[e] = t, o;
|
|
2482
2555
|
}
|
|
2483
|
-
function
|
|
2484
|
-
var e =
|
|
2556
|
+
function wt(o) {
|
|
2557
|
+
var e = Ct(o, "string");
|
|
2485
2558
|
return typeof e == "symbol" ? e : e + "";
|
|
2486
2559
|
}
|
|
2487
|
-
function
|
|
2560
|
+
function Ct(o, e) {
|
|
2488
2561
|
if (typeof o != "object" || !o) return o;
|
|
2489
2562
|
var t = o[Symbol.toPrimitive];
|
|
2490
2563
|
if (t !== void 0) {
|
|
@@ -2494,16 +2567,16 @@ function wt(o, e) {
|
|
|
2494
2567
|
}
|
|
2495
2568
|
return (e === "string" ? String : Number)(o);
|
|
2496
2569
|
}
|
|
2497
|
-
function
|
|
2570
|
+
function J(o, e) {
|
|
2498
2571
|
if (o == null) return {};
|
|
2499
|
-
var t, a, r =
|
|
2572
|
+
var t, a, r = Nt(o, e);
|
|
2500
2573
|
if (Object.getOwnPropertySymbols) {
|
|
2501
2574
|
var n = Object.getOwnPropertySymbols(o);
|
|
2502
2575
|
for (a = 0; a < n.length; a++) t = n[a], e.indexOf(t) === -1 && {}.propertyIsEnumerable.call(o, t) && (r[t] = o[t]);
|
|
2503
2576
|
}
|
|
2504
2577
|
return r;
|
|
2505
2578
|
}
|
|
2506
|
-
function
|
|
2579
|
+
function Nt(o, e) {
|
|
2507
2580
|
if (o == null) return {};
|
|
2508
2581
|
var t = {};
|
|
2509
2582
|
for (var a in o) if ({}.hasOwnProperty.call(o, a)) {
|
|
@@ -2540,18 +2613,18 @@ class Dt {
|
|
|
2540
2613
|
*/
|
|
2541
2614
|
addRectangle() {
|
|
2542
2615
|
var e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, {
|
|
2543
|
-
id: t = "rect-".concat(
|
|
2616
|
+
id: t = "rect-".concat(w()),
|
|
2544
2617
|
left: a,
|
|
2545
2618
|
top: r,
|
|
2546
2619
|
width: n = 100,
|
|
2547
2620
|
height: i = 100,
|
|
2548
2621
|
fill: s = "blue"
|
|
2549
|
-
} = e, c =
|
|
2622
|
+
} = e, c = J(e, bt), {
|
|
2550
2623
|
withoutSelection: u,
|
|
2551
2624
|
withoutAdding: l
|
|
2552
2625
|
} = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, {
|
|
2553
2626
|
canvas: d
|
|
2554
|
-
} = this.editor, h = new
|
|
2627
|
+
} = this.editor, h = new Be(Q({
|
|
2555
2628
|
id: t,
|
|
2556
2629
|
left: a,
|
|
2557
2630
|
top: r,
|
|
@@ -2577,17 +2650,17 @@ class Dt {
|
|
|
2577
2650
|
*/
|
|
2578
2651
|
addCircle() {
|
|
2579
2652
|
var e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, {
|
|
2580
|
-
id: t = "circle-".concat(
|
|
2653
|
+
id: t = "circle-".concat(w()),
|
|
2581
2654
|
left: a,
|
|
2582
2655
|
top: r,
|
|
2583
2656
|
radius: n = 50,
|
|
2584
2657
|
fill: i = "green"
|
|
2585
|
-
} = e, s =
|
|
2658
|
+
} = e, s = J(e, It), {
|
|
2586
2659
|
withoutSelection: c,
|
|
2587
2660
|
withoutAdding: u
|
|
2588
2661
|
} = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, {
|
|
2589
2662
|
canvas: l
|
|
2590
|
-
} = this.editor, d = new
|
|
2663
|
+
} = this.editor, d = new Ze(Q({
|
|
2591
2664
|
id: t,
|
|
2592
2665
|
left: a,
|
|
2593
2666
|
top: r,
|
|
@@ -2613,18 +2686,18 @@ class Dt {
|
|
|
2613
2686
|
*/
|
|
2614
2687
|
addTriangle() {
|
|
2615
2688
|
var e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, {
|
|
2616
|
-
id: t = "triangle-".concat(
|
|
2689
|
+
id: t = "triangle-".concat(w()),
|
|
2617
2690
|
left: a,
|
|
2618
2691
|
top: r,
|
|
2619
2692
|
width: n = 100,
|
|
2620
2693
|
height: i = 100,
|
|
2621
2694
|
fill: s = "yellow"
|
|
2622
|
-
} = e, c =
|
|
2695
|
+
} = e, c = J(e, At), {
|
|
2623
2696
|
withoutSelection: u,
|
|
2624
2697
|
withoutAdding: l
|
|
2625
2698
|
} = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, {
|
|
2626
2699
|
canvas: d
|
|
2627
|
-
} = this.editor, h = new
|
|
2700
|
+
} = this.editor, h = new ze(Q({
|
|
2628
2701
|
id: t,
|
|
2629
2702
|
left: a,
|
|
2630
2703
|
top: r,
|
|
@@ -2635,7 +2708,7 @@ class Dt {
|
|
|
2635
2708
|
return !a && !r && d.centerObject(h), l || (d.add(h), u || d.setActiveObject(h), d.renderAll()), h;
|
|
2636
2709
|
}
|
|
2637
2710
|
}
|
|
2638
|
-
function
|
|
2711
|
+
function pe(o, e, t, a, r, n, i) {
|
|
2639
2712
|
try {
|
|
2640
2713
|
var s = o[n](i), c = s.value;
|
|
2641
2714
|
} catch (u) {
|
|
@@ -2643,22 +2716,22 @@ function ye(o, e, t, a, r, n, i) {
|
|
|
2643
2716
|
}
|
|
2644
2717
|
s.done ? e(c) : Promise.resolve(c).then(a, r);
|
|
2645
2718
|
}
|
|
2646
|
-
function
|
|
2719
|
+
function be(o) {
|
|
2647
2720
|
return function() {
|
|
2648
2721
|
var e = this, t = arguments;
|
|
2649
2722
|
return new Promise(function(a, r) {
|
|
2650
2723
|
var n = o.apply(e, t);
|
|
2651
2724
|
function i(c) {
|
|
2652
|
-
|
|
2725
|
+
pe(n, a, r, i, s, "next", c);
|
|
2653
2726
|
}
|
|
2654
2727
|
function s(c) {
|
|
2655
|
-
|
|
2728
|
+
pe(n, a, r, i, s, "throw", c);
|
|
2656
2729
|
}
|
|
2657
2730
|
i(void 0);
|
|
2658
2731
|
});
|
|
2659
2732
|
};
|
|
2660
2733
|
}
|
|
2661
|
-
class
|
|
2734
|
+
class Lt {
|
|
2662
2735
|
/**
|
|
2663
2736
|
* @param {object} options
|
|
2664
2737
|
* @param {ImageEditor} options.editor - экземпляр редактора с доступом к canvas
|
|
@@ -2675,7 +2748,7 @@ class Nt {
|
|
|
2675
2748
|
*/
|
|
2676
2749
|
copy() {
|
|
2677
2750
|
var e = this;
|
|
2678
|
-
return
|
|
2751
|
+
return be(function* () {
|
|
2679
2752
|
var {
|
|
2680
2753
|
canvas: t
|
|
2681
2754
|
} = e.editor, a = t.getActiveObject();
|
|
@@ -2719,18 +2792,18 @@ class Nt {
|
|
|
2719
2792
|
*/
|
|
2720
2793
|
paste() {
|
|
2721
2794
|
var e = this;
|
|
2722
|
-
return
|
|
2795
|
+
return be(function* () {
|
|
2723
2796
|
var {
|
|
2724
2797
|
canvas: t
|
|
2725
2798
|
} = e.editor;
|
|
2726
2799
|
if (e.clipboard) {
|
|
2727
2800
|
var a = yield e.clipboard.clone(["format"]);
|
|
2728
2801
|
t.discardActiveObject(), a.set({
|
|
2729
|
-
id: "".concat(a.type, "-").concat(
|
|
2802
|
+
id: "".concat(a.type, "-").concat(w()),
|
|
2730
2803
|
left: a.left + 10,
|
|
2731
2804
|
top: a.top + 10,
|
|
2732
2805
|
evented: !0
|
|
2733
|
-
}), a instanceof
|
|
2806
|
+
}), a instanceof P ? (a.canvas = t, a.forEachObject((r) => {
|
|
2734
2807
|
t.add(r);
|
|
2735
2808
|
})) : t.add(a), t.setActiveObject(a), t.requestRenderAll(), t.fire("editor:object-pasted", {
|
|
2736
2809
|
object: a
|
|
@@ -2739,7 +2812,7 @@ class Nt {
|
|
|
2739
2812
|
})();
|
|
2740
2813
|
}
|
|
2741
2814
|
}
|
|
2742
|
-
class
|
|
2815
|
+
class Ot {
|
|
2743
2816
|
/**
|
|
2744
2817
|
* @param {object} options
|
|
2745
2818
|
* @param {ImageEditor} options.editor - экземпляр редактора с доступом к canvas
|
|
@@ -2822,7 +2895,7 @@ class Lt {
|
|
|
2822
2895
|
}
|
|
2823
2896
|
}
|
|
2824
2897
|
}
|
|
2825
|
-
class
|
|
2898
|
+
class Et {
|
|
2826
2899
|
/**
|
|
2827
2900
|
* @param {object} options
|
|
2828
2901
|
* @param {ImageEditor} options.editor - экземпляр редактора с доступом к canvas
|
|
@@ -2851,8 +2924,8 @@ class Ot {
|
|
|
2851
2924
|
r.suspendHistory();
|
|
2852
2925
|
var n = e || a.getActiveObject();
|
|
2853
2926
|
if (n && n.type === "activeselection") {
|
|
2854
|
-
var i = n.getObjects(), s = new
|
|
2855
|
-
i.forEach((c) => a.remove(c)), s.set("id", "".concat(s.type, "-").concat(
|
|
2927
|
+
var i = n.getObjects(), s = new Pe(i);
|
|
2928
|
+
i.forEach((c) => a.remove(c)), s.set("id", "".concat(s.type, "-").concat(w())), a.add(s), a.setActiveObject(s), a.renderAll(), r.resumeHistory(), t || r.saveState(), a.fire("editor:objects-grouped");
|
|
2856
2929
|
}
|
|
2857
2930
|
}
|
|
2858
2931
|
/**
|
|
@@ -2875,7 +2948,7 @@ class Ot {
|
|
|
2875
2948
|
if (!(!n || n.type !== "group")) {
|
|
2876
2949
|
var i = n.removeAll();
|
|
2877
2950
|
a.remove(n), i.forEach((c) => a.add(c));
|
|
2878
|
-
var s = new
|
|
2951
|
+
var s = new P(i, {
|
|
2879
2952
|
canvas: a
|
|
2880
2953
|
});
|
|
2881
2954
|
a.setActiveObject(s), a.renderAll(), r.resumeHistory(), t || r.saveState(), a.fire("editor:objects-ungrouped");
|
|
@@ -2904,7 +2977,7 @@ class Tt {
|
|
|
2904
2977
|
objectLockManager: a
|
|
2905
2978
|
} = this.editor;
|
|
2906
2979
|
e.discardActiveObject();
|
|
2907
|
-
var r = t.getObjects(), n = r.some((s) => s.locked), i = r.length > 1 ? new
|
|
2980
|
+
var r = t.getObjects(), n = r.some((s) => s.locked), i = r.length > 1 ? new P(t.getObjects(), {
|
|
2908
2981
|
canvas: e
|
|
2909
2982
|
}) : r[0];
|
|
2910
2983
|
n && a.lockObject({
|
|
@@ -2916,7 +2989,7 @@ class Tt {
|
|
|
2916
2989
|
});
|
|
2917
2990
|
}
|
|
2918
2991
|
}
|
|
2919
|
-
class
|
|
2992
|
+
class kt {
|
|
2920
2993
|
/**
|
|
2921
2994
|
* @param {object} options
|
|
2922
2995
|
* @param {ImageEditor} options.editor - экземпляр редактора с доступом к canvas
|
|
@@ -2951,7 +3024,116 @@ class Et {
|
|
|
2951
3024
|
}), a.discardActiveObject(), a.renderAll(), r.resumeHistory(), t || r.saveState(), a.fire("editor:objects-deleted"));
|
|
2952
3025
|
}
|
|
2953
3026
|
}
|
|
2954
|
-
|
|
3027
|
+
var xt = {
|
|
3028
|
+
IMAGE_MANAGER: {
|
|
3029
|
+
/**
|
|
3030
|
+
* Некорректный Content-Type изображения
|
|
3031
|
+
*/
|
|
3032
|
+
INVALID_CONTENT_TYPE: "INVALID_CONTENT_TYPE",
|
|
3033
|
+
/**
|
|
3034
|
+
* Некорректный тип источника изображения
|
|
3035
|
+
*/
|
|
3036
|
+
INVALID_SOURCE_TYPE: "INVALID_SOURCE_TYPE",
|
|
3037
|
+
/**
|
|
3038
|
+
* Ошибка при загрузке изображения
|
|
3039
|
+
*/
|
|
3040
|
+
IMPORT_FAILED: "IMPORT_FAILED",
|
|
3041
|
+
/**
|
|
3042
|
+
* Предупреждение, что изображение слишком большое, и оно будет уменьшено
|
|
3043
|
+
*/
|
|
3044
|
+
IMAGE_RESIZE_WARNING: "IMAGE_RESIZE_WARNING",
|
|
3045
|
+
/**
|
|
3046
|
+
* Не выбран объект для экспорта
|
|
3047
|
+
*/
|
|
3048
|
+
NO_OBJECT_SELECTED: "NO_OBJECT_SELECTED",
|
|
3049
|
+
/**
|
|
3050
|
+
* Ошибка при экспорте изображения
|
|
3051
|
+
*/
|
|
3052
|
+
IMAGE_EXPORT_FAILED: "IMAGE_EXPORT_FAILED"
|
|
3053
|
+
}
|
|
3054
|
+
};
|
|
3055
|
+
class F {
|
|
3056
|
+
constructor(e) {
|
|
3057
|
+
var {
|
|
3058
|
+
editor: t
|
|
3059
|
+
} = e;
|
|
3060
|
+
this.editor = t;
|
|
3061
|
+
}
|
|
3062
|
+
/**
|
|
3063
|
+
* Эмитит событие ошибки через fabricjs
|
|
3064
|
+
* @param {object} options
|
|
3065
|
+
* @param {string} [origin='ImageEditor'] — источник ошибки (по умолчанию 'ImageEditor')
|
|
3066
|
+
* @param {string} code — код ошибки (из errorCodes)
|
|
3067
|
+
* @param {object} [data] — доп. данные (опционально)
|
|
3068
|
+
* @param {string} [message] — текст ошибки (опционально, если не передан, то используется код ошибки)
|
|
3069
|
+
* @fires editor:error
|
|
3070
|
+
*/
|
|
3071
|
+
emitError(e) {
|
|
3072
|
+
var {
|
|
3073
|
+
origin: t = "ImageEditor",
|
|
3074
|
+
method: a = "Unknown Method",
|
|
3075
|
+
code: r,
|
|
3076
|
+
data: n,
|
|
3077
|
+
message: i
|
|
3078
|
+
} = e;
|
|
3079
|
+
if (!F.isValidErrorCode(r)) {
|
|
3080
|
+
console.warn("Неизвестный код ошибки: ", {
|
|
3081
|
+
code: r,
|
|
3082
|
+
origin: t,
|
|
3083
|
+
method: a
|
|
3084
|
+
});
|
|
3085
|
+
return;
|
|
3086
|
+
}
|
|
3087
|
+
if (r) {
|
|
3088
|
+
var s = i || r;
|
|
3089
|
+
console.error("".concat(t, ". ").concat(a, ". ").concat(r, ". ").concat(s), n), this.editor.canvas.fire("editor:error", {
|
|
3090
|
+
code: r,
|
|
3091
|
+
origin: t,
|
|
3092
|
+
method: a,
|
|
3093
|
+
message: s,
|
|
3094
|
+
data: n
|
|
3095
|
+
});
|
|
3096
|
+
}
|
|
3097
|
+
}
|
|
3098
|
+
/**
|
|
3099
|
+
* Эмитит предупреждение через fabricjs
|
|
3100
|
+
* @param {object} options
|
|
3101
|
+
* @param {string} [origin='ImageEditor'] — источник предупреждения (по умолчанию 'ImageEditor')
|
|
3102
|
+
* @param {string} code — код предупреждения (из errorCodes)
|
|
3103
|
+
* @param {object} [data] — доп. данные (опционально)
|
|
3104
|
+
* @param {string} [message] — текст предупреждения (опционально, если не передан, то используется код предупреждения)
|
|
3105
|
+
* @fires editor:warning
|
|
3106
|
+
*/
|
|
3107
|
+
emitWarning(e) {
|
|
3108
|
+
var {
|
|
3109
|
+
origin: t = "ImageEditor",
|
|
3110
|
+
method: a = "Unknown Method",
|
|
3111
|
+
code: r,
|
|
3112
|
+
message: n,
|
|
3113
|
+
data: i
|
|
3114
|
+
} = e;
|
|
3115
|
+
if (!F.isValidErrorCode(r)) {
|
|
3116
|
+
console.warn("Неизвестный код ошибки: ", {
|
|
3117
|
+
code: r,
|
|
3118
|
+
origin: t,
|
|
3119
|
+
method: a
|
|
3120
|
+
});
|
|
3121
|
+
return;
|
|
3122
|
+
}
|
|
3123
|
+
var s = n || r;
|
|
3124
|
+
console.warn("".concat(t, ". ").concat(a, ". ").concat(r, ". ").concat(s), i), this.editor.canvas.fire("editor:warning", {
|
|
3125
|
+
code: r,
|
|
3126
|
+
origin: t,
|
|
3127
|
+
method: a,
|
|
3128
|
+
message: n,
|
|
3129
|
+
data: i
|
|
3130
|
+
});
|
|
3131
|
+
}
|
|
3132
|
+
static isValidErrorCode(e) {
|
|
3133
|
+
return e ? Object.values(xt).some((t) => Object.values(t).includes(e)) : !1;
|
|
3134
|
+
}
|
|
3135
|
+
}
|
|
3136
|
+
function Ie(o, e, t, a, r, n, i) {
|
|
2955
3137
|
try {
|
|
2956
3138
|
var s = o[n](i), c = s.value;
|
|
2957
3139
|
} catch (u) {
|
|
@@ -2959,22 +3141,22 @@ function be(o, e, t, a, r, n, i) {
|
|
|
2959
3141
|
}
|
|
2960
3142
|
s.done ? e(c) : Promise.resolve(c).then(a, r);
|
|
2961
3143
|
}
|
|
2962
|
-
function
|
|
3144
|
+
function Bt(o) {
|
|
2963
3145
|
return function() {
|
|
2964
3146
|
var e = this, t = arguments;
|
|
2965
3147
|
return new Promise(function(a, r) {
|
|
2966
3148
|
var n = o.apply(e, t);
|
|
2967
3149
|
function i(c) {
|
|
2968
|
-
|
|
3150
|
+
Ie(n, a, r, i, s, "next", c);
|
|
2969
3151
|
}
|
|
2970
3152
|
function s(c) {
|
|
2971
|
-
|
|
3153
|
+
Ie(n, a, r, i, s, "throw", c);
|
|
2972
3154
|
}
|
|
2973
3155
|
i(void 0);
|
|
2974
3156
|
});
|
|
2975
3157
|
};
|
|
2976
3158
|
}
|
|
2977
|
-
class
|
|
3159
|
+
class ie {
|
|
2978
3160
|
constructor(e) {
|
|
2979
3161
|
var t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
2980
3162
|
this.options = t;
|
|
@@ -2983,11 +3165,11 @@ class ae {
|
|
|
2983
3165
|
minZoom: r,
|
|
2984
3166
|
maxZoom: n
|
|
2985
3167
|
} = t;
|
|
2986
|
-
this.containerId = e, this.editorId = "".concat(e, "-").concat(
|
|
3168
|
+
this.containerId = e, this.editorId = "".concat(e, "-").concat(w()), this.clipboard = null, this.defaultZoom = a, this.minZoom = r || vt, this.maxZoom = n || mt, this.init();
|
|
2987
3169
|
}
|
|
2988
3170
|
init() {
|
|
2989
3171
|
var e = this;
|
|
2990
|
-
return
|
|
3172
|
+
return Bt(function* () {
|
|
2991
3173
|
var {
|
|
2992
3174
|
editorContainerWidth: t,
|
|
2993
3175
|
editorContainerHeight: a,
|
|
@@ -3000,45 +3182,47 @@ class ae {
|
|
|
3000
3182
|
scaleType: l,
|
|
3001
3183
|
_onReadyCallback: d
|
|
3002
3184
|
} = e.options;
|
|
3003
|
-
if (
|
|
3185
|
+
if (qe.apply(), e.canvas = new Ye(e.containerId, e.options), e.moduleLoader = new We(), e.workerManager = new Fe(), e.errorManager = new F({
|
|
3186
|
+
editor: e
|
|
3187
|
+
}), e.historyManager = new gt({
|
|
3004
3188
|
editor: e
|
|
3005
|
-
}), e.toolbar = new
|
|
3189
|
+
}), e.toolbar = new ht({
|
|
3006
3190
|
editor: e
|
|
3007
|
-
}), e.transformManager = new
|
|
3191
|
+
}), e.transformManager = new yt({
|
|
3008
3192
|
editor: e
|
|
3009
|
-
}), e.canvasManager = new
|
|
3193
|
+
}), e.canvasManager = new jt({
|
|
3010
3194
|
editor: e
|
|
3011
|
-
}), e.imageManager = new
|
|
3195
|
+
}), e.imageManager = new S({
|
|
3012
3196
|
editor: e
|
|
3013
|
-
}), e.layerManager = new
|
|
3197
|
+
}), e.layerManager = new W({
|
|
3014
3198
|
editor: e
|
|
3015
3199
|
}), e.shapeManager = new Dt({
|
|
3016
3200
|
editor: e
|
|
3017
|
-
}), e.interactionBlocker = new
|
|
3201
|
+
}), e.interactionBlocker = new pt({
|
|
3018
3202
|
editor: e
|
|
3019
|
-
}), e.clipboardManager = new
|
|
3203
|
+
}), e.clipboardManager = new Lt({
|
|
3020
3204
|
editor: e
|
|
3021
|
-
}), e.objectLockManager = new
|
|
3205
|
+
}), e.objectLockManager = new Ot({
|
|
3022
3206
|
editor: e
|
|
3023
|
-
}), e.groupingManager = new
|
|
3207
|
+
}), e.groupingManager = new Et({
|
|
3024
3208
|
editor: e
|
|
3025
3209
|
}), e.selectionManager = new Tt({
|
|
3026
3210
|
editor: e
|
|
3027
|
-
}), e.deletionManager = new
|
|
3211
|
+
}), e.deletionManager = new kt({
|
|
3028
3212
|
editor: e
|
|
3029
|
-
}), e._createMonageArea(), e._createClippingArea(), e.listeners = new
|
|
3213
|
+
}), e._createMonageArea(), e._createClippingArea(), e.listeners = new z({
|
|
3030
3214
|
editor: e,
|
|
3031
3215
|
options: e.options
|
|
3032
3216
|
}), e.canvasManager.setEditorContainerWidth(t), e.canvasManager.setEditorContainerHeight(a), e.canvasManager.setCanvasWrapperWidth(r), e.canvasManager.setCanvasWrapperHeight(n), e.canvasManager.setCanvasCSSWidth(i), e.canvasManager.setCanvasCSSHeight(s), c != null && c.source) {
|
|
3033
3217
|
var {
|
|
3034
3218
|
source: h,
|
|
3035
3219
|
scale: g = "image-".concat(l),
|
|
3036
|
-
withoutSave:
|
|
3220
|
+
withoutSave: f = !0
|
|
3037
3221
|
} = c;
|
|
3038
3222
|
yield e.imageManager.importImage({
|
|
3039
3223
|
source: h,
|
|
3040
3224
|
scale: g,
|
|
3041
|
-
withoutSave:
|
|
3225
|
+
withoutSave: f
|
|
3042
3226
|
});
|
|
3043
3227
|
} else
|
|
3044
3228
|
e.canvasManager.setDefaultScale({
|
|
@@ -3060,7 +3244,7 @@ class ae {
|
|
|
3060
3244
|
this.montageArea = this.shapeManager.addRectangle({
|
|
3061
3245
|
width: e,
|
|
3062
3246
|
height: t,
|
|
3063
|
-
fill:
|
|
3247
|
+
fill: ie._createMosaicPattern(),
|
|
3064
3248
|
stroke: null,
|
|
3065
3249
|
strokeWidth: 0,
|
|
3066
3250
|
selectable: !1,
|
|
@@ -3124,7 +3308,7 @@ class ae {
|
|
|
3124
3308
|
});
|
|
3125
3309
|
}
|
|
3126
3310
|
}
|
|
3127
|
-
const
|
|
3311
|
+
const Zt = {
|
|
3128
3312
|
// Cохраняют ли объекты свой текущий порядок (z-index) при выделении
|
|
3129
3313
|
preserveObjectStacking: !0,
|
|
3130
3314
|
// Возможность взаимодействия с объектом за пределами монтажной области
|
|
@@ -3235,7 +3419,7 @@ const xt = {
|
|
|
3235
3419
|
// Сброс параметров объекта по двойному клику
|
|
3236
3420
|
resetObjectFitByDoubleClick: !0
|
|
3237
3421
|
};
|
|
3238
|
-
function
|
|
3422
|
+
function Ae(o, e) {
|
|
3239
3423
|
var t = Object.keys(o);
|
|
3240
3424
|
if (Object.getOwnPropertySymbols) {
|
|
3241
3425
|
var a = Object.getOwnPropertySymbols(o);
|
|
@@ -3248,22 +3432,22 @@ function Ie(o, e) {
|
|
|
3248
3432
|
function Se(o) {
|
|
3249
3433
|
for (var e = 1; e < arguments.length; e++) {
|
|
3250
3434
|
var t = arguments[e] != null ? arguments[e] : {};
|
|
3251
|
-
e % 2 ?
|
|
3252
|
-
|
|
3253
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(o, Object.getOwnPropertyDescriptors(t)) :
|
|
3435
|
+
e % 2 ? Ae(Object(t), !0).forEach(function(a) {
|
|
3436
|
+
zt(o, a, t[a]);
|
|
3437
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(o, Object.getOwnPropertyDescriptors(t)) : Ae(Object(t)).forEach(function(a) {
|
|
3254
3438
|
Object.defineProperty(o, a, Object.getOwnPropertyDescriptor(t, a));
|
|
3255
3439
|
});
|
|
3256
3440
|
}
|
|
3257
3441
|
return o;
|
|
3258
3442
|
}
|
|
3259
|
-
function
|
|
3260
|
-
return (e =
|
|
3443
|
+
function zt(o, e, t) {
|
|
3444
|
+
return (e = Pt(e)) in o ? Object.defineProperty(o, e, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : o[e] = t, o;
|
|
3261
3445
|
}
|
|
3262
|
-
function
|
|
3263
|
-
var e =
|
|
3446
|
+
function Pt(o) {
|
|
3447
|
+
var e = Ut(o, "string");
|
|
3264
3448
|
return typeof e == "symbol" ? e : e + "";
|
|
3265
3449
|
}
|
|
3266
|
-
function
|
|
3450
|
+
function Ut(o, e) {
|
|
3267
3451
|
if (typeof o != "object" || !o) return o;
|
|
3268
3452
|
var t = o[Symbol.toPrimitive];
|
|
3269
3453
|
if (t !== void 0) {
|
|
@@ -3273,18 +3457,18 @@ function zt(o, e) {
|
|
|
3273
3457
|
}
|
|
3274
3458
|
return (e === "string" ? String : Number)(o);
|
|
3275
3459
|
}
|
|
3276
|
-
function
|
|
3277
|
-
var e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, t = Se(Se({},
|
|
3460
|
+
function _t(o) {
|
|
3461
|
+
var e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, t = Se(Se({}, Zt), e), a = document.getElementById(o);
|
|
3278
3462
|
if (!a)
|
|
3279
3463
|
return Promise.reject(new Error('Контейнер с ID "'.concat(o, '" не найден.')));
|
|
3280
3464
|
var r = document.createElement("canvas");
|
|
3281
3465
|
return r.id = "".concat(o, "-canvas"), a.appendChild(r), t.editorContainer = a, new Promise((n) => {
|
|
3282
3466
|
t._onReadyCallback = n;
|
|
3283
|
-
var i = new
|
|
3467
|
+
var i = new ie(r.id, t);
|
|
3284
3468
|
window[o] = i;
|
|
3285
3469
|
});
|
|
3286
3470
|
}
|
|
3287
3471
|
export {
|
|
3288
|
-
|
|
3472
|
+
_t as default
|
|
3289
3473
|
};
|
|
3290
3474
|
//# sourceMappingURL=main.js.map
|