@pixldocs/canvas-renderer 0.4.1 → 0.4.3

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
@@ -12247,8 +12247,9 @@ function inlineSvgStyleBlockDeclarations(svg) {
12247
12247
  });
12248
12248
  });
12249
12249
  const normalizePresentationValue = (key, value) => {
12250
- if (["fill", "stroke", "clip-path", "mask", "filter"].includes(key)) return normalizeGradientPaintRef(value);
12251
- return value;
12250
+ const cleaned = value.replace(/\s*!important\s*$/i, "").trim();
12251
+ if (["fill", "stroke", "clip-path", "mask", "filter"].includes(key)) return normalizeGradientPaintRef(cleaned);
12252
+ return cleaned;
12252
12253
  };
12253
12254
  const applyDeclarations = (elements, declarations) => {
12254
12255
  for (const el of elements) {
@@ -12714,6 +12715,14 @@ function inlineComputedStyles(svg) {
12714
12715
  if (wrap.parentNode) document.body.removeChild(wrap);
12715
12716
  }
12716
12717
  }
12718
+ function disambiguateNestedSvgIds(rootSvg) {
12719
+ const nestedSvgs = Array.from(rootSvg.querySelectorAll("svg"));
12720
+ const toProcess = nestedSvgs.filter((s) => s !== rootSvg);
12721
+ if (toProcess.length < 2) return;
12722
+ toProcess.forEach((nested, idx) => {
12723
+ prefixSvgIds(nested, `n${idx}`);
12724
+ });
12725
+ }
12717
12726
  function prefixSvgIds(svg, prefix) {
12718
12727
  const safePrefix = String(prefix).replace(/[^a-zA-Z0-9-]/g, "_");
12719
12728
  const idMap = /* @__PURE__ */ new Map();
@@ -12939,6 +12948,7 @@ function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey, opti
12939
12948
  svg.setAttribute("viewBox", `0 0 ${pageWidth} ${pageHeight}`);
12940
12949
  sanitizeSvgTreeForPdf(svg);
12941
12950
  normalizeSvgViewBoxOrigin(svg);
12951
+ disambiguateNestedSvgIds(svg);
12942
12952
  expandSvgUseElements(svg);
12943
12953
  const svgToDraw = normalizeSvgExplicitColors(svg);
12944
12954
  inlineComputedStyles(svgToDraw);