@pixldocs/canvas-renderer 0.5.79 → 0.5.81

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
@@ -256,7 +256,7 @@ export declare function normalizeFontFamily(fontStack: string): string;
256
256
  * Package version banner. Bump alongside package.json so we can confirm
257
257
  * (via browser:log) that the deployed bundle matches the expected build.
258
258
  */
259
- export declare const PACKAGE_VERSION = "0.5.79";
259
+ export declare const PACKAGE_VERSION = "0.5.81";
260
260
 
261
261
  export declare interface PageSettings {
262
262
  backgroundColor?: string;
package/dist/index.js CHANGED
@@ -5205,6 +5205,17 @@ const stringifyDiag = (payload) => {
5205
5205
  return String(payload);
5206
5206
  }
5207
5207
  };
5208
+ function hasAnyCharStyleFlag(styles, flag) {
5209
+ if (!styles || typeof styles !== "object") return void 0;
5210
+ const lineEntries = Array.isArray(styles) ? styles : Object.values(styles);
5211
+ for (const lineStyle of lineEntries) {
5212
+ if (!lineStyle || typeof lineStyle !== "object") continue;
5213
+ for (const charStyle of Object.values(lineStyle)) {
5214
+ if (charStyle && charStyle[flag] === true) return true;
5215
+ }
5216
+ }
5217
+ return void 0;
5218
+ }
5208
5219
  function buildRoundedRectPath(w, h, tl, tr, br, bl) {
5209
5220
  return buildRoundedRectPath$1(w, h, getRoundedRectRadii(w, h, { rxTL: tl, rxTR: tr, rxBR: br, rxBL: bl }));
5210
5221
  }
@@ -5444,13 +5455,14 @@ function createText(element) {
5444
5455
  fontWeight: element.fontWeight || 400,
5445
5456
  textAlign: element.textAlign || "left",
5446
5457
  fontStyle: element.fontStyle || "normal",
5447
- underline: element.underline ?? false,
5448
- linethrough: element.linethrough ?? false,
5458
+ underline: element.underline ?? hasAnyCharStyleFlag(element.styles, "underline") ?? false,
5459
+ linethrough: element.linethrough ?? hasAnyCharStyleFlag(element.styles, "linethrough") ?? false,
5449
5460
  lineHeight: element.lineHeight || 1.2,
5450
5461
  charSpacing: element.charSpacing || 0,
5451
5462
  objectCaching: false,
5452
5463
  noScaleCache: true,
5453
- splitByGrapheme
5464
+ splitByGrapheme,
5465
+ ...element.styles ? { styles: element.styles } : {}
5454
5466
  });
5455
5467
  textbox.initDimensions();
5456
5468
  textbox.set({
@@ -12578,7 +12590,7 @@ function PixldocsPreview(props) {
12578
12590
  !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..." }) })
12579
12591
  ] });
12580
12592
  }
12581
- const PACKAGE_VERSION = "0.5.79";
12593
+ const PACKAGE_VERSION = "0.5.81";
12582
12594
  const roundParityValue = (value) => {
12583
12595
  if (typeof value !== "number") return value;
12584
12596
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -15423,7 +15435,9 @@ async function convertTextDecorationsToLines(svg) {
15423
15435
  const fontFamily = tspan.getAttribute("data-source-font-family") || textEl.getAttribute("data-source-font-family") || resolveInheritedSvgValue(tspan, "font-family") || "sans-serif";
15424
15436
  const fontWeight = tspan.getAttribute("data-source-font-weight") || textEl.getAttribute("data-source-font-weight") || resolveInheritedSvgValue(tspan, "font-weight") || "normal";
15425
15437
  const fontStyle = tspan.getAttribute("data-source-font-style") || textEl.getAttribute("data-source-font-style") || resolveInheritedSvgValue(tspan, "font-style") || "normal";
15426
- const fill = tspan.getAttribute("fill") || textEl.getAttribute("fill") || "#000000";
15438
+ const resolvedFill = tspan.getAttribute("fill") || getInlineStyleValue(tspan, "fill") || resolveInheritedSvgValue(tspan, "fill") || textEl.getAttribute("fill") || getInlineStyleValue(textEl, "fill") || "#000000";
15439
+ const fill = resolvedFill;
15440
+ const fillOpacity = tspan.getAttribute("fill-opacity") || getInlineStyleValue(tspan, "fill-opacity") || resolveInheritedSvgValue(tspan, "fill-opacity") || textEl.getAttribute("fill-opacity") || getInlineStyleValue(textEl, "fill-opacity") || null;
15427
15441
  let textWidth = content.length * fontSize * 0.6;
15428
15442
  if (ctx) {
15429
15443
  ctx.font = `${fontStyle} ${fontWeight} ${fontSize}px ${fontFamily.replace(/'/g, "")}`;
@@ -15474,6 +15488,7 @@ async function convertTextDecorationsToLines(svg) {
15474
15488
  line.setAttribute("stroke-width", String(thickness));
15475
15489
  line.setAttribute("stroke-linecap", "butt");
15476
15490
  line.setAttribute("fill", "none");
15491
+ if (fillOpacity) line.setAttribute("stroke-opacity", fillOpacity);
15477
15492
  if (textEl.parentElement) {
15478
15493
  textEl.parentElement.insertBefore(line, textEl.nextSibling);
15479
15494
  }