-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ellipsis: Add button to copy entire document
* Scrap `copyAll` shenanigan, use ClipboardButton * ClipboardButton: Accept additional onFinishCopy callback * Add component EditorActions below ModeSwitcher * Don't close menu on copy, show "Copied!" instead * MenuItems: Make it more reusable * Allow passing extra `classNames` to MenuItemsGroup, don't require a `label` * Change classes in MenuItemsToggle from `components-menu-items__toggle` to `components-menu-items__button is-toggle` * EllipsisMenu: Adopt areas Editor, Settings, Tools
- Loading branch information
Showing
9 changed files
with
122 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { connect } from 'react-redux'; | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { ClipboardButton } from '@wordpress/components'; | ||
import { Component } from '@wordpress/element'; | ||
import { __ } from '@wordpress/i18n'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { getEditedPostContent } from '../../../store/selectors'; | ||
|
||
class CopyContentButton extends Component { | ||
constructor() { | ||
super( ...arguments ); | ||
this.state = { hasCopied: false }; | ||
this.onCopy = this.onCopy.bind( this ); | ||
this.onFinishCopy = this.onFinishCopy.bind( this ); | ||
} | ||
onCopy() { | ||
this.setState( { hasCopied: true } ); | ||
} | ||
onFinishCopy() { | ||
this.setState( { hasCopied: false } ); | ||
} | ||
render() { | ||
return ( | ||
<ClipboardButton | ||
text={ this.props.editedPostContent } | ||
className="components-menu-items__button" | ||
onCopy={ this.onCopy } | ||
onFinishCopy={ this.onFinishCopy } | ||
> | ||
{ this.state.hasCopied ? | ||
__( 'Copied!' ) : | ||
__( 'Copy All Content' ) } | ||
</ClipboardButton> | ||
); | ||
} | ||
} | ||
|
||
export default connect( | ||
( state ) => ( { | ||
editedPostContent: getEditedPostContent( state ), | ||
} ) | ||
)( CopyContentButton ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { MenuItemsGroup } from '@wordpress/components'; | ||
import { __ } from '@wordpress/i18n'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import CopyContentButton from '../copy-content-button'; | ||
|
||
export default function EditorActions() { | ||
return ( | ||
<MenuItemsGroup className="editor-actions" | ||
label={ __( 'Tools' ) } | ||
> | ||
<CopyContentButton /> | ||
</MenuItemsGroup> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters