Skip to content

Commit

Permalink
Add docblock to PostTitle and PostTitleRaw component (WordPress#61740)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
2 people authored and patil-vipul committed Jun 17, 2024
1 parent c1721e3 commit 1665254
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 2 deletions.
11 changes: 10 additions & 1 deletion packages/editor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 8 additions & 1 deletion packages/editor/src/components/post-title/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* External dependencies
*/
import clsx from 'clsx';

/**
* WordPress dependencies
*/
Expand Down Expand Up @@ -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 );
8 changes: 8 additions & 0 deletions packages/editor/src/components/post-title/post-title-raw.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
5 changes: 5 additions & 0 deletions packages/editor/src/components/post-title/use-post-title.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) => {
Expand Down

0 comments on commit 1665254

Please sign in to comment.