I am using CodeMirror 6, and in the CSS, I have styled the content element (.cm-content) with white-space: pre-wrap;, but it didn’t work. I tried inserting lineWrapping: true in here:
var editor = new EditorView({
lineWrapping: true,
state,
parent: document.getElementById("editor")
});
But the line wrapping still didn’t work. Has anyone faced this issue, and if so, how do I fix it? What am I missing?
I’m also wondering how to remove line wrapping. I have a Compartment set up to add the EditorView.lineWrapping extension, but when I remove that from the Compartment, the cm-lineWrapping class still remains.
There doesn’t seem to be a way to update the lineWrappingcontentAttribute Facet to remove the class when it’s removed. Is this a bug or is this how contentAttribute is supposed to work?
Nevermind. It seems that updating a compartment from EditorView.lineWrapping to an empty array [] works as expected. I was replacing with null before, but that doesn’t have the same effect.