@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.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.
|
|
259
|
+
export declare const PACKAGE_VERSION = "0.5.80";
|
|
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.
|
|
12593
|
+
const PACKAGE_VERSION = "0.5.80";
|
|
12582
12594
|
const roundParityValue = (value) => {
|
|
12583
12595
|
if (typeof value !== "number") return value;
|
|
12584
12596
|
return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
|
|
@@ -15488,6 +15500,25 @@ async function convertTextDecorationsToLines(svg) {
|
|
|
15488
15500
|
}
|
|
15489
15501
|
}
|
|
15490
15502
|
}
|
|
15503
|
+
async function convertSvgTextDecorationsToLinesString(svgStr) {
|
|
15504
|
+
if (typeof DOMParser === "undefined" || typeof XMLSerializer === "undefined") {
|
|
15505
|
+
return svgStr;
|
|
15506
|
+
}
|
|
15507
|
+
if (!/text-decoration/i.test(svgStr) && !/underline/i.test(svgStr)) {
|
|
15508
|
+
return svgStr;
|
|
15509
|
+
}
|
|
15510
|
+
try {
|
|
15511
|
+
const parser = new DOMParser();
|
|
15512
|
+
const docEl = parser.parseFromString(svgStr, "image/svg+xml");
|
|
15513
|
+
const rootSvg = docEl.documentElement;
|
|
15514
|
+
if (!rootSvg) return svgStr;
|
|
15515
|
+
await convertTextDecorationsToLines(rootSvg);
|
|
15516
|
+
const serializer = new XMLSerializer();
|
|
15517
|
+
return serializer.serializeToString(rootSvg);
|
|
15518
|
+
} catch {
|
|
15519
|
+
return svgStr;
|
|
15520
|
+
}
|
|
15521
|
+
}
|
|
15491
15522
|
async function rasterizeShadowMarkers(svg) {
|
|
15492
15523
|
var _a, _b, _c, _d, _e;
|
|
15493
15524
|
if (typeof window === "undefined" || typeof document === "undefined") return;
|
|
@@ -15756,6 +15787,14 @@ async function assemblePdfFromSvgs(svgResults, options = {}) {
|
|
|
15756
15787
|
const shouldStripBg = stripPageBackground ?? hasGradient;
|
|
15757
15788
|
const shouldOutlineText = options.outlineText !== false;
|
|
15758
15789
|
let pageSvg = page.svg;
|
|
15790
|
+
try {
|
|
15791
|
+
pageSvg = await convertSvgTextDecorationsToLinesString(pageSvg);
|
|
15792
|
+
} catch (underlineErr) {
|
|
15793
|
+
console.warn(
|
|
15794
|
+
"[canvas-renderer][pdf] underline-to-line conversion failed (raw stage):",
|
|
15795
|
+
underlineErr
|
|
15796
|
+
);
|
|
15797
|
+
}
|
|
15759
15798
|
if (shouldOutlineText) {
|
|
15760
15799
|
try {
|
|
15761
15800
|
const { convertAllTextToPath } = await import("./svgTextToPath-BP0Kppla.js");
|