mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-25 14:56:20 +00:00
c6e0eee837
This makes it possible to use a static property to configure whether an annotation should be applied to content added after it. This makes it possible to do this for normal style stuff, but not for links. TODO: Inez is going to add IE support for this since it inverts the problem where the UI gets out of sync in all non-IE browsers to now make it so it only gets out of sync in IE. Bug: 48171 Change-Id: I5f279b06b098960be7bd4ad3f5e6f74b67e31d1a
62 lines
1.4 KiB
JavaScript
62 lines
1.4 KiB
JavaScript
/*!
|
|
* VisualEditor DataModel LinkAnnotation class.
|
|
*
|
|
* @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
*/
|
|
|
|
/**
|
|
* DataModel link annotation.
|
|
*
|
|
* Represents `<a>` tags that don't have a specific type.
|
|
*
|
|
* @class
|
|
* @extends ve.dm.Annotation
|
|
* @constructor
|
|
* @param {Object} element
|
|
*/
|
|
ve.dm.LinkAnnotation = function VeDmLinkAnnotation( element ) {
|
|
// Parent constructor
|
|
ve.dm.Annotation.call( this, element );
|
|
};
|
|
|
|
/* Inheritance */
|
|
|
|
ve.inheritClass( ve.dm.LinkAnnotation, ve.dm.Annotation );
|
|
|
|
/* Static Properties */
|
|
|
|
ve.dm.LinkAnnotation.static.name = 'link';
|
|
|
|
ve.dm.LinkAnnotation.static.matchTagNames = ['a'];
|
|
|
|
ve.dm.LinkAnnotation.static.applyToAppendedContent = false;
|
|
|
|
ve.dm.LinkAnnotation.static.toDataElement = function ( domElements ) {
|
|
return {
|
|
'type': 'link',
|
|
'attributes': {
|
|
'href': domElements[0].getAttribute( 'href' )
|
|
}
|
|
};
|
|
};
|
|
|
|
ve.dm.LinkAnnotation.static.toDomElements = function ( dataElement, doc ) {
|
|
var domElement = doc.createElement( 'a' );
|
|
domElement.setAttribute( 'href', dataElement.attributes.href );
|
|
return [ domElement ];
|
|
};
|
|
|
|
/* Methods */
|
|
|
|
ve.dm.LinkAnnotation.prototype.getComparableObject = function () {
|
|
return {
|
|
'type': this.getType(),
|
|
'href': this.getAttribute( 'href' )
|
|
};
|
|
};
|
|
|
|
/* Registration */
|
|
|
|
ve.dm.modelRegistry.register( ve.dm.LinkAnnotation );
|