draftjs_html 0.17.0 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/lib/draftjs_html/html_defaults.rb +4 -9
 - data/lib/draftjs_html/to_html.rb +12 -2
 - data/lib/draftjs_html/version.rb +1 -1
 - metadata +2 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: cc60a020f5dbdf759d93345fbc5589476a156d18d5c7b793fa7d1ebb36bb4164
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: fce62ecfe77aa2740b895fc38ec45b0d2947f47dcb202d217d9e07ec3644f791
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 06e33f852881f2f5f02edf2afdf331caa0d5fa208a0d0386a6e9eaa663eb2b11694cb3d6c942ca4cfde17edd0379ecd3d3e8abe061970494002d743f1468eed7
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 128b6ec7334c9909c209e18146e96aad8b336f8af000daefc38fa8fdbb171270d4cfa4458365326e13f33c2b155119091907ce63b08ae17739d6791c111eb3a5
         
     | 
| 
         @@ -16,25 +16,20 @@ module DraftjsHtml 
     | 
|
| 
       16 
16 
     | 
    
         
             
                  'atomic' => 'figure',
         
     | 
| 
       17 
17 
     | 
    
         
             
                }.freeze
         
     | 
| 
       18 
18 
     | 
    
         | 
| 
       19 
     | 
    
         
            -
                STYLE_MAP = {
         
     | 
| 
       20 
     | 
    
         
            -
                  'BOLD' => 'b',
         
     | 
| 
       21 
     | 
    
         
            -
                  'ITALIC' => 'i',
         
     | 
| 
       22 
     | 
    
         
            -
                  'STRIKETHROUGH' => 'del',
         
     | 
| 
       23 
     | 
    
         
            -
                  'UNDERLINE' => 'u',
         
     | 
| 
       24 
     | 
    
         
            -
                }.freeze
         
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
19 
     | 
    
         
             
                HTML_STYLE_TAGS_TO_STYLE = {
         
     | 
| 
      
 20 
     | 
    
         
            +
                  'strong' => 'BOLD',
         
     | 
| 
       27 
21 
     | 
    
         
             
                  'b' => 'BOLD',
         
     | 
| 
       28 
     | 
    
         
            -
                  'i' => 'ITALIC',
         
     | 
| 
       29 
22 
     | 
    
         
             
                  'em' => 'ITALIC',
         
     | 
| 
      
 23 
     | 
    
         
            +
                  'i' => 'ITALIC',
         
     | 
| 
       30 
24 
     | 
    
         
             
                  'del' => 'STRIKETHROUGH',
         
     | 
| 
       31 
25 
     | 
    
         
             
                  'u' => 'UNDERLINE',
         
     | 
| 
       32 
     | 
    
         
            -
                  'strong' => 'BOLD',
         
     | 
| 
       33 
26 
     | 
    
         
             
                  'small' => 'SMALL',
         
     | 
| 
       34 
27 
     | 
    
         
             
                  'sub' => 'SUBSCRIPT',
         
     | 
| 
       35 
28 
     | 
    
         
             
                  'sup' => 'SUPERSCRIPT',
         
     | 
| 
       36 
29 
     | 
    
         
             
                }.freeze
         
     | 
| 
       37 
30 
     | 
    
         | 
| 
      
 31 
     | 
    
         
            +
                STYLE_MAP = HTML_STYLE_TAGS_TO_STYLE.invert.freeze
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
       38 
33 
     | 
    
         
             
                ENTITY_ATTRIBUTE_NAME_MAP = {
         
     | 
| 
       39 
34 
     | 
    
         
             
                  'className' => 'class',
         
     | 
| 
       40 
35 
     | 
    
         
             
                  'url' => 'href',
         
     | 
    
        data/lib/draftjs_html/to_html.rb
    CHANGED
    
    | 
         @@ -56,11 +56,21 @@ module DraftjsHtml 
     | 
|
| 
       56 
56 
     | 
    
         | 
| 
       57 
57 
     | 
    
         
             
                def append_child(nokogiri, child)
         
     | 
| 
       58 
58 
     | 
    
         
             
                  new_node = DraftjsHtml::Node.of(child).to_nokogiri(@document.doc)
         
     | 
| 
       59 
     | 
    
         
            -
                   
     | 
| 
       60 
     | 
    
         
            -
                  nokogiri.parent['dir'] = 'rtl' if @current_bidi_direction.rtl?
         
     | 
| 
      
 59 
     | 
    
         
            +
                  apply_bidi_direction(new_node.inner_text, nokogiri)
         
     | 
| 
       61 
60 
     | 
    
         
             
                  nokogiri.parent.add_child(new_node)
         
     | 
| 
       62 
61 
     | 
    
         
             
                end
         
     | 
| 
       63 
62 
     | 
    
         | 
| 
      
 63 
     | 
    
         
            +
                def apply_bidi_direction(text, nokogiri)
         
     | 
| 
      
 64 
     | 
    
         
            +
                  @current_bidi_direction.update(text)
         
     | 
| 
      
 65 
     | 
    
         
            +
                  if @current_bidi_direction.rtl?
         
     | 
| 
      
 66 
     | 
    
         
            +
                    current_parent = nokogiri.parent
         
     | 
| 
      
 67 
     | 
    
         
            +
                    while current_parent.name != 'body'
         
     | 
| 
      
 68 
     | 
    
         
            +
                      current_parent['dir'] = 'rtl'
         
     | 
| 
      
 69 
     | 
    
         
            +
                      current_parent = current_parent.parent
         
     | 
| 
      
 70 
     | 
    
         
            +
                    end
         
     | 
| 
      
 71 
     | 
    
         
            +
                  end
         
     | 
| 
      
 72 
     | 
    
         
            +
                end
         
     | 
| 
      
 73 
     | 
    
         
            +
             
     | 
| 
       64 
74 
     | 
    
         
             
                def block_element_for(block)
         
     | 
| 
       65 
75 
     | 
    
         
             
                  return 'br' if block.blank?
         
     | 
| 
       66 
76 
     | 
    
         | 
    
        data/lib/draftjs_html/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: draftjs_html
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.19.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - TJ Taylor
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: exe
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2022-11- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2022-11-17 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: nokogiri
         
     |