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