// ............................................................. // // Pasting // // ............................................................. // Handles a special case for pasting a single embedded element - // needs to choose between BlockUIContainer and InlineUIContainer. private static bool PasteSingleEmbeddedElement(TextRange range, TextElement fragment) { if (fragment.ContentStart.GetOffsetToPosition(fragment.ContentEnd) == 3) { TextElement uiContainer = fragment.ContentStart.GetAdjacentElement(LogicalDirection.Forward) as TextElement; FrameworkElement embeddedElement = null; if (uiContainer is BlockUIContainer) { embeddedElement = ((BlockUIContainer)uiContainer).Child as FrameworkElement; if (embeddedElement != null) { ((BlockUIContainer)uiContainer).Child = null; } } else if (uiContainer is InlineUIContainer) { embeddedElement = ((InlineUIContainer)uiContainer).Child as FrameworkElement; if (embeddedElement != null) { ((InlineUIContainer)uiContainer).Child = null; } } if (embeddedElement != null) { range.InsertEmbeddedUIElement(embeddedElement); return true; } } return false; }