Expand description
Text editing changeset system
STATUS: The core types (TextChangeset, TextOperation, TextOp* structs) are
actively used by window.rs, undo_redo.rs, event.rs, and platform code. The
create_*_changeset free functions are not yet wired into event handling.
§Architecture
This module implements a two-phase changeset system for all text editing operations:
- Create changesets (pre-callback): Analyze what would change, don’t mutate yet
- Apply changesets (post-callback): Actually mutate state if !preventDefault
This pattern enables:
- preventDefault support for ALL operations (not just text input)
- Undo/redo stack (record changesets before applying)
- Validation (check bounds, permissions before mutation)
- Inspection (user callbacks can see planned changes)
Structs§
- Text
Changeset - A text editing changeset that can be inspected before application
- Text
OpClear Selection - Clear all selections
- Text
OpCopy - Copy selection to clipboard (no text change)
- Text
OpCut - Cut selection to clipboard (deletes text)
- Text
OpDelete Text - Delete text in range
- Text
OpExtend Selection - Extend selection in a direction
- Text
OpInsert Text - Insert text at cursor position
- Text
OpMove Cursor - Move cursor to new position
- Text
OpPaste - Paste from clipboard (inserts text)
- Text
OpReplace Text - Replace text in range with new text
- Text
OpSelect All - Select all text in node
- Text
OpSet Selection - Set selection to new range
Enums§
- Cursor
Movement - Type of cursor movement
- Selection
Direction - Re-export from events module Direction of cursor movement or selection expansion.
- Text
Operation - Text editing operation (what will change)
Functions§
- create_
copy_ changeset - Creates a copy changeset from the current selection.
- create_
cut_ changeset - Creates a cut changeset from the current selection.
- create_
delete_ selection_ changeset - Creates a delete changeset for the current selection or single character.
- create_
paste_ changeset - Creates a paste changeset at the current cursor position.
- create_
select_ all_ changeset - Creates a select-all changeset for the target node.
Type Aliases§
- Changeset
Id - Unique identifier for a changeset (for undo/redo)