mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
fix: add missing markdown converter for code block and divider
This commit is contained in:
parent
64ee3140a3
commit
29952bc7fd
@ -80,6 +80,8 @@ class DocumentMarkdownDecoder extends Converter<String, Document> {
|
|||||||
BuiltInAttributeKey.subtype: BuiltInAttributeKey.quote,
|
BuiltInAttributeKey.subtype: BuiltInAttributeKey.quote,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
} else if (RegExp(r'^-*').stringMatch(text) == text) {
|
||||||
|
return Node(type: 'divider');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (text.isNotEmpty) {
|
if (text.isNotEmpty) {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:appflowy_editor/src/core/document/document.dart';
|
import 'package:appflowy_editor/src/core/document/document.dart';
|
||||||
|
import 'package:appflowy_editor/src/plugins/markdown/encoder/parser/divider_node_parser.dart';
|
||||||
import 'package:appflowy_editor/src/plugins/markdown/encoder/parser/image_node_parser.dart';
|
import 'package:appflowy_editor/src/plugins/markdown/encoder/parser/image_node_parser.dart';
|
||||||
import 'package:appflowy_editor/src/plugins/markdown/encoder/parser/node_parser.dart';
|
import 'package:appflowy_editor/src/plugins/markdown/encoder/parser/node_parser.dart';
|
||||||
import 'package:appflowy_editor/src/plugins/markdown/encoder/parser/text_node_parser.dart';
|
import 'package:appflowy_editor/src/plugins/markdown/encoder/parser/text_node_parser.dart';
|
||||||
@ -10,6 +11,7 @@ class DocumentMarkdownEncoder extends Converter<Document, String> {
|
|||||||
this.parsers = const [
|
this.parsers = const [
|
||||||
TextNodeParser(),
|
TextNodeParser(),
|
||||||
ImageNodeParser(),
|
ImageNodeParser(),
|
||||||
|
DividerNodeParser(),
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -0,0 +1,14 @@
|
|||||||
|
import 'package:appflowy_editor/src/core/document/node.dart';
|
||||||
|
import 'package:appflowy_editor/src/plugins/markdown/encoder/parser/node_parser.dart';
|
||||||
|
|
||||||
|
class DividerNodeParser extends NodeParser {
|
||||||
|
const DividerNodeParser();
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get id => 'divider';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String transform(Node node) {
|
||||||
|
return '---\n';
|
||||||
|
}
|
||||||
|
}
|
@ -40,7 +40,7 @@ class TextNodeParser extends NodeParser {
|
|||||||
}
|
}
|
||||||
} else if (subtype == 'quote') {
|
} else if (subtype == 'quote') {
|
||||||
result = '> $markdown';
|
result = '> $markdown';
|
||||||
} else if (subtype == 'code-block') {
|
} else if (subtype == 'code_block') {
|
||||||
result = '```\n$markdown\n```';
|
result = '```\n$markdown\n```';
|
||||||
} else if (subtype == 'bulleted-list') {
|
} else if (subtype == 'bulleted-list') {
|
||||||
result = '* $markdown';
|
result = '* $markdown';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user