mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-16 10:59:56 +00:00
b62beed2e2
Change-Id: I8561d4a00ba630b86fb7bcd3e347fe2c6c2f6aa3
43 lines
996 B
JavaScript
43 lines
996 B
JavaScript
/**
|
|
* DataModel annotation for a link.
|
|
*
|
|
* @class
|
|
* @constructor
|
|
* @extends {ve.dm.Annotation}
|
|
*/
|
|
ve.dm.LinkAnnotation = function() {
|
|
// Inheritance
|
|
ve.dm.Annotation.call( this );
|
|
};
|
|
|
|
/* Static Members */
|
|
|
|
/**
|
|
* Converters.
|
|
*
|
|
* @see {ve.dm.Converter}
|
|
* @static
|
|
* @member
|
|
*/
|
|
ve.dm.LinkAnnotation.converters = {
|
|
'domElementTypes': ['a'],
|
|
'toDomElement': function( subType, annotation ) {
|
|
return annotation.type &&
|
|
ve.dm.createDomElement( 'a', { 'data-type': 'link/' + subType } );
|
|
},
|
|
'toDataAnnotation': function( tag, element ) {
|
|
// FIXME: the parser currently doesn't output this data this way
|
|
// Internal links get 'linkType': 'internal' in the data-mw-rt attrib, while external
|
|
// links currently get nothing
|
|
return { 'type': 'link/' + ( element.getAttribute( 'data-type' ) || 'unknown' ) };
|
|
}
|
|
};
|
|
|
|
/* Registration */
|
|
|
|
ve.dm.annotationFactory.register( 'link', ve.dm.LinkAnnotation );
|
|
|
|
/* Inheritance */
|
|
|
|
ve.extendClass( ve.dm.LinkAnnotation, ve.dm.Annotation );
|