Debian Codegraph @

extensions/VisualEditor/lib/ve/src/ui/tools/ve.ui.LinkInspectorTool.js

raw symbols SCIP
1 /*!
2 * VisualEditor UserInterface LinkInspectorTool classes.
3 *
4 * @copyright See AUTHORS.txt
5 */
6
7 /**
8 * UserInterface link tool.
9 *
10 * @class
11 * @extends ve.ui.FragmentInspectorTool
12 * @constructor
13 * @param {OO.ui.ToolGroup} toolGroup
14 * @param {Object} [config] Configuration options
15 */
16 ve.ui.LinkInspectorTool = function VeUiLinkInspectorTool() {
17 ve.ui.LinkInspectorTool.super.apply( this, arguments );
18 };
19 OO.inheritClass( ve.ui.LinkInspectorTool, ve.ui.FragmentInspectorTool );
20 ve.ui.LinkInspectorTool.static.name = 'link';
21 ve.ui.LinkInspectorTool.static.group = 'meta';
22 ve.ui.LinkInspectorTool.static.icon = 'link';
23 ve.ui.LinkInspectorTool.static.title =
24 OO.ui.deferMsg( 'visualeditor-annotationbutton-link-tooltip' );
25 ve.ui.LinkInspectorTool.static.modelClasses = [ ve.dm.LinkAnnotation ];
26 ve.ui.LinkInspectorTool.static.commandName = 'link';
27
28 ve.ui.LinkInspectorTool.prototype.getSelectedModels = function ( fragment ) {
29 const selection = fragment && fragment.getSelection();
30
31 // Ask the CE surface about selected models, so it can give the right
32 // answer about links based on the CE selection.
33 if ( selection instanceof ve.dm.LinearSelection ) {
34 const surfaceView = this.toolbar.getSurface().getView();
35 if ( selection.equals( surfaceView.getModel().getSelection() ) ) {
36 return surfaceView.getSelectedModels();
37 }
38 }
39
40 return ve.ui.LinkInspectorTool.super.prototype.getSelectedModels.apply( this, arguments );
41 };
42
43 ve.ui.toolFactory.register( ve.ui.LinkInspectorTool );