// remove document fragments
if (pastedHtml.match(/^<html>[\s\S]*?<body>([\s\S]+)<\/body>\s*<\/html>$/)) {
- pastedHtml = RegExp.$1;
+ pastedHtml = RegExp.$1.replace(/^\s*(?:<!--StartFragment-->)(.+)(?:<!--EndFragment-->)?\s*$/, '$1');
}
}
}
return;
}
+ if (this.detect.isWebkit()) {
+ var item, hasFile = false, hasHtml = false;
+ for (var i = 0, length = clipboard.items.length; i < length; i++) {
+ item = clipboard.items[i];
+ if (item.kind === 'string' && item.type === 'text/html') hasHtml = true;
+ else if (item.kind === 'file') hasFile = true;
+ }
+
+ // pasted an `<img>` element from clipboard
+ if (hasFile && hasHtml) {
+ return false;
+ }
+ }
+
var cancelPaste = false;
file = clipboard.items[0].getAsFile();
if (file === null) {