@rnichi11/react-column-pdf-layout 4.4.4-rnichi.0 → 4.4.4

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.
Files changed (2) hide show
  1. package/lib/index.js +29 -27
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -3032,31 +3032,9 @@ const splitNodes = (height, contentArea, nodes, fontStore, containerWidth) => {
3032
3032
  nextChildren.push(next, ...futureNodes);
3033
3033
  break;
3034
3034
  }
3035
- if (shouldSplit) {
3036
- const [currentChild, nextChild] = split(child, height, contentArea, fontStore, undefined, containerWidth);
3037
- // All children are moved to the next page, it doesn't make sense to show the parent on the current page
3038
- if (child.children.length > 0 && currentChild.children.length === 0) {
3039
- // But if the current page is empty then we can just include the parent on the current page
3040
- if (currentChildren.length === 0) {
3041
- currentChildren.push(child, ...futureFixedNodes);
3042
- nextChildren.push(...futureNodes);
3043
- }
3044
- else {
3045
- const box = Object.assign({}, child.box, {
3046
- top: child.box.top - height,
3047
- });
3048
- const next = Object.assign({}, child, { box });
3049
- currentChildren.push(...futureFixedNodes);
3050
- nextChildren.push(next, ...futureNodes);
3051
- }
3052
- break;
3053
- }
3054
- if (currentChild)
3055
- currentChildren.push(currentChild);
3056
- if (nextChild)
3057
- nextChildren.push(nextChild);
3058
- continue;
3059
- }
3035
+ // Handle multi-column containers before generic split logic.
3036
+ // `child.box.height` here comes from pre-column layout and can overestimate
3037
+ // required height, which would trigger premature page splits.
3060
3038
  if (isView(child) &&
3061
3039
  (child.props?.columns ?? 1) > 1 &&
3062
3040
  fontStore) {
@@ -3097,10 +3075,34 @@ const splitNodes = (height, contentArea, nodes, fontStore, containerWidth) => {
3097
3075
  }
3098
3076
  const childToPush = transformViewToColumns(viewChild, height - nodeTop, contentArea, fontStore, containerWidth);
3099
3077
  currentChildren.push(childToPush);
3078
+ continue;
3100
3079
  }
3101
- else {
3102
- currentChildren.push(child);
3080
+ if (shouldSplit) {
3081
+ const [currentChild, nextChild] = split(child, height, contentArea, fontStore, undefined, containerWidth);
3082
+ // All children are moved to the next page, it doesn't make sense to show the parent on the current page
3083
+ if (child.children.length > 0 && currentChild.children.length === 0) {
3084
+ // But if the current page is empty then we can just include the parent on the current page
3085
+ if (currentChildren.length === 0) {
3086
+ currentChildren.push(child, ...futureFixedNodes);
3087
+ nextChildren.push(...futureNodes);
3088
+ }
3089
+ else {
3090
+ const box = Object.assign({}, child.box, {
3091
+ top: child.box.top - height,
3092
+ });
3093
+ const next = Object.assign({}, child, { box });
3094
+ currentChildren.push(...futureFixedNodes);
3095
+ nextChildren.push(next, ...futureNodes);
3096
+ }
3097
+ break;
3098
+ }
3099
+ if (currentChild)
3100
+ currentChildren.push(currentChild);
3101
+ if (nextChild)
3102
+ nextChildren.push(nextChild);
3103
+ continue;
3103
3104
  }
3105
+ currentChildren.push(child);
3104
3106
  }
3105
3107
  return [currentChildren, nextChildren];
3106
3108
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rnichi11/react-column-pdf-layout",
3
- "version": "4.4.4-rnichi.0",
3
+ "version": "4.4.4",
4
4
  "license": "MIT",
5
5
  "description": "Multi-column layout engine for react-column-pdf",
6
6
  "author": "rnichi1",