Roo-Code/webview-ui/src/components/chat/Mention.tsx
Bruno Bergher fff5cf804f
ux: Improvements to to-do lists and task headers (#9096)
Co-authored-by: roomote[bot] <219738659+roomote[bot]@users.noreply.github.com>
Co-authored-by: Matt Rubens <mrubens@users.noreply.github.com>
2025-11-07 17:26:20 -05:00

33 lines
767 B
TypeScript

import { mentionRegexGlobal } from "@roo/context-mentions"
import { vscode } from "../../utils/vscode"
interface MentionProps {
text?: string
withShadow?: boolean
}
export const Mention = ({ text, withShadow = false }: MentionProps) => {
if (!text) {
return <>{text}</>
}
const parts = text.split(mentionRegexGlobal).map((part, index) => {
if (index % 2 === 0) {
// This is regular text.
return part
} else {
// This is a mention.
return (
<span
key={index}
className={`${withShadow ? "mention-context-highlight-with-shadow" : "mention-context-highlight"} text-[0.9em] cursor-pointer`}
onClick={() => vscode.postMessage({ type: "openMention", text: part })}>
@{part}
</span>
)
}
})
return <>{parts}</>
}