@anu3ev/fabric-image-editor 0.1.54 → 0.1.56

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 +176 -146
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -1,15 +1,15 @@
1
- var je = Object.defineProperty, fe = Object.defineProperties;
1
+ var fe = Object.defineProperty, je = Object.defineProperties;
2
2
  var be = Object.getOwnPropertyDescriptors;
3
3
  var H = Object.getOwnPropertySymbols;
4
4
  var ce = Object.prototype.hasOwnProperty, de = Object.prototype.propertyIsEnumerable;
5
- var re = (d, e, t) => e in d ? je(d, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : d[e] = t, f = (d, e) => {
5
+ var re = (d, e, t) => e in d ? fe(d, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : d[e] = t, p = (d, e) => {
6
6
  for (var t in e || (e = {}))
7
7
  ce.call(e, t) && re(d, t, e[t]);
8
8
  if (H)
9
9
  for (var t of H(e))
10
10
  de.call(e, t) && re(d, t, e[t]);
11
11
  return d;
12
- }, le = (d, e) => fe(d, be(e));
12
+ }, le = (d, e) => je(d, be(e));
13
13
  var Y = (d, e) => {
14
14
  var t = {};
15
15
  for (var s in d)
@@ -19,7 +19,7 @@ var Y = (d, e) => {
19
19
  e.indexOf(s) < 0 && de.call(d, s) && (t[s] = d[s]);
20
20
  return t;
21
21
  };
22
- var p = (d, e, t) => new Promise((s, i) => {
22
+ var I = (d, e, t) => new Promise((s, i) => {
23
23
  var n = (c) => {
24
24
  try {
25
25
  o(t.next(c));
@@ -35,10 +35,10 @@ var p = (d, e, t) => new Promise((s, i) => {
35
35
  }, o = (c) => c.done ? s(c.value) : Promise.resolve(c.value).then(n, a);
36
36
  o((t = t.apply(d, e)).next());
37
37
  });
38
- import { ActiveSelection as v, util as R, controlsUtils as ye, InteractiveFabricObject as Ie, loadSVGFromURL as pe, FabricImage as Z, Point as _, Rect as ve, Circle as Ae, Triangle as Se, Group as X, Canvas as Ce, Pattern as Ne } from "fabric";
38
+ import { ActiveSelection as v, util as R, controlsUtils as pe, InteractiveFabricObject as ye, loadSVGFromURL as Ie, FabricImage as Z, Point as _, Rect as ve, Circle as Ae, Triangle as Se, Group as X, Canvas as Ce, Pattern as Ne } from "fabric";
39
39
  import { create as De } from "jsondiffpatch";
40
40
  import Le from "diff-match-patch";
41
- var we = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", D = function() {
41
+ var we = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", L = function() {
42
42
  for (var e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 21, t = "", s = crypto.getRandomValues(new Uint8Array(e |= 0)); e--; )
43
43
  t += we[s[e] & 63];
44
44
  return t;
@@ -129,7 +129,7 @@ class z {
129
129
  // --- Глобальные DOM-обработчики ---
130
130
  /**
131
131
  * Обработчик изменения размеров окна браузера.
132
- * Адаптирует канвас к размерам контейнера.
132
+ * Адаптирует канвас к размерам контейнера, сохраняя позиции объектов.
133
133
  */
134
134
  handleContainerResize() {
135
135
  this.editor.canvasManager.updateCanvasAndFitObjects();
@@ -160,7 +160,7 @@ class z {
160
160
  * @param event.code — код клавиши
161
161
  */
162
162
  handleUndoRedoEvent(e) {
163
- return p(this, null, function* () {
163
+ return I(this, null, function* () {
164
164
  const { ctrlKey: t, metaKey: s, code: i, repeat: n } = e;
165
165
  !t && !s || n || !/Mac/i.test(navigator.userAgent) && this.isUndoRedoKeyPressed || (i === "KeyZ" ? (e.preventDefault(), this.isUndoRedoKeyPressed = !0, yield this.editor.historyManager.undo()) : i === "KeyY" && (e.preventDefault(), this.isUndoRedoKeyPressed = !0, yield this.editor.historyManager.redo()));
166
166
  });
@@ -366,7 +366,7 @@ class Te {
366
366
  * @returns Promise, который будет выполнен, когда воркер вернет ответ
367
367
  */
368
368
  post(e, t, s = []) {
369
- const i = `${e}:${D(8)}`;
369
+ const i = `${e}:${L(8)}`;
370
370
  return new Promise((n, a) => {
371
371
  this._callbacks.set(i, { resolve: n, reject: a }), this.worker.postMessage({ action: e, payload: t, requestId: i }, s);
372
372
  });
@@ -378,9 +378,9 @@ class Te {
378
378
  this.worker.terminate();
379
379
  }
380
380
  }
381
- const C = 12, ke = 2, Q = 8, J = 20, xe = 100, $ = 20, K = 8, Be = 100, q = 32, ee = 1, Ze = "#2B2D33", te = "#3D8BF4", se = "#FFFFFF";
381
+ const N = 12, ke = 2, Q = 8, J = 20, xe = 100, $ = 20, K = 8, Be = 100, q = 32, ee = 1, Ze = "#2B2D33", te = "#3D8BF4", se = "#FFFFFF";
382
382
  function W(d, e, t, s, i) {
383
- const n = C, a = ke;
383
+ const n = N, a = ke;
384
384
  d.save(), d.translate(e, t), d.rotate(R.degreesToRadians(i.angle)), d.fillStyle = se, d.strokeStyle = te, d.lineWidth = ee, d.beginPath(), d.roundRect(-12 / 2, -12 / 2, n, n, a), d.fill(), d.stroke(), d.restore();
385
385
  }
386
386
  function he(d, e, t, s, i) {
@@ -401,29 +401,29 @@ const Re = {
401
401
  // Угловые точки
402
402
  tl: {
403
403
  render: W,
404
- sizeX: C,
405
- sizeY: C,
404
+ sizeX: N,
405
+ sizeY: N,
406
406
  offsetX: 0,
407
407
  offsetY: 0
408
408
  },
409
409
  tr: {
410
410
  render: W,
411
- sizeX: C,
412
- sizeY: C,
411
+ sizeX: N,
412
+ sizeY: N,
413
413
  offsetX: 0,
414
414
  offsetY: 0
415
415
  },
416
416
  bl: {
417
417
  render: W,
418
- sizeX: C,
419
- sizeY: C,
418
+ sizeX: N,
419
+ sizeY: N,
420
420
  offsetX: 0,
421
421
  offsetY: 0
422
422
  },
423
423
  br: {
424
424
  render: W,
425
- sizeX: C,
426
- sizeY: C,
425
+ sizeX: N,
426
+ sizeY: N,
427
427
  offsetX: 0,
428
428
  offsetY: 0
429
429
  },
@@ -468,7 +468,7 @@ const Re = {
468
468
  };
469
469
  class He {
470
470
  static apply() {
471
- const e = ye.createObjectDefaultControls();
471
+ const e = pe.createObjectDefaultControls();
472
472
  Object.entries(Re).forEach(([t, s]) => {
473
473
  Object.assign(e[t], {
474
474
  render: s.render,
@@ -480,7 +480,7 @@ class He {
480
480
  var l;
481
481
  (l = a.target.canvas) == null || l.setCursor("grabbing");
482
482
  });
483
- }), Ie.ownDefaults.controls = e;
483
+ }), ye.ownDefaults.controls = e;
484
484
  }
485
485
  }
486
486
  const Ye = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNNi44NzUgMi41YS42MjUuNjI1IDAgMCAwLS42MjUuNjI0VjYuMjVIMy4xMjVhLjYyNS42MjUgMCAwIDAtLjYyNS42MjV2MTBjMCAuMzQ1LjI4LjYyNS42MjUuNjI1aDEwYy4zNDUgMCAuNjI1LS4yOC42MjUtLjYyNXYtMy4xMjZoMy4xMjVjLjM0NSAwIC42MjUtLjI4LjYyNS0uNjI1di0xMGEuNjI1LjYyNSAwIDAgMC0uNjI1LS42MjVoLTEwWm02Ljg3NSAxMGgyLjVWMy43NUg3LjV2Mi41aDUuNjI1Yy4zNDUgMCAuNjI1LjI4LjYyNS42MjV2NS42MjRabS0xMCAzLjc1VjcuNWg4Ljc1djguNzVIMy43NVoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjwvc3ZnPg==", We = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMi41IDcuNWMwLS42OS41Ni0xLjI1IDEuMjUtMS4y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DUuNjI1di01YS42MjUuNjI1IDAgMCAwLTEuMjUgMHY1YS42MjUuNjI1IDAgMSAwIDEuMjUgMFoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjwvc3ZnPg==", U = {
@@ -560,7 +560,7 @@ const Ye = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMj
560
560
  sendBackwards: Fe
561
561
  },
562
562
  handlers: {
563
- copyPaste: (d) => p(void 0, null, function* () {
563
+ copyPaste: (d) => I(void 0, null, function* () {
564
564
  yield d.clipboardManager.copy(), yield d.clipboardManager.paste();
565
565
  }),
566
566
  delete: (d) => {
@@ -593,11 +593,11 @@ class Qe {
593
593
  _initToolbar() {
594
594
  if (!this.options.showToolbar) return;
595
595
  const e = this.options.toolbar || {};
596
- this.config = le(f(f({}, U), e), {
597
- style: f(f({}, U.style), e.style || {}),
598
- btnStyle: f(f({}, U.btnStyle), e.btnStyle || {}),
599
- icons: f(f({}, U.icons), e.icons || {}),
600
- handlers: f(f({}, U.handlers), e.handlers || {})
596
+ this.config = le(p(p({}, U), e), {
597
+ style: p(p({}, U.style), e.style || {}),
598
+ btnStyle: p(p({}, U.btnStyle), e.btnStyle || {}),
599
+ icons: p(p({}, U.icons), e.icons || {}),
600
+ handlers: p(p({}, U.handlers), e.handlers || {})
601
601
  }), this.currentTarget = null, this.currentLocked = !1, this.isTransforming = !1, this._onMouseDown = this._handleMouseDown.bind(this), this._onObjectMoving = this._startTransform.bind(this), this._onObjectScaling = this._startTransform.bind(this), this._onObjectRotating = this._startTransform.bind(this), this._onMouseUp = this._endTransform.bind(this), this._onObjectModified = this._endTransform.bind(this), this._onSelectionChange = this._updateToolbar.bind(this), this._onSelectionClear = () => {
602
602
  this.el.style.display = "none";
603
603
  }, this._createDOM(), this._bindEvents();
@@ -802,7 +802,7 @@ class Je {
802
802
  console.log("Нет изменений для сохранения.");
803
803
  return;
804
804
  }
805
- console.log("baseState", this.baseState), this.currentIndex < this.patches.length && this.patches.splice(this.currentIndex), console.log("diff", s), this.totalChangesCount += 1, this.patches.push({ id: D(), diff: s }), 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);
805
+ console.log("baseState", this.baseState), this.currentIndex < this.patches.length && this.patches.splice(this.currentIndex), console.log("diff", s), this.totalChangesCount += 1, this.patches.push({ id: L(), diff: s }), 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);
806
806
  }
807
807
  /**
808
808
  * Функция загрузки состояния в канвас.
@@ -810,13 +810,13 @@ class Je {
810
810
  * @fires editor:history-state-loaded
811
811
  */
812
812
  loadStateFromFullState(e) {
813
- return p(this, null, function* () {
813
+ return I(this, null, function* () {
814
814
  if (!e) return;
815
815
  console.log("loadStateFromFullState fullState", e);
816
816
  const { canvas: t, canvasManager: s, interactionBlocker: i } = this.editor, { width: n, height: a } = t;
817
817
  yield t.loadFromJSON(e);
818
818
  const o = t.getObjects().find((r) => r.id === "montage-area");
819
- o && (this.editor.montageArea = o, (n !== e.width || a !== e.height) && s.updateCanvasAndFitObjects());
819
+ o && (this.editor.montageArea = o, (n !== t.getWidth() || a !== t.getHeight()) && s.updateCanvas());
820
820
  const c = t.getObjects().find((r) => r.id === "overlay-mask");
821
821
  c && (i.overlayMask = c, i.overlayMask.visible = !1), t.renderAll(), t.fire("editor:history-state-loaded", {
822
822
  fullState: e,
@@ -833,7 +833,7 @@ class Je {
833
833
  * @fires editor:undo
834
834
  */
835
835
  undo() {
836
- return p(this, null, function* () {
836
+ return I(this, null, function* () {
837
837
  if (!this.skipHistory) {
838
838
  if (this.currentIndex <= 0) {
839
839
  console.log("Нет предыдущих состояний для отмены.");
@@ -870,7 +870,7 @@ class Je {
870
870
  * @fires editor:redo
871
871
  */
872
872
  redo() {
873
- return p(this, null, function* () {
873
+ return I(this, null, function* () {
874
874
  if (!this.skipHistory) {
875
875
  if (this.currentIndex >= this.patches.length) {
876
876
  console.log("Нет состояний для повтора.");
@@ -904,7 +904,7 @@ class Je {
904
904
  }
905
905
  }
906
906
  const $e = 0.1, Ke = 2, qe = 0.1, et = 90, x = 16, B = 16, O = 4096, T = 4096;
907
- class N {
907
+ class D {
908
908
  constructor({ editor: e }) {
909
909
  this.editor = e, this.options = e.options, this._createdBlobUrls = [], this.acceptContentTypes = this.editor.options.acceptContentTypes, this.acceptFormats = this.getAllowedFormatsFromContentTypes();
910
910
  }
@@ -921,14 +921,14 @@ class N {
921
921
  * @returns возвращает Promise с объектом изображения или null в случае ошибки
922
922
  */
923
923
  importImage(e) {
924
- return p(this, null, function* () {
924
+ return I(this, null, function* () {
925
925
  const {
926
926
  source: t,
927
927
  scale: s = `image-${this.options.scaleType}`,
928
928
  withoutSave: i = !1
929
929
  } = e;
930
930
  if (!t) return null;
931
- const { canvas: n, montageArea: a, transformManager: o, historyManager: c, errorManager: r } = this.editor, l = yield this.getContentType(t), h = N.getFormatFromContentType(l), { acceptContentTypes: g, acceptFormats: u } = this;
931
+ const { canvas: n, montageArea: a, transformManager: o, historyManager: c, errorManager: r } = this.editor, l = yield this.getContentType(t), h = D.getFormatFromContentType(l), { acceptContentTypes: g, acceptFormats: u } = this;
932
932
  if (!this.isAllowedContentType(l)) {
933
933
  const m = `Неверный contentType для изображения: ${l}. Ожидается один из: ${this.acceptContentTypes.join(", ")}.`;
934
934
  return r.emitError({
@@ -945,8 +945,8 @@ class N {
945
945
  if (t instanceof File)
946
946
  m = URL.createObjectURL(t);
947
947
  else if (typeof t == "string") {
948
- const A = yield (yield fetch(t, { mode: "cors" })).blob();
949
- m = URL.createObjectURL(A);
948
+ const S = yield (yield fetch(t, { mode: "cors" })).blob();
949
+ m = URL.createObjectURL(S);
950
950
  } else
951
951
  return r.emitError({
952
952
  origin: "ImageManager",
@@ -956,30 +956,30 @@ class N {
956
956
  data: { source: t, format: h, contentType: l, acceptContentTypes: g, acceptFormats: u }
957
957
  }), null;
958
958
  if (this._createdBlobUrls.push(m), h === "svg") {
959
- const I = yield pe(m);
960
- M = R.groupSVGElements(I.objects, I.options);
959
+ const b = yield Ie(m);
960
+ M = R.groupSVGElements(b.objects, b.options);
961
961
  } else
962
962
  M = yield Z.fromURL(m, { crossOrigin: "anonymous" });
963
- const { width: j, height: b } = M;
963
+ const { width: f, height: j } = M;
964
964
  if (M instanceof Z) {
965
- const I = M.getElement();
966
- let A = "";
967
- if (I instanceof HTMLImageElement ? A = I.src : I instanceof HTMLCanvasElement && (A = I.toDataURL()), b > T || j > O) {
968
- const w = yield this.resizeImageToBoundaries(A, "max"), E = URL.createObjectURL(w);
965
+ const b = M.getElement();
966
+ let S = "";
967
+ if (b instanceof HTMLImageElement ? S = b.src : b instanceof HTMLCanvasElement && (S = b.toDataURL()), j > T || f > O) {
968
+ const w = yield this.resizeImageToBoundaries(S, "max"), E = URL.createObjectURL(w);
969
969
  this._createdBlobUrls.push(E), M = yield Z.fromURL(E, { crossOrigin: "anonymous" });
970
- } else if (b < B || j < x) {
971
- const w = yield this.resizeImageToBoundaries(A, "min"), E = URL.createObjectURL(w);
970
+ } else if (j < B || f < x) {
971
+ const w = yield this.resizeImageToBoundaries(S, "min"), E = URL.createObjectURL(w);
972
972
  this._createdBlobUrls.push(E), M = yield Z.fromURL(E, { crossOrigin: "anonymous" });
973
973
  }
974
974
  }
975
- if (M.set("id", `${M.type}-${D()}`), M.set("format", h), s === "scale-montage")
975
+ if (M.set("id", `${M.type}-${L()}`), M.set("format", h), s === "scale-montage")
976
976
  this.editor.canvasManager.scaleMontageAreaToImage({ object: M, withoutSave: !0 });
977
977
  else {
978
- const { width: I, height: A } = a, w = this.calculateScaleFactor({ imageObject: M, scaleType: s });
979
- s === "image-contain" && w < 1 ? o.fitObject({ object: M, type: "contain", withoutSave: !0 }) : s === "image-cover" && (j > I || b > A) && o.fitObject({ object: M, type: "cover", withoutSave: !0 });
978
+ const { width: b, height: S } = a, w = this.calculateScaleFactor({ imageObject: M, scaleType: s });
979
+ s === "image-contain" && w < 1 ? o.fitObject({ object: M, type: "contain", withoutSave: !0 }) : s === "image-cover" && (f > b || j > S) && o.fitObject({ object: M, type: "cover", withoutSave: !0 });
980
980
  }
981
981
  n.add(M), n.centerObject(M), n.setActiveObject(M), n.renderAll(), c.resumeHistory(), i || c.saveState();
982
- const L = {
982
+ const A = {
983
983
  image: M,
984
984
  format: h,
985
985
  contentType: l,
@@ -987,7 +987,7 @@ class N {
987
987
  withoutSave: i,
988
988
  source: t
989
989
  };
990
- return n.fire("editor:image-imported", L), L;
990
+ return n.fire("editor:image-imported", A), A;
991
991
  } catch (m) {
992
992
  return r.emitError({
993
993
  origin: "ImageManager",
@@ -1008,7 +1008,7 @@ class N {
1008
1008
  * @returns возвращает Promise с Blob-объектом уменьшенного изображения
1009
1009
  */
1010
1010
  resizeImageToBoundaries(e, t = "max") {
1011
- return p(this, null, function* () {
1011
+ return I(this, null, function* () {
1012
1012
  let s = `Размер изображения больше максимального размера канваса, поэтому оно будет уменьшено до максимальных размеров c сохранением пропорций: ${O}x${T}`;
1013
1013
  t === "min" && (s = `Размер изображения меньше минимального размера канваса, поэтому оно будет увеличено до минимальных размеров c сохранением пропорций: ${x}x${B}`);
1014
1014
  const i = {
@@ -1040,7 +1040,7 @@ class N {
1040
1040
  * @fires editor:canvas-exported
1041
1041
  */
1042
1042
  exportCanvasAsImageFile() {
1043
- return p(this, arguments, function* (e = {}) {
1043
+ return I(this, arguments, function* (e = {}) {
1044
1044
  const {
1045
1045
  fileName: t = "image.png",
1046
1046
  contentType: s = "image/png",
@@ -1048,18 +1048,18 @@ class N {
1048
1048
  exportAsBlob: n = !1
1049
1049
  } = e, { canvas: a, montageArea: o, workerManager: c } = this.editor;
1050
1050
  try {
1051
- const r = s === "application/pdf", l = r ? "image/jpg" : s, h = N.getFormatFromContentType(l);
1051
+ const r = s === "application/pdf", l = r ? "image/jpg" : s, h = D.getFormatFromContentType(l);
1052
1052
  o.setCoords();
1053
- const { left: g, top: u, width: m, height: M } = o.getBoundingRect(), j = yield a.clone(["id", "format", "locked"]);
1054
- ["image/jpg", "image/jpeg"].includes(l) && (j.backgroundColor = "#ffffff");
1055
- const b = j.getObjects().find((y) => y.id === o.id);
1056
- b && (b.visible = !1), j.viewportTransform = [1, 0, 0, 1, -g, -u], j.setDimensions({ width: m, height: M }, { backstoreOnly: !0 }), j.renderAll();
1057
- const L = j.getObjects().filter((y) => y.format).every((y) => y.format === "svg");
1058
- if (h === "svg" && L) {
1059
- const y = j.toSVG();
1060
- j.dispose();
1061
- const S = {
1062
- image: N._exportSVGStringAsFile(y, {
1053
+ const { left: g, top: u, width: m, height: M } = o.getBoundingRect(), f = yield a.clone(["id", "format", "locked"]);
1054
+ ["image/jpg", "image/jpeg"].includes(l) && (f.backgroundColor = "#ffffff");
1055
+ const j = f.getObjects().find((y) => y.id === o.id);
1056
+ j && (j.visible = !1), f.viewportTransform = [1, 0, 0, 1, -g, -u], f.setDimensions({ width: m, height: M }, { backstoreOnly: !0 }), f.renderAll();
1057
+ const A = f.getObjects().filter((y) => y.format).every((y) => y.format === "svg");
1058
+ if (h === "svg" && A) {
1059
+ const y = f.toSVG();
1060
+ f.dispose();
1061
+ const C = {
1062
+ image: D._exportSVGStringAsFile(y, {
1063
1063
  exportAsBase64: i,
1064
1064
  exportAsBlob: n,
1065
1065
  fileName: t
@@ -1068,34 +1068,34 @@ class N {
1068
1068
  contentType: "image/svg+xml",
1069
1069
  fileName: t.replace(/\.[^/.]+$/, ".svg")
1070
1070
  };
1071
- return a.fire("editor:canvas-exported", S), S;
1071
+ return a.fire("editor:canvas-exported", C), C;
1072
1072
  }
1073
- const I = yield new Promise((y, k) => {
1074
- j.getElement().toBlob((S) => {
1075
- S ? y(S) : k(new Error("Failed to create Blob from canvas"));
1073
+ const b = yield new Promise((y, k) => {
1074
+ f.getElement().toBlob((C) => {
1075
+ C ? y(C) : k(new Error("Failed to create Blob from canvas"));
1076
1076
  });
1077
1077
  });
1078
- if (j.dispose(), n) {
1078
+ if (f.dispose(), n) {
1079
1079
  const y = {
1080
- image: I,
1080
+ image: b,
1081
1081
  format: h,
1082
1082
  contentType: l,
1083
1083
  fileName: t
1084
1084
  };
1085
1085
  return a.fire("editor:canvas-exported", y), y;
1086
1086
  }
1087
- const A = yield createImageBitmap(I), w = yield c.post(
1087
+ const S = yield createImageBitmap(b), w = yield c.post(
1088
1088
  "toDataURL",
1089
- { format: h, quality: 1, bitmap: A },
1090
- [A]
1089
+ { format: h, quality: 1, bitmap: S },
1090
+ [S]
1091
1091
  );
1092
1092
  if (r) {
1093
- const k = m * 0.264583, S = M * 0.264583, Me = (yield this.editor.moduleLoader.loadModule("jspdf")).jsPDF, G = new Me({
1094
- orientation: k > S ? "landscape" : "portrait",
1093
+ const k = m * 0.264583, C = M * 0.264583, Me = (yield this.editor.moduleLoader.loadModule("jspdf")).jsPDF, G = new Me({
1094
+ orientation: k > C ? "landscape" : "portrait",
1095
1095
  unit: "mm",
1096
- format: [k, S]
1096
+ format: [k, C]
1097
1097
  });
1098
- if (G.addImage(String(w), "JPG", 0, 0, k, S), i) {
1098
+ if (G.addImage(String(w), "JPG", 0, 0, k, C), i) {
1099
1099
  const oe = {
1100
1100
  image: G.output("datauristring"),
1101
1101
  format: "pdf",
@@ -1121,8 +1121,8 @@ class N {
1121
1121
  };
1122
1122
  return a.fire("editor:canvas-exported", y), y;
1123
1123
  }
1124
- const E = h === "svg" && !L ? t.replace(/\.[^/.]+$/, ".png") : t, ne = {
1125
- image: new File([I], E, { type: l }),
1124
+ const E = h === "svg" && !A ? t.replace(/\.[^/.]+$/, ".png") : t, ne = {
1125
+ image: new File([b], E, { type: l }),
1126
1126
  format: h,
1127
1127
  contentType: l,
1128
1128
  fileName: E
@@ -1151,7 +1151,7 @@ class N {
1151
1151
  * @fires editor:object-exported
1152
1152
  */
1153
1153
  exportObjectAsImageFile() {
1154
- return p(this, arguments, function* (e = {}) {
1154
+ return I(this, arguments, function* (e = {}) {
1155
1155
  const {
1156
1156
  object: t,
1157
1157
  fileName: s = "image.png",
@@ -1168,23 +1168,23 @@ class N {
1168
1168
  data: { contentType: i, fileName: s, exportAsBase64: n, exportAsBlob: a }
1169
1169
  }), null;
1170
1170
  try {
1171
- const l = N.getFormatFromContentType(i);
1171
+ const l = D.getFormatFromContentType(i);
1172
1172
  if (l === "svg") {
1173
- const M = r.toSVG(), j = N._exportSVGStringAsFile(M, {
1173
+ const M = r.toSVG(), f = D._exportSVGStringAsFile(M, {
1174
1174
  exportAsBase64: n,
1175
1175
  exportAsBlob: a,
1176
1176
  fileName: s
1177
- }), b = {
1177
+ }), j = {
1178
1178
  object: r,
1179
- image: j,
1179
+ image: f,
1180
1180
  format: l,
1181
1181
  contentType: "image/svg+xml",
1182
1182
  fileName: s.replace(/\.[^/.]+$/, ".svg")
1183
1183
  };
1184
- return o.fire("editor:object-exported", b), b;
1184
+ return o.fire("editor:object-exported", j), j;
1185
1185
  }
1186
1186
  if (n && r instanceof Z) {
1187
- const M = yield createImageBitmap(r.getElement()), j = yield c.post(
1187
+ const M = yield createImageBitmap(r.getElement()), f = yield c.post(
1188
1188
  "toDataURL",
1189
1189
  {
1190
1190
  format: l,
@@ -1192,18 +1192,18 @@ class N {
1192
1192
  bitmap: M
1193
1193
  },
1194
1194
  [M]
1195
- ), b = {
1195
+ ), j = {
1196
1196
  object: r,
1197
- image: j,
1197
+ image: f,
1198
1198
  format: l,
1199
1199
  contentType: i,
1200
1200
  fileName: s
1201
1201
  };
1202
- return o.fire("editor:object-exported", b), b;
1202
+ return o.fire("editor:object-exported", j), j;
1203
1203
  }
1204
- const h = r.toCanvasElement(), g = yield new Promise((M, j) => {
1205
- h.toBlob((b) => {
1206
- b ? M(b) : j(new Error("Failed to create Blob from canvas"));
1204
+ const h = r.toCanvasElement(), g = yield new Promise((M, f) => {
1205
+ h.toBlob((j) => {
1206
+ j ? M(j) : f(new Error("Failed to create Blob from canvas"));
1207
1207
  });
1208
1208
  });
1209
1209
  if (a) {
@@ -1246,7 +1246,7 @@ class N {
1246
1246
  * @returns массив допустимых форматов изображений
1247
1247
  */
1248
1248
  getAllowedFormatsFromContentTypes() {
1249
- return this.acceptContentTypes.map((e) => N.getFormatFromContentType(e)).filter((e) => e);
1249
+ return this.acceptContentTypes.map((e) => D.getFormatFromContentType(e)).filter((e) => e);
1250
1250
  }
1251
1251
  /**
1252
1252
  * Проверяет, является ли contentType допустимым типом изображения.
@@ -1262,7 +1262,7 @@ class N {
1262
1262
  * @public
1263
1263
  */
1264
1264
  getContentType(e) {
1265
- return p(this, null, function* () {
1265
+ return I(this, null, function* () {
1266
1266
  return typeof e == "string" ? this.getContentTypeFromUrl(e) : e.type || "application/octet-stream";
1267
1267
  });
1268
1268
  }
@@ -1273,7 +1273,7 @@ class N {
1273
1273
  * @public
1274
1274
  */
1275
1275
  getContentTypeFromUrl(e) {
1276
- return p(this, null, function* () {
1276
+ return I(this, null, function* () {
1277
1277
  if (e.startsWith("data:")) {
1278
1278
  const t = e.match(/^data:([^;]+)/);
1279
1279
  return t ? t[1] : "application/octet-stream";
@@ -1299,7 +1299,7 @@ class N {
1299
1299
  try {
1300
1300
  const i = (t = new URL(e).pathname.split(".").pop()) == null ? void 0 : t.toLowerCase(), n = {};
1301
1301
  return this.acceptContentTypes.forEach((a) => {
1302
- const o = N.getFormatFromContentType(a);
1302
+ const o = D.getFormatFromContentType(a);
1303
1303
  o && (n[o] = a);
1304
1304
  }), i && n[i] || "application/octet-stream";
1305
1305
  } catch (s) {
@@ -1378,8 +1378,8 @@ class tt {
1378
1378
  options: { canvasBackstoreWidth: o }
1379
1379
  } = this.editor, { width: c, height: r } = a, l = Math.max(Math.min(Number(e), O), x);
1380
1380
  if (!o || o === "auto" || i ? this.adaptCanvasToContainer() : o ? this.setCanvasBackstoreWidth(Number(o)) : this.setCanvasBackstoreWidth(l), a.set({ width: l }), (m = n.clipPath) == null || m.set({ width: l }), t) {
1381
- const M = l / c, j = r * M;
1382
- this.setResolutionHeight(j);
1381
+ const M = l / c, f = r * M;
1382
+ this.setResolutionHeight(f);
1383
1383
  return;
1384
1384
  }
1385
1385
  const { left: h, top: g } = this.getObjectDefaultCoords(a), u = n.getZoom();
@@ -1408,8 +1408,8 @@ class tt {
1408
1408
  options: { canvasBackstoreHeight: o }
1409
1409
  } = this.editor, { width: c, height: r } = a, l = Math.max(Math.min(Number(e), T), B);
1410
1410
  if (!o || o === "auto" || i ? this.adaptCanvasToContainer() : o ? this.setCanvasBackstoreHeight(Number(o)) : this.setCanvasBackstoreHeight(l), a.set({ height: l }), (m = n.clipPath) == null || m.set({ height: l }), t) {
1411
- const M = l / r, j = c * M;
1412
- this.setResolutionWidth(j);
1411
+ const M = l / r, f = c * M;
1412
+ this.setResolutionWidth(f);
1413
1413
  return;
1414
1414
  }
1415
1415
  const { left: h, top: g } = this.getObjectDefaultCoords(a), u = n.getZoom();
@@ -1481,23 +1481,45 @@ class tt {
1481
1481
  console.log("adaptCanvasToContainer newWidth", n), console.log("adaptCanvasToContainer newHeight", a), e.setDimensions({ width: n, height: a }, { backstoreOnly: !0 });
1482
1482
  }
1483
1483
  /**
1484
- * Обновляет размеры канваса и вписывает объекты в монтажную область.
1485
- * Вызывается при изменении размеров контейнера редактора.
1484
+ * Обновляет размеры канваса без изменения позиций объектов.
1485
+ * Используется при resize окна браузера для сохранения расположения объектов.
1486
1486
  * @fires editor:canvas-updated
1487
1487
  */
1488
- updateCanvasAndFitObjects() {
1488
+ updateCanvas() {
1489
1489
  const {
1490
1490
  canvas: e,
1491
- selectionManager: t,
1492
- transformManager: s,
1491
+ montageArea: t,
1493
1492
  montageArea: {
1494
- width: i,
1495
- height: n
1493
+ width: s,
1494
+ height: i
1496
1495
  }
1497
- } = this.editor;
1498
- this.setResolutionWidth(i, { adaptCanvasToContainer: !0, withoutSave: !0 }), this.setResolutionHeight(n, { adaptCanvasToContainer: !0, withoutSave: !0 }), this.centerMontageArea(), t.selectAll(), s.fitObject({ fitAsOneObject: !0, withoutSave: !0 }), e.fire("editor:canvas-updated", {
1499
- width: i,
1500
- height: n
1496
+ } = this.editor, n = t.left, a = t.top;
1497
+ this.setResolutionWidth(s, { adaptCanvasToContainer: !0, withoutSave: !0 }), this.setResolutionHeight(i, { adaptCanvasToContainer: !0, withoutSave: !0 }), this.centerMontageArea();
1498
+ const o = t.left - n, c = t.top - a;
1499
+ if (o !== 0 || c !== 0) {
1500
+ const r = e.getActiveObject(), l = [];
1501
+ if ((r == null ? void 0 : r.type) === "activeselection") {
1502
+ const h = r;
1503
+ l.push(...h.getObjects()), e.discardActiveObject();
1504
+ }
1505
+ if (e.getObjects().forEach((h) => {
1506
+ h.id === "montage-area" || h.id === "overlay-mask" || (h.set({
1507
+ left: h.left + o,
1508
+ top: h.top + c
1509
+ }), h.setCoords());
1510
+ }), l.length > 0)
1511
+ if (l.length === 1)
1512
+ e.setActiveObject(l[0]);
1513
+ else {
1514
+ const h = new v(l, {
1515
+ canvas: e
1516
+ });
1517
+ e.setActiveObject(h);
1518
+ }
1519
+ }
1520
+ e.renderAll(), e.fire("editor:canvas-updated", {
1521
+ width: s,
1522
+ height: i
1501
1523
  });
1502
1524
  }
1503
1525
  /**
@@ -1658,8 +1680,8 @@ class tt {
1658
1680
  const {
1659
1681
  width: m,
1660
1682
  height: M
1661
- } = n, j = l / m, b = h / M, L = Math.max(j, b);
1662
- g = m * L, u = M * L;
1683
+ } = n, f = l / m, j = h / M, A = Math.max(f, j);
1684
+ g = m * A, u = M * A;
1663
1685
  }
1664
1686
  this.setResolutionWidth(g, { withoutSave: !0 }), this.setResolutionHeight(u, { withoutSave: !0 }), (l > o || h > c) && a.calculateAndApplyDefaultZoom(), a.resetObject(r, { withoutSave: !0 }), i.centerObject(r), i.renderAll(), s || this.editor.historyManager.saveState(), i.fire("editor:montage-area-scaled-to-image", {
1665
1687
  object: r,
@@ -1852,31 +1874,39 @@ class st {
1852
1874
  withoutSave: s,
1853
1875
  fitAsOneObject: i
1854
1876
  } = {}) {
1855
- const { canvas: n, imageManager: a, historyManager: o } = this.editor, c = e || n.getActiveObject();
1856
- if (c) {
1857
- if (c.set("angle", 0), c instanceof v && !i) {
1858
- const r = c.getObjects();
1859
- n.discardActiveObject(), r.forEach((h) => {
1860
- const g = a.calculateScaleFactor({ imageObject: h, scaleType: t });
1861
- h.scale(g), n.centerObject(h);
1862
- });
1863
- const l = new v(r, { canvas: n });
1864
- n.setActiveObject(l);
1865
- } else {
1866
- const r = a.calculateScaleFactor({
1867
- imageObject: c,
1868
- scaleType: t
1877
+ const { canvas: n, historyManager: a } = this.editor, o = e || n.getActiveObject();
1878
+ if (o) {
1879
+ if (o instanceof v && !i) {
1880
+ const c = o.getObjects();
1881
+ n.discardActiveObject(), c.forEach((l) => {
1882
+ this._fitSingleObject(l, t);
1869
1883
  });
1870
- c.scale(r), n.centerObject(c);
1871
- }
1872
- n.renderAll(), s || o.saveState(), n.fire("editor:object-fitted", {
1873
- object: c,
1884
+ const r = new v(c, { canvas: n });
1885
+ n.setActiveObject(r);
1886
+ } else
1887
+ this._fitSingleObject(o, t);
1888
+ n.renderAll(), s || a.saveState(), n.fire("editor:object-fitted", {
1889
+ object: o,
1874
1890
  type: t,
1875
1891
  withoutSave: s,
1876
1892
  fitAsOneObject: i
1877
1893
  });
1878
1894
  }
1879
1895
  }
1896
+ /**
1897
+ * Масштабирует отдельный объект с учетом его угла поворота
1898
+ * @param obj - объект для масштабирования
1899
+ * @param type - тип масштабирования
1900
+ * @private
1901
+ */
1902
+ _fitSingleObject(e, t) {
1903
+ const { canvas: s, montageArea: i } = this.editor, { width: n, height: a, scaleX: o = 1, scaleY: c = 1, angle: r = 0 } = e, l = n * Math.abs(o), h = a * Math.abs(c), g = r * Math.PI / 180, u = Math.abs(Math.cos(g)), m = Math.abs(Math.sin(g)), M = l * u + h * m, f = l * m + h * u, j = i.width, A = i.height;
1904
+ let b;
1905
+ t === "contain" ? b = Math.min(j / M, A / f) : b = Math.max(j / M, A / f), e.set({
1906
+ scaleX: o * b,
1907
+ scaleY: c * b
1908
+ }), s.centerObject(e);
1909
+ }
1880
1910
  /**
1881
1911
  * Установка дефолтного масштаба для всех объектов внутри монтажной области редактора
1882
1912
  */
@@ -2135,7 +2165,7 @@ class nt {
2135
2165
  */
2136
2166
  addRectangle(l = {}, { withoutSelection: c, withoutAdding: r } = {}) {
2137
2167
  var h = l, {
2138
- id: e = `rect-${D()}`,
2168
+ id: e = `rect-${L()}`,
2139
2169
  left: t,
2140
2170
  top: s,
2141
2171
  width: i = 100,
@@ -2149,7 +2179,7 @@ class nt {
2149
2179
  "height",
2150
2180
  "fill"
2151
2181
  ]);
2152
- const { canvas: g } = this.editor, u = new ve(f({
2182
+ const { canvas: g } = this.editor, u = new ve(p({
2153
2183
  id: e,
2154
2184
  left: t,
2155
2185
  top: s,
@@ -2177,7 +2207,7 @@ class nt {
2177
2207
  */
2178
2208
  addCircle(r = {}, { withoutSelection: o, withoutAdding: c } = {}) {
2179
2209
  var l = r, {
2180
- id: e = `circle-${D()}`,
2210
+ id: e = `circle-${L()}`,
2181
2211
  left: t,
2182
2212
  top: s,
2183
2213
  radius: i = 50,
@@ -2189,7 +2219,7 @@ class nt {
2189
2219
  "radius",
2190
2220
  "fill"
2191
2221
  ]);
2192
- const { canvas: h } = this.editor, g = new Ae(f({
2222
+ const { canvas: h } = this.editor, g = new Ae(p({
2193
2223
  id: e,
2194
2224
  left: t,
2195
2225
  top: s,
@@ -2217,7 +2247,7 @@ class nt {
2217
2247
  */
2218
2248
  addTriangle(l = {}, { withoutSelection: c, withoutAdding: r } = {}) {
2219
2249
  var h = l, {
2220
- id: e = `triangle-${D()}`,
2250
+ id: e = `triangle-${L()}`,
2221
2251
  left: t,
2222
2252
  top: s,
2223
2253
  width: i = 100,
@@ -2231,7 +2261,7 @@ class nt {
2231
2261
  "height",
2232
2262
  "fill"
2233
2263
  ]);
2234
- const { canvas: g } = this.editor, u = new Se(f({
2264
+ const { canvas: g } = this.editor, u = new Se(p({
2235
2265
  id: e,
2236
2266
  left: t,
2237
2267
  top: s,
@@ -2345,12 +2375,12 @@ class at {
2345
2375
  * @fires editor:object-pasted
2346
2376
  */
2347
2377
  paste() {
2348
- return p(this, null, function* () {
2378
+ return I(this, null, function* () {
2349
2379
  const { canvas: e } = this.editor;
2350
2380
  if (!this.clipboard) return;
2351
2381
  const t = yield this.clipboard.clone(["format"]);
2352
2382
  e.discardActiveObject(), t.set({
2353
- id: `${t.type}-${D()}`,
2383
+ id: `${t.type}-${L()}`,
2354
2384
  left: t.left + 10,
2355
2385
  top: t.top + 10,
2356
2386
  evented: !0
@@ -2444,7 +2474,7 @@ class ot {
2444
2474
  const n = e || s.getActiveObject();
2445
2475
  if (!n || !(n instanceof v)) return;
2446
2476
  const a = n.getObjects(), o = new X(a);
2447
- a.forEach((c) => s.remove(c)), o.set("id", `${o.type}-${D()}`), s.add(o), s.setActiveObject(o), s.renderAll(), i.resumeHistory(), t || i.saveState(), s.fire("editor:objects-grouped", {
2477
+ a.forEach((c) => s.remove(c)), o.set("id", `${o.type}-${L()}`), s.add(o), s.setActiveObject(o), s.renderAll(), i.resumeHistory(), t || i.saveState(), s.fire("editor:objects-grouped", {
2448
2478
  object: n,
2449
2479
  group: o,
2450
2480
  withoutSave: t
@@ -2623,7 +2653,7 @@ class V {
2623
2653
  message: a,
2624
2654
  data: i
2625
2655
  };
2626
- this._buffer.push(f({
2656
+ this._buffer.push(p({
2627
2657
  type: "editor:error"
2628
2658
  }, o)), this.editor.canvas.fire("editor:error", o);
2629
2659
  }
@@ -2651,7 +2681,7 @@ class V {
2651
2681
  message: a,
2652
2682
  data: n
2653
2683
  };
2654
- this._buffer.push(f({
2684
+ this._buffer.push(p({
2655
2685
  type: "editor:warning"
2656
2686
  }, o)), this.editor.canvas.fire("editor:warning", o);
2657
2687
  }
@@ -2671,7 +2701,7 @@ class ie {
2671
2701
  * @param options - опции и настройки редактора
2672
2702
  */
2673
2703
  constructor(e, t) {
2674
- this.options = t, this.containerId = e, this.editorId = `${e}-${D()}`, this.clipboard = null, this.init();
2704
+ this.options = t, this.containerId = e, this.editorId = `${e}-${L()}`, this.clipboard = null, this.init();
2675
2705
  }
2676
2706
  /**
2677
2707
  * Инициализация редактора.
@@ -2679,7 +2709,7 @@ class ie {
2679
2709
  * @fires editor:ready
2680
2710
  */
2681
2711
  init() {
2682
- return p(this, null, function* () {
2712
+ return I(this, null, function* () {
2683
2713
  const {
2684
2714
  editorContainerWidth: e,
2685
2715
  editorContainerHeight: t,
@@ -2692,7 +2722,7 @@ class ie {
2692
2722
  scaleType: r,
2693
2723
  _onReadyCallback: l
2694
2724
  } = this.options;
2695
- if (He.apply(), this.canvas = new Ce(this.containerId, this.options), this.moduleLoader = new Ee(), this.workerManager = new Te(), this.errorManager = new V({ editor: this }), this.historyManager = new Je({ editor: this }), this.toolbar = new Qe({ editor: this }), this.transformManager = new st({ editor: this }), this.canvasManager = new tt({ editor: this }), this.imageManager = new N({ editor: this }), this.layerManager = new P({ editor: this }), this.shapeManager = new nt({ editor: this }), this.interactionBlocker = new it({ editor: this }), this.clipboardManager = new at({ editor: this }), this.objectLockManager = new F({ editor: this }), this.groupingManager = new ot({ editor: this }), this.selectionManager = new rt({ editor: this }), this.deletionManager = new ct({ editor: this }), this._createMontageArea(), this._createClippingArea(), this.listeners = new z({ editor: this, options: this.options }), this.canvasManager.setEditorContainerWidth(e), this.canvasManager.setEditorContainerHeight(t), this.canvasManager.setCanvasWrapperWidth(s), this.canvasManager.setCanvasWrapperHeight(i), this.canvasManager.setCanvasCSSWidth(n), this.canvasManager.setCanvasCSSHeight(a), o != null && o.source) {
2725
+ if (He.apply(), this.canvas = new Ce(this.containerId, this.options), this.moduleLoader = new Ee(), this.workerManager = new Te(), this.errorManager = new V({ editor: this }), this.historyManager = new Je({ editor: this }), this.toolbar = new Qe({ editor: this }), this.transformManager = new st({ editor: this }), this.canvasManager = new tt({ editor: this }), this.imageManager = new D({ editor: this }), this.layerManager = new P({ editor: this }), this.shapeManager = new nt({ editor: this }), this.interactionBlocker = new it({ editor: this }), this.clipboardManager = new at({ editor: this }), this.objectLockManager = new F({ editor: this }), this.groupingManager = new ot({ editor: this }), this.selectionManager = new rt({ editor: this }), this.deletionManager = new ct({ editor: this }), this._createMontageArea(), this._createClippingArea(), this.listeners = new z({ editor: this, options: this.options }), this.canvasManager.setEditorContainerWidth(e), this.canvasManager.setEditorContainerHeight(t), this.canvasManager.setCanvasWrapperWidth(s), this.canvasManager.setCanvasWrapperHeight(i), this.canvasManager.setCanvasCSSWidth(n), this.canvasManager.setCanvasCSSHeight(a), o != null && o.source) {
2696
2726
  const {
2697
2727
  source: h,
2698
2728
  scale: g = `image-${r}`,
@@ -2860,7 +2890,7 @@ const lt = {
2860
2890
  resetObjectFitByDoubleClick: !0
2861
2891
  };
2862
2892
  function bt(d, e = {}) {
2863
- const t = f(f({}, lt), e), s = document.getElementById(d);
2893
+ const t = p(p({}, lt), e), s = document.getElementById(d);
2864
2894
  if (!s)
2865
2895
  return Promise.reject(new Error(`Контейнер с ID "${d}" не найден.`));
2866
2896
  const i = document.createElement("canvas");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anu3ev/fabric-image-editor",
3
- "version": "0.1.54",
3
+ "version": "0.1.56",
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": [