@anu3ev/fabric-image-editor 0.1.47 → 0.1.49
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 +616 -726
- package/dist/{worker.js → worker.ts} +13 -3
- package/package.json +1 -1
- package/readme.md +33 -32
package/dist/main.js
CHANGED
|
@@ -1,40 +1,41 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var ce =
|
|
1
|
+
var je = Object.defineProperty, fe = Object.defineProperties;
|
|
2
|
+
var be = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var H = Object.getOwnPropertySymbols;
|
|
4
|
+
var ce = Object.prototype.hasOwnProperty, de = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var re = (c, e, t) => e in c ? je(c, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : c[e] = t, f = (c, e) => {
|
|
5
6
|
for (var t in e || (e = {}))
|
|
6
|
-
|
|
7
|
-
if (
|
|
8
|
-
for (var t of
|
|
9
|
-
|
|
10
|
-
return
|
|
11
|
-
};
|
|
12
|
-
var Y = (
|
|
7
|
+
ce.call(e, t) && re(c, t, e[t]);
|
|
8
|
+
if (H)
|
|
9
|
+
for (var t of H(e))
|
|
10
|
+
de.call(e, t) && re(c, t, e[t]);
|
|
11
|
+
return c;
|
|
12
|
+
}, le = (c, e) => fe(c, be(e));
|
|
13
|
+
var Y = (c, e) => {
|
|
13
14
|
var t = {};
|
|
14
|
-
for (var s in
|
|
15
|
-
|
|
16
|
-
if (
|
|
17
|
-
for (var s of
|
|
18
|
-
e.indexOf(s) < 0 &&
|
|
15
|
+
for (var s in c)
|
|
16
|
+
ce.call(c, s) && e.indexOf(s) < 0 && (t[s] = c[s]);
|
|
17
|
+
if (c != null && H)
|
|
18
|
+
for (var s of H(c))
|
|
19
|
+
e.indexOf(s) < 0 && de.call(c, s) && (t[s] = c[s]);
|
|
19
20
|
return t;
|
|
20
21
|
};
|
|
21
|
-
var
|
|
22
|
-
var
|
|
22
|
+
var I = (c, e, t) => new Promise((s, i) => {
|
|
23
|
+
var n = (d) => {
|
|
23
24
|
try {
|
|
24
25
|
o(t.next(d));
|
|
25
|
-
} catch (
|
|
26
|
-
|
|
26
|
+
} catch (r) {
|
|
27
|
+
i(r);
|
|
27
28
|
}
|
|
28
29
|
}, a = (d) => {
|
|
29
30
|
try {
|
|
30
31
|
o(t.throw(d));
|
|
31
|
-
} catch (
|
|
32
|
-
|
|
32
|
+
} catch (r) {
|
|
33
|
+
i(r);
|
|
33
34
|
}
|
|
34
|
-
}, o = (d) => d.done ? s(d.value) : Promise.resolve(d.value).then(
|
|
35
|
-
o((t = t.apply(
|
|
35
|
+
}, o = (d) => d.done ? s(d.value) : Promise.resolve(d.value).then(n, a);
|
|
36
|
+
o((t = t.apply(c, e)).next());
|
|
36
37
|
});
|
|
37
|
-
import { ActiveSelection as
|
|
38
|
+
import { ActiveSelection as v, util as R, controlsUtils as pe, InteractiveFabricObject as ye, loadSVGFromURL as Ie, FabricImage as U, Point as _, Rect as ve, Circle as Ae, Triangle as Se, Group as X, Canvas as Ce, Pattern as Ne } from "fabric";
|
|
38
39
|
import { create as De } from "jsondiffpatch";
|
|
39
40
|
import Le from "diff-match-patch";
|
|
40
41
|
var we = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", D = function() {
|
|
@@ -42,7 +43,7 @@ var we = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", D =
|
|
|
42
43
|
t += we[s[e] & 63];
|
|
43
44
|
return t;
|
|
44
45
|
};
|
|
45
|
-
class
|
|
46
|
+
class z {
|
|
46
47
|
/**
|
|
47
48
|
* Конструктор принимает редактор и опции.
|
|
48
49
|
* @param params
|
|
@@ -60,7 +61,7 @@ class R {
|
|
|
60
61
|
* @param params.options.adaptCanvasToContainerOnResize — адаптировать канвас к размерам контейнера при изменении размеров окна
|
|
61
62
|
*/
|
|
62
63
|
constructor({ editor: e, options: t = {} }) {
|
|
63
|
-
this.isDragging = !1, this.lastMouseX = 0, this.lastMouseY = 0, this.isUndoRedoKeyPressed = !1, this.isSpacePressed = !1, this.canvasDragging = !1, this.mouseWheelZooming = !1, this.bringToFrontOnSelection = !1, this.resetObjectFitByDoubleClick = !1, this.copyObjectsByHotkey = !1, this.pasteImageFromClipboard = !1, this.undoRedoByHotKeys = !1, this.selectAllByHotkey = !1, this.deleteObjectsByHotkey = !1, this.adaptCanvasToContainerOnResize = !1, this.editor = e, this.canvas = e.canvas, this.options = t, this.handleContainerResizeBound =
|
|
64
|
+
this.isDragging = !1, this.lastMouseX = 0, this.lastMouseY = 0, this.isUndoRedoKeyPressed = !1, this.isSpacePressed = !1, this.canvasDragging = !1, this.mouseWheelZooming = !1, this.bringToFrontOnSelection = !1, this.resetObjectFitByDoubleClick = !1, this.copyObjectsByHotkey = !1, this.pasteImageFromClipboard = !1, this.undoRedoByHotKeys = !1, this.selectAllByHotkey = !1, this.deleteObjectsByHotkey = !1, this.adaptCanvasToContainerOnResize = !1, this.editor = e, this.canvas = e.canvas, this.options = t, this.handleContainerResizeBound = z.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 = z.debounce(this.handleObjectModifiedHistory.bind(this), 300), this.handleObjectRotatingHistoryBound = z.debounce(this.handleObjectRotatingHistory.bind(this), 300), this.handleObjectAddedHistoryBound = this.handleObjectAddedHistory.bind(this), this.handleObjectRemovedHistoryBound = this.handleObjectRemovedHistory.bind(this), this.handleOverlayUpdateBound = this.handleOverlayUpdate.bind(this), this.handleCanvasDragStartBound = this.handleCanvasDragStart.bind(this), this.handleCanvasDraggingBound = this.handleCanvasDragging.bind(this), this.handleCanvasDragEndBound = this.handleCanvasDragEnd.bind(this), this.handleMouseWheelZoomBound = this.handleMouseWheelZoom.bind(this), this.handleBringToFrontBound = this.handleBringToFront.bind(this), this.handleResetObjectFitBound = this.handleResetObjectFit.bind(this), this.handleLockedSelectionBound = this._filterLockedSelection.bind(this), this.init();
|
|
64
65
|
}
|
|
65
66
|
/**
|
|
66
67
|
* Инициализация всех обработчиков согласно опциям.
|
|
@@ -70,15 +71,15 @@ class R {
|
|
|
70
71
|
adaptCanvasToContainerOnResize: e,
|
|
71
72
|
canvasDragging: t,
|
|
72
73
|
mouseWheelZooming: s,
|
|
73
|
-
bringToFrontOnSelection:
|
|
74
|
-
copyObjectsByHotkey:
|
|
74
|
+
bringToFrontOnSelection: i,
|
|
75
|
+
copyObjectsByHotkey: n,
|
|
75
76
|
pasteImageFromClipboard: a,
|
|
76
77
|
undoRedoByHotKeys: o,
|
|
77
78
|
selectAllByHotkey: d,
|
|
78
|
-
deleteObjectsByHotkey:
|
|
79
|
+
deleteObjectsByHotkey: r,
|
|
79
80
|
resetObjectFitByDoubleClick: l
|
|
80
81
|
} = this.options;
|
|
81
|
-
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),
|
|
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), i && (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 }), n && 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 }), r && 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);
|
|
82
83
|
}
|
|
83
84
|
/**
|
|
84
85
|
* При массовом выделении объектов удаляем из него залоченные.
|
|
@@ -88,19 +89,19 @@ class R {
|
|
|
88
89
|
*/
|
|
89
90
|
_filterLockedSelection({ selected: e, e: t }) {
|
|
90
91
|
if (!(e != null && e.length) || !(t instanceof MouseEvent) || e.length === 1 || !e.some((a) => a.locked)) return;
|
|
91
|
-
const
|
|
92
|
-
if (
|
|
92
|
+
const i = e.filter((a) => !a.locked);
|
|
93
|
+
if (i.length === 0) {
|
|
93
94
|
this.canvas.discardActiveObject();
|
|
94
95
|
return;
|
|
95
96
|
}
|
|
96
|
-
if (
|
|
97
|
-
this.canvas.setActiveObject(
|
|
97
|
+
if (i.length === 1) {
|
|
98
|
+
this.canvas.setActiveObject(i[0]);
|
|
98
99
|
return;
|
|
99
100
|
}
|
|
100
|
-
const
|
|
101
|
+
const n = new v(i, {
|
|
101
102
|
canvas: this.canvas
|
|
102
103
|
});
|
|
103
|
-
this.canvas.setActiveObject(
|
|
104
|
+
this.canvas.setActiveObject(n), this.canvas.requestRenderAll();
|
|
104
105
|
}
|
|
105
106
|
/**
|
|
106
107
|
* Обработчики для сохранения состояния редактора в истории.
|
|
@@ -141,8 +142,8 @@ class R {
|
|
|
141
142
|
* @param event.code — код клавиши
|
|
142
143
|
*/
|
|
143
144
|
handleCopyEvent(e) {
|
|
144
|
-
const { ctrlKey: t, metaKey: s, code:
|
|
145
|
-
!t && !s ||
|
|
145
|
+
const { ctrlKey: t, metaKey: s, code: i } = e;
|
|
146
|
+
!t && !s || i !== "KeyC" || (e.preventDefault(), this.editor.clipboardManager.copy());
|
|
146
147
|
}
|
|
147
148
|
/**
|
|
148
149
|
* Обработчик вставки объекта или изображения из буфера обмена.
|
|
@@ -159,9 +160,9 @@ class R {
|
|
|
159
160
|
* @param event.code — код клавиши
|
|
160
161
|
*/
|
|
161
162
|
handleUndoRedoEvent(e) {
|
|
162
|
-
return
|
|
163
|
-
const { ctrlKey: t, metaKey: s, code:
|
|
164
|
-
!t && !s ||
|
|
163
|
+
return I(this, null, function* () {
|
|
164
|
+
const { ctrlKey: t, metaKey: s, code: i, repeat: n } = e;
|
|
165
|
+
!t && !s || n || !/Mac/i.test(navigator.userAgent) && this.isUndoRedoKeyPressed || (i === "KeyZ" ? (e.preventDefault(), this.isUndoRedoKeyPressed = !0, yield this.editor.historyManager.undo()) : i === "KeyY" && (e.preventDefault(), this.isUndoRedoKeyPressed = !0, yield this.editor.historyManager.redo()));
|
|
165
166
|
});
|
|
166
167
|
}
|
|
167
168
|
/**
|
|
@@ -180,8 +181,8 @@ class R {
|
|
|
180
181
|
* @param event.code — код клавиши
|
|
181
182
|
*/
|
|
182
183
|
handleSelectAllEvent(e) {
|
|
183
|
-
const { ctrlKey: t, metaKey: s, code:
|
|
184
|
-
!t && !s ||
|
|
184
|
+
const { ctrlKey: t, metaKey: s, code: i } = e;
|
|
185
|
+
!t && !s || i !== "KeyA" || (e.preventDefault(), this.editor.selectionManager.selectAll());
|
|
185
186
|
}
|
|
186
187
|
/**
|
|
187
188
|
* Обработчик для удаления объектов (Delete).
|
|
@@ -199,8 +200,8 @@ class R {
|
|
|
199
200
|
*/
|
|
200
201
|
handleSpaceKeyDown(e) {
|
|
201
202
|
if (e.code !== "Space") return;
|
|
202
|
-
const { canvas: t, editor: s, isSpacePressed:
|
|
203
|
-
|
|
203
|
+
const { canvas: t, editor: s, isSpacePressed: i, isDragging: n } = this;
|
|
204
|
+
i || n || (this.isSpacePressed = !0, e.preventDefault(), t.set({
|
|
204
205
|
selection: !1,
|
|
205
206
|
defaultCursor: "grab"
|
|
206
207
|
}), t.setCursor("grab"), s.canvasManager.getObjects().forEach((a) => {
|
|
@@ -298,14 +299,14 @@ class R {
|
|
|
298
299
|
*/
|
|
299
300
|
static debounce(e, t) {
|
|
300
301
|
let s = null;
|
|
301
|
-
return function(...
|
|
302
|
+
return function(...i) {
|
|
302
303
|
s !== null && clearTimeout(s), s = setTimeout(() => {
|
|
303
|
-
e.apply(this,
|
|
304
|
+
e.apply(this, i);
|
|
304
305
|
}, t);
|
|
305
306
|
};
|
|
306
307
|
}
|
|
307
308
|
}
|
|
308
|
-
class
|
|
309
|
+
class Ee {
|
|
309
310
|
/**
|
|
310
311
|
* Класс для динамической загрузки внешних модулей.
|
|
311
312
|
*/
|
|
@@ -323,56 +324,43 @@ class Oe {
|
|
|
323
324
|
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}"`));
|
|
324
325
|
}
|
|
325
326
|
}
|
|
326
|
-
class
|
|
327
|
+
class Oe {
|
|
327
328
|
/**
|
|
328
|
-
* @param
|
|
329
|
+
* @param scriptUrl — URL скрипта воркера.
|
|
329
330
|
* По-умолчанию использует файл рядом с этим модулем
|
|
330
331
|
*/
|
|
331
|
-
constructor() {
|
|
332
|
-
|
|
333
|
-
this.worker = new Worker(e, {
|
|
334
|
-
type: "module"
|
|
335
|
-
}), this._callbacks = /* @__PURE__ */ new Map(), this.worker.onmessage = this._handleMessage.bind(this);
|
|
332
|
+
constructor(e = new URL("" + new URL("worker.ts", import.meta.url).href, import.meta.url)) {
|
|
333
|
+
this.worker = new Worker(e, { type: "module" }), this._callbacks = /* @__PURE__ */ new Map(), this.worker.onmessage = this._handleMessage.bind(this);
|
|
336
334
|
}
|
|
337
335
|
/**
|
|
338
336
|
* Обработчик сообщений от воркера
|
|
339
|
-
* @param
|
|
340
|
-
* @param
|
|
341
|
-
* @param
|
|
342
|
-
* @param
|
|
343
|
-
* @param
|
|
344
|
-
* @param
|
|
345
|
-
* @returns
|
|
346
|
-
*/
|
|
347
|
-
_handleMessage(e) {
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
error: a
|
|
355
|
-
} = t, o = this._callbacks.get(s);
|
|
356
|
-
o && (n ? o.resolve(i) : o.reject(new Error(a)), this._callbacks.delete(s));
|
|
337
|
+
* @param data
|
|
338
|
+
* @param data.action - название действия
|
|
339
|
+
* @param data.requestId - уникальный идентификатор запроса
|
|
340
|
+
* @param data.success - успешность выполнения действия
|
|
341
|
+
* @param data.data - данные, которые вернул воркер
|
|
342
|
+
* @param data.error - ошибка, если она произошла
|
|
343
|
+
* @returns
|
|
344
|
+
*/
|
|
345
|
+
_handleMessage({ data: e }) {
|
|
346
|
+
const { requestId: t, success: s, data: i, error: n } = e, a = this._callbacks.get(t);
|
|
347
|
+
if (!a) {
|
|
348
|
+
console.warn(`No callback found for requestId: ${t}`);
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
s ? a.resolve(i) : a.reject(new Error(n)), this._callbacks.delete(t);
|
|
357
352
|
}
|
|
358
353
|
/**
|
|
359
354
|
* Универсальный метод отправки команды в воркер
|
|
360
|
-
* @param
|
|
361
|
-
* @param
|
|
362
|
-
* @param
|
|
363
|
-
* @returns
|
|
364
|
-
*/
|
|
365
|
-
post(e, t) {
|
|
366
|
-
|
|
367
|
-
return new Promise((
|
|
368
|
-
this._callbacks.set(n, {
|
|
369
|
-
resolve: i,
|
|
370
|
-
reject: a
|
|
371
|
-
}), this.worker.postMessage({
|
|
372
|
-
action: e,
|
|
373
|
-
payload: t,
|
|
374
|
-
requestId: n
|
|
375
|
-
}, s);
|
|
355
|
+
* @param action - название действия, которое нужно выполнить в воркере
|
|
356
|
+
* @param payload - данные, которые нужно отправить в воркер
|
|
357
|
+
* @param transferables - массив объектов, которые нужно передать в воркер
|
|
358
|
+
* @returns Promise, который будет выполнен, когда воркер вернет ответ
|
|
359
|
+
*/
|
|
360
|
+
post(e, t, s = []) {
|
|
361
|
+
const i = `${e}:${D(8)}`;
|
|
362
|
+
return new Promise((n, a) => {
|
|
363
|
+
this._callbacks.set(i, { resolve: n, reject: a }), this.worker.postMessage({ action: e, payload: t, requestId: i }, s);
|
|
376
364
|
});
|
|
377
365
|
}
|
|
378
366
|
/**
|
|
@@ -382,50 +370,50 @@ class Ee {
|
|
|
382
370
|
this.worker.terminate();
|
|
383
371
|
}
|
|
384
372
|
}
|
|
385
|
-
const C = 12, Te = 2,
|
|
386
|
-
function
|
|
387
|
-
const
|
|
388
|
-
|
|
373
|
+
const C = 12, Te = 2, Q = 8, J = 20, ke = 100, $ = 20, K = 8, xe = 100, q = 32, ee = 1, Be = "#2B2D33", te = "#3D8BF4", se = "#FFFFFF";
|
|
374
|
+
function W(c, e, t, s, i) {
|
|
375
|
+
const n = C, a = Te;
|
|
376
|
+
c.save(), c.translate(e, t), c.rotate(R.degreesToRadians(i.angle)), c.fillStyle = se, c.strokeStyle = te, c.lineWidth = ee, c.beginPath(), c.roundRect(-12 / 2, -12 / 2, n, n, a), c.fill(), c.stroke(), c.restore();
|
|
389
377
|
}
|
|
390
|
-
function he(
|
|
391
|
-
const
|
|
392
|
-
|
|
378
|
+
function he(c, e, t, s, i) {
|
|
379
|
+
const n = Q, a = J, o = ke;
|
|
380
|
+
c.save(), c.translate(e, t), c.rotate(R.degreesToRadians(i.angle)), c.fillStyle = se, c.strokeStyle = te, c.lineWidth = ee, c.beginPath(), c.roundRect(-8 / 2, -20 / 2, n, a, o), c.fill(), c.stroke(), c.restore();
|
|
393
381
|
}
|
|
394
|
-
function ge(
|
|
395
|
-
const
|
|
396
|
-
|
|
382
|
+
function ge(c, e, t, s, i) {
|
|
383
|
+
const n = $, a = K, o = xe;
|
|
384
|
+
c.save(), c.translate(e, t), c.rotate(R.degreesToRadians(i.angle)), c.fillStyle = se, c.strokeStyle = te, c.lineWidth = ee, c.beginPath(), c.roundRect(-20 / 2, -8 / 2, n, a, o), c.fill(), c.stroke(), c.restore();
|
|
397
385
|
}
|
|
398
|
-
const Ue = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTE4Ljc1IDQuMzc1djMuNzVhLjYyNS42MjUgMCAwIDEtLjYyNS42MjVoLTMuNzVhLjYyNS42MjUgMCAwIDEgMC0xLjI1aDIuMTRsLTIuMDc3LTEuOTAzLS4wMi0uMDE5YTYuMjUgNi4yNSAwIDEgMC0uMTMgOC45NjcuNjI2LjYyNiAwIDAgMSAuODYuOTA5QTcuNDU2IDcuNDU2IDAgMCAxIDEwIDE3LjVoLS4xMDNhNy41IDcuNSAwIDEgMSA1LjM5Ni0xMi44MTJMMTcuNSA2LjcwM1Y0LjM3NWEuNjI1LjYyNSAwIDAgMSAxLjI1IDBaIi8+PC9zdmc+",
|
|
399
|
-
|
|
400
|
-
function Ze(
|
|
401
|
-
const a =
|
|
402
|
-
|
|
386
|
+
const Ue = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTE4Ljc1IDQuMzc1djMuNzVhLjYyNS42MjUgMCAwIDEtLjYyNS42MjVoLTMuNzVhLjYyNS42MjUgMCAwIDEgMC0xLjI1aDIuMTRsLTIuMDc3LTEuOTAzLS4wMi0uMDE5YTYuMjUgNi4yNSAwIDEgMC0uMTMgOC45NjcuNjI2LjYyNiAwIDAgMSAuODYuOTA5QTcuNDU2IDcuNDU2IDAgMCAxIDEwIDE3LjVoLS4xMDNhNy41IDcuNSAwIDEgMSA1LjM5Ni0xMi44MTJMMTcuNSA2LjcwM1Y0LjM3NWEuNjI1LjYyNSAwIDAgMSAxLjI1IDBaIi8+PC9zdmc+", ue = new Image();
|
|
387
|
+
ue.src = Ue;
|
|
388
|
+
function Ze(c, e, t, s, i) {
|
|
389
|
+
const a = q / 2;
|
|
390
|
+
c.save(), c.translate(e, t), c.rotate(R.degreesToRadians(i.angle)), c.fillStyle = Be, c.beginPath(), c.arc(0, 0, a, 0, 2 * Math.PI), c.fill(), c.drawImage(ue, -16 / 2, -16 / 2, a, a), c.restore();
|
|
403
391
|
}
|
|
404
392
|
const ze = {
|
|
405
393
|
// Угловые точки
|
|
406
394
|
tl: {
|
|
407
|
-
render:
|
|
395
|
+
render: W,
|
|
408
396
|
sizeX: C,
|
|
409
397
|
sizeY: C,
|
|
410
398
|
offsetX: 0,
|
|
411
399
|
offsetY: 0
|
|
412
400
|
},
|
|
413
401
|
tr: {
|
|
414
|
-
render:
|
|
402
|
+
render: W,
|
|
415
403
|
sizeX: C,
|
|
416
404
|
sizeY: C,
|
|
417
405
|
offsetX: 0,
|
|
418
406
|
offsetY: 0
|
|
419
407
|
},
|
|
420
408
|
bl: {
|
|
421
|
-
render:
|
|
409
|
+
render: W,
|
|
422
410
|
sizeX: C,
|
|
423
411
|
sizeY: C,
|
|
424
412
|
offsetX: 0,
|
|
425
413
|
offsetY: 0
|
|
426
414
|
},
|
|
427
415
|
br: {
|
|
428
|
-
render:
|
|
416
|
+
render: W,
|
|
429
417
|
sizeX: C,
|
|
430
418
|
sizeY: C,
|
|
431
419
|
offsetX: 0,
|
|
@@ -434,38 +422,38 @@ const ze = {
|
|
|
434
422
|
// Середина вертикалей
|
|
435
423
|
ml: {
|
|
436
424
|
render: he,
|
|
437
|
-
sizeX:
|
|
438
|
-
sizeY:
|
|
425
|
+
sizeX: Q,
|
|
426
|
+
sizeY: J,
|
|
439
427
|
offsetX: 0,
|
|
440
428
|
offsetY: 0
|
|
441
429
|
},
|
|
442
430
|
mr: {
|
|
443
431
|
render: he,
|
|
444
|
-
sizeX:
|
|
445
|
-
sizeY:
|
|
432
|
+
sizeX: Q,
|
|
433
|
+
sizeY: J,
|
|
446
434
|
offsetX: 0,
|
|
447
435
|
offsetY: 0
|
|
448
436
|
},
|
|
449
437
|
// Середина горизонталей
|
|
450
438
|
mt: {
|
|
451
439
|
render: ge,
|
|
452
|
-
sizeX:
|
|
453
|
-
sizeY:
|
|
440
|
+
sizeX: $,
|
|
441
|
+
sizeY: K,
|
|
454
442
|
offsetX: 0,
|
|
455
443
|
offsetY: 0
|
|
456
444
|
},
|
|
457
445
|
mb: {
|
|
458
446
|
render: ge,
|
|
459
|
-
sizeX:
|
|
460
|
-
sizeY:
|
|
447
|
+
sizeX: $,
|
|
448
|
+
sizeY: K,
|
|
461
449
|
offsetX: 0,
|
|
462
450
|
offsetY: 0
|
|
463
451
|
},
|
|
464
452
|
// Специальный «rotate» контрол
|
|
465
453
|
mtr: {
|
|
466
454
|
render: Ze,
|
|
467
|
-
sizeX:
|
|
468
|
-
sizeY:
|
|
455
|
+
sizeX: q,
|
|
456
|
+
sizeY: q,
|
|
469
457
|
offsetX: 0,
|
|
470
458
|
offsetY: -32
|
|
471
459
|
}
|
|
@@ -480,38 +468,14 @@ class Re {
|
|
|
480
468
|
sizeY: s.sizeY,
|
|
481
469
|
offsetX: s.offsetX,
|
|
482
470
|
offsetY: s.offsetY
|
|
483
|
-
}), t === "mtr" && (e[t].cursorStyle = "grab", e[t].mouseDownHandler = (
|
|
471
|
+
}), t === "mtr" && (e[t].cursorStyle = "grab", e[t].mouseDownHandler = (n, a, o, d) => {
|
|
484
472
|
var l;
|
|
485
473
|
(l = a.target.canvas) == null || l.setCursor("grabbing");
|
|
486
474
|
});
|
|
487
475
|
}), ye.ownDefaults.controls = e;
|
|
488
476
|
}
|
|
489
477
|
}
|
|
490
|
-
|
|
491
|
-
function ue(r, e, t, s, n, i, a) {
|
|
492
|
-
try {
|
|
493
|
-
var o = r[i](a), d = o.value;
|
|
494
|
-
} catch (c) {
|
|
495
|
-
return void t(c);
|
|
496
|
-
}
|
|
497
|
-
o.done ? e(d) : Promise.resolve(d).then(s, n);
|
|
498
|
-
}
|
|
499
|
-
function Xe(r) {
|
|
500
|
-
return function() {
|
|
501
|
-
var e = this, t = arguments;
|
|
502
|
-
return new Promise(function(s, n) {
|
|
503
|
-
var i = r.apply(e, t);
|
|
504
|
-
function a(d) {
|
|
505
|
-
ue(i, s, n, a, o, "next", d);
|
|
506
|
-
}
|
|
507
|
-
function o(d) {
|
|
508
|
-
ue(i, s, n, a, o, "throw", d);
|
|
509
|
-
}
|
|
510
|
-
a(void 0);
|
|
511
|
-
});
|
|
512
|
-
};
|
|
513
|
-
}
|
|
514
|
-
const z = {
|
|
478
|
+
const He = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNNi44NzUgMi41YS42MjUuNjI1IDAgMCAwLS42MjUuNjI0VjYuMjVIMy4xMjVhLjYyNS42MjUgMCAwIDAtLjYyNS42MjV2MTBjMCAuMzQ1LjI4LjYyNS42MjUuNjI1aDEwYy4zNDUgMCAuNjI1LS4yOC42MjUtLjYyNXYtMy4xMjZoMy4xMjVjLjM0NSAwIC42MjUtLjI4LjYyNS0uNjI1di0xMGEuNjI1LjYyNSAwIDAgMC0uNjI1LS42MjVoLTEwWm02Ljg3NSAxMGgyLjVWMy43NUg3LjV2Mi41aDUuNjI1Yy4zNDUgMCAuNjI1LjI4LjYyNS42MjV2NS42MjRabS0xMCAzLjc1VjcuNWg4Ljc1djguNzVIMy43NVoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjwvc3ZnPg==", Ye = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMi41IDcuNWMwLS42OS41Ni0xLjI1IDEuMjUtMS4yNWgxMi41Yy42OSAwIDEuMjUuNTYgMS4yNSAxLjI1djguNzVjMCAuNjktLjU2IDEuMjUtMS4yNSAxLjI1SDMuNzVjLS42OSAwLTEuMjUtLjU2LTEuMjUtMS4yNVY3LjVabTEzLjc1IDBIMy43NXY4Ljc1aDEyLjVWNy41WiIgY2xpcC1ydWxlPSJldmVub2RkIi8+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMTAgMS44NzVhMi4xODggMi4xODggMCAwIDAtMi4xODggMi4xODh2Mi44MTJhLjYyNS42MjUgMCAxIDEtMS4yNSAwVjQuMDYyYTMuNDM3IDMuNDM3IDAgMSAxIDYuODc1IDB2Mi44MTNhLjYyNS42MjUgMCAxIDEtMS4yNSAwVjQuMDYyQTIuMTg4IDIuMTg4IDAgMCAwIDEwIDEuODc2WiIgY2xpcC1ydWxlPSJldmVub2RkIi8+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTEwIDEyLjgxM2EuOTM3LjkzNyAwIDEgMCAwLTEuODc1LjkzNy45MzcgMCAwIDAgMCAxLjg3NFoiLz48L3N2Zz4=", We = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTE2LjI1IDYuMjVINy41VjQuMzc1YTIuNSAyLjUgMCAwIDEgMi41LTIuNWMxLjIgMCAyLjI4MS44NiAyLjUxMiAyYS42MjUuNjI1IDAgMCAwIDEuMjI2LS4yNWMtLjM1NC0xLjczOC0xLjkyNS0zLTMuNzM4LTNhMy43NTQgMy43NTQgMCAwIDAtMy43NSAzLjc1VjYuMjVoLTIuNUExLjI1IDEuMjUgMCAwIDAgMi41IDcuNXY4Ljc1YTEuMjUgMS4yNSAwIDAgMCAxLjI1IDEuMjVoMTIuNWExLjI1IDEuMjUgMCAwIDAgMS4yNS0xLjI1VjcuNWExLjI1IDEuMjUgMCAwIDAtMS4yNS0xLjI1Wm0wIDEwSDMuNzVWNy41aDEyLjV2OC43NVptLTUuMzEzLTQuMzc1YS45MzcuOTM3IDAgMSAxLTEuODc0IDAgLjkzNy45MzcgMCAwIDEgMS44NzQgMFoiLz48L3N2Zz4K", _e = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTIuNSA4LjEyNSAxMCAxMi41bDcuNS00LjM3NUwxMCAzLjc1IDIuNSA4LjEyNVoiLz48cGF0aCBmaWxsPSIjZmZmIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik05LjY4NSAzLjIxYS42MjUuNjI1IDAgMCAxIC42MyAwbDcuNSA0LjM3NWEuNjI1LjYyNSAwIDAgMSAwIDEuMDhsLTcuNSA0LjM3NWEuNjI1LjYyNSAwIDAgMS0uNjMgMGwtNy41LTQuMzc1YS42MjUuNjI1IDAgMCAxIDAtMS4wOGw3LjUtNC4zNzVaTTMuNzQgOC4xMjUgMTAgMTEuNzc2bDYuMjYtMy42NTFMMTAgNC40NzQgMy43NCA4LjEyNVoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjxwYXRoIGZpbGw9IiNmZmYiIGZpbGwtcnVsZT0iZXZlbm9kZCIgZD0iTTUuNCA5LjQ2YS42MjUuNjI1IDAgMCAxIC42MyAwTDEwIDExLjc3NmwzLjk3LTIuMzE2YS42MjUuNjI1IDAgMCAxIC42MyAwbDMuMjE1IDEuODc1YS42MjUuNjI1IDAgMCAxIDAgMS4wOGwtNy41IDQuMzc1YS42MjUuNjI1IDAgMCAxLS42MyAwbC03LjUtNC4zNzVhLjYyNS42MjUgMCAwIDEgMC0xLjA4TDUuNCA5LjQ2Wm0tMS42NiAyLjQxNUwxMCAxNS41MjZsNi4yNi0zLjY1MS0xLjk3NC0xLjE1MS0zLjk3MSAyLjMxNmEuNjI1LjYyNSAwIDAgMS0uNjMgMGwtMy45Ny0yLjMxNi0xLjk3NSAxLjE1MVoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjwvc3ZnPg==", Pe = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNOS42ODUgMy4yMWEuNjI1LjYyNSAwIDAgMSAuNjMgMGw3LjUgNC4zNzVhLjYyNS42MjUgMCAwIDEgMCAxLjA4bC03LjUgNC4zNzVhLjYyNS42MjUgMCAwIDEtLjYzIDBsLTcuNS00LjM3NWEuNjI1LjYyNSAwIDAgMSAwLTEuMDhsNy41LTQuMzc1Wk0zLjc0IDguMTI1IDEwIDExLjc3Nmw2LjI2LTMuNjUxTDEwIDQuNDc0IDMuNzQgOC4xMjVaIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiLz48cGF0aCBmaWxsPSIjZmZmIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik01LjcxNCAxMCAxMCAxMi41bDQuMjg2LTIuNSAzLjIxNCAxLjg3NUwxMCAxNi4yNWwtNy41LTQuMzc1TDUuNzE0IDEwWiIgY2xpcC1ydWxlPSJldmVub2RkIi8+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNNS40IDkuNDZhLjYyNS42MjUgMCAwIDEgLjYzIDBMMTAgMTEuNzc2bDMuOTctMi4zMTZhLjYyNS42MjUgMCAwIDEgLjYzIDBsMy4yMTUgMS44NzVhLjYyNS42MjUgMCAwIDEgMCAxLjA4bC03LjUgNC4zNzVhLjYyNS42MjUgMCAwIDEtLjYzIDBsLTcuNS00LjM3NWEuNjI1LjYyNSAwIDAgMSAwLTEuMDhMNS40IDkuNDZabS0xLjY2IDIuNDE1TDEwIDE1LjUyNmw2LjI2LTMuNjUxLTEuOTc0LTEuMTUxLTMuOTcxIDIuMzE2YS42MjUuNjI1IDAgMCAxLS42MyAwbC0zLjk3LTIuMzE2LTEuOTc1IDEuMTUxWiIgY2xpcC1ydWxlPSJldmVub2RkIi8+PC9zdmc+", Fe = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0ibTIuNSA2LjI1IDcuNSA0LjM3NSA3LjUtNC4zNzVMMTAgMS44NzUgMi41IDYuMjVaIi8+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNOS42ODUgMS4zMzVhLjYyNS42MjUgMCAwIDEgLjYzIDBsNy41IDQuMzc1YS42MjUuNjI1IDAgMCAxIDAgMS4wOGwtNy41IDQuMzc1YS42MjUuNjI1IDAgMCAxLS42MyAwbC03LjUtNC4zNzVhLjYyNS42MjUgMCAwIDEgMC0xLjA4bDcuNS00LjM3NVpNMy43NCA2LjI1IDEwIDkuOTAxbDYuMjYtMy42NTFMMTAgMi41OTkgMy43NCA2LjI1WiIgY2xpcC1ydWxlPSJldmVub2RkIi8+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNNS40IDExLjMzNWEuNjI1LjYyNSAwIDAgMSAuNjMgMEwxMCAxMy42NTFsMy45Ny0yLjMxNmEuNjI1LjYyNSAwIDAgMSAuNjMgMGwzLjIxNSAxLjg3NWEuNjI1LjYyNSAwIDAgMSAwIDEuMDhsLTcuNSA0LjM3NWEuNjI1LjYyNSAwIDAgMS0uNjMgMGwtNy41LTQuMzc1YS42MjUuNjI1IDAgMCAxIDAtMS4wOEw1LjQgMTEuMzM1Wk0zLjc0IDEzLjc1IDEwIDE3LjQwMWw2LjI2LTMuNjUxLTEuOTc0LTEuMTUxLTMuOTcxIDIuMzE2YS42MjUuNjI1IDAgMCAxLS42MyAwbC0zLjk3LTIuMzE2TDMuNzQgMTMuNzVaIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiLz48cGF0aCBmaWxsPSIjZmZmIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik01LjQgNy41ODVhLjYyNS42MjUgMCAwIDEgLjYzIDBMMTAgOS45MDFsMy45Ny0yLjMxNmEuNjI1LjYyNSAwIDAgMSAuNjMgMGwzLjIxNSAxLjg3NWEuNjI1LjYyNSAwIDAgMSAwIDEuMDhsLTcuNSA0LjM3NWEuNjI1LjYyNSAwIDAgMS0uNjMgMGwtNy41LTQuMzc1YS42MjUuNjI1IDAgMCAxIDAtMS4wOEw1LjQgNy41ODVaTTMuNzQgMTAgMTAgMTMuNjUxIDE2LjI2IDEwbC0xLjk3NC0xLjE1MS0zLjk3MSAyLjMxNmEuNjI1LjYyNSAwIDAgMS0uNjMgMGwtMy45Ny0yLjMxNkwzLjc0IDEwWiIgY2xpcC1ydWxlPSJldmVub2RkIi8+PC9zdmc+", Ve = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMS45NiAxMy40MzVhLjYyNS42MjUgMCAwIDEgLjg1NS0uMjI1TDEwIDE3LjQwMWw3LjE4NS00LjE5YS42MjUuNjI1IDAgMCAxIC42MyAxLjA3OWwtNy41IDQuMzc1YS42MjUuNjI1IDAgMCAxLS42MyAwbC03LjUtNC4zNzVhLjYyNS42MjUgMCAwIDEtLjIyNS0uODU1Wk05LjY4NSAxLjMzNWEuNjI1LjYyNSAwIDAgMSAuNjMgMGw3LjUgNC4zNzVhLjYyNS42MjUgMCAwIDEgMCAxLjA4bC03LjUgNC4zNzVhLjYyNS42MjUgMCAwIDEtLjYzIDBsLTcuNS00LjM3NWEuNjI1LjYyNSAwIDAgMSAwLTEuMDhsNy41LTQuMzc1Wk0zLjc0IDYuMjUgMTAgOS45MDFsNi4yNi0zLjY1MUwxMCAyLjU5OSAzLjc0IDYuMjVaIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiLz48cGF0aCBmaWxsPSIjZmZmIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGQ9Im01LjcxNCAxMS44NzUgNC4yODYgMi41IDQuMjg2LTIuNUwxNy41IDEzLjc1IDEwIDE4LjEyNSAyLjUgMTMuNzVsMy4yMTQtMS44NzVaIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiLz48cGF0aCBmaWxsPSIjZmZmIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik01LjQgMTEuMzM1YS42MjUuNjI1IDAgMCAxIC42MyAwTDEwIDEzLjY1MWwzLjk3LTIuMzE2YS42MjUuNjI1IDAgMCAxIC42MyAwbDMuMjE1IDEuODc1YS42MjUuNjI1IDAgMCAxIDAgMS4wOGwtNy41IDQuMzc1YS42MjUuNjI1IDAgMCAxLS42MyAwbC03LjUtNC4zNzVhLjYyNS42MjUgMCAwIDEgMC0xLjA4TDUuNCAxMS4zMzVaTTMuNzQgMTMuNzUgMTAgMTcuNDAxbDYuMjYtMy42NTEtMS45NzQtMS4xNTEtMy45NzEgMi4zMTZhLjYyNS42MjUgMCAwIDEtLjYzIDBsLTMuOTctMi4zMTZMMy43NCAxMy43NVoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjxwYXRoIGZpbGw9IiNmZmYiIGZpbGwtcnVsZT0iZXZlbm9kZCIgZD0iTTUuNCA3LjU4NWEuNjI1LjYyNSAwIDAgMSAuNjMgMEwxMCA5LjkwMWwzLjk3LTIuMzE2YS42MjUuNjI1IDAgMCAxIC42MyAwbDMuMjE1IDEuODc1YS42MjUuNjI1IDAgMCAxIDAgMS4wOGwtNy41IDQuMzc1YS42MjUuNjI1IDAgMCAxLS42MyAwbC03LjUtNC4zNzVhLjYyNS42MjUgMCAwIDEgMC0xLjA4TDUuNCA3LjU4NVpNMy43NCAxMCAxMCAxMy42NTEgMTYuMjYgMTBsLTEuOTc0LTEuMTUxLTMuOTcxIDIuMzE2YS42MjUuNjI1IDAgMCAxLS42MyAwbC0zLjk3LTIuMzE2TDMuNzQgMTBaIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiLz48L3N2Zz4=", Ge = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI0VDNEU0MCIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNOC4xMjUgMS4yNUExLjg3NSAxLjg3NSAwIDAgMCA2LjI1IDMuMTI1di42MjVIMy4xMjVhLjYyNS42MjUgMCAwIDAgMCAxLjI1aC42MjV2MTEuMjVBMS4yNSAxLjI1IDAgMCAwIDUgMTcuNWgxMGExLjI1IDEuMjUgMCAwIDAgMS4yNS0xLjI1VjVoLjYyNWEuNjI1LjYyNSAwIDAgMCAwLTEuMjVIMTMuNzV2LS42MjVhMS44NzUgMS44NzUgMCAwIDAtMS44NzUtMS44NzVoLTMuNzVabTQuMzc1IDIuNXYtLjYyNWEuNjI1LjYyNSAwIDAgMC0uNjI1LS42MjVoLTMuNzVhLjYyNS42MjUgMCAwIDAtLjYyNS42MjV2LjYyNWg1Wk01IDE2LjI1VjVoMTB2MTEuMjVINVpNOC4xMjUgNy41Yy4zNDUgMCAuNjI1LjI4LjYyNS42MjV2NWEuNjI1LjYyNSAwIDEgMS0xLjI1IDB2LTVjMC0uMzQ1LjI4LS42MjUuNjI1LS42MjVabTQuMzc1IDUuNjI1di01YS42MjUuNjI1IDAgMCAwLTEuMjUgMHY1YS42MjUuNjI1IDAgMSAwIDEuMjUgMFoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjwvc3ZnPg==", Z = {
|
|
515
479
|
style: {
|
|
516
480
|
position: "absolute",
|
|
517
481
|
display: "none",
|
|
@@ -546,263 +510,189 @@ const z = {
|
|
|
546
510
|
name: "Разблокировать",
|
|
547
511
|
handle: "unlock"
|
|
548
512
|
}],
|
|
549
|
-
actions: [
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
513
|
+
actions: [
|
|
514
|
+
{
|
|
515
|
+
name: "Создать копию",
|
|
516
|
+
handle: "copyPaste"
|
|
517
|
+
},
|
|
518
|
+
{
|
|
519
|
+
name: "Заблокировать",
|
|
520
|
+
handle: "lock"
|
|
521
|
+
},
|
|
522
|
+
{
|
|
523
|
+
name: "На передний план",
|
|
524
|
+
handle: "bringToFront"
|
|
525
|
+
},
|
|
526
|
+
{
|
|
527
|
+
name: "На задний план",
|
|
528
|
+
handle: "sendToBack"
|
|
529
|
+
},
|
|
530
|
+
{
|
|
531
|
+
name: "На один уровень вверх",
|
|
532
|
+
handle: "bringForward"
|
|
533
|
+
},
|
|
534
|
+
{
|
|
535
|
+
name: "На один уровень вниз",
|
|
536
|
+
handle: "sendBackwards"
|
|
537
|
+
},
|
|
538
|
+
{
|
|
539
|
+
name: "Удалить",
|
|
540
|
+
handle: "delete"
|
|
541
|
+
}
|
|
542
|
+
],
|
|
571
543
|
offsetTop: 50,
|
|
572
544
|
icons: {
|
|
573
545
|
copyPaste: He,
|
|
574
546
|
delete: Ge,
|
|
575
|
-
lock:
|
|
576
|
-
unlock:
|
|
547
|
+
lock: Ye,
|
|
548
|
+
unlock: We,
|
|
577
549
|
bringToFront: Fe,
|
|
578
550
|
sendToBack: Ve,
|
|
579
|
-
bringForward:
|
|
580
|
-
sendBackwards:
|
|
551
|
+
bringForward: _e,
|
|
552
|
+
sendBackwards: Pe
|
|
581
553
|
},
|
|
582
554
|
handlers: {
|
|
583
|
-
copyPaste: function() {
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
return r.apply(this, arguments);
|
|
589
|
-
}
|
|
590
|
-
return e;
|
|
591
|
-
}(),
|
|
592
|
-
delete: (r) => {
|
|
593
|
-
r.deletionManager.deleteSelectedObjects();
|
|
555
|
+
copyPaste: (c) => I(void 0, null, function* () {
|
|
556
|
+
yield c.clipboardManager.copy(), yield c.clipboardManager.paste();
|
|
557
|
+
}),
|
|
558
|
+
delete: (c) => {
|
|
559
|
+
c.deletionManager.deleteSelectedObjects();
|
|
594
560
|
},
|
|
595
|
-
lock: (
|
|
596
|
-
|
|
561
|
+
lock: (c) => {
|
|
562
|
+
c.objectLockManager.lockObject();
|
|
597
563
|
},
|
|
598
|
-
unlock: (
|
|
599
|
-
|
|
564
|
+
unlock: (c) => {
|
|
565
|
+
c.objectLockManager.unlockObject();
|
|
600
566
|
},
|
|
601
|
-
bringForward: (
|
|
602
|
-
|
|
567
|
+
bringForward: (c) => {
|
|
568
|
+
c.layerManager.bringForward();
|
|
603
569
|
},
|
|
604
|
-
bringToFront: (
|
|
605
|
-
|
|
570
|
+
bringToFront: (c) => {
|
|
571
|
+
c.layerManager.bringToFront();
|
|
606
572
|
},
|
|
607
|
-
sendToBack: (
|
|
608
|
-
|
|
573
|
+
sendToBack: (c) => {
|
|
574
|
+
c.layerManager.sendToBack();
|
|
609
575
|
},
|
|
610
|
-
sendBackwards: (
|
|
611
|
-
|
|
576
|
+
sendBackwards: (c) => {
|
|
577
|
+
c.layerManager.sendBackwards();
|
|
612
578
|
}
|
|
613
579
|
}
|
|
614
580
|
};
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
var s = Object.getOwnPropertySymbols(r);
|
|
619
|
-
e && (s = s.filter(function(n) {
|
|
620
|
-
return Object.getOwnPropertyDescriptor(r, n).enumerable;
|
|
621
|
-
})), t.push.apply(t, s);
|
|
581
|
+
class Xe {
|
|
582
|
+
constructor({ editor: e }) {
|
|
583
|
+
this.currentTarget = null, this.currentLocked = !1, this.isTransforming = !1, this.editor = e, this.canvas = e.canvas, this.options = e.options, this._initToolbar();
|
|
622
584
|
}
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
return r;
|
|
635
|
-
}
|
|
636
|
-
function Qe(r, e, t) {
|
|
637
|
-
return (e = Je(e)) in r ? Object.defineProperty(r, e, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : r[e] = t, r;
|
|
638
|
-
}
|
|
639
|
-
function Je(r) {
|
|
640
|
-
var e = $e(r, "string");
|
|
641
|
-
return typeof e == "symbol" ? e : e + "";
|
|
642
|
-
}
|
|
643
|
-
function $e(r, e) {
|
|
644
|
-
if (typeof r != "object" || !r) return r;
|
|
645
|
-
var t = r[Symbol.toPrimitive];
|
|
646
|
-
if (t !== void 0) {
|
|
647
|
-
var s = t.call(r, e);
|
|
648
|
-
if (typeof s != "object") return s;
|
|
649
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
650
|
-
}
|
|
651
|
-
return (e === "string" ? String : Number)(r);
|
|
652
|
-
}
|
|
653
|
-
class Ke {
|
|
654
|
-
/**
|
|
655
|
-
* @param {object} options
|
|
656
|
-
* @param {ImageEditor} options.editor - экземпляр редактора с доступом к canvas
|
|
657
|
-
*/
|
|
658
|
-
constructor(e) {
|
|
659
|
-
var {
|
|
660
|
-
editor: t
|
|
661
|
-
} = e;
|
|
662
|
-
if (this.options = t.options, !!this.options.showToolbar) {
|
|
663
|
-
this.editor = t, this.canvas = t.canvas;
|
|
664
|
-
var s = this.options.toolbar || {};
|
|
665
|
-
this.config = A(A(A({}, z), s), {}, {
|
|
666
|
-
style: A(A({}, z.style), s.style || {}),
|
|
667
|
-
btnStyle: A(A({}, z.btnStyle), s.btnStyle || {}),
|
|
668
|
-
icons: A(A({}, z.icons), s.icons || {}),
|
|
669
|
-
handlers: A(A({}, z.handlers), s.handlers || {})
|
|
670
|
-
}), 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 = () => {
|
|
671
|
-
this.el.style.display = "none";
|
|
672
|
-
}, this._createDOM(), this._bindEvents();
|
|
673
|
-
}
|
|
585
|
+
_initToolbar() {
|
|
586
|
+
if (!this.options.showToolbar) return;
|
|
587
|
+
const e = this.options.toolbar || {};
|
|
588
|
+
this.config = le(f(f({}, Z), e), {
|
|
589
|
+
style: f(f({}, Z.style), e.style || {}),
|
|
590
|
+
btnStyle: f(f({}, Z.btnStyle), e.btnStyle || {}),
|
|
591
|
+
icons: f(f({}, Z.icons), e.icons || {}),
|
|
592
|
+
handlers: f(f({}, Z.handlers), e.handlers || {})
|
|
593
|
+
}), 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 = () => {
|
|
594
|
+
this.el.style.display = "none";
|
|
595
|
+
}, this._createDOM(), this._bindEvents();
|
|
674
596
|
}
|
|
675
597
|
/**
|
|
676
598
|
* Создаёт DOM элемент панели инструментов и добавляет его в canvas
|
|
677
|
-
* @private
|
|
678
599
|
*/
|
|
679
600
|
_createDOM() {
|
|
680
|
-
|
|
681
|
-
style: e
|
|
682
|
-
} = this.config;
|
|
601
|
+
const { style: e } = this.config;
|
|
683
602
|
this.el = document.createElement("div"), Object.assign(this.el.style, e), this.canvas.wrapperEl.appendChild(this.el), this._onBtnOver = (t) => {
|
|
684
|
-
|
|
685
|
-
|
|
603
|
+
const i = t.target.closest("button");
|
|
604
|
+
i && Object.assign(i.style, this.config.btnHover);
|
|
686
605
|
}, this._onBtnOut = (t) => {
|
|
687
|
-
|
|
688
|
-
|
|
606
|
+
const i = t.target.closest("button");
|
|
607
|
+
i && Object.assign(i.style, this.config.btnStyle);
|
|
689
608
|
}, this.el.addEventListener("mouseover", this._onBtnOver), this.el.addEventListener("mouseout", this._onBtnOut);
|
|
690
609
|
}
|
|
691
610
|
/**
|
|
692
611
|
* Отрисовывает кнопки панели инструментов
|
|
693
|
-
* @
|
|
694
|
-
* @param
|
|
695
|
-
* @param
|
|
696
|
-
* @param {string} actions[].handle - название обработчика
|
|
612
|
+
* @param actions - массив действий для отрисовки
|
|
613
|
+
* @param actions[].name - название действия
|
|
614
|
+
* @param actions[].handle - название обработчика
|
|
697
615
|
*/
|
|
698
616
|
_renderButtons(e) {
|
|
699
|
-
var t = this;
|
|
700
617
|
this.el.innerHTML = "";
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
handlers: l
|
|
709
|
-
} = t.config, h = document.createElement("button");
|
|
710
|
-
h.innerHTML = d[o] ? '<img src="'.concat(d[o], '" title="').concat(a, '" />') : a, Object.assign(h.style, c), h.onclick = () => {
|
|
711
|
-
var g;
|
|
712
|
-
return (g = l[o]) === null || g === void 0 ? void 0 : g.call(l, t.editor);
|
|
713
|
-
}, t.el.appendChild(h);
|
|
714
|
-
};
|
|
715
|
-
for (var n of e)
|
|
716
|
-
s();
|
|
618
|
+
for (const t of e) {
|
|
619
|
+
const { name: s, handle: i } = t, { icons: n = {}, btnStyle: a, handlers: o = {} } = this.config, d = document.createElement("button");
|
|
620
|
+
d.innerHTML = n[i] ? `<img src="${n[i]}" title="${s}" />` : s, Object.assign(d.style, a), d.onclick = () => {
|
|
621
|
+
var r;
|
|
622
|
+
return (r = o[i]) == null ? void 0 : r.call(o, this.editor);
|
|
623
|
+
}, this.el.appendChild(d);
|
|
624
|
+
}
|
|
717
625
|
}
|
|
718
626
|
/**
|
|
719
627
|
* Привязывает события к canvas
|
|
720
|
-
* @private
|
|
721
628
|
*/
|
|
722
629
|
_bindEvents() {
|
|
723
|
-
this.canvas.on("mouse:down", this._onMouseDown), this.canvas.on("object:moving", this._onObjectMoving), this.canvas.on("object:scaling", this._onObjectScaling), this.canvas.on("object:rotating", this._onObjectRotating), this.canvas.on("mouse:up", this._onMouseUp), this.canvas.on("object:modified", this._onObjectModified), this.canvas.on("selection:created", this._onSelectionChange), this.canvas.on("selection:updated", this._onSelectionChange), this.canvas.on("
|
|
630
|
+
this.canvas.on("mouse:down", this._onMouseDown), this.canvas.on("object:moving", this._onObjectMoving), this.canvas.on("object:scaling", this._onObjectScaling), this.canvas.on("object:rotating", this._onObjectRotating), this.canvas.on("mouse:up", this._onMouseUp), this.canvas.on("object:modified", this._onObjectModified), this.canvas.on("selection:created", this._onSelectionChange), this.canvas.on("selection:updated", this._onSelectionChange), this.canvas.on("after:render", this._onSelectionChange), this.canvas.on("selection:cleared", this._onSelectionClear);
|
|
724
631
|
}
|
|
725
632
|
/**
|
|
726
633
|
* На время трансформации скрываем тулбар
|
|
727
|
-
* @private
|
|
728
|
-
* @param {Object} opt - объект события
|
|
729
634
|
*/
|
|
730
635
|
_handleMouseDown(e) {
|
|
731
636
|
var t;
|
|
732
|
-
(t = e.transform)
|
|
637
|
+
(t = e.transform) != null && t.actionPerformed && this._startTransform();
|
|
733
638
|
}
|
|
734
639
|
/**
|
|
735
640
|
* Начало трансформации объекта
|
|
736
|
-
* @private
|
|
737
641
|
*/
|
|
738
642
|
_startTransform() {
|
|
739
643
|
this.isTransforming = !0, this.el.style.display = "none";
|
|
740
644
|
}
|
|
741
645
|
/**
|
|
742
646
|
* Завершение трансформации объекта
|
|
743
|
-
* @private
|
|
744
647
|
*/
|
|
745
648
|
_endTransform() {
|
|
746
649
|
this.isTransforming = !1, this._updatePos();
|
|
747
650
|
}
|
|
748
651
|
/**
|
|
749
652
|
* Обновляет панель инструментов в зависимости от выделенного объекта и его состояния
|
|
750
|
-
* @private
|
|
751
653
|
*/
|
|
752
654
|
_updateToolbar() {
|
|
753
|
-
if (
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
}
|
|
759
|
-
var t = !!e.locked;
|
|
760
|
-
if (e !== this.currentTarget || t !== this.currentLocked) {
|
|
761
|
-
this.currentTarget = e, this.currentLocked = t;
|
|
762
|
-
var s = t ? this.config.lockedActions : this.config.actions;
|
|
763
|
-
this._renderButtons(s);
|
|
764
|
-
}
|
|
765
|
-
this._updatePos();
|
|
655
|
+
if (this.isTransforming) return;
|
|
656
|
+
const e = this.canvas.getActiveObject();
|
|
657
|
+
if (!e) {
|
|
658
|
+
this.el.style.display = "none", this.currentTarget = null;
|
|
659
|
+
return;
|
|
766
660
|
}
|
|
661
|
+
const t = !!e.locked;
|
|
662
|
+
if (e !== this.currentTarget || t !== this.currentLocked) {
|
|
663
|
+
this.currentTarget = e, this.currentLocked = t;
|
|
664
|
+
const s = t ? this.config.lockedActions : this.config.actions;
|
|
665
|
+
this._renderButtons(s != null ? s : []);
|
|
666
|
+
}
|
|
667
|
+
this._updatePos();
|
|
767
668
|
}
|
|
768
669
|
/**
|
|
769
670
|
* Обновляет позицию панели инструментов в зависимости от положения выделенного объекта
|
|
770
|
-
* @private
|
|
771
671
|
*/
|
|
772
672
|
_updatePos() {
|
|
773
|
-
if (
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
}
|
|
779
|
-
var {
|
|
780
|
-
el: t,
|
|
781
|
-
config: s,
|
|
782
|
-
canvas: n
|
|
783
|
-
} = this;
|
|
784
|
-
e.setCoords();
|
|
785
|
-
var i = n.getZoom(), [, , , , a, o] = n.viewportTransform, {
|
|
786
|
-
x: d
|
|
787
|
-
} = e.getCenterPoint(), {
|
|
788
|
-
top: c,
|
|
789
|
-
height: l
|
|
790
|
-
} = e.getBoundingRect(!1, !0), h = d * i + a, g = h - t.offsetWidth / 2, u = (c + l) * i + o + s.offsetTop;
|
|
791
|
-
Object.assign(t.style, {
|
|
792
|
-
left: "".concat(g, "px"),
|
|
793
|
-
top: "".concat(u, "px"),
|
|
794
|
-
display: "flex"
|
|
795
|
-
});
|
|
673
|
+
if (this.isTransforming) return;
|
|
674
|
+
const e = this.canvas.getActiveObject();
|
|
675
|
+
if (!e) {
|
|
676
|
+
this.el.style.display = "none";
|
|
677
|
+
return;
|
|
796
678
|
}
|
|
679
|
+
const { el: t, config: s, canvas: i } = this;
|
|
680
|
+
e.setCoords();
|
|
681
|
+
const n = i.getZoom(), [, , , , a, o] = i.viewportTransform, { x: d } = e.getCenterPoint(), { top: r, height: l } = e.getBoundingRect(), g = d * n + a - t.offsetWidth / 2, u = s.offsetTop || 0, m = (r + l) * n + o + u;
|
|
682
|
+
Object.assign(t.style, {
|
|
683
|
+
left: `${g}px`,
|
|
684
|
+
top: `${m}px`,
|
|
685
|
+
display: "flex"
|
|
686
|
+
});
|
|
797
687
|
}
|
|
798
688
|
/**
|
|
799
689
|
* Удаляет слушатели событий и DOM элемент панели инструментов
|
|
800
690
|
*/
|
|
801
691
|
destroy() {
|
|
802
|
-
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("
|
|
692
|
+
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();
|
|
803
693
|
}
|
|
804
694
|
}
|
|
805
|
-
class
|
|
695
|
+
class Qe {
|
|
806
696
|
constructor({ editor: e }) {
|
|
807
697
|
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();
|
|
808
698
|
}
|
|
@@ -868,10 +758,10 @@ class qe {
|
|
|
868
758
|
*/
|
|
869
759
|
getFullState() {
|
|
870
760
|
const { baseState: e, currentIndex: t, patches: s } = this;
|
|
871
|
-
let
|
|
872
|
-
for (let
|
|
873
|
-
|
|
874
|
-
return console.log("getFullState state",
|
|
761
|
+
let i = JSON.parse(JSON.stringify(e));
|
|
762
|
+
for (let n = 0; n < t; n += 1)
|
|
763
|
+
i = this.diffPatcher.patch(i, s[n].diff);
|
|
764
|
+
return console.log("getFullState state", i), i;
|
|
875
765
|
}
|
|
876
766
|
/**
|
|
877
767
|
* Сохраняем текущее состояние в виде диффа от последнего сохранённого полного состояния.
|
|
@@ -912,15 +802,15 @@ class qe {
|
|
|
912
802
|
* @fires editor:history-state-loaded
|
|
913
803
|
*/
|
|
914
804
|
loadStateFromFullState(e) {
|
|
915
|
-
return
|
|
805
|
+
return I(this, null, function* () {
|
|
916
806
|
if (!e) return;
|
|
917
807
|
console.log("loadStateFromFullState fullState", e);
|
|
918
|
-
const { canvas: t, canvasManager: s, interactionBlocker:
|
|
808
|
+
const { canvas: t, canvasManager: s, interactionBlocker: i } = this.editor, { width: n, height: a } = t;
|
|
919
809
|
yield t.loadFromJSON(e);
|
|
920
|
-
const o = t.getObjects().find((
|
|
921
|
-
o && (this.editor.montageArea = o, (
|
|
922
|
-
const d = t.getObjects().find((
|
|
923
|
-
d && (
|
|
810
|
+
const o = t.getObjects().find((r) => r.id === "montage-area");
|
|
811
|
+
o && (this.editor.montageArea = o, (n !== e.width || a !== e.height) && s.updateCanvasAndFitObjects());
|
|
812
|
+
const d = t.getObjects().find((r) => r.id === "overlay-mask");
|
|
813
|
+
d && (i.overlayMask = d, i.overlayMask.visible = !1), t.renderAll(), t.fire("editor:history-state-loaded", {
|
|
924
814
|
fullState: e,
|
|
925
815
|
currentIndex: this.currentIndex,
|
|
926
816
|
totalChangesCount: this.totalChangesCount,
|
|
@@ -935,7 +825,7 @@ class qe {
|
|
|
935
825
|
* @fires editor:undo
|
|
936
826
|
*/
|
|
937
827
|
undo() {
|
|
938
|
-
return
|
|
828
|
+
return I(this, null, function* () {
|
|
939
829
|
if (!this.skipHistory) {
|
|
940
830
|
if (this.currentIndex <= 0) {
|
|
941
831
|
console.log("Нет предыдущих состояний для отмены.");
|
|
@@ -972,7 +862,7 @@ class qe {
|
|
|
972
862
|
* @fires editor:redo
|
|
973
863
|
*/
|
|
974
864
|
redo() {
|
|
975
|
-
return
|
|
865
|
+
return I(this, null, function* () {
|
|
976
866
|
if (!this.skipHistory) {
|
|
977
867
|
if (this.currentIndex >= this.patches.length) {
|
|
978
868
|
console.log("Нет состояний для повтора.");
|
|
@@ -1005,7 +895,7 @@ class qe {
|
|
|
1005
895
|
});
|
|
1006
896
|
}
|
|
1007
897
|
}
|
|
1008
|
-
const
|
|
898
|
+
const Je = 0.1, $e = 2, Ke = 0.1, qe = 90, x = 16, B = 16, O = 4096, T = 4096;
|
|
1009
899
|
class N {
|
|
1010
900
|
constructor({ editor: e }) {
|
|
1011
901
|
this.editor = e, this.options = e.options, this._createdBlobUrls = [], this.acceptContentTypes = this.editor.options.acceptContentTypes, this.acceptFormats = this.getAllowedFormatsFromContentTypes();
|
|
@@ -1023,80 +913,80 @@ class N {
|
|
|
1023
913
|
* @returns возвращает Promise с объектом изображения или null в случае ошибки
|
|
1024
914
|
*/
|
|
1025
915
|
importImage(e) {
|
|
1026
|
-
return
|
|
916
|
+
return I(this, null, function* () {
|
|
1027
917
|
const {
|
|
1028
918
|
source: t,
|
|
1029
919
|
scale: s = `image-${this.options.scaleType}`,
|
|
1030
|
-
withoutSave:
|
|
920
|
+
withoutSave: i = !1
|
|
1031
921
|
} = e;
|
|
1032
922
|
if (!t) return null;
|
|
1033
|
-
const { canvas:
|
|
923
|
+
const { canvas: n, montageArea: a, transformManager: o, historyManager: d, errorManager: r } = this.editor, l = yield this.getContentType(t), h = N.getFormatFromContentType(l), { acceptContentTypes: g, acceptFormats: u } = this;
|
|
1034
924
|
if (!this.isAllowedContentType(l)) {
|
|
1035
|
-
const
|
|
1036
|
-
return
|
|
925
|
+
const m = `Неверный contentType для изображения: ${l}. Ожидается один из: ${this.acceptContentTypes.join(", ")}.`;
|
|
926
|
+
return r.emitError({
|
|
1037
927
|
origin: "ImageManager",
|
|
1038
928
|
method: "importImage",
|
|
1039
929
|
code: "INVALID_CONTENT_TYPE",
|
|
1040
|
-
message:
|
|
930
|
+
message: m,
|
|
1041
931
|
data: { source: t, format: h, contentType: l, acceptContentTypes: g, acceptFormats: u }
|
|
1042
932
|
}), null;
|
|
1043
933
|
}
|
|
1044
934
|
d.suspendHistory();
|
|
1045
935
|
try {
|
|
1046
|
-
let
|
|
936
|
+
let m, M;
|
|
1047
937
|
if (t instanceof File)
|
|
1048
|
-
|
|
938
|
+
m = URL.createObjectURL(t);
|
|
1049
939
|
else if (typeof t == "string") {
|
|
1050
|
-
const
|
|
1051
|
-
|
|
940
|
+
const A = yield (yield fetch(t, { mode: "cors" })).blob();
|
|
941
|
+
m = URL.createObjectURL(A);
|
|
1052
942
|
} else
|
|
1053
|
-
return
|
|
943
|
+
return r.emitError({
|
|
1054
944
|
origin: "ImageManager",
|
|
1055
945
|
method: "importImage",
|
|
1056
946
|
code: "INVALID_SOURCE_TYPE",
|
|
1057
947
|
message: "Неверный тип источника изображения. Ожидается URL или объект File.",
|
|
1058
948
|
data: { source: t, format: h, contentType: l, acceptContentTypes: g, acceptFormats: u }
|
|
1059
949
|
}), null;
|
|
1060
|
-
if (this._createdBlobUrls.push(
|
|
1061
|
-
const
|
|
1062
|
-
M =
|
|
950
|
+
if (this._createdBlobUrls.push(m), h === "svg") {
|
|
951
|
+
const y = yield Ie(m);
|
|
952
|
+
M = R.groupSVGElements(y.objects, y.options);
|
|
1063
953
|
} else
|
|
1064
|
-
M = yield
|
|
1065
|
-
const { width:
|
|
1066
|
-
if (M instanceof
|
|
1067
|
-
const
|
|
1068
|
-
let
|
|
1069
|
-
if (
|
|
1070
|
-
const w = yield this.resizeImageToBoundaries(
|
|
1071
|
-
this._createdBlobUrls.push(
|
|
1072
|
-
} else if (
|
|
1073
|
-
const w = yield this.resizeImageToBoundaries(
|
|
1074
|
-
this._createdBlobUrls.push(
|
|
954
|
+
M = yield U.fromURL(m, { crossOrigin: "anonymous" });
|
|
955
|
+
const { width: j, height: b } = M;
|
|
956
|
+
if (M instanceof U) {
|
|
957
|
+
const y = M.getElement();
|
|
958
|
+
let A = "";
|
|
959
|
+
if (y instanceof HTMLImageElement ? A = y.src : y instanceof HTMLCanvasElement && (A = y.toDataURL()), b > T || j > O) {
|
|
960
|
+
const w = yield this.resizeImageToBoundaries(A, "max"), E = URL.createObjectURL(w);
|
|
961
|
+
this._createdBlobUrls.push(E), M = yield U.fromURL(E, { crossOrigin: "anonymous" });
|
|
962
|
+
} else if (b < B || j < x) {
|
|
963
|
+
const w = yield this.resizeImageToBoundaries(A, "min"), E = URL.createObjectURL(w);
|
|
964
|
+
this._createdBlobUrls.push(E), M = yield U.fromURL(E, { crossOrigin: "anonymous" });
|
|
1075
965
|
}
|
|
1076
966
|
}
|
|
1077
967
|
if (M.set("id", `${M.type}-${D()}`), M.set("format", h), s === "scale-montage")
|
|
1078
968
|
this.editor.canvasManager.scaleMontageAreaToImage({ object: M, withoutSave: !0 });
|
|
1079
969
|
else {
|
|
1080
|
-
const { width:
|
|
1081
|
-
s === "image-contain" && w < 1 ? o.fitObject({ object: M, type: "contain", withoutSave: !0 }) : s === "image-cover" && (
|
|
970
|
+
const { width: y, height: A } = a, w = this.calculateScaleFactor({ imageObject: M, scaleType: s });
|
|
971
|
+
s === "image-contain" && w < 1 ? o.fitObject({ object: M, type: "contain", withoutSave: !0 }) : s === "image-cover" && (j > y || b > A) && o.fitObject({ object: M, type: "cover", withoutSave: !0 });
|
|
1082
972
|
}
|
|
1083
|
-
|
|
973
|
+
n.add(M), n.centerObject(M), n.setActiveObject(M), n.renderAll(), d.resumeHistory(), i || d.saveState();
|
|
1084
974
|
const L = {
|
|
1085
975
|
image: M,
|
|
1086
976
|
format: h,
|
|
1087
977
|
contentType: l,
|
|
1088
978
|
scale: s,
|
|
1089
|
-
withoutSave:
|
|
979
|
+
withoutSave: i,
|
|
1090
980
|
source: t
|
|
1091
981
|
};
|
|
1092
|
-
return
|
|
1093
|
-
} catch (
|
|
1094
|
-
return
|
|
982
|
+
return n.fire("editor:image-imported", L), L;
|
|
983
|
+
} catch (m) {
|
|
984
|
+
return r.emitError({
|
|
1095
985
|
origin: "ImageManager",
|
|
1096
986
|
method: "importImage",
|
|
1097
987
|
code: "IMPORT_FAILED",
|
|
1098
|
-
message: `Ошибка импорта изображения: ${
|
|
1099
|
-
data: { source: t, format: h, contentType: l, scale: s, withoutSave:
|
|
988
|
+
message: `Ошибка импорта изображения: ${m.message}`,
|
|
989
|
+
data: { source: t, format: h, contentType: l, scale: s, withoutSave: i }
|
|
1100
990
|
}), d.resumeHistory(), null;
|
|
1101
991
|
}
|
|
1102
992
|
});
|
|
@@ -1110,24 +1000,24 @@ class N {
|
|
|
1110
1000
|
* @returns возвращает Promise с Blob-объектом уменьшенного изображения
|
|
1111
1001
|
*/
|
|
1112
1002
|
resizeImageToBoundaries(e, t = "max") {
|
|
1113
|
-
return
|
|
1114
|
-
let s = `Размер изображения больше максимального размера канваса, поэтому оно будет уменьшено до максимальных размеров c сохранением пропорций: ${
|
|
1115
|
-
t === "min" && (s = `Размер изображения меньше минимального размера канваса, поэтому оно будет увеличено до минимальных размеров c сохранением пропорций: ${
|
|
1116
|
-
const
|
|
1003
|
+
return I(this, null, function* () {
|
|
1004
|
+
let s = `Размер изображения больше максимального размера канваса, поэтому оно будет уменьшено до максимальных размеров c сохранением пропорций: ${O}x${T}`;
|
|
1005
|
+
t === "min" && (s = `Размер изображения меньше минимального размера канваса, поэтому оно будет увеличено до минимальных размеров c сохранением пропорций: ${x}x${B}`);
|
|
1006
|
+
const i = {
|
|
1117
1007
|
dataURL: e,
|
|
1118
1008
|
sizeType: t,
|
|
1119
|
-
maxWidth:
|
|
1120
|
-
maxHeight:
|
|
1121
|
-
minWidth:
|
|
1122
|
-
minHeight:
|
|
1009
|
+
maxWidth: O,
|
|
1010
|
+
maxHeight: T,
|
|
1011
|
+
minWidth: x,
|
|
1012
|
+
minHeight: B
|
|
1123
1013
|
};
|
|
1124
1014
|
return this.editor.errorManager.emitWarning({
|
|
1125
1015
|
origin: "ImageManager",
|
|
1126
1016
|
method: "resizeImageToBoundaries",
|
|
1127
1017
|
code: "IMAGE_RESIZE_WARNING",
|
|
1128
1018
|
message: s,
|
|
1129
|
-
data:
|
|
1130
|
-
}), this.editor.workerManager.post("resizeImage",
|
|
1019
|
+
data: i
|
|
1020
|
+
}), this.editor.workerManager.post("resizeImage", i);
|
|
1131
1021
|
});
|
|
1132
1022
|
}
|
|
1133
1023
|
/**
|
|
@@ -1142,28 +1032,28 @@ class N {
|
|
|
1142
1032
|
* @fires editor:canvas-exported
|
|
1143
1033
|
*/
|
|
1144
1034
|
exportCanvasAsImageFile() {
|
|
1145
|
-
return
|
|
1035
|
+
return I(this, arguments, function* (e = {}) {
|
|
1146
1036
|
const {
|
|
1147
1037
|
fileName: t = "image.png",
|
|
1148
1038
|
contentType: s = "image/png",
|
|
1149
|
-
exportAsBase64:
|
|
1150
|
-
exportAsBlob:
|
|
1039
|
+
exportAsBase64: i = !1,
|
|
1040
|
+
exportAsBlob: n = !1
|
|
1151
1041
|
} = e, { canvas: a, montageArea: o, workerManager: d } = this.editor;
|
|
1152
1042
|
try {
|
|
1153
|
-
const
|
|
1043
|
+
const r = s === "application/pdf", l = r ? "image/jpg" : s, h = N.getFormatFromContentType(l);
|
|
1154
1044
|
o.setCoords();
|
|
1155
|
-
const { left: g, top: u, width:
|
|
1156
|
-
["image/jpg", "image/jpeg"].includes(l) && (
|
|
1157
|
-
const
|
|
1158
|
-
|
|
1159
|
-
const L =
|
|
1045
|
+
const { left: g, top: u, width: m, height: M } = o.getBoundingRect(), j = yield a.clone(["id", "format", "locked"]);
|
|
1046
|
+
["image/jpg", "image/jpeg"].includes(l) && (j.backgroundColor = "#ffffff");
|
|
1047
|
+
const b = j.getObjects().find((p) => p.id === o.id);
|
|
1048
|
+
b && (b.visible = !1), j.viewportTransform = [1, 0, 0, 1, -g, -u], j.setDimensions({ width: m, height: M }, { backstoreOnly: !0 }), j.renderAll();
|
|
1049
|
+
const L = j.getObjects().filter((p) => p.format).every((p) => p.format === "svg");
|
|
1160
1050
|
if (h === "svg" && L) {
|
|
1161
|
-
const
|
|
1162
|
-
|
|
1051
|
+
const p = j.toSVG();
|
|
1052
|
+
j.dispose();
|
|
1163
1053
|
const S = {
|
|
1164
|
-
image: N._exportSVGStringAsFile(
|
|
1165
|
-
exportAsBase64:
|
|
1166
|
-
exportAsBlob:
|
|
1054
|
+
image: N._exportSVGStringAsFile(p, {
|
|
1055
|
+
exportAsBase64: i,
|
|
1056
|
+
exportAsBlob: n,
|
|
1167
1057
|
fileName: t
|
|
1168
1058
|
}),
|
|
1169
1059
|
format: "svg",
|
|
@@ -1172,71 +1062,71 @@ class N {
|
|
|
1172
1062
|
};
|
|
1173
1063
|
return a.fire("editor:canvas-exported", S), S;
|
|
1174
1064
|
}
|
|
1175
|
-
const
|
|
1176
|
-
|
|
1177
|
-
S ?
|
|
1065
|
+
const y = yield new Promise((p, k) => {
|
|
1066
|
+
j.getElement().toBlob((S) => {
|
|
1067
|
+
S ? p(S) : k(new Error("Failed to create Blob from canvas"));
|
|
1178
1068
|
});
|
|
1179
1069
|
});
|
|
1180
|
-
if (
|
|
1181
|
-
const
|
|
1182
|
-
image:
|
|
1070
|
+
if (j.dispose(), n) {
|
|
1071
|
+
const p = {
|
|
1072
|
+
image: y,
|
|
1183
1073
|
format: h,
|
|
1184
1074
|
contentType: l,
|
|
1185
1075
|
fileName: t
|
|
1186
1076
|
};
|
|
1187
|
-
return a.fire("editor:canvas-exported",
|
|
1077
|
+
return a.fire("editor:canvas-exported", p), p;
|
|
1188
1078
|
}
|
|
1189
|
-
const
|
|
1079
|
+
const A = yield createImageBitmap(y), w = yield d.post(
|
|
1190
1080
|
"toDataURL",
|
|
1191
|
-
{ format: h, quality: 1, bitmap:
|
|
1192
|
-
[
|
|
1081
|
+
{ format: h, quality: 1, bitmap: A },
|
|
1082
|
+
[A]
|
|
1193
1083
|
);
|
|
1194
|
-
if (
|
|
1195
|
-
const
|
|
1196
|
-
orientation:
|
|
1084
|
+
if (r) {
|
|
1085
|
+
const k = m * 0.264583, S = M * 0.264583, Me = (yield this.editor.moduleLoader.loadModule("jspdf")).jsPDF, G = new Me({
|
|
1086
|
+
orientation: k > S ? "landscape" : "portrait",
|
|
1197
1087
|
unit: "mm",
|
|
1198
|
-
format: [
|
|
1088
|
+
format: [k, S]
|
|
1199
1089
|
});
|
|
1200
|
-
if (
|
|
1201
|
-
const
|
|
1202
|
-
image:
|
|
1090
|
+
if (G.addImage(String(w), "JPG", 0, 0, k, S), i) {
|
|
1091
|
+
const oe = {
|
|
1092
|
+
image: G.output("datauristring"),
|
|
1203
1093
|
format: "pdf",
|
|
1204
1094
|
contentType: "application/pdf",
|
|
1205
1095
|
fileName: t
|
|
1206
1096
|
};
|
|
1207
|
-
return a.fire("editor:canvas-exported",
|
|
1097
|
+
return a.fire("editor:canvas-exported", oe), oe;
|
|
1208
1098
|
}
|
|
1209
|
-
const
|
|
1210
|
-
image: new File([
|
|
1099
|
+
const me = G.output("blob"), ae = {
|
|
1100
|
+
image: new File([me], t, { type: "application/pdf" }),
|
|
1211
1101
|
format: "pdf",
|
|
1212
1102
|
contentType: "application/pdf",
|
|
1213
1103
|
fileName: t
|
|
1214
1104
|
};
|
|
1215
|
-
return a.fire("editor:canvas-exported",
|
|
1105
|
+
return a.fire("editor:canvas-exported", ae), ae;
|
|
1216
1106
|
}
|
|
1217
|
-
if (
|
|
1218
|
-
const
|
|
1107
|
+
if (i) {
|
|
1108
|
+
const p = {
|
|
1219
1109
|
image: w,
|
|
1220
1110
|
format: h,
|
|
1221
1111
|
contentType: l,
|
|
1222
1112
|
fileName: t
|
|
1223
1113
|
};
|
|
1224
|
-
return a.fire("editor:canvas-exported",
|
|
1114
|
+
return a.fire("editor:canvas-exported", p), p;
|
|
1225
1115
|
}
|
|
1226
|
-
const
|
|
1227
|
-
image: new File([
|
|
1116
|
+
const E = h === "svg" && !L ? t.replace(/\.[^/.]+$/, ".png") : t, ne = {
|
|
1117
|
+
image: new File([y], E, { type: l }),
|
|
1228
1118
|
format: h,
|
|
1229
1119
|
contentType: l,
|
|
1230
|
-
fileName:
|
|
1120
|
+
fileName: E
|
|
1231
1121
|
};
|
|
1232
|
-
return a.fire("editor:canvas-exported",
|
|
1233
|
-
} catch (
|
|
1122
|
+
return a.fire("editor:canvas-exported", ne), ne;
|
|
1123
|
+
} catch (r) {
|
|
1234
1124
|
return this.editor.errorManager.emitError({
|
|
1235
1125
|
origin: "ImageManager",
|
|
1236
1126
|
method: "exportCanvasAsImageFile",
|
|
1237
1127
|
code: "IMAGE_EXPORT_FAILED",
|
|
1238
|
-
message: `Ошибка экспорта изображения: ${
|
|
1239
|
-
data: { contentType: s, fileName: t, exportAsBase64:
|
|
1128
|
+
message: `Ошибка экспорта изображения: ${r.message}`,
|
|
1129
|
+
data: { contentType: s, fileName: t, exportAsBase64: i, exportAsBlob: n }
|
|
1240
1130
|
}), null;
|
|
1241
1131
|
}
|
|
1242
1132
|
});
|
|
@@ -1253,40 +1143,40 @@ class N {
|
|
|
1253
1143
|
* @fires editor:object-exported
|
|
1254
1144
|
*/
|
|
1255
1145
|
exportObjectAsImageFile() {
|
|
1256
|
-
return
|
|
1146
|
+
return I(this, arguments, function* (e = {}) {
|
|
1257
1147
|
const {
|
|
1258
1148
|
object: t,
|
|
1259
1149
|
fileName: s = "image.png",
|
|
1260
|
-
contentType:
|
|
1261
|
-
exportAsBase64:
|
|
1150
|
+
contentType: i = "image/png",
|
|
1151
|
+
exportAsBase64: n = !1,
|
|
1262
1152
|
exportAsBlob: a = !1
|
|
1263
|
-
} = e, { canvas: o, workerManager: d } = this.editor,
|
|
1264
|
-
if (!
|
|
1153
|
+
} = e, { canvas: o, workerManager: d } = this.editor, r = t || o.getActiveObject();
|
|
1154
|
+
if (!r)
|
|
1265
1155
|
return this.editor.errorManager.emitError({
|
|
1266
1156
|
origin: "ImageManager",
|
|
1267
1157
|
method: "exportObjectAsImageFile",
|
|
1268
1158
|
code: "NO_OBJECT_SELECTED",
|
|
1269
1159
|
message: "Не выбран объект для экспорта",
|
|
1270
|
-
data: { contentType:
|
|
1160
|
+
data: { contentType: i, fileName: s, exportAsBase64: n, exportAsBlob: a }
|
|
1271
1161
|
}), null;
|
|
1272
1162
|
try {
|
|
1273
|
-
const l = N.getFormatFromContentType(
|
|
1163
|
+
const l = N.getFormatFromContentType(i);
|
|
1274
1164
|
if (l === "svg") {
|
|
1275
|
-
const M =
|
|
1276
|
-
exportAsBase64:
|
|
1165
|
+
const M = r.toSVG(), j = N._exportSVGStringAsFile(M, {
|
|
1166
|
+
exportAsBase64: n,
|
|
1277
1167
|
exportAsBlob: a,
|
|
1278
1168
|
fileName: s
|
|
1279
|
-
}),
|
|
1280
|
-
object:
|
|
1281
|
-
image:
|
|
1169
|
+
}), b = {
|
|
1170
|
+
object: r,
|
|
1171
|
+
image: j,
|
|
1282
1172
|
format: l,
|
|
1283
1173
|
contentType: "image/svg+xml",
|
|
1284
1174
|
fileName: s.replace(/\.[^/.]+$/, ".svg")
|
|
1285
1175
|
};
|
|
1286
|
-
return o.fire("editor:object-exported",
|
|
1176
|
+
return o.fire("editor:object-exported", b), b;
|
|
1287
1177
|
}
|
|
1288
|
-
if (
|
|
1289
|
-
const M = yield createImageBitmap(
|
|
1178
|
+
if (n && r instanceof U) {
|
|
1179
|
+
const M = yield createImageBitmap(r.getElement()), j = yield d.post(
|
|
1290
1180
|
"toDataURL",
|
|
1291
1181
|
{
|
|
1292
1182
|
format: l,
|
|
@@ -1294,45 +1184,45 @@ class N {
|
|
|
1294
1184
|
bitmap: M
|
|
1295
1185
|
},
|
|
1296
1186
|
[M]
|
|
1297
|
-
),
|
|
1298
|
-
object:
|
|
1299
|
-
image:
|
|
1187
|
+
), b = {
|
|
1188
|
+
object: r,
|
|
1189
|
+
image: j,
|
|
1300
1190
|
format: l,
|
|
1301
|
-
contentType:
|
|
1191
|
+
contentType: i,
|
|
1302
1192
|
fileName: s
|
|
1303
1193
|
};
|
|
1304
|
-
return o.fire("editor:object-exported",
|
|
1194
|
+
return o.fire("editor:object-exported", b), b;
|
|
1305
1195
|
}
|
|
1306
|
-
const h =
|
|
1307
|
-
h.toBlob((
|
|
1308
|
-
|
|
1196
|
+
const h = r.toCanvasElement(), g = yield new Promise((M, j) => {
|
|
1197
|
+
h.toBlob((b) => {
|
|
1198
|
+
b ? M(b) : j(new Error("Failed to create Blob from canvas"));
|
|
1309
1199
|
});
|
|
1310
1200
|
});
|
|
1311
1201
|
if (a) {
|
|
1312
1202
|
const M = {
|
|
1313
|
-
object:
|
|
1203
|
+
object: r,
|
|
1314
1204
|
image: g,
|
|
1315
1205
|
format: l,
|
|
1316
|
-
contentType:
|
|
1206
|
+
contentType: i,
|
|
1317
1207
|
fileName: s
|
|
1318
1208
|
};
|
|
1319
1209
|
return o.fire("editor:object-exported", M), M;
|
|
1320
1210
|
}
|
|
1321
|
-
const u = new File([g], s, { type:
|
|
1322
|
-
object:
|
|
1211
|
+
const u = new File([g], s, { type: i }), m = {
|
|
1212
|
+
object: r,
|
|
1323
1213
|
image: u,
|
|
1324
1214
|
format: l,
|
|
1325
|
-
contentType:
|
|
1215
|
+
contentType: i,
|
|
1326
1216
|
fileName: s
|
|
1327
1217
|
};
|
|
1328
|
-
return o.fire("editor:object-exported",
|
|
1218
|
+
return o.fire("editor:object-exported", m), m;
|
|
1329
1219
|
} catch (l) {
|
|
1330
1220
|
return this.editor.errorManager.emitError({
|
|
1331
1221
|
origin: "ImageManager",
|
|
1332
1222
|
method: "exportObjectAsImageFile",
|
|
1333
1223
|
code: "IMAGE_EXPORT_FAILED",
|
|
1334
1224
|
message: `Ошибка экспорта объекта: ${l.message}`,
|
|
1335
|
-
data: { contentType:
|
|
1225
|
+
data: { contentType: i, fileName: s, exportAsBase64: n, exportAsBlob: a }
|
|
1336
1226
|
}), null;
|
|
1337
1227
|
}
|
|
1338
1228
|
});
|
|
@@ -1364,7 +1254,7 @@ class N {
|
|
|
1364
1254
|
* @public
|
|
1365
1255
|
*/
|
|
1366
1256
|
getContentType(e) {
|
|
1367
|
-
return
|
|
1257
|
+
return I(this, null, function* () {
|
|
1368
1258
|
return typeof e == "string" ? this.getContentTypeFromUrl(e) : e.type || "application/octet-stream";
|
|
1369
1259
|
});
|
|
1370
1260
|
}
|
|
@@ -1375,7 +1265,7 @@ class N {
|
|
|
1375
1265
|
* @public
|
|
1376
1266
|
*/
|
|
1377
1267
|
getContentTypeFromUrl(e) {
|
|
1378
|
-
return
|
|
1268
|
+
return I(this, null, function* () {
|
|
1379
1269
|
if (e.startsWith("data:")) {
|
|
1380
1270
|
const t = e.match(/^data:([^;]+)/);
|
|
1381
1271
|
return t ? t[1] : "application/octet-stream";
|
|
@@ -1399,11 +1289,11 @@ class N {
|
|
|
1399
1289
|
getContentTypeFromExtension(e) {
|
|
1400
1290
|
var t;
|
|
1401
1291
|
try {
|
|
1402
|
-
const
|
|
1292
|
+
const i = (t = new URL(e).pathname.split(".").pop()) == null ? void 0 : t.toLowerCase(), n = {};
|
|
1403
1293
|
return this.acceptContentTypes.forEach((a) => {
|
|
1404
1294
|
const o = N.getFormatFromContentType(a);
|
|
1405
|
-
o && (
|
|
1406
|
-
}),
|
|
1295
|
+
o && (n[o] = a);
|
|
1296
|
+
}), i && n[i] || "application/octet-stream";
|
|
1407
1297
|
} catch (s) {
|
|
1408
1298
|
return console.warn("Не удалось определить расширение из URL:", e, s), "application/octet-stream";
|
|
1409
1299
|
}
|
|
@@ -1421,8 +1311,8 @@ class N {
|
|
|
1421
1311
|
}) {
|
|
1422
1312
|
const { montageArea: s } = this.editor;
|
|
1423
1313
|
if (!s || !e) return 1;
|
|
1424
|
-
const
|
|
1425
|
-
return t === "contain" || t === "image-contain" ? Math.min(
|
|
1314
|
+
const i = s.width, n = s.height, { width: a, height: o } = e;
|
|
1315
|
+
return t === "contain" || t === "image-contain" ? Math.min(i / a, n / o) : t === "cover" || t === "image-cover" ? Math.max(i / a, n / o) : 1;
|
|
1426
1316
|
}
|
|
1427
1317
|
/**
|
|
1428
1318
|
* Преобразует SVG-строку в Blob, файл, или base64
|
|
@@ -1438,9 +1328,9 @@ class N {
|
|
|
1438
1328
|
static _exportSVGStringAsFile(e, {
|
|
1439
1329
|
exportAsBase64: t,
|
|
1440
1330
|
exportAsBlob: s,
|
|
1441
|
-
fileName:
|
|
1331
|
+
fileName: i = "image.svg"
|
|
1442
1332
|
} = {}) {
|
|
1443
|
-
return s ? new Blob([e], { type: "image/svg+xml" }) : t ? `data:image/svg+xml;base64,${window.btoa(encodeURIComponent(e))}` : new File([e],
|
|
1333
|
+
return s ? new Blob([e], { type: "image/svg+xml" }) : t ? `data:image/svg+xml;base64,${window.btoa(encodeURIComponent(e))}` : new File([e], i.replace(/\.[^/.]+$/, ".svg"), { type: "image/svg+xml" });
|
|
1444
1334
|
}
|
|
1445
1335
|
/**
|
|
1446
1336
|
* Извлекает чистый формат (subtype) из contentType,
|
|
@@ -1454,7 +1344,7 @@ class N {
|
|
|
1454
1344
|
return t ? t[1] : "";
|
|
1455
1345
|
}
|
|
1456
1346
|
}
|
|
1457
|
-
class
|
|
1347
|
+
class et {
|
|
1458
1348
|
/**
|
|
1459
1349
|
* @param options
|
|
1460
1350
|
* @param options.editor – экземпляр редактора
|
|
@@ -1471,25 +1361,25 @@ class it {
|
|
|
1471
1361
|
* @param options.adaptCanvasToContainer - Адаптировать канвас к контейнеру
|
|
1472
1362
|
* @fires editor:resolution-width-changed
|
|
1473
1363
|
*/
|
|
1474
|
-
setResolutionWidth(e, { preserveProportional: t, withoutSave: s, adaptCanvasToContainer:
|
|
1475
|
-
var
|
|
1364
|
+
setResolutionWidth(e, { preserveProportional: t, withoutSave: s, adaptCanvasToContainer: i } = {}) {
|
|
1365
|
+
var m;
|
|
1476
1366
|
if (!e) return;
|
|
1477
1367
|
const {
|
|
1478
|
-
canvas:
|
|
1368
|
+
canvas: n,
|
|
1479
1369
|
montageArea: a,
|
|
1480
1370
|
options: { canvasBackstoreWidth: o }
|
|
1481
|
-
} = this.editor, { width: d, height:
|
|
1482
|
-
if (!o || o === "auto" ||
|
|
1483
|
-
const M = l / d,
|
|
1484
|
-
this.setResolutionHeight(
|
|
1371
|
+
} = this.editor, { width: d, height: r } = a, l = Math.max(Math.min(Number(e), O), x);
|
|
1372
|
+
if (!o || o === "auto" || i ? this.adaptCanvasToContainer() : o ? this.setCanvasBackstoreWidth(Number(o)) : this.setCanvasBackstoreWidth(l), a.set({ width: l }), (m = n.clipPath) == null || m.set({ width: l }), t) {
|
|
1373
|
+
const M = l / d, j = r * M;
|
|
1374
|
+
this.setResolutionHeight(j);
|
|
1485
1375
|
return;
|
|
1486
1376
|
}
|
|
1487
|
-
const { left: h, top: g } = this.getObjectDefaultCoords(a), u =
|
|
1488
|
-
|
|
1377
|
+
const { left: h, top: g } = this.getObjectDefaultCoords(a), u = n.getZoom();
|
|
1378
|
+
n.setViewportTransform([u, 0, 0, u, h, g]), this.centerMontageArea(), s || this.editor.historyManager.saveState(), n.fire("editor:resolution-width-changed", {
|
|
1489
1379
|
width: l,
|
|
1490
1380
|
preserveProportional: t,
|
|
1491
1381
|
withoutSave: s,
|
|
1492
|
-
adaptCanvasToContainer:
|
|
1382
|
+
adaptCanvasToContainer: i
|
|
1493
1383
|
});
|
|
1494
1384
|
}
|
|
1495
1385
|
/**
|
|
@@ -1501,25 +1391,25 @@ class it {
|
|
|
1501
1391
|
* @param options.adaptCanvasToContainer - Адаптировать канвас к контейнеру
|
|
1502
1392
|
* @fires editor:resolution-height-changed
|
|
1503
1393
|
*/
|
|
1504
|
-
setResolutionHeight(e, { preserveProportional: t, withoutSave: s, adaptCanvasToContainer:
|
|
1505
|
-
var
|
|
1394
|
+
setResolutionHeight(e, { preserveProportional: t, withoutSave: s, adaptCanvasToContainer: i } = {}) {
|
|
1395
|
+
var m;
|
|
1506
1396
|
if (!e) return;
|
|
1507
1397
|
const {
|
|
1508
|
-
canvas:
|
|
1398
|
+
canvas: n,
|
|
1509
1399
|
montageArea: a,
|
|
1510
1400
|
options: { canvasBackstoreHeight: o }
|
|
1511
|
-
} = this.editor, { width: d, height:
|
|
1512
|
-
if (!o || o === "auto" ||
|
|
1513
|
-
const M = l /
|
|
1514
|
-
this.setResolutionWidth(
|
|
1401
|
+
} = this.editor, { width: d, height: r } = a, l = Math.max(Math.min(Number(e), T), B);
|
|
1402
|
+
if (!o || o === "auto" || i ? this.adaptCanvasToContainer() : o ? this.setCanvasBackstoreHeight(Number(o)) : this.setCanvasBackstoreHeight(l), a.set({ height: l }), (m = n.clipPath) == null || m.set({ height: l }), t) {
|
|
1403
|
+
const M = l / r, j = d * M;
|
|
1404
|
+
this.setResolutionWidth(j);
|
|
1515
1405
|
return;
|
|
1516
1406
|
}
|
|
1517
|
-
const { left: h, top: g } = this.getObjectDefaultCoords(a), u =
|
|
1518
|
-
|
|
1407
|
+
const { left: h, top: g } = this.getObjectDefaultCoords(a), u = n.getZoom();
|
|
1408
|
+
n.setViewportTransform([u, 0, 0, u, h, g]), this.centerMontageArea(), s || this.editor.historyManager.saveState(), n.fire("editor:resolution-height-changed", {
|
|
1519
1409
|
height: l,
|
|
1520
1410
|
preserveProportional: t,
|
|
1521
1411
|
withoutSave: s,
|
|
1522
|
-
adaptCanvasToContainer:
|
|
1412
|
+
adaptCanvasToContainer: i
|
|
1523
1413
|
});
|
|
1524
1414
|
}
|
|
1525
1415
|
/**
|
|
@@ -1528,16 +1418,16 @@ class it {
|
|
|
1528
1418
|
*/
|
|
1529
1419
|
centerMontageArea() {
|
|
1530
1420
|
var d;
|
|
1531
|
-
const { canvas: e, montageArea: t } = this.editor, s = e.getWidth(),
|
|
1421
|
+
const { canvas: e, montageArea: t } = this.editor, s = e.getWidth(), i = e.getHeight(), n = e.getZoom(), a = new _(s / 2, i / 2);
|
|
1532
1422
|
t.set({
|
|
1533
1423
|
left: s / 2,
|
|
1534
|
-
top:
|
|
1424
|
+
top: i / 2
|
|
1535
1425
|
}), (d = e.clipPath) == null || d.set({
|
|
1536
1426
|
left: s / 2,
|
|
1537
|
-
top:
|
|
1427
|
+
top: i / 2
|
|
1538
1428
|
}), e.renderAll();
|
|
1539
1429
|
const o = e.viewportTransform;
|
|
1540
|
-
o[4] = s / 2 - a.x *
|
|
1430
|
+
o[4] = s / 2 - a.x * n, o[5] = i / 2 - a.y * n, e.setViewportTransform(o), e.renderAll();
|
|
1541
1431
|
}
|
|
1542
1432
|
/**
|
|
1543
1433
|
* Метод для получения координат объекта с учетом текущего зума
|
|
@@ -1553,7 +1443,7 @@ class it {
|
|
|
1553
1443
|
code: "NO_ACTIVE_OBJECT",
|
|
1554
1444
|
message: "Не выбран объект для получения координат"
|
|
1555
1445
|
}), { left: 0, top: 0 };
|
|
1556
|
-
const { width:
|
|
1446
|
+
const { width: i, height: n } = s, a = t.getZoom(), o = (i - i * a) / 2, d = (n - n * a) / 2;
|
|
1557
1447
|
return { left: o, top: d };
|
|
1558
1448
|
}
|
|
1559
1449
|
/**
|
|
@@ -1561,7 +1451,7 @@ class it {
|
|
|
1561
1451
|
*/
|
|
1562
1452
|
setCanvasBackstoreWidth(e) {
|
|
1563
1453
|
if (!e || typeof e != "number") return;
|
|
1564
|
-
const t = Math.max(Math.min(e,
|
|
1454
|
+
const t = Math.max(Math.min(e, O), x);
|
|
1565
1455
|
this.editor.canvas.setDimensions({ width: t }, { backstoreOnly: !0 });
|
|
1566
1456
|
}
|
|
1567
1457
|
/**
|
|
@@ -1570,7 +1460,7 @@ class it {
|
|
|
1570
1460
|
*/
|
|
1571
1461
|
setCanvasBackstoreHeight(e) {
|
|
1572
1462
|
if (!e || typeof e != "number") return;
|
|
1573
|
-
const t = Math.max(Math.min(e,
|
|
1463
|
+
const t = Math.max(Math.min(e, T), B);
|
|
1574
1464
|
this.editor.canvas.setDimensions({ height: t }, { backstoreOnly: !0 });
|
|
1575
1465
|
}
|
|
1576
1466
|
/**
|
|
@@ -1579,8 +1469,8 @@ class it {
|
|
|
1579
1469
|
* с учётом минимальных и максимальных значений.
|
|
1580
1470
|
*/
|
|
1581
1471
|
adaptCanvasToContainer() {
|
|
1582
|
-
const { canvas: e } = this.editor, t = e.editorContainer, s = t.clientWidth,
|
|
1583
|
-
console.log("adaptCanvasToContainer newWidth",
|
|
1472
|
+
const { canvas: e } = this.editor, t = e.editorContainer, s = t.clientWidth, i = t.clientHeight, n = Math.max(Math.min(s, O), x), a = Math.max(Math.min(i, T), B);
|
|
1473
|
+
console.log("adaptCanvasToContainer newWidth", n), console.log("adaptCanvasToContainer newHeight", a), e.setDimensions({ width: n, height: a }, { backstoreOnly: !0 });
|
|
1584
1474
|
}
|
|
1585
1475
|
/**
|
|
1586
1476
|
* Обновляет размеры канваса и вписывает объекты в монтажную область.
|
|
@@ -1593,13 +1483,13 @@ class it {
|
|
|
1593
1483
|
selectionManager: t,
|
|
1594
1484
|
transformManager: s,
|
|
1595
1485
|
montageArea: {
|
|
1596
|
-
width:
|
|
1597
|
-
height:
|
|
1486
|
+
width: i,
|
|
1487
|
+
height: n
|
|
1598
1488
|
}
|
|
1599
1489
|
} = this.editor;
|
|
1600
|
-
this.setResolutionWidth(
|
|
1601
|
-
width:
|
|
1602
|
-
height:
|
|
1490
|
+
this.setResolutionWidth(i, { adaptCanvasToContainer: !0, withoutSave: !0 }), this.setResolutionHeight(n, { adaptCanvasToContainer: !0, withoutSave: !0 }), this.centerMontageArea(), t.selectAll(), s.fitObject({ fitAsOneObject: !0, withoutSave: !0 }), e.fire("editor:canvas-updated", {
|
|
1491
|
+
width: i,
|
|
1492
|
+
height: n
|
|
1603
1493
|
});
|
|
1604
1494
|
}
|
|
1605
1495
|
/**
|
|
@@ -1614,9 +1504,9 @@ class it {
|
|
|
1614
1504
|
* @param zoom — текущее значение zoom (например, 1, 1.2, 2 и т.д.)
|
|
1615
1505
|
*/
|
|
1616
1506
|
updateCssDimensionsForZoom(e) {
|
|
1617
|
-
const { canvas: t, montageArea: s } = this.editor,
|
|
1507
|
+
const { canvas: t, montageArea: s } = this.editor, i = s.width * e, n = s.height * e, a = t.wrapperEl.parentNode;
|
|
1618
1508
|
if (!(a instanceof HTMLElement)) return;
|
|
1619
|
-
const o =
|
|
1509
|
+
const o = i <= a.clientWidth ? "100%" : i, d = n <= a.clientHeight ? "100%" : n;
|
|
1620
1510
|
t.setDimensions(
|
|
1621
1511
|
{ width: o, height: d },
|
|
1622
1512
|
{ cssOnly: !0 }
|
|
@@ -1705,32 +1595,32 @@ class it {
|
|
|
1705
1595
|
*/
|
|
1706
1596
|
setDisplayDimension({ element: e = "canvas", dimension: t, value: s } = {}) {
|
|
1707
1597
|
if (!s) return;
|
|
1708
|
-
const { canvas:
|
|
1598
|
+
const { canvas: i, options: { editorContainer: n } } = this.editor, a = [];
|
|
1709
1599
|
switch (e) {
|
|
1710
1600
|
case "canvas":
|
|
1711
|
-
a.push(
|
|
1601
|
+
a.push(i.lowerCanvasEl, i.upperCanvasEl);
|
|
1712
1602
|
break;
|
|
1713
1603
|
case "wrapper":
|
|
1714
|
-
a.push(
|
|
1604
|
+
a.push(i.wrapperEl);
|
|
1715
1605
|
break;
|
|
1716
1606
|
case "container":
|
|
1717
|
-
a.push(
|
|
1607
|
+
a.push(n);
|
|
1718
1608
|
break;
|
|
1719
1609
|
default:
|
|
1720
|
-
a.push(
|
|
1610
|
+
a.push(i.lowerCanvasEl, i.upperCanvasEl);
|
|
1721
1611
|
}
|
|
1722
1612
|
const o = t === "width" ? "width" : "height";
|
|
1723
1613
|
if (typeof s == "string") {
|
|
1724
|
-
a.forEach((
|
|
1725
|
-
|
|
1614
|
+
a.forEach((r) => {
|
|
1615
|
+
r.style[o] = s;
|
|
1726
1616
|
});
|
|
1727
1617
|
return;
|
|
1728
1618
|
}
|
|
1729
1619
|
if (isNaN(s)) return;
|
|
1730
1620
|
const d = `${s}px`;
|
|
1731
|
-
a.forEach((
|
|
1732
|
-
|
|
1733
|
-
}),
|
|
1621
|
+
a.forEach((r) => {
|
|
1622
|
+
r.style[o] = d;
|
|
1623
|
+
}), i.fire(`editor:display-${e}-${o}-changed`, {
|
|
1734
1624
|
element: e,
|
|
1735
1625
|
value: s
|
|
1736
1626
|
});
|
|
@@ -1745,26 +1635,26 @@ class it {
|
|
|
1745
1635
|
*/
|
|
1746
1636
|
scaleMontageAreaToImage({ object: e, preserveAspectRatio: t, withoutSave: s } = {}) {
|
|
1747
1637
|
const {
|
|
1748
|
-
canvas:
|
|
1749
|
-
montageArea:
|
|
1638
|
+
canvas: i,
|
|
1639
|
+
montageArea: n,
|
|
1750
1640
|
transformManager: a,
|
|
1751
1641
|
options: {
|
|
1752
1642
|
montageAreaWidth: o,
|
|
1753
1643
|
montageAreaHeight: d
|
|
1754
1644
|
}
|
|
1755
|
-
} = this.editor,
|
|
1756
|
-
if (!
|
|
1757
|
-
const { width: l, height: h } =
|
|
1758
|
-
let g = Math.min(l,
|
|
1645
|
+
} = this.editor, r = e || i.getActiveObject();
|
|
1646
|
+
if (!r || r.type !== "image" && r.format !== "svg") return;
|
|
1647
|
+
const { width: l, height: h } = r;
|
|
1648
|
+
let g = Math.min(l, O), u = Math.min(h, T);
|
|
1759
1649
|
if (t) {
|
|
1760
1650
|
const {
|
|
1761
|
-
width:
|
|
1651
|
+
width: m,
|
|
1762
1652
|
height: M
|
|
1763
|
-
} =
|
|
1764
|
-
g =
|
|
1653
|
+
} = n, j = l / m, b = h / M, L = Math.max(j, b);
|
|
1654
|
+
g = m * L, u = M * L;
|
|
1765
1655
|
}
|
|
1766
|
-
this.setResolutionWidth(g, { withoutSave: !0 }), this.setResolutionHeight(u, { withoutSave: !0 }), (l > o || h > d) && a.calculateAndApplyDefaultZoom(), a.resetObject(
|
|
1767
|
-
object:
|
|
1656
|
+
this.setResolutionWidth(g, { withoutSave: !0 }), this.setResolutionHeight(u, { withoutSave: !0 }), (l > o || h > d) && a.calculateAndApplyDefaultZoom(), a.resetObject(r, { withoutSave: !0 }), i.centerObject(r), i.renderAll(), s || this.editor.historyManager.saveState(), i.fire("editor:montage-area-scaled-to-image", {
|
|
1657
|
+
object: r,
|
|
1768
1658
|
width: g,
|
|
1769
1659
|
height: u,
|
|
1770
1660
|
preserveAspectRatio: t,
|
|
@@ -1789,13 +1679,13 @@ class it {
|
|
|
1789
1679
|
const {
|
|
1790
1680
|
canvas: t,
|
|
1791
1681
|
transformManager: s,
|
|
1792
|
-
historyManager:
|
|
1682
|
+
historyManager: i,
|
|
1793
1683
|
options: {
|
|
1794
|
-
montageAreaWidth:
|
|
1684
|
+
montageAreaWidth: n,
|
|
1795
1685
|
montageAreaHeight: a
|
|
1796
1686
|
}
|
|
1797
1687
|
} = this.editor;
|
|
1798
|
-
s.resetZoom(), this.setResolutionWidth(
|
|
1688
|
+
s.resetZoom(), this.setResolutionWidth(n, { withoutSave: !0 }), this.setResolutionHeight(a, { withoutSave: !0 }), t.renderAll(), s.resetObjects(), e || i.saveState(), t.fire("editor:default-scale-set");
|
|
1799
1689
|
}
|
|
1800
1690
|
/**
|
|
1801
1691
|
* Получение всех объектов внутри монтажной области редактора
|
|
@@ -1803,12 +1693,12 @@ class it {
|
|
|
1803
1693
|
*/
|
|
1804
1694
|
getObjects() {
|
|
1805
1695
|
const { canvas: e, montageArea: t, interactionBlocker: { overlayMask: s } } = this.editor;
|
|
1806
|
-
return e.getObjects().filter((
|
|
1696
|
+
return e.getObjects().filter((n) => n.id !== t.id && n.id !== (s == null ? void 0 : s.id));
|
|
1807
1697
|
}
|
|
1808
1698
|
}
|
|
1809
|
-
class
|
|
1699
|
+
class tt {
|
|
1810
1700
|
constructor({ editor: e }) {
|
|
1811
|
-
this.editor = e, this.options = e.options, this.minZoom = this.options.minZoom ||
|
|
1701
|
+
this.editor = e, this.options = e.options, this.minZoom = this.options.minZoom || Je, this.maxZoom = this.options.maxZoom || $e, this.defaultZoom = this.options.defaultScale, this.maxZoomFactor = this.options.maxZoomFactor;
|
|
1812
1702
|
}
|
|
1813
1703
|
/**
|
|
1814
1704
|
* Метод рассчитывает и применяет зум по умолчанию для монтажной области редактора.
|
|
@@ -1818,8 +1708,8 @@ class at {
|
|
|
1818
1708
|
* @param scale - Желаемый масштаб относительно размеров контейнера редактора.
|
|
1819
1709
|
*/
|
|
1820
1710
|
calculateAndApplyDefaultZoom(e = this.options.defaultScale) {
|
|
1821
|
-
const { canvas: t } = this.editor, s = t.editorContainer,
|
|
1822
|
-
this.defaultZoom = Math.min(d,
|
|
1711
|
+
const { canvas: t } = this.editor, s = t.editorContainer, i = s.clientWidth, n = s.clientHeight, { width: a, height: o } = this.editor.montageArea, d = i / a * e, r = n / o * e;
|
|
1712
|
+
this.defaultZoom = Math.min(d, r);
|
|
1823
1713
|
const { defaultZoom: l, maxZoomFactor: h, minZoom: g, maxZoom: u } = this;
|
|
1824
1714
|
this.minZoom = Math.min(l / h, g), this.maxZoom = Math.max(l * h, u), this.setZoom();
|
|
1825
1715
|
}
|
|
@@ -1832,17 +1722,17 @@ class at {
|
|
|
1832
1722
|
* @fires editor:zoom-changed
|
|
1833
1723
|
* Если передавать координаты курсора, то нужно быть аккуратнее, так как юзер может выйти за пределы рабочей области
|
|
1834
1724
|
*/
|
|
1835
|
-
zoom(e =
|
|
1725
|
+
zoom(e = Ke, t = {}) {
|
|
1836
1726
|
var g, u;
|
|
1837
1727
|
if (!e) return;
|
|
1838
|
-
const { minZoom: s, maxZoom:
|
|
1728
|
+
const { minZoom: s, maxZoom: i } = this, { canvas: n } = this.editor, a = n.getZoom(), o = n.getCenterPoint(), d = (g = t.pointX) != null ? g : o.x, r = (u = t.pointY) != null ? u : o.y, l = new _(d, r);
|
|
1839
1729
|
let h = Number((a + Number(e)).toFixed(2));
|
|
1840
|
-
h >
|
|
1730
|
+
h > i && (h = i), h < s && (h = s), n.zoomToPoint(l, h), console.log({
|
|
1841
1731
|
currentZoom: a,
|
|
1842
1732
|
zoom: h,
|
|
1843
1733
|
point: l
|
|
1844
|
-
}),
|
|
1845
|
-
currentZoom:
|
|
1734
|
+
}), n.fire("editor:zoom-changed", {
|
|
1735
|
+
currentZoom: n.getZoom(),
|
|
1846
1736
|
zoom: h,
|
|
1847
1737
|
point: l
|
|
1848
1738
|
});
|
|
@@ -1853,12 +1743,12 @@ class at {
|
|
|
1853
1743
|
* @fires editor:zoom-changed
|
|
1854
1744
|
*/
|
|
1855
1745
|
setZoom(e = this.defaultZoom) {
|
|
1856
|
-
const { minZoom: t, maxZoom: s } = this, { canvas:
|
|
1746
|
+
const { minZoom: t, maxZoom: s } = this, { canvas: i } = this.editor, n = new _(i.getCenterPoint());
|
|
1857
1747
|
let a = e;
|
|
1858
|
-
e > s && (a = s), e < t && (a = t),
|
|
1859
|
-
currentZoom:
|
|
1748
|
+
e > s && (a = s), e < t && (a = t), i.zoomToPoint(n, a), i.fire("editor:zoom-changed", {
|
|
1749
|
+
currentZoom: i.getZoom(),
|
|
1860
1750
|
zoom: a,
|
|
1861
|
-
point:
|
|
1751
|
+
point: n
|
|
1862
1752
|
});
|
|
1863
1753
|
}
|
|
1864
1754
|
/**
|
|
@@ -1866,7 +1756,7 @@ class at {
|
|
|
1866
1756
|
* @fires editor:zoom-changed
|
|
1867
1757
|
*/
|
|
1868
1758
|
resetZoom() {
|
|
1869
|
-
const { canvas: e } = this.editor, t = new
|
|
1759
|
+
const { canvas: e } = this.editor, t = new _(e.getCenterPoint());
|
|
1870
1760
|
e.zoomToPoint(t, this.defaultZoom), this.editor.canvas.fire("editor:zoom-changed", {
|
|
1871
1761
|
currentZoom: e.getZoom(),
|
|
1872
1762
|
point: t
|
|
@@ -1879,12 +1769,12 @@ class at {
|
|
|
1879
1769
|
* @param options.withoutSave - Не сохранять состояние
|
|
1880
1770
|
* @fires editor:object-rotated
|
|
1881
1771
|
*/
|
|
1882
|
-
rotate(e =
|
|
1883
|
-
const { canvas: s, historyManager:
|
|
1884
|
-
if (!
|
|
1885
|
-
const a =
|
|
1886
|
-
|
|
1887
|
-
object:
|
|
1772
|
+
rotate(e = qe, { withoutSave: t } = {}) {
|
|
1773
|
+
const { canvas: s, historyManager: i } = this.editor, n = s.getActiveObject();
|
|
1774
|
+
if (!n) return;
|
|
1775
|
+
const a = n.angle + e;
|
|
1776
|
+
n.rotate(a), n.setCoords(), s.renderAll(), t || i.saveState(), s.fire("editor:object-rotated", {
|
|
1777
|
+
object: n,
|
|
1888
1778
|
withoutSave: t,
|
|
1889
1779
|
angle: a
|
|
1890
1780
|
});
|
|
@@ -1896,9 +1786,9 @@ class at {
|
|
|
1896
1786
|
* @fires editor:object-flipped-x
|
|
1897
1787
|
*/
|
|
1898
1788
|
flipX({ withoutSave: e } = {}) {
|
|
1899
|
-
const { canvas: t, historyManager: s } = this.editor,
|
|
1900
|
-
|
|
1901
|
-
object:
|
|
1789
|
+
const { canvas: t, historyManager: s } = this.editor, i = t.getActiveObject();
|
|
1790
|
+
i && (i.flipX = !i.flipX, t.renderAll(), e || s.saveState(), t.fire("editor:object-flipped-x", {
|
|
1791
|
+
object: i,
|
|
1902
1792
|
withoutSave: e
|
|
1903
1793
|
}));
|
|
1904
1794
|
}
|
|
@@ -1909,9 +1799,9 @@ class at {
|
|
|
1909
1799
|
* @fires editor:object-flipped-y
|
|
1910
1800
|
*/
|
|
1911
1801
|
flipY({ withoutSave: e } = {}) {
|
|
1912
|
-
const { canvas: t, historyManager: s } = this.editor,
|
|
1913
|
-
|
|
1914
|
-
object:
|
|
1802
|
+
const { canvas: t, historyManager: s } = this.editor, i = t.getActiveObject();
|
|
1803
|
+
i && (i.flipY = !i.flipY, t.renderAll(), e || s.saveState(), t.fire("editor:object-flipped-y", {
|
|
1804
|
+
object: i,
|
|
1915
1805
|
withoutSave: e
|
|
1916
1806
|
}));
|
|
1917
1807
|
}
|
|
@@ -1928,10 +1818,10 @@ class at {
|
|
|
1928
1818
|
opacity: t = 1,
|
|
1929
1819
|
withoutSave: s
|
|
1930
1820
|
} = {}) {
|
|
1931
|
-
const { canvas:
|
|
1932
|
-
a && (a instanceof
|
|
1821
|
+
const { canvas: i, historyManager: n } = this.editor, a = e || i.getActiveObject();
|
|
1822
|
+
a && (a instanceof v ? a.getObjects().forEach((o) => {
|
|
1933
1823
|
o.set("opacity", t);
|
|
1934
|
-
}) : a.set("opacity", t),
|
|
1824
|
+
}) : a.set("opacity", t), i.renderAll(), s || n.saveState(), i.fire("editor:object-opacity-changed", {
|
|
1935
1825
|
object: a,
|
|
1936
1826
|
opacity: t,
|
|
1937
1827
|
withoutSave: s
|
|
@@ -1952,30 +1842,30 @@ class at {
|
|
|
1952
1842
|
object: e,
|
|
1953
1843
|
type: t = this.options.scaleType,
|
|
1954
1844
|
withoutSave: s,
|
|
1955
|
-
fitAsOneObject:
|
|
1845
|
+
fitAsOneObject: i
|
|
1956
1846
|
} = {}) {
|
|
1957
|
-
const { canvas:
|
|
1847
|
+
const { canvas: n, imageManager: a, historyManager: o } = this.editor, d = e || n.getActiveObject();
|
|
1958
1848
|
if (d) {
|
|
1959
|
-
if (d.set("angle", 0), d instanceof
|
|
1960
|
-
const
|
|
1961
|
-
|
|
1849
|
+
if (d.set("angle", 0), d instanceof v && !i) {
|
|
1850
|
+
const r = d.getObjects();
|
|
1851
|
+
n.discardActiveObject(), r.forEach((h) => {
|
|
1962
1852
|
const g = a.calculateScaleFactor({ imageObject: h, scaleType: t });
|
|
1963
|
-
h.scale(g),
|
|
1853
|
+
h.scale(g), n.centerObject(h);
|
|
1964
1854
|
});
|
|
1965
|
-
const l = new
|
|
1966
|
-
|
|
1855
|
+
const l = new v(r, { canvas: n });
|
|
1856
|
+
n.setActiveObject(l);
|
|
1967
1857
|
} else {
|
|
1968
|
-
const
|
|
1858
|
+
const r = a.calculateScaleFactor({
|
|
1969
1859
|
imageObject: d,
|
|
1970
1860
|
scaleType: t
|
|
1971
1861
|
});
|
|
1972
|
-
d.scale(
|
|
1862
|
+
d.scale(r), n.centerObject(d);
|
|
1973
1863
|
}
|
|
1974
|
-
|
|
1864
|
+
n.renderAll(), s || o.saveState(), n.fire("editor:object-fitted", {
|
|
1975
1865
|
object: d,
|
|
1976
1866
|
type: t,
|
|
1977
1867
|
withoutSave: s,
|
|
1978
|
-
fitAsOneObject:
|
|
1868
|
+
fitAsOneObject: i
|
|
1979
1869
|
});
|
|
1980
1870
|
}
|
|
1981
1871
|
}
|
|
@@ -1997,36 +1887,36 @@ class at {
|
|
|
1997
1887
|
*/
|
|
1998
1888
|
resetObject(e, { alwaysFitObject: t = !1, withoutSave: s = !1 } = {}) {
|
|
1999
1889
|
const {
|
|
2000
|
-
canvas:
|
|
2001
|
-
montageArea:
|
|
1890
|
+
canvas: i,
|
|
1891
|
+
montageArea: n,
|
|
2002
1892
|
imageManager: a,
|
|
2003
1893
|
historyManager: o,
|
|
2004
1894
|
options: { scaleType: d }
|
|
2005
|
-
} = this.editor,
|
|
2006
|
-
if (!
|
|
2007
|
-
if (o.suspendHistory(),
|
|
1895
|
+
} = this.editor, r = e || i.getActiveObject();
|
|
1896
|
+
if (!r || r.locked) return;
|
|
1897
|
+
if (o.suspendHistory(), r.type === "image" || r.format === "svg" || r.set({
|
|
2008
1898
|
scaleX: 1,
|
|
2009
1899
|
scaleY: 1,
|
|
2010
1900
|
flipX: !1,
|
|
2011
1901
|
flipY: !1,
|
|
2012
1902
|
angle: 0
|
|
2013
1903
|
}), t)
|
|
2014
|
-
this.fitObject({ object:
|
|
1904
|
+
this.fitObject({ object: r, withoutSave: !0, fitAsOneObject: !0 });
|
|
2015
1905
|
else {
|
|
2016
|
-
const { width: h, height: g } =
|
|
2017
|
-
imageObject:
|
|
1906
|
+
const { width: h, height: g } = n, { width: u, height: m } = r, M = a.calculateScaleFactor({
|
|
1907
|
+
imageObject: r,
|
|
2018
1908
|
scaleType: d
|
|
2019
1909
|
});
|
|
2020
|
-
d === "contain" && M < 1 || d === "cover" && (u > h ||
|
|
1910
|
+
d === "contain" && M < 1 || d === "cover" && (u > h || m > g) ? this.fitObject({ object: r, withoutSave: !0, fitAsOneObject: !0 }) : r.set({ scaleX: 1, scaleY: 1 });
|
|
2021
1911
|
}
|
|
2022
|
-
|
|
2023
|
-
object:
|
|
1912
|
+
r.set({ flipX: !1, flipY: !1, angle: 0 }), i.centerObject(r), i.renderAll(), o.resumeHistory(), s || o.saveState(), i.fire("editor:object-reset", {
|
|
1913
|
+
object: r,
|
|
2024
1914
|
withoutSave: s,
|
|
2025
1915
|
alwaysFitObject: t
|
|
2026
1916
|
});
|
|
2027
1917
|
}
|
|
2028
1918
|
}
|
|
2029
|
-
class
|
|
1919
|
+
class st {
|
|
2030
1920
|
constructor({ editor: e }) {
|
|
2031
1921
|
this.editor = e, this.isBlocked = !1, this.overlayMask = null, this._createOverlay();
|
|
2032
1922
|
}
|
|
@@ -2056,8 +1946,8 @@ class ot {
|
|
|
2056
1946
|
const { canvas: e, montageArea: t, historyManager: s } = this.editor;
|
|
2057
1947
|
if (!t || !this.overlayMask) return;
|
|
2058
1948
|
s.suspendHistory(), t.setCoords();
|
|
2059
|
-
const { left:
|
|
2060
|
-
this.overlayMask.set({ left:
|
|
1949
|
+
const { left: i, top: n, width: a, height: o } = t.getBoundingRect();
|
|
1950
|
+
this.overlayMask.set({ left: i, top: n, width: a, height: o }), e.discardActiveObject(), this.editor.layerManager.bringToFront(this.overlayMask, { withoutSave: !0 }), s.resumeHistory();
|
|
2061
1951
|
}
|
|
2062
1952
|
/**
|
|
2063
1953
|
* Выключает редактор:
|
|
@@ -2068,8 +1958,8 @@ class ot {
|
|
|
2068
1958
|
block() {
|
|
2069
1959
|
if (this.isBlocked || !this.overlayMask) return;
|
|
2070
1960
|
const { canvas: e, canvasManager: t, historyManager: s } = this.editor;
|
|
2071
|
-
s.suspendHistory(), this.isBlocked = !0, e.discardActiveObject(), e.selection = !1, e.skipTargetFind = !0, t.getObjects().forEach((
|
|
2072
|
-
|
|
1961
|
+
s.suspendHistory(), this.isBlocked = !0, e.discardActiveObject(), e.selection = !1, e.skipTargetFind = !0, t.getObjects().forEach((i) => {
|
|
1962
|
+
i.evented = !1, i.selectable = !1;
|
|
2073
1963
|
}), e.upperCanvasEl.style.pointerEvents = "none", e.lowerCanvasEl.style.pointerEvents = "none", this.overlayMask.visible = !0, this.refresh(), e.fire("editor:disabled"), s.resumeHistory();
|
|
2074
1964
|
}
|
|
2075
1965
|
/**
|
|
@@ -2078,12 +1968,12 @@ class ot {
|
|
|
2078
1968
|
unblock() {
|
|
2079
1969
|
if (!this.isBlocked || !this.overlayMask) return;
|
|
2080
1970
|
const { canvas: e, canvasManager: t, historyManager: s } = this.editor;
|
|
2081
|
-
s.suspendHistory(), this.isBlocked = !1, e.selection = !0, e.skipTargetFind = !1, t.getObjects().forEach((
|
|
2082
|
-
|
|
1971
|
+
s.suspendHistory(), this.isBlocked = !1, e.selection = !0, e.skipTargetFind = !1, t.getObjects().forEach((i) => {
|
|
1972
|
+
i.evented = !0, i.selectable = !0;
|
|
2083
1973
|
}), e.upperCanvasEl.style.pointerEvents = "", e.lowerCanvasEl.style.pointerEvents = "", this.overlayMask.visible = !1, e.requestRenderAll(), e.fire("editor:enabled"), s.resumeHistory();
|
|
2084
1974
|
}
|
|
2085
1975
|
}
|
|
2086
|
-
class
|
|
1976
|
+
class P {
|
|
2087
1977
|
constructor({ editor: e }) {
|
|
2088
1978
|
this.editor = e;
|
|
2089
1979
|
}
|
|
@@ -2095,13 +1985,13 @@ class F {
|
|
|
2095
1985
|
* @fires editor:object-bring-to-front
|
|
2096
1986
|
*/
|
|
2097
1987
|
bringToFront(e, { withoutSave: t } = {}) {
|
|
2098
|
-
const { canvas: s, historyManager:
|
|
2099
|
-
|
|
2100
|
-
const
|
|
2101
|
-
|
|
1988
|
+
const { canvas: s, historyManager: i } = this.editor;
|
|
1989
|
+
i.suspendHistory();
|
|
1990
|
+
const n = e || s.getActiveObject();
|
|
1991
|
+
n && (n instanceof v ? n.getObjects().forEach((a) => {
|
|
2102
1992
|
s.bringObjectToFront(a);
|
|
2103
|
-
}) : s.bringObjectToFront(
|
|
2104
|
-
object:
|
|
1993
|
+
}) : s.bringObjectToFront(n), s.renderAll(), i.resumeHistory(), t || i.saveState(), s.fire("editor:object-bring-to-front", {
|
|
1994
|
+
object: n,
|
|
2105
1995
|
withoutSave: t
|
|
2106
1996
|
}));
|
|
2107
1997
|
}
|
|
@@ -2113,11 +2003,11 @@ class F {
|
|
|
2113
2003
|
* @fires editor:object-bring-forward
|
|
2114
2004
|
*/
|
|
2115
2005
|
bringForward(e, { withoutSave: t } = {}) {
|
|
2116
|
-
const { canvas: s, historyManager:
|
|
2117
|
-
|
|
2118
|
-
const
|
|
2119
|
-
|
|
2120
|
-
object:
|
|
2006
|
+
const { canvas: s, historyManager: i } = this.editor;
|
|
2007
|
+
i.suspendHistory();
|
|
2008
|
+
const n = e || s.getActiveObject();
|
|
2009
|
+
n && (n instanceof v ? P._moveSelectionForward(s, n) : s.bringObjectForward(n), s.renderAll(), i.resumeHistory(), t || i.saveState(), s.fire("editor:object-bring-forward", {
|
|
2010
|
+
object: n,
|
|
2121
2011
|
withoutSave: t
|
|
2122
2012
|
}));
|
|
2123
2013
|
}
|
|
@@ -2131,20 +2021,20 @@ class F {
|
|
|
2131
2021
|
sendToBack(e, { withoutSave: t } = {}) {
|
|
2132
2022
|
const {
|
|
2133
2023
|
canvas: s,
|
|
2134
|
-
montageArea:
|
|
2135
|
-
historyManager:
|
|
2024
|
+
montageArea: i,
|
|
2025
|
+
historyManager: n,
|
|
2136
2026
|
interactionBlocker: { overlayMask: a }
|
|
2137
2027
|
} = this.editor;
|
|
2138
|
-
|
|
2028
|
+
n.suspendHistory();
|
|
2139
2029
|
const o = e || s.getActiveObject();
|
|
2140
2030
|
if (o) {
|
|
2141
|
-
if (o instanceof
|
|
2031
|
+
if (o instanceof v) {
|
|
2142
2032
|
const d = o.getObjects();
|
|
2143
|
-
for (let
|
|
2144
|
-
s.sendObjectToBack(d[
|
|
2033
|
+
for (let r = d.length - 1; r >= 0; r -= 1)
|
|
2034
|
+
s.sendObjectToBack(d[r]);
|
|
2145
2035
|
} else
|
|
2146
2036
|
s.sendObjectToBack(o);
|
|
2147
|
-
s.sendObjectToBack(
|
|
2037
|
+
s.sendObjectToBack(i), a && s.sendObjectToBack(a), s.renderAll(), n.resumeHistory(), t || n.saveState(), s.fire("editor:object-send-to-back", {
|
|
2148
2038
|
object: o,
|
|
2149
2039
|
withoutSave: t
|
|
2150
2040
|
});
|
|
@@ -2159,13 +2049,13 @@ class F {
|
|
|
2159
2049
|
sendBackwards(e, { withoutSave: t } = {}) {
|
|
2160
2050
|
const {
|
|
2161
2051
|
canvas: s,
|
|
2162
|
-
montageArea:
|
|
2163
|
-
historyManager:
|
|
2052
|
+
montageArea: i,
|
|
2053
|
+
historyManager: n,
|
|
2164
2054
|
interactionBlocker: { overlayMask: a }
|
|
2165
2055
|
} = this.editor;
|
|
2166
|
-
|
|
2056
|
+
n.suspendHistory();
|
|
2167
2057
|
const o = e || s.getActiveObject();
|
|
2168
|
-
o && (o instanceof
|
|
2058
|
+
o && (o instanceof v ? P._moveSelectionBackwards(s, o) : s.sendObjectBackwards(o), s.sendObjectToBack(i), a && s.sendObjectToBack(a), s.renderAll(), n.resumeHistory(), t || n.saveState(), s.fire("editor:object-send-backwards", {
|
|
2169
2059
|
object: o,
|
|
2170
2060
|
withoutSave: t
|
|
2171
2061
|
}));
|
|
@@ -2176,18 +2066,18 @@ class F {
|
|
|
2176
2066
|
* @param activeSelection - активное выделение
|
|
2177
2067
|
*/
|
|
2178
2068
|
static _moveSelectionForward(e, t) {
|
|
2179
|
-
const s = e.getObjects(),
|
|
2069
|
+
const s = e.getObjects(), i = t.getObjects(), n = i.map((o) => s.indexOf(o));
|
|
2180
2070
|
let a = -1;
|
|
2181
2071
|
for (let o = 0; o < s.length; o += 1) {
|
|
2182
2072
|
const d = s[o];
|
|
2183
|
-
if (!
|
|
2073
|
+
if (!i.includes(d) && n.some((r) => o > r)) {
|
|
2184
2074
|
a = o;
|
|
2185
2075
|
break;
|
|
2186
2076
|
}
|
|
2187
2077
|
}
|
|
2188
|
-
a !== -1 &&
|
|
2189
|
-
const
|
|
2190
|
-
|
|
2078
|
+
a !== -1 && i.map((d) => ({ obj: d, index: s.indexOf(d) })).sort((d, r) => r.index - d.index).forEach((d) => {
|
|
2079
|
+
const r = s.indexOf(d.obj);
|
|
2080
|
+
r < a && (e.moveObjectTo(d.obj, a), a = r);
|
|
2191
2081
|
});
|
|
2192
2082
|
}
|
|
2193
2083
|
/**
|
|
@@ -2196,12 +2086,12 @@ class F {
|
|
|
2196
2086
|
* @param activeSelection - активное выделение
|
|
2197
2087
|
*/
|
|
2198
2088
|
static _moveSelectionBackwards(e, t) {
|
|
2199
|
-
const s = e.getObjects(),
|
|
2200
|
-
for (let a =
|
|
2201
|
-
e.moveObjectTo(
|
|
2089
|
+
const s = e.getObjects(), i = t.getObjects(), n = Math.min(...i.map((a) => s.indexOf(a)));
|
|
2090
|
+
for (let a = i.length - 1; a >= 0; a -= 1)
|
|
2091
|
+
e.moveObjectTo(i[a], n - 1);
|
|
2202
2092
|
}
|
|
2203
2093
|
}
|
|
2204
|
-
class
|
|
2094
|
+
class it {
|
|
2205
2095
|
/**
|
|
2206
2096
|
* Менеджер фигур для редактора.
|
|
2207
2097
|
* @param options - Опции и настройки менеджера фигур.
|
|
@@ -2225,13 +2115,13 @@ class rt {
|
|
|
2225
2115
|
* @param flags.withoutSelection - Не выделять объект
|
|
2226
2116
|
* @param flags.withoutAdding - Не добавлять объект в canvas
|
|
2227
2117
|
*/
|
|
2228
|
-
addRectangle(l = {}, { withoutSelection: d, withoutAdding:
|
|
2118
|
+
addRectangle(l = {}, { withoutSelection: d, withoutAdding: r } = {}) {
|
|
2229
2119
|
var h = l, {
|
|
2230
2120
|
id: e = `rect-${D()}`,
|
|
2231
2121
|
left: t,
|
|
2232
2122
|
top: s,
|
|
2233
|
-
width:
|
|
2234
|
-
height:
|
|
2123
|
+
width: i = 100,
|
|
2124
|
+
height: n = 100,
|
|
2235
2125
|
fill: a = "blue"
|
|
2236
2126
|
} = h, o = Y(h, [
|
|
2237
2127
|
"id",
|
|
@@ -2241,15 +2131,15 @@ class rt {
|
|
|
2241
2131
|
"height",
|
|
2242
2132
|
"fill"
|
|
2243
2133
|
]);
|
|
2244
|
-
const { canvas: g } = this.editor, u = new ve(
|
|
2134
|
+
const { canvas: g } = this.editor, u = new ve(f({
|
|
2245
2135
|
id: e,
|
|
2246
2136
|
left: t,
|
|
2247
2137
|
top: s,
|
|
2248
|
-
width:
|
|
2249
|
-
height:
|
|
2138
|
+
width: i,
|
|
2139
|
+
height: n,
|
|
2250
2140
|
fill: a
|
|
2251
2141
|
}, o));
|
|
2252
|
-
return !t && !s && g.centerObject(u),
|
|
2142
|
+
return !t && !s && g.centerObject(u), r || (g.add(u), d || g.setActiveObject(u), g.renderAll()), u;
|
|
2253
2143
|
}
|
|
2254
2144
|
/**
|
|
2255
2145
|
* Добавление круга
|
|
@@ -2267,13 +2157,13 @@ class rt {
|
|
|
2267
2157
|
* @param flags.withoutSelection - Не выделять объект
|
|
2268
2158
|
* @param flags.withoutAdding - Не добавлять объект в canvas
|
|
2269
2159
|
*/
|
|
2270
|
-
addCircle(
|
|
2271
|
-
var l =
|
|
2160
|
+
addCircle(r = {}, { withoutSelection: o, withoutAdding: d } = {}) {
|
|
2161
|
+
var l = r, {
|
|
2272
2162
|
id: e = `circle-${D()}`,
|
|
2273
2163
|
left: t,
|
|
2274
2164
|
top: s,
|
|
2275
|
-
radius:
|
|
2276
|
-
fill:
|
|
2165
|
+
radius: i = 50,
|
|
2166
|
+
fill: n = "green"
|
|
2277
2167
|
} = l, a = Y(l, [
|
|
2278
2168
|
"id",
|
|
2279
2169
|
"left",
|
|
@@ -2281,12 +2171,12 @@ class rt {
|
|
|
2281
2171
|
"radius",
|
|
2282
2172
|
"fill"
|
|
2283
2173
|
]);
|
|
2284
|
-
const { canvas: h } = this.editor, g = new Ae(
|
|
2174
|
+
const { canvas: h } = this.editor, g = new Ae(f({
|
|
2285
2175
|
id: e,
|
|
2286
2176
|
left: t,
|
|
2287
2177
|
top: s,
|
|
2288
|
-
fill:
|
|
2289
|
-
radius:
|
|
2178
|
+
fill: n,
|
|
2179
|
+
radius: i
|
|
2290
2180
|
}, a));
|
|
2291
2181
|
return !t && !s && h.centerObject(g), d || (h.add(g), o || h.setActiveObject(g), h.renderAll()), g;
|
|
2292
2182
|
}
|
|
@@ -2307,13 +2197,13 @@ class rt {
|
|
|
2307
2197
|
* @param flags.withoutSelection - Не выделять объект
|
|
2308
2198
|
* @param flags.withoutAdding - Не добавлять объект в canvas
|
|
2309
2199
|
*/
|
|
2310
|
-
addTriangle(l = {}, { withoutSelection: d, withoutAdding:
|
|
2200
|
+
addTriangle(l = {}, { withoutSelection: d, withoutAdding: r } = {}) {
|
|
2311
2201
|
var h = l, {
|
|
2312
2202
|
id: e = `triangle-${D()}`,
|
|
2313
2203
|
left: t,
|
|
2314
2204
|
top: s,
|
|
2315
|
-
width:
|
|
2316
|
-
height:
|
|
2205
|
+
width: i = 100,
|
|
2206
|
+
height: n = 100,
|
|
2317
2207
|
fill: a = "yellow"
|
|
2318
2208
|
} = h, o = Y(h, [
|
|
2319
2209
|
"id",
|
|
@@ -2323,18 +2213,18 @@ class rt {
|
|
|
2323
2213
|
"height",
|
|
2324
2214
|
"fill"
|
|
2325
2215
|
]);
|
|
2326
|
-
const { canvas: g } = this.editor, u = new Se(
|
|
2216
|
+
const { canvas: g } = this.editor, u = new Se(f({
|
|
2327
2217
|
id: e,
|
|
2328
2218
|
left: t,
|
|
2329
2219
|
top: s,
|
|
2330
2220
|
fill: a,
|
|
2331
|
-
width:
|
|
2332
|
-
height:
|
|
2221
|
+
width: i,
|
|
2222
|
+
height: n
|
|
2333
2223
|
}, o));
|
|
2334
|
-
return !t && !s && g.centerObject(u),
|
|
2224
|
+
return !t && !s && g.centerObject(u), r || (g.add(u), d || g.setActiveObject(u), g.renderAll()), u;
|
|
2335
2225
|
}
|
|
2336
2226
|
}
|
|
2337
|
-
class
|
|
2227
|
+
class nt {
|
|
2338
2228
|
/**
|
|
2339
2229
|
* @param options
|
|
2340
2230
|
* @param options.editor - экземпляр редактора с доступом к canvas
|
|
@@ -2372,10 +2262,10 @@ class ct {
|
|
|
2372
2262
|
}), this._cloneAndFire(e, s);
|
|
2373
2263
|
return;
|
|
2374
2264
|
}
|
|
2375
|
-
const
|
|
2265
|
+
const n = s.toCanvasElement().toDataURL(), a = n.slice(5).split(";")[0], o = n.split(",")[1], d = atob(o), r = new Uint8Array(d.length);
|
|
2376
2266
|
for (let g = 0; g < d.length; g += 1)
|
|
2377
|
-
|
|
2378
|
-
const l = new Blob([
|
|
2267
|
+
r[g] = d.charCodeAt(g);
|
|
2268
|
+
const l = new Blob([r.buffer], { type: a }), h = new ClipboardItem({ [a]: l });
|
|
2379
2269
|
navigator.clipboard.write([h]).catch((g) => {
|
|
2380
2270
|
t.emitWarning({
|
|
2381
2271
|
origin: "ClipboardManager",
|
|
@@ -2412,21 +2302,21 @@ class ct {
|
|
|
2412
2302
|
handlePasteEvent({ clipboardData: e }) {
|
|
2413
2303
|
var a;
|
|
2414
2304
|
if (!((a = e == null ? void 0 : e.items) != null && a.length)) return;
|
|
2415
|
-
const { imageManager: t } = this.editor, { items: s } = e,
|
|
2416
|
-
if (
|
|
2417
|
-
const o =
|
|
2305
|
+
const { imageManager: t } = this.editor, { items: s } = e, i = s[s.length - 1];
|
|
2306
|
+
if (i.type !== "text/html") {
|
|
2307
|
+
const o = i.getAsFile();
|
|
2418
2308
|
if (!o) return;
|
|
2419
2309
|
const d = new FileReader();
|
|
2420
|
-
d.onload = (
|
|
2421
|
-
|
|
2310
|
+
d.onload = (r) => {
|
|
2311
|
+
r.target && this.editor.imageManager.importImage({ source: r.target.result });
|
|
2422
2312
|
}, d.readAsDataURL(o);
|
|
2423
2313
|
return;
|
|
2424
2314
|
}
|
|
2425
|
-
const
|
|
2426
|
-
if (
|
|
2427
|
-
const
|
|
2428
|
-
if (
|
|
2429
|
-
t.importImage({ source:
|
|
2315
|
+
const n = e.getData("text/html");
|
|
2316
|
+
if (n) {
|
|
2317
|
+
const r = new DOMParser().parseFromString(n, "text/html").querySelector("img");
|
|
2318
|
+
if (r != null && r.src) {
|
|
2319
|
+
t.importImage({ source: r.src });
|
|
2430
2320
|
return;
|
|
2431
2321
|
}
|
|
2432
2322
|
}
|
|
@@ -2437,7 +2327,7 @@ class ct {
|
|
|
2437
2327
|
* @fires editor:object-pasted
|
|
2438
2328
|
*/
|
|
2439
2329
|
paste() {
|
|
2440
|
-
return
|
|
2330
|
+
return I(this, null, function* () {
|
|
2441
2331
|
const { canvas: e } = this.editor;
|
|
2442
2332
|
if (!this.clipboard) return;
|
|
2443
2333
|
const t = yield this.clipboard.clone(["format"]);
|
|
@@ -2446,13 +2336,13 @@ class ct {
|
|
|
2446
2336
|
left: t.left + 10,
|
|
2447
2337
|
top: t.top + 10,
|
|
2448
2338
|
evented: !0
|
|
2449
|
-
}), t instanceof
|
|
2339
|
+
}), t instanceof v ? (t.canvas = e, t.forEachObject((s) => {
|
|
2450
2340
|
e.add(s);
|
|
2451
2341
|
})) : e.add(t), e.setActiveObject(t), e.requestRenderAll(), e.fire("editor:object-pasted", { object: t });
|
|
2452
2342
|
});
|
|
2453
2343
|
}
|
|
2454
2344
|
}
|
|
2455
|
-
class
|
|
2345
|
+
class F {
|
|
2456
2346
|
constructor({ editor: e }) {
|
|
2457
2347
|
this.editor = e;
|
|
2458
2348
|
}
|
|
@@ -2465,7 +2355,7 @@ class V {
|
|
|
2465
2355
|
* @fires editor:object-locked
|
|
2466
2356
|
*/
|
|
2467
2357
|
lockObject({ object: e, skipInnerObjects: t, withoutSave: s } = {}) {
|
|
2468
|
-
const { canvas:
|
|
2358
|
+
const { canvas: i, historyManager: n } = this.editor, a = e || i.getActiveObject();
|
|
2469
2359
|
if (!a || a.locked) return;
|
|
2470
2360
|
const o = {
|
|
2471
2361
|
lockMovementX: !0,
|
|
@@ -2477,9 +2367,9 @@ class V {
|
|
|
2477
2367
|
lockSkewingY: !0,
|
|
2478
2368
|
locked: !0
|
|
2479
2369
|
};
|
|
2480
|
-
a.set(o), !t &&
|
|
2481
|
-
|
|
2482
|
-
}),
|
|
2370
|
+
a.set(o), !t && F._isGroupOrSelection(a) && a.getObjects().forEach((r) => {
|
|
2371
|
+
r.set(o);
|
|
2372
|
+
}), i.renderAll(), s || n.saveState(), i.fire("editor:object-locked", {
|
|
2483
2373
|
object: a,
|
|
2484
2374
|
skipInnerObjects: t,
|
|
2485
2375
|
withoutSave: s
|
|
@@ -2493,8 +2383,8 @@ class V {
|
|
|
2493
2383
|
* @fires editor:object-unlocked
|
|
2494
2384
|
*/
|
|
2495
2385
|
unlockObject({ object: e, withoutSave: t } = {}) {
|
|
2496
|
-
const { canvas: s, historyManager:
|
|
2497
|
-
if (!
|
|
2386
|
+
const { canvas: s, historyManager: i } = this.editor, n = e || s.getActiveObject();
|
|
2387
|
+
if (!n) return;
|
|
2498
2388
|
const a = {
|
|
2499
2389
|
lockMovementX: !1,
|
|
2500
2390
|
lockMovementY: !1,
|
|
@@ -2505,18 +2395,18 @@ class V {
|
|
|
2505
2395
|
lockSkewingY: !1,
|
|
2506
2396
|
locked: !1
|
|
2507
2397
|
};
|
|
2508
|
-
|
|
2398
|
+
n.set(a), F._isGroupOrSelection(n) && n.getObjects().forEach((o) => {
|
|
2509
2399
|
o.set(a);
|
|
2510
|
-
}), s.renderAll(), t ||
|
|
2511
|
-
object:
|
|
2400
|
+
}), s.renderAll(), t || i.saveState(), s.fire("editor:object-unlocked", {
|
|
2401
|
+
object: n,
|
|
2512
2402
|
withoutSave: t
|
|
2513
2403
|
});
|
|
2514
2404
|
}
|
|
2515
2405
|
static _isGroupOrSelection(e) {
|
|
2516
|
-
return e instanceof
|
|
2406
|
+
return e instanceof v || e instanceof X;
|
|
2517
2407
|
}
|
|
2518
2408
|
}
|
|
2519
|
-
class
|
|
2409
|
+
class at {
|
|
2520
2410
|
constructor({ editor: e }) {
|
|
2521
2411
|
this.editor = e;
|
|
2522
2412
|
}
|
|
@@ -2531,13 +2421,13 @@ class dt {
|
|
|
2531
2421
|
object: e,
|
|
2532
2422
|
withoutSave: t
|
|
2533
2423
|
} = {}) {
|
|
2534
|
-
const { canvas: s, historyManager:
|
|
2535
|
-
|
|
2536
|
-
const
|
|
2537
|
-
if (!
|
|
2538
|
-
const a =
|
|
2539
|
-
a.forEach((d) => s.remove(d)), o.set("id", `${o.type}-${D()}`), s.add(o), s.setActiveObject(o), s.renderAll(),
|
|
2540
|
-
object:
|
|
2424
|
+
const { canvas: s, historyManager: i } = this.editor;
|
|
2425
|
+
i.suspendHistory();
|
|
2426
|
+
const n = e || s.getActiveObject();
|
|
2427
|
+
if (!n || !(n instanceof v)) return;
|
|
2428
|
+
const a = n.getObjects(), o = new X(a);
|
|
2429
|
+
a.forEach((d) => s.remove(d)), o.set("id", `${o.type}-${D()}`), s.add(o), s.setActiveObject(o), s.renderAll(), i.resumeHistory(), t || i.saveState(), s.fire("editor:objects-grouped", {
|
|
2430
|
+
object: n,
|
|
2541
2431
|
group: o,
|
|
2542
2432
|
withoutSave: t
|
|
2543
2433
|
});
|
|
@@ -2553,23 +2443,23 @@ class dt {
|
|
|
2553
2443
|
object: e,
|
|
2554
2444
|
withoutSave: t
|
|
2555
2445
|
} = {}) {
|
|
2556
|
-
const { canvas: s, historyManager:
|
|
2557
|
-
|
|
2558
|
-
const
|
|
2559
|
-
if (!(
|
|
2560
|
-
const a =
|
|
2561
|
-
s.remove(
|
|
2562
|
-
const o = new
|
|
2446
|
+
const { canvas: s, historyManager: i } = this.editor;
|
|
2447
|
+
i.suspendHistory();
|
|
2448
|
+
const n = e || s.getActiveObject();
|
|
2449
|
+
if (!(n instanceof X)) return;
|
|
2450
|
+
const a = n.removeAll();
|
|
2451
|
+
s.remove(n), a.forEach((d) => s.add(d));
|
|
2452
|
+
const o = new v(a, {
|
|
2563
2453
|
canvas: s
|
|
2564
2454
|
});
|
|
2565
|
-
s.setActiveObject(o), s.renderAll(),
|
|
2566
|
-
object:
|
|
2455
|
+
s.setActiveObject(o), s.renderAll(), i.resumeHistory(), t || i.saveState(), s.fire("editor:objects-ungrouped", {
|
|
2456
|
+
object: n,
|
|
2567
2457
|
selection: o,
|
|
2568
2458
|
withoutSave: t
|
|
2569
2459
|
});
|
|
2570
2460
|
}
|
|
2571
2461
|
}
|
|
2572
|
-
class
|
|
2462
|
+
class ot {
|
|
2573
2463
|
constructor({ editor: e }) {
|
|
2574
2464
|
this.editor = e;
|
|
2575
2465
|
}
|
|
@@ -2580,11 +2470,11 @@ class lt {
|
|
|
2580
2470
|
selectAll() {
|
|
2581
2471
|
const { canvas: e, canvasManager: t, objectLockManager: s } = this.editor;
|
|
2582
2472
|
e.discardActiveObject();
|
|
2583
|
-
const
|
|
2584
|
-
|
|
2473
|
+
const i = t.getObjects(), n = i.some((o) => o.locked), a = i.length > 1 ? new v(t.getObjects(), { canvas: e }) : i[0];
|
|
2474
|
+
n && s.lockObject({ object: a, skipInnerObjects: !0, withoutSave: !0 }), e.setActiveObject(a), e.requestRenderAll(), e.fire("editor:all-objects-selected", { selected: a });
|
|
2585
2475
|
}
|
|
2586
2476
|
}
|
|
2587
|
-
class
|
|
2477
|
+
class rt {
|
|
2588
2478
|
constructor({ editor: e }) {
|
|
2589
2479
|
this.editor = e;
|
|
2590
2480
|
}
|
|
@@ -2599,20 +2489,20 @@ class ht {
|
|
|
2599
2489
|
objects: e,
|
|
2600
2490
|
withoutSave: t
|
|
2601
2491
|
} = {}) {
|
|
2602
|
-
const { canvas: s, historyManager:
|
|
2603
|
-
a != null && a.length && (
|
|
2492
|
+
const { canvas: s, historyManager: i, groupingManager: n } = this.editor, a = (e || s.getActiveObjects()).filter((o) => !o.locked);
|
|
2493
|
+
a != null && a.length && (i.suspendHistory(), a.forEach((o) => {
|
|
2604
2494
|
if (o.type === "group" && o.format !== "svg") {
|
|
2605
|
-
|
|
2495
|
+
n.ungroup({ object: o, withoutSave: t }), this.deleteSelectedObjects();
|
|
2606
2496
|
return;
|
|
2607
2497
|
}
|
|
2608
2498
|
s.remove(o);
|
|
2609
|
-
}), s.discardActiveObject(), s.renderAll(),
|
|
2499
|
+
}), s.discardActiveObject(), s.renderAll(), i.resumeHistory(), t || i.saveState(), s.fire("editor:objects-deleted", {
|
|
2610
2500
|
objects: a,
|
|
2611
2501
|
withoutSave: t
|
|
2612
2502
|
}));
|
|
2613
2503
|
}
|
|
2614
2504
|
}
|
|
2615
|
-
const
|
|
2505
|
+
const ct = {
|
|
2616
2506
|
IMAGE_MANAGER: {
|
|
2617
2507
|
/**
|
|
2618
2508
|
* Некорректный Content-Type изображения
|
|
@@ -2674,7 +2564,7 @@ const gt = {
|
|
|
2674
2564
|
REDO_ERROR: "REDO_ERROR"
|
|
2675
2565
|
}
|
|
2676
2566
|
};
|
|
2677
|
-
class
|
|
2567
|
+
class V {
|
|
2678
2568
|
constructor({ editor: e }) {
|
|
2679
2569
|
this._buffer = [], this.editor = e;
|
|
2680
2570
|
}
|
|
@@ -2700,22 +2590,22 @@ class G {
|
|
|
2700
2590
|
* @param options.message — текст ошибки (опционально, если не передан, то используется код ошибки)
|
|
2701
2591
|
* @fires editor:error
|
|
2702
2592
|
*/
|
|
2703
|
-
emitError({ origin: e = "ImageEditor", method: t = "Unknown Method", code: s, data:
|
|
2704
|
-
if (!
|
|
2593
|
+
emitError({ origin: e = "ImageEditor", method: t = "Unknown Method", code: s, data: i, message: n }) {
|
|
2594
|
+
if (!V.isValidErrorCode(s)) {
|
|
2705
2595
|
console.warn("Неизвестный код ошибки: ", { code: s, origin: e, method: t });
|
|
2706
2596
|
return;
|
|
2707
2597
|
}
|
|
2708
2598
|
if (!s) return;
|
|
2709
|
-
const a =
|
|
2710
|
-
console.error(`${e}. ${t}. ${s}. ${a}`,
|
|
2599
|
+
const a = n || s;
|
|
2600
|
+
console.error(`${e}. ${t}. ${s}. ${a}`, i);
|
|
2711
2601
|
const o = {
|
|
2712
2602
|
code: s,
|
|
2713
2603
|
origin: e,
|
|
2714
2604
|
method: t,
|
|
2715
2605
|
message: a,
|
|
2716
|
-
data:
|
|
2606
|
+
data: i
|
|
2717
2607
|
};
|
|
2718
|
-
this._buffer.push(
|
|
2608
|
+
this._buffer.push(f({
|
|
2719
2609
|
type: "editor:error"
|
|
2720
2610
|
}, o)), this.editor.canvas.fire("editor:error", o);
|
|
2721
2611
|
}
|
|
@@ -2729,21 +2619,21 @@ class G {
|
|
|
2729
2619
|
* @param options.message — текст предупреждения (опционально, если не передан, то используется код предупреждения)
|
|
2730
2620
|
* @fires editor:warning
|
|
2731
2621
|
*/
|
|
2732
|
-
emitWarning({ origin: e = "ImageEditor", method: t = "Unknown Method", code: s, message:
|
|
2733
|
-
if (!
|
|
2622
|
+
emitWarning({ origin: e = "ImageEditor", method: t = "Unknown Method", code: s, message: i, data: n }) {
|
|
2623
|
+
if (!V.isValidErrorCode(s)) {
|
|
2734
2624
|
console.warn("Неизвестный код предупреждения: ", { code: s, origin: e, method: t });
|
|
2735
2625
|
return;
|
|
2736
2626
|
}
|
|
2737
|
-
const a =
|
|
2738
|
-
console.warn(`${e}. ${t}. ${s}. ${a}`,
|
|
2627
|
+
const a = i || s;
|
|
2628
|
+
console.warn(`${e}. ${t}. ${s}. ${a}`, n);
|
|
2739
2629
|
const o = {
|
|
2740
2630
|
code: s,
|
|
2741
2631
|
origin: e,
|
|
2742
2632
|
method: t,
|
|
2743
2633
|
message: a,
|
|
2744
|
-
data:
|
|
2634
|
+
data: n
|
|
2745
2635
|
};
|
|
2746
|
-
this._buffer.push(
|
|
2636
|
+
this._buffer.push(f({
|
|
2747
2637
|
type: "editor:warning"
|
|
2748
2638
|
}, o)), this.editor.canvas.fire("editor:warning", o);
|
|
2749
2639
|
}
|
|
@@ -2753,7 +2643,7 @@ class G {
|
|
|
2753
2643
|
* @returns true, если код допустим, иначе false
|
|
2754
2644
|
*/
|
|
2755
2645
|
static isValidErrorCode(e) {
|
|
2756
|
-
return e ? Object.values(
|
|
2646
|
+
return e ? Object.values(ct).some((t) => Object.values(t).includes(e)) : !1;
|
|
2757
2647
|
}
|
|
2758
2648
|
}
|
|
2759
2649
|
class ie {
|
|
@@ -2771,23 +2661,23 @@ class ie {
|
|
|
2771
2661
|
* @fires editor:ready
|
|
2772
2662
|
*/
|
|
2773
2663
|
init() {
|
|
2774
|
-
return
|
|
2664
|
+
return I(this, null, function* () {
|
|
2775
2665
|
const {
|
|
2776
2666
|
editorContainerWidth: e,
|
|
2777
2667
|
editorContainerHeight: t,
|
|
2778
2668
|
canvasWrapperWidth: s,
|
|
2779
|
-
canvasWrapperHeight:
|
|
2780
|
-
canvasCSSWidth:
|
|
2669
|
+
canvasWrapperHeight: i,
|
|
2670
|
+
canvasCSSWidth: n,
|
|
2781
2671
|
canvasCSSHeight: a,
|
|
2782
2672
|
initialImage: o,
|
|
2783
2673
|
initialStateJSON: d,
|
|
2784
|
-
scaleType:
|
|
2674
|
+
scaleType: r,
|
|
2785
2675
|
_onReadyCallback: l
|
|
2786
2676
|
} = this.options;
|
|
2787
|
-
if (Re.apply(), this.canvas = new Ce(this.containerId, this.options), this.moduleLoader = new
|
|
2677
|
+
if (Re.apply(), this.canvas = new Ce(this.containerId, this.options), this.moduleLoader = new Ee(), this.workerManager = new Oe(), this.errorManager = new V({ editor: this }), this.historyManager = new Qe({ editor: this }), this.toolbar = new Xe({ editor: this }), this.transformManager = new tt({ editor: this }), this.canvasManager = new et({ editor: this }), this.imageManager = new N({ editor: this }), this.layerManager = new P({ editor: this }), this.shapeManager = new it({ editor: this }), this.interactionBlocker = new st({ editor: this }), this.clipboardManager = new nt({ editor: this }), this.objectLockManager = new F({ editor: this }), this.groupingManager = new at({ editor: this }), this.selectionManager = new ot({ editor: this }), this.deletionManager = new rt({ editor: this }), this._createMontageArea(), this._createClippingArea(), this.listeners = new z({ editor: this, options: this.options }), this.canvasManager.setEditorContainerWidth(e), this.canvasManager.setEditorContainerHeight(t), this.canvasManager.setCanvasWrapperWidth(s), this.canvasManager.setCanvasWrapperHeight(i), this.canvasManager.setCanvasCSSWidth(n), this.canvasManager.setCanvasCSSHeight(a), o != null && o.source) {
|
|
2788
2678
|
const {
|
|
2789
2679
|
source: h,
|
|
2790
|
-
scale: g = `image-${
|
|
2680
|
+
scale: g = `image-${r}`,
|
|
2791
2681
|
withoutSave: u = !0
|
|
2792
2682
|
} = o;
|
|
2793
2683
|
yield this.imageManager.importImage({ source: h, scale: g, withoutSave: u });
|
|
@@ -2863,7 +2753,7 @@ class ie {
|
|
|
2863
2753
|
});
|
|
2864
2754
|
}
|
|
2865
2755
|
}
|
|
2866
|
-
const
|
|
2756
|
+
const dt = {
|
|
2867
2757
|
/**
|
|
2868
2758
|
* Опции редактора
|
|
2869
2759
|
*/
|
|
@@ -2951,18 +2841,18 @@ const ut = {
|
|
|
2951
2841
|
deleteObjectsByHotkey: !0,
|
|
2952
2842
|
resetObjectFitByDoubleClick: !0
|
|
2953
2843
|
};
|
|
2954
|
-
function
|
|
2955
|
-
const t =
|
|
2844
|
+
function ft(c, e = {}) {
|
|
2845
|
+
const t = f(f({}, dt), e), s = document.getElementById(c);
|
|
2956
2846
|
if (!s)
|
|
2957
|
-
return Promise.reject(new Error(`Контейнер с ID "${
|
|
2958
|
-
const
|
|
2959
|
-
return
|
|
2960
|
-
t._onReadyCallback =
|
|
2961
|
-
const a = new ie(
|
|
2962
|
-
window[
|
|
2847
|
+
return Promise.reject(new Error(`Контейнер с ID "${c}" не найден.`));
|
|
2848
|
+
const i = document.createElement("canvas");
|
|
2849
|
+
return i.id = `${c}-canvas`, s.appendChild(i), t.editorContainer = s, new Promise((n) => {
|
|
2850
|
+
t._onReadyCallback = n;
|
|
2851
|
+
const a = new ie(i.id, t);
|
|
2852
|
+
window[c] = a;
|
|
2963
2853
|
});
|
|
2964
2854
|
}
|
|
2965
2855
|
export {
|
|
2966
|
-
|
|
2856
|
+
ft as default
|
|
2967
2857
|
};
|
|
2968
2858
|
//# sourceMappingURL=main.js.map
|