I’m building a layer on top of CodeMirror that effectively turns it into a blocks-based editor. The blocks editor has to manage its own cursor state, since (1) setCursor() doesn’t work inside atomic ranges, (2) a block can have children and (3) we want to track when a child is focused.
Part of this work also means restoring the active block after undo/redo. That means I also need to duplicate the history functionality of CM, maintaining a parallel history infrastructure that just tracks the active block over time. Can I store some kind of data inside the entires in the history object, and have CM manage it? Ideally, I’d like to add the id of the block to the current record, such that undoing/redoing will allow me to retrieve that id and re-focus the appropriate block.
FWIW, I’ve tried doing this programmatically, but anything I add to the history object is sanitized away when the history is updated. And obviously, this wouldn’t be an issue if I could set the cursor inside an atomic range, but I don’t want to sound too whiny on here. Marijn has already been so patient with my crazy requests in the past.