@@ -7,7 +7,13 @@ import type {
7
7
} from "@/lib/enhancer"
8
8
import { logger } from "@/lib/logger"
9
9
import { 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"
11
17
12
18
const GH_EDIT = "GH_EDIT" as const
13
19
@@ -29,6 +35,50 @@ export class GitHubEditEnhancer implements CommentEnhancer<GitHubEditSpot> {
29
35
return null
30
36
}
31
37
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
+
32
82
// Parse GitHub URL structure: /owner/repo/issues/123 or /owner/repo/pull/456
33
83
const match = location . pathname . match (
34
84
/ ^ \/ ( [ ^ / ] + ) \/ ( [ ^ / ] + ) \/ (?: i s s u e s | p u l l ) \/ ( \d + ) /
@@ -46,9 +96,8 @@ export class GitHubEditEnhancer implements CommentEnhancer<GitHubEditSpot> {
46
96
"[data-wrapper-timeline-id]"
47
97
)
48
98
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!)
52
101
53
102
if ( ! isIssueBodyRootEdit && ! isIssueBodyCommentEdit && ! isPRBodyEdit ) {
54
103
return null
0 commit comments