We are using the Editor and allowing users to open the document manager and select an item and click insert. When they click Insert it will insert a link with the document name as the hyperlink text. Is there a way to make it output the full URL to the document instead of just the name of the document?
Sometimes the text that is entered into the editor is being emailed to people as plain text and they need the full URL to get the document.
8 Answers, 1 is accepted
0
Hi Adam,
In order to insert links with full / absolute urls via the document manager, you should enable the MakeUrlsAbsolute content filter of RadEditor. You can do this by setting the following method in the codebehind:
RadEditor1.EnableFilter(EditorFilters.MakeUrlsAbsolute);
You can see the following example for more information: Built-in Content Filters.
Best regards,
Rumen
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
In order to insert links with full / absolute urls via the document manager, you should enable the MakeUrlsAbsolute content filter of RadEditor. You can do this by setting the following method in the codebehind:
RadEditor1.EnableFilter(EditorFilters.MakeUrlsAbsolute);
You can see the following example for more information: Built-in Content Filters.
Best regards,
Rumen
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Adam
Top achievements
Rank 1
answered on 19 Jan 2009, 02:47 PM
The problem is not that the links are not absolute, it's that the text the Document Manager places in the editor is only the file name. For example, if I were to go in link to a file at http://www.test.com/test.doc and select it and click Insert, it would only put "test.doc" into the text window. What I want to appears as the link is the URL to the document....http://www.test.com/test.doc.
Thanks,
Adam
Thanks,
Adam
0
Hi Adam,
Thank you for the explanation of your scenario.
You can achieve it using the OnClientPasteHtml event and modifying the link output from the Document manager. For your convenience I have wrote the code solution below:
Kind regards,
Rumen
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Thank you for the explanation of your scenario.
You can achieve it using the OnClientPasteHtml event and modifying the link output from the Document manager. For your convenience I have wrote the code solution below:
<script type="text/javascript"> |
function OnClientPasteHtml(editor, args) |
{ |
var commandName = args.get_commandName(); |
var value = args.get_value(); |
if (commandName == "DocumentManager") |
{ |
//See if an img has an alt tag set |
var div = document.createElement("DIV"); |
//Do not use div.innerHTML as in IE this would cause the image's src or the link's href to be converted to absolute path. |
//This is a severe IE quirk. |
Telerik.Web.UI.Editor.Utils.setElementInnerHtml(div,value); |
//Now check if there is alt attribute |
var link = div.firstChild; |
link.innerHTML = link.href; |
//Set new content to be pasted into the editor |
args.set_value(div.innerHTML); |
} |
} |
</script> |
<telerik:RadEditor ID="RadEditor1" DocumentManager-ViewPaths="~/" OnClientPasteHtml="OnClientPasteHtml" runat="server"></telerik:RadEditor> |
Kind regards,
Rumen
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Adam
Top achievements
Rank 1
answered on 19 Jan 2009, 04:50 PM
That pretty much works. However, it is only giving the relative path and not the full path. We have the EditorFilters.MakeUrlsAbsolute filter enabled, but it still returns relative links.
Thanks,
Adam
0
Adam
Top achievements
Rank 1
answered on 19 Jan 2009, 05:23 PM
Nevermind, I found something that works.
link.innerHTML = window.location.protocol + '//' + window.location.host + link.href; |
0
Hello Adam,
Please, try the following solution:
It worked as expected on my side and the link is inserted with absolute href and text.
Best wishes,
Rumen
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Please, try the following solution:
<script type="text/javascript"> |
function OnClientPasteHtml(editor, args) |
{ |
var commandName = args.get_commandName(); |
var value = args.get_value(); |
if (commandName == "DocumentManager") |
{ |
var div = document.createElement("DIV"); |
var link = document.createElement("A"); |
div.innerHTML = value; |
link.innerHTML = div.firstChild.href; |
link.href = div.firstChild.href; |
//Set new content to be pasted into the editor |
args.set_value("<a href='" + link.href + "'>" + link.innerHTML + "</a>"); |
} |
} |
</script> |
<telerik:RadEditor ID="RadEditor1" DocumentManager-ViewPaths="~/" OnClientPasteHtml="OnClientPasteHtml" runat="server"></telerik:RadEditor> |
It worked as expected on my side and the link is inserted with absolute href and text.
Best wishes,
Rumen
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Adam
Top achievements
Rank 1
answered on 19 Jan 2009, 06:05 PM
That works as well. Thank you.
0
Nirosha
Top achievements
Rank 1
answered on 18 Apr 2017, 05:10 PM
We are using the Editor and allowing users to open the document manager and select an item and click insert.
When they click Insert it will insert a link with the document name as the hyperlink text.is there any way to convert that hyperlink into bytes.
can you please suggest the code
Thanks,
Nirosha.