Dynamically change lineWrapping

I am trying to dynamically change how editor treats line wrapping. Could someone please provide a sample of dynamically enabling / disabling extension.

See this example.

Thank you for the pointer. I was able to resolve the issue.

Init editor:

let lineWrapping = true;

const lineWrappingComp = new Compartment();
const editor = new EditorView({
        state: EditorState.create({
            doc: 'test',
            extensions: [
                basicSetup,
                this.lineWrappingComp.of(lineWrapping ? EditorView.lineWrapping : [])
            ]
        }),
        parent: editorEl
    });

When I want to change the lineWapper

lineWrapping = false;
editor.dispatch({
        effects: lineWrappingComp.reconfigure(lineWrapping ? EditorView.lineWrapping : [])
    });
1 Like