react-text-to-speech
Advanced tools
Comparing version 0.19.3 to 0.19.4
@@ -9,2 +9,3 @@ export declare const desktopChunkSize = 1000; | ||
}; | ||
export declare const sanitizeRegex: RegExp; | ||
export declare const utterancePropertiesAndEvents: (keyof SpeechSynthesisUtterance)[]; |
@@ -6,4 +6,5 @@ export const desktopChunkSize = 1000; | ||
export const symbolMapping = { "<": "lessthan", ">": "greaterthan" }; | ||
export const sanitizeRegex = new RegExp(`[${Object.keys(symbolMapping).join("")}]|(&[^\s;]+);`, "g"); | ||
const utteranceProperties = ["lang", "voice", "volume", "rate", "pitch"]; | ||
const utteranceEvents = ["onstart", "onend", "onerror", "onpause", "onresume", "onmark", "onboundary"]; | ||
export const utterancePropertiesAndEvents = utteranceProperties.concat(utteranceEvents); |
import { isValidElement } from "react"; | ||
import { desktopChunkSize, minChunkSize, mobileChunkSize, specialSymbol, symbolMapping, utterancePropertiesAndEvents } from "./constants.js"; | ||
import { desktopChunkSize, minChunkSize, mobileChunkSize, sanitizeRegex, specialSymbol, symbolMapping, utterancePropertiesAndEvents } from "./constants.js"; | ||
import { setState } from "./state.js"; | ||
@@ -85,2 +85,2 @@ export function ArrayToText(element) { | ||
} | ||
export const sanitize = (text) => text.replace(/[<>]|(&[^\s;]+);/g, (match, group) => (group ? group + ")" : ` ${symbolMapping[match]}${specialSymbol}`)); | ||
export const sanitize = (text) => text.replace(sanitizeRegex, (match, group) => (group ? group + ")" : ` ${symbolMapping[match]}${specialSymbol}`)); |
{ | ||
"name": "react-text-to-speech", | ||
"version": "0.19.3", | ||
"version": "0.19.4", | ||
"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", |
@@ -99,2 +99,2 @@ # react-text-to-speech | ||
Show your ❤️ and support by giving a ⭐. Any suggestions are welcome! Take a look at the [contributing guide](https://github.com/SahilAggarwal2004/react-text-to-speech/blob/master/CONTRIBUTING.md). | ||
Show your ❤️ and support by giving a ⭐. Any suggestions are welcome! Take a look at the [contributing guide](https://github.com/SahilAggarwal2004/react-text-to-speech/blob/master/CONTRIBUTING.md). |
31159
535
100