feat: added numbered list to the slash menu

This commit is contained in:
citricacid2 2022-10-03 17:00:17 -04:00
parent 2331b328d8
commit 3e620ed335
2 changed files with 15 additions and 0 deletions

View File

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

View File

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