返回 presentation-ai
ai-toolbar-button.tsx
根目录 / src / components / plate / ui / ai-toolbar-button.tsx
1 "use client";
2
3 import { AIChatPlugin } from "@platejs/ai/react";
4 import { useEditorPlugin } from "platejs/react";
5 import type * as React from "react";
6
7 import { ToolbarButton } from "./toolbar";
8
9 export function AIToolbarButton(
10 props: React.ComponentProps<typeof ToolbarButton>,
11 ) {
12 const { api } = useEditorPlugin(AIChatPlugin);
13
14 return (
15 <ToolbarButton
16 {...props}
17 onClick={() => {
18 api.aiChat.show();
19 }}
20 onMouseDown={(e) => {
21 e.preventDefault();
22 }}
23 />
24 );
25 }
26
26 lines Plain Text