-
Notifications
You must be signed in to change notification settings - Fork 56
Description
Hi everyone,
I'm trying to use the monaco editor and more specifically the workbench view with the explorer service override and a registered file system provider to provide a VS Code like C# editor in the web with the possibility for some asset files that can be used in the C# script. I'm using monaco-languageclient to connect the editor with my language server. The editor itself is running in a React JS frontend that also provides other features and views that are conditional rendered via router. Since there's a ton of other stuff in the frontend I was trying to implement the workbench in one of the routes because I only need it on that one page.
This worked perfectly when I was just using the regular editor without anything around it because I could just use monaco.editor.create and dispose the editor and the model when the component unmounts. But now I want to switch to the workbench and since the workbench is only rendered or initialized when the initialize (or in the case of monaco-languageclient, initServices) function is called I can't just unrender and cleanup the editor and re-initialize it again because the initialize will throw an error since the services are already initialized.
I've done a bit of research and from what I can tell it's not possible to achieve this behaviour right now which makes sense to a certain degree. However I was wondering if there was any way around this limitation so that I can actually implement the editor / workbench as a part of my application without it having to always be rendered. I don't know to what extent the initialize process is actually linked to the rendering of the workbench but it'd be great if it were decoupled.
I've tried a couple of "obvious" workarounds like storing the HTML node for the editor in a global react context and conditional rendering that but I didn't really get it to work and even if I did I wouldn't be happy with the solution