From cbf89140b3594bb7b44f8312f45c25c7c50965e8 Mon Sep 17 00:00:00 2001 From: alecpl <alec@alec.pl> Date: Mon, 07 Feb 2011 04:02:29 -0500 Subject: [PATCH] - Fix vcard export (#1487765) --- program/js/tiny_mce/plugins/paste/editor_plugin_src.js | 25 ++++++++++++++++++------- 1 files changed, 18 insertions(+), 7 deletions(-) diff --git a/program/js/tiny_mce/plugins/paste/editor_plugin_src.js b/program/js/tiny_mce/plugins/paste/editor_plugin_src.js index d85b39b..4c3bf65 100644 --- a/program/js/tiny_mce/plugins/paste/editor_plugin_src.js +++ b/program/js/tiny_mce/plugins/paste/editor_plugin_src.js @@ -113,9 +113,9 @@ if ((ed.pasteAsPlainText) && (!cookie.get("tinymcePasteText"))) { if (getParam(ed, "paste_text_sticky")) { - ed.windowManager.alert("Paste is now in plain text mode. Click again to toggle back to regular paste mode. After you paste something you will be returned to regular paste mode."); + ed.windowManager.alert(ed.translate('paste.plaintext_mode_sticky')); } else { - ed.windowManager.alert("Paste is now in plain text mode. Click again to toggle back to regular paste mode."); + ed.windowManager.alert(ed.translate('paste.plaintext_mode_sticky')); } if (!getParam(ed, "paste_text_notifyalways")) { @@ -133,6 +133,13 @@ // is done it grabs that contents and processes that function grabContent(e) { var n, or, rng, sel = ed.selection, dom = ed.dom, body = ed.getBody(), posY; + + // Check if browser supports direct plaintext access + if (ed.pasteAsPlainText && (e.clipboardData || dom.doc.dataTransfer)) { + e.preventDefault(); + process({content : (e.clipboardData || dom.doc.dataTransfer).getData('Text')}, true); + return; + } if (dom.get('_mcePaste')) return; @@ -207,8 +214,12 @@ dom.remove(n, 1); }); - // Contents in WebKit is sometimes wrapped in a apple style span so we need to grab it from that one - h += (dom.select('> span.Apple-style-span div', n)[0] || dom.select('> span.Apple-style-span', n)[0] || n).innerHTML; + // Remove apply style spans + each(dom.select('span.Apple-style-span', n), function(n) { + dom.remove(n, 1); + }); + + h += n.innerHTML; }); // Remove the nodes @@ -707,10 +718,10 @@ * Inserts the specified contents at the caret position. */ _insert : function(h, skip_undo) { - var ed = this.editor; + var ed = this.editor, r = ed.selection.getRng(); - // First delete the contents seems to work better on WebKit - if (!ed.selection.isCollapsed()) + // First delete the contents seems to work better on WebKit when the selection spans multiple list items or multiple table cells. + if (!ed.selection.isCollapsed() && r.startContainer != r.endContainer) ed.getDoc().execCommand('Delete', false, null); // It's better to use the insertHTML method on Gecko since it will combine paragraphs correctly before inserting the contents -- Gitblit v1.9.1