title | page_title | description | position | slug |
---|---|---|---|---|
Hyperlink Support |
.NET MAUI RichTextEditor Documentation - Hyperlink Support |
Review the hyperlink support documentation article for Telerik RichTextEditor for .NET MAUI control. |
3 |
richtexteditor-hyperlink-support |
The [.NET MAUI RichTextEditor]({%slug richtexteditor-overview%}) provides built-in support for creating and managing hyperlinks. Through the exposed commands related to hyperlinks, namely ApplyHyperlinkCommand
, RemoveHyperlinkCommand
, and OpenHyperlinkCommand
, users can manipulate the hyperlinks inside the RichTextEditor content.
In addition, RichTextEditorToolbar
exposes predefined toolbar items wired to the hyperlink commands.
RichTextEditorAddHyperlinkToolbarItem
—Opens a popup to enter URL information and executes an action that adds a hyperlink for the current selection.RichTextEditorAddOrEditHyperlinkToolbarItem
—Opens a popup to enter URL information and executes an action that adds or edits a hyperlink for the current selection.RichTextEditorHyperlinkNavigationToolbarItem
—This toolbar item adds or edits hyperlinks depending whether a hyperlink is selected. If a hyperlink is selected, the editor navigates to toolbar sub-items for operations related to a hyperlink. If a hyperlink is not selected, a popup with a dialog is displayed to enter URL information and add a hyperlink for the current selection.
The RichTextEditorHyperlinkNavigationToolbarItem
has the following items:
RichTextEditorEditHyperlinkToolbarItem
—Edits the hyperlink from the current selection.RichTextEditorRemoveHyperlinkToolbarItem
—Removes the hyperlink from the current selection.RichTextEditorOpenHyperlinkToolbarItem
—Navigates to the URL.
The next image shows the RichTextEditorEditHyperlinkToolbarItem
on mobile platforms:
For more details, see the [RichTextEditor Toolbar]({%slug richtexteditor-toolbar%}#predefined-toolbar-items) topic.
You can also take advantage of the following API related to hyperlinks:
GetHyperlinkAsync
method—Asynchronously returns aRichTextHyperlink
under the caret in the editor (ornull
if no hyperlink is present). TheRichTextHyperlink
object contains theUrl
andTitle
of the link.
In case users try to open invalid URLs (for example, the URL is not absolute, the domain does not exist or is incomplete, and so on), the following message is shown by default and indicates that the URL has an error:
You can override the default behavior by handling the RichTextEditor's OpenHyperlinkError
event:
-
OpenHyperlinkError
event—Raised when users try to open invalid URLs in the editor. TheOpenHyperlinkError
event handler receives two parameters:- The
Sender
which is the RichTextEditor control. OpenHyperlinkErrorEventArgs
provides the following properties:Error
—of typeSystem.Exception
, can be used to get the exact error message.Url
—of typestring
, defining the URL of the hyperlink.Handled
—boolean property indicating whether the event is handled.
- The
To change the default error handling behavior:
- Subscribe to the event.
- Set the
Handled
property of the event arguments toTrue
to prevent the default message. - Add a custom implementation.
The following example demonstrates how to use the OpenHyperlinkError
event:
The next snippet shows the event handler which shows a custom message:
For a runnable example with the RichTextEditor Hyperlink Error Handling, see the [SDKBrowser Demo Application]({%slug sdkbrowser-app%}) and go to RichTextEditor > Events.
- [Commands]({%slug richtexteditor-commands%})
- [Configure the RichTextEditor]({%slug richtexteditor-configuration%})
- [Events]({%slug richtexteditor-events%})
- [Working with images]({%slug richtexteditor-images-overview%})