Hi. I’m writing some end-to-end tests for my CodeMirror v6 project. I’d like to get the text content inside my CodeMirror v6 editor from the browser, but I’m not sure how to do it.
I’ve tried document.querySelector('.cm-content').innerText
, but the result contains some extra newlines.
What I want here is h1\nh2\n\nh3\n\n\nh4
. Could I just call text = text.replaceAll('\n\n', '\n')
to remove these extra newlines?
I’ve also tried to get a CodeMirror instance from its wrapper element, but .CodeMirror
doesn’t seem to work anymore in CodeMirror v6.