mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-29 08:34:54 +00:00
6b5310c562
Objectives: * Associate models with tools, rather than dialogs and inspectors * Move tool/model association utilities to ve.ui.ToolFactory * Obliterate the view registry Notes: The only special case for leaving modelClasses definitions in place is for the linkInspector. It uses these for selection expansion. Because tools can now override the static canEditModel method, we can dynamically evaluate a model, rather than be restricted to only comparing classes. This will be useful for disabling editors for models that are for some reason incomplete or otherwise broken and cannot be safely edited. Change-Id: I7adf254990112d90f1f808593a9111afc7a116b5
45 lines
1.1 KiB
JavaScript
45 lines
1.1 KiB
JavaScript
/*!
|
|
* VisualEditor UserInterface MWLinkButtonTool class.
|
|
*
|
|
* @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
*/
|
|
|
|
/**
|
|
* Creates an ve.ui.MWLinkButtonTool object.
|
|
*
|
|
* @class
|
|
* @extends ve.ui.LinkButtonTool
|
|
* @constructor
|
|
* @param {ve.ui.Toolbar} toolbar
|
|
* @param {Object} [config] Config options
|
|
*/
|
|
ve.ui.MWLinkButtonTool = function VeUiMwLinkButtonTool( toolbar, config ) {
|
|
// Parent constructor
|
|
ve.ui.LinkButtonTool.call( this, toolbar, config );
|
|
};
|
|
|
|
/* Inheritance */
|
|
|
|
ve.inheritClass( ve.ui.MWLinkButtonTool, ve.ui.LinkButtonTool );
|
|
|
|
/* Static Members */
|
|
|
|
ve.ui.MWLinkButtonTool.static.name = 'mwLink';
|
|
|
|
ve.ui.MWLinkButtonTool.static.inspector = 'mwLink';
|
|
|
|
ve.ui.MWLinkButtonTool.static.modelClasses = [
|
|
ve.dm.MWExternalLinkAnnotation, ve.dm.MWInternalLinkAnnotation
|
|
];
|
|
|
|
/* Registration */
|
|
|
|
ve.ui.toolFactory.register( 'mwLink', ve.ui.MWLinkButtonTool );
|
|
|
|
ve.ui.commandRegistry.register( 'mwLink', 'inspector', 'open', 'mwLink' );
|
|
|
|
ve.ui.triggerRegistry.register(
|
|
'mwLink', { 'mac': new ve.ui.Trigger( 'cmd+k' ), 'pc': new ve.ui.Trigger( 'ctrl+k' ) }
|
|
);
|