@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.
@@ -7341,6 +7341,7 @@ function extractTextBgConfig(element) {
7341
7341
  shadowAffectsBg: element.textShadowAffectsBg !== false,
7342
7342
  shadowAffectsText: element.textShadowAffectsText !== false,
7343
7343
  fitToText: element.textBgFitToText === true,
7344
+ lineFullWidth: element.textBgPerLineFullWidth === true,
7344
7345
  shadowType: element.textShadowType,
7345
7346
  shadowColor: element.textShadowColor,
7346
7347
  shadowOffsetX: Number(element.textShadowOffsetX ?? 0) || 0,
@@ -7538,7 +7539,7 @@ function applyTextBackground(obj, cfg) {
7538
7539
  if (ribbonD) {
7539
7540
  bgBounds = computeRibbonBoundsFor(this, pT, pR, pB, pL);
7540
7541
  } else {
7541
- bgRectsForFill = computeBgRects(this, w, h, pT, pR, pB, pL, !!bg.fitToText);
7542
+ bgRectsForFill = computeBgRects(this, w, h, pT, pR, pB, pL, !!bg.fitToText, !!bg.lineFullWidth);
7542
7543
  bgBounds = unionBounds(bgRectsForFill);
7543
7544
  }
7544
7545
  if (blockShadowActive && bg.shadowAffectsBg !== false) {
@@ -7730,7 +7731,8 @@ function applyTextBackground(obj, cfg) {
7730
7731
  const pB = Math.max(0, Number((bg == null ? void 0 : bg.padBottom) ?? 0));
7731
7732
  const pL = Math.max(0, Number((bg == null ? void 0 : bg.padLeft) ?? 0));
7732
7733
  const fit = !!(bg == null ? void 0 : bg.fitToText);
7733
- const rects = computeBgRects(this, w, h, pT, pR, pB, pL, fit);
7734
+ const lineFull = !!(bg == null ? void 0 : bg.lineFullWidth);
7735
+ const rects = computeBgRects(this, w, h, pT, pR, pB, pL, fit, lineFull);
7734
7736
  const ribbonD = buildWarpRibbonD(
7735
7737
  this,
7736
7738
  pT,
@@ -8002,9 +8004,9 @@ function computeTextVisualBounds(obj, w, h) {
8002
8004
  }
8003
8005
  return unionBounds(rects.length > 0 ? rects : [{ x: -w / 2, y: -h / 2, w, h }]);
8004
8006
  }
8005
- function computeBgRects(obj, w, h, pT, pR, pB, pL, fit) {
8007
+ function computeBgRects(obj, w, h, pT, pR, pB, pL, fit, lineFullWidth = false) {
8006
8008
  var _a2;
8007
- if (!fit) {
8009
+ if (!fit && !lineFullWidth) {
8008
8010
  return [{
8009
8011
  x: -w / 2 - pL,
8010
8012
  y: -h / 2 - pT,
@@ -8025,7 +8027,24 @@ function computeBgRects(obj, w, h, pT, pR, pB, pL, fit) {
8025
8027
  const halfW = w / 2;
8026
8028
  const halfH = h / 2;
8027
8029
  const lineHeightRatio = Math.max(0.01, Number((obj == null ? void 0 : obj.lineHeight) ?? 1) || 1);
8028
- let cursorY = -halfH;
8030
+ const valign = (obj == null ? void 0 : obj.verticalAlign) || "top";
8031
+ let contentH = 0;
8032
+ for (let i = 0; i < lines.length; i++) {
8033
+ try {
8034
+ contentH += obj.getHeightOfLine(i) || 0;
8035
+ } catch {
8036
+ }
8037
+ }
8038
+ if (lines.length > 0) {
8039
+ try {
8040
+ const lastH = obj.getHeightOfLine(lines.length - 1) || 0;
8041
+ contentH -= lastH - lastH / lineHeightRatio;
8042
+ } catch {
8043
+ }
8044
+ }
8045
+ const verticalPadding = Math.max(0, h - contentH);
8046
+ const valignOffset = valign === "middle" ? verticalPadding / 2 : valign === "bottom" ? verticalPadding : 0;
8047
+ let cursorY = -halfH + valignOffset;
8029
8048
  for (let i = 0; i < lines.length; i++) {
8030
8049
  let lineW = 0;
8031
8050
  let lineLeft = 0;
@@ -8047,15 +8066,18 @@ function computeBgRects(obj, w, h, pT, pR, pB, pL, fit) {
8047
8066
  }
8048
8067
  const rawSlotH = i === lines.length - 1 ? lineH / lineHeightRatio : lineH;
8049
8068
  const usedH = cursorY + halfH;
8050
- const slotH = Math.max(0, Math.min(rawSlotH, h - usedH));
8051
- if (lineW <= 0 || slotH <= 0) {
8069
+ const remaining = h - usedH;
8070
+ const slotH = Math.max(0, Math.min(rawSlotH, remaining));
8071
+ const effectiveW = lineFullWidth ? w : lineW;
8072
+ const effectiveLeft = lineFullWidth ? 0 : lineLeft;
8073
+ if (effectiveW <= 0 || slotH <= 0) {
8052
8074
  cursorY += slotH;
8053
8075
  continue;
8054
8076
  }
8055
8077
  rects.push({
8056
- x: -halfW + lineLeft - pL,
8078
+ x: -halfW + effectiveLeft - pL,
8057
8079
  y: cursorY - pT,
8058
- w: lineW + pL + pR,
8080
+ w: effectiveW + pL + pR,
8059
8081
  h: slotH + pT + pB
8060
8082
  });
8061
8083
  cursorY += slotH;
@@ -13088,6 +13110,7 @@ const PageCanvas = react.forwardRef(
13088
13110
  br: element.textBgRxBR ?? 0,
13089
13111
  bl: element.textBgRxBL ?? 0,
13090
13112
  ft: element.textBgFitToText === true,
13113
+ lf: element.textBgPerLineFullWidth === true,
13091
13114
  bo: element.textBgOpacity ?? 1,
13092
13115
  sc: element.textShadowColor ?? null,
13093
13116
  sb: element.textShadowBlur ?? 0,
@@ -14226,6 +14249,7 @@ const PageCanvas = react.forwardRef(
14226
14249
  br: element.textBgRxBR ?? 0,
14227
14250
  bl: element.textBgRxBL ?? 0,
14228
14251
  ft: element.textBgFitToText === true,
14252
+ lf: element.textBgPerLineFullWidth === true,
14229
14253
  bo: element.textBgOpacity ?? 1,
14230
14254
  sc: element.textShadowColor ?? null,
14231
14255
  sb: element.textShadowBlur ?? 0,
@@ -21115,9 +21139,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
21115
21139
  }
21116
21140
  return svgString;
21117
21141
  }
21118
- const resolvedPackageVersion = "0.5.234";
21142
+ const resolvedPackageVersion = "0.5.236";
21119
21143
  const PACKAGE_VERSION = resolvedPackageVersion;
21120
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.234";
21144
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.236";
21121
21145
  const roundParityValue = (value) => {
21122
21146
  if (typeof value !== "number") return value;
21123
21147
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -21861,7 +21885,7 @@ class PixldocsRenderer {
21861
21885
  await this.waitForCanvasScene(container, cloned, i);
21862
21886
  }
21863
21887
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
21864
- const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-Bf3z99NE.cjs"));
21888
+ const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-D90JQKe8.cjs"));
21865
21889
  const prepared = preparePagesForExport(
21866
21890
  cloned.pages,
21867
21891
  canvasWidth,
@@ -24181,7 +24205,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
24181
24205
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
24182
24206
  sanitizeSvgTreeForPdf(svgToDraw);
24183
24207
  try {
24184
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-Bf3z99NE.cjs"));
24208
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-D90JQKe8.cjs"));
24185
24209
  try {
24186
24210
  await logTextMeasurementDiagnostic(svgToDraw);
24187
24211
  } catch {
@@ -24578,4 +24602,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
24578
24602
  exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
24579
24603
  exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
24580
24604
  exports.warmTemplateFromForm = warmTemplateFromForm;
24581
- //# sourceMappingURL=index-DQRByRIO.cjs.map
24605
+ //# sourceMappingURL=index-D5oENivp.cjs.map