Skip to content

Commit

Permalink
fix deleting bulleted line
Browse files Browse the repository at this point in the history
  • Loading branch information
jhchen committed May 22, 2014
1 parent 016c11a commit bbfcdb1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/document.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class Document
lineNode = lineNode.firstChild if lineNode? and DOM.LIST_TAGS[lineNode.tagName]?
_.each(lines, (line, index) =>
while line.node != lineNode
if line.node.parentNode == @root
if line.node.parentNode?
# New line inserted
lineNode = Normalizer.normalizeLine(lineNode)
newLine = this.insertLineBefore(lineNode, line)
Expand All @@ -98,7 +98,11 @@ class Document
lineNode = Utils.getNextLineNode(lineNode, @root)

removeLine: (line) ->
DOM.removeNode(line.node) if line.node.parentNode == @root
if line.node.parentNode?
if DOM.LIST_TAGS[line.node.parentNode.tagName] and line.node.parentNode.childNodes.length == 1
DOM.removeNode(line.node.parentNode)
else
DOM.removeNode(line.node)
delete @lineMap[line.id]
@lines.remove(line)

Expand Down
4 changes: 4 additions & 0 deletions test/unit/editor.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ describe('Editor', ->
initial: ['<p>0123</p>']
expected: ['<p>0123</p>']
index: 4, length: 1
'bulleted line':
initial: ['<p>0</p><ul><li><br></li>']
expected: ['<p>0</p>']
index: 2, length: 1

_.each(tests, (test, name) ->
it(name, ->
Expand Down

0 comments on commit bbfcdb1

Please sign in to comment.