Skip to content

Commit 8678b69

Browse files
committed
[Doc] Add SmartRichTextInput, an AI assistant for rich text content
1 parent 23ecac7 commit 8678b69

8 files changed

Lines changed: 407 additions & 3 deletions

File tree

docs/Features.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ And if you want something super custom that react-admin doesn't support out of t
680680

681681
## AI-Powered Components
682682

683-
React-admin leverages recent breakthroughs in AI to **boost user productivity**.
683+
React-admin leverages recent breakthroughs in Artificial Intelligence (AI) to **boost user productivity**.
684684

685685
One example is [`<PredictiveTextInput>`](./PredictiveTextInput.md), which suggests completion for the input value, using your favorite AI backend. Users can accept the completion by pressing the `Tab` key. It's like Intellisense or Copilot for your forms.
686686

@@ -709,7 +709,12 @@ const PersonEdit = () => (
709709
);
710710
```
711711

712-
See [the `<PredictiveTextInput>` documentation](./PredictiveTextInput.md) for more details.
712+
You can also use the [`<SmartRichTextInput>`](./SmartRichTextInput.md) component, which lets users edit HTML documents in WYSIWYG with superpowers:
713+
714+
<video controls playsinline muted loop poster="https://marmelab.com/ra-enterprise/modules/assets/SmartRichTextInput.png" >
715+
<source src="https://marmelab.com/ra-enterprise/modules/assets/SmartRichTextInput.mp4" type="video/mp4" />
716+
Your browser does not support the video tag.
717+
</video>
713718

714719
## Fast
715720

docs/Inputs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ React-admin provides a set of Input components, each one designed for a specific
6363
| Data Type | Example value | Input Components |
6464
|-----------------------|--------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
6565
| String | `'Lorem Ipsum'` | [`<TextInput>`](./TextInput.md), [`<PredictiveTextInput>`](./PredictiveTextInput.md) |
66-
| Rich text | `<p>Lorem Ipsum</p>` | [`<RichTextInput>`](./RichTextInput.md) |
66+
| Rich text | `<p>Lorem Ipsum</p>` | [`<RichTextInput>`](./RichTextInput.md), [`<SmartRichTextInput>`](./SmartRichTextInput.md) |
6767
| Markdown | `# Lorem Ipsum` | [`<MarkdownInput>`](./MarkdownInput.md) |
6868
| Password | `'********'` | [`<PasswordInput>`](./PasswordInput.md) |
6969
| Image URL | `'https://example.com/image.png'` | [`<ImageInput>`](./ImageInput.md) |

docs/PredictiveTextInput.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ This [Enterprise Edition](https://marmelab.com/ra-enterprise)<img class="icon" s
1414

1515
The actual completion is fetched from your Data Provider, based on the current record and input value, using the `dataProvider.getCompletion()` method. This allows you to use any completion API, such as [OpenAI Completion API](https://beta.openai.com/docs/api-reference/completions), [Anthropic](https://console.anthropic.com/docs/api), or your own completion model.
1616

17+
You can test this component online in the [Enterprise Edition Storybook](https://react-admin.github.io/ra-enterprise/?path=/story/ra-ai-input-predictivetextinput--context).
18+
1719
## Usage
1820

1921
Use `<PredictiveTextInput>` instead of `<TextInput>` in your forms:
@@ -393,3 +395,30 @@ const getParamsForPrompt = (prompt) => {
393395
return { key, value, record };
394396
}
395397
```
398+
399+
## Rich Text Editor
400+
401+
If you want AI completions combined with a WYSIWYG editor for rich text, use [`<SmartRichTextInput>`](./SmartRichTextInput.md) instead of `<PredictiveTextInput>`.
402+
403+
<video controls playsinline muted loop poster="https://marmelab.com/ra-enterprise/modules/assets/SmartRichTextInput.png" >
404+
<source src="https://marmelab.com/ra-enterprise/modules/assets/SmartRichTextInput.mp4" type="video/mp4" />
405+
Your browser does not support the video tag.
406+
</video>
407+
408+
Use it just like `<PredictiveTextInput>`:
409+
410+
```jsx
411+
import { Edit, SimpleForm, TextInput } from 'react-admin';
412+
import { SmartRichTextInput } from '@react-admin/ra-ai';
413+
414+
export const PostEdit = () => (
415+
<Edit>
416+
<SimpleForm>
417+
<TextInput source="title" />
418+
<SmartRichTextInput source="body" />
419+
</SimpleForm>
420+
</Edit>
421+
);
422+
```
423+
424+
Check out the [`<SmartRichTextInput>` documentation](./SmartRichTextInput.md) for more details.

docs/Reference.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ title: "Index"
166166
* [`<SimpleList>`](./SimpleList.md)
167167
* [`<SimpleShowLayout>`](./SimpleShowLayout.md)
168168
* [`<SingleFieldList>`](./SingleFieldList.md)
169+
* [`<SmartRichTextInput>`](./SmartRichTextInput.md)<img class="icon" src="./img/premium.svg" />
169170
* [`<SortButton>`](./SortButton.md)
170171
* [`<StackedFilters>`](./StackedFilters.md)<img class="icon" src="./img/premium.svg" />
171172

docs/RichTextInput.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,3 +171,31 @@ const MyRichTextInput = ({ size, ...props }) => (
171171
);
172172
```
173173

174+
## AI Writing Assistant
175+
176+
Modern AI tools can be a great help for editors. React-admin proposes an AI-powered writing assistant for the `<RichTextInput>` component, called [`<SmartRichTetInput>`](./SmartRichTextInput.md):
177+
178+
<video controls playsinline muted loop poster="https://marmelab.com/ra-enterprise/modules/assets/SmartRichTextInput.png" >
179+
<source src="https://marmelab.com/ra-enterprise/modules/assets/SmartRichTextInput.mp4" type="video/mp4" />
180+
Your browser does not support the video tag.
181+
</video>
182+
183+
`<SmartRichTextInput>` is a drop-in replacement for `<RichTextInput>`:
184+
185+
```jsx
186+
import { Edit, SimpleForm, TextInput } from 'react-admin';
187+
import { SmartRichTextInput } from '@react-admin/ra-ai';
188+
189+
export const PostEdit = () => (
190+
<Edit>
191+
<SimpleForm>
192+
<TextInput source="title" />
193+
<SmartRichTextInput source="body" />
194+
</SimpleForm>
195+
</Edit>
196+
);
197+
```
198+
199+
`<SmartRichTextInput>` is available as part of the [ra-ai](https://marmelab.com/ra-enterprise/modules/ra-ai) enterprise package.
200+
201+

0 commit comments

Comments
 (0)