\r
if ((ed.pasteAsPlainText) && (!cookie.get("tinymcePasteText"))) {\r
if (getParam(ed, "paste_text_sticky")) {\r
- 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.");\r
+ ed.windowManager.alert(ed.translate('paste.plaintext_mode_sticky'));\r
} else {\r
- ed.windowManager.alert("Paste is now in plain text mode. Click again to toggle back to regular paste mode.");\r
+ ed.windowManager.alert(ed.translate('paste.plaintext_mode_sticky'));\r
}\r
\r
if (!getParam(ed, "paste_text_notifyalways")) {\r
function grabContent(e) {\r
var n, or, rng, sel = ed.selection, dom = ed.dom, body = ed.getBody(), posY;\r
\r
+ // Check if browser supports direct plaintext access\r
+ if (ed.pasteAsPlainText && (e.clipboardData || dom.doc.dataTransfer)) {\r
+ e.preventDefault();\r
+ process({content : (e.clipboardData || dom.doc.dataTransfer).getData('Text')}, true);\r
+ return;\r
+ }\r
+\r
if (dom.get('_mcePaste'))\r
return;\r
\r
// Create container to paste into\r
- n = dom.add(body, 'div', {id : '_mcePaste', 'class' : 'mcePaste'}, '\uFEFF');\r
+ n = dom.add(body, 'div', {id : '_mcePaste', 'class' : 'mcePaste'}, '\uFEFF<br _mce_bogus="1">');\r
\r
// If contentEditable mode we need to find out the position of the closest element\r
if (body != ed.getDoc().body)\r
\r
// WebKit will split the div into multiple ones so this will loop through then all and join them to get the whole HTML string\r
each(nl, function(n) {\r
+ var child = n.firstChild;\r
+\r
+ // WebKit inserts a DIV container with lots of odd styles\r
+ if (child && child.nodeName == 'DIV' && child.style.marginTop && child.style.backgroundColor) {\r
+ dom.remove(child, 1);\r
+ }\r
+\r
// WebKit duplicates the divs so we need to remove them\r
each(dom.select('div.mcePaste', n), function(n) {\r
dom.remove(n, 1);\r
});\r
\r
- // Contents in WebKit is sometimes wrapped in a apple style span so we need to grab it from that one\r
- h += (dom.select('> span.Apple-style-span div', n)[0] || dom.select('> span.Apple-style-span', n)[0] || n).innerHTML;\r
+ // Remove apply style spans\r
+ each(dom.select('span.Apple-style-span', n), function(n) {\r
+ dom.remove(n, 1);\r
+ });\r
+\r
+ // Remove bogus br elements\r
+ each(dom.select('br[_mce_bogus]', n), function(n) {\r
+ dom.remove(n);\r
+ });\r
+\r
+ h += n.innerHTML;\r
});\r
\r
// Remove the nodes\r
}\r
\r
// Insert a marker for the caret position\r
- this._insert('<span id="' + markerId + '"> </span>', 1);\r
+ this._insert('<span id="' + markerId + '"></span>', 1);\r
marker = dom.get(markerId);\r
parentBlock = dom.getParent(marker, 'p,h1,h2,h3,h4,h5,h6,ul,ol,th,td');\r
\r
* Inserts the specified contents at the caret position.\r
*/\r
_insert : function(h, skip_undo) {\r
- var ed = this.editor;\r
+ var ed = this.editor, r = ed.selection.getRng();\r
\r
- // First delete the contents seems to work better on WebKit\r
- if (!ed.selection.isCollapsed())\r
+ // First delete the contents seems to work better on WebKit when the selection spans multiple list items or multiple table cells.\r
+ if (!ed.selection.isCollapsed() && r.startContainer != r.endContainer)\r
ed.getDoc().execCommand('Delete', false, null);\r
\r
// It's better to use the insertHTML method on Gecko since it will combine paragraphs correctly before inserting the contents\r