http://jsfiddle.net/Y7tgx/2/
Firefox does this better than Chrome, but not quite the way I want. They combine all adjacent HTML tags together and treat them as one (which I don't want).
Firefox: when the cursor is left from the tag (or a group of neighboring tags), and you click to the right, the cursor jumps past the first character preceding the tag. Then, if you press left, it will move between the character and the tag. (Same thing for clicking left and right.)
Chrome: The tag and the first character following it are merged together. Cannot place cursor between tag and next character.
Required: The tag is processed as one character relative to the cursor. If the cursor is to the left of the tag, and you click to the right, it should go to the right of the tag and vice versa to click on the left.
How can I enter the desired behavior in the browser?
This is not intended for the WYSIWIG editor. To serve a specific purpose, tags are visually displayed in the production process in the same way as in jsfiddle. Users want arbitrary control over which element the cursor contains.
b:before, b:after, i:before, i:after, p:before, p:after { color: blue; } b:before { content: '<b>'; } b:after { content: '</b>'; } p:before { content: '<p>'; } p:after { content: '</p>'; } i:before { content: '<i>'; } i:after { content: '</i>'; } ---------- <p contenteditable='true'>regular regular<b>bold</b>regular - try moving the cursor to either side of either blue tag.</p> <p contenteditable='true'>try it in this: regular<b><i>bolditalic</i></b></p>
source share