Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32181055
D9392.1765076104.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D9392.1765076104.diff
View Options
diff --git a/lib/shared/markdown.js b/lib/shared/markdown.js
--- a/lib/shared/markdown.js
+++ b/lib/shared/markdown.js
@@ -232,6 +232,26 @@
return match;
}
+type ParsedUserMention = {
+ +content: string,
+ +userID: string,
+};
+
+function parseUserMentions(
+ membersMap: $ReadOnlyMap<string, string>,
+ capture: Capture,
+): ParsedUserMention {
+ const memberUsername = capture[2];
+ const memberID = membersMap.get(memberUsername.toLowerCase());
+
+ invariant(memberID, 'memberID should be set');
+
+ return {
+ content: capture[0],
+ userID: memberID,
+ };
+}
+
function parseChatMention(
chatMentionCandidates: ChatMentionCandidates,
capture: Capture,
@@ -348,6 +368,7 @@
parseList,
createMemberMapForUserMentions,
matchUserMentions,
+ parseUserMentions,
stripSpoilersFromNotifications,
stripSpoilersFromMarkdownAST,
parseChatMention,
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
@@ -387,9 +387,8 @@
userMention: {
...SimpleMarkdown.defaultRules.strong,
match: SharedMarkdown.matchUserMentions(membersMap),
- parse: (capture: SharedMarkdown.Capture) => ({
- content: capture[0],
- }),
+ parse: (capture: SharedMarkdown.Capture) =>
+ SharedMarkdown.parseUserMentions(membersMap, capture),
// eslint-disable-next-line react/display-name
react: (
node: SharedMarkdown.SingleASTNode,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Dec 7, 2:55 AM (15 h, 54 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5842199
Default Alt Text
D9392.1765076104.diff (1 KB)
Attached To
Mode
D9392: [lib/native] introduce parseUserMentions function
Attached
Detach File
Event Timeline
Log In to Comment