new text editor block that contains core blocks as inner blocks and prevents them from being used at top level
This commit is contained in:
12
resources/js/lib/isInsideBlock.js
Normal file
12
resources/js/lib/isInsideBlock.js
Normal file
@@ -0,0 +1,12 @@
|
||||
export default function isInsideMyACFBlock(blockName)
|
||||
{
|
||||
const editor = wp.data.select('core/block-editor');
|
||||
const selectedId = editor.getSelectedBlockClientId();
|
||||
|
||||
if (!selectedId) return false;
|
||||
|
||||
const parents = editor.getBlockParents(selectedId);
|
||||
const parentNames = parents.map(id => editor.getBlockName(id));
|
||||
|
||||
return parentNames.includes(blockName);
|
||||
}
|
||||
Reference in New Issue
Block a user