Skip to main content

Module rich_text

Module rich_text 

Source
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§

EditorHandle
A clone-able, 'static handle to a RichTextEditor’s shared state.
EditorTextDrag
Rich text being dragged out of an editor.
FindSession
A search-highlight layer: the matches of a query, as a document range session, with the current match distinguished.
ImageActivation
An inline image the user clicked.
ImageResize
A resize the reader finished dragging.
PolicyBundle
One bundle per construction preset: the single source of truth for the four independent decisions that separate an editable surface from a viewer.
RichTextEditor
TextAnnotationSpan
The main rich text widget. Construct via RichTextEditor::read_only (view/select only) or RichTextEditor::editor (full editing). One annotation (a comment thread) covering [start, end) of the document, in document-absolute character offsets — the space cursors and FindMatch speak.

Enums§

AccessibilityRole
Drives the AccessKit role a text surface reports.
CaretPolicy
How the caret is presented on a text surface.
ClipboardPolicy
Clipboard surface exposed by a text widget.
CommandFilter
Command filter consulted before any cursor call in a surface’s keyboard layer.
ContextTarget
What was under a click, for context-menu classification.
EditCommandKind
Commands the keyboard handler may emit. Editing commands map to TextCursor mutations; navigation commands are always accepted.
EditSource
How a piece of text reached the document — the channel, not the author.
ScrollPolicy
Scroll bar visibility policy for RichTextEditor, applied independently per axis.

Constants§

EDITOR_PRESET
The full editor preset: every command accepted, caret blinks, MultilineTextInput role, 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_menu rather than registering a custom Action against 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, Document role, 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 via PolicyBundle.