/* * This file is part of ORY Editor. * * ORY Editor is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * ORY Editor is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with ORY Editor. If not, see . * * @license LGPL-3.0 * @copyright 2016-2018 Aeneas Rekkas * @author Aeneas Rekkas * */ import * as React from 'react'; import { DropTarget as dropTarget } from 'react-dnd'; import { connect } from 'react-redux'; import classNames from 'classnames'; import { dragActions } from '../../../actions/cell/drag'; import { insertActions } from '../../../actions/cell/insert'; import { target, connect as monitorConnect } from './helper/dnd'; import { ComponetizedCell } from '../../../types/editable'; type Props = ComponetizedCell & { isLeaf: boolean; isOver: boolean; isOverCurrent: boolean; isDragging: boolean; isInsertMode: boolean; isLayoutMode: boolean; node: { hover: string; inline: string }; children: React.ReactChildren; className: string; dropTypes: Array; connectDropTarget(e: T): T; }; class Droppable extends React.PureComponent { render() { const { connectDropTarget, isLayoutMode, isInsertMode, className, isLeaf, node: { hover }, children, } = this.props; if (!(isLayoutMode || isInsertMode)) { return (
{children}
); } return connectDropTarget(
{children}
); } } const mapDispatchToProps = { ...dragActions, ...insertActions }; export default connect( null, mapDispatchToProps )( dropTarget( ({ dropTypes }: { dropTypes: Array }) => dropTypes, target, monitorConnect )(Droppable) );