Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #25877
| From | "Jukka K. Korpela" <jkorpela@cs.tut.fi> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: new line in a contentEditable div |
| Date | 2014-10-03 16:21 +0300 |
| Organization | A noiseless patient Spider |
| Message-ID | <m0m7s9$s6p$1@dont-email.me> (permalink) |
| References | <4b3afe79c9bbea3371221c48e0b0690a346b72d8@news.nemoweb.net> |
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/
Back to comp.lang.javascript | Previous | Next — Previous in thread | Find similar | Unroll thread
new line in a contentEditable div Julien Arlandis <julien.arlandis@laposte.net> - 2014-10-03 11:33 +0000
Re: new line in a contentEditable div JJ <jj4public@vfemail.net> - 2014-10-03 19:46 +0700
Re: new line in a contentEditable div Julien Arlandis <julien.arlandis@laposte.net> - 2014-10-03 13:13 +0000
Re: new line in a contentEditable div JJ <jj4public@vfemail.net> - 2014-10-04 09:29 +0700
Re: new line in a contentEditable div Julien Arlandis <julien.arlandis@laposte.net> - 2014-10-04 06:09 +0000
Re: new line in a contentEditable div "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-10-04 08:47 +0200
Re: new line in a contentEditable div JJ <jj4public@vfemail.net> - 2014-10-04 21:34 +0700
Re: new line in a contentEditable div Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-10-22 20:09 +0200
Re: new line in a contentEditable div "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-10-03 15:00 +0200
Re: new line in a contentEditable div Julien Arlandis <julien.arlandis@laposte.net> - 2014-10-03 13:18 +0000
Re: new line in a contentEditable div "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-10-03 16:23 +0200
Re: new line in a contentEditable div Julien Arlandis <julien.arlandis@laposte.net> - 2014-10-03 15:16 +0000
Re: new line in a contentEditable div "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-10-03 18:28 +0200
Re: new line in a contentEditable div "Christoph M. Becker" <cmbecker69@arcor.de> - 2014-10-03 18:54 +0200
Re: new line in a contentEditable div "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-10-03 19:07 +0200
Re: new line in a contentEditable div "Christoph M. Becker" <cmbecker69@arcor.de> - 2014-10-03 19:32 +0200
Re: new line in a contentEditable div "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2014-10-03 16:21 +0300
csiph-web