View as Markdown

API reference: @salmonui/rich-text

htmlToBlocksfunction

import { htmlToBlocks } from '@salmonui/rich-text';
function htmlToBlocks(html: string): Block[];

Parses HTML into blocks (parseHtmlToBlocks). The HTML is sanitized first. Ids come from data-block-id; missing or duplicate ids get deterministic ones from the index path (b0, b2-1, ...), so server and client agree. Content the block model has no type for (iframe embeds, images inside text) is dropped.