W3C home > Mailing lists > Public > public-html@w3.org > November 2007

Re: @contenteditable versus <richtext>

From: Jon Barnett <jonbarnett@gmail.com>
Date: Sat, 3 Nov 2007 23:34:01 -0500
Message-ID: <bde87dd20711032134i49b0113eqb8ab17c8fc3e5ff4@mail.gmail.com>
To: "Andrew Fedoniouk" <news@terrainformatica.com>
Cc: "Martin Atkins" <mart@degeneration.co.uk>, public-html <public-html@w3.org>

On 11/3/07, Andrew Fedoniouk <news@terrainformatica.com> wrote:

>
> <textarea> is declared currently as
>
> <!ELEMENT TEXTAREA - - (#PCDATA)
>
> So this:
>
> <textarea>
>    <p>Hello World</p>
> </textarea>
>
> works in all modern UA without any escapement.
> Thus it is possible to reuse <textarea> with additional attributes as
> a <richtext>:
>

I think browsers will still treat that as a single <textarea> element
with text content, not a textarea element with a p element child. See
[3].

And that's basically what I'm getting at - have a textarea element
whose value is a string of HTML code, but is presented to the user as
a rich text editor - again, basically what I do now with a set of
complex javascript and iframes.

>  >
>  > The only difference between the plain textarea and the one replaced
>  > with RTE is the way line breaks are handled.  When the form is
>  > submitted, a flag needs to be passed to let the server know if line
>  > breaks shoiuld be preserved (by converting them to <br> tags or
>  > heuristically placing <p> tags)
>  >
>
> I do not understand why do you need this. richtext aware application
> will get the value as a markup - pretty much in the same way as if you
> will submit html file by <input type="file">.
>

I didn't get very specific there.  Basically, a lot of forums such as
phpBB [1] or web sites that accept comments like Techdirt [2] allow
you to type plain text into a text area.  Paragraphs are separated by
line breaks, etc., but they also allow a set of HTML tags, like <a>,
<b>, etc.  Line breaks in your comment/post show up as line breaks on
the page.  ([2], for better or worse, replaces line breaks with <br>
tags).

If the user was presented with a Rich Text Editor, it's not safe to
assume line breaks in the HTML code are intended to be paragraph
breaks.  When the form is submitted, the server needs to know if the
submitted text is raw HTML because the user's browser supported
<textarea type="wysiwyg">, and that it shouldn't do anything heuristic
with line breaks.  (Again, [2], for better or worse has a radio button
to choose between "plain text" and "html" to handle this)

[1] http://www.phpbb.com/
[2] http://techdirt.com/articles/20071102/025323.shtml (sample site
that accepts comments, not an interesting article)
[3] http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C!DOCTYPE%20html%3E%0A%3Ctextarea%3E%3Cp%3Etest%3C%2Fp%3E%3C%2Ftextarea%3E
-- 
Jon Barnett
Received on Sunday, 4 November 2007 04:34:14 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 9 May 2012 00:16:09 GMT