How do I integrate the Monaco text editor in a webview? #74
-
I'm working on an extension that uses a webview as a GUI editor for a JSON file. Those JSONs are meant to include markdown texts and I would like to leverage the full power of Visual Studio Code's text editor. Basically this:
from: microsoft/vscode#87282 (comment) Problem is: I have no idea how to implement that. The Issue talks about including worker in a webview, but I'm not sure how that relates or would translate to the functionality mentioned above. Any pointers on how to achieve that would be highly appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
What's the reason for using a webview? If you want to edit "like any other file" then you can create a new filesystem scheme and call openTextDocument to open a normal editor. Your filesystem is told when the user asks VS Code to save the file. (VS Code calls writeFile) The only thing is this editor will be a normal tab. There's limited options for displaying information above or below the editor content in a normal tab. You could make sure the tab opens to the side of your webview instead of on top of it. You could also implement a notebook, that way there will be one tab with multiple cells, each "cell" is a full JSON editor. Using Monaco in a webview will be a completely separate inclusion of the text editor library, meaning it will not have the theme of VS Code, the settings won't match up, the snippets and intelligence won't match up, etc. |
Beta Was this translation helpful? Give feedback.
-
@Tommycore have you listed |
Beta Was this translation helpful? Give feedback.
What's the reason for using a webview?
If you want to edit "like any other file" then you can create a new filesystem scheme and call openTextDocument to open a normal editor. Your filesystem is told when the user asks VS Code to save the file. (VS Code calls writeFile)
The only thing is this editor will be a normal tab. There's limited options for displaying information above or below the editor content in a normal tab. You could make sure the tab opens to the side of your webview instead of on top of it.
You could also implement a notebook, that way there will be one tab with multiple cells, each "cell" is a full JSON editor.
Using Monaco in a webview will be a completely separate inclu…