Skip to content

Commit 9306a5b

Browse files
committed
biome
1 parent f702c57 commit 9306a5b

File tree

1 file changed

+32
-34
lines changed

1 file changed

+32
-34
lines changed
Lines changed: 32 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,47 @@
1-
import hljs from "highlight.js";
2-
import OverType from "../overtype/overtype";
1+
import hljs from 'highlight.js'
2+
import OverType from '../overtype/overtype'
33

44
export function githubPrNewCommentContentScript() {
5-
if (window.location.hostname !== "github.com") {
6-
return;
7-
}
8-
OverType.setCodeHighlighter(hljsHighlighter);
9-
const ghCommentBox = document.getElementById(
10-
"new_comment_field"
11-
) as HTMLTextAreaElement | null;
12-
if (ghCommentBox) {
13-
const overtypeContainer = modifyDOM(ghCommentBox);
14-
new OverType(overtypeContainer, {
15-
placeholder: "Add your comment here...",
16-
autoResize: true,
17-
minHeight: "102px",
18-
padding: "var(--base-size-8)",
19-
});
20-
}
5+
if (window.location.hostname !== 'github.com') {
6+
return
7+
}
8+
OverType.setCodeHighlighter(hljsHighlighter)
9+
const ghCommentBox = document.getElementById('new_comment_field') as HTMLTextAreaElement | null
10+
if (ghCommentBox) {
11+
const overtypeContainer = modifyDOM(ghCommentBox)
12+
new OverType(overtypeContainer, {
13+
autoResize: true,
14+
minHeight: '102px',
15+
padding: 'var(--base-size-8)',
16+
placeholder: 'Add your comment here...',
17+
})
18+
}
2119
}
2220

2321
function modifyDOM(overtypeInput: HTMLTextAreaElement): HTMLElement {
24-
overtypeInput.classList.add("overtype-input");
25-
const overtypePreview = document.createElement("div");
26-
overtypePreview.classList.add("overtype-preview");
27-
overtypeInput.insertAdjacentElement("afterend", overtypePreview);
28-
const overtypeWrapper = overtypeInput.parentElement!.closest("div")!;
29-
overtypeWrapper.classList.add("overtype-wrapper");
30-
overtypeInput.placeholder = "Add your comment here...";
31-
const overtypeContainer = overtypeWrapper.parentElement!.closest("div")!;
32-
overtypeContainer.classList.add("overtype-container");
33-
return overtypeContainer.parentElement!.closest("div")!;
22+
overtypeInput.classList.add('overtype-input')
23+
const overtypePreview = document.createElement('div')
24+
overtypePreview.classList.add('overtype-preview')
25+
overtypeInput.insertAdjacentElement('afterend', overtypePreview)
26+
const overtypeWrapper = overtypeInput.parentElement!.closest('div')!
27+
overtypeWrapper.classList.add('overtype-wrapper')
28+
overtypeInput.placeholder = 'Add your comment here...'
29+
const overtypeContainer = overtypeWrapper.parentElement!.closest('div')!
30+
overtypeContainer.classList.add('overtype-container')
31+
return overtypeContainer.parentElement!.closest('div')!
3432
}
3533

3634
function hljsHighlighter(code: string, language: string) {
3735
try {
3836
if (language && hljs.getLanguage(language)) {
39-
const result = hljs.highlight(code, { language });
40-
return result.value;
37+
const result = hljs.highlight(code, { language })
38+
return result.value
4139
} else {
42-
const result = hljs.highlightAuto(code);
43-
return result.value;
40+
const result = hljs.highlightAuto(code)
41+
return result.value
4442
}
4543
} catch (error) {
46-
console.warn("highlight.js highlighting failed:", error);
47-
return code;
44+
console.warn('highlight.js highlighting failed:', error)
45+
return code
4846
}
4947
}

0 commit comments

Comments
 (0)