react-text-to-speech
Advanced tools
Comparing version 0.17.0 to 0.18.0
@@ -84,3 +84,9 @@ import React, { cloneElement, isValidElement, useEffect, useMemo, useRef, useState } from "react"; | ||
utterance.onboundary = (event) => { | ||
setSpeakingWord({ index: findCharIndex(words, offset + event.charIndex), length: event.charLength }); | ||
const { charIndex, charLength } = event; | ||
if (charLength && utterance.text[charIndex] === "\u200E") { | ||
setSpeakingWord({ index: findCharIndex(words, offset + charIndex - 1), length: 1 }); | ||
offset -= charLength + 1; | ||
} | ||
else | ||
setSpeakingWord({ index: findCharIndex(words, offset + charIndex), length: charLength }); | ||
onBoundary === null || onBoundary === void 0 ? void 0 : onBoundary(event); | ||
@@ -87,0 +93,0 @@ }; |
@@ -77,2 +77,2 @@ import { isValidElement } from "react"; | ||
} | ||
export const sanitize = (text) => text.replace(/[<>]|(&[^\s;]+);/g, (match, group) => (match === "<" ? "(" : (group || "") + ")")); | ||
export const sanitize = (text) => text.replace(/[<>]|(&[^\s;]+);/g, (match, group) => (match === "<" ? " \u200Eless-than " : match === ">" ? " \u200Egreater-than " : group + ")")); |
{ | ||
"name": "react-text-to-speech", | ||
"version": "0.17.0", | ||
"version": "0.18.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", |
28231
480