mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-09-28 20:56:44 +00:00
1d6085b801
New changes: 61d20a1 Hide on-screen keyboard when selecting nodes on all mobile platforms e5aff79 Localisation updates from https://translatewiki.net. a99a897 Update OOjs UI to v0.12.3 3c01a14 Make DM nodes sensibly hashable a611eb9 Make ve.dm.example.postprocessAnnotations fluent 496c895 Update ve.dm.ElementLinearData#hasContent documentation fcaa035 Support RegExp sequences; trigger sequence matcher after newline edda1d4 Add a mechanism to wait until ve.init.platform has been created e174155 Autolink URLs when typing ac9248f Allow drag and drop of links (and subsequent autolinking) c88fad6 Localisation updates from https://translatewiki.net. Local changes: * Define `ve.init.platform.getUnanchoredExternalLinkUrlProtocolsRegexp`. * Make `ve.ui.MWLinkAction` extend `ve.ui.LinkAction`. * Override `ve.ui.LinkAction.getLinkAnnotation` so auto-links use the proper `ve.ui.MWExternalLinkAnnotation` type. Change-Id: I934f76158512e2e89b614ed92fef6481f70728e7
70 lines
1.6 KiB
JavaScript
70 lines
1.6 KiB
JavaScript
/*!
|
|
* VisualEditor UserInterface MWLinkAction class.
|
|
*
|
|
* @copyright 2011-2015 VisualEditor Team and others; see http://ve.mit-license.org
|
|
*/
|
|
|
|
/**
|
|
* Link action.
|
|
*
|
|
* Opens either MWLinkAnnotationInspector or MWLinkNodeInspector depending on what is selected.
|
|
*
|
|
* @class
|
|
* @extends ve.ui.LinkAction
|
|
* @constructor
|
|
* @param {ve.ui.Surface} surface Surface to act on
|
|
*/
|
|
ve.ui.MWLinkAction = function VeUiMWLinkAction( surface ) {
|
|
// Parent constructor
|
|
ve.ui.MWLinkAction.super.call( this, surface );
|
|
};
|
|
|
|
/* Inheritance */
|
|
|
|
OO.inheritClass( ve.ui.MWLinkAction, ve.ui.LinkAction );
|
|
|
|
/* Static Properties */
|
|
|
|
/**
|
|
* List of allowed methods for the action.
|
|
*
|
|
* @static
|
|
* @property
|
|
*/
|
|
ve.ui.MWLinkAction.static.methods = ve.ui.MWLinkAction.super.static.methods.concat( [ 'open' ] );
|
|
|
|
/* Methods */
|
|
|
|
/**
|
|
* @method
|
|
* @inheritdoc
|
|
* @return {ve.dm.MWExternalLinkAnnotation} The annotation to use.
|
|
*/
|
|
ve.ui.MWLinkAction.prototype.getLinkAnnotation = function ( href ) {
|
|
return new ve.dm.MWExternalLinkAnnotation( {
|
|
type: 'link/mwExternal',
|
|
attributes: { href: href }
|
|
} );
|
|
};
|
|
|
|
/**
|
|
* Open either the 'link' or 'linkNode' window, depending on what is selected.
|
|
*
|
|
* @method
|
|
* @return {boolean} Action was executed
|
|
*/
|
|
ve.ui.MWLinkAction.prototype.open = function () {
|
|
var fragment = this.surface.getModel().getFragment(),
|
|
windowName = 'link';
|
|
|
|
if ( fragment.getSelectedNode() instanceof ve.dm.MWNumberedExternalLinkNode ) {
|
|
windowName = 'linkNode';
|
|
}
|
|
this.surface.execute( 'window', 'open', windowName );
|
|
return true;
|
|
};
|
|
|
|
/* Registration */
|
|
|
|
ve.ui.actionFactory.register( ve.ui.MWLinkAction );
|