mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-11-24 16:34:21 +00:00
Merge "Config: Separate useVisualEditor into enableVisual and use2017Wikitext"
This commit is contained in:
commit
6ee5865228
|
@ -34,9 +34,10 @@
|
|||
]
|
||||
},
|
||||
{
|
||||
"name": "controller/config.json",
|
||||
"name": "config.json",
|
||||
"config": {
|
||||
"useVisualEditor": "DiscussionToolsUseVisualEditor"
|
||||
"enableVisual": "DiscussionToolsEnableVisual",
|
||||
"enable2017Wikitext": "DiscussionToolsEnable2017Wikitext"
|
||||
}
|
||||
},
|
||||
"CommentController.js",
|
||||
|
@ -233,9 +234,13 @@
|
|||
"value": false,
|
||||
"description": "Make DiscussionTools a BetaFeature."
|
||||
},
|
||||
"DiscussionToolsUseVisualEditor": {
|
||||
"DiscussionToolsEnableVisual": {
|
||||
"value": false,
|
||||
"description": "Use VisualEditor for editing replies (both visual and wikitext)."
|
||||
"description": "Enable a visual mode for replies."
|
||||
},
|
||||
"DiscussionToolsEnable2017Wikitext": {
|
||||
"value": false,
|
||||
"description": "Enable the 2017 wikitext editor for wikitext replies (not yet supported)."
|
||||
},
|
||||
"DTSchemaEditAttemptStepSamplingRate": {
|
||||
"value": false,
|
||||
|
|
|
@ -5,12 +5,13 @@ var
|
|||
logger = require( './logger.js' ),
|
||||
storage = mw.storage.session,
|
||||
scrollPadding = { top: 10, bottom: 10 },
|
||||
config = require( './controller/config.json' ),
|
||||
config = require( './config.json' ),
|
||||
// TODO: Remember last editor used
|
||||
useVisual = config.useVisualEditor || ( new mw.Uri() ).query.dtvisual;
|
||||
defaultVisual = false,
|
||||
enableVisual = config.enableVisual || ( new mw.Uri() ).query.dtvisual;
|
||||
|
||||
// Start loading reply widget code
|
||||
if ( useVisual ) {
|
||||
if ( defaultVisual && enableVisual ) {
|
||||
mw.loader.using( 'ext.discussionTools.ReplyWidgetVisual' );
|
||||
} else {
|
||||
mw.loader.using( 'ext.discussionTools.ReplyWidgetPlain' );
|
||||
|
@ -135,10 +136,9 @@ CommentController.prototype.setup = function () {
|
|||
action: 'init',
|
||||
type: 'page',
|
||||
mechanism: 'click',
|
||||
// TODO: when we have actual visual mode, this needs to do better at
|
||||
// working out which will be used:
|
||||
// TODO: Use 'wikitext-2017' when config.enable2017Wikitext is set
|
||||
// eslint-disable-next-line camelcase
|
||||
editor_interface: useVisual ? 'wikitext-2017' : 'wikitext'
|
||||
editor_interface: defaultVisual ? 'visual' : 'wikitext'
|
||||
} );
|
||||
|
||||
this.$replyLinkButtons.addClass( 'dt-init-replylink-active' );
|
||||
|
@ -189,7 +189,7 @@ CommentController.prototype.getReplyWidgetClass = function ( visual ) {
|
|||
var moduleName;
|
||||
|
||||
if ( visual === undefined ) {
|
||||
visual = useVisual;
|
||||
visual = defaultVisual;
|
||||
}
|
||||
|
||||
moduleName = visual ? 'ext.discussionTools.ReplyWidgetVisual' : 'ext.discussionTools.ReplyWidgetPlain';
|
||||
|
@ -203,6 +203,7 @@ CommentController.prototype.createReplyWidget = function ( parsoidData, visual )
|
|||
|
||||
return this.getReplyWidgetClass( visual ).then( function ( ReplyWidget ) {
|
||||
return new ReplyWidget( commentController, parsoidData, {
|
||||
switchable: enableVisual,
|
||||
input: {
|
||||
authors: parser.getAuthors( commentController.thread )
|
||||
}
|
||||
|
|
|
@ -26,5 +26,6 @@ module.exports = {
|
|||
parser: require( './parser.js' ),
|
||||
modifier: require( './modifier.js' ),
|
||||
utils: require( './utils.js' ),
|
||||
logger: require( './logger.js' )
|
||||
logger: require( './logger.js' ),
|
||||
config: require( './config.json' )
|
||||
};
|
||||
|
|
|
@ -12,6 +12,7 @@ var controller = require( 'ext.discussionTools.init' ).controller,
|
|||
* @param {Object} parsoidData Result from controller#getParsoidCommentData
|
||||
* @param {Object} [config] Configuration options
|
||||
* @param {Object} [config.input] Configuration options for the comment input widget
|
||||
* @param {boolean} [config.switchable] Widget can switch modes (visual/source)
|
||||
*/
|
||||
function ReplyWidget( commentController, parsoidData, config ) {
|
||||
var returnTo, contextNode, inputConfig,
|
||||
|
@ -106,12 +107,15 @@ function ReplyWidget( commentController, parsoidData, config ) {
|
|||
|
||||
// Initialization
|
||||
this.$element.addClass( 'dt-ui-replyWidget' ).append(
|
||||
this.modeTabSelect.$element,
|
||||
this.replyBodyWidget.$element,
|
||||
this.$preview,
|
||||
this.$actionsWrapper
|
||||
);
|
||||
|
||||
if ( config.switchable ) {
|
||||
this.$element.prepend( this.modeTabSelect.$element );
|
||||
}
|
||||
|
||||
if ( mw.user.isAnon() ) {
|
||||
returnTo = {
|
||||
returntoquery: encodeURIComponent( window.location.search ),
|
||||
|
|
|
@ -16,7 +16,7 @@ function ReplyWidgetVisual() {
|
|||
// Parent constructor
|
||||
ReplyWidgetVisual.super.apply( this, arguments );
|
||||
|
||||
// TODO: Use user preference
|
||||
// TODO: Support 2017 wikitext editor
|
||||
this.defaultMode = 'visual';
|
||||
this.initialValue = null;
|
||||
|
||||
|
|
Loading…
Reference in a new issue