Browse Source

Fixed file paste in IE

master
Igor Zhukov 10 years ago
parent
commit
9830340ef8
  1. 6
      app/js/directives.js
  2. 9
      app/js/message_composer.js
  3. 2
      app/js/services.js

6
app/js/directives.js

@ -1119,7 +1119,7 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -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']) @@ -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;
});
};

9
app/js/message_composer.js

@ -438,6 +438,7 @@ function MessageComposer (textarea, options) { @@ -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) { @@ -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) { @@ -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/)) {

2
app/js/services.js

@ -3710,7 +3710,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) @@ -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(/<span class="emoji emoji-(\d)-(\d+)-(\d+)"(.+?)<\/span>/g,
'<span class="emoji emoji-spritesheet-$1" style="background-position: -$2px -$3px;" $4</span>');
}

Loading…
Cancel
Save