Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
updateContentAndStats () {
this.content = this.convertHtmlToTxt(this.contentHTML)
// Store backup content (only if there is valid text)
if (this.content && this.content.length > 0) {
LocalStorage.set(CONTENT_BACKUP_KEY, this.contentHTML)
}
else {
LocalStorage.remove(CONTENT_BACKUP_KEY)
}
this.sentences = this.content
.replace(/(\.+|:|;|\?|!)/g, '$1\n')
.split(/\n+\s*/)
.filter(n => n)
this.words = this.content
.split(/\s+/)
.filter(n => n)
},
processEditOperation (operation) {
updateStats: debounce(state => {
state.content = convertHtmlToTxt(state.contentHTML)
state.sentences = state.content
.replace(/(\.+|:|;|\?|!)/g, '$1\n')
.split(/\n+\s*/)
.filter(n => n)
state.words = state.content.split(/\s+/).filter(n => n)
if (state.words) {
LocalStorage.set(CONTENT_BACKUP_KEY, state.contentHTML)
} else {
LocalStorage.remove(CONTENT_BACKUP_KEY)
}
}, 100 /* Execute at most once every 100ms */)
},
toggle (key) {
if (LocalStorage.has(key)) {
LocalStorage.remove(key)
}
else {
LocalStorage.set(key, `${key}-value`)
}
this.update()
},
clear () {
LocalStorage.remove('chosen')
break
case 'CHANGE_CHOSEN':
if (action.data.want) {
state.chosen.push(action.data.id)
}
else {
let index = state.chosen.indexOf(action.data.id)
if (index >= 0) state.chosen.splice(index, 1)
}
if (state.chosen.length) {
LocalStorage.set('chosen', state.chosen.join(','))
}
else {
LocalStorage.remove('chosen')
}
break
case 'SEARCH_CHANGED':
state.page = 1
break
}
}