Skip to content

Commit

Permalink
fix: vocabulary highlights
Browse files Browse the repository at this point in the history
  • Loading branch information
yetone committed May 1, 2023
1 parent 80f8264 commit 303a7d6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/content_script/PopupCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,9 @@ export function PopupCard(props: IPopupCardProps) {
setEditableText(originalText)
setSelectedWord('')
}, [originalText, props.uuid])
useEffect(() => {
setHighlightWords([])
}, [props.uuid])
const [originalLang, setOriginalLang] = useState('')
const [targetLang, setTargetLang] = useState('')
const stopAutomaticallyChangeTargetLang = useRef(false)
Expand Down
6 changes: 5 additions & 1 deletion src/content_script/Vocabulary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,11 @@ const Vocabulary = (props: IVocabularyProps) => {
} else {
articleTxt.current += message.content
}
if (articleUsedWord.current?.includes(message.content.toLowerCase().trim())) {
if (
articleUsedWord.current?.find(
(word) => word.toLowerCase().trim() === message.content.toLowerCase().trim()
)
) {
return e + `<b style="color: #f40;">${message.content}</b>`
} else {
return e + message.content
Expand Down

0 comments on commit 303a7d6

Please sign in to comment.