Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/lib/enhancers/github/GitHubPrAppendEnhancer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,19 @@ export class GitHubPrAppendEnhancer implements CommentEnhancer<GitHubPrAppendSpo
enhance(textArea: HTMLTextAreaElement, _spot: GitHubPrAppendSpot): OverTypeInstance {
prepareGitHubHighlighter()
const overtypeContainer = modifyDOM(textArea)
return new OverType(overtypeContainer, {
const overtype = new OverType(overtypeContainer, {
...commonGitHubOptions,
minHeight: '102px',
padding: 'var(--base-size-8)',
placeholder: 'Add your comment here...',
})[0]!
const listenForEmpty = new MutationObserver(() => {
if (textArea.value === '') {
overtype.updatePreview()
}
})
listenForEmpty.observe(textArea, { attributes: true, characterData: true })
return overtype
}

tableUpperDecoration(spot: GitHubPrAppendSpot): React.ReactNode {
Expand Down
6 changes: 6 additions & 0 deletions src/lib/registries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,15 @@ export class TextareaRegistry {
this.sendEvent('ENHANCED', enhanced)
}

private cleanupOvertype(overtype: OverTypeInstance) {
const container = overtype.element
OverType.instances.delete(container)
;(container as any).overTypeInstance = undefined
}
unregisterDueToModification(textarea: HTMLTextAreaElement): void {
const enhanced = this.textareas.get(textarea)
if (enhanced) {
this.cleanupOvertype(enhanced.overtype)
this.sendEvent('DESTROYED', enhanced)
this.textareas.delete(textarea)
}
Expand Down