GHSoftware.Avalonia.SpellChecker
0.2.0
See the version list below for details.
dotnet add package GHSoftware.Avalonia.SpellChecker --version 0.2.0
NuGet\Install-Package GHSoftware.Avalonia.SpellChecker -Version 0.2.0
<PackageReference Include="GHSoftware.Avalonia.SpellChecker" Version="0.2.0" />
paket add GHSoftware.Avalonia.SpellChecker --version 0.2.0
#r "nuget: GHSoftware.Avalonia.SpellChecker, 0.2.0"
// Install GHSoftware.Avalonia.SpellChecker as a Cake Addin #addin nuget:?package=GHSoftware.Avalonia.SpellChecker&version=0.2.0 // Install GHSoftware.Avalonia.SpellChecker as a Cake Tool #tool nuget:?package=GHSoftware.Avalonia.SpellChecker&version=0.2.0
Avalonia Spell Checker for TextBox
Avalonia Spell Checker adds real-time spell-checking to Avalonia TextBox controls without replacing or changing their behavior. It uses the WeCantSpell.Hunspell library for spell-checking and allows you to manage custom dictionaries. The extension integrates with existing TextBox elements and provides suggestions for misspelled words through a context menu.
Features
- Real-time Spell Checking: Misspelled words are highlighted as the user types.
- Custom Dictionaries (TODO): Add or manage custom words for specific languages.
- Context Menu Integration: Provides suggestions for misspelled words in a context menu.
- Customization (WIP): Developers can modify styles for underlining and other text decorations for incorrect words.
- Support for Multiple Languages: Allows the use of different language dictionaries simultaneously.
Getting Started
Prerequisites
- .NET 6 or higher < Needs to be confirmed
- AvaloniaUI
- WeCantSpell.Hunspell
Installation
Clone this repository:
git clone https://github.com/GustavoHennig/Avalonia.SpellChecker.git
Install the required packages:
dotnet restore
Ensure the dictionary files (.aff and .dic) are placed in the
Dictionaries
folder, as specified inSpellCheckerConfig
.
Usage
To enable spell checking for a TextBox
control, initialize TextBoxSpellChecker
with the required configuration:
public partial class MainWindow : Window
{
private readonly TextBoxSpellChecker textBoxSpellChecker;
public MainWindow()
{
InitializeComponent();
// Initialize the spell checker
// * default dictionaries directory is Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Dictionaries"))
textBoxSpellChecker = new TextBoxSpellChecker(SpellCheckerConfig.Create("pt_BR", "en_GB"));
var textBox = this.FindControl<TextBox>("tbDescription");
textBoxSpellChecker.Initialize(textBox);
}
}
The TextBoxSpellChecker
automatically begins spell-checking the TextBox
control. Misspelled words are underlined, and suggestions are provided in a context menu when the user right-clicks on the word.
When the TextBox
control is detached from the view, the spell checker automatically removes its event handlers, and the reference to the TextBox
is cleared.
Dictionary Files
According to ChatGPT, these are the most reliable and updated sources for downloading Hunspell dictionary files (ok, it seems that the first one is the easiest choice):
LibreOffice Dictionaries Repository: The LibreOffice project maintains updated Hunspell dictionaries for a variety of languages. You can find them here:
This is one of the best places to find dictionaries that are actively maintained and used by large communities.
Mozilla Add-ons: Mozilla also uses Hunspell dictionaries for spell checking in Firefox, and they maintain a large collection of dictionaries available for download:
Apache OpenOffice: OpenOffice also provides Hunspell-compatible dictionaries that you can download:
Hunspell Dictionaries Collection:
The Hunspell project itself hosts a repository of dictionaries:- Hunspell Dictionaries on GitHub404
These sources are widely trusted and offer dictionaries that are kept up-to-date by large communities and projects.
Known Issues
- Works only with Fluent theme
- Keyboard context menu is not showing the suggestions
- Only tested on Windows
Customization
You can customize the behavior and appearance of the spell checker by modifying:
- Text Styles: Define how misspelled words are underlined or styled in
SpellCheckerTextPresenter.cs
. (WIP) - Custom Dictionaries: Add or remove custom words for specific languages through
DictionaryManager.cs
. (WIP)
TODO
- Implement custom word management (add/remove custom words) WIP.
- Allow dynamic enabling/disabling of spell checking.
- Improve performance for larger text inputs.
- Include dictionary files for multiple languages.
Contributing
Feel free to contribute by submitting pull requests, reporting issues, or suggesting features.
License
This project is licensed under the MIT License.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- Avalonia (>= 11.1.3)
- WeCantSpell.Hunspell (>= 5.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.