draftjs_html 0.27.0 → 0.29.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/draftjs_html/html_depth.rb +35 -7
- 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: afb24dc172740e504b480688893e7501968871dc219e021b5d70885961b0fcde
|
4
|
+
data.tar.gz: ada9a89937ece511ff1c617e4e5e9754fd61be0980683b6eebe1b7a6afc64eb6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ade3fb1e8447b4f275a8ba717d41f25c43f2e5f63051ca65abbb0e540a43363add8fe67baea81976d2d03ccc350e7e1b3da43fa978fb1a69e14c540c5b3872b2
|
7
|
+
data.tar.gz: 618448a98c1f9309d3a411aa180f95fc109fedc70e0f389b8c4673f06f8cfba43f19413528ebd1c6af291706974edaf4200debc52a0d6e7465169a7ac98343f4
|
@@ -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
|
|
@@ -61,7 +67,7 @@ module DraftjsHtml
|
|
61
67
|
end
|
62
68
|
|
63
69
|
def pop_parent
|
64
|
-
@body.parent = @previous_parents.pop
|
70
|
+
@body.parent = @previous_parents.pop unless @previous_parents.empty?
|
65
71
|
end
|
66
72
|
|
67
73
|
def create_child(tagname)
|
@@ -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.29.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-05-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|