File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
browser-extension/src/lib/enhancers Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -26,5 +26,23 @@ export function modifyDOM(overtypeInput: HTMLTextAreaElement): HTMLElement {
2626 attributes : true ,
2727 } )
2828
29+ // Find the button that contains the text "Preview"
30+ const writePreviewTabs = Array . from (
31+ ( overtypeContainer . firstElementChild as HTMLElement ) . querySelectorAll ( 'button' ) ,
32+ )
33+ const writeTab = writePreviewTabs . find ( ( button ) => button . textContent . includes ( 'Write' ) )
34+ const previewTab = writePreviewTabs . find ( ( button ) => button . textContent . includes ( 'Preview' ) )
35+
36+ if ( writeTab && previewTab ) {
37+ // Hide the textarea when the user is on the "Preview" tab
38+ writeTab . addEventListener ( 'click' , ( ) => {
39+ overtypeWrapper . style . display = 'inline-block'
40+ } )
41+
42+ previewTab . addEventListener ( 'click' , ( ) => {
43+ overtypeWrapper . style . display = 'none'
44+ } )
45+ }
46+
2947 return overtypeContainer . parentElement ! . closest ( 'div' ) !
3048}
You can’t perform that action at this time.
0 commit comments