From 043153d3561d1ccf5848b4229eda92bc9c130b58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?So=CC=88ren=20Wrede?= Date: Mon, 24 Jun 2019 17:54:44 +0200 Subject: [PATCH 1/2] Add `Content copied` message --- .../plugins/copy-content-menu-item/index.js | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/packages/edit-post/src/plugins/copy-content-menu-item/index.js b/packages/edit-post/src/plugins/copy-content-menu-item/index.js index 06c83f73d1077..16b21921441db 100644 --- a/packages/edit-post/src/plugins/copy-content-menu-item/index.js +++ b/packages/edit-post/src/plugins/copy-content-menu-item/index.js @@ -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 ( setState( { hasCopied: true } ) } + onCopy={ () => { + setState( { hasCopied: true } ); + createNotice( + 'info', + 'Content copied.', + { + isDismissible: true, + type: 'snackbar', + } + ); + } } onFinishCopy={ () => setState( { hasCopied: false } ) } > { hasCopied ? @@ -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 ); From d849279d213b32e2c8c3ecb2d83eb8c323243624 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?So=CC=88ren=20Wrede?= Date: Mon, 24 Jun 2019 22:57:42 +0200 Subject: [PATCH 2/2] Update message --- packages/edit-post/src/plugins/copy-content-menu-item/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/edit-post/src/plugins/copy-content-menu-item/index.js b/packages/edit-post/src/plugins/copy-content-menu-item/index.js index 16b21921441db..af93ecb542ba6 100644 --- a/packages/edit-post/src/plugins/copy-content-menu-item/index.js +++ b/packages/edit-post/src/plugins/copy-content-menu-item/index.js @@ -16,7 +16,7 @@ function CopyContentMenuItem( { createNotice, editedPostContent, hasCopied, setS setState( { hasCopied: true } ); createNotice( 'info', - 'Content copied.', + 'All content copied.', { isDismissible: true, type: 'snackbar',