how difficult was that process? I've been consider...
# devlog-together
j
how difficult was that process? I've been considering attempting something similar to allow me to edit sample code in VS Code without having to run the Blawx server.
m
Not that difficult but there are some things to be aware of. I'll post some info here later this morning. And we can always jump on a call if needed (I am in the Netherlands, timezone wise)
I used the custom text editor example from https://github.com/microsoft/vscode-extension-samples/tree/main/custom-editor-sample and got that running first. It has two parts: the extension and the editor itself. In the example the extension is coded in typescript and the editor in vanilla-js. The extension together with some settings in package.json registers commands and event listeners.. and from within the extension you create a webview. This webview is basically an iframe which loads the editor javascript. You also provide html for the webview from within the extension. The communication between webview and extension is done using window.postMessage, but nothing complex. In my case the editor is build with typescript as well.. so I have a separate build and bundling proces using vite (I use react with my own set of visual editor components). A thing to watch out for is that you will have 2 sets of tsconfigs which need to cancel each other out (one for the extension and one for the editor).. using a monorepo might be better (tldraw does that). Another thing is that the webview has content security policies, depending on the assets that you use, you might need some extra configuration.
j
Thanks. We have different perspectives on "not that difficult", I guess, but that's very helpful!
m
You can do it!😀 and if you need some help then don't be hesitant to contact me and perhaps I can help😊. Good luck!
j
I will take you up on that. Probably not soon, though. Thanks again!
m
Just curious : do you have a typescript codebase and what bundler do you currently use?
j
I don't, no. I do a little JavaScript (badly), and I use the blockly library that is in the process of being upgraded to typescript by Google.