List numbering should be restarted when copied list is pasted after content that is not in a list.
Steps to reproduce:
1. Create a file with a list, a blank line, some text, and another blank line
2. Copy the list
3. Paste it on the blank line directly after the list
Expected: The items are added to the end of the existing list
Observed: The items are added to the end of the existing list
4. Paste it on the blank line after the text
Expected: The items are added to a new list and start numbering at 1
Observed: The items are added to the existing list and start numbering at 7
Workaround:
private void RadRichTextBox_CommandExecuting(object sender, Telerik.Windows.Documents.RichTextBoxCommands.CommandExecutingEventArgs e)
{
if (e.Command is PasteCommand)
{
DocumentPosition position = new DocumentPosition(this.radRichTextBox.Document);
position.MoveToPosition(this.radRichTextBox.Document.CaretPosition);
position.MoveUp();
Paragraph previousParagraph = position.GetCurrentParagraphBox().AssociatedParagraph;
if (previousParagraph.IsInList)
{
// We shouldn't restart the numbering when the previous paragraph is in a list.
return;
}
RadDocument doc = ClipboardEx.GetDocument().ToDocument();
Paragraph firstParagraph = doc.EnumerateChildrenOfType<Paragraph>().First();
if (firstParagraph != null && firstParagraph.IsInList)
{
RadDocumentEditor editor = new RadDocumentEditor(doc);
editor.Document.CaretPosition.MoveToStartOfDocumentElement(firstParagraph);
editor.RestartListNumbering();
}
this.radRichTextBox.InsertFragment(new DocumentFragment(doc));
e.Cancel = true;
}
}