/**
 * The dashboard's page form is a plain textarea, so an admin usually types
 * plain text with line breaks and "- " bullets (the live About / Privacy /
 * Terms content is exactly that). Injected as HTML, the browser collapses every
 * line break and the whole page becomes one paragraph.
 *
 * A body with no block-level markup is plain text: it keeps its line breaks
 * (`white-space: pre-line` on `.cms-plain`). A body that already has paragraphs,
 * lists, headings or `<br>` is real rich text and is rendered untouched.
 */
const BLOCK_MARKUP = /<\s*(p|br|ul|ol|li|h[1-6]|div|table|blockquote|pre)(\s|\/|>)/i;

export function isPlainCmsText(html: string | null | undefined): boolean {
  return typeof html === "string" && html.trim() !== "" && !BLOCK_MARKUP.test(html);
}
