Skip to content

Get List of Mentions (Mentioned People) #5395

Closed Answered by MBatCD
MBatCD asked this question in Q&A
Discussion options

You must be logged in to vote

Finally came up with a solution for this a few months ago using lodash to assist with generating an unique list of all the people mentioned in a "comment" from a SlateJS editor.

/**
 * Routine to recursively traverse a SlateJS JSON structure to find any nodes with the type === "mention".
 * As this is difficult to accomplish reliably, this function uses lodash to find all JSON nodes where
 * type === "mention", and then performs a flattenDeep operation to give us an array of people mentioned
 * in the SlateJS structure.
 * @param tree The JSON structure to parse. NOTE: the "content" node of a SlateJS JSON structure must be the root node.
 * @returns Array of objects representing the menti…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by MBatCD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant