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.
Dart blogconfluence-alternativecontent-managementcontent-servicesdocumentationflutternote-takingnotion-alternativeproject-managementtask-managementteam-collaborationwiki
feat: check previous node's number
Vincent Chan875c109b1406
diff --git a/frontend/app_flowy/packages/appflowy_editor/lib/src/service/internal_key_event_handlers/whitespace_handler.dart b/frontend/app_flowy/packages/appflowy_editor/lib/src/service/internal_key_event_handlers/whitespace_handler.dartindex f9d1f4a5fa..fb78fce1b3 100644--- a/frontend/app_flowy/packages/appflowy_editor/lib/src/service/internal_key_event_handlers/whitespace_handler.dart+++ b/frontend/app_flowy/packages/appflowy_editor/lib/src/service/internal_key_event_handlers/whitespace_handler.dart@@ -77,6 +77,22 @@ KeyEventResult _toNumberList(EditorState editorState, TextNode textNode,return KeyEventResult.ignored;}+ // The user types number + . + space, he wants to turn+ // this line into number list, but we should check if previous line+ // is number list.+ //+ // Check whether the number input by the user is the successor of the previous+ // line. If it's not, ignore it.+ final prevNode = textNode.previous;+ if (prevNode != null &&+ prevNode is TextNode &&+ prevNode.attributes[StyleKey.subtype] == StyleKey.numberList) {+ final prevNumber = prevNode.attributes[StyleKey.number] as int;+ if (numValue != prevNumber + 1) {+ return KeyEventResult.ignored;+ }+ }+final afterSelection = Selection.collapsed(Position(path: textNode.path,offset: 0,