MozReview: use text instead of html for inline comments (
Bug 1314278); r?davidwalsh
Using HTML for inline comment rendering results in bad formatting if the
comment contains multiple paragraphs. Switch to using text instead, which also
requires changing how draft comments are rendered to avoid a bug that returns
html markup in the comment.text field.
MozReview-Commit-ID: LUu65zaHd0a
--- a/reviewboard/reviewboard/static/rb/js/views/inlineCommentView_mozreview.js
+++ b/reviewboard/reviewboard/static/rb/js/views/inlineCommentView_mozreview.js
@@ -90,47 +90,40 @@ RB.InlineCommentView = RB.AbstractCommen
// Generate html.
function appendCommentHtml(root) {
_.each(root, function(element) {
var comment = element.comment;
var hasReplies = element.replies.length !== 0;
commentHtml.push(view.commentTemplate({
id: comment.comment_id,
user_name: comment.user.username,
- comment_html: comment.html,
+ comment_text: comment.text,
depth: element.depth,
icon_class: view._commentIconClass(
comment.issue_opened, comment.issue_status)
}));
if (hasReplies) {
appendCommentHtml(element.replies);
}
});
}
appendCommentHtml(comments);
if (this.isDraft) {
commentHtml.push(view.draftTemplate({
- user_name: RB.UserSession.instance.get('username')
+ user_name: RB.UserSession.instance.get('username'),
+ comment_text: view.model.get('draftComment').get('text')
}));
}
// Add to DOM.
this.$el
.html(this.rowTemplate({ commentHtml: commentHtml.join('') }))
.prop('id', this.cid);
- // Keep draft comment text in sync.
- if (this.isDraft) {
- this.$el.find('.draft .comment')
- .bindProperty('html', this.model.get('draftComment'), 'html', {
- elementToModel: false
- });
- }
-
// Hook up click and hover events.
this.$el
.click(function() {
view.trigger('clicked');
})
.hover(
function() {
_.each(view.contextRows, function($row) {
--- a/reviewboard/reviewboard/templates/diffviewer/inline_comments.html
+++ b/reviewboard/reviewboard/templates/diffviewer/inline_comments.html
@@ -12,21 +12,21 @@
</script>
<script type="text/template" id="inlineComments-comment">
<div class="inlineComment" id="c<%- id %>" style="padding-left: <%- 2 + depth * 8 %>px">
<div class="meta">
<span class="<%- icon_class %>"></span>
<span class="user"><%- user_name %></span>
</div>
- <div class="comment"><%= comment_html %></div>
+ <div class="comment"><%- comment_text %></div>
</div>
</script>
<script type="text/template" id="inlineComments-draft">
<div class="inlineComment draft">
<div class="meta">
<span class="rb-icon rb-icon-datagrid-comment-draft"></span>
<span class="user"><%- user_name %></span>
</div>
- <div class="comment"></div>
+ <div class="comment"><%- comment_text %></div>
</div>
</script>