draftjs_html 0.6.0 → 0.7.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3c112f9e968e0926060a82da8f7e2235bd96a5826b361c2748187b1e6fd9262f
4
- data.tar.gz: f87a65d70de90ee9cb22c0b923cca42d24b5555b54402f292fd38a794fda0e18
3
+ metadata.gz: 0e6d6f1d7f1c978841fe029f93f5db47688459ec70f2b33de5ed7c9cfa6d2758
4
+ data.tar.gz: 40ee34b8ba65efaf7c3c627046c06bd1e03c32547a17b111cfc661b7bd7a0a7f
5
5
  SHA512:
6
- metadata.gz: ccc0d1b85455ff2f17c501c2dd86c0535b22352e4b7558bc2a014072f2698b4a92a408f636ce1ae7aea6b1538e5b0cae1e4870ceb7ca2f87c80589560918348f
7
- data.tar.gz: d2b011db33d20ab293bd709ef5cb96c8458a14753112df0b0f88d628404115cc477357bdaad493415fa6e03f000d326a672d255ed846e6985dd14e95b395538c
6
+ metadata.gz: 4427355fcb9c1578edc43d67c7fd04ba9c64001dae800996c7124938c0fe2c28d5e4da29e35fda0f2b4659656f829c62dd16b9e482a0e4b6fc780cffe8a1223c
7
+ data.tar.gz: 1277ff4825ce7a8bb972c4c0cbca2b3b0f440eceee3e6c00346b78b99d9bc900f8497f4a562b56d2cc8427b545418f578c64358d90618dcb7ce39fff5e196b43
@@ -3,6 +3,14 @@ module DraftjsHtml
3
3
  def to_nokogiri(_document)
4
4
  node
5
5
  end
6
+
7
+ def wrap(tagname, attrs = {})
8
+ Node.new(tagname, attrs, self)
9
+ end
10
+
11
+ def to_s
12
+ node.to_s
13
+ end
6
14
  end
7
15
 
8
16
  StringNode = Struct.new(:raw) do
@@ -16,6 +24,14 @@ module DraftjsHtml
16
24
 
17
25
  Nokogiri::XML::NodeSet.new(document, text_nodes)
18
26
  end
27
+
28
+ def wrap(tagname, attrs = {})
29
+ Node.new(tagname, attrs, self)
30
+ end
31
+
32
+ def to_s
33
+ raw.to_s
34
+ end
19
35
  end
20
36
 
21
37
  Node = Struct.new(:element_name, :attributes, :content) do
@@ -30,9 +46,17 @@ module DraftjsHtml
30
46
 
31
47
  def to_nokogiri(document)
32
48
  Nokogiri::XML::Node.new(element_name, document).tap do |node|
33
- node.content = content
49
+ node << content.to_nokogiri(document) if content
34
50
  (attributes || {}).each { |k, v| node[k] = v }
35
51
  end
36
52
  end
53
+
54
+ def wrap(tagname, attrs = {})
55
+ Node.new(tagname, attrs, self)
56
+ end
57
+
58
+ def to_s
59
+ content.to_s
60
+ end
37
61
  end
38
62
  end
@@ -70,7 +70,7 @@ module DraftjsHtml
70
70
  block.each_range do |char_range|
71
71
  content = try_apply_entity_to(draftjs, char_range)
72
72
 
73
- apply_styles_to(block_body, char_range.style_names, content)
73
+ apply_styles_to(block_body, char_range.style_names, Node.of(content))
74
74
  end
75
75
  end
76
76
  end
@@ -124,7 +124,7 @@ module DraftjsHtml
124
124
  content = char_range.text
125
125
  if entity
126
126
  style_fn = (@options[:entity_style_mappings][entity.type] || DEFAULT_ENTITY_STYLE_FN)
127
- content = style_fn.call(entity, content, @document.parent)
127
+ content = style_fn.call(entity, Node.of(content), @document.parent)
128
128
  end
129
129
 
130
130
  content
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DraftjsHtml
4
- VERSION = "0.6.0"
4
+ VERSION = "0.7.0"
5
5
  end
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.6.0
4
+ version: 0.7.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-10-06 00:00:00.000000000 Z
11
+ date: 2022-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri