@@ -36,7 +36,7 @@ public struct Metadata
3636 /// <summary>
3737 /// Attributes collection for embed tag
3838 /// </summary>
39- public HtmlAttributeCollection attributes ;
39+ public object attributes ;
4040
4141 /// <summary>
4242 /// Html string of embed tag
@@ -67,5 +67,45 @@ public static implicit operator Metadata(HtmlNode node)
6767 attributes = node . Attributes
6868 } ;
6969 }
70+
71+ public static implicit operator Metadata ( Node node )
72+ {
73+ StyleType styleType ;
74+ if ( ! node . attrs . ContainsKey ( "display-type" ) || ! ( Enum . TryParse ( ( string ) node . attrs [ "display-type" ] , true , out styleType ) ) )
75+ {
76+ styleType = StyleType . Block ;
77+ }
78+
79+ EmbedItemType embedItemType ;
80+ if ( ! node . attrs . ContainsKey ( "type" ) || ! ( Enum . TryParse ( ( string ) node . attrs [ "type" ] , true , out embedItemType ) ) )
81+ {
82+ embedItemType = EmbedItemType . Entry ;
83+ }
84+ string text = "" ;
85+ if ( node . children != null && node . children . Count > 0 && node . children [ 0 ] . GetType ( ) == typeof ( TextNode ) )
86+ {
87+ text = ( ( TextNode ) node . children [ 0 ] ) . text ;
88+ }
89+ string itemUID = "" ;
90+ if ( node . attrs . ContainsKey ( "entry-uid" ) )
91+ {
92+ itemUID = ( string ) node . attrs [ "entry-uid" ] ;
93+ } else if ( node . attrs . ContainsKey ( "asset-uid" ) )
94+ {
95+ itemUID = ( string ) node . attrs [ "asset-uid" ] ;
96+ }
97+
98+ return new Metadata ( )
99+ {
100+ Text = text ,
101+ OuterHTML = "" ,
102+ StyleType = styleType ,
103+ ItemType = embedItemType ,
104+ ItemUid = itemUID ,
105+ ContentTypeUid = node . attrs . ContainsKey ( "content-type-uid" ) ? ( string ) node . attrs [ "content-type-uid" ] : "" ,
106+ attributes = node . attrs
107+ } ;
108+
109+ }
70110 }
71111}
0 commit comments