@wordpress/block-editor
Version:
8 lines (7 loc) • 2.27 kB
Source Map (JSON)
{
"version": 3,
"sources": ["../../../src/components/block-inspector/useBlockInspectorAnimationSettings.js"],
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\nexport default function useBlockInspectorAnimationSettings( blockType ) {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tif ( blockType ) {\n\t\t\t\tconst globalBlockInspectorAnimationSettings =\n\t\t\t\t\tselect( blockEditorStore ).getSettings()\n\t\t\t\t\t\t.blockInspectorAnimation;\n\n\t\t\t\t// Get the name of the block that will allow it's children to be animated.\n\t\t\t\tconst animationParent =\n\t\t\t\t\tglobalBlockInspectorAnimationSettings?.animationParent;\n\n\t\t\t\t// Determine whether the animationParent block is a parent of the selected block.\n\t\t\t\tconst { getSelectedBlockClientId, getBlockParentsByBlockName } =\n\t\t\t\t\tselect( blockEditorStore );\n\t\t\t\tconst _selectedBlockClientId = getSelectedBlockClientId();\n\t\t\t\tconst animationParentBlockClientId = getBlockParentsByBlockName(\n\t\t\t\t\t_selectedBlockClientId,\n\t\t\t\t\tanimationParent,\n\t\t\t\t\ttrue\n\t\t\t\t)[ 0 ];\n\n\t\t\t\t// If the selected block is not a child of the animationParent block,\n\t\t\t\t// and not an animationParent block itself, don't animate.\n\t\t\t\tif (\n\t\t\t\t\t! animationParentBlockClientId &&\n\t\t\t\t\tblockType.name !== animationParent\n\t\t\t\t) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\treturn globalBlockInspectorAnimationSettings?.[\n\t\t\t\t\tblockType.name\n\t\t\t\t];\n\t\t\t}\n\t\t\treturn null;\n\t\t},\n\t\t[ blockType ]\n\t);\n}\n"],
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAA0B;AAK1B,mBAA0C;AAE3B,SAAR,mCAAqD,WAAY;AACvE,aAAO;AAAA,IACN,CAAE,WAAY;AACb,UAAK,WAAY;AAChB,cAAM,wCACL,OAAQ,aAAAA,KAAiB,EAAE,YAAY,EACrC;AAGH,cAAM,kBACL,uCAAuC;AAGxC,cAAM,EAAE,0BAA0B,2BAA2B,IAC5D,OAAQ,aAAAA,KAAiB;AAC1B,cAAM,yBAAyB,yBAAyB;AACxD,cAAM,+BAA+B;AAAA,UACpC;AAAA,UACA;AAAA,UACA;AAAA,QACD,EAAG,CAAE;AAIL,YACC,CAAE,gCACF,UAAU,SAAS,iBAClB;AACD,iBAAO;AAAA,QACR;AAEA,eAAO,wCACN,UAAU,IACX;AAAA,MACD;AACA,aAAO;AAAA,IACR;AAAA,IACA,CAAE,SAAU;AAAA,EACb;AACD;",
"names": ["blockEditorStore"]
}