@anu3ev/fabric-image-editor 0.1.32 → 0.1.34
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 → main.js} +387 -389
- package/dist/worker.js +2 -2
- package/package.json +3 -2
- package/readme.md +74 -4
- package/dist/main.map +0 -1
package/dist/{main → main.js}
RENAMED
|
@@ -1,38 +1,38 @@
|
|
|
1
1
|
var Oe = Object.defineProperty;
|
|
2
|
-
var
|
|
2
|
+
var me = Object.getOwnPropertySymbols;
|
|
3
3
|
var Te = Object.prototype.hasOwnProperty, ke = Object.prototype.propertyIsEnumerable;
|
|
4
|
-
var
|
|
4
|
+
var fe = (o, e, t) => e in o ? Oe(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t, Q = (o, e) => {
|
|
5
5
|
for (var t in e || (e = {}))
|
|
6
|
-
Te.call(e, t) &&
|
|
7
|
-
if (
|
|
8
|
-
for (var t of
|
|
9
|
-
ke.call(e, t) &&
|
|
10
|
-
return
|
|
6
|
+
Te.call(e, t) && fe(o, t, e[t]);
|
|
7
|
+
if (me)
|
|
8
|
+
for (var t of me(e))
|
|
9
|
+
ke.call(e, t) && fe(o, t, e[t]);
|
|
10
|
+
return o;
|
|
11
11
|
};
|
|
12
|
-
var
|
|
12
|
+
var J = (o, e, t) => new Promise((a, r) => {
|
|
13
13
|
var i = (c) => {
|
|
14
14
|
try {
|
|
15
|
-
|
|
15
|
+
s(t.next(c));
|
|
16
16
|
} catch (u) {
|
|
17
17
|
r(u);
|
|
18
18
|
}
|
|
19
19
|
}, n = (c) => {
|
|
20
20
|
try {
|
|
21
|
-
|
|
21
|
+
s(t.throw(c));
|
|
22
22
|
} catch (u) {
|
|
23
23
|
r(u);
|
|
24
24
|
}
|
|
25
|
-
},
|
|
26
|
-
|
|
25
|
+
}, s = (c) => c.done ? a(c.value) : Promise.resolve(c.value).then(i, n);
|
|
26
|
+
s((t = t.apply(o, e)).next());
|
|
27
27
|
});
|
|
28
|
-
import { ActiveSelection as
|
|
28
|
+
import { ActiveSelection as H, util as _, controlsUtils as xe, InteractiveFabricObject as Be, loadSVGFromURL as Ze, FabricImage as K, Point as ze, Rect as Ue, Circle as Ye, Triangle as Pe, Group as He, Canvas as _e, Pattern as Re } from "fabric";
|
|
29
29
|
import { create as We } from "jsondiffpatch";
|
|
30
|
-
var Fe = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",
|
|
30
|
+
var Fe = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", C = function() {
|
|
31
31
|
for (var e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 21, t = "", a = crypto.getRandomValues(new Uint8Array(e |= 0)); e--; )
|
|
32
32
|
t += Fe[a[e] & 63];
|
|
33
33
|
return t;
|
|
34
34
|
};
|
|
35
|
-
class
|
|
35
|
+
class P {
|
|
36
36
|
/**
|
|
37
37
|
* Конструктор принимает редактор и опции.
|
|
38
38
|
* @param {Object} params
|
|
@@ -49,7 +49,7 @@ class U {
|
|
|
49
49
|
* @param {Boolean} [params.options.resetObjectFitByDoubleClick] — сброс фита объекта по двойному клику
|
|
50
50
|
*/
|
|
51
51
|
constructor({ editor: e, options: t = {} }) {
|
|
52
|
-
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.adaptCanvasToContainer = !1, this.editor = e, this.canvas = e.canvas, this.options = t, this.handleAdaptCanvasToContainerBound =
|
|
52
|
+
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.adaptCanvasToContainer = !1, this.editor = e, this.canvas = e.canvas, this.options = t, this.handleAdaptCanvasToContainerBound = P.debounce(this.handleAdaptCanvasToContainer.bind(this), 500), this.handleCopyEventBound = this.handleCopyEvent.bind(this), this.handlePasteEventBound = this.handlePasteEvent.bind(this), this.handleUndoRedoEventBound = this.handleUndoRedoEvent.bind(this), this.handleUndoRedoKeyUpBound = this.handleUndoRedoKeyUp.bind(this), this.handleSelectAllEventBound = this.handleSelectAllEvent.bind(this), this.handleDeleteObjectsEventBound = this.handleDeleteObjectsEvent.bind(this), this.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();
|
|
53
53
|
}
|
|
54
54
|
/**
|
|
55
55
|
* Инициализация всех обработчиков согласно опциям.
|
|
@@ -62,12 +62,12 @@ class U {
|
|
|
62
62
|
bringToFrontOnSelection: r,
|
|
63
63
|
copyObjectsByHotkey: i,
|
|
64
64
|
pasteImageFromClipboard: n,
|
|
65
|
-
undoRedoByHotKeys:
|
|
65
|
+
undoRedoByHotKeys: s,
|
|
66
66
|
selectAllByHotkey: c,
|
|
67
67
|
deleteObjectsByHotkey: u,
|
|
68
68
|
resetObjectFitByDoubleClick: l
|
|
69
69
|
} = this.options;
|
|
70
|
-
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), r && (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.handleAdaptCanvasToContainerBound, { capture: !0 }), i && document.addEventListener("keydown", this.handleCopyEventBound, { capture: !0 }), n && document.addEventListener("paste", this.handlePasteEventBound, { capture: !0 }),
|
|
70
|
+
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), r && (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.handleAdaptCanvasToContainerBound, { capture: !0 }), i && document.addEventListener("keydown", this.handleCopyEventBound, { capture: !0 }), n && document.addEventListener("paste", this.handlePasteEventBound, { capture: !0 }), s && (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);
|
|
71
71
|
}
|
|
72
72
|
/**
|
|
73
73
|
* При массовом выделении объектов удаляем из него залоченные.
|
|
@@ -86,7 +86,7 @@ class U {
|
|
|
86
86
|
this.canvas.setActiveObject(r[0]);
|
|
87
87
|
return;
|
|
88
88
|
}
|
|
89
|
-
const i = new
|
|
89
|
+
const i = new H(r, {
|
|
90
90
|
canvas: this.canvas
|
|
91
91
|
});
|
|
92
92
|
this.canvas.setActiveObject(i), this.canvas.requestRenderAll();
|
|
@@ -147,12 +147,12 @@ class U {
|
|
|
147
147
|
if (!((n = e == null ? void 0 : e.items) != null && n.length)) return;
|
|
148
148
|
const { imageManager: t } = this.editor, { items: a } = e, r = a[a.length - 1];
|
|
149
149
|
if (r.type.indexOf("image") !== -1) {
|
|
150
|
-
const
|
|
151
|
-
if (!
|
|
150
|
+
const s = r.getAsFile();
|
|
151
|
+
if (!s) return;
|
|
152
152
|
const c = new FileReader();
|
|
153
153
|
c.onload = (u) => {
|
|
154
154
|
u.target && this.editor.imageManager.importImage({ source: u.target.result });
|
|
155
|
-
}, c.readAsDataURL(
|
|
155
|
+
}, c.readAsDataURL(s);
|
|
156
156
|
return;
|
|
157
157
|
}
|
|
158
158
|
const i = e.getData("text/html");
|
|
@@ -173,7 +173,7 @@ class U {
|
|
|
173
173
|
* @param {String} event.code — код клавиши
|
|
174
174
|
*/
|
|
175
175
|
handleUndoRedoEvent(e) {
|
|
176
|
-
return
|
|
176
|
+
return J(this, null, function* () {
|
|
177
177
|
const { ctrlKey: t, metaKey: a, code: r, repeat: i } = e;
|
|
178
178
|
!t && !a || i || this.isUndoRedoKeyPressed || (r === "KeyZ" ? (e.preventDefault(), this.isUndoRedoKeyPressed = !0, yield this.editor.historyManager.undo()) : r === "KeyY" && (e.preventDefault(), this.isUndoRedoKeyPressed = !0, yield this.editor.historyManager.redo()));
|
|
179
179
|
});
|
|
@@ -302,7 +302,7 @@ class U {
|
|
|
302
302
|
* Метод для удаления всех слушателей
|
|
303
303
|
*/
|
|
304
304
|
destroy() {
|
|
305
|
-
window.removeEventListener("resize", this.handleAdaptCanvasToContainerBound, { capture: !0 }), document.removeEventListener("keydown", this.handleCopyEventBound, { capture: !0 }), document.removeEventListener("paste", this.handlePasteEventBound, { capture: !0 }), document.removeEventListener("keydown", this.handleUndoRedoEventBound, { capture: !0 }), document.removeEventListener("keyup", this.handleUndoRedoKeyUpBound, { capture: !0 }), document.removeEventListener("keydown", this.handleSelectAllEventBound, { capture: !0 }), document.removeEventListener("keydown", this.handleDeleteObjectsEventBound, { capture: !0 }), this.options.canvasDragging && (this.canvas.off("mouse:down", this.handleCanvasDragStartBound), this.canvas.off("mouse:move", this.handleCanvasDraggingBound), this.canvas.off("mouse:up", this.handleCanvasDragEndBound), document.removeEventListener("keydown", this.handleSpaceKeyDownBound, { capture: !0 }), document.removeEventListener("keyup", this.handleSpaceKeyUpBound, { capture: !0 })), this.options.mouseWheelZooming && this.canvas.off("mouse:wheel", this.handleMouseWheelZoomBound), this.options.bringToFrontOnSelection && (this.canvas.off("selection:created", this.handleBringToFrontBound), this.canvas.off("selection:updated", this.handleBringToFrontBound)), this.options.resetObjectFitByDoubleClick && this.canvas.off("mouse:dblclick", this.handleResetObjectFitBound), this.canvas.off("object:modified", this.handleObjectModifiedHistoryBound), this.canvas.off("object:rotating", this.handleObjectRotatingHistoryBound), this.canvas.off("object:added", this.handleObjectAddedHistoryBound), this.canvas.off("object:removed", this.handleObjectRemovedHistoryBound), this.canvas.off("object:added", this.handleOverlayUpdateBound), this.canvas.off("selection:created", this.handleOverlayUpdateBound), this.canvas.off("selection:created", this.handleLockedSelectionBound
|
|
305
|
+
window.removeEventListener("resize", this.handleAdaptCanvasToContainerBound, { capture: !0 }), document.removeEventListener("keydown", this.handleCopyEventBound, { capture: !0 }), document.removeEventListener("paste", this.handlePasteEventBound, { capture: !0 }), document.removeEventListener("keydown", this.handleUndoRedoEventBound, { capture: !0 }), document.removeEventListener("keyup", this.handleUndoRedoKeyUpBound, { capture: !0 }), document.removeEventListener("keydown", this.handleSelectAllEventBound, { capture: !0 }), document.removeEventListener("keydown", this.handleDeleteObjectsEventBound, { capture: !0 }), this.options.canvasDragging && (this.canvas.off("mouse:down", this.handleCanvasDragStartBound), this.canvas.off("mouse:move", this.handleCanvasDraggingBound), this.canvas.off("mouse:up", this.handleCanvasDragEndBound), document.removeEventListener("keydown", this.handleSpaceKeyDownBound, { capture: !0 }), document.removeEventListener("keyup", this.handleSpaceKeyUpBound, { capture: !0 })), this.options.mouseWheelZooming && this.canvas.off("mouse:wheel", this.handleMouseWheelZoomBound), this.options.bringToFrontOnSelection && (this.canvas.off("selection:created", this.handleBringToFrontBound), this.canvas.off("selection:updated", this.handleBringToFrontBound)), this.options.resetObjectFitByDoubleClick && this.canvas.off("mouse:dblclick", this.handleResetObjectFitBound), this.canvas.off("object:modified", this.handleObjectModifiedHistoryBound), this.canvas.off("object:rotating", this.handleObjectRotatingHistoryBound), this.canvas.off("object:added", this.handleObjectAddedHistoryBound), this.canvas.off("object:removed", this.handleObjectRemovedHistoryBound), this.canvas.off("object:added", this.handleOverlayUpdateBound), this.canvas.off("selection:created", this.handleOverlayUpdateBound), this.canvas.off("selection:created", this.handleLockedSelectionBound), this.canvas.off("selection:updated", this.handleLockedSelectionBound);
|
|
306
306
|
}
|
|
307
307
|
/**
|
|
308
308
|
* Дебаунс для снижения частоты вызова функции.
|
|
@@ -367,8 +367,8 @@ class Ge {
|
|
|
367
367
|
success: r,
|
|
368
368
|
data: i,
|
|
369
369
|
error: n
|
|
370
|
-
} = t,
|
|
371
|
-
|
|
370
|
+
} = t, s = this._callbacks.get(a);
|
|
371
|
+
s && (r ? s.resolve(i) : s.reject(new Error(n)), this._callbacks.delete(a));
|
|
372
372
|
}
|
|
373
373
|
/**
|
|
374
374
|
* Универсальный метод отправки команды в воркер
|
|
@@ -378,7 +378,7 @@ class Ge {
|
|
|
378
378
|
* @returns {Promise<any>}
|
|
379
379
|
*/
|
|
380
380
|
post(e, t) {
|
|
381
|
-
var a = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : [], r = "".concat(e, ":").concat(
|
|
381
|
+
var a = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : [], r = "".concat(e, ":").concat(C(8));
|
|
382
382
|
return new Promise((i, n) => {
|
|
383
383
|
this._callbacks.set(r, {
|
|
384
384
|
resolve: i,
|
|
@@ -397,50 +397,50 @@ class Ge {
|
|
|
397
397
|
this.worker.terminate();
|
|
398
398
|
}
|
|
399
399
|
}
|
|
400
|
-
var I = 12, Xe = 2,
|
|
401
|
-
function
|
|
400
|
+
var I = 12, Xe = 2, te = 8, ae = 20, Qe = 100, re = 20, ie = 8, Je = 100, ne = 32, se = 1, Ke = "#2B2D33", oe = "#3D8BF4", ce = "#FFFFFF";
|
|
401
|
+
function V(o, e, t, a, r) {
|
|
402
402
|
var i = I, n = Xe;
|
|
403
|
-
|
|
403
|
+
o.save(), o.translate(e, t), o.rotate(_.degreesToRadians(r.angle)), o.fillStyle = ce, o.strokeStyle = oe, o.lineWidth = se, o.beginPath(), o.roundRect(-12 / 2, -12 / 2, i, i, n), o.fill(), o.stroke(), o.restore();
|
|
404
404
|
}
|
|
405
|
-
function
|
|
406
|
-
var i =
|
|
407
|
-
|
|
405
|
+
function Me(o, e, t, a, r) {
|
|
406
|
+
var i = te, n = ae, s = Qe;
|
|
407
|
+
o.save(), o.translate(e, t), o.rotate(_.degreesToRadians(r.angle)), o.fillStyle = ce, o.strokeStyle = oe, o.lineWidth = se, o.beginPath(), o.roundRect(-8 / 2, -20 / 2, i, n, s), o.fill(), o.stroke(), o.restore();
|
|
408
408
|
}
|
|
409
|
-
function
|
|
410
|
-
var i =
|
|
411
|
-
|
|
409
|
+
function je(o, e, t, a, r) {
|
|
410
|
+
var i = re, n = ie, s = Je;
|
|
411
|
+
o.save(), o.translate(e, t), o.rotate(_.degreesToRadians(r.angle)), o.fillStyle = ce, o.strokeStyle = oe, o.lineWidth = se, o.beginPath(), o.roundRect(-20 / 2, -8 / 2, i, n, s), o.fill(), o.stroke(), o.restore();
|
|
412
412
|
}
|
|
413
413
|
var $e = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTE4Ljc1IDQuMzc1djMuNzVhLjYyNS42MjUgMCAwIDEtLjYyNS42MjVoLTMuNzVhLjYyNS42MjUgMCAwIDEgMC0xLjI1aDIuMTRsLTIuMDc3LTEuOTAzLS4wMi0uMDE5YTYuMjUgNi4yNSAwIDEgMC0uMTMgOC45NjcuNjI2LjYyNiAwIDAgMSAuODYuOTA5QTcuNDU2IDcuNDU2IDAgMCAxIDEwIDE3LjVoLS4xMDNhNy41IDcuNSAwIDEgMSA1LjM5Ni0xMi44MTJMMTcuNSA2LjcwM1Y0LjM3NWEuNjI1LjYyNSAwIDAgMSAxLjI1IDBaIi8+PC9zdmc+", we = new Image();
|
|
414
414
|
we.src = $e;
|
|
415
|
-
function qe(
|
|
416
|
-
var i =
|
|
417
|
-
|
|
415
|
+
function qe(o, e, t, a, r) {
|
|
416
|
+
var i = ne, n = i / 2;
|
|
417
|
+
o.save(), o.translate(e, t), o.rotate(_.degreesToRadians(r.angle)), o.fillStyle = Ke, o.beginPath(), o.arc(0, 0, n, 0, 2 * Math.PI), o.fill(), o.drawImage(we, -16 / 2, -16 / 2, n, n), o.restore();
|
|
418
418
|
}
|
|
419
419
|
var et = {
|
|
420
420
|
// Угловые точки
|
|
421
421
|
tl: {
|
|
422
|
-
render:
|
|
422
|
+
render: V,
|
|
423
423
|
sizeX: I,
|
|
424
424
|
sizeY: I,
|
|
425
425
|
offsetX: 0,
|
|
426
426
|
offsetY: 0
|
|
427
427
|
},
|
|
428
428
|
tr: {
|
|
429
|
-
render:
|
|
429
|
+
render: V,
|
|
430
430
|
sizeX: I,
|
|
431
431
|
sizeY: I,
|
|
432
432
|
offsetX: 0,
|
|
433
433
|
offsetY: 0
|
|
434
434
|
},
|
|
435
435
|
bl: {
|
|
436
|
-
render:
|
|
436
|
+
render: V,
|
|
437
437
|
sizeX: I,
|
|
438
438
|
sizeY: I,
|
|
439
439
|
offsetX: 0,
|
|
440
440
|
offsetY: 0
|
|
441
441
|
},
|
|
442
442
|
br: {
|
|
443
|
-
render:
|
|
443
|
+
render: V,
|
|
444
444
|
sizeX: I,
|
|
445
445
|
sizeY: I,
|
|
446
446
|
offsetX: 0,
|
|
@@ -448,39 +448,39 @@ var et = {
|
|
|
448
448
|
},
|
|
449
449
|
// Середина вертикалей
|
|
450
450
|
ml: {
|
|
451
|
-
render:
|
|
452
|
-
sizeX:
|
|
453
|
-
sizeY:
|
|
451
|
+
render: Me,
|
|
452
|
+
sizeX: te,
|
|
453
|
+
sizeY: ae,
|
|
454
454
|
offsetX: 0,
|
|
455
455
|
offsetY: 0
|
|
456
456
|
},
|
|
457
457
|
mr: {
|
|
458
|
-
render:
|
|
459
|
-
sizeX:
|
|
460
|
-
sizeY:
|
|
458
|
+
render: Me,
|
|
459
|
+
sizeX: te,
|
|
460
|
+
sizeY: ae,
|
|
461
461
|
offsetX: 0,
|
|
462
462
|
offsetY: 0
|
|
463
463
|
},
|
|
464
464
|
// Середина горизонталей
|
|
465
465
|
mt: {
|
|
466
|
-
render:
|
|
467
|
-
sizeX:
|
|
468
|
-
sizeY:
|
|
466
|
+
render: je,
|
|
467
|
+
sizeX: re,
|
|
468
|
+
sizeY: ie,
|
|
469
469
|
offsetX: 0,
|
|
470
470
|
offsetY: 0
|
|
471
471
|
},
|
|
472
472
|
mb: {
|
|
473
|
-
render:
|
|
474
|
-
sizeX:
|
|
475
|
-
sizeY:
|
|
473
|
+
render: je,
|
|
474
|
+
sizeX: re,
|
|
475
|
+
sizeY: ie,
|
|
476
476
|
offsetX: 0,
|
|
477
477
|
offsetY: 0
|
|
478
478
|
},
|
|
479
479
|
// Специальный «rotate» контрол
|
|
480
480
|
mtr: {
|
|
481
481
|
render: qe,
|
|
482
|
-
sizeX:
|
|
483
|
-
sizeY:
|
|
482
|
+
sizeX: ne,
|
|
483
|
+
sizeY: ne,
|
|
484
484
|
offsetX: 0,
|
|
485
485
|
offsetY: -32
|
|
486
486
|
}
|
|
@@ -501,30 +501,30 @@ class tt {
|
|
|
501
501
|
}
|
|
502
502
|
}
|
|
503
503
|
var at = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNNi44NzUgMi41YS42MjUuNjI1IDAgMCAwLS42MjUuNjI0VjYuMjVIMy4xMjVhLjYyNS42MjUgMCAwIDAtLjYyNS42MjV2MTBjMCAuMzQ1LjI4LjYyNS42MjUuNjI1aDEwYy4zNDUgMCAuNjI1LS4yOC42MjUtLjYyNXYtMy4xMjZoMy4xMjVjLjM0NSAwIC42MjUtLjI4LjYyNS0uNjI1di0xMGEuNjI1LjYyNSAwIDAgMC0uNjI1LS42MjVoLTEwWm02Ljg3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jI1VjVoLjYyNWEuNjI1LjYyNSAwIDAgMCAwLTEuMjVIMTMuNzV2LS42MjVhMS44NzUgMS44NzUgMCAwIDAtMS44NzUtMS44NzVoLTMuNzVabTQuMzc1IDIuNXYtLjYyNWEuNjI1LjYyNSAwIDAgMC0uNjI1LS42MjVoLTMuNzVhLjYyNS42MjUgMCAwIDAtLjYyNS42MjV2LjYyNWg1Wk01IDE2LjI1VjVoMTB2MTEuMjVINVpNOC4xMjUgNy41Yy4zNDUgMCAuNjI1LjI4LjYyNS42MjV2NWEuNjI1LjYyNSAwIDEgMS0xLjI1IDB2LTVjMC0uMzQ1LjI4LS42MjUuNjI1LS42MjVabTQuMzc1IDUuNjI1di01YS42MjUuNjI1IDAgMCAwLTEuMjUgMHY1YS42MjUuNjI1IDAgMSAwIDEuMjUgMFoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjwvc3ZnPg==";
|
|
504
|
-
function
|
|
504
|
+
function ye(o, e, t, a, r, i, n) {
|
|
505
505
|
try {
|
|
506
|
-
var
|
|
506
|
+
var s = o[i](n), c = s.value;
|
|
507
507
|
} catch (u) {
|
|
508
508
|
return void t(u);
|
|
509
509
|
}
|
|
510
|
-
|
|
510
|
+
s.done ? e(c) : Promise.resolve(c).then(a, r);
|
|
511
511
|
}
|
|
512
|
-
function dt(
|
|
512
|
+
function dt(o) {
|
|
513
513
|
return function() {
|
|
514
514
|
var e = this, t = arguments;
|
|
515
515
|
return new Promise(function(a, r) {
|
|
516
|
-
var i =
|
|
516
|
+
var i = o.apply(e, t);
|
|
517
517
|
function n(c) {
|
|
518
|
-
|
|
518
|
+
ye(i, a, r, n, s, "next", c);
|
|
519
519
|
}
|
|
520
|
-
function
|
|
521
|
-
|
|
520
|
+
function s(c) {
|
|
521
|
+
ye(i, a, r, n, s, "throw", c);
|
|
522
522
|
}
|
|
523
523
|
n(void 0);
|
|
524
524
|
});
|
|
525
525
|
};
|
|
526
526
|
}
|
|
527
|
-
const
|
|
527
|
+
const Y = {
|
|
528
528
|
style: {
|
|
529
529
|
position: "absolute",
|
|
530
530
|
display: "none",
|
|
@@ -594,74 +594,74 @@ const B = {
|
|
|
594
594
|
},
|
|
595
595
|
handlers: {
|
|
596
596
|
copyPaste: function() {
|
|
597
|
-
var
|
|
597
|
+
var o = dt(function* (t) {
|
|
598
598
|
yield t.clipboardManager.copy(), yield t.clipboardManager.paste();
|
|
599
599
|
});
|
|
600
600
|
function e(t) {
|
|
601
|
-
return
|
|
601
|
+
return o.apply(this, arguments);
|
|
602
602
|
}
|
|
603
603
|
return e;
|
|
604
604
|
}(),
|
|
605
|
-
delete: (
|
|
606
|
-
|
|
605
|
+
delete: (o) => {
|
|
606
|
+
o.deletionManager.deleteSelectedObjects();
|
|
607
607
|
},
|
|
608
|
-
lock: (
|
|
609
|
-
|
|
608
|
+
lock: (o) => {
|
|
609
|
+
o.objectLockManager.lockObject();
|
|
610
610
|
},
|
|
611
|
-
unlock: (
|
|
612
|
-
|
|
611
|
+
unlock: (o) => {
|
|
612
|
+
o.objectLockManager.unlockObject();
|
|
613
613
|
},
|
|
614
|
-
bringForward: (
|
|
615
|
-
|
|
614
|
+
bringForward: (o) => {
|
|
615
|
+
o.layerManager.bringForward();
|
|
616
616
|
},
|
|
617
|
-
bringToFront: (
|
|
618
|
-
|
|
617
|
+
bringToFront: (o) => {
|
|
618
|
+
o.layerManager.bringToFront();
|
|
619
619
|
},
|
|
620
|
-
sendToBack: (
|
|
621
|
-
|
|
620
|
+
sendToBack: (o) => {
|
|
621
|
+
o.layerManager.sendToBack();
|
|
622
622
|
},
|
|
623
|
-
sendBackwards: (
|
|
624
|
-
|
|
623
|
+
sendBackwards: (o) => {
|
|
624
|
+
o.layerManager.sendBackwards();
|
|
625
625
|
}
|
|
626
626
|
}
|
|
627
627
|
};
|
|
628
|
-
function
|
|
629
|
-
var t = Object.keys(
|
|
628
|
+
function pe(o, e) {
|
|
629
|
+
var t = Object.keys(o);
|
|
630
630
|
if (Object.getOwnPropertySymbols) {
|
|
631
|
-
var a = Object.getOwnPropertySymbols(
|
|
631
|
+
var a = Object.getOwnPropertySymbols(o);
|
|
632
632
|
e && (a = a.filter(function(r) {
|
|
633
|
-
return Object.getOwnPropertyDescriptor(
|
|
633
|
+
return Object.getOwnPropertyDescriptor(o, r).enumerable;
|
|
634
634
|
})), t.push.apply(t, a);
|
|
635
635
|
}
|
|
636
636
|
return t;
|
|
637
637
|
}
|
|
638
|
-
function j(
|
|
638
|
+
function j(o) {
|
|
639
639
|
for (var e = 1; e < arguments.length; e++) {
|
|
640
640
|
var t = arguments[e] != null ? arguments[e] : {};
|
|
641
|
-
e % 2 ?
|
|
642
|
-
lt(
|
|
643
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(
|
|
644
|
-
Object.defineProperty(
|
|
641
|
+
e % 2 ? pe(Object(t), !0).forEach(function(a) {
|
|
642
|
+
lt(o, a, t[a]);
|
|
643
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(o, Object.getOwnPropertyDescriptors(t)) : pe(Object(t)).forEach(function(a) {
|
|
644
|
+
Object.defineProperty(o, a, Object.getOwnPropertyDescriptor(t, a));
|
|
645
645
|
});
|
|
646
646
|
}
|
|
647
|
-
return
|
|
647
|
+
return o;
|
|
648
648
|
}
|
|
649
|
-
function lt(
|
|
650
|
-
return (e = ht(e)) in
|
|
649
|
+
function lt(o, e, t) {
|
|
650
|
+
return (e = ht(e)) in o ? Object.defineProperty(o, e, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : o[e] = t, o;
|
|
651
651
|
}
|
|
652
|
-
function ht(
|
|
653
|
-
var e = gt(
|
|
652
|
+
function ht(o) {
|
|
653
|
+
var e = gt(o, "string");
|
|
654
654
|
return typeof e == "symbol" ? e : e + "";
|
|
655
655
|
}
|
|
656
|
-
function gt(
|
|
657
|
-
if (typeof
|
|
658
|
-
var t =
|
|
656
|
+
function gt(o, e) {
|
|
657
|
+
if (typeof o != "object" || !o) return o;
|
|
658
|
+
var t = o[Symbol.toPrimitive];
|
|
659
659
|
if (t !== void 0) {
|
|
660
|
-
var a = t.call(
|
|
660
|
+
var a = t.call(o, e);
|
|
661
661
|
if (typeof a != "object") return a;
|
|
662
662
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
663
663
|
}
|
|
664
|
-
return (e === "string" ? String : Number)(
|
|
664
|
+
return (e === "string" ? String : Number)(o);
|
|
665
665
|
}
|
|
666
666
|
class vt {
|
|
667
667
|
/**
|
|
@@ -675,11 +675,11 @@ class vt {
|
|
|
675
675
|
if (this.options = t.options, !!this.options.showToolbar) {
|
|
676
676
|
this.editor = t, this.canvas = t.canvas;
|
|
677
677
|
var a = this.options.toolbar || {};
|
|
678
|
-
this.config = j(j(j({},
|
|
679
|
-
style: j(j({},
|
|
680
|
-
btnStyle: j(j({},
|
|
681
|
-
icons: j(j({},
|
|
682
|
-
handlers: j(j({},
|
|
678
|
+
this.config = j(j(j({}, Y), a), {}, {
|
|
679
|
+
style: j(j({}, Y.style), a.style || {}),
|
|
680
|
+
btnStyle: j(j({}, Y.btnStyle), a.btnStyle || {}),
|
|
681
|
+
icons: j(j({}, Y.icons), a.icons || {}),
|
|
682
|
+
handlers: j(j({}, Y.handlers), a.handlers || {})
|
|
683
683
|
}), this.currentTarget = null, this.currentLocked = null, this.isTransforming = !1, this._onMouseDown = this._handleMouseDown.bind(this), this._onObjectMoving = this._startTransform.bind(this), this._onObjectScaling = this._startTransform.bind(this), this._onObjectRotating = this._startTransform.bind(this), this._onMouseUp = this._endTransform.bind(this), this._onObjectModified = this._endTransform.bind(this), this._onSelectionChange = this._updateToolbar.bind(this), this._onSelectionClear = () => {
|
|
684
684
|
this.el.style.display = "none";
|
|
685
685
|
}, this._createDOM(), this._bindEvents();
|
|
@@ -714,15 +714,15 @@ class vt {
|
|
|
714
714
|
var a = function() {
|
|
715
715
|
var {
|
|
716
716
|
name: n,
|
|
717
|
-
handle:
|
|
717
|
+
handle: s
|
|
718
718
|
} = r, {
|
|
719
719
|
icons: c,
|
|
720
720
|
btnStyle: u,
|
|
721
721
|
handlers: l
|
|
722
722
|
} = t.config, d = document.createElement("button");
|
|
723
|
-
d.innerHTML = c[
|
|
723
|
+
d.innerHTML = c[s] ? '<img src="'.concat(c[s], '" title="').concat(n, '" />') : n, Object.assign(d.style, u), d.onclick = () => {
|
|
724
724
|
var h;
|
|
725
|
-
return (h = l[
|
|
725
|
+
return (h = l[s]) === null || h === void 0 ? void 0 : h.call(l, t.editor);
|
|
726
726
|
}, t.el.appendChild(d);
|
|
727
727
|
};
|
|
728
728
|
for (var r of e)
|
|
@@ -795,12 +795,12 @@ class vt {
|
|
|
795
795
|
canvas: r
|
|
796
796
|
} = this;
|
|
797
797
|
e.setCoords();
|
|
798
|
-
var i = r.getZoom(), [, , , , n,
|
|
798
|
+
var i = r.getZoom(), [, , , , n, s] = r.viewportTransform, {
|
|
799
799
|
x: c
|
|
800
800
|
} = e.getCenterPoint(), {
|
|
801
801
|
top: u,
|
|
802
802
|
height: l
|
|
803
|
-
} = e.getBoundingRect(!1, !0), d = c * i + n, h = d - t.offsetWidth / 2, v = (u + l) * i +
|
|
803
|
+
} = e.getBoundingRect(!1, !0), d = c * i + n, h = d - t.offsetWidth / 2, v = (u + l) * i + s + a.offsetTop;
|
|
804
804
|
Object.assign(t.style, {
|
|
805
805
|
left: "".concat(h, "px"),
|
|
806
806
|
top: "".concat(v, "px"),
|
|
@@ -815,24 +815,24 @@ class vt {
|
|
|
815
815
|
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();
|
|
816
816
|
}
|
|
817
817
|
}
|
|
818
|
-
function
|
|
818
|
+
function be(o, e, t, a, r, i, n) {
|
|
819
819
|
try {
|
|
820
|
-
var
|
|
820
|
+
var s = o[i](n), c = s.value;
|
|
821
821
|
} catch (u) {
|
|
822
822
|
return void t(u);
|
|
823
823
|
}
|
|
824
|
-
|
|
824
|
+
s.done ? e(c) : Promise.resolve(c).then(a, r);
|
|
825
825
|
}
|
|
826
|
-
function
|
|
826
|
+
function $(o) {
|
|
827
827
|
return function() {
|
|
828
828
|
var e = this, t = arguments;
|
|
829
829
|
return new Promise(function(a, r) {
|
|
830
|
-
var i =
|
|
830
|
+
var i = o.apply(e, t);
|
|
831
831
|
function n(c) {
|
|
832
|
-
|
|
832
|
+
be(i, a, r, n, s, "next", c);
|
|
833
833
|
}
|
|
834
|
-
function
|
|
835
|
-
|
|
834
|
+
function s(c) {
|
|
835
|
+
be(i, a, r, n, s, "throw", c);
|
|
836
836
|
}
|
|
837
837
|
n(void 0);
|
|
838
838
|
});
|
|
@@ -927,7 +927,7 @@ class mt {
|
|
|
927
927
|
*/
|
|
928
928
|
loadStateFromFullState(e) {
|
|
929
929
|
var t = this;
|
|
930
|
-
return
|
|
930
|
+
return $(function* () {
|
|
931
931
|
if (e) {
|
|
932
932
|
console.log("loadStateFromFullState fullState", e), yield t.canvas.loadFromJSON(e);
|
|
933
933
|
var a = t.canvas.getObjects().find((i) => i.id === "montage-area");
|
|
@@ -943,7 +943,7 @@ class mt {
|
|
|
943
943
|
*/
|
|
944
944
|
undo() {
|
|
945
945
|
var e = this;
|
|
946
|
-
return
|
|
946
|
+
return $(function* () {
|
|
947
947
|
if (!e.skipHistory) {
|
|
948
948
|
if (e.currentIndex <= 0) {
|
|
949
949
|
console.log("Нет предыдущих состояний для отмены.");
|
|
@@ -970,7 +970,7 @@ class mt {
|
|
|
970
970
|
*/
|
|
971
971
|
redo() {
|
|
972
972
|
var e = this;
|
|
973
|
-
return
|
|
973
|
+
return $(function* () {
|
|
974
974
|
if (!e.skipHistory) {
|
|
975
975
|
if (e.currentIndex >= e.patches.length) {
|
|
976
976
|
console.log("Нет состояний для повтора.");
|
|
@@ -992,25 +992,25 @@ class mt {
|
|
|
992
992
|
})();
|
|
993
993
|
}
|
|
994
994
|
}
|
|
995
|
-
const ft = 0.1, Mt = 2, jt = 0.1, yt = 90,
|
|
996
|
-
function
|
|
995
|
+
const ft = 0.1, Mt = 2, jt = 0.1, yt = 90, T = 16, k = 16, L = 4096, E = 4096;
|
|
996
|
+
function Ie(o, e, t, a, r, i, n) {
|
|
997
997
|
try {
|
|
998
|
-
var
|
|
998
|
+
var s = o[i](n), c = s.value;
|
|
999
999
|
} catch (u) {
|
|
1000
1000
|
return void t(u);
|
|
1001
1001
|
}
|
|
1002
|
-
|
|
1002
|
+
s.done ? e(c) : Promise.resolve(c).then(a, r);
|
|
1003
1003
|
}
|
|
1004
|
-
function
|
|
1004
|
+
function O(o) {
|
|
1005
1005
|
return function() {
|
|
1006
1006
|
var e = this, t = arguments;
|
|
1007
1007
|
return new Promise(function(a, r) {
|
|
1008
|
-
var i =
|
|
1008
|
+
var i = o.apply(e, t);
|
|
1009
1009
|
function n(c) {
|
|
1010
|
-
|
|
1010
|
+
Ie(i, a, r, n, s, "next", c);
|
|
1011
1011
|
}
|
|
1012
|
-
function
|
|
1013
|
-
|
|
1012
|
+
function s(c) {
|
|
1013
|
+
Ie(i, a, r, n, s, "throw", c);
|
|
1014
1014
|
}
|
|
1015
1015
|
n(void 0);
|
|
1016
1016
|
});
|
|
@@ -1041,7 +1041,7 @@ class A {
|
|
|
1041
1041
|
*/
|
|
1042
1042
|
importImage(e) {
|
|
1043
1043
|
var t = this;
|
|
1044
|
-
return
|
|
1044
|
+
return O(function* () {
|
|
1045
1045
|
var {
|
|
1046
1046
|
source: a,
|
|
1047
1047
|
scale: r = "image-".concat(t.options.scaleType),
|
|
@@ -1050,7 +1050,7 @@ class A {
|
|
|
1050
1050
|
if (!a) return null;
|
|
1051
1051
|
var {
|
|
1052
1052
|
canvas: n,
|
|
1053
|
-
montageArea:
|
|
1053
|
+
montageArea: s,
|
|
1054
1054
|
transformManager: c,
|
|
1055
1055
|
historyManager: u,
|
|
1056
1056
|
errorManager: l
|
|
@@ -1080,13 +1080,13 @@ class A {
|
|
|
1080
1080
|
if (a instanceof File)
|
|
1081
1081
|
M = URL.createObjectURL(a);
|
|
1082
1082
|
else if (typeof a == "string") {
|
|
1083
|
-
var
|
|
1083
|
+
var S = yield fetch(a, {
|
|
1084
1084
|
mode: "cors"
|
|
1085
|
-
}),
|
|
1085
|
+
}), w = yield S.blob({
|
|
1086
1086
|
type: d,
|
|
1087
1087
|
quality: 1
|
|
1088
1088
|
});
|
|
1089
|
-
M = URL.createObjectURL(
|
|
1089
|
+
M = URL.createObjectURL(w);
|
|
1090
1090
|
} else
|
|
1091
1091
|
return l.emitError({
|
|
1092
1092
|
origin: "ImageManager",
|
|
@@ -1102,47 +1102,52 @@ class A {
|
|
|
1102
1102
|
}
|
|
1103
1103
|
}), null;
|
|
1104
1104
|
if (t._createdBlobUrls.push(M), h === "svg") {
|
|
1105
|
-
var
|
|
1106
|
-
g =
|
|
1105
|
+
var D = yield Ze(M);
|
|
1106
|
+
g = _.groupSVGElements(D.objects, D.options);
|
|
1107
1107
|
} else
|
|
1108
|
-
g = yield
|
|
1108
|
+
g = yield K.fromURL(M, {
|
|
1109
1109
|
crossOrigin: "anonymous"
|
|
1110
1110
|
});
|
|
1111
1111
|
var {
|
|
1112
|
-
width:
|
|
1113
|
-
height:
|
|
1112
|
+
width: N,
|
|
1113
|
+
height: y
|
|
1114
1114
|
} = g;
|
|
1115
|
-
if (
|
|
1116
|
-
var p = yield t.resizeImageToBoundaries(g._element.src, "max"),
|
|
1117
|
-
t._createdBlobUrls.push(
|
|
1115
|
+
if (y > E || N > L) {
|
|
1116
|
+
var p = yield t.resizeImageToBoundaries(g._element.src, "max"), x = URL.createObjectURL(p);
|
|
1117
|
+
t._createdBlobUrls.push(x), g = yield K.fromURL(x, {
|
|
1118
|
+
crossOrigin: "anonymous"
|
|
1119
|
+
});
|
|
1120
|
+
} else if (y < k || N < T) {
|
|
1121
|
+
var R = yield t.resizeImageToBoundaries(g._element.src, "min"), B = URL.createObjectURL(R);
|
|
1122
|
+
t._createdBlobUrls.push(B), g = yield K.fromURL(B, {
|
|
1118
1123
|
crossOrigin: "anonymous"
|
|
1119
1124
|
});
|
|
1120
1125
|
}
|
|
1121
|
-
if (g.set("id", "".concat(g.type, "-").concat(
|
|
1126
|
+
if (g.set("id", "".concat(g.type, "-").concat(C())), g.set("format", h), r === "scale-montage")
|
|
1122
1127
|
t.editor.canvasManager.scaleMontageAreaToImage({
|
|
1123
1128
|
object: g,
|
|
1124
1129
|
withoutSave: !0
|
|
1125
1130
|
});
|
|
1126
1131
|
else {
|
|
1127
1132
|
var {
|
|
1128
|
-
width:
|
|
1129
|
-
height:
|
|
1130
|
-
} =
|
|
1133
|
+
width: W,
|
|
1134
|
+
height: Z
|
|
1135
|
+
} = s, z = t.calculateScaleFactor({
|
|
1131
1136
|
imageObject: g,
|
|
1132
1137
|
scaleType: r
|
|
1133
1138
|
});
|
|
1134
|
-
r === "image-contain" &&
|
|
1139
|
+
r === "image-contain" && z < 1 ? c.fitObject({
|
|
1135
1140
|
object: g,
|
|
1136
1141
|
type: "contain",
|
|
1137
1142
|
withoutSave: !0
|
|
1138
|
-
}) : r === "image-cover" && (
|
|
1143
|
+
}) : r === "image-cover" && (N > W || y > Z) && c.fitObject({
|
|
1139
1144
|
object: g,
|
|
1140
1145
|
type: "cover",
|
|
1141
1146
|
withoutSave: !0
|
|
1142
1147
|
});
|
|
1143
1148
|
}
|
|
1144
1149
|
n.add(g), n.centerObject(g), n.setActiveObject(g), n.renderAll(), u.resumeHistory(), i || u.saveState();
|
|
1145
|
-
var
|
|
1150
|
+
var F = {
|
|
1146
1151
|
image: g,
|
|
1147
1152
|
format: h,
|
|
1148
1153
|
contentType: d,
|
|
@@ -1150,13 +1155,13 @@ class A {
|
|
|
1150
1155
|
withoutSave: i,
|
|
1151
1156
|
source: a
|
|
1152
1157
|
};
|
|
1153
|
-
return n.fire("editor:image-imported",
|
|
1154
|
-
} catch (
|
|
1158
|
+
return n.fire("editor:image-imported", F), F;
|
|
1159
|
+
} catch (U) {
|
|
1155
1160
|
return l.emitError({
|
|
1156
1161
|
origin: "ImageManager",
|
|
1157
1162
|
method: "importImage",
|
|
1158
1163
|
code: "IMPORT_FAILED",
|
|
1159
|
-
message: "Ошибка импорта изображения: ".concat(
|
|
1164
|
+
message: "Ошибка импорта изображения: ".concat(U.message),
|
|
1160
1165
|
data: {
|
|
1161
1166
|
source: a,
|
|
1162
1167
|
format: h,
|
|
@@ -1178,25 +1183,24 @@ class A {
|
|
|
1178
1183
|
*/
|
|
1179
1184
|
resizeImageToBoundaries(e) {
|
|
1180
1185
|
var t = arguments, a = this;
|
|
1181
|
-
return
|
|
1182
|
-
var r = t.length > 1 && t[1] !== void 0 ? t[1] : "max", i = "Размер изображения больше максимального размера канваса, поэтому оно будет уменьшено до максимальных
|
|
1183
|
-
|
|
1186
|
+
return O(function* () {
|
|
1187
|
+
var r = t.length > 1 && t[1] !== void 0 ? t[1] : "max", i = "Размер изображения больше максимального размера канваса, поэтому оно будет уменьшено до максимальных размеров c сохранением пропорций: ".concat(L, "x").concat(E);
|
|
1188
|
+
r === "min" && (i = "Размер изображения меньше минимального размера канваса, поэтому оно будет увеличено до минимальных размеров c сохранением пропорций: ".concat(T, "x").concat(k));
|
|
1189
|
+
var n = {
|
|
1190
|
+
dataURL: e,
|
|
1191
|
+
sizeType: r,
|
|
1192
|
+
maxWidth: L,
|
|
1193
|
+
maxHeight: E,
|
|
1194
|
+
minWidth: T,
|
|
1195
|
+
minHeight: k
|
|
1196
|
+
};
|
|
1197
|
+
return a.editor.errorManager.emitWarning({
|
|
1184
1198
|
origin: "ImageManager",
|
|
1185
1199
|
method: "resizeImageToBoundaries",
|
|
1186
1200
|
code: "IMAGE_RESIZE_WARNING",
|
|
1187
1201
|
message: i,
|
|
1188
|
-
data:
|
|
1189
|
-
|
|
1190
|
-
size: r
|
|
1191
|
-
}
|
|
1192
|
-
});
|
|
1193
|
-
var n = yield a.editor.workerManager.post("resizeImage", {
|
|
1194
|
-
dataURL: e,
|
|
1195
|
-
maxWidth: D,
|
|
1196
|
-
maxHeight: L,
|
|
1197
|
-
sizeType: r
|
|
1198
|
-
});
|
|
1199
|
-
return n;
|
|
1202
|
+
data: n
|
|
1203
|
+
}), a.editor.workerManager.post("resizeImage", n);
|
|
1200
1204
|
})();
|
|
1201
1205
|
}
|
|
1202
1206
|
/**
|
|
@@ -1212,14 +1216,14 @@ class A {
|
|
|
1212
1216
|
*/
|
|
1213
1217
|
exportCanvasAsImageFile() {
|
|
1214
1218
|
var e = arguments, t = this;
|
|
1215
|
-
return
|
|
1219
|
+
return O(function* () {
|
|
1216
1220
|
var {
|
|
1217
1221
|
fileName: a = "image.png",
|
|
1218
1222
|
contentType: r = "image/png",
|
|
1219
1223
|
exportAsBase64: i = !1,
|
|
1220
1224
|
exportAsBlob: n = !1
|
|
1221
1225
|
} = e.length > 0 && e[0] !== void 0 ? e[0] : {}, {
|
|
1222
|
-
canvas:
|
|
1226
|
+
canvas: s,
|
|
1223
1227
|
montageArea: c,
|
|
1224
1228
|
workerManager: u
|
|
1225
1229
|
} = t.editor;
|
|
@@ -1231,91 +1235,91 @@ class A {
|
|
|
1231
1235
|
top: m,
|
|
1232
1236
|
width: f,
|
|
1233
1237
|
height: M
|
|
1234
|
-
} = c.getBoundingRect(), g = yield
|
|
1238
|
+
} = c.getBoundingRect(), g = yield s.clone(["id", "format", "locked"]);
|
|
1235
1239
|
["image/jpg", "image/jpeg"].includes(d) && (g.backgroundColor = "#ffffff");
|
|
1236
|
-
var
|
|
1237
|
-
|
|
1240
|
+
var S = g.getObjects().find((b) => b.id === c.id);
|
|
1241
|
+
S.visible = !1, g.viewportTransform = [1, 0, 0, 1, -v, -m], g.setDimensions({
|
|
1238
1242
|
width: f,
|
|
1239
1243
|
height: M
|
|
1240
1244
|
}, {
|
|
1241
1245
|
backstoreOnly: !0
|
|
1242
1246
|
}), g.renderAll();
|
|
1243
|
-
var
|
|
1244
|
-
if (h === "svg" &&
|
|
1245
|
-
var
|
|
1247
|
+
var w = g.getObjects().filter((b) => b.format).every((b) => b.format === "svg");
|
|
1248
|
+
if (h === "svg" && w) {
|
|
1249
|
+
var D = g.toSVG();
|
|
1246
1250
|
g.dispose();
|
|
1247
|
-
var
|
|
1251
|
+
var N = A._exportSVGStringAsFile(D, {
|
|
1248
1252
|
exportAsBase64: i,
|
|
1249
1253
|
exportAsBlob: n,
|
|
1250
1254
|
fileName: a
|
|
1251
|
-
}),
|
|
1252
|
-
image:
|
|
1255
|
+
}), y = {
|
|
1256
|
+
image: N,
|
|
1253
1257
|
format: "svg",
|
|
1254
1258
|
contentType: "image/svg+xml",
|
|
1255
1259
|
fileName: a.replace(/\.[^/.]+$/, ".svg")
|
|
1256
1260
|
};
|
|
1257
|
-
return
|
|
1261
|
+
return s.fire("editor:canvas-exported", y), y;
|
|
1258
1262
|
}
|
|
1259
1263
|
var p = yield new Promise((b) => {
|
|
1260
1264
|
g.getElement().toBlob(b);
|
|
1261
1265
|
});
|
|
1262
1266
|
if (g.dispose(), n) {
|
|
1263
|
-
var
|
|
1267
|
+
var x = {
|
|
1264
1268
|
image: p,
|
|
1265
1269
|
format: h,
|
|
1266
1270
|
contentType: d,
|
|
1267
1271
|
fileName: a
|
|
1268
1272
|
};
|
|
1269
|
-
return
|
|
1273
|
+
return s.fire("editor:canvas-exported", x), x;
|
|
1270
1274
|
}
|
|
1271
|
-
var
|
|
1275
|
+
var R = yield createImageBitmap(p), B = yield u.post("toDataURL", {
|
|
1272
1276
|
format: h,
|
|
1273
1277
|
quality: 1,
|
|
1274
|
-
bitmap:
|
|
1275
|
-
}, [
|
|
1278
|
+
bitmap: R
|
|
1279
|
+
}, [R]);
|
|
1276
1280
|
if (l) {
|
|
1277
|
-
var
|
|
1278
|
-
orientation:
|
|
1281
|
+
var W = 0.264583, Z = f * W, z = M * W, F = (yield t.editor.moduleLoader.loadModule("jspdf")).jsPDF, U = new F({
|
|
1282
|
+
orientation: Z > z ? "landscape" : "portrait",
|
|
1279
1283
|
unit: "mm",
|
|
1280
|
-
format: [
|
|
1284
|
+
format: [Z, z]
|
|
1281
1285
|
});
|
|
1282
|
-
if (
|
|
1283
|
-
var
|
|
1284
|
-
image:
|
|
1286
|
+
if (U.addImage(B, "JPG", 0, 0, Z, z), i) {
|
|
1287
|
+
var De = U.output("datauristring"), de = {
|
|
1288
|
+
image: De,
|
|
1285
1289
|
format: "pdf",
|
|
1286
1290
|
contentType: "application/pdf",
|
|
1287
1291
|
fileName: a
|
|
1288
1292
|
};
|
|
1289
|
-
return
|
|
1293
|
+
return s.fire("editor:canvas-exported", de), de;
|
|
1290
1294
|
}
|
|
1291
|
-
var
|
|
1295
|
+
var Ne = U.output("blob"), Le = new File([Ne], a, {
|
|
1292
1296
|
type: "application/pdf"
|
|
1293
|
-
}),
|
|
1297
|
+
}), le = {
|
|
1294
1298
|
image: Le,
|
|
1295
1299
|
format: "pdf",
|
|
1296
1300
|
contentType: "application/pdf",
|
|
1297
1301
|
fileName: a
|
|
1298
1302
|
};
|
|
1299
|
-
return
|
|
1303
|
+
return s.fire("editor:canvas-exported", le), le;
|
|
1300
1304
|
}
|
|
1301
1305
|
if (i) {
|
|
1302
|
-
var
|
|
1303
|
-
image:
|
|
1306
|
+
var he = {
|
|
1307
|
+
image: B,
|
|
1304
1308
|
format: h,
|
|
1305
1309
|
contentType: d,
|
|
1306
1310
|
fileName: a
|
|
1307
1311
|
};
|
|
1308
|
-
return
|
|
1312
|
+
return s.fire("editor:canvas-exported", he), he;
|
|
1309
1313
|
}
|
|
1310
|
-
var
|
|
1314
|
+
var ge = h === "svg" && !w ? a.replace(/\.[^/.]+$/, ".png") : a, Ee = new File([p], ge, {
|
|
1311
1315
|
type: d
|
|
1312
|
-
}),
|
|
1316
|
+
}), ve = {
|
|
1313
1317
|
image: Ee,
|
|
1314
1318
|
format: h,
|
|
1315
1319
|
contentType: d,
|
|
1316
|
-
fileName:
|
|
1320
|
+
fileName: ge
|
|
1317
1321
|
};
|
|
1318
|
-
return
|
|
1322
|
+
return s.fire("editor:canvas-exported", ve), ve;
|
|
1319
1323
|
} catch (b) {
|
|
1320
1324
|
return t.editor.errorManager.emitError({
|
|
1321
1325
|
origin: "ImageManager",
|
|
@@ -1345,13 +1349,13 @@ class A {
|
|
|
1345
1349
|
*/
|
|
1346
1350
|
exportObjectAsImageFile() {
|
|
1347
1351
|
var e = arguments, t = this;
|
|
1348
|
-
return
|
|
1352
|
+
return O(function* () {
|
|
1349
1353
|
var {
|
|
1350
1354
|
object: a,
|
|
1351
1355
|
fileName: r = "image.png",
|
|
1352
1356
|
contentType: i = "image/png",
|
|
1353
1357
|
exportAsBase64: n = !1,
|
|
1354
|
-
exportAsBlob:
|
|
1358
|
+
exportAsBlob: s = !1
|
|
1355
1359
|
} = e.length > 0 && e[0] !== void 0 ? e[0] : {}, {
|
|
1356
1360
|
canvas: c,
|
|
1357
1361
|
workerManager: u
|
|
@@ -1366,7 +1370,7 @@ class A {
|
|
|
1366
1370
|
contentType: i,
|
|
1367
1371
|
fileName: r,
|
|
1368
1372
|
exportAsBase64: n,
|
|
1369
|
-
exportAsBlob:
|
|
1373
|
+
exportAsBlob: s
|
|
1370
1374
|
}
|
|
1371
1375
|
}), "";
|
|
1372
1376
|
try {
|
|
@@ -1374,7 +1378,7 @@ class A {
|
|
|
1374
1378
|
if (d === "svg") {
|
|
1375
1379
|
var h = l.toSVG(), v = t._exportSVGStringAsFile(h, {
|
|
1376
1380
|
exportAsBase64: n,
|
|
1377
|
-
exportAsBlob:
|
|
1381
|
+
exportAsBlob: s,
|
|
1378
1382
|
fileName: r
|
|
1379
1383
|
}), m = {
|
|
1380
1384
|
image: v,
|
|
@@ -1397,27 +1401,27 @@ class A {
|
|
|
1397
1401
|
};
|
|
1398
1402
|
return c.fire("editor:object-exported", g), g;
|
|
1399
1403
|
}
|
|
1400
|
-
var
|
|
1401
|
-
|
|
1404
|
+
var S = l.toCanvasElement(), w = yield new Promise((p) => {
|
|
1405
|
+
S.toBlob(p);
|
|
1402
1406
|
});
|
|
1403
|
-
if (
|
|
1404
|
-
var
|
|
1405
|
-
image:
|
|
1407
|
+
if (s) {
|
|
1408
|
+
var D = {
|
|
1409
|
+
image: w,
|
|
1406
1410
|
format: d,
|
|
1407
1411
|
contentType: i,
|
|
1408
1412
|
fileName: r
|
|
1409
1413
|
};
|
|
1410
|
-
return c.fire("editor:object-exported",
|
|
1414
|
+
return c.fire("editor:object-exported", D), D;
|
|
1411
1415
|
}
|
|
1412
|
-
var
|
|
1416
|
+
var N = new File([w], r, {
|
|
1413
1417
|
type: i
|
|
1414
|
-
}),
|
|
1415
|
-
image:
|
|
1418
|
+
}), y = {
|
|
1419
|
+
image: N,
|
|
1416
1420
|
format: d,
|
|
1417
1421
|
contentType: i,
|
|
1418
1422
|
fileName: r
|
|
1419
1423
|
};
|
|
1420
|
-
return c.fire("editor:object-exported",
|
|
1424
|
+
return c.fire("editor:object-exported", y), y;
|
|
1421
1425
|
} catch (p) {
|
|
1422
1426
|
return t.editor.errorManager.emitError({
|
|
1423
1427
|
origin: "ImageManager",
|
|
@@ -1428,7 +1432,7 @@ class A {
|
|
|
1428
1432
|
contentType: i,
|
|
1429
1433
|
fileName: r,
|
|
1430
1434
|
exportAsBase64: n,
|
|
1431
|
-
exportAsBlob:
|
|
1435
|
+
exportAsBlob: s
|
|
1432
1436
|
}
|
|
1433
1437
|
}), "";
|
|
1434
1438
|
}
|
|
@@ -1499,7 +1503,7 @@ class A {
|
|
|
1499
1503
|
*/
|
|
1500
1504
|
getContentType(e) {
|
|
1501
1505
|
var t = this;
|
|
1502
|
-
return
|
|
1506
|
+
return O(function* () {
|
|
1503
1507
|
return typeof e == "string" ? t.getContentTypeFromUrl(e) : e.type || "application/octet-stream";
|
|
1504
1508
|
})();
|
|
1505
1509
|
}
|
|
@@ -1511,7 +1515,7 @@ class A {
|
|
|
1511
1515
|
*/
|
|
1512
1516
|
getContentTypeFromUrl(e) {
|
|
1513
1517
|
var t = this;
|
|
1514
|
-
return
|
|
1518
|
+
return O(function* () {
|
|
1515
1519
|
if (e.startsWith("data:")) {
|
|
1516
1520
|
var a = e.match(/^data:([^;]+)/);
|
|
1517
1521
|
return a ? a[1] : "application/octet-stream";
|
|
@@ -1538,8 +1542,8 @@ class A {
|
|
|
1538
1542
|
try {
|
|
1539
1543
|
var t, a = new URL(e), r = (t = a.pathname.split(".").pop()) === null || t === void 0 ? void 0 : t.toLowerCase(), i = {};
|
|
1540
1544
|
return this.acceptContentTypes.forEach((n) => {
|
|
1541
|
-
var
|
|
1542
|
-
|
|
1545
|
+
var s = A.getFormatFromContentType(n);
|
|
1546
|
+
s && (i[s] = n);
|
|
1543
1547
|
}), i[r] || "application/octet-stream";
|
|
1544
1548
|
} catch (n) {
|
|
1545
1549
|
return console.warn("Не удалось определить расширение из URL:", e, n), "application/octet-stream";
|
|
@@ -1560,10 +1564,10 @@ class A {
|
|
|
1560
1564
|
} = this.editor;
|
|
1561
1565
|
if (!r || !t) return 1;
|
|
1562
1566
|
var i = r.width, n = r.height, {
|
|
1563
|
-
width:
|
|
1567
|
+
width: s,
|
|
1564
1568
|
height: c
|
|
1565
1569
|
} = t;
|
|
1566
|
-
return a === "contain" || a === "image-contain" ? Math.min(i /
|
|
1570
|
+
return a === "contain" || a === "image-contain" ? Math.min(i / s, n / c) : a === "cover" || a === "image-cover" ? Math.max(i / s, n / c) : 1;
|
|
1567
1571
|
}
|
|
1568
1572
|
}
|
|
1569
1573
|
class pt {
|
|
@@ -1597,13 +1601,13 @@ class pt {
|
|
|
1597
1601
|
canvas: i,
|
|
1598
1602
|
montageArea: n,
|
|
1599
1603
|
options: {
|
|
1600
|
-
canvasBackstoreWidth:
|
|
1604
|
+
canvasBackstoreWidth: s
|
|
1601
1605
|
}
|
|
1602
1606
|
} = this.editor, {
|
|
1603
1607
|
width: c,
|
|
1604
1608
|
height: u
|
|
1605
|
-
} = n, l = Number(Math.max(Math.min(e,
|
|
1606
|
-
if (!
|
|
1609
|
+
} = n, l = Number(Math.max(Math.min(e, L), T));
|
|
1610
|
+
if (!s || s === "auto" || r ? this.adaptCanvasToContainer() : s ? this.setCanvasBackstoreWidth(s) : this.setCanvasBackstoreWidth(l), n.set({
|
|
1607
1611
|
width: l
|
|
1608
1612
|
}), i.clipPath.set({
|
|
1609
1613
|
width: l
|
|
@@ -1641,13 +1645,13 @@ class pt {
|
|
|
1641
1645
|
canvas: i,
|
|
1642
1646
|
montageArea: n,
|
|
1643
1647
|
options: {
|
|
1644
|
-
canvasBackstoreHeight:
|
|
1648
|
+
canvasBackstoreHeight: s
|
|
1645
1649
|
}
|
|
1646
1650
|
} = this.editor, {
|
|
1647
1651
|
width: c,
|
|
1648
1652
|
height: u
|
|
1649
|
-
} = n, l = Number(Math.max(Math.min(e,
|
|
1650
|
-
if (!
|
|
1653
|
+
} = n, l = Number(Math.max(Math.min(e, E), k));
|
|
1654
|
+
if (!s || s === "auto" || r ? this.adaptCanvasToContainer() : s ? this.setCanvasBackstoreHeight(s) : this.setCanvasBackstoreHeight(l), n.set({
|
|
1651
1655
|
height: l
|
|
1652
1656
|
}), i.clipPath.set({
|
|
1653
1657
|
height: l
|
|
@@ -1681,8 +1685,8 @@ class pt {
|
|
|
1681
1685
|
left: a / 2,
|
|
1682
1686
|
top: r / 2
|
|
1683
1687
|
}), e.renderAll();
|
|
1684
|
-
var
|
|
1685
|
-
|
|
1688
|
+
var s = e.viewportTransform;
|
|
1689
|
+
s[4] = a / 2 - n.x * i, s[5] = r / 2 - n.y * i, e.setViewportTransform(s), e.renderAll();
|
|
1686
1690
|
}
|
|
1687
1691
|
/**
|
|
1688
1692
|
* Метод для получения координат объекта с учетом текущего зума
|
|
@@ -1700,15 +1704,15 @@ class pt {
|
|
|
1700
1704
|
var {
|
|
1701
1705
|
width: r,
|
|
1702
1706
|
height: i
|
|
1703
|
-
} = a, n = t.getZoom(),
|
|
1707
|
+
} = a, n = t.getZoom(), s = (r - r * n) / 2, c = (i - i * n) / 2;
|
|
1704
1708
|
return {
|
|
1705
|
-
left:
|
|
1709
|
+
left: s,
|
|
1706
1710
|
top: c
|
|
1707
1711
|
};
|
|
1708
1712
|
}
|
|
1709
1713
|
setCanvasBackstoreWidth(e) {
|
|
1710
1714
|
if (!(!e || typeof e != "number")) {
|
|
1711
|
-
var t = Math.max(Math.min(e,
|
|
1715
|
+
var t = Math.max(Math.min(e, L), T);
|
|
1712
1716
|
this.editor.canvas.setDimensions({
|
|
1713
1717
|
width: t
|
|
1714
1718
|
}, {
|
|
@@ -1718,7 +1722,7 @@ class pt {
|
|
|
1718
1722
|
}
|
|
1719
1723
|
setCanvasBackstoreHeight(e) {
|
|
1720
1724
|
if (!(!e || typeof e != "number")) {
|
|
1721
|
-
var t = Math.max(Math.min(e,
|
|
1725
|
+
var t = Math.max(Math.min(e, E), k);
|
|
1722
1726
|
this.editor.canvas.setDimensions({
|
|
1723
1727
|
height: t
|
|
1724
1728
|
}, {
|
|
@@ -1729,7 +1733,7 @@ class pt {
|
|
|
1729
1733
|
adaptCanvasToContainer() {
|
|
1730
1734
|
var {
|
|
1731
1735
|
canvas: e
|
|
1732
|
-
} = this.editor, t = e.editorContainer, a = t.clientWidth, r = t.clientHeight, i = Math.max(Math.min(a,
|
|
1736
|
+
} = this.editor, t = e.editorContainer, a = t.clientWidth, r = t.clientHeight, i = Math.max(Math.min(a, L), T), n = Math.max(Math.min(r, E), k);
|
|
1733
1737
|
console.log("adaptCanvasToContainer newWidth", i), console.log("adaptCanvasToContainer newHeight", n), e.setDimensions({
|
|
1734
1738
|
width: i,
|
|
1735
1739
|
height: n
|
|
@@ -1752,9 +1756,9 @@ class pt {
|
|
|
1752
1756
|
var {
|
|
1753
1757
|
canvas: t,
|
|
1754
1758
|
montageArea: a
|
|
1755
|
-
} = this.editor, r = a.width * e, i = a.height * e, n = t.wrapperEl.parentNode,
|
|
1759
|
+
} = this.editor, r = a.width * e, i = a.height * e, n = t.wrapperEl.parentNode, s = r <= n.clientWidth ? "100%" : r, c = i <= n.clientHeight ? "100%" : i;
|
|
1756
1760
|
t.setDimensions({
|
|
1757
|
-
width:
|
|
1761
|
+
width: s,
|
|
1758
1762
|
height: c
|
|
1759
1763
|
}, {
|
|
1760
1764
|
cssOnly: !0
|
|
@@ -1867,10 +1871,10 @@ class pt {
|
|
|
1867
1871
|
default:
|
|
1868
1872
|
n.push(r.lowerCanvasEl, r.upperCanvasEl);
|
|
1869
1873
|
}
|
|
1870
|
-
var
|
|
1874
|
+
var s = t === "width" ? "width" : "height";
|
|
1871
1875
|
if (typeof a == "string") {
|
|
1872
1876
|
n.forEach((l) => {
|
|
1873
|
-
l.style[
|
|
1877
|
+
l.style[s] = a;
|
|
1874
1878
|
});
|
|
1875
1879
|
return;
|
|
1876
1880
|
}
|
|
@@ -1878,8 +1882,8 @@ class pt {
|
|
|
1878
1882
|
if (!isNaN(c)) {
|
|
1879
1883
|
var u = "".concat(c, "px");
|
|
1880
1884
|
n.forEach((l) => {
|
|
1881
|
-
l.style[
|
|
1882
|
-
}), r.fire("editor:display-".concat(e, "-").concat(
|
|
1885
|
+
l.style[s] = u;
|
|
1886
|
+
}), r.fire("editor:display-".concat(e, "-").concat(s, "-changed"), {
|
|
1883
1887
|
element: e,
|
|
1884
1888
|
value: a
|
|
1885
1889
|
});
|
|
@@ -1904,7 +1908,7 @@ class pt {
|
|
|
1904
1908
|
montageArea: i,
|
|
1905
1909
|
transformManager: n,
|
|
1906
1910
|
options: {
|
|
1907
|
-
montageAreaWidth:
|
|
1911
|
+
montageAreaWidth: s,
|
|
1908
1912
|
montageAreaHeight: c
|
|
1909
1913
|
}
|
|
1910
1914
|
} = this.editor, u = e || r.getActiveObject();
|
|
@@ -1912,30 +1916,23 @@ class pt {
|
|
|
1912
1916
|
var {
|
|
1913
1917
|
width: l,
|
|
1914
1918
|
height: d
|
|
1915
|
-
} = u;
|
|
1916
|
-
if (l < Z || d < z) {
|
|
1917
|
-
var h = "Размер изображения меньше минимального размера канваса, поэтому оно будет растянуто до минимальных размеров: ".concat(Z, "x").concat(z);
|
|
1918
|
-
console.warn("scaleMontageAreaToImage. ".concat(h)), r.fire("editor:warning", {
|
|
1919
|
-
message: h
|
|
1920
|
-
});
|
|
1921
|
-
}
|
|
1922
|
-
var v = Math.min(l, D), m = Math.min(d, L);
|
|
1919
|
+
} = u, h = Math.min(l, L), v = Math.min(d, E);
|
|
1923
1920
|
if (t) {
|
|
1924
1921
|
var {
|
|
1925
|
-
width:
|
|
1926
|
-
height:
|
|
1927
|
-
} = i,
|
|
1928
|
-
|
|
1922
|
+
width: m,
|
|
1923
|
+
height: f
|
|
1924
|
+
} = i, M = l / m, g = d / f, S = Math.max(M, g);
|
|
1925
|
+
h = m * S, v = f * S;
|
|
1929
1926
|
}
|
|
1930
|
-
this.setResolutionWidth(
|
|
1927
|
+
this.setResolutionWidth(h, {
|
|
1931
1928
|
withoutSave: !0
|
|
1932
|
-
}), this.setResolutionHeight(
|
|
1929
|
+
}), this.setResolutionHeight(v, {
|
|
1933
1930
|
withoutSave: !0
|
|
1934
|
-
}), (l >
|
|
1931
|
+
}), (l > s || d > c) && n.calculateAndApplyDefaultZoom(s, c), n.resetObject(u, {
|
|
1935
1932
|
withoutSave: !0
|
|
1936
1933
|
}), r.centerObject(u), r.renderAll(), a || this.editor.historyManager.saveState(), r.fire("editor:canvas-scaled", {
|
|
1937
|
-
width:
|
|
1938
|
-
height:
|
|
1934
|
+
width: h,
|
|
1935
|
+
height: v
|
|
1939
1936
|
});
|
|
1940
1937
|
}
|
|
1941
1938
|
}
|
|
@@ -2012,12 +2009,12 @@ class bt {
|
|
|
2012
2009
|
var e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : this.options.montageAreaWidth, t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : this.options.montageAreaHeight, {
|
|
2013
2010
|
width: a,
|
|
2014
2011
|
height: r
|
|
2015
|
-
} = this.editor.montageArea, i = e / a, n = t / r,
|
|
2012
|
+
} = this.editor.montageArea, i = e / a, n = t / r, s = Math.min(i, n), {
|
|
2016
2013
|
minZoom: c,
|
|
2017
2014
|
maxZoom: u,
|
|
2018
2015
|
maxZoomFactor: l
|
|
2019
2016
|
} = this.options;
|
|
2020
|
-
this.minZoom = Math.min(
|
|
2017
|
+
this.minZoom = Math.min(s / l, c), this.maxZoom = Math.max(s * l, u), this.defaultZoom = s, this.setZoom(s);
|
|
2021
2018
|
}
|
|
2022
2019
|
/**
|
|
2023
2020
|
* Увеличение/уменьшение масштаба
|
|
@@ -2036,16 +2033,16 @@ class bt {
|
|
|
2036
2033
|
minZoom: r,
|
|
2037
2034
|
maxZoom: i
|
|
2038
2035
|
} = this.editor, n = a.getZoom(), {
|
|
2039
|
-
x:
|
|
2036
|
+
x: s = t.pointX,
|
|
2040
2037
|
y: c = t.pointY
|
|
2041
2038
|
} = a.getCenterPoint(), u = Number((n + Number(e)).toFixed(2));
|
|
2042
2039
|
u > i && (u = i), u < r && (u = r), a.zoomToPoint({
|
|
2043
|
-
x: Number(
|
|
2040
|
+
x: Number(s),
|
|
2044
2041
|
y: Number(c)
|
|
2045
2042
|
}, u), a.fire("editor:zoom-changed", {
|
|
2046
2043
|
currentZoom: a.getZoom(),
|
|
2047
2044
|
zoom: u,
|
|
2048
|
-
pointX:
|
|
2045
|
+
pointX: s,
|
|
2049
2046
|
pointY: c
|
|
2050
2047
|
});
|
|
2051
2048
|
}
|
|
@@ -2063,13 +2060,13 @@ class bt {
|
|
|
2063
2060
|
} = this.editor, {
|
|
2064
2061
|
x: i,
|
|
2065
2062
|
y: n
|
|
2066
|
-
} = t.getCenterPoint(),
|
|
2067
|
-
e > r && (
|
|
2063
|
+
} = t.getCenterPoint(), s = e;
|
|
2064
|
+
e > r && (s = r), e < a && (s = a), t.zoomToPoint({
|
|
2068
2065
|
x: Number(i),
|
|
2069
2066
|
y: Number(n)
|
|
2070
|
-
},
|
|
2067
|
+
}, s), t.fire("editor:zoom-changed", {
|
|
2071
2068
|
currentZoom: t.getZoom(),
|
|
2072
|
-
zoom:
|
|
2069
|
+
zoom: s,
|
|
2073
2070
|
pointX: i,
|
|
2074
2071
|
pointY: n
|
|
2075
2072
|
});
|
|
@@ -2158,8 +2155,8 @@ class bt {
|
|
|
2158
2155
|
canvas: r,
|
|
2159
2156
|
historyManager: i
|
|
2160
2157
|
} = this.editor, n = e || r.getActiveObject();
|
|
2161
|
-
n && (n.type === "activeselection" ? n.getObjects().forEach((
|
|
2162
|
-
|
|
2158
|
+
n && (n.type === "activeselection" ? n.getObjects().forEach((s) => {
|
|
2159
|
+
s.set("opacity", t);
|
|
2163
2160
|
}) : n.set("opacity", t), r.renderAll(), a || i.saveState(), r.fire("editor:object-opacity-changed", t));
|
|
2164
2161
|
}
|
|
2165
2162
|
/**
|
|
@@ -2182,7 +2179,7 @@ class bt {
|
|
|
2182
2179
|
} = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, {
|
|
2183
2180
|
canvas: i,
|
|
2184
2181
|
imageManager: n,
|
|
2185
|
-
historyManager:
|
|
2182
|
+
historyManager: s
|
|
2186
2183
|
} = this.editor, c = e || i.getActiveObject();
|
|
2187
2184
|
if (c) {
|
|
2188
2185
|
if (["activeselection"].includes(c.type) && !r) {
|
|
@@ -2194,7 +2191,7 @@ class bt {
|
|
|
2194
2191
|
});
|
|
2195
2192
|
h.scale(v), i.centerObject(h);
|
|
2196
2193
|
});
|
|
2197
|
-
var l = new
|
|
2194
|
+
var l = new H(u, {
|
|
2198
2195
|
canvas: i
|
|
2199
2196
|
});
|
|
2200
2197
|
i.setActiveObject(l);
|
|
@@ -2205,7 +2202,7 @@ class bt {
|
|
|
2205
2202
|
});
|
|
2206
2203
|
c.scale(d), i.centerObject(c);
|
|
2207
2204
|
}
|
|
2208
|
-
i.renderAll(), a ||
|
|
2205
|
+
i.renderAll(), a || s.saveState(), i.fire("editor:image-fitted", {
|
|
2209
2206
|
type: t
|
|
2210
2207
|
});
|
|
2211
2208
|
}
|
|
@@ -2233,13 +2230,13 @@ class bt {
|
|
|
2233
2230
|
canvas: r,
|
|
2234
2231
|
montageArea: i,
|
|
2235
2232
|
imageManager: n,
|
|
2236
|
-
historyManager:
|
|
2233
|
+
historyManager: s,
|
|
2237
2234
|
options: {
|
|
2238
2235
|
scaleType: c
|
|
2239
2236
|
}
|
|
2240
2237
|
} = this.editor, u = e || r.getActiveObject();
|
|
2241
2238
|
if (!(!u || u.locked)) {
|
|
2242
|
-
if (
|
|
2239
|
+
if (s.suspendHistory(), u.type !== "image" && u.format !== "svg" && (u.set({
|
|
2243
2240
|
scaleX: 1,
|
|
2244
2241
|
scaleY: 1,
|
|
2245
2242
|
flipX: !1,
|
|
@@ -2273,7 +2270,7 @@ class bt {
|
|
|
2273
2270
|
flipX: !1,
|
|
2274
2271
|
flipY: !1,
|
|
2275
2272
|
angle: 0
|
|
2276
|
-
}), r.centerObject(u), r.renderAll(),
|
|
2273
|
+
}), r.centerObject(u), r.renderAll(), s.resumeHistory(), a || s.saveState(), r.fire("editor:object-reset");
|
|
2277
2274
|
}
|
|
2278
2275
|
}
|
|
2279
2276
|
}
|
|
@@ -2329,13 +2326,13 @@ class It {
|
|
|
2329
2326
|
left: r,
|
|
2330
2327
|
top: i,
|
|
2331
2328
|
width: n,
|
|
2332
|
-
height:
|
|
2329
|
+
height: s
|
|
2333
2330
|
} = t.getBoundingRect();
|
|
2334
2331
|
this.overlayMask.set({
|
|
2335
2332
|
left: r,
|
|
2336
2333
|
top: i,
|
|
2337
2334
|
width: n,
|
|
2338
|
-
height:
|
|
2335
|
+
height: s
|
|
2339
2336
|
}), e.discardActiveObject(), this.editor.layerManager.bringToFront(this.overlayMask, {
|
|
2340
2337
|
withoutSave: !0
|
|
2341
2338
|
}), a.resumeHistory();
|
|
@@ -2377,7 +2374,7 @@ class It {
|
|
|
2377
2374
|
}
|
|
2378
2375
|
}
|
|
2379
2376
|
}
|
|
2380
|
-
class
|
|
2377
|
+
class G {
|
|
2381
2378
|
/**
|
|
2382
2379
|
* @param {object} options
|
|
2383
2380
|
* @param {ImageEditor} options.editor - экземпляр редактора с доступом к canvas
|
|
@@ -2424,7 +2421,7 @@ class F {
|
|
|
2424
2421
|
} = this.editor;
|
|
2425
2422
|
r.suspendHistory();
|
|
2426
2423
|
var i = e || a.getActiveObject();
|
|
2427
|
-
i && (i.type === "activeselection" ?
|
|
2424
|
+
i && (i.type === "activeselection" ? G._moveSelectionForward(a, i) : a.bringObjectForward(i), a.renderAll(), r.resumeHistory(), t || r.saveState(), a.fire("editor:object-bring-forward"));
|
|
2428
2425
|
}
|
|
2429
2426
|
/**
|
|
2430
2427
|
* Отправить объект на задний план по оси Z
|
|
@@ -2445,13 +2442,13 @@ class F {
|
|
|
2445
2442
|
}
|
|
2446
2443
|
} = this.editor;
|
|
2447
2444
|
i.suspendHistory();
|
|
2448
|
-
var
|
|
2449
|
-
if (
|
|
2450
|
-
if (
|
|
2451
|
-
for (var c =
|
|
2445
|
+
var s = e || a.getActiveObject();
|
|
2446
|
+
if (s) {
|
|
2447
|
+
if (s.type === "activeselection")
|
|
2448
|
+
for (var c = s.getObjects(), u = c.length - 1; u >= 0; u -= 1)
|
|
2452
2449
|
a.sendObjectToBack(c[u]);
|
|
2453
2450
|
else
|
|
2454
|
-
a.sendObjectToBack(
|
|
2451
|
+
a.sendObjectToBack(s);
|
|
2455
2452
|
a.sendObjectToBack(r), a.sendObjectToBack(n), a.renderAll(), i.resumeHistory(), t || i.saveState(), a.fire("editor:object-send-to-back");
|
|
2456
2453
|
}
|
|
2457
2454
|
}
|
|
@@ -2473,8 +2470,8 @@ class F {
|
|
|
2473
2470
|
}
|
|
2474
2471
|
} = this.editor;
|
|
2475
2472
|
i.suspendHistory();
|
|
2476
|
-
var
|
|
2477
|
-
|
|
2473
|
+
var s = e || a.getActiveObject();
|
|
2474
|
+
s && (s.type === "activeselection" ? G._moveSelectionBackwards(a, s) : a.sendObjectBackwards(s), a.sendObjectToBack(r), a.sendObjectToBack(n), a.renderAll(), i.resumeHistory(), t || i.saveState(), a.fire("editor:object-send-backwards"));
|
|
2478
2475
|
}
|
|
2479
2476
|
/**
|
|
2480
2477
|
* Сдвигает выделенные объекты на один уровень вверх относительно ближайшего верхнего объекта
|
|
@@ -2484,11 +2481,11 @@ class F {
|
|
|
2484
2481
|
* @private
|
|
2485
2482
|
*/
|
|
2486
2483
|
static _moveSelectionForward(e, t) {
|
|
2487
|
-
for (var a = e.getObjects(), r = t.getObjects(), i = r.map((l) => a.indexOf(l)), n = -1,
|
|
2484
|
+
for (var a = e.getObjects(), r = t.getObjects(), i = r.map((l) => a.indexOf(l)), n = -1, s = function(d) {
|
|
2488
2485
|
var h = a[d];
|
|
2489
2486
|
if (!r.includes(h) && i.some((v) => d > v))
|
|
2490
2487
|
return n = d, 1;
|
|
2491
|
-
}, c = 0; c < a.length && !
|
|
2488
|
+
}, c = 0; c < a.length && !s(c); c += 1)
|
|
2492
2489
|
;
|
|
2493
2490
|
if (n !== -1) {
|
|
2494
2491
|
var u = r.map((l) => ({
|
|
@@ -2509,64 +2506,64 @@ class F {
|
|
|
2509
2506
|
* @private
|
|
2510
2507
|
*/
|
|
2511
2508
|
static _moveSelectionBackwards(e, t) {
|
|
2512
|
-
for (var a = e.getObjects(), r = t.getObjects(), i = Math.min(...r.map((
|
|
2509
|
+
for (var a = e.getObjects(), r = t.getObjects(), i = Math.min(...r.map((s) => a.indexOf(s))), n = r.length - 1; n >= 0; n -= 1)
|
|
2513
2510
|
e.moveObjectTo(r[n], i - 1);
|
|
2514
2511
|
}
|
|
2515
2512
|
}
|
|
2516
|
-
var St = ["id", "left", "top", "width", "height", "fill"], At = ["id", "left", "top", "radius", "fill"],
|
|
2517
|
-
function
|
|
2518
|
-
var t = Object.keys(
|
|
2513
|
+
var St = ["id", "left", "top", "width", "height", "fill"], At = ["id", "left", "top", "radius", "fill"], Ct = ["id", "left", "top", "width", "height", "fill"];
|
|
2514
|
+
function Se(o, e) {
|
|
2515
|
+
var t = Object.keys(o);
|
|
2519
2516
|
if (Object.getOwnPropertySymbols) {
|
|
2520
|
-
var a = Object.getOwnPropertySymbols(
|
|
2517
|
+
var a = Object.getOwnPropertySymbols(o);
|
|
2521
2518
|
e && (a = a.filter(function(r) {
|
|
2522
|
-
return Object.getOwnPropertyDescriptor(
|
|
2519
|
+
return Object.getOwnPropertyDescriptor(o, r).enumerable;
|
|
2523
2520
|
})), t.push.apply(t, a);
|
|
2524
2521
|
}
|
|
2525
2522
|
return t;
|
|
2526
2523
|
}
|
|
2527
|
-
function
|
|
2524
|
+
function q(o) {
|
|
2528
2525
|
for (var e = 1; e < arguments.length; e++) {
|
|
2529
2526
|
var t = arguments[e] != null ? arguments[e] : {};
|
|
2530
|
-
e % 2 ?
|
|
2531
|
-
|
|
2532
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(
|
|
2533
|
-
Object.defineProperty(
|
|
2527
|
+
e % 2 ? Se(Object(t), !0).forEach(function(a) {
|
|
2528
|
+
wt(o, a, t[a]);
|
|
2529
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(o, Object.getOwnPropertyDescriptors(t)) : Se(Object(t)).forEach(function(a) {
|
|
2530
|
+
Object.defineProperty(o, a, Object.getOwnPropertyDescriptor(t, a));
|
|
2534
2531
|
});
|
|
2535
2532
|
}
|
|
2536
|
-
return
|
|
2533
|
+
return o;
|
|
2537
2534
|
}
|
|
2538
|
-
function
|
|
2539
|
-
return (e =
|
|
2535
|
+
function wt(o, e, t) {
|
|
2536
|
+
return (e = Dt(e)) in o ? Object.defineProperty(o, e, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : o[e] = t, o;
|
|
2540
2537
|
}
|
|
2541
|
-
function
|
|
2542
|
-
var e =
|
|
2538
|
+
function Dt(o) {
|
|
2539
|
+
var e = Nt(o, "string");
|
|
2543
2540
|
return typeof e == "symbol" ? e : e + "";
|
|
2544
2541
|
}
|
|
2545
|
-
function
|
|
2546
|
-
if (typeof
|
|
2547
|
-
var t =
|
|
2542
|
+
function Nt(o, e) {
|
|
2543
|
+
if (typeof o != "object" || !o) return o;
|
|
2544
|
+
var t = o[Symbol.toPrimitive];
|
|
2548
2545
|
if (t !== void 0) {
|
|
2549
|
-
var a = t.call(
|
|
2546
|
+
var a = t.call(o, e);
|
|
2550
2547
|
if (typeof a != "object") return a;
|
|
2551
2548
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
2552
2549
|
}
|
|
2553
|
-
return (e === "string" ? String : Number)(
|
|
2550
|
+
return (e === "string" ? String : Number)(o);
|
|
2554
2551
|
}
|
|
2555
|
-
function
|
|
2556
|
-
if (
|
|
2557
|
-
var t, a, r = Lt(
|
|
2552
|
+
function ee(o, e) {
|
|
2553
|
+
if (o == null) return {};
|
|
2554
|
+
var t, a, r = Lt(o, e);
|
|
2558
2555
|
if (Object.getOwnPropertySymbols) {
|
|
2559
|
-
var i = Object.getOwnPropertySymbols(
|
|
2560
|
-
for (a = 0; a < i.length; a++) t = i[a], e.indexOf(t) === -1 && {}.propertyIsEnumerable.call(
|
|
2556
|
+
var i = Object.getOwnPropertySymbols(o);
|
|
2557
|
+
for (a = 0; a < i.length; a++) t = i[a], e.indexOf(t) === -1 && {}.propertyIsEnumerable.call(o, t) && (r[t] = o[t]);
|
|
2561
2558
|
}
|
|
2562
2559
|
return r;
|
|
2563
2560
|
}
|
|
2564
|
-
function Lt(
|
|
2565
|
-
if (
|
|
2561
|
+
function Lt(o, e) {
|
|
2562
|
+
if (o == null) return {};
|
|
2566
2563
|
var t = {};
|
|
2567
|
-
for (var a in
|
|
2564
|
+
for (var a in o) if ({}.hasOwnProperty.call(o, a)) {
|
|
2568
2565
|
if (e.indexOf(a) !== -1) continue;
|
|
2569
|
-
t[a] =
|
|
2566
|
+
t[a] = o[a];
|
|
2570
2567
|
}
|
|
2571
2568
|
return t;
|
|
2572
2569
|
}
|
|
@@ -2598,24 +2595,24 @@ class Et {
|
|
|
2598
2595
|
*/
|
|
2599
2596
|
addRectangle() {
|
|
2600
2597
|
var e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, {
|
|
2601
|
-
id: t = "rect-".concat(
|
|
2598
|
+
id: t = "rect-".concat(C()),
|
|
2602
2599
|
left: a,
|
|
2603
2600
|
top: r,
|
|
2604
2601
|
width: i = 100,
|
|
2605
2602
|
height: n = 100,
|
|
2606
|
-
fill:
|
|
2607
|
-
} = e, c =
|
|
2603
|
+
fill: s = "blue"
|
|
2604
|
+
} = e, c = ee(e, St), {
|
|
2608
2605
|
withoutSelection: u,
|
|
2609
2606
|
withoutAdding: l
|
|
2610
2607
|
} = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, {
|
|
2611
2608
|
canvas: d
|
|
2612
|
-
} = this.editor, h = new Ue(
|
|
2609
|
+
} = this.editor, h = new Ue(q({
|
|
2613
2610
|
id: t,
|
|
2614
2611
|
left: a,
|
|
2615
2612
|
top: r,
|
|
2616
2613
|
width: i,
|
|
2617
2614
|
height: n,
|
|
2618
|
-
fill:
|
|
2615
|
+
fill: s
|
|
2619
2616
|
}, c));
|
|
2620
2617
|
return !a && !r && d.centerObject(h), l || (d.add(h), u || d.setActiveObject(h), d.renderAll()), h;
|
|
2621
2618
|
}
|
|
@@ -2635,23 +2632,23 @@ class Et {
|
|
|
2635
2632
|
*/
|
|
2636
2633
|
addCircle() {
|
|
2637
2634
|
var e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, {
|
|
2638
|
-
id: t = "circle-".concat(
|
|
2635
|
+
id: t = "circle-".concat(C()),
|
|
2639
2636
|
left: a,
|
|
2640
2637
|
top: r,
|
|
2641
2638
|
radius: i = 50,
|
|
2642
2639
|
fill: n = "green"
|
|
2643
|
-
} = e,
|
|
2640
|
+
} = e, s = ee(e, At), {
|
|
2644
2641
|
withoutSelection: c,
|
|
2645
2642
|
withoutAdding: u
|
|
2646
2643
|
} = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, {
|
|
2647
2644
|
canvas: l
|
|
2648
|
-
} = this.editor, d = new Ye(
|
|
2645
|
+
} = this.editor, d = new Ye(q({
|
|
2649
2646
|
id: t,
|
|
2650
2647
|
left: a,
|
|
2651
2648
|
top: r,
|
|
2652
2649
|
fill: n,
|
|
2653
2650
|
radius: i
|
|
2654
|
-
},
|
|
2651
|
+
}, s));
|
|
2655
2652
|
return !a && !r && l.centerObject(d), u || (l.add(d), c || l.setActiveObject(d), l.renderAll()), d;
|
|
2656
2653
|
}
|
|
2657
2654
|
/**
|
|
@@ -2671,46 +2668,46 @@ class Et {
|
|
|
2671
2668
|
*/
|
|
2672
2669
|
addTriangle() {
|
|
2673
2670
|
var e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, {
|
|
2674
|
-
id: t = "triangle-".concat(
|
|
2671
|
+
id: t = "triangle-".concat(C()),
|
|
2675
2672
|
left: a,
|
|
2676
2673
|
top: r,
|
|
2677
2674
|
width: i = 100,
|
|
2678
2675
|
height: n = 100,
|
|
2679
|
-
fill:
|
|
2680
|
-
} = e, c =
|
|
2676
|
+
fill: s = "yellow"
|
|
2677
|
+
} = e, c = ee(e, Ct), {
|
|
2681
2678
|
withoutSelection: u,
|
|
2682
2679
|
withoutAdding: l
|
|
2683
2680
|
} = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, {
|
|
2684
2681
|
canvas: d
|
|
2685
|
-
} = this.editor, h = new Pe(
|
|
2682
|
+
} = this.editor, h = new Pe(q({
|
|
2686
2683
|
id: t,
|
|
2687
2684
|
left: a,
|
|
2688
2685
|
top: r,
|
|
2689
|
-
fill:
|
|
2686
|
+
fill: s,
|
|
2690
2687
|
width: i,
|
|
2691
2688
|
height: n
|
|
2692
2689
|
}, c));
|
|
2693
2690
|
return !a && !r && d.centerObject(h), l || (d.add(h), u || d.setActiveObject(h), d.renderAll()), h;
|
|
2694
2691
|
}
|
|
2695
2692
|
}
|
|
2696
|
-
function
|
|
2693
|
+
function Ae(o, e, t, a, r, i, n) {
|
|
2697
2694
|
try {
|
|
2698
|
-
var
|
|
2695
|
+
var s = o[i](n), c = s.value;
|
|
2699
2696
|
} catch (u) {
|
|
2700
2697
|
return void t(u);
|
|
2701
2698
|
}
|
|
2702
|
-
|
|
2699
|
+
s.done ? e(c) : Promise.resolve(c).then(a, r);
|
|
2703
2700
|
}
|
|
2704
|
-
function
|
|
2701
|
+
function Ce(o) {
|
|
2705
2702
|
return function() {
|
|
2706
2703
|
var e = this, t = arguments;
|
|
2707
2704
|
return new Promise(function(a, r) {
|
|
2708
|
-
var i =
|
|
2705
|
+
var i = o.apply(e, t);
|
|
2709
2706
|
function n(c) {
|
|
2710
|
-
|
|
2707
|
+
Ae(i, a, r, n, s, "next", c);
|
|
2711
2708
|
}
|
|
2712
|
-
function
|
|
2713
|
-
|
|
2709
|
+
function s(c) {
|
|
2710
|
+
Ae(i, a, r, n, s, "throw", c);
|
|
2714
2711
|
}
|
|
2715
2712
|
n(void 0);
|
|
2716
2713
|
});
|
|
@@ -2733,7 +2730,7 @@ class Ot {
|
|
|
2733
2730
|
*/
|
|
2734
2731
|
copy() {
|
|
2735
2732
|
var e = this;
|
|
2736
|
-
return
|
|
2733
|
+
return Ce(function* () {
|
|
2737
2734
|
var {
|
|
2738
2735
|
canvas: t
|
|
2739
2736
|
} = e.editor, a = t.getActiveObject();
|
|
@@ -2757,10 +2754,10 @@ class Ot {
|
|
|
2757
2754
|
}
|
|
2758
2755
|
var i = r.toCanvasElement(), n = yield new Promise((u) => {
|
|
2759
2756
|
i.toBlob(u);
|
|
2760
|
-
}),
|
|
2757
|
+
}), s = new ClipboardItem({
|
|
2761
2758
|
[n.type]: n
|
|
2762
2759
|
});
|
|
2763
|
-
yield navigator.clipboard.write([
|
|
2760
|
+
yield navigator.clipboard.write([s]), t.fire("editor:object-copied", {
|
|
2764
2761
|
object: r
|
|
2765
2762
|
});
|
|
2766
2763
|
} catch (u) {
|
|
@@ -2777,18 +2774,18 @@ class Ot {
|
|
|
2777
2774
|
*/
|
|
2778
2775
|
paste() {
|
|
2779
2776
|
var e = this;
|
|
2780
|
-
return
|
|
2777
|
+
return Ce(function* () {
|
|
2781
2778
|
var {
|
|
2782
2779
|
canvas: t
|
|
2783
2780
|
} = e.editor;
|
|
2784
2781
|
if (e.clipboard) {
|
|
2785
2782
|
var a = yield e.clipboard.clone(["format"]);
|
|
2786
2783
|
t.discardActiveObject(), a.set({
|
|
2787
|
-
id: "".concat(a.type, "-").concat(
|
|
2784
|
+
id: "".concat(a.type, "-").concat(C()),
|
|
2788
2785
|
left: a.left + 10,
|
|
2789
2786
|
top: a.top + 10,
|
|
2790
2787
|
evented: !0
|
|
2791
|
-
}), a instanceof
|
|
2788
|
+
}), a instanceof H ? (a.canvas = t, a.forEachObject((r) => {
|
|
2792
2789
|
t.add(r);
|
|
2793
2790
|
})) : t.add(a), t.setActiveObject(a), t.requestRenderAll(), t.fire("editor:object-pasted", {
|
|
2794
2791
|
object: a
|
|
@@ -2826,7 +2823,7 @@ class Tt {
|
|
|
2826
2823
|
historyManager: i
|
|
2827
2824
|
} = this.editor, n = e || r.getActiveObject();
|
|
2828
2825
|
if (!(!n || n.locked)) {
|
|
2829
|
-
var
|
|
2826
|
+
var s = {
|
|
2830
2827
|
lockMovementX: !0,
|
|
2831
2828
|
lockMovementY: !0,
|
|
2832
2829
|
lockRotation: !0,
|
|
@@ -2836,10 +2833,10 @@ class Tt {
|
|
|
2836
2833
|
lockSkewingY: !0,
|
|
2837
2834
|
locked: !0
|
|
2838
2835
|
};
|
|
2839
|
-
n.set(
|
|
2836
|
+
n.set(s);
|
|
2840
2837
|
var c = !t && ["activeselection", "group"].includes(n.type);
|
|
2841
2838
|
c && n.getObjects().forEach((u) => {
|
|
2842
|
-
u.set(
|
|
2839
|
+
u.set(s);
|
|
2843
2840
|
}), r.renderAll(), a || i.saveState(), r.fire("editor:object-locked", {
|
|
2844
2841
|
object: n
|
|
2845
2842
|
});
|
|
@@ -2872,8 +2869,8 @@ class Tt {
|
|
|
2872
2869
|
lockSkewingY: !1,
|
|
2873
2870
|
locked: !1
|
|
2874
2871
|
};
|
|
2875
|
-
i.set(n), ["activeselection", "group"].includes(i.type) && i.getObjects().forEach((
|
|
2876
|
-
|
|
2872
|
+
i.set(n), ["activeselection", "group"].includes(i.type) && i.getObjects().forEach((s) => {
|
|
2873
|
+
s.set(n);
|
|
2877
2874
|
}), a.renderAll(), t || r.saveState(), a.fire("editor:object-unlocked", {
|
|
2878
2875
|
object: i
|
|
2879
2876
|
});
|
|
@@ -2909,8 +2906,8 @@ class kt {
|
|
|
2909
2906
|
r.suspendHistory();
|
|
2910
2907
|
var i = e || a.getActiveObject();
|
|
2911
2908
|
if (i && i.type === "activeselection") {
|
|
2912
|
-
var n = i.getObjects(),
|
|
2913
|
-
n.forEach((c) => a.remove(c)),
|
|
2909
|
+
var n = i.getObjects(), s = new He(n);
|
|
2910
|
+
n.forEach((c) => a.remove(c)), s.set("id", "".concat(s.type, "-").concat(C())), a.add(s), a.setActiveObject(s), a.renderAll(), r.resumeHistory(), t || r.saveState(), a.fire("editor:objects-grouped");
|
|
2914
2911
|
}
|
|
2915
2912
|
}
|
|
2916
2913
|
/**
|
|
@@ -2933,10 +2930,10 @@ class kt {
|
|
|
2933
2930
|
if (!(!i || i.type !== "group")) {
|
|
2934
2931
|
var n = i.removeAll();
|
|
2935
2932
|
a.remove(i), n.forEach((c) => a.add(c));
|
|
2936
|
-
var
|
|
2933
|
+
var s = new H(n, {
|
|
2937
2934
|
canvas: a
|
|
2938
2935
|
});
|
|
2939
|
-
a.setActiveObject(
|
|
2936
|
+
a.setActiveObject(s), a.renderAll(), r.resumeHistory(), t || r.saveState(), a.fire("editor:objects-ungrouped");
|
|
2940
2937
|
}
|
|
2941
2938
|
}
|
|
2942
2939
|
}
|
|
@@ -2962,7 +2959,7 @@ class xt {
|
|
|
2962
2959
|
objectLockManager: a
|
|
2963
2960
|
} = this.editor;
|
|
2964
2961
|
e.discardActiveObject();
|
|
2965
|
-
var r = t.getObjects(), i = r.some((
|
|
2962
|
+
var r = t.getObjects(), i = r.some((s) => s.locked), n = r.length > 1 ? new H(t.getObjects(), {
|
|
2966
2963
|
canvas: e
|
|
2967
2964
|
}) : r[0];
|
|
2968
2965
|
i && a.lockObject({
|
|
@@ -2990,7 +2987,7 @@ class Bt {
|
|
|
2990
2987
|
* @param {Object} options
|
|
2991
2988
|
* @param {fabric.Object[]} options.objects - массив объектов для удаления
|
|
2992
2989
|
* @param {Boolean} options.withoutSave - Не сохранять состояние
|
|
2993
|
-
* @fires editor:
|
|
2990
|
+
* @fires editor:objects-deleted
|
|
2994
2991
|
*/
|
|
2995
2992
|
deleteSelectedObjects() {
|
|
2996
2993
|
var {
|
|
@@ -2998,14 +2995,15 @@ class Bt {
|
|
|
2998
2995
|
withoutSave: t
|
|
2999
2996
|
} = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, {
|
|
3000
2997
|
canvas: a,
|
|
3001
|
-
historyManager: r
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
2998
|
+
historyManager: r,
|
|
2999
|
+
groupingManager: i
|
|
3000
|
+
} = this.editor, n = (e || a.getActiveObjects()).filter((s) => !s.locked);
|
|
3001
|
+
n != null && n.length && (r.suspendHistory(), n.forEach((s) => {
|
|
3002
|
+
if (s.type === "group" && s.format !== "svg") {
|
|
3003
|
+
i.ungroup(s), this.deleteSelectedObjects();
|
|
3006
3004
|
return;
|
|
3007
3005
|
}
|
|
3008
|
-
a.remove(
|
|
3006
|
+
a.remove(s);
|
|
3009
3007
|
}), a.discardActiveObject(), a.renderAll(), r.resumeHistory(), t || r.saveState(), a.fire("editor:objects-deleted"));
|
|
3010
3008
|
}
|
|
3011
3009
|
}
|
|
@@ -3037,7 +3035,7 @@ var Zt = {
|
|
|
3037
3035
|
IMAGE_EXPORT_FAILED: "IMAGE_EXPORT_FAILED"
|
|
3038
3036
|
}
|
|
3039
3037
|
};
|
|
3040
|
-
class
|
|
3038
|
+
class X {
|
|
3041
3039
|
constructor(e) {
|
|
3042
3040
|
var {
|
|
3043
3041
|
editor: t
|
|
@@ -3062,7 +3060,7 @@ class V {
|
|
|
3062
3060
|
data: i,
|
|
3063
3061
|
message: n
|
|
3064
3062
|
} = e;
|
|
3065
|
-
if (!
|
|
3063
|
+
if (!X.isValidErrorCode(r)) {
|
|
3066
3064
|
console.warn("Неизвестный код ошибки: ", {
|
|
3067
3065
|
code: r,
|
|
3068
3066
|
origin: t,
|
|
@@ -3071,12 +3069,12 @@ class V {
|
|
|
3071
3069
|
return;
|
|
3072
3070
|
}
|
|
3073
3071
|
if (r) {
|
|
3074
|
-
var
|
|
3075
|
-
console.error("".concat(t, ". ").concat(a, ". ").concat(r, ". ").concat(
|
|
3072
|
+
var s = n || r;
|
|
3073
|
+
console.error("".concat(t, ". ").concat(a, ". ").concat(r, ". ").concat(s), i), this.editor.canvas.fire("editor:error", {
|
|
3076
3074
|
code: r,
|
|
3077
3075
|
origin: t,
|
|
3078
3076
|
method: a,
|
|
3079
|
-
message:
|
|
3077
|
+
message: s,
|
|
3080
3078
|
data: i
|
|
3081
3079
|
});
|
|
3082
3080
|
}
|
|
@@ -3099,7 +3097,7 @@ class V {
|
|
|
3099
3097
|
message: i,
|
|
3100
3098
|
data: n
|
|
3101
3099
|
} = e;
|
|
3102
|
-
if (!
|
|
3100
|
+
if (!X.isValidErrorCode(r)) {
|
|
3103
3101
|
console.warn("Неизвестный код ошибки: ", {
|
|
3104
3102
|
code: r,
|
|
3105
3103
|
origin: t,
|
|
@@ -3107,8 +3105,8 @@ class V {
|
|
|
3107
3105
|
});
|
|
3108
3106
|
return;
|
|
3109
3107
|
}
|
|
3110
|
-
var
|
|
3111
|
-
console.warn("".concat(t, ". ").concat(a, ". ").concat(r, ". ").concat(
|
|
3108
|
+
var s = i || r;
|
|
3109
|
+
console.warn("".concat(t, ". ").concat(a, ". ").concat(r, ". ").concat(s), n), this.editor.canvas.fire("editor:warning", {
|
|
3112
3110
|
code: r,
|
|
3113
3111
|
origin: t,
|
|
3114
3112
|
method: a,
|
|
@@ -3120,7 +3118,7 @@ class V {
|
|
|
3120
3118
|
return e ? Object.values(Zt).some((t) => Object.values(t).includes(e)) : !1;
|
|
3121
3119
|
}
|
|
3122
3120
|
}
|
|
3123
|
-
class
|
|
3121
|
+
class ue {
|
|
3124
3122
|
/**
|
|
3125
3123
|
* Конструктор класса ImageEditor.
|
|
3126
3124
|
* @param {string} canvasId - идентификатор канваса, в котором будет создан редактор
|
|
@@ -3129,10 +3127,10 @@ class oe {
|
|
|
3129
3127
|
constructor(e, t) {
|
|
3130
3128
|
this.options = t;
|
|
3131
3129
|
const { defaultScale: a, minZoom: r, maxZoom: i } = t;
|
|
3132
|
-
this.containerId = e, this.editorId = `${e}-${
|
|
3130
|
+
this.containerId = e, this.editorId = `${e}-${C()}`, this.clipboard = null, this.defaultZoom = a, this.minZoom = r || ft, this.maxZoom = i || Mt, this.init();
|
|
3133
3131
|
}
|
|
3134
3132
|
init() {
|
|
3135
|
-
return
|
|
3133
|
+
return J(this, null, function* () {
|
|
3136
3134
|
const {
|
|
3137
3135
|
editorContainerWidth: e,
|
|
3138
3136
|
editorContainerHeight: t,
|
|
@@ -3140,24 +3138,24 @@ class oe {
|
|
|
3140
3138
|
canvasWrapperHeight: r,
|
|
3141
3139
|
canvasCSSWidth: i,
|
|
3142
3140
|
canvasCSSHeight: n,
|
|
3143
|
-
initialImage:
|
|
3141
|
+
initialImage: s,
|
|
3144
3142
|
initialStateJSON: c,
|
|
3145
3143
|
scaleType: u,
|
|
3146
3144
|
_onReadyCallback: l
|
|
3147
3145
|
} = this.options;
|
|
3148
|
-
if (tt.apply(), this.canvas = new _e(this.containerId, this.options), this.moduleLoader = new Ve(), this.workerManager = new Ge(), this.errorManager = new
|
|
3146
|
+
if (tt.apply(), this.canvas = new _e(this.containerId, this.options), this.moduleLoader = new Ve(), this.workerManager = new Ge(), this.errorManager = new X({ editor: this }), this.historyManager = new mt({ editor: this }), this.toolbar = new vt({ editor: this }), this.transformManager = new bt({ editor: this }), this.canvasManager = new pt({ editor: this }), this.imageManager = new A({ editor: this }), this.layerManager = new G({ editor: this }), this.shapeManager = new Et({ editor: this }), this.interactionBlocker = new It({ editor: this }), this.clipboardManager = new Ot({ editor: this }), this.objectLockManager = new Tt({ editor: this }), this.groupingManager = new kt({ editor: this }), this.selectionManager = new xt({ editor: this }), this.deletionManager = new Bt({ 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(r), this.canvasManager.setCanvasCSSWidth(i), this.canvasManager.setCanvasCSSHeight(n), s != null && s.source) {
|
|
3149
3147
|
const {
|
|
3150
3148
|
source: d,
|
|
3151
3149
|
scale: h = `image-${u}`,
|
|
3152
3150
|
withoutSave: v = !0
|
|
3153
|
-
} =
|
|
3151
|
+
} = s;
|
|
3154
3152
|
yield this.imageManager.importImage({ source: d, scale: h, withoutSave: v });
|
|
3155
3153
|
} else
|
|
3156
3154
|
this.canvasManager.setDefaultScale({ withoutSave: !0 });
|
|
3157
3155
|
c && this.historyManager.loadStateFromFullState(c), this.historyManager.saveState(), console.log("editor:ready"), this.canvas.fire("editor:ready", this), typeof l == "function" && l(this);
|
|
3158
3156
|
});
|
|
3159
3157
|
}
|
|
3160
|
-
|
|
3158
|
+
_createMontageArea() {
|
|
3161
3159
|
const {
|
|
3162
3160
|
montageAreaWidth: e,
|
|
3163
3161
|
montageAreaHeight: t
|
|
@@ -3165,7 +3163,7 @@ class oe {
|
|
|
3165
3163
|
this.montageArea = this.shapeManager.addRectangle({
|
|
3166
3164
|
width: e,
|
|
3167
3165
|
height: t,
|
|
3168
|
-
fill:
|
|
3166
|
+
fill: ue._createMosaicPattern(),
|
|
3169
3167
|
stroke: null,
|
|
3170
3168
|
strokeWidth: 0,
|
|
3171
3169
|
selectable: !1,
|
|
@@ -3340,18 +3338,18 @@ const zt = {
|
|
|
3340
3338
|
// Сброс параметров объекта по двойному клику
|
|
3341
3339
|
resetObjectFitByDoubleClick: !0
|
|
3342
3340
|
};
|
|
3343
|
-
function Ht(
|
|
3344
|
-
const t =
|
|
3341
|
+
function Ht(o, e = {}) {
|
|
3342
|
+
const t = Q(Q({}, zt), e), a = document.getElementById(o);
|
|
3345
3343
|
if (!a)
|
|
3346
|
-
return Promise.reject(new Error(`Контейнер с ID "${
|
|
3344
|
+
return Promise.reject(new Error(`Контейнер с ID "${o}" не найден.`));
|
|
3347
3345
|
const r = document.createElement("canvas");
|
|
3348
|
-
return r.id = `${
|
|
3346
|
+
return r.id = `${o}-canvas`, a.appendChild(r), t.editorContainer = a, new Promise((i) => {
|
|
3349
3347
|
t._onReadyCallback = i;
|
|
3350
|
-
const n = new
|
|
3351
|
-
window[
|
|
3348
|
+
const n = new ue(r.id, t);
|
|
3349
|
+
window[o] = n;
|
|
3352
3350
|
});
|
|
3353
3351
|
}
|
|
3354
3352
|
export {
|
|
3355
3353
|
Ht as default
|
|
3356
3354
|
};
|
|
3357
|
-
//# sourceMappingURL=main.map
|
|
3355
|
+
//# sourceMappingURL=main.js.map
|