UNPKG

datocms-html-to-structured-text

Version:

Convert HTML (or a `hast` syntax tree) to a valid DatoCMS Structured Text `dast` document

21 lines 1.15 kB
import type { Root as HastRoot } from 'hast'; import visitNode from './visit-node.js'; import visitChildren from './visit-children.js'; import type { DefaultTreeAdapterMap } from 'parse5'; import { Document, Mark, BlockquoteType, CodeType, HeadingType, LinkType, ListType, Heading } from 'datocms-structured-text-utils'; import type { Handler } from './types.js'; export type Options = Partial<{ newlines: boolean; handlers: Record<string, Handler>; preprocess: (hast: HastRoot) => void; allowedBlocks: Array<BlockquoteType | CodeType | HeadingType | LinkType | ListType>; allowedHeadingLevels: Heading['level'][]; allowedMarks: Mark[]; shared: Record<string, unknown>; }>; export declare function htmlToStructuredText(html: string, options?: Options): Promise<Document | null>; export declare function parse5ToStructuredText(document: DefaultTreeAdapterMap['document'], options?: Options): Promise<Document | null>; export declare function hastToStructuredText(tree: HastRoot, options?: Options): Promise<Document | null>; export { visitNode, visitChildren }; export * from './types.js'; //# sourceMappingURL=index.d.ts.map