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

Forums / General Discussions / Link to Document in Document Library from RadEditor

Link to Document in Document Library from RadEditor

9 posts, 0 answered
  1. Nic
    Nic avatar
    5 posts
    Registered:
    22 Mar 2011
    22 Mar 2011
    Link to this post
    I've created a page where the user is editing a product and I used the RadEditory tool. To add a link is simple, but I would like for the document manger to be able to access a or all the document libraries that the users have created in Sitefinity. I have searched everywhere and nothing explains what the view path should be for this to work. Thanks for your help.

    Nic
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    22 Mar 2011
    Link to this post
    Hello Nick,

    Sitefinity uses specific managers which have to be declared in your tools file

    <tool name="LibraryImageManager" />
    <tool name="LibraryDocumentManager" text="Insert a document"/>

    Here is the RadEditor declaration that you have to use

    <telerik:RadEditor
                        runat="server"
                        ID="Editor"
                        ContentAreaCssFile="~/Sitefinity/Admin/Themes/Default/AjaxControlsSkins/Sitefinity/EditorContentArea.css"
                        ToolsFile="~/Sitefinity/Admin/ControlTemplates/EditorToolsFile.xml"                  
                        Skin="WebBlue"                    
                        NewLineBr="False"
                        Width="95%"
                        ContentFilters="EncodeScripts,FixUlBoldItalic,FixEnclosingP,IECleanAnchors,MozEmStrong,ConvertFontToSpan,ConvertToXhtml,IndentHTMLContent">
                        <ImageManager ViewPaths="~/Images" UploadPaths="~/Images" DeletePaths="~/Images" />
                        <MediaManager ViewPaths="~/Files" UploadPaths="~/Files" DeletePaths="~/Files" />
                        <FlashManager ViewPaths="~/Files" UploadPaths="~/Files" DeletePaths="~/Files" />
                        <DocumentManager ViewPaths="~/Files" UploadPaths="~/Files" DeletePaths="~/Files" />
                        <CssFiles>
                            <telerik:EditorCssFile Value="~/Sitefinity/Admin/Themes/Default/AjaxControlsSkins/Sitefinity/EditorCssFile.css" />
                        </CssFiles>
                        <Tools>
                        <telerik:EditorToolGroup>
                                <telerik:EditorTool Text="My Separator" Name="MySeparator" />
                        </telerik:EditorToolGroup>
                            
                        </Tools>
                    </telerik:RadEditor>
                    <script type="text/javascript">
     
                        Telerik.Web.UI.Editor.CommandList["MySeparator"] = function(commandName, editor, args) {
        editor.pasteHtml('<span style="width:200px;border: 1px dashed #bb0000;background-color: #fafafa;color: blue;"> ' + new Date() + ' </span>');
    };
                    Telerik.Web.UI.Editor.CommandList["LibraryImageManager"] = function(commandName, editor, args)
                    {
                       var editorArgs = editor.getSelectedElement();
                       if (!editorArgs.nodeName || typeof(editorArgs.nodeName) == "undefined" || editorArgs.nodeName != "A")
                            editorArgs = editor.getSelection();
                        
                       var myCallbackFunction = function(sender, args)
                       {
                            if (typeof(editorArgs.nodeName) != "undefined" && editorArgs.nodeName == "IMG")
                                args.parentNode.replaceChild(editorArgs, args);
                            else
                            {
                                var cloned = args.cloneNode(true);
                                var div = args.ownerDocument.createElement("DIV");
                                div.appendChild(cloned);
                                editorArgs.pasteHtml(div.innerHTML);
                            }
                       }
                       editor.showExternalDialog(
                       '<%= ((Telerik.Cms.Web.CmsPageBase)Page).ResolveCmsUrl("~/Sitefinity/UserControls/Dialogs/ImageEditorDialog.aspx") %>',
                       editorArgs,
                       750,
                       600,
                       myCallbackFunction,
                       null,
                       'ImageLibraryDialog',
                       true,
                       Telerik.Web.UI.WindowBehaviors.Close + Telerik.Web.UI.WindowBehaviors.Move,
                       false,
                       true)
                    };
     
                    Telerik.Web.UI.Editor.CommandList["LibraryDocumentManager"] = function(commandName, editor, args)
                    {
                       var editorArgs = editor.getSelectedElement();
                       if (!editorArgs.nodeName || typeof(editorArgs.nodeName) == "undefined" || editorArgs.nodeName != "A")
                            editorArgs = editor.getSelection();
                        
                       var myCallbackFunction = function(sender, args)
                       {
                            if (typeof(editorArgs.nodeName) != "undefined" && editorArgs.nodeName == "A")
                                args.parentNode.replaceChild(editorArgs, args);
                            else
                            {
                                var cloned = args.cloneNode(true);
                                var div = args.ownerDocument.createElement("DIV");
                                div.appendChild(cloned);
                                editorArgs.pasteHtml(div.innerHTML);
                            }
                       }
                       editor.showExternalDialog(
                       '<%= ((Telerik.Cms.Web.CmsPageBase)Page).ResolveCmsUrl("~/Sitefinity/UserControls/Dialogs/DocumentEditorDialog.aspx") %>',
                       editorArgs,
                       750,
                       600,
                       myCallbackFunction,
                       null,
                       'ImageLibraryDialog',
                       false,
                       Telerik.Web.UI.WindowBehaviors.Close + Telerik.Web.UI.WindowBehaviors.Move,
                       false,
                       true)
                    };
     
                    Telerik.Web.UI.Editor.CommandList["LinkManager"] = function(commandName, editor, args)
                    {
                       var editorArgs = editor.getSelectedElement();
                       if (!editorArgs.nodeName || typeof(editorArgs.nodeName) == "undefined" || editorArgs.nodeName != "A")
                       {                                                                  
                            var sel = editor.getSelection(); 
                            editorArgs = sel;
                            editorArgs.Html = sel.getHtml();
                            editorArgs.Text = sel.getText();                                   
                       }
                        
                       var myCallbackFunction = function(sender, args)
                       {
                            if (typeof(editorArgs.nodeName) != "undefined" && editorArgs.nodeName == "A")
                                args.parentNode.replaceChild(editorArgs, args);
                            else
                            {
                                var cloned = args.cloneNode(true);
                                var div = args.ownerDocument.createElement("DIV");
                                div.appendChild(cloned);
                                editorArgs.pasteHtml(div.innerHTML);
                            }
                       }
                       editor.showExternalDialog(
                       '<%= ((Telerik.Cms.Web.CmsPageBase)Page).ResolveCmsUrl("~/Sitefinity/UserControls/Dialogs/LinksDialog.aspx") %>',
                       editorArgs,
                       750,
                       600,
                       myCallbackFunction,
                       null,
                       'ImageLibraryDialog',
                       false,
                       Telerik.Web.UI.WindowBehaviors.Close + Telerik.Web.UI.WindowBehaviors.Move,
                       false,
                       true)
                    };
     
                    Telerik.Web.UI.Editor.CommandList["SetLinkProperties"] = function(commandName, editor, args)
                    {
                       var editorArgs = editor.getSelectedElement();
                       if (!editorArgs.nodeName || typeof(editorArgs.nodeName) == "undefined" || editorArgs.nodeName != "A")
                            editorArgs = editor.getSelection();
                        
                       var myCallbackFunction = function(sender, args)
                       {
                            if (typeof(editorArgs.nodeName) != "undefined" && editorArgs.nodeName == "A")
                                args.parentNode.replaceChild(editorArgs, args);
                            else
                            {
                                var cloned = args.cloneNode(true);
                                var div = args.ownerDocument.createElement("DIV");
                                div.appendChild(cloned);
                                editorArgs.pasteHtml(div.innerHTML);
                            }
                       }
                       editor.showExternalDialog(
                       '<%= ((Telerik.Cms.Web.CmsPageBase)Page).ResolveCmsUrl("~/Sitefinity/UserControls/Dialogs/LinksDialog.aspx") %>',
                       editorArgs,
                       750,
                       600,
                       myCallbackFunction,
                       null,
                       'ImageLibraryDialog',
                       false,
                       Telerik.Web.UI.WindowBehaviors.Close + Telerik.Web.UI.WindowBehaviors.Move,
                       false,
                       true)
                    };
                    var oldFunction = Telerik.Web.UI.Editor.CommandList["ToggleScreenMode"]; //save the original Paste function
     
                    Telerik.Web.UI.Editor.CommandList["ToggleScreenMode"] = function(commandName, editor, args)
                    {
                        oldFunction(commandName, editor, args);
                        var bd = document.getElementsByTagName("body")[0];
                         
                        if(/fullScreenMode/.test(bd.className)) {
                            var rep = bd.className.match(' '+'fullScreenMode')?' '+'fullScreenMode':'fullScreenMode';
                            bd.className=bd.className.replace(rep,'');
     
                        } else {
                            bd.className += bd.className?' '+'fullScreenMode':'fullScreenMode';
                        }
                    };
                     
                    // automated tests helper function
                    function InsertTextArea()
                    {
                        var editor = $find('<%=Editor.ClientID%>');
                        editor.set_html('<textarea id="myTableToFind" style="overflow:hidden; height: 300px; width: 500px;" border="none"></textarea>');
                    }
                     
                    </script>


    Best wishes,
    Ivan Dimitrov
    the Telerik team
  3. Nic
    Nic avatar
    5 posts
    Registered:
    22 Mar 2011
    24 Mar 2011
    Link to this post
    Thanks so much Ivan, that worked like a champ. The only issue I having now is that my RadEditor is actually in the EditItemTemplate of one of the columns in my RadGrid. When I move the editor there and click on the insert document button I get this error "the command LibraryDocumentManager is not implemented yet".

    Thanks again for your help.
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    28 Mar 2011
    Link to this post
    Hello Nic,

    Do you have the same problem with the ImageManager? These dialogs are not supposed to be nested in RadGrid and there could be some issues. We use two RadWindow controls and this could mislead the client side of the RadEditor when it is added in such context.

    Best wishes,
    Ivan Dimitrov
    the Telerik team
  5. Sachin
    Sachin avatar
    18 posts
    Registered:
    10 Nov 2010
    04 Apr 2011
    Link to this post
    I am having the similar issue. I have added the radEditor and the Javascript you specified in this post but still its not working. Its giving me the following error.

     -------------------------------------------------------------------------------------------------------------------------------------------------------

    Compilation Error

    Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

    Compiler Error Message: BC30691: 'CmsPageBase' is a type in 'Web' and cannot be used as an expression.

    Source Error:

    Line 129:                            }
    Line 130:                            editor.showExternalDialog(
    Line 131:                   '<%= ((Telerik.Cms.Web.CmsPageBase)Page).ResolveCmsUrl("~/Sitefinity/UserControls/Dialogs/ImageEditorDialog.aspx") %>',
    Line 132:                   editorArgs,
    Line 133:                   750,
    -----------------------------------------------------------------------------------------------------------------------------------------------------

    I have added this in my EditorToolsFile.xml:
     <tools name="InsertToolbar" dockable="false">
        <tool name="LibraryImageManager" text="Insert an image" />
        <tool name="LibraryDocumentManager" text="Insert a document" />
        <tool name="LinkManager" text="Insert a link" shortcut="CTRL+K"/>
        <tool name="Unlink" shortcut="CTRL+SHIFT+K"/>
        <tool name="FlashManager" />
        <tool name="MediaManager" />
      </tools>
     
    Where am I going wrong here? Is there anything else I need to specify before using radEditor?

  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    04 Apr 2011
    Link to this post
    Hi Sachin,

    1.Which version of Sitefinity you use?
    2. Do you use VB compiler instead of C#. This error might be thrown if there is an issue with the C# compiler


    Kind regards,
    Ivan Dimitrov
    the Telerik team

  7. Sachin
    Sachin avatar
    18 posts
    Registered:
    10 Nov 2010
    04 Apr 2011
    Link to this post
    Hi Ivan, thanks for the quick reply.

    My Sitefinity version is 3.7.2096.3 and yes I am developing in VB.Net. Let me know if you want more information.
  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    04 Apr 2011
    Link to this post
    Hi Sachin,

    The compiler default language should be set to C# in the web.config. If the problem persists you will have to modify the code in VB to avoid the error.

    Kind regards,
    Ivan Dimitrov
    the Telerik team

  9. Sachin
    Sachin avatar
    18 posts
    Registered:
    10 Nov 2010
    05 Apr 2011
    Link to this post
    Ivan,

    Can you please provide more information on that? What code do I have to modify?
Register for webinar
9 posts, 0 answered