@pixldocs/canvas-renderer 0.5.234 → 0.5.236

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.
@@ -7323,6 +7323,7 @@ function extractTextBgConfig(element) {
7323
7323
  shadowAffectsBg: element.textShadowAffectsBg !== false,
7324
7324
  shadowAffectsText: element.textShadowAffectsText !== false,
7325
7325
  fitToText: element.textBgFitToText === true,
7326
+ lineFullWidth: element.textBgPerLineFullWidth === true,
7326
7327
  shadowType: element.textShadowType,
7327
7328
  shadowColor: element.textShadowColor,
7328
7329
  shadowOffsetX: Number(element.textShadowOffsetX ?? 0) || 0,
@@ -7520,7 +7521,7 @@ function applyTextBackground(obj, cfg) {
7520
7521
  if (ribbonD) {
7521
7522
  bgBounds = computeRibbonBoundsFor(this, pT, pR, pB, pL);
7522
7523
  } else {
7523
- bgRectsForFill = computeBgRects(this, w, h, pT, pR, pB, pL, !!bg.fitToText);
7524
+ bgRectsForFill = computeBgRects(this, w, h, pT, pR, pB, pL, !!bg.fitToText, !!bg.lineFullWidth);
7524
7525
  bgBounds = unionBounds(bgRectsForFill);
7525
7526
  }
7526
7527
  if (blockShadowActive && bg.shadowAffectsBg !== false) {
@@ -7712,7 +7713,8 @@ function applyTextBackground(obj, cfg) {
7712
7713
  const pB = Math.max(0, Number((bg == null ? void 0 : bg.padBottom) ?? 0));
7713
7714
  const pL = Math.max(0, Number((bg == null ? void 0 : bg.padLeft) ?? 0));
7714
7715
  const fit = !!(bg == null ? void 0 : bg.fitToText);
7715
- const rects = computeBgRects(this, w, h, pT, pR, pB, pL, fit);
7716
+ const lineFull = !!(bg == null ? void 0 : bg.lineFullWidth);
7717
+ const rects = computeBgRects(this, w, h, pT, pR, pB, pL, fit, lineFull);
7716
7718
  const ribbonD = buildWarpRibbonD(
7717
7719
  this,
7718
7720
  pT,
@@ -7984,9 +7986,9 @@ function computeTextVisualBounds(obj, w, h) {
7984
7986
  }
7985
7987
  return unionBounds(rects.length > 0 ? rects : [{ x: -w / 2, y: -h / 2, w, h }]);
7986
7988
  }
7987
- function computeBgRects(obj, w, h, pT, pR, pB, pL, fit) {
7989
+ function computeBgRects(obj, w, h, pT, pR, pB, pL, fit, lineFullWidth = false) {
7988
7990
  var _a2;
7989
- if (!fit) {
7991
+ if (!fit && !lineFullWidth) {
7990
7992
  return [{
7991
7993
  x: -w / 2 - pL,
7992
7994
  y: -h / 2 - pT,
@@ -8007,7 +8009,24 @@ function computeBgRects(obj, w, h, pT, pR, pB, pL, fit) {
8007
8009
  const halfW = w / 2;
8008
8010
  const halfH = h / 2;
8009
8011
  const lineHeightRatio = Math.max(0.01, Number((obj == null ? void 0 : obj.lineHeight) ?? 1) || 1);
8010
- let cursorY = -halfH;
8012
+ const valign = (obj == null ? void 0 : obj.verticalAlign) || "top";
8013
+ let contentH = 0;
8014
+ for (let i = 0; i < lines.length; i++) {
8015
+ try {
8016
+ contentH += obj.getHeightOfLine(i) || 0;
8017
+ } catch {
8018
+ }
8019
+ }
8020
+ if (lines.length > 0) {
8021
+ try {
8022
+ const lastH = obj.getHeightOfLine(lines.length - 1) || 0;
8023
+ contentH -= lastH - lastH / lineHeightRatio;
8024
+ } catch {
8025
+ }
8026
+ }
8027
+ const verticalPadding = Math.max(0, h - contentH);
8028
+ const valignOffset = valign === "middle" ? verticalPadding / 2 : valign === "bottom" ? verticalPadding : 0;
8029
+ let cursorY = -halfH + valignOffset;
8011
8030
  for (let i = 0; i < lines.length; i++) {
8012
8031
  let lineW = 0;
8013
8032
  let lineLeft = 0;
@@ -8029,15 +8048,18 @@ function computeBgRects(obj, w, h, pT, pR, pB, pL, fit) {
8029
8048
  }
8030
8049
  const rawSlotH = i === lines.length - 1 ? lineH / lineHeightRatio : lineH;
8031
8050
  const usedH = cursorY + halfH;
8032
- const slotH = Math.max(0, Math.min(rawSlotH, h - usedH));
8033
- if (lineW <= 0 || slotH <= 0) {
8051
+ const remaining = h - usedH;
8052
+ const slotH = Math.max(0, Math.min(rawSlotH, remaining));
8053
+ const effectiveW = lineFullWidth ? w : lineW;
8054
+ const effectiveLeft = lineFullWidth ? 0 : lineLeft;
8055
+ if (effectiveW <= 0 || slotH <= 0) {
8034
8056
  cursorY += slotH;
8035
8057
  continue;
8036
8058
  }
8037
8059
  rects.push({
8038
- x: -halfW + lineLeft - pL,
8060
+ x: -halfW + effectiveLeft - pL,
8039
8061
  y: cursorY - pT,
8040
- w: lineW + pL + pR,
8062
+ w: effectiveW + pL + pR,
8041
8063
  h: slotH + pT + pB
8042
8064
  });
8043
8065
  cursorY += slotH;
@@ -13070,6 +13092,7 @@ const PageCanvas = forwardRef(
13070
13092
  br: element.textBgRxBR ?? 0,
13071
13093
  bl: element.textBgRxBL ?? 0,
13072
13094
  ft: element.textBgFitToText === true,
13095
+ lf: element.textBgPerLineFullWidth === true,
13073
13096
  bo: element.textBgOpacity ?? 1,
13074
13097
  sc: element.textShadowColor ?? null,
13075
13098
  sb: element.textShadowBlur ?? 0,
@@ -14208,6 +14231,7 @@ const PageCanvas = forwardRef(
14208
14231
  br: element.textBgRxBR ?? 0,
14209
14232
  bl: element.textBgRxBL ?? 0,
14210
14233
  ft: element.textBgFitToText === true,
14234
+ lf: element.textBgPerLineFullWidth === true,
14211
14235
  bo: element.textBgOpacity ?? 1,
14212
14236
  sc: element.textShadowColor ?? null,
14213
14237
  sb: element.textShadowBlur ?? 0,
@@ -21097,9 +21121,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
21097
21121
  }
21098
21122
  return svgString;
21099
21123
  }
21100
- const resolvedPackageVersion = "0.5.234";
21124
+ const resolvedPackageVersion = "0.5.236";
21101
21125
  const PACKAGE_VERSION = resolvedPackageVersion;
21102
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.234";
21126
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.236";
21103
21127
  const roundParityValue = (value) => {
21104
21128
  if (typeof value !== "number") return value;
21105
21129
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -21843,7 +21867,7 @@ class PixldocsRenderer {
21843
21867
  await this.waitForCanvasScene(container, cloned, i);
21844
21868
  }
21845
21869
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
21846
- const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-DZm2JXde.js");
21870
+ const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-Dd-jyAAk.js");
21847
21871
  const prepared = preparePagesForExport(
21848
21872
  cloned.pages,
21849
21873
  canvasWidth,
@@ -24163,7 +24187,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
24163
24187
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
24164
24188
  sanitizeSvgTreeForPdf(svgToDraw);
24165
24189
  try {
24166
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-DZm2JXde.js");
24190
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-Dd-jyAAk.js");
24167
24191
  try {
24168
24192
  await logTextMeasurementDiagnostic(svgToDraw);
24169
24193
  } catch {
@@ -24563,4 +24587,4 @@ export {
24563
24587
  buildTeaserBlurFlatKeys as y,
24564
24588
  collectFontDescriptorsFromConfig as z
24565
24589
  };
24566
- //# sourceMappingURL=index-BStk6K2C.js.map
24590
+ //# sourceMappingURL=index-BkWGXF6c.js.map