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

[Solved] Custom Link Manager

2 Answers 203 Views
Editor
This is a migrated thread and some comments may be shown as answers.
QScend
Top achievements
Rank 1
QScend asked on 05 Feb 2008, 10:14 PM
Hello,

With the old RadEditor, we had a custom link manager that we built. We used some of your internal functions to make things happen (per your advice), but now it seems that some of the functionality that we used to accomplish the task has either changed or is no longer available. We've converted from using ASPX pages to ASCX pages throughout, and up until this custom dialog have not had issues. We have a basic working custom link manager in place, but there is certain functionality that we're missing. Code that we used in the past that we've been unable to reproduce in the new RadEditor includes:

   var link = RadEditorNamespace.GetSelectionLinkArgument(editor);
   if (link.realLinkObject && link.realLinkObject.style && link.realLinkObject.style.cssText)
   {
        link.style = link.realLinkObject.style.cssText;
   }

We used this to get the currently selected link from the content area. What can we call in the new editor to accomplish the same thing? The new RadEditor's built-in Hyperlink Manager does this functionality still, so there must be a function that we can still call. Also:

function callBackFunctionPtr(returnValue, arg2)
{
   if (returnValue)
   {
      var originalFunctionToExecute = returnValue.realLinkObject == null
        ? RadEditorNamespace.radEditorCreateLink
        : RadEditorNamespace.radEditorSetLinkProperties;
      originalFunctionToExecute(returnValue, arg2);
   }
}

This was our old callback function that received back from the RadWindow:

  function insertLink()
  {
   var returnValue =
   {
    realLinkObject:dialogArguments.realLinkObject,
    href:document.linkform.oHref.value,
    target:document.linkform.oTarget.value,
    style:document.linkform.oStyle.value,
    className:document.linkform.oClass.value,
    name:document.linkform.oName.value
   };
   CloseDlg(returnValue);
  }

This is the other missing piece of the puzzle. How can we now take the new hyperlink parameters and create a new hyperlink, or replace the parameters of the one that was currently selected? We've managed to put together:

Telerik.Web.UI.Editor.CommandList["InternalLink"] = function(commandName, editor, args)
{
   var myCallbackFunction = function(sender, args)
   {
       if (args)
       {
       editor.setFocus();
       editor.get_document().execCommand("createlink", false, args.href);
       }
   }
   editor.showDialog("InternalLink", {}, myCallbackFunction);
}

We do not, however, know how to pass the hyperlink parameters to "createlink" to properly form the new hyperlink (or update the currently selected one). This may not even be the function that is called by the built-in Hyperlink Manager upon return, but it's all we've been able to dig up in the documentation/forums.

2 Answers, 1 is accepted

Sort by
0
QScend
Top achievements
Rank 1
answered on 05 Feb 2008, 10:18 PM
Just a quick note. In the final code snippet, what's being returned as args is the same returnValue from the prior snippet. Also, a link to the original instructions you had given us that worked in the old RadEditor that instructed us to use your internal functionality:

http://www.telerik.com/community/forums/thread/b311D-kbtdc.aspx
0
Rumen
Telerik team
answered on 13 Feb 2008, 05:22 PM
Hi Keith,

You can find attached the requested custom link manager example for RadEditor "Prometheus". Please, test it and let me know if you have any questions.

If you experience any problems, open a support ticket and send a sample runnable project that demonstrates them and explain how do you expect the dialog to work.

Best regards,
Rumen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Editor
Asked by
QScend
Top achievements
Rank 1
Answers by
QScend
Top achievements
Rank 1
Rumen
Telerik team
Share this question
or