How to properly use for managing multiple collaborative documents

Hi. I’m trying to figure out how to manage multiple collaborative documents using In this given example the main idea is built around the binding instance. We should destroy binding before switching to a new document. Unfortunately for we have no binding instance at all:
const state = EditorState.create({ doc: ytext.toString(), extensions: [ basicSetup, javascript(), yCollab(ytext, provider.awareness, { undoManager }) ] })

const view = new EditorView({ state, parent: /** @type {HTMLElement} */ (document.querySelector('#editor')) })
How can we implement this idea for
I will be very grateful for the help.

It looks like the example you have put each of the documents (Y.Text) in a Y.Array. Then when you click on the new document you want to switch to, you can update the state of the Code Mirror. Something like:

        doc: source.toString(),
        extensions: [

Or you could destroy the view with view.destroy() and then recreate it.

1 Like

@andheller Thank you so much!