Skip to content

Commit 32d024d

Browse files
authored
Merge pull request #1 from DevExpress-Examples/update-readme
Update readme
2 parents 236d017 + 2a90a68 commit 32d024d

File tree

3 files changed

+93
-12
lines changed

3 files changed

+93
-12
lines changed

README.md

Lines changed: 93 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,115 @@
11
<!-- default badges list -->
2-
![](https://img.shields.io/endpoint?url=https://codecentral.devexpress.com/api/v1/VersionRange/851771053/24.2.1%2B)
32
[![](https://img.shields.io/badge/Open_in_DevExpress_Support_Center-FF7200?style=flat-square&logo=DevExpress&logoColor=white)](https://supportcenter.devexpress.com/ticket/details/T1251646)
43
[![](https://img.shields.io/badge/📖_How_to_use_DevExpress_Examples-e9f6fc?style=flat-square)](https://docs.devexpress.com/GeneralInformation/403183)
54
[![](https://img.shields.io/badge/💬_Leave_Feedback-feecdd?style=flat-square)](#does-this-example-address-your-development-requirementsobjectives)
65
<!-- default badges end -->
7-
# Product/Platform - Task
6+
# Rich Text Editor and HTML Editor for Blazor - How to integrate AI-powered extensions
87

9-
This is the repository template for creating new examples. Describe the solved task here.
8+
This example enables AI-powered extensions for both the DevExpress Blazor Rich Text Editor and HTML Editor. These extensions supply AI functions designed to process text/HTML content.
109

11-
Put a screenshot that illustrates the result here.
10+
## Implementation Details
1211

13-
Then, add implementation details (steps, code snippets, and other technical information in a free form), or add a link to an existing document with implementation details.
12+
Both the DevExpress Blazor Rich Text Editor ([DxRichEdit](https://docs.devexpress.com/Blazor/DevExpress.Blazor.RichEdit.DxRichEdit)) and Blazor HTML Editor ([DxHtmlEditor](https://docs.devexpress.com/Blazor/DevExpress.Blazor.DxHtmlEditor)) ship with an `AdditionalSettings` property. You can populate this property with commands and allow users to process editor text as needs dictate. Available commands for both editors are as follows:
13+
14+
* `CustomAISettings` allows user to process text according to a custom prompt.
15+
* `ExpandAISettings` expands the text.
16+
* `ExplainAISettings` explains the text.
17+
* `ProofreadAISettings` proofreads the text.
18+
* `RewriteAISettings` rewrite text using a specified style.
19+
* `ShortenAISettings` shortens the text.
20+
* `SummaryAISettings` summarizes the text.
21+
* `ToneAISettings` rewrite text using a specified tone.
22+
* `TranslateAISettings` translates the text into the specified language.
23+
24+
### Register AI Services
25+
26+
Add the following code to the _Program.cs_ file to register AI services in the application:
27+
28+
```cs
29+
using DevExpress.AIIntegration;
30+
31+
string azureOpenAIEndpoint = Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT");
32+
string azureOpenAIKey = Environment.GetEnvironmentVariable("AZURE_OPENAI_API_KEY");
33+
...
34+
builder.Services.AddDevExpressAI((config) => {
35+
var client = new AzureOpenAIClient(
36+
new Uri(azureOpenAIEndpoint),
37+
new AzureKeyCredential(azureOpenAIKey));
38+
config.RegisterChatClientOpenAIService(client, "gpt4o");
39+
config.RegisterOpenAIAssistants(client, "gpt4o");
40+
});
41+
```
42+
43+
### Enable AI-powered extension for the DevExpress Rich Text Editor
44+
45+
AI-powered extension for Rich Text Editor adds AI-related commands to the editor's context menu.
46+
47+
Declare DxRichEdit's `AdditionalSettings` and populate it with commands in the following manner:
48+
49+
```razor
50+
@using DevExpress.AIIntegration.Blazor.RichEdit
51+
@using DevExpress.Blazor.RichEdit
52+
53+
<DxRichEdit DocumentContent="DocumentContent" CssClass="my-editor">
54+
<AdditionalSettings>
55+
<SummaryAISettings />
56+
<ExplainAISettings />
57+
<ProofreadAISettings />
58+
<ExpandAISettings />
59+
<ShortenAISettings />
60+
<CustomAISettings />
61+
<RewriteAISettings />
62+
<ToneAISettings />
63+
<TranslateAISettings Languages="@("German, French, Chinese")" />
64+
</AdditionalSettings>
65+
</DxRichEdit>
66+
```
67+
68+
![](richedit.png)
69+
70+
### Enable AI-powered extension for the DevExpress HTML Editor
71+
72+
The AI-powered extension for our HTML Editor adds AI-related commands to the editor's toolbar.
73+
74+
Declare DxHtmlEditor's `AdditionalSettings` and populate it with commands in the following manner:
75+
76+
```razor
77+
@using DevExpress.AIIntegration.Blazor.HtmlEditor
78+
79+
<DxHtmlEditor @bind-Markup="Value" CssClass="my-editor" BindMarkupMode="HtmlEditorBindMarkupMode.OnLostFocus">
80+
<AdditionalSettings>
81+
<SummaryAISettings />
82+
<ExplainAISettings />
83+
<ProofreadAISettings />
84+
<ExpandAISettings />
85+
<ShortenAISettings />
86+
<CustomAISettings />
87+
<RewriteAISettings />
88+
<ToneAISettings />
89+
<TranslateAISettings Languages="@("German, French, Chinese")" />
90+
</AdditionalSettings>
91+
</DxHtmlEditor>
92+
```
93+
94+
![](htmleditor.png)
1495

1596
## Files to Review
1697

17-
- link.cs (VB: link.vb)
18-
- link.js
19-
- ...
98+
* [RichEdit.razor](./CS/DevExpress.AI.Samples.Blazor.Editors/Components/Pages/RichEdit.razor)
99+
* [HtmlEditor.razor](./CS/DevExpress.AI.Samples.Blazor.Editors/Components/Pages/HtmlEditor.razor)
100+
* [Program.cs](./CS/DevExpress.AI.Samples.Blazor.Editors/Program.cs)
20101

102+
<!-- add later
21103
## Documentation
22104
23105
- link
24106
- link
25-
- ...
107+
-->
26108

27109
## More Examples
28110

29-
- link
30-
- link
31-
- ...
111+
* [AI Chat for Blazor - How to add DxAIChat component in Blazor, MAUI, WPF, and WinForms applications](https://github.com/DevExpress-Examples/devexpress-ai-chat-samples)
112+
32113
<!-- feedback -->
33114
## Does this example address your development requirements/objectives?
34115

htmleditor.png

33.5 KB
Loading

richedit.png

61.4 KB
Loading

0 commit comments

Comments
 (0)