mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-25 06:46:26 +00:00
f58b5b6fc8
ve.ce.TextNode listed textStyle annotations that didn't actually exist, and failed to recognize some that did exist (such as span; bug 37808). Added all annotations to both places. <span> tags are now tolerated by the editor in that it doesn't crash anymore, but they're displayed (and saved!) without any attributes, so <span style="color:yellow;">y</span> doesn't show a yellow 'y' in the editor and is saved back as <span>y</span> . Change-Id: Iaae11ad5044150fa904010983ff83579cb37733d
67 lines
1.4 KiB
JavaScript
67 lines
1.4 KiB
JavaScript
/**
|
|
* 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 = {
|
|
'domElementTypes': ['i', 'b', 'u', 's', 'small', 'big', 'span'],
|
|
'toDomElement': function( subType, annotation ) {
|
|
return annotation.type && document.createElement( ( {
|
|
'italic': 'i',
|
|
'bold': 'b',
|
|
'underline': 'u',
|
|
'strike': 's',
|
|
'small': 'small',
|
|
'big': 'big',
|
|
'span': 'span',
|
|
'strong': 'strong',
|
|
'emphasize': 'em',
|
|
'superScript': 'sup',
|
|
'subScript': 'sub'
|
|
// TODO: Add other supported inline DOM elements to this list
|
|
} )[subType] );
|
|
},
|
|
'toDataAnnotation': function( tag, element ) {
|
|
return {
|
|
'type': 'textStyle/' + ( {
|
|
'i': 'italic',
|
|
'b': 'bold',
|
|
'u': 'underline',
|
|
's': 'strike',
|
|
'small': 'small',
|
|
'big': 'big',
|
|
'span': 'span',
|
|
'strong': 'strong',
|
|
'em': 'emphasize',
|
|
'sup': 'superScript',
|
|
'sub': 'subScript'
|
|
// TODO: Add other supported inline DOM elements to this list
|
|
} )[tag]
|
|
};
|
|
}
|
|
};
|
|
|
|
/* Registration */
|
|
|
|
ve.dm.annotationFactory.register( 'textStyle', ve.dm.TextStyleAnnotation );
|
|
|
|
/* Inheritance */
|
|
|
|
ve.extendClass( ve.dm.TextStyleAnnotation, ve.dm.Annotation );
|