Skip to content

Commit e8e08ec

Browse files
committed
add docs
1 parent 72d3c92 commit e8e08ec

2 files changed

Lines changed: 118 additions & 0 deletions

File tree

apps/docs/content/components/(chatbot)/prompt-input.mdx

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,14 @@ Buttons can display tooltips with optional keyboard shortcut hints. Hover over t
270270

271271
<Preview path="prompt-input-tooltip" />
272272

273+
### Richtext input
274+
275+
`PromptInputRichtext` is an alternative text input to `PromptInputTextarea` when you want an extensible composer-style input with markdown shortcuts, autolink support, and Lexical plugins.
276+
277+
<Preview path="prompt-input-richtext" />
278+
279+
`PromptInputRichtext` integrates with `PromptInputProvider`, so the editor content can stay in sync with external state. On submit, the rich text content is serialized back to markdown and returned as `message.text`.
280+
273281
## Props
274282

275283
### `<PromptInput />`
@@ -330,6 +338,59 @@ Buttons can display tooltips with optional keyboard shortcut hints. Hover over t
330338
}}
331339
/>
332340

341+
### `<PromptInputRichtext />`
342+
343+
Lexical-powered rich text input for `PromptInput`. It supports markdown import/export, URL autolinking, keyboard submit behavior, attachment paste, and custom Lexical plugins.
344+
345+
<TypeTable
346+
type={{
347+
editorConfig: {
348+
description:
349+
"Optional Lexical initial config merged with the default PromptInput configuration.",
350+
type: "InitialConfigType",
351+
},
352+
autoFocus: {
353+
description: "Whether to focus the editor on mount.",
354+
type: "boolean",
355+
default: "true",
356+
},
357+
onChange: {
358+
description:
359+
"Called when the Lexical editor state changes. In provider mode, markdown text is also synced to controller state.",
360+
type: "(editorState: EditorState) => void",
361+
},
362+
onKeyDown: {
363+
description:
364+
"Optional keydown handler attached to the editor root element.",
365+
type: "(event: KeyboardEvent) => void",
366+
},
367+
placeholder: {
368+
description: "Placeholder text shown when the editor is empty.",
369+
type: "string",
370+
default: '"What would you like to know?"',
371+
},
372+
placeholderClassName: {
373+
description: "Additional class names for the placeholder element.",
374+
type: "string",
375+
},
376+
className: {
377+
description: "Additional class names for the content editable element.",
378+
type: "string",
379+
},
380+
children: {
381+
description: "Optional Lexical plugins rendered inside the composer.",
382+
type: "React.ReactNode",
383+
},
384+
"...props": {
385+
description:
386+
"Any other props are spread to the underlying Lexical `ContentEditable` element.",
387+
type: 'Omit<ContentEditableProps, "placeholder">',
388+
},
389+
}}
390+
/>
391+
392+
`PromptInputRichtext` submits on `Enter`, inserts a newline on `Shift+Enter`, removes the last attachment with `Backspace` when empty, and converts pasted files into prompt attachments.
393+
333394
### `<PromptInputFooter />`
334395

335396
<TypeTable
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
"use client";
2+
3+
import {
4+
PromptInput,
5+
PromptInputBody,
6+
PromptInputButton,
7+
PromptInputFooter,
8+
PromptInputMessage,
9+
PromptInputProvider,
10+
PromptInputRichtext,
11+
PromptInputSubmit,
12+
PromptInputTextarea,
13+
PromptInputTools,
14+
} from "@repo/elements/prompt-input";
15+
import { GlobeIcon, MicIcon, PaperclipIcon } from "lucide-react";
16+
17+
const handleSubmit = (message: PromptInputMessage) => {
18+
const hasText = Boolean(message.text);
19+
const hasAttachments = Boolean(message.files?.length);
20+
21+
if (!(hasText || hasAttachments)) {
22+
return;
23+
}
24+
25+
// eslint-disable-next-line no-console
26+
console.log("Submitting message:", message);
27+
};
28+
29+
const Example = () => (
30+
<PromptInputProvider initialInput="This **input field** supports *richtext* via the [Lexical editor](https://lexical.dev/)">
31+
<PromptInput onSubmit={handleSubmit}>
32+
<PromptInputBody>
33+
<PromptInputRichtext />
34+
</PromptInputBody>
35+
<PromptInputFooter>
36+
<PromptInputTools>
37+
<PromptInputButton tooltip="Attach files">
38+
<PaperclipIcon size={16} />
39+
</PromptInputButton>
40+
<PromptInputButton
41+
tooltip={{ content: "Search the web", shortcut: "⌘K" }}
42+
>
43+
<GlobeIcon size={16} />
44+
</PromptInputButton>
45+
<PromptInputButton
46+
tooltip={{ content: "Voice input", shortcut: "⌘M", side: "bottom" }}
47+
>
48+
<MicIcon size={16} />
49+
</PromptInputButton>
50+
</PromptInputTools>
51+
<PromptInputSubmit />
52+
</PromptInputFooter>
53+
</PromptInput>
54+
</PromptInputProvider>
55+
);
56+
57+
export default Example;

0 commit comments

Comments
 (0)