@anu3ev/fabric-image-editor 0.1.43 → 0.1.45
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 +589 -616
- package/package.json +5 -2
package/dist/main.js
CHANGED
|
@@ -1,47 +1,48 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var me = (o, e, t) => e in o ?
|
|
1
|
+
var Le = Object.defineProperty;
|
|
2
|
+
var X = Object.getOwnPropertySymbols;
|
|
3
|
+
var ve = Object.prototype.hasOwnProperty, fe = Object.prototype.propertyIsEnumerable;
|
|
4
|
+
var me = (o, e, t) => e in o ? Le(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t, C = (o, e) => {
|
|
5
5
|
for (var t in e || (e = {}))
|
|
6
|
-
|
|
7
|
-
if (
|
|
8
|
-
for (var t of
|
|
9
|
-
|
|
6
|
+
ve.call(e, t) && me(o, t, e[t]);
|
|
7
|
+
if (X)
|
|
8
|
+
for (var t of X(e))
|
|
9
|
+
fe.call(e, t) && me(o, t, e[t]);
|
|
10
10
|
return o;
|
|
11
11
|
};
|
|
12
|
-
var
|
|
12
|
+
var Q = (o, e) => {
|
|
13
13
|
var t = {};
|
|
14
14
|
for (var a in o)
|
|
15
|
-
|
|
16
|
-
if (o != null &&
|
|
17
|
-
for (var a of
|
|
18
|
-
e.indexOf(a) < 0 &&
|
|
15
|
+
ve.call(o, a) && e.indexOf(a) < 0 && (t[a] = o[a]);
|
|
16
|
+
if (o != null && X)
|
|
17
|
+
for (var a of X(o))
|
|
18
|
+
e.indexOf(a) < 0 && fe.call(o, a) && (t[a] = o[a]);
|
|
19
19
|
return t;
|
|
20
20
|
};
|
|
21
|
-
var
|
|
21
|
+
var O = (o, e, t) => new Promise((a, n) => {
|
|
22
22
|
var i = (c) => {
|
|
23
23
|
try {
|
|
24
|
-
|
|
24
|
+
r(t.next(c));
|
|
25
25
|
} catch (u) {
|
|
26
26
|
n(u);
|
|
27
27
|
}
|
|
28
|
-
},
|
|
28
|
+
}, s = (c) => {
|
|
29
29
|
try {
|
|
30
|
-
|
|
30
|
+
r(t.throw(c));
|
|
31
31
|
} catch (u) {
|
|
32
32
|
n(u);
|
|
33
33
|
}
|
|
34
|
-
},
|
|
35
|
-
|
|
34
|
+
}, r = (c) => c.done ? a(c.value) : Promise.resolve(c.value).then(i, s);
|
|
35
|
+
r((t = t.apply(o, e)).next());
|
|
36
36
|
});
|
|
37
|
-
import { ActiveSelection as
|
|
38
|
-
import { create as
|
|
39
|
-
|
|
37
|
+
import { ActiveSelection as N, util as W, controlsUtils as we, InteractiveFabricObject as Oe, loadSVGFromURL as Te, FabricImage as ee, Point as K, Rect as ke, Circle as xe, Triangle as Be, Group as je, Canvas as Ze, Pattern as ze } from "fabric";
|
|
38
|
+
import { create as Ue } from "jsondiffpatch";
|
|
39
|
+
import Re from "diff-match-patch";
|
|
40
|
+
var _e = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", A = function() {
|
|
40
41
|
for (var e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 21, t = "", a = crypto.getRandomValues(new Uint8Array(e |= 0)); e--; )
|
|
41
|
-
t +=
|
|
42
|
+
t += _e[a[e] & 63];
|
|
42
43
|
return t;
|
|
43
44
|
};
|
|
44
|
-
class
|
|
45
|
+
class P {
|
|
45
46
|
/**
|
|
46
47
|
* Конструктор принимает редактор и опции.
|
|
47
48
|
* @param {Object} params
|
|
@@ -58,7 +59,7 @@ class R {
|
|
|
58
59
|
* @param {Boolean} [params.options.resetObjectFitByDoubleClick] — сброс фита объекта по двойному клику
|
|
59
60
|
*/
|
|
60
61
|
constructor({ editor: e, options: t = {} }) {
|
|
61
|
-
this.isDragging = !1, this.lastMouseX = 0, this.lastMouseY = 0, this.isUndoRedoKeyPressed = !1, this.isSpacePressed = !1, 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 = e, this.canvas = e.canvas, this.options = t, this.handleContainerResizeBound =
|
|
62
|
+
this.isDragging = !1, this.lastMouseX = 0, this.lastMouseY = 0, this.isUndoRedoKeyPressed = !1, this.isSpacePressed = !1, 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 = e, this.canvas = e.canvas, this.options = t, this.handleContainerResizeBound = P.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 = P.debounce(this.handleObjectModifiedHistory.bind(this), 300), this.handleObjectRotatingHistoryBound = P.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();
|
|
62
63
|
}
|
|
63
64
|
/**
|
|
64
65
|
* Инициализация всех обработчиков согласно опциям.
|
|
@@ -70,13 +71,13 @@ class R {
|
|
|
70
71
|
mouseWheelZooming: a,
|
|
71
72
|
bringToFrontOnSelection: n,
|
|
72
73
|
copyObjectsByHotkey: i,
|
|
73
|
-
pasteImageFromClipboard:
|
|
74
|
-
undoRedoByHotKeys:
|
|
74
|
+
pasteImageFromClipboard: s,
|
|
75
|
+
undoRedoByHotKeys: r,
|
|
75
76
|
selectAllByHotkey: c,
|
|
76
77
|
deleteObjectsByHotkey: u,
|
|
77
78
|
resetObjectFitByDoubleClick: l
|
|
78
79
|
} = this.options;
|
|
79
|
-
t && (this.canvas.on("mouse:down", this.handleCanvasDragStartBound), this.canvas.on("mouse:move", this.handleCanvasDraggingBound), this.canvas.on("mouse:up", this.handleCanvasDragEndBound), document.addEventListener("keydown", this.handleSpaceKeyDownBound, { capture: !0 }), document.addEventListener("keyup", this.handleSpaceKeyUpBound, { capture: !0 })), a && this.canvas.on("mouse:wheel", this.handleMouseWheelZoomBound), n && (this.canvas.on("selection:created", this.handleBringToFrontBound), this.canvas.on("selection:updated", this.handleBringToFrontBound)), l && this.canvas.on("mouse:dblclick", this.handleResetObjectFitBound), e && window.addEventListener("resize", this.handleContainerResizeBound, { capture: !0 }), i && document.addEventListener("keydown", this.handleCopyEventBound, { capture: !0 }),
|
|
80
|
+
t && (this.canvas.on("mouse:down", this.handleCanvasDragStartBound), this.canvas.on("mouse:move", this.handleCanvasDraggingBound), this.canvas.on("mouse:up", this.handleCanvasDragEndBound), document.addEventListener("keydown", this.handleSpaceKeyDownBound, { capture: !0 }), document.addEventListener("keyup", this.handleSpaceKeyUpBound, { capture: !0 })), a && this.canvas.on("mouse:wheel", this.handleMouseWheelZoomBound), n && (this.canvas.on("selection:created", this.handleBringToFrontBound), this.canvas.on("selection:updated", this.handleBringToFrontBound)), l && this.canvas.on("mouse:dblclick", this.handleResetObjectFitBound), e && window.addEventListener("resize", this.handleContainerResizeBound, { capture: !0 }), i && document.addEventListener("keydown", this.handleCopyEventBound, { capture: !0 }), s && document.addEventListener("paste", this.handlePasteEventBound, { capture: !0 }), r && (document.addEventListener("keydown", this.handleUndoRedoEventBound, { capture: !0 }), document.addEventListener("keyup", this.handleUndoRedoKeyUpBound, { capture: !0 })), c && document.addEventListener("keydown", this.handleSelectAllEventBound, { capture: !0 }), u && document.addEventListener("keydown", this.handleDeleteObjectsEventBound, { capture: !0 }), this.canvas.on("object:modified", this.handleObjectModifiedHistoryBound), this.canvas.on("object:rotating", this.handleObjectRotatingHistoryBound), this.canvas.on("object:added", this.handleObjectAddedHistoryBound), this.canvas.on("object:removed", this.handleObjectRemovedHistoryBound), this.canvas.on("object:added", this.handleOverlayUpdateBound), this.canvas.on("selection:created", this.handleOverlayUpdateBound), this.canvas.on("selection:created", this.handleLockedSelectionBound), this.canvas.on("selection:updated", this.handleLockedSelectionBound);
|
|
80
81
|
}
|
|
81
82
|
/**
|
|
82
83
|
* При массовом выделении объектов удаляем из него залоченные.
|
|
@@ -85,8 +86,8 @@ class R {
|
|
|
85
86
|
* @param {TPointerEvent} [params.e] - событие указателя (опционально)
|
|
86
87
|
*/
|
|
87
88
|
_filterLockedSelection({ selected: e, e: t }) {
|
|
88
|
-
if (!(e != null && e.length) || !(t instanceof MouseEvent) || e.length === 1 || !e.some((
|
|
89
|
-
const n = e.filter((
|
|
89
|
+
if (!(e != null && e.length) || !(t instanceof MouseEvent) || e.length === 1 || !e.some((s) => s.locked)) return;
|
|
90
|
+
const n = e.filter((s) => !s.locked);
|
|
90
91
|
if (n.length === 0) {
|
|
91
92
|
this.canvas.discardActiveObject();
|
|
92
93
|
return;
|
|
@@ -95,7 +96,7 @@ class R {
|
|
|
95
96
|
this.canvas.setActiveObject(n[0]);
|
|
96
97
|
return;
|
|
97
98
|
}
|
|
98
|
-
const i = new
|
|
99
|
+
const i = new N(n, {
|
|
99
100
|
canvas: this.canvas
|
|
100
101
|
});
|
|
101
102
|
this.canvas.setActiveObject(i), this.canvas.requestRenderAll();
|
|
@@ -157,7 +158,7 @@ class R {
|
|
|
157
158
|
* @param {String} event.code — код клавиши
|
|
158
159
|
*/
|
|
159
160
|
handleUndoRedoEvent(e) {
|
|
160
|
-
return
|
|
161
|
+
return O(this, null, function* () {
|
|
161
162
|
const { ctrlKey: t, metaKey: a, code: n, repeat: i } = e;
|
|
162
163
|
!t && !a || i || !/Mac/i.test(navigator.userAgent) && this.isUndoRedoKeyPressed || (n === "KeyZ" ? (e.preventDefault(), this.isUndoRedoKeyPressed = !0, yield this.editor.historyManager.undo()) : n === "KeyY" && (e.preventDefault(), this.isUndoRedoKeyPressed = !0, yield this.editor.historyManager.redo()));
|
|
163
164
|
});
|
|
@@ -201,8 +202,8 @@ class R {
|
|
|
201
202
|
n || i || (this.isSpacePressed = !0, e.preventDefault(), t.set({
|
|
202
203
|
selection: !1,
|
|
203
204
|
defaultCursor: "grab"
|
|
204
|
-
}), t.setCursor("grab"), a.canvasManager.getObjects().forEach((
|
|
205
|
-
|
|
205
|
+
}), t.setCursor("grab"), a.canvasManager.getObjects().forEach((s) => {
|
|
206
|
+
s.set({
|
|
206
207
|
selectable: !1,
|
|
207
208
|
evented: !1
|
|
208
209
|
});
|
|
@@ -297,14 +298,13 @@ class R {
|
|
|
297
298
|
static debounce(e, t) {
|
|
298
299
|
let a = null;
|
|
299
300
|
return function(...n) {
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
e.apply(i, n);
|
|
301
|
+
a !== null && clearTimeout(a), a = setTimeout(() => {
|
|
302
|
+
e.apply(this, n);
|
|
303
303
|
}, t);
|
|
304
304
|
};
|
|
305
305
|
}
|
|
306
306
|
}
|
|
307
|
-
class
|
|
307
|
+
class He {
|
|
308
308
|
/**
|
|
309
309
|
* @description Класс для динамической загрузки внешних модулей.
|
|
310
310
|
*/
|
|
@@ -322,7 +322,7 @@ class Re {
|
|
|
322
322
|
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, '"')));
|
|
323
323
|
}
|
|
324
324
|
}
|
|
325
|
-
class
|
|
325
|
+
class Ye {
|
|
326
326
|
/**
|
|
327
327
|
* @param {string|URL} [scriptUrl] — URL скрипта воркера.
|
|
328
328
|
* По-умолчанию использует файл рядом с этим модулем
|
|
@@ -350,9 +350,9 @@ class Pe {
|
|
|
350
350
|
requestId: a,
|
|
351
351
|
success: n,
|
|
352
352
|
data: i,
|
|
353
|
-
error:
|
|
354
|
-
} = t,
|
|
355
|
-
|
|
353
|
+
error: s
|
|
354
|
+
} = t, r = this._callbacks.get(a);
|
|
355
|
+
r && (n ? r.resolve(i) : r.reject(new Error(s)), this._callbacks.delete(a));
|
|
356
356
|
}
|
|
357
357
|
/**
|
|
358
358
|
* Универсальный метод отправки команды в воркер
|
|
@@ -363,10 +363,10 @@ class Pe {
|
|
|
363
363
|
*/
|
|
364
364
|
post(e, t) {
|
|
365
365
|
var a = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : [], n = "".concat(e, ":").concat(A(8));
|
|
366
|
-
return new Promise((i,
|
|
366
|
+
return new Promise((i, s) => {
|
|
367
367
|
this._callbacks.set(n, {
|
|
368
368
|
resolve: i,
|
|
369
|
-
reject:
|
|
369
|
+
reject: s
|
|
370
370
|
}), this.worker.postMessage({
|
|
371
371
|
action: e,
|
|
372
372
|
payload: t,
|
|
@@ -381,26 +381,26 @@ class Pe {
|
|
|
381
381
|
this.worker.terminate();
|
|
382
382
|
}
|
|
383
383
|
}
|
|
384
|
-
|
|
384
|
+
const I = 12, Pe = 2, te = 8, ae = 20, We = 100, ne = 20, ie = 8, Fe = 100, se = 32, re = 1, Ve = "#2B2D33", oe = "#3D8BF4", ce = "#FFFFFF";
|
|
385
385
|
function J(o, e, t, a, n) {
|
|
386
|
-
|
|
387
|
-
o.save(), o.translate(e, t), o.rotate(
|
|
386
|
+
const i = I, s = Pe;
|
|
387
|
+
o.save(), o.translate(e, t), o.rotate(W.degreesToRadians(n.angle)), o.fillStyle = ce, o.strokeStyle = oe, o.lineWidth = re, o.beginPath(), o.roundRect(-12 / 2, -12 / 2, i, i, s), o.fill(), o.stroke(), o.restore();
|
|
388
388
|
}
|
|
389
389
|
function ye(o, e, t, a, n) {
|
|
390
|
-
|
|
391
|
-
o.save(), o.translate(e, t), o.rotate(
|
|
390
|
+
const i = te, s = ae, r = We;
|
|
391
|
+
o.save(), o.translate(e, t), o.rotate(W.degreesToRadians(n.angle)), o.fillStyle = ce, o.strokeStyle = oe, o.lineWidth = re, o.beginPath(), o.roundRect(-8 / 2, -20 / 2, i, s, r), o.fill(), o.stroke(), o.restore();
|
|
392
392
|
}
|
|
393
393
|
function be(o, e, t, a, n) {
|
|
394
|
-
|
|
395
|
-
o.save(), o.translate(e, t), o.rotate(
|
|
394
|
+
const i = ne, s = ie, r = Fe;
|
|
395
|
+
o.save(), o.translate(e, t), o.rotate(W.degreesToRadians(n.angle)), o.fillStyle = ce, o.strokeStyle = oe, o.lineWidth = re, o.beginPath(), o.roundRect(-20 / 2, -8 / 2, i, s, r), o.fill(), o.stroke(), o.restore();
|
|
396
396
|
}
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
function
|
|
400
|
-
|
|
401
|
-
o.save(), o.translate(e, t), o.rotate(
|
|
397
|
+
const Ge = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTE4Ljc1IDQuMzc1djMuNzVhLjYyNS42MjUgMCAwIDEtLjYyNS42MjVoLTMuNzVhLjYyNS42MjUgMCAwIDEgMC0xLjI1aDIuMTRsLTIuMDc3LTEuOTAzLS4wMi0uMDE5YTYuMjUgNi4yNSAwIDEgMC0uMTMgOC45NjcuNjI2LjYyNiAwIDAgMSAuODYuOTA5QTcuNDU2IDcuNDU2IDAgMCAxIDEwIDE3LjVoLS4xMDNhNy41IDcuNSAwIDEgMSA1LjM5Ni0xMi44MTJMMTcuNSA2LjcwM1Y0LjM3NWEuNjI1LjYyNSAwIDAgMSAxLjI1IDBaIi8+PC9zdmc+", Se = new Image();
|
|
398
|
+
Se.src = Ge;
|
|
399
|
+
function Xe(o, e, t, a, n) {
|
|
400
|
+
const s = se / 2;
|
|
401
|
+
o.save(), o.translate(e, t), o.rotate(W.degreesToRadians(n.angle)), o.fillStyle = Ve, o.beginPath(), o.arc(0, 0, s, 0, 2 * Math.PI), o.fill(), o.drawImage(Se, -16 / 2, -16 / 2, s, s), o.restore();
|
|
402
402
|
}
|
|
403
|
-
|
|
403
|
+
const Qe = {
|
|
404
404
|
// Угловые точки
|
|
405
405
|
tl: {
|
|
406
406
|
render: J,
|
|
@@ -433,81 +433,80 @@ var Je = {
|
|
|
433
433
|
// Середина вертикалей
|
|
434
434
|
ml: {
|
|
435
435
|
render: ye,
|
|
436
|
-
sizeX:
|
|
437
|
-
sizeY:
|
|
436
|
+
sizeX: te,
|
|
437
|
+
sizeY: ae,
|
|
438
438
|
offsetX: 0,
|
|
439
439
|
offsetY: 0
|
|
440
440
|
},
|
|
441
441
|
mr: {
|
|
442
442
|
render: ye,
|
|
443
|
-
sizeX:
|
|
444
|
-
sizeY:
|
|
443
|
+
sizeX: te,
|
|
444
|
+
sizeY: ae,
|
|
445
445
|
offsetX: 0,
|
|
446
446
|
offsetY: 0
|
|
447
447
|
},
|
|
448
448
|
// Середина горизонталей
|
|
449
449
|
mt: {
|
|
450
450
|
render: be,
|
|
451
|
-
sizeX:
|
|
452
|
-
sizeY:
|
|
451
|
+
sizeX: ne,
|
|
452
|
+
sizeY: ie,
|
|
453
453
|
offsetX: 0,
|
|
454
454
|
offsetY: 0
|
|
455
455
|
},
|
|
456
456
|
mb: {
|
|
457
457
|
render: be,
|
|
458
|
-
sizeX:
|
|
459
|
-
sizeY:
|
|
458
|
+
sizeX: ne,
|
|
459
|
+
sizeY: ie,
|
|
460
460
|
offsetX: 0,
|
|
461
461
|
offsetY: 0
|
|
462
462
|
},
|
|
463
463
|
// Специальный «rotate» контрол
|
|
464
464
|
mtr: {
|
|
465
|
-
render:
|
|
465
|
+
render: Xe,
|
|
466
466
|
sizeX: se,
|
|
467
467
|
sizeY: se,
|
|
468
468
|
offsetX: 0,
|
|
469
469
|
offsetY: -32
|
|
470
470
|
}
|
|
471
471
|
};
|
|
472
|
-
class
|
|
472
|
+
class Je {
|
|
473
473
|
static apply() {
|
|
474
|
-
|
|
475
|
-
Object.entries(
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
u.canvas.setCursor("grabbing");
|
|
474
|
+
const e = we.createObjectDefaultControls();
|
|
475
|
+
Object.entries(Qe).forEach(([t, a]) => {
|
|
476
|
+
Object.assign(e[t], {
|
|
477
|
+
render: a.render,
|
|
478
|
+
sizeX: a.sizeX,
|
|
479
|
+
sizeY: a.sizeY,
|
|
480
|
+
offsetX: a.offsetX,
|
|
481
|
+
offsetY: a.offsetY
|
|
482
|
+
}), t === "mtr" && (e[t].cursorStyle = "grab", e[t].mouseDownHandler = (i, s, r, c) => {
|
|
483
|
+
var l;
|
|
484
|
+
(l = s.target.canvas) == null || l.setCursor("grabbing");
|
|
486
485
|
});
|
|
487
|
-
}),
|
|
486
|
+
}), Oe.ownDefaults.controls = e;
|
|
488
487
|
}
|
|
489
488
|
}
|
|
490
|
-
var
|
|
491
|
-
function pe(o, e, t, a, n, i,
|
|
489
|
+
var Ke = "data:image/svg+xml;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jk3LTIuMzE2TDMuNzQgMTBaIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiLz48L3N2Zz4=", it = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI0VDNEU0MCIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNOC4xMjUgMS4yNUExLjg3NSAxLjg3NSAwIDAgMCA2LjI1IDMuMTI1di42MjVIMy4xMjVhLjYyNS42MjUgMCAwIDAgMCAxLjI1aC42MjV2MTEuMjVBMS4yNSAxLjI1IDAgMCAwIDUgMTcuNWgxMGExLjI1IDEuMjUgMCAwIDAgMS4yNS0xLjI1VjVoLjYyNWEuNjI1LjYyNSAwIDAgMCAwLTEuMjVIMTMuNzV2LS42MjVhMS44NzUgMS44NzUgMCAwIDAtMS44NzUtMS44NzVoLTMuNzVabTQuMzc1IDIuNXYtLjYyNWEuNjI1LjYyNSAwIDAgMC0uNjI1LS42MjVoLTMuNzVhLjYyNS42MjUgMCAwIDAtLjYyNS42MjV2LjYyNWg1Wk01IDE2LjI1VjVoMTB2MTEuMjVINVpNOC4xMjUgNy41Yy4zNDUgMCAuNjI1LjI4LjYyNS42MjV2NWEuNjI1LjYyNSAwIDEgMS0xLjI1IDB2LTVjMC0uMzQ1LjI4LS42MjUuNjI1LS42MjVabTQuMzc1IDUuNjI1di01YS42MjUuNjI1IDAgMCAwLTEuMjUgMHY1YS42MjUuNjI1IDAgMSAwIDEuMjUgMFoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjwvc3ZnPg==";
|
|
490
|
+
function pe(o, e, t, a, n, i, s) {
|
|
492
491
|
try {
|
|
493
|
-
var
|
|
492
|
+
var r = o[i](s), c = r.value;
|
|
494
493
|
} catch (u) {
|
|
495
494
|
return void t(u);
|
|
496
495
|
}
|
|
497
|
-
|
|
496
|
+
r.done ? e(c) : Promise.resolve(c).then(a, n);
|
|
498
497
|
}
|
|
499
498
|
function st(o) {
|
|
500
499
|
return function() {
|
|
501
500
|
var e = this, t = arguments;
|
|
502
501
|
return new Promise(function(a, n) {
|
|
503
502
|
var i = o.apply(e, t);
|
|
504
|
-
function r(c) {
|
|
505
|
-
pe(i, a, n, r, s, "next", c);
|
|
506
|
-
}
|
|
507
503
|
function s(c) {
|
|
508
|
-
pe(i, a, n,
|
|
504
|
+
pe(i, a, n, s, r, "next", c);
|
|
505
|
+
}
|
|
506
|
+
function r(c) {
|
|
507
|
+
pe(i, a, n, s, r, "throw", c);
|
|
509
508
|
}
|
|
510
|
-
|
|
509
|
+
s(void 0);
|
|
511
510
|
});
|
|
512
511
|
};
|
|
513
512
|
}
|
|
@@ -570,14 +569,14 @@ const Y = {
|
|
|
570
569
|
}],
|
|
571
570
|
offsetTop: 50,
|
|
572
571
|
icons: {
|
|
573
|
-
copyPaste:
|
|
574
|
-
delete:
|
|
575
|
-
lock:
|
|
576
|
-
unlock:
|
|
577
|
-
bringToFront:
|
|
578
|
-
sendToBack:
|
|
579
|
-
bringForward:
|
|
580
|
-
sendBackwards:
|
|
572
|
+
copyPaste: Ke,
|
|
573
|
+
delete: it,
|
|
574
|
+
lock: $e,
|
|
575
|
+
unlock: qe,
|
|
576
|
+
bringToFront: at,
|
|
577
|
+
sendToBack: nt,
|
|
578
|
+
bringForward: et,
|
|
579
|
+
sendBackwards: tt
|
|
581
580
|
},
|
|
582
581
|
handlers: {
|
|
583
582
|
copyPaste: function() {
|
|
@@ -626,21 +625,21 @@ function j(o) {
|
|
|
626
625
|
for (var e = 1; e < arguments.length; e++) {
|
|
627
626
|
var t = arguments[e] != null ? arguments[e] : {};
|
|
628
627
|
e % 2 ? Ie(Object(t), !0).forEach(function(a) {
|
|
629
|
-
|
|
628
|
+
rt(o, a, t[a]);
|
|
630
629
|
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(o, Object.getOwnPropertyDescriptors(t)) : Ie(Object(t)).forEach(function(a) {
|
|
631
630
|
Object.defineProperty(o, a, Object.getOwnPropertyDescriptor(t, a));
|
|
632
631
|
});
|
|
633
632
|
}
|
|
634
633
|
return o;
|
|
635
634
|
}
|
|
636
|
-
function
|
|
637
|
-
return (e =
|
|
635
|
+
function rt(o, e, t) {
|
|
636
|
+
return (e = ot(e)) in o ? Object.defineProperty(o, e, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : o[e] = t, o;
|
|
638
637
|
}
|
|
639
|
-
function
|
|
640
|
-
var e =
|
|
638
|
+
function ot(o) {
|
|
639
|
+
var e = ct(o, "string");
|
|
641
640
|
return typeof e == "symbol" ? e : e + "";
|
|
642
641
|
}
|
|
643
|
-
function
|
|
642
|
+
function ct(o, e) {
|
|
644
643
|
if (typeof o != "object" || !o) return o;
|
|
645
644
|
var t = o[Symbol.toPrimitive];
|
|
646
645
|
if (t !== void 0) {
|
|
@@ -650,7 +649,7 @@ function ut(o, e) {
|
|
|
650
649
|
}
|
|
651
650
|
return (e === "string" ? String : Number)(o);
|
|
652
651
|
}
|
|
653
|
-
class
|
|
652
|
+
class ut {
|
|
654
653
|
/**
|
|
655
654
|
* @param {object} options
|
|
656
655
|
* @param {ImageEditor} options.editor - экземпляр редактора с доступом к canvas
|
|
@@ -700,16 +699,16 @@ class dt {
|
|
|
700
699
|
this.el.innerHTML = "";
|
|
701
700
|
var a = function() {
|
|
702
701
|
var {
|
|
703
|
-
name:
|
|
704
|
-
handle:
|
|
702
|
+
name: s,
|
|
703
|
+
handle: r
|
|
705
704
|
} = n, {
|
|
706
705
|
icons: c,
|
|
707
706
|
btnStyle: u,
|
|
708
707
|
handlers: l
|
|
709
708
|
} = t.config, d = document.createElement("button");
|
|
710
|
-
d.innerHTML = c[
|
|
709
|
+
d.innerHTML = c[r] ? '<img src="'.concat(c[r], '" title="').concat(s, '" />') : s, Object.assign(d.style, u), d.onclick = () => {
|
|
711
710
|
var h;
|
|
712
|
-
return (h = l[
|
|
711
|
+
return (h = l[r]) === null || h === void 0 ? void 0 : h.call(l, t.editor);
|
|
713
712
|
}, t.el.appendChild(d);
|
|
714
713
|
};
|
|
715
714
|
for (var n of e)
|
|
@@ -782,12 +781,12 @@ class dt {
|
|
|
782
781
|
canvas: n
|
|
783
782
|
} = this;
|
|
784
783
|
e.setCoords();
|
|
785
|
-
var i = n.getZoom(), [, , , ,
|
|
784
|
+
var i = n.getZoom(), [, , , , s, r] = n.viewportTransform, {
|
|
786
785
|
x: c
|
|
787
786
|
} = e.getCenterPoint(), {
|
|
788
787
|
top: u,
|
|
789
788
|
height: l
|
|
790
|
-
} = e.getBoundingRect(!1, !0), d = c * i +
|
|
789
|
+
} = e.getBoundingRect(!1, !0), d = c * i + s, h = d - t.offsetWidth / 2, g = (u + l) * i + r + a.offsetTop;
|
|
791
790
|
Object.assign(t.style, {
|
|
792
791
|
left: "".concat(h, "px"),
|
|
793
792
|
top: "".concat(g, "px"),
|
|
@@ -802,39 +801,9 @@ class dt {
|
|
|
802
801
|
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();
|
|
803
802
|
}
|
|
804
803
|
}
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
} catch (u) {
|
|
809
|
-
return void t(u);
|
|
810
|
-
}
|
|
811
|
-
s.done ? e(c) : Promise.resolve(c).then(a, n);
|
|
812
|
-
}
|
|
813
|
-
function te(o) {
|
|
814
|
-
return function() {
|
|
815
|
-
var e = this, t = arguments;
|
|
816
|
-
return new Promise(function(a, n) {
|
|
817
|
-
var i = o.apply(e, t);
|
|
818
|
-
function r(c) {
|
|
819
|
-
Ae(i, a, n, r, s, "next", c);
|
|
820
|
-
}
|
|
821
|
-
function s(c) {
|
|
822
|
-
Ae(i, a, n, r, s, "throw", c);
|
|
823
|
-
}
|
|
824
|
-
r(void 0);
|
|
825
|
-
});
|
|
826
|
-
};
|
|
827
|
-
}
|
|
828
|
-
class lt {
|
|
829
|
-
/**
|
|
830
|
-
* @param {object} options
|
|
831
|
-
* @param {ImageEditor} options.editor - экземпляр редактора с доступом к canvas
|
|
832
|
-
*/
|
|
833
|
-
constructor(e) {
|
|
834
|
-
var {
|
|
835
|
-
editor: t
|
|
836
|
-
} = e;
|
|
837
|
-
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();
|
|
804
|
+
class dt {
|
|
805
|
+
constructor({ editor: e }) {
|
|
806
|
+
this.editor = e, this.canvas = e.canvas, this._historySuspendCount = 0, this.baseState = null, this.patches = [], this.currentIndex = 0, this.maxHistoryLength = e.options.maxHistoryLength, this.totalChangesCount = 0, this.baseStateChangesCount = 0, this._createDiffPatcher();
|
|
838
807
|
}
|
|
839
808
|
/** Проверка, нужно ли пропускать сохранение истории */
|
|
840
809
|
get skipHistory() {
|
|
@@ -844,15 +813,31 @@ class lt {
|
|
|
844
813
|
return this.patches[this.currentIndex - 1] || null;
|
|
845
814
|
}
|
|
846
815
|
_createDiffPatcher() {
|
|
847
|
-
this.diffPatcher =
|
|
816
|
+
this.diffPatcher = Ue({
|
|
848
817
|
objectHash(e) {
|
|
849
|
-
|
|
818
|
+
const t = e;
|
|
819
|
+
return [
|
|
820
|
+
t.id,
|
|
821
|
+
t.format,
|
|
822
|
+
t.locked,
|
|
823
|
+
t.left,
|
|
824
|
+
t.top,
|
|
825
|
+
t.width,
|
|
826
|
+
t.height,
|
|
827
|
+
t.flipX,
|
|
828
|
+
t.flipY,
|
|
829
|
+
t.scaleX,
|
|
830
|
+
t.scaleY,
|
|
831
|
+
t.angle,
|
|
832
|
+
t.opacity
|
|
833
|
+
].join("-");
|
|
850
834
|
},
|
|
851
835
|
arrays: {
|
|
852
836
|
detectMove: !0,
|
|
853
837
|
includeValueOnMove: !1
|
|
854
838
|
},
|
|
855
839
|
textDiff: {
|
|
840
|
+
diffMatchPatch: Re,
|
|
856
841
|
minLength: 60
|
|
857
842
|
}
|
|
858
843
|
});
|
|
@@ -883,11 +868,9 @@ class lt {
|
|
|
883
868
|
* Получаем полное состояние, применяя все диффы к базовому состоянию.
|
|
884
869
|
*/
|
|
885
870
|
getFullState() {
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
patches: a
|
|
890
|
-
} = this, n = JSON.parse(JSON.stringify(e)), i = 0; i < t; i += 1)
|
|
871
|
+
const { baseState: e, currentIndex: t, patches: a } = this;
|
|
872
|
+
let n = JSON.parse(JSON.stringify(e));
|
|
873
|
+
for (let i = 0; i < t; i += 1)
|
|
891
874
|
n = this.diffPatcher.patch(n, a[i].diff);
|
|
892
875
|
return console.log("getFullState state", n), n;
|
|
893
876
|
}
|
|
@@ -895,147 +878,155 @@ class lt {
|
|
|
895
878
|
* Сохраняем текущее состояние в виде диффа от последнего сохранённого полного состояния.
|
|
896
879
|
*/
|
|
897
880
|
saveState() {
|
|
898
|
-
if (console.log("saveState"),
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
881
|
+
if (console.log("saveState"), this.skipHistory) return;
|
|
882
|
+
console.time("saveState");
|
|
883
|
+
const e = this.canvas.toDatalessObject([
|
|
884
|
+
"selectable",
|
|
885
|
+
"evented",
|
|
886
|
+
"id",
|
|
887
|
+
"format",
|
|
888
|
+
"width",
|
|
889
|
+
"height",
|
|
890
|
+
"locked",
|
|
891
|
+
"lockMovementX",
|
|
892
|
+
"lockMovementY",
|
|
893
|
+
"lockRotation",
|
|
894
|
+
"lockScalingX",
|
|
895
|
+
"lockScalingY",
|
|
896
|
+
"lockSkewingX",
|
|
897
|
+
"lockSkewingY"
|
|
898
|
+
]);
|
|
899
|
+
if (console.timeEnd("saveState"), !this.baseState) {
|
|
900
|
+
this.baseState = e, this.patches = [], this.currentIndex = 0, console.log("Базовое состояние сохранено.");
|
|
901
|
+
return;
|
|
902
|
+
}
|
|
903
|
+
const t = this.getFullState(), a = this.diffPatcher.diff(t, e);
|
|
904
|
+
if (!a) {
|
|
905
|
+
console.log("Нет изменений для сохранения.");
|
|
906
|
+
return;
|
|
914
907
|
}
|
|
908
|
+
console.log("baseState", this.baseState), this.currentIndex < this.patches.length && this.patches.splice(this.currentIndex), console.log("diff", a), this.totalChangesCount += 1, this.patches.push({ id: A(), diff: a }), this.currentIndex += 1, this.patches.length > this.maxHistoryLength && (this.baseState = this.diffPatcher.patch(this.baseState, this.patches[0].diff), this.patches.shift(), this.currentIndex -= 1, this.baseStateChangesCount += 1), console.log("Состояние сохранено. Текущий индекс истории:", this.currentIndex);
|
|
915
909
|
}
|
|
916
910
|
/**
|
|
917
911
|
* Функция загрузки состояния в канвас.
|
|
918
|
-
* @param {
|
|
912
|
+
* @param {Partial<Canvas>} fullState - полное состояние канваса
|
|
919
913
|
* @fires editor:history-state-loaded
|
|
920
914
|
*/
|
|
921
915
|
loadStateFromFullState(e) {
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
fullState: e,
|
|
940
|
-
currentIndex: t.currentIndex,
|
|
941
|
-
totalChangesCount: t.totalChangesCount,
|
|
942
|
-
baseStateChangesCount: t.baseStateChangesCount,
|
|
943
|
-
patchesCount: t.patches.length,
|
|
944
|
-
patches: t.patches
|
|
945
|
-
});
|
|
946
|
-
}
|
|
947
|
-
})();
|
|
916
|
+
return O(this, null, function* () {
|
|
917
|
+
if (!e) return;
|
|
918
|
+
console.log("loadStateFromFullState fullState", e);
|
|
919
|
+
const { canvas: t, canvasManager: a, interactionBlocker: n } = this.editor, { width: i, height: s } = t;
|
|
920
|
+
yield t.loadFromJSON(e);
|
|
921
|
+
const r = t.getObjects().find((u) => u.id === "montage-area");
|
|
922
|
+
r && (this.editor.montageArea = r, (i !== e.width || s !== e.height) && a.updateCanvasAndFitObjects());
|
|
923
|
+
const c = t.getObjects().find((u) => u.id === "overlay-mask");
|
|
924
|
+
c && (n.overlayMask = c, n.overlayMask.visible = !1), t.renderAll(), t.fire("editor:history-state-loaded", {
|
|
925
|
+
fullState: e,
|
|
926
|
+
currentIndex: this.currentIndex,
|
|
927
|
+
totalChangesCount: this.totalChangesCount,
|
|
928
|
+
baseStateChangesCount: this.baseStateChangesCount,
|
|
929
|
+
patchesCount: this.patches.length,
|
|
930
|
+
patches: this.patches
|
|
931
|
+
});
|
|
932
|
+
});
|
|
948
933
|
}
|
|
949
934
|
/**
|
|
950
935
|
* Undo – отмена последнего действия, восстанавливая состояние по накопленным диффам.
|
|
951
936
|
* @fires editor:undo
|
|
952
937
|
*/
|
|
953
938
|
undo() {
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
if (e.currentIndex <= 0) {
|
|
939
|
+
return O(this, null, function* () {
|
|
940
|
+
if (!this.skipHistory) {
|
|
941
|
+
if (this.currentIndex <= 0) {
|
|
958
942
|
console.log("Нет предыдущих состояний для отмены.");
|
|
959
943
|
return;
|
|
960
944
|
}
|
|
961
|
-
|
|
945
|
+
this.suspendHistory();
|
|
962
946
|
try {
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
yield
|
|
966
|
-
fullState:
|
|
967
|
-
currentIndex:
|
|
968
|
-
totalChangesCount:
|
|
969
|
-
baseStateChangesCount:
|
|
970
|
-
patchesCount:
|
|
971
|
-
patches:
|
|
947
|
+
this.currentIndex -= 1, this.totalChangesCount -= 1;
|
|
948
|
+
const e = this.getFullState();
|
|
949
|
+
yield this.loadStateFromFullState(e), console.log("Undo выполнен. Текущий индекс истории:", this.currentIndex), this.canvas.fire("editor:undo", {
|
|
950
|
+
fullState: e,
|
|
951
|
+
currentIndex: this.currentIndex,
|
|
952
|
+
totalChangesCount: this.totalChangesCount,
|
|
953
|
+
baseStateChangesCount: this.baseStateChangesCount,
|
|
954
|
+
patchesCount: this.patches.length,
|
|
955
|
+
patches: this.patches
|
|
972
956
|
});
|
|
973
|
-
} catch (
|
|
974
|
-
|
|
975
|
-
|
|
957
|
+
} catch (e) {
|
|
958
|
+
this.editor.errorManager.emitError({
|
|
959
|
+
origin: "HistoryManager",
|
|
960
|
+
method: "undo",
|
|
961
|
+
code: "UNDO_ERROR",
|
|
962
|
+
message: "Ошибка отмены действия",
|
|
963
|
+
data: e
|
|
976
964
|
});
|
|
977
965
|
} finally {
|
|
978
|
-
|
|
966
|
+
this.resumeHistory();
|
|
979
967
|
}
|
|
980
968
|
}
|
|
981
|
-
})
|
|
969
|
+
});
|
|
982
970
|
}
|
|
983
971
|
/**
|
|
984
972
|
* Redo – повтор ранее отменённого действия.
|
|
985
973
|
* @fires editor:redo
|
|
986
974
|
*/
|
|
987
975
|
redo() {
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
if (e.currentIndex >= e.patches.length) {
|
|
976
|
+
return O(this, null, function* () {
|
|
977
|
+
if (!this.skipHistory) {
|
|
978
|
+
if (this.currentIndex >= this.patches.length) {
|
|
992
979
|
console.log("Нет состояний для повтора.");
|
|
993
980
|
return;
|
|
994
981
|
}
|
|
995
|
-
|
|
982
|
+
this.suspendHistory();
|
|
996
983
|
try {
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
console.log("fullState",
|
|
1000
|
-
fullState:
|
|
1001
|
-
currentIndex:
|
|
1002
|
-
totalChangesCount:
|
|
1003
|
-
baseStateChangesCount:
|
|
1004
|
-
patchesCount:
|
|
1005
|
-
patches:
|
|
984
|
+
this.currentIndex += 1, this.totalChangesCount += 1;
|
|
985
|
+
const e = this.getFullState();
|
|
986
|
+
console.log("fullState", e), yield this.loadStateFromFullState(e), console.log("Redo выполнен. Текущий индекс истории:", this.currentIndex), this.canvas.fire("editor:redo", {
|
|
987
|
+
fullState: e,
|
|
988
|
+
currentIndex: this.currentIndex,
|
|
989
|
+
totalChangesCount: this.totalChangesCount,
|
|
990
|
+
baseStateChangesCount: this.baseStateChangesCount,
|
|
991
|
+
patchesCount: this.patches.length,
|
|
992
|
+
patches: this.patches
|
|
1006
993
|
});
|
|
1007
|
-
} catch (
|
|
1008
|
-
|
|
1009
|
-
|
|
994
|
+
} catch (e) {
|
|
995
|
+
this.editor.errorManager.emitError({
|
|
996
|
+
origin: "HistoryManager",
|
|
997
|
+
method: "redo",
|
|
998
|
+
code: "REDO_ERROR",
|
|
999
|
+
message: "Ошибка повтора действия",
|
|
1000
|
+
data: e
|
|
1010
1001
|
});
|
|
1011
1002
|
} finally {
|
|
1012
|
-
|
|
1003
|
+
this.resumeHistory();
|
|
1013
1004
|
}
|
|
1014
1005
|
}
|
|
1015
|
-
})
|
|
1006
|
+
});
|
|
1016
1007
|
}
|
|
1017
1008
|
}
|
|
1018
|
-
const
|
|
1019
|
-
function
|
|
1009
|
+
const lt = 0.1, ht = 2, gt = 0.1, Mt = 90, B = 16, Z = 16, T = 4096, k = 4096;
|
|
1010
|
+
function Ae(o, e, t, a, n, i, s) {
|
|
1020
1011
|
try {
|
|
1021
|
-
var
|
|
1012
|
+
var r = o[i](s), c = r.value;
|
|
1022
1013
|
} catch (u) {
|
|
1023
1014
|
return void t(u);
|
|
1024
1015
|
}
|
|
1025
|
-
|
|
1016
|
+
r.done ? e(c) : Promise.resolve(c).then(a, n);
|
|
1026
1017
|
}
|
|
1027
|
-
function
|
|
1018
|
+
function x(o) {
|
|
1028
1019
|
return function() {
|
|
1029
1020
|
var e = this, t = arguments;
|
|
1030
1021
|
return new Promise(function(a, n) {
|
|
1031
1022
|
var i = o.apply(e, t);
|
|
1032
|
-
function r(c) {
|
|
1033
|
-
Se(i, a, n, r, s, "next", c);
|
|
1034
|
-
}
|
|
1035
1023
|
function s(c) {
|
|
1036
|
-
|
|
1024
|
+
Ae(i, a, n, s, r, "next", c);
|
|
1025
|
+
}
|
|
1026
|
+
function r(c) {
|
|
1027
|
+
Ae(i, a, n, s, r, "throw", c);
|
|
1037
1028
|
}
|
|
1038
|
-
|
|
1029
|
+
s(void 0);
|
|
1039
1030
|
});
|
|
1040
1031
|
};
|
|
1041
1032
|
}
|
|
@@ -1064,7 +1055,7 @@ class D {
|
|
|
1064
1055
|
*/
|
|
1065
1056
|
importImage(e) {
|
|
1066
1057
|
var t = this;
|
|
1067
|
-
return
|
|
1058
|
+
return x(function* () {
|
|
1068
1059
|
var {
|
|
1069
1060
|
source: a,
|
|
1070
1061
|
scale: n = "image-".concat(t.options.scaleType),
|
|
@@ -1072,14 +1063,14 @@ class D {
|
|
|
1072
1063
|
} = e;
|
|
1073
1064
|
if (!a) return null;
|
|
1074
1065
|
var {
|
|
1075
|
-
canvas:
|
|
1076
|
-
montageArea:
|
|
1066
|
+
canvas: s,
|
|
1067
|
+
montageArea: r,
|
|
1077
1068
|
transformManager: c,
|
|
1078
1069
|
historyManager: u,
|
|
1079
1070
|
errorManager: l
|
|
1080
1071
|
} = t.editor, d = yield t.getContentType(a), h = D.getFormatFromContentType(d), {
|
|
1081
1072
|
acceptContentTypes: g,
|
|
1082
|
-
acceptFormats:
|
|
1073
|
+
acceptFormats: m
|
|
1083
1074
|
} = t;
|
|
1084
1075
|
if (!t.isAllowedContentType(d)) {
|
|
1085
1076
|
var f = "Неверный contentType для изображения: ".concat(d, ". Ожидается один из: ").concat(t.acceptContentTypes.join(", "), ".");
|
|
@@ -1093,23 +1084,23 @@ class D {
|
|
|
1093
1084
|
format: h,
|
|
1094
1085
|
contentType: d,
|
|
1095
1086
|
acceptContentTypes: g,
|
|
1096
|
-
acceptFormats:
|
|
1087
|
+
acceptFormats: m
|
|
1097
1088
|
}
|
|
1098
1089
|
}), null;
|
|
1099
1090
|
}
|
|
1100
1091
|
u.suspendHistory();
|
|
1101
1092
|
try {
|
|
1102
|
-
var
|
|
1093
|
+
var v, M;
|
|
1103
1094
|
if (a instanceof File)
|
|
1104
|
-
|
|
1095
|
+
v = URL.createObjectURL(a);
|
|
1105
1096
|
else if (typeof a == "string") {
|
|
1106
1097
|
var S = yield fetch(a, {
|
|
1107
1098
|
mode: "cors"
|
|
1108
|
-
}),
|
|
1099
|
+
}), E = yield S.blob({
|
|
1109
1100
|
type: d,
|
|
1110
1101
|
quality: 1
|
|
1111
1102
|
});
|
|
1112
|
-
|
|
1103
|
+
v = URL.createObjectURL(E);
|
|
1113
1104
|
} else
|
|
1114
1105
|
return l.emitError({
|
|
1115
1106
|
origin: "ImageManager",
|
|
@@ -1121,64 +1112,64 @@ class D {
|
|
|
1121
1112
|
format: h,
|
|
1122
1113
|
contentType: d,
|
|
1123
1114
|
acceptContentTypes: g,
|
|
1124
|
-
acceptFormats:
|
|
1115
|
+
acceptFormats: m
|
|
1125
1116
|
}
|
|
1126
1117
|
}), null;
|
|
1127
|
-
if (t._createdBlobUrls.push(
|
|
1128
|
-
var
|
|
1129
|
-
|
|
1118
|
+
if (t._createdBlobUrls.push(v), h === "svg") {
|
|
1119
|
+
var L = yield Te(v);
|
|
1120
|
+
M = W.groupSVGElements(L.objects, L.options);
|
|
1130
1121
|
} else
|
|
1131
|
-
|
|
1122
|
+
M = yield ee.fromURL(v, {
|
|
1132
1123
|
crossOrigin: "anonymous"
|
|
1133
1124
|
});
|
|
1134
1125
|
var {
|
|
1135
|
-
width:
|
|
1126
|
+
width: w,
|
|
1136
1127
|
height: y
|
|
1137
|
-
} =
|
|
1138
|
-
if (y >
|
|
1139
|
-
var b = yield t.resizeImageToBoundaries(
|
|
1140
|
-
t._createdBlobUrls.push(
|
|
1128
|
+
} = M;
|
|
1129
|
+
if (y > k || w > T) {
|
|
1130
|
+
var b = yield t.resizeImageToBoundaries(M._element.src, "max"), z = URL.createObjectURL(b);
|
|
1131
|
+
t._createdBlobUrls.push(z), M = yield ee.fromURL(z, {
|
|
1141
1132
|
crossOrigin: "anonymous"
|
|
1142
1133
|
});
|
|
1143
|
-
} else if (y <
|
|
1144
|
-
var
|
|
1145
|
-
t._createdBlobUrls.push(
|
|
1134
|
+
} else if (y < Z || w < B) {
|
|
1135
|
+
var F = yield t.resizeImageToBoundaries(M._element.src, "min"), U = URL.createObjectURL(F);
|
|
1136
|
+
t._createdBlobUrls.push(U), M = yield ee.fromURL(U, {
|
|
1146
1137
|
crossOrigin: "anonymous"
|
|
1147
1138
|
});
|
|
1148
1139
|
}
|
|
1149
|
-
if (
|
|
1140
|
+
if (M.set("id", "".concat(M.type, "-").concat(A())), M.set("format", h), n === "scale-montage")
|
|
1150
1141
|
t.editor.canvasManager.scaleMontageAreaToImage({
|
|
1151
|
-
object:
|
|
1142
|
+
object: M,
|
|
1152
1143
|
withoutSave: !0
|
|
1153
1144
|
});
|
|
1154
1145
|
else {
|
|
1155
1146
|
var {
|
|
1156
|
-
width:
|
|
1157
|
-
height:
|
|
1158
|
-
} =
|
|
1159
|
-
imageObject:
|
|
1147
|
+
width: V,
|
|
1148
|
+
height: R
|
|
1149
|
+
} = r, _ = t.calculateScaleFactor({
|
|
1150
|
+
imageObject: M,
|
|
1160
1151
|
scaleType: n
|
|
1161
1152
|
});
|
|
1162
1153
|
n === "image-contain" && _ < 1 ? c.fitObject({
|
|
1163
|
-
object:
|
|
1154
|
+
object: M,
|
|
1164
1155
|
type: "contain",
|
|
1165
1156
|
withoutSave: !0
|
|
1166
|
-
}) : n === "image-cover" && (
|
|
1167
|
-
object:
|
|
1157
|
+
}) : n === "image-cover" && (w > V || y > R) && c.fitObject({
|
|
1158
|
+
object: M,
|
|
1168
1159
|
type: "cover",
|
|
1169
1160
|
withoutSave: !0
|
|
1170
1161
|
});
|
|
1171
1162
|
}
|
|
1172
|
-
|
|
1173
|
-
var
|
|
1174
|
-
image:
|
|
1163
|
+
s.add(M), s.centerObject(M), s.setActiveObject(M), s.renderAll(), u.resumeHistory(), i || u.saveState();
|
|
1164
|
+
var G = {
|
|
1165
|
+
image: M,
|
|
1175
1166
|
format: h,
|
|
1176
1167
|
contentType: d,
|
|
1177
1168
|
scale: n,
|
|
1178
1169
|
withoutSave: i,
|
|
1179
1170
|
source: a
|
|
1180
1171
|
};
|
|
1181
|
-
return
|
|
1172
|
+
return s.fire("editor:image-imported", G), G;
|
|
1182
1173
|
} catch (H) {
|
|
1183
1174
|
return l.emitError({
|
|
1184
1175
|
origin: "ImageManager",
|
|
@@ -1206,24 +1197,24 @@ class D {
|
|
|
1206
1197
|
*/
|
|
1207
1198
|
resizeImageToBoundaries(e) {
|
|
1208
1199
|
var t = arguments, a = this;
|
|
1209
|
-
return
|
|
1210
|
-
var n = t.length > 1 && t[1] !== void 0 ? t[1] : "max", i = "Размер изображения больше максимального размера канваса, поэтому оно будет уменьшено до максимальных размеров c сохранением пропорций: ".concat(
|
|
1211
|
-
n === "min" && (i = "Размер изображения меньше минимального размера канваса, поэтому оно будет увеличено до минимальных размеров c сохранением пропорций: ".concat(
|
|
1212
|
-
var
|
|
1200
|
+
return x(function* () {
|
|
1201
|
+
var n = t.length > 1 && t[1] !== void 0 ? t[1] : "max", i = "Размер изображения больше максимального размера канваса, поэтому оно будет уменьшено до максимальных размеров c сохранением пропорций: ".concat(T, "x").concat(k);
|
|
1202
|
+
n === "min" && (i = "Размер изображения меньше минимального размера канваса, поэтому оно будет увеличено до минимальных размеров c сохранением пропорций: ".concat(B, "x").concat(Z));
|
|
1203
|
+
var s = {
|
|
1213
1204
|
dataURL: e,
|
|
1214
1205
|
sizeType: n,
|
|
1215
|
-
maxWidth:
|
|
1216
|
-
maxHeight:
|
|
1217
|
-
minWidth:
|
|
1218
|
-
minHeight:
|
|
1206
|
+
maxWidth: T,
|
|
1207
|
+
maxHeight: k,
|
|
1208
|
+
minWidth: B,
|
|
1209
|
+
minHeight: Z
|
|
1219
1210
|
};
|
|
1220
1211
|
return a.editor.errorManager.emitWarning({
|
|
1221
1212
|
origin: "ImageManager",
|
|
1222
1213
|
method: "resizeImageToBoundaries",
|
|
1223
1214
|
code: "IMAGE_RESIZE_WARNING",
|
|
1224
1215
|
message: i,
|
|
1225
|
-
data:
|
|
1226
|
-
}), a.editor.workerManager.post("resizeImage",
|
|
1216
|
+
data: s
|
|
1217
|
+
}), a.editor.workerManager.post("resizeImage", s);
|
|
1227
1218
|
})();
|
|
1228
1219
|
}
|
|
1229
1220
|
/**
|
|
@@ -1239,14 +1230,14 @@ class D {
|
|
|
1239
1230
|
*/
|
|
1240
1231
|
exportCanvasAsImageFile() {
|
|
1241
1232
|
var e = arguments, t = this;
|
|
1242
|
-
return
|
|
1233
|
+
return x(function* () {
|
|
1243
1234
|
var {
|
|
1244
1235
|
fileName: a = "image.png",
|
|
1245
1236
|
contentType: n = "image/png",
|
|
1246
1237
|
exportAsBase64: i = !1,
|
|
1247
|
-
exportAsBlob:
|
|
1238
|
+
exportAsBlob: s = !1
|
|
1248
1239
|
} = e.length > 0 && e[0] !== void 0 ? e[0] : {}, {
|
|
1249
|
-
canvas:
|
|
1240
|
+
canvas: r,
|
|
1250
1241
|
montageArea: c,
|
|
1251
1242
|
workerManager: u
|
|
1252
1243
|
} = t.editor;
|
|
@@ -1255,94 +1246,94 @@ class D {
|
|
|
1255
1246
|
c.setCoords();
|
|
1256
1247
|
var {
|
|
1257
1248
|
left: g,
|
|
1258
|
-
top:
|
|
1249
|
+
top: m,
|
|
1259
1250
|
width: f,
|
|
1260
|
-
height:
|
|
1261
|
-
} = c.getBoundingRect(),
|
|
1262
|
-
["image/jpg", "image/jpeg"].includes(d) && (
|
|
1263
|
-
var S =
|
|
1264
|
-
S.visible = !1,
|
|
1251
|
+
height: v
|
|
1252
|
+
} = c.getBoundingRect(), M = yield r.clone(["id", "format", "locked"]);
|
|
1253
|
+
["image/jpg", "image/jpeg"].includes(d) && (M.backgroundColor = "#ffffff");
|
|
1254
|
+
var S = M.getObjects().find((p) => p.id === c.id);
|
|
1255
|
+
S.visible = !1, M.viewportTransform = [1, 0, 0, 1, -g, -m], M.setDimensions({
|
|
1265
1256
|
width: f,
|
|
1266
|
-
height:
|
|
1257
|
+
height: v
|
|
1267
1258
|
}, {
|
|
1268
1259
|
backstoreOnly: !0
|
|
1269
|
-
}),
|
|
1270
|
-
var
|
|
1271
|
-
if (h === "svg" &&
|
|
1272
|
-
var
|
|
1273
|
-
|
|
1274
|
-
var
|
|
1260
|
+
}), M.renderAll();
|
|
1261
|
+
var E = M.getObjects().filter((p) => p.format).every((p) => p.format === "svg");
|
|
1262
|
+
if (h === "svg" && E) {
|
|
1263
|
+
var L = M.toSVG();
|
|
1264
|
+
M.dispose();
|
|
1265
|
+
var w = D._exportSVGStringAsFile(L, {
|
|
1275
1266
|
exportAsBase64: i,
|
|
1276
|
-
exportAsBlob:
|
|
1267
|
+
exportAsBlob: s,
|
|
1277
1268
|
fileName: a
|
|
1278
1269
|
}), y = {
|
|
1279
|
-
image:
|
|
1270
|
+
image: w,
|
|
1280
1271
|
format: "svg",
|
|
1281
1272
|
contentType: "image/svg+xml",
|
|
1282
1273
|
fileName: a.replace(/\.[^/.]+$/, ".svg")
|
|
1283
1274
|
};
|
|
1284
|
-
return
|
|
1275
|
+
return r.fire("editor:canvas-exported", y), y;
|
|
1285
1276
|
}
|
|
1286
1277
|
var b = yield new Promise((p) => {
|
|
1287
|
-
|
|
1278
|
+
M.getElement().toBlob(p);
|
|
1288
1279
|
});
|
|
1289
|
-
if (
|
|
1290
|
-
var
|
|
1280
|
+
if (M.dispose(), s) {
|
|
1281
|
+
var z = {
|
|
1291
1282
|
image: b,
|
|
1292
1283
|
format: h,
|
|
1293
1284
|
contentType: d,
|
|
1294
1285
|
fileName: a
|
|
1295
1286
|
};
|
|
1296
|
-
return
|
|
1287
|
+
return r.fire("editor:canvas-exported", z), z;
|
|
1297
1288
|
}
|
|
1298
|
-
var
|
|
1289
|
+
var F = yield createImageBitmap(b), U = yield u.post("toDataURL", {
|
|
1299
1290
|
format: h,
|
|
1300
1291
|
quality: 1,
|
|
1301
|
-
bitmap:
|
|
1302
|
-
}, [
|
|
1292
|
+
bitmap: F
|
|
1293
|
+
}, [F]);
|
|
1303
1294
|
if (l) {
|
|
1304
|
-
var
|
|
1305
|
-
orientation:
|
|
1295
|
+
var V = 0.264583, R = f * V, _ = v * V, G = (yield t.editor.moduleLoader.loadModule("jspdf")).jsPDF, H = new G({
|
|
1296
|
+
orientation: R > _ ? "landscape" : "portrait",
|
|
1306
1297
|
unit: "mm",
|
|
1307
|
-
format: [
|
|
1298
|
+
format: [R, _]
|
|
1308
1299
|
});
|
|
1309
|
-
if (H.addImage(
|
|
1310
|
-
var
|
|
1311
|
-
image:
|
|
1300
|
+
if (H.addImage(U, "JPG", 0, 0, R, _), i) {
|
|
1301
|
+
var Ce = H.output("datauristring"), de = {
|
|
1302
|
+
image: Ce,
|
|
1312
1303
|
format: "pdf",
|
|
1313
1304
|
contentType: "application/pdf",
|
|
1314
1305
|
fileName: a
|
|
1315
1306
|
};
|
|
1316
|
-
return
|
|
1307
|
+
return r.fire("editor:canvas-exported", de), de;
|
|
1317
1308
|
}
|
|
1318
|
-
var
|
|
1309
|
+
var De = H.output("blob"), Ne = new File([De], a, {
|
|
1319
1310
|
type: "application/pdf"
|
|
1320
|
-
}),
|
|
1321
|
-
image:
|
|
1311
|
+
}), le = {
|
|
1312
|
+
image: Ne,
|
|
1322
1313
|
format: "pdf",
|
|
1323
1314
|
contentType: "application/pdf",
|
|
1324
1315
|
fileName: a
|
|
1325
1316
|
};
|
|
1326
|
-
return
|
|
1317
|
+
return r.fire("editor:canvas-exported", le), le;
|
|
1327
1318
|
}
|
|
1328
1319
|
if (i) {
|
|
1329
|
-
var
|
|
1330
|
-
image:
|
|
1320
|
+
var he = {
|
|
1321
|
+
image: U,
|
|
1331
1322
|
format: h,
|
|
1332
1323
|
contentType: d,
|
|
1333
1324
|
fileName: a
|
|
1334
1325
|
};
|
|
1335
|
-
return
|
|
1326
|
+
return r.fire("editor:canvas-exported", he), he;
|
|
1336
1327
|
}
|
|
1337
|
-
var
|
|
1328
|
+
var ge = h === "svg" && !E ? a.replace(/\.[^/.]+$/, ".png") : a, Ee = new File([b], ge, {
|
|
1338
1329
|
type: d
|
|
1339
1330
|
}), Me = {
|
|
1340
|
-
image:
|
|
1331
|
+
image: Ee,
|
|
1341
1332
|
format: h,
|
|
1342
1333
|
contentType: d,
|
|
1343
|
-
fileName:
|
|
1334
|
+
fileName: ge
|
|
1344
1335
|
};
|
|
1345
|
-
return
|
|
1336
|
+
return r.fire("editor:canvas-exported", Me), Me;
|
|
1346
1337
|
} catch (p) {
|
|
1347
1338
|
return t.editor.errorManager.emitError({
|
|
1348
1339
|
origin: "ImageManager",
|
|
@@ -1353,7 +1344,7 @@ class D {
|
|
|
1353
1344
|
contentType: n,
|
|
1354
1345
|
fileName: a,
|
|
1355
1346
|
exportAsBase64: i,
|
|
1356
|
-
exportAsBlob:
|
|
1347
|
+
exportAsBlob: s
|
|
1357
1348
|
}
|
|
1358
1349
|
}), "";
|
|
1359
1350
|
}
|
|
@@ -1372,13 +1363,13 @@ class D {
|
|
|
1372
1363
|
*/
|
|
1373
1364
|
exportObjectAsImageFile() {
|
|
1374
1365
|
var e = arguments, t = this;
|
|
1375
|
-
return
|
|
1366
|
+
return x(function* () {
|
|
1376
1367
|
var {
|
|
1377
1368
|
object: a,
|
|
1378
1369
|
fileName: n = "image.png",
|
|
1379
1370
|
contentType: i = "image/png",
|
|
1380
|
-
exportAsBase64:
|
|
1381
|
-
exportAsBlob:
|
|
1371
|
+
exportAsBase64: s = !1,
|
|
1372
|
+
exportAsBlob: r = !1
|
|
1382
1373
|
} = e.length > 0 && e[0] !== void 0 ? e[0] : {}, {
|
|
1383
1374
|
canvas: c,
|
|
1384
1375
|
workerManager: u
|
|
@@ -1392,54 +1383,54 @@ class D {
|
|
|
1392
1383
|
data: {
|
|
1393
1384
|
contentType: i,
|
|
1394
1385
|
fileName: n,
|
|
1395
|
-
exportAsBase64:
|
|
1396
|
-
exportAsBlob:
|
|
1386
|
+
exportAsBase64: s,
|
|
1387
|
+
exportAsBlob: r
|
|
1397
1388
|
}
|
|
1398
1389
|
}), "";
|
|
1399
1390
|
try {
|
|
1400
1391
|
var d = D.getFormatFromContentType(i);
|
|
1401
1392
|
if (d === "svg") {
|
|
1402
1393
|
var h = l.toSVG(), g = t._exportSVGStringAsFile(h, {
|
|
1403
|
-
exportAsBase64:
|
|
1404
|
-
exportAsBlob:
|
|
1394
|
+
exportAsBase64: s,
|
|
1395
|
+
exportAsBlob: r,
|
|
1405
1396
|
fileName: n
|
|
1406
|
-
}),
|
|
1397
|
+
}), m = {
|
|
1407
1398
|
image: g,
|
|
1408
1399
|
format: d,
|
|
1409
1400
|
contentType: "image/svg+xml",
|
|
1410
1401
|
fileName: n.replace(/\.[^/.]+$/, ".svg")
|
|
1411
1402
|
};
|
|
1412
|
-
return c.fire("editor:object-exported",
|
|
1403
|
+
return c.fire("editor:object-exported", m), m;
|
|
1413
1404
|
}
|
|
1414
|
-
if (
|
|
1415
|
-
var f = yield createImageBitmap(l._element),
|
|
1405
|
+
if (s) {
|
|
1406
|
+
var f = yield createImageBitmap(l._element), v = yield u.post("toDataURL", {
|
|
1416
1407
|
format: d,
|
|
1417
1408
|
quality: 1,
|
|
1418
1409
|
bitmap: f
|
|
1419
|
-
}, [f]),
|
|
1420
|
-
image:
|
|
1410
|
+
}, [f]), M = {
|
|
1411
|
+
image: v,
|
|
1421
1412
|
format: d,
|
|
1422
1413
|
contentType: i,
|
|
1423
1414
|
fileName: n
|
|
1424
1415
|
};
|
|
1425
|
-
return c.fire("editor:object-exported",
|
|
1416
|
+
return c.fire("editor:object-exported", M), M;
|
|
1426
1417
|
}
|
|
1427
|
-
var S = l.toCanvasElement(),
|
|
1418
|
+
var S = l.toCanvasElement(), E = yield new Promise((b) => {
|
|
1428
1419
|
S.toBlob(b);
|
|
1429
1420
|
});
|
|
1430
|
-
if (
|
|
1431
|
-
var
|
|
1432
|
-
image:
|
|
1421
|
+
if (r) {
|
|
1422
|
+
var L = {
|
|
1423
|
+
image: E,
|
|
1433
1424
|
format: d,
|
|
1434
1425
|
contentType: i,
|
|
1435
1426
|
fileName: n
|
|
1436
1427
|
};
|
|
1437
|
-
return c.fire("editor:object-exported",
|
|
1428
|
+
return c.fire("editor:object-exported", L), L;
|
|
1438
1429
|
}
|
|
1439
|
-
var
|
|
1430
|
+
var w = new File([E], n, {
|
|
1440
1431
|
type: i
|
|
1441
1432
|
}), y = {
|
|
1442
|
-
image:
|
|
1433
|
+
image: w,
|
|
1443
1434
|
format: d,
|
|
1444
1435
|
contentType: i,
|
|
1445
1436
|
fileName: n
|
|
@@ -1454,8 +1445,8 @@ class D {
|
|
|
1454
1445
|
data: {
|
|
1455
1446
|
contentType: i,
|
|
1456
1447
|
fileName: n,
|
|
1457
|
-
exportAsBase64:
|
|
1458
|
-
exportAsBlob:
|
|
1448
|
+
exportAsBase64: s,
|
|
1449
|
+
exportAsBlob: r
|
|
1459
1450
|
}
|
|
1460
1451
|
}), "";
|
|
1461
1452
|
}
|
|
@@ -1526,7 +1517,7 @@ class D {
|
|
|
1526
1517
|
*/
|
|
1527
1518
|
getContentType(e) {
|
|
1528
1519
|
var t = this;
|
|
1529
|
-
return
|
|
1520
|
+
return x(function* () {
|
|
1530
1521
|
return typeof e == "string" ? t.getContentTypeFromUrl(e) : e.type || "application/octet-stream";
|
|
1531
1522
|
})();
|
|
1532
1523
|
}
|
|
@@ -1538,7 +1529,7 @@ class D {
|
|
|
1538
1529
|
*/
|
|
1539
1530
|
getContentTypeFromUrl(e) {
|
|
1540
1531
|
var t = this;
|
|
1541
|
-
return
|
|
1532
|
+
return x(function* () {
|
|
1542
1533
|
if (e.startsWith("data:")) {
|
|
1543
1534
|
var a = e.match(/^data:([^;]+)/);
|
|
1544
1535
|
return a ? a[1] : "application/octet-stream";
|
|
@@ -1549,8 +1540,8 @@ class D {
|
|
|
1549
1540
|
}), i = n.headers.get("content-type");
|
|
1550
1541
|
if (i && i.startsWith("image/"))
|
|
1551
1542
|
return i.split(";")[0];
|
|
1552
|
-
} catch (
|
|
1553
|
-
console.warn("HEAD запрос неудачен, определяем тип по расширению:",
|
|
1543
|
+
} catch (s) {
|
|
1544
|
+
console.warn("HEAD запрос неудачен, определяем тип по расширению:", s);
|
|
1554
1545
|
}
|
|
1555
1546
|
return t.getContentTypeFromExtension(e);
|
|
1556
1547
|
})();
|
|
@@ -1564,12 +1555,12 @@ class D {
|
|
|
1564
1555
|
getContentTypeFromExtension(e) {
|
|
1565
1556
|
try {
|
|
1566
1557
|
var t, a = new URL(e), n = (t = a.pathname.split(".").pop()) === null || t === void 0 ? void 0 : t.toLowerCase(), i = {};
|
|
1567
|
-
return this.acceptContentTypes.forEach((
|
|
1568
|
-
var
|
|
1569
|
-
|
|
1558
|
+
return this.acceptContentTypes.forEach((s) => {
|
|
1559
|
+
var r = D.getFormatFromContentType(s);
|
|
1560
|
+
r && (i[r] = s);
|
|
1570
1561
|
}), i[n] || "application/octet-stream";
|
|
1571
|
-
} catch (
|
|
1572
|
-
return console.warn("Не удалось определить расширение из URL:", e,
|
|
1562
|
+
} catch (s) {
|
|
1563
|
+
return console.warn("Не удалось определить расширение из URL:", e, s), "application/octet-stream";
|
|
1573
1564
|
}
|
|
1574
1565
|
}
|
|
1575
1566
|
/**
|
|
@@ -1586,11 +1577,11 @@ class D {
|
|
|
1586
1577
|
montageArea: n
|
|
1587
1578
|
} = this.editor;
|
|
1588
1579
|
if (!n || !t) return 1;
|
|
1589
|
-
var i = n.width,
|
|
1590
|
-
width:
|
|
1580
|
+
var i = n.width, s = n.height, {
|
|
1581
|
+
width: r,
|
|
1591
1582
|
height: c
|
|
1592
1583
|
} = t;
|
|
1593
|
-
return a === "contain" || a === "image-contain" ? Math.min(i /
|
|
1584
|
+
return a === "contain" || a === "image-contain" ? Math.min(i / r, s / c) : a === "cover" || a === "image-cover" ? Math.max(i / r, s / c) : 1;
|
|
1594
1585
|
}
|
|
1595
1586
|
}
|
|
1596
1587
|
class mt {
|
|
@@ -1611,19 +1602,19 @@ class mt {
|
|
|
1611
1602
|
* @fires editor:resolution-width-changed
|
|
1612
1603
|
*/
|
|
1613
1604
|
setResolutionWidth(e, { preserveProportional: t, withoutSave: a, adaptCanvasToContainer: n } = {}) {
|
|
1614
|
-
var
|
|
1605
|
+
var m;
|
|
1615
1606
|
if (!e) return;
|
|
1616
1607
|
const {
|
|
1617
1608
|
canvas: i,
|
|
1618
|
-
montageArea:
|
|
1619
|
-
options: { canvasBackstoreWidth:
|
|
1620
|
-
} = this.editor, { width: c, height: u } =
|
|
1621
|
-
if (!
|
|
1622
|
-
const f = l / c,
|
|
1623
|
-
this.setResolutionHeight(
|
|
1609
|
+
montageArea: s,
|
|
1610
|
+
options: { canvasBackstoreWidth: r }
|
|
1611
|
+
} = this.editor, { width: c, height: u } = s, l = Math.max(Math.min(Number(e), T), B);
|
|
1612
|
+
if (!r || r === "auto" || n ? this.adaptCanvasToContainer() : r ? this.setCanvasBackstoreWidth(Number(r)) : this.setCanvasBackstoreWidth(l), s.set({ width: l }), (m = i.clipPath) == null || m.set({ width: l }), t) {
|
|
1613
|
+
const f = l / c, v = u * f;
|
|
1614
|
+
this.setResolutionHeight(v);
|
|
1624
1615
|
return;
|
|
1625
1616
|
}
|
|
1626
|
-
const { left: d, top: h } = this.getObjectDefaultCoords(
|
|
1617
|
+
const { left: d, top: h } = this.getObjectDefaultCoords(s), g = i.getZoom();
|
|
1627
1618
|
i.setViewportTransform([g, 0, 0, g, d, h]), this.centerMontageArea(), a || this.editor.historyManager.saveState(), i.fire("editor:resolution-width-changed", {
|
|
1628
1619
|
width: l,
|
|
1629
1620
|
preserveProportional: t,
|
|
@@ -1641,19 +1632,19 @@ class mt {
|
|
|
1641
1632
|
* @fires editor:resolution-height-changed
|
|
1642
1633
|
*/
|
|
1643
1634
|
setResolutionHeight(e, { preserveProportional: t, withoutSave: a, adaptCanvasToContainer: n } = {}) {
|
|
1644
|
-
var
|
|
1635
|
+
var m;
|
|
1645
1636
|
if (!e) return;
|
|
1646
1637
|
const {
|
|
1647
1638
|
canvas: i,
|
|
1648
|
-
montageArea:
|
|
1649
|
-
options: { canvasBackstoreHeight:
|
|
1650
|
-
} = this.editor, { width: c, height: u } =
|
|
1651
|
-
if (!
|
|
1652
|
-
const f = l / u,
|
|
1653
|
-
this.setResolutionWidth(
|
|
1639
|
+
montageArea: s,
|
|
1640
|
+
options: { canvasBackstoreHeight: r }
|
|
1641
|
+
} = this.editor, { width: c, height: u } = s, l = Math.max(Math.min(Number(e), k), Z);
|
|
1642
|
+
if (!r || r === "auto" || n ? this.adaptCanvasToContainer() : r ? this.setCanvasBackstoreHeight(Number(r)) : this.setCanvasBackstoreHeight(l), s.set({ height: l }), (m = i.clipPath) == null || m.set({ height: l }), t) {
|
|
1643
|
+
const f = l / u, v = c * f;
|
|
1644
|
+
this.setResolutionWidth(v);
|
|
1654
1645
|
return;
|
|
1655
1646
|
}
|
|
1656
|
-
const { left: d, top: h } = this.getObjectDefaultCoords(
|
|
1647
|
+
const { left: d, top: h } = this.getObjectDefaultCoords(s), g = i.getZoom();
|
|
1657
1648
|
i.setViewportTransform([g, 0, 0, g, d, h]), this.centerMontageArea(), a || this.editor.historyManager.saveState(), i.fire("editor:resolution-height-changed", {
|
|
1658
1649
|
height: l,
|
|
1659
1650
|
preserveProportional: t,
|
|
@@ -1667,7 +1658,7 @@ class mt {
|
|
|
1667
1658
|
*/
|
|
1668
1659
|
centerMontageArea() {
|
|
1669
1660
|
var c;
|
|
1670
|
-
const { canvas: e, montageArea: t } = this.editor, a = e.getWidth(), n = e.getHeight(), i = e.getZoom(),
|
|
1661
|
+
const { canvas: e, montageArea: t } = this.editor, a = e.getWidth(), n = e.getHeight(), i = e.getZoom(), s = new K(a / 2, n / 2);
|
|
1671
1662
|
t.set({
|
|
1672
1663
|
left: a / 2,
|
|
1673
1664
|
top: n / 2
|
|
@@ -1675,8 +1666,8 @@ class mt {
|
|
|
1675
1666
|
left: a / 2,
|
|
1676
1667
|
top: n / 2
|
|
1677
1668
|
}), e.renderAll();
|
|
1678
|
-
const
|
|
1679
|
-
|
|
1669
|
+
const r = e.viewportTransform;
|
|
1670
|
+
r[4] = a / 2 - s.x * i, r[5] = n / 2 - s.y * i, e.setViewportTransform(r), e.renderAll();
|
|
1680
1671
|
}
|
|
1681
1672
|
/**
|
|
1682
1673
|
* Метод для получения координат объекта с учетом текущего зума
|
|
@@ -1692,8 +1683,8 @@ class mt {
|
|
|
1692
1683
|
code: "NO_ACTIVE_OBJECT",
|
|
1693
1684
|
message: "Не выбран объект для получения координат"
|
|
1694
1685
|
}), { left: 0, top: 0 };
|
|
1695
|
-
const { width: n, height: i } = a,
|
|
1696
|
-
return { left:
|
|
1686
|
+
const { width: n, height: i } = a, s = t.getZoom(), r = (n - n * s) / 2, c = (i - i * s) / 2;
|
|
1687
|
+
return { left: r, top: c };
|
|
1697
1688
|
}
|
|
1698
1689
|
/**
|
|
1699
1690
|
* Устанавливаем ширину канваса в backstore (для экспорта)
|
|
@@ -1701,7 +1692,7 @@ class mt {
|
|
|
1701
1692
|
*/
|
|
1702
1693
|
setCanvasBackstoreWidth(e) {
|
|
1703
1694
|
if (!e || typeof e != "number") return;
|
|
1704
|
-
const t = Math.max(Math.min(e,
|
|
1695
|
+
const t = Math.max(Math.min(e, T), B);
|
|
1705
1696
|
this.editor.canvas.setDimensions({ width: t }, { backstoreOnly: !0 });
|
|
1706
1697
|
}
|
|
1707
1698
|
/**
|
|
@@ -1710,7 +1701,7 @@ class mt {
|
|
|
1710
1701
|
*/
|
|
1711
1702
|
setCanvasBackstoreHeight(e) {
|
|
1712
1703
|
if (!e || typeof e != "number") return;
|
|
1713
|
-
const t = Math.max(Math.min(e,
|
|
1704
|
+
const t = Math.max(Math.min(e, k), Z);
|
|
1714
1705
|
this.editor.canvas.setDimensions({ height: t }, { backstoreOnly: !0 });
|
|
1715
1706
|
}
|
|
1716
1707
|
/**
|
|
@@ -1719,8 +1710,8 @@ class mt {
|
|
|
1719
1710
|
* с учётом минимальных и максимальных значений.
|
|
1720
1711
|
*/
|
|
1721
1712
|
adaptCanvasToContainer() {
|
|
1722
|
-
const { canvas: e } = this.editor, t = e.editorContainer, a = t.clientWidth, n = t.clientHeight, i = Math.max(Math.min(a,
|
|
1723
|
-
console.log("adaptCanvasToContainer newWidth", i), console.log("adaptCanvasToContainer newHeight",
|
|
1713
|
+
const { canvas: e } = this.editor, t = e.editorContainer, a = t.clientWidth, n = t.clientHeight, i = Math.max(Math.min(a, T), B), s = Math.max(Math.min(n, k), Z);
|
|
1714
|
+
console.log("adaptCanvasToContainer newWidth", i), console.log("adaptCanvasToContainer newHeight", s), e.setDimensions({ width: i, height: s }, { backstoreOnly: !0 });
|
|
1724
1715
|
}
|
|
1725
1716
|
/**
|
|
1726
1717
|
* Обновляет размеры канваса и вписывает объекты в монтажную область.
|
|
@@ -1754,11 +1745,11 @@ class mt {
|
|
|
1754
1745
|
* @param {Number} zoom — текущее значение zoom (например, 1, 1.2, 2 и т.д.)
|
|
1755
1746
|
*/
|
|
1756
1747
|
updateCssDimensionsForZoom(e) {
|
|
1757
|
-
const { canvas: t, montageArea: a } = this.editor, n = a.width * e, i = a.height * e,
|
|
1758
|
-
if (!(
|
|
1759
|
-
const
|
|
1748
|
+
const { canvas: t, montageArea: a } = this.editor, n = a.width * e, i = a.height * e, s = t.wrapperEl.parentNode;
|
|
1749
|
+
if (!(s instanceof HTMLElement)) return;
|
|
1750
|
+
const r = n <= s.clientWidth ? "100%" : n, c = i <= s.clientHeight ? "100%" : i;
|
|
1760
1751
|
t.setDimensions(
|
|
1761
|
-
{ width:
|
|
1752
|
+
{ width: r, height: c },
|
|
1762
1753
|
{ cssOnly: !0 }
|
|
1763
1754
|
);
|
|
1764
1755
|
}
|
|
@@ -1845,32 +1836,32 @@ class mt {
|
|
|
1845
1836
|
*/
|
|
1846
1837
|
setDisplayDimension({ element: e = "canvas", dimension: t, value: a } = {}) {
|
|
1847
1838
|
if (!a) return;
|
|
1848
|
-
const { canvas: n, options: { editorContainer: i } } = this.editor,
|
|
1839
|
+
const { canvas: n, options: { editorContainer: i } } = this.editor, s = [];
|
|
1849
1840
|
switch (e) {
|
|
1850
1841
|
case "canvas":
|
|
1851
|
-
|
|
1842
|
+
s.push(n.lowerCanvasEl, n.upperCanvasEl);
|
|
1852
1843
|
break;
|
|
1853
1844
|
case "wrapper":
|
|
1854
|
-
|
|
1845
|
+
s.push(n.wrapperEl);
|
|
1855
1846
|
break;
|
|
1856
1847
|
case "container":
|
|
1857
|
-
|
|
1848
|
+
s.push(i);
|
|
1858
1849
|
break;
|
|
1859
1850
|
default:
|
|
1860
|
-
|
|
1851
|
+
s.push(n.lowerCanvasEl, n.upperCanvasEl);
|
|
1861
1852
|
}
|
|
1862
|
-
const
|
|
1853
|
+
const r = t === "width" ? "width" : "height";
|
|
1863
1854
|
if (typeof a == "string") {
|
|
1864
|
-
|
|
1865
|
-
u.style[
|
|
1855
|
+
s.forEach((u) => {
|
|
1856
|
+
u.style[r] = a;
|
|
1866
1857
|
});
|
|
1867
1858
|
return;
|
|
1868
1859
|
}
|
|
1869
1860
|
if (isNaN(a)) return;
|
|
1870
1861
|
const c = `${a}px`;
|
|
1871
|
-
|
|
1872
|
-
u.style[
|
|
1873
|
-
}), n.fire(`editor:display-${e}-${
|
|
1862
|
+
s.forEach((u) => {
|
|
1863
|
+
u.style[r] = c;
|
|
1864
|
+
}), n.fire(`editor:display-${e}-${r}-changed`, {
|
|
1874
1865
|
element: e,
|
|
1875
1866
|
value: a
|
|
1876
1867
|
});
|
|
@@ -1887,23 +1878,23 @@ class mt {
|
|
|
1887
1878
|
const {
|
|
1888
1879
|
canvas: n,
|
|
1889
1880
|
montageArea: i,
|
|
1890
|
-
transformManager:
|
|
1881
|
+
transformManager: s,
|
|
1891
1882
|
options: {
|
|
1892
|
-
montageAreaWidth:
|
|
1883
|
+
montageAreaWidth: r,
|
|
1893
1884
|
montageAreaHeight: c
|
|
1894
1885
|
}
|
|
1895
1886
|
} = this.editor, u = e || n.getActiveObject();
|
|
1896
1887
|
if (!u || u.type !== "image" && u.format !== "svg") return;
|
|
1897
1888
|
const { width: l, height: d } = u;
|
|
1898
|
-
let h = Math.min(l,
|
|
1889
|
+
let h = Math.min(l, T), g = Math.min(d, k);
|
|
1899
1890
|
if (t) {
|
|
1900
1891
|
const {
|
|
1901
|
-
width:
|
|
1892
|
+
width: m,
|
|
1902
1893
|
height: f
|
|
1903
|
-
} = i,
|
|
1904
|
-
h =
|
|
1894
|
+
} = i, v = l / m, M = d / f, S = Math.max(v, M);
|
|
1895
|
+
h = m * S, g = f * S;
|
|
1905
1896
|
}
|
|
1906
|
-
this.setResolutionWidth(h, { withoutSave: !0 }), this.setResolutionHeight(g, { withoutSave: !0 }), (l >
|
|
1897
|
+
this.setResolutionWidth(h, { withoutSave: !0 }), this.setResolutionHeight(g, { withoutSave: !0 }), (l > r || d > c) && s.calculateAndApplyDefaultZoom(), s.resetObject(u, { withoutSave: !0 }), n.centerObject(u), n.renderAll(), a || this.editor.historyManager.saveState(), n.fire("editor:montage-area-scaled-to-image", {
|
|
1907
1898
|
object: u,
|
|
1908
1899
|
width: h,
|
|
1909
1900
|
height: g,
|
|
@@ -1932,10 +1923,10 @@ class mt {
|
|
|
1932
1923
|
historyManager: n,
|
|
1933
1924
|
options: {
|
|
1934
1925
|
montageAreaWidth: i,
|
|
1935
|
-
montageAreaHeight:
|
|
1926
|
+
montageAreaHeight: s
|
|
1936
1927
|
}
|
|
1937
1928
|
} = this.editor;
|
|
1938
|
-
a.resetZoom(), this.setResolutionWidth(i, { withoutSave: !0 }), this.setResolutionHeight(
|
|
1929
|
+
a.resetZoom(), this.setResolutionWidth(i, { withoutSave: !0 }), this.setResolutionHeight(s, { withoutSave: !0 }), t.renderAll(), a.resetObjects(), e || n.saveState(), t.fire("editor:default-scale-set");
|
|
1939
1930
|
}
|
|
1940
1931
|
/**
|
|
1941
1932
|
* Получение всех объектов внутри монтажной области редактора
|
|
@@ -1946,9 +1937,9 @@ class mt {
|
|
|
1946
1937
|
return e.getObjects().filter((i) => i.id !== t.id && i.id !== a.id);
|
|
1947
1938
|
}
|
|
1948
1939
|
}
|
|
1949
|
-
class
|
|
1940
|
+
class vt {
|
|
1950
1941
|
constructor({ editor: e }) {
|
|
1951
|
-
this.editor = e, this.options = e.options, this.minZoom = this.options.minZoom ||
|
|
1942
|
+
this.editor = e, this.options = e.options, this.minZoom = this.options.minZoom || lt, this.maxZoom = this.options.maxZoom || ht, this.defaultZoom = this.options.defaultScale, this.maxZoomFactor = this.options.maxZoomFactor;
|
|
1952
1943
|
}
|
|
1953
1944
|
/**
|
|
1954
1945
|
* Метод рассчитывает и применяет зум по умолчанию для монтажной области редактора.
|
|
@@ -1958,7 +1949,7 @@ class ft {
|
|
|
1958
1949
|
* @param {Number} [scale] - Желаемый масштаб относительно размеров контейнера редактора.
|
|
1959
1950
|
*/
|
|
1960
1951
|
calculateAndApplyDefaultZoom(e = this.options.defaultScale) {
|
|
1961
|
-
const { canvas: t } = this.editor, a = t.editorContainer, n = a.clientWidth, i = a.clientHeight, { width:
|
|
1952
|
+
const { canvas: t } = this.editor, a = t.editorContainer, n = a.clientWidth, i = a.clientHeight, { width: s, height: r } = this.editor.montageArea, c = n / s * e, u = i / r * e;
|
|
1962
1953
|
this.defaultZoom = Math.min(c, u);
|
|
1963
1954
|
const { defaultZoom: l, maxZoomFactor: d, minZoom: h, maxZoom: g } = this;
|
|
1964
1955
|
this.minZoom = Math.min(l / d, h), this.maxZoom = Math.max(l * d, g), this.setZoom();
|
|
@@ -1972,13 +1963,13 @@ class ft {
|
|
|
1972
1963
|
* @fires editor:zoom-changed
|
|
1973
1964
|
* Если передавать координаты курсора, то нужно быть аккуратнее, так как юзер может выйти за пределы рабочей области
|
|
1974
1965
|
*/
|
|
1975
|
-
zoom(e =
|
|
1966
|
+
zoom(e = gt, t = {}) {
|
|
1976
1967
|
var h, g;
|
|
1977
1968
|
if (!e) return;
|
|
1978
|
-
const { minZoom: a, maxZoom: n } = this, { canvas: i } = this.editor,
|
|
1979
|
-
let d = Number((
|
|
1969
|
+
const { minZoom: a, maxZoom: n } = this, { canvas: i } = this.editor, s = i.getZoom(), r = i.getCenterPoint(), c = (h = t.pointX) != null ? h : r.x, u = (g = t.pointY) != null ? g : r.y, l = new K(c, u);
|
|
1970
|
+
let d = Number((s + Number(e)).toFixed(2));
|
|
1980
1971
|
d > n && (d = n), d < a && (d = a), i.zoomToPoint(l, d), console.log({
|
|
1981
|
-
currentZoom:
|
|
1972
|
+
currentZoom: s,
|
|
1982
1973
|
zoom: d,
|
|
1983
1974
|
point: l
|
|
1984
1975
|
}), i.fire("editor:zoom-changed", {
|
|
@@ -1994,10 +1985,10 @@ class ft {
|
|
|
1994
1985
|
*/
|
|
1995
1986
|
setZoom(e = this.defaultZoom) {
|
|
1996
1987
|
const { minZoom: t, maxZoom: a } = this, { canvas: n } = this.editor, i = new K(n.getCenterPoint());
|
|
1997
|
-
let
|
|
1998
|
-
e > a && (
|
|
1988
|
+
let s = e;
|
|
1989
|
+
e > a && (s = a), e < t && (s = t), n.zoomToPoint(i, s), n.fire("editor:zoom-changed", {
|
|
1999
1990
|
currentZoom: n.getZoom(),
|
|
2000
|
-
zoom:
|
|
1991
|
+
zoom: s,
|
|
2001
1992
|
point: i
|
|
2002
1993
|
});
|
|
2003
1994
|
}
|
|
@@ -2022,11 +2013,11 @@ class ft {
|
|
|
2022
2013
|
rotate(e = Mt, { withoutSave: t } = {}) {
|
|
2023
2014
|
const { canvas: a, historyManager: n } = this.editor, i = a.getActiveObject();
|
|
2024
2015
|
if (!i) return;
|
|
2025
|
-
const
|
|
2026
|
-
i.rotate(
|
|
2016
|
+
const s = i.angle + e;
|
|
2017
|
+
i.rotate(s), i.setCoords(), a.renderAll(), t || n.saveState(), a.fire("editor:object-rotated", {
|
|
2027
2018
|
object: i,
|
|
2028
2019
|
withoutSave: t,
|
|
2029
|
-
angle:
|
|
2020
|
+
angle: s
|
|
2030
2021
|
});
|
|
2031
2022
|
}
|
|
2032
2023
|
/**
|
|
@@ -2065,11 +2056,11 @@ class ft {
|
|
|
2065
2056
|
opacity: t = 1,
|
|
2066
2057
|
withoutSave: a
|
|
2067
2058
|
} = {}) {
|
|
2068
|
-
const { canvas: n, historyManager: i } = this.editor,
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
}) :
|
|
2072
|
-
object:
|
|
2059
|
+
const { canvas: n, historyManager: i } = this.editor, s = e || n.getActiveObject();
|
|
2060
|
+
s && (s instanceof N ? s.getObjects().forEach((r) => {
|
|
2061
|
+
r.set("opacity", t);
|
|
2062
|
+
}) : s.set("opacity", t), n.renderAll(), a || i.saveState(), n.fire("editor:object-opacity-changed", {
|
|
2063
|
+
object: s,
|
|
2073
2064
|
opacity: t,
|
|
2074
2065
|
withoutSave: a
|
|
2075
2066
|
}));
|
|
@@ -2091,24 +2082,24 @@ class ft {
|
|
|
2091
2082
|
withoutSave: a,
|
|
2092
2083
|
fitAsOneObject: n
|
|
2093
2084
|
} = {}) {
|
|
2094
|
-
const { canvas: i, imageManager:
|
|
2085
|
+
const { canvas: i, imageManager: s, historyManager: r } = this.editor, c = e || i.getActiveObject();
|
|
2095
2086
|
if (c) {
|
|
2096
|
-
if (c.set("angle", 0), c instanceof
|
|
2087
|
+
if (c.set("angle", 0), c instanceof N && !n) {
|
|
2097
2088
|
const u = c.getObjects();
|
|
2098
2089
|
i.discardActiveObject(), u.forEach((d) => {
|
|
2099
|
-
const h =
|
|
2090
|
+
const h = s.calculateScaleFactor({ imageObject: d, scaleType: t });
|
|
2100
2091
|
d.scale(h), i.centerObject(d);
|
|
2101
2092
|
});
|
|
2102
|
-
const l = new
|
|
2093
|
+
const l = new N(u, { canvas: i });
|
|
2103
2094
|
i.setActiveObject(l);
|
|
2104
2095
|
} else {
|
|
2105
|
-
const u =
|
|
2096
|
+
const u = s.calculateScaleFactor({
|
|
2106
2097
|
imageObject: c,
|
|
2107
2098
|
scaleType: t
|
|
2108
2099
|
});
|
|
2109
2100
|
c.scale(u), i.centerObject(c);
|
|
2110
2101
|
}
|
|
2111
|
-
i.renderAll(), a ||
|
|
2102
|
+
i.renderAll(), a || r.saveState(), i.fire("editor:object-fitted", {
|
|
2112
2103
|
object: c,
|
|
2113
2104
|
type: t,
|
|
2114
2105
|
withoutSave: a,
|
|
@@ -2137,12 +2128,12 @@ class ft {
|
|
|
2137
2128
|
const {
|
|
2138
2129
|
canvas: n,
|
|
2139
2130
|
montageArea: i,
|
|
2140
|
-
imageManager:
|
|
2141
|
-
historyManager:
|
|
2131
|
+
imageManager: s,
|
|
2132
|
+
historyManager: r,
|
|
2142
2133
|
options: { scaleType: c }
|
|
2143
2134
|
} = this.editor, u = e || n.getActiveObject();
|
|
2144
2135
|
if (!u || u.locked) return;
|
|
2145
|
-
if (
|
|
2136
|
+
if (r.suspendHistory(), u.type === "image" || u.format === "svg" || u.set({
|
|
2146
2137
|
scaleX: 1,
|
|
2147
2138
|
scaleY: 1,
|
|
2148
2139
|
flipX: !1,
|
|
@@ -2151,20 +2142,20 @@ class ft {
|
|
|
2151
2142
|
}), t)
|
|
2152
2143
|
this.fitObject({ object: u, withoutSave: !0, fitAsOneObject: !0 });
|
|
2153
2144
|
else {
|
|
2154
|
-
const { width: d, height: h } = i, { width: g, height:
|
|
2145
|
+
const { width: d, height: h } = i, { width: g, height: m } = u, f = s.calculateScaleFactor({
|
|
2155
2146
|
imageObject: u,
|
|
2156
2147
|
scaleType: c
|
|
2157
2148
|
});
|
|
2158
|
-
c === "contain" && f < 1 || c === "cover" && (g > d ||
|
|
2149
|
+
c === "contain" && f < 1 || c === "cover" && (g > d || m > h) ? this.fitObject({ object: u, withoutSave: !0, fitAsOneObject: !0 }) : u.set({ scaleX: 1, scaleY: 1 });
|
|
2159
2150
|
}
|
|
2160
|
-
u.set({ flipX: !1, flipY: !1, angle: 0 }), n.centerObject(u), n.renderAll(),
|
|
2151
|
+
u.set({ flipX: !1, flipY: !1, angle: 0 }), n.centerObject(u), n.renderAll(), r.resumeHistory(), a || r.saveState(), n.fire("editor:object-reset", {
|
|
2161
2152
|
object: u,
|
|
2162
2153
|
withoutSave: a,
|
|
2163
2154
|
alwaysFitObject: t
|
|
2164
2155
|
});
|
|
2165
2156
|
}
|
|
2166
2157
|
}
|
|
2167
|
-
class
|
|
2158
|
+
class ft {
|
|
2168
2159
|
/**
|
|
2169
2160
|
* @param {object} options
|
|
2170
2161
|
* @param {ImageEditor} options.editor – экземпляр редактора
|
|
@@ -2215,14 +2206,14 @@ class jt {
|
|
|
2215
2206
|
var {
|
|
2216
2207
|
left: n,
|
|
2217
2208
|
top: i,
|
|
2218
|
-
width:
|
|
2219
|
-
height:
|
|
2209
|
+
width: s,
|
|
2210
|
+
height: r
|
|
2220
2211
|
} = t.getBoundingRect();
|
|
2221
2212
|
this.overlayMask.set({
|
|
2222
2213
|
left: n,
|
|
2223
2214
|
top: i,
|
|
2224
|
-
width:
|
|
2225
|
-
height:
|
|
2215
|
+
width: s,
|
|
2216
|
+
height: r
|
|
2226
2217
|
}), e.discardActiveObject(), this.editor.layerManager.bringToFront(this.overlayMask, {
|
|
2227
2218
|
withoutSave: !0
|
|
2228
2219
|
}), a.resumeHistory();
|
|
@@ -2291,8 +2282,8 @@ class $ {
|
|
|
2291
2282
|
} = this.editor;
|
|
2292
2283
|
n.suspendHistory();
|
|
2293
2284
|
var i = e || a.getActiveObject();
|
|
2294
|
-
i && (i.type === "activeselection" ? i.getObjects().forEach((
|
|
2295
|
-
a.bringObjectToFront(
|
|
2285
|
+
i && (i.type === "activeselection" ? i.getObjects().forEach((s) => {
|
|
2286
|
+
a.bringObjectToFront(s);
|
|
2296
2287
|
}) : a.bringObjectToFront(i), a.renderAll(), n.resumeHistory(), t || n.saveState(), a.fire("editor:object-bring-to-front", {
|
|
2297
2288
|
object: i,
|
|
2298
2289
|
withoutSave: t
|
|
@@ -2334,19 +2325,19 @@ class $ {
|
|
|
2334
2325
|
montageArea: n,
|
|
2335
2326
|
historyManager: i,
|
|
2336
2327
|
interactionBlocker: {
|
|
2337
|
-
overlayMask:
|
|
2328
|
+
overlayMask: s
|
|
2338
2329
|
}
|
|
2339
2330
|
} = this.editor;
|
|
2340
2331
|
i.suspendHistory();
|
|
2341
|
-
var
|
|
2342
|
-
if (
|
|
2343
|
-
if (
|
|
2344
|
-
for (var c =
|
|
2332
|
+
var r = e || a.getActiveObject();
|
|
2333
|
+
if (r) {
|
|
2334
|
+
if (r.type === "activeselection")
|
|
2335
|
+
for (var c = r.getObjects(), u = c.length - 1; u >= 0; u -= 1)
|
|
2345
2336
|
a.sendObjectToBack(c[u]);
|
|
2346
2337
|
else
|
|
2347
|
-
a.sendObjectToBack(
|
|
2348
|
-
a.sendObjectToBack(n), a.sendObjectToBack(
|
|
2349
|
-
object:
|
|
2338
|
+
a.sendObjectToBack(r);
|
|
2339
|
+
a.sendObjectToBack(n), a.sendObjectToBack(s), a.renderAll(), i.resumeHistory(), t || i.saveState(), a.fire("editor:object-send-to-back", {
|
|
2340
|
+
object: r,
|
|
2350
2341
|
withoutSave: t
|
|
2351
2342
|
});
|
|
2352
2343
|
}
|
|
@@ -2365,13 +2356,13 @@ class $ {
|
|
|
2365
2356
|
montageArea: n,
|
|
2366
2357
|
historyManager: i,
|
|
2367
2358
|
interactionBlocker: {
|
|
2368
|
-
overlayMask:
|
|
2359
|
+
overlayMask: s
|
|
2369
2360
|
}
|
|
2370
2361
|
} = this.editor;
|
|
2371
2362
|
i.suspendHistory();
|
|
2372
|
-
var
|
|
2373
|
-
|
|
2374
|
-
object:
|
|
2363
|
+
var r = e || a.getActiveObject();
|
|
2364
|
+
r && (r.type === "activeselection" ? $._moveSelectionBackwards(a, r) : a.sendObjectBackwards(r), a.sendObjectToBack(n), a.sendObjectToBack(s), a.renderAll(), i.resumeHistory(), t || i.saveState(), a.fire("editor:object-send-backwards", {
|
|
2365
|
+
object: r,
|
|
2375
2366
|
withoutSave: t
|
|
2376
2367
|
}));
|
|
2377
2368
|
}
|
|
@@ -2383,20 +2374,20 @@ class $ {
|
|
|
2383
2374
|
* @private
|
|
2384
2375
|
*/
|
|
2385
2376
|
static _moveSelectionForward(e, t) {
|
|
2386
|
-
for (var a = e.getObjects(), n = t.getObjects(), i = n.map((l) => a.indexOf(l)),
|
|
2377
|
+
for (var a = e.getObjects(), n = t.getObjects(), i = n.map((l) => a.indexOf(l)), s = -1, r = function(d) {
|
|
2387
2378
|
var h = a[d];
|
|
2388
2379
|
if (!n.includes(h) && i.some((g) => d > g))
|
|
2389
|
-
return
|
|
2390
|
-
}, c = 0; c < a.length && !
|
|
2380
|
+
return s = d, 1;
|
|
2381
|
+
}, c = 0; c < a.length && !r(c); c += 1)
|
|
2391
2382
|
;
|
|
2392
|
-
if (
|
|
2383
|
+
if (s !== -1) {
|
|
2393
2384
|
var u = n.map((l) => ({
|
|
2394
2385
|
obj: l,
|
|
2395
2386
|
index: a.indexOf(l)
|
|
2396
2387
|
})).sort((l, d) => d.index - l.index);
|
|
2397
2388
|
u.forEach((l) => {
|
|
2398
2389
|
var d = a.indexOf(l.obj);
|
|
2399
|
-
d <
|
|
2390
|
+
d < s && (e.moveObjectTo(l.obj, s), s = d);
|
|
2400
2391
|
});
|
|
2401
2392
|
}
|
|
2402
2393
|
}
|
|
@@ -2408,11 +2399,11 @@ class $ {
|
|
|
2408
2399
|
* @private
|
|
2409
2400
|
*/
|
|
2410
2401
|
static _moveSelectionBackwards(e, t) {
|
|
2411
|
-
for (var a = e.getObjects(), n = t.getObjects(), i = Math.min(...n.map((
|
|
2412
|
-
e.moveObjectTo(n[
|
|
2402
|
+
for (var a = e.getObjects(), n = t.getObjects(), i = Math.min(...n.map((r) => a.indexOf(r))), s = n.length - 1; s >= 0; s -= 1)
|
|
2403
|
+
e.moveObjectTo(n[s], i - 1);
|
|
2413
2404
|
}
|
|
2414
2405
|
}
|
|
2415
|
-
class
|
|
2406
|
+
class jt {
|
|
2416
2407
|
/**
|
|
2417
2408
|
* Менеджер фигур для редактора.
|
|
2418
2409
|
* @param {Object} options - Опции и настройки менеджера фигур.
|
|
@@ -2443,8 +2434,8 @@ class yt {
|
|
|
2443
2434
|
top: a,
|
|
2444
2435
|
width: n = 100,
|
|
2445
2436
|
height: i = 100,
|
|
2446
|
-
fill:
|
|
2447
|
-
} = d,
|
|
2437
|
+
fill: s = "blue"
|
|
2438
|
+
} = d, r = Q(d, [
|
|
2448
2439
|
"id",
|
|
2449
2440
|
"left",
|
|
2450
2441
|
"top",
|
|
@@ -2452,14 +2443,14 @@ class yt {
|
|
|
2452
2443
|
"height",
|
|
2453
2444
|
"fill"
|
|
2454
2445
|
]);
|
|
2455
|
-
const { canvas: h } = this.editor, g = new
|
|
2446
|
+
const { canvas: h } = this.editor, g = new ke(C({
|
|
2456
2447
|
id: e,
|
|
2457
2448
|
left: t,
|
|
2458
2449
|
top: a,
|
|
2459
2450
|
width: n,
|
|
2460
2451
|
height: i,
|
|
2461
|
-
fill:
|
|
2462
|
-
},
|
|
2452
|
+
fill: s
|
|
2453
|
+
}, r));
|
|
2463
2454
|
return !t && !a && h.centerObject(g), u || (h.add(g), c || h.setActiveObject(g), h.renderAll()), g;
|
|
2464
2455
|
}
|
|
2465
2456
|
/**
|
|
@@ -2478,28 +2469,28 @@ class yt {
|
|
|
2478
2469
|
* @param {Object} flags.withoutSelection - Не выделять объект
|
|
2479
2470
|
* @param {Object} flags.withoutAdding - Не добавлять объект в canvas
|
|
2480
2471
|
*/
|
|
2481
|
-
addCircle(u = {}, { withoutSelection:
|
|
2472
|
+
addCircle(u = {}, { withoutSelection: r, withoutAdding: c } = {}) {
|
|
2482
2473
|
var l = u, {
|
|
2483
2474
|
id: e = `circle-${A()}`,
|
|
2484
2475
|
left: t,
|
|
2485
2476
|
top: a,
|
|
2486
2477
|
radius: n = 50,
|
|
2487
2478
|
fill: i = "green"
|
|
2488
|
-
} = l,
|
|
2479
|
+
} = l, s = Q(l, [
|
|
2489
2480
|
"id",
|
|
2490
2481
|
"left",
|
|
2491
2482
|
"top",
|
|
2492
2483
|
"radius",
|
|
2493
2484
|
"fill"
|
|
2494
2485
|
]);
|
|
2495
|
-
const { canvas: d } = this.editor, h = new
|
|
2486
|
+
const { canvas: d } = this.editor, h = new xe(C({
|
|
2496
2487
|
id: e,
|
|
2497
2488
|
left: t,
|
|
2498
2489
|
top: a,
|
|
2499
2490
|
fill: i,
|
|
2500
2491
|
radius: n
|
|
2501
|
-
},
|
|
2502
|
-
return !t && !a && d.centerObject(h), c || (d.add(h),
|
|
2492
|
+
}, s));
|
|
2493
|
+
return !t && !a && d.centerObject(h), c || (d.add(h), r || d.setActiveObject(h), d.renderAll()), h;
|
|
2503
2494
|
}
|
|
2504
2495
|
/**
|
|
2505
2496
|
* Добавление треугольника
|
|
@@ -2525,8 +2516,8 @@ class yt {
|
|
|
2525
2516
|
top: a,
|
|
2526
2517
|
width: n = 100,
|
|
2527
2518
|
height: i = 100,
|
|
2528
|
-
fill:
|
|
2529
|
-
} = d,
|
|
2519
|
+
fill: s = "yellow"
|
|
2520
|
+
} = d, r = Q(d, [
|
|
2530
2521
|
"id",
|
|
2531
2522
|
"left",
|
|
2532
2523
|
"top",
|
|
@@ -2534,18 +2525,18 @@ class yt {
|
|
|
2534
2525
|
"height",
|
|
2535
2526
|
"fill"
|
|
2536
2527
|
]);
|
|
2537
|
-
const { canvas: h } = this.editor, g = new
|
|
2528
|
+
const { canvas: h } = this.editor, g = new Be(C({
|
|
2538
2529
|
id: e,
|
|
2539
2530
|
left: t,
|
|
2540
2531
|
top: a,
|
|
2541
|
-
fill:
|
|
2532
|
+
fill: s,
|
|
2542
2533
|
width: n,
|
|
2543
2534
|
height: i
|
|
2544
|
-
},
|
|
2535
|
+
}, r));
|
|
2545
2536
|
return !t && !a && h.centerObject(g), u || (h.add(g), c || h.setActiveObject(g), h.renderAll()), g;
|
|
2546
2537
|
}
|
|
2547
2538
|
}
|
|
2548
|
-
class
|
|
2539
|
+
class yt {
|
|
2549
2540
|
/**
|
|
2550
2541
|
* @param {object} options
|
|
2551
2542
|
* @param {ImageEditor} options.editor - экземпляр редактора с доступом к canvas
|
|
@@ -2560,16 +2551,19 @@ class bt {
|
|
|
2560
2551
|
copy() {
|
|
2561
2552
|
const { canvas: e, errorManager: t } = this.editor, a = e.getActiveObject();
|
|
2562
2553
|
if (!a) return;
|
|
2563
|
-
if (typeof ClipboardItem == "undefined" || !navigator.clipboard)
|
|
2564
|
-
|
|
2554
|
+
if (typeof ClipboardItem == "undefined" || !navigator.clipboard) {
|
|
2555
|
+
t.emitWarning({
|
|
2565
2556
|
origin: "ClipboardManager",
|
|
2566
2557
|
method: "copy",
|
|
2567
2558
|
code: "CLIPBOARD_NOT_SUPPORTED",
|
|
2559
|
+
// eslint-disable-next-line max-len
|
|
2568
2560
|
message: "ClipboardManager. navigator.clipboard не поддерживается в этом браузере или отсутствует соединение по HTTPS-протоколу."
|
|
2569
2561
|
}), this._cloneAndFire(e, a);
|
|
2562
|
+
return;
|
|
2563
|
+
}
|
|
2570
2564
|
if (a.type !== "image") {
|
|
2571
2565
|
const h = `application/image-editor:${JSON.stringify(a.toObject(["format"]))}`;
|
|
2572
|
-
|
|
2566
|
+
navigator.clipboard.writeText(h).catch((g) => {
|
|
2573
2567
|
t.emitWarning({
|
|
2574
2568
|
origin: "ClipboardManager",
|
|
2575
2569
|
method: "copy",
|
|
@@ -2578,11 +2572,12 @@ class bt {
|
|
|
2578
2572
|
data: g
|
|
2579
2573
|
});
|
|
2580
2574
|
}), this._cloneAndFire(e, a);
|
|
2575
|
+
return;
|
|
2581
2576
|
}
|
|
2582
|
-
const i = a.toCanvasElement().toDataURL(),
|
|
2583
|
-
for (let h = 0; h < c.length; h
|
|
2577
|
+
const i = a.toCanvasElement().toDataURL(), s = i.slice(5).split(";")[0], r = i.split(",")[1], c = atob(r), u = new Uint8Array(c.length);
|
|
2578
|
+
for (let h = 0; h < c.length; h += 1)
|
|
2584
2579
|
u[h] = c.charCodeAt(h);
|
|
2585
|
-
const l = new Blob([u.buffer], { type:
|
|
2580
|
+
const l = new Blob([u.buffer], { type: s }), d = new ClipboardItem({ [s]: l });
|
|
2586
2581
|
navigator.clipboard.write([d]).catch((h) => {
|
|
2587
2582
|
t.emitWarning({
|
|
2588
2583
|
origin: "ClipboardManager",
|
|
@@ -2605,7 +2600,7 @@ class bt {
|
|
|
2605
2600
|
origin: "ClipboardManager",
|
|
2606
2601
|
method: "_cloneAndFire",
|
|
2607
2602
|
code: "CLONE_FAILED",
|
|
2608
|
-
message: "
|
|
2603
|
+
message: "Ошибка клонирования объекта",
|
|
2609
2604
|
data: a
|
|
2610
2605
|
});
|
|
2611
2606
|
});
|
|
@@ -2617,16 +2612,16 @@ class bt {
|
|
|
2617
2612
|
* @param {Array} event.clipboardData.items — элементы буфера обмена
|
|
2618
2613
|
*/
|
|
2619
2614
|
handlePasteEvent({ clipboardData: e }) {
|
|
2620
|
-
var
|
|
2621
|
-
if (!((
|
|
2615
|
+
var s;
|
|
2616
|
+
if (!((s = e == null ? void 0 : e.items) != null && s.length)) return;
|
|
2622
2617
|
const { imageManager: t } = this.editor, { items: a } = e, n = a[a.length - 1];
|
|
2623
2618
|
if (n.type !== "text/html") {
|
|
2624
|
-
const
|
|
2625
|
-
if (!
|
|
2619
|
+
const r = n.getAsFile();
|
|
2620
|
+
if (!r) return;
|
|
2626
2621
|
const c = new FileReader();
|
|
2627
2622
|
c.onload = (u) => {
|
|
2628
2623
|
u.target && this.editor.imageManager.importImage({ source: u.target.result });
|
|
2629
|
-
}, c.readAsDataURL(
|
|
2624
|
+
}, c.readAsDataURL(r);
|
|
2630
2625
|
return;
|
|
2631
2626
|
}
|
|
2632
2627
|
const i = e.getData("text/html");
|
|
@@ -2644,7 +2639,7 @@ class bt {
|
|
|
2644
2639
|
* @fires editor:object-pasted
|
|
2645
2640
|
*/
|
|
2646
2641
|
paste() {
|
|
2647
|
-
return
|
|
2642
|
+
return O(this, null, function* () {
|
|
2648
2643
|
const { canvas: e } = this.editor;
|
|
2649
2644
|
if (!this.clipboard) return;
|
|
2650
2645
|
const t = yield this.clipboard.clone(["format"]);
|
|
@@ -2653,13 +2648,13 @@ class bt {
|
|
|
2653
2648
|
left: t.left + 10,
|
|
2654
2649
|
top: t.top + 10,
|
|
2655
2650
|
evented: !0
|
|
2656
|
-
}), t instanceof
|
|
2651
|
+
}), t instanceof N ? (t.canvas = e, t.forEachObject((a) => {
|
|
2657
2652
|
e.add(a);
|
|
2658
2653
|
})) : e.add(t), e.setActiveObject(t), e.requestRenderAll(), e.fire("editor:object-pasted", { object: t });
|
|
2659
2654
|
});
|
|
2660
2655
|
}
|
|
2661
2656
|
}
|
|
2662
|
-
class
|
|
2657
|
+
class bt {
|
|
2663
2658
|
/**
|
|
2664
2659
|
* @param {object} options
|
|
2665
2660
|
* @param {ImageEditor} options.editor - экземпляр редактора с доступом к canvas
|
|
@@ -2686,9 +2681,9 @@ class pt {
|
|
|
2686
2681
|
} = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, {
|
|
2687
2682
|
canvas: n,
|
|
2688
2683
|
historyManager: i
|
|
2689
|
-
} = this.editor,
|
|
2690
|
-
if (!(!
|
|
2691
|
-
var
|
|
2684
|
+
} = this.editor, s = e || n.getActiveObject();
|
|
2685
|
+
if (!(!s || s.locked)) {
|
|
2686
|
+
var r = {
|
|
2692
2687
|
lockMovementX: !0,
|
|
2693
2688
|
lockMovementY: !0,
|
|
2694
2689
|
lockRotation: !0,
|
|
@@ -2698,12 +2693,12 @@ class pt {
|
|
|
2698
2693
|
lockSkewingY: !0,
|
|
2699
2694
|
locked: !0
|
|
2700
2695
|
};
|
|
2701
|
-
|
|
2702
|
-
var c = !t && ["activeselection", "group"].includes(
|
|
2703
|
-
c &&
|
|
2704
|
-
u.set(
|
|
2696
|
+
s.set(r);
|
|
2697
|
+
var c = !t && ["activeselection", "group"].includes(s.type);
|
|
2698
|
+
c && s.getObjects().forEach((u) => {
|
|
2699
|
+
u.set(r);
|
|
2705
2700
|
}), n.renderAll(), a || i.saveState(), n.fire("editor:object-locked", {
|
|
2706
|
-
object:
|
|
2701
|
+
object: s,
|
|
2707
2702
|
skipInnerObjects: t,
|
|
2708
2703
|
withoutSave: a
|
|
2709
2704
|
});
|
|
@@ -2726,7 +2721,7 @@ class pt {
|
|
|
2726
2721
|
historyManager: n
|
|
2727
2722
|
} = this.editor, i = e || a.getActiveObject();
|
|
2728
2723
|
if (i) {
|
|
2729
|
-
var
|
|
2724
|
+
var s = {
|
|
2730
2725
|
lockMovementX: !1,
|
|
2731
2726
|
lockMovementY: !1,
|
|
2732
2727
|
lockRotation: !1,
|
|
@@ -2736,8 +2731,8 @@ class pt {
|
|
|
2736
2731
|
lockSkewingY: !1,
|
|
2737
2732
|
locked: !1
|
|
2738
2733
|
};
|
|
2739
|
-
i.set(
|
|
2740
|
-
|
|
2734
|
+
i.set(s), ["activeselection", "group"].includes(i.type) && i.getObjects().forEach((r) => {
|
|
2735
|
+
r.set(s);
|
|
2741
2736
|
}), a.renderAll(), t || n.saveState(), a.fire("editor:object-unlocked", {
|
|
2742
2737
|
object: i,
|
|
2743
2738
|
withoutSave: t
|
|
@@ -2745,16 +2740,9 @@ class pt {
|
|
|
2745
2740
|
}
|
|
2746
2741
|
}
|
|
2747
2742
|
}
|
|
2748
|
-
class
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
* @param {ImageEditor} options.editor - экземпляр редактора с доступом к canvas
|
|
2752
|
-
*/
|
|
2753
|
-
constructor(e) {
|
|
2754
|
-
var {
|
|
2755
|
-
editor: t
|
|
2756
|
-
} = e;
|
|
2757
|
-
this.editor = t;
|
|
2743
|
+
class pt {
|
|
2744
|
+
constructor({ editor: e }) {
|
|
2745
|
+
this.editor = e;
|
|
2758
2746
|
}
|
|
2759
2747
|
/**
|
|
2760
2748
|
* Группировка объектов
|
|
@@ -2763,24 +2751,20 @@ class It {
|
|
|
2763
2751
|
* @param {fabric.Object} options.object - массив объектов для группировки
|
|
2764
2752
|
* @fires editor:objects-grouped
|
|
2765
2753
|
*/
|
|
2766
|
-
group(
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
canvas: a,
|
|
2772
|
-
historyManager: n
|
|
2773
|
-
} = this.editor;
|
|
2754
|
+
group({
|
|
2755
|
+
object: e,
|
|
2756
|
+
withoutSave: t
|
|
2757
|
+
} = {}) {
|
|
2758
|
+
const { canvas: a, historyManager: n } = this.editor;
|
|
2774
2759
|
n.suspendHistory();
|
|
2775
|
-
|
|
2776
|
-
if (i
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
}
|
|
2760
|
+
const i = e || a.getActiveObject();
|
|
2761
|
+
if (!i || !(i instanceof N)) return;
|
|
2762
|
+
const s = i.getObjects(), r = new je(s);
|
|
2763
|
+
s.forEach((c) => a.remove(c)), r.set("id", `${r.type}-${A()}`), a.add(r), a.setActiveObject(r), a.renderAll(), n.resumeHistory(), t || n.saveState(), a.fire("editor:objects-grouped", {
|
|
2764
|
+
object: i,
|
|
2765
|
+
group: r,
|
|
2766
|
+
withoutSave: t
|
|
2767
|
+
});
|
|
2784
2768
|
}
|
|
2785
2769
|
/**
|
|
2786
2770
|
* Разгруппировка объектов
|
|
@@ -2789,31 +2773,27 @@ class It {
|
|
|
2789
2773
|
* @param {Boolean} options.withoutSave - Не сохранять состояние
|
|
2790
2774
|
* @fires editor:objects-ungrouped
|
|
2791
2775
|
*/
|
|
2792
|
-
ungroup(
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
canvas: a,
|
|
2798
|
-
historyManager: n
|
|
2799
|
-
} = this.editor;
|
|
2776
|
+
ungroup({
|
|
2777
|
+
object: e,
|
|
2778
|
+
withoutSave: t
|
|
2779
|
+
} = {}) {
|
|
2780
|
+
const { canvas: a, historyManager: n } = this.editor;
|
|
2800
2781
|
n.suspendHistory();
|
|
2801
|
-
|
|
2802
|
-
if (!(
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
}
|
|
2782
|
+
const i = e || a.getActiveObject();
|
|
2783
|
+
if (!(i instanceof je)) return;
|
|
2784
|
+
const s = i.removeAll();
|
|
2785
|
+
a.remove(i), s.forEach((c) => a.add(c));
|
|
2786
|
+
const r = new N(s, {
|
|
2787
|
+
canvas: a
|
|
2788
|
+
});
|
|
2789
|
+
a.setActiveObject(r), a.renderAll(), n.resumeHistory(), t || n.saveState(), a.fire("editor:objects-ungrouped", {
|
|
2790
|
+
object: i,
|
|
2791
|
+
selection: r,
|
|
2792
|
+
withoutSave: t
|
|
2793
|
+
});
|
|
2814
2794
|
}
|
|
2815
2795
|
}
|
|
2816
|
-
class
|
|
2796
|
+
class It {
|
|
2817
2797
|
/**
|
|
2818
2798
|
* @param {object} options
|
|
2819
2799
|
* @param {ImageEditor} options.editor - экземпляр редактора с доступом к canvas
|
|
@@ -2835,58 +2815,47 @@ class At {
|
|
|
2835
2815
|
objectLockManager: a
|
|
2836
2816
|
} = this.editor;
|
|
2837
2817
|
e.discardActiveObject();
|
|
2838
|
-
var n = t.getObjects(), i = n.some((
|
|
2818
|
+
var n = t.getObjects(), i = n.some((r) => r.locked), s = n.length > 1 ? new N(t.getObjects(), {
|
|
2839
2819
|
canvas: e
|
|
2840
2820
|
}) : n[0];
|
|
2841
2821
|
i && a.lockObject({
|
|
2842
|
-
object:
|
|
2822
|
+
object: s,
|
|
2843
2823
|
skipInnerObjects: !0,
|
|
2844
2824
|
withoutSave: !0
|
|
2845
|
-
}), e.setActiveObject(
|
|
2846
|
-
selected:
|
|
2825
|
+
}), e.setActiveObject(s), e.requestRenderAll(), e.fire("editor:all-objects-selected", {
|
|
2826
|
+
selected: s
|
|
2847
2827
|
});
|
|
2848
2828
|
}
|
|
2849
2829
|
}
|
|
2850
|
-
class
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
* @param {ImageEditor} options.editor - экземпляр редактора с доступом к canvas
|
|
2854
|
-
*/
|
|
2855
|
-
constructor(e) {
|
|
2856
|
-
var {
|
|
2857
|
-
editor: t
|
|
2858
|
-
} = e;
|
|
2859
|
-
this.editor = t;
|
|
2830
|
+
class At {
|
|
2831
|
+
constructor({ editor: e }) {
|
|
2832
|
+
this.editor = e;
|
|
2860
2833
|
}
|
|
2861
2834
|
/**
|
|
2862
2835
|
* Удалить выбранные объекты
|
|
2863
2836
|
* @param {Object} options
|
|
2864
|
-
* @param {
|
|
2837
|
+
* @param {FabricObject[]} options.objects - массив объектов для удаления
|
|
2865
2838
|
* @param {Boolean} options.withoutSave - Не сохранять состояние
|
|
2866
2839
|
* @fires editor:objects-deleted
|
|
2867
2840
|
*/
|
|
2868
|
-
deleteSelectedObjects(
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
} = this.editor, r = (e || a.getActiveObjects()).filter((s) => !s.locked);
|
|
2877
|
-
r != null && r.length && (n.suspendHistory(), r.forEach((s) => {
|
|
2878
|
-
if (s.type === "group" && s.format !== "svg") {
|
|
2879
|
-
i.ungroup(s), this.deleteSelectedObjects();
|
|
2841
|
+
deleteSelectedObjects({
|
|
2842
|
+
objects: e,
|
|
2843
|
+
withoutSave: t
|
|
2844
|
+
} = {}) {
|
|
2845
|
+
const { canvas: a, historyManager: n, groupingManager: i } = this.editor, s = (e || a.getActiveObjects()).filter((r) => !r.locked);
|
|
2846
|
+
s != null && s.length && (n.suspendHistory(), s.forEach((r) => {
|
|
2847
|
+
if (r.type === "group" && r.format !== "svg") {
|
|
2848
|
+
i.ungroup({ object: r, withoutSave: t }), this.deleteSelectedObjects();
|
|
2880
2849
|
return;
|
|
2881
2850
|
}
|
|
2882
|
-
a.remove(
|
|
2851
|
+
a.remove(r);
|
|
2883
2852
|
}), a.discardActiveObject(), a.renderAll(), n.resumeHistory(), t || n.saveState(), a.fire("editor:objects-deleted", {
|
|
2884
|
-
objects:
|
|
2853
|
+
objects: s,
|
|
2885
2854
|
withoutSave: t
|
|
2886
2855
|
}));
|
|
2887
2856
|
}
|
|
2888
2857
|
}
|
|
2889
|
-
const
|
|
2858
|
+
const St = {
|
|
2890
2859
|
IMAGE_MANAGER: {
|
|
2891
2860
|
/**
|
|
2892
2861
|
* Некорректный Content-Type изображения
|
|
@@ -2942,6 +2911,10 @@ const Ct = {
|
|
|
2942
2911
|
* Ошибка при получении активного объекта.
|
|
2943
2912
|
*/
|
|
2944
2913
|
NO_ACTIVE_OBJECT: "NO_ACTIVE_OBJECT"
|
|
2914
|
+
},
|
|
2915
|
+
HISTORY_MANAGER: {
|
|
2916
|
+
UNDO_ERROR: "UNDO_ERROR",
|
|
2917
|
+
REDO_ERROR: "REDO_ERROR"
|
|
2945
2918
|
}
|
|
2946
2919
|
};
|
|
2947
2920
|
class q {
|
|
@@ -2970,18 +2943,18 @@ class q {
|
|
|
2970
2943
|
return;
|
|
2971
2944
|
}
|
|
2972
2945
|
if (!a) return;
|
|
2973
|
-
const
|
|
2974
|
-
console.error(`${e}. ${t}. ${a}. ${
|
|
2975
|
-
const
|
|
2946
|
+
const s = i || a;
|
|
2947
|
+
console.error(`${e}. ${t}. ${a}. ${s}`, n);
|
|
2948
|
+
const r = {
|
|
2976
2949
|
code: a,
|
|
2977
2950
|
origin: e,
|
|
2978
2951
|
method: t,
|
|
2979
|
-
message:
|
|
2952
|
+
message: s,
|
|
2980
2953
|
data: n
|
|
2981
2954
|
};
|
|
2982
2955
|
this._buffer.push(C({
|
|
2983
2956
|
type: "editor:error"
|
|
2984
|
-
},
|
|
2957
|
+
}, r)), this.editor.canvas.fire("editor:error", r);
|
|
2985
2958
|
}
|
|
2986
2959
|
/**
|
|
2987
2960
|
* Эмитит предупреждение через fabricjs
|
|
@@ -2998,24 +2971,24 @@ class q {
|
|
|
2998
2971
|
console.warn("Неизвестный код предупреждения: ", { code: a, origin: e, method: t });
|
|
2999
2972
|
return;
|
|
3000
2973
|
}
|
|
3001
|
-
const
|
|
3002
|
-
console.warn(`${e}. ${t}. ${a}. ${
|
|
3003
|
-
const
|
|
2974
|
+
const s = n || a;
|
|
2975
|
+
console.warn(`${e}. ${t}. ${a}. ${s}`, i);
|
|
2976
|
+
const r = {
|
|
3004
2977
|
code: a,
|
|
3005
2978
|
origin: e,
|
|
3006
2979
|
method: t,
|
|
3007
|
-
message:
|
|
2980
|
+
message: s,
|
|
3008
2981
|
data: i
|
|
3009
2982
|
};
|
|
3010
2983
|
this._buffer.push(C({
|
|
3011
2984
|
type: "editor:warning"
|
|
3012
|
-
},
|
|
2985
|
+
}, r)), this.editor.canvas.fire("editor:warning", r);
|
|
3013
2986
|
}
|
|
3014
2987
|
static isValidErrorCode(e) {
|
|
3015
|
-
return e ? Object.values(
|
|
2988
|
+
return e ? Object.values(St).some((t) => Object.values(t).includes(e)) : !1;
|
|
3016
2989
|
}
|
|
3017
2990
|
}
|
|
3018
|
-
class
|
|
2991
|
+
class ue {
|
|
3019
2992
|
/**
|
|
3020
2993
|
* Конструктор класса ImageEditor.
|
|
3021
2994
|
* @param {string} canvasId - идентификатор канваса, в котором будет создан редактор
|
|
@@ -3025,25 +2998,25 @@ class de {
|
|
|
3025
2998
|
this.options = t, this.containerId = e, this.editorId = `${e}-${A()}`, this.clipboard = null, this.init();
|
|
3026
2999
|
}
|
|
3027
3000
|
init() {
|
|
3028
|
-
return
|
|
3001
|
+
return O(this, null, function* () {
|
|
3029
3002
|
const {
|
|
3030
3003
|
editorContainerWidth: e,
|
|
3031
3004
|
editorContainerHeight: t,
|
|
3032
3005
|
canvasWrapperWidth: a,
|
|
3033
3006
|
canvasWrapperHeight: n,
|
|
3034
3007
|
canvasCSSWidth: i,
|
|
3035
|
-
canvasCSSHeight:
|
|
3036
|
-
initialImage:
|
|
3008
|
+
canvasCSSHeight: s,
|
|
3009
|
+
initialImage: r,
|
|
3037
3010
|
initialStateJSON: c,
|
|
3038
3011
|
scaleType: u,
|
|
3039
3012
|
_onReadyCallback: l
|
|
3040
3013
|
} = this.options;
|
|
3041
|
-
if (
|
|
3014
|
+
if (Je.apply(), this.canvas = new Ze(this.containerId, this.options), this.moduleLoader = new He(), this.workerManager = new Ye(), this.errorManager = new q({ editor: this }), this.historyManager = new dt({ editor: this }), this.toolbar = new ut({ editor: this }), this.transformManager = new vt({ editor: this }), this.canvasManager = new mt({ editor: this }), this.imageManager = new D({ editor: this }), this.layerManager = new $({ editor: this }), this.shapeManager = new jt({ editor: this }), this.interactionBlocker = new ft({ editor: this }), this.clipboardManager = new yt({ editor: this }), this.objectLockManager = new bt({ editor: this }), this.groupingManager = new pt({ editor: this }), this.selectionManager = new It({ editor: this }), this.deletionManager = new At({ editor: this }), this._createMontageArea(), this._createClippingArea(), this.listeners = new P({ editor: this, options: this.options }), this.canvasManager.setEditorContainerWidth(e), this.canvasManager.setEditorContainerHeight(t), this.canvasManager.setCanvasWrapperWidth(a), this.canvasManager.setCanvasWrapperHeight(n), this.canvasManager.setCanvasCSSWidth(i), this.canvasManager.setCanvasCSSHeight(s), r != null && r.source) {
|
|
3042
3015
|
const {
|
|
3043
3016
|
source: d,
|
|
3044
3017
|
scale: h = `image-${u}`,
|
|
3045
3018
|
withoutSave: g = !0
|
|
3046
|
-
} =
|
|
3019
|
+
} = r;
|
|
3047
3020
|
yield this.imageManager.importImage({ source: d, scale: h, withoutSave: g });
|
|
3048
3021
|
} else
|
|
3049
3022
|
this.canvasManager.setDefaultScale({ withoutSave: !0 });
|
|
@@ -3058,7 +3031,7 @@ class de {
|
|
|
3058
3031
|
this.montageArea = this.shapeManager.addRectangle({
|
|
3059
3032
|
width: e,
|
|
3060
3033
|
height: t,
|
|
3061
|
-
fill:
|
|
3034
|
+
fill: ue._createMosaicPattern(),
|
|
3062
3035
|
stroke: null,
|
|
3063
3036
|
strokeWidth: 0,
|
|
3064
3037
|
selectable: !1,
|
|
@@ -3102,13 +3075,13 @@ class de {
|
|
|
3102
3075
|
const e = document.createElement("canvas");
|
|
3103
3076
|
e.width = 20, e.height = 20;
|
|
3104
3077
|
const t = e.getContext("2d");
|
|
3105
|
-
return t.fillStyle = "#ddd", t.fillRect(0, 0, 40, 40), t.fillStyle = "#ccc", t.fillRect(0, 0, 10, 10), t.fillRect(10, 10, 10, 10), new
|
|
3078
|
+
return t.fillStyle = "#ddd", t.fillRect(0, 0, 40, 40), t.fillStyle = "#ccc", t.fillRect(0, 0, 10, 10), t.fillRect(10, 10, 10, 10), new ze({
|
|
3106
3079
|
source: e,
|
|
3107
3080
|
repeat: "repeat"
|
|
3108
3081
|
});
|
|
3109
3082
|
}
|
|
3110
3083
|
}
|
|
3111
|
-
const
|
|
3084
|
+
const Ct = {
|
|
3112
3085
|
/**
|
|
3113
3086
|
* Опции редактора
|
|
3114
3087
|
*/
|
|
@@ -3197,14 +3170,14 @@ const Dt = {
|
|
|
3197
3170
|
resetObjectFitByDoubleClick: !0
|
|
3198
3171
|
};
|
|
3199
3172
|
function wt(o, e = {}) {
|
|
3200
|
-
const t = C(C({},
|
|
3173
|
+
const t = C(C({}, Ct), e), a = document.getElementById(o);
|
|
3201
3174
|
if (!a)
|
|
3202
3175
|
return Promise.reject(new Error(`Контейнер с ID "${o}" не найден.`));
|
|
3203
3176
|
const n = document.createElement("canvas");
|
|
3204
3177
|
return n.id = `${o}-canvas`, a.appendChild(n), t.editorContainer = a, new Promise((i) => {
|
|
3205
3178
|
t._onReadyCallback = i;
|
|
3206
|
-
const
|
|
3207
|
-
window[o] =
|
|
3179
|
+
const s = new ue(n.id, t);
|
|
3180
|
+
window[o] = s;
|
|
3208
3181
|
});
|
|
3209
3182
|
}
|
|
3210
3183
|
export {
|