Fix highlight exlusion
This commit is contained in:
parent
431cded293
commit
4d50e79958
|
|
@ -161,7 +161,8 @@ export const getSelectionHandler =
|
||||||
// the selection is inside our container, so we can do something with it
|
// the selection is inside our container, so we can do something with it
|
||||||
const { startContainer, endContainer } = range;
|
const { startContainer, endContainer } = range;
|
||||||
// todo: handle case with paragraphs and list items
|
// 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;
|
return;
|
||||||
}
|
}
|
||||||
const startAncestor = findClosestAncestorWithTag(startContainer, ['p', 'li']);
|
const startAncestor = findClosestAncestorWithTag(startContainer, ['p', 'li']);
|
||||||
|
|
@ -178,10 +179,6 @@ export const getSelectionHandler =
|
||||||
const selector = parentSelector ? parentSelector : 'content-component';
|
const selector = parentSelector ? parentSelector : 'content-component';
|
||||||
const contentComponent = findClosestAncestorWithClass(startContainer, selector);
|
const contentComponent = findClosestAncestorWithClass(startContainer, selector);
|
||||||
if (contentComponent) {
|
if (contentComponent) {
|
||||||
if (isNotHighlightable(contentComponent)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// our selection is wholly inside the container node, we continue with it
|
// our selection is wholly inside the container node, we continue with it
|
||||||
const position = findPositionInParent(contentComponent);
|
const position = findPositionInParent(contentComponent);
|
||||||
const uuid = contentComponent.dataset.uuid || '';
|
const uuid = contentComponent.dataset.uuid || '';
|
||||||
|
|
@ -233,7 +230,7 @@ export const getSelectionHandler =
|
||||||
};
|
};
|
||||||
|
|
||||||
const isNotHighlightable = (element: HTMLElement) => {
|
const isNotHighlightable = (element: HTMLElement) => {
|
||||||
const nonHighlightableClasses = ['content-component--solution', 'solution-text'];
|
const nonHighlightableClasses = ['solution__hidden'];
|
||||||
return [...element.classList].some((value) => nonHighlightableClasses.includes(value));
|
return [...element.classList].some((value) => nonHighlightableClasses.includes(value));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue