[whatwg] Generalized execCommand() alternatives, or standardized selection and range handling

While following the discussions about Aryeh Gregor's great work on 
execCommand(), I get the impression that this method is very limited to 
some basic formatting actions. It provides shortcuts for a limited set 
of DOM actions, but is not really extendable or generalizable.

Some of the discussions were about adding support for new elements, such 
as <header> and <section>, or for distinctive <i> and <em> resp. <b> and 
<strong> elements. I doubt that extending execCommand() with specific 
new commands for more elements would be the direction to go.

With the focus on HTML editing rather than WYSIWYG editing, some kind of 
generalized wrapping/unwrapping mechanism would be helpful. This could 
be handled with a new method that offers shortcuts for 
wrapping/unwrapping selections; some kind of addWrapper(elementName) and 
removeWrapper(elementName).

Anyway, everything we need is actually available in the DOM, except a 
standardized and simple handling of selections and ranges. (Well, I 
might be wrong - but looking at the Gecko DOM reference and the MSDN 
DHTML reference, they show very different approaches to the range and 
selection objects, and the code of TinyMCE shows lots of browser 
sniffing.) I'd find it very helpful as an addition to Aryeh's work, to 
get standardized methods for actions like:
- creating a range out of a selection
- block-extending the range
- accessing all child elements of the range
- accessing all parent elements of the range
- memorizing start and end points in order to reset the selection after 
modifications
(This list may not be complete.)

I'd be happy about some thoughts on this.

-- 
Markus

Received on Tuesday, 31 May 2011 01:15:20 UTC