diff --git a/lib/rich_editor.dart b/lib/rich_editor.dart index 9478106..b5ca9cb 100644 --- a/lib/rich_editor.dart +++ b/lib/rich_editor.dart @@ -1,5 +1,5 @@ library rich_editor; export 'src/rendering/rich_editor.dart'; -export 'src/widgets/tabs.dart'; +export 'src/widgets/editor_tool_bar.dart'; export 'src/widgets/tab_button.dart'; \ No newline at end of file diff --git a/lib/src/utils/command_state.dart b/lib/src/models/command_state.dart similarity index 100% rename from lib/src/utils/command_state.dart rename to lib/src/models/command_state.dart diff --git a/lib/src/models/editor_state.dart b/lib/src/models/editor_state.dart new file mode 100644 index 0000000..f5936cc --- /dev/null +++ b/lib/src/models/editor_state.dart @@ -0,0 +1,15 @@ +import 'package:rich_editor/src/models/enum.dart'; + +import 'command_state.dart'; + +class EditorState { + bool didHtmlChange; + String html; + Map commandStates; + + EditorState({ + this.didHtmlChange = false, + this.html = '', + this.commandStates = const {}, + }); +} diff --git a/lib/src/rendering/rich_editor.dart b/lib/src/rendering/rich_editor.dart index f238abb..2c61fef 100644 --- a/lib/src/rendering/rich_editor.dart +++ b/lib/src/rendering/rich_editor.dart @@ -6,7 +6,7 @@ import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:rich_editor/src/services/local_server.dart'; import 'package:rich_editor/src/utils/javascript_executor_base.dart'; -import 'package:rich_editor/src/widgets/tabs.dart'; +import 'package:rich_editor/src/widgets/editor_tool_bar.dart'; import 'package:webview_flutter/webview_flutter.dart'; class RichEditor extends StatefulWidget { @@ -76,9 +76,10 @@ class RichEditorState extends State { Widget build(BuildContext context) { return Column( children: [ - GroupedTab( + EditorToolBar( controller: _controller, getImageUrl: widget.getImageUrl, + javascriptExecutorBase: javascriptExecutorBase, ), Expanded( child: WebView( @@ -111,9 +112,6 @@ class RichEditorState extends State { print("error ${e.description}"); }, ), - // child: InAppWebView( - // initialFile: 'packages/rich_editor/assets/editor/index.html', - // ), ) ], ); diff --git a/lib/src/utils/javascript_executor_base.dart b/lib/src/utils/javascript_executor_base.dart index 17e6235..cf398cf 100644 --- a/lib/src/utils/javascript_executor_base.dart +++ b/lib/src/utils/javascript_executor_base.dart @@ -3,7 +3,7 @@ import 'package:rich_editor/src/extensions/extensions.dart'; import 'package:rich_editor/src/models/enum.dart'; import 'package:webview_flutter/webview_flutter.dart'; -import 'command_state.dart'; +import '../models/command_state.dart'; class JavascriptExecutorBase { WebViewController? _controller; diff --git a/lib/src/widgets/tabs.dart b/lib/src/widgets/editor_tool_bar.dart similarity index 97% rename from lib/src/widgets/tabs.dart rename to lib/src/widgets/editor_tool_bar.dart index 8e67ccd..1e95ea0 100644 --- a/lib/src/widgets/tabs.dart +++ b/lib/src/widgets/editor_tool_bar.dart @@ -13,24 +13,28 @@ import 'color_picker_dialog.dart'; import 'font_size_dialog.dart'; import 'heading_dialog.dart'; -class GroupedTab extends StatelessWidget { +class EditorToolBar extends StatelessWidget { final WebViewController? controller; final Function(File image)? getImageUrl; final Function(File video)? getVideoUrl; + final JavascriptExecutorBase javascriptExecutorBase; - GroupedTab({this.controller, this.getImageUrl, this.getVideoUrl}); - - JavascriptExecutorBase javascriptExecutorBase = JavascriptExecutorBase(); + EditorToolBar({ + this.controller, + this.getImageUrl, + this.getVideoUrl, + required this.javascriptExecutorBase, + }); @override Widget build(BuildContext context) { - if (controller != null) { - javascriptExecutorBase.init(controller!); - } + // if (controller != null) { + // javascriptExecutorBase.init(controller!); + // } return Container( // color: Color(0xff424242), - height: 59.0, + height: 54.0, child: Column( children: [ Flexible( @@ -309,6 +313,7 @@ class GroupedTab extends StatelessWidget { await javascriptExecutorBase.insertCheckbox(text); }, ), + /// TODO: Implement Search feature // TabButton( // tooltip: 'Search', diff --git a/lib/src/widgets/tab_button.dart b/lib/src/widgets/tab_button.dart index b5827a6..e2bfafd 100644 --- a/lib/src/widgets/tab_button.dart +++ b/lib/src/widgets/tab_button.dart @@ -14,8 +14,8 @@ class TabButton extends StatelessWidget { child: Tooltip( message: '$tooltip', child: Container( - height: 45.0, - width: 45.0, + height: 40.0, + width: 40.0, decoration: BoxDecoration( // color: Color(0xff212121), borderRadius: BorderRadius.all(