mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
chore: fix test error
This commit is contained in:
parent
56ac86fb51
commit
fa05170c86
@ -30,14 +30,10 @@ class TransactionBuilder {
|
|||||||
|
|
||||||
insertNode(Path path, Node node) {
|
insertNode(Path path, Node node) {
|
||||||
insertNodes(path, [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) {
|
insertNodes(Path path, List<Node> nodes) {
|
||||||
beforeSelection = state.service.selectionService.currentSelection;
|
beforeSelection = state.cursorSelection;
|
||||||
add(InsertOperation(path, nodes));
|
add(InsertOperation(path, nodes));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,7 +70,7 @@ class TransactionBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
textEdit(TextNode node, Delta Function() f) {
|
textEdit(TextNode node, Delta Function() f) {
|
||||||
beforeSelection = state.service.selectionService.currentSelection;
|
beforeSelection = state.cursorSelection;
|
||||||
final path = node.path;
|
final path = node.path;
|
||||||
|
|
||||||
final delta = f();
|
final delta = f();
|
||||||
|
@ -4,6 +4,8 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
|
|
||||||
import 'package:flowy_editor/document/node.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/document/text_delta.dart';
|
||||||
import 'package:flowy_editor/extensions/node_extensions.dart';
|
import 'package:flowy_editor/extensions/node_extensions.dart';
|
||||||
import 'package:flowy_editor/extensions/path_extensions.dart';
|
import 'package:flowy_editor/extensions/path_extensions.dart';
|
||||||
@ -40,6 +42,12 @@ FlowyKeyEventHandler enterInEdgeOfTextNodeHandler = (editorState, event) {
|
|||||||
needCopyAttributes ? {StyleKey.subtype: textNode.subtype} : {},
|
needCopyAttributes ? {StyleKey.subtype: textNode.subtype} : {},
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
..afterSelection = Selection.collapsed(
|
||||||
|
Position(
|
||||||
|
path: textNode.path.next,
|
||||||
|
offset: 0,
|
||||||
|
),
|
||||||
|
)
|
||||||
..commit();
|
..commit();
|
||||||
return KeyEventResult.handled;
|
return KeyEventResult.handled;
|
||||||
} else if (textNode.selectable!.start() == selection.start) {
|
} else if (textNode.selectable!.start() == selection.start) {
|
||||||
@ -52,6 +60,12 @@ FlowyKeyEventHandler enterInEdgeOfTextNodeHandler = (editorState, event) {
|
|||||||
attributes: {},
|
attributes: {},
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
..afterSelection = Selection.collapsed(
|
||||||
|
Position(
|
||||||
|
path: textNode.path.next,
|
||||||
|
offset: 0,
|
||||||
|
),
|
||||||
|
)
|
||||||
..commit();
|
..commit();
|
||||||
return KeyEventResult.handled;
|
return KeyEventResult.handled;
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import 'package:flowy_editor/editor_state.dart';
|
|||||||
import 'package:flowy_editor/document/state_tree.dart';
|
import 'package:flowy_editor/document/state_tree.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
|
TestWidgetsFlutterBinding.ensureInitialized();
|
||||||
group('transform path', () {
|
group('transform path', () {
|
||||||
test('transform path changed', () {
|
test('transform path changed', () {
|
||||||
expect(transformPath([0, 1], [0, 1]), [0, 2]);
|
expect(transformPath([0, 1], [0, 1]), [0, 2]);
|
||||||
@ -87,7 +88,7 @@ void main() {
|
|||||||
"path": [0],
|
"path": [0],
|
||||||
"nodes": [item1.toJson()],
|
"nodes": [item1.toJson()],
|
||||||
}
|
}
|
||||||
],
|
]
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
test("delete", () {
|
test("delete", () {
|
||||||
|
Loading…
Reference in New Issue
Block a user