diff --git a/lib/src/editor/block_component/heading_block_component/heading_block_component.dart b/lib/src/editor/block_component/heading_block_component/heading_block_component.dart index ccb872556..8a13d4553 100644 --- a/lib/src/editor/block_component/heading_block_component/heading_block_component.dart +++ b/lib/src/editor/block_component/heading_block_component/heading_block_component.dart @@ -22,12 +22,10 @@ Node headingNode({ required int level, Delta? delta, Attributes? attributes, - Iterable? children, }) { attributes ??= {'delta': (delta ?? Delta()).toJson()}; return Node( type: HeadingBlockKeys.type, - children: children ?? [], attributes: { HeadingBlockKeys.level: level, ...attributes, diff --git a/lib/src/plugins/html/html_document_decoder.dart b/lib/src/plugins/html/html_document_decoder.dart index 63d9d1208..ce6bcb27d 100644 --- a/lib/src/plugins/html/html_document_decoder.dart +++ b/lib/src/plugins/html/html_document_decoder.dart @@ -62,11 +62,11 @@ class DocumentHTMLDecoder extends Converter { 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: @@ -81,7 +81,7 @@ class DocumentHTMLDecoder extends Converter { case HTMLTags.paragraph: return _parseParagraphElement(element); case HTMLTags.blockQuote: - return _parseBlockQuoteElement(element); + return [_parseBlockQuoteElement(element)]; case HTMLTags.image: return [_parseImageElement(element)]; default: @@ -132,27 +132,27 @@ class DocumentHTMLDecoder extends Converter { return attributes; } - Node _parseHeadingElement( + Iterable _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 _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 _parseUnOrderListElement(dom.Element element) {