Fix some typing issues

This commit is contained in:
Ramon Wenger 2024-01-08 22:31:21 +01:00
parent 99ce0ab84d
commit 4584cb860e
2 changed files with 3 additions and 3 deletions

View File

@ -269,7 +269,7 @@ onUnmounted(() => {
if (element !== null) {
console.log('unmounting');
element.removeEventListener('mouseup', getSelectionHandler);
element.removeEventListener('mouseup', getSelectionHandler(element, props.contentBlock));
}
});

View File

@ -102,13 +102,13 @@ export const getSelectionHandler = (el: HTMLElement, contentBlock: ContentBlockN
const paragraph = findClosestAncestorWithTag(startContainer, 'p');
const endAncestor = findClosestAncestorWithTag(endContainer, 'p');
if (paragraph === endAncestor) {
if (paragraph && paragraph === endAncestor) {
// todo: rename this variable, `parent` is not correct anymore
const contentComponent = findClosestAncestorWithClass(startContainer, 'content-component');
if (contentComponent) {
// our selection is wholly inside the container node, we continue with it
const position = findPositionInParent(contentComponent);
const siblings = Array.from(paragraph.parentElement.children);
const siblings = Array.from(paragraph.parentElement?.children || []);
const positionInTextBlock = siblings.indexOf(paragraph);
const numOfParagraphs = Array.from(contentComponent.children[1].children).filter(