Skip to content

Commit

Permalink
feat(editor): selectionKey as prop
Browse files Browse the repository at this point in the history
  • Loading branch information
moklick committed Oct 3, 2019
1 parent 5ffe4f9 commit 5dd8d6a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/GraphView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const GraphView = memo((props) => {
const updateSize = useStoreActions(actions => actions.updateSize);
const setNodesSelection = useStoreActions(actions => actions.setNodesSelection);

const shiftPressed = useKeyPress('Shift');
const selectionKeyPressed = useKeyPress(props.selectionKey);
const updateDimensions = () => {
const size = getDimensions(rendererNode.current);
updateSize(size);
Expand All @@ -39,7 +39,7 @@ const GraphView = memo((props) => {
};
}, []);

useD3Zoom(zoomPane, props.onMove, shiftPressed);
useD3Zoom(zoomPane, props.onMove, selectionKeyPressed);

useEffect(() => {
if (state.d3Initialised) {
Expand All @@ -66,7 +66,7 @@ const GraphView = memo((props) => {
connectionLineType={props.connectionLineType}
connectionLineStyle={props.connectionLineStyle}
/>
{shiftPressed && <UserSelection />}
{selectionKeyPressed && <UserSelection />}
{state.nodesSelectionActive && <NodesSelection />}
<div
className="react-graph__zoompane"
Expand Down
6 changes: 4 additions & 2 deletions src/ReactGraph/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const ReactGraph = ({
style, onElementClick, elements, children,
nodeTypes, edgeTypes, onLoad, onMove, onElementsRemove,
onConnect, onNodeDragStop, connectionLineType, connectionLineStyle,
deleteKey
deleteKey, selectionKey
}) => {
const nodeTypesParsed = useMemo(() => createNodeTypes(nodeTypes), []);
const edgeTypesParsed = useMemo(() => createEdgeTypes(edgeTypes), []);
Expand All @@ -45,6 +45,7 @@ const ReactGraph = ({
edgeTypes={edgeTypesParsed}
connectionLineType={connectionLineType}
connectionLineStyle={connectionLineStyle}
selectionKey={selectionKey}
/>
<GlobalKeyHandler
onElementsRemove={onElementsRemove}
Expand Down Expand Up @@ -77,7 +78,8 @@ ReactGraph.defaultProps = {
},
connectionLineType: 'bezier',
connectionLineStyle: {},
deleteKey: 'Backspace'
deleteKey: 'Backspace',
selectionKey: 'Shift'
};

export default ReactGraph;

0 comments on commit 5dd8d6a

Please sign in to comment.