On 25 August 2015 at 23:30, Robert Vogel <vogel(a)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=VisualEdi…
).
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 to 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.
jforrester(a)wikimedia.org | @jdforrester