[Enhancement] Format messages in widget (#268)

* Use message formatter in widget

* Rename the variable
This commit is contained in:
Pranav Raj S
2019-11-24 00:29:55 +05:30
committed by Sony Mathew
parent c96e2c334c
commit c6feea9f6d
6 changed files with 66 additions and 17 deletions

View File

@@ -42,6 +42,7 @@
</template>
<script>
/* eslint-disable no-named-as-default */
import messageFormatterMixin from 'shared/mixins/messageFormatterMixin';
import getEmojiSVG from '../emoji/utils';
import timeMixin from '../../../mixins/time';
import BubbleText from './bubble/Text';
@@ -56,7 +57,7 @@ export default {
BubbleMap,
BubbleAudio,
},
mixins: [timeMixin],
mixins: [timeMixin, messageFormatterMixin],
props: {
data: {
type: Object,
@@ -70,8 +71,7 @@ export default {
},
computed: {
message() {
const linkifiedMessage = this.linkify(this.data.content);
return linkifiedMessage.replace(/\n/g, '<br>');
return this.formatMessage(this.data.content);
},
alignBubble() {
return this.data.message_type === 1 ? 'right' : 'left';
@@ -106,14 +106,6 @@ export default {
},
methods: {
getEmojiSVG,
linkify(text) {
if (!text) return text;
const urlRegex = /(https?:\/\/[^\s]+)/g;
return text.replace(
urlRegex,
url => `<a href="${url}" target="_blank">${url}</a>`
);
},
},
};
</script>