@pixldocs/canvas-renderer 0.5.78 → 0.5.80
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 +43 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +43 -4
- 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.80";
|
|
12601
12613
|
const roundParityValue = (value) => {
|
|
12602
12614
|
if (typeof value !== "number") return value;
|
|
12603
12615
|
return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
|
|
@@ -15507,6 +15519,25 @@ async function convertTextDecorationsToLines(svg) {
|
|
|
15507
15519
|
}
|
|
15508
15520
|
}
|
|
15509
15521
|
}
|
|
15522
|
+
async function convertSvgTextDecorationsToLinesString(svgStr) {
|
|
15523
|
+
if (typeof DOMParser === "undefined" || typeof XMLSerializer === "undefined") {
|
|
15524
|
+
return svgStr;
|
|
15525
|
+
}
|
|
15526
|
+
if (!/text-decoration/i.test(svgStr) && !/underline/i.test(svgStr)) {
|
|
15527
|
+
return svgStr;
|
|
15528
|
+
}
|
|
15529
|
+
try {
|
|
15530
|
+
const parser = new DOMParser();
|
|
15531
|
+
const docEl = parser.parseFromString(svgStr, "image/svg+xml");
|
|
15532
|
+
const rootSvg = docEl.documentElement;
|
|
15533
|
+
if (!rootSvg) return svgStr;
|
|
15534
|
+
await convertTextDecorationsToLines(rootSvg);
|
|
15535
|
+
const serializer = new XMLSerializer();
|
|
15536
|
+
return serializer.serializeToString(rootSvg);
|
|
15537
|
+
} catch {
|
|
15538
|
+
return svgStr;
|
|
15539
|
+
}
|
|
15540
|
+
}
|
|
15510
15541
|
async function rasterizeShadowMarkers(svg) {
|
|
15511
15542
|
var _a, _b, _c, _d, _e;
|
|
15512
15543
|
if (typeof window === "undefined" || typeof document === "undefined") return;
|
|
@@ -15775,6 +15806,14 @@ async function assemblePdfFromSvgs(svgResults, options = {}) {
|
|
|
15775
15806
|
const shouldStripBg = stripPageBackground ?? hasGradient;
|
|
15776
15807
|
const shouldOutlineText = options.outlineText !== false;
|
|
15777
15808
|
let pageSvg = page.svg;
|
|
15809
|
+
try {
|
|
15810
|
+
pageSvg = await convertSvgTextDecorationsToLinesString(pageSvg);
|
|
15811
|
+
} catch (underlineErr) {
|
|
15812
|
+
console.warn(
|
|
15813
|
+
"[canvas-renderer][pdf] underline-to-line conversion failed (raw stage):",
|
|
15814
|
+
underlineErr
|
|
15815
|
+
);
|
|
15816
|
+
}
|
|
15778
15817
|
if (shouldOutlineText) {
|
|
15779
15818
|
try {
|
|
15780
15819
|
const { convertAllTextToPath } = await Promise.resolve().then(() => require("./svgTextToPath-BTHnqJpM.cjs"));
|