{
const block = this.props.block;
const blockKey = block.getKey();
const text = block.getText();
const lastLeafSet = this.props.tree.size - 1;
const hasSelection = isBlockOnSelectionEdge(this.props.selection, blockKey);
return this.props.tree.map((leafSet, ii) => {
const leavesForLeafSet = leafSet.get('leaves'); // T44088704
if (leavesForLeafSet.size === 0) {
return null;
}
const lastLeaf = leavesForLeafSet.size - 1;
const leaves = leavesForLeafSet.map((leaf, jj) => {
const offsetKey = DraftOffsetKey.encode(blockKey, ii, jj);
const start = leaf.get('start');
const end = leaf.get('end');
return ;
}).toArray();
const decoratorKey = leafSet.get('decoratorKey');
if (decoratorKey == null) {
return leaves;
}
if (!this.props.decorator) {
return leaves;
}
const decorator = nullthrows(this.props.decorator);
const DecoratorComponent = decorator.getComponentForKey(decoratorKey);
if (!DecoratorComponent) {
return leaves;
}
const decoratorProps = decorator.getPropsForKey(decoratorKey);
const decoratorOffsetKey = DraftOffsetKey.encode(blockKey, ii, 0);
const start = leavesForLeafSet.first().get('start');
const end = leavesForLeafSet.last().get('end');
const decoratedText = text.slice(start, end);
const entityKey = block.getEntityAt(leafSet.get('start')); // Resetting dir to the same value on a child node makes Chrome/Firefox
// confused on cursor movement. See http://jsfiddle.net/d157kLck/3/
const dir = UnicodeBidiDirection.getHTMLDirIfDifferent(UnicodeBidi.getDirection(decoratedText), this.props.direction);
const commonProps: DraftDecoratorComponentProps = {
contentState: this.props.contentState,
decoratedText,
dir: dir,
start,
end,
blockKey,
entityKey,
offsetKey: decoratorOffsetKey
};
return
{leaves}
;
}).toArray();
}
render(): React.Node {
const {
direction,
offsetKey
} = this.props;
const className = cx({
'public/DraftStyleDefault/block': true,
'public/DraftStyleDefault/ltr': direction === 'LTR',
'public/DraftStyleDefault/rtl': direction === 'RTL'
});
return this._node = ref}>
{this._renderChildren()}
;
}
}
module.exports = DraftEditorBlock;