emoji: Fix rendering of emojione images
This commit is contained in:
parent
972c31be1d
commit
12510a9689
@ -427,10 +427,11 @@
|
||||
'extra_classes': this.getExtraMessageClasses(attrs)
|
||||
})
|
||||
));
|
||||
text = utils.addEmoji(_converse, emojione, text);
|
||||
const msg_content = $msg[0].querySelector('.chat-msg-content');
|
||||
msg_content.innerHTML = xss.filterXSS(text, {'whiteList': {}});
|
||||
utils.addHyperlinks(msg_content);
|
||||
msg_content.innerHTML = utils.addEmoji(
|
||||
_converse, emojione, utils.addHyperlinks(xss.filterXSS(text, {'whiteList': {}}))
|
||||
);
|
||||
utils.renderImageURLs(msg_content);
|
||||
return $msg;
|
||||
},
|
||||
|
||||
|
19
src/utils.js
19
src/utils.js
@ -97,10 +97,6 @@
|
||||
return false;
|
||||
};
|
||||
|
||||
var throttledHTML = _.throttle(function (el, html) {
|
||||
el.innerHTML = html;
|
||||
}, 500);
|
||||
|
||||
function calculateSlideStep (height) {
|
||||
if (height > 100) {
|
||||
return 10;
|
||||
@ -157,21 +153,24 @@
|
||||
}
|
||||
};
|
||||
|
||||
utils.addHyperlinks = function (obj) {
|
||||
var x = obj.innerHTML;
|
||||
var list = x.match(/\b(https?:\/\/|www\.|https?:\/\/www\.)[^\s<]{2,200}\b/g ) || [];
|
||||
utils.addHyperlinks = function (text) {
|
||||
var list = text.match(/\b(https?:\/\/|www\.|https?:\/\/www\.)[^\s<>]{2,200}\b/g ) || [];
|
||||
_.each(list, (match) => {
|
||||
const prot = match.indexOf('http://') === 0 || match.indexOf('https://') === 0 ? '' : 'http://';
|
||||
const url = prot + encodeURI(decodeURI(match)).replace(/[!'()]/g, escape).replace(/\*/g, "%2A");
|
||||
x = x.replace(match, '<a target="_blank" rel="noopener" href="' + url + '">'+ match + '</a>' );
|
||||
text = text.replace(match, '<a target="_blank" rel="noopener" href="' + url + '">'+ match + '</a>' );
|
||||
});
|
||||
obj.innerHTML = x;
|
||||
return text;
|
||||
};
|
||||
|
||||
utils.renderImageURLs = function (obj) {
|
||||
var list = obj.textContent.match(/\b(https?:\/\/|www\.|https?:\/\/www\.)[^\s<>]{2,200}\b/g ) || [];
|
||||
_.forEach(list, function (url) {
|
||||
isImage(unescapeHTML(url)).then(function (img) {
|
||||
img.className = 'chat-image';
|
||||
var a = obj.querySelector('a');
|
||||
if (!_.isNull(a)) {
|
||||
throttledHTML(a, img.outerHTML);
|
||||
a.innerHTML = img.outerHTML;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user