Switching between language compartment and legacy modes


First of all, thanks for releasing an awesome editor! I was working on adding codemirror to a project of mine, and had a question.

To add a language mode to codemirror, we can set up the editor with a compartment as shown below:

const langHolder = new Compartment()
const state = EditorState.create({
	doc: '',
	extensions: [
const view = new EditorView({state, parent: document.querySelector("#editor")})

We can also update the language later using langHolder.reconfigure().

Now, I’d like to support languages for which no native codemirror language package exists, by using the legacy modes package.

However, I couldn’t find any documentation on how to configure an editor so that I can change between legacy modes and the native language packages. How can I do this?

Thank you.

Pretty much the same—the extension for that is created with StreamLanguage.define(...), which is what you put in the compartment instead of the css() extension.


Thank you for the hint. Much appreciated.