Introduce an option to replace a Run text with line breaks and/or new lines or with other document elements such as Table, Image, Paragraph and etc.
The following code snippet shows how a Run can be replaced with another inline element:
RadFlowDocument document = new RadFlowDocument();
RadFlowDocumentEditor editor = new RadFlowDocumentEditor(document);
editor.InsertText("text");
editor.InsertText("REMOVE");
editor.InsertText("text");
foreach (Run run in document.EnumerateChildrenOfType<Run>().ToList())
{
if (run.Text == "REMOVE")
{
Paragraph paragraph = run.Paragraph;
int childIndex = paragraph.Inlines.IndexOf(run);
ImageInline image = new ImageInline(document);
using (Stream stream = File.OpenRead("example_image.png"))
{
image.Image.ImageSource = new Telerik.Windows.Documents.Media.ImageSource(stream, "png");
}
paragraph.Inlines.Insert(childIndex, image);
paragraph.Inlines.Remove(run);
}
}