Fix highlight exlusion

This commit is contained in:
Lorenz Padberg 2024-03-19 16:03:02 +01:00
parent 431cded293
commit 4d50e79958
1 changed files with 3 additions and 6 deletions

View File

@ -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));
};