Skip to main content
A newer version of this page is available. .

SpellCheckOptions.AddToDictionaryAction Property

Allows you to implement a delegate method that writes the selected word to a dictionary file.

Namespace: DevExpress.Blazor.RichEdit.SpellCheck

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

NuGet Package: DevExpress.Blazor.RichEdit

Declaration

public Action<string, CultureInfo> AddToDictionaryAction { get; set; }

Property Value

Type Description
Action<String, CultureInfo>

A delegate method that writes the selected word to a file.

Remarks

Assign a delegate method to the AddToDictionaryAction property to show the Add to dictionary command in the context menu. After a user clicks this command, the component passes the selected word and the current document culture to the delegate method. In the method, write the word to a dictionary file depending on the document culture.

The example below demonstrates how to add a simple dictionary and use it as a storage for new words:

var DictionaryFiles = new Dictionary<string, string>() {
    { "de-DE", "de//de.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.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