Skip to content

Commit 70965a8

Browse files
authored
Merge pull request #334 from hiro-su/fix-ie11-paste-key
Fixed paste key in IE11
2 parents 26de9fe + 77ca154 commit 70965a8

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/handlers/Clipboard.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,24 @@ function copyHandler (ev) {
5050
*/
5151
function pasteHandler(ev, term) {
5252
ev.stopPropagation();
53-
if (ev.clipboardData) {
54-
var text = ev.clipboardData.getData('text/plain');
53+
54+
var dispatchPaste = function(text) {
5555
term.handler(text);
5656
term.textarea.value = '';
5757
return term.cancel(ev);
58+
};
59+
60+
var userAgent = window.navigator.userAgent.toLowerCase();
61+
if (userAgent.match(/msie|MSIE/) || userAgent.match(/(T|t)rident/)) {
62+
if (window.clipboardData) {
63+
var text = window.clipboardData.getData('Text');
64+
dispatchPaste(text);
65+
}
66+
} else {
67+
if (ev.clipboardData) {
68+
var text = ev.clipboardData.getData('text/plain');
69+
dispatchPaste(text);
70+
}
5871
}
5972
}
6073

0 commit comments

Comments
 (0)