Fix some typing issues
This commit is contained in:
parent
99ce0ab84d
commit
4584cb860e
|
|
@ -269,7 +269,7 @@ onUnmounted(() => {
|
||||||
|
|
||||||
if (element !== null) {
|
if (element !== null) {
|
||||||
console.log('unmounting');
|
console.log('unmounting');
|
||||||
element.removeEventListener('mouseup', getSelectionHandler);
|
element.removeEventListener('mouseup', getSelectionHandler(element, props.contentBlock));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -102,13 +102,13 @@ export const getSelectionHandler = (el: HTMLElement, contentBlock: ContentBlockN
|
||||||
const paragraph = findClosestAncestorWithTag(startContainer, 'p');
|
const paragraph = findClosestAncestorWithTag(startContainer, 'p');
|
||||||
const endAncestor = findClosestAncestorWithTag(endContainer, 'p');
|
const endAncestor = findClosestAncestorWithTag(endContainer, 'p');
|
||||||
|
|
||||||
if (paragraph === endAncestor) {
|
if (paragraph && paragraph === endAncestor) {
|
||||||
// todo: rename this variable, `parent` is not correct anymore
|
// todo: rename this variable, `parent` is not correct anymore
|
||||||
const contentComponent = findClosestAncestorWithClass(startContainer, 'content-component');
|
const contentComponent = findClosestAncestorWithClass(startContainer, 'content-component');
|
||||||
if (contentComponent) {
|
if (contentComponent) {
|
||||||
// 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 siblings = Array.from(paragraph.parentElement.children);
|
const siblings = Array.from(paragraph.parentElement?.children || []);
|
||||||
const positionInTextBlock = siblings.indexOf(paragraph);
|
const positionInTextBlock = siblings.indexOf(paragraph);
|
||||||
|
|
||||||
const numOfParagraphs = Array.from(contentComponent.children[1].children).filter(
|
const numOfParagraphs = Array.from(contentComponent.children[1].children).filter(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue