From e7a9185ab1f9ad6bdb07e6fcf0bddd72626a55e7 Mon Sep 17 00:00:00 2001 From: Ed Sanders Date: Wed, 24 Jun 2020 19:09:27 +0100 Subject: [PATCH] Load VisualEditor plugin modules with ReplyWidgetVisual Bug: T256292 Change-Id: Id05ad1871093e8941e54b2db8c9a76cecaac1033 --- modules/CommentController.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/modules/CommentController.js b/modules/CommentController.js index d89f5b451..5222d8c7d 100644 --- a/modules/CommentController.js +++ b/modules/CommentController.js @@ -10,13 +10,17 @@ var config = require( './config.json' ), enableVisual = config.enableVisual || ( new mw.Uri() ).query.dtvisual, defaultEditMode = mw.user.options.get( 'discussiontools-editmode' ) || mw.config.get( 'wgDiscussionToolsFallbackEditMode' ), - defaultVisual = enableVisual && defaultEditMode === 'visual'; + defaultVisual = enableVisual && defaultEditMode === 'visual', + conf = mw.config.get( 'wgVisualEditorConfig' ), + visualModules = [ 'ext.discussionTools.ReplyWidgetVisual' ] + .concat( conf.pluginModules.filter( mw.loader.getState ) ), + plainModules = [ 'ext.discussionTools.ReplyWidgetPlain' ]; // Start loading reply widget code if ( defaultVisual ) { - mw.loader.using( 'ext.discussionTools.ReplyWidgetVisual' ); + mw.loader.using( visualModules ); } else { - mw.loader.using( 'ext.discussionTools.ReplyWidgetPlain' ); + mw.loader.using( plainModules ); } function CommentController( $pageContainer, comment, thread ) { @@ -208,15 +212,12 @@ CommentController.prototype.setup = function ( mode ) { }; CommentController.prototype.getReplyWidgetClass = function ( visual ) { - var moduleName; - if ( visual === undefined ) { visual = defaultVisual; } - moduleName = visual ? 'ext.discussionTools.ReplyWidgetVisual' : 'ext.discussionTools.ReplyWidgetPlain'; - return mw.loader.using( moduleName ).then( function () { - return require( moduleName ); + return mw.loader.using( visual ? visualModules : plainModules ).then( function () { + return require( visual ? 'ext.discussionTools.ReplyWidgetVisual' : 'ext.discussionTools.ReplyWidgetPlain' ); } ); };