fix minor bug

This commit is contained in:
David Bruant 2025-05-21 15:04:16 +02:00
parent 08e40f3607
commit 1d42b4d0eb
2 changed files with 8 additions and 4 deletions

View File

@ -385,7 +385,8 @@ const EACH = eachStartMarkerRegex.source
* @returns {void} * @returns {void}
*/ */
export default function fillOdtElementTemplate(rootElement, compartment) { export default function fillOdtElementTemplate(rootElement, compartment) {
//console.log('fillTemplatedOdtElement', rootElement.nodeType, rootElement.nodeName) //console.log('fillTemplatedOdtElement', rootElement.nodeType, rootElement.nodeName, rootElement.textContent)
//console.log('fillTemplatedOdtElement', rootElement.childNodes[0].childNodes.length)
let currentlyOpenBlocks = [] let currentlyOpenBlocks = []

View File

@ -166,9 +166,10 @@ function consolidateMarkers(document){
...Array.from(document.getElementsByTagName('text:h')) ...Array.from(document.getElementsByTagName('text:h'))
] ]
const consolidatedMarkers = []
for(const potentialMarkersContainer of potentialMarkersContainers) { for(const potentialMarkersContainer of potentialMarkersContainers) {
/** @type {{marker: string, index: number}[]} */
const consolidatedMarkers = []
/** @type {Text[]} */ /** @type {Text[]} */
let containerTextNodesInTreeOrder = []; let containerTextNodesInTreeOrder = [];
@ -245,13 +246,16 @@ function consolidateMarkers(document){
// Check if marker spans multiple nodes // Check if marker spans multiple nodes
if(startNode !== endNode) { if(startNode !== endNode) {
//console.log('startNode !== endNode', startNode.textContent, endNode.textContent)
const commonAncestor = findCommonAncestor(startNode, endNode) const commonAncestor = findCommonAncestor(startNode, endNode)
/** @type {Node} */
let commonAncestorStartChild = startNode let commonAncestorStartChild = startNode
while(commonAncestorStartChild.parentNode !== commonAncestor){ while(commonAncestorStartChild.parentNode !== commonAncestor){
commonAncestorStartChild = commonAncestorStartChild.parentNode commonAncestorStartChild = commonAncestorStartChild.parentNode
} }
/** @type {Node} */
let commonAncestorEndChild = endNode let commonAncestorEndChild = endNode
while(commonAncestorEndChild.parentNode !== commonAncestor){ while(commonAncestorEndChild.parentNode !== commonAncestor){
commonAncestorEndChild = commonAncestorEndChild.parentNode commonAncestorEndChild = commonAncestorEndChild.parentNode
@ -324,7 +328,6 @@ function consolidateMarkers(document){
} }
} }
//console.log('consolidatedMarkers', consolidatedMarkers)
} }
/** /**