How to create a simple WYSIWYG text editor without contentEditable or designMode?

StackOverflow https://stackoverflow.com/questions/22156169

  •  19-10-2022
  •  | 
  •  

Вопрос

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