Expand description
Rich text editor and viewer widget.
Two construction presets share the same implementation: RichTextEditor::editor
provides a full editing surface (blinking caret, keyboard commands, clipboard,
undo/redo, Role::MultilineTextInput) and RichTextEditor::read_only is a
view-only surface (hidden caret, mutations rejected, Role::Document). Both
bind to an external [TextDocument]
via on_change subscriptions, so any number of editors and viewers can share
one document and observe each other’s edits live.
The widget owns a per-widget RichTextEngine (typesetter), and drives its own
scroll bars independently of ScrollArea to avoid the wrap/scrollbar circular
measurement dependency. Use RichTextEditor::min_lines /
RichTextEditor::max_lines to switch from greedy sizing to intrinsic
(messenger-composer) sizing. A detachable EditorHandle lets toolbars and
palette panels issue formatting commands from closures that cannot borrow the
editor directly.
use teksilo_text::text_document::TextDocument;
let doc = TextDocument::new();
let editor = RichTextEditor::editor(doc)
.min_lines(3)
.max_lines(8)
.wrap_mode(WrapMode::Word);Modules§
- caret_
highlight - An ambient band behind the sentence — or paragraph — the caret is in.
Structs§
- Editor
Handle - A clone-able,
'statichandle to aRichTextEditor’s shared state. - Editor
Text Drag - Rich text being dragged out of an editor.
- Find
Session - A search-highlight layer: the matches of a query, as a document range session, with the current match distinguished.
- Image
Activation - An inline image the user clicked.
- Image
Resize - A resize the reader finished dragging.
- Policy
Bundle - One bundle per construction preset: the single source of truth for the four independent decisions that separate an editable surface from a viewer.
- Rich
Text Editor - Text
Annotation Span - The main rich text widget. Construct via
RichTextEditor::read_only(view/select only) orRichTextEditor::editor(full editing). One annotation (a comment thread) covering[start, end)of the document, in document-absolute character offsets — the space cursors andFindMatchspeak.
Enums§
- Accessibility
Role - Drives the AccessKit role a text surface reports.
- Caret
Policy - How the caret is presented on a text surface.
- Clipboard
Policy - Clipboard surface exposed by a text widget.
- Command
Filter - Command filter consulted before any cursor call in a surface’s keyboard layer.
- Context
Target - What was under a click, for context-menu classification.
- Edit
Command Kind - Commands the keyboard handler may emit. Editing commands map to
TextCursormutations; navigation commands are always accepted. - Edit
Source - How a piece of text reached the document — the channel, not the author.
- Scroll
Policy - Scroll bar visibility policy for
RichTextEditor, applied independently per axis.
Constants§
- EDITOR_
PRESET - The full editor preset: every command accepted, caret blinks,
MultilineTextInputrole, full clipboard support. - INTENT_
COPY - Intent fired by the built-in Copy menu item.
- INTENT_
CUT - Intent fired when the user activates the Cut item of the
built-in context menu. Reserved for the framework — applications
that want bespoke cut semantics should replace the menu via
RichTextEditor::context_menurather than registering a customActionagainst this name. - INTENT_
PASTE - Intent fired by the built-in Paste menu item.
- INTENT_
PASTE_ UNFORMATTED - Intent fired by the built-in Paste Unformatted menu item.
- INTENT_
SELECT_ ALL - Intent fired by the built-in Select All menu item.
- READ_
ONLY_ PRESET - The read-only preset: only navigation + copy/select-all,
Documentrole, no cut/paste. The caret is hidden entirely — view-only widgets ship without any caret affordance. Applications that need a focusable read-only surface with a visible caret can construct a custom preset viaPolicyBundle.