| 1 | import { SlateLeaf, type SlateLeafProps } from "platejs/static"; |
| 2 | |
| 3 | import { usePresentationState } from "@/states/presentation-state"; |
| 4 | |
| 5 | export function GeneratingLeafStatic(props: SlateLeafProps) { |
| 6 | const isGeneratingPresentation = usePresentationState( |
| 7 | (state) => state.isGeneratingPresentation, |
| 8 | ); |
| 9 | type LeafWithGenerating = { generating?: boolean }; |
| 10 | const isGenerating = |
| 11 | isGeneratingPresentation && |
| 12 | Boolean( |
| 13 | (props.leaf as unknown as LeafWithGenerating | undefined)?.generating, |
| 14 | ); |
| 15 | |
| 16 | return ( |
| 17 | <SlateLeaf {...props}> |
| 18 | {props.children} |
| 19 | {isGenerating && ( |
| 20 | <span |
| 21 | aria-hidden="true" |
| 22 | className="ml-0.5 inline-flex items-baseline gap-1" |
| 23 | > |
| 24 | <span className="animate-blink inline-block h-[1.6em] w-0.5 translate-y-[0.45em] bg-purple-600" /> |
| 25 | <sup className="text-[0.85em] font-semibold leading-none text-purple-600"> |
| 26 | Generating |
| 27 | </sup> |
| 28 | </span> |
| 29 | )} |
| 30 | </SlateLeaf> |
| 31 | ); |
| 32 | } |
| 33 |