Skip to content

Commit 2012ae8

Browse files
Add a warning when pasting blocks
1 parent c537acb commit 2012ae8

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

packages/block-editor/src/store/actions.js

+15
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
} from '@wordpress/blocks';
1919
import { speak } from '@wordpress/a11y';
2020
import { __, _n, sprintf } from '@wordpress/i18n';
21+
import { store as noticesStore } from '@wordpress/notices';
2122
import { create, insert, remove, toHTMLString } from '@wordpress/rich-text';
2223
import deprecated from '@wordpress/deprecated';
2324

@@ -879,6 +880,20 @@ export const __unstableSplitSelection =
879880

880881
// If the attribute is bound, don't split the selection and insert a new block instead.
881882
if ( bindings?.[ attributeKeyA ] ) {
883+
// Show warning if user tries to insert a block into another block with bindings.
884+
if ( blocks.length ) {
885+
const { createWarningNotice } =
886+
registry.dispatch( noticesStore );
887+
createWarningNotice(
888+
__(
889+
"Blocks can't be inserted into other blocks with bindings"
890+
),
891+
{
892+
type: 'snackbar',
893+
}
894+
);
895+
return;
896+
}
882897
dispatch.insertAfterBlock( selectionA.clientId );
883898
return;
884899
}

0 commit comments

Comments
 (0)