SpellCheckOptions Class
Defines options for the Rich Text Editor‘s built-in spell check service.
Namespace: DevExpress.Blazor.RichEdit.SpellCheck
Assembly: DevExpress.Blazor.RichEdit.v24.2.dll
NuGet Package: DevExpress.Blazor.RichEdit
#Declaration
public class SpellCheckOptions
#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;
});
Refer to the following topic for more information: Spell Check.