@@ -70,6 +70,18 @@ const ELEMENT_TAGS: IHtmlToJsonElementTags = {
70
70
DIV : ( el : HTMLElement ) => {
71
71
return { type : 'div' , attrs : { } }
72
72
} ,
73
+ VIDEO : ( el : HTMLElement ) => {
74
+ const srcArray = Array . from ( el . querySelectorAll ( "source" ) ) . map ( ( source ) =>
75
+ source . getAttribute ( "src" )
76
+ ) ;
77
+
78
+ return {
79
+ type : 'embed' ,
80
+ attrs : {
81
+ src : srcArray . length > 0 ? srcArray [ 0 ] : null ,
82
+ } ,
83
+ }
84
+ } ,
73
85
STYLE : ( el : HTMLElement ) => {
74
86
return { type : 'style' , attrs : { "style-text" : el . textContent } }
75
87
} ,
@@ -381,6 +393,9 @@ export const fromRedactor = (el: any, options?:IHtmlToJsonOptions) : IAnyObject
381
393
if ( nodeName === 'FIGCAPTION' ) {
382
394
return null
383
395
}
396
+ if ( nodeName === 'SOURCE' ) {
397
+ return null ;
398
+ }
384
399
if ( nodeName === 'DIV' ) {
385
400
const dataType = el . attributes [ 'data-type' ] ?. value
386
401
if ( dataType === 'row' ) {
@@ -588,7 +603,7 @@ export const fromRedactor = (el: any, options?:IHtmlToJsonOptions) : IAnyObject
588
603
return jsx ( 'element' , elementAttrs , [ { text : '' } ] )
589
604
}
590
605
}
591
- if ( nodeName === 'IMG' || nodeName === 'IFRAME' ) {
606
+ if ( nodeName === 'IMG' || nodeName === 'IFRAME' || nodeName === 'VIDEO' ) {
592
607
if ( elementAttrs ?. attrs ?. [ "redactor-attributes" ] ?. width ) {
593
608
let width = elementAttrs . attrs [ "redactor-attributes" ] . width
594
609
if ( width . slice ( width . length - 1 ) === '%' ) {
0 commit comments