You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- renderers - object with 3 groups of renders inline, blocks and entities refer to example for more info
138
-
- options - optional settings
136
+
- **raw** - result of the Draft.js convertToRaw
137
+
- **renderers** - object with 3 groups of renders inline (or style), blocks and entities refer to example for more info
138
+
- **options** - optional settings
139
139
140
+
#### Using style renderer instead of inline
141
+
If provided with a style renderer in the renders, redraft will use it instead of the inline one. This allows a flatter render more like draft.js does in the editor. Redraft also exposes a helper to create the style renderer.
140
142
```js
141
-
RawParser.parse(block)
142
-
```
143
-
Parses the provided block and returns an ContentNode object
- node - ContentNode from `RawParser.parse(block)` method
150
-
- inlineRendrers, entityRenderers - callbacks
151
-
- entityMap - the entityMap from raw state `raw.entityMap`
152
168
153
169
### Options
154
170
- `cleanup` - cleans up blocks with no text or data (metadata or entities), by default cleanup only removes empty `unstyled` blocks inserted directly after `atomic`. Accepts false or an object containing cleanup settings:
constcorretRender=`<p><span style="${bold}">Lorem </span><a href="http://zombo.com/"><span style="${bold}${italic}">ipsum</span></a><span style="${bold}${italic}"> dolor</span><span style="${italic}"> sit amet,</span> pro nisl sonet ad. </p><blockquote>Eos affert numquam id, in est meis nobis. Legimus singulis suscipiantur eum in, <span style="${italic}">ceteros invenire </span>tractatos his id. </blockquote><p><span style="${bold}">Facer facilis definiebas ea pro, mei malis libris latine an. Senserit moderatius vituperata vis in.</span></p>`// eslint-disable-line max-len
91
+
50
92
51
93
describe('redraft with flat styles',()=>{
52
94
it('should render flat styles correctly',()=>{
53
95
constrendered=redraft(raws.raw,renderers);
54
96
constjoined=joinRecursively(rendered);
55
-
joined.should.equal(
56
-
`<p><span style="${bold}">Lorem </span><a href="http://zombo.com/" ><span style="${bold};${italic}">ipsum</span></a><span style="${bold};${italic}"> dolor</span><span style="${italic}"> sit amet,</span> pro nisl sonet ad. </p><blockquote>Eos affert numquam id, in est meis nobis. Legimus singulis suscipiantur eum in, <span style="${italic}">ceteros invenire </span>tractatos his id. </blockquote><p><span style="${bold}">Facer facilis definiebas ea pro, mei malis libris latine an. Senserit moderatius vituperata vis in.</span></p>`// eslint-disable-line max-len
97
+
joined.should.equal(corretRender);
98
+
});
99
+
it('should render flat styles correctly with ReactDOMServer.renderToStaticMarkup',()=>{
0 commit comments