mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-26 04:58:53 +08:00
This change validates mentions for `users` and `groups` when using the rich text editor. When the mention is valid (ie. the user or group exists) it will visually show as a mention node, but when the user or group does not exist then it will appear as regular text in the editor. There are 2 parts to this: ### Existing drafts / toggling from Markdown to Rich Text We automatically add mention nodes for all `@mentions` and then process any invalid mentions by removing the mention node and replacing it with text. ### When manually typing in Rich Text We find the mention within the text and then if valid we replace it with a mention node. ### Validation The validation happens in a single request when loading a draft or switching from Markdown to Rich Text. The response provides a list of valid usernames and groups. It also provides additional context for groups and users that are not reachable (ie. unmentionable groups or suspended users etc) but we don't use this currently. We then store the valid and invalid mentions to prevent unnecessary requests later. As new mentions are typed then they will also be validated using the same request as above (if they are not already stored in our valid / invalid sets). |
||
|---|---|---|
| .. | ||
| category_templates_spec.rb | ||
| default_to_subcategory_spec.rb | ||
| discard_draft_spec.rb | ||
| dont_feed_the_trolls_popup_spec.rb | ||
| post_validation_spec.rb | ||
| prosemirror_editor_spec.rb | ||
| review_media_unless_trust_level_spec.rb | ||
| template_validation_spec.rb | ||