@wordpress/block-editor
Version:
8 lines (7 loc) • 2.63 kB
Source Map (JSON)
{
"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": ";AAGA,SAAS,aAAa,iBAAiB;AAKvC,SAAS,SAAS,wBAAwB;AAC1C,SAAS,cAAc;AAQR,SAAR,0BAA4C,UAAW;AAC7D,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,IAAI;AAAA,IACH,CAAE,WAAY;AACb,YAAM;AAAA,QACL,gBAAgB;AAAA,QAChB;AAAA,QACA;AAAA,QACA;AAAA,MACD,IAAI,OAAQ,OAAQ,gBAAiB,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,qBAAqB,YAAa,gBAAiB;AACzD,QAAM,EAAE,wBAAwB,8BAA8B,IAC7D,OAAQ,kBAAmB;AAE5B,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD;",
"names": []
}