You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We'd like to achieve a functionality where mentions triggered with a decided-upon prefix (let's say @) through a MentionNode are seriealized to a @{$user-id} format, and other non-mentions (say, someone writing their email) would be backslash escaped to my\@email.com format.
We'd like to send the content of the editor it as a serialized text to our server formatted as:
Hey @{1234567890}! Welcome to the team. Feel free to contact me via my\@email.com if you have any questions.
We're sending the contents of the box to our API by a getTextContent() via a function like:
We were able to get half-way there by using the Node Overriding API with the following MentionNode.tsx:
import{BeautifulMentionNode}from"lexical-beautiful-mentions";exportclassMentionNodeextendsBeautifulMentionNode{staticgetType=()=>"mentions";getTextContent(): string{constdata=super.getData();if(!data)returnsuper.getTextContent();const{ id }=data;if(!id)returnsuper.getTextContent();return`@{${id}}`;}staticclone=(node: MentionNode): MentionNode=>{returnnewMentionNode(node.getTrigger(),node.getValue(),node.getData());};}
This would leave us with:
Hey @{1234567890}! Welcome to the team. Feel free to contact me via [email protected] if you have any questions.
How would you achieve the other half of the functionality (escaping non-mentions)? I've tried overriding the TextNode but that causes problems with triggering the mentions UI and escapes the string during typing.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
We'd like to achieve a functionality where mentions triggered with a decided-upon prefix (let's say
@
) through aMentionNode
are seriealized to a@{$user-id}
format, and other non-mentions (say, someone writing their email) would be backslash escaped tomy\@email.com
format.We'd like to send the content of the editor it as a serialized text to our server formatted as:
We're sending the contents of the box to our API by a
getTextContent()
via a function like:We were able to get half-way there by using the Node Overriding API with the following
MentionNode.tsx
:This would leave us with:
How would you achieve the other half of the functionality (escaping non-mentions)? I've tried overriding the
TextNode
but that causes problems with triggering the mentions UI and escapes the string during typing.Are we on the right track?
Beta Was this translation helpful? Give feedback.
All reactions