Commit bbc4f65
committed
feat: add hybrid input architecture modules (draft)
Add three new modules for the hybrid input architecture that combines
PTE's behavior system with ProseMirror-style parse-and-diff as a
fallback for platforms where preventDefault is unavailable (Android).
New modules:
- dom-parser.ts: Parses DOM back into PT blocks using data-slate-*
attributes. Uses ELEMENT_TO_NODE WeakMap for unchanged nodes (fast
path) and DOM walking for browser-mutated content (slow path).
Handles text blocks, void objects, inline objects, and containers.
- dom-change-detector.ts: Diffs two PT block arrays to detect what
changed. Aligns blocks by _key, detects splits/merges from content
shape, and does character-level text diffing for inline changes.
39 unit tests covering all change types.
- dom-change-to-behavior-event.ts: Maps detected changes to PTE
behavior events (insert.text, insert.break, delete.backward, etc.)
that can be dispatched through the existing behavior system.
These modules are standalone — no integration with the input pipeline
yet. This is Phase 1 of the hybrid architecture (see design doc).1 parent 16933db commit bbc4f65
4 files changed
Lines changed: 2402 additions & 0 deletions
File tree
- packages/editor/src/editor
- __tests__
0 commit comments