@@ -7,7 +7,13 @@ import type {
77} from "@/lib/enhancer"
88import { logger } from "@/lib/logger"
99import { fixupOvertype , modifyDOM } from "../overtype-misc"
10- import { commonGitHubOptions , prepareGitHubHighlighter } from "./github-common"
10+ import {
11+ commonGitHubOptions ,
12+ isInProjectCommentBox ,
13+ isProjectUrl ,
14+ parseProjectIssueParam ,
15+ prepareGitHubHighlighter ,
16+ } from "./github-common"
1117
1218const GH_EDIT = "GH_EDIT" as const
1319
@@ -29,6 +35,50 @@ export class GitHubEditEnhancer implements CommentEnhancer<GitHubEditSpot> {
2935 return null
3036 }
3137
38+ // Check for project draft edit first
39+ if ( isProjectUrl ( location . pathname ) ) {
40+ const params = new URLSearchParams ( location . search )
41+ const itemId = params . get ( "itemId" )
42+
43+ // Handle draft editing (itemId parameter)
44+ if ( itemId ) {
45+ // Exclude textareas within Shared-module__CommentBox (those are for adding new comments, not editing)
46+ if ( ! isInProjectCommentBox ( textarea ) ) {
47+ const unique_key = `github.com:project-draft:${ itemId } :edit-body`
48+ logger . debug (
49+ `${ this . constructor . name } enhanced project draft body textarea` ,
50+ unique_key
51+ )
52+ return {
53+ isIssue : true ,
54+ type : GH_EDIT ,
55+ unique_key,
56+ }
57+ }
58+ }
59+
60+ // Handle existing issue comment editing (issue parameter)
61+ const issueInfo = parseProjectIssueParam ( params )
62+ if ( issueInfo ) {
63+ // Edit mode: empty placeholder
64+ // Add new comment mode: has placeholder "Add your comment here..." or similar
65+ if ( ! textarea . placeholder || textarea . placeholder . trim ( ) === "" ) {
66+ const unique_key = `github.com:${ issueInfo . slug } :${ issueInfo . number } :edit-comment`
67+ logger . debug (
68+ `${ this . constructor . name } enhanced project issue comment edit textarea` ,
69+ unique_key
70+ )
71+ return {
72+ isIssue : true ,
73+ type : GH_EDIT ,
74+ unique_key,
75+ }
76+ }
77+ }
78+
79+ return null
80+ }
81+
3282 // Parse GitHub URL structure: /owner/repo/issues/123 or /owner/repo/pull/456
3383 const match = location . pathname . match (
3484 / ^ \/ ( [ ^ / ] + ) \/ ( [ ^ / ] + ) \/ (?: i s s u e s | p u l l ) \/ ( \d + ) /
@@ -46,9 +96,8 @@ export class GitHubEditEnhancer implements CommentEnhancer<GitHubEditSpot> {
4696 "[data-wrapper-timeline-id]"
4797 )
4898 const isPRBodyEdit =
49- textarea . name === "pull_request[body]" ||
50- textarea . name === "issue_comment[body]"
51- // ^this is the root pr comment ^this is the other pr comments (surprising!)
99+ textarea . name === "pull_request[body]" || // this is the root pr comment
100+ textarea . name === "issue_comment[body]" // this is the other pr comments (surprising!)
52101
53102 if ( ! isIssueBodyRootEdit && ! isIssueBodyCommentEdit && ! isPRBodyEdit ) {
54103 return null
0 commit comments