serialize method
Serializes the given node to a Markdown String.
When selection is null, the entire node is converted to markdown. When
selection is non-null, only the selected range is converted to markdown.
Returns null if the node is not supported by this serializer.
Implementation
@override
String? serialize(
Document document,
DocumentNode node, {
NodeSelection? selection,
}) {
if (node is! ParagraphNode) {
return null;
}
// Only serialize this node when this is a header node.
final Attribution? blockType = node.getMetadataValue('blockType');
final isHeaderNode = blockType == header1Attribution ||
blockType == header2Attribution ||
blockType == header3Attribution ||
blockType == header4Attribution ||
blockType == header5Attribution ||
blockType == header6Attribution;
if (!isHeaderNode) {
return null;
}
return doSerialization(document, node);
}