|
| 1 | +import type { OverTypeInstance } from 'overtype' |
| 2 | +import type { ReactNode } from 'react' |
| 3 | +import type { CommentEnhancer, CommentSpot } from '../enhancer' |
| 4 | + |
| 5 | +/** Used when an entry is in the table which we don't recognize. */ |
| 6 | +export class CommentEnhancerMissing implements CommentEnhancer { |
| 7 | + tableUpperDecoration(spot: CommentSpot): ReactNode { |
| 8 | + return ( |
| 9 | + <button |
| 10 | + type='button' |
| 11 | + className='relative inline-block border-none bg-transparent p-0 text-left cursor-pointer underline' |
| 12 | + style={{ |
| 13 | + display: 'inline-block', |
| 14 | + position: 'relative', |
| 15 | + }} |
| 16 | + onMouseEnter={(e) => { |
| 17 | + const popup = e.currentTarget.querySelector('.popup') as HTMLElement |
| 18 | + if (popup) popup.style.display = 'block' |
| 19 | + }} |
| 20 | + onMouseLeave={(e) => { |
| 21 | + const popup = e.currentTarget.querySelector('.popup') as HTMLElement |
| 22 | + if (popup) popup.style.display = 'none' |
| 23 | + }} |
| 24 | + > |
| 25 | + hover for json |
| 26 | + <div |
| 27 | + className='popup absolute top-full left-0 bg-gray-100 border border-gray-300 rounded shadow-lg p-2 z-50 min-w-[320px]' |
| 28 | + style={{ display: 'none' }} |
| 29 | + > |
| 30 | + <pre className='m-0 text-xs font-mono select-text cursor-text whitespace-pre-wrap break-words'> |
| 31 | + {JSON.stringify(spot, null, 2)} |
| 32 | + </pre> |
| 33 | + </div> |
| 34 | + </button> |
| 35 | + ) |
| 36 | + } |
| 37 | + tableTitle(spot: CommentSpot): string { |
| 38 | + return `Unknown type '${spot.type}'` |
| 39 | + } |
| 40 | + forSpotTypes(): string[] { |
| 41 | + throw new Error('Method not implemented.') |
| 42 | + } |
| 43 | + tryToEnhance(_textarea: HTMLTextAreaElement): CommentSpot | null { |
| 44 | + throw new Error('Method not implemented.') |
| 45 | + } |
| 46 | + prepareForFirstEnhancement(): void { |
| 47 | + throw new Error('Method not implemented.') |
| 48 | + } |
| 49 | + enhance(_textarea: HTMLTextAreaElement, _spot: CommentSpot): OverTypeInstance { |
| 50 | + throw new Error('Method not implemented.') |
| 51 | + } |
| 52 | +} |
0 commit comments