draftjs_exporter 0.0.1 → 0.0.2
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_exporter/version.rb +1 -1
- metadata +5 -89
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f8d59bea7ea1b40766a3e78d33535290d288026b
|
4
|
+
data.tar.gz: 96f8e16bfede94708c613c5205fc6450d22f428e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0133625911008a1a5f663dc5356dd47c54c9fc3abd097ab6f6f52f770a89fd89c4f329827d24e416c83988f29acbd9abafc471fac1e08717c23e5f6eeeed43e4
|
7
|
+
data.tar.gz: 4b6ca1fed16749d841f3ad4b58af395bb927a12ad5cf88b869a26901635a93c70f6042358b841c322f0311430d69c152a40685c55548dd891ef6c83c4bf9275b
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: draftjs_exporter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Theo Cushion
|
@@ -110,94 +110,10 @@ dependencies:
|
|
110
110
|
- - ">="
|
111
111
|
- !ruby/object:Gem::Version
|
112
112
|
version: 0.11.0
|
113
|
-
description:
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
[](https://codeclimate.com/github/ignitionworks/draftjs_exporter)
|
118
|
-
[](https://codeclimate.com/github/ignitionworks/draftjs_exporter/coverage)
|
119
|
-
|
120
|
-
[Draft.js](https://facebook.github.io/draft-js/) is a framework for
|
121
|
-
building rich text editors. However, it does not support exporting
|
122
|
-
documents at HTML. This gem is designed to take the raw `ContentState`
|
123
|
-
(output of [`convertToRaw`](https://facebook.github.io/draft-js/docs/api-reference-data-conversion.html#converttoraw))
|
124
|
-
from Draft.js and convert it to HTML using Ruby.
|
125
|
-
|
126
|
-
## Usage
|
127
|
-
|
128
|
-
```ruby
|
129
|
-
# Create configuration for entities and styles
|
130
|
-
config = {
|
131
|
-
entity_decorators: {
|
132
|
-
'LINK' => DraftjsExporter::Entities::Link.new
|
133
|
-
},
|
134
|
-
block_map: {
|
135
|
-
'header-one' => { element: 'h1' },
|
136
|
-
'unordered-list-item' => {
|
137
|
-
element: 'li',
|
138
|
-
wrapper: ['ul', { className: 'public-DraftStyleDefault-ul' }]
|
139
|
-
},
|
140
|
-
'unstyled' => { element: 'div' }
|
141
|
-
},
|
142
|
-
style_map: {
|
143
|
-
'ITALIC' => { fontStyle: 'italic' }
|
144
|
-
}
|
145
|
-
}
|
146
|
-
|
147
|
-
# New up the exporter
|
148
|
-
exporter = DraftjsExporter::HTML.new(config)
|
149
|
-
|
150
|
-
# Provide raw content state
|
151
|
-
exporter.call({
|
152
|
-
entityMap: {
|
153
|
-
'0' => {
|
154
|
-
type: 'LINK',
|
155
|
-
mutability: 'MUTABLE',
|
156
|
-
data: {
|
157
|
-
url: 'http://example.com'
|
158
|
-
}
|
159
|
-
}
|
160
|
-
},
|
161
|
-
blocks: [
|
162
|
-
{
|
163
|
-
key: '5s7g9',
|
164
|
-
text: 'Header',
|
165
|
-
type: 'header-one',
|
166
|
-
depth: 0,
|
167
|
-
inlineStyleRanges: [],
|
168
|
-
entityRanges: []
|
169
|
-
},
|
170
|
-
{
|
171
|
-
key: 'dem5p',
|
172
|
-
text: 'some paragraph text',
|
173
|
-
type: 'unstyled',
|
174
|
-
depth: 0,
|
175
|
-
inlineStyleRanges: [
|
176
|
-
{
|
177
|
-
offset: 0,
|
178
|
-
length: 4,
|
179
|
-
style: 'ITALIC'
|
180
|
-
}
|
181
|
-
],
|
182
|
-
entityRanges: [
|
183
|
-
{
|
184
|
-
offset: 5,
|
185
|
-
length: 9,
|
186
|
-
key: 0
|
187
|
-
}
|
188
|
-
]
|
189
|
-
}
|
190
|
-
]
|
191
|
-
})
|
192
|
-
# => "<h1>Header</h1><div>\n<span style=\"fontStyle: italic;\">some</span> <a href=\"http://example.com\">paragraph</a> text</div>"
|
193
|
-
```
|
194
|
-
|
195
|
-
## Tests
|
196
|
-
|
197
|
-
```bash
|
198
|
-
$ rspec
|
199
|
-
```
|
200
|
-
|
113
|
+
description: |
|
114
|
+
Draft.js is a framework for building rich text editors. However, it does not support exporting documents at
|
115
|
+
HTML. This gem is designed to take the raw `ContentState` (output of `convertToRaw`) from Draft.js and convert
|
116
|
+
it to HTML using Ruby.
|
201
117
|
email: theo@ignition.works
|
202
118
|
executables: []
|
203
119
|
extensions: []
|