Skip to main content
All docs
V24.2

BaseAIContextMenuItem Class

Implements the base functionality of AI-powered context menu items.

Namespace: DevExpress.AIIntegration.Blazor.RichEdit

Assembly: DevExpress.AIIntegration.Blazor.RichEdit.v24.2.dll

NuGet Package: DevExpress.AIIntegration.Blazor.RichEdit

Declaration

public abstract class BaseAIContextMenuItem :
    BasePopupItem

Remarks

Use the BaseAIContextMenuItem class to implement a custom AI-powered context menu item.

  1. Create the BaseAIContextMenuItem class successor. Specify its text and provide a custom prompt.

    public class ShakespeareAIContextMenuItem : BaseAIContextMenuItem {
        [Inject] IAIExtensionsContainer? aIExtensionsContainer { get; set; }
    
        protected override string DefaultItemText => "Rewrite like Shakespeare";
    
        protected override Task<TextResponse> GetCommandTextResult(string text) {
            var customExtension = aIExtensionsContainer.CreateCustomPromptExtension();
            return customExtension.ExecuteAsync(new CustomPromptRequest("Rewrite the following text in William Shakespeare style.", text));
        }
    }
    
  2. Add the new item to the AdditionalItems collection.

    @using DevExpress.AIIntegration.Blazor.RichEdit
    @using DevExpress.Blazor.RichEdit
    
    <DxRichEdit DocumentContent="DocumentContent" CssClass="my-editor">
        <AdditionalItems>
            <ShakespeareAIContextMenuItem />
            ...
        </AdditionalItems>
    </DxRichEdit>
    

View Example: Rich Text Editor and HTML Editor for Blazor - How to integrate AI-powered extensions

See Also