The EditorState is always synced with other parties via Collab, and part of the clipboard logic.
There's times when the result should be kept strictly offline. For example:
- Search or multi text search (i.e. VSCode find all). Or to show GenAI GPT results.
- Other player cursors in Collab (not part of th EditorState)
- GenAI GPT Office/Notion-like popover on edit when the prompt refers to a specific part of the edit but the focus has moved to the modal.
This solution leverages Range to follow DOM updates and render on top of the Lexical editor completely independently from the editor. The MutationObserver introduced below is particularly important to make sure that the position is always up-to-date. For example, additional changes in the padding or additional added/removed nodes somewhere on the contenteditable or immediately before our selection host.
The editor dependency is very lightweight, it could easily be decoupled completely.