diff --git a/lib/src/plugins/html/encoder/parser/todo_list_node_parser.dart b/lib/src/plugins/html/encoder/parser/todo_list_node_parser.dart index bae2dd9d9..5d31f6704 100644 --- a/lib/src/plugins/html/encoder/parser/todo_list_node_parser.dart +++ b/lib/src/plugins/html/encoder/parser/todo_list_node_parser.dart @@ -26,10 +26,12 @@ class HTMLTodoListNodeParser extends HTMLNodeParser { }) { final delta = node.delta ?? Delta(); final domNodes = deltaHTMLEncoder.convert(delta); + final elementNode = dom.Element.html(''); - elementNode.attributes['checked'] = - node.attributes[TodoListBlockKeys.checked].toString(); - domNodes.add(elementNode); + if (node.attributes[TodoListBlockKeys.checked] as bool? ?? false) { + elementNode.attributes['checked'] = ''; + } + domNodes.insert(0, elementNode); domNodes.addAll( processChildrenNodes(node.children, encodeParsers: encodeParsers), ); diff --git a/test/plugins/html/encoder/parser/text_node_parser_test.dart b/test/plugins/html/encoder/parser/text_node_parser_test.dart index 24b7522a5..1a4b494ca 100644 --- a/test/plugins/html/encoder/parser/text_node_parser_test.dart +++ b/test/plugins/html/encoder/parser/text_node_parser_test.dart @@ -88,12 +88,12 @@ void main() async { expect( const HTMLTodoListNodeParser() .transformNodeToHTMLString(checkedNode, encodeParsers: parser), - '
Welcome to AppFlowy
', + '
Welcome to AppFlowy
', ); expect( const HTMLTodoListNodeParser() .transformNodeToHTMLString(uncheckedNode, encodeParsers: parser), - '
Welcome to AppFlowy
', + '
Welcome to AppFlowy
', ); });