From a1e73a52c8b4b1244ec5c6f9f3a0a227b2a59197 Mon Sep 17 00:00:00 2001 From: Ellet Date: Fri, 8 Dec 2023 09:41:43 +0300 Subject: [PATCH] Update simple toolbar --- doc/todo.md | 1 + lib/src/widgets/quill/text_line.dart | 10 +++++++--- lib/src/widgets/toolbar/simple_toolbar.dart | 20 ++++++++++---------- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/doc/todo.md b/doc/todo.md index 01401c114..1800df56b 100644 --- a/doc/todo.md +++ b/doc/todo.md @@ -34,6 +34,7 @@ This is a todo list page that added recently and will be updated soon. - Fix the bugs of the font family and font size - Try to update Quill Html Converter - When pasting a HTML text from cliboard by not using the context menu builder, the new logic won't work + - Add strike-through in checkbox text when the checkpoint is checked ### Bugs diff --git a/lib/src/widgets/quill/text_line.dart b/lib/src/widgets/quill/text_line.dart index c1b68f42d..cdf493ff5 100644 --- a/lib/src/widgets/quill/text_line.dart +++ b/lib/src/widgets/quill/text_line.dart @@ -164,7 +164,8 @@ class _TextLineState extends State { } } final textSpan = _getTextSpanForWholeLine(); - final strutStyle = StrutStyle.fromTextStyle(textSpan.style!); + final strutStyle = + StrutStyle.fromTextStyle(textSpan.style ?? const TextStyle()); final textAlign = _getTextAlign(); final child = RichText( key: _richTextKey, @@ -247,8 +248,11 @@ class _TextLineState extends State { return TextAlign.start; } - TextSpan _buildTextSpan(DefaultStyles defaultStyles, LinkedList nodes, - TextStyle lineStyle) { + TextSpan _buildTextSpan( + DefaultStyles defaultStyles, + LinkedList nodes, + TextStyle lineStyle, + ) { if (nodes.isEmpty && kIsWeb) { nodes = LinkedList()..add(leaf.QuillText('\u{200B}')); } diff --git a/lib/src/widgets/toolbar/simple_toolbar.dart b/lib/src/widgets/toolbar/simple_toolbar.dart index 9794b3127..4f91cb346 100644 --- a/lib/src/widgets/toolbar/simple_toolbar.dart +++ b/lib/src/widgets/toolbar/simple_toolbar.dart @@ -133,6 +133,16 @@ class QuillSimpleToolbar extends StatelessWidget ), spacerWidget, ], + if (configurations.showStrikeThrough) ...[ + QuillToolbarToggleStyleButton( + attribute: Attribute.strikeThrough, + options: toolbarConfigurations.buttonOptions.strikeThrough, + controller: + toolbarConfigurations.buttonOptions.strikeThrough.controller ?? + globalController, + ), + spacerWidget, + ], if (configurations.showInlineCode) ...[ QuillToolbarToggleStyleButton( attribute: Attribute.inlineCode, @@ -172,16 +182,6 @@ class QuillSimpleToolbar extends StatelessWidget ), spacerWidget, ], - if (configurations.showStrikeThrough) ...[ - QuillToolbarToggleStyleButton( - attribute: Attribute.strikeThrough, - options: toolbarConfigurations.buttonOptions.strikeThrough, - controller: - toolbarConfigurations.buttonOptions.strikeThrough.controller ?? - globalController, - ), - spacerWidget, - ], if (configurations.showColorButton) ...[ QuillToolbarColorButton( controller: toolbarConfigurations.buttonOptions.color.controller ??