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
Copy file name to clipboardExpand all lines: README.md
+38-11Lines changed: 38 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ Renders the result of Draft.js convertToRaw using provided callbacks, works well
9
9
## What does it do?
10
10
It can convert whole raw state or just specific parts to desired output like React components or an html string.
11
11
12
-
Additionally you could just parse the raw using provided RawPraser to get a nested structure for a specific block.
12
+
Additionally you could just parse the raw using provided RawParser to get a nested structure for a specific block.
13
13
14
14
## Install
15
15
```sh
@@ -84,7 +84,7 @@ const renderers = {
84
84
* Array of decorators,
85
85
* Entities receive children and the entity data,
86
86
* inspired by https://facebook.github.io/draft-js/docs/advanced-topics-decorators.html
87
-
* it's also possible to pass a Decorator class to options instead (or additionaly)
87
+
* it's also possible to pass a custom Decorator class that matches the [DraftDecoratorType](https://github.com/facebook/draft-js/blob/master/src/model/decorators/DraftDecoratorType.js)
88
88
*/
89
89
decorators: [
90
90
{
@@ -95,7 +95,8 @@ const renderers = {
95
95
// decoratedText a plain string matched by the strategy
96
96
// if your decorator depends on draft-js contentState you need to provide convertFromRaw in redraft options
@@ -141,12 +142,11 @@ Returns an array of rendered blocks.
141
142
- **renderers** - object with 3 groups of renders inline (or style), blocks and entities refer to example for more info
142
143
- **options** - optional settings
143
144
144
-
#### Using style renderer instead of inline
145
-
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.
`joinOutput` - used when rendering to string, joins the output and the children of all the inline and entity renderers, it expects that all renderers return strings, you still have to join the at block level (default: `false`)
188
207
189
-
### Using custom Decorator class
190
-
`Decorator` - use this to pass a custom Decorator class that matches the [DraftDecoratorType](https://github.com/facebook/draft-js/blob/master/src/model/decorators/DraftDecoratorType.js).
208
+
209
+
### Render fallback for missing block type
210
+
`blockFallback` - redraft will render this block type if its missing a block renderer for a specific type (default: `'unstyled'`)
191
211
192
212
### Accessing contentState
193
213
`convertFromRaw` - pass the draft-js convertFromRaw to provide the contentState object to both the components in your decorators and the custom Decorator class getDecorations method.
194
214
195
215
### Creating the ContentBlock
196
216
`createContentBlock` - a function that receives a block and returns a draft-js ContentBlock, if not provided when using decorators redraft will create a ContentBlock stub with only some basic ContentBlock functionality
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)
206
233
207
234
## Changelog
208
235
The changelog is available here [CHANGELOG](CHANGELOG.md)
0 commit comments