File tree 2 files changed +16
-1
lines changed 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -997,6 +997,7 @@ class _ZulipContentParser {
997
997
assert (_debugParserContext == _ParserContext .block);
998
998
final List <BlockContentNode > result = [];
999
999
final List <dom.Node > currentParagraph = [];
1000
+ List <ImageNode > imageNodes = [];
1000
1001
void consumeParagraph () {
1001
1002
final parsed = parseBlockInline (currentParagraph);
1002
1003
result.add (ParagraphNode (
@@ -1014,9 +1015,19 @@ class _ZulipContentParser {
1014
1015
continue ;
1015
1016
}
1016
1017
if (currentParagraph.isNotEmpty) consumeParagraph ();
1017
- result.add (parseBlockContent (node));
1018
+ final block = parseBlockContent (node);
1019
+ if (block is ImageNode ) {
1020
+ imageNodes.add (block);
1021
+ continue ;
1022
+ }
1023
+ if (imageNodes.isNotEmpty) {
1024
+ result.add (ImageNodeList (imageNodes));
1025
+ imageNodes = [];
1026
+ }
1027
+ result.add (block);
1018
1028
}
1019
1029
if (currentParagraph.isNotEmpty) consumeParagraph ();
1030
+ if (imageNodes.isNotEmpty) result.add (ImageNodeList (imageNodes));
1020
1031
1021
1032
return result;
1022
1033
}
Original file line number Diff line number Diff line change @@ -85,6 +85,10 @@ class BlockContentList extends StatelessWidget {
85
85
} else if (node is ImageNodeList ) {
86
86
return MessageImageList (node: node);
87
87
} else if (node is ImageNode ) {
88
+ assert (false ,
89
+ "[ImageNode] not allowed in [BlockContentList]. "
90
+ "It should be wrapped in [ImageNodeList]."
91
+ );
88
92
return MessageImage (node: node);
89
93
} else if (node is UnimplementedBlockContentNode ) {
90
94
return Text .rich (_errorUnimplemented (node));
You can’t perform that action at this time.
0 commit comments