Merge pull request #3718 from tgxworld/allow_emojis_to_be_copy_and_pasted

FIX: Allow user to quote Emojis.
This commit is contained in:
Sam
2015-09-07 08:48:34 +10:00
3 changed files with 7 additions and 3 deletions
@@ -77,7 +77,8 @@ function imageFor(code) {
code = code.toLowerCase();
var url = urlFor(code);
if (url) {
return ['img', { href: url, title: ':' + code + ':', 'class': 'emoji', alt: code }];
var code = ':' + code + ':';
return ['img', { href: url, title: code, 'class': 'emoji', alt: code }];
}
}
@@ -97,7 +97,10 @@ Discourse.Utilities = {
// Strip out any .click elements from the HTML before converting it to text
var div = document.createElement('div');
div.innerHTML = html;
$('.clicks', $(div)).remove();
var $div = $(div);
// Find all emojis and replace with its title attribute.
$div.find('img.emoji').replaceWith(function() { return this.title });
$('.clicks', $div).remove();
var text = div.textContent || div.innerText || "";
return String(text).trim();