| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
ve.dm.CommentAnnotation = function VeDmCommentAnnotation() { |
| 16 |
|
| 17 |
ve.dm.CommentAnnotation.super.apply( this, arguments ); |
| 18 |
}; |
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
OO.inheritClass( ve.dm.CommentAnnotation, ve.dm.Annotation ); |
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
ve.dm.CommentAnnotation.static.name = 'commentAnnotation'; |
| 27 |
|
| 28 |
ve.dm.CommentAnnotation.static.matchTagNames = [ 'span' ]; |
| 29 |
|
| 30 |
ve.dm.CommentAnnotation.static.matchRdfaTypes = [ 've:CommentAnnotation' ]; |
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
ve.dm.CommentAnnotation.static.toDataElement = function ( domElements ) { |
| 35 |
return { |
| 36 |
type: this.name, |
| 37 |
attributes: { |
| 38 |
text: domElements[ 0 ].getAttribute( 'data-text' ) || '' |
| 39 |
} |
| 40 |
}; |
| 41 |
}; |
| 42 |
|
| 43 |
ve.dm.CommentAnnotation.static.toDomElements = function ( dataElement, doc, converter ) { |
| 44 |
if ( converter.isForParser() || converter.isForPreview() ) { |
| 45 |
|
| 46 |
return []; |
| 47 |
} else { |
| 48 |
const domElement = doc.createElement( 'span' ); |
| 49 |
domElement.setAttribute( 'rel', 've:CommentAnnotation' ); |
| 50 |
if ( dataElement.attributes.text ) { |
| 51 |
domElement.setAttribute( 'data-text', dataElement.attributes.text ); |
| 52 |
} |
| 53 |
return [ domElement ]; |
| 54 |
} |
| 55 |
}; |
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
ve.dm.CommentAnnotation.prototype.getAttribute = function ( key ) { |
| 60 |
|
| 61 |
if ( key === 'comments' && this.getAttribute( 'text' ) ) { |
| 62 |
return [ { |
| 63 |
author: '', |
| 64 |
text: this.getAttribute( 'text' ) |
| 65 |
} ].concat( |
| 66 |
ve.dm.CommentAnnotation.super.prototype.getAttribute.call( this, 'comments' ) || [] |
| 67 |
); |
| 68 |
} |
| 69 |
|
| 70 |
return ve.dm.CommentAnnotation.super.prototype.getAttribute.call( this, key ); |
| 71 |
}; |
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
ve.dm.modelRegistry.register( ve.dm.CommentAnnotation ); |