2015-11-08 17:05:33 +00:00
|
|
|
/*!
|
|
|
|
* VisualEditor MediaWiki UserInterface signature tool class.
|
|
|
|
*
|
2018-01-03 00:54:47 +00:00
|
|
|
* @copyright 2011-2018 VisualEditor Team and others; see AUTHORS.txt
|
2015-11-08 17:05:33 +00:00
|
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* MediaWiki UserInterface signature tool. This defines the menu button and its action.
|
|
|
|
*
|
|
|
|
* @class
|
|
|
|
* @extends ve.ui.MWTransclusionDialogTool
|
|
|
|
* @constructor
|
|
|
|
* @param {OO.ui.ToolGroup} toolGroup
|
|
|
|
* @param {Object} [config] Configuration options
|
|
|
|
*/
|
2016-08-22 21:44:59 +00:00
|
|
|
ve.ui.MWSignatureTool = function VeUiMWSignatureTool() {
|
2015-11-08 17:05:33 +00:00
|
|
|
// Parent constructor
|
2016-08-22 21:44:59 +00:00
|
|
|
ve.ui.MWSignatureTool.super.apply( this, arguments );
|
2015-11-08 17:05:33 +00:00
|
|
|
};
|
|
|
|
OO.inheritClass( ve.ui.MWSignatureTool, ve.ui.MWTransclusionDialogTool );
|
|
|
|
|
|
|
|
ve.ui.MWSignatureTool.static.name = 'mwSignature';
|
|
|
|
ve.ui.MWSignatureTool.static.group = 'object';
|
|
|
|
ve.ui.MWSignatureTool.static.icon = 'signature';
|
|
|
|
ve.ui.MWSignatureTool.static.title =
|
|
|
|
OO.ui.deferMsg( 'visualeditor-mwsignature-tool' );
|
|
|
|
ve.ui.MWSignatureTool.static.modelClasses = [ ve.dm.MWSignatureNode ];
|
|
|
|
// Link the tool to the command defined below
|
|
|
|
ve.ui.MWSignatureTool.static.commandName = 'mwSignature';
|
|
|
|
|
|
|
|
ve.ui.toolFactory.register( ve.ui.MWSignatureTool );
|
|
|
|
|
2018-11-27 17:34:39 +00:00
|
|
|
// Commands and sequences are only registered on supported namespaces.
|
|
|
|
// On other namespaces the tool is still shown, but disabled.
|
|
|
|
if ( mw.Title.wantSignaturesNamespace( mw.config.get( 'wgNamespaceNumber' ) ) ) {
|
2015-11-08 17:05:33 +00:00
|
|
|
// Command to insert signature node.
|
|
|
|
ve.ui.commandRegistry.register(
|
|
|
|
new ve.ui.Command( 'mwSignature', 'content', 'insert', {
|
|
|
|
args: [
|
|
|
|
[
|
|
|
|
{ type: 'mwSignature' },
|
|
|
|
{ type: '/mwSignature' }
|
|
|
|
],
|
|
|
|
// annotate
|
|
|
|
false,
|
|
|
|
// collapseToEnd
|
|
|
|
true
|
2015-11-18 06:08:23 +00:00
|
|
|
],
|
|
|
|
supportedSelections: [ 'linear' ]
|
2015-11-08 17:05:33 +00:00
|
|
|
} )
|
|
|
|
);
|
|
|
|
ve.ui.sequenceRegistry.register(
|
|
|
|
new ve.ui.Sequence( 'wikitextSignature', 'mwSignature', '~~~~', 4 )
|
|
|
|
);
|
|
|
|
ve.ui.commandHelpRegistry.register( 'insert', 'mwSignature', {
|
|
|
|
sequences: [ 'wikitextSignature' ],
|
|
|
|
label: OO.ui.deferMsg( 'visualeditor-mwsignature-tool' )
|
|
|
|
} );
|
2017-02-07 20:21:32 +00:00
|
|
|
if ( mw.libs.ve.isWikitextAvailable ) {
|
|
|
|
// Ensure wikitextCommandRegistry has finished loading
|
|
|
|
mw.loader.using( 'ext.visualEditor.mwwikitext' ).then( function () {
|
|
|
|
ve.ui.wikitextCommandRegistry.register(
|
|
|
|
new ve.ui.Command( 'mwSignature', 'content', 'insert', {
|
|
|
|
args: [ '~~~~', false, true /* collaseToEnd */ ],
|
|
|
|
supportedSelections: [ 'linear' ]
|
|
|
|
} )
|
|
|
|
);
|
|
|
|
} );
|
|
|
|
}
|
2015-11-08 17:05:33 +00:00
|
|
|
} else {
|
|
|
|
// No-op command that is never executable
|
|
|
|
ve.ui.commandRegistry.register(
|
|
|
|
new ve.ui.Command( 'mwSignature', 'content', 'insert', {
|
|
|
|
args: [ [] ],
|
|
|
|
supportedSelections: []
|
|
|
|
} )
|
|
|
|
);
|
|
|
|
// Wikitext insertion warning
|
|
|
|
ve.ui.sequenceRegistry.register(
|
|
|
|
new ve.ui.Sequence( 'wikitextSignature', 'mwWikitextWarning', '~~~' )
|
|
|
|
);
|
|
|
|
}
|