@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.cjs +20 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +20 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -5224,6 +5224,17 @@ const stringifyDiag = (payload) => {
|
|
|
5224
5224
|
return String(payload);
|
|
5225
5225
|
}
|
|
5226
5226
|
};
|
|
5227
|
+
function hasAnyCharStyleFlag(styles, flag) {
|
|
5228
|
+
if (!styles || typeof styles !== "object") return void 0;
|
|
5229
|
+
const lineEntries = Array.isArray(styles) ? styles : Object.values(styles);
|
|
5230
|
+
for (const lineStyle of lineEntries) {
|
|
5231
|
+
if (!lineStyle || typeof lineStyle !== "object") continue;
|
|
5232
|
+
for (const charStyle of Object.values(lineStyle)) {
|
|
5233
|
+
if (charStyle && charStyle[flag] === true) return true;
|
|
5234
|
+
}
|
|
5235
|
+
}
|
|
5236
|
+
return void 0;
|
|
5237
|
+
}
|
|
5227
5238
|
function buildRoundedRectPath(w, h, tl, tr, br, bl) {
|
|
5228
5239
|
return buildRoundedRectPath$1(w, h, getRoundedRectRadii(w, h, { rxTL: tl, rxTR: tr, rxBR: br, rxBL: bl }));
|
|
5229
5240
|
}
|
|
@@ -5463,13 +5474,14 @@ function createText(element) {
|
|
|
5463
5474
|
fontWeight: element.fontWeight || 400,
|
|
5464
5475
|
textAlign: element.textAlign || "left",
|
|
5465
5476
|
fontStyle: element.fontStyle || "normal",
|
|
5466
|
-
underline: element.underline ?? false,
|
|
5467
|
-
linethrough: element.linethrough ?? false,
|
|
5477
|
+
underline: element.underline ?? hasAnyCharStyleFlag(element.styles, "underline") ?? false,
|
|
5478
|
+
linethrough: element.linethrough ?? hasAnyCharStyleFlag(element.styles, "linethrough") ?? false,
|
|
5468
5479
|
lineHeight: element.lineHeight || 1.2,
|
|
5469
5480
|
charSpacing: element.charSpacing || 0,
|
|
5470
5481
|
objectCaching: false,
|
|
5471
5482
|
noScaleCache: true,
|
|
5472
|
-
splitByGrapheme
|
|
5483
|
+
splitByGrapheme,
|
|
5484
|
+
...element.styles ? { styles: element.styles } : {}
|
|
5473
5485
|
});
|
|
5474
5486
|
textbox.initDimensions();
|
|
5475
5487
|
textbox.set({
|
|
@@ -12597,7 +12609,7 @@ function PixldocsPreview(props) {
|
|
|
12597
12609
|
!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..." }) })
|
|
12598
12610
|
] });
|
|
12599
12611
|
}
|
|
12600
|
-
const PACKAGE_VERSION = "0.5.
|
|
12612
|
+
const PACKAGE_VERSION = "0.5.81";
|
|
12601
12613
|
const roundParityValue = (value) => {
|
|
12602
12614
|
if (typeof value !== "number") return value;
|
|
12603
12615
|
return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
|
|
@@ -15442,7 +15454,9 @@ async function convertTextDecorationsToLines(svg) {
|
|
|
15442
15454
|
const fontFamily = tspan.getAttribute("data-source-font-family") || textEl.getAttribute("data-source-font-family") || resolveInheritedSvgValue(tspan, "font-family") || "sans-serif";
|
|
15443
15455
|
const fontWeight = tspan.getAttribute("data-source-font-weight") || textEl.getAttribute("data-source-font-weight") || resolveInheritedSvgValue(tspan, "font-weight") || "normal";
|
|
15444
15456
|
const fontStyle = tspan.getAttribute("data-source-font-style") || textEl.getAttribute("data-source-font-style") || resolveInheritedSvgValue(tspan, "font-style") || "normal";
|
|
15445
|
-
const
|
|
15457
|
+
const resolvedFill = tspan.getAttribute("fill") || getInlineStyleValue(tspan, "fill") || resolveInheritedSvgValue(tspan, "fill") || textEl.getAttribute("fill") || getInlineStyleValue(textEl, "fill") || "#000000";
|
|
15458
|
+
const fill = resolvedFill;
|
|
15459
|
+
const fillOpacity = tspan.getAttribute("fill-opacity") || getInlineStyleValue(tspan, "fill-opacity") || resolveInheritedSvgValue(tspan, "fill-opacity") || textEl.getAttribute("fill-opacity") || getInlineStyleValue(textEl, "fill-opacity") || null;
|
|
15446
15460
|
let textWidth = content.length * fontSize * 0.6;
|
|
15447
15461
|
if (ctx) {
|
|
15448
15462
|
ctx.font = `${fontStyle} ${fontWeight} ${fontSize}px ${fontFamily.replace(/'/g, "")}`;
|
|
@@ -15493,6 +15507,7 @@ async function convertTextDecorationsToLines(svg) {
|
|
|
15493
15507
|
line.setAttribute("stroke-width", String(thickness));
|
|
15494
15508
|
line.setAttribute("stroke-linecap", "butt");
|
|
15495
15509
|
line.setAttribute("fill", "none");
|
|
15510
|
+
if (fillOpacity) line.setAttribute("stroke-opacity", fillOpacity);
|
|
15496
15511
|
if (textEl.parentElement) {
|
|
15497
15512
|
textEl.parentElement.insertBefore(line, textEl.nextSibling);
|
|
15498
15513
|
}
|