fix(abbreviations): fix lint, typecheck, and format errors

This commit is contained in:
Evie Gauthier committed 2026-03-25 12:49:18 -04:00
1 parent 18a7ca092b
commit bf9deae8a1
3 files changed
+14 -5

No files matched your search

+3 -3
View File
@@ -1,4 +1,4 @@
import { MouseEventHandler, ReactNode, useEffect, useState } from 'react';
import { MouseEventHandler, useEffect, useState } from 'react';
import parse, { HTMLReactParserOptions } from 'html-react-parser';
import Linkify from 'linkify-react';
import { Opts } from 'linkifyjs';
@@ -66,9 +66,9 @@ function AbbreviationTerm({ text, definition }: AbbreviationTermProps) {
*/
export function buildAbbrReplaceTextNode(
abbrMap: Map<string, string>
): ((text: string) => ReactNode | undefined) | undefined {
): ((text: string) => JSX.Element | undefined) | undefined {
if (abbrMap.size === 0) return undefined;
return (text: string) => {
return function replaceTextNode(text: string) {
const segments = splitByAbbreviations(text, abbrMap);
if (!segments.some((s) => s.termKey !== undefined)) return undefined;
return (
+10 -1
View File
@@ -408,7 +408,16 @@ export function ThreadDrawer({ room, threadRootId, onClose, overlay }: ThreadDra
nicknames,
replaceTextNode: buildAbbrReplaceTextNode(abbrMap),
}),
[mx, room, linkifyOpts, spoilerClickHandler, mentionClickHandler, useAuthentication, nicknames, abbrMap]
[
mx,
room,
linkifyOpts,
spoilerClickHandler,
mentionClickHandler,
useAuthentication,
nicknames,
abbrMap,
]
);
// Power levels & permissions
+1 -1
View File
@@ -351,7 +351,7 @@ export const getReactCustomHtmlParser = (
useAuthentication?: boolean;
nicknames?: Nicknames;
autoplayEmojis?: boolean;
replaceTextNode?: (text: string) => ReactNode | undefined;
replaceTextNode?: (text: string) => JSX.Element | undefined;
}
): HTMLReactParserOptions => {
const { replaceTextNode } = params;