Adding and removing a ProseMirror instace on demand

Hello, In a long lived JS app, one might need to destroy a ProseMirror instance expecting all listeners and references to cleared. Is this currently possible? Also, is it possible to disable an instance ( Making it appear to be not editable ) and re enable it?

Thanks

You can just remove it from the DOM, that’s all it takes. There are no events registered on any nodes outside of the editor.

There is no support for making a ProseMirror instance non-editable. You could just replace it with the rendered form of the document (and maybe wrap it in a .ProseMirror-content element if you want the editor styles to apply), but that’s all I have for now.

I thought that maybe pm.content.contenteditable = false might work but it doesn’t seem to accept it (not sure why). However I commented out the pm.content.contenteditable = true and it was no longer editable. Marijn may know if there are other things to consider.

A bunch of event handlers will also cause trouble, allowing you to still edit the document (by dragging, for example) or simply break (the selection-handling, which assumes the content is actually focusable).