diff --git a/native/chat/text-message-markdown-context.js b/native/chat/text-message-markdown-context.js --- a/native/chat/text-message-markdown-context.js +++ b/native/chat/text-message-markdown-context.js @@ -17,7 +17,7 @@ const TextMessageMarkdownContext: React.Context = React.createContext(null); -const pressableMarkdownTypes = new Set(['link', 'spoiler']); +const pressableMarkdownTypes = new Set(['link', 'spoiler', 'chatMention']); const markdownASTHasPressable = (node: ASTNode): boolean => { if (Array.isArray(node)) { return node.some(markdownASTHasPressable); diff --git a/native/markdown/rules.react.js b/native/markdown/rules.react.js --- a/native/markdown/rules.react.js +++ b/native/markdown/rules.react.js @@ -6,12 +6,14 @@ import * as SimpleMarkdown from 'simple-markdown'; import * as SharedMarkdown from 'lib/shared/markdown.js'; +import { chatMentionRegex } from 'lib/shared/mention-utils.js'; import type { RelativeMemberInfo, ThreadInfo, ChatMentionCandidates, } from 'lib/types/thread-types.js'; +import MarkdownChatMention from './markdown-chat-mention.react.js'; import MarkdownLink from './markdown-link.react.js'; import MarkdownParagraph from './markdown-paragraph.react.js'; import MarkdownSpoiler from './markdown-spoiler.react.js'; @@ -397,6 +399,25 @@ ), }, + chatMention: { + ...SimpleMarkdown.defaultRules.strong, + match: SimpleMarkdown.inlineRegex(chatMentionRegex), + parse: (capture: SharedMarkdown.Capture) => + SharedMarkdown.parseChatMention(chatMentionCandidates, capture), + // eslint-disable-next-line react/display-name + react: ( + node: SharedMarkdown.SingleASTNode, + output: SharedMarkdown.Output, + state: SharedMarkdown.State, + ) => + node.hasAccessToChat ? ( + + {node.content} + + ) : ( + {node.content} + ), + }, }, }; }