/** * Copyright (c) 2013-present, Facebook, Inc. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. * * @providesModule DraftEditorNode.react * @format * @flow * * This is unstable and not part of the public API and should not be used by * production systems. This file may be update/removed without notice. */ 'use strict'; import type { BlockNodeRecord } from './BlockNodeRecord'; import type ContentState from './ContentState'; import type { DraftDecoratorType } from './DraftDecoratorType'; import type SelectionState from './SelectionState'; import type { BidiDirection } from 'fbjs/lib/UnicodeBidiDirection'; const DraftEditorDecoratedLeaves = require('./DraftEditorDecoratedLeaves.react'); const DraftEditorLeaf = require('./DraftEditorLeaf.react'); const DraftOffsetKey = require('./DraftOffsetKey'); const Immutable = require('immutable'); const React = require('react'); const cx = require('fbjs/lib/cx'); const { List } = Immutable; type Props = { block: BlockNodeRecord; children: ?Array; contentState: ContentState; customStyleFn: Function; customStyleMap: Object; decorator: ?DraftDecoratorType; direction: BidiDirection; forceSelection: boolean; hasSelection: boolean; selection: SelectionState; tree: List; }; class DraftEditorNode extends React.Component { render(): React.Node { const { block, contentState, customStyleFn, customStyleMap, decorator, direction, forceSelection, hasSelection, selection, tree } = this.props; const blockKey = block.getKey(); const text = block.getText(); const lastLeafSet = tree.size - 1; const children = this.props.children || tree.map((leafSet, ii) => { const decoratorKey = leafSet.get('decoratorKey'); const leavesForLeafSet = leafSet.get('leaves'); 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(); if (!decoratorKey || !decorator) { return Leaves; } return ; }).toArray(); return
{children}
; } } module.exports = DraftEditorNode;