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

Tim Down timdown at gmail.com
Tue May 31 01:30:15 PDT 2011


On 31 May 2011 09:15, Markus Ernst <derernst at gmx.ch> wrote:
> 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

Aryeh's own example implementation script accompanying the execCommand
spec has several of these (block-extending a range, decomposing a
range and performing DOM manipulation while preserving ranges, for
example). See http://aryeh.name/spec/editcommands/implementation.js

Tim


More information about the whatwg mailing list