Skip to main content

Module text_input

Module text_input 

Source
Expand description

Text Input Manager

Centralizes all text editing logic for contenteditable nodes.

This manager handles text input from multiple sources:

  • Keyboard input (character insertion, backspace, etc.)
  • IME composition (multi-character input for Asian languages)
  • Accessibility actions (screen readers, voice control)
  • Programmatic edits (from callbacks)

§Architecture

The text input system uses a two-phase approach:

  1. Record Phase: When text input occurs, record what changed (old_text + inserted_text)

    • Store in pending_changeset
    • Do NOT modify any caches yet
    • Return affected nodes so callbacks can be invoked
  2. Apply Phase: After callbacks, if preventDefault was not set:

    • Compute new text using text3::edit
    • Update cursor position
    • Update text cache
    • Mark nodes dirty for re-layout

This separation allows:

  • User callbacks to inspect the changeset before it’s applied
  • preventDefault to cancel the edit
  • Consistent behavior across keyboard/IME/A11y sources

Structs§

PendingTextEdit
Information about a pending text edit that hasn’t been applied yet
TextInputManager
Text Input Manager

Enums§

OptionPendingTextEdit
C-compatible Option type for PendingTextEdit
TextInputSource
Source of a text input event