5

I would like to leave user to make rich text with tinymce and save it in db, but also I want to save plain text version.

Does tinymce provide such option?

Thariama
  • 50,002
  • 13
  • 138
  • 166

2 Answers2

2

No, tinymce is designed to create HTML/rich text. But you are free to grad the plain text content of a tinymce editor and save it yourself.

There you go:

var plain_text = $(ed.getBody()).text();
Thariama
  • 50,002
  • 13
  • 138
  • 166
  • 1
    Great. So could we possibly take this further? I'd like to get the text content, but preserving "line breaks" - meaning I want every `
    `, `

    `, and other block level elements to translate appropriately to a new line. This content should then be able to sit in a `

    – Ifedi Okonkwo Jun 30 '16 at 12:42
1

You can get plain text using this code:

var plainText = tinyMCE.activeEditor.getBody().textContent;

ALso you can get html text using this one:

var richText = tinyMCE.getInstanceById('textAreaID').getContent();
Peter T.
  • 8,757
  • 3
  • 34
  • 32
  • Great. So could we possibly take this further? I'd like to get the text content, but preserving "line breaks" - meaning I want every `
    `, `

    `, and other block level elements to translate appropriately to a new line. This content should then be able to sit in a `

    – Ifedi Okonkwo Jun 30 '16 at 12:42