Skip to content

Commit

Permalink
fix strict null error
Browse files Browse the repository at this point in the history
  • Loading branch information
Alun Turner committed May 12, 2023
1 parent ba1c47f commit cbfe5de
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ limitations under the License.
import { Attributes, MappedSuggestion } from "@matrix-org/matrix-wysiwyg";
import { SyntheticEvent, useState } from "react";

import { isNotUndefined } from "../../../../../Typeguards";
import { isNotNull, isNotUndefined } from "../../../../../Typeguards";

/**
* Information about the current state of the `useSuggestion` hook.
Expand Down Expand Up @@ -171,10 +171,12 @@ export function processMention(

// now add the leading text node, link element and trailing text node before removing the node we are replacing
const parentNode = node.parentNode;
parentNode.insertBefore(leadingTextNode, node);
parentNode.insertBefore(linkElement, node);
parentNode.insertBefore(trailingTextNode, node);
parentNode.removeChild(node);
if (isNotNull(parentNode)) {
parentNode.insertBefore(leadingTextNode, node);
parentNode.insertBefore(linkElement, node);
parentNode.insertBefore(trailingTextNode, node);
parentNode.removeChild(node);
}

// move the selection to the trailing text node
document.getSelection()?.setBaseAndExtent(trailingTextNode, 1, trailingTextNode, 1);
Expand Down

0 comments on commit cbfe5de

Please sign in to comment.