-
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: enable AI description generator on comments (#285)
* feat: show PR description generator on comments * feat: generalize the ai description generator * chore: add inject on new page * chore: lint the files * chore: format * chore: format * Update GitHub constants and fix text area bug in DescriptionGeneratorButton * chore: format * feat: enable comments button with focus and blur field * chore: format lint
- Loading branch information
Showing
5 changed files
with
25 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
// This function is used to insert text at the cursor position in the text area | ||
export const insertTextAtCursor = (textArea: HTMLTextAreaElement, text: string) => { | ||
let length = 0; | ||
|
||
textArea.focus(); | ||
const typewriter = setInterval(() => { | ||
textArea.setRangeText(text[length++], textArea.selectionStart, textArea.selectionEnd, "end"); | ||
if (length >= text.length) { | ||
clearInterval(typewriter); | ||
textArea.setRangeText("\n\n_Generated using [OpenSauced](https://opensauced.ai/)._", textArea.selectionStart, textArea.selectionEnd, "end"); | ||
textArea.ownerDocument.execCommand("insertText", false, "\n\n_Generated using [OpenSauced](https://opensauced.ai/)_"); | ||
textArea.blur(); | ||
} | ||
}, 10); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters