It is necessary to make the user copy the text from MSWord and paste it into the input field.

Wherein:

  1. After insertion (Ctrl + V), each paragraph was automatically framed in <li></li> (it seemed to cope with this, but it is not clear why an empty <li></li> is displayed at the end of the inserted text).

  2. The user could edit the entered text directly in the same field (now it is not very correct).

  3. The user could insert text from MSWord (at the moment it can be done, but only if we insert text instead of the existing one, and not in addition to it).

That's what stuck:

 $('#input').bind('input', function () { $(this).val('<li>' + $(this).val().replace(/\r?\n/g, '</li>\n<li>') + '</li>'); }); 

I tried a lot, it did not help.

Fiddle: http://jsfiddle.net/kutepovfedor/7VtGs/2/

  • I thought about doing something like this: var isCtrl = false; $ (document) .keyup (function (e) {if (e.which == 17) {isCtrl = false;}}). keydown (function (e) {if (e.which == 17) {isCtrl = true ;} if (e.which == 86 && isCtrl == true) {$ (this) .val ('<li>' + $ (this) .val (). replace (/ \ r? \ n / g, '</ li> \ n <li>') + '</ li>');}}); but it does not work out exactly and it does not work correctly jsfiddle.net/kutepovfedor/7VtGs/3 - lommusic
  • and than you paste event does not suit? - zb '
  • Tried a paste event, the problem is as follows: $ ('# input'). Bind ('paste', function () {alert ($ (this) .val ());}); the alert displays a string that was already in the field, but there is no new (inserted) one, the alert will show it at the next insertion event. Perhaps there is a way to make the text immediately inserted into the alert, in addition to the existing ... - lommusic
  • So, rummaged on a fresh mind, that's what happened: jsfiddle.net/kutepovfedor/7VtGs/4 But now with each insertion, the same replacement of symbols is applied to an already existing text. It is necessary that the formatting be applied only to the inserted text. By the way in IE does not work = ( - lommusic

0