2022-05-24 03:47:22 -04:00
|
|
|
import getMeta from '../../utils/meta'
|
2023-11-28 06:20:24 -05:00
|
|
|
|
2024-10-02 04:25:02 -04:00
|
|
|
export const globalLearnedWords = new Set([
|
2023-11-28 06:20:24 -05:00
|
|
|
'Overleaf',
|
|
|
|
'overleaf',
|
|
|
|
'ShareLaTeX',
|
|
|
|
'sharelatex',
|
|
|
|
'LaTeX',
|
|
|
|
'TeX',
|
|
|
|
'BibTeX',
|
|
|
|
'BibLaTeX',
|
|
|
|
'XeTeX',
|
|
|
|
'XeLaTeX',
|
|
|
|
'LuaTeX',
|
|
|
|
'LuaLaTeX',
|
|
|
|
'http',
|
|
|
|
'https',
|
|
|
|
'www',
|
|
|
|
'COVID',
|
|
|
|
'Lockdown',
|
|
|
|
'lockdown',
|
|
|
|
'Coronavirus',
|
|
|
|
'coronavirus',
|
2024-10-02 04:25:02 -04:00
|
|
|
])
|
2022-05-24 03:47:22 -04:00
|
|
|
|
|
|
|
export class IgnoredWords {
|
2022-05-27 08:32:27 -04:00
|
|
|
public learnedWords!: Set<string>
|
2024-10-02 04:25:02 -04:00
|
|
|
private readonly ignoredMisspellings: Set<string>
|
2022-05-24 03:47:22 -04:00
|
|
|
|
|
|
|
constructor() {
|
|
|
|
this.reset()
|
2024-10-02 04:25:02 -04:00
|
|
|
this.ignoredMisspellings = globalLearnedWords
|
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()
|