To reproduce:
- insert a fragmet from another RichtextEditor like this:
private void Button_Click(object sender, RoutedEventArgs e)
{
radRichTextBox.Document.Sections.Clear();
radRichTextBox.Document.Sections.Add(new Section());
radRichTextBox.Document.CaretPosition.MoveToLastPositionInDocument();
radRichTextBox.DocumentEditor.InsertParagraph();
radRichTextBox.DocumentEditor.InsertFragment(new DocumentFragment(radRichTextEditor1.Document));
radRichTextBox.DocumentEditor.InsertParagraph();
}
Workaround:
There is no point of resetting the section in such way. Nevertheless, you can avoid the exception by using one of the following methods:
radRichTextBox.Document.MeasureAndArrangeInDefaultSize();
radRichTextBox.UpdateEditorLayout();
To reproduce:
- Copy the content from the attached document - do not copy the last row.
- Remove the bookmarks like this:
bookmarks = radRichTextEditor1.Document.GetAllBookmarks().ToArray();
foreach (BookmarkRangeStart item in bookmarks)
{
radRichTextEditor1.Document.GoToBookmark(item);
radRichTextEditor1.DocumentEditor.DeleteBookmark(item);
}
Workaround:
var invalidStarts = this.radRichTextBox.Document
.EnumerateChildrenOfType<BookmarkRangeStart>()
.Where(start => start.End == null)
.ToList();
foreach (var invalidStart in invalidStarts)
{
invalidStart.Parent.Children.Remove(invalidStart);
}
Note that when this workaround is used the document history will be deleted as well, which means that the undo operation will no longer hold information for previous operations
Workaround:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.radRichTextEditor1.IsSpellCheckingEnabled = true;
this.radRichTextEditor1.Insert("SOooome wrrrrong wooooooooords.");
this.radRichTextEditor1.CommandExecuted += radRichTextEditor1_CommandExecuted;
}
bool shouldProcess = true;
private void radRichTextEditor1_CommandExecuted(object sender, Telerik.WinForms.Documents.RichTextBoxCommands.CommandExecutedEventArgs e)
{
if (e.Command is DeleteCommand)
{
if (shouldProcess)
{
shouldProcess = false;
RichTextEditorInputBehavior behavior = this.radRichTextEditor1.InputHandler;
behavior.ProcessKeyDown(new KeyEventArgs(Keys.Back));
}
shouldProcess = true;
}
}
}
To reproduce: - Insert the following HTML vide the HtmlFormatProvider: "<!DOCTYPE html><html><head><title>test</title> <body><span >Hello,</span><p ><span >Kind regards,</span></p> <br /> <span >Test</span><p><a href=\"#\"><span>Hyperlink</span></a><span ><br /></span><span >test: 0</span><span ><br /></span><span>Test</span><span </span></p></body></html>" - Start the application place the caret in front of the link and press the tab key, you will notice that the text below the link is also moved. This behavior is also observed when the text box contains plain text or a imported rtf, just move the caret at the top left corner, in front of all text and press Tab.
The Docm (docx) and RTF files are not imported correctly. - Paragraph's alignment is not imported when RTF file is opened by RadRichTextBox - Importing of Docm (docx) file does not imports images and does not apply correct borders of table
The equation objects in word document are not copied and imported correctly in RadRichTextBox
To reproduce:
Add image like this:
void button_Click1(object sender, EventArgs e)
{
Section section = new Section();
Paragraph paragraph = new Paragraph();
ImageInline image;
Telerik.WinControls.RichTextEditor.UI.Size size = new Telerik.WinControls.RichTextEditor.UI.Size(236, 50);
using (MemoryStream ms = new MemoryStream())
{
System.Drawing.Image.FromFile(@"C:\img\delete.png").Save(ms, System.Drawing.Imaging.ImageFormat.Png);
image = new ImageInline(ms, size, "png");
}
paragraph.Inlines.Add(image);
section.Children.Add(paragraph);
this.radRichTextEditor1.Document.Sections.Add(section);
}
Workaround:
Manually update the layout:
this.radRichTextEditor1.UpdateEditorLayout();
To reproduce: create a Word document with a table. Design a more complex table with nested tables in each cell. Specify "None" border for the internal tables. When loading the document in the RadRichTextBox, the borders are displayed.
If you export a document using the HtmlFormatProvider, all style properties which contain measurement units are exported in pixel units. This makes the exported documents look much smaller when opened on devices with higher pixel density.
WORKAROUND: use Regex to find, convert and replace the font-size attributes
HtmlFormatProvider html = new HtmlFormatProvider();
string res = html.Export(document);
Regex regex = new Regex(@"font-size: [0-9]*\.?[0-9]*px");
Match match = null;
do
{
match = regex.Match(res);
if (!match.Success)
{
break;
}
string value = match.Value.Substring("font-size: ".Length, match.Value.Length - "font-size: ".Length - "px".Length);
double pts = double.Parse(value) * 72 / 96;
res = res.Replace(match.Value, @"font-size: " + Math.Round(pts, 4) + "pt");
} while (match.Success);
File.WriteAllText("output.html", res);
To reproduce:
radRichTextEditor.Document = new RadDocument();
radRichTextEditor.Document.MeasureAndArrangeInDefaultSize();
radRichTextEditor.UpdateEditorLayout();
radRichTextEditor.Document.CaretPosition.MoveToLastPositionInDocument();
var p = new Paragraph();
p.Inlines.Add(new Span("Cell"));
var cell = new TableCell();
cell.Blocks.Add(p);
var row = new TableRow();
row.Cells.Add(cell);
var table = new Table();
table.Rows.Add(row);
var section = new Section();
section.Blocks.Add(table);
radRichTextEditor.Document.Sections.Add(section);
radRichTextEditor.Document.CaretPosition.MoveToLastPositionInDocument();
var provider = new RtfFormatProvider();
var txt = provider.Export(radRichTextEditor.Document);
Clipboard.SetText(txt, TextDataFormat.Rtf);
Workaround: measure the document after the section is added:
radRichTextEditor.Document.Sections.Add(section);
radRichTextEditor.Document.MeasureAndArrangeInDefaultSize();
radRichTextEditor.UpdateEditorLayout();
To reproduce: RadDocument document = new RadDocument(); Section section = new Section(); Paragraph p = new Paragraph(); Span span = new Span(); span.Text ="test" + Environment.NewLine + "test"; ReadOnlyRangeStart rangeStart = new ReadOnlyRangeStart(); ReadOnlyRangeEnd rangeEnd = new ReadOnlyRangeEnd(); rangeEnd.PairWithStart(rangeStart); p.Inlines.Add(rangeStart); p.Inlines.Add(span); p.Inlines.Add(rangeEnd); section.Blocks.Add(p); document.Sections.Add(section); this.radRichTextEditor1.Document = document; Workaround: add an empty span as last inline element in the paragraph: RadDocument document = new RadDocument(); Section section = new Section(); Paragraph p = new Paragraph(); Span span = new Span(); span.Text ="test" + Environment.NewLine + "test"; ReadOnlyRangeStart rangeStart = new ReadOnlyRangeStart(); ReadOnlyRangeEnd rangeEnd = new ReadOnlyRangeEnd(); rangeEnd.PairWithStart(rangeStart); p.Inlines.Add(rangeStart); p.Inlines.Add(span); p.Inlines.Add(rangeEnd); /////////////////////////////////////// Span emptySpan = new Span(); emptySpan.Text = " "; p.Inlines.Add(emptySpan); /////////////////////////////////////// section.Blocks.Add(p); document.Sections.Add(section); this.radRichTextEditor1.Document = document;
1. Open RadRichTexEditor and type the following text: "שדג:3" or open the attached file 2. Save the document as docx file 3. Compare the results in MS Word and in RadRichTexEditor Observed result: in RadRichTexEditor the text is visualized as: ":3שדג" Expected result: The text should be visualized as: "שדג:3"
Workaround:
void radRichTextEditor1_CommandExecuting(object sender, CommandExecutingEventArgs e)
{
if (e.Command is PasteCommand)
{
e.Cancel = true;
PasteNewText();
}
}
public void PasteNewText()
{
DocumentFragment clipboardDocument = null;
string clipboardText = null;
bool clipboardContainsData = false;
if (ClipboardEx.ContainsDocument(null))
{
clipboardDocument = ClipboardEx.GetDocument();
clipboardContainsData = true;
}
else if (ClipboardEx.ContainsText(null))
{
clipboardText = ClipboardEx.GetText(null);
clipboardContainsData = true;
}
if (!clipboardContainsData)
{
return;
}
if (clipboardDocument != null)
{
RadDocument doc = new RadDocument();
RadDocumentEditor editor = new RadDocumentEditor(doc);
editor.InsertFragment(clipboardDocument);
TxtFormatProvider provider = new TxtFormatProvider();
string plainText = provider.Export(doc);
this.radRichTextEditor1.RichTextBoxElement.ActiveDocumentEditor.Insert(plainText);
}
else if (!string.IsNullOrEmpty(clipboardText))
{
this.radRichTextEditor1.RichTextBoxElement.ActiveDocumentEditor.Insert(clipboardText);
}
}
Note: this problem is related to the following feedback item: http://feedback.telerik.com/Project/154/Feedback/Details/174882-fix-radrichtexteditor-spellcheckingdialog-should-not-be-closed-when-a-misspell You should apply the suggested workaround in order to be able to replicate the problem. Steps to reproduce: 1. Enter some misspelled words. 2. Open the spell checking form by using the context menu. 3. "Ignore" the first misspelled word. 4. The next wrong word is highlighted. If you add it to the dictionary, the previously ignored word is highlighted as well. Workaround: use the "Ignore All" option.
How to reproduce:
public Form1()
{
InitializeComponent();
richTextEditorRibbonBar1.AssociatedRichTextEditor = radRichTextEditor1;
radRichTextEditor1.Insert("This is a example for the \"ContextMenu shows up even when disabled\" error. If you right click on a word nothing happens (just as it is supposed to be) now klick \"Find Next Error\" and there it is (not supposed to be)\n\nlkjds klsdjfio jlk sdjfi lsdifuioew rlsoidf sjdiuf oipds jifpodsuf ");
radRichTextEditor1.IsContextMenuEnabled = false;
}
private void dropdown_PopupOpening(object sender, CancelEventArgs args)
{
args.Cancel = true;
}
Workaround:
public Form1()
{
InitializeComponent();
richTextEditorRibbonBar1.AssociatedRichTextEditor = radRichTextEditor1;
radRichTextEditor1.Insert("This is a example for the \"ContextMenu shows up even when disabled\" error. If you right click on a word nothing happens (just as it is supposed to be) now klick \"Find Next Error\" and there it is (not supposed to be)\n\nlkjds klsdjfio jlk sdjfi lsdifuioew rlsoidf sjdiuf oipds jifpodsuf ");
radRichTextEditor1.IsContextMenuEnabled = false;
FieldInfo fi = this.radRichTextEditor1.RichTextBoxElement.ContextMenu.GetType().GetField("radDropDownMenu", BindingFlags.Instance | BindingFlags.NonPublic);
RadDropDownMenu dropdown = fi.GetValue(this.radRichTextEditor1.RichTextBoxElement.ContextMenu) as RadDropDownMenu;
if (dropdown != null)
{
dropdown.PopupOpening += dropdown_PopupOpening;
}
}
private void dropdown_PopupOpening(object sender, CancelEventArgs args)
{
args.Cancel = true;
}
To reproduce: - Write some text. - Change the current user. - Repeat three or four times. - Open spellchecking dialog.
Workaround: handle the CommandExecuted event and manually adjust the location of these forms
public Form1()
{
InitializeComponent();
this.radRichTextEditor1.CommandExecuted += radRichTextEditor1_CommandExecuted;
}
private void radRichTextEditor1_CommandExecuted(object sender, Telerik.WinForms.Documents.RichTextBoxCommands.CommandExecutedEventArgs e)
{
if (e.Command is ShowInsertSymbolWindowCommand)
{
((InsertSymbolDialog)this.radRichTextEditor1.RichTextBoxElement.InsertSymbolWindow).Location = Screen.FromControl(this).WorkingArea.Location;
}
else if (e.Command is ShowFindReplaceDialogCommand)
{
((FindReplaceDialog)this.radRichTextEditor1.RichTextBoxElement.FindReplaceDialog).Location = Screen.FromControl(this).WorkingArea.Location;
}
}