@pixldocs/canvas-renderer 0.5.65 → 0.5.67

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.cjs CHANGED
@@ -12561,7 +12561,7 @@ function PixldocsPreview(props) {
12561
12561
  !canvasSettled && /* @__PURE__ */ jsxRuntime.jsx("div", { style: { position: "absolute", inset: 0, display: "flex", alignItems: "center", justifyContent: "center", minHeight: 200 }, children: /* @__PURE__ */ jsxRuntime.jsx("div", { style: { color: "#888", fontSize: 14 }, children: "Loading preview..." }) })
12562
12562
  ] });
12563
12563
  }
12564
- const PACKAGE_VERSION = "0.5.65";
12564
+ const PACKAGE_VERSION = "0.5.67";
12565
12565
  let __underlineFixInstalled = false;
12566
12566
  function installUnderlineFix(fab) {
12567
12567
  var _a;
@@ -15217,6 +15217,14 @@ async function svg2pdfWithDomMount(svg, pdf, opts) {
15217
15217
  async function convertTextDecorationsToLines(svg) {
15218
15218
  const doc = svg.ownerDocument;
15219
15219
  if (!doc) return;
15220
+ const stripTextDecoration = (el) => {
15221
+ el.removeAttribute("text-decoration");
15222
+ const style = el.getAttribute("style") || "";
15223
+ if (!style) return;
15224
+ const kept = style.split(";").map((part) => part.trim()).filter(Boolean).filter((part) => !/^text-decoration\s*:/i.test(part));
15225
+ if (kept.length > 0) el.setAttribute("style", kept.join("; "));
15226
+ else el.removeAttribute("style");
15227
+ };
15220
15228
  const resolveInheritedSvgValue = (el, attr, styleProp = attr) => {
15221
15229
  var _a, _b;
15222
15230
  let current = el;
@@ -15367,6 +15375,8 @@ async function convertTextDecorationsToLines(svg) {
15367
15375
  if (textEl.parentElement) {
15368
15376
  textEl.parentElement.insertBefore(line, textEl.nextSibling);
15369
15377
  }
15378
+ stripTextDecoration(tspan);
15379
+ if (textHasUnderline) stripTextDecoration(textEl);
15370
15380
  }
15371
15381
  }
15372
15382
  if (tempContainer) {
@@ -15605,7 +15615,7 @@ function drawPageBackground(pdf, pageIndex, pageWidth, pageHeight, backgroundCol
15605
15615
  }
15606
15616
  }
15607
15617
  async function assemblePdfFromSvgs(svgResults, options = {}) {
15608
- var _a, _b;
15618
+ var _a, _b, _c;
15609
15619
  if (svgResults.length === 0) throw new Error("No pages to export");
15610
15620
  const { title, stripPageBackground } = options;
15611
15621
  const firstPage = svgResults[0];
@@ -15633,17 +15643,33 @@ async function assemblePdfFromSvgs(svgResults, options = {}) {
15633
15643
  const hasGradient = !!((_b = (_a = page.backgroundGradient) == null ? void 0 : _a.stops) == null ? void 0 : _b.length);
15634
15644
  drawPageBackground(pdf, i, page.width, page.height, page.backgroundColor, page.backgroundGradient);
15635
15645
  const shouldStripBg = stripPageBackground ?? hasGradient;
15646
+ const shouldOutlineText = options.outlineText === true;
15636
15647
  const pageSvg = page.svg;
15637
15648
  let processedSvg = await prepareLiveCanvasSvgForPdf(pageSvg, page.width, page.height, `page-${i + 1}`, {
15638
15649
  stripPageBackground: shouldStripBg
15639
15650
  });
15640
15651
  if (processedSvg) {
15641
- const svgStr = new XMLSerializer().serializeToString(processedSvg);
15642
- const rewrittenSvg = rewriteSvgFontsForJsPDF(svgStr);
15652
+ await convertTextDecorationsToLines(processedSvg);
15653
+ if (shouldOutlineText) {
15654
+ try {
15655
+ const { convertAllTextToPath } = await Promise.resolve().then(() => require("./svgTextToPath-BTHnqJpM.cjs"));
15656
+ const outlinedSvg = await convertAllTextToPath(
15657
+ new XMLSerializer().serializeToString(processedSvg),
15658
+ fontBaseUrl
15659
+ );
15660
+ const outlineDoc = new DOMParser().parseFromString(outlinedSvg, "image/svg+xml");
15661
+ const outlinedRoot = outlineDoc.documentElement;
15662
+ if (outlinedRoot && ((_c = outlinedRoot.tagName) == null ? void 0 : _c.toLowerCase()) === "svg" && !outlineDoc.querySelector("parsererror")) {
15663
+ processedSvg = outlinedRoot;
15664
+ }
15665
+ } catch (outlineErr) {
15666
+ console.warn("[canvas-renderer][pdf] text outlining unavailable, falling back to embedded SVG text:", outlineErr);
15667
+ }
15668
+ }
15669
+ const rewrittenSvg = rewriteSvgFontsForJsPDF(new XMLSerializer().serializeToString(processedSvg));
15643
15670
  const reParser = new DOMParser();
15644
15671
  const reDoc = reParser.parseFromString(rewrittenSvg, "image/svg+xml");
15645
15672
  processedSvg = reDoc.documentElement;
15646
- await convertTextDecorationsToLines(processedSvg);
15647
15673
  }
15648
15674
  if (processedSvg) {
15649
15675
  pdf.setFillColor(0, 0, 0);