all files / src/dm/annotations/ ve.dm.TextStyleAnnotation.js

100% Statements 14/14
100% Branches 4/4
100% Functions 4/4
100% Lines 14/14
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59                                1323×                   315× 315×               306×   306×               586×          
/*!
 * VisualEditor DataModel TextStyleAnnotation class.
 *
 * @copyright 2011-2019 VisualEditor Team and others; see http://ve.mit-license.org
 */
 
/**
 * DataModel text style annotation.
 *
 * @class
 * @abstract
 * @extends ve.dm.Annotation
 * @constructor
 * @param {Object} element
 */
ve.dm.TextStyleAnnotation = function VeDmTextStyleAnnotation() {
	// Parent constructor
	ve.dm.TextStyleAnnotation.super.apply( this, arguments );
};
 
/* Inheritance */
 
OO.inheritClass( ve.dm.TextStyleAnnotation, ve.dm.Annotation );
 
/* Static Properties */
 
ve.dm.TextStyleAnnotation.static.name = 'textStyle';
 
ve.dm.TextStyleAnnotation.static.matchTagNames = [];
 
ve.dm.TextStyleAnnotation.static.toDataElement = function ( domElements, converter ) {
	var nodeName = converter.isFromClipboard() ? this.matchTagNames[ 0 ] : domElements[ 0 ].nodeName.toLowerCase();
	return {
		type: this.name,
		attributes: {
			nodeName: nodeName
		}
	};
};
 
ve.dm.TextStyleAnnotation.static.toDomElements = function ( dataElement, doc ) {
	var nodeName = ve.getProp( dataElement, 'attributes', 'nodeName' );
 
	return [ doc.createElement( nodeName || this.matchTagNames[ 0 ] ) ];
};
 
/* Methods */
 
/**
 * @return {Object}
 */
ve.dm.TextStyleAnnotation.prototype.getComparableObject = function () {
	return { type: this.getType() };
};
 
/* Registration */
 
ve.dm.modelRegistry.register( ve.dm.TextStyleAnnotation );