Skip to content

Commit

Permalink
fix: quote block return single node
Browse files Browse the repository at this point in the history
  • Loading branch information
alihassan143 committed Jun 11, 2023
1 parent 3847701 commit 4299914
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,10 @@ Node headingNode({
required int level,
Delta? delta,
Attributes? attributes,
Iterable<Node>? children,
}) {
attributes ??= {'delta': (delta ?? Delta()).toJson()};
return Node(
type: HeadingBlockKeys.type,
children: children ?? [],
attributes: {
HeadingBlockKeys.level: level,
...attributes,
Expand Down
36 changes: 18 additions & 18 deletions lib/src/plugins/html/html_document_decoder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ class DocumentHTMLDecoder extends Converter<String, Document> {
final localName = element.localName;
switch (localName) {
case HTMLTags.h1:
return [_parseHeadingElement(element, level: 1)];
return _parseHeadingElement(element, level: 1);
case HTMLTags.h2:
return [_parseHeadingElement(element, level: 2)];
return _parseHeadingElement(element, level: 2);
case HTMLTags.h3:
return [_parseHeadingElement(element, level: 3)];
return _parseHeadingElement(element, level: 3);
case HTMLTags.unorderedList:
return _parseUnOrderListElement(element);
case HTMLTags.orderedList:
Expand All @@ -81,7 +81,7 @@ class DocumentHTMLDecoder extends Converter<String, Document> {
case HTMLTags.paragraph:
return _parseParagraphElement(element);
case HTMLTags.blockQuote:
return _parseBlockQuoteElement(element);
return [_parseBlockQuoteElement(element)];
case HTMLTags.image:
return [_parseImageElement(element)];
default:
Expand Down Expand Up @@ -132,27 +132,27 @@ class DocumentHTMLDecoder extends Converter<String, Document> {
return attributes;
}

Node _parseHeadingElement(
Iterable<Node> _parseHeadingElement(
dom.Element element, {
required int level,
}) {
final (delta, specialNodes) = _parseDeltaElement(element);
return headingNode(
level: level,
children: specialNodes,
delta: delta,
);
return [
headingNode(
level: level,
delta: delta,
),
...specialNodes
];
}

Iterable<Node> _parseBlockQuoteElement(dom.Element element) {
Node _parseBlockQuoteElement(dom.Element element) {
final (delta, nodes) = _parseDeltaElement(element);
return [
Node(
type: QuoteBlockKeys.type,
children: nodes,
attributes: {ParagraphBlockKeys.delta: delta.toJson()},
)
];
return Node(
type: QuoteBlockKeys.type,
children: nodes,
attributes: {ParagraphBlockKeys.delta: delta.toJson()},
);
}

Iterable<Node> _parseUnOrderListElement(dom.Element element) {
Expand Down

0 comments on commit 4299914

Please sign in to comment.