@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.
@@ -8025,7 +8025,24 @@ function computeBgRects(obj, w, h, pT, pR, pB, pL, fit) {
8025
8025
  const halfW = w / 2;
8026
8026
  const halfH = h / 2;
8027
8027
  const lineHeightRatio = Math.max(0.01, Number((obj == null ? void 0 : obj.lineHeight) ?? 1) || 1);
8028
- let cursorY = -halfH;
8028
+ const valign = (obj == null ? void 0 : obj.verticalAlign) || "top";
8029
+ let contentH = 0;
8030
+ for (let i = 0; i < lines.length; i++) {
8031
+ try {
8032
+ contentH += obj.getHeightOfLine(i) || 0;
8033
+ } catch {
8034
+ }
8035
+ }
8036
+ if (lines.length > 0) {
8037
+ try {
8038
+ const lastH = obj.getHeightOfLine(lines.length - 1) || 0;
8039
+ contentH -= lastH - lastH / lineHeightRatio;
8040
+ } catch {
8041
+ }
8042
+ }
8043
+ const verticalPadding = Math.max(0, h - contentH);
8044
+ const valignOffset = valign === "middle" ? verticalPadding / 2 : valign === "bottom" ? verticalPadding : 0;
8045
+ let cursorY = -halfH + valignOffset;
8029
8046
  for (let i = 0; i < lines.length; i++) {
8030
8047
  let lineW = 0;
8031
8048
  let lineLeft = 0;
@@ -8047,7 +8064,8 @@ function computeBgRects(obj, w, h, pT, pR, pB, pL, fit) {
8047
8064
  }
8048
8065
  const rawSlotH = i === lines.length - 1 ? lineH / lineHeightRatio : lineH;
8049
8066
  const usedH = cursorY + halfH;
8050
- const slotH = Math.max(0, Math.min(rawSlotH, h - usedH));
8067
+ const remaining = h - usedH;
8068
+ const slotH = Math.max(0, Math.min(rawSlotH, remaining));
8051
8069
  if (lineW <= 0 || slotH <= 0) {
8052
8070
  cursorY += slotH;
8053
8071
  continue;
@@ -13386,6 +13404,14 @@ const PageCanvas = react.forwardRef(
13386
13404
  clearMeasurementCache();
13387
13405
  }
13388
13406
  doSyncRef.current();
13407
+ if ((isPreviewMode || isExportMode) && fc && (pageChildren == null ? void 0 : pageChildren.length)) {
13408
+ runFontReloadAndReflow({
13409
+ canvas: fc,
13410
+ pageTree: pageChildren,
13411
+ pageBoundsOptions,
13412
+ preserveGlobalFontCache
13413
+ });
13414
+ }
13389
13415
  if (isPreviewMode && fc && (fc.width ?? 0) > 0 && (fc.height ?? 0) > 0) {
13390
13416
  fc.requestRenderAll();
13391
13417
  }
@@ -19452,10 +19478,10 @@ async function resolveTemplateData(options) {
19452
19478
  const inlineFormSchema = template.form_schema;
19453
19479
  const defaultData = template.default_data;
19454
19480
  if (inlineFormSchema && typeof inlineFormSchema === "object") {
19455
- if (!Array.isArray(config.dynamicFields) && Array.isArray(inlineFormSchema.dynamicFields)) {
19481
+ if ((!Array.isArray(config.dynamicFields) || config.dynamicFields.length === 0) && Array.isArray(inlineFormSchema.dynamicFields)) {
19456
19482
  config.dynamicFields = inlineFormSchema.dynamicFields;
19457
19483
  }
19458
- if (!Array.isArray(config.fieldGroups) && Array.isArray(inlineFormSchema.fieldGroups)) {
19484
+ if ((!Array.isArray(config.fieldGroups) || config.fieldGroups.length === 0) && Array.isArray(inlineFormSchema.fieldGroups)) {
19459
19485
  config.fieldGroups = inlineFormSchema.fieldGroups;
19460
19486
  }
19461
19487
  }
@@ -19536,10 +19562,10 @@ async function resolveFromForm(options) {
19536
19562
  const templateFormSchema = templateRow.form_schema;
19537
19563
  const formSchema = (formSchemaRow == null ? void 0 : formSchemaRow.schema) ?? void 0;
19538
19564
  if (templateFormSchema) {
19539
- if (!Array.isArray(templateConfig.dynamicFields) && Array.isArray(templateFormSchema.dynamicFields)) {
19565
+ if ((!Array.isArray(templateConfig.dynamicFields) || templateConfig.dynamicFields.length === 0) && Array.isArray(templateFormSchema.dynamicFields)) {
19540
19566
  templateConfig.dynamicFields = templateFormSchema.dynamicFields;
19541
19567
  }
19542
- if (!Array.isArray(templateConfig.fieldGroups) && Array.isArray(templateFormSchema.fieldGroups)) {
19568
+ if ((!Array.isArray(templateConfig.fieldGroups) || templateConfig.fieldGroups.length === 0) && Array.isArray(templateFormSchema.fieldGroups)) {
19543
19569
  templateConfig.fieldGroups = templateFormSchema.fieldGroups;
19544
19570
  }
19545
19571
  }
@@ -19586,7 +19612,11 @@ async function resolveFromForm(options) {
19586
19612
  mergedSectionState = mergeRepeatableEntryMeta(mergedSectionState, templateDefaultMetaSectionState, inferredSections);
19587
19613
  mergedSectionState = mergeRepeatableEntryMeta(mergedSectionState, defaultFormMetaSectionState, inferredSections);
19588
19614
  mergedSectionState = sanitizeSectionStateAgainstSchema(mergedSectionState, formSchema);
19589
- const flatFormData = flattenSectionStateToFormData(mergedSectionState, inferredSections);
19615
+ const sectionFlatFormData = flattenSectionStateToFormData(mergedSectionState, inferredSections);
19616
+ const flatFormData = {
19617
+ ...sectionFlatFormData,
19618
+ ...directFlatFormData && typeof directFlatFormData === "object" ? directFlatFormData : {}
19619
+ };
19590
19620
  const dynamicFields = templateConfig.dynamicFields || [];
19591
19621
  const mappings = [];
19592
19622
  for (const field of dynamicFields) {
@@ -21103,9 +21133,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
21103
21133
  }
21104
21134
  return svgString;
21105
21135
  }
21106
- const resolvedPackageVersion = "0.5.233";
21136
+ const resolvedPackageVersion = "0.5.235";
21107
21137
  const PACKAGE_VERSION = resolvedPackageVersion;
21108
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.233";
21138
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.235";
21109
21139
  const roundParityValue = (value) => {
21110
21140
  if (typeof value !== "number") return value;
21111
21141
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -21849,7 +21879,7 @@ class PixldocsRenderer {
21849
21879
  await this.waitForCanvasScene(container, cloned, i);
21850
21880
  }
21851
21881
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
21852
- const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-DTCd5GSf.cjs"));
21882
+ const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-BtoxAWSs.cjs"));
21853
21883
  const prepared = preparePagesForExport(
21854
21884
  cloned.pages,
21855
21885
  canvasWidth,
@@ -24169,7 +24199,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
24169
24199
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
24170
24200
  sanitizeSvgTreeForPdf(svgToDraw);
24171
24201
  try {
24172
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-DTCd5GSf.cjs"));
24202
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-BtoxAWSs.cjs"));
24173
24203
  try {
24174
24204
  await logTextMeasurementDiagnostic(svgToDraw);
24175
24205
  } catch {
@@ -24566,4 +24596,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
24566
24596
  exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
24567
24597
  exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
24568
24598
  exports.warmTemplateFromForm = warmTemplateFromForm;
24569
- //# sourceMappingURL=index-3rzFNy2Z.cjs.map
24599
+ //# sourceMappingURL=index-CFIdusRV.cjs.map