38 lines
1.3 KiB
JavaScript
38 lines
1.3 KiB
JavaScript
import { Handler } from '/csspageweaver/lib/paged.esm.js';
|
|
|
|
export default class thesis extends Handler {
|
|
constructor(chunker, polisher, caller) {
|
|
super(chunker, polisher, caller);
|
|
}
|
|
|
|
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;
|
|
|
|
// 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';
|
|
}
|
|
});
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|