woofmark icon indicating copy to clipboard operation
woofmark copied to clipboard

Firefox bug: Images are not being appended to current cursor position

Open slwen opened this issue 8 years ago • 2 comments

When inserting an image in WYSIWYG mode it should display at the users current cursor position.

Currently the cursor position appears to be ignored and the image is inserted at the top. Here's an example:

example

Firefox v41.0.2 on OS X (El Capitan)

screen shot 2015-10-16 at 1 33 31 pm

slwen avatar Oct 16 '15 03:10 slwen

As an update for this I've found a work-around that I'm currently rolling with in Firefox and it appears to be fine in other browsers too, though I suspect the root cause of this problem has something to do with the regex matching being a bit off inside of src/getSurface.js. It seems to split text chunks incorrectly when it encounters <br> tags.

The work-around is to force Firefox content editable divs (WYSIWYG mode) to insert <p> tags rather than <br> when the user hits the enter key. This seemingly brings it in to line with Chrome and IE.

Here's some example code I use after instantiating a woofmark editor:

wysiwygElement.addEventListener('keypress', function(e) {
  if (e.keyCode == '13' || e.which == '13') {
    document.execCommand('formatBlock', false, 'p');
  }
}, false);

slwen avatar Oct 26 '15 05:10 slwen

@slwen Would that change still work in Chrome/IE?

bevacqua avatar May 26 '16 15:05 bevacqua