Hi,
Is there any way to get the text content inside the text area of Editor without html…? Currently the getContent() function gives you the text with the formatting.For a particular section of my work,I need the unformatted text content.
Thanks in advance !
Editor API doesn’t allow to get text conent. You can try to use JavaScript methods to replace all html tags with white spaces. For example:
var html = editor.getContent();
var text = html.replace(/<[^>]*>/g,’ ‘).replace(/ +/g,’ ');
I had a similar issue where I only wanted the text so I modified my local version of dhtmlxEditor.js and added the getContentText method (for IE you can use .innerText property directly).
Not sure if this is the correct (or “official”) way, but it worked for what I needed.
/**
* @desc: gets html text content of editor document
* @type: public
* @topic: 1
/
this.getContentText = function(){
if(!this.edDoc.body)
return “”;
else{
if (_isIE)
{
return this.edDoc.body.innerText;
}
return this.edDoc.body.innerHTML.replace(/<[^>]>/g,’ ‘).replace(/ +/g,’ ');
}
}
Thank you for the provided method. Possibly we will add the similar method to the next editor realese.