Skip to content

DevExpress-Examples/blazor-dxrichedit-spell-check

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Blazor Rich Text Editor – How to Customize the Built-in Spell Check Service

This example customizes the built-in spell check service of the DevExpress Blazor Rich Text Editor component.

The code adds French and German dictionaries to its list of supported dictionaries (American English is supported by default). A ComboBox above the Rich Text Editor allows you to switch between English, French, and German documents so you can evaluate the capabilities of our spell check engine against the three languages.

This example also changes the maximum number of suggestions and allows users to add words to dictionaries.

Blazor DxRichEdit Customize the Spell Check Service

Overview

To enable/configure our built-in spell check service, you must:

Register and Configure the Service

Call the AddSpellCheck extension method to register the built-in spell check service in your application. Within this method call, you can access and customize spell check options in the following ways:

Add a Dictionary

Our built-in service ships with a default American English dictionary. Follow the steps below to add a different dictionary (simple, ISpell, or Hunspell):

  • Assign a file provider to the FileProvider option so that the service can access dictionary files.
  • Use the Dictionaries spell check option to access the dictionary list.
  • Pass a dictionary to the list's Add method.

Note that the service disables the default dictionary once you add another dictionary for the same culture.

Allow Users to Add Words to a Dictionary

In the default configuration, our built-in spell check service hides its context menu's Add to dictionary command (this command allows users to add words to a dictionary). To display this command, assign a delegate method to the AddToDictionaryAction spell check option. This delegate method should meet the following requirements:

  • Accept current document culture and the word to be added.
  • Write the word to the dictionary file based on document culture.

Our Blazor Rich Text Editor executes the method assigned to the AddToDictionaryAction property once a user clicks the Add to dictionary command.

Change the Maximum Number of Suggestions

The MaxSuggestionCount option specifies the maximum number of suggestions displayed within the Rich Text Editor's context menu. The component can display up to 15 suggestions.

Configure the Rich Text Editor

Set the CheckSpelling property to true to enable spell checking. Use the DocumentCulture property to specify culture name for an open document. An empty property value corresponds to an invariant culture.

The Rich Text Editor uses all dictionaries to check spelling when the DocumentCulture property corresponds to an invariant culture. Otherwise, the Rich Text Editor uses only the dictionaries whose culture is invariant or matches the document's culture. You need to update document culture each time a new document is opened.

Files to Review

Documentation

More Examples

About

Customize the built-in spell check service of the Blazor Rich Text Editor component.

Topics

Resources

License

Stars

Watchers

Forks