From 3e620ed3358be9f1e6e63d2daae7c9d6290a1343 Mon Sep 17 00:00:00 2001 From: citricacid2 <61765149+citricacid2@users.noreply.github.com> Date: Mon, 3 Oct 2022 17:00:17 -0400 Subject: [PATCH] feat: added numbered list to the slash menu --- .../src/render/selection_menu/selection_menu_service.dart | 8 ++++++++ .../default_text_operations/format_rich_text_style.dart | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/frontend/app_flowy/packages/appflowy_editor/lib/src/render/selection_menu/selection_menu_service.dart b/frontend/app_flowy/packages/appflowy_editor/lib/src/render/selection_menu/selection_menu_service.dart index 4fbc480dfd..4da824db80 100644 --- a/frontend/app_flowy/packages/appflowy_editor/lib/src/render/selection_menu/selection_menu_service.dart +++ b/frontend/app_flowy/packages/appflowy_editor/lib/src/render/selection_menu/selection_menu_service.dart @@ -169,6 +169,14 @@ final List _defaultSelectionMenuItems = [ insertBulletedListAfterSelection(editorState); }, ), + SelectionMenuItem( + name: () => AppFlowyEditorLocalizations.current.numberedList, + icon: _selectionMenuIcon('number'), + keywords: ['numbered list', 'list', 'ordered list'], + handler: (editorState, _, __) { + insertNumberedListAfterSelection(editorState); + }, + ), SelectionMenuItem( name: () => AppFlowyEditorLocalizations.current.checkbox, icon: _selectionMenuIcon('checkbox'), diff --git a/frontend/app_flowy/packages/appflowy_editor/lib/src/service/default_text_operations/format_rich_text_style.dart b/frontend/app_flowy/packages/appflowy_editor/lib/src/service/default_text_operations/format_rich_text_style.dart index 053d9e542a..adf45bec65 100644 --- a/frontend/app_flowy/packages/appflowy_editor/lib/src/service/default_text_operations/format_rich_text_style.dart +++ b/frontend/app_flowy/packages/appflowy_editor/lib/src/service/default_text_operations/format_rich_text_style.dart @@ -34,6 +34,13 @@ void insertBulletedListAfterSelection(EditorState editorState) { }); } +void insertNumberedListAfterSelection(EditorState editorState) { + insertTextNodeAfterSelection(editorState, { + BuiltInAttributeKey.subtype: BuiltInAttributeKey.numberList, + BuiltInAttributeKey.number: 1, + }); +} + bool insertTextNodeAfterSelection( EditorState editorState, Attributes attributes) { final selection = editorState.service.selectionService.currentSelection.value;