Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const initialBlocks = useMemo( () => {
if ( status !== 'publish' ) {
// Publish if still an auto-draft.
setStatus( 'publish' );
}
if ( typeof content !== 'function' ) {
const parsedContent = parse( content );
return parsedContent.length ? parsedContent : undefined;
}
}, [] );
const [ blocks = initialBlocks, setBlocks ] = useEntityProp(
'postType',
'wp_template_part',
'blocks'
);
const [ isDirty, isSaving, save ] = __experimentalUseEntitySaving(
'postType',
'wp_template_part',
saveProps
);
const saveContent = useCallback( () => {
_setContent( content( { blocks } ) );
save();
}, [ content, blocks ] );
const setContent = useCallback( () => {
_setContent( ( { blocks: blocksForSerialization = [] } ) =>
serializeBlocks( blocksForSerialization )
);
}, [] );
return (
<>
function SiteDescriptionEdit( {
attributes,
backgroundColor,
className,
fontSize,
insertDefaultBlock,
setAttributes,
setBackgroundColor,
setFontSize,
setTextColor,
textColor,
} ) {
const [ description, setDescription ] = useEntityProp( 'root', 'site', 'description' );
const [ isDirty, isSaving, save ] = __experimentalUseEntitySaving(
'root',
'site',
'description'
);
const { customFontSize, textAlign } = attributes;
const actualFontSize = customFontSize || fontSize.size;
const preventNewlines = ( event ) => {
if ( event.keyCode === ENTER ) {
event.preventDefault();
insertDefaultBlock();
}
};
return (
export default function PostTitleEdit() {
const [ title, setTitle ] = useEntityProp( 'postType', 'post', 'title' );
const [ , setSlug ] = useEntityProp( 'postType', 'post', 'slug' );
const [ isDirty, isSaving, save ] = __experimentalUseEntitySaving(
'postType',
'post',
saveProps
);
return (
<>
<button title="" disabled="{">
{ __( 'Update' ) }
</button>