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 live copy/cut/select-all/delete paths run through common/event.rs
(SystemChange::CopyToClipboard/CutToClipboard, CallbackChange::SetSelectAllRange,
LayoutWindow::delete_selection), not through changeset constructors. The earlier
create_*_changeset helpers were a never-wired parallel implementation (with
placeholder deleted_text, CursorPosition::Uninitialized cursors, and byte±1
UTF-8 deletion) and have been removed.
§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)
Type Aliases§
- Changeset
Id - Unique identifier for a changeset (for undo/redo)