User:SnowyCinema/highlight.js

document.addEventListener('DOMContentLoaded', => {    const input = document.querySelector('.wikiEditor-ui');    const overlay = document.createElement('div');    overlay.style.position = 'absolute';    overlay.style.pointerEvents = 'none';    input.parentNode.insertBefore(overlay, input.nextSibling);

function updateOverlay { const text = input.value; const html = text.replace(/["'—:.;]/g, match => {           let colorClass = '';            if (match === '"') colorClass = 'highlight-yellow';            else if (match === "'") colorClass = 'highlight-blue';            else if (match === '—') colorClass = 'highlight-lightblue';            else if (match === ': ') colorClass = 'highlight-blue';             else if (['.', ';'].includes(match)) colorClass = 'highlight-lightorange';            return `${match} `;        });

overlay.innerHTML = html.replace(/\n/g, ' '); overlay.style.width = `${input.offsetWidth}px`; overlay.style.height = `${input.offsetHeight}px`; overlay.style.top = `${input.offsetTop}px`; overlay.style.left = `${input.offsetLeft}px`; }

input.addEventListener('input', updateOverlay); updateOverlay; });