From 813793100b2d1baeba78ed3bb8f2efcbbbac8be1 Mon Sep 17 00:00:00 2001 From: the-airbender <57312080+the-airbender@users.noreply.github.com> Date: Fri, 28 Apr 2023 14:54:00 +0530 Subject: [PATCH] ### 2.1.9 - Added a customisable option to make toolbar scrollable horizontally or vertically - Fixed `onFocusChanged` method not returning focus on iOS properly - Fixed text-change method is not returning text properly on Android - Fixed moving cursor to end after `setDelta` - Fix the white space in theme dark mode after adding minHeight property, thanks to `cabbagelol` for PR - Fix Mobile Web - Clicking on toolbar icon does not toggle highlight color, and keyboard loses focus - Updated `webview_flutter_android`, `webview_flutter_wkwebview` to latest versions - Fix customToolBarList: ToolBarStyle.background adds table items #63 - Improved `onEditorCreated` callback functionality --- example/lib/main.dart | 85 ++++++----- example/pubspec.lock | 10 +- lib/src/quill_editor_wrapper.dart | 163 ++++++++++++++++------ lib/src/tool_bar.dart | 162 +++++++++++++++++++-- lib/src/widgets/edit_table_drop_down.dart | 10 +- pubspec.yaml | 4 +- 6 files changed, 327 insertions(+), 107 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index 64c3ee0..e754123 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -26,15 +26,21 @@ class _MyAppState extends State { ToolBarStyle.italic, ToolBarStyle.align, ToolBarStyle.color, + ToolBarStyle.background, + ToolBarStyle.listBullet, + ToolBarStyle.listOrdered, + ToolBarStyle.clean, + ToolBarStyle.addTable, + ToolBarStyle.editTable, ]; - final _toolbarColor = Colors.greenAccent.shade100; + final _toolbarColor = Colors.grey.shade200; final _backgroundColor = Colors.white70; final _toolbarIconColor = Colors.black87; final _editorTextStyle = const TextStyle( fontSize: 18, color: Colors.black, fontWeight: FontWeight.normal); final _hintTextStyle = const TextStyle( - fontSize: 18, color: Colors.teal, fontWeight: FontWeight.normal); + fontSize: 18, color: Colors.black12, fontWeight: FontWeight.normal); @override void initState() { @@ -56,41 +62,44 @@ class _MyAppState extends State { Widget build(BuildContext context) { return SafeArea( child: Scaffold( + backgroundColor: Colors.white, resizeToAvoidBottomInset: true, - backgroundColor: Colors.white70, - body: Column( + body: Row( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start, children: [ - ToolBar( - toolBarColor: _toolbarColor, - padding: const EdgeInsets.all(8), - iconSize: 25, - iconColor: _toolbarIconColor, - activeIconColor: Colors.purple.shade300, - controller: controller, - alignment: WrapAlignment.start, - crossAxisAlignment: WrapCrossAlignment.center, - customButtons: [ - InkWell( - onTap: () => unFocusEditor(), - child: const Icon( - Icons.favorite, - color: Colors.black, - )), - InkWell( - onTap: () async { - var selectedText = await controller.getSelectedText(); - debugPrint('selectedText $selectedText'); - var selectedHtmlText = - await controller.getSelectedHtmlText(); - debugPrint('selectedHtmlText $selectedHtmlText'); - }, - child: const Icon( - Icons.add_circle, - color: Colors.black, - )), - ], + SizedBox( + width: 50, + child: ToolBar.scroll( + toolBarColor: _toolbarColor, + padding: const EdgeInsets.all(8), + iconSize: 25, + iconColor: _toolbarIconColor, + activeIconColor: Colors.greenAccent.shade400, + controller: controller, + crossAxisAlignment: CrossAxisAlignment.center, + direction: Axis.vertical, + customButtons: [ + InkWell( + onTap: () => unFocusEditor(), + child: const Icon( + Icons.favorite, + color: Colors.black, + )), + InkWell( + onTap: () async { + var selectedText = await controller.getSelectedText(); + debugPrint('selectedText $selectedText'); + var selectedHtmlText = + await controller.getSelectedHtmlText(); + debugPrint('selectedHtmlText $selectedHtmlText'); + }, + child: const Icon( + Icons.add_circle, + color: Colors.black, + )), + ], + ), ), Flexible( fit: FlexFit.tight, @@ -99,7 +108,7 @@ class _MyAppState extends State { hintText: 'Hint text goes here', controller: controller, isEnabled: true, - minHeight: 300, + minHeight: 500, textStyle: _editorTextStyle, hintTextStyle: _hintTextStyle, hintTextAlign: TextAlign.start, @@ -108,7 +117,10 @@ class _MyAppState extends State { backgroundColor: _backgroundColor, onFocusChanged: (hasFocus) => debugPrint('has focus $hasFocus'), onTextChanged: (text) => debugPrint('widget text change $text'), - onEditorCreated: () => debugPrint('Editor has been loaded'), + onEditorCreated: () { + debugPrint('Editor has been loaded'); + setHtmlText('Testing text on load'); + }, onEditorResized: (height) => debugPrint('Editor resized $height'), onSelectionChanged: (sel) => @@ -127,8 +139,7 @@ class _MyAppState extends State { textButton( text: 'Set Text', onPressed: () { - setHtmlText( - '