Page MenuHomePhabricator

Allow people to add customized buttons to OOUI/VE toolbar in an easy way
Open, LowPublic40 Estimated Story Points

Description

Many users have customized buttons on wikis. Some buttons are gadgets, others are created from scratch for very particular purposes. You can have buttons to preload pre-formatted messages or to insert you favorite templates.

At the moment, it is complicated for a typical user to add customized buttons to the visual editor or Flow.

See also:

Event Timeline

Well, "no possibility" is not true. But it's not as easy as with WikiEditor or the old toolbar:

function makeMyTool () {
	var insert = [{
		type: 'mwTransclusion',
		attributes: {
			mw: {
				parts: [{
					template: {
						target: {
							href: 'Template:MyTemplate',
							wt: 'MyTemplate'
						},
						params: {
							1: {
								wt: 'my parameter'
							}
						}
					}
				}]
			}
		}
	}];

	function MyTool (toolGroup, conf) {
		ve.ui.MWTransclusionDialogTool.call(this, toolGroup, conf);
	}
	OO.inheritClass(MyTool, ve.ui.MWTransclusionDialogTool);

	MyTool.static.name = 'mytool';
	MyTool.static.group = 'object';
	MyTool.static.title = 'My tool';
	MyTool.static.commandName = 'mycommand';
	ve.ui.toolFactory.register(MyTool);

	ve.ui.commandRegistry.register(
		new ve.ui.Command('mycommand', 'content', 'insert', {
			args: [insert, false, true],
			supportedSelections: ['linear']
		})
	);
}

mw.loader.using('ext.visualEditor.desktopArticleTarget.init').done(function () {
	mw.libs.ve.addPlugin(function () {
		return mw.loader.using(['ext.visualEditor.core', 'ext.visualEditor.mwtransclusion'])
			.done(function () {
				makeMyTool();
			});
	});
});
Trizek-WMF renamed this task from Allow people to add customized buttons to VE toolbar to Allow people to add customized buttons to VE toolbar by an easy way.May 25 2016, 2:35 PM

I can't do anything else than renaming the task.

The above snippet isn't that complicated for a gadget. See also https://www.mediawiki.org/wiki/VisualEditor/Gadgets

Generating linear model data for a template is probably going to be more complex than generating wikitext, but that is unavoidable.

The above snippet isn't that complicated for a gadget.

If by gadget you mean "add a button which will preload a template", it is complicated for people like me, lazy and not code-enthusiasts. That's obvious if I compare it with how I've created my customized buttons.

Jdforrester-WMF renamed this task from Allow people to add customized buttons to VE toolbar by an easy way to Allow people to add customized buttons to OOUI/VE toolbar in an easy way.May 31 2016, 7:15 PM
Jdforrester-WMF triaged this task as Low priority.
Jdforrester-WMF set the point value for this task to 40.
Jdforrester-WMF moved this task from To Triage to Freezer on the VisualEditor board.