fix(markups): render wrapped user mentions as plain text#1139
fix(markups): render wrapped user mentions as plain text#1139Shreyas2004wagh wants to merge 1 commit intoRocketChat:developfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the @embeddedchat/markups rendering layer to match Rocket.Chat core behavior by displaying wrapped user mentions like (@user) as plain text (no mention styling), while keeping normal mentions like @user styled as mentions.
Changes:
- Add a render-time rule in
InlineElementsto treatMENTION_USERtokens surrounded by(and)(with optional whitespace) as plain text. - Add unit tests covering wrapped vs. normal mention rendering behavior.
- Add Jest/Babel test configuration and a
testscript for the@embeddedchat/markupsworkspace package.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/markups/src/elements/InlineElements.js | Detects (@user)-style wrapped mentions and renders them using PlainSpan instead of UserMention. |
| packages/markups/src/elements/InlineElements.test.js | Adds tests ensuring wrapped mentions render as plain text and unwrapped mentions remain styled. |
| packages/markups/jest.config.js | Introduces a Jest config for the markups package (Node environment + babel-jest transform). |
| packages/markups/babel.config.js | Adds a test-only Babel config adjustment for Jest runs. |
| packages/markups/package.json | Adds a test script to run Jest in the workspace. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| env: { | ||
| test: { | ||
| presets: [ | ||
| [ | ||
| '@babel/preset-env', | ||
| { | ||
| modules: 'commonjs', | ||
| }, | ||
| ], | ||
| ], | ||
| }, | ||
| }, |
There was a problem hiding this comment.
env.test.presets adds a second @babel/preset-env on top of the top-level presets, so preset-env will run twice with different modules settings. To keep test/build transforms simpler and more predictable, consider conditionally configuring the existing preset-env (e.g., function export + api.env('test')) or using @babel/plugin-transform-modules-commonjs for tests instead of introducing a second preset-env.
Fixes #1136
Summary
This PR aligns EmbeddedChat mention rendering with Rocket.Chat core for wrapped mentions.
When the parser emits
MENTION_USERtokens for values like(@user), EmbeddedChat currently renders them with mention styling. Rocket.Chat core renders the same pattern as plain text. This change keeps parser behavior unchanged and applies a conservative render-time rule so wrapped mentions are displayed as plain text.This preserves deterministic behavior and avoids parser-side risk.
Acceptance Criteria fulfillment
(@user)) are rendered as plain text@user) continue to render as mentionsPR Test Details
Notes
I've validated this behavior locally; this PR applies the same render-scoped approach to ensure compatibility with Rocket.Chat core.