If the position is moved to the end of a paragraph by clicking with the mouse in the empty space just left of the paragraph text, sometimes the subsequent text input (typing, pasting) is inserted at the beginning of the next paragraph, instead of at the end of the clicked one. The issue is somewhat random and cannot be reproduced consistently, though it's not hard to reproduce if clicking and typing is fast enough.
When importing image with invalid ur/base64 encoded data the document won't be opened correctly and an exception will be thrown. Load default image instead of throwing exception and failing to open the document.
The scenario:
We have a document with text inside and we are executing the following steps:
Observed: Before releasing the mouse button the cursor position is correct but after releasing it the cursor position is changed to the initial selection end.
A user reported a significant performance impact with the RichTextBox in our recent update. The UI hangs repeatedly while typing.
Profiling showed a lot of garbage collections, and profiling highlighted the the Telerik class Telerik.Windows.Controls.MarkupExtensions.DocumentsResourceProvider.
#if NETCORE
private static Style ThemeStyle
{
get
{
if (themeStyle == null)
{
themeStyle = GetStyleFromApplicationTheme();
}
return themeStyle;
}
}
private static Style GetStyleFromApplicationTheme()
{
if (StyleManager.IsEnabled && StyleManager.ApplicationTheme != null)
{
var themeName = StyleManager.ApplicationTheme.GetType().Name.Trim('_').ToLower();
themeName = themeName.Replace("theme", string.Empty);
var themesGeneric = Application.LoadComponent(new Uri("/Telerik.Windows.Controls.RichTextBox;component/themes/generic.xaml", UriKind.Relative)) as ResourceDictionary;
if (themesGeneric != null)
{
var currentThemeDictionary = themesGeneric.MergedDictionaries.FirstOrDefault(rd => rd.Source != null && rd.Source.OriginalString.ToLower().Contains(themeName));
if (currentThemeDictionary != null)
{
return currentThemeDictionary[typeof(DocumentsResourceProvider)] as Style;
}
}
}
return null;
}
I copied this code into my project to debug it, and found:
As the method returns null, it means themeStyle is always null, and it will try again on the next caller. This code is called repeatedly while typing. Using my code (and reflection) to force this ThemeStyle to Fluent fixes the performance, though obviously is a huge workaround.
When ScaleFactor is set to less that (1,1), this causes the caret to disappear at specific positions in the document. These positions depend on the exact value of the scale factor. The focus is still in the editor and users can type. Note that if the scale factor changes, the positions where the caret is not visualized will change as well.
Add support for line numbering in paged layout mode, similar to MS Word.
RichTextBox: The RepeatButtonStyle is not merged in the RichTextBox Xaml file when declaring the styles on a window level.
Workaround: Add the dictionaries to the App.xaml file instead of the Window file.
User is not able to select the current date wen Date Picker content control is used.
Select another date and then the current one as a workaround.
If there is an empty cell with a permission range and you go to it by pressing the Tab key from the previous cell and then start typing it removes the annotation range. If the cell with the permission range is not empty and the same technique is used there is an InvalidOperationException thrown with the message: "Selection contains uneditable ranges".
Here is a workaround:
this.radRichTextBox.CommandExecuted += this.RadRichTextBox_CommandExecuted;
private void RadRichTextBox_CommandExecuted(object sender, CommandExecutedEventArgs e)
{
if (e.Command is TabForwardCommand)
{
DocumentPosition caret = this.radRichTextBox.Document.CaretPosition;
if (caret.IsPositionInsideTable)
{
DocumentSelection selection = this.radRichTextBox.Document.Selection;
DocumentPosition start = selection.Ranges.First.StartPosition;
DocumentPosition end = selection.Ranges.Last.EndPosition;
Inline currentInline = start.GetCurrentInline();
if (currentInline is PermissionRangeStart)
{
start.MoveToNext();
}
Inline previousInline = end.GetPreviousInline();
if (previousInline is PermissionRangeEnd)
{
end.MoveToPrevious();
}
this.radRichTextBox.Document.Selection.SetSelectionStart(start);
this.radRichTextBox.Document.Selection.AddSelectionEnd(end);
}
}
}
First, you need to subscribe to the CommandExecuted event. Then change the selection after a TabForwardCommand to exclude the PermissionRangeStart and PermissionRangeEnd elements. Your workaround also works, so there is no need to change it.
foreach (Span span in paragraphCopy.EnumerateChildrenOfType<Span>())
{
if (string.IsNullOrEmpty(span.Text))
{
span.Text = " ";
}
}