feat: implement revert text in toolbar service

This commit is contained in:
Lucas.Xu 2022-08-02 11:47:48 +08:00
parent 9b6afcc5c9
commit 1ba15b321b
2 changed files with 6 additions and 0 deletions

View File

@ -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',

View File

@ -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,