The Mozilla
Organization
Our Mission
Who We Are
Getting Involved
Community
Editorials
What's New
Newsbot
Development
Roadmap
Module Owners
Blue Sky
Projects
Status
Tools
Products
Source Code
Binaries
Documentation
License Terms
Bug Reports
Quality
Search
Feedback


Ender HTML Typing Rules


Here is the current thinking on the typing rules for the HTML editor.  Note that these are different from the Plaintext editor rules, and there may someday be yet another flavor of editor rules for a a more style-savvy editor.  The purpose of these editor rules are to give a word processing feel to the user editing HTML documents, such as in a mail compose window.

Space Rules:

"Word" refers to any run of non-whitespace characters.  All sorts of things count as non-whitespace characters, including inline images and nbsp's.  Whitespace is a space, tab, or newline (plus a funky zero-width whitespace character).
 
Selection State
Results
collapsed; in a block with style white-space: PRE space inserted
collapsed; in the middle of a word space inserted
collapsed; after a word and before whitespace nbsp inserted
collapsed; after whitespace before a word existing space replaced with nbsp+space
collapsed; surrounded by whitespace nbsp inserted
non-collapsed delete the selection range(s) and obtain a collapsed selection, then same as above
not covered by above space inserted


Tab Rules:

In the tab rules, N is the tab width, which is based on a user pref.
 
Selection State
Results
collapsed; in a table cell other than the last set selection to next table cell
collapsed; in the last table cell insert new table row and set selection to first cell in last row
collapsed; in a block with style white-space: PRE tab inserted
collapsed; in the middle of a word insert N-1 nbsp's followed by a space
collapsed; after a word and before whitespace insert N nbsp's
collapsed; after whitespace before a word existing space replaced with N nbsp's+space
collapsed; surrounded by whitespace insert N nbsp's
non-collapsed; no portion of table selected delete selection then apply collapsed selection rule
non-collapsed; inside single table cell as if collapsed selection in that cell
non-collapsed; not contained in single table cell do nothing
not covered by above insert N nbsp's


Return rules:

"Block parent" refers to the first ancestor of the node (or the node itself) that has block formatting; in other words, that is not inline.  A collapsed selection is assumed for the return rules.
 
Selection State
Results
Block parent has white-space: PRE insert a newline character
Block parent is  {OL,UL} close any <LI> we are in, insert new <LI>
Block parent is <DL> if in <DT>, close <DT> and insert <DD>
if in <DD> insert <BR>
else insert a <DT>
Block parent is one of: {H1, ... H6} close block
Block parent is one of: {P, BODY, DIV, NOSCRIPT, BLOCKQUOTE, ADDRESS}
no <BR> tags are adjacent to insertion point
insert a <BR>
Block parent is <P>
a <BR> tag is adjacent to insertion point
 
remove <BR> then split <P>, with contents before insertion point in first <P> and the rest in the second <P>
Block parent is one of {BODY, DIV, NOSCRIPT, BLOCKQUOTE, ADDRESS}
a <BR> tag is adjacent to insertion point
 
remove <BR> and insert <P>
not covered by above insert a <BR>


Backspace Rules:

A collapsed selection is assumed for the backspace rules.
Note that if I don't mention a tag below, it is considered inline and deletion moves through it (such as the <A> tag, for instance).
 
Selection State
Results
after a nbsp-space combination (in same block parent) replace nbsp-space with space
after non-whitespace (in same block parent) delete previous character
after the close of <TABLE> do nothing
between <TD>s, or at beginning of <TD> do nothing
after close of {HR, IMG, BR, MAP, OBJECT, form element} delete element
after close of {DIV, BLOCKQUOTE, NOSCRIPT, ADDRESS, FORM} pretend you are in same block, i.e., text inside these counts as if it were in your same block for deletion purposes
after </P><P> join <P>s, insert <BR>
between two like elements that are one of {H*,LI} join elements
not covered by above do nothing

Forward delete rules will be similar to backspace rules (only deleting forwards, of course).

If you backspace/delete completely through an inline block, that block will be removed.  But the editor will remember the "typing style" of your cursor location, so if you backspace up to the last character of, say, a <b> tag, but no further, and then type again, the <b> will be reinserted and text you type will be bold (modulo your style sheet).

The HTML editor is not style sheet savvy and no plans are made for any of the typing rules to use style to make rules decisions except for the determination of the white-space: PRE style.


Last modified Fri Apr 16 1999
jfrancis@netscape.com



Copyright © 1998 The Mozilla Organization.