Milkdown / milkdown

🍼 Plugin driven WYSIWYG markdown editor framework.
https://milkdown.dev
MIT License
8.94k stars 405 forks source link

[Bug] undo/redo after scrolling doesn't show the result of the redo #1361

Closed benatkin closed 5 months ago

benatkin commented 5 months ago

Initial checklist

Affected packages and versions

7.3.5

Link to runnable example

No response

Steps to reproduce

Type "hello" below the header on https://milkdown.dev/playground

Press Command-down to go to the bottom

Press Ctrl-Z to undo. It scrolls to the top.

Press Ctrl-shift-z to redo. It scrolls back to the bottom.

undo-redo.webm

Expected behavior

It should stay at the top so the user can see "Hello" after ctrl-shift-z

Actual behavior

It scrolls to the bottom where ctrl-z was typed

Runtime

Chrome

OS

macOS

Build and bundle tools

No response

Saul-Mirone commented 5 months ago

In fact that's the expected behavior. Prosemirror based editors (like tiptap, remirror, prosekit) all behaved the same because the behavior is actually provided by prosemirror-history. I remember there were some discussion (like pm-677) about the behavior in the prosemirror community. I think the cursor restore should be considered as a feature.

benatkin commented 5 months ago

It isn't familiar to me. What's more familiar is how CodeMirror, vscode, and Google Docs behave - the restored text is visible upon pressing Ctrl Shift Z

Saul-Mirone commented 5 months ago

You can still customize the behavior if it doesn't fit your needs.