getBlockFormats method
Given the textBlock, decides what combination of block-level attributes
should be applied to the Quill Delta for this text block.
Implementation
@protected
Map<String, dynamic> getBlockFormats(TextNode textBlock) {
final blockAttributes = <String, dynamic>{};
// Add all the block-level formats that aren't mutually exclusive.
if (textBlock.metadata["textAlign"] != null) {
blockAttributes["align"] = textBlock.metadata["textAlign"];
}
final blockType = textBlock.metadata["blockType"] as Attribution?;
if (blockType == null) {
return blockAttributes;
}
// Add the mutually exclusive block format.
switch (blockType) {
case header1Attribution:
blockAttributes["header"] = 1;
case header2Attribution:
blockAttributes["header"] = 2;
case header3Attribution:
blockAttributes["header"] = 3;
case header4Attribution:
blockAttributes["header"] = 4;
case header5Attribution:
blockAttributes["header"] = 5;
case header6Attribution:
blockAttributes["header"] = 6;
case blockquoteAttribution:
blockAttributes["blockquote"] = true;
case codeAttribution:
blockAttributes["code-block"] = "plain";
}
return blockAttributes;
}