You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
1000 B
30 lines
1000 B
(function () { |
|
// Guard against running multiple observers if the script is loaded more than once |
|
if (window.__miradorSpaceFixInitialized) return; |
|
window.__miradorSpaceFixInitialized = true; |
|
|
|
const observer = new MutationObserver((mutations) => { |
|
// Target any third-party HTML content blocks in Mirador that haven't been cleaned yet |
|
const elements = document.querySelectorAll( |
|
".mirador-third-party-html:not([data-fixed])" |
|
); |
|
|
|
if (elements.length > 0) { |
|
elements.forEach((el) => { |
|
// Swap non-breaking spaces for normal breakable spaces |
|
el.innerHTML = el.innerHTML |
|
.replace(/ /g, " ") |
|
.replace(/\u00A0/g, " "); |
|
|
|
// Mark element so we don't re-process it on subsequent mutations |
|
el.setAttribute("data-fixed", "true"); |
|
}); |
|
} |
|
}); |
|
|
|
// Start observing the document body for dynamically added Mirador elements |
|
observer.observe(document.body, { |
|
childList: true, |
|
subtree: true, |
|
}); |
|
})();
|
|
|