= (props) => {
const {
settings,
mode,
id,
children,
pageContent,
moveThisByThat,
addThisAfterThat,
} = props;
const properties = convertProperties(settings.properties);
const sections = pageContent.filter((itm) => itm.type === "Section");
const key = sections.findIndex((itm) => itm.id === settings.id);
const handleSectionMove = (id) => {
if (id === movePositions.MOVE_UP) {
moveThisByThat(sections[key].id, sections[key - 1].id);
}
if (id === movePositions.MOVE_DOWN) {
moveThisByThat(sections[key].id, sections[key + 1].id);
}
if (id === "SNAPSHOT") {
const headerSection = document.getElementById("section");
html2canvas(headerSection).then((canvas) => {
const base64image = canvas.toDataURL("image/png");
console.log({ base64image });
window.open(base64image, "_blank");
});
}
if (id === "COPY") {
// generate JSON
const df = _.head(pageContent.filter((itm) => itm.id === settings.id));
const cnt = listChildren(pageContent, settings.id);
// console.log(cnt);
const clipboard = JSON.stringify(cnt);
// add to local storage
if (typeof window === "object") {
window.sessionStorage.setItem("clipboard", clipboard);
alert("The Section Has Been Copied");
}
console.log(clipboard);
}
if (id === "PASTE") {
// grab from local storage
const clipboard = JSON.parse(sessionStorage.getItem("clipboard"));
// add to canvas below this section
addThisAfterThat(clipboard, settings.id);
}
};
// const MoveUpDown: React.FC = () => (
//
// {_.has(sections, key - 1) && (
// handleSectionMove(movePositions.MOVE_UP)}
// >
//
//
// )}
// {_.has(sections, key + 1) && (
// handleSectionMove(movePositions.MOVE_DOWN)}
// >
//
//
// )}
//
// );
return (
}
>
);
};
export default EditorSection;