尝试此操作,它会将芯垫块从设计更改为插入器中的介质类别:
function myprefixFilterSpacerCategory(settings, name) {
if (name === "core/spacer") {
// Object.assign can also be used instead of lodash.assign
return lodash.assign({}, settings, {
category: "media",
});
}
return settings;
}
wp.hooks.addFilter(
"blocks.registerBlockType",
"myprefix/filter-spacer-category",
myprefixFilterSpacerCategory
);