diff --git a/examples/landing/components/editor/RenderNode.tsx b/examples/landing/components/editor/RenderNode.tsx index 8f849016c..1c6a2f97a 100644 --- a/examples/landing/components/editor/RenderNode.tsx +++ b/examples/landing/components/editor/RenderNode.tsx @@ -6,6 +6,7 @@ import styled from 'styled-components'; import ArrowUp from '../../public/icons/arrow-up.svg'; import Delete from '../../public/icons/delete.svg'; +import Duplicate from '../../public/icons/duplicate.svg'; import Move from '../../public/icons/move.svg'; const IndicatorDiv = styled.div` @@ -13,6 +14,18 @@ const IndicatorDiv = styled.div` margin-top: -29px; font-size: 12px; line-height: 12px; +`; + +const Btn = styled.a` + padding: 0 0px; + opacity: 0.9; + display: flex; + align-items: center; + > div { + position: relative; + top: -50%; + left: -50%; + } svg { fill: #fff; @@ -21,7 +34,7 @@ const IndicatorDiv = styled.div` } `; -const Btn = styled.a` +const DuplicateBtn = styled.a` padding: 0 0px; opacity: 0.9; display: flex; @@ -31,6 +44,11 @@ const Btn = styled.a` top: -50%; left: -50%; } + + svg { + width: 15px; + height: 15px; + } `; export const RenderNode = ({ render }) => { @@ -47,6 +65,7 @@ export const RenderNode = ({ render }) => { deletable, connectors: { drag }, parent, + isCanvas, } = useNode((node) => ({ isHover: node.events.hovered, dom: node.dom, @@ -55,6 +74,7 @@ export const RenderNode = ({ render }) => { deletable: query.node(node.id).isDeletable(), parent: node.data.parent, props: node.data.props, + isCanvas: query.node(node.id).isCanvas(), })); const currentRef = useRef(); @@ -128,7 +148,7 @@ export const RenderNode = ({ render }) => { )} {deletable ? ( { e.stopPropagation(); actions.delete(id); @@ -137,6 +157,22 @@ export const RenderNode = ({ render }) => { ) : null} + {!isCanvas ? ( + { + const { + data: { type, props }, + } = query.node(id).get(); + actions.add( + query.createNode(React.createElement(type, props)), + parent + ); + }} + > + + + ) : null} , document.querySelector('.page-container') ) diff --git a/examples/landing/public/icons/duplicate.svg b/examples/landing/public/icons/duplicate.svg new file mode 100644 index 000000000..10895b924 --- /dev/null +++ b/examples/landing/public/icons/duplicate.svg @@ -0,0 +1 @@ + \ No newline at end of file