2012-05-31 23:50:16 +00:00
|
|
|
/**
|
|
|
|
* DataModel annotation for a text style.
|
|
|
|
*
|
|
|
|
* @class
|
|
|
|
* @constructor
|
|
|
|
* @extends {ve.dm.Annotation}
|
|
|
|
*/
|
|
|
|
ve.dm.TextStyleAnnotation = function() {
|
|
|
|
// Inheritance
|
|
|
|
ve.dm.Annotation.call( this );
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Static Members */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Converters.
|
|
|
|
*
|
|
|
|
* @see {ve.dm.Converter}
|
|
|
|
* @static
|
|
|
|
* @member
|
|
|
|
*/
|
|
|
|
ve.dm.TextStyleAnnotation.converters = {
|
2012-06-07 00:47:27 +00:00
|
|
|
'domElementTypes': ['i', 'b', 'u', 's', 'small', 'big', 'span'],
|
|
|
|
'toDomElement': function( subType, annotation ) {
|
2012-06-07 22:02:25 +00:00
|
|
|
return annotation.type && document.createElement( ( {
|
2012-06-01 00:02:50 +00:00
|
|
|
'italic': 'i',
|
|
|
|
'bold': 'b',
|
|
|
|
'underline': 'u',
|
|
|
|
'strike': 's',
|
|
|
|
'small': 'small',
|
|
|
|
'big': 'big',
|
2012-06-21 21:46:43 +00:00
|
|
|
'span': 'span',
|
|
|
|
'strong': 'strong',
|
|
|
|
'emphasize': 'em',
|
|
|
|
'superScript': 'sup',
|
|
|
|
'subScript': 'sub'
|
2012-06-07 00:47:27 +00:00
|
|
|
// TODO: Add other supported inline DOM elements to this list
|
2012-06-01 00:02:50 +00:00
|
|
|
} )[subType] );
|
|
|
|
},
|
2012-06-07 00:47:27 +00:00
|
|
|
'toDataAnnotation': function( tag, element ) {
|
2012-06-01 00:02:50 +00:00
|
|
|
return {
|
|
|
|
'type': 'textStyle/' + ( {
|
|
|
|
'i': 'italic',
|
|
|
|
'b': 'bold',
|
|
|
|
'u': 'underline',
|
|
|
|
's': 'strike',
|
2012-05-31 23:50:16 +00:00
|
|
|
'small': 'small',
|
|
|
|
'big': 'big',
|
2012-06-21 21:46:43 +00:00
|
|
|
'span': 'span',
|
|
|
|
'strong': 'strong',
|
|
|
|
'em': 'emphasize',
|
|
|
|
'sup': 'superScript',
|
|
|
|
'sub': 'subScript'
|
2012-06-07 00:47:27 +00:00
|
|
|
// TODO: Add other supported inline DOM elements to this list
|
2012-06-01 00:02:50 +00:00
|
|
|
} )[tag]
|
|
|
|
};
|
2012-05-31 23:50:16 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Registration */
|
|
|
|
|
|
|
|
ve.dm.annotationFactory.register( 'textStyle', ve.dm.TextStyleAnnotation );
|
|
|
|
|
|
|
|
/* Inheritance */
|
|
|
|
|
|
|
|
ve.extendClass( ve.dm.TextStyleAnnotation, ve.dm.Annotation );
|