# `PhiaUi.Components.Collab.MentionHelpers`
[🔗](https://github.com/charlenopires/PhiaUI/blob/v0.1.17/lib/phia_ui/components/collab/mention_helpers.ex#L1)

Helper functions for @mention parsing and rendering.

Mentions follow the format `@[Display Name](user_id)` in raw text.
This module provides utilities to parse, render, and extract user IDs
from mention markup.

# `mentioned_user_ids`

```elixir
@spec mentioned_user_ids(String.t() | nil) :: [String.t()]
```

Extract unique user IDs mentioned in text.

## Examples

    iex> mentioned_user_ids("Hey @[Alice](u1) and @[Bob](u2) and @[Alice](u1)")
    ["u1", "u2"]

    iex> mentioned_user_ids("No mentions")
    []

    iex> mentioned_user_ids(nil)
    []

# `parse_mentions`

```elixir
@spec parse_mentions(String.t() | nil) :: [map()]
```

Parse mentions from text.

Returns a list of maps with `:start`, `:end`, `:user_id`, and `:name` keys.

Mention format: `@[Display Name](user_id)`

## Examples

    iex> parse_mentions("Hello @[Alice](user-1) and @[Bob](user-2)")
    [
      %{start: 6, end: 26, user_id: "user-1", name: "Alice"},
      %{start: 31, end: 49, user_id: "user-2", name: "Bob"}
    ]

    iex> parse_mentions("No mentions here")
    []

    iex> parse_mentions(nil)
    []

# `render_mentions`

```elixir
@spec render_mentions(String.t(), map()) :: String.t()
```

Replace mention markup with display names prefixed by @.

Transforms `@[Display Name](user_id)` into `@Display Name`.

## Examples

    iex> render_mentions("Hello @[Alice](user-1)!")
    "Hello @Alice!"

    iex> render_mentions("No mentions")
    "No mentions"

---

*Consult [api-reference.md](api-reference.md) for complete listing*
