{
e.clipboardData.setData(
"text/plain",
JSON.stringify(elements.filter(element => element.isSelected))
);
deleteSelectedElements(elements);
this.forceUpdate();
e.preventDefault();
}}
onCopy={e => {
e.clipboardData.setData(
"text/plain",
JSON.stringify(elements.filter(element => element.isSelected))
);
e.preventDefault();
}}
onPaste={e => {
const paste = e.clipboardData.getData("text");
let parsedElements;
try {
parsedElements = JSON.parse(paste);
} catch (e) {}
if (
Array.isArray(parsedElements) &&
parsedElements.length > 0 &&
parsedElements[0].type // need to implement a better check here...
) {
clearSelection(elements);
parsedElements.forEach(parsedElement => {
parsedElement.x += 10;
parsedElement.y += 10;
parsedElement.seed = randomSeed();
generateDraw(parsedElement);
elements.push(parsedElement);
});
this.forceUpdate();
}
e.preventDefault();
}}
>
Shapes
{SHAPES.map(({ value, icon }) => (
))}
{someElementIsSelected(elements) && (
)}
Canvas
Canvas Background Color
this.setState({ viewBackgroundColor: color })}
/>
Export
Name
{this.state.name && (
this.updateProjectName(name)}
/>
)}
Image
Scene