Product Updates

DatoCMS changelog for new features and general improvements
Plugins

Plugin SDK exposes blocks usage information

September 15th, 2022

A small addition to our Plugin SDK: it is now possible to retrieve the number of blocks currently used inside a record via the ctx.blocksAnalysis property.

The information is exposed in every hook related to records editing, namely Field extensions, Sidebar panels, and Form outlets:

import React from 'react';
import ReactDOM from 'react-dom';
import { connect, RenderItemFormOutletCtx } from 'datocms-plugin-sdk';
connect({
itemFormOutlets(model, ctx) {
return [{ id: 'myOutlet' }];
},
renderItemFormOutlet(outletId, ctx) {
const {
blocksAnalysis: {
usage: {
/** Total number of blocks present in form state */
total,
/** Total number of blocks present in non-localized fields */
nonLocalized,
/** Total number of blocks present in localized fields, per locale */
perLocale,
},
/** Maximum number of blocks per item */
maximumPerItem,
},
} = ctx;
// render the outlet here
},
});
Start using DatoCMS today
According to Gartner 89% of companies plan to compete primarily on the basis of customer experience this year. Don't get caught unprepared.
  • No credit card
  • Easy setup
Subscribe to our newsletter! 📥
One update per month. All the latest news and sneak peeks directly in your inbox.
support@datocms.com ©2024 Dato srl, all rights reserved P.IVA 06969620480