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: added numbered list to the slash menu

citricacid23e620ed3358b
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<SelectionMenuItem> _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;