Skip to content

Build your personal knowledge base with Trilium Notes

chore(highlights_list): improve performance by matching fewer elements

Elian Doran751a874c5119
diff --git a/apps/client/src/widgets/sidebar/HighlightsList.tsx b/apps/client/src/widgets/sidebar/HighlightsList.tsx
index 755071cab3..4007cc91f8 100644
--- a/apps/client/src/widgets/sidebar/HighlightsList.tsx
+++ b/apps/client/src/widgets/sidebar/HighlightsList.tsx
@@ -180,6 +180,8 @@ function ReadOnlyTextHighlightsList() {
function extractHeadingsFromStaticHtml(el: HTMLElement | null) {
if (!el) return [];
+ const { color: defaultColor, backgroundColor: defaultBackgroundColor } = getComputedStyle(el);
+
const walker = document.createTreeWalker(
el,
NodeFilter.SHOW_TEXT,
@@ -197,7 +199,8 @@ function extractHeadingsFromStaticHtml(el: HTMLElement | null) {
if (
el.closest('strong, em, u') ||
- style.color || style.backgroundColor
+ style.color !== defaultColor ||
+ style.backgroundColor !== defaultBackgroundColor
) {
const attrs: RawHighlight["attrs"] = {
bold: !!el.closest("strong"),