Re: [selection-api] caret-based selection movement (#27)

>And what is the intermediate step? To the user, these two situations will look the same:
>```
><p>Hello <i>Austria</i>|</p> and <p>Hello <i>Austria|</i></p>
>```
> so it seems it would be reasonable that they will behave the same as well.

I am not sure each of these should behave the same. In the first, the subsequently typed text should not be italic, in the second it should be italic (because it is inside the `<i>`.)

In practice they won't look the same either because the editor UI usually provides feedback on the style about to be used by showing the style buttons as pressed (the [i] button would be "pushed/on" in the second case.)

>If the user hits the right-key and then enters a "!", where should that end?
>```
><p>Hello <i>Austria</i>!|</p> or  <p>Hello <i>Austria!|</i></p> ?
>```

I think the default behavior should mimic existing paradigms for editing UIs, so I played with a couple of existing "standard" rich text editors to see how they behaved (Mac's textEdit and Google "Docs".) The result I have so far is as follows. (assume we have entered 'Hello Austria!', and the country name is italic)
- place caret to the left of 'A' in Austria, and type. result: text typed is not italic.
- place caret to the right of 'a' in Austria (end of word). result: text typed is italic.

With this we can say that the default position of the caret when the user places it at the beginning of an element like `<i>` is that it is outside that element. When placed at the end of the element, it is inside the element. See the two pipes in the markup below:
```
<p>Hello |<i>Austria|</i></p>
```

This "default" position for caret should be in effect when user presses arrow keys to move caret around and when the user clicks the mouse to place the cursor at the edge of an element.

By the way it turns out this is already the default behavior on the browsers I tested (Safari, Chrome, FF, IE11).

---
Reply to this email directly or view it on GitHub:
https://github.com/w3c/selection-api/issues/27#issuecomment-65732595

Received on Friday, 5 December 2014 01:08:31 UTC