Ticket #849 (confirmed New Feature)

Opened 7 years ago

Last modified 2 years ago

Get the "plain text" (tags stripped) content from the editor

Reported by: anonymous Owned by:
Priority: Normal Milestone:
Component: General Version: 3.0
Keywords: Cc:

Description

I want to get the pure content,i.e. the value of the editor discarding all the tags related to format, such as html tags or javascript tags. In other word, I need not the html source in the editor but the all text displayed on the html page without any tags.

A new method is desirable to implement such a function.


Moved from SF:
http://sourceforge.net/tracker/index.php?func=detail&aid=1371816&group_id=75348&atid=543656

Change History

comment:1 follow-up: ↓ 2 Changed 7 years ago by martinkou

  • Cc fredck, alfonsoml added
  • Reporter changed from martinkou to anonymous

I think that's useful.

function getClearText( strSrc ) {
	//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
+-+-+-+-+-+-+-+-+-+-+-+-+
	// Strip off HTML tags. Better than other 
removeHtml functions out there.
	//+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
+-+-+-+-+-+-+-+-+-+-+-+-
	
	return  strSrc.replace( /<[^<|>]+?>/gi,'' );
}

clear_text=getClearText(FCKeditorAPI.GetInstance
("FCKeditor1").GetXHTML());
alert(clear_text);

Moved from SF. Original poster: Anonymous

I am needing the same exact thing!!! We are developing for people who dont know web so it would be nice for them to have a paste-from web page option


Moved from SF. Original poster: Anonymous

It may be useful in order to send emails with both HTML and text versions with only one FCKeditor input.


Moved from SF. Original poster: Anonymous

Take a look at the "GetLength()" function in the sample08.html file.


Moved from SF. Original poster: fredck

You can do it getting the current output and processing it with a regexp, but I don't see any value of using this editor to get the plain text. To get plain text is easier to use a textarea.


Moved from SF. Original poster: alfonsoml

comment:2 in reply to: ↑ 1 Changed 7 years ago by pgoiffon

I've got this same problem to. I use FCK in a mailing editor, and so getting plain text and html values are mandatory (sending in multipart/alternative). For now I use lots of regexp to do the job (if FormatOuput is set to true this is a real nightmare). A FCK API method would be greatly appreciate !

comment:3 Changed 7 years ago by w.olchawa

  • Status changed from new to closed
  • Resolution set to wontfix

As mentioned above to get the plain text is better to use a normal textarea. FCKeditor is build to change the text to html code so I don't see it changing in that sense.

comment:4 Changed 7 years ago by fredck

  • Status changed from closed to reopened
  • Keywords Confirmed added
  • Resolution wontfix deleted
  • Cc fredck, alfonsoml removed

Even if in the fair past this the idea didn't caught my mind properly, the situation proposed by pgoiffon is a reality. So, the request is not totally wrong.

I don't think we would ever have a core function for that, but it fits well in a plugin. Let's leave this request opened just for reference.

comment:5 follow-up: ↓ 6 Changed 5 years ago by pgoiffon

Another use case I've just saw in a newsgroup : a char counter... that would counts only the characters the user has typed, and no html tags or indentation space.

With that content : <p>

Hello <b>World</b>

</p> The counter should return 11 characters (the length of the string "Hello World").

comment:6 in reply to: ↑ 5 Changed 5 years ago by arczi

Replying to pgoiffon:

Another use case I've just saw in a newsgroup : a char counter... that would counts only the characters the user has typed, and no html tags or indentation space. (...)

The counter should return 11 characters (the length of the string "Hello World").

Similar to #854.

comment:7 Changed 2 years ago by j.swiderski

  • Status changed from reopened to confirmed
  • Keywords SF Confirmed removed
  • Version set to 3.0

Getting text from whole page - I think we could create a plug-in that moves down the DOM tree gets text from elements and returns nice plain line of text or perhaps a text with line-breaks.

Another approach would be using regular expressions on data from getData() method.

comment:8 Changed 2 years ago by j.swiderski

#7585 was marked as duplicate.

Note: See TracTickets for help on using tickets.
© 2003 – 2012 CKSource – Frederico Knabben. All rights reserved. | Terms of use | Privacy policy