mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-16 02:51:50 +00:00
0b55bb8cdc
ve.dm.Model is now the common base class for these three. ve.dm.Node inherited from ve.Node before, so it now uses it as a mixin instead. This required changing ve.Node's usage of ve.EventEmitter from inhertiance to a mixin as well, because inherited methods apparently don't get mixed in correctly. * Change annotation terminology from linmodAnnotation to element for consistency with Node, MetaItem and Model * Reimplement getClonedElement() in Node for .internal treatment Change-Id: Ifd3922af23557c0b0f8984d36b31c8a1e2ec497e
51 lines
1.1 KiB
JavaScript
51 lines
1.1 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.toDataElement = function ( domElements ) {
|
|
return {
|
|
'type': 'link',
|
|
'attributes': {
|
|
'href': domElements[0].getAttribute( 'href' )
|
|
}
|
|
};
|
|
};
|
|
|
|
ve.dm.LinkAnnotation.static.toDomElements = function ( dataElement ) {
|
|
var domElement = document.createElement( 'a' );
|
|
domElement.setAttribute( 'href', dataElement.attributes.href );
|
|
return [ domElement ];
|
|
};
|
|
|
|
/* Registration */
|
|
|
|
ve.dm.modelRegistry.register( ve.dm.LinkAnnotation );
|