Add support for bold, italics and strikethrough formatting in comments (#2475)

This commit is contained in:
absidue 2022-08-16 14:11:29 +02:00 committed by GitHub
parent 83d54bec39
commit 3e07114d47
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -268,7 +268,8 @@ export default Vue.extend({
if (this.hideCommentLikes) { if (this.hideCommentLikes) {
comment.likes = null comment.likes = null
} }
comment.text = autolinker.link(comment.text.replace(/(<(?!br>)([^>]+)>)/ig, '')) // strip html tags but keep <br>, <b>, </b> <s>, </s>, <i>, </i>
comment.text = autolinker.link(comment.text.replace(/(<(?!br|\/?(?:b|s|i)>)([^>]+)>)/ig, ''))
if (comment.customEmojis.length > 0) { if (comment.customEmojis.length > 0) {
comment.customEmojis.forEach(emoji => { comment.customEmojis.forEach(emoji => {
comment.text = comment.text.replace(emoji.text, `<img width="14" height="14" class="commentCustomEmoji" alt="${emoji.text.substring(2, emoji.text.length - 1)}" src="${emoji.emojiThumbnails[0].url}">`) comment.text = comment.text.replace(emoji.text, `<img width="14" height="14" class="commentCustomEmoji" alt="${emoji.text.substring(2, emoji.text.length - 1)}" src="${emoji.emojiThumbnails[0].url}">`)