@pixldocs/canvas-renderer 0.5.114 → 0.5.116

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.d.ts CHANGED
@@ -259,7 +259,7 @@ export declare function normalizeFontFamily(fontStack: string): string;
259
259
  * Package version banner. Bump alongside package.json so we can confirm
260
260
  * (via browser:log) that the deployed bundle matches the expected build.
261
261
  */
262
- export declare const PACKAGE_VERSION = "0.5.114";
262
+ export declare const PACKAGE_VERSION = "0.5.116";
263
263
 
264
264
  export declare interface PageSettings {
265
265
  backgroundColor?: string;
package/dist/index.js CHANGED
@@ -13998,7 +13998,7 @@ function PixldocsPreview(props) {
13998
13998
  !canvasSettled && /* @__PURE__ */ jsx("div", { style: { position: "absolute", inset: 0, display: "flex", alignItems: "center", justifyContent: "center", minHeight: 200 }, children: /* @__PURE__ */ jsx("div", { style: { color: "#888", fontSize: 14 }, children: "Loading preview..." }) })
13999
13999
  ] });
14000
14000
  }
14001
- const PACKAGE_VERSION = "0.5.114";
14001
+ const PACKAGE_VERSION = "0.5.116";
14002
14002
  const roundParityValue = (value) => {
14003
14003
  if (typeof value !== "number") return value;
14004
14004
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -16030,7 +16030,7 @@ function splitIntoRuns(text, mainSupportsChar) {
16030
16030
  return runs;
16031
16031
  }
16032
16032
  function rewriteSvgFontsForJsPDF(svgStr) {
16033
- var _a, _b, _c;
16033
+ var _a, _b;
16034
16034
  const parser = new DOMParser();
16035
16035
  const doc = parser.parseFromString(svgStr, "image/svg+xml");
16036
16036
  const allTextEls = Array.from(doc.querySelectorAll("text, tspan, textPath"));
@@ -16169,26 +16169,37 @@ function rewriteSvgFontsForJsPDF(svgStr) {
16169
16169
  }
16170
16170
  }
16171
16171
  const SVG_NS = "http://www.w3.org/2000/svg";
16172
- const transformedTspans = Array.from(doc.querySelectorAll("tspan[transform]"));
16173
- for (const tspan of transformedTspans) {
16174
- const parentText = tspan.parentElement;
16175
- if (!parentText || parentText.tagName.toLowerCase() !== "text") continue;
16176
- const transformVal = tspan.getAttribute("transform") || "";
16177
- if (!/skewX/i.test(transformVal)) continue;
16178
- const wrapper = doc.createElementNS(SVG_NS, "text");
16172
+ const positionedRunParents = Array.from(doc.querySelectorAll("text")).filter((textEl) => {
16173
+ const directTspans = Array.from(textEl.children).filter((child) => child.tagName.toLowerCase() === "tspan");
16174
+ if (directTspans.length === 0) return false;
16175
+ const directText = Array.from(textEl.childNodes).filter((node) => node.nodeType === 3).map((node) => node.textContent || "").join("");
16176
+ if (directText.trim()) return false;
16177
+ const hasTransformedRun = directTspans.some((tspan) => /skewX/i.test(tspan.getAttribute("transform") || ""));
16178
+ const allPositioned = directTspans.every((tspan) => tspan.hasAttribute("x") || tspan.hasAttribute("y"));
16179
+ return hasTransformedRun || directTspans.length > 1 && allPositioned;
16180
+ });
16181
+ for (const parentText of positionedRunParents) {
16182
+ if (!parentText.parentNode) continue;
16183
+ const directTspans = Array.from(parentText.children).filter((child) => child.tagName.toLowerCase() === "tspan");
16179
16184
  let parentTransform = "";
16180
- for (const attr of Array.from(parentText.attributes)) {
16185
+ const parentAttrs = Array.from(parentText.attributes).filter((attr) => {
16181
16186
  if (attr.name === "transform") {
16182
16187
  parentTransform = attr.value;
16183
- continue;
16188
+ return false;
16184
16189
  }
16185
- wrapper.setAttribute(attr.name, attr.value);
16186
- }
16187
- const combined = parentTransform ? `${parentTransform} ${transformVal}` : transformVal;
16188
- wrapper.setAttribute("transform", combined);
16189
- tspan.removeAttribute("transform");
16190
- wrapper.appendChild(tspan);
16191
- (_c = parentText.parentNode) == null ? void 0 : _c.insertBefore(wrapper, parentText.nextSibling);
16190
+ return true;
16191
+ });
16192
+ for (const tspan of directTspans) {
16193
+ const wrapper = doc.createElementNS(SVG_NS, "text");
16194
+ for (const attr of parentAttrs) wrapper.setAttribute(attr.name, attr.value);
16195
+ const runTransform = tspan.getAttribute("transform") || "";
16196
+ const combined = [parentTransform, runTransform].filter(Boolean).join(" ");
16197
+ if (combined) wrapper.setAttribute("transform", combined);
16198
+ tspan.removeAttribute("transform");
16199
+ wrapper.appendChild(tspan);
16200
+ parentText.parentNode.insertBefore(wrapper, parentText);
16201
+ }
16202
+ parentText.parentNode.removeChild(parentText);
16192
16203
  }
16193
16204
  return new XMLSerializer().serializeToString(doc.documentElement);
16194
16205
  }