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

RadEditor in plain text mode only?

4 Answers 767 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Troy Young
Top achievements
Rank 1
Troy Young asked on 10 Apr 2009, 06:13 PM
Is it possible to use the RadEditor in a plain text mode only, where the content going in and out of the editor is always treated as text and never as html?  Currently, my application has a screen with a textarea element that the users use to input blocks of vbscript and perlscript commands that are saved in and out of a database and executed in other processes.  I would like to migrate to the RadEditor and take advantage of some of its features such as copy,paste,undo,redo,find,replace,font changes,etc.  But it seems that the editor always presents HTML, and I lose carriages returns, tabs, whitespace, etc when I originally load the text to display for the user.  I see the .Text property will retrieve plain text, but I would like to be able to load the data as plain text too, without it ever being converted to html.  Basically I want to use RadEditor as a text editor and not an HTML editor.  I am not seeing a way to do this, am I missing something, or is it not possible?

4 Answers, 1 is accepted

Sort by
0
ManniAT
Top achievements
Rank 2
answered on 11 Apr 2009, 06:17 PM
Hi Troy,

I guess this post gives some kind of answer to your question.
http://www.telerik.com/community/forums/aspnet-ajax/editor/edit-files-directly.aspx

I found it these days because I was also searching for an "extended text editor".
I want (like you) text file edit - and (like the other poster) CSS file edit.

Reading the linked post I decided not to use RadEditor in this case.
So I do two different things
a.) for Textfiles (small ones) I use a normal textbox
Spell is useable - and "formatting" on a textfile :)
b.) for CSS and other specialized filetypes I implemented a download / upload scenario with RadFileExplorer
This is OK for my customer - he uses Visual Studio Express Web for CSS - which gives "WYSIWYG" editing.

Ah, by the way - my HTML content editing is done with RadEditor.

HTH

Manfred
0
Tervel
Telerik team
answered on 13 Apr 2009, 07:17 AM
Hi Troy,

The editor is meant and designed to be used as a HTML editor, and not as textbox (the assumption being that if one needs a textbox one would use a textbox).

Still, the editor does offer some text- and textbox- related features, such as the read-only Text property which returns editor content as pure text, for example.

As far as setting [text] content is concerned, the link provided by Manfred is quite good and will help you in your scenario.

In case you are looking also for more textbox-like RadEditor look II want to point your attention to the following online demo:
http://demos.telerik.com/aspnet-ajax/editor/examples/editorastextbox/defaultcs.aspx

Best regards,
Tervel
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
David
Top achievements
Rank 1
Veteran
Iron
answered on 14 Aug 2020, 10:19 PM

I was able to get it to work as an extended simple text editor with a little work put in.

1. I used a custom .xml file for the Toolbar to eliminate any richtext features. I just gave the user the very basics of text manipulation but much more than a textbox would give you. I felt this was needed because the users would be editing text that would go out in form emails from my application.

2. I created methods to do conversion just before loading into the editor object (ConvertCrToBr) and an html scrub on the output (ScrubOutHtml).

I am sure even more improvements could be made or something I am not anticipating but it seems to be working well for me for what I need it for.

<?xml version="1.0" encoding="utf-8" ?>
<root>
    <modules>
        <module name="RadEditorStatistics" dockingZone="Bottom"/>
        
    </modules>
    <tools name="Clipboard" tab="Home">
        <tool name="PasteStrip" size="large"/>
        <tool name="Cut" size="medium"/>
        <tool name="Copy" size="medium" shortcut="CTRL+C"/>
        <tool name="Print" size="medium" shortcut="CTRL+P"/>
    </tools>
    
    <tools name="Editing" tab="Home">
        <tool name="Undo" shortcut="CTRL+Z"/>
        <tool name="FindAndReplace" shortcut="CTRL+F"/>
        <tool name="SelectAll" shortcut="CTRL+A"/>
        <tool name="Redo" shortcut="CTRL+Y"/>
    </tools>
    
    <tools name="Content" tab="Insert">
         
        <tool name="InsertDate" />
        <tool name="InsertTime" />
         
    </tools>
    <tools name="Zoom" tab="View">
        <tool name="Zoom"/>
    </tools>
    <tools name="Preferences" tab="View">
        
        <tool name="ToggleScreenMode" size="medium" shortcut="F11"/>
        
    </tools>
    <tools name="Proofing" tab="Review">
        <tool name="AjaxSpellCheck" size="large" />       
    </tools>
     
</root>

I

 

 

 

 

 

<?xml version="1.0" encoding="utf-8" ?>
<root>
    <modules>
        <module name="RadEditorStatistics" dockingZone="Bottom"/>
        
    </modules>
    <tools name="Clipboard" tab="Home">
        <tool name="PasteStrip" size="large"/>
        <tool name="Cut" size="medium"/>
        <tool name="Copy" size="medium" shortcut="CTRL+C"/>
        <tool name="Print" size="medium" shortcut="CTRL+P"/>
    </tools>
    
    <tools name="Editing" tab="Home">
        <tool name="Undo" shortcut="CTRL+Z"/>
        <tool name="FindAndReplace" shortcut="CTRL+F"/>
        <tool name="SelectAll" shortcut="CTRL+A"/>
        <tool name="Redo" shortcut="CTRL+Y"/>
    </tools>
    
    <tools name="Content" tab="Insert">
         
        <tool name="InsertDate" />
        <tool name="InsertTime" />
         
    </tools>
    <tools name="Zoom" tab="View">
        <tool name="Zoom"/>
    </tools>
    <tools name="Preferences" tab="View">
        
        <tool name="ToggleScreenMode" size="medium" shortcut="F11"/>
        
    </tools>
    <tools name="Proofing" tab="Review">
        <tool name="AjaxSpellCheck" size="large" />       
    </tools>
     
</root>
<telerik:RadEditor ID="editorTemplate" runat="server" 
         ToolsFile="EmailTemplateEditorTools.xml" Height="500px"
         EditModes="Design"  EditType="Normal" ToolbarMode="RibbonBar"
         SpellCheckSettings-AjaxUrl="~/Telerik.Web.UI.SpellCheckHandler.ashx"
         NewLineMode="Br">        
</telerik:RadEditor>
private string ConvertCrToBr(string stringToConvert)
{
            // Count how many Char(10) occurances
            // string needle = Convert.ToChar(10).ToString();
            // int needleCount = (stringToConvert.Length - stringToConvert.Replace(needle, "").Length) / needle.Length;
 
            string returnValue = stringToConvert.Replace(Convert.ToChar(10).ToString(), "<br />");
           
            return returnValue;
}
private string ScrubOutHtml(string stringToScrub)
{          
         var step1 = Regex.Replace(stringToScrub, @"<[^>]+>", "").Trim();
         var step2 = Regex.Replace(step1, @" ", " ");               
         return step2;           
}
0
Rumen
Telerik team
answered on 18 Aug 2020, 02:13 PM

Hi David,

Thank you for sharing your solution with the community!

I'd like to add also this demo on the matter Displaying RadEditor as a TextBox. It shows how to customize the appearance of the control so it looks similar to a textarea.

Another option is to force RadEditor to be rendered as a standard textarea by setting its EnableTextareaMode="true" property.

Best Regards,
Rumen
Progress Telerik

Tags
Editor
Asked by
Troy Young
Top achievements
Rank 1
Answers by
ManniAT
Top achievements
Rank 2
Tervel
Telerik team
David
Top achievements
Rank 1
Veteran
Iron
Rumen
Telerik team
Share this question
or