Skip to content

Commit

Permalink
correct handling of deleted selections
Browse files Browse the repository at this point in the history
  • Loading branch information
charlieroberts committed Nov 28, 2024
1 parent c5df428 commit ead9547
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions bitty.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,17 @@ let bitty = window.bitty = {
bitty.el.appendChild( el )

setCaret( 0 )
}else{
const nodes = Array.from( bitty.el.childNodes )
for( let node of nodes ) {
if( node.localName === 'br' ) { // line break
const div = document.createElement( 'div' )
const pos = caret()
div.innerHTML = ' '
node.replaceWith( div )
setCaret( pos + 1 )
}
}
}
}, 10 )
}
Expand Down

0 comments on commit ead9547

Please sign in to comment.