Skip to content

Commit

Permalink
Documentation: PostPreviewButton editor component (#62036)
Browse files Browse the repository at this point in the history
* Add JSDocs for PostPreviewButton editor component

* Auto-generate editor docs for PostPreviewButton component add

* Refine PostPreviewButton editor component JSDocs

* Auto-generate editor docs for PostPreviewButton updates
  • Loading branch information
colorful-tones authored May 30, 2024
1 parent cbae9e9 commit 9c5897f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
15 changes: 14 additions & 1 deletion packages/editor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1138,7 +1138,20 @@ Renders a control for enabling or disabling pingbacks and trackbacks in a WordPr

### PostPreviewButton

Undocumented declaration.
Renders a button that opens a new window or tab for the preview, writes the interstitial message to this window, and then navigates to the actual preview link. The button is not rendered if the post is not viewable and disabled if the post is not saveable.

_Parameters_

- _props_ `Object`: The component props.
- _props.className_ `string`: The class name for the button.
- _props.textContent_ `string`: The text content for the button.
- _props.forceIsAutosaveable_ `boolean`: Whether to force autosave.
- _props.role_ `string`: The role attribute for the button.
- _props.onPreview_ `Function`: The callback function for preview event.

_Returns_

- `JSX.Element|null`: The rendered button component.

### PostPublishButton

Expand Down
15 changes: 15 additions & 0 deletions packages/editor/src/components/post-preview-button/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,21 @@ function writeInterstitialMessage( targetDocument ) {
targetDocument.close();
}

/**
* Renders a button that opens a new window or tab for the preview,
* writes the interstitial message to this window, and then navigates
* to the actual preview link. The button is not rendered if the post
* is not viewable and disabled if the post is not saveable.
*
* @param {Object} props The component props.
* @param {string} props.className The class name for the button.
* @param {string} props.textContent The text content for the button.
* @param {boolean} props.forceIsAutosaveable Whether to force autosave.
* @param {string} props.role The role attribute for the button.
* @param {Function} props.onPreview The callback function for preview event.
*
* @return {JSX.Element|null} The rendered button component.
*/
export default function PostPreviewButton( {
className,
textContent,
Expand Down

0 comments on commit 9c5897f

Please sign in to comment.