woofmark
woofmark copied to clipboard
Firefox bug: Images are not being appended to current cursor position
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:
Firefox v41.0.2 on OS X (El Capitan)
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 Would that change still work in Chrome/IE?