mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
24c8629cd4
GitOrigin-RevId: c4d0d9e06fe0cc9d7cb7a058fd0768eb024e44f5
62 lines
1.3 KiB
TypeScript
62 lines
1.3 KiB
TypeScript
import getMeta from '../../utils/meta'
|
|
|
|
export const globalLearnedWords = new Set([
|
|
'Overleaf',
|
|
'overleaf',
|
|
'ShareLaTeX',
|
|
'sharelatex',
|
|
'LaTeX',
|
|
'TeX',
|
|
'BibTeX',
|
|
'BibLaTeX',
|
|
'XeTeX',
|
|
'XeLaTeX',
|
|
'LuaTeX',
|
|
'LuaLaTeX',
|
|
'http',
|
|
'https',
|
|
'www',
|
|
'COVID',
|
|
'Lockdown',
|
|
'lockdown',
|
|
'Coronavirus',
|
|
'coronavirus',
|
|
])
|
|
|
|
export class IgnoredWords {
|
|
public learnedWords!: Set<string>
|
|
private readonly ignoredMisspellings: Set<string>
|
|
|
|
constructor() {
|
|
this.reset()
|
|
this.ignoredMisspellings = globalLearnedWords
|
|
window.addEventListener('learnedWords:doreset', () => this.reset()) // for tests
|
|
}
|
|
|
|
reset() {
|
|
this.learnedWords = new Set(getMeta('ol-learnedWords'))
|
|
window.dispatchEvent(new CustomEvent('learnedWords:reset'))
|
|
}
|
|
|
|
add(wordText: string) {
|
|
this.learnedWords.add(wordText)
|
|
window.dispatchEvent(
|
|
new CustomEvent('learnedWords:add', { detail: wordText })
|
|
)
|
|
}
|
|
|
|
remove(wordText: string) {
|
|
this.learnedWords.delete(wordText)
|
|
window.dispatchEvent(
|
|
new CustomEvent('learnedWords:remove', { detail: wordText })
|
|
)
|
|
}
|
|
|
|
has(wordText: string) {
|
|
return (
|
|
this.ignoredMisspellings.has(wordText) || this.learnedWords.has(wordText)
|
|
)
|
|
}
|
|
}
|
|
|
|
export default new IgnoredWords()
|