From b599aed8eda595ee5c7f4cc54df4c11f2eed886c Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Fri, 10 Apr 2015 12:58:46 -0400 Subject: [PATCH] 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 --- resource/tinymce/plugins/paste/editor_plugin.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/resource/tinymce/plugins/paste/editor_plugin.js b/resource/tinymce/plugins/paste/editor_plugin.js index 848abfdd88..36b85c2aff 100644 --- a/resource/tinymce/plugins/paste/editor_plugin.js +++ b/resource/tinymce/plugins/paste/editor_plugin.js @@ -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);