File tree Expand file tree Collapse file tree 2 files changed +19
-9
lines changed Expand file tree Collapse file tree 2 files changed +19
-9
lines changed Original file line number Diff line number Diff line change @@ -24,15 +24,13 @@ describe('htmlToDraft test suite', () => {
24
24
contentBlocks = htmlToDraft ( '<p>test<a>link</a></p>' ) ;
25
25
console . log ( 'contentBlocks' , contentBlocks ) ;
26
26
27
- contentBlocks = htmlToDraft ( '<hr/>' , function ( nodeName ) {
28
- if ( nodeName === 'hr' ) {
29
- return {
30
- type : 'HORIZONTAL_RULE' ,
31
- mutability : 'IMMUTABLE' ,
32
- data : { }
33
- } ;
34
- }
35
- } ) ;
27
+ contentBlocks = htmlToDraft ( `<span style="font-weight:bold;">bold</span>` ) ;
28
+ console . log ( 'contentBlocks' , contentBlocks ) ;
29
+
30
+ contentBlocks = htmlToDraft ( `<span style="text-decoration:underline;">underline</span>` ) ;
31
+ console . log ( 'contentBlocks' , contentBlocks ) ;
32
+
33
+ contentBlocks = htmlToDraft ( `<span style="font-style:italic;">italic</span>` ) ;
36
34
console . log ( 'contentBlocks' , contentBlocks ) ;
37
35
38
36
assert . equal ( true , true ) ;
Original file line number Diff line number Diff line change @@ -25,6 +25,9 @@ export default function processInlineTag(
25
25
const backgroundColor = htmlElement . style . backgroundColor ;
26
26
const fontSize = htmlElement . style . fontSize ;
27
27
const fontFamily = htmlElement . style . fontFamily . replace ( / ^ " | " $ / g, '' ) ;
28
+ const fontWeight = htmlElement . style . fontWeight ;
29
+ const textDecoration = htmlElement . style . textDecoration ;
30
+ const fontStyle = htmlElement . style . fontStyle ;
28
31
if ( color ) {
29
32
style . add ( `color-${ color . replace ( / / g, '' ) } ` ) ;
30
33
}
@@ -37,6 +40,15 @@ export default function processInlineTag(
37
40
if ( fontFamily ) {
38
41
style . add ( `fontfamily-${ fontFamily } ` ) ;
39
42
}
43
+ if ( fontWeight === 'bold' ) {
44
+ style . add ( inlineTags . strong )
45
+ }
46
+ if ( textDecoration === 'underline' ) {
47
+ style . add ( inlineTags . ins )
48
+ }
49
+ if ( fontStyle === 'italic' ) {
50
+ style . add ( inlineTags . em )
51
+ }
40
52
} ) . toOrderedSet ( ) ;
41
53
}
42
54
return inlineStyle ;
You can’t perform that action at this time.
0 commit comments