All files / src/ui/tools ve.ui.LinkInspectorTool.js

58.82% Statements 10/17
0% Branches 0/6
0% Functions 0/2
58.82% Lines 10/17

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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                              1x     1x 1x 1x 1x 1x   1x 1x   1x                             1x  
/*!
 * VisualEditor UserInterface LinkInspectorTool classes.
 *
 * @copyright See AUTHORS.txt
 */
 
/**
 * UserInterface link tool.
 *
 * @class
 * @extends ve.ui.FragmentInspectorTool
 * @constructor
 * @param {OO.ui.ToolGroup} toolGroup
 * @param {Object} [config] Configuration options
 */
ve.ui.LinkInspectorTool = function VeUiLinkInspectorTool() {
	ve.ui.LinkInspectorTool.super.apply( this, arguments );
};
OO.inheritClass( ve.ui.LinkInspectorTool, ve.ui.FragmentInspectorTool );
ve.ui.LinkInspectorTool.static.name = 'link';
ve.ui.LinkInspectorTool.static.group = 'meta';
ve.ui.LinkInspectorTool.static.icon = 'link';
ve.ui.LinkInspectorTool.static.title =
	OO.ui.deferMsg( 'visualeditor-annotationbutton-link-tooltip' );
ve.ui.LinkInspectorTool.static.modelClasses = [ ve.dm.LinkAnnotation ];
ve.ui.LinkInspectorTool.static.commandName = 'link';
 
ve.ui.LinkInspectorTool.prototype.getSelectedModels = function ( fragment ) {
	const selection = fragment && fragment.getSelection();
 
	// Ask the CE surface about selected models, so it can give the right
	// answer about links based on the CE selection.
	if ( selection instanceof ve.dm.LinearSelection ) {
		const surfaceView = this.toolbar.getSurface().getView();
		if ( selection.equals( surfaceView.getModel().getSelection() ) ) {
			return surfaceView.getSelectedModels();
		}
	}
 
	return ve.ui.LinkInspectorTool.super.prototype.getSelectedModels.apply( this, arguments );
};
 
ve.ui.toolFactory.register( ve.ui.LinkInspectorTool );