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
Add a way to clear history #405
Comments
I don't understand how to re-use that code when we are using react-codemirror. If somewhere in my code I'm using react-codemirror like this:
Then how am I supposed to recreate the Editor to keep absolutely everything the same, but only removing History? If I create a new instance without all the options set then it's just broken. But if I need to carefully craft the arguments to exactly match whatever react-codemirror is generating, then why use codemirror in the first place? It seems like I shouldn't....? Just FYI, my attempt that is broken, is inside useEffect() I set state like this:
I end up with a white box with zero formatting (no line numbers, highlighting etc). How can I call EditorState.create() with the same values that react-codemirror would have used? |
Actually one hacky workaround that seems to work is by setting the history state to false then back to true again right after. So code like this appears to work fine:
Dirty but somehow seems better than the other alternative... |
I think this problem needs to be resolved |
it seems as view.setState will break functionality like this react-codemirror/merge/src/Modified.tsx Line 18 in c68d27d
|
+1, if I reset state, all the internal extensions of react-codemirror will be lost |
I cannot find any method to clear history (to prevent Ctrl+Z in some cases)
It seems that CodeMirror 6 suggests doing
editor.setState(...)
with a new state, but in this library states are created internally and there's no easy way to do it.The text was updated successfully, but these errors were encountered: