mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-11-24 08:23:52 +00:00
35e97c24fe
Bug: T280745 Depends-On: Icc716563e5536b4ef33a48ba10a72f3a39bdec35 Change-Id: I5875d8aa12dee694c3e5bd7e1a980da284343722
100 lines
2.7 KiB
JavaScript
100 lines
2.7 KiB
JavaScript
var registries = require( './dt.ui.registries.js' );
|
|
|
|
/**
|
|
* DiscussionTools-specific target, inheriting from the stand-alone target
|
|
*
|
|
* @class
|
|
* @extends ve.init.mw.Target
|
|
*
|
|
* @param {mw.dt.ReplyWidgetVisual} replyWidget
|
|
* @param {Object} config Configuration options
|
|
*/
|
|
function CommentTarget( replyWidget, config ) {
|
|
config = config || {};
|
|
|
|
this.replyWidget = replyWidget;
|
|
|
|
// Parent constructor
|
|
CommentTarget.super.call( this, ve.extendObject( {
|
|
toolbarConfig: { actions: true, $overlay: true, position: 'top' }
|
|
}, 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' ),
|
|
include: [ 'bold', 'italic', 'moreTextStyle' ]
|
|
},
|
|
{
|
|
name: 'link',
|
|
include: [ 'link' ]
|
|
},
|
|
{
|
|
name: 'other',
|
|
include: [ 'usernameCompletion' ]
|
|
}
|
|
];
|
|
|
|
CommentTarget.static.importRules = ve.copy( CommentTarget.static.importRules );
|
|
|
|
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
|
|
}
|
|
);
|
|
|
|
// T280745
|
|
CommentTarget.static.convertToWikitextOnPaste = false;
|
|
|
|
CommentTarget.prototype.attachToolbar = function () {
|
|
this.replyWidget.$headerWrapper.append(
|
|
this.getToolbar().$element.append( this.replyWidget.modeTabSelect.$element )
|
|
);
|
|
this.getToolbar().$element.prepend( this.getSurface().getToolbarDialogs().$element );
|
|
};
|
|
|
|
CommentTarget.prototype.getSurfaceConfig = function ( config ) {
|
|
config = ve.extendObject( { mode: this.defaultMode }, config );
|
|
return CommentTarget.super.prototype.getSurfaceConfig.call( this, ve.extendObject( {
|
|
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,
|
|
// eslint-disable-next-line no-jquery/no-global-selector
|
|
$overlayContainer: $( '#content' )
|
|
}, config ) );
|
|
};
|
|
|
|
/* Registration */
|
|
|
|
ve.init.mw.targetFactory.register( CommentTarget );
|
|
|
|
module.exports = CommentTarget;
|