@@ -613,6 +613,93 @@ class ContentExample {
613
613
ThematicBreakNode (),
614
614
ParagraphNode (links: null , nodes: [TextNode ('b' )]),
615
615
]);
616
+
617
+ static const videoEmbedYoutube = ContentExample (
618
+ 'video preview for youtube embed with thumbnail' ,
619
+ 'https://www.youtube.com/watch?v=aqz-KE-bpKQ' ,
620
+ '<p>'
621
+ '<a href="https://www.youtube.com/watch?v=aqz-KE-bpKQ">https://www.youtube.com/watch?v=aqz-KE-bpKQ</a>'
622
+ '</p>\n '
623
+ '<div class="youtube-video message_inline_image">'
624
+ '<a data-id="aqz-KE-bpKQ" href="https://www.youtube.com/watch?v=aqz-KE-bpKQ">'
625
+ '<img src="/external_content/ecb96e8f884f481c4bc0179287a44ab9014aa78f/68747470733a2f2f692e7974696d672e636f6d2f76692f61717a2d4b452d62704b512f64656661756c742e6a7067"></a></div>' , [
626
+ ParagraphNode (links: null , nodes: [
627
+ LinkNode (url: 'https://www.youtube.com/watch?v=aqz-KE-bpKQ' , nodes: [TextNode ('https://www.youtube.com/watch?v=aqz-KE-bpKQ' )]),
628
+ ]),
629
+ EmbedVideoNode (
630
+ hrefUrl: 'https://www.youtube.com/watch?v=aqz-KE-bpKQ' ,
631
+ previewImageSrcUrl: '/external_content/ecb96e8f884f481c4bc0179287a44ab9014aa78f/68747470733a2f2f692e7974696d672e636f6d2f76692f61717a2d4b452d62704b512f64656661756c742e6a7067'
632
+ ),
633
+ ]);
634
+
635
+ static const videoEmbedYoutubeClassesFlipped = ContentExample (
636
+ 'video preview for youtube embed with thumbnail, (hypothetical) class name reorder' ,
637
+ null , // "https://www.youtube.com/watch?v=aqz-KE-bpKQ" (hypothetical server variation)
638
+ '<p>'
639
+ '<a href="https://www.youtube.com/watch?v=aqz-KE-bpKQ">https://www.youtube.com/watch?v=aqz-KE-bpKQ</a>'
640
+ '</p>\n '
641
+ '<div class="message_inline_image youtube-video">'
642
+ '<a data-id="aqz-KE-bpKQ" href="https://www.youtube.com/watch?v=aqz-KE-bpKQ">'
643
+ '<img src="/external_content/ecb96e8f884f481c4bc0179287a44ab9014aa78f/68747470733a2f2f692e7974696d672e636f6d2f76692f61717a2d4b452d62704b512f64656661756c742e6a7067"></a></div>' , [
644
+ ParagraphNode (links: null , nodes: [
645
+ LinkNode (url: 'https://www.youtube.com/watch?v=aqz-KE-bpKQ' , nodes: [TextNode ('https://www.youtube.com/watch?v=aqz-KE-bpKQ' )]),
646
+ ]),
647
+ EmbedVideoNode (
648
+ hrefUrl: 'https://www.youtube.com/watch?v=aqz-KE-bpKQ' ,
649
+ previewImageSrcUrl: '/external_content/ecb96e8f884f481c4bc0179287a44ab9014aa78f/68747470733a2f2f692e7974696d672e636f6d2f76692f61717a2d4b452d62704b512f64656661756c742e6a7067'
650
+ ),
651
+ ]);
652
+
653
+ static const videoEmbedVimeoPreviewDisabled = ContentExample (
654
+ 'video non-preview for attempted vimeo embed with realm link previews disabled' ,
655
+ 'https://vimeo.com/1084537' ,
656
+ '<p>'
657
+ '<a href="https://vimeo.com/1084537">https://vimeo.com/1084537</a></p>' , [
658
+ ParagraphNode (links: null , nodes: [
659
+ LinkNode (url: 'https://vimeo.com/1084537' , nodes: [TextNode ('https://vimeo.com/1084537' )]),
660
+ ]),
661
+ ]);
662
+
663
+ static const videoEmbedVimeo = ContentExample (
664
+ 'video preview for vimeo embed with realm link previews enabled' ,
665
+ 'https://vimeo.com/1084537' ,
666
+ // The server really does generate an attribute called "data-id" whose value
667
+ // is a blob of HTML. The web client uses this to show Vimeo's video player
668
+ // inside a sandbox iframe. The HTML comes from Vimeo and may change form;
669
+ // that's OK the way web uses it, but we shouldn't try to parse it. See:
670
+ // 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
671
+ '<p>'
672
+ '<a href="https://vimeo.com/1084537">Vimeo - Big Buck Bunny</a>'
673
+ '</p>\n '
674
+ '<div class="embed-video message_inline_image">'
675
+ '<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">'
676
+ '<img src="https://uploads.zulipusercontent.net/75aed2df4a1e8657176fcd6159fc40876ace4070/68747470733a2f2f692e76696d656f63646e2e636f6d2f766964656f2f32303936333634392d663032383137343536666334386537633331376566346330376261323539636434623430613336343962643865623530613434313862353965633366356166352d645f363430"></a></div>' , [
677
+ ParagraphNode (links: null , nodes: [
678
+ LinkNode (url: 'https://vimeo.com/1084537' , nodes: [TextNode ('Vimeo - Big Buck Bunny' )]),
679
+ ]),
680
+ EmbedVideoNode (
681
+ hrefUrl: 'https://vimeo.com/1084537' ,
682
+ previewImageSrcUrl: 'https://uploads.zulipusercontent.net/75aed2df4a1e8657176fcd6159fc40876ace4070/68747470733a2f2f692e76696d656f63646e2e636f6d2f766964656f2f32303936333634392d663032383137343536666334386537633331376566346330376261323539636434623430613336343962643865623530613434313862353965633366356166352d645f363430'
683
+ ),
684
+ ]);
685
+
686
+ static const videoEmbedVimeoClassesFlipped = ContentExample (
687
+ 'video preview for vimeo embed with realm link previews enabled, (hypothetical) class name reorder' ,
688
+ 'https://vimeo.com/1084537' ,
689
+ '<p>'
690
+ '<a href="https://vimeo.com/1084537">Vimeo - Big Buck Bunny</a>'
691
+ '</p>\n '
692
+ '<div class="message_inline_image embed-video">'
693
+ '<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">'
694
+ '<img src="https://uploads.zulipusercontent.net/75aed2df4a1e8657176fcd6159fc40876ace4070/68747470733a2f2f692e76696d656f63646e2e636f6d2f766964656f2f32303936333634392d663032383137343536666334386537633331376566346330376261323539636434623430613336343962643865623530613434313862353965633366356166352d645f363430"></a></div>' , [
695
+ ParagraphNode (links: null , nodes: [
696
+ LinkNode (url: 'https://vimeo.com/1084537' , nodes: [TextNode ('Vimeo - Big Buck Bunny' )]),
697
+ ]),
698
+ EmbedVideoNode (
699
+ hrefUrl: 'https://vimeo.com/1084537' ,
700
+ previewImageSrcUrl: 'https://uploads.zulipusercontent.net/75aed2df4a1e8657176fcd6159fc40876ace4070/68747470733a2f2f692e76696d656f63646e2e636f6d2f766964656f2f32303936333634392d663032383137343536666334386537633331376566346330376261323539636434623430613336343962643865623530613434313862353965633366356166352d645f363430'
701
+ ),
702
+ ]);
616
703
}
617
704
618
705
UnimplementedBlockContentNode blockUnimplemented (String html) {
@@ -925,6 +1012,12 @@ void main() {
925
1012
testParseExample (ContentExample .imageClusterInImplicitParagraph);
926
1013
testParseExample (ContentExample .imageClusterInImplicitParagraphThenContent);
927
1014
1015
+ testParseExample (ContentExample .videoEmbedYoutube);
1016
+ testParseExample (ContentExample .videoEmbedYoutubeClassesFlipped);
1017
+ testParseExample (ContentExample .videoEmbedVimeoPreviewDisabled);
1018
+ testParseExample (ContentExample .videoEmbedVimeo);
1019
+ testParseExample (ContentExample .videoEmbedVimeoClassesFlipped);
1020
+
928
1021
testParse ('parse nested lists, quotes, headings, code blocks' ,
929
1022
// "1. > ###### two\n > * three\n\n four"
930
1023
'<ol>\n <li>\n <blockquote>\n <h6>two</h6>\n <ul>\n <li>three</li>\n '
0 commit comments