Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undo/Redo does not work properly in MacOS Ventura #73

Closed
stevengharris opened this issue Nov 4, 2022 · 1 comment · Fixed by #75
Closed

Undo/Redo does not work properly in MacOS Ventura #73

stevengharris opened this issue Nov 4, 2022 · 1 comment · Fixed by #75

Comments

@stevengharris
Copy link
Owner

When you "do" an action (e.g., bold, indent, etc) in the MarkupEditor, a change is pushed on the native undo stack by executing:

document.execCommand('selectAll');
document.execCommand('insertText', false, nextID);

while focused on a hidden div in the document. The nextID tracks a pointer into the internal undo stack. The code to do this is in markup.js in the Undoer class.

Version 0.5.1 works properly on Big Sur. As you "do" actions, you can see that the Undo menu option in the Edit menu is enabled, because the execCommand('insertText') runs and pushes the change to the div's content onto the native undo stack. Once the Undo and/or Redo are enabled, then the standard hot-keys (⌘Z and ⇧⌘Z) work which in turn invoke the undo operation in the MarkupEditor.

In Ventura, the same code executes, but the native undo stack is not changed. The Undo and Redo never get enabled in the Edit as you invoke operations on the document, and therefore neither the menu or hot-keys work for Undo/Redo.

Editing operations that don't have to do with MarkupEditor actions (e.g., type some text then undo) work properly in both versions. Only the MarkupEditor operations (think: things that are exposed via the MarkupToolbar) are impacted.

FWIW, the undo/redo tests work properly because the invoke the operations queued in the internal undo stack.

In a sad bit of irony, this is one of the very few places where the MarkupEditor uses the deprecated and browser-dependent execCommand.

@stevengharris
Copy link
Owner Author

This issue turns out to be specific to Mac Catalyst as of MacOS 13 (Ventura), as discussed in #76. However, a fix to use an input element rather than a contenteditable div within the Undoer works on Mac Catalyst on Ventura and earlier versions.

@stevengharris stevengharris linked a pull request Nov 28, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant