@contentstack/utils
Version:
Contentstack utilities for Javascript
22 lines (21 loc) • 1.09 kB
TypeScript
import Node from './nodes/node';
import TextNode from './nodes/text-node';
import { EntryEmbedable } from './Models/embedded-object';
import { RenderOption } from './options';
export type AnyNode = TextNode | Node;
/**
* Converts Supercharged RTE (JSON) content to HTML for one or more entries.
* Walks the given paths on each entry, finds JSON RTE content, resolves embedded
* items from the entry, and renders nodes using the optional renderOption. Mutates
* the entry JSON in-place by replacing content with the generated HTML.
*
* @param option - Configuration for conversion.
* @param option.entry - Entry or array of entries that contain Supercharged RTE (JSON) fields.
* @param option.paths - Key paths to the JSON RTE fields (e.g. `['rte_field_uid', 'group.rte_uid']`).
* @param option.renderOption - Optional render options to customize how nodes and embedded items are rendered to HTML.
*/
export declare function jsonToHTML(option: {
entry: EntryEmbedable | EntryEmbedable[];
paths: string[];
renderOption?: RenderOption;
}): void;