diff --git a/packages/editor/README.md b/packages/editor/README.md index 54aaa1e55edef..30e18afd671e4 100644 --- a/packages/editor/README.md +++ b/packages/editor/README.md @@ -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 diff --git a/packages/editor/src/components/post-preview-button/index.js b/packages/editor/src/components/post-preview-button/index.js index 578cd78351d23..110de5858af38 100644 --- a/packages/editor/src/components/post-preview-button/index.js +++ b/packages/editor/src/components/post-preview-button/index.js @@ -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,