Page MenuHomeWickedGov Phorge

ve.dm.CommentAnnotation.js
No OneTemporary

Size
1 KB
Referenced Files
None
Subscribers
None

ve.dm.CommentAnnotation.js

/*!
* VisualEditor DataModel CommentAnnotation class.
*
* @copyright See AUTHORS.txt
*/
/**
* DataModel comment annotation.
*
* @class
* @extends ve.dm.Annotation
* @constructor
* @param {Object} element
*/
ve.dm.CommentAnnotation = function VeDmCommentAnnotation() {
// Parent constructor
ve.dm.CommentAnnotation.super.apply( this, arguments );
};
/* Inheritance */
OO.inheritClass( ve.dm.CommentAnnotation, ve.dm.Annotation );
/* Static Properties */
ve.dm.CommentAnnotation.static.name = 'commentAnnotation';
ve.dm.CommentAnnotation.static.matchTagNames = [ 'span' ];
ve.dm.CommentAnnotation.static.matchRdfaTypes = [ 've:CommentAnnotation' ];
// ve.dm.CommentAnnotation.static.applyToAppendedContent = true;
ve.dm.CommentAnnotation.static.toDataElement = function ( domElements ) {
return {
type: this.name,
attributes: {
text: domElements[ 0 ].getAttribute( 'data-text' ) || ''
}
};
};
ve.dm.CommentAnnotation.static.toDomElements = function ( dataElement, doc, converter ) {
if ( converter.isForParser() || converter.isForPreview() ) {
// TODO: Return some nodes for preview?
return [];
} else {
const domElement = doc.createElement( 'span' );
domElement.setAttribute( 'rel', 've:CommentAnnotation' );
if ( dataElement.attributes.text ) {
domElement.setAttribute( 'data-text', dataElement.attributes.text );
}
return [ domElement ];
}
};
/* Methods */
ve.dm.CommentAnnotation.prototype.getAttribute = function ( key ) {
// Support old documents with text attributes
if ( key === 'comments' && this.getAttribute( 'text' ) ) {
return [ {
author: '',
text: this.getAttribute( 'text' )
} ].concat(
ve.dm.CommentAnnotation.super.prototype.getAttribute.call( this, 'comments' ) || []
);
}
// Parent method
return ve.dm.CommentAnnotation.super.prototype.getAttribute.call( this, key );
};
/* Registration */
ve.dm.modelRegistry.register( ve.dm.CommentAnnotation );

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 21, 14:19 (1 d, 23 h ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
ba/49/7bcb1531f30217e614b89e6eae4c
Default Alt Text
ve.dm.CommentAnnotation.js (1 KB)

Event Timeline