Improve typing

This commit is contained in:
nexy7574 2024-12-28 20:51:02 +00:00
parent fee4065486
commit a51538dd81

View file

@ -301,13 +301,15 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
} }
let mentionsRoom = false; let mentionsRoom = false;
editor.children.forEach((node: Descendant): void => { editor.children.forEach((node: Descendant): void => {
if(node.type !== "paragraph") return; if(node.type === undefined || node.type !== "paragraph") return;
(node as ParagraphElement).children?.forEach((child: InlineElement): void => { const paragraph: ParagraphElement = node as ParagraphElement;
paragraph.children?.forEach((child: InlineElement): void => {
if (child.type === "mention") { if (child.type === "mention") {
if(child.name === "@room" && !child.id.startsWith("@")) { const mention: MentionElement = child as MentionElement;
if (mention.name === "@room" && !mention.id.startsWith("@")) {
mentionsRoom = true mentionsRoom = true
} else { } else {
userIdMentions.add(child.id) userIdMentions.add(mention.id)
} }
} }
}) })