2024-01-23 20:58:23 +00:00
|
|
|
require( './CommentTarget.js' );
|
|
|
|
|
2019-11-05 14:07:50 +00:00
|
|
|
/**
|
|
|
|
* DiscussionTools TargetWidget class
|
|
|
|
*
|
|
|
|
* @class
|
|
|
|
* @extends ve.ui.MWTargetWidget
|
|
|
|
*
|
|
|
|
* @constructor
|
2021-02-28 22:06:12 +00:00
|
|
|
* @param {mw.dt.ReplyWidgetVisual} replyWidget
|
2019-11-05 14:07:50 +00:00
|
|
|
* @param {Object} [config] Configuration options
|
|
|
|
*/
|
2021-02-28 22:06:12 +00:00
|
|
|
function CommentTargetWidget( replyWidget, config ) {
|
2022-07-30 23:57:22 +00:00
|
|
|
var excludeCommands = [
|
|
|
|
'blockquoteWrap', // T258194
|
|
|
|
// Disable to allow Tab/Shift+Tab to move focus out of the widget (T172694)
|
|
|
|
'indent',
|
|
|
|
'outdent',
|
|
|
|
// Save commands get loaded from articletarget module, which we load
|
|
|
|
// to get the edit switching tool for mobile
|
|
|
|
'showSave',
|
|
|
|
'showChanges',
|
|
|
|
'showPreview',
|
|
|
|
'saveMinoredit',
|
|
|
|
'saveWatchthis'
|
|
|
|
];
|
|
|
|
|
|
|
|
if ( !replyWidget.isNewTopic ) {
|
|
|
|
excludeCommands = excludeCommands.concat( [
|
|
|
|
// Disable commands for things whose wikitext markup doesn't work when indented
|
2020-02-06 23:48:26 +00:00
|
|
|
'heading1',
|
|
|
|
'heading2',
|
|
|
|
'heading3',
|
|
|
|
'heading4',
|
|
|
|
'heading5',
|
|
|
|
'heading6',
|
2020-06-03 18:26:49 +00:00
|
|
|
'insertTable',
|
2020-07-17 22:25:15 +00:00
|
|
|
'transclusionFromSequence', // T253667
|
2022-07-30 23:57:22 +00:00
|
|
|
'preformatted'
|
|
|
|
] );
|
|
|
|
}
|
|
|
|
|
|
|
|
config = $.extend( {}, {
|
|
|
|
excludeCommands: excludeCommands
|
2020-02-06 23:48:26 +00:00
|
|
|
}, config );
|
|
|
|
|
2021-02-28 22:06:12 +00:00
|
|
|
this.replyWidget = replyWidget;
|
2019-12-10 16:18:24 +00:00
|
|
|
this.authors = config.authors;
|
|
|
|
|
2019-11-05 14:07:50 +00:00
|
|
|
// Parent constructor
|
2020-02-06 23:48:26 +00:00
|
|
|
CommentTargetWidget.super.call( this, config );
|
2019-11-05 14:07:50 +00:00
|
|
|
|
|
|
|
// Initialization
|
2021-03-13 14:39:39 +00:00
|
|
|
this.$element.addClass( 'ext-discussiontools-ui-targetWidget' );
|
2019-11-05 14:07:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Inheritance */
|
|
|
|
|
|
|
|
OO.inheritClass( CommentTargetWidget, ve.ui.MWTargetWidget );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
CommentTargetWidget.prototype.createTarget = function () {
|
2024-01-23 17:18:31 +00:00
|
|
|
return ve.init.mw.targetFactory.create( 'discussionTools', this.replyWidget, {
|
2019-11-05 14:07:50 +00:00
|
|
|
// A lot of places expect ve.init.target to exist...
|
|
|
|
register: true,
|
|
|
|
toolbarGroups: this.toolbarGroups,
|
|
|
|
modes: this.modes,
|
|
|
|
defaultMode: this.defaultMode
|
|
|
|
} );
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
CommentTargetWidget.prototype.setDocument = function ( docOrHtml ) {
|
2020-09-21 20:13:35 +00:00
|
|
|
var mode = this.target.getDefaultMode(),
|
|
|
|
doc = ( mode === 'visual' && typeof docOrHtml === 'string' ) ?
|
|
|
|
this.target.parseDocument( docOrHtml ) :
|
|
|
|
docOrHtml,
|
2020-05-20 21:26:09 +00:00
|
|
|
// TODO: This could be upstreamed:
|
2020-09-21 20:13:35 +00:00
|
|
|
dmDoc = this.target.constructor.static.createModelFromDom( doc, mode );
|
2019-11-05 14:07:50 +00:00
|
|
|
|
|
|
|
// Parent method
|
2020-05-20 21:26:09 +00:00
|
|
|
CommentTargetWidget.super.prototype.setDocument.call( this, dmDoc );
|
2019-11-05 14:07:50 +00:00
|
|
|
|
|
|
|
// Remove MW specific classes as the widget is already inside the content area
|
|
|
|
this.getSurface().getView().$element.removeClass( 'mw-body-content' );
|
|
|
|
this.getSurface().$placeholder.removeClass( 'mw-body-content' );
|
2019-12-10 16:18:24 +00:00
|
|
|
|
2020-07-13 16:45:06 +00:00
|
|
|
// Fix jquery.ime position (T255191)
|
|
|
|
this.getSurface().getView().getDocument().getDocumentNode().$element.addClass( 'ime-position-inside' );
|
|
|
|
|
2019-12-10 16:18:24 +00:00
|
|
|
// HACK
|
|
|
|
this.getSurface().authors = this.authors;
|
2019-11-05 14:07:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = CommentTargetWidget;
|