Search code examples
javascriptckeditor

Get Value of text including newline characters


I want to get number of characters entered in CKEditor. Here is my function which is being called within CKEditor events.

function EditorTextCount(editor)
{
   //var data = editor.document.getBody().getText();
   var data = editor.getData();
}

In the above function "editor" is the CKEditor object. When I use var data = editor.document.getBody().getText() I get the text inside editor without newline/enter characters. When I use var data = editor.getData() I get some extra special characters.


Solution

  • You can try use property innerText, if it will work for you.

    var data = editor.document.getBody().$.innerText