htmlArea

A directory of browser-based WYSIWYG editors

  MAIN
INDEX
SEARCH
POSTS
WHO'S
ONLINE
LOG
IN

Home: htmlArea 3 (beta): htmlArea 2 & 3 archive (read only): htmlArea v3.0 - Discussion:
Tag Replacement


The htmlArea 2 & 3 editors have been discontinued.

We've made these forums available as a read-only reference and knowledge-base for people using or developing editors based on htmlArea 2 or 3.

Anyone who is interested in taking over version 2 or 3 is free to do so. All we ask is that you choose a new name that doesn't have "htmlarea" in it to avoid confusion with this site. We'll even give you a link in the directory to make it easier for people to find you. If you are developing or hosting an htmlArea based-editor under a new name, please submit it to our directory.

 


_-FTH-_
Novice

Apr 19, 2004, 11:27 PM

Post #1 of 20 (7360 views)
Shortcut
Tag Replacement Can't Post

in the htmlarea.js i found the following code

Code
// The following function is a slight variation of the word cleaner code posted 
// by Weeezl (user @ InteractiveTools forums).
HTMLArea.prototype._wordClean = 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(/\&nbsp\;/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();
}
};


I want HTMLArea to kill the <font> tag when i paste some stuff i copyed i my textarea. must i switch this function on?

Sorry, my english is PirateCrazy but please helb me


ytztech
Novice

Apr 20, 2004, 12:10 AM

Post #2 of 20 (7356 views)
Shortcut
Re: [_-FTH-_] Tag Replacement [In reply to] Can't Post

After you create your new HTMLArea object and before you generate the editor, add the following lines:


Code
var config = new HTMLArea.Config(); 
config.killWordOnPaste = true;


Of course, if you already have a config created, only the second line is needed.
--
Justin White, CCNA MCSE
Consultant / YTZ Technical Services, LLC


_-FTH-_
Novice

Apr 20, 2004, 11:04 PM

Post #3 of 20 (7324 views)
Shortcut
Re: [ytztech] Tag Replacement [In reply to] Can't Post

Okay, i added these code to my Config:



Code
var config = new HTMLArea.Config();  
config.killWordOnPaste = true;

But i still got the Problem!
I want to kill some tags (font,p,table,etc.), so i add these one in my htmlarea.js under the point
// kill unwanted tags like this:

Code
replace(/<\/?p[^>]*>/gi,' '). 
replace(/<\/?table[^>]*>/gi,' ').
replace(/<\/?tr[^>]*>/gi,' ').
replace(/<\/?td[^>]*>/gi,' ');

but the tags won't be killed, when i paste my text into the textarea Frown
is there also a way to kill BR-Tags, when there is no Text after it?!?

Thx for Help


ytztech
Novice

Apr 21, 2004, 12:14 AM

Post #4 of 20 (7321 views)
Shortcut
Re: [_-FTH-_] Tag Replacement [In reply to] Can't Post

Are you generating your editor with the new config? Like:

Code
editor = new HTMLArea("ta",config); 
editor.generate();


Using that config will make the change active. Also, be aware that the WordClean function will not clean just what you pasted. It cleans the entire HTML code in the editor, so I don't think this is what you're looking for anyway.
--
Justin White, CCNA MCSE
Consultant / YTZ Technical Services, LLC


_-FTH-_
Novice

Apr 21, 2004, 12:21 AM

Post #5 of 20 (7319 views)
Shortcut
Re: [ytztech] Tag Replacement [In reply to] Can't Post

I'm generating my editor like this:


Code
 <body  onload="HTMLArea.replaceAll()">



ytztech
Novice

Apr 21, 2004, 12:36 AM

Post #6 of 20 (7317 views)
Shortcut
Re: [_-FTH-_] Tag Replacement [In reply to] Can't Post

Not the replace code, the generate code. Typically, you'll have a function called initEditor(). It's in the examples and that's where the config code must be used.
--
Justin White, CCNA MCSE
Consultant / YTZ Technical Services, LLC


_-FTH-_
Novice

Apr 21, 2004, 1:47 AM

Post #7 of 20 (7313 views)
Shortcut
Re: [ytztech] Tag Replacement [In reply to] Can't Post

This is my code:

Code
  

<script type="text/javascript">

_editor_url = "/admin/htmlarea/";

_editor_lang = "de";

</script>

<script type="text/javascript" src="/admin/htmlarea/htmlarea.js"></script>

<script type="text/javascript">

var config = new HTMLArea.Config();

config.killWordOnPaste = true;

config.toolbar = [

['fontname', 'space',

'fontsize', 'space',

'formatblock', 'space',

'bold', 'italic', 'underline']

];

</script>



hubertus
User

Apr 22, 2004, 12:51 AM

Post #8 of 20 (7283 views)
Shortcut
Re: [_-FTH-_] Tag Replacement [In reply to] Can't Post

Hi,

in your case try this:

Code
<body  onload="HTMLArea.replaceAll(config)">


Hubertus
----------------------
CMS with HTMLArea (Username: testuser Password: test):
http://www.sundes.de/sundes_wcg/
HTMLArea direct(choose "Textinhalt"):
http://www.sundes.de/cgi-bin/sundes_wcg/egert.pl?layout&kundendir=gastzugang&idlog=RMNaNcMRMcLa2NP

http://www.sundes.de - http://www.hubertus-egert.de


_-FTH-_
Novice

Apr 22, 2004, 1:22 AM

Post #9 of 20 (7282 views)
Shortcut
Re: [hubertus] Tag Replacement [In reply to] Can't Post

i try...

But the tags (table,td,font,...) are still not deleted Frown


hubertus
User

Apr 22, 2004, 2:00 AM

Post #10 of 20 (7279 views)
Shortcut
Re: [_-FTH-_] Tag Replacement [In reply to] Can't Post

Did you read and tried this?
http://www.interactivetools.com/forum/gforum.cgi?post=27187;search_string=wordclean;#27187

Hubertus
----------------------
CMS with HTMLArea (Username: testuser Password: test):
http://www.sundes.de/sundes_wcg/
HTMLArea direct(choose "Textinhalt"):
http://www.sundes.de/cgi-bin/sundes_wcg/egert.pl?layout&kundendir=gastzugang&idlog=RMNaNcMRMcLa2NP

http://www.sundes.de - http://www.hubertus-egert.de


_-FTH-_
Novice

Apr 22, 2004, 2:27 AM

Post #11 of 20 (7269 views)
Shortcut
Re: [hubertus] Tag Replacement [In reply to] Can't Post

now i tried!

Still not killing the Tags



i got the following code in my textarea document

Code
<script type="text/javascript"> 
_editor_url = "/admin/htmlarea/";
_editor_lang = "de";
</script>
<script type="text/javascript" src="/admin/htmlarea/htmlarea.js"></script>

<script type="text/javascript">
var config = new HTMLArea.Config();
config.killWordOnPaste = true;
config.toolbar = [
['fontname', 'space',
'fontsize', 'space',
'formatblock', 'space',
'bold', 'italic', 'underline']
];
</script>

and

Code
<body  onload="HTMLArea.replaceAll(config)">


also i make the changes from this poting
http://www.interactivetools.com/forum/gforum.cgi?post=27187;search_string=wordclean;#27187

but i still dosn't work


hubertus
User

Apr 22, 2004, 3:09 AM

Post #12 of 20 (7265 views)
Shortcut
Re: [_-FTH-_] Tag Replacement [In reply to] Can't Post

Hi

did you clear your cache?
Works your toolbar configuration?

Hubertus
----------------------
CMS with HTMLArea (Username: testuser Password: test):
http://www.sundes.de/sundes_wcg/
HTMLArea direct(choose "Textinhalt"):
http://www.sundes.de/cgi-bin/sundes_wcg/egert.pl?layout&kundendir=gastzugang&idlog=RMNaNcMRMcLa2NP

http://www.sundes.de - http://www.hubertus-egert.de


_-FTH-_
Novice

Apr 22, 2004, 3:22 AM

Post #13 of 20 (7263 views)
Shortcut
Re: [hubertus] Tag Replacement [In reply to] Can't Post

My Cache is empty, my toolbar configuration works... (ich dreh gleich durch)


hubertus
User

Apr 22, 2004, 3:31 AM

Post #14 of 20 (7260 views)
Shortcut
Re: [_-FTH-_] Tag Replacement [In reply to] Can't Post

Did you tested if the _wordClean function is called?
If not, insert an alert("test") in it.

Hubertus
----------------------
CMS with HTMLArea (Username: testuser Password: test):
http://www.sundes.de/sundes_wcg/
HTMLArea direct(choose "Textinhalt"):
http://www.sundes.de/cgi-bin/sundes_wcg/egert.pl?layout&kundendir=gastzugang&idlog=RMNaNcMRMcLa2NP

http://www.sundes.de - http://www.hubertus-egert.de


hubertus
User

Apr 22, 2004, 3:36 AM

Post #15 of 20 (7258 views)
Shortcut
Re: [_-FTH-_] Tag Replacement [In reply to] Can't Post


Code
HTMLArea.prototype._wordClean = function() { 
var D = this.getInnerHTML();
if (D.indexOf('class=Mso') >= 0) {

Is there class=Mso in your pasted html?

Hubertus
----------------------
CMS with HTMLArea (Username: testuser Password: test):
http://www.sundes.de/sundes_wcg/
HTMLArea direct(choose "Textinhalt"):
http://www.sundes.de/cgi-bin/sundes_wcg/egert.pl?layout&kundendir=gastzugang&idlog=RMNaNcMRMcLa2NP

http://www.sundes.de - http://www.hubertus-egert.de


_-FTH-_
Novice

Apr 22, 2004, 3:37 AM

Post #16 of 20 (7258 views)
Shortcut
Re: [hubertus] Tag Replacement [In reply to] Can't Post

How can i test that? where should i insert the alert("test") function?


hubertus
User

Apr 22, 2004, 3:42 AM

Post #17 of 20 (7256 views)
Shortcut
Re: [_-FTH-_] Tag Replacement [In reply to] Can't Post


Code
HTMLArea.prototype._wordClean = function() { 
alert("test1");
var D = this.getInnerHTML();
if (D.indexOf('class=Mso') >= 0) {
alert("test2");

Hubertus
----------------------
CMS with HTMLArea (Username: testuser Password: test):
http://www.sundes.de/sundes_wcg/
HTMLArea direct(choose "Textinhalt"):
http://www.sundes.de/cgi-bin/sundes_wcg/egert.pl?layout&kundendir=gastzugang&idlog=RMNaNcMRMcLa2NP

http://www.sundes.de - http://www.hubertus-egert.de


_-FTH-_
Novice

Apr 22, 2004, 3:45 AM

Post #18 of 20 (7254 views)
Shortcut
Re: [hubertus] Tag Replacement [In reply to] Can't Post

No, there isn't a class call MSO is that the problem? i did not change the class...


hubertus
User

Apr 22, 2004, 3:54 AM

Post #19 of 20 (7251 views)
Shortcut
Re: [_-FTH-_] Tag Replacement [In reply to] Can't Post

Hi,

the function calls _wordClean, cause its
cleaning code from MS Word.
The function at first looks if the pasted code
is from MS Word (if (D.indexOf('class=Mso') >= 0) {).
If this is false the function does nothing!!!
So if you want the function ever cleans your pasted code,
you have to remove this "if".

Code
HTMLArea.prototype._wordClean = function() { 
var D = this.getInnerHTML();
//if (D.indexOf('class=Mso') >= 0) {

...

//}
};

----------------------
CMS with HTMLArea (Username: testuser Password: test):
http://www.sundes.de/sundes_wcg/
HTMLArea direct(choose "Textinhalt"):
http://www.sundes.de/cgi-bin/sundes_wcg/egert.pl?layout&kundendir=gastzugang&idlog=RMNaNcMRMcLa2NP

http://www.sundes.de - http://www.hubertus-egert.de


_-FTH-_
Novice

Apr 22, 2004, 3:59 AM

Post #20 of 20 (7248 views)
Shortcut
Re: [hubertus] Tag Replacement [In reply to] Can't Post

That's it... Sorry, i'm new in these things... But now it works. Thx for help

 
 
 


Search for (options)