Created
December 27, 2012 16:53
-
-
Save Matho/4389818 to your computer and use it in GitHub Desktop.
TinyMCE settings for Word html cleaning, preserving text color
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Paste in http://fiddle.tinymce.com/baaaab | |
// This settings strip all span and font tag, but preserving color and text-decoration | |
<script type="text/javascript"> | |
tinyMCE.init({ | |
// General options | |
mode : "textareas", | |
theme : "advanced", | |
plugins : "autolink,lists,spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,imagemanager,filemanager", | |
// Theme options | |
theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect", | |
theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor", | |
theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen", | |
theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,spellchecker,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,blockquote,pagebreak,|,insertfile,insertimage", | |
theme_advanced_toolbar_location : "top", | |
theme_advanced_toolbar_align : "left", | |
theme_advanced_statusbar_location : "bottom", | |
theme_advanced_resizing : true, | |
paste_auto_cleanup_on_paste : true, | |
// remove all span tag, which dont have style attribute with color or text-decoration | |
paste_remove_spans: true, | |
paste_retain_style_properties: "color, text-decoration", | |
paste_remove_styles: false, | |
paste_remove_styles_if_webkit: false, | |
paste_strip_class_attributes : "all", | |
paste_strip_class_attributes : "none", | |
// delete only those css classes, which are not specified in style using content_css | |
verify_css_classes: true, | |
paste_preprocess : function(pl, o) { | |
//o.content = o.content.replace(/<\/?<font color="#000000">(.*?)<\/font>\s/gi, "$1"); | |
alert(o.content); | |
//o.content = o.content.replace(/<font color="(.*?)">(.*?)<\/font>/gi, "<span style=\"color:$1;\">$2</span>"); | |
//we don't need font tag with black color | |
o.content = o.content.replace(/color="#000000"/gi, ""); | |
//replace color="..." with style="..." | |
o.content = o.content.replace(/color="(.*?)"/gi, "style=\"color:$1;\""); | |
//replace all font tag with span. | |
o.content = o.content.replace(/font/gi, "span"); | |
// Content string containing the HTML from the clipboard | |
alert(o.content); | |
o.content = "-: CLEANED :-\n" + o.content; | |
}, | |
paste_postprocess : function(pl, o) { | |
// Content DOM node containing the DOM structure of the clipboard | |
alert(o.node.innerHTML); | |
o.node.innerHTML = o.node.innerHTML + "\n-: CLEANED :-"; | |
}, | |
width: "100%", | |
height: "400" | |
}); | |
</script> | |
<form method="post" action="dump.php"> | |
<textarea name="content"></textarea> | |
</form> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment