diff --git a/extension.json b/extension.json index 85bdff69a..10e00184e 100644 --- a/extension.json +++ b/extension.json @@ -188,7 +188,10 @@ }, "ext.discussionTools.ReplyWidget": { "packageFiles": [ + "dt.ui.ReplyWidget.init.js", "dt.ui.ReplyWidget.js", + "dt.ui.ReplyWidgetVisual.js", + "dt.ui.ReplyWidgetPlain.js", "ModeTabSelectWidget.js", "ModeTabOptionWidget.js", "AbandonCommentDialog.js", @@ -204,10 +207,21 @@ "name": "licenseMessages.json", "callback": "\\MediaWiki\\Extension\\DiscussionTools\\ResourceLoaderData::getTermsOfUseMessagesParsed", "versionCallback": "\\MediaWiki\\Extension\\DiscussionTools\\ResourceLoaderData::getTermsOfUseMessagesVersion" - } + }, + "dt-ve/CommentTarget.js", + "dt-ve/CommentTargetWidget.js", + "dt-ve/dt.dm.MWSignatureNode.js", + "dt-ve/dt.ce.MWSignatureNode.js", + "dt-ve/dt.ui.MWSignatureContextItem.js", + "dt-ve/dt.ui.registries.js", + "dt-ve/dt.ui.UsernameCompletionAction.js", + "dt-ve/dt.ui.UsernameCompletionTool.js", + "dt-ve/dt.dm.PingNode.js", + "dt-ve/dt.ce.PingNode.js" ], "styles": [ - "dt.ui.ReplyWidget.less" + "dt.ui.ReplyWidget.less", + "dt-ve/CommentTargetWidget.less" ], "messages": [ "discussiontools-replywidget-abandon", @@ -236,6 +250,8 @@ "discussiontools-replywidget-reply", "discussiontools-replywidget-return-to-newtopic", "discussiontools-replywidget-return-to-reply", + "discussiontools-replywidget-signature-body", + "discussiontools-replywidget-signature-title", "discussiontools-replywidget-summary", "discussiontools-replywidget-transcluded", "ooui-popup-widget-close-button-aria-label", @@ -245,11 +261,19 @@ "visualeditor-mweditmode-tooltip" ], "dependencies": [ - "oojs-ui-widgets", - "oojs-ui.styles.indicators", "ext.discussionTools.init", + "ext.visualEditor.articleTarget", + "ext.visualEditor.mwcore", + "ext.visualEditor.mwsignature", + "ext.visualEditor.mwwikitext", + "ext.visualEditor.switching", + "mediawiki.editfont.styles", + "mediawiki.jqueryMsg", + "mediawiki.user", "mediawiki.widgets.AbandonEditDialog", - "mediawiki.widgets.visibleLengthLimit" + "mediawiki.widgets.visibleLengthLimit", + "oojs-ui-widgets", + "oojs-ui.styles.indicators" ], "optionalDependencies": { "ConfirmEdit": "ext.confirmEdit.CaptchaInputWidget" @@ -259,55 +283,6 @@ "desktop", "mobile" ] - }, - "ext.discussionTools.ReplyWidgetPlain": { - "packageFiles": [ - "dt.ui.ReplyWidgetPlain.js" - ], - "dependencies": [ - "ext.discussionTools.ReplyWidget", - "mediawiki.editfont.styles", - "mediawiki.user", - "mediawiki.jqueryMsg", - "ext.visualEditor.switching" - ], - "targets": [ - "desktop", - "mobile" - ] - }, - "ext.discussionTools.ReplyWidgetVisual": { - "packageFiles": [ - "dt.ui.ReplyWidgetVisual.js", - "dt-ve/CommentTarget.js", - "dt-ve/CommentTargetWidget.js", - "dt-ve/dt.dm.MWSignatureNode.js", - "dt-ve/dt.ce.MWSignatureNode.js", - "dt-ve/dt.ui.MWSignatureContextItem.js", - "dt-ve/dt.ui.registries.js", - "dt-ve/dt.ui.UsernameCompletionAction.js", - "dt-ve/dt.ui.UsernameCompletionTool.js", - "dt-ve/dt.dm.PingNode.js", - "dt-ve/dt.ce.PingNode.js" - ], - "styles": [ - "dt-ve/CommentTargetWidget.less" - ], - "messages": [ - "discussiontools-replywidget-signature-title", - "discussiontools-replywidget-signature-body" - ], - "dependencies": [ - "ext.discussionTools.ReplyWidget", - "ext.visualEditor.mwcore", - "ext.visualEditor.mwsignature", - "ext.visualEditor.mwwikitext", - "ext.visualEditor.articleTarget" - ], - "targets": [ - "desktop", - "mobile" - ] } }, "ForeignResourcesDir": "modules/lib", diff --git a/modules/CommentController.js b/modules/CommentController.js index 314ce54ec..3fafb9944 100644 --- a/modules/CommentController.js +++ b/modules/CommentController.js @@ -299,8 +299,8 @@ CommentController.prototype.getReplyWidgetClass = function ( visual ) { // If 2017WTE mode is enabled, always use ReplyWidgetVisual. visual = visual || enable2017Wikitext; - return mw.loader.using( controller.getReplyWidgetModules( visual ) ).then( function () { - return require( visual ? 'ext.discussionTools.ReplyWidgetVisual' : 'ext.discussionTools.ReplyWidgetPlain' ); + return mw.loader.using( controller.getReplyWidgetModules() ).then( function () { + return require( 'ext.discussionTools.ReplyWidget' )[ visual ? 'ReplyWidgetVisual' : 'ReplyWidgetPlain' ]; } ); }; diff --git a/modules/controller.js b/modules/controller.js index 4a427c665..e993c1acd 100644 --- a/modules/controller.js +++ b/modules/controller.js @@ -257,31 +257,26 @@ function getCheckboxesPromise( pageName, oldId ) { /** * Get the resourceloader modules required for a mode of the reply widget * - * @param {boolean} visual Prefer the VE-based class * @return {string[]} */ -function getReplyWidgetModules( visual ) { - if ( !visual ) { - return [ 'ext.discussionTools.ReplyWidgetPlain' ]; - } - +function getReplyWidgetModules() { var veConf = mw.config.get( 'wgVisualEditorConfig' ), - visualModules = [ 'ext.discussionTools.ReplyWidgetVisual' ] + modules = [ 'ext.discussionTools.ReplyWidget' ] .concat( veConf.pluginModules.filter( mw.loader.getState ) ); if ( OO.ui.isMobile() ) { - visualModules = [ + modules = [ 'ext.visualEditor.core.mobile', 'ext.visualEditor.mwextensions' - ].concat( visualModules ); + ].concat( modules ); } else { - visualModules = [ + modules = [ 'ext.visualEditor.core.desktop', 'ext.visualEditor.desktopTarget', 'ext.visualEditor.mwextensions.desktop' - ].concat( visualModules ); + ].concat( modules ); } - return visualModules; + return modules; } /** @@ -350,7 +345,7 @@ function init( $container, state ) { // and the add-topic link suppressed, *but* which has valid links to // trigger the new topic tool within the content. If that happens, // the modules will still be loaded when those links are interacted with. - mw.loader.using( getReplyWidgetModules( defaultVisual || enable2017Wikitext ) ); + mw.loader.using( getReplyWidgetModules() ); } /** diff --git a/modules/dt.ui.ReplyWidget.init.js b/modules/dt.ui.ReplyWidget.init.js new file mode 100644 index 000000000..ea9a347e9 --- /dev/null +++ b/modules/dt.ui.ReplyWidget.init.js @@ -0,0 +1,4 @@ +module.exports = { + ReplyWidgetVisual: require( './dt.ui.ReplyWidgetVisual.js' ), + ReplyWidgetPlain: require( './dt.ui.ReplyWidgetPlain.js' ) +}; diff --git a/modules/dt.ui.ReplyWidgetPlain.js b/modules/dt.ui.ReplyWidgetPlain.js index f1a7235d7..74d15c2a3 100644 --- a/modules/dt.ui.ReplyWidgetPlain.js +++ b/modules/dt.ui.ReplyWidgetPlain.js @@ -50,7 +50,7 @@ function ReplyWidgetPlain() { /* Inheritance */ -OO.inheritClass( ReplyWidgetPlain, require( 'ext.discussionTools.ReplyWidget' ) ); +OO.inheritClass( ReplyWidgetPlain, require( './dt.ui.ReplyWidget.js' ) ); /* Methods */ diff --git a/modules/dt.ui.ReplyWidgetVisual.js b/modules/dt.ui.ReplyWidgetVisual.js index 7ff3737a1..56e108cbf 100644 --- a/modules/dt.ui.ReplyWidgetVisual.js +++ b/modules/dt.ui.ReplyWidgetVisual.js @@ -31,7 +31,7 @@ function ReplyWidgetVisual( commentController, commentDetails, config ) { /* Inheritance */ -OO.inheritClass( ReplyWidgetVisual, require( 'ext.discussionTools.ReplyWidget' ) ); +OO.inheritClass( ReplyWidgetVisual, require( './dt.ui.ReplyWidget.js' ) ); /* Methods */