diff --git a/components/post-meta/index.tsx b/components/post-meta/index.tsx index fdec1f2a..2bd7eea8 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. */ @@ -15,6 +18,11 @@ interface MetaStringProps const MetaString: React.FC = (props) => { const { metaKey, tagName = 'p' } = props; const [metaValue, setMetaValue] = usePostMetaValue(metaKey); + const { isEditable } = usePost(); + + if (!isEditable) { + return ; + } return ( = (props) => { const { metaKey } = props; const [metaValue, setMetaValue] = usePostMetaValue(metaKey); + const { isEditable } = usePost(); return ( setMetaValue(parseInt(value ?? '', 10))} + disabled={!isEditable} {...props} /> ); @@ -56,8 +66,16 @@ interface MetaBooleanProps extends Pick { const MetaBoolean: React.FC = (props) => { const { metaKey } = props; const [metaValue, setMetaValue] = usePostMetaValue(metaKey); + const { isEditable } = usePost(); - return ; + return ( + + ); }; interface PostMetaProps {