Any idea how I can improve this experience?
3 Answers, 1 is accepted
The observed behavior is due to Visual Studio, which converts the C# code to HTML markup and exports it to the Clipboard and after that to the editor. Very often, the produced by Visual Studio content has wrong DOM child relation which causes additional problems.
You can easily verify that the observed behavior is not related to RadEditor by setting the StripFormattingOptions to None. In this mode the editor does not strip any tags and formatting and keeps the content as it is supplied by the clipboard.
Could you please open a support ticket and send us a concreted C# file for test? We will copy / paste its content in the editor and if possible we will provide a solution.
Best regards,
Rumen
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
if (RadEditor.Enabled)
{
// Remove CodeSnippet tags when editing
sb.Append(htmlBody);
}
In the above pasting, the comment should appear on the same line as the opening brace, the 4th line should be indented and there should not be so much white space between each line.
The text looks ok when pasted in Notepad or Outlook - am I missing something here?
We already answered in a separate email, but I am providing our answer here for convenience of other users:
=========================================================================
These are two separate problems – the first one is about excessive spacing, the second one is about missing indentation.
The first problem
(excessive spacing) can be handled easily. However, let me explain quickly where
both problems come from. The editor (or more precisely – the browser) is a
clipboard consumer. It identifies to Visual Studio that it is able to use HTML,
but of course has no control over the way VS creates this HTML. So, Visual
Studio exports the selection using P tags – this is purely a VS matter, and the
editor can do nothing much about it – it correctly pastes the Ps. However, by
default when no styling is applied P tags have extra margin.
This can easily be handled by modifying the editor’s content area css file and setting it with the ContentAreaCssFile property.
What you should do is
add a global P style in the file that removes margins,
e.g.
P
{
margin:0;
}
Please have a look at this demo for extra information:
Regarding the second
problem – indentation removed when pasting. Unfortunately it is again related to
the way VS exports the HTML. It simply strips away the indentation – looking at
the raw HTML code it can be seen that the TAB elements, which are used to
tabulate code in VS are just completely gone – as if they were never exported at
all. Since the editor does not receive any information on where tabs should be,
there does not seem to be any way to restore the original
tabs.
=========================================================================
Some additional information: Yes, it is possible to access the clipboard content and obtain it as simple text - however this is only possible in IE6, as well as IE7 with user security approval. It is not possible with any other browser, so developing a crossbrowser solution using just this approach is impossible. We will look further whether a combination of options can do the trick in a "cross-browser fashion".
Best regards,
Tervel
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
