fastcomments-react-native-sdk
Version:
React Native FastComments Components. Add live commenting to any React Native application.
27 lines (26 loc) • 1.24 kB
JavaScript
import { EditorNodeText } from "./editor-node-text";
import { EditorNodeEmoticon } from "./editor-node-emoticon";
import { EditorNodeType } from "./node-types";
import { EditorNodeImage } from "./editor-node-image";
export function EditorNode(props) {
// OPTIMIZATION: in order of popularity
// OPTIMIZATION: Not using TSX here to try to reduce number of objects getting re-allocated, instead calling element function with same props object.
switch (props.nodeState.type.get()) {
// we do this in an attempt to not re-render the code and trigger keyboard blur/focus on backspacing bold->text etc
case EditorNodeType.TEXT:
case EditorNodeType.TEXT_BOLD:
case EditorNodeType.TEXT_ITALIC:
case EditorNodeType.TEXT_UNDERLINE:
case EditorNodeType.TEXT_STRIKETHROUGH:
return EditorNodeText(props);
case EditorNodeType.EMOTICON:
return EditorNodeEmoticon(props);
case EditorNodeType.IMAGE:
return EditorNodeImage(props);
}
// OPTIMIZATION: We don't actually have to render newline nodes.
// if (props.node.type.get() === EditorNodeType.NEWLINE) {
// return EditorNodeNewline(props);
// }
return null;
}