using DocumentFormat.OpenXml; namespace AIStudio.Tools.OpenXml; internal static class OpenXmlElementExtensions { /// The element. /// The type of the element. extension(T element) where T : OpenXmlElement { /// /// Takes the element out of its parent, if it has one, so that it can move to another place. /// /// /// Moving keeps everything within the element, e.g., a text box with the new words of its own paragraphs, /// which a copy made before those were written would lack. /// /// The element, without a parent. public T Detached() { if (element.Parent is not null) element.Remove(); return element; } } }