Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation: PostPreviewButton editor component #62036

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion packages/editor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1117,7 +1117,20 @@ Undocumented declaration.

### 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
Loading