diff options
Diffstat (limited to 'program/js/tiny_mce/plugins/paste')
-rw-r--r-- | program/js/tiny_mce/plugins/paste/editor_plugin.js | 2 | ||||
-rw-r--r-- | program/js/tiny_mce/plugins/paste/editor_plugin_src.js | 638 | ||||
-rw-r--r-- | program/js/tiny_mce/plugins/paste/js/pastetext.js | 62 | ||||
-rw-r--r-- | program/js/tiny_mce/plugins/paste/js/pasteword.js | 91 | ||||
-rw-r--r-- | program/js/tiny_mce/plugins/paste/pastetext.htm | 35 | ||||
-rw-r--r-- | program/js/tiny_mce/plugins/paste/pasteword.htm | 8 |
6 files changed, 417 insertions, 419 deletions
diff --git a/program/js/tiny_mce/plugins/paste/editor_plugin.js b/program/js/tiny_mce/plugins/paste/editor_plugin.js index 4a35002b4..93848bf78 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 Event=tinymce.dom.Event;tinymce.create('tinymce.plugins.PastePlugin',{init:function(ed,url){var t=this;t.editor=ed;ed.addCommand('mcePasteText',function(ui,v){if(ui){if((ed.getParam('paste_use_dialog',true))||(!tinymce.isIE)){ed.windowManager.open({file:url+'/pastetext.htm',width:450,height:400,inline:1},{plugin_url:url});}else t._insertText(clipboardData.getData("Text"),true);}else t._insertText(v.html,v.linebreaks);});ed.addCommand('mcePasteWord',function(ui,v){if(ui){if((ed.getParam('paste_use_dialog',true))||(!tinymce.isIE)){ed.windowManager.open({file:url+'/pasteword.htm',width:450,height:400,inline:1},{plugin_url:url});}else t._insertText(t._clipboardHTML());}else t._insertWordContent(v);});ed.addCommand('mceSelectAll',function(){ed.execCommand('selectall');});ed.addButton('pastetext',{title:'paste.paste_text_desc',cmd:'mcePasteText',ui:true});ed.addButton('pasteword',{title:'paste.paste_word_desc',cmd:'mcePasteWord',ui:true});ed.addButton('selectall',{title:'paste.selectall_desc',cmd:'mceSelectAll'});if(ed.getParam("paste_auto_cleanup_on_paste",false)){ed.onPaste.add(function(ed,e){return t._handlePasteEvent(e)});}if(!tinymce.isIE&&ed.getParam("paste_auto_cleanup_on_paste",false)){ed.onKeyDown.add(function(ed,e){if(e.ctrlKey&&e.keyCode==86){window.setTimeout(function(){ed.execCommand("mcePasteText",true);},1);Event.cancel(e);}});}},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};},_handlePasteEvent:function(e){var html=this._clipboardHTML(),ed=this.editor,sel=ed.selection,r;if(ed&&(r=sel.getRng())&&r.text.length>0)ed.execCommand('delete');if(html&&html.length>0)ed.execCommand('mcePasteWord',false,html);return Event.cancel(e);},_insertText:function(content,bLinebreaks){content=this.editor.dom.encode(content);if(content&&content.length>0){if(bLinebreaks){if(this.editor.getParam("paste_create_paragraphs",true)){var rl=this.editor.getParam("paste_replace_list",'\u2122,<sup>TM</sup>,\u2026,...,\u201c|\u201d,",\u2019,\',\u2013|\u2014|\u2015|\u2212,-').split(',');for(var i=0;i<rl.length;i+=2)content=content.replace(new RegExp(rl[i],'gi'),rl[i+1]);content=content.replace(/\r\n\r\n/g,'</p><p>');content=content.replace(/\r\r/g,'</p><p>');content=content.replace(/\n\n/g,'</p><p>');if((pos=content.indexOf('</p><p>'))!=-1){this.editor.execCommand("Delete");var node=this.editor.selection.getNode();var breakElms=[];do{if(node.nodeType==1){if(node.nodeName=="TD"||node.nodeName=="BODY")break;breakElms[breakElms.length]=node;}}while(node=node.parentNode);var before="",after="</p>";before+=content.substring(0,pos);for(var i=0;i<breakElms.length;i++){before+="</"+breakElms[i].nodeName+">";after+="<"+breakElms[(breakElms.length-1)-i].nodeName+">";}before+="<p>";content=before+content.substring(pos+7)+after;}}if(this.editor.getParam("paste_create_linebreaks",true)){content=content.replace(/\r\n/g,'<br />');content=content.replace(/\r/g,'<br />');content=content.replace(/\n/g,'<br />');}}this.editor.execCommand("mceInsertRawHTML",false,content);}},_insertWordContent:function(content){var t=this,ed=t.editor;if(content&&content.length>0){var bull=String.fromCharCode(8226);var middot=String.fromCharCode(183);if(ed.getParam('paste_insert_word_content_callback'))content=ed.execCallback('paste_insert_word_content_callback','before',content);var rl=ed.getParam("paste_replace_list",'\u2122,<sup>TM</sup>,\u2026,...,\u201c|\u201d,",\u2019,\',\u2013|\u2014|\u2015|\u2212,-').split(',');for(var i=0;i<rl.length;i+=2)content=content.replace(new RegExp(rl[i],'gi'),rl[i+1]);if(this.editor.getParam("paste_convert_headers_to_strong",false)){content=content.replace(new RegExp('<p class=MsoHeading.*?>(.*?)<\/p>','gi'),'<p><b>$1</b></p>');}content=content.replace(new RegExp('tab-stops: list [0-9]+.0pt">','gi'),'">'+"--list--");content=content.replace(new RegExp(bull+"(.*?)<BR>","gi"),"<p>"+middot+"$1</p>");content=content.replace(new RegExp('<SPAN style="mso-list: Ignore">','gi'),"<span>"+bull);content=content.replace(/<o:p><\/o:p>/gi,"");content=content.replace(new RegExp('<br style="page-break-before: always;.*>','gi'),'-- page break --');content=content.replace(new RegExp('<(!--)([^>]*)(--)>','g'),"");if(this.editor.getParam("paste_remove_spans",true))content=content.replace(/<\/?span[^>]*>/gi,"");if(this.editor.getParam("paste_remove_styles",true))content=content.replace(new RegExp('<(\\w[^>]*) style="([^"]*)"([^>]*)','gi'),"<$1$3");content=content.replace(/<\/?font[^>]*>/gi,"");switch(this.editor.getParam("paste_strip_class_attributes","all")){case"all":content=content.replace(/<(\w[^>]*) class=([^ |>]*)([^>]*)/gi,"<$1$3");break;case"mso":content=content.replace(new RegExp('<(\\w[^>]*) class="?mso([^ |>]*)([^>]*)','gi'),"<$1$3");break;}content=content.replace(new RegExp('href="?'+this._reEscape(""+document.location)+'','gi'),'href="'+this.editor.documentBaseURI.getURI());content=content.replace(/<(\w[^>]*) lang=([^ |>]*)([^>]*)/gi,"<$1$3");content=content.replace(/<\\?\?xml[^>]*>/gi,"");content=content.replace(/<\/?\w+:[^>]*>/gi,"");content=content.replace(/-- page break --\s*<p> <\/p>/gi,"");content=content.replace(/-- page break --/gi,"");if(!this.editor.getParam('force_p_newlines')){content=content.replace('','','gi');content=content.replace('</p>','<br /><br />','gi');}if(!tinymce.isIE&&!this.editor.getParam('force_p_newlines')){content=content.replace(/<\/?p[^>]*>/gi,"");}content=content.replace(/<\/?div[^>]*>/gi,"");if(this.editor.getParam("paste_convert_middot_lists",true)){var div=ed.dom.create("div",null,content);var className=this.editor.getParam("paste_unindented_list_class","unIndentedList");while(this._convertMiddots(div,"--list--"));while(this._convertMiddots(div,middot,className));while(this._convertMiddots(div,bull));content=div.innerHTML;}if(this.editor.getParam("paste_convert_headers_to_strong",false)){content=content.replace(/<h[1-6]> <\/h[1-6]>/gi,'<p> </p>');content=content.replace(/<h[1-6]>/gi,'<p><b>');content=content.replace(/<\/h[1-6]>/gi,'</b></p>');content=content.replace(/<b> <\/b>/gi,'<b> </b>');content=content.replace(/^( )*/gi,'');}content=content.replace(/--list--/gi,"");if(ed.getParam('paste_insert_word_content_callback'))content=ed.execCallback('paste_insert_word_content_callback','after',content);this.editor.execCommand("mceInsertContent",false,content);if(this.editor.getParam('paste_force_cleanup_wordpaste',true)){var ed=this.editor;window.setTimeout(function(){ed.execCommand("mceCleanup");},1);}}},_reEscape:function(s){var l="?.\\*[](){}+^$:";var o="";for(var i=0;i<s.length;i++){var c=s.charAt(i);if(l.indexOf(c)!=-1)o+='\\'+c;else o+=c;}return o;},_convertMiddots:function(div,search,class_name){var ed=this.editor,mdot=String.fromCharCode(183),bull=String.fromCharCode(8226);var nodes,prevul,i,p,ul,li,np,cp,li;nodes=div.getElementsByTagName("p");for(i=0;i<nodes.length;i++){p=nodes[i];if(p.innerHTML.indexOf(search)==0){ul=ed.dom.create("ul");if(class_name)ul.className=class_name;li=ed.dom.create("li");li.innerHTML=p.innerHTML.replace(new RegExp(''+mdot+'|'+bull+'|--list--| ',"gi"),'');ul.appendChild(li);np=p.nextSibling;while(np){if(np.nodeType==3&&new RegExp('^\\s$','m').test(np.nodeValue)){np=np.nextSibling;continue;}if(search==mdot){if(np.nodeType==1&&new RegExp('^o(\\s+| )').test(np.innerHTML)){if(!prevul){prevul=ul;ul=ed.dom.create("ul");prevul.appendChild(ul);}np.innerHTML=np.innerHTML.replace(/^o/,'');}else{if(prevul){ul=prevul;prevul=null;}if(np.nodeType!=1||np.innerHTML.indexOf(search)!=0)break;}}else{if(np.nodeType!=1||np.innerHTML.indexOf(search)!=0)break;}cp=np.nextSibling;li=ed.dom.create("li");li.innerHTML=np.innerHTML.replace(new RegExp(''+mdot+'|'+bull+'|--list--| ',"gi"),'');np.parentNode.removeChild(np);ul.appendChild(li);np=cp;}p.parentNode.replaceChild(ul,p);return true;}}return false;},_clipboardHTML:function(){var div=document.getElementById('_TinyMCE_clipboardHTML');if(!div){var div=document.createElement('DIV');div.id='_TinyMCE_clipboardHTML';with(div.style){visibility='hidden';overflow='hidden';position='absolute';width=1;height=1;}document.body.appendChild(div);}div.innerHTML='';var rng=document.body.createTextRange();rng.moveToElementText(div);rng.execCommand('Paste');var html=div.innerHTML;div.innerHTML='';return html;}});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 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"}," ");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*( )+/g,/( |<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,[/ /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*( |\u00a0)+\s*/,"")}else{n=q.innerHTML.replace(/^[\s\S]*\w+\.( |\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"> </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 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 f271758f9..14d86a957 100644 --- a/program/js/tiny_mce/plugins/paste/editor_plugin_src.js +++ b/program/js/tiny_mce/plugins/paste/editor_plugin_src.js @@ -1,386 +1,398 @@ /**
- * $Id: editor_plugin_src.js 862 2008-06-02 20:09:06Z spocke $
+ * $Id: editor_plugin_src.js 1104 2009-04-22 12:16:47Z spocke $
*
* @author Moxiecode
* @copyright Copyright © 2004-2008, Moxiecode Systems AB, All rights reserved.
*/
(function() {
- var Event = tinymce.dom.Event;
+ var each = tinymce.each;
tinymce.create('tinymce.plugins.PastePlugin', {
init : function(ed, url) {
- var t = this;
-
- t.editor = ed;
-
- // Register commands
- ed.addCommand('mcePasteText', function(ui, v) {
- if (ui) {
- if ((ed.getParam('paste_use_dialog', true)) || (!tinymce.isIE)) {
- ed.windowManager.open({
- file : url + '/pastetext.htm',
- width : 450,
- height : 400,
- inline : 1
- }, {
- plugin_url : url
- });
- } else
- t._insertText(clipboardData.getData("Text"), true);
- } else
- t._insertText(v.html, v.linebreaks);
- });
+ var t = this, cb;
- ed.addCommand('mcePasteWord', function(ui, v) {
- if (ui) {
- if ((ed.getParam('paste_use_dialog', true)) || (!tinymce.isIE)) {
- ed.windowManager.open({
- file : url + '/pasteword.htm',
- width : 450,
- height : 400,
- inline : 1
- }, {
- plugin_url : url
- });
- } else
- t._insertText(t._clipboardHTML());
- } else
- t._insertWordContent(v);
- });
+ t.editor = ed;
+ t.url = url;
- ed.addCommand('mceSelectAll', function() {
- ed.execCommand('selectall');
- });
+ // Setup plugin events
+ t.onPreProcess = new tinymce.util.Dispatcher(t);
+ t.onPostProcess = new tinymce.util.Dispatcher(t);
- // Register buttons
- ed.addButton('pastetext', {title : 'paste.paste_text_desc', cmd : 'mcePasteText', ui : true});
- ed.addButton('pasteword', {title : 'paste.paste_word_desc', cmd : 'mcePasteWord', ui : true});
- ed.addButton('selectall', {title : 'paste.selectall_desc', cmd : 'mceSelectAll'});
+ // Register default handlers
+ t.onPreProcess.add(t._preProcess);
+ t.onPostProcess.add(t._postProcess);
- if (ed.getParam("paste_auto_cleanup_on_paste", false)) {
- ed.onPaste.add(function(ed, e) {
- return t._handlePasteEvent(e)
- });
- }
-
- if (!tinymce.isIE && ed.getParam("paste_auto_cleanup_on_paste", false)) {
- // Force paste dialog if non IE browser
- ed.onKeyDown.add(function(ed, e) {
- if (e.ctrlKey && e.keyCode == 86) {
- window.setTimeout(function() {
- ed.execCommand("mcePasteText", true);
- }, 1);
+ // Register optional preprocess handler
+ t.onPreProcess.add(function(pl, o) {
+ ed.execCallback('paste_preprocess', pl, o);
+ });
- Event.cancel(e);
- }
- });
- }
- },
+ // Register optional postprocess
+ t.onPostProcess.add(function(pl, o) {
+ ed.execCallback('paste_postprocess', pl, o);
+ });
- 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
- };
- },
+ // This function executes the process handlers and inserts the contents
+ function process(h) {
+ var dom = ed.dom, o = {content : h};
- // Private methods
+ // Execute pre process handlers
+ t.onPreProcess.dispatch(t, o);
- _handlePasteEvent : function(e) {
- var html = this._clipboardHTML(), ed = this.editor, sel = ed.selection, r;
+ // Create DOM structure
+ o.node = dom.create('div', 0, o.content);
- // Removes italic, strong etc, the if was needed due to bug #1437114
- if (ed && (r = sel.getRng()) && r.text.length > 0)
- ed.execCommand('delete');
+ // Execute post process handlers
+ t.onPostProcess.dispatch(t, o);
- if (html && html.length > 0)
- ed.execCommand('mcePasteWord', false, html);
+ // Serialize content
+ o.content = ed.serializer.serialize(o.node, {getInner : 1});
- return Event.cancel(e);
- },
+ // Insert cleaned content. We need to handle insertion of contents containing block elements separatly
+ if (/<(p|h[1-6]|ul|ol)/.test(o.content))
+ t._insertBlockContent(ed, dom, o.content);
+ else
+ t._insert(o.content);
+ };
- _insertText : function(content, bLinebreaks) {
- content = this.editor.dom.encode(content);
-
- if (content && content.length > 0) {
- if (bLinebreaks) {
- // Special paragraph treatment
- if (this.editor.getParam("paste_create_paragraphs", true)) {
- var rl = this.editor.getParam("paste_replace_list", '\u2122,<sup>TM</sup>,\u2026,...,\u201c|\u201d,",\u2019,\',\u2013|\u2014|\u2015|\u2212,-').split(',');
- for (var i=0; i<rl.length; i+=2)
- content = content.replace(new RegExp(rl[i], 'gi'), rl[i+1]);
-
- content = content.replace(/\r\n\r\n/g, '</p><p>');
- content = content.replace(/\r\r/g, '</p><p>');
- content = content.replace(/\n\n/g, '</p><p>');
-
- // Has paragraphs
- if ((pos = content.indexOf('</p><p>')) != -1) {
- this.editor.execCommand("Delete");
-
- var node = this.editor.selection.getNode();
-
- // Get list of elements to break
- var breakElms = [];
-
- do {
- if (node.nodeType == 1) {
- // Don't break tables and break at body
- if (node.nodeName == "TD" || node.nodeName == "BODY")
- break;
-
- breakElms[breakElms.length] = node;
- }
- } while(node = node.parentNode);
-
- var before = "", after = "</p>";
- before += content.substring(0, pos);
-
- for (var i=0; i<breakElms.length; i++) {
- before += "</" + breakElms[i].nodeName + ">";
- after += "<" + breakElms[(breakElms.length-1)-i].nodeName + ">";
- }
-
- before += "<p>";
- content = before + content.substring(pos+7) + after;
- }
- }
-
- if (this.editor.getParam("paste_create_linebreaks", true)) {
- content = content.replace(/\r\n/g, '<br />');
- content = content.replace(/\r/g, '<br />');
- content = content.replace(/\n/g, '<br />');
- }
- }
+ // Add command for external usage
+ ed.addCommand('mceInsertClipboardContent', function(u, v) {
+ process(v);
+ });
- this.editor.execCommand("mceInsertRawHTML", false, content);
- }
- },
+ // This function grabs the contents from the clipboard by adding a
+ // hidden div and placing the caret inside it and after the browser paste
+ // 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;
- _insertWordContent : function(content) {
- var t = this, ed = t.editor;
+ if (dom.get('_mcePaste'))
+ return;
- if (content && content.length > 0) {
- // Cleanup Word content
- var bull = String.fromCharCode(8226);
- var middot = String.fromCharCode(183);
+ // Create container to paste into
+ n = dom.add(body, 'div', {id : '_mcePaste'}, ' ');
- if (ed.getParam('paste_insert_word_content_callback'))
- content = ed.execCallback('paste_insert_word_content_callback', 'before', content);
+ // If contentEditable mode we need to find out the position of the closest element
+ if (body != ed.getDoc().body)
+ posY = dom.getPos(ed.selection.getStart(), body).y;
+ else
+ posY = body.scrollTop;
+
+ // Styles needs to be applied after the element is added to the document since WebKit will otherwise remove all styles
+ dom.setStyles(n, {
+ position : 'absolute',
+ left : -10000,
+ top : posY,
+ width : 1,
+ height : 1,
+ overflow : 'hidden'
+ });
- var rl = ed.getParam("paste_replace_list", '\u2122,<sup>TM</sup>,\u2026,...,\u201c|\u201d,",\u2019,\',\u2013|\u2014|\u2015|\u2212,-').split(',');
- for (var i=0; i<rl.length; i+=2)
- content = content.replace(new RegExp(rl[i], 'gi'), rl[i+1]);
+ if (tinymce.isIE) {
+ // Select the container
+ rng = dom.doc.body.createTextRange();
+ rng.moveToElementText(n);
+ rng.execCommand('Paste');
- if (this.editor.getParam("paste_convert_headers_to_strong", false)) {
- content = content.replace(new RegExp('<p class=MsoHeading.*?>(.*?)<\/p>', 'gi'), '<p><b>$1</b></p>');
- }
+ // Remove container
+ dom.remove(n);
- content = content.replace(new RegExp('tab-stops: list [0-9]+.0pt">', 'gi'), '">' + "--list--");
- content = content.replace(new RegExp(bull + "(.*?)<BR>", "gi"), "<p>" + middot + "$1</p>");
- content = content.replace(new RegExp('<SPAN style="mso-list: Ignore">', 'gi'), "<span>" + bull); // Covert to bull list
- content = content.replace(/<o:p><\/o:p>/gi, "");
- content = content.replace(new RegExp('<br style="page-break-before: always;.*>', 'gi'), '-- page break --'); // Replace pagebreaks
- content = content.replace(new RegExp('<(!--)([^>]*)(--)>', 'g'), ""); // Word comments
+ // Process contents
+ process(n.innerHTML);
- if (this.editor.getParam("paste_remove_spans", true))
- content = content.replace(/<\/?span[^>]*>/gi, "");
+ return tinymce.dom.Event.cancel(e);
+ } else {
+ or = ed.selection.getRng();
- if (this.editor.getParam("paste_remove_styles", true))
- content = content.replace(new RegExp('<(\\w[^>]*) style="([^"]*)"([^>]*)', 'gi'), "<$1$3");
+ // Move caret into hidden div
+ n = n.firstChild;
+ rng = ed.getDoc().createRange();
+ rng.setStart(n, 0);
+ rng.setEnd(n, 1);
+ sel.setRng(rng);
- content = content.replace(/<\/?font[^>]*>/gi, "");
+ // Wait a while and grab the pasted contents
+ window.setTimeout(function() {
+ var n = dom.get('_mcePaste'), h;
- // Strips class attributes.
- switch (this.editor.getParam("paste_strip_class_attributes", "all")) {
- case "all":
- content = content.replace(/<(\w[^>]*) class=([^ |>]*)([^>]*)/gi, "<$1$3");
- break;
+ // 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;
- case "mso":
- content = content.replace(new RegExp('<(\\w[^>]*) class="?mso([^ |>]*)([^>]*)', 'gi'), "<$1$3");
- break;
- }
+ // 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;
- content = content.replace(new RegExp('href="?' + this._reEscape("" + document.location) + '', 'gi'), 'href="' + this.editor.documentBaseURI.getURI());
- content = content.replace(/<(\w[^>]*) lang=([^ |>]*)([^>]*)/gi, "<$1$3");
- content = content.replace(/<\\?\?xml[^>]*>/gi, "");
- content = content.replace(/<\/?\w+:[^>]*>/gi, "");
- content = content.replace(/-- page break --\s*<p> <\/p>/gi, ""); // Remove pagebreaks
- content = content.replace(/-- page break --/gi, ""); // Remove pagebreaks
+ // Remove hidden div and restore selection
+ dom.remove(n);
- // content = content.replace(/\/? */gi, "");
- // content = content.replace(/<p> <\/p>/gi, '');
+ // Restore the old selection
+ if (or)
+ sel.setRng(or);
- if (!this.editor.getParam('force_p_newlines')) {
- content = content.replace('', '' ,'gi');
- content = content.replace('</p>', '<br /><br />' ,'gi');
+ process(h);
+ }, 0);
}
+ };
- if (!tinymce.isIE && !this.editor.getParam('force_p_newlines')) {
- content = content.replace(/<\/?p[^>]*>/gi, "");
+ // Check if we should use the new auto process method
+ if (ed.getParam('paste_auto_cleanup_on_paste', true)) {
+ // Is it's Opera or older FF use key handler
+ if (tinymce.isOpera || /Firefox\/2/.test(navigator.userAgent)) {
+ ed.onKeyDown.add(function(ed, e) {
+ if (((tinymce.isMac ? e.metaKey : e.ctrlKey) && e.keyCode == 86) || (e.shiftKey && e.keyCode == 45))
+ grabContent(e);
+ });
+ } else {
+ // Grab contents on paste event on Gecko and WebKit
+ ed.onPaste.addToTop(function(ed, e) {
+ return grabContent(e);
+ });
}
+ }
- content = content.replace(/<\/?div[^>]*>/gi, "");
+ // Add legacy support
+ t._legacySupport();
+ },
- // Convert all middlot lists to UL lists
- if (this.editor.getParam("paste_convert_middot_lists", true)) {
- var div = ed.dom.create("div", null, content);
+ 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
+ };
+ },
- // Convert all middot paragraphs to li elements
- var className = this.editor.getParam("paste_unindented_list_class", "unIndentedList");
+ _preProcess : function(pl, o) {
+ var h = o.content, process;
- while (this._convertMiddots(div, "--list--")) ; // bull
- while (this._convertMiddots(div, middot, className)) ; // Middot
- while (this._convertMiddots(div, bull)) ; // bull
+ //console.log('Before preprocess:' + o.content);
- content = div.innerHTML;
- }
+ function process(items) {
+ each(items, function(v) {
+ // Remove or replace
+ if (v.constructor == RegExp)
+ h = h.replace(v, '');
+ else
+ h = h.replace(v[0], v[1]);
+ });
+ };
- // Replace all headers with strong and fix some other issues
- if (this.editor.getParam("paste_convert_headers_to_strong", false)) {
- content = content.replace(/<h[1-6]> <\/h[1-6]>/gi, '<p> </p>');
- content = content.replace(/<h[1-6]>/gi, '<p><b>');
- content = content.replace(/<\/h[1-6]>/gi, '</b></p>');
- content = content.replace(/<b> <\/b>/gi, '<b> </b>');
- content = content.replace(/^( )*/gi, '');
- }
+ // Process away some basic content
+ process([
+ /^\s*( )+/g, // nbsp entities at the start of contents
+ /( |<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)) {
+ o.wordContent = true; // Mark the pasted contents as word specific content
+ //console.log('Word contents detected.');
+
+ process([
+ /<!--[\s\S]+?-->/gi, // Word comments
+ /<\/?(img|font|meta|link|style|span|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)
+ [/<(\/?)s>/gi, '<$1strike>'], // Convert <s> into <strike> for line-though
+ /<script[^>]+>[\s\S]*?<\/script>/gi, // All scripts elements for msoShowComment for example
+ [/ /g, '\u00a0'] // Replace nsbp entites to char since it's easier to handle
+ ]);
+ }
- content = content.replace(/--list--/gi, ""); // Remove --list--
+ //console.log('After preprocess:' + h);
- if (ed.getParam('paste_insert_word_content_callback'))
- content = ed.execCallback('paste_insert_word_content_callback', 'after', content);
+ o.content = h;
+ },
- // Insert cleaned content
- this.editor.execCommand("mceInsertContent", false, content);
+ /**
+ * Various post process items.
+ */
+ _postProcess : function(pl, o) {
+ var t = this, dom = t.editor.dom;
+
+ if (o.wordContent) {
+ // Remove named anchors or TOC links
+ each(dom.select('a', o.node), function(a) {
+ if (!a.href || a.href.indexOf('#_Toc') != -1)
+ dom.remove(a, 1);
+ });
- if (this.editor.getParam('paste_force_cleanup_wordpaste', true)) {
- var ed = this.editor;
+ if (t.editor.getParam('paste_convert_middot_lists', true))
+ t._convertLists(pl, o);
- window.setTimeout(function() {
- ed.execCommand("mceCleanup");
- }, 1); // Do normal cleanup detached from this thread
- }
+ // Remove all styles
+ each(dom.select('*', o.node), function(el) {
+ dom.setAttrib(el, 'style', '');
+ });
+ }
+
+ 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');
+ });
}
},
- _reEscape : function(s) {
- var l = "?.\\*[](){}+^$:";
- var o = "";
+ /**
+ * 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;
+
+ // Convert middot lists into real scemantic lists
+ each(dom.select('p', o.node), function(p) {
+ var sib, val = '', type, html, idx, parents;
+
+ // Get text node value at beginning of paragraph
+ for (sib = p.firstChild; sib && sib.nodeType == 3; sib = sib.nextSibling)
+ val += sib.nodeValue;
+
+ // Detect unordered lists look for bullets
+ if (/^[\u2022\u00b7\u00a7\u00d8o]\s*\u00a0\u00a0*/.test(val))
+ type = 'ul';
+
+ // Detect ordered lists 1., a. or ixv.
+ if (/^[\s\S]*\w+\.[\s\S]*\u00a0{2,}/.test(val))
+ type = 'ol';
+
+ // Check if node value matches the list pattern: o
+ if (type) {
+ margin = parseFloat(p.style.marginLeft || 0);
+
+ if (margin > lastMargin)
+ levels.push(margin);
+
+ if (!listElm || type != lastType) {
+ listElm = dom.create(type);
+ dom.insertAfter(listElm, p);
+ } else {
+ // Nested list element
+ if (margin > lastMargin) {
+ listElm = li.appendChild(dom.create(type));
+ } else if (margin < lastMargin) {
+ // Find parent level based on margin value
+ idx = tinymce.inArray(levels, margin);
+ parents = dom.getParents(listElm.parentNode, type);
+ listElm = parents[parents.length - 1 - idx] || listElm;
+ }
+ }
- for (var i=0; i<s.length; i++) {
- var c = s.charAt(i);
+ if (type == 'ul')
+ html = p.innerHTML.replace(/^[\u2022\u00b7\u00a7\u00d8o]\s*( |\u00a0)+\s*/, '');
+ else
+ html = p.innerHTML.replace(/^[\s\S]*\w+\.( |\u00a0)+\s*/, '');
- if (l.indexOf(c) != -1)
- o += '\\' + c;
- else
- o += c;
- }
+ li = listElm.appendChild(dom.create('li', 0, html));
+ dom.remove(p);
- return o;
+ lastMargin = margin;
+ lastType = type;
+ } else
+ listElm = lastMargin = 0; // End list element
+ });
},
- _convertMiddots : function(div, search, class_name) {
- var ed = this.editor, mdot = String.fromCharCode(183), bull = String.fromCharCode(8226);
- var nodes, prevul, i, p, ul, li, np, cp, li;
-
- nodes = div.getElementsByTagName("p");
- for (i=0; i<nodes.length; i++) {
- p = nodes[i];
-
- // Is middot
- if (p.innerHTML.indexOf(search) == 0) {
- ul = ed.dom.create("ul");
-
- if (class_name)
- ul.className = class_name;
-
- // Add the first one
- li = ed.dom.create("li");
- li.innerHTML = p.innerHTML.replace(new RegExp('' + mdot + '|' + bull + '|--list--| ', "gi"), '');
- ul.appendChild(li);
-
- // Add the rest
- np = p.nextSibling;
- while (np) {
- // If the node is whitespace, then
- // ignore it and continue on.
- if (np.nodeType == 3 && new RegExp('^\\s$', 'm').test(np.nodeValue)) {
- np = np.nextSibling;
- continue;
- }
+ /**
+ * This method will split the current block parent and insert the contents inside the split position.
+ * This logic can be improved so text nodes at the start/end remain in the start/end block elements
+ */
+ _insertBlockContent : function(ed, dom, content) {
+ var parentBlock, marker, sel = ed.selection, last, elm, vp, y, elmHeight;
+
+ function select(n) {
+ var r;
+
+ if (tinymce.isIE) {
+ r = ed.getDoc().body.createTextRange();
+ r.moveToElementText(n);
+ r.collapse(false);
+ r.select();
+ } else {
+ sel.select(n, 1);
+ sel.collapse(false);
+ }
+ };
- if (search == mdot) {
- if (np.nodeType == 1 && new RegExp('^o(\\s+| )').test(np.innerHTML)) {
- // Second level of nesting
- if (!prevul) {
- prevul = ul;
- ul = ed.dom.create("ul");
- prevul.appendChild(ul);
- }
- np.innerHTML = np.innerHTML.replace(/^o/, '');
- } else {
- // Pop the stack if we're going back up to the first level
- if (prevul) {
- ul = prevul;
- prevul = null;
- }
- // Not element or middot paragraph
- if (np.nodeType != 1 || np.innerHTML.indexOf(search) != 0)
- break;
- }
- } else {
- // Not element or middot paragraph
- if (np.nodeType != 1 || np.innerHTML.indexOf(search) != 0)
- break;
- }
-
- cp = np.nextSibling;
- li = ed.dom.create("li");
- li.innerHTML = np.innerHTML.replace(new RegExp('' + mdot + '|' + bull + '|--list--| ', "gi"), '');
- np.parentNode.removeChild(np);
- ul.appendChild(li);
- np = cp;
- }
+ // Insert a marker for the caret position
+ this._insert('<span id="_marker"> </span>', 1);
+ marker = dom.get('_marker');
+ parentBlock = dom.getParent(marker, 'p,h1,h2,h3,h4,h5,h6,ul,ol');
- p.parentNode.replaceChild(ul, p);
+ if (parentBlock) {
+ // Split parent block
+ marker = dom.split(parentBlock, marker);
- return true;
- }
+ // Insert nodes before the marker
+ each(dom.create('div', 0, content).childNodes, function(n) {
+ last = marker.parentNode.insertBefore(n.cloneNode(true), marker);
+ });
+
+ // Move caret after marker
+ select(last);
+ } else {
+ dom.setOuterHTML(marker, content);
+ sel.select(ed.getBody(), 1);
+ sel.collapse(0);
}
- return false;
+ dom.remove('_marker'); // Remove marker if it's left
+
+ // Get element, position and height
+ elm = sel.getStart();
+ vp = dom.getViewPort(ed.getWin());
+ y = ed.dom.getPos(elm).y;
+ elmHeight = elm.clientHeight;
+
+ // Is element within viewport if not then scroll it into view
+ if (y < vp.y || y + elmHeight > vp.y + vp.h)
+ ed.getDoc().body.scrollTop = y < vp.y ? y : y - vp.h + 25;
},
- _clipboardHTML : function() {
- var div = document.getElementById('_TinyMCE_clipboardHTML');
+ /**
+ * Inserts the specified contents at the caret position.
+ */
+ _insert : function(h, skip_undo) {
+ var ed = this.editor;
- if (!div) {
- var div = document.createElement('DIV');
- div.id = '_TinyMCE_clipboardHTML';
+ // First delete the contents seems to work better on WebKit
+ ed.execCommand('Delete');
- with (div.style) {
- visibility = 'hidden';
- overflow = 'hidden';
- position = 'absolute';
- width = 1;
- height = 1;
- }
+ // 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});
+ },
- document.body.appendChild(div);
- }
+ /**
+ * This method will open the old style paste dialogs. Some users might want the old behavior but still use the new cleanup engine.
+ */
+ _legacySupport : function() {
+ var t = this, ed = t.editor;
+
+ // Register commands for backwards compatibility
+ each(['mcePasteText', 'mcePasteWord'], function(cmd) {
+ ed.addCommand(cmd, function() {
+ ed.windowManager.open({
+ file : t.url + (cmd == 'mcePasteText' ? '/pastetext.htm' : '/pasteword.htm'),
+ width : 450,
+ height : 400,
+ inline : 1
+ });
+ });
+ });
- div.innerHTML = '';
- var rng = document.body.createTextRange();
- rng.moveToElementText(div);
- rng.execCommand('Paste');
- var html = div.innerHTML;
- div.innerHTML = '';
- return html;
+ // Register buttons for backwards compatibility
+ ed.addButton('pastetext', {title : 'paste.paste_text_desc', cmd : 'mcePasteText'});
+ ed.addButton('pasteword', {title : 'paste.paste_word_desc', cmd : 'mcePasteWord'});
+ ed.addButton('selectall', {title : 'paste.selectall_desc', cmd : 'selectall'});
}
});
diff --git a/program/js/tiny_mce/plugins/paste/js/pastetext.js b/program/js/tiny_mce/plugins/paste/js/pastetext.js index 326bb16a2..303439b33 100644 --- a/program/js/tiny_mce/plugins/paste/js/pastetext.js +++ b/program/js/tiny_mce/plugins/paste/js/pastetext.js @@ -1,42 +1,36 @@ tinyMCEPopup.requireLangPack();
-function saveContent() {
- if (document.forms[0].htmlSource.value == '') {
+var PasteTextDialog = {
+ init : function() {
+ this.resize();
+ },
+
+ insert : function() {
+ var h = tinyMCEPopup.dom.encode(document.getElementById('content').value), lines;
+
+ // Convert linebreaks into paragraphs
+ if (document.getElementById('linebreaks').checked) {
+ lines = h.split(/\r?\n/);
+ if (lines.length > 1) {
+ h = '';
+ tinymce.each(lines, function(row) {
+ h += '<p>' + row + '</p>';
+ });
+ }
+ }
+
+ tinyMCEPopup.editor.execCommand('mceInsertClipboardContent', false, h);
tinyMCEPopup.close();
- return false;
- }
-
- tinyMCEPopup.execCommand('mcePasteText', false, {
- html : document.forms[0].htmlSource.value,
- linebreaks : document.forms[0].linebreaks.checked
- });
-
- tinyMCEPopup.close();
-}
+ },
-function onLoadInit() {
- tinyMCEPopup.resizeToInnerSize();
+ resize : function() {
+ var vp = tinyMCEPopup.dom.getViewPort(window), el;
- // Remove Gecko spellchecking
- if (tinymce.isGecko)
- document.body.spellcheck = tinyMCEPopup.getParam("gecko_spellcheck");
+ el = document.getElementById('content');
- resizeInputs();
-}
-
-var wHeight=0, wWidth=0, owHeight=0, owWidth=0;
-
-function resizeInputs() {
- if (!tinymce.isIE) {
- wHeight = self.innerHeight-80;
- wWidth = self.innerWidth-17;
- } else {
- wHeight = document.body.clientHeight-80;
- wWidth = document.body.clientWidth-17;
+ el.style.width = (vp.w - 20) + 'px';
+ el.style.height = (vp.h - 90) + 'px';
}
+};
- document.forms[0].htmlSource.style.height = Math.abs(wHeight) + 'px';
- document.forms[0].htmlSource.style.width = Math.abs(wWidth) + 'px';
-}
-
-tinyMCEPopup.onInit.add(onLoadInit);
\ No newline at end of file +tinyMCEPopup.onInit.add(PasteTextDialog.init, PasteTextDialog);
diff --git a/program/js/tiny_mce/plugins/paste/js/pasteword.js b/program/js/tiny_mce/plugins/paste/js/pasteword.js index 6701b99fc..fe053a721 100644 --- a/program/js/tiny_mce/plugins/paste/js/pasteword.js +++ b/program/js/tiny_mce/plugins/paste/js/pasteword.js @@ -1,56 +1,51 @@ tinyMCEPopup.requireLangPack();
-function saveContent() {
- var html = document.getElementById("frmData").contentWindow.document.body.innerHTML;
-
- if (html == ''){
+var PasteWordDialog = {
+ init : function() {
+ var ed = tinyMCEPopup.editor, el = document.getElementById('iframecontainer'), ifr, doc, css, cssHTML = '';
+
+ // Create iframe
+ el.innerHTML = '<iframe id="iframe" src="javascript:\'\';" frameBorder="0" style="border: 1px solid gray"></iframe>';
+ ifr = document.getElementById('iframe');
+ doc = ifr.contentWindow.document;
+
+ // Force absolute CSS urls
+ 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" />';
+ });
+
+ // Write content into iframe
+ doc.open();
+ doc.write('<html><head>' + cssHTML + '</head><body spellcheck="false"></body></html>');
+ doc.close();
+
+ doc.designMode = 'on';
+ this.resize();
+
+ window.setTimeout(function() {
+ ifr.contentWindow.focus();
+ }, 10);
+ },
+
+ insert : function() {
+ var h = document.getElementById('iframe').contentWindow.document.body.innerHTML;
+
+ tinyMCEPopup.editor.execCommand('mceInsertClipboardContent', false, h);
tinyMCEPopup.close();
- return false;
- }
-
- tinyMCEPopup.execCommand('mcePasteWord', false, html);
- tinyMCEPopup.close();
-}
-
-function onLoadInit() {
- tinyMCEPopup.resizeToInnerSize();
-
- // Fix for endless reloading in FF
- window.setTimeout(createIFrame, 10);
-}
-
-function createIFrame() {
- document.getElementById('iframecontainer').innerHTML = '<iframe id="frmData" name="frmData" class="sourceIframe" src="blank.htm" height="280" width="400" frameborder="0" style="background-color:#FFFFFF; width:100%;" dir="ltr" wrap="soft"></iframe>';
-}
+ },
-var wHeight=0, wWidth=0, owHeight=0, owWidth=0;
+ resize : function() {
+ var vp = tinyMCEPopup.dom.getViewPort(window), el;
-function initIframe(doc) {
- var dir = tinyMCEPopup.editor.settings.directionality;
-
- doc.body.dir = dir;
-
- // Remove Gecko spellchecking
- if (tinymce.isGecko)
- doc.body.spellcheck = tinyMCEPopup.getParam("gecko_spellcheck");
-
- resizeInputs();
-}
-
-function resizeInputs() {
- if (!tinymce.isIE) {
- wHeight = self.innerHeight - 80;
- wWidth = self.innerWidth - 18;
- } else {
- wHeight = document.body.clientHeight - 80;
- wWidth = document.body.clientWidth - 18;
- }
+ el = document.getElementById('iframe');
- var elm = document.getElementById('frmData');
- if (elm) {
- elm.style.height = Math.abs(wHeight) + 'px';
- elm.style.width = Math.abs(wWidth) + 'px';
+ if (el) {
+ el.style.width = (vp.w - 20) + 'px';
+ el.style.height = (vp.h - 90) + 'px';
+ }
}
-}
+};
-tinyMCEPopup.onInit.add(onLoadInit);
+tinyMCEPopup.onInit.add(PasteWordDialog.init, PasteWordDialog);
diff --git a/program/js/tiny_mce/plugins/paste/pastetext.htm b/program/js/tiny_mce/plugins/paste/pastetext.htm index 2f2b341a1..42c3d9c84 100644 --- a/program/js/tiny_mce/plugins/paste/pastetext.htm +++ b/program/js/tiny_mce/plugins/paste/pastetext.htm @@ -4,31 +4,30 @@ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script type="text/javascript" src="../../tiny_mce_popup.js"></script>
<script type="text/javascript" src="js/pastetext.js"></script>
- <base target="_self" />
</head>
-<body onresize="resizeInputs();" style="display:none; overflow:hidden;">
-<form name="source" onsubmit="saveContent();return false;" action="#">
- <div style="float: left" class="title">{#paste.paste_text_desc}</div>
+<body onresize="PasteTextDialog.resize();" style="display:none; overflow:hidden;">
+ <form name="source" onsubmit="return PasteTextDialog.insert();" action="#">
+ <div style="float: left" class="title">{#paste.paste_text_desc}</div>
- <div style="float: right">
- <input type="checkbox" name="linebreaks" id="linebreaks" class="wordWrapCode" checked="checked" /><label for="linebreaks">{#paste_dlg.text_linebreaks}</label>
- </div>
+ <div style="float: right">
+ <input type="checkbox" name="linebreaks" id="linebreaks" class="wordWrapCode" checked="checked" /><label for="linebreaks">{#paste_dlg.text_linebreaks}</label>
+ </div>
- <br style="clear: both" />
+ <br style="clear: both" />
- <div>{#paste_dlg.text_title}</div>
+ <div>{#paste_dlg.text_title}</div>
- <textarea name="htmlSource" id="htmlSource" rows="15" cols="100" style="width: 100%; height: 100%; font-family: 'Courier New',Courier,mono; font-size: 12px;" dir="ltr" wrap="soft" class="mceFocus"></textarea>
+ <textarea id="content" name="content" rows="15" cols="100" style="width: 100%; height: 100%; font-family: 'Courier New',Courier,mono; font-size: 12px;" dir="ltr" wrap="soft" class="mceFocus"></textarea>
- <div class="mceActionPanel">
- <div style="float: left">
- <input type="submit" name="insert" value="{#insert}" id="insert" />
- </div>
+ <div class="mceActionPanel">
+ <div style="float: left">
+ <input type="submit" name="insert" value="{#insert}" id="insert" />
+ </div>
- <div style="float: right">
- <input type="button" name="cancel" value="{#cancel}" onclick="tinyMCEPopup.close();" id="cancel" />
+ <div style="float: right">
+ <input type="button" name="cancel" value="{#cancel}" onclick="tinyMCEPopup.close();" id="cancel" />
+ </div>
</div>
- </div>
-</form>
+ </form>
</body>
</html>
\ No newline at end of file diff --git a/program/js/tiny_mce/plugins/paste/pasteword.htm b/program/js/tiny_mce/plugins/paste/pasteword.htm index 9e5ab1b5b..f4a9b3db3 100644 --- a/program/js/tiny_mce/plugins/paste/pasteword.htm +++ b/program/js/tiny_mce/plugins/paste/pasteword.htm @@ -4,11 +4,9 @@ <title>{#paste.paste_word_desc}</title>
<script type="text/javascript" src="../../tiny_mce_popup.js"></script>
<script type="text/javascript" src="js/pasteword.js"></script>
- <link href="css/pasteword.css" rel="stylesheet" type="text/css" />
- <base target="_self" />
</head>
-<body onresize="resizeInputs();" style="display:none; overflow:hidden;">
- <form name="source" onsubmit="saveContent();" action="#">
+<body onresize="PasteWordDialog.resize();" style="display:none; overflow:hidden;">
+ <form name="source" onsubmit="return PasteWordDialog.insert();" action="#">
<div class="title">{#paste.paste_word_desc}</div>
<div>{#paste_dlg.word_title}</div>
@@ -17,7 +15,7 @@ <div class="mceActionPanel">
<div style="float: left">
- <input type="button" id="insert" name="insert" value="{#insert}" onclick="saveContent();" />
+ <input type="submit" id="insert" name="insert" value="{#insert}" />
</div>
<div style="float: right">
|