blazor-devexpress-dot-blazor-dot-richedit-dot-spellcheck-c7594ae1.md
Defines options for the Rich Text Editor‘s built-in spell check service.
Namespace : DevExpress.Blazor.RichEdit.SpellCheck
Assembly : DevExpress.Blazor.RichEdit.v25.2.dll
NuGet Package : DevExpress.Blazor.RichEdit
public class SpellCheckOptions
Call the AddSpellCheck method to register the built-in spell check service in your application and configure the following spell check options:
AddToDictionaryActionAllows 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.DictionariesStores a list of dictionaries you added. To extend the dictionary list, pass a simple, ISpell, or Hunspell dictionary to the list’s Add method.FileProviderSpecifies a file provider that accesses dictionary files. The FileNotFoundException error occurs if you do not set a file provider, but add a dictionary.MaxSuggestionCountSpecifies 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 additional information: Spell Check.
Object SpellCheckOptions
See Also