import { __ } from "@wordpress/i18n";
import "./editor.scss";
import "../lien-chapitre";
import {
useBlockProps,
RichText,
InnerBlocks,
BlockControls,
} from "@wordpress/block-editor";
import { ToolbarGroup, ToolbarButton } from "@wordpress/components";
import { MediaReplaceFlow, MediaPlaceholder } from "@wordpress/block-editor";
import { trash } from "@wordpress/icons";
export default function Edit({ attributes, setAttributes, ...props }) {
let { chapterTitle, chapterDescription } = attributes;
function onChangeChapterTitle(chapterTitle) {
setAttributes({ chapterTitle });
}
function onChangeChapterDescription(chapterDescription) {
setAttributes({ chapterDescription });
}
let { chapterImageUrl, chapterImageId, chapterImageAlt } = attributes;
function setImageAttributes(media) {
if (!media || !media.url) {
setAttributes({
chapterImageUrl: null,
chapterImageId: null,
chapterImageAlt: null,
});
return;
}
setAttributes({
chapterImageUrl: media.url,
chapterImageId: media.id,
chapterImageAlt: media?.alt,
});
}
function removeImageAttributes() {
setAttributes({
chapterImageUrl: null,
chapterImageId: null,
chapterImageAlt: null,
});
}
return (
<>