mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-16 02:51:50 +00:00
d2476a26d2
ve.AnnotationAction * Added filter to the clearAll method to allow clearing all matching annotations only ve.dm.Document * Some variable renaming for consistency ve.dm.SurfaceFragment * Added truncateRange method * Added annotation scope to expandRange method * Added support for passing an annotation object into annotateContent method * Switched to using name instead of type in annotateContent method to match the ve.dm.Annotation class * Fixed logic in annotation mode of expandSelection so that expansion only takes place if the annotation is found ve.ui.LinkInspector * Moved most of the functionality elsewhere * General reorganization * Changed setOverlayPosition to accept 2 arguments instead of an object with 2 properties and renamed it to positionOverlayBelow * Check for annotation object before extracting target information from it * Initialize default target as empty string to avoid undefined being cast to a string and the default target becoming 'undefined' icons.ai, inspector.png, inspector.svg * Added generic inspector icon which will be used when a custom icon is not specified in future inspector subclasses ve.ui.Inspector.Icons * Added inspector icon * Renamed clear icon to remove to match it's actual image ve.ui.Context * Greatly simplified the interface, reducing the number of methods by inlining a few things and combining others * Now always listening to resize events on the window rather than only while document is focused * Not listening to scroll events anymore, they used to affect the top/bottom positioning of the menu which we don't do anymore * Lots of cleanup and reorganization * No need to fallback to empty array since getInspectorsForAnnotations does so already * Only consider fully-covered annotations for inspectors ve.ui.Frame * Simplified the constructor by introducing the createFrame method * General cleanup * Typo fixes ve.ui.Inspector * Generalized lots of functionality previously located in the link inspector class which will be useful to all inspectors (such as title, clear button, saving changes, etc.) * Added setDisabled and isDisabled methods to manage CSS changes and avoid needing to check the CSS to determine the state of the inspector (storing state in the view is evil) * Added getMatchingAnnotations method for convenience * Added prepareSelection stub * Lots of cleanup and documentation * Type pattern is now defined in base class * Added stubs for onOpen and onClose with documentation so that subclass authors know what these methods do * Removed checks for onOpen or onClose methods since they are now noop stubs and are always there * Added stub and removed checks for onRemove * Made esc key close and accept - the illusion is supposed to be that the link changes are applied instantly, even though they are only updated when you close, so all closing except for when removing should apply changes - i.e. esc is now equal to back rather than being a special function that doesn't have an associated affordance * Only consider fully-covered annotations when getting matching annotations ve.ui.InspectorFactory * Depending on type pattern now since it's always there * Added getInspectorsForAnnotations method * Return empty array if annotation set is empty VisualEditor, VisualEditor.i18n * Added default inspector message Change-Id: I1cc008445bcbc8cba6754ca4b6ac0397575980d5
64 lines
1.6 KiB
JavaScript
64 lines
1.6 KiB
JavaScript
/**
|
|
* VisualEditor data model InspectorFactory class.
|
|
*
|
|
* @copyright 2011-2012 VisualEditor Team and others; see AUTHORS.txt
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
*/
|
|
|
|
/**
|
|
* DataModel Inspector factory.
|
|
*
|
|
* @class
|
|
* @constructor
|
|
* @extends {ve.Factory}
|
|
*/
|
|
ve.ui.InspectorFactory = function VeDmInspectorFactory() {
|
|
// Parent constructor
|
|
ve.Factory.call( this );
|
|
};
|
|
|
|
/* Inheritance */
|
|
|
|
ve.inheritClass( ve.ui.InspectorFactory, ve.Factory );
|
|
|
|
/* Methods */
|
|
|
|
/**
|
|
* Gets an inspector constructor for a given annotation type.
|
|
*
|
|
* @method
|
|
* @param {String} name Symbolic name of inspector to get pattern for
|
|
* @returns {RegExp} Regular expression matching annotations relevant to a given inspector
|
|
* @throws {Error} Unknown inspector
|
|
*/
|
|
ve.ui.InspectorFactory.prototype.getTypePattern = function ( name ) {
|
|
if ( name in this.registry ) {
|
|
return this.registry[name].static.typePattern;
|
|
}
|
|
throw new Error( 'Unknown inspector: ' + name );
|
|
};
|
|
|
|
/**
|
|
* Reduces an annotations set to only those which can be inspected by given inspector.
|
|
*
|
|
* @method
|
|
* @param {ve.AnnotationSet} annotations Annotations to be inspected
|
|
* @returns {String[]} Symbolic names of inspectors that can be used to inspect annotations
|
|
*/
|
|
ve.ui.InspectorFactory.prototype.getInspectorsForAnnotations = function ( annotations ) {
|
|
var name,
|
|
names = [];
|
|
if ( !annotations.isEmpty() ) {
|
|
for ( name in this.registry ) {
|
|
if ( annotations.hasAnnotationWithName( this.registry[name].static.typePattern ) ) {
|
|
names.push( name );
|
|
}
|
|
}
|
|
}
|
|
return names;
|
|
};
|
|
|
|
/* Initialization */
|
|
|
|
ve.ui.inspectorFactory = new ve.ui.InspectorFactory();
|