Fix pasting of non-HTTP URLs into notes from non-note sources

Copying zotero:// and other non-HTTP links from a note itself was fixed
in #452, but copying such links from other sources still stripped the
hrefs. This removes the patch in #452 and just gets the HTML directly
from the clipboard. I'm not sure why TinyMCE doesn't try to do this by
default (it only tries for plaintext), so maybe there's a problem with
this approach, but it seems to work for me (strips bad HTML, etc.).

Fixes #697
This commit is contained in:
Dan Stillman 2015-04-10 12:58:46 -04:00
parent 1c2b2575f7
commit b599aed8ed

View file

@ -152,6 +152,15 @@
// Check if browser supports direct plaintext access
if (e.clipboardData || dom.doc.dataTransfer) {
// Added by Zotero
// Get HTML from the clipboard directly
var html = e.clipboardData && e.clipboardData.getData('text/html');
if (html) {
e.preventDefault();
process({content : html});
return;
}
textContent = (e.clipboardData || dom.doc.dataTransfer).getData('Text');
if (ed.pasteAsPlainText) {
@ -248,14 +257,6 @@
each(nl, function(n) {
var child = n.firstChild;
// Added by Zotero
// fix copy/paste of non-http links
var links = n.querySelectorAll('a');
for (var i = 0; i < links.length; i++) {
if (!links[i].href && links[i].getAttribute('data-mce-href'))
links[i].setAttribute('href', links[i].getAttribute('data-mce-href'));
}
// WebKit inserts a DIV container with lots of odd styles
if (child && child.nodeName == 'DIV' && child.style.marginTop && child.style.backgroundColor) {
dom.remove(child, 1);