From 1ba15b321b0cf1454ab8e8771e04d9b9c37c0b7b Mon Sep 17 00:00:00 2001 From: "Lucas.Xu" Date: Tue, 2 Aug 2022 11:47:48 +0800 Subject: [PATCH] feat: implement revert text in toolbar service --- .../flowy_editor/lib/render/selection/toolbar_widget.dart | 2 ++ .../default_text_operations/format_rich_text_style.dart | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/frontend/app_flowy/packages/flowy_editor/lib/render/selection/toolbar_widget.dart b/frontend/app_flowy/packages/flowy_editor/lib/render/selection/toolbar_widget.dart index c06776a0a3..91659e1d1f 100644 --- a/frontend/app_flowy/packages/flowy_editor/lib/render/selection/toolbar_widget.dart +++ b/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 defaultListToolbarEventNames = [ + 'Text', 'H1', 'H2', 'H3', diff --git a/frontend/app_flowy/packages/flowy_editor/lib/service/default_text_operations/format_rich_text_style.dart b/frontend/app_flowy/packages/flowy_editor/lib/service/default_text_operations/format_rich_text_style.dart index 73945e5d88..79e7bfe077 100644 --- a/frontend/app_flowy/packages/flowy_editor/lib/service/default_text_operations/format_rich_text_style.dart +++ b/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,