fix(highlights_list): displaying non-highlighted attributes

This commit is contained in:
Elian Doran 2025-12-18 13:33:08 +02:00
parent cd9654cd5f
commit d18ac0c613
No known key found for this signature in database

View File

@ -191,7 +191,7 @@ function extractHeadingsFromStaticHtml(el: HTMLElement | null) {
let node: Node | null; let node: Node | null;
while ((node = walker.nextNode())) { while ((node = walker.nextNode())) {
const el = node.parentElement; const el = node.parentElement;
if (!el || !node.textContent?.trim()) continue; if (!el || !node.textContent) continue;
const style = getComputedStyle(el); const style = getComputedStyle(el);
@ -199,18 +199,22 @@ function extractHeadingsFromStaticHtml(el: HTMLElement | null) {
el.closest('strong, em, u') || el.closest('strong, em, u') ||
style.color || style.backgroundColor style.color || style.backgroundColor
) { ) {
highlights.push({ const attrs: RawHighlight["attrs"] = {
id: crypto.randomUUID(), bold: !!el.closest("strong"),
text: node.textContent, italic: !!el.closest("em"),
element: el, underline: !!el.closest("u"),
attrs: { background: el.style.backgroundColor,
bold: !!el.closest("strong"), color: el.style.color
italic: !!el.closest("em"), };
underline: !!el.closest("u"),
background: el.style.backgroundColor, if (Object.values(attrs).some(Boolean)) {
color: el.style.color highlights.push({
} id: crypto.randomUUID(),
}); text: node.textContent,
element: el,
attrs
});
}
} }
} }