clone numParagraph (page + column)

This commit is contained in:
Julie Blanc 2026-04-10 11:24:39 +02:00
parent bdb35a7ea6
commit 3b91983491
9 changed files with 147 additions and 86 deletions

View file

@ -20,8 +20,6 @@ export default class followingNotes extends Handler {
beforeParsed(content) {
console.log("floatnotes");
let newNotesClass = this.newNotesClass;
resetCounter(content, this.reset, this.notesClass);
createCallandMarker(content, this.notesClass, newNotesClass);
@ -34,9 +32,16 @@ export default class followingNotes extends Handler {
let paragraph = note.closest("p");
if (!paragraph) return;
// Find next boundary: heading or ol[type="1"]
// Remonter au niveau direct de #section__content (ignorer blockquote et autres conteneurs)
const sectionContent = note.closest('#section__content') || content;
let topLevel = paragraph;
while (topLevel.parentElement && topLevel.parentElement !== sectionContent) {
topLevel = topLevel.parentElement;
}
// Find next boundary: heading or ol[type="1"], au niveau de #section__content
let boundary = null;
let sibling = paragraph.nextElementSibling;
let sibling = topLevel.nextElementSibling;
while (sibling) {
if (sibling.matches('h1, h2, h3, h4, h5, h6, ol[type="1"]')) {
boundary = sibling;
@ -45,7 +50,7 @@ export default class followingNotes extends Handler {
sibling = sibling.nextElementSibling;
}
const mapKey = boundary || paragraph.parentElement;
const mapKey = boundary || sectionContent;
if (!containerMap.has(mapKey)) {
let container = document.createElement("div");
@ -53,7 +58,7 @@ export default class followingNotes extends Handler {
if (boundary) {
boundary.before(container);
} else {
paragraph.parentElement.appendChild(container);
sectionContent.appendChild(container);
}
containerMap.set(mapKey, container);
}