@anu3ev/fabric-image-editor 0.1.63 → 0.1.65

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 +21 -25
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -35,7 +35,7 @@ var v = (r, e, t) => new Promise((s, n) => {
35
35
  }, o = (d) => d.done ? s(d.value) : Promise.resolve(d.value).then(i, a);
36
36
  o((t = t.apply(r, e)).next());
37
37
  });
38
- import { ActiveSelection as p, util as H, controlsUtils as Ie, InteractiveFabricObject as ve, loadSVGFromURL as Ae, FabricImage as U, Point as P, Rect as Se, Circle as Ce, Triangle as Ne, Group as $, Canvas as De, Pattern as Le } from "fabric";
38
+ import { ActiveSelection as p, util as H, controlsUtils as Ie, InteractiveFabricObject as ve, loadSVGFromURL as Ae, FabricImage as Z, Point as P, Rect as Se, Circle as Ce, Triangle as Ne, Group as $, Canvas as De, Pattern as Le } from "fabric";
39
39
  import { create as we } from "jsondiffpatch";
40
40
  import Ee from "diff-match-patch";
41
41
  var Oe = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", L = function() {
@@ -436,17 +436,17 @@ class xe {
436
436
  this.worker.terminate();
437
437
  }
438
438
  }
439
- const N = 12, Be = 2, J = 8, K = 20, Ze = 100, q = 20, ee = 8, Ue = 100, F = 32, te = 1, ze = "#2B2D33", se = "#3D8BF4", ne = "#FFFFFF";
439
+ const N = 12, Be = 2, J = 8, K = 20, Ue = 100, q = 20, ee = 8, Ze = 100, F = 32, te = 1, ze = "#2B2D33", se = "#3D8BF4", ne = "#FFFFFF";
440
440
  function W(r, e, t, s, n) {
441
441
  const i = N, a = Be;
442
442
  r.save(), r.translate(e, t), r.rotate(H.degreesToRadians(n.angle)), r.fillStyle = ne, r.strokeStyle = se, r.lineWidth = te, r.beginPath(), r.roundRect(-i / 2, -i / 2, i, i, a), r.fill(), r.stroke(), r.restore();
443
443
  }
444
444
  function ge(r, e, t, s, n) {
445
- const i = J, a = K, o = Ze;
445
+ const i = J, a = K, o = Ue;
446
446
  r.save(), r.translate(e, t), r.rotate(H.degreesToRadians(n.angle)), r.fillStyle = ne, r.strokeStyle = se, r.lineWidth = te, r.beginPath(), r.roundRect(-i / 2, -a / 2, i, a, o), r.fill(), r.stroke(), r.restore();
447
447
  }
448
448
  function ue(r, e, t, s, n) {
449
- const i = q, a = ee, o = Ue;
449
+ const i = q, a = ee, o = Ze;
450
450
  r.save(), r.translate(e, t), r.rotate(H.degreesToRadians(n.angle)), r.fillStyle = ne, r.strokeStyle = se, r.lineWidth = te, r.beginPath(), r.roundRect(-i / 2, -a / 2, i, a, o), r.fill(), r.stroke(), r.restore();
451
451
  }
452
452
  const Re = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTE4Ljc1IDQuMzc1djMuNzVhLjYyNS42MjUgMCAwIDEtLjYyNS42MjVoLTMuNzVhLjYyNS42MjUgMCAwIDEgMC0xLjI1aDIuMTRsLTIuMDc3LTEuOTAzLS4wMi0uMDE5YTYuMjUgNi4yNSAwIDEgMC0uMTMgOC45NjcuNjI2LjYyNiAwIDAgMSAuODYuOTA5QTcuNDU2IDcuNDU2IDAgMCAxIDEwIDE3LjVoLS4xMDNhNy41IDcuNSAwIDEgMSA1LjM5Ni0xMi44MTJMMTcuNSA2LjcwM1Y0LjM3NWEuNjI1LjYyNSAwIDAgMSAxLjI1IDBaIi8+PC9zdmc+", me = new Image();
@@ -688,7 +688,9 @@ class Je {
688
688
  d.innerHTML = i[n] ? `<img src="${i[n]}" title="${s}" />` : s, Object.assign(d.style, a), d.onclick = () => {
689
689
  var c;
690
690
  return (c = o[n]) == null ? void 0 : c.call(o, this.editor);
691
- }, this.el.appendChild(d);
691
+ }, d.onmousedown = (c) => {
692
+ c.stopPropagation(), c.preventDefault();
693
+ }, d.ondragstart = (c) => c.preventDefault(), this.el.appendChild(d);
692
694
  }
693
695
  }
694
696
  /**
@@ -963,7 +965,7 @@ class Ke {
963
965
  });
964
966
  }
965
967
  }
966
- const qe = 0.1, et = 2, tt = 0.1, st = 90, B = 16, Z = 16, O = 4096, T = 4096;
968
+ const qe = 0.1, et = 2, tt = 0.1, st = 90, B = 16, U = 16, O = 4096, T = 4096;
967
969
  class D {
968
970
  constructor({ editor: e }) {
969
971
  this.editor = e, this.options = e.options, this._createdBlobUrls = [], this.acceptContentTypes = this.editor.options.acceptContentTypes, this.acceptFormats = this.getAllowedFormatsFromContentTypes();
@@ -1019,17 +1021,17 @@ class D {
1019
1021
  const b = yield Ae(m);
1020
1022
  M = H.groupSVGElements(b.objects, b.options);
1021
1023
  } else
1022
- M = yield U.fromURL(m, { crossOrigin: "anonymous" });
1024
+ M = yield Z.fromURL(m, { crossOrigin: "anonymous" });
1023
1025
  const { width: f, height: j } = M;
1024
- if (M instanceof U) {
1026
+ if (M instanceof Z) {
1025
1027
  const b = M.getElement();
1026
1028
  let S = "";
1027
1029
  if (b instanceof HTMLImageElement ? S = b.src : b instanceof HTMLCanvasElement && (S = b.toDataURL()), j > T || f > O) {
1028
1030
  const w = yield this.resizeImageToBoundaries(S, "max"), E = URL.createObjectURL(w);
1029
- this._createdBlobUrls.push(E), M = yield U.fromURL(E, { crossOrigin: "anonymous" });
1030
- } else if (j < Z || f < B) {
1031
+ this._createdBlobUrls.push(E), M = yield Z.fromURL(E, { crossOrigin: "anonymous" });
1032
+ } else if (j < U || f < B) {
1031
1033
  const w = yield this.resizeImageToBoundaries(S, "min"), E = URL.createObjectURL(w);
1032
- this._createdBlobUrls.push(E), M = yield U.fromURL(E, { crossOrigin: "anonymous" });
1034
+ this._createdBlobUrls.push(E), M = yield Z.fromURL(E, { crossOrigin: "anonymous" });
1033
1035
  }
1034
1036
  }
1035
1037
  if (M.set("id", `${M.type}-${L()}`), M.set("format", h), s === "scale-montage")
@@ -1070,14 +1072,14 @@ class D {
1070
1072
  resizeImageToBoundaries(e, t = "max") {
1071
1073
  return v(this, null, function* () {
1072
1074
  let s = `Размер изображения больше максимального размера канваса, поэтому оно будет уменьшено до максимальных размеров c сохранением пропорций: ${O}x${T}`;
1073
- t === "min" && (s = `Размер изображения меньше минимального размера канваса, поэтому оно будет увеличено до минимальных размеров c сохранением пропорций: ${B}x${Z}`);
1075
+ t === "min" && (s = `Размер изображения меньше минимального размера канваса, поэтому оно будет увеличено до минимальных размеров c сохранением пропорций: ${B}x${U}`);
1074
1076
  const n = {
1075
1077
  dataURL: e,
1076
1078
  sizeType: t,
1077
1079
  maxWidth: O,
1078
1080
  maxHeight: T,
1079
1081
  minWidth: B,
1080
- minHeight: Z
1082
+ minHeight: U
1081
1083
  };
1082
1084
  return this.editor.errorManager.emitWarning({
1083
1085
  origin: "ImageManager",
@@ -1243,7 +1245,7 @@ class D {
1243
1245
  };
1244
1246
  return o.fire("editor:object-exported", j), j;
1245
1247
  }
1246
- if (i && c instanceof U) {
1248
+ if (i && c instanceof Z) {
1247
1249
  const M = yield createImageBitmap(c.getElement()), f = yield d.post(
1248
1250
  "toDataURL",
1249
1251
  {
@@ -1477,7 +1479,7 @@ class at {
1477
1479
  canvas: i,
1478
1480
  montageArea: a,
1479
1481
  options: { canvasBackstoreHeight: o }
1480
- } = this.editor, { width: d, height: c } = a, l = x(Number(e), Z, T);
1482
+ } = this.editor, { width: d, height: c } = a, l = x(Number(e), U, T);
1481
1483
  if (!o || o === "auto" || n ? this.adaptCanvasToContainer() : o ? this.setCanvasBackstoreHeight(Number(o)) : this.setCanvasBackstoreHeight(l), a.set({ height: l }), (m = i.clipPath) == null || m.set({ height: l }), t) {
1482
1484
  const M = l / c, f = Me(d, M);
1483
1485
  this.setResolutionWidth(f);
@@ -1539,7 +1541,7 @@ class at {
1539
1541
  */
1540
1542
  setCanvasBackstoreHeight(e) {
1541
1543
  if (!e || typeof e != "number") return;
1542
- const t = x(e, Z, T);
1544
+ const t = x(e, U, T);
1543
1545
  this.editor.canvas.setDimensions({ height: t }, { backstoreOnly: !0 });
1544
1546
  }
1545
1547
  /**
@@ -1548,7 +1550,7 @@ class at {
1548
1550
  * с учётом минимальных и максимальных значений.
1549
1551
  */
1550
1552
  adaptCanvasToContainer() {
1551
- const { canvas: e } = this.editor, t = this.getEditorContainer(), s = t.clientWidth, n = t.clientHeight, i = x(s, B, O), a = x(n, Z, T);
1553
+ const { canvas: e } = this.editor, t = this.getEditorContainer(), s = t.clientWidth, n = t.clientHeight, i = x(s, B, O), a = x(n, U, T);
1552
1554
  e.setDimensions({ width: i, height: a }, { backstoreOnly: !0 });
1553
1555
  }
1554
1556
  /**
@@ -1814,9 +1816,7 @@ class ot {
1814
1816
  */
1815
1817
  calculateAndApplyDefaultZoom(e = this.options.defaultScale) {
1816
1818
  const { canvas: t } = this.editor, s = t.editorContainer, n = s.clientWidth, i = s.clientHeight, { width: a, height: o } = this.editor.montageArea, d = n / a * e, c = i / o * e;
1817
- this.defaultZoom = Math.min(d, c);
1818
- const { defaultZoom: l, maxZoomFactor: h, minZoom: g, maxZoom: u } = this;
1819
- this.minZoom = Math.min(l / h, g), this.maxZoom = Math.max(l * h, u), this.setZoom();
1819
+ this.defaultZoom = Math.min(d, c), this.setZoom();
1820
1820
  }
1821
1821
  /**
1822
1822
  * Увеличение/уменьшение масштаба
@@ -1832,11 +1832,7 @@ class ot {
1832
1832
  if (!e) return;
1833
1833
  const { minZoom: s, maxZoom: n } = this, { canvas: i } = this.editor, a = i.getZoom(), o = i.getCenterPoint(), d = (g = t.pointX) != null ? g : o.x, c = (u = t.pointY) != null ? u : o.y, l = new P(d, c);
1834
1834
  let h = Number((a + Number(e)).toFixed(2));
1835
- h > n && (h = n), h < s && (h = s), i.zoomToPoint(l, h), console.log({
1836
- currentZoom: a,
1837
- zoom: h,
1838
- point: l
1839
- }), i.fire("editor:zoom-changed", {
1835
+ h > n && (h = n), h < s && (h = s), i.zoomToPoint(l, h), i.fire("editor:zoom-changed", {
1840
1836
  currentZoom: i.getZoom(),
1841
1837
  zoom: h,
1842
1838
  point: l
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anu3ev/fabric-image-editor",
3
- "version": "0.1.63",
3
+ "version": "0.1.65",
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": [