diff --git a/blocks/_components/Image.jsx b/blocks/_components/Image.jsx new file mode 100644 index 0000000..dfd041e --- /dev/null +++ b/blocks/_components/Image.jsx @@ -0,0 +1,9 @@ +export default function Image({ imageUrl, imageAlt, imageProportion }) { + return ( + {imageAlt} + ); +} diff --git a/blocks/_components/ImageMediaPlaceholder.jsx b/blocks/_components/ImageMediaPlaceholder.jsx new file mode 100644 index 0000000..21e8f78 --- /dev/null +++ b/blocks/_components/ImageMediaPlaceholder.jsx @@ -0,0 +1,33 @@ +import { MediaReplaceFlow, MediaPlaceholder } from "@wordpress/block-editor"; + +export default function ImageMediaPlaceholder({ imageId, imageAlt, imageUrl, setAttributes }) { + function setImageAttributes(image) { + setAttributes({ + imageId: image.id, + imageAlt: image.alt, + imageUrl: image.url, + }); + } + + function removeImageAttributes() { + console.log("removeImageAttributes"); + setAttributes({ + imageId: null, + imageAlt: null, + imageUrl: null, + }); + } + return ( + <> + {!imageUrl && ( + + )} + + ); +} diff --git a/blocks/_components/ImagePanelBody.jsx b/blocks/_components/ImagePanelBody.jsx new file mode 100644 index 0000000..20b92c0 --- /dev/null +++ b/blocks/_components/ImagePanelBody.jsx @@ -0,0 +1,98 @@ +import { __ } from "@wordpress/i18n"; +import { + PanelBody, + Button, + Tip, + __experimentalToggleGroupControl as ToggleGroupControl, + __experimentalToggleGroupControlOption as ToggleGroupControlOption, +} from "@wordpress/components"; +import { MediaReplaceFlow, MediaPlaceholder } from "@wordpress/block-editor"; +import { trash } from "@wordpress/icons"; + +export default function ImagePanelBody({ imageUrl, imageAlt, imageId, imageProportion, setAttributes }) { + function setImageAttributes(image) { + setAttributes({ + imageId: image.id, + imageAlt: image.alt, + imageUrl: image.url, + }); + } + + function removeImageAttributes() { + setAttributes({ + imageId: null, + imageAlt: null, + imageUrl: null, + }); + } + function onImageProportionChange(imageProportion) { + console.log(imageProportion); + setAttributes({ imageProportion }); + } + return ( + <> + + {imageUrl && {imageAlt}} +
+ + {imageUrl && ( + <> +
+ + Si besoin, Utilisez le champ "Légende"de la médiathèque pour afficher un + copyright + + + Si besoin, Utilisez le champ "Description" de la médiathèque pour donner + afficher une description de votre image + + {imageUrl && ( + + + + + + )} +
+ + ); +} diff --git a/blocks/_components/ImageUtils.jsx b/blocks/_components/ImageUtils.jsx new file mode 100644 index 0000000..b02fb78 --- /dev/null +++ b/blocks/_components/ImageUtils.jsx @@ -0,0 +1,16 @@ +export function setImageAttributes(image) { + setAttributes({ + imageId: image.id, + imageAlt: image.alt, + imageUrl: image.url, + }); +} + +export function removeImageAttributes() { + console.log("removeImageAttributes"); + setAttributes({ + imageId: null, + imageAlt: null, + imageUrl: null, + }); +} diff --git a/blocks/_components/editor.css b/blocks/_components/editor.css new file mode 100644 index 0000000..e69de29