mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 18:39:52 +00:00
042ffb4e3b
* Added converters to all relevant node implementations * Added new annotation objects with their own factory Change-Id: I9870d6d5eac45083929d74d2e58917d0939ca917
44 lines
840 B
JavaScript
44 lines
840 B
JavaScript
/**
|
|
* DataModel annotation for a object.
|
|
*
|
|
* @class
|
|
* @constructor
|
|
* @extends {ve.dm.Annotation}
|
|
*/
|
|
ve.dm.ObjectAnnotation = function() {
|
|
// Inheritance
|
|
ve.dm.Annotation.call( this );
|
|
};
|
|
|
|
/* Static Members */
|
|
|
|
/**
|
|
* Converters.
|
|
*
|
|
* @see {ve.dm.Converter}
|
|
* @static
|
|
* @member
|
|
*/
|
|
ve.dm.ObjectAnnotation.converters = {
|
|
'tags': ['template', 'hook'],
|
|
'html': {
|
|
'convert': function( subType, annotation ) {
|
|
return annotation.type &&
|
|
ve.dm.createHtmlElement( 'div', { 'data-type': subType } );
|
|
}
|
|
},
|
|
'data': {
|
|
'convert': function( tag, element ) {
|
|
return { 'type': 'object/' + ( element.getAttribute( 'data-type' ) || 'unknown' ) };
|
|
}
|
|
}
|
|
};
|
|
|
|
/* Registration */
|
|
|
|
ve.dm.annotationFactory.register( 'object', ve.dm.ObjectAnnotation );
|
|
|
|
/* Inheritance */
|
|
|
|
ve.extendClass( ve.dm.ObjectAnnotation, ve.dm.Annotation );
|