@voiceflow/slate-serializer
TypeScript icon, indicating that this package has built-in type declarations

1.6.0 • Public • Published

Slate Serializer

Utilities for converting slate data into raw text or JSX.

Installation

yarn add @voiceflow/slate-serializer @voiceflow/base-types slate
# or
npm install @voiceflow/slate-serializer @voiceflow/base-types slate

If you want to use the JSX serializer make sure to install react.

yarn add react
# or
npm install react

Usage

You can access type guards and other extraction utilities through the main import.

import { isLinkElement, getTextCSSProperties } from '@voiceflow/react-chat';

Text Serialization

If you need the textual representation you can import the text serializer.

import { serializeToText } from '@voiceflow/react-chat/text';

const text = serializeToText(slateValue);

You can turn off encodeVariables to avoid encoding variables in the text.

import { serializeToText } from '@voiceflow/react-chat/text';

const textWithoutVariables = serializeToText(slateValue, { encodeVariables: false });

JSX Serialization

If you want to render the result in a browser you can serialize to JSX.

import { serializeToJSX } from '@voiceflow/react-chat/jsx';

const content = <div>{serializeToJSX(slateValue)}</div>;

Markdown Serialization

If you want to render the result in a browser you can serialize to JSX.

import { serializeToMarkdown } from '@voiceflow/react-chat/markdown';

const content = <div>{serializeToMarkdown(slateValue)}</div>;

Readme

Keywords

Package Sidebar

Install

npm i @voiceflow/slate-serializer

Weekly Downloads

410

Version

1.6.0

License

ISC

Unpacked Size

51 kB

Total Files

50

Last publish

Collaborators

  • ose-voiceflow
  • theprof
  • bhuvana.adur.kannan
  • abuyak
  • e_vandenberg
  • ninabondar
  • yoyotruly
  • matthewnaik
  • edison-vflow
  • shelone.grantwatson
  • zhilight
  • amandasteinhauer
  • pmvrmc
  • filipemerker
  • viniciusdacal
  • trs
  • matheuspoleza
  • denyslinkov
  • andrewlawrence
  • tylerhhan
  • effervescentia
  • josh_vf
  • voiceflow-gallagan
  • z4o4z
  • xavidop
  • vf-serviceaccount