2020-04-08 18:23:22 +00:00
|
|
|
var
|
|
|
|
registries = require( './dt.ui.registries.js' );
|
|
|
|
|
2019-11-05 14:07:50 +00:00
|
|
|
/**
|
|
|
|
* DiscussionTools-specific target, inheriting from the stand-alone target
|
|
|
|
*
|
|
|
|
* @class
|
|
|
|
* @extends ve.init.mw.Target
|
|
|
|
*
|
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 CommentTarget( replyWidget, config ) {
|
2019-11-05 14:07:50 +00:00
|
|
|
config = config || {};
|
|
|
|
|
2021-02-28 22:06:12 +00:00
|
|
|
this.replyWidget = replyWidget;
|
|
|
|
|
2019-11-05 14:07:50 +00:00
|
|
|
// Parent constructor
|
|
|
|
CommentTarget.super.call( this, ve.extendObject( {
|
2020-04-27 15:42:35 +00:00
|
|
|
toolbarConfig: { actions: true, $overlay: true, position: 'top' }
|
2019-11-05 14:07:50 +00:00
|
|
|
}, config ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Inheritance */
|
|
|
|
|
|
|
|
OO.inheritClass( CommentTarget, ve.init.mw.Target );
|
|
|
|
|
|
|
|
/* Static methods */
|
|
|
|
|
|
|
|
CommentTarget.static.name = 'discussionTools';
|
|
|
|
|
|
|
|
CommentTarget.static.modes = [ 'visual', 'source' ];
|
|
|
|
|
|
|
|
CommentTarget.static.toolbarGroups = [
|
|
|
|
{
|
|
|
|
name: 'style',
|
|
|
|
title: OO.ui.deferMsg( 'visualeditor-toolbar-style-tooltip' ),
|
2020-04-27 15:42:35 +00:00
|
|
|
include: [ 'bold', 'italic', 'moreTextStyle' ]
|
2019-11-05 14:07:50 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'link',
|
|
|
|
include: [ 'link' ]
|
2020-06-11 14:56:17 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'other',
|
|
|
|
include: [ 'usernameCompletion' ]
|
2019-11-05 14:07:50 +00:00
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
CommentTarget.static.importRules = ve.copy( CommentTarget.static.importRules );
|
2020-02-06 23:48:26 +00:00
|
|
|
|
|
|
|
CommentTarget.static.importRules.external.conversions = ve.extendObject(
|
|
|
|
{},
|
|
|
|
CommentTarget.static.importRules.external.conversions,
|
|
|
|
{
|
|
|
|
mwHeading: 'paragraph'
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
CommentTarget.static.importRules.external.blacklist = ve.extendObject(
|
|
|
|
{},
|
|
|
|
CommentTarget.static.importRules.external.blacklist,
|
|
|
|
{
|
|
|
|
// Annotations
|
|
|
|
// Allow pasting external links
|
|
|
|
'link/mwExternal': false,
|
|
|
|
// Strip all table structure
|
|
|
|
mwTable: true,
|
|
|
|
tableSection: true,
|
|
|
|
tableRow: true,
|
|
|
|
tableCell: true
|
|
|
|
}
|
|
|
|
);
|
2019-11-05 14:07:50 +00:00
|
|
|
|
|
|
|
CommentTarget.prototype.attachToolbar = function () {
|
2021-02-28 22:08:54 +00:00
|
|
|
this.replyWidget.$headerWrapper.append(
|
|
|
|
this.getToolbar().$element.append( this.replyWidget.modeTabSelect.$element )
|
|
|
|
);
|
|
|
|
this.getToolbar().$element.prepend( this.getSurface().getToolbarDialogs().$element );
|
2019-11-05 14:07:50 +00:00
|
|
|
};
|
|
|
|
|
2020-04-30 13:06:57 +00:00
|
|
|
CommentTarget.prototype.getSurfaceConfig = function ( config ) {
|
2020-09-21 20:13:35 +00:00
|
|
|
config = ve.extendObject( { mode: this.defaultMode }, config );
|
2020-04-30 13:06:57 +00:00
|
|
|
return CommentTarget.super.prototype.getSurfaceConfig.call( this, ve.extendObject( {
|
2020-09-21 20:13:35 +00:00
|
|
|
commandRegistry: config.mode === 'source' ? registries.wikitextCommandRegistry : registries.commandRegistry,
|
|
|
|
sequenceRegistry: config.mode === 'source' ? registries.wikitextSequenceRegistry : registries.sequenceRegistry,
|
|
|
|
dataTransferHandlerFactory: config.mode === 'source' ? ve.ui.wikitextDataTransferHandlerFactory : ve.ui.dataTransferHandlerFactory,
|
2020-04-30 13:06:57 +00:00
|
|
|
// eslint-disable-next-line no-jquery/no-global-selector
|
|
|
|
$overlayContainer: $( '#content' )
|
|
|
|
}, config ) );
|
|
|
|
};
|
|
|
|
|
2019-11-05 14:07:50 +00:00
|
|
|
/* Registration */
|
|
|
|
|
|
|
|
ve.init.mw.targetFactory.register( CommentTarget );
|
|
|
|
|
|
|
|
module.exports = CommentTarget;
|