返回 presentation-ai
ghost-text.tsx
根目录 / src / components / plate / ui / ghost-text.tsx
1 "use client";
2
3 import { CopilotPlugin } from "@platejs/ai/react";
4 import { useElement, usePluginOption } from "platejs/react";
5
6 export function GhostText() {
7 const element = useElement();
8
9 const isSuggested = usePluginOption(
10 CopilotPlugin,
11 "isSuggested",
12 element.id as string,
13 );
14
15 if (!isSuggested) return null;
16
17 return <GhostTextContent />;
18 }
19
20 function GhostTextContent() {
21 const suggestionText = usePluginOption(CopilotPlugin, "suggestionText");
22
23 return (
24 <span
25 className="pointer-events-none text-muted-foreground/70 max-sm:hidden"
26 contentEditable={false}
27 >
28 {suggestionText && suggestionText}
29 </span>
30 );
31 }
32
32 lines Plain Text