draftjs_html 0.34.0 → 0.35.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 51c56851fb84b6e413463210677f5e98a15e9ae40a361f73c889d601a6f3e52f
|
4
|
+
data.tar.gz: 45583f01646408735b320847452df1469bfe605efeca9c6ee801f3b9c30a4f6e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4751bb0add2faf14ed3d14bfbcb6080ee2f53bc879fb0db91a0a79b0de0d5605870573f34a00d991633c556efc9191c78e30451bc641fca225bbd0d570ee770d
|
7
|
+
data.tar.gz: 4cb9501eac617513071c070a0d666a26f1eb146b1c3b775d0a16b3a4e48751e8057a645bef30b9a1989b322f90d78a60e0e442bdce523c54537b84e6d8dc461c
|
@@ -34,12 +34,13 @@ module DraftjsHtml
|
|
34
34
|
|
35
35
|
def pop(draftjs)
|
36
36
|
return if @stack.empty?
|
37
|
+
return merge_current_into_parent! if current_is_block_content_inside_list_item?
|
37
38
|
return if inside_parent?
|
38
39
|
|
39
40
|
if @nodes.last == current.tagname && current.flushable?
|
40
41
|
flush_to(draftjs)
|
41
|
-
elsif
|
42
|
-
|
42
|
+
elsif parent
|
43
|
+
parent.consume(current)
|
43
44
|
end
|
44
45
|
|
45
46
|
@stack.pop
|
@@ -98,13 +99,34 @@ module DraftjsHtml
|
|
98
99
|
@nodes << name
|
99
100
|
end
|
100
101
|
|
102
|
+
def merge_current_into_parent!
|
103
|
+
parent.consume(current)
|
104
|
+
@stack.pop
|
105
|
+
end
|
106
|
+
|
107
|
+
def current_is_block_content_inside_list_item?
|
108
|
+
block_content? && inside_parent? && inside_list_item?
|
109
|
+
end
|
110
|
+
|
101
111
|
def inside_parent?
|
102
112
|
(FromHtml::LIST_PARENT_ELEMENTS & @nodes).any?
|
103
113
|
end
|
104
114
|
|
115
|
+
def inside_list_item?
|
116
|
+
(FromHtml::LIST_ITEM_ELEMENTS & @nodes).any?
|
117
|
+
end
|
118
|
+
|
119
|
+
def block_content?
|
120
|
+
BLOCK_CONTENT_ELEMENTS.include?(current.tagname)
|
121
|
+
end
|
122
|
+
|
105
123
|
def current
|
106
124
|
@stack.last
|
107
125
|
end
|
126
|
+
|
127
|
+
def parent
|
128
|
+
@stack[-2]
|
129
|
+
end
|
108
130
|
end
|
109
131
|
end
|
110
132
|
end
|
@@ -2,6 +2,7 @@ module DraftjsHtml
|
|
2
2
|
class FromHtml < Nokogiri::XML::SAX::Document
|
3
3
|
INLINE_STYLE_ELEMENTS = HtmlDefaults::HTML_STYLE_TAGS_TO_STYLE.keys.freeze
|
4
4
|
LIST_PARENT_ELEMENTS = %w[ol ul].freeze
|
5
|
+
LIST_ITEM_ELEMENTS = %w[li].freeze
|
5
6
|
INLINE_NON_STYLE_ELEMENTS = %w[a abbr cite font img output q samp span table thead tbody td time var].freeze
|
6
7
|
BLOCK_CONTENT_ELEMENTS = %w[p dl h1 h2 h3 h4 h5 h6].freeze
|
7
8
|
FLUSH_BOUNDARIES = %w[OPENING div ol ul li tr].freeze
|
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.35.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:
|
11
|
+
date: 2025-05-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -105,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
105
105
|
- !ruby/object:Gem::Version
|
106
106
|
version: '0'
|
107
107
|
requirements: []
|
108
|
-
rubygems_version: 3.4.
|
108
|
+
rubygems_version: 3.4.20
|
109
109
|
signing_key:
|
110
110
|
specification_version: 4
|
111
111
|
summary: A tool for converting DraftJS JSON to HTML (and back again)
|