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:
Default styles


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.

 


nlogic
Novice

Feb 20, 2003, 8:31 PM

Post #1 of 6 (6750 views)
Shortcut
Default styles Can't Post

Is there a way to automatically cause everything typed into HTMLarea to be given a predefined style? In other words, it seems to me that, even if styles are added via config.fontstyles and config.stylesheet, the user still has to actually select the style from the drop-down. Otherwise, if they just type in some text and then submit, the output will be like this, <P>some text</P>, rather than like this, <P><FONT class=MyClass>some text</FONT></P>. I'd like to set up HTMLarea so that anything that is typed, without the user having to select anything, is output like: <P><FONT class=MyClass>some text</FONT></P>. I thought maybe config.bodyStyle would have been the answer, but it seems to me that it affects only the appearance in the HTMLarea iframe, and doesn't alter the actual text output from HTMLarea. Please help!
Thanks


lvni900
User

Feb 21, 2003, 2:21 PM

Post #2 of 6 (6720 views)
Shortcut
Re: [nlogic] Default styles [In reply to] Can't Post

Just put <link rel="stylesheet" href="yourstylesheet.css" type="text/css"> in the <head> of your document.


nlogic
Novice

Feb 21, 2003, 2:49 PM

Post #3 of 6 (6717 views)
Shortcut
Re: [lvni900] Default styles [In reply to] Can't Post

I did that, eg the code below. But the result is still that the user must select the class from the HTMLarea select box in order for it to be applied. Unless I'm missing something...


Code
  

<script
language="Javascript1.2"><!--//load htmlarea
_editor_url="/dev/includes/htmlarea/";
var
win_ie_ver=parseFloat(navigator.appVersion.split("MSIE")[1]);
if(navigator.userAgent.indexOf('Mac')>=0){win_ie_ver=0;}
if(navigator.userAgent.indexOf('Windows CE')>=0){win_ie_ver=0;}
if(navigator.userAgent.indexOf('Opera')>=0){win_ie_ver=0;}
if(win_ie_ver>=5.5){
document.write('<scr'+'ipt src="'+_editor_url+'editor.js"');
document.write('language="Javascript1.2"></scr'+'ipt>');
}
else{
document.write('<scr'+'ipt>function editor_generate(){return false;}</scr'+'ipt>');}
//--
></script>

<script language="JavaScript1.2" defer>
var
config=new Object();//create new config object
config.stylesheet = "/Stylebook.css";
config.fontstyles = [
{
name: "Special_entry",
className: "Normal3",
classStyle: ""
}
];
editor_generate('entry',config);
</script>



lvni900
User

Feb 21, 2003, 5:15 PM

Post #4 of 6 (6709 views)
Shortcut
Re: [nlogic] Default styles [In reply to] Can't Post

In the configuration table, you can find the config.bodyStyle parameter. If set it will cause the style to be activated in your editor.

eg.

config.bodyStyle = 'background-color: #FF0000; font-family: "Trebuchet MS"; font-size: x-small;';


nlogic
Novice

Feb 21, 2003, 5:46 PM

Post #5 of 6 (6708 views)
Shortcut
Re: [lvni900] Default styles [In reply to] Can't Post

lvni900,

Thanks for all the suggestions. I'm afraid I tried that too, though (config.bodyStyle). I might be missing something, but although config.bodyStyle properly changes how text appears in HTMLarea, it doesn't seem to change the actual output.

That is, if I typed "some text" into the HTMLarea, the words "some text" would appear to have the style set in config.bodyStyle (for example, 'background-color: #FF0000; font-family: "Trebuchet MS"; font-size: x-small;), but only inside HTMLarea; when the form is submitted, the value returned is still "<P>some text</P>" when what I want returned is "<P CLASS='background-color: #FF0000; font-family: "Trebuchet MS"; font-size: x-small;>some text</P>" or "<P><FONT CLASS='background-color: #FF0000; font-family: "Trebuchet MS"; font-size: x-small;>some text</FONT></P>"


lvni900
User

Feb 22, 2003, 3:45 AM

Post #6 of 6 (6668 views)
Shortcut
Re: [nlogic] Default styles [In reply to] Can't Post

Now I think I see what you mean.

Either you'll have to embed the htmlarea generated code in a page which contains a link to your css in the head, either you'll have to write a function in editor.js that explicitly takes over the config.bodyStyle as attribute on your <P> tag.

 
 
 


Search for (options)