I want to build a lightweight online text editor like google doc, but quite quite lighter than that.
What I mean is, I only want to realize the following three functions:
- input/delete characters
- create/delete a new line
- indent
But I'm not quite sure how to build it.
Here is my idea:
Treat every line as a single div. Monitor the keyboard event, when user hit enter, create a new div
According to my method, I need to set the div's contentEditable=true However, after that, whenever I hit enter, a newline is created inside the div.
So, how to stop that? (can it only be solved by using javascript?) Or, is there any other way to achieve my goal?