numParagraph.js
This commit is contained in:
parent
a8e3f5c31b
commit
84633a1d4a
5 changed files with 43 additions and 2 deletions
27
js/numParagraph.js
Normal file
27
js/numParagraph.js
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
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) {
|
||||
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;
|
||||
sibling = sibling.nextElementSibling;
|
||||
}
|
||||
if (totalHeight > 0) {
|
||||
num.style.height = totalHeight + 'px';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue