/**
 * The visible text of a rich-text field, with markup and `&nbsp;` removed.
 *
 * Used for two "is this actually empty?" questions the raw HTML cannot answer:
 * validation (an editor left untouched still emits `<p></p>`) and deciding
 * whether an English description differs from the Arabic one.
 */
export const richTextToPlain = (value?: string | null): string =>
  (value || "")
    .replace(/<[^>]*>/g, "")
    .replace(/&nbsp;/g, " ")
    .trim();
