@json-to-office/core-docx 4.2.0 → 4.4.0

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.
@@ -9307,6 +9307,15 @@ function compileColumns(component, scope) {
9307
9307
  if (configs.length === 0) return [];
9308
9308
  const available = getAvailableWidthTwips(ctx.theme, ctx.themeName);
9309
9309
  const { widths, gaps } = columnMetrics(configs, props.gap, available);
9310
+ const stated = widths.map(
9311
+ (width, index) => width + gaps[index] / 2 + (index > 0 ? gaps[index - 1] / 2 : 0)
9312
+ );
9313
+ const statedTotal = stated.reduce((sum, cell) => sum + cell, 0);
9314
+ const scale = statedTotal > available ? available / statedTotal : 1;
9315
+ const exact = stated.map((cell) => cell * scale);
9316
+ const cells = exact.map((cell) => Math.round(cell));
9317
+ const total = exact.reduce((sum, cell) => sum + cell, 0);
9318
+ cells[cells.length - 1] += Math.round(total) - cells.reduce((a, b) => a + b, 0);
9310
9319
  const contents = configs.map(() => []);
9311
9320
  const children = component.children ?? [];
9312
9321
  children.forEach((child, index) => {
@@ -9318,7 +9327,7 @@ function compileColumns(component, scope) {
9318
9327
  kind: "table",
9319
9328
  id: scope.id,
9320
9329
  path: path3,
9321
- columnGrid: { unit: "twips", values: [] },
9330
+ columnGrid: { unit: "twips", values: cells },
9322
9331
  width: { kind: "percent", value: 100 },
9323
9332
  layout: "fixed",
9324
9333
  borders: NO_BORDERS,
@@ -9343,7 +9352,7 @@ function compileColumns(component, scope) {
9343
9352
  children: []
9344
9353
  }
9345
9354
  ],
9346
- widthTwips: widths[index],
9355
+ widthTwips: cells[index],
9347
9356
  margins: {
9348
9357
  topTwips: 0,
9349
9358
  rightTwips: gaps[index] / 2,
@@ -9921,6 +9930,11 @@ function compileList(component, scope, referencePrefix = "list", explicitLevels)
9921
9930
  const props = component.props ?? {};
9922
9931
  const items = props.items ?? [];
9923
9932
  if (items.length === 0) return [];
9933
+ const base = runFormatting3(
9934
+ props.font ?? {},
9935
+ props,
9936
+ ctx
9937
+ );
9924
9938
  const notes = createNoteBinding(props.footnotes, props.endnotes, ctx);
9925
9939
  const reference = declareNumbering(
9926
9940
  props,
@@ -9956,17 +9970,21 @@ function compileList(component, scope, referencePrefix = "list", explicitLevels)
9956
9970
  paragraphNode(
9957
9971
  { ctx, path: itemPath, id: `${scope.id}:i${index}` },
9958
9972
  revision === void 0 ? parseInline(text, {
9959
- base: {},
9973
+ base,
9960
9974
  hyperlinks: true,
9961
9975
  ...notes ? { resolveNote: notes.resolve } : {},
9962
9976
  resolvePlaceholder: placeholderResolver(ctx),
9963
9977
  resolveCrossReference: crossReferenceResolver(ctx, itemPath)
9964
- }) : compileRevision(revision, {}, ctx),
9978
+ }) : compileRevision(revision, base, ctx),
9965
9979
  {
9966
9980
  styleId: "Normal",
9967
9981
  formatting: {
9968
9982
  alignment: compileAlignment(props.alignment) ?? "left",
9969
- spacing: itemSpacing(props.spacing, index, items.length)
9983
+ spacing: itemSpacing(props.spacing, index, items.length),
9984
+ // Every item carries the flags, not just the first: keeping a list
9985
+ // with what introduces it means keeping it whole.
9986
+ ...props.keepNext !== void 0 ? { keepNext: props.keepNext } : {},
9987
+ ...props.keepLines !== void 0 ? { keepLines: props.keepLines } : {}
9970
9988
  },
9971
9989
  ...commentIds && index === firstRendered ? { commentOpen: commentIds } : {},
9972
9990
  ...commentIds && index === lastRendered ? { commentClose: commentIds } : {},
@@ -11679,12 +11697,6 @@ function determineComponentLayout(component) {
11679
11697
  }
11680
11698
  return "single";
11681
11699
  }
11682
- if ("children" in component && component.children) {
11683
- const hasColumns = component.children.some(
11684
- (child) => isColumnsComponent(child)
11685
- );
11686
- return hasColumns ? "multi-column" : "single";
11687
- }
11688
11700
  return "single";
11689
11701
  }
11690
11702
  function processLayoutComponents(components) {