mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-15 06:33:55 +01:00
Merge pull request #8001 from overleaf/ta-td-refactor-learned-words
Refactor Learned Words Class GitOrigin-RevId: eae6558b5d4eb03b95df511d1cd9ba35b22bb344
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import getMeta from '../../utils/meta'
|
||||
import { IGNORED_MISSPELLINGS } from '../../ide/editor/directives/aceEditor/spell-check/IgnoredMisspellings'
|
||||
|
||||
export class IgnoredWords {
|
||||
public learnedWords: Set<string>
|
||||
private ignoredMisspellings: Set<string>
|
||||
|
||||
constructor() {
|
||||
this.reset()
|
||||
this.ignoredMisspellings = new Set(IGNORED_MISSPELLINGS)
|
||||
}
|
||||
|
||||
reset() {
|
||||
this.learnedWords = new Set(getMeta('ol-learnedWords'))
|
||||
}
|
||||
|
||||
add(wordText) {
|
||||
this.learnedWords.add(wordText)
|
||||
window.dispatchEvent(
|
||||
new CustomEvent('learnedWords:add', { detail: wordText })
|
||||
)
|
||||
}
|
||||
|
||||
has(wordText) {
|
||||
return (
|
||||
this.ignoredMisspellings.has(wordText) || this.learnedWords.has(wordText)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export default new IgnoredWords()
|
||||
Reference in New Issue
Block a user