arkynChangelogGuides

toHtml

The toHtml function converts a rich text value array into an HTML string.

Import

ts

import { toHtml } from "@arkyn/shared";

Parameters

The function accepts the following parameter:

richTextValue (required)

Array of rich text nodes to be serialized into HTML.
Type: RichTextValue

Usage example

The function returns an HTML string generated by serializing each rich text node and joining the result.
Type: string

typescript

import { toHtml } from "@arkyn/shared";
const richText = [
{
type: "paragraph",
children: [{ text: "Hello world", bold: true }],
},
];
const html = toHtml(richText);
console.log(html);
// Output: "<p><strong>Hello world</strong></p>"

Notes

  • The function serializes each node individually and concatenates the resulting HTML strings.
  • An empty rich text array returns an empty string.
  • Use this function when you need to persist or render editor content as HTML.
On this page