[Mozile] A try to enhance mozile to handle newlines and whitespaces

Josef Hahn j-hahn at gmx.de
Thu Apr 13 15:46:16 EDT 2006


Hi,

based on the discussion "Smoothing out spaces" in August 2005 and the 
ideas I read in the archive, I tried to change moziles handling of 
newlines. I want to use moziles inline editing capabilities to make 
selected tags of a page editable like this:

<h1 id="editor1">Edit this headline</h1>
<p id="editor2">Type in your text here</p>

So I can provide kind of templates for example in a CMS: The user should 
type in his text in this editors (linefeeds should be possible). With 
this method the text contents don't have to be filled in formfields 
(this is the old school way in CMS templates) but can be edited in the 
layouted webpage. So it would be possible to create pre-layouted and 
structured inline templates that allow the user to change the text but 
permit them to change the layout (or style) of the edited text.

You can test my first steps here:

http://www.buero-hahn.de/mozile/

Instead of splitting a node (the node is the mozile editor!), I'm 
inserting <br>-childnodes when the 'enter'-key is hit inside of an 
editable tag. So it is possible to type in a text with numerous 
linefeeds inside a html tag.

As I said, this is my very first attempt to change mozile to this 
behaviour. There are a few problems right now:

1. when the toolbar is switched off (setting in mozile.js is set to 
false) the added newline functionality behaves totaly weird, I don't 
know why. So please don't use the toolbar even it is shown.

2. the most serious (and strange) problem right now: move the caret in 
the middle of the first line, hit the 'enter'-key -> the first line is 
splitted an the caret is positioned at the beginning of the second line, 
then move the caret with the left arrow key to the last position of the 
first line and hit enter again -> an javascript error occurs.

So I had to add a workaround for this case (moving the caret at the end 
of a line), because Firefox seems to loose the node level when moving 
the caret backwards (take a look at the field "current nodname" on my 
demonstration page): Firefox says, the caret is in the DIV-node when 
moving out of the #text node of the second line trying to reach the next 
#text node at the end of the first line. But the DIV node is the parent 
node of the two #text nodes (text in line 1 and line 2) so it is one 
level up in the DOM tree.
My solutions works fine when characters are typed in, but fails when you 
hit the 'enter'-key at the end of the first line a second time (the 
caret has to be moved there with the left cursor key).

If someone out there thinks, this way to use mozile would be worth to 
take a look at the described bugs, I would be very glad for help or 
ideas who to solve these problems.

TIA and regards, Joe


More information about the Mozile mailing list