UNPKG

1.07 kBJavaScriptView Raw
1import { createElement } from "@wordpress/element";
2
3/**
4 * WordPress dependencies
5 */
6import { ClipboardButton } from '@wordpress/components';
7import { withSelect } from '@wordpress/data';
8import { __ } from '@wordpress/i18n';
9import { withState, compose } from '@wordpress/compose';
10
11function 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
31export default compose(withSelect(function (select) {
32 return {
33 editedPostContent: select('core/editor').getEditedPostAttribute('content')
34 };
35}), withState({
36 hasCopied: false
37}))(CopyContentMenuItem);
38//# sourceMappingURL=index.js.map
\No newline at end of file