draftjs_html 0.20.0 → 0.21.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +14 -0
- data/lib/draftjs_html/html_defaults.rb +4 -1
- data/lib/draftjs_html/to_html.rb +3 -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: 662afcc40856fc071f8933862c939e45da447bfcf089287ef486c20eaa9ad9ea
|
4
|
+
data.tar.gz: e3c86eb5fd81a6daf446d3cd6a2a8394d4db8c2a79a4d7e3dfc9aa0ff1524514
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 91d4da6dd384c6b38fda6edaa8653af2a968b04e53ab3b0bdc4b1305242043f816c25f906508fb6800ab306bbe8967d6608e3a411294152b53c22f375b0cf6dd
|
7
|
+
data.tar.gz: 8840930b9e1d680477ca458b7b44faff3343dfd1d4129b4e28c931e62c2318dddee8d8c4f8c32bf1f5eaa13e8b542f6704b09ee766c95c9049b9bfa4d37441cf
|
data/README.md
CHANGED
@@ -127,6 +127,20 @@ DraftjsHtml.to_html(raw_draftjs, options: {
|
|
127
127
|
# This would generate <strong> tags instead of <b> tags around ranges of `BOLD` inline styles.
|
128
128
|
```
|
129
129
|
|
130
|
+
You may also add attributes to tags created by `inline_style_mapping`s by using a two element array.
|
131
|
+
The first element should be the tagname and the second argument a hash of attributes to values, like this:
|
132
|
+
|
133
|
+
```ruby
|
134
|
+
|
135
|
+
DraftjsHtml.to_html(raw_draftjs, options: {
|
136
|
+
inline_style_mapping: {
|
137
|
+
'BOLD' => ['strong', style: 'font-weight: 900'],
|
138
|
+
},
|
139
|
+
})
|
140
|
+
```
|
141
|
+
|
142
|
+
# This would generate <strong> tags instead of <b> tags around ranges of `BOLD` inline styles.
|
143
|
+
|
130
144
|
#### `:inline_style_renderer`
|
131
145
|
|
132
146
|
If the direct mapping from `:inline_style_mapping` isn't enough, you can supply a custom function for rendering a style range.
|
@@ -29,7 +29,10 @@ module DraftjsHtml
|
|
29
29
|
'code' => 'CODE',
|
30
30
|
}.freeze
|
31
31
|
|
32
|
-
STYLE_MAP = HTML_STYLE_TAGS_TO_STYLE.invert.
|
32
|
+
STYLE_MAP = HTML_STYLE_TAGS_TO_STYLE.invert.merge(
|
33
|
+
'HIGHLIGHT' => 'em',
|
34
|
+
'RTL' => ['div', dir: 'rtl']
|
35
|
+
).freeze
|
33
36
|
|
34
37
|
ENTITY_ATTRIBUTE_NAME_MAP = {
|
35
38
|
'className' => 'class',
|
data/lib/draftjs_html/to_html.rb
CHANGED
@@ -49,7 +49,8 @@ module DraftjsHtml
|
|
49
49
|
return append_child(html, custom_render_content) if custom_render_content
|
50
50
|
|
51
51
|
style, *rest = style_names
|
52
|
-
|
52
|
+
|
53
|
+
html.public_send(*style_element_for(style)) do |builder|
|
53
54
|
apply_styles_to(builder, rest, child)
|
54
55
|
end
|
55
56
|
end
|
@@ -78,7 +79,7 @@ module DraftjsHtml
|
|
78
79
|
end
|
79
80
|
|
80
81
|
def style_element_for(style)
|
81
|
-
@options[:inline_style_mapping].value_of!(style)
|
82
|
+
Array(@options[:inline_style_mapping].value_of!(style))
|
82
83
|
end
|
83
84
|
|
84
85
|
def try_apply_entity_to(draftjs, char_range)
|
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.21.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-11-
|
11
|
+
date: 2022-11-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|