From 9830340ef86d910af9f799689d18d0a5f8b48612 Mon Sep 17 00:00:00 2001 From: Igor Zhukov Date: Fri, 13 Feb 2015 15:16:03 +0300 Subject: [PATCH] Fixed file paste in IE --- app/js/directives.js | 6 +++--- app/js/message_composer.js | 9 +++++++-- app/js/services.js | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/app/js/directives.js b/app/js/directives.js index 3ec69b13..264989bd 100755 --- a/app/js/directives.js +++ b/app/js/directives.js @@ -1119,7 +1119,7 @@ angular.module('myApp.directives', ['myApp.filters']) return sendOnEnter; }, onMessageSubmit: onMessageSubmit, - onFilesPaste: onFilesPaste + onFilePaste: onFilePaste }); var richTextarea = composer.richTextareaEl[0]; @@ -1223,9 +1223,9 @@ angular.module('myApp.directives', ['myApp.filters']) }); } - function onFilesPaste (blobs) { + function onFilePaste (blob) { ErrorService.confirm({type: 'FILE_CLIPBOARD_PASTE'}).then(function () { - $scope.draftMessage.files = blobs; + $scope.draftMessage.files = [blob]; $scope.draftMessage.isMedia = true; }); }; diff --git a/app/js/message_composer.js b/app/js/message_composer.js index 9afa2252..b03b97c9 100644 --- a/app/js/message_composer.js +++ b/app/js/message_composer.js @@ -438,6 +438,7 @@ function MessageComposer (textarea, options) { this.onTyping = options.onTyping; this.onMessageSubmit = options.onMessageSubmit; this.getSendOnEnter = options.getSendOnEnter; + this.onFilePaste = options.onFilePaste; } MessageComposer.prototype.setUpInput = function () { @@ -673,7 +674,11 @@ MessageComposer.prototype.onRichPaste = function (e) { } } - var text = (e.originalEvent || e).clipboardData.getData('text/plain'); + try { + var text = cData.getData('text/plain'); + } catch (e) { + return true; + } setZeroTimeout(this.onChange.bind(this), 0); if (text.length) { document.execCommand('insertText', false, text); @@ -692,7 +697,7 @@ MessageComposer.prototype.onRichPasteNode = function (e) { var blob = dataUrlToBlob(src); this.onFilePaste(blob); setZeroTimeout(function () { - element.parentNode.removeChild(element); + element.parentNode.replaceChild(document.createTextNode('   '), element); }) } else if (src && !src.match(/img\/blank\.gif/)) { diff --git a/app/js/services.js b/app/js/services.js index e52b5b9c..acfe68fb 100755 --- a/app/js/services.js +++ b/app/js/services.js @@ -3710,7 +3710,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) // console.log(3, text, html); if (emojiFound) { - text = text.replace(/\ufe0f/g, '', text); + text = text.replace(/\ufe0f|️/g, '', text); text = text.replace(//g, ''); }