I have a new problem: my content script works in developer version (joplin desktop, Windows 10). I use fs-extra to read a resource file. But in production version I get log messages: 'fs-extra could not be loaded'. The plugin is not activated for this reason.
So what do you want to do? The repository is public. For code inspection look at this. Or do you want to participate in code development? The code isn't ready yet. But if the plugin works in Joplin, I will publish it.
For postMessage I had a look at the sample code. It uses the webviewApi object. But this is only available (from my knowledge) via HTML webview. I do not have access to such a view as the sample code has with its returned link.
The plugin uses a codesection fence to insert a code section from a code source. I found this useful and did not find any existing possibility to do that. The same concept is used in the Latex Listings package.
In my plugin I write some files but I do it in the plugin thread.
The contentScript is sending a message to the plugin using webviewApi.postMessage that is writing the file based on the content inside the markdown fences.
In the meantime my plugin works. I was not aware of using content scripts in Typescript. After I renamed my two js scripts to ts and after registering the extra scripts it worked very well. Probably I do not need the approach with the messages.