comparison media/js/tiny_mce/plugins/paste/editor_plugin_src.js @ 217:237710206167

Update TinyMCE to 3.3.6
author Brian Neal <bgneal@gmail.com>
date Tue, 01 Jun 2010 04:49:29 +0000
parents 149c3567fec1
children 6ed2932901fa
comparison
equal deleted inserted replaced
216:fe900598f81c 217:237710206167
111 ed.pasteAsPlainText = !ed.pasteAsPlainText; 111 ed.pasteAsPlainText = !ed.pasteAsPlainText;
112 ed.controlManager.setActive('pastetext', ed.pasteAsPlainText); 112 ed.controlManager.setActive('pastetext', ed.pasteAsPlainText);
113 113
114 if ((ed.pasteAsPlainText) && (!cookie.get("tinymcePasteText"))) { 114 if ((ed.pasteAsPlainText) && (!cookie.get("tinymcePasteText"))) {
115 if (getParam(ed, "paste_text_sticky")) { 115 if (getParam(ed, "paste_text_sticky")) {
116 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."); 116 ed.windowManager.alert(ed.translate('paste.plaintext_mode_sticky'));
117 } else { 117 } else {
118 ed.windowManager.alert("Paste is now in plain text mode. Click again to toggle back to regular paste mode."); 118 ed.windowManager.alert(ed.translate('paste.plaintext_mode_sticky'));
119 } 119 }
120 120
121 if (!getParam(ed, "paste_text_notifyalways")) { 121 if (!getParam(ed, "paste_text_notifyalways")) {
122 cookie.set("tinymcePasteText", "1", new Date(new Date().getFullYear() + 1, 12, 31)) 122 cookie.set("tinymcePasteText", "1", new Date(new Date().getFullYear() + 1, 12, 31))
123 } 123 }
131 // This function grabs the contents from the clipboard by adding a 131 // This function grabs the contents from the clipboard by adding a
132 // hidden div and placing the caret inside it and after the browser paste 132 // hidden div and placing the caret inside it and after the browser paste
133 // is done it grabs that contents and processes that 133 // is done it grabs that contents and processes that
134 function grabContent(e) { 134 function grabContent(e) {
135 var n, or, rng, sel = ed.selection, dom = ed.dom, body = ed.getBody(), posY; 135 var n, or, rng, sel = ed.selection, dom = ed.dom, body = ed.getBody(), posY;
136
137 // Check if browser supports direct plaintext access
138 if (ed.pasteAsPlainText && (e.clipboardData || dom.doc.dataTransfer)) {
139 e.preventDefault();
140 process({content : (e.clipboardData || dom.doc.dataTransfer).getData('Text')}, true);
141 return;
142 }
136 143
137 if (dom.get('_mcePaste')) 144 if (dom.get('_mcePaste'))
138 return; 145 return;
139 146
140 // Create container to paste into 147 // Create container to paste into
205 // WebKit duplicates the divs so we need to remove them 212 // WebKit duplicates the divs so we need to remove them
206 each(dom.select('div.mcePaste', n), function(n) { 213 each(dom.select('div.mcePaste', n), function(n) {
207 dom.remove(n, 1); 214 dom.remove(n, 1);
208 }); 215 });
209 216
210 // Contents in WebKit is sometimes wrapped in a apple style span so we need to grab it from that one 217 // Remove apply style spans
211 h += (dom.select('> span.Apple-style-span div', n)[0] || dom.select('> span.Apple-style-span', n)[0] || n).innerHTML; 218 each(dom.select('span.Apple-style-span', n), function(n) {
219 dom.remove(n, 1);
220 });
221
222 h += n.innerHTML;
212 }); 223 });
213 224
214 // Remove the nodes 225 // Remove the nodes
215 each(nl, function(n) { 226 each(nl, function(n) {
216 dom.remove(n); 227 dom.remove(n);
705 716
706 /** 717 /**
707 * Inserts the specified contents at the caret position. 718 * Inserts the specified contents at the caret position.
708 */ 719 */
709 _insert : function(h, skip_undo) { 720 _insert : function(h, skip_undo) {
710 var ed = this.editor; 721 var ed = this.editor, r = ed.selection.getRng();
711 722
712 // First delete the contents seems to work better on WebKit 723 // First delete the contents seems to work better on WebKit when the selection spans multiple list items or multiple table cells.
713 if (!ed.selection.isCollapsed()) 724 if (!ed.selection.isCollapsed() && r.startContainer != r.endContainer)
714 ed.getDoc().execCommand('Delete', false, null); 725 ed.getDoc().execCommand('Delete', false, null);
715 726
716 // It's better to use the insertHTML method on Gecko since it will combine paragraphs correctly before inserting the contents 727 // It's better to use the insertHTML method on Gecko since it will combine paragraphs correctly before inserting the contents
717 ed.execCommand(tinymce.isGecko ? 'insertHTML' : 'mceInsertContent', false, h, {skip_undo : skip_undo}); 728 ed.execCommand(tinymce.isGecko ? 'insertHTML' : 'mceInsertContent', false, h, {skip_undo : skip_undo});
718 }, 729 },