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

RadEditor w/ custom link manager not pasting html at correct position in IE7+.

7 Answers 60 Views
Editor
This is a migrated thread and some comments may be shown as answers.
PSCU Developers
Top achievements
Rank 1
PSCU Developers asked on 12 Feb 2013, 03:21 PM
We are using the RadEditor with the LinkManager.ascx dialog (v2012.3.1308.45). We had to extend the link manager to add additional attributes to the link. To do so, we modified the _insertClickHandler function in link manager to the following:

_insertClickHandler: function (e) {

var modifiedLink = this.getModifiedLink();
modifiedLink.setAttribute("LinkOptions", "2");

var args = new Telerik.Web.UI.EditorCommandEventArgs("LinkManager", null, modifiedLink);
//backwards compatibility
args.realLink = modifiedLink;
Telerik.Web.UI.Dialogs.CommonDialogScript.get_windowReference().close(args);

},

This worked fine in our previous version of controls (v2011.something). After upgrading this now returns a link without the added attribute at the beginning of the editor.

Expected results:

some text.....
< a href LinkOptions="2" / >
some text....


Actual results:
< a href / >
some text...
some text...

I also tried the following:

_insertClickHandler: function (e) {
var modifiedLink = this.getModifiedLink();
modifiedLink.setAttribute("LinkOptions", "2");

var args = new Telerik.Web.UI.EditorCommandEventArgs("LinkManager", null, modifiedLink);
//backwards compatibility
args.realLink = modifiedLink;

var editor = this._clientParameters.editor;
editor.pasteHtml(args.value.outerHTML);

Telerik.Web.UI.Dialogs.CommonDialogScript.get_windowReference().close();
},


Not handing in args to the close routine keeps the added attribute and paste position and works well in chrome, but not in IE. How can I return the link I want at the cursor position? This worked great in previous versions. I don't want Telerik assuming that 'LinkOptions' is an invalid element and stripping it before it gets to the editor.

Thanks

7 Answers, 1 is accepted

Sort by
0
PSCU Developers
Top achievements
Rank 1
answered on 13 Feb 2013, 04:11 PM
Telerik, please provide some assistance on this.

Thanks
0
Rumen
Telerik team
answered on 14 Feb 2013, 02:00 PM
Hello,

The reported regression is due to a change in the RadEditor's API for link insertion. In the older versions, there was a huge bug which appeared when selecting multiple lists and applying a link to them. This wrapped the <li> tags in a <a> tag, which was invalid XHTML.

In the current Q1 2013 Beta release, there is a new OnClientDomChange property which will allow you to inspect the inserted link(s) tags via the Link Manager and modify it (them).

Unfortunately, we will be unable to fix the reported problem for the Q1 2013 release, because we will not have time, but you can use the following workaround to implement your scenario with the beta and the official Q1 2013 build (scheduled for next week):

Default.aspx
<telerik:RadEditor ID="RadEditor1" runat="server" ExternalDialogsPath="~/EditorDialogs" OnClientDomChange="OnClientDomChange">
</telerik:RadEditor>
<script>
    var customAttribute = null;
 
    function getCustomAtrribute(attribute) {
        customAttribute = attribute;
    }
 
    function OnClientDomChange(editor, args) {
        var link = args.get_value();
        link.setAttribute(customAttribute, "2");
    }
</script>

EditorDialogs/LinkManager.aspx
_insertClickHandler: function (e)
{
    var modifiedLink = this.getModifiedLink();
    window.top.getCustomAtrribute("LinkOptions");
    var args = new Telerik.Web.UI.EditorCommandEventArgs("LinkManager", null, modifiedLink);
    //backwards compatibility
    args.realLink = modifiedLink;
             
    Telerik.Web.UI.Dialogs.CommonDialogScript.get_windowReference().close(args);
},


Kind regards,
Rumen
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
PSCU Developers
Top achievements
Rank 1
answered on 14 Feb 2013, 09:11 PM
Thanks, I will take a look.

Just to be sure, I am using the Q3 2012 release. Is there a workaround for Q3 2012 that I can do? We are in the middle of our regression, and upgrading the control suite to a beta (or even waiting to next week) is too big of a change to do right before deployment.

I am open to any temporary js hacks I may need to add to get this to work. I also have a ticket open about this issue.
0
Rumen
Telerik team
answered on 15 Feb 2013, 10:26 AM
Hello,

The change was introduced in the Q3 2012 SP2 release, so you should not experience problems with Q3 2012.

I created a test project with Q3 2012 and your code works as expected: http://screencast.com/t/pjcWdCDxbL.

Kind regards,
Rumen
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
PSCU Developers
Top achievements
Rank 1
answered on 15 Feb 2013, 04:12 PM
Rumen, the version we have is 2012.3.1308. The link gets added to the editor but the LinkOptions attribute is no where to be found. Can you try adding this to your editor example and see if it still passes? 

StripFormattingOnPaste="MSWord"

If it does, how do I get the exact version you are using? We downloaded what appears to be Q3 2012 from the Telerik admin site.
0
PSCU Developers
Top achievements
Rank 1
answered on 15 Feb 2013, 04:38 PM
I just downgraded to the version you used in the video. The 2012 Q3 version I was using has this bug FYI.
0
Rumen
Telerik team
answered on 19 Feb 2013, 12:27 PM
Hi,

Version 2012.3.1308 (Q3 2012 SP2) does not offer a way to modify the inserted links and apply custom attributes to them.
You have two options to downgrade to Q3 2012 SP1 or to upgrade tomorrow to Q1 2013. The new version will offer the OnClientDomChange property, which will allow you to use the provided workaround in my earlier post, e.g.

Default.aspx
Copy Code
<telerik:RadEditor ID="RadEditor1" runat="server" ExternalDialogsPath="~/EditorDialogs" OnClientDomChange="OnClientDomChange">
</telerik:RadEditor>
<script>
    var customAttribute = null;
 
    function getCustomAtrribute(attribute) {
        customAttribute = attribute;
    }
 
    function OnClientDomChange(editor, args) {
        var link = args.get_value();
        link.setAttribute(customAttribute, "2");
    }
</script>

EditorDialogs/LinkManager.aspx
Copy Code
_insertClickHandler: function (e)
{
    var modifiedLink = this.getModifiedLink();
    window.top.getCustomAtrribute("LinkOptions");
    var args = new Telerik.Web.UI.EditorCommandEventArgs("LinkManager", null, modifiedLink);
    //backwards compatibility
    args.realLink = modifiedLink;
             
    Telerik.Web.UI.Dialogs.CommonDialogScript.get_windowReference().close(args);
},




Kind regards,
Rumen
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Editor
Asked by
PSCU Developers
Top achievements
Rank 1
Answers by
PSCU Developers
Top achievements
Rank 1
Rumen
Telerik team
Share this question
or