@@ -10,7 +10,7 @@ export default defineContentScript({
1010 "new_comment_field"
1111 ) as HTMLTextAreaElement | null ;
1212 if ( ghCommentBox ) {
13- const overtypeContainer = modifyGithubDOM ( ghCommentBox ) ;
13+ const overtypeContainer = modifyDOM ( ghCommentBox ) ;
1414 new OverType ( overtypeContainer , {
1515 placeholder : "Add your comment here..." ,
1616 autoResize : true ,
@@ -23,42 +23,15 @@ export default defineContentScript({
2323 runAt : "document_end" ,
2424} ) ;
2525
26- function modifyGithubDOM ( ghCommentBox : HTMLTextAreaElement ) : HTMLElement {
27- ghCommentBox . classList . add ( "overtype-input" ) ;
28- const previewDiv = document . createElement ( "div" ) ;
29- previewDiv . classList . add ( "overtype-preview" ) ;
30- ghCommentBox . insertAdjacentElement ( "afterend" , previewDiv ) ;
31- const ghCommentWrapper = ghCommentBox . parentElement ! . closest ( "div" ) ! ;
32- ghCommentWrapper . classList . add ( "overtype-wrapper" ) ;
33- injectGithubStyles ( {
34- commentBox : ghCommentBox ,
35- commentWrapper : ghCommentWrapper ,
36- overtypePreviewDiv : previewDiv ,
37- } ) ;
38- const ghCommentContainer = ghCommentWrapper . parentElement ! . closest ( "div" ) ! ;
39- ghCommentContainer . classList . add ( "overtype-container" ) ;
40- return ghCommentContainer . parentElement ! . closest ( "div" ) ! ;
41- }
42-
43- interface GithubDOM {
44- commentBox : HTMLTextAreaElement ;
45- commentWrapper : HTMLDivElement ;
46- overtypePreviewDiv : HTMLDivElement ;
47- }
48- function injectGithubStyles ( {
49- commentBox,
50- commentWrapper,
51- overtypePreviewDiv,
52- } : GithubDOM ) {
53- commentBox . placeholder = "Add your comment here..." ;
54- commentBox . style . fontFamily = "inherit !important" ;
55- commentBox . style . fontSize = "var(--text-body-size-medium) !important" ;
56- overtypePreviewDiv . style . fontFamily = "inherit !important" ;
57- overtypePreviewDiv . style . fontSize = "var(--text-body-size-medium) !important" ;
58- commentWrapper . style . margin = "var(--base-size-8) !important" ;
59- commentWrapper . style . border =
60- "var(--borderWidth-thin) solid var(--borderColor-default, var(--color-border-default)) !important" ;
61- commentWrapper . style . borderRadius = "var(--borderRadius-medium) !important" ;
62- commentWrapper . style . width =
63- "calc(100% - var(--stack-padding-condensed, 8px) * 2) !important" ;
26+ function modifyDOM ( overtypeInput : HTMLTextAreaElement ) : HTMLElement {
27+ overtypeInput . classList . add ( "overtype-input" ) ;
28+ const overtypePreview = document . createElement ( "div" ) ;
29+ overtypePreview . classList . add ( "overtype-preview" ) ;
30+ overtypeInput . insertAdjacentElement ( "afterend" , overtypePreview ) ;
31+ const overtypeWrapper = overtypeInput . parentElement ! . closest ( "div" ) ! ;
32+ overtypeWrapper . classList . add ( "overtype-wrapper" ) ;
33+ overtypeInput . placeholder = "Add your comment here..." ;
34+ const overtypeContainer = overtypeWrapper . parentElement ! . closest ( "div" ) ! ;
35+ overtypeContainer . classList . add ( "overtype-container" ) ;
36+ return overtypeContainer . parentElement ! . closest ( "div" ) ! ;
6437}
0 commit comments