Skip to content

Commit

Permalink
Snackbar notification for "Copy All Content (#16265)
Browse files Browse the repository at this point in the history
* Add `Content copied` message

* Update message
  • Loading branch information
Soean committed Jun 25, 2019
1 parent 91163be commit 736adf3
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions packages/edit-post/src/plugins/copy-content-menu-item/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,27 @@
* WordPress dependencies
*/
import { ClipboardButton } from '@wordpress/components';
import { withSelect } from '@wordpress/data';
import { withDispatch, withSelect } from '@wordpress/data';
import { __ } from '@wordpress/i18n';
import { withState, compose } from '@wordpress/compose';

function CopyContentMenuItem( { editedPostContent, hasCopied, setState } ) {
function CopyContentMenuItem( { createNotice, editedPostContent, hasCopied, setState } ) {
return (
<ClipboardButton
text={ editedPostContent }
role="menuitem"
className="components-menu-item__button"
onCopy={ () => setState( { hasCopied: true } ) }
onCopy={ () => {
setState( { hasCopied: true } );
createNotice(
'info',
'All content copied.',
{
isDismissible: true,
type: 'snackbar',
}
);
} }
onFinishCopy={ () => setState( { hasCopied: false } ) }
>
{ hasCopied ?
Expand All @@ -26,5 +36,14 @@ export default compose(
withSelect( ( select ) => ( {
editedPostContent: select( 'core/editor' ).getEditedPostAttribute( 'content' ),
} ) ),
withDispatch( ( dispatch ) => {
const {
createNotice,
} = dispatch( 'core/notices' );

return {
createNotice,
};
} ),
withState( { hasCopied: false } )
)( CopyContentMenuItem );

0 comments on commit 736adf3

Please sign in to comment.