@@ -521,6 +521,125 @@ class ContentExample {
521
521
blockUnimplemented ('more text' ),
522
522
]]),
523
523
]);
524
+
525
+ static const videoEmbedYoutube = ContentExample (
526
+ 'video preview for youtube embed with thumbnail' ,
527
+ 'https://www.youtube.com/watch?v=aqz-KE-bpKQ' ,
528
+ '<p>'
529
+ '<a href="https://www.youtube.com/watch?v=aqz-KE-bpKQ">https://www.youtube.com/watch?v=aqz-KE-bpKQ</a>'
530
+ '</p>\n '
531
+ '<div class="youtube-video message_inline_image">'
532
+ '<a data-id="aqz-KE-bpKQ" href="https://www.youtube.com/watch?v=aqz-KE-bpKQ">'
533
+ '<img src="/external_content/ecb96e8f884f481c4bc0179287a44ab9014aa78f/68747470733a2f2f692e7974696d672e636f6d2f76692f61717a2d4b452d62704b512f64656661756c742e6a7067"></a></div>' , [
534
+ ParagraphNode (links: null , nodes: [
535
+ LinkNode (url: 'https://www.youtube.com/watch?v=aqz-KE-bpKQ' , nodes: [TextNode ('https://www.youtube.com/watch?v=aqz-KE-bpKQ' )]),
536
+ ]),
537
+ VideoNode (
538
+ srcUrl: 'https://www.youtube.com/watch?v=aqz-KE-bpKQ' ,
539
+ previewImageUrl: '/external_content/ecb96e8f884f481c4bc0179287a44ab9014aa78f/68747470733a2f2f692e7974696d672e636f6d2f76692f61717a2d4b452d62704b512f64656661756c742e6a7067'
540
+ ),
541
+ ]);
542
+
543
+ static const videoEmbedYoutubeClassesFlipped = ContentExample (
544
+ 'video preview for youtube embed with thumbnail, (hypothetical) class name reorder' ,
545
+ 'https://www.youtube.com/watch?v=aqz-KE-bpKQ' ,
546
+ '<p>'
547
+ '<a href="https://www.youtube.com/watch?v=aqz-KE-bpKQ">https://www.youtube.com/watch?v=aqz-KE-bpKQ</a>'
548
+ '</p>\n '
549
+ '<div class="message_inline_image youtube-video">'
550
+ '<a data-id="aqz-KE-bpKQ" href="https://www.youtube.com/watch?v=aqz-KE-bpKQ">'
551
+ '<img src="/external_content/ecb96e8f884f481c4bc0179287a44ab9014aa78f/68747470733a2f2f692e7974696d672e636f6d2f76692f61717a2d4b452d62704b512f64656661756c742e6a7067"></a></div>' , [
552
+ ParagraphNode (links: null , nodes: [
553
+ LinkNode (url: 'https://www.youtube.com/watch?v=aqz-KE-bpKQ' , nodes: [TextNode ('https://www.youtube.com/watch?v=aqz-KE-bpKQ' )]),
554
+ ]),
555
+ VideoNode (
556
+ srcUrl: 'https://www.youtube.com/watch?v=aqz-KE-bpKQ' ,
557
+ previewImageUrl: '/external_content/ecb96e8f884f481c4bc0179287a44ab9014aa78f/68747470733a2f2f692e7974696d672e636f6d2f76692f61717a2d4b452d62704b512f64656661756c742e6a7067'
558
+ ),
559
+ ]);
560
+
561
+ static const videoEmbedVimeoPreviewDisabled = ContentExample (
562
+ 'video non-preview for attempted vimeo embed with realm link previews disabled' ,
563
+ 'https://vimeo.com/1084537' ,
564
+ '<p>'
565
+ '<a href="https://vimeo.com/1084537">https://vimeo.com/1084537</a></p>' , [
566
+ ParagraphNode (links: null , nodes: [
567
+ LinkNode (url: 'https://vimeo.com/1084537' , nodes: [TextNode ('https://vimeo.com/1084537' )]),
568
+ ]),
569
+ ]);
570
+
571
+ static const videoEmbedVimeo = ContentExample (
572
+ 'video preview for vimeo embed with realm link previews enabled' ,
573
+ 'https://vimeo.com/1084537' ,
574
+ // Note that the server generates "data-id" attribute with value of a raw HTML,
575
+ // web client uses this to show Vimeo's video player in a sandbox iframe.
576
+ // The HTML blob is provided by Vimeo and them changing it wouldn't break the
577
+ // web client because it relies on this dynamic value.
578
+ //
579
+ // Discussion:
580
+ // https://chat.zulip.org/#narrow/stream/9-issues/topic/Vimeo.20link.20previews.20HTML.20.22data-id.22.20isn't.20a.20.20Vimeo.20video.20ID/near/1767563
581
+ '<p>'
582
+ '<a href="https://vimeo.com/1084537">Vimeo - Big Buck Bunny</a>'
583
+ '</p>\n '
584
+ '<div class="embed-video message_inline_image">'
585
+ '<a data-id="<iframe src="https://player.vimeo.com/video/1084537?app_id=122963" width="640" height="360" frameborder="0" allow="autoplay; fullscreen; picture-in-picture; clipboard-write" title="Big Buck Bunny"></iframe>" href="https://vimeo.com/1084537" title="Big Buck Bunny">'
586
+ '<img src="https://uploads.zulipusercontent.net/75aed2df4a1e8657176fcd6159fc40876ace4070/68747470733a2f2f692e76696d656f63646e2e636f6d2f766964656f2f32303936333634392d663032383137343536666334386537633331376566346330376261323539636434623430613336343962643865623530613434313862353965633366356166352d645f363430"></a></div>' , [
587
+ ParagraphNode (links: null , nodes: [
588
+ LinkNode (url: 'https://vimeo.com/1084537' , nodes: [TextNode ('Vimeo - Big Buck Bunny' )]),
589
+ ]),
590
+ VideoNode (
591
+ srcUrl: 'https://vimeo.com/1084537' ,
592
+ previewImageUrl: 'https://uploads.zulipusercontent.net/75aed2df4a1e8657176fcd6159fc40876ace4070/68747470733a2f2f692e76696d656f63646e2e636f6d2f766964656f2f32303936333634392d663032383137343536666334386537633331376566346330376261323539636434623430613336343962643865623530613434313862353965633366356166352d645f363430'
593
+ ),
594
+ ]);
595
+
596
+ static const videoEmbedVimeoClassesFlipped = ContentExample (
597
+ 'video preview for vimeo embed with realm link previews enabled, (hypothetical) class name reorder' ,
598
+ 'https://vimeo.com/1084537' ,
599
+ '<p>'
600
+ '<a href="https://vimeo.com/1084537">Vimeo - Big Buck Bunny</a>'
601
+ '</p>\n '
602
+ '<div class="message_inline_image embed-video">'
603
+ '<a data-id="<iframe src="https://player.vimeo.com/video/1084537?app_id=122963" width="640" height="360" frameborder="0" allow="autoplay; fullscreen; picture-in-picture; clipboard-write" title="Big Buck Bunny"></iframe>" href="https://vimeo.com/1084537" title="Big Buck Bunny">'
604
+ '<img src="https://uploads.zulipusercontent.net/75aed2df4a1e8657176fcd6159fc40876ace4070/68747470733a2f2f692e76696d656f63646e2e636f6d2f766964656f2f32303936333634392d663032383137343536666334386537633331376566346330376261323539636434623430613336343962643865623530613434313862353965633366356166352d645f363430"></a></div>' , [
605
+ ParagraphNode (links: null , nodes: [
606
+ LinkNode (url: 'https://vimeo.com/1084537' , nodes: [TextNode ('Vimeo - Big Buck Bunny' )]),
607
+ ]),
608
+ VideoNode (
609
+ srcUrl: 'https://vimeo.com/1084537' ,
610
+ previewImageUrl: 'https://uploads.zulipusercontent.net/75aed2df4a1e8657176fcd6159fc40876ace4070/68747470733a2f2f692e76696d656f63646e2e636f6d2f766964656f2f32303936333634392d663032383137343536666334386537633331376566346330376261323539636434623430613336343962643865623530613434313862353965633366356166352d645f363430'
611
+ ),
612
+ ]);
613
+
614
+ static const videoInline = ContentExample (
615
+ 'video preview for user uploaded video' ,
616
+ '[Big-Buck-Bunny.webm](/user_uploads/2/78/_KoRecCHZTFrVtyTKCkIh5Hq/Big-Buck-Bunny.webm)' ,
617
+ '<p>'
618
+ '<a href="/user_uploads/2/78/_KoRecCHZTFrVtyTKCkIh5Hq/Big-Buck-Bunny.webm">Big-Buck-Bunny.webm</a>'
619
+ '</p>\n '
620
+ '<div class="message_inline_image message_inline_video">'
621
+ '<a href="/user_uploads/2/78/_KoRecCHZTFrVtyTKCkIh5Hq/Big-Buck-Bunny.webm" title="Big-Buck-Bunny.webm">'
622
+ '<video preload="metadata" src="/user_uploads/2/78/_KoRecCHZTFrVtyTKCkIh5Hq/Big-Buck-Bunny.webm"></video></a></div>' , [
623
+ ParagraphNode (links: null , nodes: [
624
+ LinkNode (url: '/user_uploads/2/78/_KoRecCHZTFrVtyTKCkIh5Hq/Big-Buck-Bunny.webm' , nodes: [TextNode ('Big-Buck-Bunny.webm' )]),
625
+ ]),
626
+ VideoNode (srcUrl: '/user_uploads/2/78/_KoRecCHZTFrVtyTKCkIh5Hq/Big-Buck-Bunny.webm' , previewImageUrl: null ),
627
+ ]);
628
+
629
+ static const videoInlineClassesFlipped = ContentExample (
630
+ 'video preview for user uploaded video, (hypothetical) class name reorder' ,
631
+ '[Big-Buck-Bunny.webm](/user_uploads/2/78/_KoRecCHZTFrVtyTKCkIh5Hq/Big-Buck-Bunny.webm)' ,
632
+ '<p>'
633
+ '<a href="/user_uploads/2/78/_KoRecCHZTFrVtyTKCkIh5Hq/Big-Buck-Bunny.webm">Big-Buck-Bunny.webm</a>'
634
+ '</p>\n '
635
+ '<div class="message_inline_video message_inline_image">'
636
+ '<a href="/user_uploads/2/78/_KoRecCHZTFrVtyTKCkIh5Hq/Big-Buck-Bunny.webm" title="Big-Buck-Bunny.webm">'
637
+ '<video preload="metadata" src="/user_uploads/2/78/_KoRecCHZTFrVtyTKCkIh5Hq/Big-Buck-Bunny.webm"></video></a></div>' , [
638
+ ParagraphNode (links: null , nodes: [
639
+ LinkNode (url: '/user_uploads/2/78/_KoRecCHZTFrVtyTKCkIh5Hq/Big-Buck-Bunny.webm' , nodes: [TextNode ('Big-Buck-Bunny.webm' )]),
640
+ ]),
641
+ VideoNode (srcUrl: '/user_uploads/2/78/_KoRecCHZTFrVtyTKCkIh5Hq/Big-Buck-Bunny.webm' , previewImageUrl: null ),
642
+ ]);
524
643
}
525
644
526
645
UnimplementedBlockContentNode blockUnimplemented (String html) {
@@ -856,6 +975,14 @@ void main() {
856
975
testParseExample (ContentExample .imageClusterInImplicitParagraph);
857
976
testParseExample (ContentExample .imageClusterInImplicitParagraphThenContent);
858
977
978
+ testParseExample (ContentExample .videoEmbedYoutube);
979
+ testParseExample (ContentExample .videoEmbedYoutubeClassesFlipped);
980
+ testParseExample (ContentExample .videoEmbedVimeoPreviewDisabled);
981
+ testParseExample (ContentExample .videoEmbedVimeo);
982
+ testParseExample (ContentExample .videoEmbedVimeoClassesFlipped);
983
+ testParseExample (ContentExample .videoInline);
984
+ testParseExample (ContentExample .videoInlineClassesFlipped);
985
+
859
986
testParse ('parse nested lists, quotes, headings, code blocks' ,
860
987
// "1. > ###### two\n > * three\n\n four"
861
988
'<ol>\n <li>\n <blockquote>\n <h6>two</h6>\n <ul>\n <li>three</li>\n '
0 commit comments