Create editor at runtime

Hello, I am new to bundling, and I followed the guide “Bundling Codemirror with Rollup”, writing this in my .html:

and this in my editor.js:
parent: document.querySelector("#editor1")

But I need to create multiple editors at runtime, how can I do? I cannot just create a function in editor.js that returns a new editor because it has a local scope in editor.bundle.js and I cannot call it from my html. Is there a way I can do this?

This seems more of a basic JavaScript question than a CodeMirror question. The easiest way around it is to put your function in the global scope (by assigning to window.someName) I guess.

1 Like