Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

💄 style(channel): show composer mentions as highlighted text, not a tag (#22846)

Arvin Xu7d966a6a7760
diff --git a/src/features/Channels/Composer.tsx b/src/features/Channels/Composer.tsx
index 49708591e2c..1775301bc44 100644
--- a/src/features/Channels/Composer.tsx
+++ b/src/features/Channels/Composer.tsx
@@ -76,7 +76,11 @@ type ComposerDelivery =
onSend: ChannelComposerSend;
};
-const plugins = [ReactCodePlugin, ReactListPlugin, ReactLinkHighlightPlugin, ReactMentionPlugin];
+const plugins = [ReactCodePlugin, ReactListPlugin, ReactLinkHighlightPlugin];
+
+/** Highlighted text like the rest of the line, not the editor's default boxed tag. */
+const mentionTheme = { mention: stylex.props(styles.composerMention).className };
+const writeMention = (node: { label: string }) => `@${node.label}`;
/** Keeps ChatInput's raised card (elevated background, border, soft shadow) from the chat page. */
const inputShell = { borderRadius: 12 };
@@ -347,7 +351,7 @@ export function Composer({
]
: options;
},
- markdownWriter: (node) => `@${node.label}`,
+ markdownWriter: writeMention,
onSelect: (instance, option) => {
instance.dispatchCommand(INSERT_MENTION_COMMAND, {
label: String(option.label),
@@ -385,7 +389,11 @@ export function Composer({
void send();
return true;
}}
- />
+ >
+ {/* <Editor> registers its own mention plugin after `plugins`, and a later
+ registration replaces the config; a child registers last, so this theme wins. */}
+ <ReactMentionPlugin markdownWriter={writeMention} theme={mentionTheme} />
+ </Editor>
</div>
{/* Replies run asynchronously, so Send never turns into Stop; each reply stops from the activity line. */}
{/* Enter sends; like an IM, the button only appears once there is something to send. */}
diff --git a/src/features/Channels/styles.ts b/src/features/Channels/styles.ts
index 05a3cc4f2b4..f0c3fd86a43 100644
--- a/src/features/Channels/styles.ts
+++ b/src/features/Channels/styles.ts
@@ -196,6 +196,15 @@ export const styles = stylex.create({
color: cssVar.colorInfo,
backgroundColor: cssVar.colorInfoBg,
},
+ /** A mention inside the composer: highlighted text, no tag; tinted like selected text while selected. */
+ composerMention: {
+ userSelect: 'none',
+ fontWeight: 500,
+ color: cssVar.colorInfo,
+ // `.selected` is added by the editor's selection observer, not by React.
+ borderRadius: { 'default': null, ':is(.selected)': cssVar.borderRadiusXS },
+ backgroundColor: { 'default': null, ':is(.selected)': cssVar.colorInfoBgHover },
+ },
composer: {
'position': 'relative',
'flexShrink': 0,