Skip to content
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

chore: deprecate spell checker service #2255

Merged
merged 3 commits into from
Sep 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -286,11 +286,8 @@ The following packages can be used:

## 📝 Spelling checker

While spell-checking is not a feature that's implemented into the project, it can be used using external dependencies.

It's implemented using the package `simple_spell_checker` in the [Example](./example/).

Take a look at [Spelling Checker](./doc/spell_checker.md) page for more info.
This feature is currently not implemented and is being planned. Refer to [#2246](https://github.com/singerdmx/flutter-quill/issues/2246)
for discussion.

## ✂️ Shortcut events

Expand Down
79 changes: 0 additions & 79 deletions doc/spell_checker.md

This file was deleted.

1 change: 1 addition & 0 deletions example/lib/screens/home/widgets/home_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class HomeScreen extends StatefulWidget {
class _HomeScreenState extends State<HomeScreen> {
@override
void dispose() {
// ignore: deprecated_member_use
SpellCheckerServiceProvider.dispose();
super.dispose();
}
Expand Down
2 changes: 2 additions & 0 deletions example/lib/screens/quill/quill_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,13 @@ class _QuillScreenState extends State<QuillScreen> {
IconButton(
tooltip: 'Spell-checker',
onPressed: () {
// ignore: deprecated_member_use
SpellCheckerServiceProvider.toggleState();
setState(() {});
},
icon: Icon(
Icons.document_scanner,
// ignore: deprecated_member_use
color: SpellCheckerServiceProvider.isServiceActive()
? Colors.red.withOpacity(0.5)
: null,
Expand Down
7 changes: 6 additions & 1 deletion example/lib/spell_checker/simple_spell_checker_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@ import 'package:flutter_quill/flutter_quill.dart';
import 'package:simple_spell_checker/simple_spell_checker.dart';

/// SimpleSpellChecker is a simple spell checker for get
/// all words divide on different objects if them are wrong or not
/// all words divide on different objects if them are wrong or not.
///
/// **Important**: A breaking change is planned and this shouldn't be used
/// for new applications. A replacement will arrive soon.
/// See: https://github.com/singerdmx/flutter-quill/issues/2246
class SimpleSpellCheckerService
// ignore: deprecated_member_use
extends SpellCheckerService<LanguageIdentifier> {
SimpleSpellCheckerService({required super.language})
: checker = SimpleSpellChecker(
Expand Down
2 changes: 2 additions & 0 deletions example/lib/spell_checker/spell_checker.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// ignore_for_file: deprecated_member_use

import 'package:flutter_quill/flutter_quill.dart';

import 'simple_spell_checker_service.dart';
Expand Down
9 changes: 9 additions & 0 deletions lib/src/editor/spellchecker/default_spellchecker_service.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
// ignore_for_file: deprecated_member_use_from_same_package

import 'package:flutter/gestures.dart' show LongPressGestureRecognizer;
import 'package:flutter/material.dart' show TextSpan;
import 'package:meta/meta.dart';
import 'spellchecker_service.dart' show SpellCheckerService;

/// A default implementation of the [SpellcheckerService]
/// that always will return null since Spell checking
/// is not a standard feature
@Deprecated(
'A breaking change is being planned for the SpellCheckerService and SpellCheckerServiceProvider.\n'
"A replacement doesn't exist yet but should arrive soon."
'See https://github.com/singerdmx/flutter-quill/issues/2246 for more details.',
)
@experimental
class DefaultSpellCheckerService extends SpellCheckerService<Object?> {
DefaultSpellCheckerService() : super(language: 'en');

Expand Down
7 changes: 7 additions & 0 deletions lib/src/editor/spellchecker/spellchecker_service.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:meta/meta.dart';

/// A representation a custom SpellCheckService.
@Deprecated(
'A breaking change is being planned for the SpellCheckerService.\n'
"A replacement doesn't exist yet but should arrive soon."
'See https://github.com/singerdmx/flutter-quill/issues/2246 for more details.',
)
@experimental
abstract class SpellCheckerService<T> {
SpellCheckerService({required this.language});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
// ignore_for_file: deprecated_member_use_from_same_package

import 'package:flutter/foundation.dart' show immutable;
import 'package:meta/meta.dart' show experimental;
import 'default_spellchecker_service.dart';
import 'spellchecker_service.dart';

@immutable
@Deprecated(
'A breaking change is being planned for the SpellCheckerService and SpellCheckerServiceProvider.\n'
"A replacement doesn't exist yet but should arrive soon."
'See https://github.com/singerdmx/flutter-quill/issues/2246 for more details.',
)
@experimental
class SpellCheckerServiceProvider {
const SpellCheckerServiceProvider._();
static SpellCheckerService _instance = DefaultSpellCheckerService();
Expand Down
1 change: 1 addition & 0 deletions lib/src/editor/widgets/text/text_line.dart
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,7 @@ class _TextLineState extends State<TextLine> {
!widget.line.style.attributes.containsKey('code-block') &&
!widget.line.style.attributes.containsKey('placeholder') &&
!isPlaceholderLine) {
// ignore: deprecated_member_use_from_same_package
final service = SpellCheckerServiceProvider.instance;
final spellcheckedSpans = service.checkSpelling(textNode.value);
if (spellcheckedSpans != null && spellcheckedSpans.isNotEmpty) {
Expand Down