Prevent history commands when view is not editable #10
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix-history-editable-check"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Description
This pull request fixes an issue where history commands (undo/redo) could still be triggered even when the editor view is not editable. The change ensures that the
beforeinputevent handler properly checks theview.editableflag before executing history commands.Why this is needed:
The current behavior allows undo/redo operations even when the editor is not in an editable state, which is inconsistent with expected behavior. This fix resolves that issue by ensuring that history commands are only available in editable mode.
None of the other commands make such a check.
EditorView.editableindicates whether the DOM has been marked as editable, but is not intended to be a flag that commands consult to determine whether the user may change the content.How are the commands being called, in this case? Through a keymap? Or by some other means?
The prosemirror-history plugin is binding a default
beforeinputhandler which is called even when there is no keymap. Our preference is that when the editor is not editable, these commands do not execute. But, since the plugin binds this event by default, we either have to resort to capturing these events ourselves, or have the plugin not call the command in the first place.We wrote a plugin that captures the event, and while it does produce our desired behavior, it feels hacky to include.
The desire here is not that the command consults with the
EditorView.editableproperty, but that the plugin does since it handles these events when keymaps do not apply.Oh, I see, you're modifying the beforeinput handler, not the commands. That does seem reasonable!