Opened 17 years ago

Last modified 12 years ago

#849 confirmed New Feature

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 (8)

comment:1 Changed 17 years ago by Martin Kou

Cc: Frederico Caldeira Knabben Alfonso Martínez de Lizarrondo added
Reporter: changed from Martin Kou 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 17 years ago by Pierre Goiffon

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 16 years ago by Wojciech Olchawa

Resolution: wontfix
Status: newclosed

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 16 years ago by Frederico Caldeira Knabben

Cc: Frederico Caldeira Knabben Alfonso Martínez de Lizarrondo removed
Keywords: Confirmed added
Resolution: wontfix
Status: closedreopened

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 Changed 15 years ago by Pierre Goiffon

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 15 years ago by Artur Formella

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 12 years ago by Jakub Ś

Keywords: SF Confirmed removed
Status: reopenedconfirmed
Version: 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 12 years ago by Jakub Ś

#7585 was marked as duplicate.

Note: See TracTickets for help on using tickets.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy