@anu3ev/fabric-image-editor 0.1.61 → 0.1.63
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 +359 -325
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
1
|
+
var be = Object.defineProperty, ye = Object.defineProperties;
|
|
2
|
+
var pe = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var Y = Object.getOwnPropertySymbols;
|
|
4
|
+
var de = Object.prototype.hasOwnProperty, le = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var ce = (r, e, t) => e in r ? be(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, y = (r, e) => {
|
|
6
6
|
for (var t in e || (e = {}))
|
|
7
|
-
|
|
8
|
-
if (
|
|
9
|
-
for (var t of
|
|
10
|
-
|
|
11
|
-
return
|
|
12
|
-
},
|
|
13
|
-
var
|
|
7
|
+
de.call(e, t) && ce(r, t, e[t]);
|
|
8
|
+
if (Y)
|
|
9
|
+
for (var t of Y(e))
|
|
10
|
+
le.call(e, t) && ce(r, t, e[t]);
|
|
11
|
+
return r;
|
|
12
|
+
}, he = (r, e) => ye(r, pe(e));
|
|
13
|
+
var _ = (r, e) => {
|
|
14
14
|
var t = {};
|
|
15
|
-
for (var s in
|
|
16
|
-
|
|
17
|
-
if (
|
|
18
|
-
for (var s of
|
|
19
|
-
e.indexOf(s) < 0 &&
|
|
15
|
+
for (var s in r)
|
|
16
|
+
de.call(r, s) && e.indexOf(s) < 0 && (t[s] = r[s]);
|
|
17
|
+
if (r != null && Y)
|
|
18
|
+
for (var s of Y(r))
|
|
19
|
+
e.indexOf(s) < 0 && le.call(r, s) && (t[s] = r[s]);
|
|
20
20
|
return t;
|
|
21
21
|
};
|
|
22
|
-
var v = (
|
|
22
|
+
var v = (r, e, t) => new Promise((s, n) => {
|
|
23
23
|
var i = (d) => {
|
|
24
24
|
try {
|
|
25
25
|
o(t.next(d));
|
|
26
|
-
} catch (
|
|
27
|
-
n(
|
|
26
|
+
} catch (c) {
|
|
27
|
+
n(c);
|
|
28
28
|
}
|
|
29
29
|
}, a = (d) => {
|
|
30
30
|
try {
|
|
31
31
|
o(t.throw(d));
|
|
32
|
-
} catch (
|
|
33
|
-
n(
|
|
32
|
+
} catch (c) {
|
|
33
|
+
n(c);
|
|
34
34
|
}
|
|
35
35
|
}, o = (d) => d.done ? s(d.value) : Promise.resolve(d.value).then(i, a);
|
|
36
|
-
o((t = t.apply(
|
|
36
|
+
o((t = t.apply(r, e)).next());
|
|
37
37
|
});
|
|
38
|
-
import { ActiveSelection as
|
|
39
|
-
import { create as
|
|
40
|
-
import
|
|
41
|
-
var
|
|
38
|
+
import { ActiveSelection as p, util as H, controlsUtils as Ie, InteractiveFabricObject as ve, loadSVGFromURL as Ae, FabricImage as U, Point as P, Rect as Se, Circle as Ce, Triangle as Ne, Group as $, Canvas as De, Pattern as Le } from "fabric";
|
|
39
|
+
import { create as we } from "jsondiffpatch";
|
|
40
|
+
import Ee from "diff-match-patch";
|
|
41
|
+
var Oe = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", L = function() {
|
|
42
42
|
for (var e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 21, t = "", s = crypto.getRandomValues(new Uint8Array(e |= 0)); e--; )
|
|
43
|
-
t +=
|
|
43
|
+
t += Oe[s[e] & 63];
|
|
44
44
|
return t;
|
|
45
45
|
};
|
|
46
|
-
class
|
|
46
|
+
class R {
|
|
47
47
|
/**
|
|
48
48
|
* Конструктор принимает редактор и опции.
|
|
49
49
|
* @param params
|
|
@@ -61,7 +61,7 @@ class z {
|
|
|
61
61
|
* @param params.options.adaptCanvasToContainerOnResize — адаптировать канвас к размерам контейнера при изменении размеров окна
|
|
62
62
|
*/
|
|
63
63
|
constructor({ editor: e, options: t = {} }) {
|
|
64
|
-
this.isDragging = !1, this.lastMouseX = 0, this.lastMouseY = 0, this.isUndoRedoKeyPressed = !1, this.isSpacePressed = !1, this.savedSelection = [], this.canvasDragging = !1, this.mouseWheelZooming = !1, this.bringToFrontOnSelection = !1, this.resetObjectFitByDoubleClick = !1, this.copyObjectsByHotkey = !1, this.pasteImageFromClipboard = !1, this.undoRedoByHotKeys = !1, this.selectAllByHotkey = !1, this.deleteObjectsByHotkey = !1, this.adaptCanvasToContainerOnResize = !1, this.editor = e, this.canvas = e.canvas, this.options = t, this.handleContainerResizeBound =
|
|
64
|
+
this.isDragging = !1, this.lastMouseX = 0, this.lastMouseY = 0, this.isUndoRedoKeyPressed = !1, this.isSpacePressed = !1, this.savedSelection = [], this.canvasDragging = !1, this.mouseWheelZooming = !1, this.bringToFrontOnSelection = !1, this.resetObjectFitByDoubleClick = !1, this.copyObjectsByHotkey = !1, this.pasteImageFromClipboard = !1, this.undoRedoByHotKeys = !1, this.selectAllByHotkey = !1, this.deleteObjectsByHotkey = !1, this.adaptCanvasToContainerOnResize = !1, this.editor = e, this.canvas = e.canvas, this.options = t, this.handleContainerResizeBound = R.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 = R.debounce(this.handleObjectModifiedHistory.bind(this), 300), this.handleObjectRotatingHistoryBound = R.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();
|
|
65
65
|
}
|
|
66
66
|
/**
|
|
67
67
|
* Инициализация всех обработчиков согласно опциям.
|
|
@@ -76,10 +76,10 @@ class z {
|
|
|
76
76
|
pasteImageFromClipboard: a,
|
|
77
77
|
undoRedoByHotKeys: o,
|
|
78
78
|
selectAllByHotkey: d,
|
|
79
|
-
deleteObjectsByHotkey:
|
|
79
|
+
deleteObjectsByHotkey: c,
|
|
80
80
|
resetObjectFitByDoubleClick: l
|
|
81
81
|
} = this.options;
|
|
82
|
-
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 })), s && 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 }), a && document.addEventListener("paste", this.handlePasteEventBound, { capture: !0 }), o && (document.addEventListener("keydown", this.handleUndoRedoEventBound, { capture: !0 }), document.addEventListener("keyup", this.handleUndoRedoKeyUpBound, { capture: !0 })), d && document.addEventListener("keydown", this.handleSelectAllEventBound, { capture: !0 }),
|
|
82
|
+
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 })), s && 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 }), a && document.addEventListener("paste", this.handlePasteEventBound, { capture: !0 }), o && (document.addEventListener("keydown", this.handleUndoRedoEventBound, { capture: !0 }), document.addEventListener("keyup", this.handleUndoRedoKeyUpBound, { capture: !0 })), d && document.addEventListener("keydown", this.handleSelectAllEventBound, { capture: !0 }), c && 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);
|
|
83
83
|
}
|
|
84
84
|
/**
|
|
85
85
|
* При массовом выделении объектов удаляем из него залоченные.
|
|
@@ -88,20 +88,32 @@ class z {
|
|
|
88
88
|
* @param params.e - событие указателя (опционально)
|
|
89
89
|
*/
|
|
90
90
|
_filterLockedSelection({ selected: e, e: t }) {
|
|
91
|
-
if (!(e != null && e.length) || !(t instanceof MouseEvent) || e.length === 1
|
|
92
|
-
const n = e.
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
if (n.length
|
|
98
|
-
|
|
91
|
+
if (!(e != null && e.length) || !(t instanceof MouseEvent) || e.length === 1) return;
|
|
92
|
+
const { lockedObjects: s, unlockedObjects: n } = e.reduce(
|
|
93
|
+
(a, o) => o.locked ? (a.lockedObjects.push(o), a) : (a.unlockedObjects.push(o), a),
|
|
94
|
+
{ lockedObjects: [], unlockedObjects: [] }
|
|
95
|
+
);
|
|
96
|
+
if (s.length === 0) return;
|
|
97
|
+
if (n.length > 0) {
|
|
98
|
+
if (n.length === 1)
|
|
99
|
+
this.canvas.setActiveObject(n[0]);
|
|
100
|
+
else {
|
|
101
|
+
const a = new p(n, {
|
|
102
|
+
canvas: this.canvas
|
|
103
|
+
});
|
|
104
|
+
this.canvas.setActiveObject(a);
|
|
105
|
+
}
|
|
106
|
+
this.canvas.requestRenderAll();
|
|
99
107
|
return;
|
|
100
108
|
}
|
|
101
|
-
const i = new
|
|
109
|
+
const i = new p(e, {
|
|
102
110
|
canvas: this.canvas
|
|
103
111
|
});
|
|
104
|
-
this.
|
|
112
|
+
this.editor.objectLockManager.lockObject({
|
|
113
|
+
object: i,
|
|
114
|
+
skipInnerObjects: !0,
|
|
115
|
+
withoutSave: !0
|
|
116
|
+
}), this.canvas.setActiveObject(i), this.canvas.requestRenderAll();
|
|
105
117
|
}
|
|
106
118
|
/**
|
|
107
119
|
* Обработчики для сохранения состояния редактора в истории.
|
|
@@ -205,7 +217,7 @@ class z {
|
|
|
205
217
|
if (n || i) return;
|
|
206
218
|
this.isSpacePressed = !0, e.preventDefault();
|
|
207
219
|
const a = t.getActiveObject() || null;
|
|
208
|
-
a instanceof
|
|
220
|
+
a instanceof p ? this.savedSelection = a.getObjects().slice() : a && (this.savedSelection = [a]), t.discardActiveObject(), t.set({
|
|
209
221
|
selection: !1,
|
|
210
222
|
defaultCursor: "grab"
|
|
211
223
|
}), t.setCursor("grab"), s.canvasManager.getObjects().forEach((o) => {
|
|
@@ -244,7 +256,7 @@ class z {
|
|
|
244
256
|
t.setActiveObject(e[0]);
|
|
245
257
|
return;
|
|
246
258
|
}
|
|
247
|
-
const n = e.filter((a) => s.canvasManager.getObjects().includes(a)), i = new
|
|
259
|
+
const n = e.filter((a) => s.canvasManager.getObjects().includes(a)), i = new p(n, { canvas: t });
|
|
248
260
|
t.setActiveObject(i);
|
|
249
261
|
}
|
|
250
262
|
// --- Обработчики для событий canvas (Fabric) ---
|
|
@@ -254,7 +266,7 @@ class z {
|
|
|
254
266
|
* @param options.e — объект события (MouseEvent или TouchEvent)
|
|
255
267
|
*/
|
|
256
268
|
handleCanvasDragStart({ e }) {
|
|
257
|
-
!this.isSpacePressed || !(e instanceof MouseEvent) || (this.isDragging = !0, this.lastMouseX = e.clientX, this.lastMouseY = e.clientY, this.canvas.setCursor("grabbing"));
|
|
269
|
+
!this.isSpacePressed || !(e instanceof MouseEvent) || (this.isDragging = !0, this.lastMouseX = e.clientX, this.lastMouseY = e.clientY, this.canvas.set("defaultCursor", "grabbing"), this.canvas.setCursor("grabbing"));
|
|
258
270
|
}
|
|
259
271
|
/**
|
|
260
272
|
* Перетаскивание канваса (mouse:move).
|
|
@@ -352,7 +364,7 @@ class z {
|
|
|
352
364
|
};
|
|
353
365
|
}
|
|
354
366
|
}
|
|
355
|
-
class
|
|
367
|
+
class Te {
|
|
356
368
|
/**
|
|
357
369
|
* Класс для динамической загрузки внешних модулей.
|
|
358
370
|
*/
|
|
@@ -370,21 +382,21 @@ class Ee {
|
|
|
370
382
|
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 "${e}"`));
|
|
371
383
|
}
|
|
372
384
|
}
|
|
373
|
-
function
|
|
385
|
+
function ke(r) {
|
|
374
386
|
return new Worker(
|
|
375
387
|
"" + new URL("assets/worker-CN39s7P7.js", import.meta.url).href,
|
|
376
388
|
{
|
|
377
|
-
name:
|
|
389
|
+
name: r == null ? void 0 : r.name
|
|
378
390
|
}
|
|
379
391
|
);
|
|
380
392
|
}
|
|
381
|
-
class
|
|
393
|
+
class xe {
|
|
382
394
|
/**
|
|
383
395
|
* @param scriptUrl — URL скрипта воркера.
|
|
384
396
|
* По-умолчанию использует DefaultWorker из соседнего файла
|
|
385
397
|
*/
|
|
386
398
|
constructor(e) {
|
|
387
|
-
e ? this.worker = new Worker(e, { type: "module" }) : this.worker = new
|
|
399
|
+
e ? this.worker = new Worker(e, { type: "module" }) : this.worker = new ke(), this._callbacks = /* @__PURE__ */ new Map(), this.worker.onmessage = this._handleMessage.bind(this);
|
|
388
400
|
}
|
|
389
401
|
/**
|
|
390
402
|
* Обработчик сообщений от воркера
|
|
@@ -424,50 +436,50 @@ class Te {
|
|
|
424
436
|
this.worker.terminate();
|
|
425
437
|
}
|
|
426
438
|
}
|
|
427
|
-
const N = 12,
|
|
428
|
-
function
|
|
429
|
-
const i = N, a =
|
|
430
|
-
|
|
439
|
+
const N = 12, Be = 2, J = 8, K = 20, Ze = 100, q = 20, ee = 8, Ue = 100, F = 32, te = 1, ze = "#2B2D33", se = "#3D8BF4", ne = "#FFFFFF";
|
|
440
|
+
function W(r, e, t, s, n) {
|
|
441
|
+
const i = N, a = Be;
|
|
442
|
+
r.save(), r.translate(e, t), r.rotate(H.degreesToRadians(n.angle)), r.fillStyle = ne, r.strokeStyle = se, r.lineWidth = te, r.beginPath(), r.roundRect(-i / 2, -i / 2, i, i, a), r.fill(), r.stroke(), r.restore();
|
|
431
443
|
}
|
|
432
|
-
function
|
|
433
|
-
const i =
|
|
434
|
-
|
|
444
|
+
function ge(r, e, t, s, n) {
|
|
445
|
+
const i = J, a = K, o = Ze;
|
|
446
|
+
r.save(), r.translate(e, t), r.rotate(H.degreesToRadians(n.angle)), r.fillStyle = ne, r.strokeStyle = se, r.lineWidth = te, r.beginPath(), r.roundRect(-i / 2, -a / 2, i, a, o), r.fill(), r.stroke(), r.restore();
|
|
435
447
|
}
|
|
436
|
-
function
|
|
437
|
-
const i =
|
|
438
|
-
|
|
448
|
+
function ue(r, e, t, s, n) {
|
|
449
|
+
const i = q, a = ee, o = Ue;
|
|
450
|
+
r.save(), r.translate(e, t), r.rotate(H.degreesToRadians(n.angle)), r.fillStyle = ne, r.strokeStyle = se, r.lineWidth = te, r.beginPath(), r.roundRect(-i / 2, -a / 2, i, a, o), r.fill(), r.stroke(), r.restore();
|
|
439
451
|
}
|
|
440
|
-
const
|
|
441
|
-
|
|
442
|
-
function
|
|
443
|
-
const a =
|
|
444
|
-
|
|
452
|
+
const Re = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTE4Ljc1IDQuMzc1djMuNzVhLjYyNS42MjUgMCAwIDEtLjYyNS42MjVoLTMuNzVhLjYyNS42MjUgMCAwIDEgMC0xLjI1aDIuMTRsLTIuMDc3LTEuOTAzLS4wMi0uMDE5YTYuMjUgNi4yNSAwIDEgMC0uMTMgOC45NjcuNjI2LjYyNiAwIDAgMSAuODYuOTA5QTcuNDU2IDcuNDU2IDAgMCAxIDEwIDE3LjVoLS4xMDNhNy41IDcuNSAwIDEgMSA1LjM5Ni0xMi44MTJMMTcuNSA2LjcwM1Y0LjM3NWEuNjI1LjYyNSAwIDAgMSAxLjI1IDBaIi8+PC9zdmc+", me = new Image();
|
|
453
|
+
me.src = Re;
|
|
454
|
+
function He(r, e, t, s, n) {
|
|
455
|
+
const a = F / 2;
|
|
456
|
+
r.save(), r.translate(e, t), r.rotate(H.degreesToRadians(n.angle)), r.fillStyle = ze, r.beginPath(), r.arc(0, 0, a, 0, 2 * Math.PI), r.fill(), r.drawImage(me, -a / 2, -a / 2, a, a), r.restore();
|
|
445
457
|
}
|
|
446
|
-
const
|
|
458
|
+
const Ye = {
|
|
447
459
|
// Угловые точки
|
|
448
460
|
tl: {
|
|
449
|
-
render:
|
|
461
|
+
render: W,
|
|
450
462
|
sizeX: N,
|
|
451
463
|
sizeY: N,
|
|
452
464
|
offsetX: 0,
|
|
453
465
|
offsetY: 0
|
|
454
466
|
},
|
|
455
467
|
tr: {
|
|
456
|
-
render:
|
|
468
|
+
render: W,
|
|
457
469
|
sizeX: N,
|
|
458
470
|
sizeY: N,
|
|
459
471
|
offsetX: 0,
|
|
460
472
|
offsetY: 0
|
|
461
473
|
},
|
|
462
474
|
bl: {
|
|
463
|
-
render:
|
|
475
|
+
render: W,
|
|
464
476
|
sizeX: N,
|
|
465
477
|
sizeY: N,
|
|
466
478
|
offsetX: 0,
|
|
467
479
|
offsetY: 0
|
|
468
480
|
},
|
|
469
481
|
br: {
|
|
470
|
-
render:
|
|
482
|
+
render: W,
|
|
471
483
|
sizeX: N,
|
|
472
484
|
sizeY: N,
|
|
473
485
|
offsetX: 0,
|
|
@@ -475,47 +487,47 @@ const Re = {
|
|
|
475
487
|
},
|
|
476
488
|
// Середина вертикалей
|
|
477
489
|
ml: {
|
|
478
|
-
render:
|
|
479
|
-
sizeX:
|
|
480
|
-
sizeY:
|
|
490
|
+
render: ge,
|
|
491
|
+
sizeX: J,
|
|
492
|
+
sizeY: K,
|
|
481
493
|
offsetX: 0,
|
|
482
494
|
offsetY: 0
|
|
483
495
|
},
|
|
484
496
|
mr: {
|
|
485
|
-
render:
|
|
486
|
-
sizeX:
|
|
487
|
-
sizeY:
|
|
497
|
+
render: ge,
|
|
498
|
+
sizeX: J,
|
|
499
|
+
sizeY: K,
|
|
488
500
|
offsetX: 0,
|
|
489
501
|
offsetY: 0
|
|
490
502
|
},
|
|
491
503
|
// Середина горизонталей
|
|
492
504
|
mt: {
|
|
493
|
-
render:
|
|
494
|
-
sizeX:
|
|
495
|
-
sizeY:
|
|
505
|
+
render: ue,
|
|
506
|
+
sizeX: q,
|
|
507
|
+
sizeY: ee,
|
|
496
508
|
offsetX: 0,
|
|
497
509
|
offsetY: 0
|
|
498
510
|
},
|
|
499
511
|
mb: {
|
|
500
|
-
render:
|
|
501
|
-
sizeX:
|
|
502
|
-
sizeY:
|
|
512
|
+
render: ue,
|
|
513
|
+
sizeX: q,
|
|
514
|
+
sizeY: ee,
|
|
503
515
|
offsetX: 0,
|
|
504
516
|
offsetY: 0
|
|
505
517
|
},
|
|
506
518
|
// Специальный «rotate» контрол
|
|
507
519
|
mtr: {
|
|
508
|
-
render:
|
|
509
|
-
sizeX:
|
|
510
|
-
sizeY:
|
|
520
|
+
render: He,
|
|
521
|
+
sizeX: F,
|
|
522
|
+
sizeY: F,
|
|
511
523
|
offsetX: 0,
|
|
512
|
-
offsetY: -
|
|
524
|
+
offsetY: -F
|
|
513
525
|
}
|
|
514
526
|
};
|
|
515
|
-
class
|
|
527
|
+
class _e {
|
|
516
528
|
static apply() {
|
|
517
|
-
const e =
|
|
518
|
-
Object.entries(
|
|
529
|
+
const e = Ie.createObjectDefaultControls();
|
|
530
|
+
Object.entries(Ye).forEach(([t, s]) => {
|
|
519
531
|
Object.assign(e[t], {
|
|
520
532
|
render: s.render,
|
|
521
533
|
sizeX: s.sizeX,
|
|
@@ -526,10 +538,10 @@ class He {
|
|
|
526
538
|
var l;
|
|
527
539
|
(l = a.target.canvas) == null || l.setCursor("grabbing");
|
|
528
540
|
});
|
|
529
|
-
}),
|
|
541
|
+
}), ve.ownDefaults.controls = e;
|
|
530
542
|
}
|
|
531
543
|
}
|
|
532
|
-
const
|
|
544
|
+
const We = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNNi44NzUgMi41YS42MjUuNjI1IDAgMCAwLS42MjUuNjI0V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ZmlsbD0iI0VDNEU0MCIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNOC4xMjUgMS4yNUExLjg3NSAxLjg3NSAwIDAgMCA2LjI1IDMuMTI1di42MjVIMy4xMjVhLjYyNS42MjUgMCAwIDAgMCAxLjI1aC42MjV2MTEuMjVBMS4yNSAxLjI1IDAgMCAwIDUgMTcuNWgxMGExLjI1IDEuMjUgMCAwIDAgMS4yNS0xLjI1VjVoLjYyNWEuNjI1LjYyNSAwIDAgMCAwLTEuMjVIMTMuNzV2LS42MjVhMS44NzUgMS44NzUgMCAwIDAtMS44NzUtMS44NzVoLTMuNzVabTQuMzc1IDIuNXYtLjYyNWEuNjI1LjYyNSAwIDAgMC0uNjI1LS42MjVoLTMuNzVhLjYyNS42MjUgMCAwIDAtLjYyNS42MjV2LjYyNWg1Wk01IDE2LjI1VjVoMTB2MTEuMjVINVpNOC4xMjUgNy41Yy4zNDUgMCAuNjI1LjI4LjYyNS42MjV2NWEuNjI1LjYyNSAwIDEgMS0xLjI1IDB2LTVjMC0uMzQ1LjI4LS42MjUuNjI1LS42MjVabTQuMzc1IDUuNjI1di01YS42MjUuNjI1IDAgMCAwLTEuMjUgMHY1YS42MjUuNjI1IDAgMSAwIDEuMjUgMFoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjwvc3ZnPg==", z = {
|
|
533
545
|
style: {
|
|
534
546
|
position: "absolute",
|
|
535
547
|
display: "none",
|
|
@@ -596,56 +608,56 @@ const Ye = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMj
|
|
|
596
608
|
],
|
|
597
609
|
offsetTop: 50,
|
|
598
610
|
icons: {
|
|
599
|
-
copyPaste:
|
|
600
|
-
delete:
|
|
601
|
-
lock:
|
|
602
|
-
unlock:
|
|
603
|
-
bringToFront:
|
|
604
|
-
sendToBack:
|
|
605
|
-
bringForward:
|
|
606
|
-
sendBackwards:
|
|
611
|
+
copyPaste: We,
|
|
612
|
+
delete: $e,
|
|
613
|
+
lock: Pe,
|
|
614
|
+
unlock: Fe,
|
|
615
|
+
bringToFront: Xe,
|
|
616
|
+
sendToBack: Qe,
|
|
617
|
+
bringForward: Ve,
|
|
618
|
+
sendBackwards: Ge
|
|
607
619
|
},
|
|
608
620
|
handlers: {
|
|
609
|
-
copyPaste: (
|
|
610
|
-
yield
|
|
611
|
-
object:
|
|
621
|
+
copyPaste: (r) => v(null, null, function* () {
|
|
622
|
+
yield r.clipboardManager.copy(), yield r.clipboardManager.paste(), r.clipboardManager.clipboard && r.canvas.fire("editor:object-duplicated", {
|
|
623
|
+
object: r.clipboardManager.clipboard
|
|
612
624
|
});
|
|
613
625
|
}),
|
|
614
|
-
delete: (
|
|
615
|
-
|
|
626
|
+
delete: (r) => {
|
|
627
|
+
r.deletionManager.deleteSelectedObjects();
|
|
616
628
|
},
|
|
617
|
-
lock: (
|
|
618
|
-
|
|
629
|
+
lock: (r) => {
|
|
630
|
+
r.objectLockManager.lockObject();
|
|
619
631
|
},
|
|
620
|
-
unlock: (
|
|
621
|
-
|
|
632
|
+
unlock: (r) => {
|
|
633
|
+
r.objectLockManager.unlockObject();
|
|
622
634
|
},
|
|
623
|
-
bringForward: (
|
|
624
|
-
|
|
635
|
+
bringForward: (r) => {
|
|
636
|
+
r.layerManager.bringForward();
|
|
625
637
|
},
|
|
626
|
-
bringToFront: (
|
|
627
|
-
|
|
638
|
+
bringToFront: (r) => {
|
|
639
|
+
r.layerManager.bringToFront();
|
|
628
640
|
},
|
|
629
|
-
sendToBack: (
|
|
630
|
-
|
|
641
|
+
sendToBack: (r) => {
|
|
642
|
+
r.layerManager.sendToBack();
|
|
631
643
|
},
|
|
632
|
-
sendBackwards: (
|
|
633
|
-
|
|
644
|
+
sendBackwards: (r) => {
|
|
645
|
+
r.layerManager.sendBackwards();
|
|
634
646
|
}
|
|
635
647
|
}
|
|
636
648
|
};
|
|
637
|
-
class
|
|
649
|
+
class Je {
|
|
638
650
|
constructor({ editor: e }) {
|
|
639
651
|
this.currentTarget = null, this.currentLocked = !1, this.isTransforming = !1, this.editor = e, this.canvas = e.canvas, this.options = e.options, this._initToolbar();
|
|
640
652
|
}
|
|
641
653
|
_initToolbar() {
|
|
642
654
|
if (!this.options.showToolbar) return;
|
|
643
655
|
const e = this.options.toolbar || {};
|
|
644
|
-
this.config =
|
|
645
|
-
style: y(y({},
|
|
646
|
-
btnStyle: y(y({},
|
|
647
|
-
icons: y(y({},
|
|
648
|
-
handlers: y(y({},
|
|
656
|
+
this.config = he(y(y({}, z), e), {
|
|
657
|
+
style: y(y({}, z.style), e.style || {}),
|
|
658
|
+
btnStyle: y(y({}, z.btnStyle), e.btnStyle || {}),
|
|
659
|
+
icons: y(y({}, z.icons), e.icons || {}),
|
|
660
|
+
handlers: y(y({}, z.handlers), e.handlers || {})
|
|
649
661
|
}), this.currentTarget = null, this.currentLocked = !1, this.isTransforming = !1, this._onMouseDown = this._handleMouseDown.bind(this), this._onObjectMoving = this._startTransform.bind(this), this._onObjectScaling = this._startTransform.bind(this), this._onObjectRotating = this._startTransform.bind(this), this._onMouseUp = this._endTransform.bind(this), this._onObjectModified = this._endTransform.bind(this), this._onSelectionChange = this._updateToolbar.bind(this), this._onSelectionClear = () => {
|
|
650
662
|
this.el.style.display = "none";
|
|
651
663
|
}, this._createDOM(), this._bindEvents();
|
|
@@ -674,8 +686,8 @@ class Qe {
|
|
|
674
686
|
for (const t of e) {
|
|
675
687
|
const { name: s, handle: n } = t, { icons: i = {}, btnStyle: a, handlers: o = {} } = this.config, d = document.createElement("button");
|
|
676
688
|
d.innerHTML = i[n] ? `<img src="${i[n]}" title="${s}" />` : s, Object.assign(d.style, a), d.onclick = () => {
|
|
677
|
-
var
|
|
678
|
-
return (
|
|
689
|
+
var c;
|
|
690
|
+
return (c = o[n]) == null ? void 0 : c.call(o, this.editor);
|
|
679
691
|
}, this.el.appendChild(d);
|
|
680
692
|
}
|
|
681
693
|
}
|
|
@@ -734,7 +746,7 @@ class Qe {
|
|
|
734
746
|
}
|
|
735
747
|
const { el: t, config: s, canvas: n } = this;
|
|
736
748
|
e.setCoords();
|
|
737
|
-
const i = n.getZoom(), [, , , , a, o] = n.viewportTransform, { x: d } = e.getCenterPoint(), { top:
|
|
749
|
+
const i = n.getZoom(), [, , , , a, o] = n.viewportTransform, { x: d } = e.getCenterPoint(), { top: c, height: l } = e.getBoundingRect(), g = d * i + a - t.offsetWidth / 2, u = s.offsetTop || 0, m = (c + l) * i + o + u;
|
|
738
750
|
Object.assign(t.style, {
|
|
739
751
|
left: `${g}px`,
|
|
740
752
|
top: `${m}px`,
|
|
@@ -748,7 +760,7 @@ class Qe {
|
|
|
748
760
|
this.el.removeEventListener("mouseover", this._onBtnOver), this.el.removeEventListener("mouseout", this._onBtnOut), this.canvas.off("mouse:down", this._onMouseDown), this.canvas.off("object:moving", this._onObjectMoving), this.canvas.off("object:scaling", this._onObjectScaling), this.canvas.off("object:rotating", this._onObjectRotating), this.canvas.off("mouse:up", this._onMouseUp), this.canvas.off("object:modified", this._onObjectModified), this.canvas.off("selection:created", this._onSelectionChange), this.canvas.off("selection:updated", this._onSelectionChange), this.canvas.off("after:render", this._onSelectionChange), this.canvas.off("selection:cleared", this._onSelectionClear), this.el.remove();
|
|
749
761
|
}
|
|
750
762
|
}
|
|
751
|
-
class
|
|
763
|
+
class Ke {
|
|
752
764
|
constructor({ editor: e }) {
|
|
753
765
|
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();
|
|
754
766
|
}
|
|
@@ -760,7 +772,7 @@ class $e {
|
|
|
760
772
|
return this.patches[this.currentIndex - 1] || null;
|
|
761
773
|
}
|
|
762
774
|
_createDiffPatcher() {
|
|
763
|
-
this.diffPatcher =
|
|
775
|
+
this.diffPatcher = we({
|
|
764
776
|
objectHash(e) {
|
|
765
777
|
const t = e;
|
|
766
778
|
return [
|
|
@@ -784,7 +796,7 @@ class $e {
|
|
|
784
796
|
includeValueOnMove: !1
|
|
785
797
|
},
|
|
786
798
|
textDiff: {
|
|
787
|
-
diffMatchPatch:
|
|
799
|
+
diffMatchPatch: Ee,
|
|
788
800
|
minLength: 60
|
|
789
801
|
}
|
|
790
802
|
});
|
|
@@ -863,9 +875,9 @@ class $e {
|
|
|
863
875
|
console.log("loadStateFromFullState fullState", e);
|
|
864
876
|
const { canvas: t, canvasManager: s, interactionBlocker: n } = this.editor, { width: i, height: a } = t;
|
|
865
877
|
yield t.loadFromJSON(e);
|
|
866
|
-
const o = t.getObjects().find((
|
|
878
|
+
const o = t.getObjects().find((c) => c.id === "montage-area");
|
|
867
879
|
o && (this.editor.montageArea = o, (i !== t.getWidth() || a !== t.getHeight()) && s.updateCanvas());
|
|
868
|
-
const d = t.getObjects().find((
|
|
880
|
+
const d = t.getObjects().find((c) => c.id === "overlay-mask");
|
|
869
881
|
d && (n.overlayMask = d, n.overlayMask.visible = !1), t.renderAll(), t.fire("editor:history-state-loaded", {
|
|
870
882
|
fullState: e,
|
|
871
883
|
currentIndex: this.currentIndex,
|
|
@@ -951,7 +963,7 @@ class $e {
|
|
|
951
963
|
});
|
|
952
964
|
}
|
|
953
965
|
}
|
|
954
|
-
const
|
|
966
|
+
const qe = 0.1, et = 2, tt = 0.1, st = 90, B = 16, Z = 16, O = 4096, T = 4096;
|
|
955
967
|
class D {
|
|
956
968
|
constructor({ editor: e }) {
|
|
957
969
|
this.editor = e, this.options = e.options, this._createdBlobUrls = [], this.acceptContentTypes = this.editor.options.acceptContentTypes, this.acceptFormats = this.getAllowedFormatsFromContentTypes();
|
|
@@ -976,10 +988,10 @@ class D {
|
|
|
976
988
|
withoutSave: n = !1
|
|
977
989
|
} = e;
|
|
978
990
|
if (!t) return null;
|
|
979
|
-
const { canvas: i, montageArea: a, transformManager: o, historyManager: d, errorManager:
|
|
991
|
+
const { canvas: i, montageArea: a, transformManager: o, historyManager: d, errorManager: c } = this.editor, l = yield this.getContentType(t), h = D.getFormatFromContentType(l), { acceptContentTypes: g, acceptFormats: u } = this;
|
|
980
992
|
if (!this.isAllowedContentType(l)) {
|
|
981
993
|
const m = `Неверный contentType для изображения: ${l}. Ожидается один из: ${this.acceptContentTypes.join(", ")}.`;
|
|
982
|
-
return
|
|
994
|
+
return c.emitError({
|
|
983
995
|
origin: "ImageManager",
|
|
984
996
|
method: "importImage",
|
|
985
997
|
code: "INVALID_CONTENT_TYPE",
|
|
@@ -996,7 +1008,7 @@ class D {
|
|
|
996
1008
|
const S = yield (yield fetch(t, { mode: "cors" })).blob();
|
|
997
1009
|
m = URL.createObjectURL(S);
|
|
998
1010
|
} else
|
|
999
|
-
return
|
|
1011
|
+
return c.emitError({
|
|
1000
1012
|
origin: "ImageManager",
|
|
1001
1013
|
method: "importImage",
|
|
1002
1014
|
code: "INVALID_SOURCE_TYPE",
|
|
@@ -1004,20 +1016,20 @@ class D {
|
|
|
1004
1016
|
data: { source: t, format: h, contentType: l, acceptContentTypes: g, acceptFormats: u }
|
|
1005
1017
|
}), null;
|
|
1006
1018
|
if (this._createdBlobUrls.push(m), h === "svg") {
|
|
1007
|
-
const b = yield
|
|
1008
|
-
M =
|
|
1019
|
+
const b = yield Ae(m);
|
|
1020
|
+
M = H.groupSVGElements(b.objects, b.options);
|
|
1009
1021
|
} else
|
|
1010
|
-
M = yield
|
|
1022
|
+
M = yield U.fromURL(m, { crossOrigin: "anonymous" });
|
|
1011
1023
|
const { width: f, height: j } = M;
|
|
1012
|
-
if (M instanceof
|
|
1024
|
+
if (M instanceof U) {
|
|
1013
1025
|
const b = M.getElement();
|
|
1014
1026
|
let S = "";
|
|
1015
1027
|
if (b instanceof HTMLImageElement ? S = b.src : b instanceof HTMLCanvasElement && (S = b.toDataURL()), j > T || f > O) {
|
|
1016
1028
|
const w = yield this.resizeImageToBoundaries(S, "max"), E = URL.createObjectURL(w);
|
|
1017
|
-
this._createdBlobUrls.push(E), M = yield
|
|
1018
|
-
} else if (j <
|
|
1029
|
+
this._createdBlobUrls.push(E), M = yield U.fromURL(E, { crossOrigin: "anonymous" });
|
|
1030
|
+
} else if (j < Z || f < B) {
|
|
1019
1031
|
const w = yield this.resizeImageToBoundaries(S, "min"), E = URL.createObjectURL(w);
|
|
1020
|
-
this._createdBlobUrls.push(E), M = yield
|
|
1032
|
+
this._createdBlobUrls.push(E), M = yield U.fromURL(E, { crossOrigin: "anonymous" });
|
|
1021
1033
|
}
|
|
1022
1034
|
}
|
|
1023
1035
|
if (M.set("id", `${M.type}-${L()}`), M.set("format", h), s === "scale-montage")
|
|
@@ -1037,7 +1049,7 @@ class D {
|
|
|
1037
1049
|
};
|
|
1038
1050
|
return i.fire("editor:image-imported", A), A;
|
|
1039
1051
|
} catch (m) {
|
|
1040
|
-
return
|
|
1052
|
+
return c.emitError({
|
|
1041
1053
|
origin: "ImageManager",
|
|
1042
1054
|
method: "importImage",
|
|
1043
1055
|
code: "IMPORT_FAILED",
|
|
@@ -1058,14 +1070,14 @@ class D {
|
|
|
1058
1070
|
resizeImageToBoundaries(e, t = "max") {
|
|
1059
1071
|
return v(this, null, function* () {
|
|
1060
1072
|
let s = `Размер изображения больше максимального размера канваса, поэтому оно будет уменьшено до максимальных размеров c сохранением пропорций: ${O}x${T}`;
|
|
1061
|
-
t === "min" && (s = `Размер изображения меньше минимального размера канваса, поэтому оно будет увеличено до минимальных размеров c сохранением пропорций: ${
|
|
1073
|
+
t === "min" && (s = `Размер изображения меньше минимального размера канваса, поэтому оно будет увеличено до минимальных размеров c сохранением пропорций: ${B}x${Z}`);
|
|
1062
1074
|
const n = {
|
|
1063
1075
|
dataURL: e,
|
|
1064
1076
|
sizeType: t,
|
|
1065
1077
|
maxWidth: O,
|
|
1066
1078
|
maxHeight: T,
|
|
1067
|
-
minWidth:
|
|
1068
|
-
minHeight:
|
|
1079
|
+
minWidth: B,
|
|
1080
|
+
minHeight: Z
|
|
1069
1081
|
};
|
|
1070
1082
|
return this.editor.errorManager.emitWarning({
|
|
1071
1083
|
origin: "ImageManager",
|
|
@@ -1096,18 +1108,18 @@ class D {
|
|
|
1096
1108
|
exportAsBlob: i = !1
|
|
1097
1109
|
} = e, { canvas: a, montageArea: o, workerManager: d } = this.editor;
|
|
1098
1110
|
try {
|
|
1099
|
-
const
|
|
1111
|
+
const c = s === "application/pdf", l = c ? "image/jpg" : s, h = D.getFormatFromContentType(l);
|
|
1100
1112
|
o.setCoords();
|
|
1101
1113
|
const { left: g, top: u, width: m, height: M } = o.getBoundingRect(), f = yield a.clone(["id", "format", "locked"]);
|
|
1102
1114
|
["image/jpg", "image/jpeg"].includes(l) && (f.backgroundColor = "#ffffff");
|
|
1103
|
-
const j = f.getObjects().find((
|
|
1115
|
+
const j = f.getObjects().find((I) => I.id === o.id);
|
|
1104
1116
|
j && (j.visible = !1), f.viewportTransform = [1, 0, 0, 1, -g, -u], f.setDimensions({ width: m, height: M }, { backstoreOnly: !0 }), f.renderAll();
|
|
1105
|
-
const A = f.getObjects().filter((
|
|
1117
|
+
const A = f.getObjects().filter((I) => I.format).every((I) => I.format === "svg");
|
|
1106
1118
|
if (h === "svg" && A) {
|
|
1107
|
-
const
|
|
1119
|
+
const I = f.toSVG();
|
|
1108
1120
|
f.dispose();
|
|
1109
1121
|
const C = {
|
|
1110
|
-
image: D._exportSVGStringAsFile(
|
|
1122
|
+
image: D._exportSVGStringAsFile(I, {
|
|
1111
1123
|
exportAsBase64: n,
|
|
1112
1124
|
exportAsBlob: i,
|
|
1113
1125
|
fileName: t
|
|
@@ -1118,70 +1130,70 @@ class D {
|
|
|
1118
1130
|
};
|
|
1119
1131
|
return a.fire("editor:canvas-exported", C), C;
|
|
1120
1132
|
}
|
|
1121
|
-
const b = yield new Promise((
|
|
1133
|
+
const b = yield new Promise((I, k) => {
|
|
1122
1134
|
f.getElement().toBlob((C) => {
|
|
1123
|
-
C ?
|
|
1135
|
+
C ? I(C) : k(new Error("Failed to create Blob from canvas"));
|
|
1124
1136
|
});
|
|
1125
1137
|
});
|
|
1126
1138
|
if (f.dispose(), i) {
|
|
1127
|
-
const
|
|
1139
|
+
const I = {
|
|
1128
1140
|
image: b,
|
|
1129
1141
|
format: h,
|
|
1130
1142
|
contentType: l,
|
|
1131
1143
|
fileName: t
|
|
1132
1144
|
};
|
|
1133
|
-
return a.fire("editor:canvas-exported",
|
|
1145
|
+
return a.fire("editor:canvas-exported", I), I;
|
|
1134
1146
|
}
|
|
1135
1147
|
const S = yield createImageBitmap(b), w = yield d.post(
|
|
1136
1148
|
"toDataURL",
|
|
1137
1149
|
{ format: h, quality: 1, bitmap: S },
|
|
1138
1150
|
[S]
|
|
1139
1151
|
);
|
|
1140
|
-
if (
|
|
1141
|
-
const k = m * 0.264583, C = M * 0.264583,
|
|
1152
|
+
if (c) {
|
|
1153
|
+
const k = m * 0.264583, C = M * 0.264583, fe = (yield this.editor.moduleLoader.loadModule("jspdf")).jsPDF, Q = new fe({
|
|
1142
1154
|
orientation: k > C ? "landscape" : "portrait",
|
|
1143
1155
|
unit: "mm",
|
|
1144
1156
|
format: [k, C]
|
|
1145
1157
|
});
|
|
1146
|
-
if (
|
|
1147
|
-
const
|
|
1148
|
-
image:
|
|
1158
|
+
if (Q.addImage(String(w), "JPG", 0, 0, k, C), n) {
|
|
1159
|
+
const re = {
|
|
1160
|
+
image: Q.output("datauristring"),
|
|
1149
1161
|
format: "pdf",
|
|
1150
1162
|
contentType: "application/pdf",
|
|
1151
1163
|
fileName: t
|
|
1152
1164
|
};
|
|
1153
|
-
return a.fire("editor:canvas-exported",
|
|
1165
|
+
return a.fire("editor:canvas-exported", re), re;
|
|
1154
1166
|
}
|
|
1155
|
-
const
|
|
1156
|
-
image: new File([
|
|
1167
|
+
const je = Q.output("blob"), oe = {
|
|
1168
|
+
image: new File([je], t, { type: "application/pdf" }),
|
|
1157
1169
|
format: "pdf",
|
|
1158
1170
|
contentType: "application/pdf",
|
|
1159
1171
|
fileName: t
|
|
1160
1172
|
};
|
|
1161
|
-
return a.fire("editor:canvas-exported",
|
|
1173
|
+
return a.fire("editor:canvas-exported", oe), oe;
|
|
1162
1174
|
}
|
|
1163
1175
|
if (n) {
|
|
1164
|
-
const
|
|
1176
|
+
const I = {
|
|
1165
1177
|
image: w,
|
|
1166
1178
|
format: h,
|
|
1167
1179
|
contentType: l,
|
|
1168
1180
|
fileName: t
|
|
1169
1181
|
};
|
|
1170
|
-
return a.fire("editor:canvas-exported",
|
|
1182
|
+
return a.fire("editor:canvas-exported", I), I;
|
|
1171
1183
|
}
|
|
1172
|
-
const E = h === "svg" && !A ? t.replace(/\.[^/.]+$/, ".png") : t,
|
|
1184
|
+
const E = h === "svg" && !A ? t.replace(/\.[^/.]+$/, ".png") : t, ae = {
|
|
1173
1185
|
image: new File([b], E, { type: l }),
|
|
1174
1186
|
format: h,
|
|
1175
1187
|
contentType: l,
|
|
1176
1188
|
fileName: E
|
|
1177
1189
|
};
|
|
1178
|
-
return a.fire("editor:canvas-exported",
|
|
1179
|
-
} catch (
|
|
1190
|
+
return a.fire("editor:canvas-exported", ae), ae;
|
|
1191
|
+
} catch (c) {
|
|
1180
1192
|
return this.editor.errorManager.emitError({
|
|
1181
1193
|
origin: "ImageManager",
|
|
1182
1194
|
method: "exportCanvasAsImageFile",
|
|
1183
1195
|
code: "IMAGE_EXPORT_FAILED",
|
|
1184
|
-
message: `Ошибка экспорта изображения: ${
|
|
1196
|
+
message: `Ошибка экспорта изображения: ${c.message}`,
|
|
1185
1197
|
data: { contentType: s, fileName: t, exportAsBase64: n, exportAsBlob: i }
|
|
1186
1198
|
}), null;
|
|
1187
1199
|
}
|
|
@@ -1206,8 +1218,8 @@ class D {
|
|
|
1206
1218
|
contentType: n = "image/png",
|
|
1207
1219
|
exportAsBase64: i = !1,
|
|
1208
1220
|
exportAsBlob: a = !1
|
|
1209
|
-
} = e, { canvas: o, workerManager: d } = this.editor,
|
|
1210
|
-
if (!
|
|
1221
|
+
} = e, { canvas: o, workerManager: d } = this.editor, c = t || o.getActiveObject();
|
|
1222
|
+
if (!c)
|
|
1211
1223
|
return this.editor.errorManager.emitError({
|
|
1212
1224
|
origin: "ImageManager",
|
|
1213
1225
|
method: "exportObjectAsImageFile",
|
|
@@ -1218,12 +1230,12 @@ class D {
|
|
|
1218
1230
|
try {
|
|
1219
1231
|
const l = D.getFormatFromContentType(n);
|
|
1220
1232
|
if (l === "svg") {
|
|
1221
|
-
const M =
|
|
1233
|
+
const M = c.toSVG(), f = D._exportSVGStringAsFile(M, {
|
|
1222
1234
|
exportAsBase64: i,
|
|
1223
1235
|
exportAsBlob: a,
|
|
1224
1236
|
fileName: s
|
|
1225
1237
|
}), j = {
|
|
1226
|
-
object:
|
|
1238
|
+
object: c,
|
|
1227
1239
|
image: f,
|
|
1228
1240
|
format: l,
|
|
1229
1241
|
contentType: "image/svg+xml",
|
|
@@ -1231,8 +1243,8 @@ class D {
|
|
|
1231
1243
|
};
|
|
1232
1244
|
return o.fire("editor:object-exported", j), j;
|
|
1233
1245
|
}
|
|
1234
|
-
if (i &&
|
|
1235
|
-
const M = yield createImageBitmap(
|
|
1246
|
+
if (i && c instanceof U) {
|
|
1247
|
+
const M = yield createImageBitmap(c.getElement()), f = yield d.post(
|
|
1236
1248
|
"toDataURL",
|
|
1237
1249
|
{
|
|
1238
1250
|
format: l,
|
|
@@ -1241,7 +1253,7 @@ class D {
|
|
|
1241
1253
|
},
|
|
1242
1254
|
[M]
|
|
1243
1255
|
), j = {
|
|
1244
|
-
object:
|
|
1256
|
+
object: c,
|
|
1245
1257
|
image: f,
|
|
1246
1258
|
format: l,
|
|
1247
1259
|
contentType: n,
|
|
@@ -1249,14 +1261,14 @@ class D {
|
|
|
1249
1261
|
};
|
|
1250
1262
|
return o.fire("editor:object-exported", j), j;
|
|
1251
1263
|
}
|
|
1252
|
-
const h =
|
|
1264
|
+
const h = c.toCanvasElement(), g = yield new Promise((M, f) => {
|
|
1253
1265
|
h.toBlob((j) => {
|
|
1254
1266
|
j ? M(j) : f(new Error("Failed to create Blob from canvas"));
|
|
1255
1267
|
});
|
|
1256
1268
|
});
|
|
1257
1269
|
if (a) {
|
|
1258
1270
|
const M = {
|
|
1259
|
-
object:
|
|
1271
|
+
object: c,
|
|
1260
1272
|
image: g,
|
|
1261
1273
|
format: l,
|
|
1262
1274
|
contentType: n,
|
|
@@ -1265,7 +1277,7 @@ class D {
|
|
|
1265
1277
|
return o.fire("editor:object-exported", M), M;
|
|
1266
1278
|
}
|
|
1267
1279
|
const u = new File([g], s, { type: n }), m = {
|
|
1268
|
-
object:
|
|
1280
|
+
object: c,
|
|
1269
1281
|
image: u,
|
|
1270
1282
|
format: l,
|
|
1271
1283
|
contentType: n,
|
|
@@ -1400,7 +1412,11 @@ class D {
|
|
|
1400
1412
|
return t ? t[1] : "";
|
|
1401
1413
|
}
|
|
1402
1414
|
}
|
|
1403
|
-
|
|
1415
|
+
const x = (r, e, t) => Math.max(Math.min(r, t), e), Me = (r, e) => r * e, nt = (r, e) => new P(r / 2, e / 2);
|
|
1416
|
+
function it(r) {
|
|
1417
|
+
return ((r == null ? void 0 : r.type) === "image" || (r == null ? void 0 : r.format) === "svg") && typeof (r == null ? void 0 : r.width) == "number" && typeof (r == null ? void 0 : r.height) == "number";
|
|
1418
|
+
}
|
|
1419
|
+
class at {
|
|
1404
1420
|
/**
|
|
1405
1421
|
* @param options
|
|
1406
1422
|
* @param options.editor – экземпляр редактора
|
|
@@ -1408,6 +1424,13 @@ class tt {
|
|
|
1408
1424
|
constructor({ editor: e }) {
|
|
1409
1425
|
this.editor = e;
|
|
1410
1426
|
}
|
|
1427
|
+
/**
|
|
1428
|
+
* Возвращает контейнер редактора
|
|
1429
|
+
*/
|
|
1430
|
+
getEditorContainer() {
|
|
1431
|
+
const { canvas: e, options: { editorContainer: t } } = this.editor;
|
|
1432
|
+
return e.editorContainer || t;
|
|
1433
|
+
}
|
|
1411
1434
|
/**
|
|
1412
1435
|
* Устанавливаем внутреннюю ширину канваса (для экспорта)
|
|
1413
1436
|
* @param width - ширина канваса
|
|
@@ -1424,9 +1447,9 @@ class tt {
|
|
|
1424
1447
|
canvas: i,
|
|
1425
1448
|
montageArea: a,
|
|
1426
1449
|
options: { canvasBackstoreWidth: o }
|
|
1427
|
-
} = this.editor, { width: d, height:
|
|
1450
|
+
} = this.editor, { width: d, height: c } = a, l = x(Number(e), B, O);
|
|
1428
1451
|
if (!o || o === "auto" || n ? this.adaptCanvasToContainer() : o ? this.setCanvasBackstoreWidth(Number(o)) : this.setCanvasBackstoreWidth(l), a.set({ width: l }), (m = i.clipPath) == null || m.set({ width: l }), t) {
|
|
1429
|
-
const M = l / d, f =
|
|
1452
|
+
const M = l / d, f = Me(c, M);
|
|
1430
1453
|
this.setResolutionHeight(f);
|
|
1431
1454
|
return;
|
|
1432
1455
|
}
|
|
@@ -1454,9 +1477,9 @@ class tt {
|
|
|
1454
1477
|
canvas: i,
|
|
1455
1478
|
montageArea: a,
|
|
1456
1479
|
options: { canvasBackstoreHeight: o }
|
|
1457
|
-
} = this.editor, { width: d, height:
|
|
1480
|
+
} = this.editor, { width: d, height: c } = a, l = x(Number(e), Z, T);
|
|
1458
1481
|
if (!o || o === "auto" || n ? this.adaptCanvasToContainer() : o ? this.setCanvasBackstoreHeight(Number(o)) : this.setCanvasBackstoreHeight(l), a.set({ height: l }), (m = i.clipPath) == null || m.set({ height: l }), t) {
|
|
1459
|
-
const M = l /
|
|
1482
|
+
const M = l / c, f = Me(d, M);
|
|
1460
1483
|
this.setResolutionWidth(f);
|
|
1461
1484
|
return;
|
|
1462
1485
|
}
|
|
@@ -1474,7 +1497,7 @@ class tt {
|
|
|
1474
1497
|
*/
|
|
1475
1498
|
centerMontageArea() {
|
|
1476
1499
|
var d;
|
|
1477
|
-
const { canvas: e, montageArea: t } = this.editor, s = e.getWidth(), n = e.getHeight(), i = e.getZoom(), a =
|
|
1500
|
+
const { canvas: e, montageArea: t } = this.editor, s = e.getWidth(), n = e.getHeight(), i = e.getZoom(), a = nt(s, n);
|
|
1478
1501
|
t.set({
|
|
1479
1502
|
left: s / 2,
|
|
1480
1503
|
top: n / 2
|
|
@@ -1507,7 +1530,7 @@ class tt {
|
|
|
1507
1530
|
*/
|
|
1508
1531
|
setCanvasBackstoreWidth(e) {
|
|
1509
1532
|
if (!e || typeof e != "number") return;
|
|
1510
|
-
const t =
|
|
1533
|
+
const t = x(e, B, O);
|
|
1511
1534
|
this.editor.canvas.setDimensions({ width: t }, { backstoreOnly: !0 });
|
|
1512
1535
|
}
|
|
1513
1536
|
/**
|
|
@@ -1516,7 +1539,7 @@ class tt {
|
|
|
1516
1539
|
*/
|
|
1517
1540
|
setCanvasBackstoreHeight(e) {
|
|
1518
1541
|
if (!e || typeof e != "number") return;
|
|
1519
|
-
const t =
|
|
1542
|
+
const t = x(e, Z, T);
|
|
1520
1543
|
this.editor.canvas.setDimensions({ height: t }, { backstoreOnly: !0 });
|
|
1521
1544
|
}
|
|
1522
1545
|
/**
|
|
@@ -1525,8 +1548,8 @@ class tt {
|
|
|
1525
1548
|
* с учётом минимальных и максимальных значений.
|
|
1526
1549
|
*/
|
|
1527
1550
|
adaptCanvasToContainer() {
|
|
1528
|
-
const { canvas: e } = this.editor, t =
|
|
1529
|
-
|
|
1551
|
+
const { canvas: e } = this.editor, t = this.getEditorContainer(), s = t.clientWidth, n = t.clientHeight, i = x(s, B, O), a = x(n, Z, T);
|
|
1552
|
+
e.setDimensions({ width: i, height: a }, { backstoreOnly: !0 });
|
|
1530
1553
|
}
|
|
1531
1554
|
/**
|
|
1532
1555
|
* Обновляет размеры канваса без изменения позиций объектов.
|
|
@@ -1545,9 +1568,9 @@ class tt {
|
|
|
1545
1568
|
this.setResolutionWidth(s, { adaptCanvasToContainer: !0, withoutSave: !0 }), this.setResolutionHeight(n, { adaptCanvasToContainer: !0, withoutSave: !0 }), this.centerMontageArea();
|
|
1546
1569
|
const o = t.left - i, d = t.top - a;
|
|
1547
1570
|
if (o !== 0 || d !== 0) {
|
|
1548
|
-
const
|
|
1549
|
-
if ((
|
|
1550
|
-
const h =
|
|
1571
|
+
const c = e.getActiveObject(), l = [];
|
|
1572
|
+
if ((c == null ? void 0 : c.type) === "activeselection") {
|
|
1573
|
+
const h = c;
|
|
1551
1574
|
l.push(...h.getObjects()), e.discardActiveObject();
|
|
1552
1575
|
}
|
|
1553
1576
|
if (e.getObjects().forEach((h) => {
|
|
@@ -1559,7 +1582,7 @@ class tt {
|
|
|
1559
1582
|
if (l.length === 1)
|
|
1560
1583
|
e.setActiveObject(l[0]);
|
|
1561
1584
|
else {
|
|
1562
|
-
const h = new
|
|
1585
|
+
const h = new p(l, {
|
|
1563
1586
|
canvas: e
|
|
1564
1587
|
});
|
|
1565
1588
|
e.setActiveObject(h);
|
|
@@ -1581,15 +1604,19 @@ class tt {
|
|
|
1581
1604
|
*
|
|
1582
1605
|
* @param zoom — текущее значение zoom (например, 1, 1.2, 2 и т.д.)
|
|
1583
1606
|
*/
|
|
1584
|
-
updateCssDimensionsForZoom(
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1607
|
+
// public updateCssDimensionsForZoom(zoom: number): void {
|
|
1608
|
+
// const { canvas, montageArea } = this.editor
|
|
1609
|
+
// const zoomedWidth = montageArea.width * zoom
|
|
1610
|
+
// const zoomedHeight = montageArea.height * zoom
|
|
1611
|
+
// const scrollContainer = canvas.wrapperEl.parentNode
|
|
1612
|
+
// if (!(scrollContainer instanceof HTMLElement)) return
|
|
1613
|
+
// const cssWidth = zoomedWidth <= scrollContainer.clientWidth ? '100%' : zoomedWidth
|
|
1614
|
+
// const cssHeight = zoomedHeight <= scrollContainer.clientHeight ? '100%' : zoomedHeight
|
|
1615
|
+
// canvas.setDimensions(
|
|
1616
|
+
// { width: cssWidth, height: cssHeight },
|
|
1617
|
+
// { cssOnly: true }
|
|
1618
|
+
// )
|
|
1619
|
+
// }
|
|
1593
1620
|
/**
|
|
1594
1621
|
* Устанавливаем CSS ширину канваса для отображения
|
|
1595
1622
|
* @param width
|
|
@@ -1673,32 +1700,32 @@ class tt {
|
|
|
1673
1700
|
*/
|
|
1674
1701
|
setDisplayDimension({ element: e = "canvas", dimension: t, value: s } = {}) {
|
|
1675
1702
|
if (!s) return;
|
|
1676
|
-
const { canvas: n
|
|
1703
|
+
const { canvas: n } = this.editor, i = [];
|
|
1677
1704
|
switch (e) {
|
|
1678
1705
|
case "canvas":
|
|
1679
|
-
|
|
1706
|
+
i.push(n.lowerCanvasEl, n.upperCanvasEl);
|
|
1680
1707
|
break;
|
|
1681
1708
|
case "wrapper":
|
|
1682
|
-
|
|
1709
|
+
i.push(n.wrapperEl);
|
|
1683
1710
|
break;
|
|
1684
1711
|
case "container":
|
|
1685
|
-
|
|
1712
|
+
i.push(this.getEditorContainer());
|
|
1686
1713
|
break;
|
|
1687
1714
|
default:
|
|
1688
|
-
|
|
1715
|
+
i.push(n.lowerCanvasEl, n.upperCanvasEl);
|
|
1689
1716
|
}
|
|
1690
|
-
const
|
|
1717
|
+
const a = t === "width" ? "width" : "height";
|
|
1691
1718
|
if (typeof s == "string") {
|
|
1692
|
-
|
|
1693
|
-
|
|
1719
|
+
i.forEach((d) => {
|
|
1720
|
+
d.style[a] = s;
|
|
1694
1721
|
});
|
|
1695
1722
|
return;
|
|
1696
1723
|
}
|
|
1697
1724
|
if (isNaN(s)) return;
|
|
1698
|
-
const
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
}), n.fire(`editor:display-${e}-${
|
|
1725
|
+
const o = `${s}px`;
|
|
1726
|
+
i.forEach((d) => {
|
|
1727
|
+
d.style[a] = o;
|
|
1728
|
+
}), n.fire(`editor:display-${e}-${a}-changed`, {
|
|
1702
1729
|
element: e,
|
|
1703
1730
|
value: s
|
|
1704
1731
|
});
|
|
@@ -1720,9 +1747,9 @@ class tt {
|
|
|
1720
1747
|
montageAreaWidth: o,
|
|
1721
1748
|
montageAreaHeight: d
|
|
1722
1749
|
}
|
|
1723
|
-
} = this.editor,
|
|
1724
|
-
if (!
|
|
1725
|
-
const { width: l, height: h } =
|
|
1750
|
+
} = this.editor, c = e || n.getActiveObject();
|
|
1751
|
+
if (!it(c)) return;
|
|
1752
|
+
const { width: l, height: h } = c;
|
|
1726
1753
|
let g = Math.min(l, O), u = Math.min(h, T);
|
|
1727
1754
|
if (t) {
|
|
1728
1755
|
const {
|
|
@@ -1731,8 +1758,8 @@ class tt {
|
|
|
1731
1758
|
} = i, f = l / m, j = h / M, A = Math.max(f, j);
|
|
1732
1759
|
g = m * A, u = M * A;
|
|
1733
1760
|
}
|
|
1734
|
-
this.setResolutionWidth(g, { withoutSave: !0 }), this.setResolutionHeight(u, { withoutSave: !0 }), (l > o || h > d) && a.calculateAndApplyDefaultZoom(), a.resetObject(
|
|
1735
|
-
object:
|
|
1761
|
+
this.setResolutionWidth(g, { withoutSave: !0 }), this.setResolutionHeight(u, { withoutSave: !0 }), (l > o || h > d) && a.calculateAndApplyDefaultZoom(), a.resetObject(c, { withoutSave: !0 }), n.centerObject(c), n.renderAll(), s || this.editor.historyManager.saveState(), n.fire("editor:montage-area-scaled-to-image", {
|
|
1762
|
+
object: c,
|
|
1736
1763
|
width: g,
|
|
1737
1764
|
height: u,
|
|
1738
1765
|
preserveAspectRatio: t,
|
|
@@ -1774,9 +1801,9 @@ class tt {
|
|
|
1774
1801
|
return e.getObjects().filter((i) => i.id !== t.id && i.id !== (s == null ? void 0 : s.id));
|
|
1775
1802
|
}
|
|
1776
1803
|
}
|
|
1777
|
-
class
|
|
1804
|
+
class ot {
|
|
1778
1805
|
constructor({ editor: e }) {
|
|
1779
|
-
this.editor = e, this.options = e.options, this.minZoom = this.options.minZoom ||
|
|
1806
|
+
this.editor = e, this.options = e.options, this.minZoom = this.options.minZoom || qe, this.maxZoom = this.options.maxZoom || et, this.defaultZoom = this.options.defaultScale, this.maxZoomFactor = this.options.maxZoomFactor;
|
|
1780
1807
|
}
|
|
1781
1808
|
/**
|
|
1782
1809
|
* Метод рассчитывает и применяет зум по умолчанию для монтажной области редактора.
|
|
@@ -1786,8 +1813,8 @@ class st {
|
|
|
1786
1813
|
* @param scale - Желаемый масштаб относительно размеров контейнера редактора.
|
|
1787
1814
|
*/
|
|
1788
1815
|
calculateAndApplyDefaultZoom(e = this.options.defaultScale) {
|
|
1789
|
-
const { canvas: t } = this.editor, s = t.editorContainer, n = s.clientWidth, i = s.clientHeight, { width: a, height: o } = this.editor.montageArea, d = n / a * e,
|
|
1790
|
-
this.defaultZoom = Math.min(d,
|
|
1816
|
+
const { canvas: t } = this.editor, s = t.editorContainer, n = s.clientWidth, i = s.clientHeight, { width: a, height: o } = this.editor.montageArea, d = n / a * e, c = i / o * e;
|
|
1817
|
+
this.defaultZoom = Math.min(d, c);
|
|
1791
1818
|
const { defaultZoom: l, maxZoomFactor: h, minZoom: g, maxZoom: u } = this;
|
|
1792
1819
|
this.minZoom = Math.min(l / h, g), this.maxZoom = Math.max(l * h, u), this.setZoom();
|
|
1793
1820
|
}
|
|
@@ -1800,10 +1827,10 @@ class st {
|
|
|
1800
1827
|
* @fires editor:zoom-changed
|
|
1801
1828
|
* Если передавать координаты курсора, то нужно быть аккуратнее, так как юзер может выйти за пределы рабочей области
|
|
1802
1829
|
*/
|
|
1803
|
-
zoom(e =
|
|
1830
|
+
zoom(e = tt, t = {}) {
|
|
1804
1831
|
var g, u;
|
|
1805
1832
|
if (!e) return;
|
|
1806
|
-
const { minZoom: s, maxZoom: n } = this, { canvas: i } = this.editor, a = i.getZoom(), o = i.getCenterPoint(), d = (g = t.pointX) != null ? g : o.x,
|
|
1833
|
+
const { minZoom: s, maxZoom: n } = this, { canvas: i } = this.editor, a = i.getZoom(), o = i.getCenterPoint(), d = (g = t.pointX) != null ? g : o.x, c = (u = t.pointY) != null ? u : o.y, l = new P(d, c);
|
|
1807
1834
|
let h = Number((a + Number(e)).toFixed(2));
|
|
1808
1835
|
h > n && (h = n), h < s && (h = s), i.zoomToPoint(l, h), console.log({
|
|
1809
1836
|
currentZoom: a,
|
|
@@ -1821,7 +1848,7 @@ class st {
|
|
|
1821
1848
|
* @fires editor:zoom-changed
|
|
1822
1849
|
*/
|
|
1823
1850
|
setZoom(e = this.defaultZoom) {
|
|
1824
|
-
const { minZoom: t, maxZoom: s } = this, { canvas: n } = this.editor, i = new
|
|
1851
|
+
const { minZoom: t, maxZoom: s } = this, { canvas: n } = this.editor, i = new P(n.getCenterPoint());
|
|
1825
1852
|
let a = e;
|
|
1826
1853
|
e > s && (a = s), e < t && (a = t), n.zoomToPoint(i, a), n.fire("editor:zoom-changed", {
|
|
1827
1854
|
currentZoom: n.getZoom(),
|
|
@@ -1834,7 +1861,7 @@ class st {
|
|
|
1834
1861
|
* @fires editor:zoom-changed
|
|
1835
1862
|
*/
|
|
1836
1863
|
resetZoom() {
|
|
1837
|
-
const { canvas: e } = this.editor, t = new
|
|
1864
|
+
const { canvas: e } = this.editor, t = new P(e.getCenterPoint());
|
|
1838
1865
|
e.zoomToPoint(t, this.defaultZoom), this.editor.canvas.fire("editor:zoom-changed", {
|
|
1839
1866
|
currentZoom: e.getZoom(),
|
|
1840
1867
|
point: t
|
|
@@ -1847,7 +1874,7 @@ class st {
|
|
|
1847
1874
|
* @param options.withoutSave - Не сохранять состояние
|
|
1848
1875
|
* @fires editor:object-rotated
|
|
1849
1876
|
*/
|
|
1850
|
-
rotate(e =
|
|
1877
|
+
rotate(e = st, { withoutSave: t } = {}) {
|
|
1851
1878
|
const { canvas: s, historyManager: n } = this.editor, i = s.getActiveObject();
|
|
1852
1879
|
if (!i) return;
|
|
1853
1880
|
const a = i.angle + e;
|
|
@@ -1897,7 +1924,7 @@ class st {
|
|
|
1897
1924
|
withoutSave: s
|
|
1898
1925
|
} = {}) {
|
|
1899
1926
|
const { canvas: n, historyManager: i } = this.editor, a = e || n.getActiveObject();
|
|
1900
|
-
a && (a instanceof
|
|
1927
|
+
a && (a instanceof p ? a.getObjects().forEach((o) => {
|
|
1901
1928
|
o.set("opacity", t);
|
|
1902
1929
|
}) : a.set("opacity", t), n.renderAll(), s || i.saveState(), n.fire("editor:object-opacity-changed", {
|
|
1903
1930
|
object: a,
|
|
@@ -1924,13 +1951,13 @@ class st {
|
|
|
1924
1951
|
} = {}) {
|
|
1925
1952
|
const { canvas: i, historyManager: a } = this.editor, o = e || i.getActiveObject();
|
|
1926
1953
|
if (o) {
|
|
1927
|
-
if (o instanceof
|
|
1954
|
+
if (o instanceof p && !n) {
|
|
1928
1955
|
const d = o.getObjects();
|
|
1929
1956
|
i.discardActiveObject(), d.forEach((l) => {
|
|
1930
1957
|
this._fitSingleObject(l, t);
|
|
1931
1958
|
});
|
|
1932
|
-
const
|
|
1933
|
-
i.setActiveObject(
|
|
1959
|
+
const c = new p(d, { canvas: i });
|
|
1960
|
+
i.setActiveObject(c);
|
|
1934
1961
|
} else
|
|
1935
1962
|
this._fitSingleObject(o, t);
|
|
1936
1963
|
i.renderAll(), s || a.saveState(), i.fire("editor:object-fitted", {
|
|
@@ -1948,7 +1975,7 @@ class st {
|
|
|
1948
1975
|
* @private
|
|
1949
1976
|
*/
|
|
1950
1977
|
_fitSingleObject(e, t) {
|
|
1951
|
-
const { canvas: s, montageArea: n } = this.editor, { width: i, height: a, scaleX: o = 1, scaleY: d = 1, angle:
|
|
1978
|
+
const { canvas: s, montageArea: n } = this.editor, { width: i, height: a, scaleX: o = 1, scaleY: d = 1, angle: c = 0 } = e, l = i * Math.abs(o), h = a * Math.abs(d), g = c * Math.PI / 180, u = Math.abs(Math.cos(g)), m = Math.abs(Math.sin(g)), M = l * u + h * m, f = l * m + h * u, j = n.width, A = n.height;
|
|
1952
1979
|
let b;
|
|
1953
1980
|
t === "contain" ? b = Math.min(j / M, A / f) : b = Math.max(j / M, A / f), e.set({
|
|
1954
1981
|
scaleX: o * b,
|
|
@@ -1978,31 +2005,31 @@ class st {
|
|
|
1978
2005
|
imageManager: a,
|
|
1979
2006
|
historyManager: o,
|
|
1980
2007
|
options: { scaleType: d }
|
|
1981
|
-
} = this.editor,
|
|
1982
|
-
if (!
|
|
1983
|
-
if (o.suspendHistory(),
|
|
2008
|
+
} = this.editor, c = e || n.getActiveObject();
|
|
2009
|
+
if (!c || c.locked) return;
|
|
2010
|
+
if (o.suspendHistory(), c.type === "image" || c.format === "svg" || c.set({
|
|
1984
2011
|
scaleX: 1,
|
|
1985
2012
|
scaleY: 1,
|
|
1986
2013
|
flipX: !1,
|
|
1987
2014
|
flipY: !1,
|
|
1988
2015
|
angle: 0
|
|
1989
2016
|
}), t)
|
|
1990
|
-
this.fitObject({ object:
|
|
2017
|
+
this.fitObject({ object: c, withoutSave: !0, fitAsOneObject: !0 });
|
|
1991
2018
|
else {
|
|
1992
|
-
const { width: h, height: g } = i, { width: u, height: m } =
|
|
1993
|
-
imageObject:
|
|
2019
|
+
const { width: h, height: g } = i, { width: u, height: m } = c, M = a.calculateScaleFactor({
|
|
2020
|
+
imageObject: c,
|
|
1994
2021
|
scaleType: d
|
|
1995
2022
|
});
|
|
1996
|
-
d === "contain" && M < 1 || d === "cover" && (u > h || m > g) ? this.fitObject({ object:
|
|
2023
|
+
d === "contain" && M < 1 || d === "cover" && (u > h || m > g) ? this.fitObject({ object: c, withoutSave: !0, fitAsOneObject: !0 }) : c.set({ scaleX: 1, scaleY: 1 });
|
|
1997
2024
|
}
|
|
1998
|
-
|
|
1999
|
-
object:
|
|
2025
|
+
c.set({ flipX: !1, flipY: !1, angle: 0 }), n.centerObject(c), n.renderAll(), o.resumeHistory(), s || o.saveState(), n.fire("editor:object-reset", {
|
|
2026
|
+
object: c,
|
|
2000
2027
|
withoutSave: s,
|
|
2001
2028
|
alwaysFitObject: t
|
|
2002
2029
|
});
|
|
2003
2030
|
}
|
|
2004
2031
|
}
|
|
2005
|
-
class
|
|
2032
|
+
class rt {
|
|
2006
2033
|
constructor({ editor: e }) {
|
|
2007
2034
|
this.editor = e, this.isBlocked = !1, this.overlayMask = null, this._createOverlay();
|
|
2008
2035
|
}
|
|
@@ -2059,7 +2086,7 @@ class nt {
|
|
|
2059
2086
|
}), e.upperCanvasEl.style.pointerEvents = "", e.lowerCanvasEl.style.pointerEvents = "", this.overlayMask.visible = !1, e.requestRenderAll(), e.fire("editor:enabled"), s.resumeHistory();
|
|
2060
2087
|
}
|
|
2061
2088
|
}
|
|
2062
|
-
class
|
|
2089
|
+
class V {
|
|
2063
2090
|
constructor({ editor: e }) {
|
|
2064
2091
|
this.editor = e;
|
|
2065
2092
|
}
|
|
@@ -2074,7 +2101,7 @@ class F {
|
|
|
2074
2101
|
const { canvas: s, historyManager: n } = this.editor;
|
|
2075
2102
|
n.suspendHistory();
|
|
2076
2103
|
const i = e || s.getActiveObject();
|
|
2077
|
-
i && (i instanceof
|
|
2104
|
+
i && (i instanceof p ? i.getObjects().forEach((a) => {
|
|
2078
2105
|
s.bringObjectToFront(a);
|
|
2079
2106
|
}) : s.bringObjectToFront(i), s.renderAll(), n.resumeHistory(), t || n.saveState(), s.fire("editor:object-bring-to-front", {
|
|
2080
2107
|
object: i,
|
|
@@ -2092,7 +2119,7 @@ class F {
|
|
|
2092
2119
|
const { canvas: s, historyManager: n } = this.editor;
|
|
2093
2120
|
n.suspendHistory();
|
|
2094
2121
|
const i = e || s.getActiveObject();
|
|
2095
|
-
i && (i instanceof
|
|
2122
|
+
i && (i instanceof p ? V._moveSelectionForward(s, i) : s.bringObjectForward(i), s.renderAll(), n.resumeHistory(), t || n.saveState(), s.fire("editor:object-bring-forward", {
|
|
2096
2123
|
object: i,
|
|
2097
2124
|
withoutSave: t
|
|
2098
2125
|
}));
|
|
@@ -2114,10 +2141,10 @@ class F {
|
|
|
2114
2141
|
i.suspendHistory();
|
|
2115
2142
|
const o = e || s.getActiveObject();
|
|
2116
2143
|
if (o) {
|
|
2117
|
-
if (o instanceof
|
|
2144
|
+
if (o instanceof p) {
|
|
2118
2145
|
const d = o.getObjects();
|
|
2119
|
-
for (let
|
|
2120
|
-
s.sendObjectToBack(d[
|
|
2146
|
+
for (let c = d.length - 1; c >= 0; c -= 1)
|
|
2147
|
+
s.sendObjectToBack(d[c]);
|
|
2121
2148
|
} else
|
|
2122
2149
|
s.sendObjectToBack(o);
|
|
2123
2150
|
s.sendObjectToBack(n), a && s.sendObjectToBack(a), s.renderAll(), i.resumeHistory(), t || i.saveState(), s.fire("editor:object-send-to-back", {
|
|
@@ -2141,7 +2168,7 @@ class F {
|
|
|
2141
2168
|
} = this.editor;
|
|
2142
2169
|
i.suspendHistory();
|
|
2143
2170
|
const o = e || s.getActiveObject();
|
|
2144
|
-
o && (o instanceof
|
|
2171
|
+
o && (o instanceof p ? V._moveSelectionBackwards(s, o) : s.sendObjectBackwards(o), s.sendObjectToBack(n), a && s.sendObjectToBack(a), s.renderAll(), i.resumeHistory(), t || i.saveState(), s.fire("editor:object-send-backwards", {
|
|
2145
2172
|
object: o,
|
|
2146
2173
|
withoutSave: t
|
|
2147
2174
|
}));
|
|
@@ -2156,8 +2183,8 @@ class F {
|
|
|
2156
2183
|
const s = e.getObjects(), n = t.getObjects();
|
|
2157
2184
|
if (!n.some((o) => {
|
|
2158
2185
|
const d = s.indexOf(o);
|
|
2159
|
-
for (let
|
|
2160
|
-
if (!n.includes(s[
|
|
2186
|
+
for (let c = d + 1; c < s.length; c += 1)
|
|
2187
|
+
if (!n.includes(s[c]))
|
|
2161
2188
|
return !0;
|
|
2162
2189
|
return !1;
|
|
2163
2190
|
})) return;
|
|
@@ -2175,8 +2202,8 @@ class F {
|
|
|
2175
2202
|
const s = e.getObjects(), n = t.getObjects();
|
|
2176
2203
|
if (!n.some((o) => {
|
|
2177
2204
|
const d = s.indexOf(o);
|
|
2178
|
-
for (let
|
|
2179
|
-
if (!n.includes(s[
|
|
2205
|
+
for (let c = d - 1; c >= 0; c -= 1)
|
|
2206
|
+
if (!n.includes(s[c]))
|
|
2180
2207
|
return !0;
|
|
2181
2208
|
return !1;
|
|
2182
2209
|
})) return;
|
|
@@ -2185,7 +2212,7 @@ class F {
|
|
|
2185
2212
|
});
|
|
2186
2213
|
}
|
|
2187
2214
|
}
|
|
2188
|
-
class
|
|
2215
|
+
class ct {
|
|
2189
2216
|
/**
|
|
2190
2217
|
* Менеджер фигур для редактора.
|
|
2191
2218
|
* @param options - Опции и настройки менеджера фигур.
|
|
@@ -2209,7 +2236,7 @@ class it {
|
|
|
2209
2236
|
* @param flags.withoutSelection - Не выделять объект
|
|
2210
2237
|
* @param flags.withoutAdding - Не добавлять объект в canvas
|
|
2211
2238
|
*/
|
|
2212
|
-
addRectangle(l = {}, { withoutSelection: d, withoutAdding:
|
|
2239
|
+
addRectangle(l = {}, { withoutSelection: d, withoutAdding: c } = {}) {
|
|
2213
2240
|
var h = l, {
|
|
2214
2241
|
id: e = `rect-${L()}`,
|
|
2215
2242
|
left: t,
|
|
@@ -2217,7 +2244,7 @@ class it {
|
|
|
2217
2244
|
width: n = 100,
|
|
2218
2245
|
height: i = 100,
|
|
2219
2246
|
fill: a = "blue"
|
|
2220
|
-
} = h, o =
|
|
2247
|
+
} = h, o = _(h, [
|
|
2221
2248
|
"id",
|
|
2222
2249
|
"left",
|
|
2223
2250
|
"top",
|
|
@@ -2225,7 +2252,7 @@ class it {
|
|
|
2225
2252
|
"height",
|
|
2226
2253
|
"fill"
|
|
2227
2254
|
]);
|
|
2228
|
-
const { canvas: g } = this.editor, u = new
|
|
2255
|
+
const { canvas: g } = this.editor, u = new Se(y({
|
|
2229
2256
|
id: e,
|
|
2230
2257
|
left: t,
|
|
2231
2258
|
top: s,
|
|
@@ -2233,7 +2260,7 @@ class it {
|
|
|
2233
2260
|
height: i,
|
|
2234
2261
|
fill: a
|
|
2235
2262
|
}, o));
|
|
2236
|
-
return !t && !s && g.centerObject(u),
|
|
2263
|
+
return !t && !s && g.centerObject(u), c || (g.add(u), d || g.setActiveObject(u), g.renderAll()), u;
|
|
2237
2264
|
}
|
|
2238
2265
|
/**
|
|
2239
2266
|
* Добавление круга
|
|
@@ -2251,21 +2278,21 @@ class it {
|
|
|
2251
2278
|
* @param flags.withoutSelection - Не выделять объект
|
|
2252
2279
|
* @param flags.withoutAdding - Не добавлять объект в canvas
|
|
2253
2280
|
*/
|
|
2254
|
-
addCircle(
|
|
2255
|
-
var l =
|
|
2281
|
+
addCircle(c = {}, { withoutSelection: o, withoutAdding: d } = {}) {
|
|
2282
|
+
var l = c, {
|
|
2256
2283
|
id: e = `circle-${L()}`,
|
|
2257
2284
|
left: t,
|
|
2258
2285
|
top: s,
|
|
2259
2286
|
radius: n = 50,
|
|
2260
2287
|
fill: i = "green"
|
|
2261
|
-
} = l, a =
|
|
2288
|
+
} = l, a = _(l, [
|
|
2262
2289
|
"id",
|
|
2263
2290
|
"left",
|
|
2264
2291
|
"top",
|
|
2265
2292
|
"radius",
|
|
2266
2293
|
"fill"
|
|
2267
2294
|
]);
|
|
2268
|
-
const { canvas: h } = this.editor, g = new
|
|
2295
|
+
const { canvas: h } = this.editor, g = new Ce(y({
|
|
2269
2296
|
id: e,
|
|
2270
2297
|
left: t,
|
|
2271
2298
|
top: s,
|
|
@@ -2291,7 +2318,7 @@ class it {
|
|
|
2291
2318
|
* @param flags.withoutSelection - Не выделять объект
|
|
2292
2319
|
* @param flags.withoutAdding - Не добавлять объект в canvas
|
|
2293
2320
|
*/
|
|
2294
|
-
addTriangle(l = {}, { withoutSelection: d, withoutAdding:
|
|
2321
|
+
addTriangle(l = {}, { withoutSelection: d, withoutAdding: c } = {}) {
|
|
2295
2322
|
var h = l, {
|
|
2296
2323
|
id: e = `triangle-${L()}`,
|
|
2297
2324
|
left: t,
|
|
@@ -2299,7 +2326,7 @@ class it {
|
|
|
2299
2326
|
width: n = 100,
|
|
2300
2327
|
height: i = 100,
|
|
2301
2328
|
fill: a = "yellow"
|
|
2302
|
-
} = h, o =
|
|
2329
|
+
} = h, o = _(h, [
|
|
2303
2330
|
"id",
|
|
2304
2331
|
"left",
|
|
2305
2332
|
"top",
|
|
@@ -2307,7 +2334,7 @@ class it {
|
|
|
2307
2334
|
"height",
|
|
2308
2335
|
"fill"
|
|
2309
2336
|
]);
|
|
2310
|
-
const { canvas: g } = this.editor, u = new
|
|
2337
|
+
const { canvas: g } = this.editor, u = new Ne(y({
|
|
2311
2338
|
id: e,
|
|
2312
2339
|
left: t,
|
|
2313
2340
|
top: s,
|
|
@@ -2315,10 +2342,10 @@ class it {
|
|
|
2315
2342
|
width: n,
|
|
2316
2343
|
height: i
|
|
2317
2344
|
}, o));
|
|
2318
|
-
return !t && !s && g.centerObject(u),
|
|
2345
|
+
return !t && !s && g.centerObject(u), c || (g.add(u), d || g.setActiveObject(u), g.renderAll()), u;
|
|
2319
2346
|
}
|
|
2320
2347
|
}
|
|
2321
|
-
class
|
|
2348
|
+
class dt {
|
|
2322
2349
|
/**
|
|
2323
2350
|
* @param options
|
|
2324
2351
|
* @param options.editor - экземпляр редактора с доступом к canvas
|
|
@@ -2333,7 +2360,7 @@ class at {
|
|
|
2333
2360
|
copy() {
|
|
2334
2361
|
return v(this, null, function* () {
|
|
2335
2362
|
const { canvas: e, errorManager: t } = this.editor, s = e.getActiveObject();
|
|
2336
|
-
if (!s) return;
|
|
2363
|
+
if (!s || s.locked) return;
|
|
2337
2364
|
try {
|
|
2338
2365
|
const g = yield s.clone(["format"]);
|
|
2339
2366
|
this.clipboard = g, e.fire("editor:object-copied", { object: g });
|
|
@@ -2370,10 +2397,10 @@ class at {
|
|
|
2370
2397
|
});
|
|
2371
2398
|
return;
|
|
2372
2399
|
}
|
|
2373
|
-
const i = s.toCanvasElement().toDataURL(), a = i.slice(5).split(";")[0], o = i.split(",")[1], d = atob(o),
|
|
2400
|
+
const i = s.toCanvasElement().toDataURL(), a = i.slice(5).split(";")[0], o = i.split(",")[1], d = atob(o), c = new Uint8Array(d.length);
|
|
2374
2401
|
for (let g = 0; g < d.length; g += 1)
|
|
2375
|
-
|
|
2376
|
-
const l = new Blob([
|
|
2402
|
+
c[g] = d.charCodeAt(g);
|
|
2403
|
+
const l = new Blob([c.buffer], { type: a }), h = new ClipboardItem({ [a]: l });
|
|
2377
2404
|
navigator.clipboard.write([h]).catch((g) => {
|
|
2378
2405
|
t.emitWarning({
|
|
2379
2406
|
origin: "ClipboardManager",
|
|
@@ -2390,28 +2417,35 @@ class at {
|
|
|
2390
2417
|
* @param event.clipboardData — данные из буфера обмена
|
|
2391
2418
|
* @param event.clipboardData.items — элементы буфера обмена
|
|
2392
2419
|
*/
|
|
2393
|
-
handlePasteEvent(
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
const d = new FileReader();
|
|
2401
|
-
d.onload = (r) => {
|
|
2402
|
-
r.target && this.editor.imageManager.importImage({ source: r.target.result });
|
|
2403
|
-
}, d.readAsDataURL(o);
|
|
2404
|
-
return;
|
|
2405
|
-
}
|
|
2406
|
-
const i = e.getData("text/html");
|
|
2407
|
-
if (i) {
|
|
2408
|
-
const r = new DOMParser().parseFromString(i, "text/html").querySelector("img");
|
|
2409
|
-
if (r != null && r.src) {
|
|
2410
|
-
t.importImage({ source: r.src });
|
|
2420
|
+
handlePasteEvent(t) {
|
|
2421
|
+
return v(this, arguments, function* ({ clipboardData: e }) {
|
|
2422
|
+
var d;
|
|
2423
|
+
if (!((d = e == null ? void 0 : e.items) != null && d.length)) return;
|
|
2424
|
+
const s = e.getData("text/plain");
|
|
2425
|
+
if (s && s.startsWith("application/image-editor:")) {
|
|
2426
|
+
this.paste();
|
|
2411
2427
|
return;
|
|
2412
2428
|
}
|
|
2413
|
-
|
|
2414
|
-
|
|
2429
|
+
const { imageManager: n } = this.editor, { items: i } = e, a = i[i.length - 1];
|
|
2430
|
+
if (a.type !== "text/html") {
|
|
2431
|
+
const c = a.getAsFile();
|
|
2432
|
+
if (!c) return;
|
|
2433
|
+
const l = new FileReader();
|
|
2434
|
+
l.onload = (h) => {
|
|
2435
|
+
h.target && this.editor.imageManager.importImage({ source: h.target.result });
|
|
2436
|
+
}, l.readAsDataURL(c);
|
|
2437
|
+
return;
|
|
2438
|
+
}
|
|
2439
|
+
const o = e.getData("text/html");
|
|
2440
|
+
if (o) {
|
|
2441
|
+
const h = new DOMParser().parseFromString(o, "text/html").querySelector("img");
|
|
2442
|
+
if (h != null && h.src) {
|
|
2443
|
+
n.importImage({ source: h.src });
|
|
2444
|
+
return;
|
|
2445
|
+
}
|
|
2446
|
+
}
|
|
2447
|
+
this.paste();
|
|
2448
|
+
});
|
|
2415
2449
|
}
|
|
2416
2450
|
/**
|
|
2417
2451
|
* Вставка объекта
|
|
@@ -2427,13 +2461,13 @@ class at {
|
|
|
2427
2461
|
left: t.left + 10,
|
|
2428
2462
|
top: t.top + 10,
|
|
2429
2463
|
evented: !0
|
|
2430
|
-
}), t instanceof
|
|
2464
|
+
}), t instanceof p ? (t.canvas = e, t.forEachObject((s) => {
|
|
2431
2465
|
e.add(s);
|
|
2432
2466
|
})) : e.add(t), e.setActiveObject(t), e.requestRenderAll(), e.fire("editor:object-pasted", { object: t });
|
|
2433
2467
|
});
|
|
2434
2468
|
}
|
|
2435
2469
|
}
|
|
2436
|
-
class
|
|
2470
|
+
class G {
|
|
2437
2471
|
constructor({ editor: e }) {
|
|
2438
2472
|
this.editor = e;
|
|
2439
2473
|
}
|
|
@@ -2458,8 +2492,8 @@ class V {
|
|
|
2458
2492
|
lockSkewingY: !0,
|
|
2459
2493
|
locked: !0
|
|
2460
2494
|
};
|
|
2461
|
-
a.set(o), !t &&
|
|
2462
|
-
|
|
2495
|
+
a.set(o), !t && G._isGroupOrSelection(a) && a.getObjects().forEach((c) => {
|
|
2496
|
+
c.set(o);
|
|
2463
2497
|
}), n.renderAll(), s || i.saveState(), n.fire("editor:object-locked", {
|
|
2464
2498
|
object: a,
|
|
2465
2499
|
skipInnerObjects: t,
|
|
@@ -2486,7 +2520,7 @@ class V {
|
|
|
2486
2520
|
lockSkewingY: !1,
|
|
2487
2521
|
locked: !1
|
|
2488
2522
|
};
|
|
2489
|
-
i.set(a),
|
|
2523
|
+
i.set(a), G._isGroupOrSelection(i) && i.getObjects().forEach((o) => {
|
|
2490
2524
|
o.set(a);
|
|
2491
2525
|
}), s.renderAll(), t || n.saveState(), s.fire("editor:object-unlocked", {
|
|
2492
2526
|
object: i,
|
|
@@ -2494,10 +2528,10 @@ class V {
|
|
|
2494
2528
|
});
|
|
2495
2529
|
}
|
|
2496
2530
|
static _isGroupOrSelection(e) {
|
|
2497
|
-
return e instanceof
|
|
2531
|
+
return e instanceof p || e instanceof $;
|
|
2498
2532
|
}
|
|
2499
2533
|
}
|
|
2500
|
-
class
|
|
2534
|
+
class lt {
|
|
2501
2535
|
constructor({ editor: e }) {
|
|
2502
2536
|
this.editor = e;
|
|
2503
2537
|
}
|
|
@@ -2515,8 +2549,8 @@ class ot {
|
|
|
2515
2549
|
const { canvas: s, historyManager: n } = this.editor;
|
|
2516
2550
|
n.suspendHistory();
|
|
2517
2551
|
const i = e || s.getActiveObject();
|
|
2518
|
-
if (!i || !(i instanceof
|
|
2519
|
-
const a = i.getObjects(), o = new
|
|
2552
|
+
if (!i || !(i instanceof p)) return;
|
|
2553
|
+
const a = i.getObjects(), o = new $(a);
|
|
2520
2554
|
a.forEach((d) => s.remove(d)), o.set("id", `${o.type}-${L()}`), s.add(o), s.setActiveObject(o), s.renderAll(), n.resumeHistory(), t || n.saveState(), s.fire("editor:objects-grouped", {
|
|
2521
2555
|
object: i,
|
|
2522
2556
|
group: o,
|
|
@@ -2537,10 +2571,10 @@ class ot {
|
|
|
2537
2571
|
const { canvas: s, historyManager: n } = this.editor;
|
|
2538
2572
|
n.suspendHistory();
|
|
2539
2573
|
const i = e || s.getActiveObject();
|
|
2540
|
-
if (!(i instanceof
|
|
2574
|
+
if (!(i instanceof $)) return;
|
|
2541
2575
|
const a = i.removeAll();
|
|
2542
2576
|
s.remove(i), a.forEach((d) => s.add(d));
|
|
2543
|
-
const o = new
|
|
2577
|
+
const o = new p(a, {
|
|
2544
2578
|
canvas: s
|
|
2545
2579
|
});
|
|
2546
2580
|
s.setActiveObject(o), s.renderAll(), n.resumeHistory(), t || n.saveState(), s.fire("editor:objects-ungrouped", {
|
|
@@ -2550,7 +2584,7 @@ class ot {
|
|
|
2550
2584
|
});
|
|
2551
2585
|
}
|
|
2552
2586
|
}
|
|
2553
|
-
class
|
|
2587
|
+
class ht {
|
|
2554
2588
|
constructor({ editor: e }) {
|
|
2555
2589
|
this.editor = e;
|
|
2556
2590
|
}
|
|
@@ -2561,11 +2595,11 @@ class rt {
|
|
|
2561
2595
|
selectAll() {
|
|
2562
2596
|
const { canvas: e, canvasManager: t, objectLockManager: s } = this.editor;
|
|
2563
2597
|
e.discardActiveObject();
|
|
2564
|
-
const n = t.getObjects(), i = n.some((o) => o.locked), a = n.length > 1 ? new
|
|
2598
|
+
const n = t.getObjects(), i = n.some((o) => o.locked), a = n.length > 1 ? new p(t.getObjects(), { canvas: e }) : n[0];
|
|
2565
2599
|
i && s.lockObject({ object: a, skipInnerObjects: !0, withoutSave: !0 }), e.setActiveObject(a), e.requestRenderAll(), e.fire("editor:all-objects-selected", { selected: a });
|
|
2566
2600
|
}
|
|
2567
2601
|
}
|
|
2568
|
-
class
|
|
2602
|
+
class gt {
|
|
2569
2603
|
constructor({ editor: e }) {
|
|
2570
2604
|
this.editor = e;
|
|
2571
2605
|
}
|
|
@@ -2593,7 +2627,7 @@ class ct {
|
|
|
2593
2627
|
}));
|
|
2594
2628
|
}
|
|
2595
2629
|
}
|
|
2596
|
-
const
|
|
2630
|
+
const ut = {
|
|
2597
2631
|
IMAGE_MANAGER: {
|
|
2598
2632
|
/**
|
|
2599
2633
|
* Некорректный Content-Type изображения
|
|
@@ -2655,7 +2689,7 @@ const dt = {
|
|
|
2655
2689
|
REDO_ERROR: "REDO_ERROR"
|
|
2656
2690
|
}
|
|
2657
2691
|
};
|
|
2658
|
-
class
|
|
2692
|
+
class X {
|
|
2659
2693
|
constructor({ editor: e }) {
|
|
2660
2694
|
this._buffer = [], this.editor = e;
|
|
2661
2695
|
}
|
|
@@ -2682,7 +2716,7 @@ class G {
|
|
|
2682
2716
|
* @fires editor:error
|
|
2683
2717
|
*/
|
|
2684
2718
|
emitError({ origin: e = "ImageEditor", method: t = "Unknown Method", code: s, data: n, message: i }) {
|
|
2685
|
-
if (!
|
|
2719
|
+
if (!X.isValidErrorCode(s)) {
|
|
2686
2720
|
console.warn("Неизвестный код ошибки: ", { code: s, origin: e, method: t });
|
|
2687
2721
|
return;
|
|
2688
2722
|
}
|
|
@@ -2711,7 +2745,7 @@ class G {
|
|
|
2711
2745
|
* @fires editor:warning
|
|
2712
2746
|
*/
|
|
2713
2747
|
emitWarning({ origin: e = "ImageEditor", method: t = "Unknown Method", code: s, message: n, data: i }) {
|
|
2714
|
-
if (!
|
|
2748
|
+
if (!X.isValidErrorCode(s)) {
|
|
2715
2749
|
console.warn("Неизвестный код предупреждения: ", { code: s, origin: e, method: t });
|
|
2716
2750
|
return;
|
|
2717
2751
|
}
|
|
@@ -2734,10 +2768,10 @@ class G {
|
|
|
2734
2768
|
* @returns true, если код допустим, иначе false
|
|
2735
2769
|
*/
|
|
2736
2770
|
static isValidErrorCode(e) {
|
|
2737
|
-
return e ? Object.values(
|
|
2771
|
+
return e ? Object.values(ut).some((t) => Object.values(t).includes(e)) : !1;
|
|
2738
2772
|
}
|
|
2739
2773
|
}
|
|
2740
|
-
class
|
|
2774
|
+
class ie {
|
|
2741
2775
|
/**
|
|
2742
2776
|
* Конструктор класса ImageEditor.
|
|
2743
2777
|
* @param canvasId - идентификатор канваса, в котором будет создан редактор
|
|
@@ -2762,13 +2796,13 @@ class ne {
|
|
|
2762
2796
|
canvasCSSHeight: a,
|
|
2763
2797
|
initialImage: o,
|
|
2764
2798
|
initialStateJSON: d,
|
|
2765
|
-
scaleType:
|
|
2799
|
+
scaleType: c,
|
|
2766
2800
|
_onReadyCallback: l
|
|
2767
2801
|
} = this.options;
|
|
2768
|
-
if (
|
|
2802
|
+
if (_e.apply(), this.canvas = new De(this.containerId, this.options), this.moduleLoader = new Te(), this.workerManager = new xe(), this.errorManager = new X({ editor: this }), this.historyManager = new Ke({ editor: this }), this.toolbar = new Je({ editor: this }), this.transformManager = new ot({ editor: this }), this.canvasManager = new at({ editor: this }), this.imageManager = new D({ editor: this }), this.layerManager = new V({ editor: this }), this.shapeManager = new ct({ editor: this }), this.interactionBlocker = new rt({ editor: this }), this.clipboardManager = new dt({ editor: this }), this.objectLockManager = new G({ editor: this }), this.groupingManager = new lt({ editor: this }), this.selectionManager = new ht({ editor: this }), this.deletionManager = new gt({ editor: this }), this._createMontageArea(), this._createClippingArea(), this.listeners = new R({ editor: this, options: this.options }), this.canvasManager.setEditorContainerWidth(e), this.canvasManager.setEditorContainerHeight(t), this.canvasManager.setCanvasWrapperWidth(s), this.canvasManager.setCanvasWrapperHeight(n), this.canvasManager.setCanvasCSSWidth(i), this.canvasManager.setCanvasCSSHeight(a), o != null && o.source) {
|
|
2769
2803
|
const {
|
|
2770
2804
|
source: h,
|
|
2771
|
-
scale: g = `image-${
|
|
2805
|
+
scale: g = `image-${c}`,
|
|
2772
2806
|
withoutSave: u = !0
|
|
2773
2807
|
} = o;
|
|
2774
2808
|
yield this.imageManager.importImage({ source: h, scale: g, withoutSave: u });
|
|
@@ -2788,7 +2822,7 @@ class ne {
|
|
|
2788
2822
|
this.montageArea = this.shapeManager.addRectangle({
|
|
2789
2823
|
width: e,
|
|
2790
2824
|
height: t,
|
|
2791
|
-
fill:
|
|
2825
|
+
fill: ie._createMosaicPattern(),
|
|
2792
2826
|
stroke: null,
|
|
2793
2827
|
strokeWidth: 0,
|
|
2794
2828
|
selectable: !1,
|
|
@@ -2838,13 +2872,13 @@ class ne {
|
|
|
2838
2872
|
const e = document.createElement("canvas");
|
|
2839
2873
|
e.width = 20, e.height = 20;
|
|
2840
2874
|
const t = e.getContext("2d");
|
|
2841
|
-
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
|
|
2875
|
+
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 Le({
|
|
2842
2876
|
source: e,
|
|
2843
2877
|
repeat: "repeat"
|
|
2844
2878
|
});
|
|
2845
2879
|
}
|
|
2846
2880
|
}
|
|
2847
|
-
const
|
|
2881
|
+
const Mt = {
|
|
2848
2882
|
/**
|
|
2849
2883
|
* Опции редактора
|
|
2850
2884
|
*/
|
|
@@ -2933,18 +2967,18 @@ const lt = {
|
|
|
2933
2967
|
resetObjectFitByDoubleClick: !0,
|
|
2934
2968
|
keyboardIgnoreSelectors: []
|
|
2935
2969
|
};
|
|
2936
|
-
function
|
|
2937
|
-
const t = y(y({},
|
|
2970
|
+
function vt(r, e = {}) {
|
|
2971
|
+
const t = y(y({}, Mt), e), s = document.getElementById(r);
|
|
2938
2972
|
if (!s)
|
|
2939
|
-
return Promise.reject(new Error(`Контейнер с ID "${
|
|
2973
|
+
return Promise.reject(new Error(`Контейнер с ID "${r}" не найден.`));
|
|
2940
2974
|
const n = document.createElement("canvas");
|
|
2941
|
-
return n.id = `${
|
|
2975
|
+
return n.id = `${r}-canvas`, s.appendChild(n), t.editorContainer = s, new Promise((i) => {
|
|
2942
2976
|
t._onReadyCallback = i;
|
|
2943
|
-
const a = new
|
|
2944
|
-
window[
|
|
2977
|
+
const a = new ie(n.id, t);
|
|
2978
|
+
window[r] = a;
|
|
2945
2979
|
});
|
|
2946
2980
|
}
|
|
2947
2981
|
export {
|
|
2948
|
-
|
|
2982
|
+
vt as default
|
|
2949
2983
|
};
|
|
2950
2984
|
//# sourceMappingURL=main.js.map
|