|
1 | 1 | import type { OverTypeInstance } from 'overtype' |
2 | 2 | import OverType from 'overtype' |
3 | | -import type { CommentEnhancer, CommentSpot, StrippedLocation } from './enhancer' |
| 3 | +import type { CommentEnhancer, CommentEvent, CommentSpot, StrippedLocation } from './enhancer' |
4 | 4 | import { CommentEnhancerMissing } from './enhancers/CommentEnhancerMissing' |
5 | 5 | import { GitHubEditEnhancer } from './enhancers/github/GitHubEditEnhancer' |
6 | 6 | import { GitHubIssueAppendEnhancer } from './enhancers/github/GitHubIssueAppendEnhancer' |
@@ -104,12 +104,19 @@ export class TextareaRegistry { |
104 | 104 | private onEnhanced?: (textareaInfo: EnhancedTextarea) => void |
105 | 105 | private onDestroyed?: (textareaInfo: EnhancedTextarea) => void |
106 | 106 |
|
107 | | - setEventHandlers( |
108 | | - onEnhanced: (textareaInfo: EnhancedTextarea) => void, |
109 | | - onDestroyed: (textareaInfo: EnhancedTextarea) => void, |
110 | | - ): void { |
111 | | - this.onEnhanced = onEnhanced |
112 | | - this.onDestroyed = onDestroyed |
| 107 | + setCommentEventSender(sendEvent: (event: CommentEvent) => void): void { |
| 108 | + this.onEnhanced = (textareaInfo) => |
| 109 | + sendEvent({ |
| 110 | + draft: textareaInfo.textarea.value, |
| 111 | + spot: textareaInfo.spot, |
| 112 | + type: 'ENHANCED', |
| 113 | + }) |
| 114 | + this.onDestroyed = (textareaInfo) => |
| 115 | + sendEvent({ |
| 116 | + draft: textareaInfo.textarea.value, |
| 117 | + spot: textareaInfo.spot, |
| 118 | + type: 'DESTROYED', |
| 119 | + }) |
113 | 120 | } |
114 | 121 |
|
115 | 122 | register<T extends CommentSpot>(textareaInfo: EnhancedTextarea<T>): void { |
|
0 commit comments