Skip to content

Commit

Permalink
Merge pull request matrix-org#1889 from matrix-org/t3chguy/replies-ht…
Browse files Browse the repository at this point in the history
…ml-tag

T3chguy/replies html tag
  • Loading branch information
ara4n authored May 12, 2018
2 parents eabcbb3 + dbbcabf commit f8fd90c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
1 change: 0 additions & 1 deletion src/HtmlUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ const sanitizeHtmlParams = {
],
allowedAttributes: {
// custom ones first:
blockquote: ['data-mx-reply'], // used to allow explicit removal of a reply fallback blockquote, value ignored
font: ['color', 'data-mx-bg-color', 'data-mx-color', 'style'], // custom to matrix
span: ['data-mx-bg-color', 'data-mx-color', 'style'], // custom to matrix
a: ['href', 'name', 'target', 'rel'], // remote target: custom to matrix
Expand Down
26 changes: 13 additions & 13 deletions src/components/views/elements/ReplyThread.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export default class ReplyThread extends React.Component {

// Part of Replies fallback support
static stripHTMLReply(html) {
return html.replace(/^<blockquote data-mx-reply>[\s\S]+?<!--end-mx-reply--><\/blockquote>/, '');
return html.replace(/^<mx-reply>[\s\S]+?<\/mx-reply>/, '');
}

// Part of Replies fallback support
Expand All @@ -102,8 +102,8 @@ export default class ReplyThread extends React.Component {
switch (ev.getContent().msgtype) {
case 'm.text':
case 'm.notice': {
html = `<blockquote data-mx-reply><a href="${evLink}">In reply to</a> <a href="${userLink}">${mxid}</a>`
+ `<br>${html || body}<!--end-mx-reply--></blockquote>`;
html = `<mx-reply><blockquote><a href="${evLink}">In reply to</a> <a href="${userLink}">${mxid}</a>`
+ `<br>${html || body}</blockquote></mx-reply>`;
const lines = body.trim().split('\n');
if (lines.length > 0) {
lines[0] = `<${mxid}> ${lines[0]}`;
Expand All @@ -112,28 +112,28 @@ export default class ReplyThread extends React.Component {
break;
}
case 'm.image':
html = `<blockquote data-mx-reply><a href="${evLink}">In reply to</a> <a href="${userLink}">${mxid}</a>`
+ `<br>sent an image.<!--end-mx-reply--></blockquote>`;
html = `<mx-reply><blockquote><a href="${evLink}">In reply to</a> <a href="${userLink}">${mxid}</a>`
+ `<br>sent an image.</blockquote></mx-reply>`;
body = `> <${mxid}> sent an image.\n\n`;
break;
case 'm.video':
html = `<blockquote data-mx-reply><a href="${evLink}">In reply to</a> <a href="${userLink}">${mxid}</a>`
+ `<br>sent a video.<!--end-mx-reply--></blockquote>`;
html = `<mx-reply><blockquote><a href="${evLink}">In reply to</a> <a href="${userLink}">${mxid}</a>`
+ `<br>sent a video.</blockquote></mx-reply>`;
body = `> <${mxid}> sent a video.\n\n`;
break;
case 'm.audio':
html = `<blockquote data-mx-reply><a href="${evLink}">In reply to</a> <a href="${userLink}">${mxid}</a>`
+ `<br>sent an audio file.<!--end-mx-reply--></blockquote>`;
html = `<mx-reply><blockquote><a href="${evLink}">In reply to</a> <a href="${userLink}">${mxid}</a>`
+ `<br>sent an audio file.</blockquote></mx-reply>`;
body = `> <${mxid}> sent an audio file.\n\n`;
break;
case 'm.file':
html = `<blockquote data-mx-reply><a href="${evLink}">In reply to</a> <a href="${userLink}">${mxid}</a>`
+ `<br>sent a file.<!--end-mx-reply--></blockquote>`;
html = `<mx-reply><blockquote><a href="${evLink}">In reply to</a> <a href="${userLink}">${mxid}</a>`
+ `<br>sent a file.</blockquote></mx-reply>`;
body = `> <${mxid}> sent a file.\n\n`;
break;
case 'm.emote': {
html = `<blockquote data-mx-reply><a href="${evLink}">In reply to</a> * `
+ `<a href="${userLink}">${mxid}</a><br>${html || body}<!--end-mx-reply--></blockquote>`;
html = `<mx-reply><blockquote><a href="${evLink}">In reply to</a> * `
+ `<a href="${userLink}">${mxid}</a><br>${html || body}</blockquote></mx-reply>`;
const lines = body.trim().split('\n');
if (lines.length > 0) {
lines[0] = `* <${mxid}> ${lines[0]}`;
Expand Down

0 comments on commit f8fd90c

Please sign in to comment.