Browse Source

feat: implement revert text in toolbar service

Lucas.Xu 2 years ago
parent
commit
1ba15b321b

+ 2 - 0
frontend/app_flowy/packages/flowy_editor/lib/render/selection/toolbar_widget.dart

@@ -17,12 +17,14 @@ ToolbarEventHandlers defaultToolbarEventHandlers = {
   'quote': (editorState) => formatQuote(editorState),
   'number_list': (editorState) {},
   'bulleted_list': (editorState) => formatBulletedList(editorState),
+  'Text': (editorState) => formatText(editorState),
   'H1': (editorState) => formatHeading(editorState, StyleKey.h1),
   'H2': (editorState) => formatHeading(editorState, StyleKey.h2),
   'H3': (editorState) => formatHeading(editorState, StyleKey.h3),
 };
 
 List<String> defaultListToolbarEventNames = [
+  'Text',
   'H1',
   'H2',
   'H3',

+ 4 - 0
frontend/app_flowy/packages/flowy_editor/lib/service/default_text_operations/format_rich_text_style.dart

@@ -5,6 +5,10 @@ import 'package:flowy_editor/extensions/text_node_extensions.dart';
 import 'package:flowy_editor/operation/transaction_builder.dart';
 import 'package:flowy_editor/render/rich_text/rich_text_style.dart';
 
+void formatText(EditorState editorState) {
+  formatTextNodes(editorState, {});
+}
+
 void formatHeading(EditorState editorState, String heading) {
   formatTextNodes(editorState, {
     StyleKey.subtype: StyleKey.heading,