Selection service
Inspect, select or clear the current text range. Read selected text separately from selected HTML when your application needs literal values.
The facade is available as editor.Selection; its interface can be replaced by an application implementation.

Use it in your application
Indices are UTF-16 units in the active view. Keep a selection and its document ownership together across awaited work instead of reusing a stale range.
All examples assume an editor named editor, already attached to a visible window, and an awaited editor.Ready. Keep operations asynchronous instead of blocking the UI thread.
string text = await editor.Selection.GetSelectedTextAsync();
string selectedHtml = await editor.Selection.GetSelectedHtmlAsync();Members
These signatures come from the delivered 1.0.2 assemblies and XML documentation. Cancellation tokens can be supplied to awaited operations. Follow the source-specific notes above when adapting a WPF integration.
| Member | Signature |
|---|---|
DeselectAllAsync | Task DeselectAllAsync(CancellationToken cancellationToken) |
GetSelectedHtmlAsync | Task<string> GetSelectedHtmlAsync(CancellationToken cancellationToken) |
GetSelectedTextAsync | Task<string> GetSelectedTextAsync(CancellationToken cancellationToken) |
GetSelectionInfoAsync | Task<SelectionInfo> GetSelectionInfoAsync(CancellationToken cancellationToken) |
GetSelectionLengthAsync | Task<int> GetSelectionLengthAsync(CancellationToken cancellationToken) |
SelectAllAsync | Task SelectAllAsync(CancellationToken cancellationToken) |
SelectTextAsync | Task SelectTextAsync(int startIndex, int length, CancellationToken cancellationToken) |
SelectTextAsync | Task SelectTextAsync(int startIndex, CancellationToken cancellationToken) |
TrimSelectionAsync | Task<string> TrimSelectionAsync(TrimDirections trimDirection, CancellationToken cancellationToken) |
UnselectAsync | Task UnselectAsync(CancellationToken cancellationToken) |