diff --git a/packages/block-editor/CHANGELOG.md b/packages/block-editor/CHANGELOG.md index 5c4cae61450ac4..4306b855955f52 100644 --- a/packages/block-editor/CHANGELOG.md +++ b/packages/block-editor/CHANGELOG.md @@ -1,3 +1,9 @@ +## 2.0.0 (Unreleased) + +### Breaking Changes + +- `CopyHandler` will now only catch cut/copy events coming from its `props.children`, instead of from anywhere in the `document`. + ## 1.0.0 (2019-03-06) ### New Features diff --git a/packages/block-editor/src/components/copy-handler/index.js b/packages/block-editor/src/components/copy-handler/index.js index 3942eaae71b034..3f73d5f672c153 100644 --- a/packages/block-editor/src/components/copy-handler/index.js +++ b/packages/block-editor/src/components/copy-handler/index.js @@ -1,33 +1,17 @@ /** * WordPress dependencies */ -import { Component } from '@wordpress/element'; import { serialize } from '@wordpress/blocks'; import { documentHasSelection } from '@wordpress/dom'; import { withDispatch } from '@wordpress/data'; import { compose } from '@wordpress/compose'; -class CopyHandler extends Component { - constructor() { - super( ...arguments ); - - this.onCopy = ( event ) => this.props.onCopy( event ); - this.onCut = ( event ) => this.props.onCut( event ); - } - - componentDidMount() { - document.addEventListener( 'copy', this.onCopy ); - document.addEventListener( 'cut', this.onCut ); - } - - componentWillUnmount() { - document.removeEventListener( 'copy', this.onCopy ); - document.removeEventListener( 'cut', this.onCut ); - } - - render() { - return null; - } +function CopyHandler( { children, onCopy, onCut } ) { + return ( +