MentionText
Since 0.1.0-alpha.24Text written in a Mentions<T> field, shown with each mention marked, or linked with Href. Its lines are kept.
Mentions in a comment
Set Text to the saved text: each mention is marked, and Href links it to a profile; here the link opens it under the comment. Its lines are kept.
Static
Preview
Code
@* A posted comment's text with its mentions linked; a link opens that person's profile under it. *@
NavigationManager Navigation
<Stack Gap="4" Grow>
<Comment Author="Aisha Bello" Time="_posted" RelativeTime>
<MentionText Text="_text" Href="ProfileOf" />
</Comment>
if (Profile is not null && Team.TryGetValue(Profile, out var person))
{
<Card MaxWidth="20.Rem">
<Row Gap="3" Align="Align.Center">
<Avatar Name="person.Name" Decorative />
<Stack Gap="0">
<TextBlock Weight="FontWeight.Medium">person.Name</TextBlock>
<TextBlock Size="TextSize.Sm" Color="Color.Muted">person.Role</TextBlock>
</Stack>
</Row>
</Card>
}
</Stack>
{
[SupplyParameterFromQuery(Name = "profile")] private string? Profile { get; set; }
private readonly DateTimeOffset _posted = DateTimeOffset.UtcNow.AddHours(-3);
private readonly string _text = """
The revised quote is in. @daniel.kim can you check it against the budget?
@mei.chen the install dates moved to the 14th.
""";
// An app links to its profile page, such as $"/people/{m.Text}".
private string ProfileOf(Mention m) => Navigation.GetUriWithQueryParameter("profile", m.Text) + "#ex-mention-text-usage";
}Add this example to a page with the izzy CLI:
izzy add component MentionText --at <file>:<line>Prefixes sets the triggers to find, as on the Mentions field that wrote the text. Mention.Parse finds the same names in C#, to notify the people mentioned.
Details
Mentions are found as Parse finds them.
Mode support
| Feature | Static | Interactive |
|---|---|---|
| Everything | Yes | Yes |
Static: static server-side rendering, with no circuit and no WebAssembly. Interactive: Server, WebAssembly or Auto.
Accessibility
- A mention without a link is text in a different color and weight, read as part of the sentence.
- With
Href, each mention is a link named by its text, such as "@ana".
Parameters
Plus 17 item props and 4 common props.
Full APISee also
- Mentions: suggests people or tags as the user types @ or # in a text area, and writes the chosen name into the text.
- Comment: shows a comment in a discussion, with who wrote it, when, and replies nested under it.
Aisha Bello
·