The `@token` being typed at the cursor, if any.
(value: string, cursor: number)
| 39 | |
| 40 | /** The `@token` being typed at the cursor, if any. */ |
| 41 | function findAtToken(value: string, cursor: number): { query: string; start: number } | null { |
| 42 | const before = value.slice(0, cursor) |
| 43 | const match = /(?:^|\s)@([^\s@]*)$/.exec(before) |
| 44 | if (!match) return null |
| 45 | return { query: match[1], start: cursor - match[1].length - 1 } |
| 46 | } |
| 47 | |
| 48 | export function InputBox({ active, slashCommands, onSubmit }: InputBoxProps) { |
| 49 | const [value, setValue] = useState("") |