Skip to content

Commit e604908

Browse files
committed
Implement render empty blocks
1 parent ce93af9 commit e604908

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

src/components/DraftJsText.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ import defaultStyles from './defaultStyles';
1515
import type { DraftJsTextPropsType } from './types';
1616

1717
const DraftJsText = (props: DraftJsTextPropsType): any => {
18-
const { text } = props;
18+
const { text, renderEmptyBlocks } = props;
1919
let textElements = text;
2020

21-
if (textElements) {
21+
if (textElements || renderEmptyBlocks) {
2222
textElements = loadAttributes({
2323
text: props.text,
2424
customStyles: props.customStyles,

src/components/types.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export type BlockQuotePropsType = {
1515
entityRanges: Array<Object>,
1616
entityMap: ?Object,
1717
textProps: ?Object,
18+
renderEmptyBlocks: boolean,
1819
};
1920

2021
export type DraftJsTextPropsType = {
@@ -27,6 +28,7 @@ export type DraftJsTextPropsType = {
2728
entityMap: ?Object,
2829
navigate?: Function,
2930
textProps: ?Object,
31+
renderEmptyBlocks: boolean,
3032
};
3133

3234
export type OrderedListItemPropsType = {
@@ -42,6 +44,7 @@ export type OrderedListItemPropsType = {
4244
depth: number,
4345
defaultMarginLeft: number,
4446
textProps: ?Object,
47+
renderEmptyBlocks: boolean,
4548
};
4649

4750
export type UnorderedListItemPropsType = {
@@ -55,6 +58,7 @@ export type UnorderedListItemPropsType = {
5558
depth: number,
5659
defaultMarginLeft: number,
5760
textProps: ?Object,
61+
renderEmptyBlocks: boolean,
5862
};
5963

6064
export type TextStyledPropsType = {

src/getBlocks.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ type ParamsType = {
2020
blocks: ?Array<*>,
2121
entityMap: Object,
2222
},
23+
renderEmptyBlocks: boolean,
2324
customStyles: Object,
2425
atomicHandler: Function,
2526
navigate?: Function,
@@ -36,6 +37,7 @@ export const ViewAfterList = (props: Object): React$Element<*> => (
3637
const getBlocks = (params: ParamsType): ?Array<React$Element<*>> => {
3738
const {
3839
contentState,
40+
renderEmptyBlocks,
3941
customStyles,
4042
navigate,
4143
orderedListSeparator,
@@ -123,6 +125,7 @@ const getBlocks = (params: ParamsType): ?Array<React$Element<*>> => {
123125
{viewBefore}
124126
<DraftJsText
125127
{...itemData}
128+
renderEmptyBlocks={renderEmptyBlocks}
126129
entityMap={contentState.entityMap}
127130
customStyles={customStyles}
128131
navigate={navigate}
@@ -160,6 +163,7 @@ const getBlocks = (params: ParamsType): ?Array<React$Element<*>> => {
160163
customStyles={customStyles}
161164
navigate={navigate}
162165
textProps={textProps}
166+
renderEmptyBlocks={renderEmptyBlocks}
163167
/>
164168
</View>
165169
);
@@ -178,6 +182,7 @@ const getBlocks = (params: ParamsType): ?Array<React$Element<*>> => {
178182
navigate={navigate}
179183
defaultMarginLeft={depthMargin}
180184
textProps={textProps}
185+
renderEmptyBlocks={renderEmptyBlocks}
181186
/>
182187
</View>
183188
);
@@ -217,6 +222,7 @@ const getBlocks = (params: ParamsType): ?Array<React$Element<*>> => {
217222
navigate={navigate}
218223
defaultMarginLeft={depthMargin}
219224
textProps={textProps}
225+
renderEmptyBlocks={renderEmptyBlocks}
220226
/>
221227
</View>
222228
);

0 commit comments

Comments
 (0)