diff --git a/apps/meteor/app/emoji/client/emojiParser.js b/apps/meteor/app/emoji/client/emojiParser.js index 7b887bb0575f..0b3b722aaebd 100644 --- a/apps/meteor/app/emoji/client/emojiParser.js +++ b/apps/meteor/app/emoji/client/emojiParser.js @@ -1,17 +1,13 @@ import { isIE11 } from '../../../client/lib/utils/isIE11'; import { emoji } from './lib'; -/* +/** * emojiParser is a function that will replace emojis - * @param {Object} message - The message object + * @param {{ html: string }} message - The message object + * @return {{ html: string }} */ - -const emojiParser = (message) => { - if (!message.html?.trim()) { - return message; - } - - let html = message.html.trim(); +export const emojiParser = ({ html }) => { + html = html.trim(); // ' to apostrophe (') for emojis such as :') html = html.replace(/'/g, "'"); @@ -64,7 +60,5 @@ const emojiParser = (message) => { // line breaks '
' back to '
' html = html.replace(/
/g, '
'); - return { ...message, html }; + return { html }; }; - -export { emojiParser }; diff --git a/apps/meteor/app/markdown/lib/markdown.js b/apps/meteor/app/markdown/lib/markdown.js index 3c3acdb17893..c7fe452e0829 100644 --- a/apps/meteor/app/markdown/lib/markdown.js +++ b/apps/meteor/app/markdown/lib/markdown.js @@ -69,6 +69,7 @@ class MarkdownClass { return code(...args); } + /** @param {string} message */ filterMarkdownFromMessage(message) { return parsers.filtered(message); } @@ -76,6 +77,7 @@ class MarkdownClass { export const Markdown = new MarkdownClass(); +/** @param {string} message */ export const filterMarkdown = (message) => Markdown.filterMarkdownFromMessage(message); export const createMarkdownMessageRenderer = ({ ...options }) => { diff --git a/apps/meteor/app/markdown/lib/parser/filtered/filtered.js b/apps/meteor/app/markdown/lib/parser/filtered/filtered.js index ac53144d6d1b..260fc835d8a0 100644 --- a/apps/meteor/app/markdown/lib/parser/filtered/filtered.js +++ b/apps/meteor/app/markdown/lib/parser/filtered/filtered.js @@ -1,6 +1,7 @@ -/* +/** * Filter markdown tags in message - * Use case: notifications + * Use case: notifications + * @param {string} message */ export const filtered = ( message, diff --git a/apps/meteor/client/lib/utils/renderMessageEmoji.ts b/apps/meteor/client/lib/utils/renderMessageEmoji.ts index 20986c803ab8..7960ec1914e5 100644 --- a/apps/meteor/client/lib/utils/renderMessageEmoji.ts +++ b/apps/meteor/client/lib/utils/renderMessageEmoji.ts @@ -1,5 +1,3 @@ -import type { IMessage } from '@rocket.chat/core-typings'; +import { emojiParser } from '../../../app/emoji/client/emojiParser'; -import { emojiParser } from '../../../app/emoji/client/emojiParser.js'; - -export const renderMessageEmoji = & { html?: string }>(message: T): string => emojiParser(message)?.html; +export const renderMessageEmoji = ({ html }: { html: string }): string => emojiParser({ html }).html; diff --git a/apps/meteor/client/views/room/contextualBar/Threads/components/ThreadTitle.tsx b/apps/meteor/client/views/room/contextualBar/Threads/components/ThreadTitle.tsx index 6440a5e726a1..ada559d7af7d 100644 --- a/apps/meteor/client/views/room/contextualBar/Threads/components/ThreadTitle.tsx +++ b/apps/meteor/client/views/room/contextualBar/Threads/components/ThreadTitle.tsx @@ -9,7 +9,7 @@ type ThreadTitleProps = { }; const ThreadTitle = ({ mainMessage }: ThreadTitleProps) => { - const innerHTML = useMemo(() => ({ __html: normalizeThreadTitle(mainMessage) }), [mainMessage]); + const innerHTML = useMemo(() => ({ __html: normalizeThreadTitle(mainMessage) ?? '' }), [mainMessage]); return ; };