Reputation: 1762
<p>
or <br />
after line breaks. When i remove these tags, CKEditor cannot recognize there's a line break.Purpose : I'm using a word counter plugin with CKEditor, so i need to use CKEditor as like a textarea. I need the plain text value.
I tried these so far :
CKEDITOR.instances.editor1.document.getBody().getText()
Yes i can get the text value correctly, i put this value on DB, but when i reload my page, the line breaks are gone. Because ckeditor works only with html tags ?
config.autoParagraph = false;
This one just removes the <p>
tag at the beginning of the content.
I need plain text+line breaks that's it. Any suggestions ? Or should i write down my own classes ?
Upvotes: 2
Views: 1607
Reputation: 15566
Array.prototype.map
.call(CKEDITOR.instances.editor1.document.getBody().$.childNodes,
function(item){
return item.innerText;
})
.join("\n");
Just a crazy answer to convert <p>
blocks to a string separated by \n
Upvotes: 2