File
Blob: src/shared/editor/schema/callout-model.ts
| 1 | // Runtime-safe callout metadata used by both editor extensions and static presentation. |
| 2 | // Keep this file free of Tiptap imports so public Sites islands can use it. |
| 3 | |
| 4 | export const CALLOUT_KINDS = ["info", "tip", "warning"] as const; |
| 5 | export type CalloutKind = (typeof CALLOUT_KINDS)[number]; |
| 6 | export const DEFAULT_CALLOUT_KIND: CalloutKind = "info"; |
| 7 | |
| 8 | const CALLOUT_KIND_SET: ReadonlySet<string> = new Set(CALLOUT_KINDS); |
| 9 | |
| 10 | export function isCalloutKind(value: unknown): value is CalloutKind { |
| 11 | return typeof value === "string" && CALLOUT_KIND_SET.has(value); |
| 12 | } |
| 13 | |
| 14 | export function normalizeCalloutKind(value: unknown): CalloutKind { |
| 15 | return isCalloutKind(value) ? value : DEFAULT_CALLOUT_KIND; |
| 16 | } |