Skip to main content
All docs
V25.1
  • SpellCheckExtensions.AddSpellCheck(IDevExpressBlazorBuilder, Action<SpellCheckOptions>) Method

    Adds the built-in spell check service to the application’s service collection and configures the service options.

    Namespace: DevExpress.Blazor.RichEdit.SpellCheck

    Assembly: DevExpress.Blazor.RichEdit.v25.1.dll

    NuGet Package: DevExpress.Blazor.RichEdit

    Declaration

    public static IDevExpressBlazorBuilder AddSpellCheck(
        this IDevExpressBlazorBuilder builder,
        Action<SpellCheckOptions> configure
    )

    Parameters

    Name Type Description
    builder IDevExpressBlazorBuilder

    An object that can be used to configure internal DevExpress Blazor services.

    Optional Parameters

    Name Type Default Description
    configure Action<SpellCheckOptions> null

    A delegate method that configures the service options.

    Returns

    Type Description
    IDevExpressBlazorBuilder

    An object that can be used to further configure internal DevExpress Blazor services.

    Remarks

    Call the AddSpellCheck method to register the built-in spell check service in your application and configure the following spell check options:

    AddToDictionaryAction
    Allows you to implement a delegate method that writes the selected word to a dictionary file. The Rich Text Editor executes this method after a user clicks the Add to dictionary command in the context menu. If you do not set the AddToDictionaryAction property value, the component hides the command.
    Dictionaries
    Stores a list of dictionaries you added. To extend the dictionary list, pass a simple, ISpell, or Hunspell dictionary to the list’s Add method.
    FileProvider
    Specifies a file provider that accesses dictionary files. The FileNotFoundException error occurs if you do not set a file provider, but add a dictionary.
    MaxSuggestionCount
    Specifies the maximum number of suggestions that the Rich Text Editor should display in its context menu. The component can display up to 15 suggestions.

    The following code snippet registers the built-in spell check service:

    var DictionaryFiles = new Dictionary<string, string>() {
        { "de-DE", "de//de.dic" },
        { "fr-FR", "fr//fr.dic" },
    };
    var builder = WebApplication.CreateBuilder(args);
    // ...
    builder.Services.AddDevExpressBlazor().AddSpellCheck(opts => {
        opts.FileProvider = new PhysicalFileProvider(
            Path.Combine(Directory.GetCurrentDirectory(), "Data", "Dictionaries"));
        opts.Dictionaries.Add(new Dictionary {
            DictionaryPath = "de\\de.dic",
            AlphabetPath = "de\\alphabet.txt",
            Culture = "de-DE"
        });
        opts.Dictionaries.Add(new Dictionary {
            DictionaryPath = "fr\\fr.dic",
            AlphabetPath = "fr\\alphabet.txt",
            Culture = "fr-FR"
        });
        opts.AddToDictionaryAction = (word, culture) => {
            string dictionaryFile = DictionaryFiles.GetValueOrDefault(culture.Name);
            if (dictionaryFile != default) {
                var filePath = opts.FileProvider.GetFileInfo(dictionaryFile).PhysicalPath;
                File.AppendAllText(filePath, "\n" + word);
            }
        };
        opts.MaxSuggestionCount = 7;
    });
    

    View Example: How to Customize the Built-in Spell Check Services

    Refer to the following topic for more information: Spell Check.

    See Also