mirror of
https://github.com/bendtherules/piktochart-create-editor.git
synced 2026-08-18 22:02:56 +00:00
Add DraggableNode component
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import * as React from 'react';
|
||||
|
||||
interface OnClickProps {
|
||||
onClick(event: React.MouseEvent<HTMLDivElement>): void;
|
||||
}
|
||||
|
||||
export class DraggableNode extends React.Component {
|
||||
getModifiedChildrenWithAddedClickHandler(): React.ReactElement<OnClickProps>[] {
|
||||
return React.Children.map(this.props.children, (eachChild) => {
|
||||
// tslint:disable-next-line:no-console
|
||||
return React.cloneElement(
|
||||
eachChild as React.ReactElement<OnClickProps>,
|
||||
{
|
||||
onClick: function (event: React.MouseEvent<HTMLDivElement>) {
|
||||
// tslint:disable-next-line:no-console
|
||||
console.log(arguments);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
return this.getModifiedChildrenWithAddedClickHandler();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export { DraggableNode } from './DraggableNode';
|
||||
Reference in New Issue
Block a user