1 | import { createElement } from "@wordpress/element";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | import { ClipboardButton } from '@wordpress/components';
|
7 | import { withSelect } from '@wordpress/data';
|
8 | import { __ } from '@wordpress/i18n';
|
9 | import { withState, compose } from '@wordpress/compose';
|
10 |
|
11 | function CopyContentMenuItem(_ref) {
|
12 | var editedPostContent = _ref.editedPostContent,
|
13 | hasCopied = _ref.hasCopied,
|
14 | setState = _ref.setState;
|
15 | return createElement(ClipboardButton, {
|
16 | text: editedPostContent,
|
17 | className: "components-menu-item__button",
|
18 | onCopy: function onCopy() {
|
19 | return setState({
|
20 | hasCopied: true
|
21 | });
|
22 | },
|
23 | onFinishCopy: function onFinishCopy() {
|
24 | return setState({
|
25 | hasCopied: false
|
26 | });
|
27 | }
|
28 | }, hasCopied ? __('Copied!') : __('Copy All Content'));
|
29 | }
|
30 |
|
31 | export default compose(withSelect(function (select) {
|
32 | return {
|
33 | editedPostContent: select('core/editor').getEditedPostAttribute('content')
|
34 | };
|
35 | }), withState({
|
36 | hasCopied: false
|
37 | }))(CopyContentMenuItem);
|
38 |
|
\ | No newline at end of file |