Skip to content
This repository has been archived by the owner on Feb 6, 2023. It is now read-only.

Commit

Permalink
Support custom block rendering
Browse files Browse the repository at this point in the history
Summary: In tree mode, we were ignoring the custom block components passed via the block renderer function.

Differential Revision: D9954387

fbshipit-source-id: 9165b015c1ddcdd9cfbce94a09e7f2e60c68bce9
  • Loading branch information
niveditc authored and facebook-github-bot committed Sep 20, 2018
1 parent d9c9d40 commit fbe2267
Showing 1 changed file with 27 additions and 16 deletions.
43 changes: 27 additions & 16 deletions src/component/contents/exploration/DraftEditorBlockNode.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,21 +341,32 @@ class DraftEditorBlockNode extends React.Component<Props> {
const blockKey = block.getKey();
const offsetKey = DraftOffsetKey.encode(blockKey, 0, 0);

const blockNode = (
<DraftEditorNode
block={block}
children={children}
contentState={contentState}
customStyleFn={customStyleFn}
customStyleMap={customStyleMap}
decorator={decorator}
direction={direction}
forceSelection={forceSelection}
hasSelection={isBlockOnSelectionEdge(selection, blockKey)}
selection={selection}
tree={tree}
/>
);
const customConfig = getCustomRenderConfig(block, blockRendererFn);
const Component = customConfig.CustomComponent;
const blockNode =
Component != null ? (
<Component
{...this.props}
tree={editorState.getBlockTree(blockKey)}
blockProps={customConfig.customProps}
offsetKey={offsetKey}
block={block}
/>
) : (
<DraftEditorNode
block={block}
children={children}
contentState={contentState}
customStyleFn={customStyleFn}
customStyleMap={customStyleMap}
decorator={decorator}
direction={direction}
forceSelection={forceSelection}
hasSelection={isBlockOnSelectionEdge(selection, blockKey)}
selection={selection}
tree={tree}
/>
);

if (block.getParentKey()) {
return blockNode;
Expand All @@ -367,7 +378,7 @@ class DraftEditorBlockNode extends React.Component<Props> {
editorKey,
offsetKey,
blockStyleFn,
getCustomRenderConfig(block, blockRendererFn),
customConfig,
);

// root block nodes needs to be wrapped
Expand Down

0 comments on commit fbe2267

Please sign in to comment.