Page MenuHomePhabricator

Allow plugin modules to be added in JS on mobile
Closed, ResolvedPublic

Description

Right now this is only possible on desktop, and it requires annoying code:

var veState = mw.loader.getState( 'ext.visualEditor.desktopArticleTarget.init' );
if ( veState === 'loading' || veState === 'loaded' || veState === 'ready' ) {
	mw.loader.using( 'ext.visualEditor.desktopArticleTarget.init' ).done( function () {
		mw.libs.ve.addPlugin( 'modulename' );
	}
}

https://gerrit.wikimedia.org/r/c/mediawiki/extensions/VisualEditor/+/638204 implements a hook that allows the following instead:

mw.hook( 've.loadModules' ).add( function ( addPlugin ) {
	addPlugin( 'modulename' );
} );

This works on desktop and mobile, but @DLynch correctly points out that it won't work for DiscussionTools, because ArticleTargetLoader isn't used there. We'll either have to accept this limitation, or figure out a way to make it work for DT as well (and all ways that VE can be loaded more generally).

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Change 638204 had a related patch set uploaded (by Catrope; owner: Catrope):
[mediawiki/extensions/VisualEditor@master] ArticleTargetLoader: Add ve.loadModules hook

https://gerrit.wikimedia.org/r/638204

Change 638204 merged by jenkins-bot:
[mediawiki/extensions/VisualEditor@master] ArticleTargetLoader: Add ve.loadModules hook

https://gerrit.wikimedia.org/r/638204

Catrope claimed this task.

I think this is resolved, now that the patch is merged.