@anu3ev/fabric-image-editor 0.8.9 → 0.8.10

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 +32 -32
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -10394,16 +10394,16 @@ var ea = class {
10394
10394
  bounds: m,
10395
10395
  baseWidth: g,
10396
10396
  baseHeight: _
10397
- })), y = {
10397
+ })), y = typeof r.previewId == "string" ? r.previewId : void 0, b = {
10398
10398
  ...r,
10399
10399
  baseWidth: g,
10400
10400
  baseHeight: _,
10401
10401
  positionsNormalized: !0,
10402
- previewId: n ?? r.previewId
10402
+ previewId: n ?? y
10403
10403
  };
10404
10404
  return {
10405
10405
  id: e ?? `template-${O()}`,
10406
- meta: y,
10406
+ meta: b,
10407
10407
  objects: v
10408
10408
  };
10409
10409
  }
@@ -10494,17 +10494,20 @@ var ea = class {
10494
10494
  if (!e) return null;
10495
10495
  try {
10496
10496
  e.setCoords();
10497
- let t = e.getBoundingRect(!1, !0);
10497
+ let n = t._getBoundingRect(e);
10498
10498
  return {
10499
- left: t.left,
10500
- top: t.top,
10501
- width: t.width,
10502
- height: t.height
10499
+ left: n.left,
10500
+ top: n.top,
10501
+ width: n.width,
10502
+ height: n.height
10503
10503
  };
10504
10504
  } catch {
10505
10505
  return null;
10506
10506
  }
10507
10507
  }
10508
+ static _getBoundingRect(e) {
10509
+ return e.getBoundingRect(!1, !0);
10510
+ }
10508
10511
  static async _enlivenObjects(e) {
10509
10512
  return (await Promise.all(e.map(async (e) => {
10510
10513
  if (t._hasSerializedSvgMarkup(e)) {
@@ -10589,20 +10592,20 @@ var ea = class {
10589
10592
  return e.format === "svg";
10590
10593
  }
10591
10594
  static _extractSvgMarkup(e) {
10592
- let t = e.toSVG;
10593
- if (typeof t != "function") return null;
10595
+ let n = e.toSVG;
10596
+ if (typeof n != "function") return null;
10594
10597
  try {
10595
- let n = t.call(e);
10596
- if (!n) return null;
10597
- if (/<svg[\s>]/i.test(n)) return n;
10598
- let { width: r, height: i } = e.getBoundingRect(!1, !0), a = r || e.width || 0, o = i || e.height || 0;
10598
+ let r = n.call(e);
10599
+ if (!r) return null;
10600
+ if (/<svg[\s>]/i.test(r)) return r;
10601
+ let { width: i, height: a } = t._getBoundingRect(e), o = i || e.width || 0, s = a || e.height || 0;
10599
10602
  return `
10600
10603
  <svg
10601
10604
  xmlns="http://www.w3.org/2000/svg"
10602
- width="${a}"
10603
- height="${o}"
10604
- viewBox="0 0 ${a} ${o}">
10605
- ${n}
10605
+ width="${o}"
10606
+ height="${s}"
10607
+ viewBox="0 0 ${o} ${s}">
10608
+ ${r}
10606
10609
  </svg>
10607
10610
  `;
10608
10611
  } catch {
@@ -10645,7 +10648,7 @@ var ea = class {
10645
10648
  originX: _,
10646
10649
  originY: v
10647
10650
  }
10648
- }), delete s[ia], delete s[aa];
10651
+ }), delete s._templateAnchorX, delete s._templateAnchorY;
10649
10652
  }
10650
10653
  static _getPositioningBounds({ bounds: e, baseWidth: n, baseHeight: r, scale: i, useRelativePositions: a, anchorX: o, anchorY: s }) {
10651
10654
  if (!a) return e;
@@ -10698,26 +10701,23 @@ var ea = class {
10698
10701
  let r = typeof e.text == "string" ? e.text : "";
10699
10702
  if (!r) return;
10700
10703
  let i = It({
10701
- value: this.editor?.montageArea?.width,
10702
- fallback: 0
10703
- }), { width: a = 0 } = e, o = It({
10704
10704
  value: n,
10705
10705
  fallback: 0
10706
- }), s = It({
10707
- value: a,
10706
+ }), a = It({
10707
+ value: e.width,
10708
10708
  fallback: 0
10709
10709
  });
10710
- if (!i || !s || !o) return;
10710
+ if (!i || !a) return;
10711
10711
  e.setCoords();
10712
- let c = e, l = t._resolveAnchor(c, ia), u = typeof c.left == "number" ? c.left : null, d = e.originX ?? "center", f = e.originY ?? "center", p = e.getPointByOrigin(d, f), m = e.getBoundingRect(!1, !0), h = m.left + m.width;
10712
+ let o = e, s = t._resolveAnchor(o, ia), c = typeof e.left == "number" ? e.left : null, l = e.originX ?? "center", u = e.originY ?? "center", d = e.getPointByOrigin(l, u), f = t._getBoundingRect(e), p = f.left + f.width / 2, m = f.left + f.width;
10713
10713
  e.set("width", i), e.initDimensions();
10714
- let g = t._getLongestLineWidth({
10714
+ let h = t._getLongestLineWidth({
10715
10715
  textbox: e,
10716
10716
  text: r
10717
- }), _ = g > s ? g + 1 : s;
10718
- if (e.set("width", _), e.initDimensions(), e.setPositionByOrigin(p, d, f), e.setCoords(), u === null) return;
10719
- let y = e.getBoundingRect(!1, !0), b = y.left + y.width, x = u;
10720
- l === "start" ? x += (m.left - y.left) / o : l === "end" && (x += (h - b) / o), c.left = x;
10717
+ }), g = h > a ? h + 1 : a;
10718
+ if (e.set("width", g), e.initDimensions(), e.setPositionByOrigin(d, l, u), e.setCoords(), c === null) return;
10719
+ let _ = t._getBoundingRect(e), y = _.left + _.width / 2, b = _.left + _.width, x = c;
10720
+ s === "start" ? x += (f.left - _.left) / i : s === "center" ? x += (p - y) / i : s === "end" && (x += (m - b) / i), e.left = x;
10721
10721
  }
10722
10722
  static _getLongestLineWidth({ textbox: e, text: t }) {
10723
10723
  let { textLines: n } = e, r = Array.isArray(n) && n.length > 0 ? n.length : Math.max(t.split("\n").length, 1), i = 0;
@@ -10734,7 +10734,7 @@ var ea = class {
10734
10734
  n && (a.svgMarkup = n, delete a.objects, delete a.path);
10735
10735
  }
10736
10736
  if (!n) return a;
10737
- let { left: o, top: s, width: c, height: l } = n, u = e.getBoundingRect(!1, !0), d = r || c || 1, f = i || l || 1, p = this.editor.canvasManager.getObjectPlacement({ object: e }), m = {
10737
+ let { left: o, top: s, width: c, height: l } = n, u = t._getBoundingRect(e), d = r || c || 1, f = i || l || 1, p = this.editor.canvasManager.getObjectPlacement({ object: e }), m = {
10738
10738
  x: (p.left - o) / d,
10739
10739
  y: (p.top - s) / f
10740
10740
  }, h = (u.left - o) / d, g = (u.top - s) / f, _ = h + u.width / d, v = g + u.height / f;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anu3ev/fabric-image-editor",
3
- "version": "0.8.9",
3
+ "version": "0.8.10",
4
4
  "description": "TypeScript image editor library 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": [