Skip to content

Commit 8fa7f19

Browse files
committed
Add the POC script as github-playground
1 parent f92f6cb commit 8fa7f19

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import OverType from "../overtype/overtype";
2+
3+
export function githubPrNewCommentContentScript() {
4+
if (window.location.hostname !== "github.com") {
5+
return;
6+
}
7+
8+
const ghCommentBox = document.getElementById(
9+
"new_comment_field"
10+
) as HTMLTextAreaElement | null;
11+
if (ghCommentBox) {
12+
const overtypeContainer = modifyDOM(ghCommentBox);
13+
new OverType(overtypeContainer, {
14+
placeholder: "Add your comment here...",
15+
autoResize: true,
16+
minHeight: "102px",
17+
padding: "var(--base-size-8)",
18+
});
19+
}
20+
}
21+
22+
function modifyDOM(overtypeInput: HTMLTextAreaElement): HTMLElement {
23+
overtypeInput.classList.add("overtype-input");
24+
const overtypePreview = document.createElement("div");
25+
overtypePreview.classList.add("overtype-preview");
26+
overtypeInput.insertAdjacentElement("afterend", overtypePreview);
27+
const overtypeWrapper = overtypeInput.parentElement!.closest("div")!;
28+
overtypeWrapper.classList.add("overtype-wrapper");
29+
overtypeInput.placeholder = "Add your comment here...";
30+
const overtypeContainer = overtypeWrapper.parentElement!.closest("div")!;
31+
overtypeContainer.classList.add("overtype-container");
32+
return overtypeContainer.parentElement!.closest("div")!;
33+
}

0 commit comments

Comments
 (0)