summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJonas Sulzer <jonas@violoncello.ch>2019-06-26 00:00:30 +0200
committerCyrille Bollu <cyrpub@bollu.be>2019-10-03 21:54:49 +0200
commit5303d2692be2ac07c53ff230e853bfe85a671825 (patch)
tree55c8c80320df26c95eedb5710fe5847e980ac3f3 /src
parenta9c9f6dd45fa8dcb42d97684ad2447f85dc056b8 (diff)
🐛 FIX: line breaks not handled correctly
Signed-off-by: Jonas Sulzer <jonas@violoncello.ch>
Diffstat (limited to 'src')
-rw-r--r--src/components/Composer.vue13
-rw-r--r--src/components/TimelinePost.vue2
2 files changed, 12 insertions, 3 deletions
diff --git a/src/components/Composer.vue b/src/components/Composer.vue
index 5f7ccd53..857e3bb1 100644
--- a/src/components/Composer.vue
+++ b/src/components/Composer.vue
@@ -732,9 +732,11 @@ export default {
var em = document.createTextNode(emoji.getAttribute('alt'))
emoji.replaceWith(em)
})
+
let contentHtml = element.innerHTML
+
+ // Extract mentions from content and create an array ot of them
let to = []
- let hashtags = []
const mentionRegex = /<span class="mention"[^>]+><a[^>]+><img[^>]+>@([\w-_.]+@[\w-.]+)/g
let match = null
do {
@@ -744,7 +746,9 @@ export default {
}
} while (match)
+ // Extract hashtags from content and create an array ot of them
const hashtagRegex = />#([^<]+)</g
+ let hashtags = []
match = null
do {
match = hashtagRegex.exec(contentHtml)
@@ -753,16 +757,21 @@ export default {
}
} while (match)
+ // Remove all html tags but <br>
+ let content = element.innerHTML.replace(/<(?!br\s*\/?)[^>]+>/gi, '').replace(/<br\s*\/?>/gi, '\n').trim()
+
let data = {
- content: element.innerText.trim(),
+ content: content,
to: to,
hashtags: hashtags,
type: this.type,
attachments: this.postAttachments
}
+
if (this.replyTo) {
data.replyTo = this.replyTo.id
}
+
return data
},
keyup(event) {
diff --git a/src/components/TimelinePost.vue b/src/components/TimelinePost.vue
index aee1437e..88a16f44 100644
--- a/src/components/TimelinePost.vue
+++ b/src/components/TimelinePost.vue
@@ -109,7 +109,6 @@ export default {
if (typeof message === 'undefined') {
return ''
}
- message = message.replace(/(?:\r\n|\r|\n)/g, '<br />')
message = message.linkify({
formatHref: {
mention: function(href) {
@@ -120,6 +119,7 @@ export default {
if (this.item.hashtags !== undefined) {
message = this.mangleHashtags(message)
}
+ message = message.replace(/(?:\r\n|\r|\n)/g, '<br>')
message = this.$twemoji.parse(message)
return message
},