using System.Diagnostics.CodeAnalysis; using Umbraco.Cms.Core.Strings; namespace Umbraco.Extensions; public static class HtmlEncodedStringExtensions { /// /// Checks if the specified is null or only contains whitespace, optionally after all HTML tags have been stripped/removed. /// /// The encoded HTML string. /// If set to true strips/removes all HTML tags. /// /// Returns true if the HTML string is null or only contains whitespace, optionally after all HTML tags have been stripped/removed. /// public static bool IsNullOrWhiteSpace([NotNullWhen(false)] this IHtmlEncodedString? htmlEncodedString, bool stripHtml = false) => (htmlEncodedString?.ToHtmlString() is var htmlString && string.IsNullOrWhiteSpace(htmlString)) || (stripHtml && string.IsNullOrWhiteSpace(htmlString.StripHtml())); }