From 2012ae84396ffb0d96829830d36483365555a733 Mon Sep 17 00:00:00 2001 From: Mario Santos Date: Wed, 29 May 2024 17:48:19 +0200 Subject: [PATCH] Add a warning when pasting blocks --- packages/block-editor/src/store/actions.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages/block-editor/src/store/actions.js b/packages/block-editor/src/store/actions.js index 6bb4eddd083c82..e289011ab6ebce 100644 --- a/packages/block-editor/src/store/actions.js +++ b/packages/block-editor/src/store/actions.js @@ -18,6 +18,7 @@ import { } from '@wordpress/blocks'; import { speak } from '@wordpress/a11y'; import { __, _n, sprintf } from '@wordpress/i18n'; +import { store as noticesStore } from '@wordpress/notices'; import { create, insert, remove, toHTMLString } from '@wordpress/rich-text'; import deprecated from '@wordpress/deprecated'; @@ -879,6 +880,20 @@ export const __unstableSplitSelection = // If the attribute is bound, don't split the selection and insert a new block instead. if ( bindings?.[ attributeKeyA ] ) { + // Show warning if user tries to insert a block into another block with bindings. + if ( blocks.length ) { + const { createWarningNotice } = + registry.dispatch( noticesStore ); + createWarningNotice( + __( + "Blocks can't be inserted into other blocks with bindings" + ), + { + type: 'snackbar', + } + ); + return; + } dispatch.insertAfterBlock( selectionA.clientId ); return; }