Fix unregister cleanup

This commit is contained in:
Simon Rozman 2025-02-27 16:03:45 +01:00
parent cf70e4128e
commit 16e85f5498

View File

@ -840,8 +840,8 @@ class BesService {
* Creates auxiliary DOM elements for text adornments.
*/
createCorrectionPanel() {
const panelParent = document.createElement('div')
panelParent.classList.add('bes-correction-panel-parent')
this.panelParent = document.createElement('div')
this.panelParent.classList.add('bes-correction-panel-parent')
this.correctionPanel = document.createElement('div')
this.correctionPanel.classList.add('bes-correction-panel')
@ -851,9 +851,12 @@ class BesService {
this.ctx = this.canvasPanel.getContext('2d')
this.ctx.scale(1, 1)
panelParent.appendChild(this.correctionPanel)
this.panelParent.appendChild(this.correctionPanel)
this.correctionPanel.appendChild(this.canvasPanel)
this.textElement.parentElement.insertBefore(panelParent, this.textElement)
this.textElement.parentElement.insertBefore(
this.panelParent,
this.textElement
)
this.setCorrectionPanelSize()
}
@ -861,8 +864,7 @@ class BesService {
* Clears auxiliary DOM elements for text adornments.
*/
clearCorrectionPanel() {
this.correctionPanel.remove()
this.canvasPanel.remove()
this.panelParent.remove()
}
/**
@ -2243,6 +2245,14 @@ class BesTAService extends BesPlainTextService {
return service
}
/**
* Unregisters grammar checking service.
*/
unregister() {
super.unregister()
this.textElement.remove()
}
/**
* Creates a clone div element for the <textarea> element
*