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:

1
import React from 'react';
2
import ReactDOM from 'react-dom';
3
import { connect, RenderItemFormOutletCtx } from 'datocms-plugin-sdk';
4
5
connect({
6
itemFormOutlets(model, ctx) {
7
return [{ id: 'myOutlet' }];
8
},
9
renderItemFormOutlet(outletId, ctx) {
10
const {
11
blocksAnalysis: {
12
usage: {
13
/** Total number of blocks present in form state */
14
total,
15
/** Total number of blocks present in non-localized fields */
16
nonLocalized,
17
/** Total number of blocks present in localized fields, per locale */
18
perLocale,
19
},
20
/** Maximum number of blocks per item */
21
maximumPerItem,
22
},
23
} = ctx;
24
25
// render the outlet here
26
},
27
});
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