mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: IE compatability issue in clipboard data types array
This commit is contained in:
parent
6e054b2572
commit
8cf7152151
@ -396,10 +396,10 @@ export default Ember.Component.extend({
|
|||||||
});
|
});
|
||||||
|
|
||||||
$element.on('fileuploadpaste', (e) => {
|
$element.on('fileuploadpaste', (e) => {
|
||||||
const clipboard = clipboardData(e);
|
const { types } = clipboardData(e);
|
||||||
this._pasted = true;
|
this._pasted = true;
|
||||||
|
|
||||||
if (clipboard.types.some(t => t === "text/plain")) {
|
if (types.includes("text/plain")) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -640,7 +640,7 @@ export default Ember.Component.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
paste(e) {
|
paste(e) {
|
||||||
const clipboard = clipboardData(e);
|
const { clipboard, types } = clipboardData(e);
|
||||||
const placeholder = `${ I18n.t('pasting') }`;
|
const placeholder = `${ I18n.t('pasting') }`;
|
||||||
let plainText = clipboard.getData("text/plain");
|
let plainText = clipboard.getData("text/plain");
|
||||||
const html = clipboard.getData("text/html");
|
const html = clipboard.getData("text/html");
|
||||||
@ -675,7 +675,7 @@ export default Ember.Component.extend({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const uploadFiles = clipboard.types.includes("Files") && !plainText && !html;
|
const uploadFiles = types.includes("Files") && !plainText && !html;
|
||||||
|
|
||||||
if (handled || uploadFiles) {
|
if (handled || uploadFiles) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
@ -422,9 +422,17 @@ export function isAppleDevice() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function clipboardData(e) {
|
export function clipboardData(e) {
|
||||||
return e.clipboardData ||
|
const clipboard = e.clipboardData ||
|
||||||
e.originalEvent.clipboardData ||
|
e.originalEvent.clipboardData ||
|
||||||
e.delegatedEvent.originalEvent.clipboardData;
|
e.delegatedEvent.originalEvent.clipboardData;
|
||||||
|
|
||||||
|
let types = clipboard.types;
|
||||||
|
|
||||||
|
if (typeof types !== "array") {
|
||||||
|
types = Array.from(types);
|
||||||
|
}
|
||||||
|
|
||||||
|
return { clipboard: clipboard, types: types };
|
||||||
}
|
}
|
||||||
|
|
||||||
// This prevents a mini racer crash
|
// This prevents a mini racer crash
|
||||||
|
Loading…
Reference in New Issue
Block a user