@@ -6,30 +6,59 @@ export default defineContentScript({
66 return ;
77 }
88
9- const ghCommentBox = document . getElementById ( "new_comment_field" ) as
10- | HTMLTextAreaElement
11- | undefined ;
9+ const ghCommentBox = document . getElementById (
10+ "new_comment_field"
11+ ) as HTMLTextAreaElement | null ;
1212 if ( ghCommentBox ) {
1313 const overtypeContainer = modifyGithubDOM ( ghCommentBox ) ;
1414 new OverType ( overtypeContainer , {
1515 placeholder : "Add your comment here..." ,
1616 autoResize : true ,
1717 minHeight : "102px" ,
18+ padding : "var(--base-size-8)" ,
1819 } ) ;
1920 }
2021 } ,
2122 matches : [ "<all_urls>" ] ,
2223 runAt : "document_end" ,
2324} ) ;
2425
25- function modifyGithubDOM ( ghCommentBox : HTMLTextAreaElement ) {
26+ function modifyGithubDOM ( ghCommentBox : HTMLTextAreaElement ) : HTMLElement {
2627 ghCommentBox . classList . add ( "overtype-input" ) ;
2728 const previewDiv = document . createElement ( "div" ) ;
2829 previewDiv . classList . add ( "overtype-preview" ) ;
2930 ghCommentBox . insertAdjacentElement ( "afterend" , previewDiv ) ;
3031 const ghCommentWrapper = ghCommentBox . parentElement ! . closest ( "div" ) ! ;
3132 ghCommentWrapper . classList . add ( "overtype-wrapper" ) ;
33+ injectGithubStyles ( {
34+ commentBox : ghCommentBox ,
35+ commentWrapper : ghCommentWrapper ,
36+ overtypePreviewDiv : previewDiv ,
37+ } ) ;
3238 const ghCommentContainer = ghCommentWrapper . parentElement ! . closest ( "div" ) ! ;
3339 ghCommentContainer . classList . add ( "overtype-container" ) ;
3440 return ghCommentContainer . parentElement ! . closest ( "div" ) ! ;
3541}
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" ;
64+ }
0 commit comments