Still not sure if CodeMirror can act as a form though.
Regardless, I need a way to send in the 2 notes into the Webview. I don't think I can simply just hardcode them into the HTML as well..? As the DOM of CodeMirror is dynamically created?
Sounds like you could set the note content when you create the view, without the need for sending messages. Then to get the note back, the view can send messages to the plugin.
Right, I think it came up before but the issue is that dialogs are supposed to be modal. So the user makes some changes, click Save, the modal is closed and you get the result back. Is there something more you'd need?
Hm. Yeah I still need to try that. My concern is that I'm unsure if CodeMirror can act a normal input field. (In order to get it's contents sent by Joplin).
Anyways,
I have another issue though that's stopping me, For some reason when Joplin is loading webview scripts, it somehow doesn't load them in correct order.
I will get an error that CodeMirror doesn't exist even though it's right there, as if it tried to load all scripts at once on dialog open.
The only way I got it to work is by delaying the call await dialogs.addScript(diffViewDialog, './UI/codemirror/addon/merge/merge.js'); until after the open function is called. (So that the view would be loaded already). But this solution isn't practical, I have to assume it's just a bug in Joplin that can be fixed ?
It doesn't have to. You're in control of the dialog content, so you can dynamically create hidden input fields and set the content to anything you want, which will be picked up by the dialog when it's closed.
I just noticed, the intended way to use dialogs is to create it once when loading the plugin. And then use .open when it's needed. So I'm back to step 1. A delay wouldn't work or else I'd have to create a new dialog every time.