View as Markdown

API reference: @salmonui/rich-text

SanitizeHookResulttype

import type { SanitizeHookResult } from '@salmonui/rich-text';
type SanitizeHookResult = undefined | null | 'keep' | 'remove' | 'unwrap' | {
    attrs: Record<string, string>;
};

What the sanitize hook returns for an element:

  • undefined / 'keep': keep it as is;
  • null / 'remove': remove it with its content;
  • 'unwrap': remove the element and keep its content;
  • { attrs }: keep it with these attributes. Only names the element already has are accepted and every value is validated again by the built-in rules, so the hook can drop or narrow attributes but never add one or re-enable a value the sanitizer refused.