In the desktop app, paste emoji as text to work around webkit bug

See Trac #1060

(imported from commit 860f16c5a9db626a4fd2d55bcb0dd137e5196560)
This commit is contained in:
Jeff Arnold 2013-07-22 18:25:25 -04:00
parent 6cd0b0468d
commit ee3806ef5b
2 changed files with 14 additions and 3 deletions

View File

@ -174,9 +174,7 @@ function process_notification(notification) {
// Convert the content to plain text, replacing emoji with their alt text
content = $('<div/>').html(message.content);
content.find(".emoji").replaceWith(function () {
return $(this).attr("alt");
});
ui.replace_emoji_with_text(content);
content = content.text();
if (message.type === "private") {

View File

@ -114,6 +114,12 @@ function find_boundary_tr(initial_tr, iterate_row) {
return [rows.id(tr), skip_same_td_check];
}
exports.replace_emoji_with_text = function (element) {
element.find(".emoji").replaceWith(function () {
return $(this).attr("alt");
});
};
function copy_handler(e) {
var selection = window.getSelection();
var i, range, ranges = [], startc, endc, initial_end_tr, start_id, end_id, row, message;
@ -183,6 +189,13 @@ function copy_handler(e) {
}
}
if (window.bridge !== undefined) {
// If the user is running the desktop app,
// convert emoji images to plain text for
// copy-paste purposes.
exports.replace_emoji_with_text(div);
}
// Select div so that the browser will copy it
// instead of copying the original selection
div.css({position: 'absolute', 'left': '-99999px'})