fix: markdown decoder and encoder test error

This commit is contained in:
Lucas.Xu 2022-12-06 17:48:00 +08:00
parent 29952bc7fd
commit 114968f2ee
3 changed files with 17 additions and 2 deletions

View File

@ -80,7 +80,7 @@ class DocumentMarkdownDecoder extends Converter<String, Document> {
BuiltInAttributeKey.subtype: BuiltInAttributeKey.quote,
},
);
} else if (RegExp(r'^-*').stringMatch(text) == text) {
} else if (text.isNotEmpty && RegExp(r'^-*').stringMatch(text) == text) {
return Node(type: 'divider');
}

View File

@ -0,0 +1,15 @@
import 'package:appflowy_editor/appflowy_editor.dart';
import 'package:appflowy_editor/src/plugins/markdown/encoder/parser/divider_node_parser.dart';
import 'package:flutter_test/flutter_test.dart';
void main() async {
group('divider_node_parser.dart', () {
test('parser divider node', () {
final node = Node(
type: 'divider',
);
final result = const DividerNodeParser().transform(node);
expect(result, '---\n');
});
});
}

View File

@ -86,7 +86,7 @@ void main() async {
final node = TextNode(
delta: Delta(operations: [TextInsert(text)]),
attributes: {
BuiltInAttributeKey.subtype: 'code-block',
BuiltInAttributeKey.subtype: 'code_block',
},
);
expect(const TextNodeParser().transform(node), '```\n$text\n```');