@pixldocs/canvas-renderer 0.5.233 → 0.5.235

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.
@@ -8007,7 +8007,24 @@ function computeBgRects(obj, w, h, pT, pR, pB, pL, fit) {
8007
8007
  const halfW = w / 2;
8008
8008
  const halfH = h / 2;
8009
8009
  const lineHeightRatio = Math.max(0.01, Number((obj == null ? void 0 : obj.lineHeight) ?? 1) || 1);
8010
- let cursorY = -halfH;
8010
+ const valign = (obj == null ? void 0 : obj.verticalAlign) || "top";
8011
+ let contentH = 0;
8012
+ for (let i = 0; i < lines.length; i++) {
8013
+ try {
8014
+ contentH += obj.getHeightOfLine(i) || 0;
8015
+ } catch {
8016
+ }
8017
+ }
8018
+ if (lines.length > 0) {
8019
+ try {
8020
+ const lastH = obj.getHeightOfLine(lines.length - 1) || 0;
8021
+ contentH -= lastH - lastH / lineHeightRatio;
8022
+ } catch {
8023
+ }
8024
+ }
8025
+ const verticalPadding = Math.max(0, h - contentH);
8026
+ const valignOffset = valign === "middle" ? verticalPadding / 2 : valign === "bottom" ? verticalPadding : 0;
8027
+ let cursorY = -halfH + valignOffset;
8011
8028
  for (let i = 0; i < lines.length; i++) {
8012
8029
  let lineW = 0;
8013
8030
  let lineLeft = 0;
@@ -8029,7 +8046,8 @@ function computeBgRects(obj, w, h, pT, pR, pB, pL, fit) {
8029
8046
  }
8030
8047
  const rawSlotH = i === lines.length - 1 ? lineH / lineHeightRatio : lineH;
8031
8048
  const usedH = cursorY + halfH;
8032
- const slotH = Math.max(0, Math.min(rawSlotH, h - usedH));
8049
+ const remaining = h - usedH;
8050
+ const slotH = Math.max(0, Math.min(rawSlotH, remaining));
8033
8051
  if (lineW <= 0 || slotH <= 0) {
8034
8052
  cursorY += slotH;
8035
8053
  continue;
@@ -13368,6 +13386,14 @@ const PageCanvas = forwardRef(
13368
13386
  clearMeasurementCache();
13369
13387
  }
13370
13388
  doSyncRef.current();
13389
+ if ((isPreviewMode || isExportMode) && fc && (pageChildren == null ? void 0 : pageChildren.length)) {
13390
+ runFontReloadAndReflow({
13391
+ canvas: fc,
13392
+ pageTree: pageChildren,
13393
+ pageBoundsOptions,
13394
+ preserveGlobalFontCache
13395
+ });
13396
+ }
13371
13397
  if (isPreviewMode && fc && (fc.width ?? 0) > 0 && (fc.height ?? 0) > 0) {
13372
13398
  fc.requestRenderAll();
13373
13399
  }
@@ -19434,10 +19460,10 @@ async function resolveTemplateData(options) {
19434
19460
  const inlineFormSchema = template.form_schema;
19435
19461
  const defaultData = template.default_data;
19436
19462
  if (inlineFormSchema && typeof inlineFormSchema === "object") {
19437
- if (!Array.isArray(config.dynamicFields) && Array.isArray(inlineFormSchema.dynamicFields)) {
19463
+ if ((!Array.isArray(config.dynamicFields) || config.dynamicFields.length === 0) && Array.isArray(inlineFormSchema.dynamicFields)) {
19438
19464
  config.dynamicFields = inlineFormSchema.dynamicFields;
19439
19465
  }
19440
- if (!Array.isArray(config.fieldGroups) && Array.isArray(inlineFormSchema.fieldGroups)) {
19466
+ if ((!Array.isArray(config.fieldGroups) || config.fieldGroups.length === 0) && Array.isArray(inlineFormSchema.fieldGroups)) {
19441
19467
  config.fieldGroups = inlineFormSchema.fieldGroups;
19442
19468
  }
19443
19469
  }
@@ -19518,10 +19544,10 @@ async function resolveFromForm(options) {
19518
19544
  const templateFormSchema = templateRow.form_schema;
19519
19545
  const formSchema = (formSchemaRow == null ? void 0 : formSchemaRow.schema) ?? void 0;
19520
19546
  if (templateFormSchema) {
19521
- if (!Array.isArray(templateConfig.dynamicFields) && Array.isArray(templateFormSchema.dynamicFields)) {
19547
+ if ((!Array.isArray(templateConfig.dynamicFields) || templateConfig.dynamicFields.length === 0) && Array.isArray(templateFormSchema.dynamicFields)) {
19522
19548
  templateConfig.dynamicFields = templateFormSchema.dynamicFields;
19523
19549
  }
19524
- if (!Array.isArray(templateConfig.fieldGroups) && Array.isArray(templateFormSchema.fieldGroups)) {
19550
+ if ((!Array.isArray(templateConfig.fieldGroups) || templateConfig.fieldGroups.length === 0) && Array.isArray(templateFormSchema.fieldGroups)) {
19525
19551
  templateConfig.fieldGroups = templateFormSchema.fieldGroups;
19526
19552
  }
19527
19553
  }
@@ -19568,7 +19594,11 @@ async function resolveFromForm(options) {
19568
19594
  mergedSectionState = mergeRepeatableEntryMeta(mergedSectionState, templateDefaultMetaSectionState, inferredSections);
19569
19595
  mergedSectionState = mergeRepeatableEntryMeta(mergedSectionState, defaultFormMetaSectionState, inferredSections);
19570
19596
  mergedSectionState = sanitizeSectionStateAgainstSchema(mergedSectionState, formSchema);
19571
- const flatFormData = flattenSectionStateToFormData(mergedSectionState, inferredSections);
19597
+ const sectionFlatFormData = flattenSectionStateToFormData(mergedSectionState, inferredSections);
19598
+ const flatFormData = {
19599
+ ...sectionFlatFormData,
19600
+ ...directFlatFormData && typeof directFlatFormData === "object" ? directFlatFormData : {}
19601
+ };
19572
19602
  const dynamicFields = templateConfig.dynamicFields || [];
19573
19603
  const mappings = [];
19574
19604
  for (const field of dynamicFields) {
@@ -21085,9 +21115,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
21085
21115
  }
21086
21116
  return svgString;
21087
21117
  }
21088
- const resolvedPackageVersion = "0.5.233";
21118
+ const resolvedPackageVersion = "0.5.235";
21089
21119
  const PACKAGE_VERSION = resolvedPackageVersion;
21090
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.233";
21120
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.235";
21091
21121
  const roundParityValue = (value) => {
21092
21122
  if (typeof value !== "number") return value;
21093
21123
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -21831,7 +21861,7 @@ class PixldocsRenderer {
21831
21861
  await this.waitForCanvasScene(container, cloned, i);
21832
21862
  }
21833
21863
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
21834
- const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-D-bYnkA5.js");
21864
+ const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-DzgUFIK9.js");
21835
21865
  const prepared = preparePagesForExport(
21836
21866
  cloned.pages,
21837
21867
  canvasWidth,
@@ -24151,7 +24181,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
24151
24181
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
24152
24182
  sanitizeSvgTreeForPdf(svgToDraw);
24153
24183
  try {
24154
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-D-bYnkA5.js");
24184
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-DzgUFIK9.js");
24155
24185
  try {
24156
24186
  await logTextMeasurementDiagnostic(svgToDraw);
24157
24187
  } catch {
@@ -24551,4 +24581,4 @@ export {
24551
24581
  buildTeaserBlurFlatKeys as y,
24552
24582
  collectFontDescriptorsFromConfig as z
24553
24583
  };
24554
- //# sourceMappingURL=index-DJ3tFfRA.js.map
24584
+ //# sourceMappingURL=index-B8RvBKaU.js.map