2019-11-23 18:59:55 +00:00
|
|
|
import MessageFormatter from '../helpers/MessageFormatter';
|
2021-07-15 07:24:31 +00:00
|
|
|
import DOMPurify from 'dompurify';
|
2019-11-23 18:59:55 +00:00
|
|
|
|
|
|
|
export default {
|
|
|
|
methods: {
|
2022-03-31 14:52:52 +00:00
|
|
|
formatMessage(message, isATweet, isAPrivateNote) {
|
|
|
|
const messageFormatter = new MessageFormatter(
|
|
|
|
message,
|
|
|
|
isATweet,
|
|
|
|
isAPrivateNote
|
|
|
|
);
|
2019-11-23 18:59:55 +00:00
|
|
|
return messageFormatter.formattedMessage;
|
|
|
|
},
|
2021-01-15 09:10:50 +00:00
|
|
|
getPlainText(message, isATweet) {
|
|
|
|
const messageFormatter = new MessageFormatter(message, isATweet);
|
|
|
|
return messageFormatter.plainText;
|
|
|
|
},
|
2020-04-10 11:12:37 +00:00
|
|
|
truncateMessage(description = '') {
|
|
|
|
if (description.length < 100) {
|
|
|
|
return description;
|
|
|
|
}
|
|
|
|
|
|
|
|
return `${description.slice(0, 97)}...`;
|
|
|
|
},
|
2021-07-15 07:24:31 +00:00
|
|
|
stripStyleCharacters(message) {
|
|
|
|
return DOMPurify.sanitize(message, {
|
|
|
|
FORBID_TAGS: ['style'],
|
|
|
|
FORBID_ATTR: [
|
|
|
|
'id',
|
|
|
|
'class',
|
|
|
|
'style',
|
|
|
|
'bgcolor',
|
|
|
|
'valign',
|
|
|
|
'width',
|
|
|
|
'face',
|
|
|
|
'color',
|
|
|
|
'height',
|
|
|
|
'lang',
|
|
|
|
'align',
|
|
|
|
'size',
|
2021-09-14 06:25:48 +00:00
|
|
|
'border',
|
2021-07-15 07:24:31 +00:00
|
|
|
],
|
|
|
|
});
|
|
|
|
},
|
2019-11-23 18:59:55 +00:00
|
|
|
},
|
|
|
|
};
|