On 27 August 2015 at 05:59, Robert Vogel vogel@hallowelt.com wrote:
Hi!
James, Florian, thank you for your responses! This will be very useful for me.
I didn't have the time to look through all of Florian's links, so maybe it's somewhere in there, but, James, can you give me a hint how to register a tool with visual editor? What is the recommended time/callback to call the 've.ui.toolFactory.register' method? mw.loader.using(<some-RL-module>)?
Yes, use ext.visualEditor.desktopArticleTarget.init for that.
If your code is 'real' and not just a gadget you can get loaded by registering as a "VisualEditorPluginModule" (see e.g. how the Math extension does this in extension.json: https://git.wikimedia.org/blob/mediawiki%2Fextensions%2FMath/b0dce0fe46dd053... and the wikihiero extension does this using the old PHP method: https://git.wikimedia.org/blob/mediawiki%2Fextensions%2Fwikihiero/e7cb93e529... ).
Regarding the 'save' event question: I want to check if a category is set and if it is not, show a message window to the user _before_ he/she can save. I've already implemented a serverside check and the API returns an error if no category is set. But this API error message cannot be styled/customized and it gets displayed _after_ the user clicked "save".
Interesting idea.
We've got vague plans for a system of pre-save suggestions/reminders/warnings/errors, but we've not started designing it yet, so there's nothing into which to register, sorry.
But of course I will open a Phabricator task if that is the better place for such a discussion.
Please do.
Yours,