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 +4 -4
- data/lib/draftjs_html/node.rb +25 -1
- data/lib/draftjs_html/to_html.rb +2 -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: 0e6d6f1d7f1c978841fe029f93f5db47688459ec70f2b33de5ed7c9cfa6d2758
|
4
|
+
data.tar.gz: 40ee34b8ba65efaf7c3c627046c06bd1e03c32547a17b111cfc661b7bd7a0a7f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4427355fcb9c1578edc43d67c7fd04ba9c64001dae800996c7124938c0fe2c28d5e4da29e35fda0f2b4659656f829c62dd16b9e482a0e4b6fc780cffe8a1223c
|
7
|
+
data.tar.gz: 1277ff4825ce7a8bb972c4c0cbca2b3b0f440eceee3e6c00346b78b99d9bc900f8497f4a562b56d2cc8427b545418f578c64358d90618dcb7ce39fff5e196b43
|
data/lib/draftjs_html/node.rb
CHANGED
@@ -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.
|
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
|
data/lib/draftjs_html/to_html.rb
CHANGED
@@ -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
|
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.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-
|
11
|
+
date: 2022-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|