@wordpress/edit-post
Version:
Edit Post module for WordPress.
8 lines (7 loc) • 2.69 kB
Source Map (JSON)
{
"version": 3,
"sources": ["../../../src/components/layout/use-should-iframe.js"],
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { store as editorStore } from '@wordpress/editor';\nimport { useSelect } from '@wordpress/data';\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\n\nconst isGutenbergPlugin = globalThis.IS_GUTENBERG_PLUGIN ? true : false;\n\nexport function useShouldIframe() {\n\treturn useSelect( ( select ) => {\n\t\tconst { getCurrentPostType, getDeviceType } = select( editorStore );\n\t\tconst { getClientIdsWithDescendants, getBlockName } =\n\t\t\tselect( blockEditorStore );\n\t\tconst { getBlockType } = select( blocksStore );\n\n\t\treturn (\n\t\t\t// If the Gutenberg plugin is active, we ALWAYS use the iframe for\n\t\t\t// consistency across the post and site editor. We plan on enforcing\n\t\t\t// the iframe in the future, so Gutenberg both serves as way for us\n\t\t\t// to warn plugin developers and for plugin developers to test their\n\t\t\t// blocks easily. Before GB v22.5, we only enforced it for\n\t\t\t// block-based themes (classic themes used the same rules as core).\n\t\t\tisGutenbergPlugin ||\n\t\t\t// We also still want to iframe all the special\n\t\t\t// editor features and modes such as device previews, zoom out, and\n\t\t\t// template/pattern editing.\n\t\t\tgetDeviceType() !== 'Desktop' ||\n\t\t\t[ 'wp_template', 'wp_block' ].includes( getCurrentPostType() ) ||\n\t\t\tunlock( select( blockEditorStore ) ).isZoomOut() ||\n\t\t\t// Finally, still iframe the editor if all present blocks are v3\n\t\t\t// (which means they are marked as iframe-compatible).\n\t\t\t[ ...new Set( getClientIdsWithDescendants().map( getBlockName ) ) ]\n\t\t\t\t.map( getBlockType )\n\t\t\t\t.filter( Boolean )\n\t\t\t\t.every( ( blockType ) => blockType.apiVersion >= 3 )\n\t\t);\n\t}, [] );\n}\n"],
"mappings": ";AAGA,SAAS,SAAS,mBAAmB;AACrC,SAAS,iBAAiB;AAC1B,SAAS,SAAS,mBAAmB;AACrC,SAAS,SAAS,wBAAwB;AAK1C,SAAS,cAAc;AAEvB,IAAM,oBAAoB,WAAW,sBAAsB,OAAO;AAE3D,SAAS,kBAAkB;AACjC,SAAO,UAAW,CAAE,WAAY;AAC/B,UAAM,EAAE,oBAAoB,cAAc,IAAI,OAAQ,WAAY;AAClE,UAAM,EAAE,6BAA6B,aAAa,IACjD,OAAQ,gBAAiB;AAC1B,UAAM,EAAE,aAAa,IAAI,OAAQ,WAAY;AAE7C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAOC;AAAA;AAAA;AAAA,MAIA,cAAc,MAAM,aACpB,CAAE,eAAe,UAAW,EAAE,SAAU,mBAAmB,CAAE,KAC7D,OAAQ,OAAQ,gBAAiB,CAAE,EAAE,UAAU;AAAA;AAAA,MAG/C,CAAE,GAAG,IAAI,IAAK,4BAA4B,EAAE,IAAK,YAAa,CAAE,CAAE,EAChE,IAAK,YAAa,EAClB,OAAQ,OAAQ,EAChB,MAAO,CAAE,cAAe,UAAU,cAAc,CAAE;AAAA;AAAA,EAEtD,GAAG,CAAC,CAAE;AACP;",
"names": []
}