@pixldocs/canvas-renderer 0.5.136 → 0.5.138
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/{index-DUHE7WhJ.cjs → index-CkbBhnZd.cjs} +18 -6
- package/dist/{index-DUHE7WhJ.cjs.map → index-CkbBhnZd.cjs.map} +1 -1
- package/dist/{index-BHa3ekoF.js → index-D-I6bYGU.js} +18 -6
- package/dist/{index-BHa3ekoF.js.map → index-D-I6bYGU.js.map} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/{vectorPdfExport-D3L64sAJ.js → vectorPdfExport-BGqNP_R0.js} +19 -15
- package/dist/vectorPdfExport-BGqNP_R0.js.map +1 -0
- package/dist/{vectorPdfExport-Bq-_OarH.cjs → vectorPdfExport-Bw9l0p9C.cjs} +19 -15
- package/dist/vectorPdfExport-Bw9l0p9C.cjs.map +1 -0
- package/package.json +1 -1
- package/dist/vectorPdfExport-Bq-_OarH.cjs.map +0 -1
- package/dist/vectorPdfExport-D3L64sAJ.js.map +0 -1
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
3
3
|
const jspdf = require("jspdf");
|
|
4
4
|
const svg2pdf_js = require("svg2pdf.js");
|
|
5
5
|
const fabric = require("fabric");
|
|
6
|
-
const index = require("./index-
|
|
6
|
+
const index = require("./index-CkbBhnZd.cjs");
|
|
7
7
|
const pdfFonts = require("./pdfFonts-BU2Lqz_O.cjs");
|
|
8
8
|
function _interopNamespaceDefault(e) {
|
|
9
9
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
@@ -1160,8 +1160,15 @@ async function bakeTextAnchorPositionsFromLiveSvg(svg) {
|
|
|
1160
1160
|
if (!liveText) continue;
|
|
1161
1161
|
const srcTspans = Array.from(srcText.querySelectorAll("tspan"));
|
|
1162
1162
|
const liveTspans = Array.from(liveText.querySelectorAll("tspan"));
|
|
1163
|
-
const
|
|
1164
|
-
const
|
|
1163
|
+
const stripTextAnchorStyle = (node) => {
|
|
1164
|
+
const style = node.getAttribute("style") || "";
|
|
1165
|
+
if (!/text-anchor\s*:/i.test(style)) return;
|
|
1166
|
+
const cleaned = style.split(";").map((p) => p.trim()).filter(Boolean).filter((p) => !/^text-anchor\s*:/i.test(p)).join("; ");
|
|
1167
|
+
if (cleaned) node.setAttribute("style", cleaned);
|
|
1168
|
+
else node.removeAttribute("style");
|
|
1169
|
+
};
|
|
1170
|
+
const bakeNode = (srcNode, liveNode, anchorOverride) => {
|
|
1171
|
+
const anchor = (anchorOverride || _resolveAnchor(srcNode)).trim().toLowerCase();
|
|
1165
1172
|
if (anchor !== "middle" && anchor !== "end") return;
|
|
1166
1173
|
try {
|
|
1167
1174
|
const n = typeof liveNode.getNumberOfChars === "function" ? liveNode.getNumberOfChars() : 0;
|
|
@@ -1170,23 +1177,20 @@ async function bakeTextAnchorPositionsFromLiveSvg(svg) {
|
|
|
1170
1177
|
if (!Number.isFinite(start == null ? void 0 : start.x)) return;
|
|
1171
1178
|
srcNode.setAttribute("x", String(start.x));
|
|
1172
1179
|
srcNode.setAttribute("text-anchor", "start");
|
|
1173
|
-
|
|
1174
|
-
if (/text-anchor\s*:/i.test(style)) {
|
|
1175
|
-
const cleaned = style.split(";").map((p) => p.trim()).filter(Boolean).filter((p) => !/^text-anchor\s*:/i.test(p)).join("; ");
|
|
1176
|
-
if (cleaned) srcNode.setAttribute("style", cleaned);
|
|
1177
|
-
else srcNode.removeAttribute("style");
|
|
1178
|
-
}
|
|
1180
|
+
stripTextAnchorStyle(srcNode);
|
|
1179
1181
|
baked++;
|
|
1180
1182
|
} catch {
|
|
1181
1183
|
}
|
|
1182
1184
|
};
|
|
1183
1185
|
if (srcTspans.length > 0) {
|
|
1184
|
-
|
|
1186
|
+
const parentAnchor = _resolveAnchor(srcText);
|
|
1187
|
+
const tspanAnchors = srcTspans.map((tspan) => _resolveAnchor(tspan));
|
|
1188
|
+
bakeNode(srcText, liveText, parentAnchor);
|
|
1185
1189
|
for (let j = 0; j < srcTspans.length; j++) {
|
|
1186
|
-
if (liveTspans[j]) bakeNode(srcTspans[j], liveTspans[j],
|
|
1190
|
+
if (liveTspans[j]) bakeNode(srcTspans[j], liveTspans[j], tspanAnchors[j]);
|
|
1187
1191
|
}
|
|
1188
1192
|
} else {
|
|
1189
|
-
bakeNode(srcText, liveText
|
|
1193
|
+
bakeNode(srcText, liveText);
|
|
1190
1194
|
}
|
|
1191
1195
|
}
|
|
1192
1196
|
} finally {
|
|
@@ -2242,7 +2246,7 @@ async function fetchSvgAsElement(imageUrl, colorMap) {
|
|
|
2242
2246
|
async function getRecoloredSvgDataUrl(imageUrl, colorMap) {
|
|
2243
2247
|
if (!colorMap || Object.keys(colorMap).length === 0) return null;
|
|
2244
2248
|
try {
|
|
2245
|
-
const { getNormalizedSvgUrl } = await Promise.resolve().then(() => require("./index-
|
|
2249
|
+
const { getNormalizedSvgUrl } = await Promise.resolve().then(() => require("./index-CkbBhnZd.cjs")).then((n) => n.canvasImageLoader);
|
|
2246
2250
|
return await getNormalizedSvgUrl(imageUrl, colorMap);
|
|
2247
2251
|
} catch {
|
|
2248
2252
|
return null;
|
|
@@ -3023,7 +3027,7 @@ async function fetchImageAsBase64(imageUrl, opts = {}) {
|
|
|
3023
3027
|
}
|
|
3024
3028
|
let fetchUrl = imageUrl;
|
|
3025
3029
|
if (imageUrl.startsWith("http://") || imageUrl.startsWith("https://")) {
|
|
3026
|
-
const { isPrivateUrl } = await Promise.resolve().then(() => require("./index-
|
|
3030
|
+
const { isPrivateUrl } = await Promise.resolve().then(() => require("./index-CkbBhnZd.cjs")).then((n) => n.canvasImageLoader);
|
|
3027
3031
|
if (isPrivateUrl(imageUrl)) return null;
|
|
3028
3032
|
const proxyUrl = new URL(`${index.API_URL}/image-proxy`);
|
|
3029
3033
|
proxyUrl.searchParams.set("url", imageUrl);
|
|
@@ -5004,4 +5008,4 @@ exports.exportFabricCanvasToVectorPdf = exportFabricCanvasToVectorPdf;
|
|
|
5004
5008
|
exports.exportMultiPagePdf = exportMultiPagePdf;
|
|
5005
5009
|
exports.preparePagesForExport = preparePagesForExport;
|
|
5006
5010
|
exports.rewriteSvgFontsForJsPDFWithSourceMeta = rewriteSvgFontsForJsPDFWithSourceMeta;
|
|
5007
|
-
//# sourceMappingURL=vectorPdfExport-
|
|
5011
|
+
//# sourceMappingURL=vectorPdfExport-Bw9l0p9C.cjs.map
|