Interface IMentionProvider
Interface for providing mention suggestions and resolving mention markup in thread messages.
Namespace: Unity.AppUI.Core
Assembly: Unity.AppUI.dll
Syntax
public interface IMentionProvider
Remarks
Mentions in raw message content use the format :entityType[displayName].
For example: :user[Jane Doe].
The ConvertToRichText(string) method converts these patterns into rich text for display.
Methods
BindItem(VisualElement, object)
Binds a mention suggestion data object to a visual element for display in the suggestions list.
Declaration
void BindItem(VisualElement item, object mention)
Parameters
| Type | Name | Description |
|---|---|---|
| VisualElement | item | The visual element created by MakeSuggestionItem() to bind data to. |
| object | mention | The mention suggestion data object to display. |
ConvertToRichText(string)
Resolves mention markup in raw message content into rich text for display.
Declaration
string ConvertToRichText(string rawContent)
Parameters
| Type | Name | Description |
|---|---|---|
| string | rawContent | The raw message content potentially containing mention markup. |
Returns
| Type | Description |
|---|---|
| string | The content with mentions resolved to rich text. |
Remarks
The raw content may contain mention patterns like :user[Jane Doe].
Implementations should replace these patterns with appropriate rich text markup
(e.g. <b>@Jane Doe</b>).
Because the output is rendered with enableRichText = true, implementations must
sanitize user-provided text segments (e.g. by wrapping them in <noparse> tags)
to prevent rich text injection.
Encode(object)
Formats a selected mention into the markup string to be inserted into the message content.
Declaration
string Encode(object mention)
Parameters
| Type | Name | Description |
|---|---|---|
| object | mention | The mention to format. |
Returns
| Type | Description |
|---|---|
| string | The formatted mention markup string. |
Remarks
Implementations define the serialization format. For example, a user mention might
produce :user[Jane Doe].
GetDisplayName(object)
Use a mention to the display text for that mention without rich text formatting.
Declaration
string GetDisplayName(object mention)
Parameters
| Type | Name | Description |
|---|---|---|
| object | mention | The mention |
Returns
| Type | Description |
|---|---|
| string | The display name |
GetSuggestions(string)
Returns mention suggestions matching the given query.
Declaration
IList GetSuggestions(string query)
Parameters
| Type | Name | Description |
|---|---|---|
| string | query | The search query typed after the @ character. |
Returns
| Type | Description |
|---|---|
| IList | An list of mention suggestions matching the query. The type of the objects in the list is defined by the implementation. |
MakeSuggestionItem()
Creates a visual element to represent a mention suggestion in the UI.
Declaration
VisualElement MakeSuggestionItem()
Returns
| Type | Description |
|---|---|
| VisualElement | A new instance of a VisualElement configured to display a mention suggestion. |