@@ -262,7 +262,8 @@ class ContentExample {
262262 nodes: [TextNode ('image' )]),
263263 ]),
264264 ImageNodeList ([
265- ImageNode (srcUrl: 'https://chat.zulip.org/user_avatars/2/realm/icon.png?version=3' ),
265+ ImageNode (srcUrl: 'https://chat.zulip.org/user_avatars/2/realm/icon.png?version=3' ,
266+ thumbnailUrl: null , loading: false ),
266267 ]),
267268 ],
268269 content: [ParagraphNode (links: null , nodes: [TextNode ('hello world' )])],
@@ -420,12 +421,40 @@ class ContentExample {
420421
421422 static const imageSingle = ContentExample (
422423 'single image' ,
424+ // https://chat.zulip.org/#narrow/stream/7-test-here/topic/Thumbnails/near/1893590
425+ "[image.jpg](/user_uploads/2/c3/wb9FXk8Ej6qIc28aWKcqUogD/image.jpg)" ,
426+ '<div class="message_inline_image">'
427+ '<a href="/user_uploads/2/c3/wb9FXk8Ej6qIc28aWKcqUogD/image.jpg" title="image.jpg">'
428+ '<img src="/user_uploads/thumbnail/2/c3/wb9FXk8Ej6qIc28aWKcqUogD/image.jpg/840x560.webp"/></a></div>' , [
429+ ImageNodeList ([
430+ ImageNode (srcUrl: '/user_uploads/2/c3/wb9FXk8Ej6qIc28aWKcqUogD/image.jpg' ,
431+ thumbnailUrl: '/user_uploads/thumbnail/2/c3/wb9FXk8Ej6qIc28aWKcqUogD/image.jpg/840x560.webp' ,
432+ loading: false ),
433+ ]),
434+ ]);
435+
436+ static const imageSingleNoThumbnail = ContentExample (
437+ 'single image no thumbnail' ,
423438 "https://chat.zulip.org/user_avatars/2/realm/icon.png?version=3" ,
424439 '<div class="message_inline_image">'
425440 '<a href="https://chat.zulip.org/user_avatars/2/realm/icon.png?version=3">'
426441 '<img src="https://chat.zulip.org/user_avatars/2/realm/icon.png?version=3"></a></div>' , [
427442 ImageNodeList ([
428- ImageNode (srcUrl: 'https://chat.zulip.org/user_avatars/2/realm/icon.png?version=3' ),
443+ ImageNode (srcUrl: 'https://chat.zulip.org/user_avatars/2/realm/icon.png?version=3' ,
444+ thumbnailUrl: null , loading: false ),
445+ ]),
446+ ]);
447+
448+ static const imageSingleLoadingPlaceholder = ContentExample (
449+ 'single image loading placeholder' ,
450+ // https://chat.zulip.org/#narrow/stream/7-test-here/topic/Thumbnails/near/1893590
451+ "[image.jpg](/user_uploads/2/c3/wb9FXk8Ej6qIc28aWKcqUogD/image.jpg)" ,
452+ '<div class="message_inline_image">'
453+ '<a href="/user_uploads/2/c3/wb9FXk8Ej6qIc28aWKcqUogD/image.jpg" title="image.jpg">'
454+ '<img class="image-loading-placeholder" src="/static/images/loading/loader-black.svg"></a></div>' , [
455+ ImageNodeList ([
456+ ImageNode (srcUrl: '/user_uploads/2/c3/wb9FXk8Ej6qIc28aWKcqUogD/image.jpg' ,
457+ thumbnailUrl: null , loading: true ),
429458 ]),
430459 ]);
431460
@@ -436,12 +465,41 @@ class ContentExample {
436465 '<a href="::not a URL::">'
437466 '<img src="::not a URL::"></a></div>' , [
438467 ImageNodeList ([
439- ImageNode (srcUrl: '::not a URL::' ),
468+ ImageNode (srcUrl: '::not a URL::' , thumbnailUrl : null , loading : false ),
440469 ]),
441470 ]);
442471
443472 static const imageCluster = ContentExample (
444473 'multiple images' ,
474+ // https://chat.zulip.org/#narrow/stream/7-test-here/topic/Thumbnails/near/1893154
475+ "[image.jpg](/user_uploads/2/9b/WkDt2Qsy79iwf3sM9EMp9fYL/image.jpg)\n [image2.jpg](/user_uploads/2/70/pVeI52TwFUEoFE2qT_u9AMCO/image2.jpg)" ,
476+ '<p>'
477+ '<a href="/user_uploads/2/9b/WkDt2Qsy79iwf3sM9EMp9fYL/image.jpg">image.jpg</a><br/>\n '
478+ '<a href="/user_uploads/2/70/pVeI52TwFUEoFE2qT_u9AMCO/image2.jpg">image2.jpg</a></p>\n '
479+ '<div class="message_inline_image">'
480+ '<a href="/user_uploads/2/9b/WkDt2Qsy79iwf3sM9EMp9fYL/image.jpg" title="image.jpg">'
481+ '<img src="/user_uploads/thumbnail/2/9b/WkDt2Qsy79iwf3sM9EMp9fYL/image.jpg/840x560.webp"/></a></div>'
482+ '<div class="message_inline_image">'
483+ '<a href="/user_uploads/2/70/pVeI52TwFUEoFE2qT_u9AMCO/image2.jpg" title="image2.jpg">'
484+ '<img src="/user_uploads/thumbnail/2/70/pVeI52TwFUEoFE2qT_u9AMCO/image2.jpg/840x560.webp"/></a></div>' , [
485+ ParagraphNode (links: null , nodes: [
486+ LinkNode (url: '/user_uploads/2/9b/WkDt2Qsy79iwf3sM9EMp9fYL/image.jpg' , nodes: [TextNode ('image.jpg' )]),
487+ LineBreakInlineNode (),
488+ TextNode ('\n ' ),
489+ LinkNode (url: '/user_uploads/2/70/pVeI52TwFUEoFE2qT_u9AMCO/image2.jpg' , nodes: [TextNode ('image2.jpg' )]),
490+ ]),
491+ ImageNodeList ([
492+ ImageNode (srcUrl: '/user_uploads/2/9b/WkDt2Qsy79iwf3sM9EMp9fYL/image.jpg' ,
493+ thumbnailUrl: '/user_uploads/thumbnail/2/9b/WkDt2Qsy79iwf3sM9EMp9fYL/image.jpg/840x560.webp' ,
494+ loading: false ),
495+ ImageNode (srcUrl: '/user_uploads/2/70/pVeI52TwFUEoFE2qT_u9AMCO/image2.jpg' ,
496+ thumbnailUrl: '/user_uploads/thumbnail/2/70/pVeI52TwFUEoFE2qT_u9AMCO/image2.jpg/840x560.webp' ,
497+ loading: false ),
498+ ]),
499+ ]);
500+
501+ static const imageClusterNoThumbnails = ContentExample (
502+ 'multiple images no thumbnails' ,
445503 "https://chat.zulip.org/user_avatars/2/realm/icon.png?version=3\n https://chat.zulip.org/user_avatars/2/realm/icon.png?version=4" ,
446504 '<p>'
447505 '<a href="https://chat.zulip.org/user_avatars/2/realm/icon.png?version=3">https://chat.zulip.org/user_avatars/2/realm/icon.png?version=3</a><br>\n '
@@ -459,8 +517,10 @@ class ContentExample {
459517 LinkNode (url: 'https://chat.zulip.org/user_avatars/2/realm/icon.png?version=4' , nodes: [TextNode ('https://chat.zulip.org/user_avatars/2/realm/icon.png?version=4' )]),
460518 ]),
461519 ImageNodeList ([
462- ImageNode (srcUrl: 'https://uploads.zulipusercontent.net/f535ba07f95b99a83aa48e44fd62bbb6c6cf6615/68747470733a2f2f636861742e7a756c69702e6f72672f757365725f617661746172732f322f7265616c6d2f69636f6e2e706e673f76657273696f6e3d33' ),
463- ImageNode (srcUrl: 'https://uploads.zulipusercontent.net/8f63bc2632a0e41be3f457d86c077e61b4a03e7e/68747470733a2f2f636861742e7a756c69702e6f72672f757365725f617661746172732f322f7265616c6d2f69636f6e2e706e673f76657273696f6e3d34' ),
520+ ImageNode (srcUrl: 'https://uploads.zulipusercontent.net/f535ba07f95b99a83aa48e44fd62bbb6c6cf6615/68747470733a2f2f636861742e7a756c69702e6f72672f757365725f617661746172732f322f7265616c6d2f69636f6e2e706e673f76657273696f6e3d33' ,
521+ thumbnailUrl: null , loading: false ),
522+ ImageNode (srcUrl: 'https://uploads.zulipusercontent.net/8f63bc2632a0e41be3f457d86c077e61b4a03e7e/68747470733a2f2f636861742e7a756c69702e6f72672f757365725f617661746172732f322f7265616c6d2f69636f6e2e706e673f76657273696f6e3d34' ,
523+ thumbnailUrl: null , loading: false ),
464524 ]),
465525 ]);
466526
@@ -484,8 +544,10 @@ class ContentExample {
484544 LinkNode (url: 'https://chat.zulip.org/user_avatars/2/realm/icon.png?version=2' , nodes: [TextNode ('icon.png' )]),
485545 ]),
486546 ImageNodeList ([
487- ImageNode (srcUrl: 'https://chat.zulip.org/user_avatars/2/realm/icon.png' ),
488- ImageNode (srcUrl: 'https://chat.zulip.org/user_avatars/2/realm/icon.png?version=2' ),
547+ ImageNode (srcUrl: 'https://chat.zulip.org/user_avatars/2/realm/icon.png' ,
548+ thumbnailUrl: null , loading: false ),
549+ ImageNode (srcUrl: 'https://chat.zulip.org/user_avatars/2/realm/icon.png?version=2' ,
550+ thumbnailUrl: null , loading: false ),
489551 ]),
490552 ParagraphNode (links: null , nodes: [
491553 TextNode ('more content' ),
@@ -520,8 +582,10 @@ class ContentExample {
520582 LinkNode (url: 'https://en.wikipedia.org/static/images/icons/wikipedia.png?v=1' , nodes: [TextNode ('https://en.wikipedia.org/static/images/icons/wikipedia.png?v=1' )]),
521583 ]),
522584 ImageNodeList ([
523- ImageNode (srcUrl: 'https://uploads.zulipusercontent.net/34b2695ca83af76204b0b25a8f2019ee35ec38fa/68747470733a2f2f656e2e77696b6970656469612e6f72672f7374617469632f696d616765732f69636f6e732f77696b6970656469612e706e67' ),
524- ImageNode (srcUrl: 'https://uploads.zulipusercontent.net/d200fb112aaccbff9df767373a201fa59601f362/68747470733a2f2f656e2e77696b6970656469612e6f72672f7374617469632f696d616765732f69636f6e732f77696b6970656469612e706e673f763d31' ),
585+ ImageNode (srcUrl: 'https://uploads.zulipusercontent.net/34b2695ca83af76204b0b25a8f2019ee35ec38fa/68747470733a2f2f656e2e77696b6970656469612e6f72672f7374617469632f696d616765732f69636f6e732f77696b6970656469612e706e67' ,
586+ thumbnailUrl: null , loading: false ),
587+ ImageNode (srcUrl: 'https://uploads.zulipusercontent.net/d200fb112aaccbff9df767373a201fa59601f362/68747470733a2f2f656e2e77696b6970656469612e6f72672f7374617469632f696d616765732f69636f6e732f77696b6970656469612e706e673f763d31' ,
588+ thumbnailUrl: null , loading: false ),
525589 ]),
526590 ParagraphNode (links: null , nodes: [
527591 TextNode ('Test' ),
@@ -533,8 +597,10 @@ class ContentExample {
533597 LinkNode (url: 'https://en.wikipedia.org/static/images/icons/wikipedia.png?v=3' , nodes: [TextNode ('https://en.wikipedia.org/static/images/icons/wikipedia.png?v=3' )]),
534598 ]),
535599 ImageNodeList ([
536- ImageNode (srcUrl: 'https://uploads.zulipusercontent.net/c4db87e81348dac94eacaa966b46d968b34029cc/68747470733a2f2f656e2e77696b6970656469612e6f72672f7374617469632f696d616765732f69636f6e732f77696b6970656469612e706e673f763d32' ),
537- ImageNode (srcUrl: 'https://uploads.zulipusercontent.net/51b70540cf6a5b3c8a0b919c893b8abddd447e88/68747470733a2f2f656e2e77696b6970656469612e6f72672f7374617469632f696d616765732f69636f6e732f77696b6970656469612e706e673f763d33' ),
600+ ImageNode (srcUrl: 'https://uploads.zulipusercontent.net/c4db87e81348dac94eacaa966b46d968b34029cc/68747470733a2f2f656e2e77696b6970656469612e6f72672f7374617469632f696d616765732f69636f6e732f77696b6970656469612e706e673f763d32' ,
601+ thumbnailUrl: null , loading: false ),
602+ ImageNode (srcUrl: 'https://uploads.zulipusercontent.net/51b70540cf6a5b3c8a0b919c893b8abddd447e88/68747470733a2f2f656e2e77696b6970656469612e6f72672f7374617469632f696d616765732f69636f6e732f77696b6970656469612e706e673f763d33' ,
603+ thumbnailUrl: null , loading: false ),
538604 ]),
539605 ]);
540606
@@ -548,7 +614,8 @@ class ContentExample {
548614 '<img src="https://chat.zulip.org/user_avatars/2/realm/icon.png"></a></div></li>\n </ul>' , [
549615 ListNode (ListStyle .unordered, [[
550616 ImageNodeList ([
551- ImageNode (srcUrl: 'https://chat.zulip.org/user_avatars/2/realm/icon.png' ),
617+ ImageNode (srcUrl: 'https://chat.zulip.org/user_avatars/2/realm/icon.png' ,
618+ thumbnailUrl: null , loading: false ),
552619 ]),
553620 ]]),
554621 ]);
@@ -573,8 +640,10 @@ class ContentExample {
573640 LinkNode (url: 'https://chat.zulip.org/user_avatars/2/realm/icon.png?version=2' , nodes: [TextNode ('icon.png' )]),
574641 ]),
575642 ImageNodeList ([
576- ImageNode (srcUrl: 'https://chat.zulip.org/user_avatars/2/realm/icon.png' ),
577- ImageNode (srcUrl: 'https://chat.zulip.org/user_avatars/2/realm/icon.png?version=2' ),
643+ ImageNode (srcUrl: 'https://chat.zulip.org/user_avatars/2/realm/icon.png' ,
644+ thumbnailUrl: null , loading: false ),
645+ ImageNode (srcUrl: 'https://chat.zulip.org/user_avatars/2/realm/icon.png?version=2' ,
646+ thumbnailUrl: null , loading: false ),
578647 ]),
579648 ]]),
580649 ]);
@@ -597,7 +666,8 @@ class ContentExample {
597666 TextNode (' ' ),
598667 ]),
599668 const ImageNodeList ([
600- ImageNode (srcUrl: 'https://chat.zulip.org/user_avatars/2/realm/icon.png' ),
669+ ImageNode (srcUrl: 'https://chat.zulip.org/user_avatars/2/realm/icon.png' ,
670+ thumbnailUrl: null , loading: false ),
601671 ]),
602672 blockUnimplemented ('more text' ),
603673 ]]),
@@ -1034,8 +1104,11 @@ void main() {
10341104 testParseExample (ContentExample .mathBlockInQuote);
10351105
10361106 testParseExample (ContentExample .imageSingle);
1107+ testParseExample (ContentExample .imageSingleNoThumbnail);
1108+ testParseExample (ContentExample .imageSingleLoadingPlaceholder);
10371109 testParseExample (ContentExample .imageInvalidUrl);
10381110 testParseExample (ContentExample .imageCluster);
1111+ testParseExample (ContentExample .imageClusterNoThumbnails);
10391112 testParseExample (ContentExample .imageClusterThenContent);
10401113 testParseExample (ContentExample .imageMultipleClusters);
10411114 testParseExample (ContentExample .imageInImplicitParagraph);
0 commit comments