@@ -14,13 +14,7 @@ export interface TextareaHandler<T extends CommentContext = CommentContext> {
1414 forCommentTypes ( ) : string [ ] ;
1515 // whenever a new `textarea` is added to any webpage, this method is called to try to find a handler for it
1616 identifyContextOf ( textarea : HTMLTextAreaElement ) : TextareaInfo | null ;
17-
18- // Content script functionality
19- identify ( ) : TextareaInfo < T > [ ] ;
20- readContent ( textarea : HTMLTextAreaElement ) : string ;
21- setContent ( textarea : HTMLTextAreaElement , content : string ) : void ;
22- onSubmit ( textarea : HTMLTextAreaElement , callback : ( success : boolean ) => void ) : void ;
23-
17+
2418 // Context extraction
2519 extractContext ( textarea : HTMLTextAreaElement ) : T | null ;
2620 determineType ( textarea : HTMLTextAreaElement ) : string | null ;
@@ -40,29 +34,9 @@ export abstract class BaseTextareaHandler<T extends CommentContext = CommentCont
4034
4135 abstract forCommentTypes ( ) : string [ ] ;
4236 abstract identifyContextOf ( textarea : HTMLTextAreaElement ) : TextareaInfo < T > | null ;
43- abstract identify ( ) : TextareaInfo < T > [ ] ;
4437 abstract extractContext ( textarea : HTMLTextAreaElement ) : T | null ;
4538 abstract determineType ( textarea : HTMLTextAreaElement ) : string | null ;
4639 abstract generateDisplayTitle ( context : T ) : string ;
4740 abstract generateIcon ( type : string ) : string ;
4841 abstract buildUrl ( context : T , withDraft ?: boolean ) : string ;
49-
50- readContent ( textarea : HTMLTextAreaElement ) : string {
51- return textarea . value ;
52- }
53-
54- setContent ( textarea : HTMLTextAreaElement , content : string ) : void {
55- textarea . value = content ;
56- textarea . dispatchEvent ( new Event ( 'input' , { bubbles : true } ) ) ;
57- textarea . dispatchEvent ( new Event ( 'change' , { bubbles : true } ) ) ;
58- }
59-
60- onSubmit ( textarea : HTMLTextAreaElement , callback : ( success : boolean ) => void ) : void {
61- const form = textarea . closest ( 'form' ) ;
62- if ( form ) {
63- form . addEventListener ( 'submit' , ( ) => {
64- setTimeout ( ( ) => callback ( true ) , 100 ) ;
65- } , { once : true } ) ;
66- }
67- }
6842}
0 commit comments