Bold text in textarea

I am trying to write a very simple wysiwyg editor where users can simply add bold text, hyperlinks and markers, after selecting part of the text. In fact, like CKEditor.

But as far as I know, there is no way to add formatting to the text box. Therefore, I would like to know how other wysiwyg editors like CKEditor solve it.

+3
source share
4 answers

Browser-based WYSIWYG editors work by generating HTML code for the document / text you are editing. In other words, you are essentially editing the HTML inside the browser, not the text in TEXTAREA. You might want to take a look at the source code for Rich Text Editor and check out the Mozilla Midas Specification before you start writing everything from scratch.

+4
source

Well, that doesn't answer the question of how they do it, but you can apply style to the text area. Just try:

<textarea style="font-weight:bold;"> </textarea>

, , CKEditor, , javascript css, <div> <textarea>. MS AJAX. , CKEditor, , <div>.

+5

contenteditable. Google

+2

WYSIWYG, TinyMCE, JavaScript, , textarea html .

What the javascript editor really does is add the appropriate html tags, such as <b> or <i> to the content of the text.

Therefore, when you send the contents of the WYSIWYG editor to the server, you usually get html.

+1
source

Source: https://habr.com/ru/post/1756286/


All Articles