Skip to content

Commit 09a5578

Browse files
committed
Add a special CommentEnhancerNoDraftHistory
1 parent dcb18bd commit 09a5578

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

src/lib/enhancer.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,40 @@ export interface CommentEnhancer<Spot extends CommentSpot = CommentSpot> {
5050
/** The default title of a row */
5151
tableTitle(spot: Spot): string
5252
}
53+
54+
/**
55+
* Special sentinel value for unique_key indicating that draft history
56+
* should not be stored for this spot. Spots with this unique_key will:
57+
* - Still be enhanced with OverType
58+
* - NOT be stored in the background service's openSpots map
59+
* - NOT appear in the popup table
60+
*/
61+
export const DRAFT_STORAGE_UNSUPPORTED = "DRAFT_STORAGE_UNSUPPORTED" as const
62+
63+
/**
64+
* Abstract base class for enhancers that return spots with DRAFT_STORAGE_UNSUPPORTED.
65+
* Table methods throw exceptions since such spots won't appear in the table.
66+
*/
67+
export abstract class CommentEnhancerNoDraftHistory<
68+
Spot extends CommentSpot = CommentSpot,
69+
> implements CommentEnhancer<Spot>
70+
{
71+
abstract forSpotTypes(): string[]
72+
abstract tryToEnhance(
73+
textarea: HTMLTextAreaElement,
74+
location: StrippedLocation
75+
): Spot | null
76+
abstract enhance(textarea: HTMLTextAreaElement, spot: Spot): OverTypeInstance
77+
78+
tableUpperDecoration(_spot: Spot): never {
79+
throw new Error(
80+
"tableUpperDecoration should not be called for DRAFT_STORAGE_UNSUPPORTED spots"
81+
)
82+
}
83+
84+
tableTitle(_spot: Spot): never {
85+
throw new Error(
86+
"tableTitle should not be called for DRAFT_STORAGE_UNSUPPORTED spots"
87+
)
88+
}
89+
}

0 commit comments

Comments
 (0)