Re: [w3c/editing] undo manager (#209)

I've been thinking about real-time collab (RTC) editing and selective undo and, if I get the proposal right, it should be fine. Maybe not ideal, but fine.

The problem in RTC editing is that you don't know precisely what will have to be done upon undoing, but you know that an undo step was created. Your editor must have its own internal undo manager which knows when an undo step is created and it allows performing undo/redo operations on the editor.

For CKEditor 5 and integration between its internal undo manager and the browser's undo manager would look more or less like this:

```js
editor.plugins.get( 'Undo' ).on( 'newItem', () => {
    document.undoManager.addItem( new UndoItem( {
        label: 'Editing',
        undo: () => editor.execute( 'undo' ),
        redo: () => editor.execute( 'redo' )
    } ) );
} );
```

And as long as the number of undo steps that are available in the editor's internal data model is equal to the number of undo items added to the browser's undo manager, this integration should work for undoing.

The same should be true for redoing because, again, the number of browser redo steps must simply match the number of redo steps available in the editor's undo manager. As long as in both implementations (browser's and editor's) there's always just one redo step for one undo step, both mechanisms should stay in sync.

---

BTW, I found one typo in https://rniwa.github.io/undo-api/#undomanager-interface (I can't find the GH repo for it):

![image](https://user-images.githubusercontent.com/156149/64924705-a0ff1680-d7e7-11e9-89b1-7f4d7af8ced3.png)


-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/editing/issues/209#issuecomment-531580367

Received on Sunday, 15 September 2019 16:41:40 UTC