mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-11-27 09:43:30 +00:00
Merge ReplyWidget[Plain/Visual] modules
Only a fraction of a percentage of users are still using ReplyWidgetPlain, and keeping these modules separate: * Adds to code complexity * Adds to ResourceLoader module bloat * Causes bugs when we use VE dependencies in the core ReplyWidget class The disadvantage is that ReplyWidgetPlain will now be loading all of the VE dependencies, but this will make switching to visual mode faster. Bug: T348834 Change-Id: Ifb0cfd43fdab761c3321ad01fa9fefca26473f86
This commit is contained in:
parent
67cb2ee5b6
commit
185396a8e5
|
@ -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",
|
||||
|
|
|
@ -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' ];
|
||||
} );
|
||||
};
|
||||
|
||||
|
|
|
@ -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() );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
4
modules/dt.ui.ReplyWidget.init.js
Normal file
4
modules/dt.ui.ReplyWidget.init.js
Normal file
|
@ -0,0 +1,4 @@
|
|||
module.exports = {
|
||||
ReplyWidgetVisual: require( './dt.ui.ReplyWidgetVisual.js' ),
|
||||
ReplyWidgetPlain: require( './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 */
|
||||
|
||||
|
|
|
@ -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 */
|
||||
|
||||
|
|
Loading…
Reference in a new issue