UNPKG

@wordpress/block-library

Version:
1 lines • 1.65 kB
{"version":3,"file":"edit.mjs","names":[],"sources":["../../src/tabs/edit.jsx"],"sourcesContent":["import { useBlockProps, useInnerBlocksProps } from '@wordpress/block-editor';\nimport TabToolbarControls from './tab-toolbar-controls';\nimport useTabListItemsSync from './use-tab-list-items-sync';\n\nfunction Edit( { clientId } ) {\n\tuseTabListItemsSync( clientId );\n\n\tconst blockProps = useBlockProps();\n\n\t// The template in the block type settings only specifies the two\n\t// structural child blocks, without inner block entries for\n\t// core/tab-list or core/tab-panels.\n\t//\n\t// If inner blocks were included in that template,\n\t// `synchronizeBlocksWithTemplate` (called whenever templateLock === 'all')\n\t// would recurse into the containers and truncate them to the template\n\t// count, causing data loss when a saved block with more than two tabs is\n\t// re-opened in the editor.\n\t//\n\t// Initial tab/panel creation is delegated to the tab-panels template\n\t// (templateLock: false, applied only when empty).\n\tconst innerBlockProps = useInnerBlocksProps( blockProps, {\n\t\t__experimentalCaptureToolbars: true,\n\t\ttemplateLock: 'all',\n\t\trenderAppender: false,\n\t} );\n\n\treturn (\n\t\t<div { ...innerBlockProps }>\n\t\t\t<TabToolbarControls tabsClientId={ clientId } />\n\t\t\t{ innerBlockProps.children }\n\t\t</div>\n\t);\n}\n\nexport default Edit;\n"],"mappings":";;;;;AAIA,SAAS,KAAM,EAAE,YAAa;CAC7B,oBAAqB,QAAS;CAE9B,MAAM,aAAa,cAAc;CAcjC,MAAM,kBAAkB,oBAAqB,YAAY;EACxD,+BAA+B;EAC/B,cAAc;EACd,gBAAgB;CACjB,CAAE;CAEF,OACC,qBAAC,OAAD;EAAK,GAAK;EAAV,UAAA,CACC,oBAAC,oBAAD,EAAoB,cAAe,SAAY,CAAA,GAC7C,gBAAgB,QACd;;AAEP"}