Skip to content

Add support for mentions to the editor #815

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 24 commits into from
Feb 10, 2022
Merged

Add support for mentions to the editor #815

merged 24 commits into from
Feb 10, 2022

Conversation

joedixon
Copy link
Contributor

@joedixon joedixon commented Jan 23, 2022

This PR resolves #271 by adding support for GitHub style mentions to the editor. Typing an @ symbol triggers a dropdown, initially containing all users participating in the thread (thread owner and every user who has replied). When typing more characters, the database of users is queried (using WERE username LIKE 'dries%'). Results are merged with participants, but participants are always prioritised over other users if the filter matches. The dropdown is navigable by both mouse and keyboard.

When a user is mentioned, they are subscribed to the thread and notified by email. They will not be notified again should an existing thread or reply be updated.

A few things to note here:

  • We use a similar regex in three places now (frontend, commonmark extension, and extracting mentioned users to notify by email). The regex isn't exactly the same across all scenarios, but it makes me nervous that we might miss somewhere if we ever need to change it. Open to suggestions for better ways to handle this.
  • I have added two different listeners for when a thread is created and when a reply is created. Both of these essentially do the same thing, but I couldn't think of a nice way to reuse the listener. I may be too close to the code at this point, so again, I'm open to suggestions.
Screen.Recording.2022-01-21.at.09.48.54.mov

Screenshot 2022-01-23 at 20 13 07

Screenshot 2022-01-23 at 20 07 55

Updated to also resolve #663

@joedixon joedixon changed the title Mentions Add support for mentions to the editor Jan 23, 2022
@joedixon joedixon force-pushed the mentions branch 2 times, most recently from c3d9e24 to 2de2255 Compare January 23, 2022 20:54
@joedixon joedixon marked this pull request as ready for review February 2, 2022 08:55
@joedixon joedixon requested a review from driesvints February 2, 2022 08:55
Copy link
Member

@driesvints driesvints left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing work @joedixon 👏

Just a couple of small things. You can squash merge this after they're done.

@joedixon joedixon merged commit 3ac7e6b into main Feb 10, 2022
@joedixon joedixon deleted the mentions branch February 10, 2022 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

WYSIWYG doesn't yet supports multiline codeblocks Mention users
3 participants