import { checkboxHtmlForTiptap, checkboxHtmlFromTiptap, } from './checkboxHtmlNormalizer'; export function prepareHtmlForTiptap(html: string): string { html = checkboxHtmlForTiptap(html); html = html.replace(//gi, '

'); return html; } export function normalizeHtmlFromTiptap(html: string): string { html = checkboxHtmlFromTiptap(html); // Strip

wrappers inside

  • elements. // TipTap renders
  • text

  • but native expects
  • text
  • . // This regex is safe because EnrichedListItem.content is 'paragraph', which // prevents TipTap from ever emitting nested lists html = html.replace(/]*)>

    (.*?)<\/p><\/li>/gs, '$2'); // Convert remaining empty

    to
    (outside of lists) html = html.replace(/

    <\/p>/g, '
    '); // Convert tags to self-closing tags html = html.replace(/]*)>/gi, (_, attrs: string) => { if (attrs.trimEnd().endsWith('/')) { return ``; } return ``; }); return `${html}`; }