pub struct EditorHandle { /* private fields */ }Expand description
A clone-able, 'static handle to a RichTextEditor’s shared
state.
Use this when a toolbar, palette, command panel, or other external
widget needs to invoke editor commands from on_activate_fn /
ctx.effect closures that outlive the borrow of &editor.
RichTextEditor itself is move-only (the optional
custom_context_menu factory holds a Box<dyn Fn>, which prevents
Clone), so a closure cannot just capture editor.clone().
Obtain a handle via RichTextEditor::handle() and clone it into
each closure that needs to issue commands.
EditorHandle mirrors the toolbar-relevant subset of the editor’s
public API:
- Inline character formatting —
set_bold/toggle_bold/is_boldand the italic / underline / strikethrough variants. - Block-level formatting —
set_alignment,set_heading_level,apply_block_format,insert_list,indent/outdent. - Tables —
insert_tableand the per-row / per-column / remove operations, plusis_in_tablefor contextual UI enable state. - History —
undo/redo. - Clipboard —
copy/cut/paste/paste_unformatted, pluscan_pastefor Paste enable-state — so a context-menu factory (which can only capture a handle, never the editor that owns it) can rebuild Cut / Copy / Paste / Paste-Unformatted. - Selection —
select_all/delete_selection. - Reactive signal accessors —
format_version,cursor_position_signal,cursor_anchor_signal,has_selection,can_undo/can_redo— so callers that hold only anEditorHandlecan derive bound signals without keeping a separateRichTextEditorreference.
Cloning is cheap (an Rc clone). All clones share the same
underlying state — mutations through any clone, through other
clones, or through the originating RichTextEditor are all
immediately observable through the same signals.
Implementations§
Source§impl EditorHandle
impl EditorHandle
Sourcepub fn to_djot(&self) -> String
pub fn to_djot(&self) -> String
This editor’s content as Djot.
The counterpart to insert_djot: a toolbar or command that can
write into an editor it did not build should be able to read it back the same way.
Without this the only route to the text is the host’s own document bookkeeping,
which knows about the editors it mounted and not about the ones a list or a card
grid created — so a command ends up working on some surfaces and silently doing
nothing on others.
Empty string on a serialisation error, matching TextDocument::to_djot’s own
callers: a command reading an editor has no better answer than “nothing there”, and
propagating a Result here would push that decision onto every call site.
Sourcepub fn to_plain_text(&self) -> String
pub fn to_plain_text(&self) -> String
This editor’s content as the addressable plain text — the view whose character offsets are the document’s own.
The counterpart to to_djot for a caller that has an
offset (a caret, a selection, a click) and needs to know what is there.
An inline image appears as its U+FFFC, so offsets into this string are
offsets into the document, character for character — which the .txt
export’s view deliberately is not.
Empty string on error, for the same reason to_djot returns one.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Whether this editor holds no text at all.
character_count() == 0, so a document of one empty paragraph is empty but one
holding only spaces is not — the distinction a caller usually wants is
to_djot().trim().is_empty(), and this is the cheap O(1) pre-check.
Sourcepub fn focused_signal(&self) -> Signal<bool>
pub fn focused_signal(&self) -> Signal<bool>
Reactive signal — true while this editor holds keyboard focus.
See RichTextEditor::focused_signal.
Sourcepub fn select_range(&self, start: usize, end: usize)
pub fn select_range(&self, start: usize, end: usize)
Select the character range [start, end) without collapsing (anchor at
start, caret at end). See RichTextEditor::select_range.
Sourcepub fn replace_range(&self, start: usize, end: usize, text: &str)
pub fn replace_range(&self, start: usize, end: usize, text: &str)
Replace the character range [start, end) with text, leaving the caret
after the inserted text.
The counterpart to select_range for callers that
must rewrite a span rather than merely reveal it — a spell-check
correction picked from a context menu, an autocorrect, a
replace-this-occurrence action. It goes through the widget’s internal
cursor, so the edit behaves exactly like typed text: it lands on the
editor’s undo stack as one entry (the replacement is a single
insert-over-selection), fires the document’s change notifications, and
leaves the caret where the user would expect it.
Offsets are character positions, the same space
cursor_position and select_range use. The
inserted text inherits the character format at start, so correcting a
word inside italic prose stays italic.
Reaching through TextDocument::cursor
instead would mutate the document behind the widget’s back, leaving the
caret decoupled from the edit — use this.
Sourcepub fn replace_range_from(
&self,
start: usize,
end: usize,
text: &str,
source: EditSource,
)
pub fn replace_range_from( &self, start: usize, end: usize, text: &str, source: EditSource, )
As replace_range, saying which channel the text
came through for on_text_inserted.
replace_range itself reports EditSource::Programmatic, which is
what a handle-driven edit is by default: a toolbar, a menu command, a
substitution the application made. An application that knows better
should say so here rather than let the default stand. The distinction
that matters most is an edit which merely puts back what the person
typed — undoing an autocorrect, say. Those characters were typed, they
are being typed again, and reporting them as the application’s own work
would credit the application with the writer’s words.
One call rather than an insert plus a separate report, so the two cannot drift apart at a call site that later grows a second early return.
Sourcepub fn insert_text(&self, text: &str)
pub fn insert_text(&self, text: &str)
Insert plain text at the caret, replacing any selection. The
EditorHandle counterpart of
RichTextEditor::insert_text, for callers
that hold only a handle — a toolbar button or a global menu command.
Sourcepub fn add_image_resource(
&self,
name: &str,
mime_type: &str,
bytes: &[u8],
) -> bool
pub fn add_image_resource( &self, name: &str, mime_type: &str, bytes: &[u8], ) -> bool
Register an image’s bytes on this editor’s document, under name.
An inline image stores only a name; the paint pass resolves it to pixels through the document’s resource table. So an image inserted without this lays out and stays blank — and the name is also what a reload resolves against, which is why a host restoring a document has to register its images before the first paint rather than at insertion time only.
On the handle rather than only on the widget because commands operate on whichever editor has focus, including ones a list or card grid built that the host never mounted itself.
Sourcepub fn image_resource_size(&self, name: &str) -> Option<(u32, u32)>
pub fn image_resource_size(&self, name: &str) -> Option<(u32, u32)>
The natural pixel size of a registered image, decoded from its bytes.
What the file actually is, not what the document asks it to be shown at — so a host offering “reset to the original size” restores the picture’s own dimensions rather than a number remembered from when it was inserted, which is wrong the moment the file behind the name is replaced.
Decodes on call. That is deliberate: this answers an explicit, rare request, and caching it would mean holding a second copy of every image in the document for a question almost nobody asks.
Sourcepub fn has_image_resource(&self, name: &str) -> bool
pub fn has_image_resource(&self, name: &str) -> bool
Whether this editor’s document already has an image under name.
Registering the same name twice appends a second resource row, so a host re-registering on every paint would grow the document without bound.
Sourcepub fn insert_djot(&self, djot: &str)
pub fn insert_djot(&self, djot: &str)
Insert a fragment parsed from djot at the caret, replacing any selection.
Unlike insert_text, which drops its bytes into the
current block verbatim (a \n becomes literal content, not a new
paragraph), this parses block-level djot into a DocumentFragment, so
inserting a standalone paragraph really does create one.
Sourcepub fn insert_block(&self)
pub fn insert_block(&self)
Split the current block at the caret, as pressing Enter does.
Sourcepub fn insert_paragraph(&self, text: &str) -> bool
pub fn insert_paragraph(&self, text: &str) -> bool
Insert text as a paragraph of its own at the caret: split here, fill
the new block, split again, so whatever followed the caret continues in a
third block.
Deliberately one call rather than three. Composing
insert_block + insert_text + insert_block from outside re-enters the
widget three times, and an application that rebuilds its editor in
response to the first change notification is left driving a handle that
no longer points at the mounted widget — the split lands and the text
silently does not. Doing the whole edit under a single borrow, with one
signal sync at the end, makes it atomic from the caller’s side.
Returns false if any step failed, leaving the document as far as it
got. Steps are not attempted after a failure: filling and re-splitting
on top of a split that did not happen produces a mangled paragraph rather
than a partial one, and the caller has no way to tell.
Sourcepub fn selection(&self) -> (usize, usize)
pub fn selection(&self) -> (usize, usize)
The live selection as (anchor, position), unordered — anchor is where the
selection started, position is where the caret is, so a backwards drag
reports anchor > position. Equal values mean no selection.
Both ends are read under a single borrow, so the pair cannot tear. That is
the reason to prefer this over pairing cursor_position
with cursor_anchor_signal: the former is a live
read of the cursor while the latter is a mirror refreshed on sync, so combining
them mixes two different moments in time and can invent — or miss — a selection
if the mirror lags. A caller deciding “is there a selection, and over what”
wants one consistent answer.
Sourcepub fn selected_text(&self) -> String
pub fn selected_text(&self) -> String
The selected text, or an empty string when nothing is selected.
O(selection), not O(document). Pairs with selection
for a caller that needs the range and what is in it — a link dialog
pre-filling its display name from what the writer highlighted, say.
Sourcepub fn range_rect(&self, start: usize, end: usize) -> Option<Rect>
pub fn range_rect(&self, start: usize, end: usize) -> Option<Rect>
The window-space rectangle enclosing the character range [start, end).
The inverse of offset_at_point: that maps a point
to an offset, this maps offsets back to a point. It is what a decoration
drawn outside the editor — a margin annotation, a connector leader, a
bracket spanning a paragraph — needs in order to line itself up with the
text it refers to.
Coordinates match what the arena stores (viewport_origin + engine-local −
scroll), so the result can be compared with any other widget’s bounds
directly, and it tracks scrolling for free.
None before the first full layout. Focus is not required — a margin
annotation must stay aligned whether or not the writer is typing.
Sourcepub fn offset_rect(&self, offset: usize) -> Option<Rect>
pub fn offset_rect(&self, offset: usize) -> Option<Rect>
The window-space caret rectangle at one offset — a zero-width
range_rect, and the anchor point for a marker drawn at
one end of a span (the triangle at a comment’s tail).
Sourcepub fn range_content_rect(&self, start: usize, end: usize) -> Option<Rect>
pub fn range_content_rect(&self, start: usize, end: usize) -> Option<Rect>
The content-space rectangle enclosing [start, end) — y = 0 at the top
of the laid-out text, unaffected by scrolling and by where the editor sits
in the window.
The scroll-free counterpart to range_rect, and the one
to reach for when the question is what proportion of the document is this
rather than where is this on screen. Divided by
content_height it gives a fraction an overview
strip can draw against, for offsets the writer has long scrolled past —
which window space cannot express at all, since it reports those relative to
a viewport they are nowhere near.
None before the first full layout. Focus is not required.
Sourcepub fn offset_content_rect(&self, offset: usize) -> Option<Rect>
pub fn offset_content_rect(&self, offset: usize) -> Option<Rect>
The content-space caret rectangle at one offset — a zero-width
range_content_rect.
Sourcepub fn document_version(&self) -> Signal<u64>
pub fn document_version(&self) -> Signal<u64>
Reactive counter that bumps on every document change — the handle mirror of
RichTextEditor::document_version.
The change token a decoration drawn outside the editor binds, so it re-derives when the text moves under it. Without it such a widget has only the scroll metrics to go on, and those move on a reflow but not on an edit that leaves the height alone — which is most edits, and exactly the ones that shift the offsets a mark is anchored to.
Sourcepub fn content_height(&self) -> Option<f32>
pub fn content_height(&self) -> Option<f32>
Height of the laid-out text, in the same space
range_content_rect reports.
The denominator that turns a content rect into a fraction of the document.
None before the first full layout — the same gate the rect queries use, so
a caller that has one has the other and the division is never against a
stale height.
This is the text’s height, not the widget’s: an editor laid out taller than its content (a short scene in a tall pane) reports the text.
Sourcepub fn offset_at_point(&self, window_point: Point) -> Option<usize>
pub fn offset_at_point(&self, window_point: Point) -> Option<usize>
Hit-test a point — in window coordinates, as a
context_menu factory receives it — to a
document character offset. None when the point resolves to no text
(past the last glyph on an empty line, outside the body, etc.).
Lets a custom context-menu factory resolve “the word under the pointer” from the right-click position, since a bare right-click does not move the caret on its own.
Reposition the caret to a right-click point (window coordinates)
unless the click lands inside the current selection (then the selection
is preserved). Call this at the top of a custom
context_menu factory so the menu’s Paste
— and any caret-relative action — operates where the user clicked, exactly
as the built-in menu and the single-line field do.
Sourcepub fn reveal_range(
&self,
ctx: &mut EventContext<'_>,
start: usize,
end: usize,
) -> bool
pub fn reveal_range( &self, ctx: &mut EventContext<'_>, start: usize, end: usize, ) -> bool
Scroll the character range [start, end) into view, reporting whether this editor
could — it has a layout to locate the range in, and is on screen rather than parked
dormant. See RichTextEditor::reveal_range.
When it answers false because there is no layout yet, the coarser
reveal_widget is the way to get one.
Sourcepub fn reveal_widget(&self, ctx: &mut EventContext<'_>) -> bool
pub fn reveal_widget(&self, ctx: &mut EventContext<'_>) -> bool
Scroll the editor itself into view — the coarse fallback for the one case
reveal_range cannot serve at all. Reports whether this
editor could: it has been built, so the arena knows a widget to scroll to, and
it is on screen rather than parked dormant.
A row of a stream that has never been painted has no full layout, so there is
no rect to locate an offset in and reveal_range answers false — for ever,
because the row only gets a layout when it is painted and it is only painted
when it comes on screen. That is a deadlock a range reveal has no way out of:
a match found in row 31 of a Book leaves the page exactly where it was, with
the counter cheerfully reading 1 of 40.
Revealing by widget breaks it, because the arena knows where row 31 is laid
out whether or not its text has been shaped. The row comes on screen, the next
paint gives it a layout, and a later reveal_range can then put the match
itself where the caller wants it. Coarser on purpose: this reveals the row,
not the offset inside it.
Sourcepub fn focus(&self, ctx: &mut EventContext<'_>)
pub fn focus(&self, ctx: &mut EventContext<'_>)
Move keyboard focus onto the editor. Lets a control built above the editor — a find banner returning focus to the prose on Escape — put the caret back where the user expects. A no-op until the editor has built at least once (its wrapper id is stashed then).
Sourcepub fn caret_char_format(&self) -> TextFormat
pub fn caret_char_format(&self) -> TextFormat
Read the current character format at the caret. When a selection
is active, reads from selection_start() rather than
position() so toolbar bistate stays stable across selection
extension (same rule as
RichTextEditor::caret_char_format).
Sourcepub fn set_italic(&self, enabled: bool)
pub fn set_italic(&self, enabled: bool)
Apply italic to the current selection.
Sourcepub fn set_underline(&self, enabled: bool)
pub fn set_underline(&self, enabled: bool)
Apply underline to the current selection.
Sourcepub fn set_strikethrough(&self, enabled: bool)
pub fn set_strikethrough(&self, enabled: bool)
Apply strikethrough to the current selection.
Sourcepub fn set_font_family(&self, family: impl Into<String>)
pub fn set_font_family(&self, family: impl Into<String>)
Set the font family for the current selection (a character-format
change applied over the selected range). Like the other char-format
setters (set_bold, …), this is a no-op when there is no
selection — the document model has no typing/pending format, so a
bare caret has no range to format. family must be a name resolvable
by the shared typesetter’s font registrar — e.g. a value chosen from
a FontPicker.
Sourcepub fn set_font_size(&self, size: u32)
pub fn set_font_size(&self, size: u32)
Set the font size (in points) for the current selection.
Sourcepub fn set_typography_defaults(&self, defaults: EditorTypographyDefaults)
pub fn set_typography_defaults(&self, defaults: EditorTypographyDefaults)
Set the non-destructive default typography (font family / line height /
first-line indent) filled onto runs and blocks with no explicit
override. Unlike set_font_family /
set_font_size — which mutate the selected text —
this is a display-time default: it never touches the document, undo
stack, or modified flag. Schedules a relayout + repaint.
Sourcepub fn get_typography_defaults(&self) -> EditorTypographyDefaults
pub fn get_typography_defaults(&self) -> EditorTypographyDefaults
Current default typography.
Sourcepub fn set_font_size_scale(&self, scale: f32)
pub fn set_font_size_scale(&self, scale: f32)
Set the per-editor logical font-size multiplier. See
RichTextEditor::set_font_size_scale.
Sourcepub fn get_font_size_scale(&self) -> f32
pub fn get_font_size_scale(&self) -> f32
Current per-editor font-size scale (1.0 = 100 %).
Sourcepub fn set_typewriter(&self, anchor: Option<f32>)
pub fn set_typewriter(&self, anchor: Option<f32>)
Set the typewriter-scrolling anchor — the EditorHandle counterpart of
RichTextEditor::set_typewriter. None turns pinning off.
This is the door a host uses to keep the pin following a live setting,
the same way set_typography_defaults
keeps typography following one.
Sourcepub fn get_typewriter(&self) -> Option<f32>
pub fn get_typewriter(&self) -> Option<f32>
Current typewriter anchor.
Sourcepub fn set_command_filter(&self, filter: CommandFilter)
pub fn set_command_filter(&self, filter: CommandFilter)
Narrow (or restore) what the keyboard may do — the EditorHandle
counterpart of RichTextEditor::set_command_filter, for hosts that
drive a drafting mode from a settings or session effect after the editor
is mounted.
Sourcepub fn command_filter(&self) -> CommandFilter
pub fn command_filter(&self) -> CommandFilter
The filter currently in force on this editor.
Sourcepub fn set_caret_highlight(&self, highlight: Option<CaretHighlight>)
pub fn set_caret_highlight(&self, highlight: Option<CaretHighlight>)
Draw an ambient band behind the caret’s sentence or paragraph — the EditorHandle
counterpart of RichTextEditor::set_caret_highlight, for hosts that re-push it from a
settings or theme effect after the editor is mounted.
Sourcepub fn get_caret_highlight(&self) -> Option<CaretHighlight>
pub fn get_caret_highlight(&self) -> Option<CaretHighlight>
What this editor’s caret band is currently configured to draw.
Sourcepub fn caret_window_rect(&self) -> Option<Rect>
pub fn caret_window_rect(&self) -> Option<Rect>
The caret’s rectangle in absolute window (tree) coordinates — the
EditorHandle counterpart of RichTextEditor::caret_window_rect.
None when unfocused or not yet laid out.
Sourcepub fn apply_text_format(&self, fmt: TextFormat)
pub fn apply_text_format(&self, fmt: TextFormat)
Apply an arbitrary [TextFormat] (escape hatch for fields not
covered by the dedicated setters: letter_spacing,
foreground_color, …).
Sourcepub fn toggle_bold(&self)
pub fn toggle_bold(&self)
Toggle bold on the current selection.
Sourcepub fn toggle_italic(&self)
pub fn toggle_italic(&self)
Toggle italic on the current selection.
Sourcepub fn toggle_underline(&self)
pub fn toggle_underline(&self)
Toggle underline on the current selection.
Sourcepub fn toggle_strikethrough(&self)
pub fn toggle_strikethrough(&self)
Toggle strikethrough on the current selection.
Sourcepub fn set_link(&self, href: &str)
pub fn set_link(&self, href: &str)
Point the selection at href.
Merges, so formatting already on the range is kept. A collapsed
selection formats nothing (as everywhere else), so a caller linking
existing text should select it first — see
link_at_caret for the range of a link already
there.
Sourcepub fn clear_link(&self)
pub fn clear_link(&self)
Take the link off the selection, leaving its text.
Sourcepub fn link_at_caret(&self) -> Option<LinkExtent>
pub fn link_at_caret(&self) -> Option<LinkExtent>
The link the caret is in, and how far it reaches.
Coalesced across the runs an inner mark splits a link into, so the
range covers the whole link rather than the piece under the caret.
None when the caret is not on a link.
Sourcepub fn is_underline(&self) -> bool
pub fn is_underline(&self) -> bool
Whether underline.
Sourcepub fn is_strikethrough(&self) -> bool
pub fn is_strikethrough(&self) -> bool
Whether strikethrough.
Sourcepub fn set_superscript(&self, enabled: bool)
pub fn set_superscript(&self, enabled: bool)
Raise the selection to superscript, or return it to the baseline.
Sourcepub fn set_subscript(&self, enabled: bool)
pub fn set_subscript(&self, enabled: bool)
Lower the selection to subscript, or return it to the baseline.
Sourcepub fn set_vertical_alignment(&self, alignment: CharVerticalAlignment)
pub fn set_vertical_alignment(&self, alignment: CharVerticalAlignment)
Set the selection’s vertical alignment directly.
Sourcepub fn get_vertical_alignment(&self) -> CharVerticalAlignment
pub fn get_vertical_alignment(&self) -> CharVerticalAlignment
The caret’s vertical alignment, Normal when unset.
Sourcepub fn is_superscript(&self) -> bool
pub fn is_superscript(&self) -> bool
True while the caret sits in superscript text.
Sourcepub fn is_subscript(&self) -> bool
pub fn is_subscript(&self) -> bool
True while the caret sits in subscript text.
Sourcepub fn toggle_superscript(&self)
pub fn toggle_superscript(&self)
Flip superscript on the selection. Turning it on replaces subscript.
Sourcepub fn toggle_subscript(&self)
pub fn toggle_subscript(&self)
Flip subscript on the selection. Turning it on replaces superscript.
Sourcepub fn apply_block_format(&self, fmt: BlockFormat)
pub fn apply_block_format(&self, fmt: BlockFormat)
Apply an arbitrary [BlockFormat] to the caret’s block.
Sourcepub fn set_alignment(&self, alignment: Alignment)
pub fn set_alignment(&self, alignment: Alignment)
Set paragraph alignment for the caret’s block.
Sourcepub fn clear_direction(&self)
pub fn clear_direction(&self)
Unset the block’s direction, handing the paragraph back to automatic detection.
Not the same as setting left-to-right. An explicit direction
pins the paragraph and overrides the bidi algorithm, so
“clearing” a direction by writing LeftToRight would force
Arabic and Hebrew prose to lay out backwards. Only an unset
direction lets the text speak for itself.
Sourcepub fn set_direction(&self, direction: TextDirection)
pub fn set_direction(&self, direction: TextDirection)
Set the base reading direction of the caret’s block. See
RichTextEditor::set_direction.
Sourcepub fn set_heading_level(&self, level: u8)
pub fn set_heading_level(&self, level: u8)
Set heading level for the caret’s block. 0 = plain paragraph,
1..=6 follow the HTML <h1>..<h6> convention.
Sourcepub fn get_alignment(&self) -> Alignment
pub fn get_alignment(&self) -> Alignment
Current block alignment.
Sourcepub fn get_direction(&self) -> Option<TextDirection>
pub fn get_direction(&self) -> Option<TextDirection>
The block’s explicitly-set reading direction, if it has one.
None means the writer never chose — the bidi algorithm decides
from the text. That is a genuinely different state from an
explicit left-to-right, so it is reported rather than defaulted:
a toggle needs to show “auto” as its own setting.
Sourcepub fn get_heading_level(&self) -> u8
pub fn get_heading_level(&self) -> u8
Current heading level (0 = plain paragraph).
Sourcepub fn insert_list(&self, ordered: bool)
pub fn insert_list(&self, ordered: bool)
Wrap the caret’s block in a list. ordered = true uses decimal
numbering, false uses bullet discs.
Sourcepub fn create_list(&self, style: ListStyle)
pub fn create_list(&self, style: ListStyle)
Wrap the caret’s block in a list with an explicit
[ListStyle].
Sourcepub fn indent(&self)
pub fn indent(&self)
Indent the caret’s current list item by one nesting level. No-op when the caret is not inside a list. Equivalent to Tab.
Sourcepub fn outdent(&self)
pub fn outdent(&self)
Outdent the caret’s current list item by one nesting level. No-op at depth 0. Equivalent to Shift+Tab.
Sourcepub fn remove_from_list(&self)
pub fn remove_from_list(&self)
Take the caret’s block out of its list entirely, leaving a plain paragraph. No-op when the caret is not inside a list.
See RichTextEditor::remove_from_list for why this is separate from
outdent, which stops at depth 0 by design.
Sourcepub fn is_in_blockquote(&self) -> bool
pub fn is_in_blockquote(&self) -> bool
True iff the caret currently sits inside a blockquote frame at any nesting depth.
Sourcepub fn selection_spans_multiple_frames(&self) -> bool
pub fn selection_spans_multiple_frames(&self) -> bool
True iff the selection spans more than one frame — the “Toggle blockquote” affordance should be disabled in this case.
Sourcepub fn toggle_blockquote(&self)
pub fn toggle_blockquote(&self)
Wrap the current block/selection in a blockquote, or unwrap the innermost enclosing blockquote if already inside one. Toolbar counterpart for a Ctrl+Shift+Q-style toggle.
Sourcepub fn increase_blockquote_depth(&self)
pub fn increase_blockquote_depth(&self)
Wrap the current block in a deeper nested quote. Equivalent to Tab inside a blockquote.
Sourcepub fn decrease_blockquote_depth(&self)
pub fn decrease_blockquote_depth(&self)
Pop the caret out of one blockquote nesting level. Equivalent to Shift+Tab inside a blockquote.
Sourcepub fn insert_table(&self, rows: usize, columns: usize)
pub fn insert_table(&self, rows: usize, columns: usize)
Insert a fresh rows × columns table at the caret.
Sourcepub fn remove_current_table(&self)
pub fn remove_current_table(&self)
Remove the table containing the caret. No-op outside a table.
Sourcepub fn insert_row_above(&self)
pub fn insert_row_above(&self)
Insert a row above the caret’s current table row.
Sourcepub fn insert_row_below(&self)
pub fn insert_row_below(&self)
Insert a row below the caret’s current table row.
Sourcepub fn insert_column_before(&self)
pub fn insert_column_before(&self)
Insert a column before the caret’s current table column.
Sourcepub fn insert_column_after(&self)
pub fn insert_column_after(&self)
Insert a column after the caret’s current table column.
Sourcepub fn remove_current_row(&self)
pub fn remove_current_row(&self)
Remove the caret’s current table row.
Sourcepub fn remove_current_column(&self)
pub fn remove_current_column(&self)
Remove the caret’s current table column.
Sourcepub fn is_in_table(&self) -> bool
pub fn is_in_table(&self) -> bool
Whether the caret is currently inside a table cell.
Sourcepub fn break_undo_merge(&self)
pub fn break_undo_merge(&self)
Close the current undo entry, so the next edit starts a new one.
Typing coalesces into word-sized undo steps by looking only at the shape of two edits — adjacent, moments apart. It cannot see that the user did something else in between, somewhere else in the application, that they would remember as a dividing line. A host that knows one was crossed says so here, and the burst before it stops merging with the burst after.
Sourcepub fn begin_edit_block(&self)
pub fn begin_edit_block(&self)
Begin grouping subsequent edits into a single undo entry. Pair with
end_edit_block, or prefer the scoped
edit_block.
Sourcepub fn end_edit_block(&self)
pub fn end_edit_block(&self)
Close the group opened by begin_edit_block.
Sourcepub fn edit_block<R>(&self, edits: impl FnOnce() -> R) -> R
pub fn edit_block<R>(&self, edits: impl FnOnce() -> R) -> R
Run edits as one undo entry — the pairing-safe form.
Sourcepub fn copy(&self, ctx: &EventContext<'_>)
pub fn copy(&self, ctx: &EventContext<'_>)
Copy the current selection to the system clipboard (plain + HTML
payloads). No-op when there is no selection. See
RichTextEditor::copy.
Sourcepub fn cut(&self, ctx: &EventContext<'_>)
pub fn cut(&self, ctx: &EventContext<'_>)
Cut the current selection: copy first, then remove. See
RichTextEditor::cut.
Sourcepub fn paste(&self, ctx: &EventContext<'_>)
pub fn paste(&self, ctx: &EventContext<'_>)
Paste from the system clipboard. Prefers an in-process fragment
over HTML over plain text. See RichTextEditor::paste.
Sourcepub fn paste_unformatted(&self, ctx: &EventContext<'_>)
pub fn paste_unformatted(&self, ctx: &EventContext<'_>)
Paste plain text only, stripping any rich payload. See
RichTextEditor::paste_unformatted.
Sourcepub fn can_paste(&self, ctx: &EventContext<'_>) -> bool
pub fn can_paste(&self, ctx: &EventContext<'_>) -> bool
Whether a paste would insert anything — true iff the system
clipboard carries text or an HTML payload. A point-in-time
query (clipboard contents are not reactively observable), taking
the active EventContext.
Use it to drive a context-menu / toolbar Paste enable-state,
re-querying on menu-open. Mirrors RichTextEditor::can_paste.
Sourcepub fn select_all(&self)
pub fn select_all(&self)
Select the entire document programmatically. Resets the Ctrl+A
ladder so a subsequent Ctrl+A starts fresh at level 1. Mirrors
RichTextEditor::select_all.
Sourcepub fn delete_selection(&self)
pub fn delete_selection(&self)
Delete the current selection. No-op when nothing is selected.
Mirrors RichTextEditor::delete_selection.
Sourcepub fn format_version(&self) -> Signal<u64>
pub fn format_version(&self) -> Signal<u64>
Bumps on every format-only document event (bold / italic /
heading / alignment / list-style changes). See
RichTextEditor::format_version.
Sourcepub fn cursor_position(&self) -> usize
pub fn cursor_position(&self) -> usize
The live caret offset — reads cursor.position() directly, unbatched. Unlike
cursor_position_signal, whose stored value lags one frame
behind a just-typed printable character (the insert is deferred to the frame loop and the
signal is only re-synced on the next caret event), this always reflects the true caret —
what a host that recomputes highlights on a frame tick must read. Mirrors
RichTextEditor::cursor_position.
Sourcepub fn is_composing(&self) -> bool
pub fn is_composing(&self) -> bool
true while an IME composition is actively in progress. Mirrors
RichTextEditor::is_composing.
Sourcepub fn cursor_position_signal(&self) -> Signal<usize>
pub fn cursor_position_signal(&self) -> Signal<usize>
Reactive caret position signal.
Sourcepub fn cursor_anchor_signal(&self) -> Signal<usize>
pub fn cursor_anchor_signal(&self) -> Signal<usize>
Reactive selection anchor signal.
Sourcepub fn has_selection(&self) -> Signal<bool>
pub fn has_selection(&self) -> Signal<bool>
Reactive selection-non-empty signal.
Trait Implementations§
Source§impl Clone for EditorHandle
impl Clone for EditorHandle
Source§fn clone(&self) -> EditorHandle
fn clone(&self) -> EditorHandle
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for EditorHandle
impl Debug for EditorHandle
Source§impl TextSurface for EditorHandle
impl TextSurface for EditorHandle
Source§fn history_frozen(&self) -> bool
fn history_frozen(&self) -> bool
The editor’s own CommandFilter
is the authority: a host that has imposed ForwardOnly or ReadOnly on
this editor must not be able to route around it from a menu.
Source§fn can_undo(&self) -> bool
fn can_undo(&self) -> bool
fn undo(&self)
fn redo(&self)
Source§fn has_selection(&self) -> bool
fn has_selection(&self) -> bool
Source§fn is_read_only(&self) -> bool
fn is_read_only(&self) -> bool
Source§fn allows_copy(&self) -> bool
fn allows_copy(&self) -> bool
fn cut(&self, ctx: &EventContext<'_>)
fn copy(&self, ctx: &EventContext<'_>)
fn paste(&self, ctx: &EventContext<'_>)
Source§fn paste_plain(&self, ctx: &EventContext<'_>)
fn paste_plain(&self, ctx: &EventContext<'_>)
fn select_all(&self)
Auto Trait Implementations§
impl !RefUnwindSafe for EditorHandle
impl !Send for EditorHandle
impl !Sync for EditorHandle
impl !UnwindSafe for EditorHandle
impl Freeze for EditorHandle
impl Unpin for EditorHandle
impl UnsafeUnpin for EditorHandle
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more