Re: wysiwyg editors

Andrew Tetlaw <[email protected]> Fri, 25 Jun 2004 09:40:40 +1000
Newsgroups gmane.comp.windows.devel.netwindows
Message-ID <OFF4A625E5.A25EB4D8-ON4A256EBD.007CD026-4A256EBD.00821664@bvn.com.au>
[email protected] wrote on 24/06/2004 11:07:40 PM:

> > Don't forget the worthwhile: HTMLArea 3
> 
> Hrm... very nice. Thanks for pointing it out.

No worries! I like HTMLArea 3 because the API is easy to use. It has a 
plugin API too which is spiffy. But it means it's easy to add your own 
buttons to do things the way you want.

> 
> Looks like it tries to produce XHTML too, even though it doesn't
> advertise that.

Like most of them HTMLArea is a wrapper around the rich text editors 
supplied by the two platforms. Most of the editor output comes from the 
client platform not from the javascript library. The Moz editor, 'Midas', 
does try to use XHTML but neither are really any good IMHO.

> Well, <br /> anyway - it does produce depreciated <font>
> tags and according to the forum does no-nos like nesting <table>s inside
> <p>s. 

The font tags are produced by IE always and Moz only if use CSS is off. If 
useCSS is on then Moz will use a span and an inline style.

There are differences between the standard behaviour of editors in IE and 
Moz. For example doing a simple execCommand('bold') in both doesn't always 
do the same thing:

IE : '<strong>bold</strong>'
Moz - (default): '<span style="font-weight: bold;">Bold</span>'

However if you execCommand('useCSS', false, false), with which you can 
toggle between outputting the above 'span' (if last arg is true) based 
markup and:

Moz - (useCSS off): '<b>Bold</b>'

This causes problems for me because if I have a piece of text edited in 
IE, it cannot be edited in Moz; Moz can't unbold what was made bold in IE. 
Furthermore if I have useCSS on in one Moz client and make text bold, in 
another Moz client with useCSS off I can't unbold it either.

For me this kind of throws a wet blanket over the whole rich-text editing 
thing. Play with the examples in both clients and compare the HTML output.

Unless you do not use the default markup and instead make your own, which 
HTMLArea lets you do quite easily. In the above case I'd put:

var config = new HTMLArea.Config();
config.registerButton({
        id        : "my-bold",
        tooltip   : "Bold", 
        image     : "bold.gif",
        textMode  : false,
        action    : function(editor) {
                editor.surroundHTML("<strong>", "</strong>");
        }
  });

That way I'm always sure the markup produced is consistant in all clients. 
BUT if course then implementing buttons to do things like 
indent/outdent/tables and so on without relying on the platform editors 
default behaviour is quite a chore. So I think most people just put up 
with what ever the editors output just don't think about it.

I've used the editor on my company's Intranet but I've limited it to 
Headings/bold/italic and lists. Anything else puts too much crap in with 
the data and it'd mean I'd loose control of the presentation of the 
content (i.e. definately don't want font tags or even inline font styles 
in body text).

I've even started to think the wiki style of markup is a better solution! 
Although my users (who are all architects and designers) might not think 
that aesthetically pleasing enough :)
 
> How strict is netWindows about XHTML? Does a document have to be valid,
> or just well-formed?
> 
> M 
> 


Cheers,
Andrew Tetlaw

Bligh Voller Nield
http://www.bvn.com.au
p: (07) 3251 5778
f: (07) 3852 2544


<font face="Arial, Helvetica, sans-serif" size="2">
<b>
Please Note
</b>This document, including attachments, is only intended for the addressees and may contain privileged or confidential information. Unauthorised use, copying or distribution of the document or any part of its contents, is prohibited. If you receive this Email in error please notify us by return Email or telephone. We will reimburse you for any reasonable expenses incurred in meeting this request.</font> 


_______________________________________________
The netWindows developers list: [email protected]
http://netwindows.org/mailman/listinfo/devel_netwindows.org