@wordpress/block-editor 15.6.1-next.36001005c.0 → 15.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/block-list/block.js +3 -3
  3. package/build/components/block-list/block.js.map +2 -2
  4. package/build/components/block-list/index.js +2 -2
  5. package/build/components/block-list/index.js.map +1 -1
  6. package/build/components/block-toolbar/switch-section-style.js +2 -5
  7. package/build/components/block-toolbar/switch-section-style.js.map +2 -2
  8. package/build/components/global-styles/hooks.js +0 -107
  9. package/build/components/global-styles/hooks.js.map +3 -3
  10. package/build/components/global-styles/index.js +0 -15
  11. package/build/components/global-styles/index.js.map +2 -2
  12. package/build/components/global-styles/typography-panel.js +18 -1
  13. package/build/components/global-styles/typography-panel.js.map +2 -2
  14. package/build/components/global-styles/utils.js +0 -19
  15. package/build/components/global-styles/utils.js.map +3 -3
  16. package/build/components/inserter/media-tab/media-tab.js +33 -1
  17. package/build/components/inserter/media-tab/media-tab.js.map +3 -3
  18. package/build/components/inserter/tips.js +0 -2
  19. package/build/components/inserter/tips.js.map +2 -2
  20. package/build/components/media-placeholder/index.js +31 -1
  21. package/build/components/media-placeholder/index.js.map +3 -3
  22. package/build/components/media-replace-flow/index.js +29 -1
  23. package/build/components/media-replace-flow/index.js.map +3 -3
  24. package/build/components/{global-styles/context.js → media-upload-modal/index.js} +8 -23
  25. package/build/components/media-upload-modal/index.js.map +7 -0
  26. package/build/components/rich-text/index.js +8 -7
  27. package/build/components/rich-text/index.js.map +2 -2
  28. package/build/hooks/allowed-blocks.js +3 -8
  29. package/build/hooks/allowed-blocks.js.map +3 -3
  30. package/build/hooks/block-bindings.js +111 -170
  31. package/build/hooks/block-bindings.js.map +2 -2
  32. package/build/hooks/block-style-variation.js +4 -13
  33. package/build/hooks/block-style-variation.js.map +2 -2
  34. package/build/hooks/custom-class-name.js +1 -1
  35. package/build/hooks/custom-class-name.js.map +1 -1
  36. package/build/hooks/fit-text.js +33 -20
  37. package/build/hooks/fit-text.js.map +2 -2
  38. package/build/hooks/font-size.js +4 -3
  39. package/build/hooks/font-size.js.map +2 -2
  40. package/build/hooks/metadata.js +48 -2
  41. package/build/hooks/metadata.js.map +2 -2
  42. package/build/hooks/typography.js +11 -4
  43. package/build/hooks/typography.js.map +3 -3
  44. package/build/private-apis.js +3 -1
  45. package/build/private-apis.js.map +3 -3
  46. package/build/store/private-selectors.js +3 -3
  47. package/build/store/private-selectors.js.map +2 -2
  48. package/build/store/selectors.js +38 -13
  49. package/build/store/selectors.js.map +2 -2
  50. package/build/store/utils.js +2 -1
  51. package/build/store/utils.js.map +2 -2
  52. package/build/utils/fit-text-utils.js +4 -4
  53. package/build/utils/fit-text-utils.js.map +2 -2
  54. package/build-module/components/block-list/block.js +3 -3
  55. package/build-module/components/block-list/block.js.map +2 -2
  56. package/build-module/components/block-list/index.js +2 -2
  57. package/build-module/components/block-list/index.js.map +1 -1
  58. package/build-module/components/block-toolbar/switch-section-style.js +2 -5
  59. package/build-module/components/block-toolbar/switch-section-style.js.map +2 -2
  60. package/build-module/components/global-styles/hooks.js +1 -99
  61. package/build-module/components/global-styles/hooks.js.map +2 -2
  62. package/build-module/components/global-styles/index.js +1 -15
  63. package/build-module/components/global-styles/index.js.map +2 -2
  64. package/build-module/components/global-styles/typography-panel.js +18 -1
  65. package/build-module/components/global-styles/typography-panel.js.map +2 -2
  66. package/build-module/components/global-styles/utils.js +0 -8
  67. package/build-module/components/global-styles/utils.js.map +2 -2
  68. package/build-module/components/inserter/media-tab/media-tab.js +34 -2
  69. package/build-module/components/inserter/media-tab/media-tab.js.map +2 -2
  70. package/build-module/components/inserter/tips.js +0 -2
  71. package/build-module/components/inserter/tips.js.map +2 -2
  72. package/build-module/components/media-placeholder/index.js +31 -1
  73. package/build-module/components/media-placeholder/index.js.map +2 -2
  74. package/build-module/components/media-replace-flow/index.js +29 -1
  75. package/build-module/components/media-replace-flow/index.js.map +2 -2
  76. package/build-module/components/media-upload-modal/index.js +7 -0
  77. package/build-module/components/media-upload-modal/index.js.map +7 -0
  78. package/build-module/components/rich-text/index.js +8 -7
  79. package/build-module/components/rich-text/index.js.map +2 -2
  80. package/build-module/hooks/allowed-blocks.js +3 -8
  81. package/build-module/hooks/allowed-blocks.js.map +2 -2
  82. package/build-module/hooks/block-bindings.js +112 -172
  83. package/build-module/hooks/block-bindings.js.map +2 -2
  84. package/build-module/hooks/block-style-variation.js +5 -14
  85. package/build-module/hooks/block-style-variation.js.map +2 -2
  86. package/build-module/hooks/custom-class-name.js +1 -1
  87. package/build-module/hooks/custom-class-name.js.map +1 -1
  88. package/build-module/hooks/fit-text.js +34 -21
  89. package/build-module/hooks/fit-text.js.map +2 -2
  90. package/build-module/hooks/font-size.js +4 -3
  91. package/build-module/hooks/font-size.js.map +2 -2
  92. package/build-module/hooks/metadata.js +46 -1
  93. package/build-module/hooks/metadata.js.map +2 -2
  94. package/build-module/hooks/typography.js +11 -4
  95. package/build-module/hooks/typography.js.map +3 -3
  96. package/build-module/private-apis.js +3 -1
  97. package/build-module/private-apis.js.map +2 -2
  98. package/build-module/store/private-selectors.js +2 -2
  99. package/build-module/store/private-selectors.js.map +2 -2
  100. package/build-module/store/selectors.js +39 -14
  101. package/build-module/store/selectors.js.map +2 -2
  102. package/build-module/store/utils.js +3 -2
  103. package/build-module/store/utils.js.map +2 -2
  104. package/build-module/utils/fit-text-utils.js +4 -4
  105. package/build-module/utils/fit-text-utils.js.map +2 -2
  106. package/package.json +36 -36
  107. package/src/components/block-list/block.js +1 -1
  108. package/src/components/block-list/index.js +2 -2
  109. package/src/components/block-toolbar/switch-section-style.js +2 -5
  110. package/src/components/global-styles/hooks.js +1 -121
  111. package/src/components/global-styles/index.js +1 -9
  112. package/src/components/global-styles/typography-panel.js +26 -1
  113. package/src/components/global-styles/utils.js +0 -31
  114. package/src/components/inserter/media-tab/media-tab.js +44 -2
  115. package/src/components/inserter/tips.js +0 -2
  116. package/src/components/media-placeholder/index.js +41 -1
  117. package/src/components/media-replace-flow/index.js +39 -1
  118. package/src/components/media-upload-modal/index.js +18 -0
  119. package/src/components/rich-text/index.js +8 -14
  120. package/src/hooks/allowed-blocks.js +3 -11
  121. package/src/hooks/block-bindings.js +79 -153
  122. package/src/hooks/block-style-variation.js +5 -17
  123. package/src/hooks/custom-class-name.js +1 -1
  124. package/src/hooks/fit-text.js +39 -30
  125. package/src/hooks/font-size.js +7 -3
  126. package/src/hooks/metadata.js +89 -0
  127. package/src/hooks/test/metadata.js +316 -0
  128. package/src/hooks/typography.js +15 -4
  129. package/src/private-apis.js +2 -0
  130. package/src/store/private-selectors.js +2 -2
  131. package/src/store/selectors.js +59 -21
  132. package/src/store/test/selectors.js +1 -1
  133. package/src/store/utils.js +2 -1
  134. package/src/utils/fit-text-utils.js +4 -16
  135. package/tsconfig.json +1 -0
  136. package/build/components/global-styles/context.js.map +0 -7
  137. package/build/components/global-styles/get-global-styles-changes.js +0 -216
  138. package/build/components/global-styles/get-global-styles-changes.js.map +0 -7
  139. package/build-module/components/global-styles/context.js +0 -17
  140. package/build-module/components/global-styles/context.js.map +0 -7
  141. package/build-module/components/global-styles/get-global-styles-changes.js +0 -182
  142. package/build-module/components/global-styles/get-global-styles-changes.js.map +0 -7
  143. package/src/components/global-styles/README.md +0 -190
  144. package/src/components/global-styles/context.js +0 -16
  145. package/src/components/global-styles/get-global-styles-changes.js +0 -252
  146. package/src/components/global-styles/test/get-global-styles-changes.js +0 -290
  147. package/src/components/global-styles/test/utils.js +0 -58
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/store/private-selectors.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createSelector, createRegistrySelector } from '@wordpress/data';\nimport {\n\thasBlockSupport,\n\tprivateApis as blocksPrivateApis,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport {\n\tgetBlockOrder,\n\tgetBlockParents,\n\tgetBlockEditingMode,\n\tgetSettings,\n\tcanInsertBlockType,\n\tgetBlockName,\n\tgetTemplateLock,\n\tgetClientIdsWithDescendants,\n\tgetBlockRootClientId,\n\tgetBlockAttributes,\n} from './selectors';\nimport {\n\tcheckAllowListRecursive,\n\tgetAllPatternsDependants,\n\tgetInsertBlockTypeDependants,\n\tgetGrammar,\n\tmapUserPattern,\n} from './utils';\nimport { STORE_NAME } from './constants';\nimport { unlock } from '../lock-unlock';\nimport {\n\tselectBlockPatternsKey,\n\treusableBlocksSelectKey,\n\tsectionRootClientIdKey,\n} from './private-keys';\n\nconst { isContentBlock } = unlock( blocksPrivateApis );\n\nexport { getBlockSettings } from './get-block-settings';\n\n/**\n * Returns true if the block interface is hidden, or false otherwise.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether the block toolbar is hidden.\n */\nexport function isBlockInterfaceHidden( state ) {\n\treturn state.isBlockInterfaceHidden;\n}\n\n/**\n * Gets the client ids of the last inserted blocks.\n *\n * @param {Object} state Global application state.\n * @return {Array|undefined} Client Ids of the last inserted block(s).\n */\nexport function getLastInsertedBlocksClientIds( state ) {\n\treturn state?.lastBlockInserted?.clientIds;\n}\n\nexport function getBlockWithoutAttributes( state, clientId ) {\n\treturn state.blocks.byClientId.get( clientId );\n}\n\n/**\n * Returns true if all of the descendants of a block with the given client ID\n * have an editing mode of 'disabled', or false otherwise.\n *\n * @param {Object} state Global application state.\n * @param {string} clientId The block client ID.\n *\n * @return {boolean} Whether the block descendants are disabled.\n */\nexport const isBlockSubtreeDisabled = ( state, clientId ) => {\n\tconst isChildSubtreeDisabled = ( childClientId ) => {\n\t\treturn (\n\t\t\tgetBlockEditingMode( state, childClientId ) === 'disabled' &&\n\t\t\tgetBlockOrder( state, childClientId ).every(\n\t\t\t\tisChildSubtreeDisabled\n\t\t\t)\n\t\t);\n\t};\n\treturn getBlockOrder( state, clientId ).every( isChildSubtreeDisabled );\n};\n\n/**\n * Determines if a container (clientId) allows insertion of blocks, considering contentOnly mode restrictions.\n *\n * @param {Object} state Editor state.\n * @param {string} blockName The block name to insert.\n * @param {string} rootClientId The client ID of the root container block.\n * @return {boolean} Whether the container allows insertion.\n */\nexport function isContainerInsertableToInWriteMode(\n\tstate,\n\tblockName,\n\trootClientId\n) {\n\tconst isBlockContentBlock = isContentBlock( blockName );\n\tconst rootBlockName = getBlockName( state, rootClientId );\n\tconst isContainerContentBlock = isContentBlock( rootBlockName );\n\tconst isRootBlockMain = getSectionRootClientId( state ) === rootClientId;\n\n\t// In write mode, containers shouldn't be inserted into unless:\n\t// 1. they are a section root;\n\t// 2. they are a content block and the block to be inserted is also content.\n\treturn (\n\t\tisRootBlockMain || ( isContainerContentBlock && isBlockContentBlock )\n\t);\n}\n\nfunction getEnabledClientIdsTreeUnmemoized( state, rootClientId ) {\n\tconst blockOrder = getBlockOrder( state, rootClientId );\n\tconst result = [];\n\n\tfor ( const clientId of blockOrder ) {\n\t\tconst innerBlocks = getEnabledClientIdsTreeUnmemoized(\n\t\t\tstate,\n\t\t\tclientId\n\t\t);\n\t\tif ( getBlockEditingMode( state, clientId ) !== 'disabled' ) {\n\t\t\tresult.push( { clientId, innerBlocks } );\n\t\t} else {\n\t\t\tresult.push( ...innerBlocks );\n\t\t}\n\t}\n\n\treturn result;\n}\n\n/**\n * Returns a tree of block objects with only clientID and innerBlocks set.\n * Blocks with a 'disabled' editing mode are not included.\n *\n * @param {Object} state Global application state.\n * @param {?string} rootClientId Optional root client ID of block list.\n *\n * @return {Object[]} Tree of block objects with only clientID and innerBlocks set.\n */\nexport const getEnabledClientIdsTree = createRegistrySelector( () =>\n\tcreateSelector( getEnabledClientIdsTreeUnmemoized, ( state ) => [\n\t\tstate.blocks.order,\n\t\tstate.derivedBlockEditingModes,\n\t\tstate.blockEditingModes,\n\t] )\n);\n\n/**\n * Returns a list of a given block's ancestors, from top to bottom. Blocks with\n * a 'disabled' editing mode are excluded.\n *\n * @see getBlockParents\n *\n * @param {Object} state Global application state.\n * @param {string} clientId The block client ID.\n * @param {boolean} ascending Order results from bottom to top (true) or top\n * to bottom (false).\n */\nexport const getEnabledBlockParents = createSelector(\n\t( state, clientId, ascending = false ) => {\n\t\treturn getBlockParents( state, clientId, ascending ).filter(\n\t\t\t( parent ) => getBlockEditingMode( state, parent ) !== 'disabled'\n\t\t);\n\t},\n\t( state ) => [\n\t\tstate.blocks.parents,\n\t\tstate.blockEditingModes,\n\t\tstate.settings.templateLock,\n\t\tstate.blockListSettings,\n\t]\n);\n\n/**\n * Selector that returns the data needed to display a prompt when certain\n * blocks are removed, or `false` if no such prompt is requested.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object|false} Data for removal prompt display, if any.\n */\nexport function getRemovalPromptData( state ) {\n\treturn state.removalPromptData;\n}\n\n/**\n * Returns true if removal prompt exists, or false otherwise.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether removal prompt exists.\n */\nexport function getBlockRemovalRules( state ) {\n\treturn state.blockRemovalRules;\n}\n\n/**\n * Returns the client ID of the block settings menu that is currently open.\n *\n * @param {Object} state Global application state.\n * @return {string|null} The client ID of the block menu that is currently open.\n */\nexport function getOpenedBlockSettingsMenu( state ) {\n\treturn state.openedBlockSettingsMenu;\n}\n\n/**\n * Returns all style overrides, intended to be merged with global editor styles.\n *\n * Overrides are sorted to match the order of the blocks they relate to. This\n * is useful to maintain correct CSS cascade order.\n *\n * @param {Object} state Global application state.\n *\n * @return {Array} An array of style ID to style override pairs.\n */\nexport const getStyleOverrides = createSelector(\n\t( state ) => {\n\t\tconst clientIds = getClientIdsWithDescendants( state );\n\t\tconst clientIdMap = clientIds.reduce( ( acc, clientId, index ) => {\n\t\t\tacc[ clientId ] = index;\n\t\t\treturn acc;\n\t\t}, {} );\n\n\t\treturn [ ...state.styleOverrides ].sort( ( overrideA, overrideB ) => {\n\t\t\t// Once the overrides Map is spread to an array, the first element\n\t\t\t// is the key, while the second is the override itself including\n\t\t\t// the clientId to sort by.\n\t\t\tconst [ , { clientId: clientIdA } ] = overrideA;\n\t\t\tconst [ , { clientId: clientIdB } ] = overrideB;\n\n\t\t\tconst aIndex = clientIdMap[ clientIdA ] ?? -1;\n\t\t\tconst bIndex = clientIdMap[ clientIdB ] ?? -1;\n\n\t\t\treturn aIndex - bIndex;\n\t\t} );\n\t},\n\t( state ) => [ state.blocks.order, state.styleOverrides ]\n);\n\n/** @typedef {import('./actions').InserterMediaCategory} InserterMediaCategory */\n/**\n * Returns the registered inserter media categories through the public API.\n *\n * @param {Object} state Editor state.\n *\n * @return {InserterMediaCategory[]} Inserter media categories.\n */\nexport function getRegisteredInserterMediaCategories( state ) {\n\treturn state.registeredInserterMediaCategories;\n}\n\n/**\n * Returns an array containing the allowed inserter media categories.\n * It merges the registered media categories from extenders with the\n * core ones. It also takes into account the allowed `mime_types`, which\n * can be altered by `upload_mimes` filter and restrict some of them.\n *\n * @param {Object} state Global application state.\n *\n * @return {InserterMediaCategory[]} Client IDs of descendants.\n */\nexport const getInserterMediaCategories = createSelector(\n\t( state ) => {\n\t\tconst {\n\t\t\tsettings: {\n\t\t\t\tinserterMediaCategories,\n\t\t\t\tallowedMimeTypes,\n\t\t\t\tenableOpenverseMediaCategory,\n\t\t\t},\n\t\t\tregisteredInserterMediaCategories,\n\t\t} = state;\n\t\t// The allowed `mime_types` can be altered by `upload_mimes` filter and restrict\n\t\t// some of them. In this case we shouldn't add the category to the available media\n\t\t// categories list in the inserter.\n\t\tif (\n\t\t\t( ! inserterMediaCategories &&\n\t\t\t\t! registeredInserterMediaCategories.length ) ||\n\t\t\t! allowedMimeTypes\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\tconst coreInserterMediaCategoriesNames =\n\t\t\tinserterMediaCategories?.map( ( { name } ) => name ) || [];\n\t\tconst mergedCategories = [\n\t\t\t...( inserterMediaCategories || [] ),\n\t\t\t...( registeredInserterMediaCategories || [] ).filter(\n\t\t\t\t( { name } ) =>\n\t\t\t\t\t! coreInserterMediaCategoriesNames.includes( name )\n\t\t\t),\n\t\t];\n\t\treturn mergedCategories.filter( ( category ) => {\n\t\t\t// Check if Openverse category is enabled.\n\t\t\tif (\n\t\t\t\t! enableOpenverseMediaCategory &&\n\t\t\t\tcategory.name === 'openverse'\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\treturn Object.values( allowedMimeTypes ).some( ( mimeType ) =>\n\t\t\t\tmimeType.startsWith( `${ category.mediaType }/` )\n\t\t\t);\n\t\t} );\n\t},\n\t( state ) => [\n\t\tstate.settings.inserterMediaCategories,\n\t\tstate.settings.allowedMimeTypes,\n\t\tstate.settings.enableOpenverseMediaCategory,\n\t\tstate.registeredInserterMediaCategories,\n\t]\n);\n\n/**\n * Returns whether there is at least one allowed pattern for inner blocks children.\n * This is useful for deferring the parsing of all patterns until needed.\n *\n * @param {Object} state Editor state.\n * @param {string} [rootClientId=null] Target root client ID.\n *\n * @return {boolean} If there is at least one allowed pattern.\n */\nexport const hasAllowedPatterns = createRegistrySelector( ( select ) =>\n\tcreateSelector(\n\t\t( state, rootClientId = null ) => {\n\t\t\tconst { getAllPatterns } = unlock( select( STORE_NAME ) );\n\t\t\tconst patterns = getAllPatterns();\n\t\t\tconst { allowedBlockTypes } = getSettings( state );\n\t\t\treturn patterns.some( ( pattern ) => {\n\t\t\t\tconst { inserter = true } = pattern;\n\t\t\t\tif ( ! inserter ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tconst grammar = getGrammar( pattern );\n\t\t\t\treturn (\n\t\t\t\t\tcheckAllowListRecursive( grammar, allowedBlockTypes ) &&\n\t\t\t\t\tgrammar.every( ( { name: blockName } ) =>\n\t\t\t\t\t\tcanInsertBlockType( state, blockName, rootClientId )\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t} );\n\t\t},\n\t\t( state, rootClientId ) => [\n\t\t\t...getAllPatternsDependants( select )( state ),\n\t\t\t...getInsertBlockTypeDependants( select )( state, rootClientId ),\n\t\t]\n\t)\n);\n\nexport const getPatternBySlug = createRegistrySelector( ( select ) =>\n\tcreateSelector(\n\t\t( state, patternName ) => {\n\t\t\t// Only fetch reusable blocks if we know we need them. To do: maybe\n\t\t\t// use the entity record API to retrieve the block by slug.\n\t\t\tif ( patternName?.startsWith( 'core/block/' ) ) {\n\t\t\t\tconst _id = parseInt(\n\t\t\t\t\tpatternName.slice( 'core/block/'.length ),\n\t\t\t\t\t10\n\t\t\t\t);\n\t\t\t\tconst block = unlock( select( STORE_NAME ) )\n\t\t\t\t\t.getReusableBlocks()\n\t\t\t\t\t.find( ( { id } ) => id === _id );\n\n\t\t\t\tif ( ! block ) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\treturn mapUserPattern(\n\t\t\t\t\tblock,\n\t\t\t\t\tstate.settings.__experimentalUserPatternCategories\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn [\n\t\t\t\t// This setting is left for back compat.\n\t\t\t\t...( state.settings.__experimentalBlockPatterns ?? [] ),\n\t\t\t\t...( state.settings[ selectBlockPatternsKey ]?.( select ) ??\n\t\t\t\t\t[] ),\n\t\t\t].find( ( { name } ) => name === patternName );\n\t\t},\n\t\t( state, patternName ) =>\n\t\t\tpatternName?.startsWith( 'core/block/' )\n\t\t\t\t? [\n\t\t\t\t\t\tunlock( select( STORE_NAME ) ).getReusableBlocks(),\n\t\t\t\t\t\tstate.settings.__experimentalReusableBlocks,\n\t\t\t\t ]\n\t\t\t\t: [\n\t\t\t\t\t\tstate.settings.__experimentalBlockPatterns,\n\t\t\t\t\t\tstate.settings[ selectBlockPatternsKey ]?.( select ),\n\t\t\t\t ]\n\t)\n);\n\nexport const getAllPatterns = createRegistrySelector( ( select ) =>\n\tcreateSelector( ( state ) => {\n\t\treturn [\n\t\t\t...unlock( select( STORE_NAME ) )\n\t\t\t\t.getReusableBlocks()\n\t\t\t\t.map( ( userPattern ) =>\n\t\t\t\t\tmapUserPattern(\n\t\t\t\t\t\tuserPattern,\n\t\t\t\t\t\tstate.settings.__experimentalUserPatternCategories\n\t\t\t\t\t)\n\t\t\t\t),\n\t\t\t// This setting is left for back compat.\n\t\t\t...( state.settings.__experimentalBlockPatterns ?? [] ),\n\t\t\t...( state.settings[ selectBlockPatternsKey ]?.( select ) ?? [] ),\n\t\t].filter(\n\t\t\t( x, index, arr ) =>\n\t\t\t\tindex === arr.findIndex( ( y ) => x.name === y.name )\n\t\t);\n\t}, getAllPatternsDependants( select ) )\n);\n\nconst EMPTY_ARRAY = [];\n\nexport const getReusableBlocks = createRegistrySelector(\n\t( select ) => ( state ) => {\n\t\tconst reusableBlocksSelect = state.settings[ reusableBlocksSelectKey ];\n\t\treturn (\n\t\t\t( reusableBlocksSelect\n\t\t\t\t? reusableBlocksSelect( select )\n\t\t\t\t: state.settings.__experimentalReusableBlocks ) ?? EMPTY_ARRAY\n\t\t);\n\t}\n);\n\n/**\n * Returns the element of the last element that had focus when focus left the editor canvas.\n *\n * @param {Object} state Block editor state.\n *\n * @return {Object} Element.\n */\nexport function getLastFocus( state ) {\n\treturn state.lastFocus;\n}\n\n/**\n * Returns true if the user is dragging anything, or false otherwise. It is possible for a\n * user to be dragging data from outside of the editor, so this selector is separate from\n * the `isDraggingBlocks` selector which only returns true if the user is dragging blocks.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether user is dragging.\n */\nexport function isDragging( state ) {\n\treturn state.isDragging;\n}\n\n/**\n * Retrieves the expanded block from the state.\n *\n * @param {Object} state Block editor state.\n *\n * @return {string|null} The client ID of the expanded block, if set.\n */\nexport function getExpandedBlock( state ) {\n\treturn state.expandedBlock;\n}\n\n/**\n * Retrieves the client ID of the ancestor block that is content locking the block\n * with the provided client ID.\n *\n * @param {Object} state Global application state.\n * @param {string} clientId Client Id of the block.\n *\n * @return {?string} Client ID of the ancestor block that is content locking the block.\n */\nexport const getContentLockingParent = ( state, clientId ) => {\n\tlet current = clientId;\n\tlet result;\n\twhile ( ! result && ( current = state.blocks.parents.get( current ) ) ) {\n\t\tif ( getTemplateLock( state, current ) === 'contentOnly' ) {\n\t\t\tresult = current;\n\t\t}\n\t}\n\treturn result;\n};\n\n/**\n * Retrieves the client ID of the parent section block.\n *\n * @param {Object} state Global application state.\n * @param {string} clientId Client Id of the block.\n *\n * @return {?string} Client ID of the ancestor block that is content locking the block.\n */\nexport const getParentSectionBlock = ( state, clientId ) => {\n\tlet current = clientId;\n\tlet result;\n\twhile ( ! result && ( current = state.blocks.parents.get( current ) ) ) {\n\t\tif ( isSectionBlock( state, current ) ) {\n\t\t\tresult = current;\n\t\t}\n\t}\n\treturn result;\n};\n\n/**\n * Retrieves the client ID is a content locking parent\n *\n * @param {Object} state Global application state.\n * @param {string} clientId Client Id of the block.\n *\n * @return {boolean} Whether the block is a content locking parent.\n */\nexport function isSectionBlock( state, clientId ) {\n\tconst blockName = getBlockName( state, clientId );\n\tif (\n\t\tblockName === 'core/block' ||\n\t\tgetTemplateLock( state, clientId ) === 'contentOnly'\n\t) {\n\t\treturn true;\n\t}\n\n\tconst attributes = getBlockAttributes( state, clientId );\n\tconst isTemplatePart = blockName === 'core/template-part';\n\tif (\n\t\t( attributes?.metadata?.patternName || isTemplatePart ) &&\n\t\t!! window?.__experimentalContentOnlyPatternInsertion\n\t) {\n\t\treturn true;\n\t}\n\treturn false;\n}\n\n/**\n * Retrieves the client ID of the block that is content locked but is\n * currently being temporarily edited as a non-locked block.\n *\n * @param {Object} state Global application state.\n *\n * @return {?string} The client ID of the block being temporarily edited as a non-locked block.\n */\nexport function getTemporarilyEditingAsBlocks( state ) {\n\treturn state.temporarilyEditingAsBlocks;\n}\n\n/**\n * Returns the focus mode that should be reapplied when the user stops editing\n * a content locked blocks as a block without locking.\n *\n * @param {Object} state Global application state.\n *\n * @return {?string} The focus mode that should be re-set when temporarily editing as blocks stops.\n */\nexport function getTemporarilyEditingFocusModeToRevert( state ) {\n\treturn state.temporarilyEditingFocusModeRevert;\n}\n\n/**\n * Returns the style attributes of multiple blocks.\n *\n * @param {Object} state Global application state.\n * @param {string[]} clientIds An array of block client IDs.\n *\n * @return {Object} An object where keys are client IDs and values are the corresponding block styles or undefined.\n */\nexport const getBlockStyles = createSelector(\n\t( state, clientIds ) =>\n\t\tclientIds.reduce( ( styles, clientId ) => {\n\t\t\tstyles[ clientId ] = state.blocks.attributes.get( clientId )?.style;\n\t\t\treturn styles;\n\t\t}, {} ),\n\t( state, clientIds ) => [\n\t\t...clientIds.map(\n\t\t\t( clientId ) => state.blocks.attributes.get( clientId )?.style\n\t\t),\n\t]\n);\n\n/**\n * Retrieves the client ID of the block which contains the blocks\n * acting as \"sections\" in the editor. This is typically the \"main content\"\n * of the template/post.\n *\n * @param {Object} state Editor state.\n *\n * @return {string|undefined} The section root client ID or undefined if not set.\n */\nexport function getSectionRootClientId( state ) {\n\treturn state.settings?.[ sectionRootClientIdKey ];\n}\n\n/**\n * Returns whether the editor is considered zoomed out.\n *\n * @param {Object} state Global application state.\n * @return {boolean} Whether the editor is zoomed.\n */\nexport function isZoomOut( state ) {\n\treturn state.zoomLevel === 'auto-scaled' || state.zoomLevel < 100;\n}\n\n/**\n * Returns whether the zoom level.\n *\n * @param {Object} state Global application state.\n * @return {number|\"auto-scaled\"} Zoom level.\n */\nexport function getZoomLevel( state ) {\n\treturn state.zoomLevel;\n}\n\n/**\n * Finds the closest block where the block is allowed to be inserted.\n *\n * @param {Object} state Editor state.\n * @param {string[] | string} name Block name or names.\n * @param {string} clientId Default insertion point.\n *\n * @return {string} clientID of the closest container when the block name can be inserted.\n */\nexport function getClosestAllowedInsertionPoint( state, name, clientId = '' ) {\n\tconst blockNames = Array.isArray( name ) ? name : [ name ];\n\tconst areBlockNamesAllowedInClientId = ( id ) =>\n\t\tblockNames.every( ( currentName ) =>\n\t\t\tcanInsertBlockType( state, currentName, id )\n\t\t);\n\n\t// If we're trying to insert at the root level and it's not allowed\n\t// Try the section root instead.\n\tif ( ! clientId ) {\n\t\tif ( areBlockNamesAllowedInClientId( clientId ) ) {\n\t\t\treturn clientId;\n\t\t}\n\n\t\tconst sectionRootClientId = getSectionRootClientId( state );\n\t\tif (\n\t\t\tsectionRootClientId &&\n\t\t\tareBlockNamesAllowedInClientId( sectionRootClientId )\n\t\t) {\n\t\t\treturn sectionRootClientId;\n\t\t}\n\t\treturn null;\n\t}\n\n\t// Traverse the block tree up until we find a place where we can insert.\n\tlet current = clientId;\n\twhile ( current !== null && ! areBlockNamesAllowedInClientId( current ) ) {\n\t\tconst parentClientId = getBlockRootClientId( state, current );\n\t\tcurrent = parentClientId;\n\t}\n\n\treturn current;\n}\n\nexport function getClosestAllowedInsertionPointForPattern(\n\tstate,\n\tpattern,\n\tclientId\n) {\n\tconst { allowedBlockTypes } = getSettings( state );\n\tconst isAllowed = checkAllowListRecursive(\n\t\tgetGrammar( pattern ),\n\t\tallowedBlockTypes\n\t);\n\tif ( ! isAllowed ) {\n\t\treturn null;\n\t}\n\tconst names = getGrammar( pattern ).map( ( { blockName: name } ) => name );\n\treturn getClosestAllowedInsertionPoint( state, names, clientId );\n}\n\n/**\n * Where the point where the next block will be inserted into.\n *\n * @param {Object} state\n * @return {Object} where the insertion point in the block editor is or null if none is set.\n */\nexport function getInsertionPoint( state ) {\n\treturn state.insertionPoint;\n}\n\n/**\n * Returns true if the block is hidden, or false otherwise.\n *\n * @param {Object} state Global application state.\n * @param {string} clientId Client ID of the block.\n *\n * @return {boolean} Whether the block is hidden.\n */\nexport const isBlockHidden = ( state, clientId ) => {\n\tconst blockName = getBlockName( state, clientId );\n\tif ( ! hasBlockSupport( state, blockName, 'blockVisibility', true ) ) {\n\t\treturn false;\n\t}\n\tconst attributes = state.blocks.attributes.get( clientId );\n\treturn attributes?.metadata?.blockVisibility === false;\n};\n\n/**\n * Returns true if the current spotlighted block matches the block clientId.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether the block is currently spotlighted.\n */\nexport function hasBlockSpotlight( state ) {\n\treturn !! state.hasBlockSpotlight;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;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EAAG;AAAA,EAC5C;AAID,MAAK,CAAE,UAAW;AACjB,QAAK,+BAAgC,QAAS,GAAI;AACjD,aAAO;AAAA,IACR;AAEA,UAAM,sBAAsB,uBAAwB,KAAM;AAC1D,QACC,uBACA,+BAAgC,mBAAoB,GACnD;AACD,aAAO;AAAA,IACR;AACA,WAAO;AAAA,EACR;AAGA,MAAI,UAAU;AACd,SAAQ,YAAY,QAAQ,CAAE,+BAAgC,OAAQ,GAAI;AACzE,UAAM,qBAAiB,uCAAsB,OAAO,OAAQ;AAC5D,cAAU;AAAA,EACX;AAEA,SAAO;AACR;AAEO,SAAS,0CACf,OACA,SACA,UACC;AACD,QAAM,EAAE,kBAAkB,QAAI,8BAAa,KAAM;AACjD,QAAM,gBAAY;AAAA,QACjB,yBAAY,OAAQ;AAAA,IACpB;AAAA,EACD;AACA,MAAK,CAAE,WAAY;AAClB,WAAO;AAAA,EACR;AACA,QAAM,YAAQ,yBAAY,OAAQ,EAAE,IAAK,CAAE,EAAE,WAAW,KAAK,MAAO,IAAK;AACzE,SAAO,gCAAiC,OAAO,OAAO,QAAS;AAChE;AAQO,SAAS,kBAAmB,OAAQ;AAC1C,SAAO,MAAM;AACd;AAUO,MAAM,gBAAgB,CAAE,OAAO,aAAc;AACnD,QAAM,gBAAY,+BAAc,OAAO,QAAS;AAChD,MAAK,KAAE,+BAAiB,OAAO,WAAW,mBAAmB,IAAK,GAAI;AACrE,WAAO;AAAA,EACR;AACA,QAAM,aAAa,MAAM,OAAO,WAAW,IAAK,QAAS;AACzD,SAAO,YAAY,UAAU,oBAAoB;AAClD;AASO,SAAS,kBAAmB,OAAQ;AAC1C,SAAO,CAAC,CAAE,MAAM;AACjB;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createSelector, createRegistrySelector } from '@wordpress/data';\nimport {\n\thasBlockSupport,\n\tprivateApis as blocksPrivateApis,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport {\n\tgetBlockOrder,\n\tgetBlockParents,\n\tgetBlockEditingMode,\n\tgetSettings,\n\tcanInsertBlockType,\n\tgetBlockName,\n\tgetTemplateLock,\n\tgetClientIdsWithDescendants,\n\tgetBlockRootClientId,\n\tgetBlockAttributes,\n} from './selectors';\nimport {\n\tcheckAllowListRecursive,\n\tgetAllPatternsDependants,\n\tgetInsertBlockTypeDependants,\n\tgetGrammar,\n\tmapUserPattern,\n} from './utils';\nimport { STORE_NAME } from './constants';\nimport { unlock } from '../lock-unlock';\nimport {\n\tselectBlockPatternsKey,\n\treusableBlocksSelectKey,\n\tsectionRootClientIdKey,\n} from './private-keys';\n\nconst { isContentBlock } = unlock( blocksPrivateApis );\n\nexport { getBlockSettings } from './get-block-settings';\n\n/**\n * Returns true if the block interface is hidden, or false otherwise.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether the block toolbar is hidden.\n */\nexport function isBlockInterfaceHidden( state ) {\n\treturn state.isBlockInterfaceHidden;\n}\n\n/**\n * Gets the client ids of the last inserted blocks.\n *\n * @param {Object} state Global application state.\n * @return {Array|undefined} Client Ids of the last inserted block(s).\n */\nexport function getLastInsertedBlocksClientIds( state ) {\n\treturn state?.lastBlockInserted?.clientIds;\n}\n\nexport function getBlockWithoutAttributes( state, clientId ) {\n\treturn state.blocks.byClientId.get( clientId );\n}\n\n/**\n * Returns true if all of the descendants of a block with the given client ID\n * have an editing mode of 'disabled', or false otherwise.\n *\n * @param {Object} state Global application state.\n * @param {string} clientId The block client ID.\n *\n * @return {boolean} Whether the block descendants are disabled.\n */\nexport const isBlockSubtreeDisabled = ( state, clientId ) => {\n\tconst isChildSubtreeDisabled = ( childClientId ) => {\n\t\treturn (\n\t\t\tgetBlockEditingMode( state, childClientId ) === 'disabled' &&\n\t\t\tgetBlockOrder( state, childClientId ).every(\n\t\t\t\tisChildSubtreeDisabled\n\t\t\t)\n\t\t);\n\t};\n\treturn getBlockOrder( state, clientId ).every( isChildSubtreeDisabled );\n};\n\n/**\n * Determines if a container (clientId) allows insertion of blocks, considering contentOnly mode restrictions.\n *\n * @param {Object} state Editor state.\n * @param {string} blockName The block name to insert.\n * @param {string} rootClientId The client ID of the root container block.\n * @return {boolean} Whether the container allows insertion.\n */\nexport function isContainerInsertableToInContentOnlyMode(\n\tstate,\n\tblockName,\n\trootClientId\n) {\n\tconst isBlockContentBlock = isContentBlock( blockName );\n\tconst rootBlockName = getBlockName( state, rootClientId );\n\tconst isContainerContentBlock = isContentBlock( rootBlockName );\n\tconst isRootBlockMain = getSectionRootClientId( state ) === rootClientId;\n\n\t// In contentOnly mode, containers shouldn't be inserted into unless:\n\t// 1. they are a section root;\n\t// 2. they are a content block and the block to be inserted is also content.\n\treturn (\n\t\tisRootBlockMain || ( isContainerContentBlock && isBlockContentBlock )\n\t);\n}\n\nfunction getEnabledClientIdsTreeUnmemoized( state, rootClientId ) {\n\tconst blockOrder = getBlockOrder( state, rootClientId );\n\tconst result = [];\n\n\tfor ( const clientId of blockOrder ) {\n\t\tconst innerBlocks = getEnabledClientIdsTreeUnmemoized(\n\t\t\tstate,\n\t\t\tclientId\n\t\t);\n\t\tif ( getBlockEditingMode( state, clientId ) !== 'disabled' ) {\n\t\t\tresult.push( { clientId, innerBlocks } );\n\t\t} else {\n\t\t\tresult.push( ...innerBlocks );\n\t\t}\n\t}\n\n\treturn result;\n}\n\n/**\n * Returns a tree of block objects with only clientID and innerBlocks set.\n * Blocks with a 'disabled' editing mode are not included.\n *\n * @param {Object} state Global application state.\n * @param {?string} rootClientId Optional root client ID of block list.\n *\n * @return {Object[]} Tree of block objects with only clientID and innerBlocks set.\n */\nexport const getEnabledClientIdsTree = createRegistrySelector( () =>\n\tcreateSelector( getEnabledClientIdsTreeUnmemoized, ( state ) => [\n\t\tstate.blocks.order,\n\t\tstate.derivedBlockEditingModes,\n\t\tstate.blockEditingModes,\n\t] )\n);\n\n/**\n * Returns a list of a given block's ancestors, from top to bottom. Blocks with\n * a 'disabled' editing mode are excluded.\n *\n * @see getBlockParents\n *\n * @param {Object} state Global application state.\n * @param {string} clientId The block client ID.\n * @param {boolean} ascending Order results from bottom to top (true) or top\n * to bottom (false).\n */\nexport const getEnabledBlockParents = createSelector(\n\t( state, clientId, ascending = false ) => {\n\t\treturn getBlockParents( state, clientId, ascending ).filter(\n\t\t\t( parent ) => getBlockEditingMode( state, parent ) !== 'disabled'\n\t\t);\n\t},\n\t( state ) => [\n\t\tstate.blocks.parents,\n\t\tstate.blockEditingModes,\n\t\tstate.settings.templateLock,\n\t\tstate.blockListSettings,\n\t]\n);\n\n/**\n * Selector that returns the data needed to display a prompt when certain\n * blocks are removed, or `false` if no such prompt is requested.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object|false} Data for removal prompt display, if any.\n */\nexport function getRemovalPromptData( state ) {\n\treturn state.removalPromptData;\n}\n\n/**\n * Returns true if removal prompt exists, or false otherwise.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether removal prompt exists.\n */\nexport function getBlockRemovalRules( state ) {\n\treturn state.blockRemovalRules;\n}\n\n/**\n * Returns the client ID of the block settings menu that is currently open.\n *\n * @param {Object} state Global application state.\n * @return {string|null} The client ID of the block menu that is currently open.\n */\nexport function getOpenedBlockSettingsMenu( state ) {\n\treturn state.openedBlockSettingsMenu;\n}\n\n/**\n * Returns all style overrides, intended to be merged with global editor styles.\n *\n * Overrides are sorted to match the order of the blocks they relate to. This\n * is useful to maintain correct CSS cascade order.\n *\n * @param {Object} state Global application state.\n *\n * @return {Array} An array of style ID to style override pairs.\n */\nexport const getStyleOverrides = createSelector(\n\t( state ) => {\n\t\tconst clientIds = getClientIdsWithDescendants( state );\n\t\tconst clientIdMap = clientIds.reduce( ( acc, clientId, index ) => {\n\t\t\tacc[ clientId ] = index;\n\t\t\treturn acc;\n\t\t}, {} );\n\n\t\treturn [ ...state.styleOverrides ].sort( ( overrideA, overrideB ) => {\n\t\t\t// Once the overrides Map is spread to an array, the first element\n\t\t\t// is the key, while the second is the override itself including\n\t\t\t// the clientId to sort by.\n\t\t\tconst [ , { clientId: clientIdA } ] = overrideA;\n\t\t\tconst [ , { clientId: clientIdB } ] = overrideB;\n\n\t\t\tconst aIndex = clientIdMap[ clientIdA ] ?? -1;\n\t\t\tconst bIndex = clientIdMap[ clientIdB ] ?? -1;\n\n\t\t\treturn aIndex - bIndex;\n\t\t} );\n\t},\n\t( state ) => [ state.blocks.order, state.styleOverrides ]\n);\n\n/** @typedef {import('./actions').InserterMediaCategory} InserterMediaCategory */\n/**\n * Returns the registered inserter media categories through the public API.\n *\n * @param {Object} state Editor state.\n *\n * @return {InserterMediaCategory[]} Inserter media categories.\n */\nexport function getRegisteredInserterMediaCategories( state ) {\n\treturn state.registeredInserterMediaCategories;\n}\n\n/**\n * Returns an array containing the allowed inserter media categories.\n * It merges the registered media categories from extenders with the\n * core ones. It also takes into account the allowed `mime_types`, which\n * can be altered by `upload_mimes` filter and restrict some of them.\n *\n * @param {Object} state Global application state.\n *\n * @return {InserterMediaCategory[]} Client IDs of descendants.\n */\nexport const getInserterMediaCategories = createSelector(\n\t( state ) => {\n\t\tconst {\n\t\t\tsettings: {\n\t\t\t\tinserterMediaCategories,\n\t\t\t\tallowedMimeTypes,\n\t\t\t\tenableOpenverseMediaCategory,\n\t\t\t},\n\t\t\tregisteredInserterMediaCategories,\n\t\t} = state;\n\t\t// The allowed `mime_types` can be altered by `upload_mimes` filter and restrict\n\t\t// some of them. In this case we shouldn't add the category to the available media\n\t\t// categories list in the inserter.\n\t\tif (\n\t\t\t( ! inserterMediaCategories &&\n\t\t\t\t! registeredInserterMediaCategories.length ) ||\n\t\t\t! allowedMimeTypes\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\tconst coreInserterMediaCategoriesNames =\n\t\t\tinserterMediaCategories?.map( ( { name } ) => name ) || [];\n\t\tconst mergedCategories = [\n\t\t\t...( inserterMediaCategories || [] ),\n\t\t\t...( registeredInserterMediaCategories || [] ).filter(\n\t\t\t\t( { name } ) =>\n\t\t\t\t\t! coreInserterMediaCategoriesNames.includes( name )\n\t\t\t),\n\t\t];\n\t\treturn mergedCategories.filter( ( category ) => {\n\t\t\t// Check if Openverse category is enabled.\n\t\t\tif (\n\t\t\t\t! enableOpenverseMediaCategory &&\n\t\t\t\tcategory.name === 'openverse'\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\treturn Object.values( allowedMimeTypes ).some( ( mimeType ) =>\n\t\t\t\tmimeType.startsWith( `${ category.mediaType }/` )\n\t\t\t);\n\t\t} );\n\t},\n\t( state ) => [\n\t\tstate.settings.inserterMediaCategories,\n\t\tstate.settings.allowedMimeTypes,\n\t\tstate.settings.enableOpenverseMediaCategory,\n\t\tstate.registeredInserterMediaCategories,\n\t]\n);\n\n/**\n * Returns whether there is at least one allowed pattern for inner blocks children.\n * This is useful for deferring the parsing of all patterns until needed.\n *\n * @param {Object} state Editor state.\n * @param {string} [rootClientId=null] Target root client ID.\n *\n * @return {boolean} If there is at least one allowed pattern.\n */\nexport const hasAllowedPatterns = createRegistrySelector( ( select ) =>\n\tcreateSelector(\n\t\t( state, rootClientId = null ) => {\n\t\t\tconst { getAllPatterns } = unlock( select( STORE_NAME ) );\n\t\t\tconst patterns = getAllPatterns();\n\t\t\tconst { allowedBlockTypes } = getSettings( state );\n\t\t\treturn patterns.some( ( pattern ) => {\n\t\t\t\tconst { inserter = true } = pattern;\n\t\t\t\tif ( ! inserter ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tconst grammar = getGrammar( pattern );\n\t\t\t\treturn (\n\t\t\t\t\tcheckAllowListRecursive( grammar, allowedBlockTypes ) &&\n\t\t\t\t\tgrammar.every( ( { name: blockName } ) =>\n\t\t\t\t\t\tcanInsertBlockType( state, blockName, rootClientId )\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t} );\n\t\t},\n\t\t( state, rootClientId ) => [\n\t\t\t...getAllPatternsDependants( select )( state ),\n\t\t\t...getInsertBlockTypeDependants( select )( state, rootClientId ),\n\t\t]\n\t)\n);\n\nexport const getPatternBySlug = createRegistrySelector( ( select ) =>\n\tcreateSelector(\n\t\t( state, patternName ) => {\n\t\t\t// Only fetch reusable blocks if we know we need them. To do: maybe\n\t\t\t// use the entity record API to retrieve the block by slug.\n\t\t\tif ( patternName?.startsWith( 'core/block/' ) ) {\n\t\t\t\tconst _id = parseInt(\n\t\t\t\t\tpatternName.slice( 'core/block/'.length ),\n\t\t\t\t\t10\n\t\t\t\t);\n\t\t\t\tconst block = unlock( select( STORE_NAME ) )\n\t\t\t\t\t.getReusableBlocks()\n\t\t\t\t\t.find( ( { id } ) => id === _id );\n\n\t\t\t\tif ( ! block ) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\treturn mapUserPattern(\n\t\t\t\t\tblock,\n\t\t\t\t\tstate.settings.__experimentalUserPatternCategories\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn [\n\t\t\t\t// This setting is left for back compat.\n\t\t\t\t...( state.settings.__experimentalBlockPatterns ?? [] ),\n\t\t\t\t...( state.settings[ selectBlockPatternsKey ]?.( select ) ??\n\t\t\t\t\t[] ),\n\t\t\t].find( ( { name } ) => name === patternName );\n\t\t},\n\t\t( state, patternName ) =>\n\t\t\tpatternName?.startsWith( 'core/block/' )\n\t\t\t\t? [\n\t\t\t\t\t\tunlock( select( STORE_NAME ) ).getReusableBlocks(),\n\t\t\t\t\t\tstate.settings.__experimentalReusableBlocks,\n\t\t\t\t ]\n\t\t\t\t: [\n\t\t\t\t\t\tstate.settings.__experimentalBlockPatterns,\n\t\t\t\t\t\tstate.settings[ selectBlockPatternsKey ]?.( select ),\n\t\t\t\t ]\n\t)\n);\n\nexport const getAllPatterns = createRegistrySelector( ( select ) =>\n\tcreateSelector( ( state ) => {\n\t\treturn [\n\t\t\t...unlock( select( STORE_NAME ) )\n\t\t\t\t.getReusableBlocks()\n\t\t\t\t.map( ( userPattern ) =>\n\t\t\t\t\tmapUserPattern(\n\t\t\t\t\t\tuserPattern,\n\t\t\t\t\t\tstate.settings.__experimentalUserPatternCategories\n\t\t\t\t\t)\n\t\t\t\t),\n\t\t\t// This setting is left for back compat.\n\t\t\t...( state.settings.__experimentalBlockPatterns ?? [] ),\n\t\t\t...( state.settings[ selectBlockPatternsKey ]?.( select ) ?? [] ),\n\t\t].filter(\n\t\t\t( x, index, arr ) =>\n\t\t\t\tindex === arr.findIndex( ( y ) => x.name === y.name )\n\t\t);\n\t}, getAllPatternsDependants( select ) )\n);\n\nconst EMPTY_ARRAY = [];\n\nexport const getReusableBlocks = createRegistrySelector(\n\t( select ) => ( state ) => {\n\t\tconst reusableBlocksSelect = state.settings[ reusableBlocksSelectKey ];\n\t\treturn (\n\t\t\t( reusableBlocksSelect\n\t\t\t\t? reusableBlocksSelect( select )\n\t\t\t\t: state.settings.__experimentalReusableBlocks ) ?? EMPTY_ARRAY\n\t\t);\n\t}\n);\n\n/**\n * Returns the element of the last element that had focus when focus left the editor canvas.\n *\n * @param {Object} state Block editor state.\n *\n * @return {Object} Element.\n */\nexport function getLastFocus( state ) {\n\treturn state.lastFocus;\n}\n\n/**\n * Returns true if the user is dragging anything, or false otherwise. It is possible for a\n * user to be dragging data from outside of the editor, so this selector is separate from\n * the `isDraggingBlocks` selector which only returns true if the user is dragging blocks.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether user is dragging.\n */\nexport function isDragging( state ) {\n\treturn state.isDragging;\n}\n\n/**\n * Retrieves the expanded block from the state.\n *\n * @param {Object} state Block editor state.\n *\n * @return {string|null} The client ID of the expanded block, if set.\n */\nexport function getExpandedBlock( state ) {\n\treturn state.expandedBlock;\n}\n\n/**\n * Retrieves the client ID of the ancestor block that is content locking the block\n * with the provided client ID.\n *\n * @param {Object} state Global application state.\n * @param {string} clientId Client Id of the block.\n *\n * @return {?string} Client ID of the ancestor block that is content locking the block.\n */\nexport const getContentLockingParent = ( state, clientId ) => {\n\tlet current = clientId;\n\tlet result;\n\twhile ( ! result && ( current = state.blocks.parents.get( current ) ) ) {\n\t\tif ( getTemplateLock( state, current ) === 'contentOnly' ) {\n\t\t\tresult = current;\n\t\t}\n\t}\n\treturn result;\n};\n\n/**\n * Retrieves the client ID of the parent section block.\n *\n * @param {Object} state Global application state.\n * @param {string} clientId Client Id of the block.\n *\n * @return {?string} Client ID of the ancestor block that is content locking the block.\n */\nexport const getParentSectionBlock = ( state, clientId ) => {\n\tlet current = clientId;\n\tlet result;\n\twhile ( ! result && ( current = state.blocks.parents.get( current ) ) ) {\n\t\tif ( isSectionBlock( state, current ) ) {\n\t\t\tresult = current;\n\t\t}\n\t}\n\treturn result;\n};\n\n/**\n * Retrieves the client ID is a content locking parent\n *\n * @param {Object} state Global application state.\n * @param {string} clientId Client Id of the block.\n *\n * @return {boolean} Whether the block is a content locking parent.\n */\nexport function isSectionBlock( state, clientId ) {\n\tconst blockName = getBlockName( state, clientId );\n\tif (\n\t\tblockName === 'core/block' ||\n\t\tgetTemplateLock( state, clientId ) === 'contentOnly'\n\t) {\n\t\treturn true;\n\t}\n\n\tconst attributes = getBlockAttributes( state, clientId );\n\tconst isTemplatePart = blockName === 'core/template-part';\n\tif (\n\t\t( attributes?.metadata?.patternName || isTemplatePart ) &&\n\t\t!! window?.__experimentalContentOnlyPatternInsertion\n\t) {\n\t\treturn true;\n\t}\n\treturn false;\n}\n\n/**\n * Retrieves the client ID of the block that is content locked but is\n * currently being temporarily edited as a non-locked block.\n *\n * @param {Object} state Global application state.\n *\n * @return {?string} The client ID of the block being temporarily edited as a non-locked block.\n */\nexport function getTemporarilyEditingAsBlocks( state ) {\n\treturn state.temporarilyEditingAsBlocks;\n}\n\n/**\n * Returns the focus mode that should be reapplied when the user stops editing\n * a content locked blocks as a block without locking.\n *\n * @param {Object} state Global application state.\n *\n * @return {?string} The focus mode that should be re-set when temporarily editing as blocks stops.\n */\nexport function getTemporarilyEditingFocusModeToRevert( state ) {\n\treturn state.temporarilyEditingFocusModeRevert;\n}\n\n/**\n * Returns the style attributes of multiple blocks.\n *\n * @param {Object} state Global application state.\n * @param {string[]} clientIds An array of block client IDs.\n *\n * @return {Object} An object where keys are client IDs and values are the corresponding block styles or undefined.\n */\nexport const getBlockStyles = createSelector(\n\t( state, clientIds ) =>\n\t\tclientIds.reduce( ( styles, clientId ) => {\n\t\t\tstyles[ clientId ] = state.blocks.attributes.get( clientId )?.style;\n\t\t\treturn styles;\n\t\t}, {} ),\n\t( state, clientIds ) => [\n\t\t...clientIds.map(\n\t\t\t( clientId ) => state.blocks.attributes.get( clientId )?.style\n\t\t),\n\t]\n);\n\n/**\n * Retrieves the client ID of the block which contains the blocks\n * acting as \"sections\" in the editor. This is typically the \"main content\"\n * of the template/post.\n *\n * @param {Object} state Editor state.\n *\n * @return {string|undefined} The section root client ID or undefined if not set.\n */\nexport function getSectionRootClientId( state ) {\n\treturn state.settings?.[ sectionRootClientIdKey ];\n}\n\n/**\n * Returns whether the editor is considered zoomed out.\n *\n * @param {Object} state Global application state.\n * @return {boolean} Whether the editor is zoomed.\n */\nexport function isZoomOut( state ) {\n\treturn state.zoomLevel === 'auto-scaled' || state.zoomLevel < 100;\n}\n\n/**\n * Returns whether the zoom level.\n *\n * @param {Object} state Global application state.\n * @return {number|\"auto-scaled\"} Zoom level.\n */\nexport function getZoomLevel( state ) {\n\treturn state.zoomLevel;\n}\n\n/**\n * Finds the closest block where the block is allowed to be inserted.\n *\n * @param {Object} state Editor state.\n * @param {string[] | string} name Block name or names.\n * @param {string} clientId Default insertion point.\n *\n * @return {string} clientID of the closest container when the block name can be inserted.\n */\nexport function getClosestAllowedInsertionPoint( state, name, clientId = '' ) {\n\tconst blockNames = Array.isArray( name ) ? name : [ name ];\n\tconst areBlockNamesAllowedInClientId = ( id ) =>\n\t\tblockNames.every( ( currentName ) =>\n\t\t\tcanInsertBlockType( state, currentName, id )\n\t\t);\n\n\t// If we're trying to insert at the root level and it's not allowed\n\t// Try the section root instead.\n\tif ( ! clientId ) {\n\t\tif ( areBlockNamesAllowedInClientId( clientId ) ) {\n\t\t\treturn clientId;\n\t\t}\n\n\t\tconst sectionRootClientId = getSectionRootClientId( state );\n\t\tif (\n\t\t\tsectionRootClientId &&\n\t\t\tareBlockNamesAllowedInClientId( sectionRootClientId )\n\t\t) {\n\t\t\treturn sectionRootClientId;\n\t\t}\n\t\treturn null;\n\t}\n\n\t// Traverse the block tree up until we find a place where we can insert.\n\tlet current = clientId;\n\twhile ( current !== null && ! areBlockNamesAllowedInClientId( current ) ) {\n\t\tconst parentClientId = getBlockRootClientId( state, current );\n\t\tcurrent = parentClientId;\n\t}\n\n\treturn current;\n}\n\nexport function getClosestAllowedInsertionPointForPattern(\n\tstate,\n\tpattern,\n\tclientId\n) {\n\tconst { allowedBlockTypes } = getSettings( state );\n\tconst isAllowed = checkAllowListRecursive(\n\t\tgetGrammar( pattern ),\n\t\tallowedBlockTypes\n\t);\n\tif ( ! isAllowed ) {\n\t\treturn null;\n\t}\n\tconst names = getGrammar( pattern ).map( ( { blockName: name } ) => name );\n\treturn getClosestAllowedInsertionPoint( state, names, clientId );\n}\n\n/**\n * Where the point where the next block will be inserted into.\n *\n * @param {Object} state\n * @return {Object} where the insertion point in the block editor is or null if none is set.\n */\nexport function getInsertionPoint( state ) {\n\treturn state.insertionPoint;\n}\n\n/**\n * Returns true if the block is hidden, or false otherwise.\n *\n * @param {Object} state Global application state.\n * @param {string} clientId Client ID of the block.\n *\n * @return {boolean} Whether the block is hidden.\n */\nexport const isBlockHidden = ( state, clientId ) => {\n\tconst blockName = getBlockName( state, clientId );\n\tif ( ! hasBlockSupport( state, blockName, 'blockVisibility', true ) ) {\n\t\treturn false;\n\t}\n\tconst attributes = state.blocks.attributes.get( clientId );\n\treturn attributes?.metadata?.blockVisibility === false;\n};\n\n/**\n * Returns true if the current spotlighted block matches the block clientId.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether the block is currently spotlighted.\n */\nexport function hasBlockSpotlight( state ) {\n\treturn !! state.hasBlockSpotlight;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;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nB,qCAAoB,OAAO,aAAa,EAAG;AAAA,EAC5C;AAID,MAAK,CAAE,UAAW;AACjB,QAAK,+BAAgC,QAAS,GAAI;AACjD,aAAO;AAAA,IACR;AAEA,UAAM,sBAAsB,uBAAwB,KAAM;AAC1D,QACC,uBACA,+BAAgC,mBAAoB,GACnD;AACD,aAAO;AAAA,IACR;AACA,WAAO;AAAA,EACR;AAGA,MAAI,UAAU;AACd,SAAQ,YAAY,QAAQ,CAAE,+BAAgC,OAAQ,GAAI;AACzE,UAAM,qBAAiB,uCAAsB,OAAO,OAAQ;AAC5D,cAAU;AAAA,EACX;AAEA,SAAO;AACR;AAEO,SAAS,0CACf,OACA,SACA,UACC;AACD,QAAM,EAAE,kBAAkB,QAAI,8BAAa,KAAM;AACjD,QAAM,gBAAY;AAAA,QACjB,yBAAY,OAAQ;AAAA,IACpB;AAAA,EACD;AACA,MAAK,CAAE,WAAY;AAClB,WAAO;AAAA,EACR;AACA,QAAM,YAAQ,yBAAY,OAAQ,EAAE,IAAK,CAAE,EAAE,WAAW,KAAK,MAAO,IAAK;AACzE,SAAO,gCAAiC,OAAO,OAAO,QAAS;AAChE;AAQO,SAAS,kBAAmB,OAAQ;AAC1C,SAAO,MAAM;AACd;AAUO,MAAM,gBAAgB,CAAE,OAAO,aAAc;AACnD,QAAM,gBAAY,+BAAc,OAAO,QAAS;AAChD,MAAK,KAAE,+BAAiB,OAAO,WAAW,mBAAmB,IAAK,GAAI;AACrE,WAAO;AAAA,EACR;AACA,QAAM,aAAa,MAAM,OAAO,WAAW,IAAK,QAAS;AACzD,SAAO,YAAY,UAAU,oBAAoB;AAClD;AASO,SAAS,kBAAmB,OAAQ;AAC1C,SAAO,CAAC,CAAE,MAAM;AACjB;",
6
6
  "names": ["blocksPrivateApis", "getAllPatterns"]
7
7
  }
@@ -842,13 +842,7 @@ const canInsertBlockTypeUnmemoized = (state, blockName, rootClientId = null) =>
842
842
  } else {
843
843
  blockType = (0, import_blocks.getBlockType)(blockName);
844
844
  }
845
- const isLocked = !!getTemplateLock(state, rootClientId);
846
- if (isLocked) {
847
- return false;
848
- }
849
- const isContentRoleBlock = isContentBlock(blockName);
850
- const isParentSectionBlock = !!(0, import_private_selectors.isSectionBlock)(state, rootClientId);
851
- if (isParentSectionBlock && !isContentRoleBlock) {
845
+ if (getTemplateLock(state, rootClientId)) {
852
846
  return false;
853
847
  }
854
848
  const blockEditingMode = getBlockEditingMode(state, rootClientId ?? "");
@@ -859,7 +853,20 @@ const canInsertBlockTypeUnmemoized = (state, blockName, rootClientId = null) =>
859
853
  if (rootClientId && parentBlockListSettings === void 0) {
860
854
  return false;
861
855
  }
862
- if (blockEditingMode === "contentOnly" && !(0, import_private_selectors.isContainerInsertableToInWriteMode)(state, blockName, rootClientId)) {
856
+ const isContentRoleBlock = isContentBlock(blockName);
857
+ const isParentSectionBlock = !!(0, import_private_selectors.isSectionBlock)(state, rootClientId);
858
+ const isBlockWithinSection = !!(0, import_private_selectors.getParentSectionBlock)(
859
+ state,
860
+ rootClientId
861
+ );
862
+ if ((isParentSectionBlock || isBlockWithinSection) && !isContentRoleBlock) {
863
+ return false;
864
+ }
865
+ if ((isParentSectionBlock || blockEditingMode === "contentOnly") && !(0, import_private_selectors.isContainerInsertableToInContentOnlyMode)(
866
+ state,
867
+ blockName,
868
+ rootClientId
869
+ )) {
863
870
  return false;
864
871
  }
865
872
  const parentName = getBlockName(state, rootClientId);
@@ -949,15 +956,16 @@ function canRemoveBlock(state, clientId) {
949
956
  if (isBlockWithinSection && !isContentRoleBlock) {
950
957
  return false;
951
958
  }
952
- const blockEditingMode = getBlockEditingMode(state, rootClientId);
953
- if (blockEditingMode === "contentOnly" && !(0, import_private_selectors.isContainerInsertableToInWriteMode)(
959
+ const isParentSectionBlock = !!(0, import_private_selectors.isSectionBlock)(state, rootClientId);
960
+ const rootBlockEditingMode = getBlockEditingMode(state, rootClientId);
961
+ if ((isParentSectionBlock || rootBlockEditingMode === "contentOnly") && !(0, import_private_selectors.isContainerInsertableToInContentOnlyMode)(
954
962
  state,
955
- getBlockName(state, rootClientId),
963
+ getBlockName(state, clientId),
956
964
  rootClientId
957
965
  )) {
958
966
  return false;
959
967
  }
960
- return blockEditingMode !== "disabled";
968
+ return rootBlockEditingMode !== "disabled";
961
969
  }
962
970
  function canRemoveBlocks(state, clientIds) {
963
971
  return clientIds.every((clientId) => canRemoveBlock(state, clientId));
@@ -971,7 +979,24 @@ function canMoveBlock(state, clientId) {
971
979
  return !attributes.lock.move;
972
980
  }
973
981
  const rootClientId = getBlockRootClientId(state, clientId);
974
- if (getTemplateLock(state, rootClientId) === "all") {
982
+ const templateLock = getTemplateLock(state, rootClientId);
983
+ if (templateLock === "all" || templateLock === "contentOnly") {
984
+ return false;
985
+ }
986
+ const isBlockWithinSection = !!(0, import_private_selectors.getParentSectionBlock)(state, clientId);
987
+ const isContentRoleBlock = isContentBlock(
988
+ getBlockName(state, clientId)
989
+ );
990
+ if (isBlockWithinSection && !isContentRoleBlock) {
991
+ return false;
992
+ }
993
+ const isParentSectionBlock = !!(0, import_private_selectors.isSectionBlock)(state, rootClientId);
994
+ const rootBlockEditingMode = getBlockEditingMode(state, rootClientId);
995
+ if ((isParentSectionBlock || rootBlockEditingMode === "contentOnly") && !(0, import_private_selectors.isContainerInsertableToInContentOnlyMode)(
996
+ state,
997
+ getBlockName(state, clientId),
998
+ rootClientId
999
+ )) {
975
1000
  return false;
976
1001
  }
977
1002
  return getBlockEditingMode(state, rootClientId) !== "disabled";