Reputation: 1427
So I'm working with a content editable DIV and I want to implement a smart word breaking feature like you see in most word processors, sites like Medium.com, and in the very box I'm typing this into on Stack Overflow
What I mean by smart word breaking is that if you're in the middle of typing a word and you're about to hit the end of the div then it pushes the whole word down to the next line as opposed to just breaking off the word.
Any leads on how to do this?
Thanks!
Upvotes: 1
Views: 870
Reputation: 1425
What you're referring to is 'word wrapping', where the word is 'wrapped' to the next line. This is done automatically so if you're div is not doing this then you may have a problem somewhere else. The reason this happens is because a div
would word wrap normally even if it were not contenteditable
so it does this by default. One way it could be disabled from wordwrapping is if you have white-space: nowrap
in your CSS (more info at How to turn off word wrapping in HTML?), but this seems unlikely.
Upvotes: 1