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>)?

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".
But of course I will open a Phabricator task if that is the better place for 
such a discussion.

Thanks again,
Robert Vogel

-----Ursprüngliche Nachricht-----
Von: wikitech-l-boun...@lists.wikimedia.org 
[mailto:wikitech-l-boun...@lists.wikimedia.org] Im Auftrag von James Forrester
Gesendet: Mittwoch, 26. August 2015 21:53
An: Wikimedia developers <wikitech-l@lists.wikimedia.org>
Betreff: Re: [Wikitech-l] Tutorials / HowTos for VisualEditor

On 25 August 2015 at 23:30, Robert Vogel <vo...@hallowelt.com> wrote:

> Hi everybody!
>
> I want to write an extension for the VisualEditor (great work by the 
> way) and I need a little help.


First off, the easiest way to get help is to ask in IRC ( 
#mediawiki-visualeditor <irc://irc.freenode.net/mediawiki-visualeditor>) or 
file a Phabricator task asking for something specific ( 
https://phabricator.wikimedia.org/maniphest/task/create/?projects=VisualEditor
).

One thing to remember is that though VisualEditor is *complex*, it's nowhere 
near *complete* – there's a lot of functionality still to build (essentially, 
anything we've not had a need to build yet), so the answer to "what method can 
I use to do X?" is often "there isn't one, but we can build it".

That said…


> I've browsed through various documentation [1-4](and more) and already 
> learned that using RL module 'ext.visualEditor.desktopArticleTarget.init'
> and 'mw.lib.ve.addPlugin' method is the way to go. Unfortunately my 
> attempts to hook into the user interface by binding on events provided 
> by the components (like 'save' from 've.ui.MWSaveDialog' or
> 've.init.mw.Target') have not been successful yet. Maybe you could 
> give me a little push into the right direction.
>

As a general rule, don't try to bind to VisualEditor's internal events.
They're intended for internal consumption and aren't an API, and change without 
notice.
​​

​


> Are there any HowTos or Tutorials for VisualEditor that cover topics 
> like
>
> 1.       Adding buttons to the toolbar
>

​We don't have an API for this yet, partially because the current system is 
terrible and building an API just to make a breaking change to it feels unkind. 
There are a number of ways you can grab onto the private.



> 2.       Accessing the data model (e.g. retrieve all set categories from
> the Parsoid DOM)
>

Are you trying to replace the category nodes with a new one with extra 
features? If so, you'd want t​o sub-class the core one, or register a node with 
more specificity in the registry than other things (and/or de-register the 
existing one). Neither of those are very stable, though. If something else, 
file a ticket and we can discuss options.


3.       Extending/replacing a single tool (e.g. the GalleryInspector)
>

​Probably you want to sub-class the existing tool and register that with the 
same name to over-write.


4.       Binding on components events (e.g. the 'save' event, to analyze
> content and maybe abort saving)
>

​Save abort hooks are done in MediaWiki. We haven't built (and don't intend to 
ever build)​ a hooks system into VisualEditor. If you file a ticket explaining 
what you're looking to do I'd be happy to give more advice.

​Yours,
--
James D. Forrester
Lead Product Manager, Editing
Wikimedia Foundation, Inc.

jforres...@wikimedia.org | @jdforrester
_______________________________________________
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
_______________________________________________
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l

Reply via email to