This is a migrated thread and some comments may be shown as answers.

How to clear all Non-Visible characters when there is no visible content

2 Answers 72 Views
Editor
This is a migrated thread and some comments may be shown as answers.
j
Top achievements
Rank 1
j asked on 16 Apr 2018, 12:39 PM

Hey folks,

This should be an easy one, but unfortunately not finding an easy way around it.

 

Problem Statement: When there are no visible characters in the input area, strip out all non-visible characters.

Details:

            Our users can copy past from word files and or other sources, then they can decide to remove it.But this creates HTML equivalents of non-visible characters like 1) Tab, 2) whitespaces, 3)Carriage Returns or any other possible non-visible characters. My requirement is simple, if there are no visible characters, the input area should be reset to nothing or null.But in my case HTML equivalents of the above mentioned visible chars are saved which is not ideal.

I tied some JS to strip those using regular expressions, but not quite working, tried server side one too(c#) but it is messing up the visible content too. Is there a property I can set to make this working ?

 

Thanks for  your help!

2 Answers, 1 is accepted

Sort by
0
Marcel
Top achievements
Rank 1
answered on 14 May 2018, 01:15 PM

I have the same problem since updating to the new version

&  is always present in the text returned to the server

any solutions ???

0
Marin Bratanov
Telerik team
answered on 17 May 2018, 11:49 AM
Hello,

The most likely reason for such behavior is that the user does not select all the content (e..g, when using the mouse) and thus some content is left over.

I am attaching a short video with the expected behavior of using ctrl+a and then del or backspace.

@Marcel - it is possible that a proxy or some browser extension is adding that the POST. In any case, if you get this consistently instead of an empty string, you can add a check to see if this is all you get and if so - consider it empty.

@j - this is actually not easy at all, because non-breaking spaces can get created by the user (e..g, when holding the space button). They will not be seen by the user, but they are still part of the content and so the editor must not remove them on its own, because they will often be required as part of the content. Nevertheless, you  can use the .Text server property or get_text() methods to get the text equivalent of the content. So, if trimming it (e..g, the JS .trim() or C#'s Trim() methods on that string return an empty string - you'll know it's all whitespace.


Regards,
Marin Bratanov
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Editor
Asked by
j
Top achievements
Rank 1
Answers by
Marcel
Top achievements
Rank 1
Marin Bratanov
Telerik team
Share this question
or