Debian Codegraph @

extensions/VisualEditor/modules/ve-mw/ui/tools/ve.ui.MWTransclusionDialogTool.js

raw symbols SCIP
1 /*!
2 * VisualEditor MediaWiki UserInterface transclusion tool classes.
3 *
4 * @copyright See AUTHORS.txt
5 * @license The MIT License (MIT); see LICENSE.txt
6 */
7
8 /**
9 * MediaWiki UserInterface transclusion tool.
10 *
11 * @class
12 * @extends ve.ui.FragmentWindowTool
13 * @constructor
14 * @param {OO.ui.ToolGroup} toolGroup
15 * @param {Object} [config] Configuration options
16 */
17 ve.ui.MWTransclusionDialogTool = function VeUiMWTransclusionDialogTool() {
18 ve.ui.MWTransclusionDialogTool.super.apply( this, arguments );
19 };
20
21 /* Inheritance */
22
23 OO.inheritClass( ve.ui.MWTransclusionDialogTool, ve.ui.FragmentWindowTool );
24
25 /* Static Properties */
26
27 ve.ui.MWTransclusionDialogTool.static.name = 'transclusion';
28
29 ve.ui.MWTransclusionDialogTool.static.group = 'object';
30
31 ve.ui.MWTransclusionDialogTool.static.icon = 'puzzle';
32
33 ve.ui.MWTransclusionDialogTool.static.title =
34 OO.ui.deferMsg( 'visualeditor-dialogbutton-template-tooltip' );
35
36 ve.ui.MWTransclusionDialogTool.static.modelClasses = [ ve.dm.MWTransclusionNode ];
37
38 ve.ui.MWTransclusionDialogTool.static.commandName = 'transclusion';
39
40 /**
41 * Only display tool for single-template transclusions of these templates.
42 *
43 * @property {string|string[]|null}
44 * @static
45 * @inheritable
46 */
47 ve.ui.MWTransclusionDialogTool.static.template = null;
48
49 /* Methods */
50
51 /**
52 * @inheritdoc
53 */
54 ve.ui.MWTransclusionDialogTool.static.isCompatibleWith = function ( model ) {
55 // Parent method
56 const compatible = ve.ui.MWTransclusionDialogTool.super.static.isCompatibleWith.call( this, model );
57
58 if ( compatible && this.template ) {
59 return model.isSingleTemplate( this.template );
60 }
61
62 return compatible;
63 };
64
65 /* Registration */
66
67 ve.ui.toolFactory.register( ve.ui.MWTransclusionDialogTool );
68
69 ve.ui.commandRegistry.register(
70 new ve.ui.Command(
71 'transclusion', 'window', 'open',
72 { args: [ 'transclusion' ], supportedSelections: [ 'linear' ] }
73 )
74 );
75
76 ve.ui.commandRegistry.register(
77 new ve.ui.Command(
78 'transclusionFromSequence', 'window', 'open',
79 { args: [ 'transclusion', { cancelCommand: 'undo' } ], supportedSelections: [ 'linear' ] }
80 )
81 );
82
83 ve.ui.sequenceRegistry.register(
84 new ve.ui.Sequence( 'wikitextTemplate', 'transclusionFromSequence', '{{', 2 )
85 );
86
87 ve.ui.commandHelpRegistry.register( 'insert', 'template', {
88 sequences: [ 'wikitextTemplate' ],
89 label: OO.ui.deferMsg( 'visualeditor-dialog-template-title' )
90 } );