@anu3ev/fabric-image-editor 0.1.38 → 0.1.39

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.
Files changed (2) hide show
  1. package/dist/main.js +437 -413
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -1,24 +1,24 @@
1
- var Te = Object.defineProperty;
2
- var G = Object.getOwnPropertySymbols;
1
+ var Le = Object.defineProperty;
2
+ var X = Object.getOwnPropertySymbols;
3
3
  var Me = Object.prototype.hasOwnProperty, fe = Object.prototype.propertyIsEnumerable;
4
- var me = (o, e, t) => e in o ? Te(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t, w = (o, e) => {
4
+ var me = (o, e, t) => e in o ? Le(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t, C = (o, e) => {
5
5
  for (var t in e || (e = {}))
6
6
  Me.call(e, t) && me(o, t, e[t]);
7
- if (G)
8
- for (var t of G(e))
7
+ if (X)
8
+ for (var t of X(e))
9
9
  fe.call(e, t) && me(o, t, e[t]);
10
10
  return o;
11
11
  };
12
- var X = (o, e) => {
12
+ var Q = (o, e) => {
13
13
  var t = {};
14
14
  for (var a in o)
15
15
  Me.call(o, a) && e.indexOf(a) < 0 && (t[a] = o[a]);
16
- if (o != null && G)
17
- for (var a of G(o))
16
+ if (o != null && X)
17
+ for (var a of X(o))
18
18
  e.indexOf(a) < 0 && fe.call(o, a) && (t[a] = o[a]);
19
19
  return t;
20
20
  };
21
- var $ = (o, e, t) => new Promise((a, r) => {
21
+ var H = (o, e, t) => new Promise((a, r) => {
22
22
  var i = (c) => {
23
23
  try {
24
24
  s(t.next(c));
@@ -34,14 +34,14 @@ var $ = (o, e, t) => new Promise((a, r) => {
34
34
  }, s = (c) => c.done ? a(c.value) : Promise.resolve(c.value).then(i, n);
35
35
  s((t = t.apply(o, e)).next());
36
36
  });
37
- import { ActiveSelection as _, util as R, controlsUtils as Oe, InteractiveFabricObject as ke, loadSVGFromURL as xe, FabricImage as q, Point as Be, Rect as Ze, Circle as ze, Triangle as Ue, Group as Ye, Canvas as He, Pattern as Pe } from "fabric";
38
- import { create as _e } from "jsondiffpatch";
39
- var Re = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", D = function() {
37
+ import { ActiveSelection as W, util as _, controlsUtils as Ee, InteractiveFabricObject as Oe, loadSVGFromURL as Te, FabricImage as q, Point as ke, Rect as xe, Circle as Be, Triangle as Ze, Group as ze, Canvas as Ue, Pattern as Ye } from "fabric";
38
+ import { create as He } from "jsondiffpatch";
39
+ var Pe = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", S = function() {
40
40
  for (var e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 21, t = "", a = crypto.getRandomValues(new Uint8Array(e |= 0)); e--; )
41
- t += Re[a[e] & 63];
41
+ t += Pe[a[e] & 63];
42
42
  return t;
43
43
  };
44
- class P {
44
+ class R {
45
45
  /**
46
46
  * Конструктор принимает редактор и опции.
47
47
  * @param {Object} params
@@ -58,14 +58,14 @@ class P {
58
58
  * @param {Boolean} [params.options.resetObjectFitByDoubleClick] — сброс фита объекта по двойному клику
59
59
  */
60
60
  constructor({ editor: e, options: t = {} }) {
61
- this.isDragging = !1, this.lastMouseX = 0, this.lastMouseY = 0, this.isUndoRedoKeyPressed = !1, this.isSpacePressed = !1, this.canvasDragging = !1, this.mouseWheelZooming = !1, this.bringToFrontOnSelection = !1, this.resetObjectFitByDoubleClick = !1, this.copyObjectsByHotkey = !1, this.pasteImageFromClipboard = !1, this.undoRedoByHotKeys = !1, this.selectAllByHotkey = !1, this.deleteObjectsByHotkey = !1, this.adaptCanvasToContainer = !1, this.editor = e, this.canvas = e.canvas, this.options = t, this.handleAdaptCanvasToContainerBound = P.debounce(this.handleAdaptCanvasToContainer.bind(this), 500), this.handleCopyEventBound = this.handleCopyEvent.bind(this), this.handlePasteEventBound = this.handlePasteEvent.bind(this), this.handleUndoRedoEventBound = this.handleUndoRedoEvent.bind(this), this.handleUndoRedoKeyUpBound = this.handleUndoRedoKeyUp.bind(this), this.handleSelectAllEventBound = this.handleSelectAllEvent.bind(this), this.handleDeleteObjectsEventBound = this.handleDeleteObjectsEvent.bind(this), this.handleSpaceKeyDownBound = this.handleSpaceKeyDown.bind(this), this.handleSpaceKeyUpBound = this.handleSpaceKeyUp.bind(this), this.handleObjectModifiedHistoryBound = P.debounce(this.handleObjectModifiedHistory.bind(this), 300), this.handleObjectRotatingHistoryBound = P.debounce(this.handleObjectRotatingHistory.bind(this), 300), this.handleObjectAddedHistoryBound = this.handleObjectAddedHistory.bind(this), this.handleObjectRemovedHistoryBound = this.handleObjectRemovedHistory.bind(this), this.handleOverlayUpdateBound = this.handleOverlayUpdate.bind(this), this.handleCanvasDragStartBound = this.handleCanvasDragStart.bind(this), this.handleCanvasDraggingBound = this.handleCanvasDragging.bind(this), this.handleCanvasDragEndBound = this.handleCanvasDragEnd.bind(this), this.handleMouseWheelZoomBound = this.handleMouseWheelZoom.bind(this), this.handleBringToFrontBound = this.handleBringToFront.bind(this), this.handleResetObjectFitBound = this.handleResetObjectFit.bind(this), this.handleLockedSelectionBound = this._filterLockedSelection.bind(this), this.init();
61
+ this.isDragging = !1, this.lastMouseX = 0, this.lastMouseY = 0, this.isUndoRedoKeyPressed = !1, this.isSpacePressed = !1, this.canvasDragging = !1, this.mouseWheelZooming = !1, this.bringToFrontOnSelection = !1, this.resetObjectFitByDoubleClick = !1, this.copyObjectsByHotkey = !1, this.pasteImageFromClipboard = !1, this.undoRedoByHotKeys = !1, this.selectAllByHotkey = !1, this.deleteObjectsByHotkey = !1, this.adaptCanvasToContainerOnResize = !1, this.editor = e, this.canvas = e.canvas, this.options = t, this.handleContainerResizeBound = R.debounce(this.handleContainerResize.bind(this), 500), this.handleCopyEventBound = this.handleCopyEvent.bind(this), this.handlePasteEventBound = this.handlePasteEvent.bind(this), this.handleUndoRedoEventBound = this.handleUndoRedoEvent.bind(this), this.handleUndoRedoKeyUpBound = this.handleUndoRedoKeyUp.bind(this), this.handleSelectAllEventBound = this.handleSelectAllEvent.bind(this), this.handleDeleteObjectsEventBound = this.handleDeleteObjectsEvent.bind(this), this.handleSpaceKeyDownBound = this.handleSpaceKeyDown.bind(this), this.handleSpaceKeyUpBound = this.handleSpaceKeyUp.bind(this), this.handleObjectModifiedHistoryBound = R.debounce(this.handleObjectModifiedHistory.bind(this), 300), this.handleObjectRotatingHistoryBound = R.debounce(this.handleObjectRotatingHistory.bind(this), 300), this.handleObjectAddedHistoryBound = this.handleObjectAddedHistory.bind(this), this.handleObjectRemovedHistoryBound = this.handleObjectRemovedHistory.bind(this), this.handleOverlayUpdateBound = this.handleOverlayUpdate.bind(this), this.handleCanvasDragStartBound = this.handleCanvasDragStart.bind(this), this.handleCanvasDraggingBound = this.handleCanvasDragging.bind(this), this.handleCanvasDragEndBound = this.handleCanvasDragEnd.bind(this), this.handleMouseWheelZoomBound = this.handleMouseWheelZoom.bind(this), this.handleBringToFrontBound = this.handleBringToFront.bind(this), this.handleResetObjectFitBound = this.handleResetObjectFit.bind(this), this.handleLockedSelectionBound = this._filterLockedSelection.bind(this), this.init();
62
62
  }
63
63
  /**
64
64
  * Инициализация всех обработчиков согласно опциям.
65
65
  */
66
66
  init() {
67
67
  const {
68
- adaptCanvasToContainer: e,
68
+ adaptCanvasToContainerOnResize: e,
69
69
  canvasDragging: t,
70
70
  mouseWheelZooming: a,
71
71
  bringToFrontOnSelection: r,
@@ -74,9 +74,9 @@ class P {
74
74
  undoRedoByHotKeys: s,
75
75
  selectAllByHotkey: c,
76
76
  deleteObjectsByHotkey: u,
77
- resetObjectFitByDoubleClick: l
77
+ resetObjectFitByDoubleClick: d
78
78
  } = this.options;
79
- t && (this.canvas.on("mouse:down", this.handleCanvasDragStartBound), this.canvas.on("mouse:move", this.handleCanvasDraggingBound), this.canvas.on("mouse:up", this.handleCanvasDragEndBound), document.addEventListener("keydown", this.handleSpaceKeyDownBound, { capture: !0 }), document.addEventListener("keyup", this.handleSpaceKeyUpBound, { capture: !0 })), a && this.canvas.on("mouse:wheel", this.handleMouseWheelZoomBound), r && (this.canvas.on("selection:created", this.handleBringToFrontBound), this.canvas.on("selection:updated", this.handleBringToFrontBound)), l && this.canvas.on("mouse:dblclick", this.handleResetObjectFitBound), e && window.addEventListener("resize", this.handleAdaptCanvasToContainerBound, { capture: !0 }), i && document.addEventListener("keydown", this.handleCopyEventBound, { capture: !0 }), n && document.addEventListener("paste", this.handlePasteEventBound, { capture: !0 }), s && (document.addEventListener("keydown", this.handleUndoRedoEventBound, { capture: !0 }), document.addEventListener("keyup", this.handleUndoRedoKeyUpBound, { capture: !0 })), c && document.addEventListener("keydown", this.handleSelectAllEventBound, { capture: !0 }), u && document.addEventListener("keydown", this.handleDeleteObjectsEventBound, { capture: !0 }), this.canvas.on("object:modified", this.handleObjectModifiedHistoryBound), this.canvas.on("object:rotating", this.handleObjectRotatingHistoryBound), this.canvas.on("object:added", this.handleObjectAddedHistoryBound), this.canvas.on("object:removed", this.handleObjectRemovedHistoryBound), this.canvas.on("object:added", this.handleOverlayUpdateBound), this.canvas.on("selection:created", this.handleOverlayUpdateBound), this.canvas.on("selection:created", this.handleLockedSelectionBound), this.canvas.on("selection:updated", this.handleLockedSelectionBound);
79
+ t && (this.canvas.on("mouse:down", this.handleCanvasDragStartBound), this.canvas.on("mouse:move", this.handleCanvasDraggingBound), this.canvas.on("mouse:up", this.handleCanvasDragEndBound), document.addEventListener("keydown", this.handleSpaceKeyDownBound, { capture: !0 }), document.addEventListener("keyup", this.handleSpaceKeyUpBound, { capture: !0 })), a && this.canvas.on("mouse:wheel", this.handleMouseWheelZoomBound), r && (this.canvas.on("selection:created", this.handleBringToFrontBound), this.canvas.on("selection:updated", this.handleBringToFrontBound)), d && this.canvas.on("mouse:dblclick", this.handleResetObjectFitBound), e && window.addEventListener("resize", this.handleContainerResizeBound, { capture: !0 }), i && document.addEventListener("keydown", this.handleCopyEventBound, { capture: !0 }), n && document.addEventListener("paste", this.handlePasteEventBound, { capture: !0 }), s && (document.addEventListener("keydown", this.handleUndoRedoEventBound, { capture: !0 }), document.addEventListener("keyup", this.handleUndoRedoKeyUpBound, { capture: !0 })), c && document.addEventListener("keydown", this.handleSelectAllEventBound, { capture: !0 }), u && document.addEventListener("keydown", this.handleDeleteObjectsEventBound, { capture: !0 }), this.canvas.on("object:modified", this.handleObjectModifiedHistoryBound), this.canvas.on("object:rotating", this.handleObjectRotatingHistoryBound), this.canvas.on("object:added", this.handleObjectAddedHistoryBound), this.canvas.on("object:removed", this.handleObjectRemovedHistoryBound), this.canvas.on("object:added", this.handleOverlayUpdateBound), this.canvas.on("selection:created", this.handleOverlayUpdateBound), this.canvas.on("selection:created", this.handleLockedSelectionBound), this.canvas.on("selection:updated", this.handleLockedSelectionBound);
80
80
  }
81
81
  /**
82
82
  * При массовом выделении объектов удаляем из него залоченные.
@@ -95,7 +95,7 @@ class P {
95
95
  this.canvas.setActiveObject(r[0]);
96
96
  return;
97
97
  }
98
- const i = new _(r, {
98
+ const i = new W(r, {
99
99
  canvas: this.canvas
100
100
  });
101
101
  this.canvas.setActiveObject(i), this.canvas.requestRenderAll();
@@ -128,9 +128,8 @@ class P {
128
128
  * Обработчик изменения размеров окна браузера.
129
129
  * Адаптирует канвас к размерам контейнера.
130
130
  */
131
- handleAdaptCanvasToContainer() {
132
- const { width: e, height: t } = this.editor.montageArea;
133
- this.editor.canvasManager.setResolutionWidth(e, { adaptCanvasToContainer: !0, withoutSave: !0 }), this.editor.canvasManager.setResolutionHeight(t, { adaptCanvasToContainer: !0, withoutSave: !0 }), this.editor.canvasManager.centerMontageArea(), this.editor.selectionManager.selectAll(), this.editor.transformManager.fitObject({ fitAsOneObject: !0, withoutSave: !0 });
131
+ handleContainerResize() {
132
+ this.editor.canvasManager.updateCanvasAndFitObjects();
134
133
  }
135
134
  /**
136
135
  * Обработчик для Ctrl+C (копирование).
@@ -145,34 +144,10 @@ class P {
145
144
  }
146
145
  /**
147
146
  * Обработчик вставки объекта или изображения из буфера обмена.
148
- * @param {Object} event — объект события
149
- * @param {Object} event.clipboardData — данные из буфера обмена
150
- * @param {Array} event.clipboardData.items — элементы буфера обмена
151
- *
152
- * TODO: Попробовать вынести методы в классы-менеджеры.
147
+ * @param {ClipboardEvent} event — объект события
153
148
  */
154
- handlePasteEvent({ clipboardData: e }) {
155
- var n;
156
- if (!((n = e == null ? void 0 : e.items) != null && n.length)) return;
157
- const { imageManager: t } = this.editor, { items: a } = e, r = a[a.length - 1];
158
- if (r.type.indexOf("image") !== -1) {
159
- const s = r.getAsFile();
160
- if (!s) return;
161
- const c = new FileReader();
162
- c.onload = (u) => {
163
- u.target && this.editor.imageManager.importImage({ source: u.target.result });
164
- }, c.readAsDataURL(s);
165
- return;
166
- }
167
- const i = e.getData("text/html");
168
- if (i) {
169
- const u = new DOMParser().parseFromString(i, "text/html").querySelector("img");
170
- if (u != null && u.src) {
171
- t.importImage({ source: u.src });
172
- return;
173
- }
174
- }
175
- this.editor.clipboardManager.paste();
149
+ handlePasteEvent(e) {
150
+ this.editor.clipboardManager.handlePasteEvent(e);
176
151
  }
177
152
  /**
178
153
  * Обработчик для отмены/повтора (Ctrl+Z/Ctrl+Y).
@@ -182,7 +157,7 @@ class P {
182
157
  * @param {String} event.code — код клавиши
183
158
  */
184
159
  handleUndoRedoEvent(e) {
185
- return $(this, null, function* () {
160
+ return H(this, null, function* () {
186
161
  const { ctrlKey: t, metaKey: a, code: r, repeat: i } = e;
187
162
  !t && !a || i || this.isUndoRedoKeyPressed || (r === "KeyZ" ? (e.preventDefault(), this.isUndoRedoKeyPressed = !0, yield this.editor.historyManager.undo()) : r === "KeyY" && (e.preventDefault(), this.isUndoRedoKeyPressed = !0, yield this.editor.historyManager.redo()));
188
163
  });
@@ -311,7 +286,7 @@ class P {
311
286
  * Метод для удаления всех слушателей
312
287
  */
313
288
  destroy() {
314
- window.removeEventListener("resize", this.handleAdaptCanvasToContainerBound, { capture: !0 }), document.removeEventListener("keydown", this.handleCopyEventBound, { capture: !0 }), document.removeEventListener("paste", this.handlePasteEventBound, { capture: !0 }), document.removeEventListener("keydown", this.handleUndoRedoEventBound, { capture: !0 }), document.removeEventListener("keyup", this.handleUndoRedoKeyUpBound, { capture: !0 }), document.removeEventListener("keydown", this.handleSelectAllEventBound, { capture: !0 }), document.removeEventListener("keydown", this.handleDeleteObjectsEventBound, { capture: !0 }), this.options.canvasDragging && (this.canvas.off("mouse:down", this.handleCanvasDragStartBound), this.canvas.off("mouse:move", this.handleCanvasDraggingBound), this.canvas.off("mouse:up", this.handleCanvasDragEndBound), document.removeEventListener("keydown", this.handleSpaceKeyDownBound, { capture: !0 }), document.removeEventListener("keyup", this.handleSpaceKeyUpBound, { capture: !0 })), this.options.mouseWheelZooming && this.canvas.off("mouse:wheel", this.handleMouseWheelZoomBound), this.options.bringToFrontOnSelection && (this.canvas.off("selection:created", this.handleBringToFrontBound), this.canvas.off("selection:updated", this.handleBringToFrontBound)), this.options.resetObjectFitByDoubleClick && this.canvas.off("mouse:dblclick", this.handleResetObjectFitBound), this.canvas.off("object:modified", this.handleObjectModifiedHistoryBound), this.canvas.off("object:rotating", this.handleObjectRotatingHistoryBound), this.canvas.off("object:added", this.handleObjectAddedHistoryBound), this.canvas.off("object:removed", this.handleObjectRemovedHistoryBound), this.canvas.off("object:added", this.handleOverlayUpdateBound), this.canvas.off("selection:created", this.handleOverlayUpdateBound), this.canvas.off("selection:created", this.handleLockedSelectionBound), this.canvas.off("selection:updated", this.handleLockedSelectionBound);
289
+ window.removeEventListener("resize", this.handleContainerResizeBound, { capture: !0 }), document.removeEventListener("keydown", this.handleCopyEventBound, { capture: !0 }), document.removeEventListener("paste", this.handlePasteEventBound, { capture: !0 }), document.removeEventListener("keydown", this.handleUndoRedoEventBound, { capture: !0 }), document.removeEventListener("keyup", this.handleUndoRedoKeyUpBound, { capture: !0 }), document.removeEventListener("keydown", this.handleSelectAllEventBound, { capture: !0 }), document.removeEventListener("keydown", this.handleDeleteObjectsEventBound, { capture: !0 }), this.options.canvasDragging && (this.canvas.off("mouse:down", this.handleCanvasDragStartBound), this.canvas.off("mouse:move", this.handleCanvasDraggingBound), this.canvas.off("mouse:up", this.handleCanvasDragEndBound), document.removeEventListener("keydown", this.handleSpaceKeyDownBound, { capture: !0 }), document.removeEventListener("keyup", this.handleSpaceKeyUpBound, { capture: !0 })), this.options.mouseWheelZooming && this.canvas.off("mouse:wheel", this.handleMouseWheelZoomBound), this.options.bringToFrontOnSelection && (this.canvas.off("selection:created", this.handleBringToFrontBound), this.canvas.off("selection:updated", this.handleBringToFrontBound)), this.options.resetObjectFitByDoubleClick && this.canvas.off("mouse:dblclick", this.handleResetObjectFitBound), this.canvas.off("object:modified", this.handleObjectModifiedHistoryBound), this.canvas.off("object:rotating", this.handleObjectRotatingHistoryBound), this.canvas.off("object:added", this.handleObjectAddedHistoryBound), this.canvas.off("object:removed", this.handleObjectRemovedHistoryBound), this.canvas.off("object:added", this.handleOverlayUpdateBound), this.canvas.off("selection:created", this.handleOverlayUpdateBound), this.canvas.off("selection:created", this.handleLockedSelectionBound), this.canvas.off("selection:updated", this.handleLockedSelectionBound);
315
290
  }
316
291
  /**
317
292
  * Дебаунс для снижения частоты вызова функции.
@@ -329,7 +304,7 @@ class P {
329
304
  };
330
305
  }
331
306
  }
332
- class We {
307
+ class Re {
333
308
  /**
334
309
  * @description Класс для динамической загрузки внешних модулей.
335
310
  */
@@ -347,7 +322,7 @@ class We {
347
322
  return this.loaders[e] ? (this.cache.has(e) || this.cache.set(e, this.loaders[e]()), this.cache.get(e)) : Promise.reject(new Error('Unknown module "'.concat(e, '"')));
348
323
  }
349
324
  }
350
- class Fe {
325
+ class We {
351
326
  /**
352
327
  * @param {string|URL} [scriptUrl] — URL скрипта воркера.
353
328
  * По-умолчанию использует файл рядом с этим модулем
@@ -387,7 +362,7 @@ class Fe {
387
362
  * @returns {Promise<any>}
388
363
  */
389
364
  post(e, t) {
390
- var a = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : [], r = "".concat(e, ":").concat(D(8));
365
+ var a = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : [], r = "".concat(e, ":").concat(S(8));
391
366
  return new Promise((i, n) => {
392
367
  this._callbacks.set(r, {
393
368
  resolve: i,
@@ -406,52 +381,52 @@ class Fe {
406
381
  this.worker.terminate();
407
382
  }
408
383
  }
409
- var C = 12, Ve = 2, te = 8, ae = 20, Ge = 100, re = 20, ie = 8, Xe = 100, ne = 32, se = 1, Qe = "#2B2D33", oe = "#3D8BF4", ce = "#FFFFFF";
410
- function Q(o, e, t, a, r) {
411
- var i = C, n = Ve;
412
- o.save(), o.translate(e, t), o.rotate(R.degreesToRadians(r.angle)), o.fillStyle = ce, o.strokeStyle = oe, o.lineWidth = se, o.beginPath(), o.roundRect(-12 / 2, -12 / 2, i, i, n), o.fill(), o.stroke(), o.restore();
384
+ var I = 12, _e = 2, te = 8, ae = 20, Fe = 100, re = 20, ie = 8, Ve = 100, ne = 32, se = 1, Ge = "#2B2D33", oe = "#3D8BF4", ce = "#FFFFFF";
385
+ function J(o, e, t, a, r) {
386
+ var i = I, n = _e;
387
+ o.save(), o.translate(e, t), o.rotate(_.degreesToRadians(r.angle)), o.fillStyle = ce, o.strokeStyle = oe, o.lineWidth = se, o.beginPath(), o.roundRect(-12 / 2, -12 / 2, i, i, n), o.fill(), o.stroke(), o.restore();
413
388
  }
414
389
  function je(o, e, t, a, r) {
415
- var i = te, n = ae, s = Ge;
416
- o.save(), o.translate(e, t), o.rotate(R.degreesToRadians(r.angle)), o.fillStyle = ce, o.strokeStyle = oe, o.lineWidth = se, o.beginPath(), o.roundRect(-8 / 2, -20 / 2, i, n, s), o.fill(), o.stroke(), o.restore();
390
+ var i = te, n = ae, s = Fe;
391
+ o.save(), o.translate(e, t), o.rotate(_.degreesToRadians(r.angle)), o.fillStyle = ce, o.strokeStyle = oe, o.lineWidth = se, o.beginPath(), o.roundRect(-8 / 2, -20 / 2, i, n, s), o.fill(), o.stroke(), o.restore();
417
392
  }
418
393
  function ye(o, e, t, a, r) {
419
- var i = re, n = ie, s = Xe;
420
- o.save(), o.translate(e, t), o.rotate(R.degreesToRadians(r.angle)), o.fillStyle = ce, o.strokeStyle = oe, o.lineWidth = se, o.beginPath(), o.roundRect(-20 / 2, -8 / 2, i, n, s), o.fill(), o.stroke(), o.restore();
394
+ var i = re, n = ie, s = Ve;
395
+ o.save(), o.translate(e, t), o.rotate(_.degreesToRadians(r.angle)), o.fillStyle = ce, o.strokeStyle = oe, o.lineWidth = se, o.beginPath(), o.roundRect(-20 / 2, -8 / 2, i, n, s), o.fill(), o.stroke(), o.restore();
421
396
  }
422
- var Je = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTE4Ljc1IDQuMzc1djMuNzVhLjYyNS42MjUgMCAwIDEtLjYyNS42MjVoLTMuNzVhLjYyNS42MjUgMCAwIDEgMC0xLjI1aDIuMTRsLTIuMDc3LTEuOTAzLS4wMi0uMDE5YTYuMjUgNi4yNSAwIDEgMC0uMTMgOC45NjcuNjI2LjYyNiAwIDAgMSAuODYuOTA5QTcuNDU2IDcuNDU2IDAgMCAxIDEwIDE3LjVoLS4xMDNhNy41IDcuNSAwIDEgMSA1LjM5Ni0xMi44MTJMMTcuNSA2LjcwM1Y0LjM3NWEuNjI1LjYyNSAwIDAgMSAxLjI1IDBaIi8+PC9zdmc+", De = new Image();
423
- De.src = Je;
424
- function Ke(o, e, t, a, r) {
397
+ var Xe = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTE4Ljc1IDQuMzc1djMuNzVhLjYyNS42MjUgMCAwIDEtLjYyNS42MjVoLTMuNzVhLjYyNS42MjUgMCAwIDEgMC0xLjI1aDIuMTRsLTIuMDc3LTEuOTAzLS4wMi0uMDE5YTYuMjUgNi4yNSAwIDEgMC0uMTMgOC45NjcuNjI2LjYyNiAwIDAgMSAuODYuOTA5QTcuNDU2IDcuNDU2IDAgMCAxIDEwIDE3LjVoLS4xMDNhNy41IDcuNSAwIDEgMSA1LjM5Ni0xMi44MTJMMTcuNSA2LjcwM1Y0LjM3NWEuNjI1LjYyNSAwIDAgMSAxLjI1IDBaIi8+PC9zdmc+", Ae = new Image();
398
+ Ae.src = Xe;
399
+ function Qe(o, e, t, a, r) {
425
400
  var i = ne, n = i / 2;
426
- o.save(), o.translate(e, t), o.rotate(R.degreesToRadians(r.angle)), o.fillStyle = Qe, o.beginPath(), o.arc(0, 0, n, 0, 2 * Math.PI), o.fill(), o.drawImage(De, -16 / 2, -16 / 2, n, n), o.restore();
401
+ o.save(), o.translate(e, t), o.rotate(_.degreesToRadians(r.angle)), o.fillStyle = Ge, o.beginPath(), o.arc(0, 0, n, 0, 2 * Math.PI), o.fill(), o.drawImage(Ae, -16 / 2, -16 / 2, n, n), o.restore();
427
402
  }
428
- var $e = {
403
+ var Je = {
429
404
  // Угловые точки
430
405
  tl: {
431
- render: Q,
432
- sizeX: C,
433
- sizeY: C,
406
+ render: J,
407
+ sizeX: I,
408
+ sizeY: I,
434
409
  offsetX: 0,
435
410
  offsetY: 0
436
411
  },
437
412
  tr: {
438
- render: Q,
439
- sizeX: C,
440
- sizeY: C,
413
+ render: J,
414
+ sizeX: I,
415
+ sizeY: I,
441
416
  offsetX: 0,
442
417
  offsetY: 0
443
418
  },
444
419
  bl: {
445
- render: Q,
446
- sizeX: C,
447
- sizeY: C,
420
+ render: J,
421
+ sizeX: I,
422
+ sizeY: I,
448
423
  offsetX: 0,
449
424
  offsetY: 0
450
425
  },
451
426
  br: {
452
- render: Q,
453
- sizeX: C,
454
- sizeY: C,
427
+ render: J,
428
+ sizeX: I,
429
+ sizeY: I,
455
430
  offsetX: 0,
456
431
  offsetY: 0
457
432
  },
@@ -487,17 +462,17 @@ var $e = {
487
462
  },
488
463
  // Специальный «rotate» контрол
489
464
  mtr: {
490
- render: Ke,
465
+ render: Qe,
491
466
  sizeX: ne,
492
467
  sizeY: ne,
493
468
  offsetX: 0,
494
469
  offsetY: -32
495
470
  }
496
471
  };
497
- class qe {
472
+ class Ke {
498
473
  static apply() {
499
- var e = Oe.createObjectDefaultControls();
500
- Object.entries($e).forEach((t) => {
474
+ var e = Ee.createObjectDefaultControls();
475
+ Object.entries(Je).forEach((t) => {
501
476
  var [a, r] = t;
502
477
  Object.assign(e[a], {
503
478
  render: r.render,
@@ -509,10 +484,10 @@ class qe {
509
484
  var u = n.target;
510
485
  u.canvas.setCursor("grabbing");
511
486
  });
512
- }), ke.ownDefaults.controls = e;
487
+ }), Oe.ownDefaults.controls = e;
513
488
  }
514
489
  }
515
- var et = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNNi44NzUgMi41YS42MjUuNjI1IDAgMCAwLS42MjUuNjI0VjYuMjVIMy4xMjVhLjYyNS42MjUgMCAwIDAtLjYyNS42MjV2MTBjMCAuMzQ1LjI4LjYyNS42MjUuNjI1aDEwYy4zNDUgMCAuNjI1LS4yOC42MjUtLjYyNXYtMy4xMjZoMy4xMjVjLjM0NSAwIC42MjUtLjI4LjYyNS0uNjI1di0xMGEuNjI1LjYyNSAwIDAgMC0uNjI1LS42MjVoLTEwWm02Ljg3NSAxMGgyLjVWMy43NUg3LjV2Mi41aDUuNjI1Yy4zNDUgMCAuNjI1LjI4LjYyNS42MjV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1Wk01IDE2LjI1VjVoMTB2MTEuMjVINVpNOC4xMjUgNy41Yy4zNDUgMCAuNjI1LjI4LjYyNS42MjV2NWEuNjI1LjYyNSAwIDEgMS0xLjI1IDB2LTVjMC0uMzQ1LjI4LS42MjUuNjI1LS42MjVabTQuMzc1IDUuNjI1di01YS42MjUuNjI1IDAgMCAwLTEuMjUgMHY1YS42MjUuNjI1IDAgMSAwIDEuMjUgMFoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjwvc3ZnPg==";
516
491
  function pe(o, e, t, a, r, i, n) {
517
492
  try {
518
493
  var s = o[i](n), c = s.value;
@@ -521,7 +496,7 @@ function pe(o, e, t, a, r, i, n) {
521
496
  }
522
497
  s.done ? e(c) : Promise.resolve(c).then(a, r);
523
498
  }
524
- function ct(o) {
499
+ function st(o) {
525
500
  return function() {
526
501
  var e = this, t = arguments;
527
502
  return new Promise(function(a, r) {
@@ -536,7 +511,7 @@ function ct(o) {
536
511
  });
537
512
  };
538
513
  }
539
- const H = {
514
+ const P = {
540
515
  style: {
541
516
  position: "absolute",
542
517
  display: "none",
@@ -595,18 +570,18 @@ const H = {
595
570
  }],
596
571
  offsetTop: 50,
597
572
  icons: {
598
- copyPaste: et,
599
- delete: ot,
600
- lock: tt,
601
- unlock: at,
602
- bringToFront: nt,
603
- sendToBack: st,
604
- bringForward: rt,
605
- sendBackwards: it
573
+ copyPaste: $e,
574
+ delete: nt,
575
+ lock: qe,
576
+ unlock: et,
577
+ bringToFront: rt,
578
+ sendToBack: it,
579
+ bringForward: tt,
580
+ sendBackwards: at
606
581
  },
607
582
  handlers: {
608
583
  copyPaste: function() {
609
- var o = ct(function* (t) {
584
+ var o = st(function* (t) {
610
585
  yield t.clipboardManager.copy(), yield t.clipboardManager.paste();
611
586
  });
612
587
  function e(t) {
@@ -647,25 +622,25 @@ function be(o, e) {
647
622
  }
648
623
  return t;
649
624
  }
650
- function p(o) {
625
+ function j(o) {
651
626
  for (var e = 1; e < arguments.length; e++) {
652
627
  var t = arguments[e] != null ? arguments[e] : {};
653
628
  e % 2 ? be(Object(t), !0).forEach(function(a) {
654
- ut(o, a, t[a]);
629
+ ot(o, a, t[a]);
655
630
  }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(o, Object.getOwnPropertyDescriptors(t)) : be(Object(t)).forEach(function(a) {
656
631
  Object.defineProperty(o, a, Object.getOwnPropertyDescriptor(t, a));
657
632
  });
658
633
  }
659
634
  return o;
660
635
  }
661
- function ut(o, e, t) {
662
- return (e = dt(e)) in o ? Object.defineProperty(o, e, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : o[e] = t, o;
636
+ function ot(o, e, t) {
637
+ return (e = ct(e)) in o ? Object.defineProperty(o, e, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : o[e] = t, o;
663
638
  }
664
- function dt(o) {
665
- var e = lt(o, "string");
639
+ function ct(o) {
640
+ var e = ut(o, "string");
666
641
  return typeof e == "symbol" ? e : e + "";
667
642
  }
668
- function lt(o, e) {
643
+ function ut(o, e) {
669
644
  if (typeof o != "object" || !o) return o;
670
645
  var t = o[Symbol.toPrimitive];
671
646
  if (t !== void 0) {
@@ -675,7 +650,7 @@ function lt(o, e) {
675
650
  }
676
651
  return (e === "string" ? String : Number)(o);
677
652
  }
678
- class ht {
653
+ class dt {
679
654
  /**
680
655
  * @param {object} options
681
656
  * @param {ImageEditor} options.editor - экземпляр редактора с доступом к canvas
@@ -687,11 +662,11 @@ class ht {
687
662
  if (this.options = t.options, !!this.options.showToolbar) {
688
663
  this.editor = t, this.canvas = t.canvas;
689
664
  var a = this.options.toolbar || {};
690
- this.config = p(p(p({}, H), a), {}, {
691
- style: p(p({}, H.style), a.style || {}),
692
- btnStyle: p(p({}, H.btnStyle), a.btnStyle || {}),
693
- icons: p(p({}, H.icons), a.icons || {}),
694
- handlers: p(p({}, H.handlers), a.handlers || {})
665
+ this.config = j(j(j({}, P), a), {}, {
666
+ style: j(j({}, P.style), a.style || {}),
667
+ btnStyle: j(j({}, P.btnStyle), a.btnStyle || {}),
668
+ icons: j(j({}, P.icons), a.icons || {}),
669
+ handlers: j(j({}, P.handlers), a.handlers || {})
695
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 = () => {
696
671
  this.el.style.display = "none";
697
672
  }, this._createDOM(), this._bindEvents();
@@ -730,12 +705,12 @@ class ht {
730
705
  } = r, {
731
706
  icons: c,
732
707
  btnStyle: u,
733
- handlers: l
734
- } = t.config, d = document.createElement("button");
735
- d.innerHTML = c[s] ? '<img src="'.concat(c[s], '" title="').concat(n, '" />') : n, Object.assign(d.style, u), d.onclick = () => {
708
+ handlers: d
709
+ } = t.config, l = document.createElement("button");
710
+ l.innerHTML = c[s] ? '<img src="'.concat(c[s], '" title="').concat(n, '" />') : n, Object.assign(l.style, u), l.onclick = () => {
736
711
  var h;
737
- return (h = l[s]) === null || h === void 0 ? void 0 : h.call(l, t.editor);
738
- }, t.el.appendChild(d);
712
+ return (h = d[s]) === null || h === void 0 ? void 0 : h.call(d, t.editor);
713
+ }, t.el.appendChild(l);
739
714
  };
740
715
  for (var r of e)
741
716
  a();
@@ -811,8 +786,8 @@ class ht {
811
786
  x: c
812
787
  } = e.getCenterPoint(), {
813
788
  top: u,
814
- height: l
815
- } = e.getBoundingRect(!1, !0), d = c * i + n, h = d - t.offsetWidth / 2, g = (u + l) * i + s + a.offsetTop;
789
+ height: d
790
+ } = e.getBoundingRect(!1, !0), l = c * i + n, h = l - t.offsetWidth / 2, g = (u + d) * i + s + a.offsetTop;
816
791
  Object.assign(t.style, {
817
792
  left: "".concat(h, "px"),
818
793
  top: "".concat(g, "px"),
@@ -850,7 +825,7 @@ function ee(o) {
850
825
  });
851
826
  };
852
827
  }
853
- class gt {
828
+ class lt {
854
829
  /**
855
830
  * @param {object} options
856
831
  * @param {ImageEditor} options.editor - экземпляр редактора с доступом к canvas
@@ -869,7 +844,7 @@ class gt {
869
844
  return this.patches[this.currentIndex - 1] || null;
870
845
  }
871
846
  _createDiffPatcher() {
872
- this.diffPatcher = _e({
847
+ this.diffPatcher = He({
873
848
  objectHash(e) {
874
849
  return [e.id, e.format, e.locked, e.left, e.top, e.width, e.height, e.flipX, e.flipY, e.scaleX, e.scaleY, e.angle, e.opacity].join("-");
875
850
  },
@@ -933,7 +908,7 @@ class gt {
933
908
  return;
934
909
  }
935
910
  console.log("baseState", this.baseState), this.currentIndex < this.patches.length && this.patches.splice(this.currentIndex), console.log("diff", a), this.totalChangesCount += 1, this.patches.push({
936
- id: D(),
911
+ id: S(),
937
912
  diff: a
938
913
  }), this.currentIndex += 1, this.patches.length > this.maxHistoryLength && (this.baseState = this.diffPatcher.patch(this.baseState, this.patches[0].diff), this.patches.shift(), this.currentIndex -= 1, this.baseStateChangesCount += 1), console.log("Состояние сохранено. Текущий индекс истории:", this.currentIndex);
939
914
  }
@@ -947,11 +922,27 @@ class gt {
947
922
  var t = this;
948
923
  return ee(function* () {
949
924
  if (e) {
950
- console.log("loadStateFromFullState fullState", e), yield t.canvas.loadFromJSON(e);
951
- var a = t.canvas.getObjects().find((i) => i.id === "montage-area");
952
- a && (t.editor.montageArea = a);
953
- var r = t.canvas.getObjects().find((i) => i.id === "overlay-mask");
954
- r && (t.editor.interactionBlocker.overlayMask = r, t.editor.interactionBlocker.overlayMask.visible = !1), t.canvas.renderAll(), t.canvas.fire("editor:history-state-loaded");
925
+ console.log("loadStateFromFullState fullState", e);
926
+ var {
927
+ canvas: a,
928
+ canvasManager: r,
929
+ interactionBlocker: i
930
+ } = t.editor, {
931
+ width: n,
932
+ height: s
933
+ } = a;
934
+ yield a.loadFromJSON(e);
935
+ var c = a.getObjects().find((d) => d.id === "montage-area");
936
+ c && (t.editor.montageArea = c, (n !== e.width || s !== e.height) && r.updateCanvasAndFitObjects());
937
+ var u = a.getObjects().find((d) => d.id === "overlay-mask");
938
+ u && (i.overlayMask = u, i.overlayMask.visible = !1), a.renderAll(), a.fire("editor:history-state-loaded", {
939
+ fullState: e,
940
+ currentIndex: t.currentIndex,
941
+ totalChangesCount: t.totalChangesCount,
942
+ baseStateChangesCount: t.baseStateChangesCount,
943
+ patchesCount: t.patches.length,
944
+ patches: t.patches
945
+ });
955
946
  }
956
947
  })();
957
948
  }
@@ -1010,7 +1001,7 @@ class gt {
1010
1001
  })();
1011
1002
  }
1012
1003
  }
1013
- const vt = 0.1, mt = 2, Mt = 0.1, ft = 90, k = 16, x = 16, E = 4096, T = 4096;
1004
+ const ht = 0.1, gt = 2, vt = 0.1, mt = 90, k = 16, x = 16, E = 4096, O = 4096;
1014
1005
  function Se(o, e, t, a, r, i, n) {
1015
1006
  try {
1016
1007
  var s = o[i](n), c = s.value;
@@ -1019,7 +1010,7 @@ function Se(o, e, t, a, r, i, n) {
1019
1010
  }
1020
1011
  s.done ? e(c) : Promise.resolve(c).then(a, r);
1021
1012
  }
1022
- function O(o) {
1013
+ function T(o) {
1023
1014
  return function() {
1024
1015
  var e = this, t = arguments;
1025
1016
  return new Promise(function(a, r) {
@@ -1034,7 +1025,7 @@ function O(o) {
1034
1025
  });
1035
1026
  };
1036
1027
  }
1037
- class L {
1028
+ class w {
1038
1029
  /**
1039
1030
  * @param {object} options
1040
1031
  * @param {ImageEditor} options.editor - экземпляр редактора с доступом к canvas
@@ -1059,7 +1050,7 @@ class L {
1059
1050
  */
1060
1051
  importImage(e) {
1061
1052
  var t = this;
1062
- return O(function* () {
1053
+ return T(function* () {
1063
1054
  var {
1064
1055
  source: a,
1065
1056
  scale: r = "image-".concat(t.options.scaleType),
@@ -1071,14 +1062,14 @@ class L {
1071
1062
  montageArea: s,
1072
1063
  transformManager: c,
1073
1064
  historyManager: u,
1074
- errorManager: l
1075
- } = t.editor, d = yield t.getContentType(a), h = L.getFormatFromContentType(d), {
1065
+ errorManager: d
1066
+ } = t.editor, l = yield t.getContentType(a), h = w.getFormatFromContentType(l), {
1076
1067
  acceptContentTypes: g,
1077
1068
  acceptFormats: M
1078
1069
  } = t;
1079
- if (!t.isAllowedContentType(d)) {
1080
- var m = "Неверный contentType для изображения: ".concat(d, ". Ожидается один из: ").concat(t.acceptContentTypes.join(", "), ".");
1081
- return l.emitError({
1070
+ if (!t.isAllowedContentType(l)) {
1071
+ var m = "Неверный contentType для изображения: ".concat(l, ". Ожидается один из: ").concat(t.acceptContentTypes.join(", "), ".");
1072
+ return d.emitError({
1082
1073
  origin: "ImageManager",
1083
1074
  method: "importImage",
1084
1075
  code: "INVALID_CONTENT_TYPE",
@@ -1086,7 +1077,7 @@ class L {
1086
1077
  data: {
1087
1078
  source: a,
1088
1079
  format: h,
1089
- contentType: d,
1080
+ contentType: l,
1090
1081
  acceptContentTypes: g,
1091
1082
  acceptFormats: M
1092
1083
  }
@@ -1098,15 +1089,15 @@ class L {
1098
1089
  if (a instanceof File)
1099
1090
  f = URL.createObjectURL(a);
1100
1091
  else if (typeof a == "string") {
1101
- var N = yield fetch(a, {
1092
+ var A = yield fetch(a, {
1102
1093
  mode: "cors"
1103
- }), b = yield N.blob({
1104
- type: d,
1094
+ }), D = yield A.blob({
1095
+ type: l,
1105
1096
  quality: 1
1106
1097
  });
1107
- f = URL.createObjectURL(b);
1098
+ f = URL.createObjectURL(D);
1108
1099
  } else
1109
- return l.emitError({
1100
+ return d.emitError({
1110
1101
  origin: "ImageManager",
1111
1102
  method: "importImage",
1112
1103
  code: "INVALID_SOURCE_TYPE",
@@ -1114,41 +1105,41 @@ class L {
1114
1105
  data: {
1115
1106
  source: a,
1116
1107
  format: h,
1117
- contentType: d,
1108
+ contentType: l,
1118
1109
  acceptContentTypes: g,
1119
1110
  acceptFormats: M
1120
1111
  }
1121
1112
  }), null;
1122
1113
  if (t._createdBlobUrls.push(f), h === "svg") {
1123
- var I = yield xe(f);
1124
- v = R.groupSVGElements(I.objects, I.options);
1114
+ var N = yield Te(f);
1115
+ v = _.groupSVGElements(N.objects, N.options);
1125
1116
  } else
1126
1117
  v = yield q.fromURL(f, {
1127
1118
  crossOrigin: "anonymous"
1128
1119
  });
1129
1120
  var {
1130
- width: S,
1131
- height: j
1121
+ width: L,
1122
+ height: y
1132
1123
  } = v;
1133
- if (j > T || S > E) {
1134
- var y = yield t.resizeImageToBoundaries(v._element.src, "max"), B = URL.createObjectURL(y);
1124
+ if (y > O || L > E) {
1125
+ var p = yield t.resizeImageToBoundaries(v._element.src, "max"), B = URL.createObjectURL(p);
1135
1126
  t._createdBlobUrls.push(B), v = yield q.fromURL(B, {
1136
1127
  crossOrigin: "anonymous"
1137
1128
  });
1138
- } else if (j < x || S < k) {
1139
- var W = yield t.resizeImageToBoundaries(v._element.src, "min"), Z = URL.createObjectURL(W);
1129
+ } else if (y < x || L < k) {
1130
+ var F = yield t.resizeImageToBoundaries(v._element.src, "min"), Z = URL.createObjectURL(F);
1140
1131
  t._createdBlobUrls.push(Z), v = yield q.fromURL(Z, {
1141
1132
  crossOrigin: "anonymous"
1142
1133
  });
1143
1134
  }
1144
- if (v.set("id", "".concat(v.type, "-").concat(D())), v.set("format", h), r === "scale-montage")
1135
+ if (v.set("id", "".concat(v.type, "-").concat(S())), v.set("format", h), r === "scale-montage")
1145
1136
  t.editor.canvasManager.scaleMontageAreaToImage({
1146
1137
  object: v,
1147
1138
  withoutSave: !0
1148
1139
  });
1149
1140
  else {
1150
1141
  var {
1151
- width: F,
1142
+ width: V,
1152
1143
  height: z
1153
1144
  } = s, U = t.calculateScaleFactor({
1154
1145
  imageObject: v,
@@ -1158,24 +1149,24 @@ class L {
1158
1149
  object: v,
1159
1150
  type: "contain",
1160
1151
  withoutSave: !0
1161
- }) : r === "image-cover" && (S > F || j > z) && c.fitObject({
1152
+ }) : r === "image-cover" && (L > V || y > z) && c.fitObject({
1162
1153
  object: v,
1163
1154
  type: "cover",
1164
1155
  withoutSave: !0
1165
1156
  });
1166
1157
  }
1167
1158
  n.add(v), n.centerObject(v), n.setActiveObject(v), n.renderAll(), u.resumeHistory(), i || u.saveState();
1168
- var V = {
1159
+ var G = {
1169
1160
  image: v,
1170
1161
  format: h,
1171
- contentType: d,
1162
+ contentType: l,
1172
1163
  scale: r,
1173
1164
  withoutSave: i,
1174
1165
  source: a
1175
1166
  };
1176
- return n.fire("editor:image-imported", V), V;
1167
+ return n.fire("editor:image-imported", G), G;
1177
1168
  } catch (Y) {
1178
- return l.emitError({
1169
+ return d.emitError({
1179
1170
  origin: "ImageManager",
1180
1171
  method: "importImage",
1181
1172
  code: "IMPORT_FAILED",
@@ -1183,7 +1174,7 @@ class L {
1183
1174
  data: {
1184
1175
  source: a,
1185
1176
  format: h,
1186
- contentType: d,
1177
+ contentType: l,
1187
1178
  scale: r,
1188
1179
  withoutSave: i
1189
1180
  }
@@ -1201,14 +1192,14 @@ class L {
1201
1192
  */
1202
1193
  resizeImageToBoundaries(e) {
1203
1194
  var t = arguments, a = this;
1204
- return O(function* () {
1205
- var r = t.length > 1 && t[1] !== void 0 ? t[1] : "max", i = "Размер изображения больше максимального размера канваса, поэтому оно будет уменьшено до максимальных размеров c сохранением пропорций: ".concat(E, "x").concat(T);
1195
+ return T(function* () {
1196
+ var r = t.length > 1 && t[1] !== void 0 ? t[1] : "max", i = "Размер изображения больше максимального размера канваса, поэтому оно будет уменьшено до максимальных размеров c сохранением пропорций: ".concat(E, "x").concat(O);
1206
1197
  r === "min" && (i = "Размер изображения меньше минимального размера канваса, поэтому оно будет увеличено до минимальных размеров c сохранением пропорций: ".concat(k, "x").concat(x));
1207
1198
  var n = {
1208
1199
  dataURL: e,
1209
1200
  sizeType: r,
1210
1201
  maxWidth: E,
1211
- maxHeight: T,
1202
+ maxHeight: O,
1212
1203
  minWidth: k,
1213
1204
  minHeight: x
1214
1205
  };
@@ -1234,7 +1225,7 @@ class L {
1234
1225
  */
1235
1226
  exportCanvasAsImageFile() {
1236
1227
  var e = arguments, t = this;
1237
- return O(function* () {
1228
+ return T(function* () {
1238
1229
  var {
1239
1230
  fileName: a = "image.png",
1240
1231
  contentType: r = "image/png",
@@ -1246,7 +1237,7 @@ class L {
1246
1237
  workerManager: u
1247
1238
  } = t.editor;
1248
1239
  try {
1249
- var l = r === "application/pdf", d = l ? "image/jpg" : r, h = L.getFormatFromContentType(d);
1240
+ var d = r === "application/pdf", l = d ? "image/jpg" : r, h = w.getFormatFromContentType(l);
1250
1241
  c.setCoords();
1251
1242
  var {
1252
1243
  left: g,
@@ -1254,66 +1245,66 @@ class L {
1254
1245
  width: m,
1255
1246
  height: f
1256
1247
  } = c.getBoundingRect(), v = yield s.clone(["id", "format", "locked"]);
1257
- ["image/jpg", "image/jpeg"].includes(d) && (v.backgroundColor = "#ffffff");
1258
- var N = v.getObjects().find((A) => A.id === c.id);
1259
- N.visible = !1, v.viewportTransform = [1, 0, 0, 1, -g, -M], v.setDimensions({
1248
+ ["image/jpg", "image/jpeg"].includes(l) && (v.backgroundColor = "#ffffff");
1249
+ var A = v.getObjects().find((b) => b.id === c.id);
1250
+ A.visible = !1, v.viewportTransform = [1, 0, 0, 1, -g, -M], v.setDimensions({
1260
1251
  width: m,
1261
1252
  height: f
1262
1253
  }, {
1263
1254
  backstoreOnly: !0
1264
1255
  }), v.renderAll();
1265
- var b = v.getObjects().filter((A) => A.format).every((A) => A.format === "svg");
1266
- if (h === "svg" && b) {
1267
- var I = v.toSVG();
1256
+ var D = v.getObjects().filter((b) => b.format).every((b) => b.format === "svg");
1257
+ if (h === "svg" && D) {
1258
+ var N = v.toSVG();
1268
1259
  v.dispose();
1269
- var S = L._exportSVGStringAsFile(I, {
1260
+ var L = w._exportSVGStringAsFile(N, {
1270
1261
  exportAsBase64: i,
1271
1262
  exportAsBlob: n,
1272
1263
  fileName: a
1273
- }), j = {
1274
- image: S,
1264
+ }), y = {
1265
+ image: L,
1275
1266
  format: "svg",
1276
1267
  contentType: "image/svg+xml",
1277
1268
  fileName: a.replace(/\.[^/.]+$/, ".svg")
1278
1269
  };
1279
- return s.fire("editor:canvas-exported", j), j;
1270
+ return s.fire("editor:canvas-exported", y), y;
1280
1271
  }
1281
- var y = yield new Promise((A) => {
1282
- v.getElement().toBlob(A);
1272
+ var p = yield new Promise((b) => {
1273
+ v.getElement().toBlob(b);
1283
1274
  });
1284
1275
  if (v.dispose(), n) {
1285
1276
  var B = {
1286
- image: y,
1277
+ image: p,
1287
1278
  format: h,
1288
- contentType: d,
1279
+ contentType: l,
1289
1280
  fileName: a
1290
1281
  };
1291
1282
  return s.fire("editor:canvas-exported", B), B;
1292
1283
  }
1293
- var W = yield createImageBitmap(y), Z = yield u.post("toDataURL", {
1284
+ var F = yield createImageBitmap(p), Z = yield u.post("toDataURL", {
1294
1285
  format: h,
1295
1286
  quality: 1,
1296
- bitmap: W
1297
- }, [W]);
1298
- if (l) {
1299
- var F = 0.264583, z = m * F, U = f * F, V = (yield t.editor.moduleLoader.loadModule("jspdf")).jsPDF, Y = new V({
1287
+ bitmap: F
1288
+ }, [F]);
1289
+ if (d) {
1290
+ var V = 0.264583, z = m * V, U = f * V, G = (yield t.editor.moduleLoader.loadModule("jspdf")).jsPDF, Y = new G({
1300
1291
  orientation: z > U ? "landscape" : "portrait",
1301
1292
  unit: "mm",
1302
1293
  format: [z, U]
1303
1294
  });
1304
1295
  if (Y.addImage(Z, "JPG", 0, 0, z, U), i) {
1305
- var Ne = Y.output("datauristring"), de = {
1306
- image: Ne,
1296
+ var Ce = Y.output("datauristring"), de = {
1297
+ image: Ce,
1307
1298
  format: "pdf",
1308
1299
  contentType: "application/pdf",
1309
1300
  fileName: a
1310
1301
  };
1311
1302
  return s.fire("editor:canvas-exported", de), de;
1312
1303
  }
1313
- var we = Y.output("blob"), Le = new File([we], a, {
1304
+ var we = Y.output("blob"), De = new File([we], a, {
1314
1305
  type: "application/pdf"
1315
1306
  }), le = {
1316
- image: Le,
1307
+ image: De,
1317
1308
  format: "pdf",
1318
1309
  contentType: "application/pdf",
1319
1310
  fileName: a
@@ -1324,26 +1315,26 @@ class L {
1324
1315
  var he = {
1325
1316
  image: Z,
1326
1317
  format: h,
1327
- contentType: d,
1318
+ contentType: l,
1328
1319
  fileName: a
1329
1320
  };
1330
1321
  return s.fire("editor:canvas-exported", he), he;
1331
1322
  }
1332
- var ge = h === "svg" && !b ? a.replace(/\.[^/.]+$/, ".png") : a, Ee = new File([y], ge, {
1333
- type: d
1323
+ var ge = h === "svg" && !D ? a.replace(/\.[^/.]+$/, ".png") : a, Ne = new File([p], ge, {
1324
+ type: l
1334
1325
  }), ve = {
1335
- image: Ee,
1326
+ image: Ne,
1336
1327
  format: h,
1337
- contentType: d,
1328
+ contentType: l,
1338
1329
  fileName: ge
1339
1330
  };
1340
1331
  return s.fire("editor:canvas-exported", ve), ve;
1341
- } catch (A) {
1332
+ } catch (b) {
1342
1333
  return t.editor.errorManager.emitError({
1343
1334
  origin: "ImageManager",
1344
1335
  method: "exportCanvasAsImageFile",
1345
1336
  code: "IMAGE_EXPORT_FAILED",
1346
- message: "Ошибка экспорта изображения: ".concat(A.message),
1337
+ message: "Ошибка экспорта изображения: ".concat(b.message),
1347
1338
  data: {
1348
1339
  contentType: r,
1349
1340
  fileName: a,
@@ -1367,7 +1358,7 @@ class L {
1367
1358
  */
1368
1359
  exportObjectAsImageFile() {
1369
1360
  var e = arguments, t = this;
1370
- return O(function* () {
1361
+ return T(function* () {
1371
1362
  var {
1372
1363
  object: a,
1373
1364
  fileName: r = "image.png",
@@ -1377,8 +1368,8 @@ class L {
1377
1368
  } = e.length > 0 && e[0] !== void 0 ? e[0] : {}, {
1378
1369
  canvas: c,
1379
1370
  workerManager: u
1380
- } = t.editor, l = a || c.getActiveObject();
1381
- if (!l)
1371
+ } = t.editor, d = a || c.getActiveObject();
1372
+ if (!d)
1382
1373
  return t.editor.errorManager.emitError({
1383
1374
  origin: "ImageManager",
1384
1375
  method: "exportObjectAsImageFile",
@@ -1392,60 +1383,60 @@ class L {
1392
1383
  }
1393
1384
  }), "";
1394
1385
  try {
1395
- var d = L.getFormatFromContentType(i);
1396
- if (d === "svg") {
1397
- var h = l.toSVG(), g = t._exportSVGStringAsFile(h, {
1386
+ var l = w.getFormatFromContentType(i);
1387
+ if (l === "svg") {
1388
+ var h = d.toSVG(), g = t._exportSVGStringAsFile(h, {
1398
1389
  exportAsBase64: n,
1399
1390
  exportAsBlob: s,
1400
1391
  fileName: r
1401
1392
  }), M = {
1402
1393
  image: g,
1403
- format: d,
1394
+ format: l,
1404
1395
  contentType: "image/svg+xml",
1405
1396
  fileName: r.replace(/\.[^/.]+$/, ".svg")
1406
1397
  };
1407
1398
  return c.fire("editor:object-exported", M), M;
1408
1399
  }
1409
1400
  if (n) {
1410
- var m = yield createImageBitmap(l._element), f = yield u.post("toDataURL", {
1411
- format: d,
1401
+ var m = yield createImageBitmap(d._element), f = yield u.post("toDataURL", {
1402
+ format: l,
1412
1403
  quality: 1,
1413
1404
  bitmap: m
1414
1405
  }, [m]), v = {
1415
1406
  image: f,
1416
- format: d,
1407
+ format: l,
1417
1408
  contentType: i,
1418
1409
  fileName: r
1419
1410
  };
1420
1411
  return c.fire("editor:object-exported", v), v;
1421
1412
  }
1422
- var N = l.toCanvasElement(), b = yield new Promise((y) => {
1423
- N.toBlob(y);
1413
+ var A = d.toCanvasElement(), D = yield new Promise((p) => {
1414
+ A.toBlob(p);
1424
1415
  });
1425
1416
  if (s) {
1426
- var I = {
1427
- image: b,
1428
- format: d,
1417
+ var N = {
1418
+ image: D,
1419
+ format: l,
1429
1420
  contentType: i,
1430
1421
  fileName: r
1431
1422
  };
1432
- return c.fire("editor:object-exported", I), I;
1423
+ return c.fire("editor:object-exported", N), N;
1433
1424
  }
1434
- var S = new File([b], r, {
1425
+ var L = new File([D], r, {
1435
1426
  type: i
1436
- }), j = {
1437
- image: S,
1438
- format: d,
1427
+ }), y = {
1428
+ image: L,
1429
+ format: l,
1439
1430
  contentType: i,
1440
1431
  fileName: r
1441
1432
  };
1442
- return c.fire("editor:object-exported", j), j;
1443
- } catch (y) {
1433
+ return c.fire("editor:object-exported", y), y;
1434
+ } catch (p) {
1444
1435
  return t.editor.errorManager.emitError({
1445
1436
  origin: "ImageManager",
1446
1437
  method: "exportObjectAsImageFile",
1447
1438
  code: "IMAGE_EXPORT_FAILED",
1448
- message: "Ошибка экспорта объекта: ".concat(y.message),
1439
+ message: "Ошибка экспорта объекта: ".concat(p.message),
1449
1440
  data: {
1450
1441
  contentType: i,
1451
1442
  fileName: r,
@@ -1491,7 +1482,7 @@ class L {
1491
1482
  * @returns {string[]} - массив допустимых форматов изображений
1492
1483
  */
1493
1484
  getAllowedFormatsFromContentTypes() {
1494
- return this.acceptContentTypes.map((e) => L.getFormatFromContentType(e)).filter((e) => e);
1485
+ return this.acceptContentTypes.map((e) => w.getFormatFromContentType(e)).filter((e) => e);
1495
1486
  }
1496
1487
  /**
1497
1488
  * Извлекает чистый формат (subtype) из contentType,
@@ -1521,7 +1512,7 @@ class L {
1521
1512
  */
1522
1513
  getContentType(e) {
1523
1514
  var t = this;
1524
- return O(function* () {
1515
+ return T(function* () {
1525
1516
  return typeof e == "string" ? t.getContentTypeFromUrl(e) : e.type || "application/octet-stream";
1526
1517
  })();
1527
1518
  }
@@ -1533,7 +1524,7 @@ class L {
1533
1524
  */
1534
1525
  getContentTypeFromUrl(e) {
1535
1526
  var t = this;
1536
- return O(function* () {
1527
+ return T(function* () {
1537
1528
  if (e.startsWith("data:")) {
1538
1529
  var a = e.match(/^data:([^;]+)/);
1539
1530
  return a ? a[1] : "application/octet-stream";
@@ -1560,7 +1551,7 @@ class L {
1560
1551
  try {
1561
1552
  var t, a = new URL(e), r = (t = a.pathname.split(".").pop()) === null || t === void 0 ? void 0 : t.toLowerCase(), i = {};
1562
1553
  return this.acceptContentTypes.forEach((n) => {
1563
- var s = L.getFormatFromContentType(n);
1554
+ var s = w.getFormatFromContentType(n);
1564
1555
  s && (i[s] = n);
1565
1556
  }), i[r] || "application/octet-stream";
1566
1557
  } catch (n) {
@@ -1588,7 +1579,7 @@ class L {
1588
1579
  return a === "contain" || a === "image-contain" ? Math.min(i / s, n / c) : a === "cover" || a === "image-cover" ? Math.max(i / s, n / c) : 1;
1589
1580
  }
1590
1581
  }
1591
- class jt {
1582
+ class Mt {
1592
1583
  /**
1593
1584
  * @param {object} options
1594
1585
  * @param {ImageEditor} options.editor – экземпляр редактора
@@ -1624,13 +1615,13 @@ class jt {
1624
1615
  } = this.editor, {
1625
1616
  width: c,
1626
1617
  height: u
1627
- } = n, l = Number(Math.max(Math.min(e, E), k));
1628
- if (!s || s === "auto" || r ? this.adaptCanvasToContainer() : s ? this.setCanvasBackstoreWidth(s) : this.setCanvasBackstoreWidth(l), n.set({
1629
- width: l
1618
+ } = n, d = Number(Math.max(Math.min(e, E), k));
1619
+ if (!s || s === "auto" || r ? this.adaptCanvasToContainer() : s ? this.setCanvasBackstoreWidth(s) : this.setCanvasBackstoreWidth(d), n.set({
1620
+ width: d
1630
1621
  }), i.clipPath.set({
1631
- width: l
1622
+ width: d
1632
1623
  }), t) {
1633
- var d = l / c, h = u * d;
1624
+ var l = d / c, h = u * l;
1634
1625
  this.setResolutionHeight(h);
1635
1626
  return;
1636
1627
  }
@@ -1668,13 +1659,13 @@ class jt {
1668
1659
  } = this.editor, {
1669
1660
  width: c,
1670
1661
  height: u
1671
- } = n, l = Number(Math.max(Math.min(e, T), x));
1672
- if (!s || s === "auto" || r ? this.adaptCanvasToContainer() : s ? this.setCanvasBackstoreHeight(s) : this.setCanvasBackstoreHeight(l), n.set({
1673
- height: l
1662
+ } = n, d = Number(Math.max(Math.min(e, O), x));
1663
+ if (!s || s === "auto" || r ? this.adaptCanvasToContainer() : s ? this.setCanvasBackstoreHeight(s) : this.setCanvasBackstoreHeight(d), n.set({
1664
+ height: d
1674
1665
  }), i.clipPath.set({
1675
- height: l
1666
+ height: d
1676
1667
  }), t) {
1677
- var d = l / u, h = c * d;
1668
+ var l = d / u, h = c * l;
1678
1669
  this.setResolutionWidth(h);
1679
1670
  return;
1680
1671
  }
@@ -1695,7 +1686,7 @@ class jt {
1695
1686
  var {
1696
1687
  canvas: e,
1697
1688
  montageArea: t
1698
- } = this.editor, a = e.getWidth(), r = e.getHeight(), i = e.getZoom(), n = new Be(a / 2, r / 2);
1689
+ } = this.editor, a = e.getWidth(), r = e.getHeight(), i = e.getZoom(), n = new ke(a / 2, r / 2);
1699
1690
  t.set({
1700
1691
  left: a / 2,
1701
1692
  top: r / 2
@@ -1740,7 +1731,7 @@ class jt {
1740
1731
  }
1741
1732
  setCanvasBackstoreHeight(e) {
1742
1733
  if (!(!e || typeof e != "number")) {
1743
- var t = Math.max(Math.min(e, T), x);
1734
+ var t = Math.max(Math.min(e, O), x);
1744
1735
  this.editor.canvas.setDimensions({
1745
1736
  height: t
1746
1737
  }, {
@@ -1751,7 +1742,7 @@ class jt {
1751
1742
  adaptCanvasToContainer() {
1752
1743
  var {
1753
1744
  canvas: e
1754
- } = this.editor, t = e.editorContainer, a = t.clientWidth, r = t.clientHeight, i = Math.max(Math.min(a, E), k), n = Math.max(Math.min(r, T), x);
1745
+ } = this.editor, t = e.editorContainer, a = t.clientWidth, r = t.clientHeight, i = Math.max(Math.min(a, E), k), n = Math.max(Math.min(r, O), x);
1755
1746
  console.log("adaptCanvasToContainer newWidth", i), console.log("adaptCanvasToContainer newHeight", n), e.setDimensions({
1756
1747
  width: i,
1757
1748
  height: n
@@ -1759,6 +1750,35 @@ class jt {
1759
1750
  backstoreOnly: !0
1760
1751
  });
1761
1752
  }
1753
+ /**
1754
+ * Обновляет размеры канваса и вписывает объекты в монтажную область.
1755
+ * Вызывается при изменении размеров контейнера редактора.
1756
+ * @fires editor:canvas-updated
1757
+ */
1758
+ updateCanvasAndFitObjects() {
1759
+ var {
1760
+ canvas: e,
1761
+ selectionManager: t,
1762
+ transformManager: a,
1763
+ montageArea: {
1764
+ width: r,
1765
+ height: i
1766
+ }
1767
+ } = this.editor;
1768
+ this.setResolutionWidth(r, {
1769
+ adaptCanvasToContainer: !0,
1770
+ withoutSave: !0
1771
+ }), this.setResolutionHeight(i, {
1772
+ adaptCanvasToContainer: !0,
1773
+ withoutSave: !0
1774
+ }), this.centerMontageArea(), t.selectAll(), a.fitObject({
1775
+ fitAsOneObject: !0,
1776
+ withoutSave: !0
1777
+ }), e.fire("editor:canvas-updated", {
1778
+ width: r,
1779
+ height: i
1780
+ });
1781
+ }
1762
1782
  /**
1763
1783
  * Заготовка.
1764
1784
  * Обновляет CSS-размеры канваса в зависимости от текущего зума, чтобы можно было скроллить вниз-вверх, влево-вправо.
@@ -1891,16 +1911,16 @@ class jt {
1891
1911
  }
1892
1912
  var s = t === "width" ? "width" : "height";
1893
1913
  if (typeof a == "string") {
1894
- n.forEach((l) => {
1895
- l.style[s] = a;
1914
+ n.forEach((d) => {
1915
+ d.style[s] = a;
1896
1916
  });
1897
1917
  return;
1898
1918
  }
1899
1919
  var c = parseFloat(a);
1900
1920
  if (!isNaN(c)) {
1901
1921
  var u = "".concat(c, "px");
1902
- n.forEach((l) => {
1903
- l.style[s] = u;
1922
+ n.forEach((d) => {
1923
+ d.style[s] = u;
1904
1924
  }), r.fire("editor:display-".concat(e, "-").concat(s, "-changed"), {
1905
1925
  element: e,
1906
1926
  value: a
@@ -1914,7 +1934,7 @@ class jt {
1914
1934
  * @param {fabric.Object} [options.object] - Объект с изображением, которое нужно масштабировать
1915
1935
  * @param {Boolean} [options.withoutSave] - Не сохранять состояние
1916
1936
  * @param {Boolean} [options.preserveAspectRatio] - Сохранять изначальные пропорции монтажной области
1917
- * @fires editor:canvas-scaled
1937
+ * @fires editor:montage-area-scaled-to-image
1918
1938
  */
1919
1939
  scaleMontageAreaToImage() {
1920
1940
  var {
@@ -1932,29 +1952,28 @@ class jt {
1932
1952
  } = this.editor, u = e || r.getActiveObject();
1933
1953
  if (!(!u || u.type !== "image" && u.format !== "svg")) {
1934
1954
  var {
1935
- width: l,
1936
- height: d
1937
- } = u, h = Math.min(l, E), g = Math.min(d, T);
1955
+ width: d,
1956
+ height: l
1957
+ } = u, h = Math.min(d, E), g = Math.min(l, O);
1938
1958
  if (t) {
1939
1959
  var {
1940
1960
  width: M,
1941
1961
  height: m
1942
- } = i, f = l / M, v = d / m, N = Math.max(f, v);
1943
- h = M * N, g = m * N;
1962
+ } = i, f = d / M, v = l / m, A = Math.max(f, v);
1963
+ h = M * A, g = m * A;
1944
1964
  }
1945
- if (this.setResolutionWidth(h, {
1965
+ this.setResolutionWidth(h, {
1946
1966
  withoutSave: !0
1947
1967
  }), this.setResolutionHeight(g, {
1948
1968
  withoutSave: !0
1949
- }), l > s || d > c) {
1950
- var b = r.editorContainer, I = b.clientWidth, S = b.clientHeight * 0.5, j = Math.min(s, S), y = Math.min(c, I);
1951
- n.calculateAndApplyDefaultZoom(j, y);
1952
- }
1953
- n.resetObject(u, {
1969
+ }), (d > s || l > c) && n.calculateAndApplyDefaultZoom(), n.resetObject(u, {
1954
1970
  withoutSave: !0
1955
- }), r.centerObject(u), r.renderAll(), a || this.editor.historyManager.saveState(), r.fire("editor:canvas-scaled", {
1971
+ }), r.centerObject(u), r.renderAll(), a || this.editor.historyManager.saveState(), r.fire("editor:montage-area-scaled-to-image", {
1972
+ object: u,
1956
1973
  width: h,
1957
- height: g
1974
+ height: g,
1975
+ preserveAspectRatio: t,
1976
+ withoutSave: a
1958
1977
  });
1959
1978
  }
1960
1979
  }
@@ -2009,7 +2028,7 @@ class jt {
2009
2028
  return r.filter((i) => i.id !== t.id && i.id !== a.id);
2010
2029
  }
2011
2030
  }
2012
- class yt {
2031
+ class ft {
2013
2032
  /**
2014
2033
  * @param {object} options
2015
2034
  * @param {ImageEditor} options.editor - экземпляр редактора с доступом к canvas
@@ -2021,22 +2040,24 @@ class yt {
2021
2040
  this.editor = t, this.options = t.options;
2022
2041
  }
2023
2042
  /**
2024
- * Метод рассчитывает дефолтный, максимальный, и минимальный зум таким образом,
2025
- * чтобы монтажная область визуально занимала переданные размеры.
2026
- * Если размеры не переданы, то используются дефолтные размеры монтажной области переданные в options.
2027
- * @param {number} [targetWidth] — желаемая видимая ширина (px)
2028
- * @param {number} [targetHeight] желаемая видимая высота (px)
2043
+ * Метод рассчитывает и применяет зум по умолчанию для монтажной области редактора.
2044
+ * Зум рассчитывается исходя из размеров контейнера редактора и текущих размеров монтажной области.
2045
+ * Расчёт происходит таким образом, чтобы монтажная область визуально целиком помещалась в контейнер редактора.
2046
+ * Если scale не передан, то используется значение из options.defaultScale.
2047
+ * @param {Number} [scale] - Желаемый масштаб относительно размеров контейнера редактора.
2029
2048
  */
2030
2049
  calculateAndApplyDefaultZoom() {
2031
- var e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : this.options.montageAreaWidth, t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : this.options.montageAreaHeight, {
2032
- width: a,
2033
- height: r
2034
- } = this.editor.montageArea, i = e / a, n = t / r, s = Math.min(i, n), {
2035
- minZoom: c,
2036
- maxZoom: u,
2037
- maxZoomFactor: l
2050
+ var e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : this.options.defaultScale, {
2051
+ canvas: t
2052
+ } = this.editor, a = t.editorContainer, r = a.clientWidth, i = a.clientHeight, {
2053
+ width: n,
2054
+ height: s
2055
+ } = this.editor.montageArea, c = r / n * e, u = i / s * e, d = Math.min(c, u), {
2056
+ minZoom: l,
2057
+ maxZoom: h,
2058
+ maxZoomFactor: g
2038
2059
  } = this.options;
2039
- this.minZoom = Math.min(s / l, c), this.maxZoom = Math.max(s * l, u), this.defaultZoom = s, this.setZoom(s);
2060
+ this.minZoom = Math.min(d / g, l), this.maxZoom = Math.max(d * g, h), this.defaultZoom = d, this.setZoom(d);
2040
2061
  }
2041
2062
  /**
2042
2063
  * Увеличение/уменьшение масштаба
@@ -2048,7 +2069,7 @@ class yt {
2048
2069
  * Если передавать координаты курсора, то нужно быть аккуратнее, так как юзер может выйти за пределы рабочей области
2049
2070
  */
2050
2071
  zoom() {
2051
- var e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : Mt, t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
2072
+ var e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : vt, t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
2052
2073
  if (e) {
2053
2074
  var {
2054
2075
  canvas: a,
@@ -2120,7 +2141,7 @@ class yt {
2120
2141
  * @fires editor:object-rotated
2121
2142
  */
2122
2143
  rotate() {
2123
- var e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : ft, {
2144
+ var e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : mt, {
2124
2145
  withoutSave: t
2125
2146
  } = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, {
2126
2147
  canvas: a,
@@ -2182,7 +2203,7 @@ class yt {
2182
2203
  }) : n.set("opacity", t), r.renderAll(), a || i.saveState(), r.fire("editor:object-opacity-changed", t));
2183
2204
  }
2184
2205
  /**
2185
- * Масштабирование изображения
2206
+ * Масштабирование объекта
2186
2207
  * @param {Object} options
2187
2208
  * @param {fabric.Object} [options.object] - Объект с изображением, которое нужно масштабировать
2188
2209
  * @param {String} [options.type] - Тип масштабирования
@@ -2213,19 +2234,22 @@ class yt {
2213
2234
  });
2214
2235
  h.scale(g), i.centerObject(h);
2215
2236
  });
2216
- var l = new _(u, {
2237
+ var d = new W(u, {
2217
2238
  canvas: i
2218
2239
  });
2219
- i.setActiveObject(l);
2240
+ i.setActiveObject(d);
2220
2241
  } else {
2221
- var d = n.calculateScaleFactor({
2242
+ var l = n.calculateScaleFactor({
2222
2243
  imageObject: c,
2223
2244
  scaleType: t
2224
2245
  });
2225
- c.scale(d), i.centerObject(c);
2246
+ c.scale(l), i.centerObject(c);
2226
2247
  }
2227
- i.renderAll(), a || s.saveState(), i.fire("editor:image-fitted", {
2228
- type: t
2248
+ i.renderAll(), a || s.saveState(), i.fire("editor:object-fitted", {
2249
+ object: c,
2250
+ type: t,
2251
+ withoutSave: a,
2252
+ fitAsOneObject: r
2229
2253
  });
2230
2254
  }
2231
2255
  }
@@ -2261,8 +2285,8 @@ class yt {
2261
2285
  } = this.editor, u = e || r.getActiveObject();
2262
2286
  if (!(!u || u.locked)) {
2263
2287
  s.suspendHistory();
2264
- var l = u.type === "image" || u.format === "svg";
2265
- if (l || u.set({
2288
+ var d = u.type === "image" || u.format === "svg";
2289
+ if (d || u.set({
2266
2290
  scaleX: 1,
2267
2291
  scaleY: 1,
2268
2292
  flipX: !1,
@@ -2276,7 +2300,7 @@ class yt {
2276
2300
  });
2277
2301
  else {
2278
2302
  var {
2279
- width: d,
2303
+ width: l,
2280
2304
  height: h
2281
2305
  } = i, {
2282
2306
  width: g,
@@ -2284,7 +2308,7 @@ class yt {
2284
2308
  } = u, m = n.calculateScaleFactor({
2285
2309
  imageObject: u,
2286
2310
  scaleType: c
2287
- }), f = c === "contain" && m < 1 || c === "cover" && (g > d || M > h);
2311
+ }), f = c === "contain" && m < 1 || c === "cover" && (g > l || M > h);
2288
2312
  f ? this.fitObject({
2289
2313
  object: u,
2290
2314
  withoutSave: !0,
@@ -2302,7 +2326,7 @@ class yt {
2302
2326
  }
2303
2327
  }
2304
2328
  }
2305
- class pt {
2329
+ class jt {
2306
2330
  /**
2307
2331
  * @param {object} options
2308
2332
  * @param {ImageEditor} options.editor – экземпляр редактора
@@ -2402,7 +2426,7 @@ class pt {
2402
2426
  }
2403
2427
  }
2404
2428
  }
2405
- class J {
2429
+ class K {
2406
2430
  /**
2407
2431
  * @param {object} options
2408
2432
  * @param {ImageEditor} options.editor - экземпляр редактора с доступом к canvas
@@ -2449,7 +2473,7 @@ class J {
2449
2473
  } = this.editor;
2450
2474
  r.suspendHistory();
2451
2475
  var i = e || a.getActiveObject();
2452
- i && (i.type === "activeselection" ? J._moveSelectionForward(a, i) : a.bringObjectForward(i), a.renderAll(), r.resumeHistory(), t || r.saveState(), a.fire("editor:object-bring-forward"));
2476
+ i && (i.type === "activeselection" ? K._moveSelectionForward(a, i) : a.bringObjectForward(i), a.renderAll(), r.resumeHistory(), t || r.saveState(), a.fire("editor:object-bring-forward"));
2453
2477
  }
2454
2478
  /**
2455
2479
  * Отправить объект на задний план по оси Z
@@ -2499,7 +2523,7 @@ class J {
2499
2523
  } = this.editor;
2500
2524
  i.suspendHistory();
2501
2525
  var s = e || a.getActiveObject();
2502
- s && (s.type === "activeselection" ? J._moveSelectionBackwards(a, s) : a.sendObjectBackwards(s), a.sendObjectToBack(r), a.sendObjectToBack(n), a.renderAll(), i.resumeHistory(), t || i.saveState(), a.fire("editor:object-send-backwards"));
2526
+ s && (s.type === "activeselection" ? K._moveSelectionBackwards(a, s) : a.sendObjectBackwards(s), a.sendObjectToBack(r), a.sendObjectToBack(n), a.renderAll(), i.resumeHistory(), t || i.saveState(), a.fire("editor:object-send-backwards"));
2503
2527
  }
2504
2528
  /**
2505
2529
  * Сдвигает выделенные объекты на один уровень вверх относительно ближайшего верхнего объекта
@@ -2509,20 +2533,20 @@ class J {
2509
2533
  * @private
2510
2534
  */
2511
2535
  static _moveSelectionForward(e, t) {
2512
- for (var a = e.getObjects(), r = t.getObjects(), i = r.map((l) => a.indexOf(l)), n = -1, s = function(d) {
2513
- var h = a[d];
2514
- if (!r.includes(h) && i.some((g) => d > g))
2515
- return n = d, 1;
2536
+ for (var a = e.getObjects(), r = t.getObjects(), i = r.map((d) => a.indexOf(d)), n = -1, s = function(l) {
2537
+ var h = a[l];
2538
+ if (!r.includes(h) && i.some((g) => l > g))
2539
+ return n = l, 1;
2516
2540
  }, c = 0; c < a.length && !s(c); c += 1)
2517
2541
  ;
2518
2542
  if (n !== -1) {
2519
- var u = r.map((l) => ({
2520
- obj: l,
2521
- index: a.indexOf(l)
2522
- })).sort((l, d) => d.index - l.index);
2523
- u.forEach((l) => {
2524
- var d = a.indexOf(l.obj);
2525
- d < n && (e.moveObjectTo(l.obj, n), n = d);
2543
+ var u = r.map((d) => ({
2544
+ obj: d,
2545
+ index: a.indexOf(d)
2546
+ })).sort((d, l) => l.index - d.index);
2547
+ u.forEach((d) => {
2548
+ var l = a.indexOf(d.obj);
2549
+ l < n && (e.moveObjectTo(d.obj, n), n = l);
2526
2550
  });
2527
2551
  }
2528
2552
  }
@@ -2538,7 +2562,7 @@ class J {
2538
2562
  e.moveObjectTo(r[n], i - 1);
2539
2563
  }
2540
2564
  }
2541
- class bt {
2565
+ class yt {
2542
2566
  /**
2543
2567
  * Менеджер фигур для редактора.
2544
2568
  * @param {Object} options - Опции и настройки менеджера фигур.
@@ -2562,15 +2586,15 @@ class bt {
2562
2586
  * @param {Object} flags.withoutSelection - Не выделять объект
2563
2587
  * @param {Object} flags.withoutAdding - Не добавлять объект в canvas
2564
2588
  */
2565
- addRectangle(l = {}, { withoutSelection: c, withoutAdding: u } = {}) {
2566
- var d = l, {
2567
- id: e = `rect-${D()}`,
2589
+ addRectangle(d = {}, { withoutSelection: c, withoutAdding: u } = {}) {
2590
+ var l = d, {
2591
+ id: e = `rect-${S()}`,
2568
2592
  left: t,
2569
2593
  top: a,
2570
2594
  width: r = 100,
2571
2595
  height: i = 100,
2572
2596
  fill: n = "blue"
2573
- } = d, s = X(d, [
2597
+ } = l, s = Q(l, [
2574
2598
  "id",
2575
2599
  "left",
2576
2600
  "top",
@@ -2578,7 +2602,7 @@ class bt {
2578
2602
  "height",
2579
2603
  "fill"
2580
2604
  ]);
2581
- const { canvas: h } = this.editor, g = new Ze(w({
2605
+ const { canvas: h } = this.editor, g = new xe(C({
2582
2606
  id: e,
2583
2607
  left: t,
2584
2608
  top: a,
@@ -2605,27 +2629,27 @@ class bt {
2605
2629
  * @param {Object} flags.withoutAdding - Не добавлять объект в canvas
2606
2630
  */
2607
2631
  addCircle(u = {}, { withoutSelection: s, withoutAdding: c } = {}) {
2608
- var l = u, {
2609
- id: e = `circle-${D()}`,
2632
+ var d = u, {
2633
+ id: e = `circle-${S()}`,
2610
2634
  left: t,
2611
2635
  top: a,
2612
2636
  radius: r = 50,
2613
2637
  fill: i = "green"
2614
- } = l, n = X(l, [
2638
+ } = d, n = Q(d, [
2615
2639
  "id",
2616
2640
  "left",
2617
2641
  "top",
2618
2642
  "radius",
2619
2643
  "fill"
2620
2644
  ]);
2621
- const { canvas: d } = this.editor, h = new ze(w({
2645
+ const { canvas: l } = this.editor, h = new Be(C({
2622
2646
  id: e,
2623
2647
  left: t,
2624
2648
  top: a,
2625
2649
  fill: i,
2626
2650
  radius: r
2627
2651
  }, n));
2628
- return !t && !a && d.centerObject(h), c || (d.add(h), s || d.setActiveObject(h), d.renderAll()), h;
2652
+ return !t && !a && l.centerObject(h), c || (l.add(h), s || l.setActiveObject(h), l.renderAll()), h;
2629
2653
  }
2630
2654
  /**
2631
2655
  * Добавление треугольника
@@ -2644,15 +2668,15 @@ class bt {
2644
2668
  * @param {Object} flags.withoutSelection - Не выделять объект
2645
2669
  * @param {Object} flags.withoutAdding - Не добавлять объект в canvas
2646
2670
  */
2647
- addTriangle(l = {}, { withoutSelection: c, withoutAdding: u } = {}) {
2648
- var d = l, {
2649
- id: e = `triangle-${D()}`,
2671
+ addTriangle(d = {}, { withoutSelection: c, withoutAdding: u } = {}) {
2672
+ var l = d, {
2673
+ id: e = `triangle-${S()}`,
2650
2674
  left: t,
2651
2675
  top: a,
2652
2676
  width: r = 100,
2653
2677
  height: i = 100,
2654
2678
  fill: n = "yellow"
2655
- } = d, s = X(d, [
2679
+ } = l, s = Q(l, [
2656
2680
  "id",
2657
2681
  "left",
2658
2682
  "top",
@@ -2660,7 +2684,7 @@ class bt {
2660
2684
  "height",
2661
2685
  "fill"
2662
2686
  ]);
2663
- const { canvas: h } = this.editor, g = new Ue(w({
2687
+ const { canvas: h } = this.editor, g = new Ze(C({
2664
2688
  id: e,
2665
2689
  left: t,
2666
2690
  top: a,
@@ -2671,111 +2695,100 @@ class bt {
2671
2695
  return !t && !a && h.centerObject(g), u || (h.add(g), c || h.setActiveObject(g), h.renderAll()), g;
2672
2696
  }
2673
2697
  }
2674
- function Ae(o, e, t, a, r, i, n) {
2675
- try {
2676
- var s = o[i](n), c = s.value;
2677
- } catch (u) {
2678
- return void t(u);
2679
- }
2680
- s.done ? e(c) : Promise.resolve(c).then(a, r);
2681
- }
2682
- function Ce(o) {
2683
- return function() {
2684
- var e = this, t = arguments;
2685
- return new Promise(function(a, r) {
2686
- var i = o.apply(e, t);
2687
- function n(c) {
2688
- Ae(i, a, r, n, s, "next", c);
2689
- }
2690
- function s(c) {
2691
- Ae(i, a, r, n, s, "throw", c);
2692
- }
2693
- n(void 0);
2694
- });
2695
- };
2696
- }
2697
- class It {
2698
+ class pt {
2698
2699
  /**
2699
2700
  * @param {object} options
2700
2701
  * @param {ImageEditor} options.editor - экземпляр редактора с доступом к canvas
2701
2702
  */
2702
- constructor(e) {
2703
- var {
2704
- editor: t
2705
- } = e;
2706
- this.editor = t, this.clipboard = null;
2703
+ constructor({ editor: e }) {
2704
+ this.editor = e, this.clipboard = null;
2707
2705
  }
2708
2706
  /**
2709
2707
  * Копирование объекта
2710
2708
  * @fires editor:object-copied
2711
2709
  */
2712
2710
  copy() {
2713
- var e = this;
2714
- return Ce(function* () {
2715
- var {
2716
- canvas: t
2717
- } = e.editor, a = t.getActiveObject();
2718
- if (a)
2711
+ return H(this, null, function* () {
2712
+ const { canvas: e } = this.editor, t = e.getActiveObject();
2713
+ if (t)
2719
2714
  try {
2720
- var r = yield a.clone(["format"]);
2721
- if (e.clipboard = r, typeof ClipboardItem == "undefined" || !navigator.clipboard) {
2715
+ const a = yield t.clone(["format"]);
2716
+ if (this.clipboard = a, typeof ClipboardItem == "undefined" || !navigator.clipboard) {
2722
2717
  console.warn(
2723
2718
  // eslint-disable-next-line max-len
2724
2719
  "ClipboardManager. navigator.clipboard не поддерживается в этом браузере или отсутствует соединение по HTTPS-протоколу."
2725
- ), t.fire("editor:object-copied", {
2726
- object: r
2727
- });
2720
+ ), e.fire("editor:object-copied", { object: a });
2728
2721
  return;
2729
2722
  }
2730
- if (e.clipboard.type !== "image") {
2731
- yield navigator.clipboard.writeText(["application/image-editor", JSON.stringify(r)]), t.fire("editor:object-copied", {
2732
- object: r
2733
- });
2723
+ if (this.clipboard.type !== "image") {
2724
+ yield navigator.clipboard.writeText(`application/image-editor:${JSON.stringify(a)}`), e.fire("editor:object-copied", { object: a });
2734
2725
  return;
2735
2726
  }
2736
- var i = r.toCanvasElement(), n = yield new Promise((u) => {
2737
- i.toBlob(u);
2738
- }), s = new ClipboardItem({
2739
- [n.type]: n
2727
+ const r = a.toCanvasElement(), i = yield new Promise((s) => {
2728
+ r.toBlob(s);
2740
2729
  });
2741
- yield navigator.clipboard.write([s]), t.fire("editor:object-copied", {
2742
- object: r
2743
- });
2744
- } catch (u) {
2745
- var c = "ClipboardManager. Ошибка записи в системный буфер обмена:";
2746
- console.error(c, u), t.fire("editor:error", {
2747
- message: "".concat(c, " ").concat(u.message)
2730
+ if (!i) return;
2731
+ const n = new ClipboardItem({ [i.type]: i });
2732
+ yield navigator.clipboard.write([n]), e.fire("editor:object-copied", { object: a });
2733
+ } catch (a) {
2734
+ if (!(a instanceof Error)) return;
2735
+ const r = "ClipboardManager. Ошибка записи в системный буфер обмена:";
2736
+ console.error(r, a), e.fire("editor:error", {
2737
+ message: `${r} ${a.message}`
2748
2738
  });
2749
2739
  }
2750
- })();
2740
+ });
2741
+ }
2742
+ /**
2743
+ * Обработчик вставки объекта или изображения из буфера обмена.
2744
+ * @param {Object} event — объект события
2745
+ * @param {Object} event.clipboardData — данные из буфера обмена
2746
+ * @param {Array} event.clipboardData.items — элементы буфера обмена
2747
+ */
2748
+ handlePasteEvent({ clipboardData: e }) {
2749
+ var n;
2750
+ if (!((n = e == null ? void 0 : e.items) != null && n.length)) return;
2751
+ const { imageManager: t } = this.editor, { items: a } = e, r = a[a.length - 1];
2752
+ if (console.log("handlePasteEvent clipboardData", e), console.log("handlePasteEvent lastItem", r), r.type !== "text/html") {
2753
+ const s = r.getAsFile();
2754
+ if (!s) return;
2755
+ const c = new FileReader();
2756
+ c.onload = (u) => {
2757
+ u.target && this.editor.imageManager.importImage({ source: u.target.result });
2758
+ }, c.readAsDataURL(s);
2759
+ return;
2760
+ }
2761
+ const i = e.getData("text/html");
2762
+ if (i) {
2763
+ const u = new DOMParser().parseFromString(i, "text/html").querySelector("img");
2764
+ if (u != null && u.src) {
2765
+ t.importImage({ source: u.src });
2766
+ return;
2767
+ }
2768
+ }
2769
+ this.paste();
2751
2770
  }
2752
2771
  /**
2753
2772
  * Вставка объекта
2754
2773
  * @fires editor:object-pasted
2755
2774
  */
2756
2775
  paste() {
2757
- var e = this;
2758
- return Ce(function* () {
2759
- var {
2760
- canvas: t
2761
- } = e.editor;
2762
- if (e.clipboard) {
2763
- var a = yield e.clipboard.clone(["format"]);
2764
- t.discardActiveObject(), a.set({
2765
- id: "".concat(a.type, "-").concat(D()),
2766
- left: a.left + 10,
2767
- top: a.top + 10,
2768
- evented: !0
2769
- }), a instanceof _ ? (a.canvas = t, a.forEachObject((r) => {
2770
- t.add(r);
2771
- })) : t.add(a), t.setActiveObject(a), t.requestRenderAll(), t.fire("editor:object-pasted", {
2772
- object: a
2773
- });
2774
- }
2775
- })();
2776
+ return H(this, null, function* () {
2777
+ const { canvas: e } = this.editor;
2778
+ if (!this.clipboard) return;
2779
+ const t = yield this.clipboard.clone(["format"]);
2780
+ e.discardActiveObject(), t.set({
2781
+ id: `${t.type}-${S()}`,
2782
+ left: t.left + 10,
2783
+ top: t.top + 10,
2784
+ evented: !0
2785
+ }), t instanceof W ? (t.canvas = e, t.forEachObject((a) => {
2786
+ e.add(a);
2787
+ })) : e.add(t), e.setActiveObject(t), e.requestRenderAll(), e.fire("editor:object-pasted", { object: t });
2788
+ });
2776
2789
  }
2777
2790
  }
2778
- class St {
2791
+ class bt {
2779
2792
  /**
2780
2793
  * @param {object} options
2781
2794
  * @param {ImageEditor} options.editor - экземпляр редактора с доступом к canvas
@@ -2858,7 +2871,7 @@ class St {
2858
2871
  }
2859
2872
  }
2860
2873
  }
2861
- class At {
2874
+ class It {
2862
2875
  /**
2863
2876
  * @param {object} options
2864
2877
  * @param {ImageEditor} options.editor - экземпляр редактора с доступом к canvas
@@ -2887,8 +2900,12 @@ class At {
2887
2900
  r.suspendHistory();
2888
2901
  var i = e || a.getActiveObject();
2889
2902
  if (i && i.type === "activeselection") {
2890
- var n = i.getObjects(), s = new Ye(n);
2891
- n.forEach((c) => a.remove(c)), s.set("id", "".concat(s.type, "-").concat(D())), a.add(s), a.setActiveObject(s), a.renderAll(), r.resumeHistory(), t || r.saveState(), a.fire("editor:objects-grouped");
2903
+ var n = i.getObjects(), s = new ze(n);
2904
+ n.forEach((c) => a.remove(c)), s.set("id", "".concat(s.type, "-").concat(S())), a.add(s), a.setActiveObject(s), a.renderAll(), r.resumeHistory(), t || r.saveState(), a.fire("editor:objects-grouped", {
2905
+ object: i,
2906
+ group: s,
2907
+ withoutSave: t
2908
+ });
2892
2909
  }
2893
2910
  }
2894
2911
  /**
@@ -2911,14 +2928,18 @@ class At {
2911
2928
  if (!(!i || i.type !== "group")) {
2912
2929
  var n = i.removeAll();
2913
2930
  a.remove(i), n.forEach((c) => a.add(c));
2914
- var s = new _(n, {
2931
+ var s = new W(n, {
2915
2932
  canvas: a
2916
2933
  });
2917
- a.setActiveObject(s), a.renderAll(), r.resumeHistory(), t || r.saveState(), a.fire("editor:objects-ungrouped");
2934
+ a.setActiveObject(s), a.renderAll(), r.resumeHistory(), t || r.saveState(), a.fire("editor:objects-ungrouped", {
2935
+ object: i,
2936
+ selection: s,
2937
+ withoutSave: t
2938
+ });
2918
2939
  }
2919
2940
  }
2920
2941
  }
2921
- class Ct {
2942
+ class St {
2922
2943
  /**
2923
2944
  * @param {object} options
2924
2945
  * @param {ImageEditor} options.editor - экземпляр редактора с доступом к canvas
@@ -2940,7 +2961,7 @@ class Ct {
2940
2961
  objectLockManager: a
2941
2962
  } = this.editor;
2942
2963
  e.discardActiveObject();
2943
- var r = t.getObjects(), i = r.some((s) => s.locked), n = r.length > 1 ? new _(t.getObjects(), {
2964
+ var r = t.getObjects(), i = r.some((s) => s.locked), n = r.length > 1 ? new W(t.getObjects(), {
2944
2965
  canvas: e
2945
2966
  }) : r[0];
2946
2967
  i && a.lockObject({
@@ -2952,7 +2973,7 @@ class Ct {
2952
2973
  });
2953
2974
  }
2954
2975
  }
2955
- class Dt {
2976
+ class At {
2956
2977
  /**
2957
2978
  * @param {object} options
2958
2979
  * @param {ImageEditor} options.editor - экземпляр редактора с доступом к canvas
@@ -2985,10 +3006,13 @@ class Dt {
2985
3006
  return;
2986
3007
  }
2987
3008
  a.remove(s);
2988
- }), a.discardActiveObject(), a.renderAll(), r.resumeHistory(), t || r.saveState(), a.fire("editor:objects-deleted"));
3009
+ }), a.discardActiveObject(), a.renderAll(), r.resumeHistory(), t || r.saveState(), a.fire("editor:objects-deleted", {
3010
+ objects: n,
3011
+ withoutSave: t
3012
+ }));
2989
3013
  }
2990
3014
  }
2991
- var Nt = {
3015
+ var Ct = {
2992
3016
  IMAGE_MANAGER: {
2993
3017
  /**
2994
3018
  * Некорректный Content-Type изображения
@@ -3016,7 +3040,7 @@ var Nt = {
3016
3040
  IMAGE_EXPORT_FAILED: "IMAGE_EXPORT_FAILED"
3017
3041
  }
3018
3042
  };
3019
- class K {
3043
+ class $ {
3020
3044
  constructor({ editor: e }) {
3021
3045
  this._buffer = [], this.editor = e;
3022
3046
  }
@@ -3037,7 +3061,7 @@ class K {
3037
3061
  * @fires editor:error
3038
3062
  */
3039
3063
  emitError({ origin: e = "ImageEditor", method: t = "Unknown Method", code: a, data: r, message: i }) {
3040
- if (!K.isValidErrorCode(a)) {
3064
+ if (!$.isValidErrorCode(a)) {
3041
3065
  console.warn("Неизвестный код ошибки: ", { code: a, origin: e, method: t });
3042
3066
  return;
3043
3067
  }
@@ -3051,7 +3075,7 @@ class K {
3051
3075
  message: n,
3052
3076
  data: r
3053
3077
  };
3054
- this._buffer.push(w({
3078
+ this._buffer.push(C({
3055
3079
  type: "editor:error"
3056
3080
  }, s)), this.editor.canvas.fire("editor:error", s);
3057
3081
  }
@@ -3066,7 +3090,7 @@ class K {
3066
3090
  * @fires editor:warning
3067
3091
  */
3068
3092
  emitWarning({ origin: e = "ImageEditor", method: t = "Unknown Method", code: a, message: r, data: i }) {
3069
- if (!K.isValidErrorCode(a)) {
3093
+ if (!$.isValidErrorCode(a)) {
3070
3094
  console.warn("Неизвестный код предупреждения: ", { code: a, origin: e, method: t });
3071
3095
  return;
3072
3096
  }
@@ -3079,12 +3103,12 @@ class K {
3079
3103
  message: n,
3080
3104
  data: i
3081
3105
  };
3082
- this._buffer.push(w({
3106
+ this._buffer.push(C({
3083
3107
  type: "editor:warning"
3084
3108
  }, s)), this.editor.canvas.fire("editor:warning", s);
3085
3109
  }
3086
3110
  static isValidErrorCode(e) {
3087
- return e ? Object.values(Nt).some((t) => Object.values(t).includes(e)) : !1;
3111
+ return e ? Object.values(Ct).some((t) => Object.values(t).includes(e)) : !1;
3088
3112
  }
3089
3113
  }
3090
3114
  class ue {
@@ -3096,10 +3120,10 @@ class ue {
3096
3120
  constructor(e, t) {
3097
3121
  this.options = t;
3098
3122
  const { defaultScale: a, minZoom: r, maxZoom: i } = t;
3099
- this.containerId = e, this.editorId = `${e}-${D()}`, this.clipboard = null, this.defaultZoom = a, this.minZoom = r || vt, this.maxZoom = i || mt, this.init();
3123
+ this.containerId = e, this.editorId = `${e}-${S()}`, this.clipboard = null, this.defaultZoom = a, this.minZoom = r || ht, this.maxZoom = i || gt, this.init();
3100
3124
  }
3101
3125
  init() {
3102
- return $(this, null, function* () {
3126
+ return H(this, null, function* () {
3103
3127
  const {
3104
3128
  editorContainerWidth: e,
3105
3129
  editorContainerHeight: t,
@@ -3110,18 +3134,18 @@ class ue {
3110
3134
  initialImage: s,
3111
3135
  initialStateJSON: c,
3112
3136
  scaleType: u,
3113
- _onReadyCallback: l
3137
+ _onReadyCallback: d
3114
3138
  } = this.options;
3115
- if (qe.apply(), this.canvas = new He(this.containerId, this.options), this.moduleLoader = new We(), this.workerManager = new Fe(), this.errorManager = new K({ editor: this }), this.historyManager = new gt({ editor: this }), this.toolbar = new ht({ editor: this }), this.transformManager = new yt({ editor: this }), this.canvasManager = new jt({ editor: this }), this.imageManager = new L({ editor: this }), this.layerManager = new J({ editor: this }), this.shapeManager = new bt({ editor: this }), this.interactionBlocker = new pt({ editor: this }), this.clipboardManager = new It({ editor: this }), this.objectLockManager = new St({ editor: this }), this.groupingManager = new At({ editor: this }), this.selectionManager = new Ct({ editor: this }), this.deletionManager = new Dt({ editor: this }), this._createMontageArea(), this._createClippingArea(), this.listeners = new P({ editor: this, options: this.options }), this.canvasManager.setEditorContainerWidth(e), this.canvasManager.setEditorContainerHeight(t), this.canvasManager.setCanvasWrapperWidth(a), this.canvasManager.setCanvasWrapperHeight(r), this.canvasManager.setCanvasCSSWidth(i), this.canvasManager.setCanvasCSSHeight(n), s != null && s.source) {
3139
+ if (Ke.apply(), this.canvas = new Ue(this.containerId, this.options), this.moduleLoader = new Re(), this.workerManager = new We(), this.errorManager = new $({ editor: this }), this.historyManager = new lt({ editor: this }), this.toolbar = new dt({ editor: this }), this.transformManager = new ft({ editor: this }), this.canvasManager = new Mt({ editor: this }), this.imageManager = new w({ editor: this }), this.layerManager = new K({ editor: this }), this.shapeManager = new yt({ editor: this }), this.interactionBlocker = new jt({ editor: this }), this.clipboardManager = new pt({ editor: this }), this.objectLockManager = new bt({ editor: this }), this.groupingManager = new It({ editor: this }), this.selectionManager = new St({ editor: this }), this.deletionManager = new At({ editor: this }), this._createMontageArea(), this._createClippingArea(), this.listeners = new R({ editor: this, options: this.options }), this.canvasManager.setEditorContainerWidth(e), this.canvasManager.setEditorContainerHeight(t), this.canvasManager.setCanvasWrapperWidth(a), this.canvasManager.setCanvasWrapperHeight(r), this.canvasManager.setCanvasCSSWidth(i), this.canvasManager.setCanvasCSSHeight(n), s != null && s.source) {
3116
3140
  const {
3117
- source: d,
3141
+ source: l,
3118
3142
  scale: h = `image-${u}`,
3119
3143
  withoutSave: g = !0
3120
3144
  } = s;
3121
- yield this.imageManager.importImage({ source: d, scale: h, withoutSave: g });
3145
+ yield this.imageManager.importImage({ source: l, scale: h, withoutSave: g });
3122
3146
  } else
3123
3147
  this.canvasManager.setDefaultScale({ withoutSave: !0 });
3124
- c && this.historyManager.loadStateFromFullState(c), this.historyManager.saveState(), console.log("editor:ready"), this.canvas.fire("editor:ready", this), typeof l == "function" && l(this);
3148
+ c && this.historyManager.loadStateFromFullState(c), this.historyManager.saveState(), console.log("editor:ready"), this.canvas.fire("editor:ready", this), typeof d == "function" && d(this);
3125
3149
  });
3126
3150
  }
3127
3151
  _createMontageArea() {
@@ -3176,7 +3200,7 @@ class ue {
3176
3200
  const e = document.createElement("canvas");
3177
3201
  e.width = 20, e.height = 20;
3178
3202
  const t = e.getContext("2d");
3179
- return t.fillStyle = "#ddd", t.fillRect(0, 0, 40, 40), t.fillStyle = "#ccc", t.fillRect(0, 0, 10, 10), t.fillRect(10, 10, 10, 10), new Pe({
3203
+ return t.fillStyle = "#ddd", t.fillRect(0, 0, 40, 40), t.fillStyle = "#ccc", t.fillRect(0, 0, 10, 10), t.fillRect(10, 10, 10, 10), new Ye({
3180
3204
  source: e,
3181
3205
  repeat: "repeat"
3182
3206
  });
@@ -3250,7 +3274,7 @@ const wt = {
3250
3274
  },
3251
3275
  initialStateJSON: null,
3252
3276
  initialImage: null,
3253
- defaultScale: 1,
3277
+ defaultScale: 0.5,
3254
3278
  minZoom: 0.1,
3255
3279
  maxZoom: 2,
3256
3280
  maxZoomFactor: 2,
@@ -3259,7 +3283,7 @@ const wt = {
3259
3283
  /*
3260
3284
  * Настройки слушателей событий
3261
3285
  */
3262
- adaptCanvasToContainer: !0,
3286
+ adaptCanvasToContainerOnResize: !0,
3263
3287
  bringToFrontOnSelection: !1,
3264
3288
  mouseWheelZooming: !0,
3265
3289
  canvasDragging: !0,
@@ -3270,8 +3294,8 @@ const wt = {
3270
3294
  deleteObjectsByHotkey: !0,
3271
3295
  resetObjectFitByDoubleClick: !0
3272
3296
  };
3273
- function Ot(o, e = {}) {
3274
- const t = w(w({}, wt), e), a = document.getElementById(o);
3297
+ function Et(o, e = {}) {
3298
+ const t = C(C({}, wt), e), a = document.getElementById(o);
3275
3299
  if (!a)
3276
3300
  return Promise.reject(new Error(`Контейнер с ID "${o}" не найден.`));
3277
3301
  const r = document.createElement("canvas");
@@ -3282,6 +3306,6 @@ function Ot(o, e = {}) {
3282
3306
  });
3283
3307
  }
3284
3308
  export {
3285
- Ot as default
3309
+ Et as default
3286
3310
  };
3287
3311
  //# sourceMappingURL=main.js.map