diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000000000..d1987c7ba053b --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,13 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations. + // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp + + // List of extensions which should be recommended for users of this workspace. + "recommendations": [ + + ], + // List of extensions recommended by VS Code that should not be recommended for users of this workspace. + "unwantedRecommendations": [ + + ] +} \ No newline at end of file diff --git a/packages/block-library/src/block/edit.js b/packages/block-library/src/block/edit.js index 966654c87a3dc..bdfe2c55d043b 100644 --- a/packages/block-library/src/block/edit.js +++ b/packages/block-library/src/block/edit.js @@ -14,8 +14,10 @@ import { ToolbarButton, TextControl, PanelBody, + Disabled, } from '@wordpress/components'; import { __ } from '@wordpress/i18n'; +import { useState, useEffect } from '@wordpress/element'; import { __experimentalUseInnerBlocksProps as useInnerBlocksProps, __experimentalUseNoRecursiveRenders as useNoRecursiveRenders, @@ -24,6 +26,7 @@ import { InspectorControls, useBlockProps, Warning, + store as blockEditorStore, } from '@wordpress/block-editor'; import { store as reusableBlocksStore } from '@wordpress/reusable-blocks'; import { ungroup } from '@wordpress/icons'; @@ -32,7 +35,12 @@ export default function ReusableBlockEdit( { attributes: { ref }, clientId } ) { const [ hasAlreadyRendered, RecursionProvider ] = useNoRecursiveRenders( ref ); - const { isMissing, hasResolved } = useSelect( + const { + isMissing, + hasResolved, + parentBlockName, + selectedBlock, + } = useSelect( ( select ) => { const persistedBlock = select( coreStore ).getEntityRecord( 'postType', @@ -46,9 +54,23 @@ export default function ReusableBlockEdit( { attributes: { ref }, clientId } ) { 'wp_block', ref, ] ); + + const { + getSelectedBlockClientId, + getBlockName, + getBlockParents, + } = select( blockEditorStore ); + + const currentBlockId = getSelectedBlockClientId(); + const parents = getBlockParents( currentBlockId ); + const _firstParentClientId = parents[ parents.length - 1 ]; + const _parentBlockName = getBlockName( _firstParentClientId ); + return { hasResolved: hasResolvedBlock, isMissing: hasResolvedBlock && ! persistedBlock, + parentBlockName: _parentBlockName, + selectedBlock: currentBlockId, }; }, [ ref, clientId ] @@ -84,6 +106,24 @@ export default function ReusableBlockEdit( { attributes: { ref }, clientId } ) { const blockProps = useBlockProps(); + // state for lock + const [ isLocked, setIsLocked ] = useState( true ); + + let innerBlocks =
; + if ( isLocked ) { + innerBlocks =