Voog / wysihtml

Open source rich text editor for the modern web
http://wysihtml.com
MIT License
3.36k stars 338 forks source link

Deleting text using BACKSPACE into control selection deletes DIV container #319

Open foo6 opened 8 years ago

foo6 commented 8 years ago

Only with IE,when we deleting the text using BACKSPACE into control and reach the start point of the control content, an extra BACKSPACE will to delete the DIV container.

damsorian commented 7 years ago

I have the same issue

damsorian commented 7 years ago

You can try this temporal fix:

$(function() {
  var placeholder = 'Enter text ...';
  var contentFix = '<span></span>';
  $('.wysihtml-editor')
    .on('blur', function(event) {
      if (event.target.innerHTML === contentFix) {
        $(this).html(placeholder);
      }
    })
    .on('focus', function(event) {
      var text = event.target.innerText;
      if (text === '' || text === placeholder) {
        $(this).html(contentFix);
      }
    });
});