mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-09-24 00:51:34 +00:00
Co-authored-by: roomote[bot] <219738659+roomote[bot]@users.noreply.github.com> Co-authored-by: Matt Rubens <mrubens@users.noreply.github.com>
33 lines
767 B
TypeScript
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}</>
|
|
}
|