Step 1: Requirements
Requirements
Questions to ask
- What operations? (insert, delete, replace, format)
- How deep is the undo history? (unlimited, fixed-size)
- Do we need redo?
- Do we need multi-cursor support?
- Is this collaborative (multi-user)?
- Do we need clipboard (cut/copy/paste)?
Functional requirements
- Insert text at a position
- Delete a range of text
- Replace text in a range
- Undo the last operation
- Redo a previously undone operation
- Copy and paste text
- Get the current document content
Non-functional requirements
- Undo/redo must be O(1)
- Support documents up to 1MB
- Operations must be reversible without data loss