diff --git a/packages/editor/README.md b/packages/editor/README.md index 341cda77474e0d..91072345f10605 100644 --- a/packages/editor/README.md +++ b/packages/editor/README.md @@ -974,15 +974,49 @@ Undocumented declaration. ### PostFeaturedImage -Undocumented declaration. +Renders the component for managing the featured image of a post. + +_Parameters_ + +- _props_ `Object`: Props. +- _props.currentPostId_ `number`: ID of the current post. +- _props.featuredImageId_ `number`: ID of the featured image. +- _props.onUpdateImage_ `Function`: Function to call when the image is updated. +- _props.onRemoveImage_ `Function`: Function to call when the image is removed. +- _props.media_ `Object`: The media object representing the featured image. +- _props.postType_ `string`: Post type. +- _props.noticeUI_ `Element`: UI for displaying notices. +- _props.noticeOperations_ `Object`: Operations for managing notices. + +_Returns_ + +- `Element`: Component to be rendered . ### PostFeaturedImageCheck -Undocumented declaration. +Wrapper component that renders its children only if the post type supports a featured image and the theme supports post thumbnails. + +_Parameters_ + +- _props_ `Object`: Props. +- _props.children_ `Element`: Children to be rendered. + +_Returns_ + +- `Component`: The component to be rendered. ### PostFeaturedImagePanel -Undocumented declaration. +Renders the panel for the post featured image. + +_Parameters_ + +- _props_ `Object`: Props. +- _props.withPanelBody_ `boolean`: Whether to include the panel body. Default true. + +_Returns_ + +- `Component|null`: The component to be rendered. Return Null if the editor panel is disabled for featured image. ### PostFormat diff --git a/packages/editor/src/components/post-featured-image/check.js b/packages/editor/src/components/post-featured-image/check.js index 24a9f80058ddcc..823559f766bc35 100644 --- a/packages/editor/src/components/post-featured-image/check.js +++ b/packages/editor/src/components/post-featured-image/check.js @@ -4,6 +4,15 @@ import PostTypeSupportCheck from '../post-type-support-check'; import ThemeSupportCheck from '../theme-support-check'; +/** + * Wrapper component that renders its children only if the post type supports a featured image + * and the theme supports post thumbnails. + * + * @param {Object} props Props. + * @param {Element} props.children Children to be rendered. + * + * @return {Component} The component to be rendered. + */ function PostFeaturedImageCheck( { children } ) { return ( diff --git a/packages/editor/src/components/post-featured-image/index.js b/packages/editor/src/components/post-featured-image/index.js index 5407cac15b5422..63c89669435d5e 100644 --- a/packages/editor/src/components/post-featured-image/index.js +++ b/packages/editor/src/components/post-featured-image/index.js @@ -266,6 +266,21 @@ const applyWithDispatch = withDispatch( } ); +/** + * Renders the component for managing the featured image of a post. + * + * @param {Object} props Props. + * @param {number} props.currentPostId ID of the current post. + * @param {number} props.featuredImageId ID of the featured image. + * @param {Function} props.onUpdateImage Function to call when the image is updated. + * @param {Function} props.onRemoveImage Function to call when the image is removed. + * @param {Object} props.media The media object representing the featured image. + * @param {string} props.postType Post type. + * @param {Element} props.noticeUI UI for displaying notices. + * @param {Object} props.noticeOperations Operations for managing notices. + * + * @return {Element} Component to be rendered . + */ export default compose( withNotices, applyWithSelect, diff --git a/packages/editor/src/components/post-featured-image/panel.js b/packages/editor/src/components/post-featured-image/panel.js index 87d80dda4a7c1f..dd2a1527152ddf 100644 --- a/packages/editor/src/components/post-featured-image/panel.js +++ b/packages/editor/src/components/post-featured-image/panel.js @@ -15,6 +15,15 @@ import PostFeaturedImageCheck from './check'; const PANEL_NAME = 'featured-image'; +/** + * Renders the panel for the post featured image. + * + * @param {Object} props Props. + * @param {boolean} props.withPanelBody Whether to include the panel body. Default true. + * + * @return {Component|null} The component to be rendered. + * Return Null if the editor panel is disabled for featured image. + */ export default function PostFeaturedImagePanel( { withPanelBody = true } ) { const { postType, isEnabled, isOpened } = useSelect( ( select ) => { const {