[whatwg] Ongoing work on an editing commands (execCommand()) specification

Brett Zamir brettz9 at yahoo.com
Wed Mar 2 17:27:18 PST 2011


On 3/3/2011 3:18 AM, Aryeh Gregor wrote:
> On Tue, Mar 1, 2011 at 5:11 PM, Ryosuke Niwa<rniwa at webkit.org>  wrote:
>> Styling a Range doesn't support styleWithCSS=false
> I saw this feature in Mozilla's docs, but I don't really get it.  What
> use-cases does it have?  Why do we need to support both ways of doing
> things if they create the same visible effect?

Maybe the use of non-CSS mode was for backward-compatibility with 
earlier versions or for easier overriding of styling in the target 
document (e.g., "b {color:red;}").

Using CSS might have been added by Mozilla since the predefined commands 
are formatting-specified (e.g., it is a "bold" command not a "strong" 
one), so in the absence of a semantically-based API, it is technically 
more accurate for the resulting code to be non-committal about semantic 
meaning (there is always "insertHTML" if you need semantically-accurate 
(WYSIWYM) mark-up internally). (Granted in Mozilla, the non-CSS version 
is also non-committal in producing <b> rather than <strong>, but perhaps 
it was seen at the time that such mark-up was out of favor and expected 
to be soon out the door?)

In any case, spans with inline styles are much less likely to conflict 
with other styling, but on the other hand, they do not provide granular 
control, unless perhaps classes were also to be added to these spans to 
indicate the formatting (<span class="bold">)--one case where it might 
be actually reasonable to use non-semantic class names--and allow CSS in 
the document to target these classes.

If one wishes to allow convenient export of the internally generated 
mark-up for the sake of the user (e.g., to allow them to copy the markup 
for use on their own site), it is nice for there to be choice at least 
between non-formatting-committal (semantic) markup and 
non-semantically-committal (formatted) mark-up, although I could 
understand if people wanted to force the more rare WYSIWYM editor to use 
insertHTML to handle such cases.

Brett




More information about the whatwg mailing list