Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/block-editor/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
28 changes: 6 additions & 22 deletions packages/block-editor/src/components/copy-handler/index.js
Original file line number Diff line number Diff line change
@@ -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 (
<div onCopy={ onCopy } onCut={ onCut }>
{ children }
</div>
);
}

export default compose( [
Expand Down
4 changes: 3 additions & 1 deletion packages/edit-post/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
* Expose the `className` property to style the `PluginSidebar` component.

### Bug Fixes
- Fix 'save' keyboard shortcut not functioning in the Code Editor.

- Fix 'save' keyboard shortcut not functioning in the Code Editor.
- Prevent `ClipboardButton` from incorrectly copying a serialized block string instead of the intended text in Safari.

## 3.1.7 (2019-01-03)

Expand Down
7 changes: 4 additions & 3 deletions packages/edit-post/src/components/visual-editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@ function VisualEditor() {
return (
<BlockSelectionClearer className="edit-post-visual-editor editor-styles-wrapper">
<VisualEditorGlobalKeyboardShortcuts />
<CopyHandler />
<MultiSelectScrollIntoView />
<WritingFlow>
<ObserveTyping>
<PostTitle />
<BlockList />
<CopyHandler>
<PostTitle />
<BlockList />
</CopyHandler>
</ObserveTyping>
</WritingFlow>
<_BlockSettingsMenuFirstItem>
Expand Down