2023-08-21 08:08:23 +00:00
|
|
|
'use strict';
|
|
|
|
|
2016-02-03 21:03:41 +00:00
|
|
|
/*!
|
|
|
|
* VisualEditor UserInterface MediaWiki UseExistingReferenceCommand class.
|
|
|
|
*
|
2018-01-03 01:05:45 +00:00
|
|
|
* @copyright 2011-2018 VisualEditor Team's Cite sub-team and others; see AUTHORS.txt
|
2017-12-29 12:12:35 +00:00
|
|
|
* @license MIT
|
2016-02-03 21:03:41 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Use existing reference command.
|
|
|
|
*
|
|
|
|
* @class
|
|
|
|
* @extends ve.ui.Command
|
|
|
|
*
|
|
|
|
* @constructor
|
|
|
|
*/
|
|
|
|
ve.ui.MWUseExistingReferenceCommand = function VeUiMWUseExistingReferenceCommand() {
|
|
|
|
// Parent constructor
|
|
|
|
ve.ui.MWUseExistingReferenceCommand.super.call(
|
|
|
|
this, 'reference/existing', 'window', 'open',
|
|
|
|
{ args: [ 'reference', { useExisting: true } ], supportedSelections: [ 'linear' ] }
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Inheritance */
|
|
|
|
|
|
|
|
OO.inheritClass( ve.ui.MWUseExistingReferenceCommand, ve.ui.Command );
|
|
|
|
|
|
|
|
/* Methods */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
ve.ui.MWUseExistingReferenceCommand.prototype.isExecutable = function ( fragment ) {
|
2024-01-30 11:18:52 +00:00
|
|
|
if ( !ve.ui.MWUseExistingReferenceCommand.super.prototype
|
|
|
|
.isExecutable.apply( this, arguments )
|
|
|
|
) {
|
2016-02-03 21:03:41 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2023-08-21 08:08:23 +00:00
|
|
|
const groups = fragment.getDocument().getInternalList().getNodeGroups();
|
|
|
|
for ( const groupName in groups ) {
|
2023-05-16 15:16:04 +00:00
|
|
|
if ( groupName.indexOf( 'mwReference/' ) === 0 && groups[ groupName ].indexOrder.length ) {
|
2016-02-03 21:03:41 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Registration */
|
|
|
|
|
|
|
|
ve.ui.commandRegistry.register( new ve.ui.MWUseExistingReferenceCommand() );
|