File: ve.ui.MWSignatureTool.js

package info (click to toggle)
mediawiki 1%3A1.43.3%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 417,464 kB
  • sloc: php: 1,062,949; javascript: 664,290; sql: 9,714; python: 5,458; xml: 3,489; sh: 1,131; makefile: 64
file content (83 lines) | stat: -rw-r--r-- 2,630 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*!
 * VisualEditor MediaWiki UserInterface signature tool class.
 *
 * @copyright See AUTHORS.txt
 * @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
 */
ve.ui.MWSignatureTool = function VeUiMWSignatureTool() {
	// Parent constructor
	ve.ui.MWSignatureTool.super.apply( this, arguments );
};
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 );

// 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' ) ) ) {
	// 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
			],
			supportedSelections: [ 'linear' ]
		} )
	);
	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' )
	} );
	if ( mw.libs.ve.isWikitextAvailable ) {
		// Ensure wikitextCommandRegistry has finished loading
		mw.loader.using( 'ext.visualEditor.mwwikitext' ).then( () => {
			ve.ui.wikitextCommandRegistry.register(
				new ve.ui.Command( 'mwSignature', 'content', 'insert', {
					args: [ '~~~~', false, true /* collaseToEnd */ ],
					supportedSelections: [ 'linear' ]
				} )
			);
		} );
	}
} 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', '~~~' )
	);
}