summaryrefslogtreecommitdiff
path: root/program/js/tiny_mce/plugins/paste
diff options
context:
space:
mode:
authoralecpl <alec@alec.pl>2009-12-15 08:48:45 +0000
committeralecpl <alec@alec.pl>2009-12-15 08:48:45 +0000
commit58fb6502e3550e59afa8799d36dfce61a18f8b1b (patch)
tree821b5ac61675cada8977d956262ffb5e9b90a2fb /program/js/tiny_mce/plugins/paste
parent463a03112260ecf39818eac09905f41d8e84ced7 (diff)
- Updated TinyMCE to 3.2.7
Diffstat (limited to 'program/js/tiny_mce/plugins/paste')
-rw-r--r--program/js/tiny_mce/plugins/paste/blank.htm22
-rw-r--r--program/js/tiny_mce/plugins/paste/css/blank.css14
-rw-r--r--program/js/tiny_mce/plugins/paste/css/pasteword.css3
-rw-r--r--program/js/tiny_mce/plugins/paste/editor_plugin.js2
-rw-r--r--program/js/tiny_mce/plugins/paste/editor_plugin_src.js230
-rw-r--r--program/js/tiny_mce/plugins/paste/js/pastetext.js2
-rw-r--r--program/js/tiny_mce/plugins/paste/js/pasteword.js6
7 files changed, 185 insertions, 94 deletions
diff --git a/program/js/tiny_mce/plugins/paste/blank.htm b/program/js/tiny_mce/plugins/paste/blank.htm
deleted file mode 100644
index 7ba26bd65..000000000
--- a/program/js/tiny_mce/plugins/paste/blank.htm
+++ /dev/null
@@ -1,22 +0,0 @@
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
-<title>blank_page</title>
-<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
-<link href="css/blank.css" rel="stylesheet" type="text/css" />
-<base target="_self" />
-<script type="text/javascript">
-function init() {
- if (parent.tinymce.isIE)
- document.body.contentEditable = true;
- else
- document.designMode = 'on';
-
- parent.initIframe(document);
- window.focus();
-}
-</script>
-</head>
-<body onload="init();">
-
-</body>
-</html>
diff --git a/program/js/tiny_mce/plugins/paste/css/blank.css b/program/js/tiny_mce/plugins/paste/css/blank.css
deleted file mode 100644
index 6b16bac25..000000000
--- a/program/js/tiny_mce/plugins/paste/css/blank.css
+++ /dev/null
@@ -1,14 +0,0 @@
-html, body {height:98%}
-body {
-background-color: #FFFFFF;
-font-family: Verdana, Arial, Helvetica, sans-serif;
-font-size: 10px;
-scrollbar-3dlight-color: #F0F0EE;
-scrollbar-arrow-color: #676662;
-scrollbar-base-color: #F0F0EE;
-scrollbar-darkshadow-color: #DDDDDD;
-scrollbar-face-color: #E0E0DD;
-scrollbar-highlight-color: #F0F0EE;
-scrollbar-shadow-color: #F0F0EE;
-scrollbar-track-color: #F5F5F5;
-}
diff --git a/program/js/tiny_mce/plugins/paste/css/pasteword.css b/program/js/tiny_mce/plugins/paste/css/pasteword.css
deleted file mode 100644
index b3be6270b..000000000
--- a/program/js/tiny_mce/plugins/paste/css/pasteword.css
+++ /dev/null
@@ -1,3 +0,0 @@
-.sourceIframe {
- border: 1px solid #808080;
-}
diff --git a/program/js/tiny_mce/plugins/paste/editor_plugin.js b/program/js/tiny_mce/plugins/paste/editor_plugin.js
index 93848bf78..7b2bbd9b3 100644
--- a/program/js/tiny_mce/plugins/paste/editor_plugin.js
+++ b/program/js/tiny_mce/plugins/paste/editor_plugin.js
@@ -1 +1 @@
-(function(){var a=tinymce.each;tinymce.create("tinymce.plugins.PastePlugin",{init:function(c,d){var e=this,b;e.editor=c;e.url=d;e.onPreProcess=new tinymce.util.Dispatcher(e);e.onPostProcess=new tinymce.util.Dispatcher(e);e.onPreProcess.add(e._preProcess);e.onPostProcess.add(e._postProcess);e.onPreProcess.add(function(h,i){c.execCallback("paste_preprocess",h,i)});e.onPostProcess.add(function(h,i){c.execCallback("paste_postprocess",h,i)});function g(i){var k=c.dom,j={content:i};e.onPreProcess.dispatch(e,j);j.node=k.create("div",0,j.content);e.onPostProcess.dispatch(e,j);j.content=c.serializer.serialize(j.node,{getInner:1});if(/<(p|h[1-6]|ul|ol)/.test(j.content)){e._insertBlockContent(c,k,j.content)}else{e._insert(j.content)}}c.addCommand("mceInsertClipboardContent",function(i,h){g(h)});function f(l){var p,k,i,j=c.selection,o=c.dom,h=c.getBody(),m;if(o.get("_mcePaste")){return}p=o.add(h,"div",{id:"_mcePaste"},"&nbsp;");if(h!=c.getDoc().body){m=o.getPos(c.selection.getStart(),h).y}else{m=h.scrollTop}o.setStyles(p,{position:"absolute",left:-10000,top:m,width:1,height:1,overflow:"hidden"});if(tinymce.isIE){i=o.doc.body.createTextRange();i.moveToElementText(p);i.execCommand("Paste");o.remove(p);g(p.innerHTML);return tinymce.dom.Event.cancel(l)}else{k=c.selection.getRng();p=p.firstChild;i=c.getDoc().createRange();i.setStart(p,0);i.setEnd(p,1);j.setRng(i);window.setTimeout(function(){var r=o.get("_mcePaste"),q;r.id="_mceRemoved";o.remove(r);r=o.get("_mcePaste")||r;q=(o.select("> span.Apple-style-span div",r)[0]||o.select("> span.Apple-style-span",r)[0]||r).innerHTML;o.remove(r);if(k){j.setRng(k)}g(q)},0)}}if(c.getParam("paste_auto_cleanup_on_paste",true)){if(tinymce.isOpera||/Firefox\/2/.test(navigator.userAgent)){c.onKeyDown.add(function(h,i){if(((tinymce.isMac?i.metaKey:i.ctrlKey)&&i.keyCode==86)||(i.shiftKey&&i.keyCode==45)){f(i)}})}else{c.onPaste.addToTop(function(h,i){return f(i)})}}e._legacySupport()},getInfo:function(){return{longname:"Paste text/word",author:"Moxiecode Systems AB",authorurl:"http://tinymce.moxiecode.com",infourl:"http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/paste",version:tinymce.majorVersion+"."+tinymce.minorVersion}},_preProcess:function(c,e){var b=e.content,d;function d(f){a(f,function(g){if(g.constructor==RegExp){b=b.replace(g,"")}else{b=b.replace(g[0],g[1])}})}d([/^\s*(&nbsp;)+/g,/(&nbsp;|<br[^>]*>)+\s*$/g]);if(/(class=\"?Mso|style=\"[^\"]*\bmso\-|w:WordDocument)/.test(b)){e.wordContent=true;d([/<!--[\s\S]+?-->/gi,/<\/?(img|font|meta|link|style|span|div|v:\w+)[^>]*>/gi,/<\\?\?xml[^>]*>/gi,/<\/?o:[^>]*>/gi,/ (id|name|class|language|type|on\w+|v:\w+)=\"([^\"]*)\"/gi,/ (id|name|class|language|type|on\w+|v:\w+)=(\w+)/gi,[/<(\/?)s>/gi,"<$1strike>"],/<script[^>]+>[\s\S]*?<\/script>/gi,[/&nbsp;/g,"\u00a0"]])}e.content=b},_postProcess:function(c,e){var b=this,d=b.editor.dom;if(e.wordContent){a(d.select("a",e.node),function(f){if(!f.href||f.href.indexOf("#_Toc")!=-1){d.remove(f,1)}});if(b.editor.getParam("paste_convert_middot_lists",true)){b._convertLists(c,e)}a(d.select("*",e.node),function(f){d.setAttrib(f,"style","")})}if(tinymce.isWebKit){a(d.select("*",e.node),function(f){f.removeAttribute("mce_style")})}},_convertLists:function(e,c){var g=e.editor.dom,f,i,b=-1,d,j=[],h;a(g.select("p",c.node),function(q){var m,r="",o,n,k,l;for(m=q.firstChild;m&&m.nodeType==3;m=m.nextSibling){r+=m.nodeValue}if(/^[\u2022\u00b7\u00a7\u00d8o]\s*\u00a0\u00a0*/.test(r)){o="ul"}if(/^[\s\S]*\w+\.[\s\S]*\u00a0{2,}/.test(r)){o="ol"}if(o){d=parseFloat(q.style.marginLeft||0);if(d>b){j.push(d)}if(!f||o!=h){f=g.create(o);g.insertAfter(f,q)}else{if(d>b){f=i.appendChild(g.create(o))}else{if(d<b){k=tinymce.inArray(j,d);l=g.getParents(f.parentNode,o);f=l[l.length-1-k]||f}}}if(o=="ul"){n=q.innerHTML.replace(/^[\u2022\u00b7\u00a7\u00d8o]\s*(&nbsp;|\u00a0)+\s*/,"")}else{n=q.innerHTML.replace(/^[\s\S]*\w+\.(&nbsp;|\u00a0)+\s*/,"")}i=f.appendChild(g.create("li",0,n));g.remove(q);b=d;h=o}else{f=b=0}})},_insertBlockContent:function(h,e,i){var c,g,d=h.selection,m,j,b,k,f;function l(p){var o;if(tinymce.isIE){o=h.getDoc().body.createTextRange();o.moveToElementText(p);o.collapse(false);o.select()}else{d.select(p,1);d.collapse(false)}}this._insert('<span id="_marker">&nbsp;</span>',1);g=e.get("_marker");c=e.getParent(g,"p,h1,h2,h3,h4,h5,h6,ul,ol");if(c){g=e.split(c,g);a(e.create("div",0,i).childNodes,function(o){m=g.parentNode.insertBefore(o.cloneNode(true),g)});l(m)}else{e.setOuterHTML(g,i);d.select(h.getBody(),1);d.collapse(0)}e.remove("_marker");j=d.getStart();b=e.getViewPort(h.getWin());k=h.dom.getPos(j).y;f=j.clientHeight;if(k<b.y||k+f>b.y+b.h){h.getDoc().body.scrollTop=k<b.y?k:k-b.h+25}},_insert:function(d,b){var c=this.editor;c.execCommand("Delete");c.execCommand(tinymce.isGecko?"insertHTML":"mceInsertContent",false,d,{skip_undo:b})},_legacySupport:function(){var c=this,b=c.editor;a(["mcePasteText","mcePasteWord"],function(d){b.addCommand(d,function(){b.windowManager.open({file:c.url+(d=="mcePasteText"?"/pastetext.htm":"/pasteword.htm"),width:450,height:400,inline:1})})});b.addButton("pastetext",{title:"paste.paste_text_desc",cmd:"mcePasteText"});b.addButton("pasteword",{title:"paste.paste_word_desc",cmd:"mcePasteWord"});b.addButton("selectall",{title:"paste.selectall_desc",cmd:"selectall"})}});tinymce.PluginManager.add("paste",tinymce.plugins.PastePlugin)})(); \ No newline at end of file
+(function(){var a=tinymce.each;tinymce.create("tinymce.plugins.PastePlugin",{init:function(c,d){var e=this,b;e.editor=c;e.url=d;e.onPreProcess=new tinymce.util.Dispatcher(e);e.onPostProcess=new tinymce.util.Dispatcher(e);e.onPreProcess.add(e._preProcess);e.onPostProcess.add(e._postProcess);e.onPreProcess.add(function(h,i){c.execCallback("paste_preprocess",h,i)});e.onPostProcess.add(function(h,i){c.execCallback("paste_postprocess",h,i)});function g(i){var h=c.dom;e.onPreProcess.dispatch(e,i);i.node=h.create("div",0,i.content);e.onPostProcess.dispatch(e,i);i.content=c.serializer.serialize(i.node,{getInner:1});if(/<(p|h[1-6]|ul|ol)/.test(i.content)){e._insertBlockContent(c,h,i.content)}else{e._insert(i.content)}}c.addCommand("mceInsertClipboardContent",function(h,i){g(i)});function f(l){var p,k,i,j=c.selection,o=c.dom,h=c.getBody(),m;if(o.get("_mcePaste")){return}p=o.add(h,"div",{id:"_mcePaste"},"\uFEFF");if(h!=c.getDoc().body){m=o.getPos(c.selection.getStart(),h).y}else{m=h.scrollTop}o.setStyles(p,{position:"absolute",left:-10000,top:m,width:1,height:1,overflow:"hidden"});if(tinymce.isIE){i=o.doc.body.createTextRange();i.moveToElementText(p);i.execCommand("Paste");o.remove(p);if(p.innerHTML==="\uFEFF"){c.execCommand("mcePasteWord");l.preventDefault();return}g({content:p.innerHTML});return tinymce.dom.Event.cancel(l)}else{k=c.selection.getRng();p=p.firstChild;i=c.getDoc().createRange();i.setStart(p,0);i.setEnd(p,1);j.setRng(i);window.setTimeout(function(){var q="",n=o.select("div[id=_mcePaste]");a(n,function(r){q+=(o.select("> span.Apple-style-span div",r)[0]||o.select("> span.Apple-style-span",r)[0]||r).innerHTML});a(n,function(r){o.remove(r)});if(k){j.setRng(k)}g({content:q})},0)}}if(c.getParam("paste_auto_cleanup_on_paste",true)){if(tinymce.isOpera||/Firefox\/2/.test(navigator.userAgent)){c.onKeyDown.add(function(h,i){if(((tinymce.isMac?i.metaKey:i.ctrlKey)&&i.keyCode==86)||(i.shiftKey&&i.keyCode==45)){f(i)}})}else{c.onPaste.addToTop(function(h,i){return f(i)})}}if(c.getParam("paste_block_drop")){c.onInit.add(function(){c.dom.bind(c.getBody(),["dragend","dragover","draggesture","dragdrop","drop","drag"],function(h){h.preventDefault();h.stopPropagation();return false})})}e._legacySupport()},getInfo:function(){return{longname:"Paste text/word",author:"Moxiecode Systems AB",authorurl:"http://tinymce.moxiecode.com",infourl:"http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/paste",version:tinymce.majorVersion+"."+tinymce.minorVersion}},_preProcess:function(d,i){var b=this.editor,c=i.content,g,f;function g(h){a(h,function(j){if(j.constructor==RegExp){c=c.replace(j,"")}else{c=c.replace(j[0],j[1])}})}if(/(class=\"?Mso|style=\"[^\"]*\bmso\-|w:WordDocument)/.test(c)||i.wordContent){i.wordContent=true;g([/^\s*(&nbsp;)+/g,/(&nbsp;|<br[^>]*>)+\s*$/g]);if(b.getParam("paste_convert_middot_lists",true)){g([[/<!--\[if !supportLists\]-->/gi,"$&__MCE_ITEM__"],[/(<span[^>]+:\s*symbol[^>]+>)/gi,"$1__MCE_ITEM__"],[/(<span[^>]+mso-list:[^>]+>)/gi,"$1__MCE_ITEM__"]])}g([/<!--[\s\S]+?-->/gi,/<\/?(img|font|meta|link|style|div|v:\w+)[^>]*>/gi,/<\\?\?xml[^>]*>/gi,/<\/?o:[^>]*>/gi,/ (id|name|language|type|on\w+|v:\w+)=\"([^\"]*)\"/gi,/ (id|name|language|type|on\w+|v:\w+)=(\w+)/gi,[/<(\/?)s>/gi,"<$1strike>"],/<script[^>]+>[\s\S]*?<\/script>/gi,[/&nbsp;/g,"\u00a0"]]);if(!b.getParam("paste_retain_style_properties")){g([/<\/?(span)[^>]*>/gi])}}f=b.getParam("paste_strip_class_attributes");if(f!="none"){function e(l,h){var k,j="";if(f=="all"){return""}h=tinymce.explode(h," ");for(k=h.length-1;k>=0;k--){if(!/^(Mso)/i.test(h[k])){j+=(!j?"":" ")+h[k]}}return' class="'+j+'"'}g([[/ class=\"([^\"]*)\"/gi,e],[/ class=(\w+)/gi,e]])}if(b.getParam("paste_remove_spans")){g([/<\/?(span)[^>]*>/gi])}i.content=c},_postProcess:function(e,g){var d=this,c=d.editor,f=c.dom,b;if(g.wordContent){a(f.select("a",g.node),function(h){if(!h.href||h.href.indexOf("#_Toc")!=-1){f.remove(h,1)}});if(d.editor.getParam("paste_convert_middot_lists",true)){d._convertLists(e,g)}b=c.getParam("paste_retain_style_properties");if(tinymce.is(b,"string")){b=tinymce.explode(b)}a(f.select("*",g.node),function(l){var m={},j=0,k,n,h;if(b){for(k=0;k<b.length;k++){n=b[k];h=f.getStyle(l,n);if(h){m[n]=h;j++}}}f.setAttrib(l,"style","");if(b&&j>0){f.setStyles(l,m)}else{if(l.nodeName=="SPAN"&&!l.className){f.remove(l,true)}}})}if(c.getParam("paste_remove_styles")||(c.getParam("paste_remove_styles_if_webkit")&&tinymce.isWebKit)){a(f.select("*[style]",g.node),function(h){h.removeAttribute("style");h.removeAttribute("mce_style")})}else{if(tinymce.isWebKit){a(f.select("*",g.node),function(h){h.removeAttribute("mce_style")})}}},_convertLists:function(e,c){var g=e.editor.dom,f,j,b=-1,d,k=[],i,h;a(g.select("p",c.node),function(r){var n,s="",q,o,l,m;for(n=r.firstChild;n&&n.nodeType==3;n=n.nextSibling){s+=n.nodeValue}s=r.innerHTML.replace(/<\/?\w+[^>]*>/gi,"").replace(/&nbsp;/g,"\u00a0");if(/^(__MCE_ITEM__)+[\u2022\u00b7\u00a7\u00d8o]\s*\u00a0*/.test(s)){q="ul"}if(/^__MCE_ITEM__\s*\w+\.\s*\u00a0{2,}/.test(s)){q="ol"}if(q){d=parseFloat(r.style.marginLeft||0);if(d>b){k.push(d)}if(!f||q!=i){f=g.create(q);g.insertAfter(f,r)}else{if(d>b){f=j.appendChild(g.create(q))}else{if(d<b){l=tinymce.inArray(k,d);m=g.getParents(f.parentNode,q);f=m[m.length-1-l]||f}}}a(g.select("span",r),function(t){var p=t.innerHTML.replace(/<\/?\w+[^>]*>/gi,"");if(q=="ul"&&/^[\u2022\u00b7\u00a7\u00d8o]/.test(p)){g.remove(t)}else{if(/^[\s\S]*\w+\.(&nbsp;|\u00a0)*\s*/.test(p)){g.remove(t)}}});o=r.innerHTML;if(q=="ul"){o=r.innerHTML.replace(/__MCE_ITEM__/g,"").replace(/^[\u2022\u00b7\u00a7\u00d8o]\s*(&nbsp;|\u00a0)+\s*/,"")}else{o=r.innerHTML.replace(/__MCE_ITEM__/g,"").replace(/^\s*\w+\.(&nbsp;|\u00a0)+\s*/,"")}j=f.appendChild(g.create("li",0,o));g.remove(r);b=d;i=q}else{f=b=0}});h=c.node.innerHTML;if(h.indexOf("__MCE_ITEM__")!=-1){c.node.innerHTML=h.replace(/__MCE_ITEM__/g,"")}},_insertBlockContent:function(h,e,i){var c,g,d=h.selection,m,j,b,k,f;function l(p){var o;if(tinymce.isIE){o=h.getDoc().body.createTextRange();o.moveToElementText(p);o.collapse(false);o.select()}else{d.select(p,1);d.collapse(false)}}this._insert('<span id="_marker">&nbsp;</span>',1);g=e.get("_marker");c=e.getParent(g,"p,h1,h2,h3,h4,h5,h6,ul,ol,th,td");if(c&&!/TD|TH/.test(c.nodeName)){g=e.split(c,g);a(e.create("div",0,i).childNodes,function(o){m=g.parentNode.insertBefore(o.cloneNode(true),g)});l(m)}else{e.setOuterHTML(g,i);d.select(h.getBody(),1);d.collapse(0)}e.remove("_marker");j=d.getStart();b=e.getViewPort(h.getWin());k=h.dom.getPos(j).y;f=j.clientHeight;if(k<b.y||k+f>b.y+b.h){h.getDoc().body.scrollTop=k<b.y?k:k-b.h+25}},_insert:function(d,b){var c=this.editor;if(!c.selection.isCollapsed()){c.getDoc().execCommand("Delete",false,null)}c.execCommand(tinymce.isGecko?"insertHTML":"mceInsertContent",false,d,{skip_undo:b})},_legacySupport:function(){var c=this,b=c.editor;a(["mcePasteText","mcePasteWord"],function(d){b.addCommand(d,function(){b.windowManager.open({file:c.url+(d=="mcePasteText"?"/pastetext.htm":"/pasteword.htm"),width:parseInt(b.getParam("paste_dialog_width","450")),height:parseInt(b.getParam("paste_dialog_height","400")),inline:1})})});b.addButton("pastetext",{title:"paste.paste_text_desc",cmd:"mcePasteText"});b.addButton("pasteword",{title:"paste.paste_word_desc",cmd:"mcePasteWord"});b.addButton("selectall",{title:"paste.selectall_desc",cmd:"selectall"})}});tinymce.PluginManager.add("paste",tinymce.plugins.PastePlugin)})(); \ No newline at end of file
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 14d86a957..8b6cae3d1 100644
--- a/program/js/tiny_mce/plugins/paste/editor_plugin_src.js
+++ b/program/js/tiny_mce/plugins/paste/editor_plugin_src.js
@@ -1,5 +1,5 @@
/**
- * $Id: editor_plugin_src.js 1104 2009-04-22 12:16:47Z spocke $
+ * $Id: editor_plugin_src.js 1225 2009-09-07 19:06:19Z spocke $
*
* @author Moxiecode
* @copyright Copyright © 2004-2008, Moxiecode Systems AB, All rights reserved.
@@ -34,8 +34,8 @@
});
// This function executes the process handlers and inserts the contents
- function process(h) {
- var dom = ed.dom, o = {content : h};
+ function process(o) {
+ var dom = ed.dom;
// Execute pre process handlers
t.onPreProcess.dispatch(t, o);
@@ -49,7 +49,7 @@
// Serialize content
o.content = ed.serializer.serialize(o.node, {getInner : 1});
- // Insert cleaned content. We need to handle insertion of contents containing block elements separatly
+ // Insert cleaned content. We need to handle insertion of contents containing block elements separately
if (/<(p|h[1-6]|ul|ol)/.test(o.content))
t._insertBlockContent(ed, dom, o.content);
else
@@ -57,8 +57,8 @@
};
// Add command for external usage
- ed.addCommand('mceInsertClipboardContent', function(u, v) {
- process(v);
+ ed.addCommand('mceInsertClipboardContent', function(u, o) {
+ process(o);
});
// This function grabs the contents from the clipboard by adding a
@@ -71,7 +71,7 @@
return;
// Create container to paste into
- n = dom.add(body, 'div', {id : '_mcePaste'}, '&nbsp;');
+ n = dom.add(body, 'div', {id : '_mcePaste'}, '\uFEFF');
// If contentEditable mode we need to find out the position of the closest element
if (body != ed.getDoc().body)
@@ -98,9 +98,18 @@
// Remove container
dom.remove(n);
+ // Check if the contents was changed, if it wasn't then clipboard extraction failed probably due
+ // to IE security settings so we pass the junk though better than nothing right
+ if (n.innerHTML === '\uFEFF') {
+ ed.execCommand('mcePasteWord');
+ e.preventDefault();
+ return;
+ }
+
// Process contents
- process(n.innerHTML);
+ process({content : n.innerHTML});
+ // Block the real paste event
return tinymce.dom.Event.cancel(e);
} else {
or = ed.selection.getRng();
@@ -114,26 +123,23 @@
// Wait a while and grab the pasted contents
window.setTimeout(function() {
- var n = dom.get('_mcePaste'), h;
-
- // Webkit clones the _mcePaste div for some odd reason so this will ensure that we get the real new div not the old empty one
- n.id = '_mceRemoved';
- dom.remove(n);
- n = dom.get('_mcePaste') || n;
+ var h = '', nl = dom.select('div[id=_mcePaste]');
- // Grab the HTML contents
- // We need to look for a apple style wrapper on webkit it also adds a div wrapper if you copy/paste the body of the editor
- // It's amazing how strange the contentEditable mode works in WebKit
- h = (dom.select('> span.Apple-style-span div', n)[0] || dom.select('> span.Apple-style-span', n)[0] || n).innerHTML;
+ // WebKit will split the div into multiple ones so this will loop through then all and join them to get the whole HTML string
+ each(nl, function(n) {
+ h += (dom.select('> span.Apple-style-span div', n)[0] || dom.select('> span.Apple-style-span', n)[0] || n).innerHTML;
+ });
- // Remove hidden div and restore selection
- dom.remove(n);
+ // Remove the nodes
+ each(nl, function(n) {
+ dom.remove(n);
+ });
// Restore the old selection
if (or)
sel.setRng(or);
- process(h);
+ process({content : h});
}, 0);
}
};
@@ -154,6 +160,18 @@
}
}
+ // Block all drag/drop events
+ if (ed.getParam('paste_block_drop')) {
+ ed.onInit.add(function() {
+ ed.dom.bind(ed.getBody(), ['dragend', 'dragover', 'draggesture', 'dragdrop', 'drop', 'drag'], function(e) {
+ e.preventDefault();
+ e.stopPropagation();
+
+ return false;
+ });
+ });
+ }
+
// Add legacy support
t._legacySupport();
},
@@ -169,7 +187,7 @@
},
_preProcess : function(pl, o) {
- var h = o.content, process;
+ var ed = this.editor, h = o.content, process, stripClass;
//console.log('Before preprocess:' + o.content);
@@ -183,28 +201,79 @@
});
};
- // Process away some basic content
- process([
- /^\s*(&nbsp;)+/g, // nbsp entities at the start of contents
- /(&nbsp;|<br[^>]*>)+\s*$/g // nbsp entities at the end of contents
- ]);
-
- // Detect Word content and process it more agressive
- if (/(class=\"?Mso|style=\"[^\"]*\bmso\-|w:WordDocument)/.test(h)) {
+ // Detect Word content and process it more aggressive
+ if (/(class=\"?Mso|style=\"[^\"]*\bmso\-|w:WordDocument)/.test(h) || o.wordContent) {
o.wordContent = true; // Mark the pasted contents as word specific content
//console.log('Word contents detected.');
+ // Process away some basic content
+ process([
+ /^\s*(&nbsp;)+/g, // nbsp entities at the start of contents
+ /(&nbsp;|<br[^>]*>)+\s*$/g // nbsp entities at the end of contents
+ ]);
+
+ if (ed.getParam('paste_convert_middot_lists', true)) {
+ process([
+ [/<!--\[if !supportLists\]-->/gi, '$&__MCE_ITEM__'], // Convert supportLists to a list item marker
+ [/(<span[^>]+:\s*symbol[^>]+>)/gi, '$1__MCE_ITEM__'], // Convert symbol spans to list items
+ [/(<span[^>]+mso-list:[^>]+>)/gi, '$1__MCE_ITEM__'] // Convert mso-list to item marker
+ ]);
+ }
+
process([
/<!--[\s\S]+?-->/gi, // Word comments
- /<\/?(img|font|meta|link|style|span|div|v:\w+)[^>]*>/gi, // Remove some tags including VML content
+ /<\/?(img|font|meta|link|style|div|v:\w+)[^>]*>/gi, // Remove some tags including VML content
/<\\?\?xml[^>]*>/gi, // XML namespace declarations
/<\/?o:[^>]*>/gi, // MS namespaced elements <o:tag>
- / (id|name|class|language|type|on\w+|v:\w+)=\"([^\"]*)\"/gi, // on.., class, style and language attributes with quotes
- / (id|name|class|language|type|on\w+|v:\w+)=(\w+)/gi, // on.., class, style and language attributes without quotes (IE)
+ / (id|name|language|type|on\w+|v:\w+)=\"([^\"]*)\"/gi, // on.., class, style and language attributes with quotes
+ / (id|name|language|type|on\w+|v:\w+)=(\w+)/gi, // on.., class, style and language attributes without quotes (IE)
[/<(\/?)s>/gi, '<$1strike>'], // Convert <s> into <strike> for line-though
/<script[^>]+>[\s\S]*?<\/script>/gi, // All scripts elements for msoShowComment for example
[/&nbsp;/g, '\u00a0'] // Replace nsbp entites to char since it's easier to handle
]);
+
+ // Remove all spans if no styles is to be retained
+ if (!ed.getParam('paste_retain_style_properties')) {
+ process([
+ /<\/?(span)[^>]*>/gi
+ ]);
+ }
+ }
+
+ // Allow for class names to be retained if desired; either all, or just the ones from Word
+ // Note that the paste_strip_class_attributes: 'none, verify_css_classes: true is also a good variation.
+ stripClass = ed.getParam('paste_strip_class_attributes');
+ if (stripClass != 'none') {
+ // Cleans everything but mceItem... classes
+ function cleanClasses(str, cls) {
+ var i, out = '';
+
+ // Remove all classes
+ if (stripClass == 'all')
+ return '';
+
+ cls = tinymce.explode(cls, ' ');
+
+ for (i = cls.length - 1; i >= 0; i--) {
+ // Remove Mso classes
+ if (!/^(Mso)/i.test(cls[i]))
+ out += (!out ? '' : ' ') + cls[i];
+ }
+
+ return ' class="' + out + '"';
+ };
+
+ process([
+ [/ class=\"([^\"]*)\"/gi, cleanClasses], // class attributes with quotes
+ [/ class=(\w+)/gi, cleanClasses] // class attributes without quotes (IE)
+ ]);
+ }
+
+ // Remove spans option
+ if (ed.getParam('paste_remove_spans')) {
+ process([
+ /<\/?(span)[^>]*>/gi
+ ]);
}
//console.log('After preprocess:' + h);
@@ -216,7 +285,7 @@
* Various post process items.
*/
_postProcess : function(pl, o) {
- var t = this, dom = t.editor.dom;
+ var t = this, ed = t.editor, dom = ed.dom, styleProps;
if (o.wordContent) {
// Remove named anchors or TOC links
@@ -228,18 +297,55 @@
if (t.editor.getParam('paste_convert_middot_lists', true))
t._convertLists(pl, o);
- // Remove all styles
+ // Process styles
+ styleProps = ed.getParam('paste_retain_style_properties'); // retained properties
+
+ // If string property then split it
+ if (tinymce.is(styleProps, 'string'))
+ styleProps = tinymce.explode(styleProps);
+
+ // Retains some style properties
each(dom.select('*', o.node), function(el) {
+ var newStyle = {}, npc = 0, i, sp, sv;
+
+ // Store a subset of the existing styles
+ if (styleProps) {
+ for (i = 0; i < styleProps.length; i++) {
+ sp = styleProps[i];
+ sv = dom.getStyle(el, sp);
+
+ if (sv) {
+ newStyle[sp] = sv;
+ npc++;
+ }
+ }
+ }
+
+ // Remove all of the existing styles
dom.setAttrib(el, 'style', '');
+
+ if (styleProps && npc > 0)
+ dom.setStyles(el, newStyle); // Add back the stored subset of styles
+ else // Remove empty span tags that do not have class attributes
+ if (el.nodeName == 'SPAN' && !el.className)
+ dom.remove(el, true);
});
}
- if (tinymce.isWebKit) {
- // We need to compress the styles on WebKit since if you paste <img border="0" /> it will become <img border="0" style="... lots of junk ..." />
- // Removing the mce_style that contains the real value will force the Serializer engine to compress the styles
- each(dom.select('*', o.node), function(el) {
+ // Remove all style information or only specifically on WebKit to avoid the style bug on that browser
+ if (ed.getParam("paste_remove_styles") || (ed.getParam("paste_remove_styles_if_webkit") && tinymce.isWebKit)) {
+ each(dom.select('*[style]', o.node), function(el) {
+ el.removeAttribute('style');
el.removeAttribute('mce_style');
});
+ } else {
+ if (tinymce.isWebKit) {
+ // We need to compress the styles on WebKit since if you paste <img border="0" /> it will become <img border="0" style="... lots of junk ..." />
+ // Removing the mce_style that contains the real value will force the Serializer engine to compress the styles
+ each(dom.select('*', o.node), function(el) {
+ el.removeAttribute('mce_style');
+ });
+ }
}
},
@@ -247,9 +353,9 @@
* Converts the most common bullet and number formats in Office into a real semantic UL/LI list.
*/
_convertLists : function(pl, o) {
- var dom = pl.editor.dom, listElm, li, lastMargin = -1, margin, levels = [], lastType;
+ var dom = pl.editor.dom, listElm, li, lastMargin = -1, margin, levels = [], lastType, html;
- // Convert middot lists into real scemantic lists
+ // Convert middot lists into real semantic lists
each(dom.select('p', o.node), function(p) {
var sib, val = '', type, html, idx, parents;
@@ -257,12 +363,14 @@
for (sib = p.firstChild; sib && sib.nodeType == 3; sib = sib.nextSibling)
val += sib.nodeValue;
+ val = p.innerHTML.replace(/<\/?\w+[^>]*>/gi, '').replace(/&nbsp;/g, '\u00a0');
+
// Detect unordered lists look for bullets
- if (/^[\u2022\u00b7\u00a7\u00d8o]\s*\u00a0\u00a0*/.test(val))
+ if (/^(__MCE_ITEM__)+[\u2022\u00b7\u00a7\u00d8o]\s*\u00a0*/.test(val))
type = 'ul';
// Detect ordered lists 1., a. or ixv.
- if (/^[\s\S]*\w+\.[\s\S]*\u00a0{2,}/.test(val))
+ if (/^__MCE_ITEM__\s*\w+\.\s*\u00a0{2,}/.test(val))
type = 'ol';
// Check if node value matches the list pattern: o&nbsp;&nbsp;
@@ -287,11 +395,26 @@
}
}
+ // Remove middot or number spans if they exists
+ each(dom.select('span', p), function(span) {
+ var html = span.innerHTML.replace(/<\/?\w+[^>]*>/gi, '');
+
+ // Remove span with the middot or the number
+ if (type == 'ul' && /^[\u2022\u00b7\u00a7\u00d8o]/.test(html))
+ dom.remove(span);
+ else if (/^[\s\S]*\w+\.(&nbsp;|\u00a0)*\s*/.test(html))
+ dom.remove(span);
+ });
+
+ html = p.innerHTML;
+
+ // Remove middot/list items
if (type == 'ul')
- html = p.innerHTML.replace(/^[\u2022\u00b7\u00a7\u00d8o]\s*(&nbsp;|\u00a0)+\s*/, '');
+ html = p.innerHTML.replace(/__MCE_ITEM__/g, '').replace(/^[\u2022\u00b7\u00a7\u00d8o]\s*(&nbsp;|\u00a0)+\s*/, '');
else
- html = p.innerHTML.replace(/^[\s\S]*\w+\.(&nbsp;|\u00a0)+\s*/, '');
+ html = p.innerHTML.replace(/__MCE_ITEM__/g, '').replace(/^\s*\w+\.(&nbsp;|\u00a0)+\s*/, '');
+ // Create li and add paragraph data into the new li
li = listElm.appendChild(dom.create('li', 0, html));
dom.remove(p);
@@ -300,6 +423,11 @@
} else
listElm = lastMargin = 0; // End list element
});
+
+ // Remove any left over makers
+ html = o.node.innerHTML;
+ if (html.indexOf('__MCE_ITEM__') != -1)
+ o.node.innerHTML = html.replace(/__MCE_ITEM__/g, '');
},
/**
@@ -326,9 +454,10 @@
// Insert a marker for the caret position
this._insert('<span id="_marker">&nbsp;</span>', 1);
marker = dom.get('_marker');
- parentBlock = dom.getParent(marker, 'p,h1,h2,h3,h4,h5,h6,ul,ol');
+ parentBlock = dom.getParent(marker, 'p,h1,h2,h3,h4,h5,h6,ul,ol,th,td');
- if (parentBlock) {
+ // If it's a parent block but not a table cell
+ if (parentBlock && !/TD|TH/.test(parentBlock.nodeName)) {
// Split parent block
marker = dom.split(parentBlock, marker);
@@ -365,7 +494,8 @@
var ed = this.editor;
// First delete the contents seems to work better on WebKit
- ed.execCommand('Delete');
+ if (!ed.selection.isCollapsed())
+ 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
ed.execCommand(tinymce.isGecko ? 'insertHTML' : 'mceInsertContent', false, h, {skip_undo : skip_undo});
@@ -382,8 +512,8 @@
ed.addCommand(cmd, function() {
ed.windowManager.open({
file : t.url + (cmd == 'mcePasteText' ? '/pastetext.htm' : '/pasteword.htm'),
- width : 450,
- height : 400,
+ width : parseInt(ed.getParam("paste_dialog_width", "450")),
+ height : parseInt(ed.getParam("paste_dialog_height", "400")),
inline : 1
});
});
diff --git a/program/js/tiny_mce/plugins/paste/js/pastetext.js b/program/js/tiny_mce/plugins/paste/js/pastetext.js
index 303439b33..c524f9eb0 100644
--- a/program/js/tiny_mce/plugins/paste/js/pastetext.js
+++ b/program/js/tiny_mce/plugins/paste/js/pastetext.js
@@ -19,7 +19,7 @@ var PasteTextDialog = {
}
}
- tinyMCEPopup.editor.execCommand('mceInsertClipboardContent', false, h);
+ tinyMCEPopup.editor.execCommand('mceInsertClipboardContent', false, {content : h});
tinyMCEPopup.close();
},
diff --git a/program/js/tiny_mce/plugins/paste/js/pasteword.js b/program/js/tiny_mce/plugins/paste/js/pasteword.js
index fe053a721..a52731c36 100644
--- a/program/js/tiny_mce/plugins/paste/js/pasteword.js
+++ b/program/js/tiny_mce/plugins/paste/js/pasteword.js
@@ -13,12 +13,12 @@ var PasteWordDialog = {
css = [ed.baseURI.toAbsolute("themes/" + ed.settings.theme + "/skins/" + ed.settings.skin + "/content.css")];
css = css.concat(tinymce.explode(ed.settings.content_css) || []);
tinymce.each(css, function(u) {
- cssHTML += '<link href="' + ed.documentBaseURI.toAbsolute(u) + '" rel="stylesheet" type="text/css" />';
+ cssHTML += '<link href="' + ed.documentBaseURI.toAbsolute('' + u) + '" rel="stylesheet" type="text/css" />';
});
// Write content into iframe
doc.open();
- doc.write('<html><head>' + cssHTML + '</head><body spellcheck="false"></body></html>');
+ doc.write('<html><head>' + cssHTML + '</head><body class="mceContentBody" spellcheck="false"></body></html>');
doc.close();
doc.designMode = 'on';
@@ -32,7 +32,7 @@ var PasteWordDialog = {
insert : function() {
var h = document.getElementById('iframe').contentWindow.document.body.innerHTML;
- tinyMCEPopup.editor.execCommand('mceInsertClipboardContent', false, h);
+ tinyMCEPopup.editor.execCommand('mceInsertClipboardContent', false, {content : h, wordContent : true});
tinyMCEPopup.close();
},