返回 presentation-ai
generating-leaf.tsx
根目录 / src / components / notebook / presentation / editor / custom-elements / generating-leaf.tsx
1 "use client";
2
3 import { PlateLeaf, type PlateLeafProps } from "platejs/react";
4
5 import { usePresentationState } from "@/states/presentation-state";
6
7 export const GeneratingLeaf = ({ children, ref, ...props }: PlateLeafProps) => {
8 const { leaf } = props;
9 const { isGeneratingPresentation } = usePresentationState();
10 const isGenerating = isGeneratingPresentation && (leaf.generating as boolean);
11
12 return (
13 <PlateLeaf ref={ref} {...props}>
14 {children}
15 {isGenerating && (
16 <span
17 aria-hidden="true"
18 className="ml-0.5 inline-flex items-baseline gap-1"
19 >
20 <span className="animate-blink inline-block h-[1.6em] w-0.5 translate-y-[0.45em] bg-purple-600" />
21 <sup className="text-[0.85em] font-semibold leading-none text-purple-600">
22 Generating
23 </sup>
24 </span>
25 )}
26 </PlateLeaf>
27 );
28 };
29
29 lines Plain Text