KLA6
1
I want to execute “deleteTrailingWhitespace” (CodeMirror Reference Manual), when the user press Ctrl+S.
I thought the below way, but it doesn’t work.
editor.execCommand("deleteTrailingWhitespace");
Could you please give me an advise how to execute “deleteTrailingWhitespace”…?
Thank you.
marijn
2
Import it, and call it with the editor view as only argument.
KLA6
3
Thank you so much for your quick response, but sorry for a more low level question.
In my case, I’m using CodeMirror by CDN as following.
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/6.65.7/codemirror.min.js" integrity="..." crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<textarea id='editor'></textarea>
<script>
var editor = CodeMirror.fromTextArea( document.getElementById( 'editor' ), { ... } )
</script>
In my situation, is executing “deleteTrailingWhitespace” impossible…?
marijn
4
You seem to be mixing up the version 5 and 6 APIs — the link in the initial post was to the 6.x docs, but fromTextArea
doesn’t exist there.
(In general, CodeMirror 6 isn’t really something you’ll want to pull from a CDN, since those tend to duplicate shared dependency packages.)
KLA6
5
Thank you for your response…! : )