draftjs_html 0.27.0 → 0.28.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_depth.rb +34 -6
- 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: ee7df9bd0f6a54994b17925c487f2c824ec538e773abe2c56b5591e5cd846573
|
4
|
+
data.tar.gz: c874e8b188f77d2ffd7ade661ff5e61cea5c136b0d89e3a9bf022a5e87de142f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f4dc0f13111d6a0424d24620810bb5ac928bade2a1ba29fee46baa182e91a67430909920b3c9be69f4836299fbc44953f4db8c20a4948431e33bfc496def6a0
|
7
|
+
data.tar.gz: 852986e0ce26c74d377bd8c202de3a898510b5ef5b20f594b65e035c3b25258a11375a4aed562aa62cbfcdd42388125316d9bef82cbf8ff670ba442a766ff926
|
@@ -19,7 +19,7 @@ module DraftjsHtml
|
|
19
19
|
return unless nesting_root_changed?(block) || depth_changed?(block)
|
20
20
|
|
21
21
|
if deepening?(block)
|
22
|
-
deepen(block)
|
22
|
+
deepen(block, desired_depth_change: block.depth - @current_depth)
|
23
23
|
elsif rising?(block) && still_nested?(block)
|
24
24
|
rise(times: @current_depth - block.depth)
|
25
25
|
elsif rising?(block)
|
@@ -36,11 +36,17 @@ module DraftjsHtml
|
|
36
36
|
|
37
37
|
private
|
38
38
|
|
39
|
-
def deepen(block)
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
39
|
+
def deepen(block, desired_depth_change: 0)
|
40
|
+
if inside_valid_nesting_root?
|
41
|
+
set_previous_li_as_parent(block)
|
42
|
+
else
|
43
|
+
create_valid_nesting_root(block)
|
44
|
+
end
|
45
|
+
|
46
|
+
(desired_depth_change - 1).times do
|
47
|
+
create_valid_nesting_root(block)
|
48
|
+
end
|
49
|
+
|
44
50
|
push_parent(block)
|
45
51
|
end
|
46
52
|
|
@@ -91,5 +97,27 @@ module DraftjsHtml
|
|
91
97
|
def deepening?(block)
|
92
98
|
@current_depth < block.depth
|
93
99
|
end
|
100
|
+
|
101
|
+
def create_valid_nesting_root(block)
|
102
|
+
parent_tagname = BLOCK_TYPE_TO_HTML_WRAPPER[block.type]
|
103
|
+
node = create_child(parent_tagname)
|
104
|
+
@previous_parents << node
|
105
|
+
@nesting_roots << parent_tagname
|
106
|
+
@body.parent = node
|
107
|
+
|
108
|
+
list_item = create_child('li')
|
109
|
+
@body.parent = list_item
|
110
|
+
end
|
111
|
+
|
112
|
+
def set_previous_li_as_parent(block)
|
113
|
+
tagname = BLOCK_TYPE_TO_HTML_WRAPPER[block.type]
|
114
|
+
@previous_parents << @body.parent
|
115
|
+
@nesting_roots << tagname
|
116
|
+
@body.parent = @body.parent.last_element_child
|
117
|
+
end
|
118
|
+
|
119
|
+
def inside_valid_nesting_root?
|
120
|
+
BLOCK_TYPE_TO_HTML_WRAPPER.values.include?(@body.parent.name)
|
121
|
+
end
|
94
122
|
end
|
95
123
|
end
|
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.28.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: 2023-
|
11
|
+
date: 2023-02-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|