From 8872055f5cac48b64b12d9163b7e1b820118da7d Mon Sep 17 00:00:00 2001 From: Ellet Date: Mon, 13 Nov 2023 23:55:13 +0300 Subject: [PATCH] fix: Drop the support for formula in the editor --- example/lib/pages/home_page.dart | 2 - flutter_quill_extensions/CHANGELOG.md | 2 +- .../lib/flutter_quill_extensions.dart | 17 +++----- .../presentation/embeds/editor/formula.dart | 43 ++++++++++--------- flutter_quill_extensions/pubspec.yaml | 2 +- 5 files changed, 32 insertions(+), 34 deletions(-) diff --git a/example/lib/pages/home_page.dart b/example/lib/pages/home_page.dart index bd298345..7755e336 100644 --- a/example/lib/pages/home_page.dart +++ b/example/lib/pages/home_page.dart @@ -536,7 +536,6 @@ class _HomePageState extends State { configurations: QuillToolbarConfigurations( customButtons: customButtons, embedButtons: FlutterQuillEmbeds.toolbarButtons( - formulaButtonOptions: const QuillToolbarFormulaButtonOptions(), cameraButtonOptions: const QuillToolbarCameraButtonOptions(), imageButtonOptions: QuillToolbarImageButtonOptions( imageButtonConfigurations: QuillToolbarImageConfigurations( @@ -582,7 +581,6 @@ class _HomePageState extends State { configurations: QuillToolbarConfigurations( customButtons: customButtons, embedButtons: FlutterQuillEmbeds.toolbarButtons( - formulaButtonOptions: const QuillToolbarFormulaButtonOptions(), cameraButtonOptions: const QuillToolbarCameraButtonOptions(), videoButtonOptions: QuillToolbarVideoButtonOptions( videoConfigurations: QuillToolbarVideoConfigurations( diff --git a/flutter_quill_extensions/CHANGELOG.md b/flutter_quill_extensions/CHANGELOG.md index 7752eec2..83b9140c 100644 --- a/flutter_quill_extensions/CHANGELOG.md +++ b/flutter_quill_extensions/CHANGELOG.md @@ -1,7 +1,7 @@ ## 0.6.9 - Feature: Add supprot for formula for web - Remove duplicated class -- Improve the image and video embed builder for both web and other platforms +- Drop the support for `QuillEditorFormulaEmbedBuilder` for now as it's not usable, we are working on providing a fixes ## 0.6.8 - Feature: Allow the developer to override the `assetsPrefix` and default value is `assets`, you should define this correctly if you planning on using asset images in the `QuillEditor`, take a look at `QuillSharedExtensionsConfigurations` class for more info diff --git a/flutter_quill_extensions/lib/flutter_quill_extensions.dart b/flutter_quill_extensions/lib/flutter_quill_extensions.dart index f31e5532..6cb74e11 100644 --- a/flutter_quill_extensions/lib/flutter_quill_extensions.dart +++ b/flutter_quill_extensions/lib/flutter_quill_extensions.dart @@ -107,7 +107,6 @@ class FlutterQuillEmbeds { QuillEditorVideoEmbedBuilder( configurations: videoEmbedConfigurations, ), - const QuillEditorFormulaEmbedBuilder(), if (webViewEmbedConfigurations != null) QuillEditorWebViewEmbedBuilder( configurations: webViewEmbedConfigurations, @@ -143,7 +142,6 @@ class FlutterQuillEmbeds { QuillEditorWebVideoEmbedBuilder( configurations: videoEmbedConfigurations, ), - const QuillEditorFormulaEmbedBuilder() ]; } @@ -185,8 +183,6 @@ class FlutterQuillEmbeds { const QuillToolbarImageButtonOptions(), QuillToolbarVideoButtonOptions? videoButtonOptions = const QuillToolbarVideoButtonOptions(), - QuillToolbarFormulaButtonOptions? formulaButtonOptions = - const QuillToolbarFormulaButtonOptions(), QuillToolbarCameraButtonOptions? cameraButtonOptions, QuillToolbarMediaButtonOptions? mediaButtonOptions, }) => @@ -216,11 +212,12 @@ class FlutterQuillEmbeds { // controller: mediaButtonOptions.controller ?? controller, // options: mediaButtonOptions, // ), - if (formulaButtonOptions != null) - (controller, toolbarIconSize, iconTheme, dialogTheme) => - QuillToolbarFormulaButton( - controller: formulaButtonOptions.controller ?? controller, - options: formulaButtonOptions, - ), + // Drop the support for formula button for now + // if (formulaButtonOptions != null) + // (controller, toolbarIconSize, iconTheme, dialogTheme) => + // QuillToolbarFormulaButton( + // controller: formulaButtonOptions.controller ?? controller, + // options: formulaButtonOptions, + // ), ]; } diff --git a/flutter_quill_extensions/lib/presentation/embeds/editor/formula.dart b/flutter_quill_extensions/lib/presentation/embeds/editor/formula.dart index c363658d..41b61e09 100644 --- a/flutter_quill_extensions/lib/presentation/embeds/editor/formula.dart +++ b/flutter_quill_extensions/lib/presentation/embeds/editor/formula.dart @@ -1,16 +1,16 @@ -import 'package:flutter/foundation.dart' show kIsWeb; -import 'package:flutter/services.dart' show SystemChannels; import 'package:flutter/widgets.dart'; import 'package:flutter_quill/extensions.dart' as base; import 'package:flutter_quill/flutter_quill.dart' show BlockEmbed, EmbedBuilder, QuillController; -import 'package:math_keyboard/math_keyboard.dart'; class QuillEditorFormulaEmbedBuilder extends EmbedBuilder { const QuillEditorFormulaEmbedBuilder(); @override String get key => BlockEmbed.formulaType; + @override + bool get expanded => false; + @override Widget build( BuildContext context, @@ -20,23 +20,26 @@ class QuillEditorFormulaEmbedBuilder extends EmbedBuilder { bool inline, TextStyle textStyle, ) { - assert(!kIsWeb, 'Please provide formula EmbedBuilder for Web'); - - final mathController = MathFieldEditingController(); - return Focus( - onFocusChange: (hasFocus) { - if (hasFocus) { - // If the MathField is tapped, hides the built in keyboard - SystemChannels.textInput.invokeMethod('TextInput.hide'); - debugPrint(mathController.currentEditingValue()); - } - }, - child: MathField( - controller: mathController, - variables: const ['x', 'y', 'z'], - onChanged: (value) {}, - onSubmitted: (value) {}, - ), + throw UnsupportedError( + 'The formula EmbedBuilder is not supported for now.', ); + // assert(!kIsWeb, 'Please provide formula EmbedBuilder for Web'); + + // final mathController = MathFieldEditingController(); + // return Focus( + // onFocusChange: (hasFocus) { + // if (hasFocus) { + // // If the MathField is tapped, hides the built in keyboard + // SystemChannels.textInput.invokeMethod('TextInput.hide'); + // debugPrint(mathController.currentEditingValue()); + // } + // }, + // child: MathField( + // controller: mathController, + // variables: const ['x', 'y', 'z'], + // onChanged: (value) {}, + // onSubmitted: (value) {}, + // ), + // ); } } diff --git a/flutter_quill_extensions/pubspec.yaml b/flutter_quill_extensions/pubspec.yaml index 1ee13713..e55a1d14 100644 --- a/flutter_quill_extensions/pubspec.yaml +++ b/flutter_quill_extensions/pubspec.yaml @@ -33,7 +33,7 @@ dependencies: meta: ^1.9.1 universal_html: ^2.2.4 cross_file: ^0.3.3+6 - math_keyboard: ^0.2.1 + # math_keyboard: ^0.2.1 photo_view: ^0.14.0