Skip to content

Commit 089ab7e

Browse files
committed
0.10.0
- updated readme and changelog
1 parent c8eb62c commit 089ab7e

File tree

3 files changed

+35
-7
lines changed

3 files changed

+35
-7
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
## 0.9.1
1+
## 0.10.0
22
- switch from Decorator option to custom decorators in renderer array #33
3+
- add blockFallback option, render provided type when missing renderer for a block #35
4+
- expose createBlockRenderer to create block renderer from blockRenderMap #32
5+
- add Common Issues to readme
36

47
## 0.9.0
58
- added support for custom Decorator class and accessing contentState #30

README.md

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,11 @@ Returns an array of rendered blocks.
142142
- **renderers** - object with 3 groups of renders inline (or style), blocks and entities refer to example for more info
143143
- **options** - optional settings
144144
145-
#### Using style renderer instead of inline
146-
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.
145+
#### Using styleMap and blockRenderMap instead of inline and block renders
146+
If provided with a styles 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 styles and block renderers.
147147
```js
148148
import React from 'react';
149-
import redraft, { createStylesRenderer } from 'redraft';
150-
149+
import redraft, { createStylesRenderer, createBlockRenderer } from 'redraft';
151150

152151
const styleMap = {
153152
BOLD: {
@@ -167,9 +166,28 @@ const styleMap = {
167166
const InlineWrapper = ({ children, style, key }) => <span key={key} style={style}>{children}</span>
168167
// this Component results in a flatter output as it can have multiple styles (also possibly less semantic)
169168

170-
// note the style key and createStylesRenderer helper
169+
// Api aligned w draft-js, aliasedElements are not required as draft-js uses them for parsing pasted html
170+
const blockRenderMap = {
171+
unstyled: {
172+
element: 'div',
173+
},
174+
blockquote: {
175+
element: 'blockquote',
176+
},
177+
'ordered-list-item': {
178+
element: 'li',
179+
wrapper: 'ol',
180+
},
181+
'unordered-list-item': {
182+
element: 'li',
183+
wrapper: 'ul',
184+
},
185+
};
186+
171187
const renderers = {
188+
// note the styles key and createStylesRenderer helper
172189
styles: createStylesRenderer(InlineWrapper, styleMap),
190+
blocks: createBlockRenderer(React.createElement, blockRenderMap),
173191
...
174192
};
175193
```
@@ -205,6 +223,13 @@ const createContentBlock = block => new ContentBlock(block)
205223

206224
```
207225
226+
## Common issues
227+
228+
#### Missing String.fromCodePoint in React Native
229+
Consider using a polyfill like [`String.fromCodePoint`](https://github.com/mathiasbynens/String.fromCodePoint) or [`babel-polyfill`](https://babeljs.io/docs/usage/polyfill/)
230+
231+
#### Can the multiple spaces between text be persisted?
232+
Add `white-space: pre-wrap` to a parent div, this way it will preserve spaces and wrap to new lines (as editor js does)
208233
209234
## Changelog
210235
The changelog is available here [CHANGELOG](CHANGELOG.md)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "redraft",
3-
"version": "0.9.1-beta2",
3+
"version": "0.10.0",
44
"description": "Renders the result of Draft.js convertToRaw using provided callbacks, works well with React",
55
"main": "./lib/index.js",
66
"scripts": {

0 commit comments

Comments
 (0)