mirror of
https://github.com/SableClient/Sable.git
synced 2026-11-20 09:01:17 -08:00
fix(abbreviations): fix lint, typecheck, and format errors
This commit is contained in:
3 files changed
+14
-5
No files matched your search
@@ -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 (
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user