2014-10-03 14:33, Julien Arlandis wrote:
> If i insert a line break into this contentEditable div :
>
> <div class="a">I insert a line break ^ here</div>
>
> I get the result :
>
> <div class="a">I insert a break <br> here</div>
The contenteditable="true" attribute has been defined just as making the
element content editable by the user. The user interface has been left
browser-dependent. This also applies to handling Enter, which actually
varies a lot. Some browsers generate br elements, some generate div
elements, and some generate p elements, etc.
> But I want :
>
> <div class="a">I insert a break</div>
> <div class="a">here</div>
What you need to do is to process the element content after user edits
and, if needed, modify it. Then you can, for example, split a div
element if it contains a br element. I won't write the code for you,
mainly because I don't know what you want as a whole. In addition to
tactical questions like dealing with a br element, you need a strategy:
what are you going to do with the element as modified user input, and if
it is to be converted to some specific canonical format, what exactly is
that format.
Note that user input may, for example produce b and i elements in the
content. It may also contain links etc., at least if it was copypasted.
--
Yucca,
http://www.cs.tut.fi/~jkorpela/