javascript - How to stop contentEditable="true" inserting <div> instead of <p> when pressing return? -
i have div
<div contenteditable="true"> <h1> headline</h1> </div>
if editing text inside <h1>
tag, , press return, adds new div under, instead of normal paragraph tag inserts when entering return
making it:
<div contenteditable="true"> <h1> headline edited</h1> <div> tapped return</div> </div>
what want is
<div contenteditable="true"> <h1> headline edited</h1> <p> tapped return</p> <p> return again</p> </div>
whats strange when write somewhere , press return adds new <p>
, not when editing <h1>
. possible fix javascript/jquery/html5?
i using safari on ios-device
adding format blocker inside onkeyup p force contenteditable (div) add <p>
tag on return.
editable.onkeyup = (e)=> { e = e || window.event if (e.keycode === 13) document.execcommand('formatblock', false, 'p'); }
Comments
Post a Comment