Utilities for serializing slate data
npm install @voiceflow/slate-serializerUtilities for converting slate data into raw text or JSX.
``sh`
yarn add @voiceflow/slate-serializer @voiceflow/dtos-interact slateor
npm install @voiceflow/slate-serializer @voiceflow/dtos-interact slate
If you want to use the JSX serializer make sure to install react.
`sh`
yarn add reactor
npm install react
You can access type guards and other extraction utilities through the main import.
`tsx`
import { isLinkElement, getTextCSSProperties } from '@voiceflow/react-chat';
If you need the textual representation you can import the text serializer.
`tsx
import { serializeToText } from '@voiceflow/react-chat/text';
const text = serializeToText(slateValue);
`
You can turn off encodeVariables to avoid encoding variables in the text.
`tsx
import { serializeToText } from '@voiceflow/react-chat/text';
const textWithoutVariables = serializeToText(slateValue, { encodeVariables: false });
`
If you want to render the result in a browser you can serialize to JSX.
`tsx
import { serializeToJSX } from '@voiceflow/react-chat/jsx';
const content =
$3
If you want to render the result in a browser you can serialize to JSX.
`tsx
import { serializeToMarkdown } from '@voiceflow/react-chat/markdown';const content =
{serializeToMarkdown(slateValue)};
``