[whatwg] Proposed updates for the command API's

----- Original Message ----

From: Ian Hickson <ian@hixie.ch>

> Why not do:
>   function showInfo() {
>     // do whatever you want with elements
>     // ...
>  }

So what about if I did a document.execCommand('bold') on that selection?
I wouldn't be able to get the new <B> elements with the above.

>> It seems like you can already do this in a more flexible manner with the 
>> current selection, range and traversal features, no?

Without walking that selection twice and check to see what was new.
Sounds like a waste of performance to me.

>> AFAIK, a selection object gives you the data about some of the elements, 
>> but not all of the containing elements (especially in the situation I 
>> have as an example on the site).

> I'm not sure I understand what you mean.

Using the walking technique above, I could get the elements in the range.
However, the modifiedNodes property should still work for:
execCommand('inserthtml', '<b>Bold</b> <em>Em</em>');
execCommand('insertimage', 'URL');
execCommand('insertANYTHING');

Then when there is no selection, I can still tell what items were added to the document via execCommand.

>> There is also the use case of someone selecting part of a node (like in 
>> between tags) and executing a command, some commands will auto select 
>> the node others won't.
>>
>> The modifiedNodes command would allow us to get that data.

> But why would you need that data? (This is different from the "show 
> information about the selection" case you mentioned earlier.)

As an implementer of a WYSIWYG editor, I would use this all the time:
     Inserting an Image and having a reference to it.
     Inserting HTML, then being able to filter the content.
     Hopefully capturing the change from a paste event so I can fix/filter the content.

Does that make more sense?
Dav

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'

Received on Wednesday, 13 August 2008 15:49:01 UTC