editor.getPlainText()
Returns the editor’s content as plain text, with all HTML formatting removed. Use it for a text preview, a search index, an excerpt, or a character/word count — anywhere you want the words without the markup. It is also available under the alias editor.getText().
Syntax
editor.getPlainText()
Parameters
None.
Returns
The content as a plain-text string.
Behavior notes
- Rendered text, not raw markup.The result is the visible text of the content — block structure appears as line breaks, and formatting tags are dropped. For the HTML itself, use getHTMLCode().
getText()is an alias.editor.getText()andeditor.getPlainText()return the same value.- Round-trips with setPlainText.
editor.setPlainText(value)replaces the content with plain text the same way.
Example usage
Build a short excerpt for a list view:
var editor1 = new RichTextEditor("#div_editor1");
var text = editor1.getPlainText();
var excerpt = text.slice(0, 140) + (text.length > 140 ? "..." : "");Show a live character count:
console.log(editor1.getPlainText().length + " characters");Related
- editor.getHTMLCode()— the content as HTML.
- editor.getSelectedText()— plain text of just the selection.
- All editor methods— the full JavaScript API surface.