We are using the latest version Q2 2010 of asp.net ajax and from what I have read in the forum you previously fixed a problem with IE where if you paste a relative url into the editor it gets turned into absolute.
However I am experiencing the same problem in the latest version of the editor. Using IE 8 if I edit content with relative urls, copy and paste one of them it gets turned absolute. The content filters is set to "None" as I know there is one for marking urls absolute.
Is the bug reintroduced or am I missing something?
Thanks
7 Answers, 1 is accepted
I have almost the same problem. When I insert the image from the image manager the url is correct, but if I just move it within the editor the url turns absolute. We write text in one webpage and display it on another. Using releative URL this works fine, but it fails when they are absolute.
I can use Properties on the image to make it back to relative, but this is easy to forget since it looks fine in the webpage where this is edited.
Espen
When copying and pasting a link or an image with a relative path in Internet Explorer, the browser automatically converts the path to absolute. The code below demonstrates how to attach to the OnClientPasteHtml event and strip the desired url path using the StripPathFilter content filter. The StripPathsFilter() method receives as a parameter an array of strings (devided by a white space) that will be stripped from the absolute path.
<script type="text/javascript">
function OnClientPasteHtml(sender, args)
{
var commandName = args.get_commandName();
var value = args.get_value();
if (commandName == "Paste")
{
// The StripPathsFilter() method receives as a parameter an array of strings (devided by a white space) that will be stripped from the absolute links.
var domainName = "http://" + window.location.host; //returns the hostname and port number of the current URL
var filter = new Telerik.Web.UI.Editor.StripPathsFilter([domainName]); //strip the domain name from the absolute path
var contentElement = document.createElement("SPAN");
contentElement.innerHTML = value;
var newElement = filter.getHtmlContent(contentElement);
alert(newElement.outerHTML);
args.set_value(newElement.outerHTML); //set the modified pasted content in the editor
}
}
</script>
Please, note that the OnClientPasteHtml event fires the Paste command only when the StripFormattingOnPaste property is not set to "NoneSupressCleanMessage". In this case the editor does not process the pasted content and pastes it without modifications.
All the best,
Rumen
the Telerik team
Yes, the solution for this problem is provided in the following forum thread: Image path problem, e.g.
<script type=
"text/javascript"
>
function
OnClientLoad(editor, args)
{
var
element = document.all ? editor.get_document().body : editor.get_document();
var
eventHandler = document.all ?
"drop"
:
"dragend"
;
$telerik.addExternalHandler(element, eventHandler,
function
(e)
{
setTimeout(
function
()
{
var
domainName =
"http://"
+ window.location.host;
var
filter =
new
Telerik.Web.UI.Editor.StripPathsFilter([domainName]);
var
div = editor.get_document().createElement(
"DIV"
);
div.innerHTML = editor.get_html(
true
);
var
newElement = filter.getHtmlContent(div);
editor.set_html(div.innerHTML);
}, 300);
});
}
</script>
<telerik:radeditor runat=
"server"
OnClientLoad=
"OnClientLoad"
ID=
"RadEditor1"
>
<Content><img src=
"/mdc-logo.png"
/>test test test</Content>
</telerik:radeditor>
Best regards,
Rumen
the Telerik team
This works, but it is no good(almost useless) solution.
Since the text is changed the content reloads and move the cursor to top of the text. When you have a long text this is more irritating than changing the URL manually.
Any other solution?
Indeed, the solution to replace the whole content when the drop event occurs is not fully functional because the selection is lost. What you can do is to implement your own custom content filter that will convert the absolute paths to relative when switching to HTML mode or submitting the content by firing the
Telerik.Web.UI.Editor.StripPathsFilter([domainName]);
filter of RadEditor.Another approach is to strip the absolute paths on the server when obtaining the content through the RadEditor1.Content property. The content is returned as a simple string and you can change the src / href values using the String.Replace server method.
Best regards,
Rumen
the Telerik team
The easy way is the best way :-) I am stripping the url on save from the page. This works fine.
Thanks.