react-text-to-speech
Advanced tools
Comparing version 1.1.2 to 1.2.0
@@ -14,3 +14,3 @@ import { DetailedHTMLProps, HTMLAttributes, JSX, ReactNode } from "react"; | ||
export type UseSpeechOptions = { | ||
text: string | JSX.Element; | ||
text: ReactNode; | ||
pitch?: number; | ||
@@ -17,0 +17,0 @@ rate?: number; |
@@ -10,8 +10,6 @@ import { isValidElement } from "react"; | ||
export function JSXToArray(node) { | ||
if (isValidElement(node)) { | ||
const { children } = node.props; | ||
if (Array.isArray(children)) | ||
return children.map(JSXToArray); | ||
return JSXToArray(children); | ||
} | ||
if (Array.isArray(node)) | ||
return node.map(JSXToArray); | ||
if (isValidElement(node)) | ||
return JSXToArray(node.props.children); | ||
return typeof node === "string" ? node : typeof node === "number" ? String(node) : ""; | ||
@@ -18,0 +16,0 @@ } |
{ | ||
"name": "react-text-to-speech", | ||
"version": "1.1.2", | ||
"version": "1.2.0", | ||
"description": "An easy-to-use React.js component that leverages the Web Speech API to convert text to speech.", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -9,13 +9,13 @@ # react-text-to-speech | ||
- Highlights words as they are read aloud. See: | ||
- [Highlighting text with `useSpeech` hook](https://rtts.vercel.app/docs/usage/useSpeech#highlight-text). | ||
- [Highlighting text with `Speech` component](https://rtts.vercel.app/docs/usage/speech#highlight-text). | ||
- [Highlighting text with the `useSpeech` hook](/docs/usage/useSpeech#highlight-text). | ||
- [Highlighting text with the `Speech` component](/docs/usage/speech#highlight-text). | ||
- Provides an API for handling errors and events: | ||
- [Error handling with `useSpeech` hook](https://rtts.vercel.app/docs/usage/useSpeech#handling-errors-and-events). | ||
- [Error handling with `Speech` component](https://rtts.vercel.app/docs/usage/speech#handling-errors-and-events). | ||
- [Handling errors and events with the `useSpeech` hook](/docs/usage/useSpeech#handling-errors-and-events). | ||
- [Handling errors and events with the `Speech` component](/docs/usage/speech#handling-errors-and-events). | ||
- Manages multiple speech instances: | ||
- [Multiple instances with `useSpeech` hook](https://rtts.vercel.app/docs/usage/useSpeech#multiple-instance-usage). | ||
- [Multiple instances with `Speech` component](https://rtts.vercel.app/docs/usage/speech#multiple-instance-usage). | ||
- [Multiple instances with the `useSpeech` hook](/docs/usage/useSpeech#multiple-instance-usage). | ||
- [Multiple instances with the `Speech` component](/docs/usage/speech#multiple-instance-usage). | ||
- Fully customizable for various use cases: | ||
- [Customizing `useSpeech` hook](https://rtts.vercel.app/docs/usage/useSpeech). | ||
- [Customizing `Speech` component](https://rtts.vercel.app/docs/usage/speech#full-customization). | ||
- [Using the `useSpeech` hook](/docs/usage/useSpeech). | ||
- [Customizing the `Speech` component](/docs/usage/speech#full-customization). | ||
- Overcomes the [Web Speech API's text length limit](https://developer.mozilla.org/en-US/docs/Web/API/SpeechSynthesisUtterance/text), enabling infinite text input. | ||
@@ -22,0 +22,0 @@ - Automatically stops speech instances when the component unmounts. |
35182
597