From 4d50e799589965d4b1febce4b954195fe0cdb9e1 Mon Sep 17 00:00:00 2001 From: Lorenz Padberg Date: Tue, 19 Mar 2024 16:03:02 +0100 Subject: [PATCH] Fix highlight exlusion --- client/src/helpers/highlight.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/client/src/helpers/highlight.ts b/client/src/helpers/highlight.ts index 3956df57..6369f351 100644 --- a/client/src/helpers/highlight.ts +++ b/client/src/helpers/highlight.ts @@ -161,7 +161,8 @@ export const getSelectionHandler = // the selection is inside our container, so we can do something with it const { startContainer, endContainer } = range; // todo: handle case with paragraphs and list items - if (startContainer.parentElement && isNotHighlightable(startContainer.parentElement)) { + const div_ancestor = findClosestAncestorWithTag(startContainer, 'div'); + if (div_ancestor && isNotHighlightable(div_ancestor)) { return; } const startAncestor = findClosestAncestorWithTag(startContainer, ['p', 'li']); @@ -178,10 +179,6 @@ export const getSelectionHandler = const selector = parentSelector ? parentSelector : 'content-component'; const contentComponent = findClosestAncestorWithClass(startContainer, selector); if (contentComponent) { - if (isNotHighlightable(contentComponent)) { - return; - } - // our selection is wholly inside the container node, we continue with it const position = findPositionInParent(contentComponent); const uuid = contentComponent.dataset.uuid || ''; @@ -233,7 +230,7 @@ export const getSelectionHandler = }; const isNotHighlightable = (element: HTMLElement) => { - const nonHighlightableClasses = ['content-component--solution', 'solution-text']; + const nonHighlightableClasses = ['solution__hidden']; return [...element.classList].some((value) => nonHighlightableClasses.includes(value)); };