import { __ } from "@wordpress/i18n"; import { useSelect } from "@wordpress/data"; import { useBlockProps, RichText } from "@wordpress/block-editor"; import arrow from "../img/arrow-right-circle.svg"; import "./editor.scss"; import OptionsSelectControl from "./OptionsSelectControl"; export default function Edit({ attributes, setAttributes, ...props }) { let { chapterLinkTitle, chapterLinkDescription, chapterLinkRelatedPostId, chapterLinkRelatedPostUrl, } = attributes; let currentRelatedPostConseil = useSelect((select) => select("core").getEntityRecord( "postType", "conseils", chapterLinkRelatedPostId ) ); if ( currentRelatedPostConseil && currentRelatedPostConseil.link !== chapterLinkRelatedPostUrl ) { console.log(chapterLinkRelatedPostUrl); console.log(currentRelatedPostConseil.link); setAttributes({ chapterLinkRelatedPostUrl: currentRelatedPostConseil.link, }); } function onChangeChapterLinkTitle(chapterLinkTitle) { setAttributes({ chapterLinkTitle }); } function onChangeChapterLinkDescription(chapterLinkDescription) { setAttributes({ chapterLinkDescription }); } return ( <>
{chapterLinkRelatedPostUrl && ( {__("En savoir plus", "homegrade-blocks")}
)}
); }