RE: Manageable and predictable text insertion

Thoughts inline

From: Olivier Forget [mailto:teleclimber@gmail.com] 
>Hi Ben, thanks for commenting on my email.
>
>On Mon, Nov 10, 2014 at 1:33 PM, Ben Peters <Ben.Peters@microsoft.com> wrote:
>>A novel approach, Oliver. I’m not sure we want to put the editor in an in-between state though. 
>
>I'm not sure what you mean by in-between state?

It sounds like you're saying that a browser would insert the text before the deletion happens. That's what I'm calling an in-between state.
Example:
Text in page: "Some Stuff"
Selected text: "Stuff"
User types: "a"
New Text in page: "Some aStuff" ***in-between state***
New Selected text: "Stuff"
Then the site can remove "Stuff"

This is backwards. We should instead have a "Replace" intention, with context data like the affected Range and the inserted Range.
Example:
Text in page: "Some Stuff"
Selected text: "Stuff"
User types: "a"
Intention Event: Replace "Stuff" with "a"
Site removes "Stuff" 
Current Text in page "Some "
Site does not call preventDefault() so browser replaces the now-empty selection with "a"
New Text in page: "Some a"

>>If we have a ‘replace’ intention, it seems like script should be able to overwrite ‘delete’ and ‘insert’ separately. 
> 
> Right, and that's the problem as I see it. Is there any precedent for overriding/canceling part of an event but not another part? That sounds problematic to me.
>
>>I prefer to keep things in order. For Replace, this means Delete and then Insert. Does that cover your use case below?
>
>Indeed we should split the "Replace" intent into two intents: "Delete" first, then "Insert" second when the user types over selected text. This would be a good thing.

Does my example above solve this in a single intention?

Received on Wednesday, 12 November 2014 17:26:27 UTC