singerdmx / flutter-quill

Rich text editor for Flutter
https://pub.dev/packages/flutter_quill
MIT License
2.6k stars 840 forks source link

Chore: update simple_spell_checker package #2139

Closed CatHood0 closed 3 months ago

CatHood0 commented 3 months ago

Description

Was updated since the last version of the package added this new things:

New separator regexp

At the version 1.1.7 was fixed some issues related with the characters because the separator not works as expected. This is the old regexp that only accept spanish, english, a some deutsch or italian characters.

'''(\s+|[,;:'`´^¨`\'\.°\|\*\•µ\[\]\(\)\!\¡\¿\?\¶\$\%\&\/\\=\}
\{\+\-©℗ⓒ·~½¬ſþˀ\_\«\»\<\>\¢\@\€\←\↓\→\ð\ø\¢\”\“\„\"]|
[\wẃĺĸẗŕýảẻủỷỉỏẢẺỶỦỈỎƙïßśŔŸËẄÄŸÏÖÜüÍÁẂÉÚÝÓÁäëÿïößðẅẍæëïüãñõáéíóúýâêîôûöáéíñǵñÑü
ÜçÇàèìòùÀÈÌÒÙâêîôûÂÊÎÔÛãõÃÕćóúüñÁÉÍÓÚÜÑ]+)'''

As you see, it wont work with chinese, arabic, or hebrew. By this issue we now use a regexp using unicode standard to make more simple the regexp and letting to all users use the SimpleSpellChecker without loss any characters.

// matches with any visible or invisible whitespaces format
const String _whitespaces = r'''\p{Z}''';
// Accept all characters from any languages
const String _allWords =
    r'''\p{L}\p{M}\p{Lm}\p{Lo}\p{Script=Arabic}\p{Script=Armenian}\p{Script=Bengali}\p{Script=Bopomofo}\p{Script=Braille}\p{Script=Buhid}\p{Script=Canadian_Aboriginal}\p{Script=Cherokee}\p{Script=Cyrillic}\p{Script=Devanagari}\p{Script=Ethiopic}\p{Script=Georgian}\p{Script=Greek}\p{Script=Gujarati}\p{Script=Gurmukhi}\p{Script=Han}\p{Script=Hangul}\p{Script=Hanunoo}\p{Script=Hebrew}\p{Script=Hiragana}\p{Script=Inherited}\p{Script=Kannada}\p{Script=Katakana}\p{Script=Khmer}\p{Script=Lao}\p{Script=Latin}\p{Script=Limbu}\p{Script=Malayalam}\p{Script=Mongolian}\p{Script=Myanmar}\p{Script=Ogham}\p{Script=Oriya}\p{Script=Runic}\p{Script=Sinhala}\p{Script=Syriac}\p{Script=Tagalog}\p{Script=Tagbanwa}\p{Script=Tamil}\p{Script=Telugu}\p{Script=Thaana}\p{Script=Thai}\p{Script=Tibetan}\p{Script=Yi}''';
// Accept non letter characters like dots, or emojis
const String _nonWordsCharacters =
    r'''\p{P}\p{N}\p{Pd}\p{Nd}\p{Nl}\p{Pi}\p{No}\p{Pf}\p{Pc}\p{Ps}\p{Cf}\p{Co}\p{Cn}\p{Cs}\p{Pe}\p{S}\p{Sm}\p{Sc}\p{Sk}\p{So}\p{Cc}\p{Po}\p{Mc}''';

final RegExp separatorRegExp = RegExp('''([$_whitespaces]+|[$_allWords]+|[$_nonWordsCharacters])''', unicode: true);

New translations:

Checking even the dictionary is empty

This feature give us the ability to check our texts even the language is not founded and the dictionary is practicaly empty using worksWithoutDictionary param.

Note: This feature need to have safeDictionaryLoad active to avoid goes into a exception.

MultiSpellChecker

This feature let us create an instance like SimpleSpellChecker but this one accept more than one language. More info in PR.