@anu3ev/fabric-image-editor 0.4.2 → 0.4.3

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 +100 -100
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -1,5 +1,5 @@
1
1
  var Re = Object.defineProperty, Ue = Object.defineProperties;
2
- var ze = Object.getOwnPropertyDescriptors;
2
+ var Ye = Object.getOwnPropertyDescriptors;
3
3
  var bt = Object.getOwnPropertySymbols;
4
4
  var ve = Object.prototype.hasOwnProperty, je = Object.prototype.propertyIsEnumerable;
5
5
  var be = (h, t, e) => t in h ? Re(h, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : h[t] = e, D = (h, t) => {
@@ -9,7 +9,7 @@ var be = (h, t, e) => t in h ? Re(h, t, { enumerable: !0, configurable: !0, writ
9
9
  for (var e of bt(t))
10
10
  je.call(t, e) && be(h, e, t[e]);
11
11
  return h;
12
- }, Ie = (h, t) => Ue(h, ze(t));
12
+ }, Ie = (h, t) => Ue(h, Ye(t));
13
13
  var K = (h, t) => {
14
14
  var e = {};
15
15
  for (var s in h)
@@ -35,7 +35,7 @@ var C = (h, t, e) => new Promise((s, n) => {
35
35
  }, i = (r) => r.done ? s(r.value) : Promise.resolve(r.value).then(o, a);
36
36
  i((e = e.apply(h, t)).next());
37
37
  });
38
- import { ActiveSelection as T, Textbox as mt, util as Mt, controlsUtils as Ae, InteractiveFabricObject as Se, loadSVGFromURL as Ye, FabricImage as gt, Point as It, Gradient as Ce, Rect as Fe, Circle as He, Triangle as We, Group as Q, Canvas as Ze, Pattern as Pe } from "fabric";
38
+ import { ActiveSelection as T, Textbox as mt, util as Mt, controlsUtils as Ae, InteractiveFabricObject as Se, loadSVGFromURL as Fe, FabricImage as gt, Point as It, Gradient as Ce, Rect as ze, Circle as He, Triangle as We, Group as Q, Canvas as Ze, Pattern as Pe } from "fabric";
39
39
  import { create as Ve } from "jsondiffpatch";
40
40
  import Ge from "diff-match-patch";
41
41
  var Xe = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", x = function() {
@@ -463,9 +463,9 @@ class Qe {
463
463
  this.worker.terminate();
464
464
  }
465
465
  }
466
- const F = 12, Je = 2, Tt = 8, Nt = 20, qe = 100, Lt = 20, kt = 8, ts = 100, At = 32, _t = 1, es = "#2B2D33", Bt = "#3D8BF4", Rt = "#FFFFFF";
466
+ const z = 12, Je = 2, Tt = 8, Nt = 20, qe = 100, Lt = 20, kt = 8, ts = 100, At = 32, _t = 1, es = "#2B2D33", Bt = "#3D8BF4", Rt = "#FFFFFF";
467
467
  function vt(h, t, e, s, n) {
468
- const o = F, a = Je;
468
+ const o = z, a = Je;
469
469
  h.save(), h.translate(t, e), h.rotate(Mt.degreesToRadians(n.angle)), h.fillStyle = Rt, h.strokeStyle = Bt, h.lineWidth = _t, h.beginPath(), h.roundRect(-o / 2, -o / 2, o, o, a), h.fill(), h.stroke(), h.restore();
470
470
  }
471
471
  function we(h, t, e, s, n) {
@@ -486,29 +486,29 @@ const os = {
486
486
  // Угловые точки
487
487
  tl: {
488
488
  render: vt,
489
- sizeX: F,
490
- sizeY: F,
489
+ sizeX: z,
490
+ sizeY: z,
491
491
  offsetX: 0,
492
492
  offsetY: 0
493
493
  },
494
494
  tr: {
495
495
  render: vt,
496
- sizeX: F,
497
- sizeY: F,
496
+ sizeX: z,
497
+ sizeY: z,
498
498
  offsetX: 0,
499
499
  offsetY: 0
500
500
  },
501
501
  bl: {
502
502
  render: vt,
503
- sizeX: F,
504
- sizeY: F,
503
+ sizeX: z,
504
+ sizeY: z,
505
505
  offsetX: 0,
506
506
  offsetY: 0
507
507
  },
508
508
  br: {
509
509
  render: vt,
510
- sizeX: F,
511
- sizeY: F,
510
+ sizeX: z,
511
+ sizeY: z,
512
512
  offsetX: 0,
513
513
  offsetY: 0
514
514
  },
@@ -1350,7 +1350,7 @@ class H {
1350
1350
  withoutSelection: i = !1
1351
1351
  } = t;
1352
1352
  if (!e) return null;
1353
- const { canvas: r, montageArea: c, transformManager: d, historyManager: l, errorManager: u } = this.editor, g = yield this.getContentType(e), f = H.getFormatFromContentType(g), { acceptContentTypes: m, acceptFormats: j } = this;
1353
+ const { canvas: r, montageArea: c, transformManager: d, historyManager: l, errorManager: u } = this.editor, g = yield this.getContentType(e), f = H.getFormatFromContentType(g), { acceptContentTypes: m, acceptFormats: v } = this;
1354
1354
  if (!this.isAllowedContentType(g)) {
1355
1355
  const p = `Неверный contentType для изображения: ${g}. Ожидается один из: ${this.acceptContentTypes.join(", ")}.`;
1356
1356
  return u.emitError({
@@ -1363,7 +1363,7 @@ class H {
1363
1363
  format: f,
1364
1364
  contentType: g,
1365
1365
  acceptContentTypes: m,
1366
- acceptFormats: j,
1366
+ acceptFormats: v,
1367
1367
  fromClipboard: o,
1368
1368
  isBackground: a,
1369
1369
  withoutSelection: i
@@ -1389,14 +1389,14 @@ class H {
1389
1389
  format: f,
1390
1390
  contentType: g,
1391
1391
  acceptContentTypes: m,
1392
- acceptFormats: j,
1392
+ acceptFormats: v,
1393
1393
  fromClipboard: o,
1394
1394
  isBackground: a,
1395
1395
  withoutSelection: i
1396
1396
  }
1397
1397
  }), null;
1398
1398
  if (this._createdBlobUrls.push(p), f === "svg") {
1399
- const b = yield Ye(p);
1399
+ const b = yield Fe(p);
1400
1400
  M = Mt.groupSVGElements(b.objects, b.options);
1401
1401
  } else
1402
1402
  M = yield gt.fromURL(p, { crossOrigin: "anonymous" });
@@ -1405,11 +1405,11 @@ class H {
1405
1405
  const b = M.getElement();
1406
1406
  let y = "";
1407
1407
  if (b instanceof HTMLImageElement ? y = b.src : b instanceof HTMLCanvasElement && (y = b.toDataURL()), L > G || w > V) {
1408
- const S = yield this.resizeImageToBoundaries(y, "max"), v = URL.createObjectURL(S);
1409
- this._createdBlobUrls.push(v), M = yield gt.fromURL(v, { crossOrigin: "anonymous" });
1408
+ const S = yield this.resizeImageToBoundaries(y, "max"), j = URL.createObjectURL(S);
1409
+ this._createdBlobUrls.push(j), M = yield gt.fromURL(j, { crossOrigin: "anonymous" });
1410
1410
  } else if (L < et || w < tt) {
1411
- const S = yield this.resizeImageToBoundaries(y, "min"), v = URL.createObjectURL(S);
1412
- this._createdBlobUrls.push(v), M = yield gt.fromURL(v, { crossOrigin: "anonymous" });
1411
+ const S = yield this.resizeImageToBoundaries(y, "min"), j = URL.createObjectURL(S);
1412
+ this._createdBlobUrls.push(j), M = yield gt.fromURL(j, { crossOrigin: "anonymous" });
1413
1413
  }
1414
1414
  }
1415
1415
  if (M.set("id", `${M.type}-${x()}`), M.set("format", f), s === "scale-montage")
@@ -1502,14 +1502,14 @@ class H {
1502
1502
  try {
1503
1503
  const d = s === "application/pdf", l = d ? "image/jpg" : s, u = H.getFormatFromContentType(l);
1504
1504
  i.setCoords();
1505
- const { left: g, top: f, width: m, height: j } = i.getBoundingRect(), p = yield a.clone(["id", "format", "locked"]);
1505
+ const { left: g, top: f, width: m, height: v } = i.getBoundingRect(), p = yield a.clone(["id", "format", "locked"]);
1506
1506
  p.enableRetinaScaling = !1, ["image/jpg", "image/jpeg"].includes(l) && (p.backgroundColor = "#ffffff");
1507
1507
  const M = p.getObjects().find((I) => I.id === i.id);
1508
1508
  if (M && (M.visible = !1), c != null && c.isBlocked) {
1509
1509
  const I = p.getObjects().find((E) => E.id === c.overlayMask.id);
1510
1510
  I && (I.visible = !1);
1511
1511
  }
1512
- p.viewportTransform = [1, 0, 0, 1, -g, -f], p.setDimensions({ width: m, height: j }, { backstoreOnly: !0 }), p.renderAll();
1512
+ p.viewportTransform = [1, 0, 0, 1, -g, -f], p.setDimensions({ width: m, height: v }, { backstoreOnly: !0 }), p.renderAll();
1513
1513
  const w = p.getObjects().filter((I) => I.format).every((I) => I.format === "svg");
1514
1514
  if (u === "svg" && w) {
1515
1515
  const I = p.toSVG();
@@ -1546,7 +1546,7 @@ class H {
1546
1546
  [k]
1547
1547
  );
1548
1548
  if (d) {
1549
- const E = m * 0.264583, N = j * 0.264583, B = (yield this.editor.moduleLoader.loadModule("jspdf")).jsPDF, U = new B({
1549
+ const E = m * 0.264583, N = v * 0.264583, B = (yield this.editor.moduleLoader.loadModule("jspdf")).jsPDF, U = new B({
1550
1550
  orientation: E > N ? "landscape" : "portrait",
1551
1551
  unit: "mm",
1552
1552
  format: [E, N]
@@ -1577,13 +1577,13 @@ class H {
1577
1577
  };
1578
1578
  return a.fire("editor:canvas-exported", I), I;
1579
1579
  }
1580
- const y = u === "svg" && !w ? e.replace(/\.[^/.]+$/, ".png") : e, v = {
1580
+ const y = u === "svg" && !w ? e.replace(/\.[^/.]+$/, ".png") : e, j = {
1581
1581
  image: new File([L], y, { type: l }),
1582
1582
  format: u,
1583
1583
  contentType: l,
1584
1584
  fileName: y
1585
1585
  };
1586
- return a.fire("editor:canvas-exported", v), v;
1586
+ return a.fire("editor:canvas-exported", j), j;
1587
1587
  } catch (d) {
1588
1588
  return this.editor.errorManager.emitError({
1589
1589
  origin: "ImageManager",
@@ -1626,13 +1626,13 @@ class H {
1626
1626
  try {
1627
1627
  const d = H.getFormatFromContentType(n);
1628
1628
  if (d === "svg") {
1629
- const m = c.toSVG(), j = H._exportSVGStringAsFile(m, {
1629
+ const m = c.toSVG(), v = H._exportSVGStringAsFile(m, {
1630
1630
  exportAsBase64: o,
1631
1631
  exportAsBlob: a,
1632
1632
  fileName: s
1633
1633
  }), p = {
1634
1634
  object: c,
1635
- image: j,
1635
+ image: v,
1636
1636
  format: d,
1637
1637
  contentType: "image/svg+xml",
1638
1638
  fileName: s.replace(/\.[^/.]+$/, ".svg")
@@ -1640,7 +1640,7 @@ class H {
1640
1640
  return i.fire("editor:object-exported", p), p;
1641
1641
  }
1642
1642
  if (o && c instanceof gt) {
1643
- const m = yield createImageBitmap(c.getElement()), j = yield r.post(
1643
+ const m = yield createImageBitmap(c.getElement()), v = yield r.post(
1644
1644
  "toDataURL",
1645
1645
  {
1646
1646
  format: d,
@@ -1650,7 +1650,7 @@ class H {
1650
1650
  [m]
1651
1651
  ), p = {
1652
1652
  object: c,
1653
- image: j,
1653
+ image: v,
1654
1654
  format: d,
1655
1655
  contentType: n,
1656
1656
  fileName: s
@@ -1659,9 +1659,9 @@ class H {
1659
1659
  }
1660
1660
  const l = c.toCanvasElement({
1661
1661
  enableRetinaScaling: !1
1662
- }), u = yield new Promise((m, j) => {
1662
+ }), u = yield new Promise((m, v) => {
1663
1663
  l.toBlob((p) => {
1664
- p ? m(p) : j(new Error("Failed to create Blob from canvas"));
1664
+ p ? m(p) : v(new Error("Failed to create Blob from canvas"));
1665
1665
  });
1666
1666
  });
1667
1667
  if (a) {
@@ -1847,8 +1847,8 @@ class As {
1847
1847
  options: { canvasBackstoreWidth: i }
1848
1848
  } = this.editor, { width: r, height: c } = a, d = $(Number(t), tt, V);
1849
1849
  if (!i || i === "auto" || n ? this.adaptCanvasToContainer() : i ? this.setCanvasBackstoreWidth(Number(i)) : this.setCanvasBackstoreWidth(d), a.set({ width: d }), (f = o.clipPath) == null || f.set({ width: d }), e) {
1850
- const m = d / r, j = Le(c, m);
1851
- this.setResolutionHeight(j);
1850
+ const m = d / r, v = Le(c, m);
1851
+ this.setResolutionHeight(v);
1852
1852
  return;
1853
1853
  }
1854
1854
  const { left: l, top: u } = this.getObjectDefaultCoords(a), g = o.getZoom();
@@ -1877,8 +1877,8 @@ class As {
1877
1877
  options: { canvasBackstoreHeight: i }
1878
1878
  } = this.editor, { width: r, height: c } = a, d = $(Number(t), et, G);
1879
1879
  if (!i || i === "auto" || n ? this.adaptCanvasToContainer() : i ? this.setCanvasBackstoreHeight(Number(i)) : this.setCanvasBackstoreHeight(d), a.set({ height: d }), (f = o.clipPath) == null || f.set({ height: d }), e) {
1880
- const m = d / c, j = Le(r, m);
1881
- this.setResolutionWidth(j);
1880
+ const m = d / c, v = Le(r, m);
1881
+ this.setResolutionWidth(v);
1882
1882
  return;
1883
1883
  }
1884
1884
  const { left: l, top: u } = this.getObjectDefaultCoords(a), g = o.getZoom();
@@ -2153,7 +2153,7 @@ class As {
2153
2153
  const {
2154
2154
  width: f,
2155
2155
  height: m
2156
- } = o, j = d / f, p = l / m, M = Math.max(j, p);
2156
+ } = o, v = d / f, p = l / m, M = Math.max(v, p);
2157
2157
  u = f * M, g = m * M;
2158
2158
  }
2159
2159
  this.setResolutionWidth(u, { withoutSave: !0 }), this.setResolutionHeight(g, { withoutSave: !0 }), this.editor.backgroundManager.backgroundObject && this.editor.backgroundManager.refresh(), (d > i || l > r) && this.editor.zoomManager.calculateAndApplyDefaultZoom(), a.resetObject({ object: c, withoutSave: !0 }), n.centerObject(c), n.renderAll(), s || this.editor.historyManager.saveState(), n.fire("editor:montage-area-scaled-to-image", {
@@ -2318,9 +2318,9 @@ class Ss {
2318
2318
  * @private
2319
2319
  */
2320
2320
  _fitSingleObject(t, e) {
2321
- const { canvas: s, montageArea: n } = this.editor, { width: o, height: a, scaleX: i = 1, scaleY: r = 1, angle: c = 0 } = t, d = o * Math.abs(i), l = a * Math.abs(r), u = c * Math.PI / 180, g = Math.abs(Math.cos(u)), f = Math.abs(Math.sin(u)), m = d * g + l * f, j = d * f + l * g, p = n.width, M = n.height;
2321
+ const { canvas: s, montageArea: n } = this.editor, { width: o, height: a, scaleX: i = 1, scaleY: r = 1, angle: c = 0 } = t, d = o * Math.abs(i), l = a * Math.abs(r), u = c * Math.PI / 180, g = Math.abs(Math.cos(u)), f = Math.abs(Math.sin(u)), m = d * g + l * f, v = d * f + l * g, p = n.width, M = n.height;
2322
2322
  let w;
2323
- e === "contain" ? w = Math.min(p / m, M / j) : w = Math.max(p / m, M / j), t.set({
2323
+ e === "contain" ? w = Math.min(p / m, M / v) : w = Math.max(p / m, M / v), t.set({
2324
2324
  scaleX: i * w,
2325
2325
  scaleY: r * w
2326
2326
  }), s.centerObject(t);
@@ -2396,10 +2396,10 @@ class Cs {
2396
2396
  * @private
2397
2397
  */
2398
2398
  _getClampedPointerCoordinates(t) {
2399
- const { canvas: e, montageArea: s } = this.editor, n = e.getPointer(t, !0), o = e.viewportTransform, a = e.getZoom(), i = s.left - s.width / 2, r = s.left + s.width / 2, c = s.top - s.height / 2, d = s.top + s.height / 2, l = i * a + o[4], u = r * a + o[4], g = c * a + o[5], f = d * a + o[5], m = Math.max(l, Math.min(u, n.x)), j = Math.max(g, Math.min(f, n.y));
2399
+ const { canvas: e, montageArea: s } = this.editor, n = e.getPointer(t, !0), o = e.viewportTransform, a = e.getZoom(), i = s.left - s.width / 2, r = s.left + s.width / 2, c = s.top - s.height / 2, d = s.top + s.height / 2, l = i * a + o[4], u = r * a + o[4], g = c * a + o[5], f = d * a + o[5], m = Math.max(l, Math.min(u, n.x)), v = Math.max(g, Math.min(f, n.y));
2400
2400
  return {
2401
2401
  x: m,
2402
- y: j
2402
+ y: v
2403
2403
  };
2404
2404
  }
2405
2405
  /**
@@ -2431,9 +2431,9 @@ class Cs {
2431
2431
  * @private
2432
2432
  */
2433
2433
  _calculateEmptySpaceRatio(t) {
2434
- const { canvas: e, montageArea: s } = this.editor, n = e.viewportTransform, o = e.getWidth(), a = e.getHeight(), i = s.left - s.width / 2, r = s.left + s.width / 2, c = s.top - s.height / 2, d = s.top + s.height / 2, l = -n[4] / t, u = (-n[4] + o) / t, g = -n[5] / t, f = (-n[5] + a) / t, m = l < i, j = u > r, p = g < c, M = f > d;
2435
- if (!(m || j || p || M)) return 0;
2436
- const L = Math.max(0, i - l), k = Math.max(0, u - r), b = Math.max(0, c - g), y = Math.max(0, f - d), S = Math.max(L, k), v = Math.max(b, y), I = S / o, E = v / a;
2434
+ const { canvas: e, montageArea: s } = this.editor, n = e.viewportTransform, o = e.getWidth(), a = e.getHeight(), i = s.left - s.width / 2, r = s.left + s.width / 2, c = s.top - s.height / 2, d = s.top + s.height / 2, l = -n[4] / t, u = (-n[4] + o) / t, g = -n[5] / t, f = (-n[5] + a) / t, m = l < i, v = u > r, p = g < c, M = f > d;
2435
+ if (!(m || v || p || M)) return 0;
2436
+ const L = Math.max(0, i - l), k = Math.max(0, u - r), b = Math.max(0, c - g), y = Math.max(0, f - d), S = Math.max(L, k), j = Math.max(b, y), I = S / o, E = j / a;
2437
2437
  return Math.max(I, E);
2438
2438
  }
2439
2439
  /**
@@ -2450,7 +2450,7 @@ class Cs {
2450
2450
  const { canvas: a, montageArea: i } = this.editor, r = a.viewportTransform, c = a.getWidth(), d = a.getHeight(), l = t.x - r[4], u = t.y - r[5], g = Math.abs(n), f = e - s;
2451
2451
  if (Math.abs(f) / g <= 0.1)
2452
2452
  return { x: l, y: u };
2453
- const j = c / 2, p = d / 2, M = i.left, w = i.top, L = j - M * s, k = p - w * s, b = (L - r[4]) / (e - s), y = (k - r[5]) / (e - s), S = b * g, v = y * g, I = S * o, E = v * o, N = Math.abs(I) > Math.abs(l) ? l : I, B = Math.abs(E) > Math.abs(u) ? u : E;
2453
+ const v = c / 2, p = d / 2, M = i.left, w = i.top, L = v - M * s, k = p - w * s, b = (L - r[4]) / (e - s), y = (k - r[5]) / (e - s), S = b * g, j = y * g, I = S * o, E = j * o, N = Math.abs(I) > Math.abs(l) ? l : I, B = Math.abs(E) > Math.abs(u) ? u : E;
2454
2454
  return { x: N, y: B };
2455
2455
  }
2456
2456
  /**
@@ -3136,7 +3136,7 @@ class Es {
3136
3136
  "height",
3137
3137
  "fill"
3138
3138
  ]);
3139
- const { canvas: u } = this.editor, g = new Fe(D({
3139
+ const { canvas: u } = this.editor, g = new ze(D({
3140
3140
  id: t,
3141
3141
  left: e,
3142
3142
  top: s,
@@ -3674,7 +3674,7 @@ class Ts {
3674
3674
  o && s.lockObject({ object: a, skipInnerObjects: !0, withoutSave: !0 }), t.setActiveObject(a), t.requestRenderAll(), t.fire("editor:all-objects-selected", { selected: a });
3675
3675
  }
3676
3676
  }
3677
- class zt {
3677
+ class Yt {
3678
3678
  constructor({ editor: t }) {
3679
3679
  this.editor = t;
3680
3680
  }
@@ -3721,7 +3721,7 @@ class zt {
3721
3721
  s || o.suspendHistory();
3722
3722
  const r = [];
3723
3723
  if (i.forEach((d) => {
3724
- if (zt._isUngroupableGroup(d)) {
3724
+ if (Yt._isUngroupableGroup(d)) {
3725
3725
  const l = this._handleGroupDeletion(d);
3726
3726
  r.push(...l);
3727
3727
  return;
@@ -4044,9 +4044,9 @@ class O {
4044
4044
  const { target: n, transform: o } = s;
4045
4045
  if (!O._isTextbox(n) || !o) return;
4046
4046
  n.isScaling = !0;
4047
- const a = this._ensureScalingState(n), { baseWidth: i, baseLeft: r, baseFontSize: c } = a, d = typeof ((P = o.original) == null ? void 0 : P.width) == "number" ? o.original.width : void 0, l = typeof ((X = o.original) == null ? void 0 : X.left) == "number" ? o.original.left : void 0, u = d != null ? d : i, g = l != null ? l : r, f = (Z = o.corner) != null ? Z : "", m = (st = o.action) != null ? st : "", j = ["ml", "mr"].includes(f) || m === "scaleX", p = ["mt", "mb"].includes(f) || m === "scaleY", M = ["tl", "tr", "bl", "br"].includes(f) || m === "scale";
4048
- if (!j && !p && !M) return;
4049
- const w = Math.abs((ot = (nt = n.scaleX) != null ? nt : o.scaleX) != null ? ot : 1) || 1, L = Math.abs((it = (at = n.scaleY) != null ? at : o.scaleY) != null ? it : 1) || 1, k = Math.max(1, u * w), b = Math.max(1, c * L), y = (ct = (rt = o.originX) != null ? rt : n.originX) != null ? ct : "left", S = g + u, v = g + u / 2, I = (dt = n.width) != null ? dt : u, E = Math.abs(k - I) > Ot, N = Math.abs(b - ((lt = n.fontSize) != null ? lt : c)) > Ot;
4047
+ const a = this._ensureScalingState(n), { baseWidth: i, baseLeft: r, baseFontSize: c } = a, d = typeof ((P = o.original) == null ? void 0 : P.width) == "number" ? o.original.width : void 0, l = typeof ((X = o.original) == null ? void 0 : X.left) == "number" ? o.original.left : void 0, u = d != null ? d : i, g = l != null ? l : r, f = (Z = o.corner) != null ? Z : "", m = (st = o.action) != null ? st : "", v = ["ml", "mr"].includes(f) || m === "scaleX", p = ["mt", "mb"].includes(f) || m === "scaleY", M = ["tl", "tr", "bl", "br"].includes(f) || m === "scale";
4048
+ if (!v && !p && !M) return;
4049
+ const w = Math.abs((ot = (nt = n.scaleX) != null ? nt : o.scaleX) != null ? ot : 1) || 1, L = Math.abs((it = (at = n.scaleY) != null ? at : o.scaleY) != null ? it : 1) || 1, k = Math.max(1, u * w), b = Math.max(1, c * L), y = (ct = (rt = o.originX) != null ? rt : n.originX) != null ? ct : "left", S = g + u, j = g + u / 2, I = (dt = n.width) != null ? dt : u, E = Math.abs(k - I) > Ot, N = Math.abs(b - ((lt = n.fontSize) != null ? lt : c)) > Ot;
4050
4050
  if (!E && !N) {
4051
4051
  n.set({ scaleX: 1, scaleY: 1 }), o.scaleX = 1, o.scaleY = 1;
4052
4052
  return;
@@ -4059,7 +4059,7 @@ class O {
4059
4059
  });
4060
4060
  const B = (ht = n.width) != null ? ht : k, U = Math.abs(B - I) > Ot;
4061
4061
  let W = g;
4062
- U && (j || M) && (y === "right" ? W = S - B : y === "center" && (W = v - B / 2)), n.set({ left: W }), a.baseLeft = W, o.scaleX = 1, o.scaleY = 1;
4062
+ U && (v || M) && (y === "right" ? W = S - B : y === "center" && (W = j - B / 2)), n.set({ left: W }), a.baseLeft = W, o.scaleX = 1, o.scaleY = 1;
4063
4063
  const { original: R } = o;
4064
4064
  R && (R.scaleX = 1, R.scaleY = 1, R.width = B, R.height = n.height, R.left = W), n.setCoords(), this.canvas.requestRenderAll(), a.baseWidth = B, a.baseFontSize = (ut = n.fontSize) != null ? ut : b, a.hasWidthChange = U || N;
4065
4065
  }, this._handleObjectModified = (s) => {
@@ -4078,7 +4078,7 @@ class O {
4078
4078
  * @param options — настройки текста
4079
4079
  * @param flags — флаги поведения
4080
4080
  */
4081
- addText(w = {}, { withoutSelection: j = !1, withoutSave: p = !1, withoutAdding: M = !1 } = {}) {
4081
+ addText(w = {}, { withoutSelection: v = !1, withoutSave: p = !1, withoutAdding: M = !1 } = {}) {
4082
4082
  var L = w, {
4083
4083
  id: t = `text-${x()}`,
4084
4084
  text: e = "Новый текст",
@@ -4116,7 +4116,7 @@ class O {
4116
4116
  const b = s != null ? s : this._getDefaultFontFamily(), y = O._resolveStrokeWidth(g), S = O._resolveStrokeColor(
4117
4117
  u,
4118
4118
  y
4119
- ), v = new mt(e, D({
4119
+ ), j = new mt(e, D({
4120
4120
  id: t,
4121
4121
  fontFamily: b,
4122
4122
  fontSize: n,
@@ -4132,11 +4132,11 @@ class O {
4132
4132
  strokeUniform: !0,
4133
4133
  opacity: f
4134
4134
  }, m));
4135
- if (v.textCaseRaw = (E = v.text) != null ? E : "", r) {
4136
- const N = O._toUpperCase(v.textCaseRaw);
4137
- N !== v.text && v.set({ text: N });
4135
+ if (j.textCaseRaw = (E = j.text) != null ? E : "", r) {
4136
+ const N = O._toUpperCase(j.textCaseRaw);
4137
+ N !== j.text && j.set({ text: N });
4138
4138
  }
4139
- m.left === void 0 && m.top === void 0 && this.canvas.centerObject(v), M || this.canvas.add(v), j || this.canvas.setActiveObject(v), this.canvas.requestRenderAll(), k.resumeHistory(), p || k.saveState();
4139
+ m.left === void 0 && m.top === void 0 && this.canvas.centerObject(j), M || this.canvas.add(j), v || this.canvas.setActiveObject(j), this.canvas.requestRenderAll(), k.resumeHistory(), p || k.saveState();
4140
4140
  const I = D({
4141
4141
  id: t,
4142
4142
  text: e,
@@ -4154,14 +4154,14 @@ class O {
4154
4154
  opacity: f
4155
4155
  }, m);
4156
4156
  return this.canvas.fire("editor:text-added", {
4157
- textbox: v,
4157
+ textbox: j,
4158
4158
  options: I,
4159
4159
  flags: {
4160
- withoutSelection: !!j,
4160
+ withoutSelection: !!v,
4161
4161
  withoutSave: !!p,
4162
4162
  withoutAdding: !!M
4163
4163
  }
4164
- }), v;
4164
+ }), j;
4165
4165
  }
4166
4166
  /**
4167
4167
  * Обновляет текстовый объект.
@@ -4172,7 +4172,7 @@ class O {
4172
4172
  * @param options.skipRender — не вызывать перерисовку канваса
4173
4173
  */
4174
4174
  updateText({ target: t, style: e = {}, withoutSave: s, skipRender: n } = {}) {
4175
- var X, Z, st, nt, ot, at, it, rt, ct, dt, lt, ht, ut, Ft, Ht, Wt, Zt, Pt, Vt, Xt, Kt, $t, Qt, Jt, qt, te, ee, se, ne, oe, ae, ie, re, ce, de, le, he, ue, ge, fe, me, pe, Me, ye;
4175
+ var X, Z, st, nt, ot, at, it, rt, ct, dt, lt, ht, ut, zt, Ht, Wt, Zt, Pt, Vt, Xt, Kt, $t, Qt, Jt, qt, te, ee, se, ne, oe, ae, ie, re, ce, de, le, he, ue, ge, fe, me, pe, Me, ye;
4176
4176
  const o = this._resolveTextObject(t);
4177
4177
  if (!o) return null;
4178
4178
  const { historyManager: a } = this.editor;
@@ -4194,7 +4194,7 @@ class O {
4194
4194
  strokeWidth: (lt = o.strokeWidth) != null ? lt : void 0,
4195
4195
  opacity: (ht = o.opacity) != null ? ht : void 0,
4196
4196
  left: (ut = o.left) != null ? ut : void 0,
4197
- top: (Ft = o.top) != null ? Ft : void 0,
4197
+ top: (zt = o.top) != null ? zt : void 0,
4198
4198
  width: (Ht = o.width) != null ? Ht : void 0,
4199
4199
  height: (Wt = o.height) != null ? Wt : void 0,
4200
4200
  angle: (Zt = o.angle) != null ? Zt : void 0,
@@ -4209,7 +4209,7 @@ class O {
4209
4209
  underline: g,
4210
4210
  uppercase: f,
4211
4211
  strikethrough: m,
4212
- align: j,
4212
+ align: v,
4213
4213
  color: p,
4214
4214
  strokeColor: M,
4215
4215
  strokeWidth: w,
@@ -4228,18 +4228,18 @@ class O {
4228
4228
  "strokeColor",
4229
4229
  "strokeWidth",
4230
4230
  "opacity"
4231
- ]), b = D({}, k), y = O._getSelectionRange(o), S = {}, v = {};
4232
- if (c !== void 0 && (y ? S.fontFamily = c : (b.fontFamily = c, v.fontFamily = c)), d !== void 0 && (y ? S.fontSize = d : (b.fontSize = d, v.fontSize = d)), l !== void 0) {
4231
+ ]), b = D({}, k), y = O._getSelectionRange(o), S = {}, j = {};
4232
+ if (c !== void 0 && (y ? S.fontFamily = c : (b.fontFamily = c, j.fontFamily = c)), d !== void 0 && (b.fontSize = d), l !== void 0) {
4233
4233
  const _ = l ? "bold" : "normal";
4234
- y ? S.fontWeight = _ : (b.fontWeight = _, v.fontWeight = _);
4234
+ y ? S.fontWeight = _ : (b.fontWeight = _, j.fontWeight = _);
4235
4235
  }
4236
4236
  if (u !== void 0) {
4237
4237
  const _ = u ? "italic" : "normal";
4238
- y ? S.fontStyle = _ : (b.fontStyle = _, v.fontStyle = _);
4238
+ y ? S.fontStyle = _ : (b.fontStyle = _, j.fontStyle = _);
4239
4239
  }
4240
- if (g !== void 0 && (y ? S.underline = g : (b.underline = g, v.underline = g)), m !== void 0 && (y ? S.linethrough = m : (b.linethrough = m, v.linethrough = m)), j !== void 0 && (b.textAlign = j), p !== void 0 && (y ? S.fill = p : (b.fill = p, v.fill = p)), M !== void 0 || w !== void 0) {
4240
+ if (g !== void 0 && (y ? S.underline = g : (b.underline = g, j.underline = g)), m !== void 0 && (y ? S.linethrough = m : (b.linethrough = m, j.linethrough = m)), v !== void 0 && (b.textAlign = v), p !== void 0 && (y ? S.fill = p : (b.fill = p, j.fill = p)), M !== void 0 || w !== void 0) {
4241
4241
  const _ = y ? O._getSelectionStyleValue(o, y, "strokeWidth") : void 0, xe = y ? O._getSelectionStyleValue(o, y, "stroke") : void 0, _e = (Kt = (Xt = w != null ? w : _) != null ? Xt : o.strokeWidth) != null ? Kt : 0, yt = O._resolveStrokeWidth(_e), Be = (Qt = ($t = M != null ? M : xe) != null ? $t : o.stroke) != null ? Qt : void 0, Dt = O._resolveStrokeColor(Be, yt);
4242
- y ? (S.stroke = Dt, S.strokeWidth = yt) : (b.stroke = Dt, b.strokeWidth = yt, v.stroke = Dt, v.strokeWidth = yt);
4242
+ y ? (S.stroke = Dt, S.strokeWidth = yt) : (b.stroke = Dt, b.strokeWidth = yt, j.stroke = Dt, j.strokeWidth = yt);
4243
4243
  }
4244
4244
  L !== void 0 && (b.opacity = L);
4245
4245
  const I = (qt = o.textCaseRaw) != null ? qt : (Jt = o.text) != null ? Jt : "", E = !!o.uppercase, N = r !== void 0, B = N ? r != null ? r : "" : I, U = f != null ? f : E;
@@ -4251,9 +4251,9 @@ class O {
4251
4251
  let R = !1;
4252
4252
  if (y)
4253
4253
  R = O._applyStylesToRange(o, S, y);
4254
- else if (Object.keys(v).length) {
4254
+ else if (Object.keys(j).length) {
4255
4255
  const _ = O._getFullTextRange(o);
4256
- _ && (R = O._applyStylesToRange(o, v, _));
4256
+ _ && (R = O._applyStylesToRange(o, j, _));
4257
4257
  }
4258
4258
  R && (o.dirty = !0), o.setCoords(), n || this.canvas.requestRenderAll(), a.resumeHistory(), s || a.saveState();
4259
4259
  const P = {
@@ -4381,7 +4381,7 @@ class O {
4381
4381
  return (e = (t = this.fonts[0]) == null ? void 0 : t.family) != null ? e : "Arial";
4382
4382
  }
4383
4383
  }
4384
- class Yt {
4384
+ class Ft {
4385
4385
  /**
4386
4386
  * Конструктор класса ImageEditor.
4387
4387
  * @param canvasId - идентификатор канваса, в котором будет создан редактор
@@ -4411,7 +4411,7 @@ class Yt {
4411
4411
  showRotationAngle: d,
4412
4412
  _onReadyCallback: l
4413
4413
  } = this.options;
4414
- if (J.apply(), this.canvas = new Ze(this.containerId, this.options), this.moduleLoader = new Ke(), this.workerManager = new Qe(), this.errorManager = new Et({ editor: this }), this.historyManager = new St({ editor: this }), this.toolbar = new gs({ editor: this }), this.transformManager = new Ss({ editor: this }), this.zoomManager = new Cs({ editor: this }), this.canvasManager = new As({ editor: this }), this.imageManager = new H({ editor: this }), this.layerManager = new Ct({ editor: this }), this.shapeManager = new Es({ editor: this }), this.interactionBlocker = new ws({ editor: this }), this.backgroundManager = new q({ editor: this }), this.clipboardManager = new Ds({ editor: this }), this.objectLockManager = new wt({ editor: this }), this.groupingManager = new Os({ editor: this }), this.selectionManager = new Ts({ editor: this }), this.deletionManager = new zt({ editor: this }), this.panConstraintManager = new Ls({ editor: this }), this.fontManager = new xt((u = this.options.fonts) != null ? u : []), this.textManager = new O({ editor: this }), d && (this.angleIndicator = new Ut({ editor: this })), this._createMontageArea(), this._createClippingArea(), this.listeners = new pt({ editor: this, options: this.options }), this.canvasManager.setEditorContainerWidth(t), this.canvasManager.setEditorContainerHeight(e), this.canvasManager.setCanvasWrapperWidth(s), this.canvasManager.setCanvasWrapperHeight(n), this.canvasManager.setCanvasCSSWidth(o), this.canvasManager.setCanvasCSSHeight(a), this.canvasManager.updateCanvas(), this.zoomManager.calculateAndApplyDefaultZoom(), yield this.fontManager.loadFonts(), i != null && i.source) {
4414
+ if (J.apply(), this.canvas = new Ze(this.containerId, this.options), this.moduleLoader = new Ke(), this.workerManager = new Qe(), this.errorManager = new Et({ editor: this }), this.historyManager = new St({ editor: this }), this.toolbar = new gs({ editor: this }), this.transformManager = new Ss({ editor: this }), this.zoomManager = new Cs({ editor: this }), this.canvasManager = new As({ editor: this }), this.imageManager = new H({ editor: this }), this.layerManager = new Ct({ editor: this }), this.shapeManager = new Es({ editor: this }), this.interactionBlocker = new ws({ editor: this }), this.backgroundManager = new q({ editor: this }), this.clipboardManager = new Ds({ editor: this }), this.objectLockManager = new wt({ editor: this }), this.groupingManager = new Os({ editor: this }), this.selectionManager = new Ts({ editor: this }), this.deletionManager = new Yt({ editor: this }), this.panConstraintManager = new Ls({ editor: this }), this.fontManager = new xt((u = this.options.fonts) != null ? u : []), this.textManager = new O({ editor: this }), d && (this.angleIndicator = new Ut({ editor: this })), this._createMontageArea(), this._createClippingArea(), this.listeners = new pt({ editor: this, options: this.options }), this.canvasManager.setEditorContainerWidth(t), this.canvasManager.setEditorContainerHeight(e), this.canvasManager.setCanvasWrapperWidth(s), this.canvasManager.setCanvasWrapperHeight(n), this.canvasManager.setCanvasCSSWidth(o), this.canvasManager.setCanvasCSSHeight(a), this.canvasManager.updateCanvas(), this.zoomManager.calculateAndApplyDefaultZoom(), yield this.fontManager.loadFonts(), i != null && i.source) {
4415
4415
  const {
4416
4416
  source: g,
4417
4417
  scale: f = `image-${c}`,
@@ -4433,7 +4433,7 @@ class Yt {
4433
4433
  this.montageArea = this.shapeManager.addRectangle({
4434
4434
  width: t,
4435
4435
  height: e,
4436
- fill: Yt._createMosaicPattern(),
4436
+ fill: Ft._createMosaicPattern(),
4437
4437
  stroke: null,
4438
4438
  strokeWidth: 0,
4439
4439
  selectable: !1,
@@ -4490,7 +4490,7 @@ class Yt {
4490
4490
  });
4491
4491
  }
4492
4492
  }
4493
- const z = [
4493
+ const Y = [
4494
4494
  "U+0000-00FF",
4495
4495
  "U+0131",
4496
4496
  "U+0152-0153",
@@ -4510,7 +4510,7 @@ const z = [
4510
4510
  "U+2215",
4511
4511
  "U+FEFF",
4512
4512
  "U+FFFD"
4513
- ].join(", "), Y = [
4513
+ ].join(", "), F = [
4514
4514
  "U+0301",
4515
4515
  "U+0400-045F",
4516
4516
  "U+0490-0491",
@@ -4533,7 +4533,7 @@ const z = [
4533
4533
  style: "normal",
4534
4534
  weight: "400",
4535
4535
  display: "swap",
4536
- unicodeRange: Y
4536
+ unicodeRange: F
4537
4537
  }
4538
4538
  },
4539
4539
  {
@@ -4543,7 +4543,7 @@ const z = [
4543
4543
  style: "normal",
4544
4544
  weight: "400",
4545
4545
  display: "swap",
4546
- unicodeRange: z
4546
+ unicodeRange: Y
4547
4547
  }
4548
4548
  },
4549
4549
  {
@@ -4553,7 +4553,7 @@ const z = [
4553
4553
  style: "normal",
4554
4554
  weight: "700",
4555
4555
  display: "swap",
4556
- unicodeRange: Y
4556
+ unicodeRange: F
4557
4557
  }
4558
4558
  },
4559
4559
  {
@@ -4563,7 +4563,7 @@ const z = [
4563
4563
  style: "normal",
4564
4564
  weight: "700",
4565
4565
  display: "swap",
4566
- unicodeRange: z
4566
+ unicodeRange: Y
4567
4567
  }
4568
4568
  },
4569
4569
  {
@@ -4573,7 +4573,7 @@ const z = [
4573
4573
  style: "normal",
4574
4574
  weight: "200 700",
4575
4575
  display: "swap",
4576
- unicodeRange: Y
4576
+ unicodeRange: F
4577
4577
  }
4578
4578
  },
4579
4579
  {
@@ -4583,7 +4583,7 @@ const z = [
4583
4583
  style: "normal",
4584
4584
  weight: "200 700",
4585
4585
  display: "swap",
4586
- unicodeRange: z
4586
+ unicodeRange: Y
4587
4587
  }
4588
4588
  },
4589
4589
  {
@@ -4593,7 +4593,7 @@ const z = [
4593
4593
  style: "normal",
4594
4594
  weight: "300 900",
4595
4595
  display: "swap",
4596
- unicodeRange: Y
4596
+ unicodeRange: F
4597
4597
  }
4598
4598
  },
4599
4599
  {
@@ -4603,7 +4603,7 @@ const z = [
4603
4603
  style: "normal",
4604
4604
  weight: "300 900",
4605
4605
  display: "swap",
4606
- unicodeRange: z
4606
+ unicodeRange: Y
4607
4607
  }
4608
4608
  },
4609
4609
  {
@@ -4613,7 +4613,7 @@ const z = [
4613
4613
  style: "normal",
4614
4614
  weight: "400 700",
4615
4615
  display: "swap",
4616
- unicodeRange: Y
4616
+ unicodeRange: F
4617
4617
  }
4618
4618
  },
4619
4619
  {
@@ -4623,7 +4623,7 @@ const z = [
4623
4623
  style: "normal",
4624
4624
  weight: "400 700",
4625
4625
  display: "swap",
4626
- unicodeRange: z
4626
+ unicodeRange: Y
4627
4627
  }
4628
4628
  },
4629
4629
  {
@@ -4633,7 +4633,7 @@ const z = [
4633
4633
  style: "normal",
4634
4634
  weight: "300 700",
4635
4635
  display: "swap",
4636
- unicodeRange: Y
4636
+ unicodeRange: F
4637
4637
  }
4638
4638
  },
4639
4639
  {
@@ -4643,7 +4643,7 @@ const z = [
4643
4643
  style: "normal",
4644
4644
  weight: "300 700",
4645
4645
  display: "swap",
4646
- unicodeRange: z
4646
+ unicodeRange: Y
4647
4647
  }
4648
4648
  },
4649
4649
  {
@@ -4653,7 +4653,7 @@ const z = [
4653
4653
  style: "normal",
4654
4654
  weight: "300 700",
4655
4655
  display: "swap",
4656
- unicodeRange: Y
4656
+ unicodeRange: F
4657
4657
  }
4658
4658
  },
4659
4659
  {
@@ -4663,7 +4663,7 @@ const z = [
4663
4663
  style: "normal",
4664
4664
  weight: "300 700",
4665
4665
  display: "swap",
4666
- unicodeRange: z
4666
+ unicodeRange: Y
4667
4667
  }
4668
4668
  },
4669
4669
  {
@@ -4673,7 +4673,7 @@ const z = [
4673
4673
  style: "normal",
4674
4674
  weight: "400",
4675
4675
  display: "swap",
4676
- unicodeRange: Y
4676
+ unicodeRange: F
4677
4677
  }
4678
4678
  },
4679
4679
  {
@@ -4683,7 +4683,7 @@ const z = [
4683
4683
  style: "normal",
4684
4684
  weight: "400",
4685
4685
  display: "swap",
4686
- unicodeRange: z
4686
+ unicodeRange: Y
4687
4687
  }
4688
4688
  },
4689
4689
  {
@@ -4693,7 +4693,7 @@ const z = [
4693
4693
  style: "normal",
4694
4694
  weight: "400 700",
4695
4695
  display: "swap",
4696
- unicodeRange: Y
4696
+ unicodeRange: F
4697
4697
  }
4698
4698
  },
4699
4699
  {
@@ -4703,7 +4703,7 @@ const z = [
4703
4703
  style: "normal",
4704
4704
  weight: "400 700",
4705
4705
  display: "swap",
4706
- unicodeRange: z
4706
+ unicodeRange: Y
4707
4707
  }
4708
4708
  },
4709
4709
  {
@@ -4713,7 +4713,7 @@ const z = [
4713
4713
  style: "normal",
4714
4714
  weight: "100 900",
4715
4715
  display: "swap",
4716
- unicodeRange: Y
4716
+ unicodeRange: F
4717
4717
  }
4718
4718
  },
4719
4719
  {
@@ -4723,7 +4723,7 @@ const z = [
4723
4723
  style: "normal",
4724
4724
  weight: "100 900",
4725
4725
  display: "swap",
4726
- unicodeRange: z
4726
+ unicodeRange: Y
4727
4727
  }
4728
4728
  }
4729
4729
  ], xs = {
@@ -4820,18 +4820,18 @@ const z = [
4820
4820
  */
4821
4821
  fonts: ks
4822
4822
  };
4823
- function zs(h, t = {}) {
4823
+ function Ys(h, t = {}) {
4824
4824
  const e = D(D({}, xs), t), s = document.getElementById(h);
4825
4825
  if (!s)
4826
4826
  return Promise.reject(new Error(`Контейнер с ID "${h}" не найден.`));
4827
4827
  const n = document.createElement("canvas");
4828
4828
  return n.id = `${h}-canvas`, s.appendChild(n), e.editorContainer = s, new Promise((o) => {
4829
4829
  e._onReadyCallback = o;
4830
- const a = new Yt(n.id, e);
4830
+ const a = new Ft(n.id, e);
4831
4831
  window[h] = a;
4832
4832
  });
4833
4833
  }
4834
4834
  export {
4835
- zs as default
4835
+ Ys as default
4836
4836
  };
4837
4837
  //# sourceMappingURL=main.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anu3ev/fabric-image-editor",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
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": [