Adding a button to the MenuBar

I am trying to add an image chooser. I couldn’t work out how to add a button to the menubar, so I launch the image chooser with a button outside of ProseMirror. The problem with this (apart from UX) is that the cursor position is lost so images are always inserted at the start of the editor content.

How do I add a button to the menubar that runs some javascript (to launch the filepicker)?

Is it possible to populate the ‘Image Url’ field of the Insert Image dialog instead of inserting the image directly? (using execCommand(‘image:insert’, [url, “”, “”]) at the moment).

Thank you.

Firstly, this is all going to be a lot easier to do in the upcoming 0.8.0 release.

But you should be able to use the old selection after closing your form – when ProseMirror loses focus, it preserves the last selection.

I don’t understand what you are asking about populating the field in the dialog – of course you can, just put some value in there. In the 0.7.0 system, that’s done by providing a default for the command parameter (but in the master branch command parameters don’t exist anymore, and you’re expected to just create the dialog entirely in your own code).