UNPKG

@wordpress/block-library

Version:
43 lines (42 loc) • 1.53 kB
import { details } from "@wordpress/icons"; import { __, sprintf } from "@wordpress/i18n"; import initBlock from "../utils/init-block.mjs"; import metadata from "./block.json"; import edit from "./edit.mjs"; import save from "./save.mjs"; import transforms from "./transforms.mjs"; // packages/block-library/src/details/index.js const { name } = metadata; const TEMPLATE = [["core/paragraph", { placeholder: __("Type / to add a hidden block") }]]; const settings = { icon: details, template: TEMPLATE, example: { attributes: { summary: __("La Mancha"), showContent: true }, innerBlocks: [{ name: "core/paragraph", attributes: { content: __("In a village of La Mancha, the name of which I have no desire to call to mind, there lived not long since one of those gentlemen that keep a lance in the lance-rack, an old buckler, a lean hack, and a greyhound for coursing.") } }] }, __experimentalLabel(attributes, { context }) { const { summary } = attributes; const customName = attributes?.metadata?.name; const hasSummary = summary?.trim().length > 0; if (context === "list-view" && (customName || hasSummary)) return customName || summary; if (context === "breadcrumb" && customName) return customName; if (context === "accessibility") return !hasSummary ? __("Details. Empty.") : sprintf(__("Details. %s"), summary); }, save, edit, transforms }; const init = () => initBlock({ name, metadata, settings }); export { init, metadata, name, settings }; //# sourceMappingURL=index.mjs.map