copy_and_paste.js: Fix exception on IE11 with clipboardData.

On IE11, ClipboardData isn't defined; one can instead access it with
`window.clipboardData`, but that doesn't support text/html, so this
code path couldn't do anything special anyway.

So we instead just let the default paste handler run on IE11.

Fixes #8850.
This commit is contained in:
Aastha Gupta
2018-03-30 16:30:44 +05:30
committed by Tim Abbott
parent cd8c15f1cf
commit 9d052bcf5e

View File

@@ -213,13 +213,23 @@ exports.paste_handler_converter = function (paste_html) {
exports.paste_handler = function (event) { exports.paste_handler = function (event) {
var clipboardData = event.originalEvent.clipboardData; var clipboardData = event.originalEvent.clipboardData;
if (!clipboardData) {
// On IE11, ClipboardData isn't defined. One can instead
// access it with `window.clipboardData`, but even that
// doesn't support text/html, so this code path couldn't do
// anything special anyway. So we instead just let the
// default paste handler run on IE11.
return;
}
if (clipboardData.getData) {
var paste_html = clipboardData.getData('text/html'); var paste_html = clipboardData.getData('text/html');
if (paste_html) { if (paste_html) {
event.preventDefault(); event.preventDefault();
var text = exports.paste_handler_converter(paste_html); var text = exports.paste_handler_converter(paste_html);
compose_ui.insert_syntax_and_focus(text); compose_ui.insert_syntax_and_focus(text);
} }
}
}; };
$(function () { $(function () {