Skip to content

Commit 42956bf

Browse files
authored
Fix preview gap (#40)
2 parents 6f5def5 + db8d03f commit 42956bf

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

browser-extension/src/lib/enhancers/modifyDOM.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)