diff --git a/api/register-block-extension/index.tsx b/api/register-block-extension/index.tsx index 32766464..0c82a4e9 100644 --- a/api/register-block-extension/index.tsx +++ b/api/register-block-extension/index.tsx @@ -49,6 +49,10 @@ function registerBlockExtension( return blockType === blockName; }; + if (blockName === '*') { + blockName = 'all'; + } + const blockNamespace = isMultiBlock ? blockName.join('-') : blockName; const addAttributesToBlock = (settings: Record, name: string) => { diff --git a/components/post-meta/index.tsx b/components/post-meta/index.tsx index fdec1f2a..2c954b81 100644 --- a/components/post-meta/index.tsx +++ b/components/post-meta/index.tsx @@ -1,11 +1,14 @@ import { RichText } from '@wordpress/block-editor'; import { __experimentalNumberControl as NumberControl, ToggleControl } from '@wordpress/components'; import type { ToggleControlProps } from '@wordpress/components/src/toggle-control/types'; -import { usePostMetaValue, useIsSupportedMetaField } from '../../hooks'; +import { usePostMetaValue, useIsSupportedMetaField, usePost } from '../../hooks'; import { toSentence } from './utilities'; interface MetaStringProps - extends Omit, 'value' | 'onChange'> { + extends Omit< + React.ComponentPropsWithoutRef, + 'value' | 'onChange' | 'multiline' + > { /** * The meta key to use. */ @@ -13,15 +16,20 @@ interface MetaStringProps } const MetaString: React.FC = (props) => { - const { metaKey, tagName = 'p' } = props; + const { metaKey, tagName = 'p', ...rest } = props; const [metaValue, setMetaValue] = usePostMetaValue(metaKey); + const { isEditable } = usePost(); + + if (!isEditable) { + return ; + } return ( setMetaValue(value)} tagName={tagName} - {...props} + {...rest} /> ); }; @@ -34,14 +42,16 @@ interface MetaNumberProps { } const MetaNumber: React.FC = (props) => { - const { metaKey } = props; + const { metaKey, ...rest } = props; const [metaValue, setMetaValue] = usePostMetaValue(metaKey); + const { isEditable } = usePost(); return ( setMetaValue(parseInt(value ?? '', 10))} - {...props} + disabled={!isEditable} + {...rest} /> ); }; @@ -54,10 +64,18 @@ interface MetaBooleanProps extends Pick { } const MetaBoolean: React.FC = (props) => { - const { metaKey } = props; + const { metaKey, ...rest } = props; const [metaValue, setMetaValue] = usePostMetaValue(metaKey); + const { isEditable } = usePost(); - return ; + return ( + + ); }; interface PostMetaProps {