2022-05-24 03:47:22 -04:00
|
|
|
import getMeta from '../../utils/meta'
|
2023-11-28 06:20:24 -05:00
|
|
|
|
|
|
|
const IGNORED_MISSPELLINGS = [
|
|
|
|
'Overleaf',
|
|
|
|
'overleaf',
|
|
|
|
'ShareLaTeX',
|
|
|
|
'sharelatex',
|
|
|
|
'LaTeX',
|
|
|
|
'TeX',
|
|
|
|
'BibTeX',
|
|
|
|
'BibLaTeX',
|
|
|
|
'XeTeX',
|
|
|
|
'XeLaTeX',
|
|
|
|
'LuaTeX',
|
|
|
|
'LuaLaTeX',
|
|
|
|
'http',
|
|
|
|
'https',
|
|
|
|
'www',
|
|
|
|
'COVID',
|
|
|
|
'Lockdown',
|
|
|
|
'lockdown',
|
|
|
|
'Coronavirus',
|
|
|
|
'coronavirus',
|
|
|
|
]
|
2022-05-24 03:47:22 -04:00
|
|
|
|
|
|
|
export class IgnoredWords {
|
2022-05-27 08:32:27 -04:00
|
|
|
public learnedWords!: Set<string>
|
2022-05-24 03:47:22 -04:00
|
|
|
private ignoredMisspellings: Set<string>
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
this.reset()
|
|
|
|
this.ignoredMisspellings = new Set(IGNORED_MISSPELLINGS)
|
2022-05-24 07:21:25 -04:00
|
|
|
window.addEventListener('learnedWords:doreset', () => this.reset()) // for tests
|
2022-05-24 03:47:22 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
reset() {
|
|
|
|
this.learnedWords = new Set(getMeta('ol-learnedWords'))
|
2022-05-24 07:21:25 -04:00
|
|
|
window.dispatchEvent(new CustomEvent('learnedWords:reset'))
|
2022-05-24 03:47:22 -04:00
|
|
|
}
|
|
|
|
|
2022-05-27 08:32:27 -04:00
|
|
|
add(wordText: string) {
|
2022-05-24 03:47:22 -04:00
|
|
|
this.learnedWords.add(wordText)
|
|
|
|
window.dispatchEvent(
|
|
|
|
new CustomEvent('learnedWords:add', { detail: wordText })
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2022-05-27 08:32:27 -04:00
|
|
|
remove(wordText: string) {
|
2022-05-24 07:21:25 -04:00
|
|
|
this.learnedWords.delete(wordText)
|
|
|
|
window.dispatchEvent(
|
|
|
|
new CustomEvent('learnedWords:remove', { detail: wordText })
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2022-05-27 08:32:27 -04:00
|
|
|
has(wordText: string) {
|
2022-05-24 03:47:22 -04:00
|
|
|
return (
|
|
|
|
this.ignoredMisspellings.has(wordText) || this.learnedWords.has(wordText)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default new IgnoredWords()
|