draftjs_html 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 947546094b93886a5533fe19720c44671066c08ebe079dd9a628cead629e880e
4
- data.tar.gz: 280b8abcae0942d236f2352ef8f6aac6fb4a34d51323ed9cb15b8667c8e24d41
3
+ metadata.gz: 3c112f9e968e0926060a82da8f7e2235bd96a5826b361c2748187b1e6fd9262f
4
+ data.tar.gz: f87a65d70de90ee9cb22c0b923cca42d24b5555b54402f292fd38a794fda0e18
5
5
  SHA512:
6
- metadata.gz: c0b41f31e0c06a0c9dd6ee08ad7c4cbfd534875130503439ff21777a3145551fd15ac01496e96ec144a96c69ab4e137b4213eefe5f14c1b0b920bf6759e1d1a9
7
- data.tar.gz: 991cabc0dd8a3ccb1785a34f9c629be7b5bc0ee0ec83498ba0e494a234eb3175c5089d3b44a533caa271dd115a499e710cf2bddc5d6442d181ebf2b980438f6c
6
+ metadata.gz: ccc0d1b85455ff2f17c501c2dd86c0535b22352e4b7558bc2a014072f2698b4a92a408f636ce1ae7aea6b1538e5b0cae1e4870ceb7ca2f87c80589560918348f
7
+ data.tar.gz: d2b011db33d20ab293bd709ef5cb96c8458a14753112df0b0f88d628404115cc477357bdaad493415fa6e03f000d326a672d255ed846e6985dd14e95b395538c
@@ -7,8 +7,14 @@ module DraftjsHtml
7
7
 
8
8
  StringNode = Struct.new(:raw) do
9
9
  def to_nokogiri(document)
10
- raw
11
- Nokogiri::XML::Text.new(raw, document)
10
+ lines = raw.lines
11
+ text_nodes = lines.flat_map.with_index do |text, i|
12
+ nodes = [Nokogiri::XML::Text.new(text.chomp, document)]
13
+ nodes << Nokogiri::XML::Node.new('br', document) if i < lines.size - 1
14
+ nodes
15
+ end
16
+
17
+ Nokogiri::XML::NodeSet.new(document, text_nodes)
12
18
  end
13
19
  end
14
20
 
@@ -106,7 +106,7 @@ module DraftjsHtml
106
106
  end
107
107
 
108
108
  def append_child(nokogiri, child)
109
- nokogiri.parent.add_child(DraftjsHtml::Node.of(child).to_nokogiri(@document.parent))
109
+ nokogiri.parent.add_child(DraftjsHtml::Node.of(child).to_nokogiri(@document.doc))
110
110
  end
111
111
 
112
112
  def block_element_for(block)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DraftjsHtml
4
- VERSION = "0.5.0"
4
+ VERSION = "0.6.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: draftjs_html
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - TJ Taylor