I would like to create a very simple WYSIWYG text editor that would only allow the user to italicize or bold the text.
I was using a simple div with contentEditable but users could paste formatted text or format text using their browser features.
What I want is more like a textarea with bold or italic text inside…
I heard about a technique of hidden textarea but I didn't really understood how it works (how the user can change the cursor position…)

有帮助吗?

解决方案

Im putting this as a more formal answer


You can basically use ckeditor here and as Renmar suggested, you can disable buttons which disable formatting features. e.g:

  • Disabling Bold and Italic will remove any bold and Italic formatting on preformated text

You can experiment here in the text editors where some features have been disabled

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top