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
chore: fix test error
Lucas.Xufa05170c8602
diff --git a/frontend/app_flowy/packages/flowy_editor/lib/operation/transaction_builder.dart b/frontend/app_flowy/packages/flowy_editor/lib/operation/transaction_builder.dartindex dd531d5d5e..88e0c00890 100644--- a/frontend/app_flowy/packages/flowy_editor/lib/operation/transaction_builder.dart+++ b/frontend/app_flowy/packages/flowy_editor/lib/operation/transaction_builder.dart@@ -30,14 +30,10 @@ class TransactionBuilder {insertNode(Path path, Node node) {insertNodes(path, [node]);- // FIXME: Not exactly correct, needs to be customized.- afterSelection = Selection.collapsed(- Position(path: path, offset: 0),- );}insertNodes(Path path, List<Node> nodes) {- beforeSelection = state.service.selectionService.currentSelection;+ beforeSelection = state.cursorSelection;add(InsertOperation(path, nodes));}@@ -74,7 +70,7 @@ class TransactionBuilder {}textEdit(TextNode node, Delta Function() f) {- beforeSelection = state.service.selectionService.currentSelection;+ beforeSelection = state.cursorSelection;final path = node.path;final delta = f();diff --git a/frontend/app_flowy/packages/flowy_editor/lib/service/internal_key_event_handlers/enter_in_edge_of_text_node_handler.dart b/frontend/app_flowy/packages/flowy_editor/lib/service/internal_key_event_handlers/enter_in_edge_of_text_node_handler.dartindex b08dcb1f80..525afd9021 100644--- a/frontend/app_flowy/packages/flowy_editor/lib/service/internal_key_event_handlers/enter_in_edge_of_text_node_handler.dart+++ b/frontend/app_flowy/packages/flowy_editor/lib/service/internal_key_event_handlers/enter_in_edge_of_text_node_handler.dart@@ -4,6 +4,8 @@ import 'package:flutter/material.dart';import 'package:flutter/services.dart';import 'package:flowy_editor/document/node.dart';+import 'package:flowy_editor/document/position.dart';+import 'package:flowy_editor/document/selection.dart';import 'package:flowy_editor/document/text_delta.dart';import 'package:flowy_editor/extensions/node_extensions.dart';import 'package:flowy_editor/extensions/path_extensions.dart';@@ -40,6 +42,12 @@ FlowyKeyEventHandler enterInEdgeOfTextNodeHandler = (editorState, event) {needCopyAttributes ? {StyleKey.subtype: textNode.subtype} : {},),)+ ..afterSelection = Selection.collapsed(+ Position(+ path: textNode.path.next,+ offset: 0,+ ),+ )..commit();return KeyEventResult.handled;} else if (textNode.selectable!.start() == selection.start) {@@ -52,6 +60,12 @@ FlowyKeyEventHandler enterInEdgeOfTextNodeHandler = (editorState, event) {attributes: {},),)+ ..afterSelection = Selection.collapsed(+ Position(+ path: textNode.path.next,+ offset: 0,+ ),+ )..commit();return KeyEventResult.handled;}diff --git a/frontend/app_flowy/packages/flowy_editor/test/operation_test.dart b/frontend/app_flowy/packages/flowy_editor/test/operation_test.dartindex 7507cb65bf..339807cea4 100644--- a/frontend/app_flowy/packages/flowy_editor/test/operation_test.dart+++ b/frontend/app_flowy/packages/flowy_editor/test/operation_test.dart@@ -8,6 +8,7 @@ import 'package:flowy_editor/editor_state.dart';import 'package:flowy_editor/document/state_tree.dart';void main() {+ TestWidgetsFlutterBinding.ensureInitialized();group('transform path', () {test('transform path changed', () {expect(transformPath([0, 1], [0, 1]), [0, 2]);@@ -87,7 +88,7 @@ void main() {"path": [0],"nodes": [item1.toJson()],}- ],+ ]});});test("delete", () {