Skip to content
9 changes: 9 additions & 0 deletions packages/block-editor/src/components/block-tools/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import usePopoverScroll from '../block-popover/use-popover-scroll';
import ZoomOutModeInserters from './zoom-out-mode-inserters';
import { useShowBlockTools } from './use-show-block-tools';
import { unlock } from '../../lock-unlock';
import usePasteStyles from '../use-paste-styles';

function selector( select ) {
const {
Expand Down Expand Up @@ -74,6 +75,7 @@ export default function BlockTools( {
const { getGroupingBlockName } = useSelect( blocksStore );
const { showEmptyBlockSideInserter, showBlockToolbarPopover } =
useShowBlockTools();
const pasteStyles = usePasteStyles();

const {
duplicateBlocks,
Expand Down Expand Up @@ -134,6 +136,13 @@ export default function BlockTools( {
event.preventDefault();
removeBlocks( clientIds );
}
} else if ( isMatch( 'core/block-editor/paste-styles', event ) ) {
const clientIds = getSelectedBlockClientIds();
if ( clientIds.length ) {
event.preventDefault();
const blocks = getBlocksByClientId( clientIds );
pasteStyles( blocks );
}
} else if ( isMatch( 'core/block-editor/insert-after', event ) ) {
const clientIds = getSelectedBlockClientIds();
if ( clientIds.length ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,18 @@ function KeyboardShortcutsRegister() {
},
} );

registerShortcut( {
name: 'core/block-editor/paste-styles',
category: 'block',
description: __(
'Paste the copied style to the selected block(s).'
),
keyCombination: {
modifier: 'primaryAlt',
character: 'v',
},
} );

registerShortcut( {
name: 'core/block-editor/insert-before',
category: 'block',
Expand Down
10 changes: 10 additions & 0 deletions packages/block-editor/src/components/list-view/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import useBlockDisplayInformation from '../use-block-display-information';
import { useBlockLock } from '../block-lock';
import AriaReferencedText from './aria-referenced-text';
import { unlock } from '../../lock-unlock';
import usePasteStyles from '../use-paste-styles';

function ListViewBlock( {
block: { clientId },
Expand Down Expand Up @@ -112,6 +113,8 @@ function ListViewBlock( {

const blockInformation = useBlockDisplayInformation( clientId );

const pasteStyles = usePasteStyles();

const { block, blockName, allowRightClickOverrides } = useSelect(
( select ) => {
const { getBlock, getBlockName, getSettings } =
Expand Down Expand Up @@ -233,6 +236,13 @@ function ListViewBlock( {
}

updateFocusAndSelection( blockToFocus, shouldUpdateSelection );
} else if ( isMatch( 'core/block-editor/paste-styles', event ) ) {
event.preventDefault();

const { blocksToUpdate } = getBlocksToUpdate();
const blocks = getBlocksByClientId( blocksToUpdate );

pasteStyles( blocks );
} else if ( isMatch( 'core/block-editor/duplicate', event ) ) {
event.preventDefault();

Expand Down
Loading