@anu3ev/fabric-image-editor 0.1.30 → 0.1.31

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 +162 -163
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -1,4 +1,4 @@
1
- import { ActiveSelection as P, util as U, controlsUtils as Oe, InteractiveFabricObject as Te, loadSVGFromURL as ke, FabricImage as le, Point as xe, Rect as Be, Circle as Ze, Triangle as ze, Group as Pe, Pattern as Ue, Canvas as Ye } from "fabric";
1
+ import { ActiveSelection as U, util as Y, controlsUtils as Oe, InteractiveFabricObject as Te, loadSVGFromURL as ke, FabricImage as le, Point as xe, Rect as Be, Circle as Ze, Triangle as ze, Group as Pe, Pattern as Ue, Canvas as Ye } from "fabric";
2
2
  import { create as He } from "jsondiffpatch";
3
3
  var _e = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", w = function() {
4
4
  for (var e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 21, t = "", a = crypto.getRandomValues(new Uint8Array(e |= 0)); e--; )
@@ -28,7 +28,7 @@ function Re(o) {
28
28
  });
29
29
  };
30
30
  }
31
- class z {
31
+ class P {
32
32
  /**
33
33
  * Конструктор принимает редактор и опции.
34
34
  * @param {Object} params
@@ -49,7 +49,7 @@ class z {
49
49
  editor: t,
50
50
  options: a = {}
51
51
  } = e;
52
- this.editor = t, this.canvas = t.canvas, this.options = a, this.isUndoRedoKeyPressed = !1, this.isSpacePressed = !1, this.handleAdaptCanvasToContainerBound = z.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 = 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();
52
+ this.editor = t, this.canvas = t.canvas, this.options = a, this.isUndoRedoKeyPressed = !1, this.isSpacePressed = !1, this.handleAdaptCanvasToContainerBound = P.debounce(this.handleAdaptCanvasToContainer.bind(this), 500), this.handleCopyEventBound = this.handleCopyEvent.bind(this), this.handlePasteEventBound = this.handlePasteEvent.bind(this), this.handleUndoRedoEventBound = this.handleUndoRedoEvent.bind(this), this.handleUndoRedoKeyUpBound = this.handleUndoRedoKeyUp.bind(this), this.handleSelectAllEventBound = this.handleSelectAllEvent.bind(this), this.handleDeleteObjectsEventBound = this.handleDeleteObjectsEvent.bind(this), this.handleSpaceKeyDownBound = this.handleSpaceKeyDown.bind(this), this.handleSpaceKeyUpBound = this.handleSpaceKeyUp.bind(this), this.handleObjectModifiedHistoryBound = P.debounce(this.handleObjectModifiedHistory.bind(this), 300), this.handleObjectRotatingHistoryBound = P.debounce(this.handleObjectRotatingHistory.bind(this), 300), this.handleObjectAddedHistoryBound = this.handleObjectAddedHistory.bind(this), this.handleObjectRemovedHistoryBound = this.handleObjectRemovedHistory.bind(this), this.handleOverlayUpdateBound = this.handleOverlayUpdate.bind(this), this.handleCanvasDragStartBound = this.handleCanvasDragStart.bind(this), this.handleCanvasDraggingBound = this.handleCanvasDragging.bind(this), this.handleCanvasDragEndBound = this.handleCanvasDragEnd.bind(this), this.handleMouseWheelZoomBound = this.handleMouseWheelZoom.bind(this), this.handleBringToFrontBound = this.handleBringToFront.bind(this), this.handleResetObjectFitBound = this.handleResetObjectFit.bind(this), this.handleLockedSelectionBound = this._filterLockedSelection.bind(this), this.init();
53
53
  }
54
54
  /**
55
55
  * Инициализация всех обработчиков согласно опциям.
@@ -107,7 +107,7 @@ class z {
107
107
  this.canvas.setActiveObject(n[0]);
108
108
  return;
109
109
  }
110
- var i = new P(n, {
110
+ var i = new U(n, {
111
111
  canvas: this.canvas
112
112
  });
113
113
  this.canvas.setActiveObject(i), this.canvas.requestRenderAll();
@@ -502,49 +502,49 @@ class Fe {
502
502
  }
503
503
  }
504
504
  var I = 12, Ve = 2, K = 8, $ = 20, Ge = 100, q = 20, ee = 8, Xe = 100, te = 32, ae = 1, Qe = "#2B2D33", re = "#3D8BF4", ne = "#FFFFFF";
505
- function R(o, e, t, a, r) {
505
+ function W(o, e, t, a, r) {
506
506
  var n = I, i = Ve;
507
- o.save(), o.translate(e, t), o.rotate(U.degreesToRadians(r.angle)), o.fillStyle = ne, o.strokeStyle = re, o.lineWidth = ae, o.beginPath(), o.roundRect(-12 / 2, -12 / 2, n, n, i), o.fill(), o.stroke(), o.restore();
507
+ o.save(), o.translate(e, t), o.rotate(Y.degreesToRadians(r.angle)), o.fillStyle = ne, o.strokeStyle = re, o.lineWidth = ae, o.beginPath(), o.roundRect(-12 / 2, -12 / 2, n, n, i), o.fill(), o.stroke(), o.restore();
508
508
  }
509
509
  function ge(o, e, t, a, r) {
510
510
  var n = K, i = $, s = Ge;
511
- o.save(), o.translate(e, t), o.rotate(U.degreesToRadians(r.angle)), o.fillStyle = ne, o.strokeStyle = re, o.lineWidth = ae, o.beginPath(), o.roundRect(-8 / 2, -20 / 2, n, i, s), o.fill(), o.stroke(), o.restore();
511
+ o.save(), o.translate(e, t), o.rotate(Y.degreesToRadians(r.angle)), o.fillStyle = ne, o.strokeStyle = re, o.lineWidth = ae, o.beginPath(), o.roundRect(-8 / 2, -20 / 2, n, i, s), o.fill(), o.stroke(), o.restore();
512
512
  }
513
513
  function ve(o, e, t, a, r) {
514
514
  var n = q, i = ee, s = Xe;
515
- o.save(), o.translate(e, t), o.rotate(U.degreesToRadians(r.angle)), o.fillStyle = ne, o.strokeStyle = re, o.lineWidth = ae, o.beginPath(), o.roundRect(-20 / 2, -8 / 2, n, i, s), o.fill(), o.stroke(), o.restore();
515
+ o.save(), o.translate(e, t), o.rotate(Y.degreesToRadians(r.angle)), o.fillStyle = ne, o.strokeStyle = re, o.lineWidth = ae, o.beginPath(), o.roundRect(-20 / 2, -8 / 2, n, i, s), o.fill(), o.stroke(), o.restore();
516
516
  }
517
517
  var Je = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTE4Ljc1IDQuMzc1djMuNzVhLjYyNS42MjUgMCAwIDEtLjYyNS42MjVoLTMuNzVhLjYyNS42MjUgMCAwIDEgMC0xLjI1aDIuMTRsLTIuMDc3LTEuOTAzLS4wMi0uMDE5YTYuMjUgNi4yNSAwIDEgMC0uMTMgOC45NjcuNjI2LjYyNiAwIDAgMSAuODYuOTA5QTcuNDU2IDcuNDU2IDAgMCAxIDEwIDE3LjVoLS4xMDNhNy41IDcuNSAwIDEgMSA1LjM5Ni0xMi44MTJMMTcuNSA2LjcwM1Y0LjM3NWEuNjI1LjYyNSAwIDAgMSAxLjI1IDBaIi8+PC9zdmc+", we = new Image();
518
518
  we.src = Je;
519
519
  function Ke(o, e, t, a, r) {
520
520
  var n = te, i = n / 2;
521
- o.save(), o.translate(e, t), o.rotate(U.degreesToRadians(r.angle)), o.fillStyle = Qe, o.beginPath(), o.arc(0, 0, i, 0, 2 * Math.PI), o.fill(), o.drawImage(we, -16 / 2, -16 / 2, i, i), o.restore();
521
+ o.save(), o.translate(e, t), o.rotate(Y.degreesToRadians(r.angle)), o.fillStyle = Qe, o.beginPath(), o.arc(0, 0, i, 0, 2 * Math.PI), o.fill(), o.drawImage(we, -16 / 2, -16 / 2, i, i), o.restore();
522
522
  }
523
523
  var $e = {
524
524
  // Угловые точки
525
525
  tl: {
526
- render: R,
526
+ render: W,
527
527
  sizeX: I,
528
528
  sizeY: I,
529
529
  offsetX: 0,
530
530
  offsetY: 0
531
531
  },
532
532
  tr: {
533
- render: R,
533
+ render: W,
534
534
  sizeX: I,
535
535
  sizeY: I,
536
536
  offsetX: 0,
537
537
  offsetY: 0
538
538
  },
539
539
  bl: {
540
- render: R,
540
+ render: W,
541
541
  sizeX: I,
542
542
  sizeY: I,
543
543
  offsetX: 0,
544
544
  offsetY: 0
545
545
  },
546
546
  br: {
547
- render: R,
547
+ render: W,
548
548
  sizeX: I,
549
549
  sizeY: I,
550
550
  offsetX: 0,
@@ -628,7 +628,7 @@ function ct(o) {
628
628
  });
629
629
  };
630
630
  }
631
- const x = {
631
+ const B = {
632
632
  style: {
633
633
  position: "absolute",
634
634
  display: "none",
@@ -779,11 +779,11 @@ class ht {
779
779
  if (this.options = t.options, !!this.options.showToolbar) {
780
780
  this.editor = t, this.canvas = t.canvas;
781
781
  var a = this.options.toolbar || {};
782
- this.config = j(j(j({}, x), a), {}, {
783
- style: j(j({}, x.style), a.style || {}),
784
- btnStyle: j(j({}, x.btnStyle), a.btnStyle || {}),
785
- icons: j(j({}, x.icons), a.icons || {}),
786
- handlers: j(j({}, x.handlers), a.handlers || {})
782
+ this.config = j(j(j({}, B), a), {}, {
783
+ style: j(j({}, B.style), a.style || {}),
784
+ btnStyle: j(j({}, B.btnStyle), a.btnStyle || {}),
785
+ icons: j(j({}, B.icons), a.icons || {}),
786
+ handlers: j(j({}, B.handlers), a.handlers || {})
787
787
  }), 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 = () => {
788
788
  this.el.style.display = "none";
789
789
  }, this._createDOM(), this._bindEvents();
@@ -1096,7 +1096,7 @@ class gt {
1096
1096
  })();
1097
1097
  }
1098
1098
  }
1099
- var vt = 0.1, mt = 2, ft = 0.1, Mt = 90, B = 16, Z = 16, N = 4096, L = 4096;
1099
+ var vt = 0.1, mt = 2, ft = 0.1, Mt = 90, Z = 16, z = 16, N = 4096, L = 4096;
1100
1100
  function je(o, e, t, a, r, n, i) {
1101
1101
  try {
1102
1102
  var s = o[n](i), c = s.value;
@@ -1105,7 +1105,7 @@ function je(o, e, t, a, r, n, i) {
1105
1105
  }
1106
1106
  s.done ? e(c) : Promise.resolve(c).then(a, r);
1107
1107
  }
1108
- function O(o) {
1108
+ function T(o) {
1109
1109
  return function() {
1110
1110
  var e = this, t = arguments;
1111
1111
  return new Promise(function(a, r) {
@@ -1141,33 +1141,62 @@ class A {
1141
1141
  * 'scale-montage' - Обновляет backstore-резолюцию монтажной области (масштабирует
1142
1142
  * экспортный размер канваса под размер изображения)
1143
1143
  * @param {Boolean} [options.withoutSave] - Не сохранять в историю изменений
1144
+ * @returns {Promise<Object|null>} - возвращает Promise с объектом изображения или null в случае ошибки
1144
1145
  */
1145
1146
  importImage(e) {
1146
1147
  var t = this;
1147
- return O(function* () {
1148
+ return T(function* () {
1148
1149
  var {
1149
1150
  source: a,
1150
1151
  scale: r = "image-".concat(t.options.scaleType),
1151
1152
  withoutSave: n = !1
1152
1153
  } = e;
1153
- if (a) {
1154
- var {
1155
- canvas: i,
1156
- montageArea: s,
1157
- transformManager: c,
1158
- historyManager: u,
1159
- errorManager: l
1160
- } = t.editor, d = yield t.getContentType(a), h = A.getFormatFromContentType(d), {
1161
- acceptContentTypes: v,
1162
- acceptFormats: m
1163
- } = t;
1164
- if (!t.isAllowedContentType(d)) {
1165
- var f = "Неверный contentType для изображения: ".concat(d, ". Ожидается один из: ").concat(t.acceptContentTypes.join(", "), ".");
1166
- l.emitError({
1154
+ if (!a) return null;
1155
+ var {
1156
+ canvas: i,
1157
+ montageArea: s,
1158
+ transformManager: c,
1159
+ historyManager: u,
1160
+ errorManager: l
1161
+ } = t.editor, d = yield t.getContentType(a), h = A.getFormatFromContentType(d), {
1162
+ acceptContentTypes: v,
1163
+ acceptFormats: m
1164
+ } = t;
1165
+ if (!t.isAllowedContentType(d)) {
1166
+ var f = "Неверный contentType для изображения: ".concat(d, ". Ожидается один из: ").concat(t.acceptContentTypes.join(", "), ".");
1167
+ return l.emitError({
1168
+ origin: "ImageManager",
1169
+ method: "importImage",
1170
+ code: "INVALID_CONTENT_TYPE",
1171
+ message: f,
1172
+ data: {
1173
+ source: a,
1174
+ format: h,
1175
+ contentType: d,
1176
+ acceptContentTypes: v,
1177
+ acceptFormats: m
1178
+ }
1179
+ }), null;
1180
+ }
1181
+ u.suspendHistory();
1182
+ try {
1183
+ var M, g;
1184
+ if (a instanceof File)
1185
+ M = URL.createObjectURL(a);
1186
+ else if (typeof a == "string") {
1187
+ var C = yield fetch(a, {
1188
+ mode: "cors"
1189
+ }), y = yield C.blob({
1190
+ type: d,
1191
+ quality: 1
1192
+ });
1193
+ M = URL.createObjectURL(y);
1194
+ } else
1195
+ return l.emitError({
1167
1196
  origin: "ImageManager",
1168
1197
  method: "importImage",
1169
- code: "INVALID_CONTENT_TYPE",
1170
- message: f,
1198
+ code: "INVALID_SOURCE_TYPE",
1199
+ message: "Неверный тип источника изображения. Ожидается URL или объект File.",
1171
1200
  data: {
1172
1201
  source: a,
1173
1202
  format: h,
@@ -1175,101 +1204,71 @@ class A {
1175
1204
  acceptContentTypes: v,
1176
1205
  acceptFormats: m
1177
1206
  }
1207
+ }), null;
1208
+ if (t._createdBlobUrls.push(M), h === "svg") {
1209
+ var D = yield ke(M);
1210
+ g = Y.groupSVGElements(D.objects, D.options);
1211
+ } else
1212
+ g = yield le.fromURL(M, {
1213
+ crossOrigin: "anonymous"
1214
+ });
1215
+ var {
1216
+ width: E,
1217
+ height: S
1218
+ } = g;
1219
+ if (S > L || E > N) {
1220
+ var p = yield t.resizeImageToBoundaries(g._element.src, "max"), k = URL.createObjectURL(p);
1221
+ t._createdBlobUrls.push(k), g = yield le.fromURL(k, {
1222
+ crossOrigin: "anonymous"
1178
1223
  });
1179
- return;
1180
1224
  }
1181
- u.suspendHistory();
1182
- try {
1183
- var M, g;
1184
- if (a instanceof File)
1185
- M = URL.createObjectURL(a);
1186
- else if (typeof a == "string") {
1187
- var C = yield fetch(a, {
1188
- mode: "cors"
1189
- }), y = yield C.blob({
1190
- type: d,
1191
- quality: 1
1192
- });
1193
- M = URL.createObjectURL(y);
1194
- } else {
1195
- l.emitError({
1196
- origin: "ImageManager",
1197
- method: "importImage",
1198
- code: "INVALID_SOURCE_TYPE",
1199
- message: "Неверный тип источника изображения. Ожидается URL или объект File.",
1200
- data: {
1201
- source: a,
1202
- format: h,
1203
- contentType: d,
1204
- acceptContentTypes: v,
1205
- acceptFormats: m
1206
- }
1207
- });
1208
- return;
1209
- }
1210
- if (t._createdBlobUrls.push(M), h === "svg") {
1211
- var D = yield ke(M);
1212
- g = U.groupSVGElements(D.objects, D.options);
1213
- } else
1214
- g = yield le.fromURL(M, {
1215
- crossOrigin: "anonymous"
1216
- });
1225
+ if (g.set("id", "".concat(g.type, "-").concat(w())), g.set("format", h), r === "scale-montage")
1226
+ t.editor.canvasManager.scaleMontageAreaToImage({
1227
+ object: g,
1228
+ withoutSave: !0
1229
+ });
1230
+ else {
1217
1231
  var {
1218
- width: E,
1219
- height: S
1220
- } = g;
1221
- if (S > L || E > N) {
1222
- var p = yield t.resizeImageToBoundaries(g._element.src, "max"), T = URL.createObjectURL(p);
1223
- t._createdBlobUrls.push(T), g = yield le.fromURL(T, {
1224
- crossOrigin: "anonymous"
1225
- });
1226
- }
1227
- if (g.set("id", "".concat(g.type, "-").concat(w())), g.set("format", h), r === "scale-montage")
1228
- t.editor.canvasManager.scaleMontageAreaToImage({
1229
- object: g,
1230
- withoutSave: !0
1231
- });
1232
- else {
1233
- var {
1234
- width: Y,
1235
- height: H
1236
- } = s, _ = t.calculateScaleFactor({
1237
- imageObject: g,
1238
- scaleType: r
1239
- });
1240
- r === "image-contain" && _ < 1 ? c.fitObject({
1241
- object: g,
1242
- type: "contain",
1243
- withoutSave: !0
1244
- }) : r === "image-cover" && (E > Y || S > H) && c.fitObject({
1245
- object: g,
1246
- type: "cover",
1247
- withoutSave: !0
1248
- });
1249
- }
1250
- i.add(g), i.centerObject(g), i.setActiveObject(g), i.renderAll(), u.resumeHistory(), n || u.saveState(), i.fire("editor:image-imported", {
1251
- image: g,
1232
+ width: H,
1233
+ height: _
1234
+ } = s, R = t.calculateScaleFactor({
1235
+ imageObject: g,
1236
+ scaleType: r
1237
+ });
1238
+ r === "image-contain" && R < 1 ? c.fitObject({
1239
+ object: g,
1240
+ type: "contain",
1241
+ withoutSave: !0
1242
+ }) : r === "image-cover" && (E > H || S > _) && c.fitObject({
1243
+ object: g,
1244
+ type: "cover",
1245
+ withoutSave: !0
1246
+ });
1247
+ }
1248
+ i.add(g), i.centerObject(g), i.setActiveObject(g), i.renderAll(), u.resumeHistory(), n || u.saveState();
1249
+ var O = {
1250
+ image: g,
1251
+ format: h,
1252
+ contentType: d,
1253
+ scale: r,
1254
+ withoutSave: n,
1255
+ source: a
1256
+ };
1257
+ return i.fire("editor:image-imported", O), O;
1258
+ } catch (x) {
1259
+ return l.emitError({
1260
+ origin: "ImageManager",
1261
+ method: "importImage",
1262
+ code: "IMPORT_FAILED",
1263
+ message: "Ошибка импорта изображения: ".concat(x.message),
1264
+ data: {
1265
+ source: a,
1252
1266
  format: h,
1253
1267
  contentType: d,
1254
1268
  scale: r,
1255
- withoutSave: n,
1256
- source: a
1257
- });
1258
- } catch (k) {
1259
- l.emitError({
1260
- origin: "ImageManager",
1261
- method: "importImage",
1262
- code: "IMPORT_FAILED",
1263
- message: "Ошибка импорта изображения: ".concat(k.message),
1264
- data: {
1265
- source: a,
1266
- format: h,
1267
- contentType: d,
1268
- scale: r,
1269
- withoutSave: n
1270
- }
1271
- }), u.resumeHistory();
1272
- }
1269
+ withoutSave: n
1270
+ }
1271
+ }), u.resumeHistory(), null;
1273
1272
  }
1274
1273
  })();
1275
1274
  }
@@ -1283,7 +1282,7 @@ class A {
1283
1282
  */
1284
1283
  resizeImageToBoundaries(e) {
1285
1284
  var t = arguments, a = this;
1286
- return O(function* () {
1285
+ return T(function* () {
1287
1286
  var r = t.length > 1 && t[1] !== void 0 ? t[1] : "max", n = "Размер изображения больше максимального размера канваса, поэтому оно будет уменьшено до максимальных размеров: ".concat(N, "x").concat(L);
1288
1287
  a.editor.errorManager.emitWarning({
1289
1288
  origin: "ImageManager",
@@ -1317,7 +1316,7 @@ class A {
1317
1316
  */
1318
1317
  exportCanvasAsImageFile() {
1319
1318
  var e = arguments, t = this;
1320
- return O(function* () {
1319
+ return T(function* () {
1321
1320
  var {
1322
1321
  fileName: a = "image.png",
1323
1322
  contentType: r = "image/png",
@@ -1365,26 +1364,26 @@ class A {
1365
1364
  g.getElement().toBlob(b);
1366
1365
  });
1367
1366
  if (g.dispose(), i) {
1368
- var T = {
1367
+ var k = {
1369
1368
  image: p,
1370
1369
  format: h,
1371
1370
  contentType: d,
1372
1371
  fileName: a
1373
1372
  };
1374
- return s.fire("editor:canvas-exported", T), T;
1373
+ return s.fire("editor:canvas-exported", k), k;
1375
1374
  }
1376
- var Y = yield createImageBitmap(p), H = yield u.post("toDataURL", {
1375
+ var H = yield createImageBitmap(p), _ = yield u.post("toDataURL", {
1377
1376
  format: h,
1378
1377
  quality: 1,
1379
- bitmap: Y
1380
- }, [Y]);
1378
+ bitmap: H
1379
+ }, [H]);
1381
1380
  if (l) {
1382
- var _ = 0.264583, k = f * _, V = M * _, Ce = (yield t.editor.moduleLoader.loadModule("jspdf")).jsPDF, G = new Ce({
1383
- orientation: k > V ? "landscape" : "portrait",
1381
+ var R = 0.264583, O = f * R, x = M * R, Ce = (yield t.editor.moduleLoader.loadModule("jspdf")).jsPDF, G = new Ce({
1382
+ orientation: O > x ? "landscape" : "portrait",
1384
1383
  unit: "mm",
1385
- format: [k, V]
1384
+ format: [O, x]
1386
1385
  });
1387
- if (G.addImage(H, "JPG", 0, 0, k, V), n) {
1386
+ if (G.addImage(_, "JPG", 0, 0, O, x), n) {
1388
1387
  var De = G.output("datauristring"), oe = {
1389
1388
  image: De,
1390
1389
  format: "pdf",
@@ -1405,7 +1404,7 @@ class A {
1405
1404
  }
1406
1405
  if (n) {
1407
1406
  var ce = {
1408
- image: H,
1407
+ image: _,
1409
1408
  format: h,
1410
1409
  contentType: d,
1411
1410
  fileName: a
@@ -1450,7 +1449,7 @@ class A {
1450
1449
  */
1451
1450
  exportObjectAsImageFile() {
1452
1451
  var e = arguments, t = this;
1453
- return O(function* () {
1452
+ return T(function* () {
1454
1453
  var {
1455
1454
  object: a,
1456
1455
  fileName: r = "image.png",
@@ -1604,7 +1603,7 @@ class A {
1604
1603
  */
1605
1604
  getContentType(e) {
1606
1605
  var t = this;
1607
- return O(function* () {
1606
+ return T(function* () {
1608
1607
  return typeof e == "string" ? t.getContentTypeFromUrl(e) : e.type || "application/octet-stream";
1609
1608
  })();
1610
1609
  }
@@ -1616,7 +1615,7 @@ class A {
1616
1615
  */
1617
1616
  getContentTypeFromUrl(e) {
1618
1617
  var t = this;
1619
- return O(function* () {
1618
+ return T(function* () {
1620
1619
  if (e.startsWith("data:")) {
1621
1620
  var a = e.match(/^data:([^;]+)/);
1622
1621
  return a ? a[1] : "application/octet-stream";
@@ -1706,7 +1705,7 @@ class jt {
1706
1705
  } = this.editor, {
1707
1706
  width: c,
1708
1707
  height: u
1709
- } = i, l = Number(Math.max(Math.min(e, N), B));
1708
+ } = i, l = Number(Math.max(Math.min(e, N), Z));
1710
1709
  if (!s || s === "auto" || r ? this.adaptCanvasToContainer() : s ? this.setCanvasBackstoreWidth(s) : this.setCanvasBackstoreWidth(l), i.set({
1711
1710
  width: l
1712
1711
  }), n.clipPath.set({
@@ -1749,7 +1748,7 @@ class jt {
1749
1748
  } = this.editor, {
1750
1749
  width: c,
1751
1750
  height: u
1752
- } = i, l = Number(Math.max(Math.min(e, L), Z));
1751
+ } = i, l = Number(Math.max(Math.min(e, L), z));
1753
1752
  if (!s || s === "auto" || r ? this.adaptCanvasToContainer() : s ? this.setCanvasBackstoreHeight(s) : this.setCanvasBackstoreHeight(l), i.set({
1754
1753
  height: l
1755
1754
  }), n.clipPath.set({
@@ -1811,7 +1810,7 @@ class jt {
1811
1810
  }
1812
1811
  setCanvasBackstoreWidth(e) {
1813
1812
  if (!(!e || typeof e != "number")) {
1814
- var t = Math.max(Math.min(e, N), B);
1813
+ var t = Math.max(Math.min(e, N), Z);
1815
1814
  this.editor.canvas.setDimensions({
1816
1815
  width: t
1817
1816
  }, {
@@ -1821,7 +1820,7 @@ class jt {
1821
1820
  }
1822
1821
  setCanvasBackstoreHeight(e) {
1823
1822
  if (!(!e || typeof e != "number")) {
1824
- var t = Math.max(Math.min(e, L), Z);
1823
+ var t = Math.max(Math.min(e, L), z);
1825
1824
  this.editor.canvas.setDimensions({
1826
1825
  height: t
1827
1826
  }, {
@@ -1832,7 +1831,7 @@ class jt {
1832
1831
  adaptCanvasToContainer() {
1833
1832
  var {
1834
1833
  canvas: e
1835
- } = this.editor, t = e.editorContainer, a = t.clientWidth, r = t.clientHeight, n = Math.max(Math.min(a, N), B), i = Math.max(Math.min(r, L), Z);
1834
+ } = this.editor, t = e.editorContainer, a = t.clientWidth, r = t.clientHeight, n = Math.max(Math.min(a, N), Z), i = Math.max(Math.min(r, L), z);
1836
1835
  console.log("adaptCanvasToContainer newWidth", n), console.log("adaptCanvasToContainer newHeight", i), e.setDimensions({
1837
1836
  width: n,
1838
1837
  height: i
@@ -2016,8 +2015,8 @@ class jt {
2016
2015
  width: l,
2017
2016
  height: d
2018
2017
  } = u;
2019
- if (l < B || d < Z) {
2020
- var h = "Размер изображения меньше минимального размера канваса, поэтому оно будет растянуто до минимальных размеров: ".concat(B, "x").concat(Z);
2018
+ if (l < Z || d < z) {
2019
+ var h = "Размер изображения меньше минимального размера канваса, поэтому оно будет растянуто до минимальных размеров: ".concat(Z, "x").concat(z);
2021
2020
  console.warn("scaleMontageAreaToImage. ".concat(h)), r.fire("editor:warning", {
2022
2021
  message: h
2023
2022
  });
@@ -2297,7 +2296,7 @@ class yt {
2297
2296
  });
2298
2297
  h.scale(v), n.centerObject(h);
2299
2298
  });
2300
- var l = new P(u, {
2299
+ var l = new U(u, {
2301
2300
  canvas: n
2302
2301
  });
2303
2302
  n.setActiveObject(l);
@@ -2480,7 +2479,7 @@ class pt {
2480
2479
  }
2481
2480
  }
2482
2481
  }
2483
- class W {
2482
+ class F {
2484
2483
  /**
2485
2484
  * @param {object} options
2486
2485
  * @param {ImageEditor} options.editor - экземпляр редактора с доступом к canvas
@@ -2527,7 +2526,7 @@ class W {
2527
2526
  } = this.editor;
2528
2527
  r.suspendHistory();
2529
2528
  var n = e || a.getActiveObject();
2530
- n && (n.type === "activeselection" ? W._moveSelectionForward(a, n) : a.bringObjectForward(n), a.renderAll(), r.resumeHistory(), t || r.saveState(), a.fire("editor:object-bring-forward"));
2529
+ n && (n.type === "activeselection" ? F._moveSelectionForward(a, n) : a.bringObjectForward(n), a.renderAll(), r.resumeHistory(), t || r.saveState(), a.fire("editor:object-bring-forward"));
2531
2530
  }
2532
2531
  /**
2533
2532
  * Отправить объект на задний план по оси Z
@@ -2577,7 +2576,7 @@ class W {
2577
2576
  } = this.editor;
2578
2577
  n.suspendHistory();
2579
2578
  var s = e || a.getActiveObject();
2580
- s && (s.type === "activeselection" ? W._moveSelectionBackwards(a, s) : a.sendObjectBackwards(s), a.sendObjectToBack(r), a.sendObjectToBack(i), a.renderAll(), n.resumeHistory(), t || n.saveState(), a.fire("editor:object-send-backwards"));
2579
+ s && (s.type === "activeselection" ? F._moveSelectionBackwards(a, s) : a.sendObjectBackwards(s), a.sendObjectToBack(r), a.sendObjectToBack(i), a.renderAll(), n.resumeHistory(), t || n.saveState(), a.fire("editor:object-send-backwards"));
2581
2580
  }
2582
2581
  /**
2583
2582
  * Сдвигает выделенные объекты на один уровень вверх относительно ближайшего верхнего объекта
@@ -2891,7 +2890,7 @@ class Lt {
2891
2890
  left: a.left + 10,
2892
2891
  top: a.top + 10,
2893
2892
  evented: !0
2894
- }), a instanceof P ? (a.canvas = t, a.forEachObject((r) => {
2893
+ }), a instanceof U ? (a.canvas = t, a.forEachObject((r) => {
2895
2894
  t.add(r);
2896
2895
  })) : t.add(a), t.setActiveObject(a), t.requestRenderAll(), t.fire("editor:object-pasted", {
2897
2896
  object: a
@@ -3036,7 +3035,7 @@ class Ot {
3036
3035
  if (!(!n || n.type !== "group")) {
3037
3036
  var i = n.removeAll();
3038
3037
  a.remove(n), i.forEach((c) => a.add(c));
3039
- var s = new P(i, {
3038
+ var s = new U(i, {
3040
3039
  canvas: a
3041
3040
  });
3042
3041
  a.setActiveObject(s), a.renderAll(), r.resumeHistory(), t || r.saveState(), a.fire("editor:objects-ungrouped");
@@ -3065,7 +3064,7 @@ class Tt {
3065
3064
  objectLockManager: a
3066
3065
  } = this.editor;
3067
3066
  e.discardActiveObject();
3068
- var r = t.getObjects(), n = r.some((s) => s.locked), i = r.length > 1 ? new P(t.getObjects(), {
3067
+ var r = t.getObjects(), n = r.some((s) => s.locked), i = r.length > 1 ? new U(t.getObjects(), {
3069
3068
  canvas: e
3070
3069
  }) : r[0];
3071
3070
  n && a.lockObject({
@@ -3140,7 +3139,7 @@ var xt = {
3140
3139
  IMAGE_EXPORT_FAILED: "IMAGE_EXPORT_FAILED"
3141
3140
  }
3142
3141
  };
3143
- class F {
3142
+ class V {
3144
3143
  constructor(e) {
3145
3144
  var {
3146
3145
  editor: t
@@ -3165,7 +3164,7 @@ class F {
3165
3164
  data: n,
3166
3165
  message: i
3167
3166
  } = e;
3168
- if (!F.isValidErrorCode(r)) {
3167
+ if (!V.isValidErrorCode(r)) {
3169
3168
  console.warn("Неизвестный код ошибки: ", {
3170
3169
  code: r,
3171
3170
  origin: t,
@@ -3202,7 +3201,7 @@ class F {
3202
3201
  message: n,
3203
3202
  data: i
3204
3203
  } = e;
3205
- if (!F.isValidErrorCode(r)) {
3204
+ if (!V.isValidErrorCode(r)) {
3206
3205
  console.warn("Неизвестный код ошибки: ", {
3207
3206
  code: r,
3208
3207
  origin: t,
@@ -3272,7 +3271,7 @@ class ie {
3272
3271
  scaleType: l,
3273
3272
  _onReadyCallback: d
3274
3273
  } = e.options;
3275
- if (qe.apply(), e.canvas = new Ye(e.containerId, e.options), e.moduleLoader = new We(), e.workerManager = new Fe(), e.errorManager = new F({
3274
+ if (qe.apply(), e.canvas = new Ye(e.containerId, e.options), e.moduleLoader = new We(), e.workerManager = new Fe(), e.errorManager = new V({
3276
3275
  editor: e
3277
3276
  }), e.historyManager = new gt({
3278
3277
  editor: e
@@ -3284,7 +3283,7 @@ class ie {
3284
3283
  editor: e
3285
3284
  }), e.imageManager = new A({
3286
3285
  editor: e
3287
- }), e.layerManager = new W({
3286
+ }), e.layerManager = new F({
3288
3287
  editor: e
3289
3288
  }), e.shapeManager = new Nt({
3290
3289
  editor: e
@@ -3300,7 +3299,7 @@ class ie {
3300
3299
  editor: e
3301
3300
  }), e.deletionManager = new kt({
3302
3301
  editor: e
3303
- }), e._createMonageArea(), e._createClippingArea(), e.listeners = new z({
3302
+ }), e._createMonageArea(), e._createClippingArea(), e.listeners = new P({
3304
3303
  editor: e,
3305
3304
  options: e.options
3306
3305
  }), e.canvasManager.setEditorContainerWidth(t), e.canvasManager.setEditorContainerHeight(a), e.canvasManager.setCanvasWrapperWidth(r), e.canvasManager.setCanvasWrapperHeight(n), e.canvasManager.setCanvasCSSWidth(i), e.canvasManager.setCanvasCSSHeight(s), c != null && c.source) {
@@ -3495,7 +3494,7 @@ const Zt = {
3495
3494
  // Зум по колесику мыши
3496
3495
  mouseWheelZooming: !0,
3497
3496
  // Перемещение канваса при зажатой кнопке ALT
3498
- canvasDragging: !1,
3497
+ canvasDragging: !0,
3499
3498
  // Копирование объектов (Ctrl + C, Ctrl + V)
3500
3499
  copyObjectsByHotkey: !0,
3501
3500
  // Вставка изображения из буфера обмена
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anu3ev/fabric-image-editor",
3
- "version": "0.1.30",
3
+ "version": "0.1.31",
4
4
  "description": "JavaScript image editor built on FabricJS, allowing you to create instances with an integrated montage area and providing an API to modify and manage state.",
5
5
  "module": "dist/main.js",
6
6
  "files": [