Hello,
i use WYSIWYG editor ver. 2.03 and i am confortable with it ..to day i want to do some medication by adding function word cleaner code..
However..
i was found this function ( clean word code post ) in deffrent ver. i read the script & extract the function but i don't now how we can use in deffrent way!
:rolleyes: for example if we have botton name (Clean) & want to use this function to clean text paset it in textarea from Microsoft word how we can use !?
Code:
// The following function is a slight variation of the word cleaner code posted
function() {
var D = this.getInnerHTML();
if (D.indexOf('class=Mso') >= 0) {
// make one line
D = D.replace(/\r\n/g, ' ').
replace(/\n/g, ' ').
replace(/\r/g, ' ').
replace(/\ \;/g,' ');
// keep tags, strip attributes
D = D.replace(/ class=[^\s|>]*/gi,'').
//replace(/<p [^>]*TEXT-ALIGN: justify[^>]*>/gi,'<p align="justify">').
replace(/ style=\"[^>]*\"/gi,'').
replace(/ align=[^\s|>]*/gi,'');
//clean up tags
D = D.replace(/<b [^>]*>/gi,'<b>').
replace(/<i [^>]*>/gi,'<i>').
replace(/<li [^>]*>/gi,'<li>').
replace(/<ul [^>]*>/gi,'<ul>');
// replace outdated tags
D = D.replace(/<b>/gi,'<strong>').
replace(/<\/b>/gi,'</strong>');
// mozilla doesn't like <em> tags
D = D.replace(/<em>/gi,'<i>').
replace(/<\/em>/gi,'</i>');
// kill unwanted tags
D = D.replace(/<\?xml:[^>]*>/g, ''). // Word xml
replace(/<\/?st1:[^>]*>/g,''). // Word SmartTags
replace(/<\/?[a-z]\:[^>]*>/g,''). // All other funny Word non-HTML stuff
replace(/<\/?font[^>]*>/gi,''). // Disable if you want to keep font formatting
replace(/<\/?span[^>]*>/gi,' ').
replace(/<\/?div[^>]*>/gi,' ').
replace(/<\/?pre[^>]*>/gi,' ').
replace(/<\/?h[1-6][^>]*>/gi,' ');
//remove empty tags
//D = D.replace(/<strong><\/strong>/gi,'').
//replace(/<i><\/i>/gi,'').
//replace(/<P[^>]*><\/P>/gi,'');
// nuke double tags
oldlen = D.length + 1;
while(oldlen > D.length) {
oldlen = D.length;
// join us now and free the tags, we'll be free hackers, we'll be free... ;-)
D = D.replace(/<([a-z][a-z]*)> *<\/\1>/gi,' ').
replace(/<([a-z][a-z]*)> *<([a-z][^>]*)> *<\/\1>/gi,'<$2>');
}
D = D.replace(/<([a-z][a-z]*)><\1>/gi,'<$1>').
replace(/<\/([a-z][a-z]*)><\/\1>/gi,'<\/$1>');
// nuke double spaces
D = D.replace(/ */gi,' ');
this.setHTML(D);
this.updateToolbar();
}
};
you can test that editor have this functional by download it from:
http://www.4shared.com/file/7378555/149945d9/editor.html
any one can help please don't hesitate..