@@ -19,7 +19,6 @@ export interface EnhancedTextarea<T extends CommentSpot = CommentSpot> {
1919 spot : T
2020 enhancer : CommentEnhancer < T >
2121 overtype : OverTypeInstance
22- cleanup ?: ( ) => void
2322}
2423
2524export class EnhancerRegistry {
@@ -72,9 +71,9 @@ export class EnhancerRegistry {
7271 try {
7372 const spot = enhancer . tryToEnhance ( textarea , location )
7473 if ( spot ) {
75- const { instance : overtype , cleanup } = enhancer . enhance ( textarea , spot )
74+ const overtype = enhancer . enhance ( textarea , spot )
7675 this . handleDelayedValueInjection ( overtype )
77- return { enhancer, overtype, spot, textarea, ... ( cleanup && { cleanup } ) }
76+ return { enhancer, overtype, spot, textarea }
7877 }
7978 } catch ( error ) {
8079 console . warn ( 'Handler failed to identify textarea:' , error )
@@ -130,12 +129,15 @@ export class TextareaRegistry {
130129 this . sendEvent ( 'ENHANCED' , enhanced )
131130 }
132131
132+ private cleanupOvertype ( overtype : OverTypeInstance ) {
133+ const container = overtype . element
134+ OverType . instances . delete ( container )
135+ ; ( container as any ) . overTypeInstance = undefined
136+ }
133137 unregisterDueToModification ( textarea : HTMLTextAreaElement ) : void {
134138 const enhanced = this . textareas . get ( textarea )
135139 if ( enhanced ) {
136- if ( enhanced . cleanup ) {
137- enhanced . cleanup ( )
138- }
140+ this . cleanupOvertype ( enhanced . overtype )
139141 this . sendEvent ( 'DESTROYED' , enhanced )
140142 this . textareas . delete ( textarea )
141143 }
0 commit comments