mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-25 14:56:20 +00:00
5ce4885529
Uses the generic sequence detection now available in core instead of a custom hack that had to been manually bound and unbound to every surface and surface widget. As the sequence detection looks at just-typed characters the behaviour has reverted to showing a auto-hide message. This resolves an issue with the previous system whereby typing in the same paragraph as existing wikitext patterns triggered the warning. Depends on I6a4d71d in core. Bug: T53751 Change-Id: I7d914b1b60a1cf8c79a724e5f634e1e666c9562d
52 lines
1.2 KiB
JavaScript
52 lines
1.2 KiB
JavaScript
/*!
|
|
* VisualEditor UserInterface MediaWiki UseExistingReferenceCommand class.
|
|
*
|
|
* @copyright 2011-2014 VisualEditor Team and others; see http://ve.mit-license.org
|
|
*/
|
|
|
|
/**
|
|
* 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 ) {
|
|
// Parent method
|
|
if ( !ve.ui.MWUseExistingReferenceCommand.super.prototype.isExecutable.apply( this, arguments ) ) {
|
|
return false;
|
|
}
|
|
|
|
var groupName,
|
|
groups = fragment.getDocument().getInternalList().getNodeGroups();
|
|
|
|
for ( groupName in groups ) {
|
|
if ( groupName.lastIndexOf( 'mwReference/' ) === 0 && groups[groupName].indexOrder.length ) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
};
|
|
|
|
/* Registration */
|
|
|
|
ve.ui.commandRegistry.register( new ve.ui.MWUseExistingReferenceCommand() );
|