@@ -262,7 +262,8 @@ class ContentExample {
262
262
nodes: [TextNode ('image' )]),
263
263
]),
264
264
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 ),
266
267
]),
267
268
],
268
269
content: [ParagraphNode (links: null , nodes: [TextNode ('hello world' )])],
@@ -420,12 +421,53 @@ class ContentExample {
420
421
421
422
static const imageSingle = ContentExample (
422
423
'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' ,
423
438
"https://chat.zulip.org/user_avatars/2/realm/icon.png?version=3" ,
424
439
'<div class="message_inline_image">'
425
440
'<a href="https://chat.zulip.org/user_avatars/2/realm/icon.png?version=3">'
426
441
'<img src="https://chat.zulip.org/user_avatars/2/realm/icon.png?version=3"></a></div>' , [
427
442
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 ),
458
+ ]),
459
+ ]);
460
+
461
+ static const imageSingleExternal = ContentExample (
462
+ 'single image external' ,
463
+ // https://chat.zulip.org/#narrow/stream/7-test-here/topic/Greg/near/1892172
464
+ "https://upload.wikimedia.org/wikipedia/commons/7/78/Verregende_bloem_van_een_Helenium_%27El_Dorado%27._22-07-2023._%28d.j.b%29.jpg" ,
465
+ '<div class="message_inline_image">'
466
+ '<a href="https://upload.wikimedia.org/wikipedia/commons/7/78/Verregende_bloem_van_een_Helenium_%27El_Dorado%27._22-07-2023._%28d.j.b%29.jpg">'
467
+ '<img src="/external_content/de28eb3abf4b7786de4545023dc42d434a2ea0c2/68747470733a2f2f75706c6f61642e77696b696d656469612e6f72672f77696b6970656469612f636f6d6d6f6e732f372f37382f566572726567656e64655f626c6f656d5f76616e5f65656e5f48656c656e69756d5f253237456c5f446f7261646f2532372e5f32322d30372d323032332e5f253238642e6a2e622532392e6a7067"></a></div>' , [
468
+ ImageNodeList ([
469
+ ImageNode (srcUrl: '/external_content/de28eb3abf4b7786de4545023dc42d434a2ea0c2/68747470733a2f2f75706c6f61642e77696b696d656469612e6f72672f77696b6970656469612f636f6d6d6f6e732f372f37382f566572726567656e64655f626c6f656d5f76616e5f65656e5f48656c656e69756d5f253237456c5f446f7261646f2532372e5f32322d30372d323032332e5f253238642e6a2e622532392e6a7067' ,
470
+ thumbnailUrl: null , loading: false ),
429
471
]),
430
472
]);
431
473
@@ -436,12 +478,41 @@ class ContentExample {
436
478
'<a href="::not a URL::">'
437
479
'<img src="::not a URL::"></a></div>' , [
438
480
ImageNodeList ([
439
- ImageNode (srcUrl: '::not a URL::' ),
481
+ ImageNode (srcUrl: '::not a URL::' , thumbnailUrl : null , loading : false ),
440
482
]),
441
483
]);
442
484
443
485
static const imageCluster = ContentExample (
444
486
'multiple images' ,
487
+ // https://chat.zulip.org/#narrow/stream/7-test-here/topic/Thumbnails/near/1893154
488
+ "[image.jpg](/user_uploads/2/9b/WkDt2Qsy79iwf3sM9EMp9fYL/image.jpg)\n [image2.jpg](/user_uploads/2/70/pVeI52TwFUEoFE2qT_u9AMCO/image2.jpg)" ,
489
+ '<p>'
490
+ '<a href="/user_uploads/2/9b/WkDt2Qsy79iwf3sM9EMp9fYL/image.jpg">image.jpg</a><br/>\n '
491
+ '<a href="/user_uploads/2/70/pVeI52TwFUEoFE2qT_u9AMCO/image2.jpg">image2.jpg</a></p>\n '
492
+ '<div class="message_inline_image">'
493
+ '<a href="/user_uploads/2/9b/WkDt2Qsy79iwf3sM9EMp9fYL/image.jpg" title="image.jpg">'
494
+ '<img src="/user_uploads/thumbnail/2/9b/WkDt2Qsy79iwf3sM9EMp9fYL/image.jpg/840x560.webp"/></a></div>'
495
+ '<div class="message_inline_image">'
496
+ '<a href="/user_uploads/2/70/pVeI52TwFUEoFE2qT_u9AMCO/image2.jpg" title="image2.jpg">'
497
+ '<img src="/user_uploads/thumbnail/2/70/pVeI52TwFUEoFE2qT_u9AMCO/image2.jpg/840x560.webp"/></a></div>' , [
498
+ ParagraphNode (links: null , nodes: [
499
+ LinkNode (url: '/user_uploads/2/9b/WkDt2Qsy79iwf3sM9EMp9fYL/image.jpg' , nodes: [TextNode ('image.jpg' )]),
500
+ LineBreakInlineNode (),
501
+ TextNode ('\n ' ),
502
+ LinkNode (url: '/user_uploads/2/70/pVeI52TwFUEoFE2qT_u9AMCO/image2.jpg' , nodes: [TextNode ('image2.jpg' )]),
503
+ ]),
504
+ ImageNodeList ([
505
+ ImageNode (srcUrl: '/user_uploads/2/9b/WkDt2Qsy79iwf3sM9EMp9fYL/image.jpg' ,
506
+ thumbnailUrl: '/user_uploads/thumbnail/2/9b/WkDt2Qsy79iwf3sM9EMp9fYL/image.jpg/840x560.webp' ,
507
+ loading: false ),
508
+ ImageNode (srcUrl: '/user_uploads/2/70/pVeI52TwFUEoFE2qT_u9AMCO/image2.jpg' ,
509
+ thumbnailUrl: '/user_uploads/thumbnail/2/70/pVeI52TwFUEoFE2qT_u9AMCO/image2.jpg/840x560.webp' ,
510
+ loading: false ),
511
+ ]),
512
+ ]);
513
+
514
+ static const imageClusterNoThumbnails = ContentExample (
515
+ 'multiple images no thumbnails' ,
445
516
"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" ,
446
517
'<p>'
447
518
'<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 +530,10 @@ class ContentExample {
459
530
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' )]),
460
531
]),
461
532
ImageNodeList ([
462
- ImageNode (srcUrl: 'https://uploads.zulipusercontent.net/f535ba07f95b99a83aa48e44fd62bbb6c6cf6615/68747470733a2f2f636861742e7a756c69702e6f72672f757365725f617661746172732f322f7265616c6d2f69636f6e2e706e673f76657273696f6e3d33' ),
463
- ImageNode (srcUrl: 'https://uploads.zulipusercontent.net/8f63bc2632a0e41be3f457d86c077e61b4a03e7e/68747470733a2f2f636861742e7a756c69702e6f72672f757365725f617661746172732f322f7265616c6d2f69636f6e2e706e673f76657273696f6e3d34' ),
533
+ ImageNode (srcUrl: 'https://uploads.zulipusercontent.net/f535ba07f95b99a83aa48e44fd62bbb6c6cf6615/68747470733a2f2f636861742e7a756c69702e6f72672f757365725f617661746172732f322f7265616c6d2f69636f6e2e706e673f76657273696f6e3d33' ,
534
+ thumbnailUrl: null , loading: false ),
535
+ ImageNode (srcUrl: 'https://uploads.zulipusercontent.net/8f63bc2632a0e41be3f457d86c077e61b4a03e7e/68747470733a2f2f636861742e7a756c69702e6f72672f757365725f617661746172732f322f7265616c6d2f69636f6e2e706e673f76657273696f6e3d34' ,
536
+ thumbnailUrl: null , loading: false ),
464
537
]),
465
538
]);
466
539
@@ -484,8 +557,10 @@ class ContentExample {
484
557
LinkNode (url: 'https://chat.zulip.org/user_avatars/2/realm/icon.png?version=2' , nodes: [TextNode ('icon.png' )]),
485
558
]),
486
559
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' ),
560
+ ImageNode (srcUrl: 'https://chat.zulip.org/user_avatars/2/realm/icon.png' ,
561
+ thumbnailUrl: null , loading: false ),
562
+ ImageNode (srcUrl: 'https://chat.zulip.org/user_avatars/2/realm/icon.png?version=2' ,
563
+ thumbnailUrl: null , loading: false ),
489
564
]),
490
565
ParagraphNode (links: null , nodes: [
491
566
TextNode ('more content' ),
@@ -520,8 +595,10 @@ class ContentExample {
520
595
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' )]),
521
596
]),
522
597
ImageNodeList ([
523
- ImageNode (srcUrl: 'https://uploads.zulipusercontent.net/34b2695ca83af76204b0b25a8f2019ee35ec38fa/68747470733a2f2f656e2e77696b6970656469612e6f72672f7374617469632f696d616765732f69636f6e732f77696b6970656469612e706e67' ),
524
- ImageNode (srcUrl: 'https://uploads.zulipusercontent.net/d200fb112aaccbff9df767373a201fa59601f362/68747470733a2f2f656e2e77696b6970656469612e6f72672f7374617469632f696d616765732f69636f6e732f77696b6970656469612e706e673f763d31' ),
598
+ ImageNode (srcUrl: 'https://uploads.zulipusercontent.net/34b2695ca83af76204b0b25a8f2019ee35ec38fa/68747470733a2f2f656e2e77696b6970656469612e6f72672f7374617469632f696d616765732f69636f6e732f77696b6970656469612e706e67' ,
599
+ thumbnailUrl: null , loading: false ),
600
+ ImageNode (srcUrl: 'https://uploads.zulipusercontent.net/d200fb112aaccbff9df767373a201fa59601f362/68747470733a2f2f656e2e77696b6970656469612e6f72672f7374617469632f696d616765732f69636f6e732f77696b6970656469612e706e673f763d31' ,
601
+ thumbnailUrl: null , loading: false ),
525
602
]),
526
603
ParagraphNode (links: null , nodes: [
527
604
TextNode ('Test' ),
@@ -533,8 +610,10 @@ class ContentExample {
533
610
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' )]),
534
611
]),
535
612
ImageNodeList ([
536
- ImageNode (srcUrl: 'https://uploads.zulipusercontent.net/c4db87e81348dac94eacaa966b46d968b34029cc/68747470733a2f2f656e2e77696b6970656469612e6f72672f7374617469632f696d616765732f69636f6e732f77696b6970656469612e706e673f763d32' ),
537
- ImageNode (srcUrl: 'https://uploads.zulipusercontent.net/51b70540cf6a5b3c8a0b919c893b8abddd447e88/68747470733a2f2f656e2e77696b6970656469612e6f72672f7374617469632f696d616765732f69636f6e732f77696b6970656469612e706e673f763d33' ),
613
+ ImageNode (srcUrl: 'https://uploads.zulipusercontent.net/c4db87e81348dac94eacaa966b46d968b34029cc/68747470733a2f2f656e2e77696b6970656469612e6f72672f7374617469632f696d616765732f69636f6e732f77696b6970656469612e706e673f763d32' ,
614
+ thumbnailUrl: null , loading: false ),
615
+ ImageNode (srcUrl: 'https://uploads.zulipusercontent.net/51b70540cf6a5b3c8a0b919c893b8abddd447e88/68747470733a2f2f656e2e77696b6970656469612e6f72672f7374617469632f696d616765732f69636f6e732f77696b6970656469612e706e673f763d33' ,
616
+ thumbnailUrl: null , loading: false ),
538
617
]),
539
618
]);
540
619
@@ -548,7 +627,8 @@ class ContentExample {
548
627
'<img src="https://chat.zulip.org/user_avatars/2/realm/icon.png"></a></div></li>\n </ul>' , [
549
628
ListNode (ListStyle .unordered, [[
550
629
ImageNodeList ([
551
- ImageNode (srcUrl: 'https://chat.zulip.org/user_avatars/2/realm/icon.png' ),
630
+ ImageNode (srcUrl: 'https://chat.zulip.org/user_avatars/2/realm/icon.png' ,
631
+ thumbnailUrl: null , loading: false ),
552
632
]),
553
633
]]),
554
634
]);
@@ -573,8 +653,10 @@ class ContentExample {
573
653
LinkNode (url: 'https://chat.zulip.org/user_avatars/2/realm/icon.png?version=2' , nodes: [TextNode ('icon.png' )]),
574
654
]),
575
655
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' ),
656
+ ImageNode (srcUrl: 'https://chat.zulip.org/user_avatars/2/realm/icon.png' ,
657
+ thumbnailUrl: null , loading: false ),
658
+ ImageNode (srcUrl: 'https://chat.zulip.org/user_avatars/2/realm/icon.png?version=2' ,
659
+ thumbnailUrl: null , loading: false ),
578
660
]),
579
661
]]),
580
662
]);
@@ -597,7 +679,8 @@ class ContentExample {
597
679
TextNode (' ' ),
598
680
]),
599
681
const ImageNodeList ([
600
- ImageNode (srcUrl: 'https://chat.zulip.org/user_avatars/2/realm/icon.png' ),
682
+ ImageNode (srcUrl: 'https://chat.zulip.org/user_avatars/2/realm/icon.png' ,
683
+ thumbnailUrl: null , loading: false ),
601
684
]),
602
685
blockUnimplemented ('more text' ),
603
686
]]),
@@ -1034,8 +1117,12 @@ void main() {
1034
1117
testParseExample (ContentExample .mathBlockInQuote);
1035
1118
1036
1119
testParseExample (ContentExample .imageSingle);
1120
+ testParseExample (ContentExample .imageSingleNoThumbnail);
1121
+ testParseExample (ContentExample .imageSingleLoadingPlaceholder);
1122
+ testParseExample (ContentExample .imageSingleExternal);
1037
1123
testParseExample (ContentExample .imageInvalidUrl);
1038
1124
testParseExample (ContentExample .imageCluster);
1125
+ testParseExample (ContentExample .imageClusterNoThumbnails);
1039
1126
testParseExample (ContentExample .imageClusterThenContent);
1040
1127
testParseExample (ContentExample .imageMultipleClusters);
1041
1128
testParseExample (ContentExample .imageInImplicitParagraph);
0 commit comments