UNPKG

@wordpress/block-editor

Version:
8 lines (7 loc) 2.68 kB
{ "version": 3, "sources": ["../../src/hooks/use-content-only-section-edit.js"], "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../store';\nimport { unlock } from '../lock-unlock';\n\n/**\n * Hook that provides section block editing state and actions.\n *\n * @param {string} clientId Block client ID.\n * @return {Object} Object containing section block state and actions.\n */\nexport default function useContentOnlySectionEdit( clientId ) {\n\tconst {\n\t\tisSectionBlock,\n\t\tisWithinSection,\n\t\tisWithinEditedSection,\n\t\tisEditingContentOnlySection,\n\t\teditedContentOnlySection,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tisSectionBlock: _isSectionBlock,\n\t\t\t\tgetParentSectionBlock,\n\t\t\t\tgetEditedContentOnlySection,\n\t\t\t\tisWithinEditedContentOnlySection,\n\t\t\t} = unlock( select( blockEditorStore ) );\n\n\t\t\tconst editedSection = getEditedContentOnlySection();\n\n\t\t\treturn {\n\t\t\t\tisSectionBlock: _isSectionBlock( clientId ),\n\t\t\t\tisWithinSection:\n\t\t\t\t\t_isSectionBlock( clientId ) ||\n\t\t\t\t\t!! getParentSectionBlock( clientId ),\n\t\t\t\tisWithinEditedSection:\n\t\t\t\t\tisWithinEditedContentOnlySection( clientId ),\n\t\t\t\tisEditingContentOnlySection: editedSection === clientId,\n\t\t\t\teditedContentOnlySection: editedSection,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst blockEditorActions = useDispatch( blockEditorStore );\n\tconst { editContentOnlySection, stopEditingContentOnlySection } =\n\t\tunlock( blockEditorActions );\n\n\treturn {\n\t\tisSectionBlock,\n\t\tisWithinSection,\n\t\tisWithinEditedSection,\n\t\tisEditingContentOnlySection,\n\t\teditedContentOnlySection,\n\t\teditContentOnlySection,\n\t\tstopEditingContentOnlySection,\n\t};\n}\n"], "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAuC;AAKvC,mBAA0C;AAC1C,yBAAuB;AAQR,SAAR,0BAA4C,UAAW;AAC7D,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,QAAI;AAAA,IACH,CAAE,WAAY;AACb,YAAM;AAAA,QACL,gBAAgB;AAAA,QAChB;AAAA,QACA;AAAA,QACA;AAAA,MACD,QAAI,2BAAQ,OAAQ,aAAAA,KAAiB,CAAE;AAEvC,YAAM,gBAAgB,4BAA4B;AAElD,aAAO;AAAA,QACN,gBAAgB,gBAAiB,QAAS;AAAA,QAC1C,iBACC,gBAAiB,QAAS,KAC1B,CAAC,CAAE,sBAAuB,QAAS;AAAA,QACpC,uBACC,iCAAkC,QAAS;AAAA,QAC5C,6BAA6B,kBAAkB;AAAA,QAC/C,0BAA0B;AAAA,MAC3B;AAAA,IACD;AAAA,IACA,CAAE,QAAS;AAAA,EACZ;AAEA,QAAM,yBAAqB,yBAAa,aAAAA,KAAiB;AACzD,QAAM,EAAE,wBAAwB,8BAA8B,QAC7D,2BAAQ,kBAAmB;AAE5B,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD;", "names": ["blockEditorStore"] }