fix: bulleted list format error
This commit is contained in:
parent
6473be7c68
commit
8bc0b8be99
1 changed files with 78 additions and 21 deletions
|
|
@ -1,10 +1,23 @@
|
|||
import 'package:appflowy_editor/appflowy_editor.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
import '../../util/document_util.dart';
|
||||
import '../../util/util.dart';
|
||||
|
||||
void main() async {
|
||||
group('bulleted_list_shortcut.dart', () {
|
||||
setUpAll(() {
|
||||
if (kDebugMode) {
|
||||
activateLog();
|
||||
}
|
||||
});
|
||||
|
||||
tearDownAll(() {
|
||||
if (kDebugMode) {
|
||||
deactivateLog();
|
||||
}
|
||||
});
|
||||
|
||||
group('formatAsteriskToBulletedList', () {
|
||||
// Before
|
||||
// *|Welcome to AppFlowy Editor 🔥!
|
||||
|
|
@ -58,6 +71,40 @@ void main() async {
|
|||
expect(result, false);
|
||||
expect(before.toJson(), after.toJson());
|
||||
});
|
||||
|
||||
// Before
|
||||
// Welcome to AppFlowy Editor 🔥!
|
||||
// *|Welcome to AppFlowy Editor 🔥!
|
||||
// After
|
||||
// Welcome to AppFlowy Editor 🔥!
|
||||
//[bulleted_list] Welcome to AppFlowy Editor 🔥!
|
||||
test('mock inputting a ` ` in the middle of the text', () async {
|
||||
const text = 'Welcome to AppFlowy Editor 🔥!';
|
||||
final document = Document.blank()
|
||||
.addParagraphs(
|
||||
1,
|
||||
builder: (index) => Delta()..insert(text),
|
||||
)
|
||||
.addParagraphs(
|
||||
1,
|
||||
builder: (index) => Delta()..insert('*$text'),
|
||||
);
|
||||
final editorState = EditorState(document: document);
|
||||
|
||||
// Welcome to AppFlowy Editor 🔥!
|
||||
// *|Welcome to AppFlowy Editor 🔥!
|
||||
final selection = Selection.collapsed(
|
||||
Position(path: [1], offset: 1),
|
||||
);
|
||||
editorState.selection = selection;
|
||||
final result = await formatAsteriskToBulletedList.execute(editorState);
|
||||
final after = editorState.getNodeAtPath([1])!;
|
||||
|
||||
// the second line will be formatted as the bulleted list style
|
||||
expect(result, true);
|
||||
expect(after.type, 'bulleted_list');
|
||||
expect(after.delta!.toPlainText(), text);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue