From 58fb6502e3550e59afa8799d36dfce61a18f8b1b Mon Sep 17 00:00:00 2001 From: alecpl Date: Tue, 15 Dec 2009 08:48:45 +0000 Subject: - Updated TinyMCE to 3.2.7 --- program/js/tiny_mce/plugins/paste/blank.htm | 22 -- program/js/tiny_mce/plugins/paste/css/blank.css | 14 -- .../js/tiny_mce/plugins/paste/css/pasteword.css | 3 - program/js/tiny_mce/plugins/paste/editor_plugin.js | 2 +- .../js/tiny_mce/plugins/paste/editor_plugin_src.js | 230 ++++++++++++++++----- program/js/tiny_mce/plugins/paste/js/pastetext.js | 2 +- program/js/tiny_mce/plugins/paste/js/pasteword.js | 6 +- 7 files changed, 185 insertions(+), 94 deletions(-) delete mode 100644 program/js/tiny_mce/plugins/paste/blank.htm delete mode 100644 program/js/tiny_mce/plugins/paste/css/blank.css delete mode 100644 program/js/tiny_mce/plugins/paste/css/pasteword.css (limited to 'program/js/tiny_mce/plugins/paste') 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 @@ - - -blank_page - - - - - - - - - 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"}," ");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,/( |]*>)+\s*$/g]);if(/(class=\"?Mso|style=\"[^\"]*\bmso\-|w:WordDocument)/.test(b)){e.wordContent=true;d([//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>"],/]+>[\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 ',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(kb.y+b.h){h.getDoc().body.scrollTop=k 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*( )+/g,/( |]*>)+\s*$/g]);if(b.getParam("paste_convert_middot_lists",true)){g([[//gi,"$&__MCE_ITEM__"],[/(]+:\s*symbol[^>]+>)/gi,"$1__MCE_ITEM__"],[/(]+mso-list:[^>]+>)/gi,"$1__MCE_ITEM__"]])}g([//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>"],/]+>[\s\S]*?<\/script>/gi,[/ /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;k0){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(/ /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]*>/gi,"");if(q=="ul"&&/^[\u2022\u00b7\u00a7\u00d8o]/.test(p)){g.remove(t)}else{if(/^[\s\S]*\w+\.( |\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*( |\u00a0)+\s*/,"")}else{o=r.innerHTML.replace(/__MCE_ITEM__/g,"").replace(/^\s*\w+\.( |\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(' ',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(kb.y+b.h){h.getDoc().body.scrollTop=k 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*( )+/g, // nbsp entities at the start of contents - /( |]*>)+\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*( )+/g, // nbsp entities at the start of contents + /( |]*>)+\s*$/g // nbsp entities at the end of contents + ]); + + if (ed.getParam('paste_convert_middot_lists', true)) { + process([ + [//gi, '$&__MCE_ITEM__'], // Convert supportLists to a list item marker + [/(]+:\s*symbol[^>]+>)/gi, '$1__MCE_ITEM__'], // Convert symbol spans to list items + [/(]+mso-list:[^>]+>)/gi, '$1__MCE_ITEM__'] // Convert mso-list to item marker + ]); + } + process([ //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 - / (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 into for line-though /]+>[\s\S]*?<\/script>/gi, // All scripts elements for msoShowComment for example [/ /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 it will become - // 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 it will become + // 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(/ /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   @@ -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+\.( |\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*( |\u00a0)+\s*/, ''); + html = p.innerHTML.replace(/__MCE_ITEM__/g, '').replace(/^[\u2022\u00b7\u00a7\u00d8o]\s*( |\u00a0)+\s*/, ''); else - html = p.innerHTML.replace(/^[\s\S]*\w+\.( |\u00a0)+\s*/, ''); + html = p.innerHTML.replace(/__MCE_ITEM__/g, '').replace(/^\s*\w+\.( |\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(' ', 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 += ''; + cssHTML += ''; }); // Write content into iframe doc.open(); - doc.write('' + cssHTML + ''); + doc.write('' + cssHTML + ''); 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(); }, -- cgit v1.2.3