In this episode, we're bringing everything together by adding the ability to edit comments, including the functionality to add or remove user mentions (using the @ syntax). We'll start by building an edit button on each comment. When clicked, it switches the comment into an "edit mode" with a text area pre-populated with the comment's content – just like when you create a new comment.
From here, you can freely edit the comment text, add new mentions, or remove existing ones. We'll make sure that whenever you enter edit mode, the text area is always up-to-date with the latest comment content.
Once you make your changes and submit, we handle the validation and update the comment in the database. It also takes care of keeping mentions in sync, so if you remove or add @-mentions in your edit, the database reflects this exactly.
Finally, we'll hook up the actual @-mention functionality in the edit form, making it just as smooth as when originally creating a comment. So now, not only can you mention people in new comments, but you can also go back and edit mentions on any existing comment. All the mention magic, now with full editing support!