File tree Expand file tree Collapse file tree 4 files changed +13
-1
lines changed Expand file tree Collapse file tree 4 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -65,6 +65,13 @@ stateFromElement(element, {
6565});
6666``` 
6767
68+ -  ` inlineElements ` : Array of (lowercase) tag names which should be handled as inline tags. Example:
69+ ``` js 
70+ stateFromElement (element, {
71+   inlineElements:  [' my-first-custom-tag' ' my-second-custom-tag' 
72+ });
73+ ``` 
74+ 
6875## License  
6976
7077This software is [ BSD Licensed] ( /LICENSE ) .
Original file line number Diff line number Diff line change @@ -83,6 +83,7 @@ type Options = {
8383  blockTypes ?: { [ key : string ] : string } ; 
8484  customBlockFn ?: CustomBlockFn ; 
8585  customInlineFn ?CustomInlineFn ; 
86+   inlineElements ?: string [ ] ; 
8687} ; 
8788type  DataMap < T >  =  { [ key : string ] : T } ; 
8889
@@ -403,10 +404,12 @@ class ContentGenerator {
403404
404405  processNode(node: DOMNode) { 
405406    if  ( node . nodeType  ===  NODE_TYPE_ELEMENT ) { 
407+       let  { inlineElements}  =  this . options ; 
406408      // $FlowIssue 
407409      let  element DOMElement  =  node ; 
408410      let  tagName  =  element . nodeName . toLowerCase ( ) ; 
409-       if  ( INLINE_ELEMENTS . hasOwnProperty ( tagName ) )  { 
411+       if  ( INLINE_ELEMENTS . hasOwnProperty ( tagName ) 
412+         ||  ( inlineElements  &&  inlineElements . find ( ( el )  =>  el  ===  tagName ) ) )  { 
410413        this . processInlineElement ( element ) ; 
411414      }  else  { 
412415        this . processBlockElement ( element ) ; 
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ type Options = {
1212  blockTypes ?: { [ key : string ] : string } ; 
1313  customBlockFn ?: CustomBlockFn ; 
1414  customInlineFn ?CustomInlineFn ; 
15+   inlineElements ?: string [ ] ; 
1516} ; 
1617
1718const  defaultOptions : Options  =  { } ; 
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ declare module 'draft-js-import-html' {
2626        elementStyles ?: {  [ styleName : string ] : string  } ; 
2727        customBlockFn ?: CustomBlockFn ; 
2828        customInlineFn ?: CustomInlineFn ; 
29+         inlineElements ?: string  [ ] 
2930    } 
3031
3132    export  function  stateFromHTML ( html : string ,  options ?: Options ) : draftjs . ContentState ; 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments