Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

feat: implement revert text in toolbar service

Lucas.Xu1ba15b321b0c
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<String> 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,