@pixldocs/canvas-renderer 0.5.153 → 0.5.155
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-CAH9akzI.js → index-BQA8_wgq.js} +17 -8
- package/dist/index-BQA8_wgq.js.map +1 -0
- package/dist/{index-Bp0cz5Mq.cjs → index-BwHwQrnS.cjs} +17 -8
- package/dist/index-BwHwQrnS.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/{vectorPdfExport-YSo453Ul.cjs → vectorPdfExport-C5NmVmxB.cjs} +53 -23
- package/dist/vectorPdfExport-C5NmVmxB.cjs.map +1 -0
- package/dist/{vectorPdfExport-DTssH1-U.js → vectorPdfExport-vCax992V.js} +53 -23
- package/dist/vectorPdfExport-vCax992V.js.map +1 -0
- package/package.json +1 -1
- package/dist/index-Bp0cz5Mq.cjs.map +0 -1
- package/dist/index-CAH9akzI.js.map +0 -1
- package/dist/vectorPdfExport-DTssH1-U.js.map +0 -1
- package/dist/vectorPdfExport-YSo453Ul.cjs.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsPDF, ShadingPattern } from "jspdf";
|
|
2
2
|
import { svg2pdf } from "svg2pdf.js";
|
|
3
3
|
import * as fabric from "fabric";
|
|
4
|
-
import { g as getCanvasForPage, c as captureFabricCanvasSvgForPdf, f as findNodeById, a as getAbsoluteBounds, p as parseTextMarkdown, r as renderSmartElementToSvg, n as normalizeShapeType, h as hasEdgeFade, b as getProxiedImageUrl, d as bakeEdgeFade, i as isElement, e as isGroup, j as buildRoundedTrianglePath, A as API_URL, k as getImageProxyFetchOptions, l as getRoundedRectRadii, T as TRIANGLE_STROKE_MITER_LIMIT, m as getTrianglePoints } from "./index-
|
|
4
|
+
import { g as getCanvasForPage, c as captureFabricCanvasSvgForPdf, f as findNodeById, a as getAbsoluteBounds, p as parseTextMarkdown, r as renderSmartElementToSvg, n as normalizeShapeType, h as hasEdgeFade, b as getProxiedImageUrl, d as bakeEdgeFade, i as isElement, e as isGroup, j as buildRoundedTrianglePath, A as API_URL, k as getImageProxyFetchOptions, l as getRoundedRectRadii, T as TRIANGLE_STROKE_MITER_LIMIT, m as getTrianglePoints } from "./index-BQA8_wgq.js";
|
|
5
5
|
import { resetPdfFontRegistry, FONT_FALLBACK_SYMBOLS, FONT_FALLBACK_MATH, FONT_FALLBACK_DEVANAGARI, embedFontWithGoogleFallback, getEmbeddedVariantsList, isFontAvailable, isFamilyEmbedded, resolveBestRegisteredVariant, getEmbeddedJsPDFFontName, resolveFontWeight, doesVariantSupportChar } from "./pdfFonts-b3_bv7F0.js";
|
|
6
6
|
async function embedFontsForSvg(pdf, svgStr) {
|
|
7
7
|
var _a;
|
|
@@ -1308,6 +1308,51 @@ async function bakeTextAnchorPositionsFromLiveSvg(svg) {
|
|
|
1308
1308
|
}
|
|
1309
1309
|
}
|
|
1310
1310
|
}
|
|
1311
|
+
function promoteFabricLineAnchorsToSelectableText(svg) {
|
|
1312
|
+
const doc = svg.ownerDocument;
|
|
1313
|
+
if (!doc) return;
|
|
1314
|
+
const lineTspans = Array.from(svg.querySelectorAll('tspan[data-pd-line-anchor="1"]'));
|
|
1315
|
+
if (lineTspans.length === 0) return;
|
|
1316
|
+
const SVG_NS = "http://www.w3.org/2000/svg";
|
|
1317
|
+
const touchedParents = /* @__PURE__ */ new Set();
|
|
1318
|
+
let promoted = 0;
|
|
1319
|
+
for (const tspan of lineTspans) {
|
|
1320
|
+
const parentText = tspan.parentElement;
|
|
1321
|
+
if (!parentText || parentText.tagName.toLowerCase() !== "text" || !parentText.parentNode) continue;
|
|
1322
|
+
const rawWidth = Number.parseFloat(tspan.getAttribute("data-pd-line-width") || "");
|
|
1323
|
+
const rawX = Number.parseFloat(tspan.getAttribute("x") || parentText.getAttribute("x") || "");
|
|
1324
|
+
if (!Number.isFinite(rawWidth) || rawWidth <= 0 || !Number.isFinite(rawX)) continue;
|
|
1325
|
+
const anchor = (tspan.getAttribute("text-anchor") || "start").trim().toLowerCase();
|
|
1326
|
+
if (anchor !== "middle" && anchor !== "end") continue;
|
|
1327
|
+
const startX = anchor === "end" ? rawX - rawWidth : anchor === "middle" ? rawX - rawWidth / 2 : rawX;
|
|
1328
|
+
const y = tspan.getAttribute("y") || parentText.getAttribute("y") || "0";
|
|
1329
|
+
const wrapper = doc.createElementNS(SVG_NS, "text");
|
|
1330
|
+
for (const attr of Array.from(parentText.attributes)) {
|
|
1331
|
+
if (["x", "y", "dx", "dy", "text-anchor", "textLength", "lengthAdjust"].includes(attr.name)) continue;
|
|
1332
|
+
wrapper.setAttribute(attr.name, attr.value);
|
|
1333
|
+
}
|
|
1334
|
+
for (const attr of Array.from(tspan.attributes)) {
|
|
1335
|
+
if (["x", "y", "dx", "dy", "text-anchor", "data-pd-line-anchor", "data-pd-line-width", "textLength", "lengthAdjust"].includes(attr.name)) continue;
|
|
1336
|
+
wrapper.setAttribute(attr.name, attr.value);
|
|
1337
|
+
}
|
|
1338
|
+
wrapper.setAttribute("x", startX.toFixed(3));
|
|
1339
|
+
wrapper.setAttribute("y", y);
|
|
1340
|
+
wrapper.setAttribute("text-anchor", "start");
|
|
1341
|
+
wrapper.setAttribute("textLength", rawWidth.toFixed(3));
|
|
1342
|
+
wrapper.setAttribute("lengthAdjust", "spacing");
|
|
1343
|
+
wrapper.textContent = tspan.textContent || "";
|
|
1344
|
+
parentText.parentNode.insertBefore(wrapper, parentText);
|
|
1345
|
+
tspan.remove();
|
|
1346
|
+
touchedParents.add(parentText);
|
|
1347
|
+
promoted++;
|
|
1348
|
+
}
|
|
1349
|
+
for (const parentText of touchedParents) {
|
|
1350
|
+
if (!parentText.parentNode) continue;
|
|
1351
|
+
const hasText = Array.from(parentText.childNodes).some((node) => (node.textContent || "").trim().length > 0);
|
|
1352
|
+
if (!hasText) parentText.parentNode.removeChild(parentText);
|
|
1353
|
+
}
|
|
1354
|
+
if (promoted > 0) console.log(`[Vector PDF][parity] promoted ${promoted} Fabric line anchor(s) to selectable fixed-width text`);
|
|
1355
|
+
}
|
|
1311
1356
|
async function logTextMeasurementDiagnostic(svg) {
|
|
1312
1357
|
var _a, _b, _c, _d, _e;
|
|
1313
1358
|
if (typeof window === "undefined" || typeof document === "undefined") return;
|
|
@@ -1836,7 +1881,7 @@ async function collectInlinedFontFaceCss() {
|
|
|
1836
1881
|
return cachedInlinedFontFaceCss;
|
|
1837
1882
|
}
|
|
1838
1883
|
async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey, options) {
|
|
1839
|
-
var _a
|
|
1884
|
+
var _a;
|
|
1840
1885
|
try {
|
|
1841
1886
|
const parser = new DOMParser();
|
|
1842
1887
|
const processedSvg = inlineNestedSvgImageDataUris(rawSvg, parser);
|
|
@@ -1874,27 +1919,11 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
|
|
|
1874
1919
|
console.warn("[Vector PDF] anchor-bake pass failed (continuing):", e);
|
|
1875
1920
|
}
|
|
1876
1921
|
await rasterizeShadowMarkers(svgToDraw);
|
|
1877
|
-
|
|
1878
|
-
if (svgToDraw.querySelector("g[data-pd-shadow-blur] text, g[data-pd-text-bg] text")) {
|
|
1879
|
-
const { convertAllTextToPath } = await import("./svgTextToPath-BXAzwaaR.js");
|
|
1880
|
-
const outlined = await convertAllTextToPath(
|
|
1881
|
-
new XMLSerializer().serializeToString(svgToDraw),
|
|
1882
|
-
void 0,
|
|
1883
|
-
{ mode: "shadow-bound" }
|
|
1884
|
-
);
|
|
1885
|
-
const outlinedDoc = parser.parseFromString(outlined, "image/svg+xml");
|
|
1886
|
-
if (!outlinedDoc.querySelector("parsererror") && ((_a = outlinedDoc.documentElement) == null ? void 0 : _a.tagName.toLowerCase()) === "svg") {
|
|
1887
|
-
svgToDraw = outlinedDoc.documentElement;
|
|
1888
|
-
console.log("[Vector PDF][parity] decorated text outlined for headless alignment");
|
|
1889
|
-
}
|
|
1890
|
-
}
|
|
1891
|
-
} catch (outlineErr) {
|
|
1892
|
-
console.warn("[Vector PDF] shadow-bound text outline failed (continuing):", outlineErr);
|
|
1893
|
-
}
|
|
1922
|
+
promoteFabricLineAnchorsToSelectableText(svgToDraw);
|
|
1894
1923
|
await convertTextDecorationsToLines(svgToDraw);
|
|
1895
1924
|
const rewritten = rewriteSvgFontsForJsPDFWithSourceMeta(new XMLSerializer().serializeToString(svgToDraw));
|
|
1896
1925
|
const rewrittenDoc = parser.parseFromString(rewritten, "image/svg+xml");
|
|
1897
|
-
if (!rewrittenDoc.querySelector("parsererror") && ((
|
|
1926
|
+
if (!rewrittenDoc.querySelector("parsererror") && ((_a = rewrittenDoc.documentElement) == null ? void 0 : _a.tagName.toLowerCase()) === "svg") {
|
|
1898
1927
|
return rewrittenDoc.documentElement;
|
|
1899
1928
|
}
|
|
1900
1929
|
return svgToDraw;
|
|
@@ -2476,7 +2505,7 @@ async function fetchSvgAsElement(imageUrl, colorMap) {
|
|
|
2476
2505
|
async function getRecoloredSvgDataUrl(imageUrl, colorMap) {
|
|
2477
2506
|
if (!colorMap || Object.keys(colorMap).length === 0) return null;
|
|
2478
2507
|
try {
|
|
2479
|
-
const { getNormalizedSvgUrl } = await import("./index-
|
|
2508
|
+
const { getNormalizedSvgUrl } = await import("./index-BQA8_wgq.js").then((n) => n.$);
|
|
2480
2509
|
return await getNormalizedSvgUrl(imageUrl, colorMap);
|
|
2481
2510
|
} catch {
|
|
2482
2511
|
return null;
|
|
@@ -3257,7 +3286,7 @@ async function fetchImageAsBase64(imageUrl, opts = {}) {
|
|
|
3257
3286
|
}
|
|
3258
3287
|
let fetchUrl = imageUrl;
|
|
3259
3288
|
if (imageUrl.startsWith("http://") || imageUrl.startsWith("https://")) {
|
|
3260
|
-
const { isPrivateUrl } = await import("./index-
|
|
3289
|
+
const { isPrivateUrl } = await import("./index-BQA8_wgq.js").then((n) => n.$);
|
|
3261
3290
|
if (isPrivateUrl(imageUrl)) return null;
|
|
3262
3291
|
const proxyUrl = new URL(`${API_URL}/image-proxy`);
|
|
3263
3292
|
proxyUrl.searchParams.set("url", imageUrl);
|
|
@@ -5239,6 +5268,7 @@ export {
|
|
|
5239
5268
|
exportMultiPagePdf,
|
|
5240
5269
|
logTextMeasurementDiagnostic,
|
|
5241
5270
|
preparePagesForExport,
|
|
5271
|
+
promoteFabricLineAnchorsToSelectableText,
|
|
5242
5272
|
rewriteSvgFontsForJsPDFWithSourceMeta
|
|
5243
5273
|
};
|
|
5244
|
-
//# sourceMappingURL=vectorPdfExport-
|
|
5274
|
+
//# sourceMappingURL=vectorPdfExport-vCax992V.js.map
|