Disable grammarly extension on host element

This commit is contained in:
Aljaž Grilc 2024-05-24 08:50:24 +02:00
parent 5871f38f26
commit 033b56329f

View File

@ -31,6 +31,17 @@ class BesService {
this.originalSpellcheck = this.hostElement.spellcheck this.originalSpellcheck = this.hostElement.spellcheck
this.hostElement.spellcheck = false this.hostElement.spellcheck = false
// This is coppied from https://stackoverflow.com/questions/37444906/how-to-stop-extensions-add-ons-like-grammarly-on-contenteditable-editors
this.originalDataGramm = this.hostElement.getAttribute('data-gramm')
this.originalDataGrammEditor =
this.hostElement.getAttribute('data-gramm_editor')
this.originalEnableGrammarly = this.hostElement.getAttribute(
'data-enable-grammarly'
)
this.hostElement.setAttribute('data-gramm', 'false')
this.hostElement.setAttribute('data-gramm_editor', 'false')
this.hostElement.setAttribute('data-enable-grammarly', 'false')
this.onScroll = this.onScroll.bind(this) this.onScroll = this.onScroll.bind(this)
this.hostElement.addEventListener('scroll', this.onScroll) this.hostElement.addEventListener('scroll', this.onScroll)
@ -48,6 +59,12 @@ class BesService {
besServices = besServices.filter(item => item !== this) besServices = besServices.filter(item => item !== this)
this.resizeObserver.disconnect() this.resizeObserver.disconnect()
this.hostElement.removeEventListener('scroll', this.onScroll) this.hostElement.removeEventListener('scroll', this.onScroll)
this.hostElement.setAttribute('spellcheck', this.originalSpellcheck)
this.hostElement.setAttribute('data-gramm', this.originalDataGramm)
this.hostElement.setAttribute(
'data-gramm_editor',
this.originalDataGrammEditor
)
this.hostElement.spellcheck = this.originalSpellcheck this.hostElement.spellcheck = this.originalSpellcheck
this.clearCorrectionPanel() this.clearCorrectionPanel()
} }