marhoons Posted December 14, 2006 Share Posted December 14, 2006 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..[color=red]i was found function to clean word code post but i dont now how to use it ! any way if we have botton name (past) for i.e when i copy text from microsoft word How i can use this function to clean it!?[/color][code]// The following function is a slight variation of the word cleaner code postedfunction() { 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(); }};[/code] any one can help me please don't hesitate.. Quote Link to comment Share on other sites More sharing options...
fenway Posted December 16, 2006 Share Posted December 16, 2006 You copied this from some larger code repository that had custom JS objects... you'll have to pass in whatever you want to cleanse, and fix all of the references to it accordingly. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.