From 1665254d8845c7b4bb14875037829c36f381b130 Mon Sep 17 00:00:00 2001 From: sanjucta Date: Wed, 22 May 2024 03:21:59 +0530 Subject: [PATCH] Add docblock to PostTitle and PostTitleRaw component (#61740) * Add docblock to PostTitle component * Refine PostTitle component JSDocs * Add PostTitleRaw component JSDocs * Add usePostTitle JSDocs * Add usePostTitleFocus JSDocs * Auto-generate editor docs for PostTitle updates --------- Co-authored-by: Damon Cook --- packages/editor/README.md | 11 ++++++++++- packages/editor/src/components/post-title/index.js | 9 ++++++++- .../src/components/post-title/post-title-raw.js | 8 ++++++++ .../src/components/post-title/use-post-title-focus.js | 7 +++++++ .../src/components/post-title/use-post-title.js | 5 +++++ 5 files changed, 38 insertions(+), 2 deletions(-) diff --git a/packages/editor/README.md b/packages/editor/README.md index 2997ac0c2d420a..341cda77474e0d 100644 --- a/packages/editor/README.md +++ b/packages/editor/README.md @@ -1177,7 +1177,16 @@ Undocumented declaration. ### PostTitle -Undocumented declaration. +Renders the `PostTitle` component. + +_Parameters_ + +- \_\_\_ `Object`: Unused parameter. +- _forwardedRef_ `Element`: Forwarded ref for the component. + +_Returns_ + +- `Component`: The rendered PostTitle component. ### PostTitleRaw diff --git a/packages/editor/src/components/post-title/index.js b/packages/editor/src/components/post-title/index.js index b307b2467b869b..57ab39f0061615 100644 --- a/packages/editor/src/components/post-title/index.js +++ b/packages/editor/src/components/post-title/index.js @@ -2,7 +2,6 @@ * External dependencies */ import clsx from 'clsx'; - /** * WordPress dependencies */ @@ -211,4 +210,12 @@ function PostTitle( _, forwardedRef ) { ); } +/** + * Renders the `PostTitle` component. + * + * @param {Object} _ Unused parameter. + * @param {Element} forwardedRef Forwarded ref for the component. + * + * @return {Component} The rendered PostTitle component. + */ export default forwardRef( PostTitle ); diff --git a/packages/editor/src/components/post-title/post-title-raw.js b/packages/editor/src/components/post-title/post-title-raw.js index a9510bc136c231..a4c9713a094925 100644 --- a/packages/editor/src/components/post-title/post-title-raw.js +++ b/packages/editor/src/components/post-title/post-title-raw.js @@ -20,6 +20,14 @@ import { DEFAULT_CLASSNAMES, REGEXP_NEWLINES } from './constants'; import usePostTitleFocus from './use-post-title-focus'; import usePostTitle from './use-post-title'; +/** + * Renders a raw post title input field. + * + * @param {Object} _ Unused parameter. + * @param {Element} forwardedRef Reference to the component's DOM node. + * + * @return {Component} The rendered component. + */ function PostTitleRaw( _, forwardedRef ) { const { placeholder, hasFixedToolbar } = useSelect( ( select ) => { const { getSettings } = select( blockEditorStore ); diff --git a/packages/editor/src/components/post-title/use-post-title-focus.js b/packages/editor/src/components/post-title/use-post-title-focus.js index effac53f2670a2..127b7661462ba9 100644 --- a/packages/editor/src/components/post-title/use-post-title-focus.js +++ b/packages/editor/src/components/post-title/use-post-title-focus.js @@ -9,6 +9,13 @@ import { useSelect } from '@wordpress/data'; */ import { store as editorStore } from '../../store'; +/** + * Custom hook that manages the focus behavior of the post title input field. + * + * @param {Element} forwardedRef - The forwarded ref for the input field. + * + * @return {Object} - The ref object. + */ export default function usePostTitleFocus( forwardedRef ) { const ref = useRef(); diff --git a/packages/editor/src/components/post-title/use-post-title.js b/packages/editor/src/components/post-title/use-post-title.js index 65bd67af6fb4c8..d335064a523549 100644 --- a/packages/editor/src/components/post-title/use-post-title.js +++ b/packages/editor/src/components/post-title/use-post-title.js @@ -7,6 +7,11 @@ import { useSelect, useDispatch } from '@wordpress/data'; */ import { store as editorStore } from '../../store'; +/** + * Custom hook for managing the post title in the editor. + * + * @return {Object} An object containing the current title and a function to update the title. + */ export default function usePostTitle() { const { editPost } = useDispatch( editorStore ); const { title } = useSelect( ( select ) => {