Message Editor
AI · MessageEditor, VersionSwitch
Editing a sent message in place, and stepping between the versions it leaves behind. ChatMessage uses both (onEdit, versionCount); they work on their own too.
MessageEditor: value / defaultValue / onChange, onSubmit(text), onCancel, hint (default "The conversation runs again from here"), submitLabel, busy, autoFocus.
- Enter sends, Shift+Enter adds a line, Esc cancels. The field grows with the text and opens with the caret at the end.
- Say what happens: sending an edit runs the conversation again from that message.
VersionSwitch: "‹ 2/3 ›". count, index (0-based, default the newest) / defaultIndex / onChange, busy (the arrows wait while a new version is made), label.
- Show it on an edited user message and on a regenerated answer; the answer below follows the version shown.
2/33/3
Props
MessageEditor
| Prop | Type | Notes |
|---|---|---|
value? | string | |
defaultValue? | string | |
onChange? | (v: string) => void | |
onSubmit? | (text: string) => void | Enter (or the button) sends the new text. |
onCancel? | () => void | Esc (or the button) cancels. |
hint? | string | The line under the field (default "The conversation runs again from here"). |
submitLabel? | string | |
label? | string | |
busy? | boolean | |
autoFocus? | boolean | Focuses the field with the caret at the end (default true). |
className? | string | Extra class on the root element. |
style? | CSSProperties | Inline style on the root element. |
VersionSwitch
| Prop | Type | Notes |
|---|---|---|
count | number | How many versions there are. |
index? | number | The version shown, 0-based (default the newest). |
defaultIndex? | number | |
onChange? | (index: number) => void | |
busy? | boolean | While a new version is being made: the arrows wait. |
label? | string | |
className? | string | Extra class on the root element. |
style? | CSSProperties | Inline style on the root element. |