mediawiki-extensions-Discus.../modules/CommentItem.js
Bartosz Dziewoński 044bc50fb6 Fix some TODOs about test data
We avoided fixing these because it causes changes in just about all of
the test data, which is annoying when reviewing or blaming changes.

But the previous several commits also caused changes in just about all
of the test data, so we might as well do this too.

Change-Id: I83b64d83b6f12c04dc06c0cadff7cdd89417e137
2020-10-22 00:21:04 +00:00

58 lines
1.5 KiB
JavaScript

var ThreadItem = require( './ThreadItem.js' );
/**
* @external moment
* @external HeadingItem
*/
/**
* A comment item
*
* @class CommentItem
* @extends ThreadItem
* @constructor
* @param {number} level
* @param {Object} range
* @param {Object[]} [signatureRanges] Objects describing the extent of signatures (plus
* timestamps) for this comment. There is always at least one signature, but there may be
* multiple. The author and timestamp of the comment is determined from the first signature.
* The last node in every signature range is a node containing the timestamp.
* @param {moment} [timestamp] Timestamp (Moment object)
* @param {string} [author] Comment author's username
*/
function CommentItem( level, range, signatureRanges, timestamp, author ) {
// Parent constructor
CommentItem.super.call( this, 'comment', level, range );
this.signatureRanges = signatureRanges || [];
this.timestamp = timestamp || null;
this.author = author || null;
/**
* @member {string[]} Comment warnings
*/
this.warnings = [];
/**
* @member {ThreadItem} Parent thread item
*/
this.parent = null;
}
OO.inheritClass( CommentItem, ThreadItem );
/**
* @return {HeadingItem} Closest ancestor which is a HeadingItem
*/
CommentItem.prototype.getHeading = function () {
var parent = this;
while ( parent && parent.type !== 'heading' ) {
parent = parent.parent;
}
return parent;
};
// TODO: Implement getBodyRange/getBodyHTML/getBodyText/getMentions if required
module.exports = CommentItem;