Skip to content

Right-Click: Add options to cut/copy/paste blocks #2989

@swissspidy

Description

@swissspidy

As outlined in #2785, let's extend the block settings menu to offer cut + copy options, where the block content is added to the clipboard.

Cases where Gutenberg is adding blocks to the clipboard:

https://github.com/WordPress/gutenberg/blob/b95e865de32ee62d722be3e3e71b334a4b639032/packages/block-editor/src/components/copy-handler/index.js#L26-L57

https://github.com/WordPress/gutenberg/blob/b95e865de32ee62d722be3e3e71b334a4b639032/packages/components/src/clipboard-button/index.js#L27-L67

Pasting would be handled by the RichText component which we use in all the text-based blocks and has some complex logic for handling the clipboard data properly:

https://github.com/WordPress/gutenberg/blob/03121c5e59c63d4c79a293f71bbb7b9613fd311c/packages/rich-text/src/component/index.js#L187-L260

We probably need to copy most of that component's logic.

Metadata

Metadata

Assignees

Labels

EnhancementNew feature or improvement of an existing one

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions