numParagraph.js break column

This commit is contained in:
Julie Blanc 2026-04-09 22:35:44 +02:00
parent 84633a1d4a
commit bdb35a7ea6
4 changed files with 17 additions and 2 deletions

View file

@ -8,13 +8,24 @@ export default class thesis extends Handler {
afterPageLayout(pageElement, page, breakToken){
let nums = pageElement.querySelectorAll('ol[type="1"]');
nums.forEach(function (num) {
const colContainer = num.closest('#section__content') || num.offsetParent;
const colHeight = colContainer.offsetHeight;
let totalHeight = 0;
let sibling = num.nextElementSibling;
while (sibling) {
if (sibling.matches('ol[type="1"], h1, h2, h3, h4, h5, h6, .container-following-note')) break;
totalHeight += sibling.offsetHeight;
// Le frère commence dans la colonne 2 → stop
if (sibling.offsetTop >= colHeight) break;
// Le frère est coupé entre les deux colonnes → ne compter que la partie en colonne 1
const partHeight = Math.min(sibling.offsetHeight, colHeight - sibling.offsetTop);
totalHeight += partHeight;
sibling = sibling.nextElementSibling;
}
if (totalHeight > 0) {
num.style.height = totalHeight + 'px';
}