11import { IssueOpenedIcon } from '@primer/octicons-react'
22import OverType , { type OverTypeInstance } from 'overtype'
33import type React from 'react'
4- import type { CommentEnhancer , CommentSpot , StrippedLocation } from '@/lib/enhancer'
4+ import type {
5+ CommentEnhancer ,
6+ CommentSpot ,
7+ OvertypeWithCleanup ,
8+ StrippedLocation ,
9+ } from '@/lib/enhancer'
510import { logger } from '@/lib/logger'
611import { oncePerRefresh } from '@/lib/once-per-refresh'
712import { modifyDOM } from '../modifyDOM'
@@ -66,12 +71,12 @@ export class GitHubIssueAppendEnhancer implements CommentEnhancer<GitHubIssueApp
6671
6772 instance : OverTypeInstance | undefined
6873
69- enhance ( textArea : HTMLTextAreaElement , _spot : GitHubIssueAppendSpot ) : OverTypeInstance {
74+ enhance ( textArea : HTMLTextAreaElement , _spot : GitHubIssueAppendSpot ) : OvertypeWithCleanup {
7075 prepareGitHubHighlighter ( )
7176 const overtypeContainer = modifyDOM ( textArea )
7277 if ( this . instance ) {
7378 OverType . instances . delete ( overtypeContainer )
74- ; ( overtypeContainer as any ) . overTypeInstance = undefined
79+ ; ( overtypeContainer as any ) . overTypeInstance = undefined
7580 }
7681 this . registerSubmitHandler ( textArea , _spot )
7782 const thing = new OverType ( overtypeContainer , {
@@ -80,7 +85,7 @@ export class GitHubIssueAppendEnhancer implements CommentEnhancer<GitHubIssueApp
8085 placeholder : 'Use Markdown to format your comment' ,
8186 } ) [ 0 ] !
8287 this . instance = thing
83- return thing
88+ return { instance : thing }
8489 }
8590
8691 private registerSubmitHandler ( textArea : HTMLTextAreaElement , _spot : GitHubIssueAppendSpot ) {
@@ -90,7 +95,10 @@ export class GitHubIssueAppendEnhancer implements CommentEnhancer<GitHubIssueApp
9095 if ( target ) {
9196 const btn = ( e . target as HTMLElement ) . closest ( 'button' )
9297 if ( btn ) {
93- if ( btn . textContent . trim ( ) === 'Comment' || btn . matches ( 'button[data-variant="primary"]' ) ) {
98+ if (
99+ btn . textContent . trim ( ) === 'Comment' ||
100+ btn . matches ( 'button[data-variant="primary"]' )
101+ ) {
94102 this . enhance ( textArea , _spot )
95103 return true
96104 }
0 commit comments