How to set caret/cursor position in a contenteditable div between two divs.

后端 未结 3 621
别跟我提以往
别跟我提以往 2020-12-10 17:36

Consider the following contenteditable div.

bold text
bold text
3条回答
  •  爱一瞬间的悲伤
    2020-12-10 18:00

    My answer will be just an addition to Tim's one, which is comprehensive.

    AFAIK Facebook doesn't use content editable. Status box is made of a simple textarea and div layer underneath it on which they render blue rects for nicks.

    Although, even if they did, that would be a different case, because nick would be an inline element and luckily with inline elements situation is simpler :).

    Regarding positioning caret at inaccessible places - at CKEditor we had the same problem. There are many places where user can't move caret. We decided to solve this issue with a plugin called Magic-line. As you can see in the demo we bypassed the problem with selection completely and I think that this is the best way to solve this issue. It's very usable and in CKEditor 4.0.1 it will be (and already is on master) also fully accessible by keystrokes.

提交回复
热议问题