Skip to content

Loading…

Webkit browsers insert DIV after closing UL #48

Closed
sitesense opened this Issue · 1 comment

3 participants

@sitesense

Normally when creating a new line by pressing enter, a new paragraph is created.

If you press enter twice after an unordered list to create a new line, Webkit browsers will insert a DIV element instead of a paragraph.

There is a fix for this in the formatNewLine function, however if the element that you transform into the editor (in my case a div) already has a class name, the function won't work because the class name no longer matches in this line:

if (parent.nodeName === 'DIV' && parent.className === 'redactor_editor')

Changing this line as below will fix this issue:

if (parent.nodeName === 'DIV' && parent.className.indexOf('redactor_editor') >= 0)

There is also another issue in that depending on the css that the editor is using, Webkit browsers may insert more than an empty DIV. In my case the line below is inserted after a closing UL instead:

<div><span style="line-height: 18px;"><br></span></div>

Therefore this line never matches and the cleanup fails:

if (element.get(0).tagName === 'DIV' && (element.html() === '' || element.html() === '<br>'))

I don't think it's really necessary to check the contents of the new line, so perhaps we can safely replace this line with the code below:

if (element.get(0).tagName === 'DIV')
@agis-

@sitesense What browser/version are you using? Your first proposed fix didn't work for me. When I press enter after

    I get this markup:

<p>
  <ul>
    <li><font color="#404040">hi there</font></li>
  </ul>
  <div>
    should be paragraph
  </div>
</p>
@html5cat html5cat closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.