CM6 changes editable mode at runtime

After I started the CM6 editor in editable mode, how do I set editable to false at runtime?

const view = new EditorVIew({
  state: EditorState.create({
    extensions: [ EditorView.editable.of(true) ]
  })
});

// I only found the api to read a facet at runtime. How to change/add a facet?
view.state.facet(EditorView.editable);

Check out the section on Compartments.
https://codemirror.net/6/examples/config/

2 Likes