-
Notifications
You must be signed in to change notification settings - Fork 245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Spelling error decorations and suggestions (Partial for #388) #2324
Conversation
@miguelcmedeiros @brian-superlist - Do you guys wanna try out this PR and report back with any issues? |
super_editor/lib/src/default_editor/spelling_and_grammar/spelling_and_grammar_styler.dart
Outdated
Show resolved
Hide resolved
super_editor/lib/src/default_editor/spelling_and_grammar/spelling_and_grammar_styler.dart
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new golden isn't showing an underline. This seem to be the case for other goldens as well.
super_editor_spellcheck/lib/src/super_editor/spelling_and_grammar_plugin.dart
Show resolved
Hide resolved
super_editor_spellcheck/lib/src/super_editor/spelling_error_suggestion_overlay.dart
Outdated
Show resolved
Hide resolved
super_editor_spellcheck/lib/src/super_editor/spelling_error_suggestion_overlay.dart
Outdated
Show resolved
Hide resolved
super_editor_spellcheck/lib/src/super_editor/spelling_error_suggestion_overlay.dart
Show resolved
Hide resolved
super_editor_spellcheck/lib/src/super_editor/spelling_error_suggestions.dart
Outdated
Show resolved
Hide resolved
super_editor_spellcheck/lib/src/super_editor/spelling_error_suggestions.dart
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@matthew-carroll noticed a small issue (see comment) with the code.
Also tested the feature. Here's my initial feedback:
- We should be able to pass a
tapRegionGroupId
to the suggestion toolbar so that it plays well with aTapRegion
ancestor - Tested on android for potential regression and the following is thrown:
I/flutter ( 5003): (12.427) PlatformException(channel-error, Unable to establish connection on channel: "dev.flutter.pigeon.super_editor_spellcheck.SpellCheckMac.checkSpelling"., null, null)
I/flutter ( 5003): #0 SpellCheckMac.checkSpelling (package:super_editor_spellcheck/src/platform/messages.g.dart:277:7)
I/flutter ( 5003): <asynchronous suspension>
I/flutter ( 5003): #1 SuperEditorSpellCheckerMacPlugin.checkSpelling (package:super_editor_spellcheck/src/platform/spell_checker_mac.dart:37:20)
I/flutter ( 5003): <asynchronous suspension>
I/flutter ( 5003): #2 SpellingAndGrammarReaction._findSpellingAndGrammarErrors (package:super_editor_spellcheck/src/super_editor/spelling_and_grammar_plugin.dart:200:21)
I/flutter ( 5003): <asynchronous suspension>
}) : super(nodeId: nodeId, maxWidth: maxWidth, padding: padding) { | ||
this.composingRegion = composingRegion; | ||
this.showComposingRegionUnderline = showComposingRegionUnderline; | ||
|
||
this.spellingErrorUnderlineStyle = spellingErrorUnderlineStyle; | ||
this.spellingErrors = spellingErrors; | ||
|
||
this.grammarErrorUnderlineStyle = grammarErrorUnderlineStyle; | ||
this.grammarErrors = spellingErrors; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.grammarErrors = spellingErrors; | |
this.grammarErrors = grammarErrors; |
parentNode: widget.editorFocusNode, | ||
child: Container( | ||
decoration: BoxDecoration( | ||
color: Colors.white, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current implementation looks fine on light mode, but not on dark mode.
Also, it would be great to be able to customize the suggestion overlay. Is it possible to expose this in the API?
* Spellcheck plugin toolbar builder is configurable * Default toolbar changes colors in dark mode * Default toolbar takes a tap region ID * Spell check reaction fizzles when not on Mac desktop * Fixed list items that were passing spelling errors for grammar errors
@miguelcmedeiros - I addressed your issues. Screen.Recording.2024-09-22.at.10.17.55.AM.movDo you want to try out the configurable toolbar builder with tap region ID to make sure you can build the kind of toolbar you want with the given API? The configuration point is at the plugin level. You pass your own toolbar builder to the plugin. |
super_editor_spellcheck/lib/src/super_editor/spelling_error_suggestion_overlay.dart
Show resolved
Hide resolved
super_editor_spellcheck/lib/src/super_editor/spelling_error_suggestion_overlay.dart
Outdated
Show resolved
Hide resolved
super_editor_spellcheck/lib/src/super_editor/spelling_error_suggestion_overlay.dart
Show resolved
Hide resolved
@matthew-carroll tried to give it another go with the latest changes, but it was not possible. Left a few comments related to why it was not possible. |
…er interface, export all package files.
@miguelcmedeiros I updated the widget tree to use the toolbar builder, exported all source files, and removed the tap region ID from the toolbar build interface. |
@matthew-carroll since commit 58f4769 it works well 🚀 |
@miguelcmedeiros any comments at all? any adjustments? do you think you should try to ship with this PR before we merge, or do you feel good about us merging this? |
@angelosilvestre can you take another look. I resolved most of your comments, and then followed up with a few of them. I think as soon as you approve this PR, we're ready to merge in. Superlist seems happy with it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with a couple comments. Also, I'm still seeing a bunch of golden files that previously were showing an underline, and now aren't. I wanted to make sure this is correct.
_asyncRequestIds[textNode.id] = _asyncRequestIds[textNode.id]! + 1; | ||
|
||
int startingOffset = 0; | ||
TextRange prevError = TextRange.empty; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it makes sense.
final spellingSuggestions = <TextRange, SpellingErrorSuggestion>{}; | ||
if (isSpellCheckEnabled) { | ||
do { | ||
prevError = await spellChecker.checkSpelling( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should pass the language to avoid any surprises, the code would be:
final locale = PlatformDispatcher.instance.locale;
final language = spellChecker.convertDartLocaleToMacLanguageCode(locale)!;
_suggestionListenable.value = spellingSuggestion; | ||
|
||
WidgetsBinding.instance.addPostFrameCallback((_) { | ||
_suggestionToolbarOverlayController.show(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we check if we are still mounted?
… to spell checker
@angelosilvestre do you wanna do a final pass? I think the goldens should be OK now, but let me know if you see anything wrong there. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks good. We still have some golden files that are removing the underlines. I left a comment at each of them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The underline was removed from this golden. Is that correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another golden with the underline removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another golden with the underline removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another golden with the underline removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another golden with the underline removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another golden with the underline removed.
@angelosilvestre I fixed a task spelling error bug - can you check the goldens again? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Spelling error decorations and suggestions (Partial for #388)
Screen.Recording.2024-09-17.at.7.09.40.PM.mov