4

I am using ckeditor to compose the emails, I am using the html generated by it to send the html emails ad i also need the text version also, So having both html and plain text version in emails will avoid the spam.

What is the way to get the text from ckeditor html code in java.

1 Answer 1

11

This is quite simple JavaScript call:

CKEDITOR.instances.yourEditorInstance.getData() 

Returns:

<h1>Apollo 11</h1>    
<p><b>Apollo 11</b> was the spaceflight that landed the first humans, Americans <a href="http://en.wikipedia.org/wiki/Neil_Armstrong" title="Neil Armstrong">Neil Armstrong</a> and <a href="http://en.wikipedia.org/wiki/Buzz_Aldrin" title="Buzz Aldrin">Buzz Aldrin</a>, on the Moon on July 20, 1969, at 20:18 UTC. Armstrong became the first to step onto the lunar surface 6 hours later on July 21 at 02:56 UTC.</p>

However:

CKEDITOR.instances.yourEditorInstance.editable().getText() 

Returns:

Apollo 11
Apollo 11 was the spaceflight that landed the first humans, Americans Neil Armstrong and Buzz Aldrin, on the Moon on July 20, 1969, at 20:18 UTC. Armstrong became the first to step onto the lunar surface 6 hours later on July 21 at 02:56 UTC.
Sign up to request clarification or add additional context in comments.

1 Comment

getText() displays everything in a single line. Doesn't display 2nd "Apollo 11 " in next line

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.