+1-888-365-2779
Try Now
More in this section

Forums / Bugs & Issues / Editor: unformatting rule and paste behavior

Editor: unformatting rule and paste behavior

12 posts, 0 answered
  1. Bachar Zeidan
    Bachar Zeidan avatar
    67 posts
    Registered:
    01 Jul 2010
    16 Dec 2010
    Link to this post
    Hi Telerik,
    I need to "unformat" a text, to remove the html tags previously set. In the "paragraph style" dropdown there's a "normal" selection, but i cannot retrieve it when I select the text to clean.
    For example: I write a h3 title, then I would to normalize the text (=clean the h3 tags), but there's no way to do that.

    Second question: when i paste a text (i usually "paste plain text" to remove undesired formats), the editor don't encapsulate it in paragraphs, and this cause me validation and graphic problems. There's a way to solve that?

    As always, thank you in advance for your reply.
    Bachar
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    16 Dec 2010
    Link to this post
    Hello Bachar,

    1. Clear class clears only the "class" from a <span>. You can create custom button or drop down and clear the HTML from the selected content. You can use get_text and set_html client side methods.

    2. There is a client event - OnClientPasteHtml which you can use to alter the text that is pasted.

    Kind regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Bachar Zeidan
    Bachar Zeidan avatar
    67 posts
    Registered:
    01 Jul 2010
    16 Dec 2010
    Link to this post
    Thank you, it's all I needed.
    I'm adding my new custom button to all the instances of the RadEditor. To do that, I need to map the Generic Content external template for ItemEdit and ItemNew.
    I added the lines
    <!--Provides user interface for editing a content item in the Generic Content module.-->
    <viewSettings hostType="Telerik.Cms.Engine.WebControls.Admin.ContentItemEdit`1[[Telerik.Cms.Engine.WebControls.Admin.ContentItemsView, Telerik.Cms.Engine]]" layoutTemplatePath="~/Sitefinity/Admin/ControlTemplates/Generic_Content/ContentEditView.ascx" />
    <!--Provides user interface for adding a new content item in the Generic Content module.-->
    <viewSettings hostType="Telerik.Cms.Engine.WebControls.Admin.ContentItemNew`1[[Telerik.Cms.Engine.WebControls.Admin.ContentItemsView, Telerik.Cms.Engine]]" layoutTemplatePath="~/Sitefinity/Admin/ControlTemplates/Generic_Content/ContentNewView.ascx" />

    in the Telerik.Sitefinity.Configuration.ControlsConfig.xml file but the external templates seems doesn't attach to the default ones.
    What's my mistake?
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    16 Dec 2010
    Link to this post
    Hi Bachar,

    Have you restarted the application after you modified the ControlsConfig? If the application is not restarted the changes do not take an effect.

    Greetings,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Bachar Zeidan
    Bachar Zeidan avatar
    67 posts
    Registered:
    01 Jul 2010
    16 Dec 2010
    Link to this post
    I'm debugging the application, I launched it from Visual Studio.
    I've also cleared the browser cache, and also I've inspected the code with FireBug to check the changes.
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    16 Dec 2010
    Link to this post
    Hi Bachar,

    Can you past the code you have inside ControlsConfig file? There is not such a issue where you cannot map a Generic Content module template. Please make sure that you have followed correctly How to map a template

    All the best,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  7. Bachar Zeidan
    Bachar Zeidan avatar
    67 posts
    Registered:
    01 Jul 2010
    17 Dec 2010
    Link to this post
    Ok:
    <?xml version="1.0" encoding="utf-8" ?>
      
     <controlsConfig>
       <viewMap>
         <viewSettings hostType="Telerik.News.WebControls.Admin.NewsItemsList" layoutTemplatePath="~/Sitefinity/Admin/ControlTemplates/News/NewsItemsList.ascx" />
      
      
           <viewSettings
              hostType="Telerik.Libraries.WebControls.Admin.LibraryItemEdit, Telerik.Libraries"
              layoutTemplatePath="~/Sitefinity/Admin/ControlTemplates/Libraries/LibraryItemEdit.ascx"
            />
      
           <viewSettings hostType="Telerik.Events.WebControls.EventsView">
           <additionalTemplates>
             <add key="ItemListTemplatePath" layoutTemplatePath="~/Sitefinity/Admin/ControlTemplates/Events/ListPageMaster.ascx" />
             <add key="SingleItemTemplatePath" layoutTemplatePath="~/Sitefinity/Admin/ControlTemplates/Events/ListPageDetails.ascx" />
           </additionalTemplates>
         </viewSettings>
      
      
           <!--Provides user interface for editing a content item in the Generic Content module.-->
           <viewSettings hostType="Telerik.Cms.Engine.WebControls.Admin.ContentItemEdit`1[[Telerik.Cms.Engine.WebControls.Admin.ContentItemsView, Telerik.Cms.Engine]]" layoutTemplatePath="~/Sitefinity/Admin/ControlTemplates/Generic_Content/ContentEditView.ascx" />
           <!--Provides user interface for adding a new content item in the Generic Content module.-->
           <viewSettings hostType="Telerik.Cms.Engine.WebControls.Admin.ContentItemNew`1[[Telerik.Cms.Engine.WebControls.Admin.ContentItemsView, Telerik.Cms.Engine]]" layoutTemplatePath="~/Sitefinity/Admin/ControlTemplates/Generic_Content/ContentNewView.ascx" />
      
           <viewSettings hostType="Telerik.News.WebControls.Admin.NewsItemEdit" layoutTemplatePath="~/Sitefinity/Admin/ControlTemplates/News/NewsItemEdit.ascx" />
      
         <viewSettings hostType="Telerik.News.WebControls.Admin.NewsItemPreview" layoutTemplatePath="~/Sitefinity/Admin/ControlTemplates/News/NewsItemPreview.ascx"/>
      
         <viewSettings hostType="Telerik.News.WebControls.Admin.NewsItemNew" layoutTemplatePath="~/Sitefinity/Admin/ControlTemplates/News/NewsItemNew.ascx" />
      
         <viewSettings hostType="Telerik.News.WebControls.Admin.NewsItemHistory" layoutTemplatePath="~/Sitefinity/Admin/ControlTemplates/News/NewsItemHistory.ascx" />
      
         <viewSettings hostType="Telerik.News.WebControls.Admin.NewsCategoriesView" layoutTemplatePath="~/Sitefinity/Admin/ControlTemplates/News/CategoriesView.ascx" />
      
         <viewSettings hostType="Telerik.News.WebControls.Admin.NewsTagsView" layoutTemplatePath="~/Sitefinity/Admin/ControlTemplates/News/TagsView.ascx" />
      
         <viewSettings hostType="Telerik.News.WebControls.Admin.NewsPermissionsView" layoutTemplatePath="~/Sitefinity/Admin/ControlTemplates/News/PermissionsView.ascx" />
      
         <viewSettings hostType="Telerik.News.Design.NewsListControlDesigner" layoutTemplatePath="~/Sitefinity/Admin/ControlTemplates/News/NewsListControlDesigner.ascx" />
      
         <viewSettings hostType="Telerik.News.WebControls.Admin.NewsCommentsEdit" layoutTemplatePath="~/Sitefinity/Admin/ControlTemplates/News/CommentsEdit.ascx" />
      
         <viewSettings hostType="Telerik.Cms.Engine.WebControls.Tags.TagsList" layoutTemplatePath="~/Sitefinity/ControlTemplates/Generic_Content/TagsList.ascx" />
      
         <viewSettings hostType="Telerik.Cms.Engine.WebControls.Categories.CategoriesTree" layoutTemplatePath="~/Sitefinity/ControlTemplates/Generic_Content/CategoriesTree.ascx" />
      
      
         <viewSettings hostType="Telerik.News.WebControls.Admin.NewsCommentsList" layoutTemplatePath="~/Sitefinity/Admin/ControlTemplates/News/CommentsList.ascx" />
      
         <viewSettings hostType="Telerik.News.WebControls.Admin.NewsCommentsPreview" layoutTemplatePath="~/Sitefinity/Admin/ControlTemplates/News/CommentsPreview.ascx" />
      
         <viewSettings hostType="Telerik.News.WebControls.Design.NewsViewDesigner" layoutTemplatePath="~/Sitefinity/Admin/ControlTemplates/News/NewsViewControlDesigner.ascx" />
      
         <viewSettings hostType="Telerik.News.WebControls.Rss.RssSettingsControl" layoutTemplatePath="~/Sitefinity/Admin/ControlTemplates/News/RssSettingsControlTemplate.ascx" />
      
         <viewSettings hostType="Telerik.News.WebControls.Rss.RssViewControl" layoutTemplatePath="~/Sitefinity/Admin/ControlTemplates/News/RssViewSettingsControl.ascx" />
      
         <viewSettings hostType="Telerik.News.WebControls.Search.NewsIndexSettingsControl" layoutTemplatePath="~/Sitefinity/Admin/ControlTemplates/News/NewsIndexSettingsControl.ascx" />
      
         <viewSettings hostType="Telerik.News.WebControls.Search.NewsIndexViewControl" layoutTemplatePath="~/Sitefinity/Admin/ControlTemplates/News/NewsIndexViewSettingsControl.ascx" />
      
      
         <viewSettings hostType="Telerik.News.WebControls.NewsArchive" layoutTemplatePath="~/Sitefinity/ControlTemplates/News/ArchiveTemplate.ascx" />
          <viewSettings hostType="Telerik.News.WebControls.NewsView">
            <additionalTemplates>
             
             <add key="ItemListTemplatePath" layoutTemplatePath="~/Sitefinity/ControlTemplates/News/ListPageMaster.ascx" />
             
             <add key="SingleItemTemplatePath" layoutTemplatePath="~/Sitefinity/ControlTemplates/News/ListPageDetails.ascx" />
           </additionalTemplates>
         </viewSettings>
      
       </viewMap>
     </controlsConfig>
  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    17 Dec 2010
    Link to this post
    Hello Bachar,

    The config file looks fine

    1. Make sure that you have a folder called - Configuration in App_Data
    2. Inside Configuration you have this file Telerik.Sitefinity.Configuration.ControlsConfig.xml
    3. You restart the application.

    I attached a short video for you.

    Greetings,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  9. Bachar Zeidan
    Bachar Zeidan avatar
    67 posts
    Registered:
    01 Jul 2010
    17 Dec 2010
    Link to this post

    Hi Ivan, thank you for the reply, now it works.

    There's a bug in the RadEditor that making me crazy.
    I need to clear some html tags from a selected text, so I use this code to obtain it:

    Telerik.Web.UI.Editor.CommandList["Normale"] = function(commandName, editor, args) {
        var selectionHtml = editor.getSelectionHtml();
        alert('clearing: ' + selectionHtml);
        selectionHtml = selectionHtml.replace(/(<([^>]+)>)/ig, "");
        alert('pasting: ' + selectionHtml);
        editor.pasteHtml(selectionHtml);
    };

    If my text begins with a h3 title, there's no way to select  it. The editor select only the text inside the tags (test1_steps1-2-3.jpg attachment), so it's impossible for me to manage the tags.

    Only for testing purpose (test2), I tried to extend the selection to the next char the editor takes the next paragraph's beginning tag. In this way I the js code can work, but the editor create an empty h3 tag.

    So, the problem is the impossibility to take the right selection. Can you help me?
    Thank you,

  10. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    30 Dec 2010
    Link to this post
    Hello Bachar,

    There are some issues when you use FireFox. You can use editor.get_document() which will return you the document and then you can use the FireFox API. Another option is using innerHtml which works fine

    Best wishes,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  11. Bachar Zeidan
    Bachar Zeidan avatar
    67 posts
    Registered:
    01 Jul 2010
    03 Jan 2011
    Link to this post
    Hi Ivan
    the code pasted above don't works with IE.

    The editor.innerHtml() command doesn't work: the script debugger says: Property or method don't allowed for the object...

    For the other need I have, I use the OnClientPasteHtml, but there is a little strange: if I try to add a <p> to my editor content (i need to encapsulate into paragraphs the user-text), don't work. Instead, if I try with a SPAN element it works. Why?

    function OnClientPasteHtml(sender, args) {
        var commandName = args.get_commandName();
        var value = args.get_value();
     
        String.prototype.clearHTML = function(str) {
            return this.replace(/(<([^>]+)>)/ig, "");
        }
     
        if (commandName == "Paste") {
            var p = document.createElement("p");
            p.innerHTML = value.clearHTML();
            args.set_value(p.outerHTML);
        }
    }


    Thank you,
    and happy new year!
  12. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    05 Jan 2011
    Link to this post
    Hi Bachar,

    There is a content filter - FixEnclosingP  - This filter removes a paragraph if the whole content is inside it.
    You can try turning off the filter. Also use editor.get_document().body.innerHTML, because there is no method editor.innerHtml() in the client side specification of the RadEditor control.

    All the best,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Register for webinar
12 posts, 0 answered