@wordpress/block-editor 14.6.0 → 14.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 (187) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/block-list/block.js +14 -28
  3. package/build/components/block-list/block.js.map +1 -1
  4. package/build/components/block-patterns-list/index.js +23 -26
  5. package/build/components/block-patterns-list/index.js.map +1 -1
  6. package/build/components/block-popover/index.js +1 -1
  7. package/build/components/block-popover/index.js.map +1 -1
  8. package/build/components/block-preview/async.js +51 -0
  9. package/build/components/block-preview/async.js.map +1 -0
  10. package/build/components/block-preview/index.js +4 -1
  11. package/build/components/block-preview/index.js.map +1 -1
  12. package/build/components/block-toolbar/change-design.js +1 -4
  13. package/build/components/block-toolbar/change-design.js.map +1 -1
  14. package/build/components/block-tools/index.js +12 -9
  15. package/build/components/block-tools/index.js.map +1 -1
  16. package/build/components/block-tools/use-block-toolbar-popover-props.js +1 -1
  17. package/build/components/block-tools/use-block-toolbar-popover-props.js.map +1 -1
  18. package/build/components/block-tools/use-show-block-tools.js +4 -1
  19. package/build/components/block-tools/use-show-block-tools.js.map +1 -1
  20. package/build/components/global-styles/dimensions-panel.js +26 -14
  21. package/build/components/global-styles/dimensions-panel.js.map +1 -1
  22. package/build/components/iframe/get-compatibility-styles.js +4 -4
  23. package/build/components/iframe/get-compatibility-styles.js.map +1 -1
  24. package/build/components/iframe/index.js +16 -0
  25. package/build/components/iframe/index.js.map +1 -1
  26. package/build/components/inserter/block-patterns-explorer/pattern-list.js +2 -2
  27. package/build/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -1
  28. package/build/components/inserter/block-patterns-tab/index.js +1 -2
  29. package/build/components/inserter/block-patterns-tab/index.js.map +1 -1
  30. package/build/components/inserter/block-patterns-tab/pattern-category-previews.js +3 -1
  31. package/build/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -1
  32. package/build/components/inserter/block-patterns-tab/use-pattern-categories.js +3 -0
  33. package/build/components/inserter/block-patterns-tab/use-pattern-categories.js.map +1 -1
  34. package/build/components/inserter/block-patterns-tab/utils.js +5 -1
  35. package/build/components/inserter/block-patterns-tab/utils.js.map +1 -1
  36. package/build/components/inserter/hooks/use-block-types-state.js +1 -1
  37. package/build/components/inserter/hooks/use-block-types-state.js.map +1 -1
  38. package/build/components/inserter/hooks/use-patterns-paging.js +0 -5
  39. package/build/components/inserter/hooks/use-patterns-paging.js.map +1 -1
  40. package/build/components/inserter/search-results.js +0 -2
  41. package/build/components/inserter/search-results.js.map +1 -1
  42. package/build/components/media-placeholder/index.js +4 -4
  43. package/build/components/media-placeholder/index.js.map +1 -1
  44. package/build/components/rich-text/index.js +1 -1
  45. package/build/components/rich-text/index.js.map +1 -1
  46. package/build/components/tabbed-sidebar/index.js +1 -1
  47. package/build/components/tabbed-sidebar/index.js.map +1 -1
  48. package/build/components/url-input/index.js +3 -1
  49. package/build/components/url-input/index.js.map +1 -1
  50. package/build/components/use-block-commands/index.js +5 -6
  51. package/build/components/use-block-commands/index.js.map +1 -1
  52. package/build/hooks/font-family.js +1 -1
  53. package/build/hooks/font-family.js.map +1 -1
  54. package/build/hooks/supports.js +6 -6
  55. package/build/hooks/supports.js.map +1 -1
  56. package/build/hooks/typography.js +5 -5
  57. package/build/hooks/typography.js.map +1 -1
  58. package/build/hooks/utils.js +2 -2
  59. package/build/hooks/utils.js.map +1 -1
  60. package/build/lock-unlock.js.map +1 -1
  61. package/build/store/private-selectors.js +2 -2
  62. package/build/store/private-selectors.js.map +1 -1
  63. package/build/store/selectors.js +9 -8
  64. package/build/store/selectors.js.map +1 -1
  65. package/build/store/utils.js +5 -4
  66. package/build/store/utils.js.map +1 -1
  67. package/build/utils/dom.js +27 -22
  68. package/build/utils/dom.js.map +1 -1
  69. package/build-module/components/block-list/block.js +15 -27
  70. package/build-module/components/block-list/block.js.map +1 -1
  71. package/build-module/components/block-patterns-list/index.js +23 -26
  72. package/build-module/components/block-patterns-list/index.js.map +1 -1
  73. package/build-module/components/block-popover/index.js +2 -2
  74. package/build-module/components/block-popover/index.js.map +1 -1
  75. package/build-module/components/block-preview/async.js +44 -0
  76. package/build-module/components/block-preview/async.js.map +1 -0
  77. package/build-module/components/block-preview/index.js +4 -1
  78. package/build-module/components/block-preview/index.js.map +1 -1
  79. package/build-module/components/block-toolbar/change-design.js +1 -4
  80. package/build-module/components/block-toolbar/change-design.js.map +1 -1
  81. package/build-module/components/block-tools/index.js +13 -10
  82. package/build-module/components/block-tools/index.js.map +1 -1
  83. package/build-module/components/block-tools/use-block-toolbar-popover-props.js +2 -2
  84. package/build-module/components/block-tools/use-block-toolbar-popover-props.js.map +1 -1
  85. package/build-module/components/block-tools/use-show-block-tools.js +4 -1
  86. package/build-module/components/block-tools/use-show-block-tools.js.map +1 -1
  87. package/build-module/components/global-styles/dimensions-panel.js +26 -14
  88. package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
  89. package/build-module/components/iframe/get-compatibility-styles.js +4 -4
  90. package/build-module/components/iframe/get-compatibility-styles.js.map +1 -1
  91. package/build-module/components/iframe/index.js +16 -0
  92. package/build-module/components/iframe/index.js.map +1 -1
  93. package/build-module/components/inserter/block-patterns-explorer/pattern-list.js +2 -2
  94. package/build-module/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -1
  95. package/build-module/components/inserter/block-patterns-tab/index.js +1 -2
  96. package/build-module/components/inserter/block-patterns-tab/index.js.map +1 -1
  97. package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js +4 -2
  98. package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -1
  99. package/build-module/components/inserter/block-patterns-tab/use-pattern-categories.js +4 -1
  100. package/build-module/components/inserter/block-patterns-tab/use-pattern-categories.js.map +1 -1
  101. package/build-module/components/inserter/block-patterns-tab/utils.js +4 -0
  102. package/build-module/components/inserter/block-patterns-tab/utils.js.map +1 -1
  103. package/build-module/components/inserter/hooks/use-block-types-state.js +1 -1
  104. package/build-module/components/inserter/hooks/use-block-types-state.js.map +1 -1
  105. package/build-module/components/inserter/hooks/use-patterns-paging.js +1 -6
  106. package/build-module/components/inserter/hooks/use-patterns-paging.js.map +1 -1
  107. package/build-module/components/inserter/search-results.js +0 -2
  108. package/build-module/components/inserter/search-results.js.map +1 -1
  109. package/build-module/components/media-placeholder/index.js +4 -4
  110. package/build-module/components/media-placeholder/index.js.map +1 -1
  111. package/build-module/components/rich-text/index.js +1 -1
  112. package/build-module/components/rich-text/index.js.map +1 -1
  113. package/build-module/components/tabbed-sidebar/index.js +1 -1
  114. package/build-module/components/tabbed-sidebar/index.js.map +1 -1
  115. package/build-module/components/url-input/index.js +3 -1
  116. package/build-module/components/url-input/index.js.map +1 -1
  117. package/build-module/components/use-block-commands/index.js +4 -4
  118. package/build-module/components/use-block-commands/index.js.map +1 -1
  119. package/build-module/hooks/font-family.js +1 -1
  120. package/build-module/hooks/font-family.js.map +1 -1
  121. package/build-module/hooks/supports.js +6 -6
  122. package/build-module/hooks/supports.js.map +1 -1
  123. package/build-module/hooks/typography.js +5 -5
  124. package/build-module/hooks/typography.js.map +1 -1
  125. package/build-module/hooks/utils.js +2 -2
  126. package/build-module/hooks/utils.js.map +1 -1
  127. package/build-module/lock-unlock.js.map +1 -1
  128. package/build-module/store/private-selectors.js +2 -2
  129. package/build-module/store/private-selectors.js.map +1 -1
  130. package/build-module/store/selectors.js +9 -8
  131. package/build-module/store/selectors.js.map +1 -1
  132. package/build-module/store/utils.js +3 -3
  133. package/build-module/store/utils.js.map +1 -1
  134. package/build-module/utils/dom.js +25 -21
  135. package/build-module/utils/dom.js.map +1 -1
  136. package/build-style/content-rtl.css +7 -6
  137. package/build-style/content.css +7 -6
  138. package/build-style/style-rtl.css +14 -3
  139. package/build-style/style.css +14 -3
  140. package/build-types/utils/dom.d.ts +7 -9
  141. package/build-types/utils/dom.d.ts.map +1 -1
  142. package/package.json +4 -3
  143. package/src/components/block-canvas/style.scss +1 -1
  144. package/src/components/block-inspector/style.scss +2 -1
  145. package/src/components/block-list/block.js +28 -48
  146. package/src/components/block-patterns-list/README.md +8 -8
  147. package/src/components/block-patterns-list/index.js +35 -51
  148. package/src/components/block-patterns-list/stories/index.story.js +2 -19
  149. package/src/components/block-popover/index.js +4 -4
  150. package/src/components/block-preview/async.js +43 -0
  151. package/src/components/block-preview/index.js +6 -1
  152. package/src/components/block-toolbar/change-design.js +1 -7
  153. package/src/components/block-tools/index.js +26 -10
  154. package/src/components/block-tools/style.scss +12 -0
  155. package/src/components/block-tools/use-block-toolbar-popover-props.js +2 -2
  156. package/src/components/block-tools/use-show-block-tools.js +3 -1
  157. package/src/components/default-block-appender/content.scss +13 -19
  158. package/src/components/global-styles/dimensions-panel.js +22 -16
  159. package/src/components/iframe/get-compatibility-styles.js +4 -9
  160. package/src/components/iframe/index.js +17 -0
  161. package/src/components/inserter/block-patterns-explorer/pattern-list.js +3 -6
  162. package/src/components/inserter/block-patterns-tab/index.js +0 -1
  163. package/src/components/inserter/block-patterns-tab/pattern-category-previews.js +8 -1
  164. package/src/components/inserter/block-patterns-tab/use-pattern-categories.js +8 -0
  165. package/src/components/inserter/block-patterns-tab/utils.js +5 -0
  166. package/src/components/inserter/hooks/use-block-types-state.js +6 -1
  167. package/src/components/inserter/hooks/use-patterns-paging.js +1 -6
  168. package/src/components/inserter/search-results.js +0 -6
  169. package/src/components/media-placeholder/index.js +4 -4
  170. package/src/components/rich-text/index.js +8 -1
  171. package/src/components/tabbed-sidebar/index.js +1 -1
  172. package/src/components/tabbed-sidebar/style.scss +1 -1
  173. package/src/components/url-input/index.js +3 -4
  174. package/src/components/use-block-commands/index.js +245 -234
  175. package/src/hooks/font-family.js +1 -1
  176. package/src/hooks/supports.js +6 -6
  177. package/src/hooks/typography.js +5 -5
  178. package/src/hooks/utils.js +7 -2
  179. package/src/store/private-selectors.js +5 -6
  180. package/src/store/selectors.js +57 -45
  181. package/src/store/test/private-selectors.js +5 -0
  182. package/src/store/utils.js +12 -11
  183. package/src/utils/dom.js +26 -21
  184. package/src/utils/test/dom.js +224 -0
  185. package/tsconfig.json +1 -0
  186. package/tsconfig.tsbuildinfo +1 -1
  187. /package/src/{lock-unlock.js → lock-unlock.ts} +0 -0
@@ -87,7 +87,7 @@ export const checkAllowListRecursive = (blocks, allowedBlockTypes) => {
87
87
  export const getAllPatternsDependants = select => state => {
88
88
  return [state.settings.__experimentalBlockPatterns, state.settings.__experimentalUserPatternCategories, state.settings.__experimentalReusableBlocks, state.settings[selectBlockPatternsKey]?.(select), state.blockPatterns, unlock(select(STORE_NAME)).getReusableBlocks()];
89
89
  };
90
- export function getInsertBlockTypeDependants(state, rootClientId) {
91
- return [state.blockListSettings[rootClientId], state.blocks.byClientId.get(rootClientId), state.settings.allowedBlockTypes, state.settings.templateLock, state.blockEditingModes, state.editorMode, getSectionRootClientId(state)];
92
- }
90
+ export const getInsertBlockTypeDependants = select => (state, rootClientId) => {
91
+ return [state.blockListSettings[rootClientId], state.blocks.byClientId.get(rootClientId), state.settings.allowedBlockTypes, state.settings.templateLock, state.blockEditingModes, select(STORE_NAME).__unstableGetEditorMode(state), getSectionRootClientId(state)];
92
+ };
93
93
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["parse","grammarParse","selectBlockPatternsKey","unlock","STORE_NAME","getSectionRootClientId","isFiltered","Symbol","parsedPatternCache","WeakMap","grammarMapCache","parsePattern","pattern","blocks","content","__unstableSkipMigrationLogs","length","attributes","metadata","categories","patternName","name","title","getParsedPattern","parsedPattern","get","set","getGrammar","grammarMap","filter","block","blockName","checkAllowList","list","item","defaultResult","Array","isArray","includes","checkAllowListRecursive","allowedBlockTypes","blocksQueue","shift","isAllowed","innerBlocks","forEach","innerBlock","push","getAllPatternsDependants","select","state","settings","__experimentalBlockPatterns","__experimentalUserPatternCategories","__experimentalReusableBlocks","blockPatterns","getReusableBlocks","getInsertBlockTypeDependants","rootClientId","blockListSettings","byClientId","templateLock","blockEditingModes","editorMode"],"sources":["@wordpress/block-editor/src/store/utils.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { parse } from '@wordpress/blocks';\nimport { parse as grammarParse } from '@wordpress/block-serialization-default-parser';\n\n/**\n * Internal dependencies\n */\nimport { selectBlockPatternsKey } from './private-keys';\nimport { unlock } from '../lock-unlock';\nimport { STORE_NAME } from './constants';\nimport { getSectionRootClientId } from './private-selectors';\n\nexport const isFiltered = Symbol( 'isFiltered' );\nconst parsedPatternCache = new WeakMap();\nconst grammarMapCache = new WeakMap();\n\nfunction parsePattern( pattern ) {\n\tconst blocks = parse( pattern.content, {\n\t\t__unstableSkipMigrationLogs: true,\n\t} );\n\tif ( blocks.length === 1 ) {\n\t\tblocks[ 0 ].attributes = {\n\t\t\t...blocks[ 0 ].attributes,\n\t\t\tmetadata: {\n\t\t\t\t...( blocks[ 0 ].attributes.metadata || {} ),\n\t\t\t\tcategories: pattern.categories,\n\t\t\t\tpatternName: pattern.name,\n\t\t\t\tname: blocks[ 0 ].attributes.metadata?.name || pattern.title,\n\t\t\t},\n\t\t};\n\t}\n\treturn {\n\t\t...pattern,\n\t\tblocks,\n\t};\n}\n\nexport function getParsedPattern( pattern ) {\n\tlet parsedPattern = parsedPatternCache.get( pattern );\n\tif ( ! parsedPattern ) {\n\t\tparsedPattern = parsePattern( pattern );\n\t\tparsedPatternCache.set( pattern, parsedPattern );\n\t}\n\treturn parsedPattern;\n}\n\nexport function getGrammar( pattern ) {\n\tlet grammarMap = grammarMapCache.get( pattern );\n\tif ( ! grammarMap ) {\n\t\tgrammarMap = grammarParse( pattern.content );\n\t\t// Block names are null only at the top level for whitespace.\n\t\tgrammarMap = grammarMap.filter( ( block ) => block.blockName !== null );\n\t\tgrammarMapCache.set( pattern, grammarMap );\n\t}\n\treturn grammarMap;\n}\n\nexport const checkAllowList = ( list, item, defaultResult = null ) => {\n\tif ( typeof list === 'boolean' ) {\n\t\treturn list;\n\t}\n\tif ( Array.isArray( list ) ) {\n\t\t// TODO: when there is a canonical way to detect that we are editing a post\n\t\t// the following check should be changed to something like:\n\t\t// if ( list.includes( 'core/post-content' ) && getEditorMode() === 'post-content' && item === null )\n\t\tif ( list.includes( 'core/post-content' ) && item === null ) {\n\t\t\treturn true;\n\t\t}\n\t\treturn list.includes( item );\n\t}\n\treturn defaultResult;\n};\n\nexport const checkAllowListRecursive = ( blocks, allowedBlockTypes ) => {\n\tif ( typeof allowedBlockTypes === 'boolean' ) {\n\t\treturn allowedBlockTypes;\n\t}\n\n\tconst blocksQueue = [ ...blocks ];\n\twhile ( blocksQueue.length > 0 ) {\n\t\tconst block = blocksQueue.shift();\n\n\t\tconst isAllowed = checkAllowList(\n\t\t\tallowedBlockTypes,\n\t\t\tblock.name || block.blockName,\n\t\t\ttrue\n\t\t);\n\t\tif ( ! isAllowed ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tblock.innerBlocks?.forEach( ( innerBlock ) => {\n\t\t\tblocksQueue.push( innerBlock );\n\t\t} );\n\t}\n\n\treturn true;\n};\n\nexport const getAllPatternsDependants = ( select ) => ( state ) => {\n\treturn [\n\t\tstate.settings.__experimentalBlockPatterns,\n\t\tstate.settings.__experimentalUserPatternCategories,\n\t\tstate.settings.__experimentalReusableBlocks,\n\t\tstate.settings[ selectBlockPatternsKey ]?.( select ),\n\t\tstate.blockPatterns,\n\t\tunlock( select( STORE_NAME ) ).getReusableBlocks(),\n\t];\n};\n\nexport function getInsertBlockTypeDependants( state, rootClientId ) {\n\treturn [\n\t\tstate.blockListSettings[ rootClientId ],\n\t\tstate.blocks.byClientId.get( rootClientId ),\n\t\tstate.settings.allowedBlockTypes,\n\t\tstate.settings.templateLock,\n\t\tstate.blockEditingModes,\n\t\tstate.editorMode,\n\t\tgetSectionRootClientId( state ),\n\t];\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAK,QAAQ,mBAAmB;AACzC,SAASA,KAAK,IAAIC,YAAY,QAAQ,+CAA+C;;AAErF;AACA;AACA;AACA,SAASC,sBAAsB,QAAQ,gBAAgB;AAC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CAAEY,SAAS,EAAG;MAClB,OAAO,KAAK;IACb;IAEAb,KAAK,CAACc,WAAW,EAAEC,OAAO,CAAIC,UAAU,IAAM;MAC7CL,WAAW,CAACM,IAAI,CAAED,UAAW,CAAC;IAC/B,CAAE,CAAC;EACJ;EAEA,OAAO,IAAI;AACZ,CAAC;AAED,OAAO,MAAME,wBAAwB,GAAKC,MAAM,IAAQC,KAAK,IAAM;EAClE,OAAO,CACNA,KAAK,CAACC,QAAQ,CAACC,2BAA2B,EAC1CF,KAAK,CAACC,QAAQ,CAACE,mCAAmC,EAClDH,KAAK,CAACC,QAAQ,CAACG,4BAA4B,EAC3CJ,KAAK,CAACC,QAAQ,CAAEjD,sBAAsB,CAAE,GAAI+C,MAAO,CAAC,EACpDC,KAAK,CAACK,aAAa,EACnBpD,MAAM,CAAE8C,MAAM,CAAE7C,UAAW,CAAE,CAAC,CAACoD,iBAAiB,CAAC,CAAC,CAClD;AACF,CAAC;AAED,OAAO,SAASC,4BAA4BA,CAAEP,KAAK,EAAEQ,YAAY,EAAG;EACnE,OAAO,CACNR,KAAK,CAACS,iBAAiB,CAAED,YAAY,CAAE,EACvCR,KAAK,CAACrC,MAAM,CAAC+C,UAAU,CAACnC,GAAG,CAAEiC,YAAa,CAAC,EAC3CR,KAAK,CAACC,QAAQ,CAACX,iBAAiB,EAChCU,KAAK,CAACC,QAAQ,CAACU,YAAY,EAC3BX,KAAK,CAACY,iBAAiB,EACvBZ,KAAK,CAACa,UAAU,EAChB1D,sBAAsB,CAAE6C,KAAM,CAAC,CAC/B;AACF","ignoreList":[]}
1
+ {"version":3,"names":["parse","grammarParse","selectBlockPatternsKey","unlock","STORE_NAME","getSectionRootClientId","isFiltered","Symbol","parsedPatternCache","WeakMap","grammarMapCache","parsePattern","pattern","blocks","content","__unstableSkipMigrationLogs","length","attributes","metadata","categories","patternName","name","title","getParsedPattern","parsedPattern","get","set","getGrammar","grammarMap","filter","block","blockName","checkAllowList","list","item","defaultResult","Array","isArray","includes","checkAllowListRecursive","allowedBlockTypes","blocksQueue","shift","isAllowed","innerBlocks","forEach","innerBlock","push","getAllPatternsDependants","select","state","settings","__experimentalBlockPatterns","__experimentalUserPatternCategories","__experimentalReusableBlocks","blockPatterns","getReusableBlocks","getInsertBlockTypeDependants","rootClientId","blockListSettings","byClientId","templateLock","blockEditingModes","__unstableGetEditorMode"],"sources":["@wordpress/block-editor/src/store/utils.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { parse } from '@wordpress/blocks';\nimport { parse as grammarParse } from '@wordpress/block-serialization-default-parser';\n\n/**\n * Internal dependencies\n */\nimport { selectBlockPatternsKey } from './private-keys';\nimport { unlock } from '../lock-unlock';\nimport { STORE_NAME } from './constants';\nimport { getSectionRootClientId } from './private-selectors';\n\nexport const isFiltered = Symbol( 'isFiltered' );\nconst parsedPatternCache = new WeakMap();\nconst grammarMapCache = new WeakMap();\n\nfunction parsePattern( pattern ) {\n\tconst blocks = parse( pattern.content, {\n\t\t__unstableSkipMigrationLogs: true,\n\t} );\n\tif ( blocks.length === 1 ) {\n\t\tblocks[ 0 ].attributes = {\n\t\t\t...blocks[ 0 ].attributes,\n\t\t\tmetadata: {\n\t\t\t\t...( blocks[ 0 ].attributes.metadata || {} ),\n\t\t\t\tcategories: pattern.categories,\n\t\t\t\tpatternName: pattern.name,\n\t\t\t\tname: blocks[ 0 ].attributes.metadata?.name || pattern.title,\n\t\t\t},\n\t\t};\n\t}\n\treturn {\n\t\t...pattern,\n\t\tblocks,\n\t};\n}\n\nexport function getParsedPattern( pattern ) {\n\tlet parsedPattern = parsedPatternCache.get( pattern );\n\tif ( ! parsedPattern ) {\n\t\tparsedPattern = parsePattern( pattern );\n\t\tparsedPatternCache.set( pattern, parsedPattern );\n\t}\n\treturn parsedPattern;\n}\n\nexport function getGrammar( pattern ) {\n\tlet grammarMap = grammarMapCache.get( pattern );\n\tif ( ! grammarMap ) {\n\t\tgrammarMap = grammarParse( pattern.content );\n\t\t// Block names are null only at the top level for whitespace.\n\t\tgrammarMap = grammarMap.filter( ( block ) => block.blockName !== null );\n\t\tgrammarMapCache.set( pattern, grammarMap );\n\t}\n\treturn grammarMap;\n}\n\nexport const checkAllowList = ( list, item, defaultResult = null ) => {\n\tif ( typeof list === 'boolean' ) {\n\t\treturn list;\n\t}\n\tif ( Array.isArray( list ) ) {\n\t\t// TODO: when there is a canonical way to detect that we are editing a post\n\t\t// the following check should be changed to something like:\n\t\t// if ( list.includes( 'core/post-content' ) && getEditorMode() === 'post-content' && item === null )\n\t\tif ( list.includes( 'core/post-content' ) && item === null ) {\n\t\t\treturn true;\n\t\t}\n\t\treturn list.includes( item );\n\t}\n\treturn defaultResult;\n};\n\nexport const checkAllowListRecursive = ( blocks, allowedBlockTypes ) => {\n\tif ( typeof allowedBlockTypes === 'boolean' ) {\n\t\treturn allowedBlockTypes;\n\t}\n\n\tconst blocksQueue = [ ...blocks ];\n\twhile ( blocksQueue.length > 0 ) {\n\t\tconst block = blocksQueue.shift();\n\n\t\tconst isAllowed = checkAllowList(\n\t\t\tallowedBlockTypes,\n\t\t\tblock.name || block.blockName,\n\t\t\ttrue\n\t\t);\n\t\tif ( ! isAllowed ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tblock.innerBlocks?.forEach( ( innerBlock ) => {\n\t\t\tblocksQueue.push( innerBlock );\n\t\t} );\n\t}\n\n\treturn true;\n};\n\nexport const getAllPatternsDependants = ( select ) => ( state ) => {\n\treturn [\n\t\tstate.settings.__experimentalBlockPatterns,\n\t\tstate.settings.__experimentalUserPatternCategories,\n\t\tstate.settings.__experimentalReusableBlocks,\n\t\tstate.settings[ selectBlockPatternsKey ]?.( select ),\n\t\tstate.blockPatterns,\n\t\tunlock( select( STORE_NAME ) ).getReusableBlocks(),\n\t];\n};\n\nexport const getInsertBlockTypeDependants =\n\t( select ) => ( state, rootClientId ) => {\n\t\treturn [\n\t\t\tstate.blockListSettings[ rootClientId ],\n\t\t\tstate.blocks.byClientId.get( rootClientId ),\n\t\t\tstate.settings.allowedBlockTypes,\n\t\t\tstate.settings.templateLock,\n\t\t\tstate.blockEditingModes,\n\t\t\tselect( STORE_NAME ).__unstableGetEditorMode( state ),\n\t\t\tgetSectionRootClientId( state ),\n\t\t];\n\t};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAK,QAAQ,mBAAmB;AACzC,SAASA,KAAK,IAAIC,YAAY,QAAQ,+CAA+C;;AAErF;AACA;AACA;AACA,SAASC,sBAAsB,QAAQ,gBAAgB;AACvD,SAASC,MAAM,QAAQ,gBAAgB;AACvC,SAASC,UAAU,QAAQ,aAAa;AACxC,SAASC,sBAAsB,QAAQ,qBAAqB;AAE5D,OAAO,MAAMC,UAAU,GAAGC,MAAM,CAAE,YAAa,CAAC;AAChD,MAAMC,kBAAkB,GAAG,IAAIC,OAAO,CAAC,CAAC;AACxC,MAAMC,eAAe,GAAG,IAAID,OAAO,CAAC,CAAC;AAErC,SAASE,YAAYA,CAAEC,OAAO,EAAG;EAChC,MAAMC,MAAM,GAAGb,KAAK,CAAEY,OAAO,CAACE,OAAO,EAAE;IACtCC,2BAA2B,EAAE;EAC9B,CAAE,CAAC;EACH,IAAKF,MAAM,CAACG,MAAM,KAAK,CAAC,EAAG;IAC1BH,MAAM,CAAE,CAAC,CAAE,CAACI,UAAU,GAAG;MACxB,GAAGJ,MAAM,CAAE,CAAC,CAAE,CAACI,UAAU;MACzBC,QAAQ,EAAE;QACT,IAAKL,MAAM,CAAE,CAAC,CAAE,CAACI,UAAU,CAACC,QAAQ,IAAI,CAAC,CAAC,CAAE;QAC5CC,UAAU,EAAEP,OAAO,CAACO,UAAU;QAC9BC,WAAW,EAAER,OAAO,CAACS,IAAI;QACzBA,IAAI,EAAER,MAAM,CAAE,CAAC,CAAE,CAACI,UAAU,CAACC,QAAQ,EAAEG,IAAI,IAAIT,OAAO,CAACU;MACxD;IACD,CAAC;EACF;EACA,OAAO;IACN,GAAGV,OAAO;IACVC;EACD,CAAC;AACF;AAEA,OAAO,SAAS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AAE7C,UAAW,CAAC,CAAC2D,uBAAuB,CAAEb,KAAM,CAAC,EACrD7C,sBAAsB,CAAE6C,KAAM,CAAC,CAC/B;AACF,CAAC","ignoreList":[]}
@@ -113,41 +113,45 @@ function isScrollable(element) {
113
113
  const style = window.getComputedStyle(element);
114
114
  return style.overflowX === 'auto' || style.overflowX === 'scroll' || style.overflowY === 'auto' || style.overflowY === 'scroll';
115
115
  }
116
-
116
+ export const WITH_OVERFLOW_ELEMENT_BLOCKS = ['core/navigation'];
117
117
  /**
118
- * Returns the rect of the element including all visible nested elements.
119
- *
120
- * Visible nested elements, including elements that overflow the parent, are
121
- * taken into account.
122
- *
123
- * This function is useful for calculating the visible area of a block that
124
- * contains nested elements that overflow the block, e.g. the Navigation block,
125
- * which can contain overflowing Submenu blocks.
118
+ * Returns the bounding rectangle of an element, with special handling for blocks
119
+ * that have visible overflowing children (defined in WITH_OVERFLOW_ELEMENT_BLOCKS).
126
120
  *
121
+ * For blocks like Navigation that can have overflowing elements (e.g. submenus),
122
+ * this function calculates the combined bounds of both the parent and its visible
123
+ * children. The returned rect may extend beyond the viewport.
127
124
  * The returned rect represents the full extent of the element and its visible
128
125
  * children, which may extend beyond the viewport.
129
126
  *
130
127
  * @param {Element} element Element.
131
128
  * @return {DOMRect} Bounding client rect of the element and its visible children.
132
129
  */
133
- export function getVisibleElementBounds(element) {
130
+ export function getElementBounds(element) {
134
131
  const viewport = element.ownerDocument.defaultView;
135
132
  if (!viewport) {
136
133
  return new window.DOMRectReadOnly();
137
134
  }
138
135
  let bounds = element.getBoundingClientRect();
139
- const stack = [element];
140
- let currentElement;
141
- while (currentElement = stack.pop()) {
142
- for (const child of currentElement.children) {
143
- if (isElementVisible(child)) {
144
- let childBounds = child.getBoundingClientRect();
145
- // If the parent is scrollable, use parent's scrollable bounds.
146
- if (isScrollable(currentElement)) {
147
- childBounds = currentElement.getBoundingClientRect();
136
+ const dataType = element.getAttribute('data-type');
137
+
138
+ /*
139
+ * For blocks with overflowing elements (like Navigation), include the bounds
140
+ * of visible children that extend beyond the parent container.
141
+ */
142
+ if (dataType && WITH_OVERFLOW_ELEMENT_BLOCKS.includes(dataType)) {
143
+ const stack = [element];
144
+ let currentElement;
145
+ while (currentElement = stack.pop()) {
146
+ // Children won’t affect bounds unless the element is not scrollable.
147
+ if (!isScrollable(currentElement)) {
148
+ for (const child of currentElement.children) {
149
+ if (isElementVisible(child)) {
150
+ const childBounds = child.getBoundingClientRect();
151
+ bounds = rectUnion(bounds, childBounds);
152
+ stack.push(child);
153
+ }
148
154
  }
149
- bounds = rectUnion(bounds, childBounds);
150
- stack.push(child);
151
155
  }
152
156
  }
153
157
  }
@@ -1 +1 @@
1
- {"version":3,"names":["BLOCK_SELECTOR","APPENDER_SELECTOR","BLOCK_APPENDER_CLASS","isInSameBlock","a","b","closest","isInsideRootBlock","blockElement","element","parentBlock","join","getBlockClientId","node","nodeType","ELEMENT_NODE","parentNode","elementNode","blockNode","id","slice","length","rectUnion","rect1","rect2","left","Math","min","right","max","bottom","top","window","DOMRectReadOnly","isElementVisible","viewport","ownerDocument","defaultView","classList","contains","bounds","getBoundingClientRect","width","height","checkVisibility","opacityProperty","contentVisibilityAuto","visibilityProperty","style","getComputedStyle","display","visibility","opacity","isScrollable","overflowX","overflowY","getVisibleElementBounds","stack","currentElement","pop","child","children","childBounds","push","innerWidth"],"sources":["@wordpress/block-editor/src/utils/dom.js"],"sourcesContent":["const BLOCK_SELECTOR = '.block-editor-block-list__block';\nconst APPENDER_SELECTOR = '.block-list-appender';\nconst BLOCK_APPENDER_CLASS = '.block-editor-button-block-appender';\n\n/**\n * Returns true if two elements are contained within the same block.\n *\n * @param {Element} a First element.\n * @param {Element} b Second element.\n *\n * @return {boolean} Whether elements are in the same block.\n */\nexport function isInSameBlock( a, b ) {\n\treturn a.closest( BLOCK_SELECTOR ) === b.closest( BLOCK_SELECTOR );\n}\n\n/**\n * Returns true if an element is considered part of the block and not its inner\n * blocks or appender.\n *\n * @param {Element} blockElement Block container element.\n * @param {Element} element Element.\n *\n * @return {boolean} Whether an element is considered part of the block and not\n * its inner blocks or appender.\n */\nexport function isInsideRootBlock( blockElement, element ) {\n\tconst parentBlock = element.closest(\n\t\t[ BLOCK_SELECTOR, APPENDER_SELECTOR, BLOCK_APPENDER_CLASS ].join( ',' )\n\t);\n\treturn parentBlock === blockElement;\n}\n\n/**\n * Finds the block client ID given any DOM node inside the block.\n *\n * @param {Node?} node DOM node.\n *\n * @return {string|undefined} Client ID or undefined if the node is not part of\n * a block.\n */\nexport function getBlockClientId( node ) {\n\twhile ( node && node.nodeType !== node.ELEMENT_NODE ) {\n\t\tnode = node.parentNode;\n\t}\n\n\tif ( ! node ) {\n\t\treturn;\n\t}\n\n\tconst elementNode = /** @type {Element} */ ( node );\n\tconst blockNode = elementNode.closest( BLOCK_SELECTOR );\n\n\tif ( ! blockNode ) {\n\t\treturn;\n\t}\n\n\treturn blockNode.id.slice( 'block-'.length );\n}\n\n/**\n * Calculates the union of two rectangles.\n *\n * @param {DOMRect} rect1 First rectangle.\n * @param {DOMRect} rect2 Second rectangle.\n * @return {DOMRect} Union of the two rectangles.\n */\nexport function rectUnion( rect1, rect2 ) {\n\tconst left = Math.min( rect1.left, rect2.left );\n\tconst right = Math.max( rect1.right, rect2.right );\n\tconst bottom = Math.max( rect1.bottom, rect2.bottom );\n\tconst top = Math.min( rect1.top, rect2.top );\n\n\treturn new window.DOMRectReadOnly( left, top, right - left, bottom - top );\n}\n\n/**\n * Returns whether an element is visible.\n *\n * @param {Element} element Element.\n * @return {boolean} Whether the element is visible.\n */\nfunction isElementVisible( element ) {\n\tconst viewport = element.ownerDocument.defaultView;\n\tif ( ! viewport ) {\n\t\treturn false;\n\t}\n\n\t// Check for <VisuallyHidden> component.\n\tif ( element.classList.contains( 'components-visually-hidden' ) ) {\n\t\treturn false;\n\t}\n\n\tconst bounds = element.getBoundingClientRect();\n\tif ( bounds.width === 0 || bounds.height === 0 ) {\n\t\treturn false;\n\t}\n\n\t// Older browsers, e.g. Safari < 17.4 may not support the `checkVisibility` method.\n\tif ( element.checkVisibility ) {\n\t\treturn element.checkVisibility?.( {\n\t\t\topacityProperty: true,\n\t\t\tcontentVisibilityAuto: true,\n\t\t\tvisibilityProperty: true,\n\t\t} );\n\t}\n\n\tconst style = viewport.getComputedStyle( element );\n\n\tif (\n\t\tstyle.display === 'none' ||\n\t\tstyle.visibility === 'hidden' ||\n\t\tstyle.opacity === '0'\n\t) {\n\t\treturn false;\n\t}\n\n\treturn true;\n}\n\n/**\n * Checks if the element is scrollable.\n *\n * @param {Element} element Element.\n * @return {boolean} True if the element is scrollable.\n */\nfunction isScrollable( element ) {\n\tconst style = window.getComputedStyle( element );\n\treturn (\n\t\tstyle.overflowX === 'auto' ||\n\t\tstyle.overflowX === 'scroll' ||\n\t\tstyle.overflowY === 'auto' ||\n\t\tstyle.overflowY === 'scroll'\n\t);\n}\n\n/**\n * Returns the rect of the element including all visible nested elements.\n *\n * Visible nested elements, including elements that overflow the parent, are\n * taken into account.\n *\n * This function is useful for calculating the visible area of a block that\n * contains nested elements that overflow the block, e.g. the Navigation block,\n * which can contain overflowing Submenu blocks.\n *\n * The returned rect represents the full extent of the element and its visible\n * children, which may extend beyond the viewport.\n *\n * @param {Element} element Element.\n * @return {DOMRect} Bounding client rect of the element and its visible children.\n */\nexport function getVisibleElementBounds( element ) {\n\tconst viewport = element.ownerDocument.defaultView;\n\n\tif ( ! viewport ) {\n\t\treturn new window.DOMRectReadOnly();\n\t}\n\n\tlet bounds = element.getBoundingClientRect();\n\tconst stack = [ element ];\n\tlet currentElement;\n\n\twhile ( ( currentElement = stack.pop() ) ) {\n\t\tfor ( const child of currentElement.children ) {\n\t\t\tif ( isElementVisible( child ) ) {\n\t\t\t\tlet childBounds = child.getBoundingClientRect();\n\t\t\t\t// If the parent is scrollable, use parent's scrollable bounds.\n\t\t\t\tif ( isScrollable( currentElement ) ) {\n\t\t\t\t\tchildBounds = currentElement.getBoundingClientRect();\n\t\t\t\t}\n\t\t\t\tbounds = rectUnion( bounds, childBounds );\n\t\t\t\tstack.push( child );\n\t\t\t}\n\t\t}\n\t}\n\n\t/*\n\t * Take into account the outer horizontal limits of the container in which\n\t * an element is supposed to be \"visible\". For example, if an element is\n\t * positioned -10px to the left of the window x value (0), this function\n\t * discounts the negative overhang because it's not visible and therefore\n\t * not to be counted in the visibility calculations. Top and bottom values\n\t * are not accounted for to accommodate vertical scroll.\n\t */\n\tconst left = Math.max( bounds.left, 0 );\n\tconst right = Math.min( bounds.right, viewport.innerWidth );\n\tbounds = new window.DOMRectReadOnly(\n\t\tleft,\n\t\tbounds.top,\n\t\tright - left,\n\t\tbounds.height\n\t);\n\n\treturn bounds;\n}\n"],"mappings":"AAAA,MAAMA,cAAc,GAAG,iCAAiC;AACxD,MAAMC,iBAAiB,GAAG,sBAAsB;AAChD,MAAMC,oBAAoB,GAAG,qCAAqC;;AAElE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,aAAaA,CAAEC,CAAC,EAAEC,CAAC,EAAG;EACrC,OAAOD,CAAC,CAACE,OAAO,CAAEN,cAAe,CAAC,KAAKK,CAAC,CAACC,OAAO,CAAEN,cAAe,CAAC;AACnE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASO,iBAAiBA,CAAEC,YAAY,EAAEC,OAAO,EAAG;EAC1D,MAAMC,WAAW,GAAGD,OAAO,CAACH,OAAO,CAClC,CAAEN,cAAc,EAAEC,iBAAiB,EAAEC,oBAAoB,CAAE,CAACS,IAAI,CAAE,GAAI,CACvE,CAAC;EACD,OAAOD,WAAW,KAAKF,YAAY;AACpC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASI,gBAAgBA,CAAEC,IAAI,EAAG;EACxC,OAAQA,IAAI,IAAIA,IAAI,CAACC,QAAQ,KAAKD,IAAI,CAACE,YAAY,EAAG;IACrDF,IAAI,GAAGA,IAAI,CAAC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,MAAMgB,KAAK,GAAG,CAAEhD,OAAO,CAAE;EACzB,IAAIiD,cAAc;EAElB,OAAUA,cAAc,GAAGD,KAAK,CAACE,GAAG,CAAC,CAAC,EAAK;IAC1C,KAAM,MAAMC,KAAK,IAAIF,cAAc,CAACG,QAAQ,EAAG;MAC9C,IAAK3B,gBAAgB,CAAE0B,KAAM,CAAC,EAAG;QAChC,IAAIE,WAAW,GAAGF,KAAK,CAACnB,qBAAqB,CAAC,CAAC;QAC/C;QACA,IAAKY,YAAY,CAAEK,cAAe,CAAC,EAAG;UACrCI,WAAW,GAAGJ,cAAc,CAACjB,qBAAqB,CAAC,CAAC;QACrD;QACAD,MAAM,GAAGlB,SAAS,CAAEkB,MAAM,EAAEsB,WAAY,CAAC;QACzCL,KAAK,CAACM,IAAI,CAAEH,KAAM,CAAC;MACpB;IACD;EACD;;EAEA;AACD;AACA;AACA;AACA;AACA;AACA;AACA;EACC,MAAMnC,IAAI,GAAGC,IAAI,CAACG,GAAG,CAAEW,MAAM,CAACf,IAAI,EAAE,CAAE,CAAC;EACvC,MAAMG,KAAK,GAAGF,IAAI,CAACC,GAAG,CAAEa,MAAM,CAACZ,KAAK,EAAEO,QAAQ,CAAC6B,UAAW,CAAC;EAC3DxB,MAAM,GAAG,IAAIR,MAAM,CAACC,eAAe,CAClCR,IAAI,EACJe,MAAM,CAACT,GAAG,EACVH,KAAK,GAAGH,IAAI,EACZe,MAAM,CAACG,MACR,CAAC;EAED,OAAOH,MAAM;AACd","ignoreList":[]}
1
+ {"version":3,"names":["BLOCK_SELECTOR","APPENDER_SELECTOR","BLOCK_APPENDER_CLASS","isInSameBlock","a","b","closest","isInsideRootBlock","blockElement","element","parentBlock","join","getBlockClientId","node","nodeType","ELEMENT_NODE","parentNode","elementNode","blockNode","id","slice","length","rectUnion","rect1","rect2","left","Math","min","right","max","bottom","top","window","DOMRectReadOnly","isElementVisible","viewport","ownerDocument","defaultView","classList","contains","bounds","getBoundingClientRect","width","height","checkVisibility","opacityProperty","contentVisibilityAuto","visibilityProperty","style","getComputedStyle","display","visibility","opacity","isScrollable","overflowX","overflowY","WITH_OVERFLOW_ELEMENT_BLOCKS","getElementBounds","dataType","getAttribute","includes","stack","currentElement","pop","child","children","childBounds","push","innerWidth"],"sources":["@wordpress/block-editor/src/utils/dom.js"],"sourcesContent":["const BLOCK_SELECTOR = '.block-editor-block-list__block';\nconst APPENDER_SELECTOR = '.block-list-appender';\nconst BLOCK_APPENDER_CLASS = '.block-editor-button-block-appender';\n\n/**\n * Returns true if two elements are contained within the same block.\n *\n * @param {Element} a First element.\n * @param {Element} b Second element.\n *\n * @return {boolean} Whether elements are in the same block.\n */\nexport function isInSameBlock( a, b ) {\n\treturn a.closest( BLOCK_SELECTOR ) === b.closest( BLOCK_SELECTOR );\n}\n\n/**\n * Returns true if an element is considered part of the block and not its inner\n * blocks or appender.\n *\n * @param {Element} blockElement Block container element.\n * @param {Element} element Element.\n *\n * @return {boolean} Whether an element is considered part of the block and not\n * its inner blocks or appender.\n */\nexport function isInsideRootBlock( blockElement, element ) {\n\tconst parentBlock = element.closest(\n\t\t[ BLOCK_SELECTOR, APPENDER_SELECTOR, BLOCK_APPENDER_CLASS ].join( ',' )\n\t);\n\treturn parentBlock === blockElement;\n}\n\n/**\n * Finds the block client ID given any DOM node inside the block.\n *\n * @param {Node?} node DOM node.\n *\n * @return {string|undefined} Client ID or undefined if the node is not part of\n * a block.\n */\nexport function getBlockClientId( node ) {\n\twhile ( node && node.nodeType !== node.ELEMENT_NODE ) {\n\t\tnode = node.parentNode;\n\t}\n\n\tif ( ! node ) {\n\t\treturn;\n\t}\n\n\tconst elementNode = /** @type {Element} */ ( node );\n\tconst blockNode = elementNode.closest( BLOCK_SELECTOR );\n\n\tif ( ! blockNode ) {\n\t\treturn;\n\t}\n\n\treturn blockNode.id.slice( 'block-'.length );\n}\n\n/**\n * Calculates the union of two rectangles.\n *\n * @param {DOMRect} rect1 First rectangle.\n * @param {DOMRect} rect2 Second rectangle.\n * @return {DOMRect} Union of the two rectangles.\n */\nexport function rectUnion( rect1, rect2 ) {\n\tconst left = Math.min( rect1.left, rect2.left );\n\tconst right = Math.max( rect1.right, rect2.right );\n\tconst bottom = Math.max( rect1.bottom, rect2.bottom );\n\tconst top = Math.min( rect1.top, rect2.top );\n\n\treturn new window.DOMRectReadOnly( left, top, right - left, bottom - top );\n}\n\n/**\n * Returns whether an element is visible.\n *\n * @param {Element} element Element.\n * @return {boolean} Whether the element is visible.\n */\nfunction isElementVisible( element ) {\n\tconst viewport = element.ownerDocument.defaultView;\n\tif ( ! viewport ) {\n\t\treturn false;\n\t}\n\n\t// Check for <VisuallyHidden> component.\n\tif ( element.classList.contains( 'components-visually-hidden' ) ) {\n\t\treturn false;\n\t}\n\n\tconst bounds = element.getBoundingClientRect();\n\tif ( bounds.width === 0 || bounds.height === 0 ) {\n\t\treturn false;\n\t}\n\n\t// Older browsers, e.g. Safari < 17.4 may not support the `checkVisibility` method.\n\tif ( element.checkVisibility ) {\n\t\treturn element.checkVisibility?.( {\n\t\t\topacityProperty: true,\n\t\t\tcontentVisibilityAuto: true,\n\t\t\tvisibilityProperty: true,\n\t\t} );\n\t}\n\n\tconst style = viewport.getComputedStyle( element );\n\n\tif (\n\t\tstyle.display === 'none' ||\n\t\tstyle.visibility === 'hidden' ||\n\t\tstyle.opacity === '0'\n\t) {\n\t\treturn false;\n\t}\n\n\treturn true;\n}\n\n/**\n * Checks if the element is scrollable.\n *\n * @param {Element} element Element.\n * @return {boolean} True if the element is scrollable.\n */\nfunction isScrollable( element ) {\n\tconst style = window.getComputedStyle( element );\n\treturn (\n\t\tstyle.overflowX === 'auto' ||\n\t\tstyle.overflowX === 'scroll' ||\n\t\tstyle.overflowY === 'auto' ||\n\t\tstyle.overflowY === 'scroll'\n\t);\n}\n\nexport const WITH_OVERFLOW_ELEMENT_BLOCKS = [ 'core/navigation' ];\n/**\n * Returns the bounding rectangle of an element, with special handling for blocks\n * that have visible overflowing children (defined in WITH_OVERFLOW_ELEMENT_BLOCKS).\n *\n * For blocks like Navigation that can have overflowing elements (e.g. submenus),\n * this function calculates the combined bounds of both the parent and its visible\n * children. The returned rect may extend beyond the viewport.\n * The returned rect represents the full extent of the element and its visible\n * children, which may extend beyond the viewport.\n *\n * @param {Element} element Element.\n * @return {DOMRect} Bounding client rect of the element and its visible children.\n */\nexport function getElementBounds( element ) {\n\tconst viewport = element.ownerDocument.defaultView;\n\n\tif ( ! viewport ) {\n\t\treturn new window.DOMRectReadOnly();\n\t}\n\n\tlet bounds = element.getBoundingClientRect();\n\tconst dataType = element.getAttribute( 'data-type' );\n\n\t/*\n\t * For blocks with overflowing elements (like Navigation), include the bounds\n\t * of visible children that extend beyond the parent container.\n\t */\n\tif ( dataType && WITH_OVERFLOW_ELEMENT_BLOCKS.includes( dataType ) ) {\n\t\tconst stack = [ element ];\n\t\tlet currentElement;\n\n\t\twhile ( ( currentElement = stack.pop() ) ) {\n\t\t\t// Children won’t affect bounds unless the element is not scrollable.\n\t\t\tif ( ! isScrollable( currentElement ) ) {\n\t\t\t\tfor ( const child of currentElement.children ) {\n\t\t\t\t\tif ( isElementVisible( child ) ) {\n\t\t\t\t\t\tconst childBounds = child.getBoundingClientRect();\n\t\t\t\t\t\tbounds = rectUnion( bounds, childBounds );\n\t\t\t\t\t\tstack.push( child );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/*\n\t * Take into account the outer horizontal limits of the container in which\n\t * an element is supposed to be \"visible\". For example, if an element is\n\t * positioned -10px to the left of the window x value (0), this function\n\t * discounts the negative overhang because it's not visible and therefore\n\t * not to be counted in the visibility calculations. Top and bottom values\n\t * are not accounted for to accommodate vertical scroll.\n\t */\n\tconst left = Math.max( bounds.left, 0 );\n\tconst right = Math.min( bounds.right, viewport.innerWidth );\n\tbounds = new window.DOMRectReadOnly(\n\t\tleft,\n\t\tbounds.top,\n\t\tright - left,\n\t\tbounds.height\n\t);\n\n\treturn bounds;\n}\n"],"mapp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,IAAK/B,gBAAgB,CAAE8B,KAAM,CAAC,EAAG;YAChC,MAAME,WAAW,GAAGF,KAAK,CAACvB,qBAAqB,CAAC,CAAC;YACjDD,MAAM,GAAGlB,SAAS,CAAEkB,MAAM,EAAE0B,WAAY,CAAC;YACzCL,KAAK,CAACM,IAAI,CAAEH,KAAM,CAAC;UACpB;QACD;MACD;IACD;EACD;;EAEA;AACD;AACA;AACA;AACA;AACA;AACA;AACA;EACC,MAAMvC,IAAI,GAAGC,IAAI,CAACG,GAAG,CAAEW,MAAM,CAACf,IAAI,EAAE,CAAE,CAAC;EACvC,MAAMG,KAAK,GAAGF,IAAI,CAACC,GAAG,CAAEa,MAAM,CAACZ,KAAK,EAAEO,QAAQ,CAACiC,UAAW,CAAC;EAC3D5B,MAAM,GAAG,IAAIR,MAAM,CAACC,eAAe,CAClCR,IAAI,EACJe,MAAM,CAACT,GAAG,EACVH,KAAK,GAAGH,IAAI,EACZe,MAAM,CAACG,MACR,CAAC;EAED,OAAOH,MAAM;AACd","ignoreList":[]}
@@ -677,8 +677,6 @@ _::-webkit-full-page-media, _:future, :root [data-has-multi-selection=true] .blo
677
677
  }
678
678
  .block-editor-default-block-appender .block-editor-default-block-appender__content {
679
679
  opacity: 0.62;
680
- }
681
- :where(body .is-layout-constrained) .block-editor-default-block-appender > :first-child, :where(.wp-site-blocks) .block-editor-default-block-appender > :first-child {
682
680
  margin-block-start: 0;
683
681
  margin-block-end: 0;
684
682
  }
@@ -697,21 +695,21 @@ _::-webkit-full-page-media, _:future, :root [data-has-multi-selection=true] .blo
697
695
  background: var(--wp-admin-theme-color);
698
696
  }
699
697
 
700
- .block-editor-block-list__empty-block-inserter.block-editor-block-list__empty-block-inserter,
701
698
  .block-editor-default-block-appender .block-editor-inserter {
702
699
  position: absolute;
703
700
  top: 0;
704
701
  left: 0;
705
702
  line-height: 0;
706
703
  }
707
- .block-editor-block-list__empty-block-inserter.block-editor-block-list__empty-block-inserter:disabled,
708
704
  .block-editor-default-block-appender .block-editor-inserter:disabled {
709
705
  display: none;
710
706
  }
711
707
 
712
708
  /**
713
- * Fixed position appender.
714
- * These styles apply to all in-canvas inserters that exist inside nesting containers.
709
+ * Fixed position appender (right bottom corner).
710
+ *
711
+ * These styles apply to all in-canvas inserters. All in-canvas inserters always
712
+ * exist within a block.
715
713
  */
716
714
  .block-editor-block-list__block .block-list-appender {
717
715
  position: absolute;
@@ -725,6 +723,9 @@ _::-webkit-full-page-media, _:future, :root [data-has-multi-selection=true] .blo
725
723
  margin: 0;
726
724
  line-height: 0;
727
725
  }
726
+ .block-editor-block-list__block .block-list-appender .block-editor-inserter:disabled {
727
+ display: none;
728
+ }
728
729
  .block-editor-block-list__block .block-list-appender .block-editor-default-block-appender {
729
730
  height: 24px;
730
731
  }
@@ -677,8 +677,6 @@ _::-webkit-full-page-media, _:future, :root [data-has-multi-selection=true] .blo
677
677
  }
678
678
  .block-editor-default-block-appender .block-editor-default-block-appender__content {
679
679
  opacity: 0.62;
680
- }
681
- :where(body .is-layout-constrained) .block-editor-default-block-appender > :first-child, :where(.wp-site-blocks) .block-editor-default-block-appender > :first-child {
682
680
  margin-block-start: 0;
683
681
  margin-block-end: 0;
684
682
  }
@@ -697,21 +695,21 @@ _::-webkit-full-page-media, _:future, :root [data-has-multi-selection=true] .blo
697
695
  background: var(--wp-admin-theme-color);
698
696
  }
699
697
 
700
- .block-editor-block-list__empty-block-inserter.block-editor-block-list__empty-block-inserter,
701
698
  .block-editor-default-block-appender .block-editor-inserter {
702
699
  position: absolute;
703
700
  top: 0;
704
701
  right: 0;
705
702
  line-height: 0;
706
703
  }
707
- .block-editor-block-list__empty-block-inserter.block-editor-block-list__empty-block-inserter:disabled,
708
704
  .block-editor-default-block-appender .block-editor-inserter:disabled {
709
705
  display: none;
710
706
  }
711
707
 
712
708
  /**
713
- * Fixed position appender.
714
- * These styles apply to all in-canvas inserters that exist inside nesting containers.
709
+ * Fixed position appender (right bottom corner).
710
+ *
711
+ * These styles apply to all in-canvas inserters. All in-canvas inserters always
712
+ * exist within a block.
715
713
  */
716
714
  .block-editor-block-list__block .block-list-appender {
717
715
  position: absolute;
@@ -725,6 +723,9 @@ _::-webkit-full-page-media, _:future, :root [data-has-multi-selection=true] .blo
725
723
  margin: 0;
726
724
  line-height: 0;
727
725
  }
726
+ .block-editor-block-list__block .block-list-appender .block-editor-inserter:disabled {
727
+ display: none;
728
+ }
728
729
  .block-editor-block-list__block .block-list-appender .block-editor-default-block-appender {
729
730
  height: 24px;
730
731
  }
@@ -278,8 +278,8 @@ iframe[name=editor-canvas] {
278
278
  width: 100%;
279
279
  height: 100%;
280
280
  display: block;
281
- background-color: transparent;
282
281
  transition: all 400ms cubic-bezier(0.46, 0.03, 0.52, 0.96);
282
+ background-color: #ddd;
283
283
  }
284
284
  @media (prefers-reduced-motion: reduce) {
285
285
  iframe[name=editor-canvas] {
@@ -319,7 +319,8 @@ iframe[name=editor-canvas] {
319
319
  color: #1e1e1e;
320
320
  margin-bottom: 1.5em;
321
321
  }
322
- .block-editor-block-inspector .components-base-control:where(:not(:last-child)) {
322
+ .block-editor-block-inspector .components-base-control:where(:not(:last-child)),
323
+ .block-editor-block-inspector .components-radio-control:where(:not(:last-child)) {
323
324
  margin-bottom: 16px;
324
325
  }
325
326
  .block-editor-block-inspector .components-focal-point-picker-control .components-base-control,
@@ -398,6 +399,16 @@ iframe[name=editor-canvas] {
398
399
  pointer-events: all;
399
400
  }
400
401
 
402
+ .block-editor-block-list__empty-block-inserter.block-editor-block-list__empty-block-inserter {
403
+ position: absolute;
404
+ top: 0;
405
+ left: 0;
406
+ line-height: 0;
407
+ }
408
+ .block-editor-block-list__empty-block-inserter.block-editor-block-list__empty-block-inserter:disabled {
409
+ display: none;
410
+ }
411
+
401
412
  .block-editor-block-list__empty-block-inserter .block-editor-inserter__toggle.components-button.has-icon,
402
413
  .block-editor-block-list__insertion-point-inserter .block-editor-inserter__toggle.components-button.has-icon {
403
414
  background: #1e1e1e;
@@ -3025,7 +3036,7 @@ iframe[name=editor-canvas] {
3025
3036
  border-bottom: 1px solid #ddd;
3026
3037
  display: flex;
3027
3038
  justify-content: space-between;
3028
- padding-left: 12px;
3039
+ padding-left: 8px;
3029
3040
  }
3030
3041
 
3031
3042
  .block-editor-tabbed-sidebar__close-button {
@@ -278,8 +278,8 @@ iframe[name=editor-canvas] {
278
278
  width: 100%;
279
279
  height: 100%;
280
280
  display: block;
281
- background-color: transparent;
282
281
  transition: all 400ms cubic-bezier(0.46, 0.03, 0.52, 0.96);
282
+ background-color: #ddd;
283
283
  }
284
284
  @media (prefers-reduced-motion: reduce) {
285
285
  iframe[name=editor-canvas] {
@@ -319,7 +319,8 @@ iframe[name=editor-canvas] {
319
319
  color: #1e1e1e;
320
320
  margin-bottom: 1.5em;
321
321
  }
322
- .block-editor-block-inspector .components-base-control:where(:not(:last-child)) {
322
+ .block-editor-block-inspector .components-base-control:where(:not(:last-child)),
323
+ .block-editor-block-inspector .components-radio-control:where(:not(:last-child)) {
323
324
  margin-bottom: 16px;
324
325
  }
325
326
  .block-editor-block-inspector .components-focal-point-picker-control .components-base-control,
@@ -398,6 +399,16 @@ iframe[name=editor-canvas] {
398
399
  pointer-events: all;
399
400
  }
400
401
 
402
+ .block-editor-block-list__empty-block-inserter.block-editor-block-list__empty-block-inserter {
403
+ position: absolute;
404
+ top: 0;
405
+ right: 0;
406
+ line-height: 0;
407
+ }
408
+ .block-editor-block-list__empty-block-inserter.block-editor-block-list__empty-block-inserter:disabled {
409
+ display: none;
410
+ }
411
+
401
412
  .block-editor-block-list__empty-block-inserter .block-editor-inserter__toggle.components-button.has-icon,
402
413
  .block-editor-block-list__insertion-point-inserter .block-editor-inserter__toggle.components-button.has-icon {
403
414
  background: #1e1e1e;
@@ -3026,7 +3037,7 @@ iframe[name=editor-canvas] {
3026
3037
  border-bottom: 1px solid #ddd;
3027
3038
  display: flex;
3028
3039
  justify-content: space-between;
3029
- padding-right: 12px;
3040
+ padding-right: 8px;
3030
3041
  }
3031
3042
 
3032
3043
  .block-editor-tabbed-sidebar__close-button {
@@ -36,20 +36,18 @@ export function getBlockClientId(node: Node | null): string | undefined;
36
36
  */
37
37
  export function rectUnion(rect1: DOMRect, rect2: DOMRect): DOMRect;
38
38
  /**
39
- * Returns the rect of the element including all visible nested elements.
40
- *
41
- * Visible nested elements, including elements that overflow the parent, are
42
- * taken into account.
43
- *
44
- * This function is useful for calculating the visible area of a block that
45
- * contains nested elements that overflow the block, e.g. the Navigation block,
46
- * which can contain overflowing Submenu blocks.
39
+ * Returns the bounding rectangle of an element, with special handling for blocks
40
+ * that have visible overflowing children (defined in WITH_OVERFLOW_ELEMENT_BLOCKS).
47
41
  *
42
+ * For blocks like Navigation that can have overflowing elements (e.g. submenus),
43
+ * this function calculates the combined bounds of both the parent and its visible
44
+ * children. The returned rect may extend beyond the viewport.
48
45
  * The returned rect represents the full extent of the element and its visible
49
46
  * children, which may extend beyond the viewport.
50
47
  *
51
48
  * @param {Element} element Element.
52
49
  * @return {DOMRect} Bounding client rect of the element and its visible children.
53
50
  */
54
- export function getVisibleElementBounds(element: Element): DOMRect;
51
+ export function getElementBounds(element: Element): DOMRect;
52
+ export const WITH_OVERFLOW_ELEMENT_BLOCKS: string[];
55
53
  //# sourceMappingURL=dom.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"dom.d.ts","sourceRoot":"","sources":["../../src/utils/dom.js"],"names":[],"mappings":"AAIA;;;;;;;GAOG;AACH,iCALW,OAAO,KACP,OAAO,GAEN,OAAO,CAIlB;AAED;;;;;;;;;GASG;AACH,gDANW,OAAO,WACP,OAAO,GAEN,OAAO,CAQlB;AAED;;;;;;;GAOG;AACH,uCALW,IAAI,OAAC,GAEJ,MAAM,GAAC,SAAS,CAoB3B;AAED;;;;;;GAMG;AACH,iCAJW,OAAO,SACP,OAAO,GACN,OAAO,CASlB;AA8DD;;;;;;;;;;;;;;;GAeG;AACH,iDAHW,OAAO,GACN,OAAO,CA6ClB"}
1
+ {"version":3,"file":"dom.d.ts","sourceRoot":"","sources":["../../src/utils/dom.js"],"names":[],"mappings":"AAIA;;;;;;;GAOG;AACH,iCALW,OAAO,KACP,OAAO,GAEN,OAAO,CAIlB;AAED;;;;;;;;;GASG;AACH,gDANW,OAAO,WACP,OAAO,GAEN,OAAO,CAQlB;AAED;;;;;;;GAOG;AACH,uCALW,IAAI,OAAC,GAEJ,MAAM,GAAC,SAAS,CAoB3B;AAED;;;;;;GAMG;AACH,iCAJW,OAAO,SACP,OAAO,GACN,OAAO,CASlB;AA+DD;;;;;;;;;;;;GAYG;AACH,0CAHW,OAAO,GACN,OAAO,CAoDlB;AAhED,oDAAkE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/block-editor",
3
- "version": "14.6.0",
3
+ "version": "14.7.0",
4
4
  "description": "Generic block editor.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -26,6 +26,7 @@
26
26
  "main": "build/index.js",
27
27
  "module": "build-module/index.js",
28
28
  "react-native": "src/index",
29
+ "wpScript": true,
29
30
  "sideEffects": [
30
31
  "build-style/**",
31
32
  "src/**/*.scss",
@@ -59,6 +60,7 @@
59
60
  "@wordpress/keycodes": "*",
60
61
  "@wordpress/notices": "*",
61
62
  "@wordpress/preferences": "*",
63
+ "@wordpress/priority-queue": "*",
62
64
  "@wordpress/private-apis": "*",
63
65
  "@wordpress/rich-text": "*",
64
66
  "@wordpress/style-engine": "*",
@@ -88,6 +90,5 @@
88
90
  "publishConfig": {
89
91
  "access": "public"
90
92
  },
91
- "wpScript": true,
92
- "gitHead": "dcf4613b33b0eda14e203ac30f700ed0db70347f"
93
+ "gitHead": "510540d99f3d222a96f08d3d7b66c9e7a726f705"
93
94
  }
@@ -3,7 +3,7 @@ iframe[name="editor-canvas"] {
3
3
  width: 100%;
4
4
  height: 100%;
5
5
  display: block;
6
- background-color: transparent;
7
6
  // Handles transitions between device previews
8
7
  @include editor-canvas-resize-animation;
8
+ background-color: $gray-300;
9
9
  }
@@ -10,7 +10,8 @@
10
10
  margin-bottom: 1.5em;
11
11
  }
12
12
 
13
- .components-base-control {
13
+ .components-base-control,
14
+ .components-radio-control {
14
15
  &:where(:not(:last-child)) {
15
16
  margin-bottom: $grid-unit-20;
16
17
  }
@@ -24,8 +24,8 @@ import {
24
24
  isReusableBlock,
25
25
  getBlockDefaultClassName,
26
26
  hasBlockSupport,
27
+ createBlock,
27
28
  store as blocksStore,
28
- privateApis as blocksPrivateApis,
29
29
  } from '@wordpress/blocks';
30
30
  import { withFilters } from '@wordpress/components';
31
31
  import { withDispatch, useDispatch, useSelect } from '@wordpress/data';
@@ -47,8 +47,6 @@ import { PrivateBlockContext } from './private-block-context';
47
47
 
48
48
  import { unlock } from '../../lock-unlock';
49
49
 
50
- const { isUnmodifiedBlockContent } = unlock( blocksPrivateApis );
51
-
52
50
  /**
53
51
  * Merges wrapper props with special handling for classNames and styles.
54
52
  *
@@ -313,6 +311,7 @@ const applyWithDispatch = withDispatch( ( dispatch, ownProps, registry ) => {
313
311
  function switchToDefaultOrRemove() {
314
312
  const block = getBlock( clientId );
315
313
  const defaultBlockName = getDefaultBlockName();
314
+ const defaultBlockType = getBlockType( defaultBlockName );
316
315
  if ( getBlockName( clientId ) !== defaultBlockName ) {
317
316
  const replacement = switchToBlockType(
318
317
  block,
@@ -329,6 +328,15 @@ const applyWithDispatch = withDispatch( ( dispatch, ownProps, registry ) => {
329
328
  selectBlock( nextBlockClientId );
330
329
  } );
331
330
  }
331
+ } else if ( defaultBlockType.merge ) {
332
+ const attributes = defaultBlockType.merge(
333
+ {},
334
+ block.attributes
335
+ );
336
+ replaceBlocks(
337
+ [ clientId ],
338
+ [ createBlock( defaultBlockName, attributes ) ]
339
+ );
332
340
  }
333
341
  }
334
342
 
@@ -342,6 +350,9 @@ const applyWithDispatch = withDispatch( ( dispatch, ownProps, registry ) => {
342
350
  * to the moved block.
343
351
  */
344
352
  function moveFirstItemUp( _clientId, changeSelection = true ) {
353
+ const wrapperBlockName = getBlockName( _clientId );
354
+ const wrapperBlockType = getBlockType( wrapperBlockName );
355
+ const isTextualWrapper = wrapperBlockType.category === 'text';
345
356
  const targetRootClientId = getBlockRootClientId( _clientId );
346
357
  const blockOrder = getBlockOrder( _clientId );
347
358
  const [ firstClientId ] = blockOrder;
@@ -351,50 +362,14 @@ const applyWithDispatch = withDispatch( ( dispatch, ownProps, registry ) => {
351
362
  isUnmodifiedBlock( getBlock( firstClientId ) )
352
363
  ) {
353
364
  removeBlock( _clientId );
354
- } else {
365
+ } else if ( isTextualWrapper ) {
355
366
  registry.batch( () => {
356
- const firstBlock = getBlock( firstClientId );
357
- const isFirstBlockContentUnmodified =
358
- isUnmodifiedBlockContent( firstBlock );
359
- const defaultBlockName = getDefaultBlockName();
360
- const replacement = switchToBlockType(
361
- firstBlock,
362
- defaultBlockName
363
- );
364
- const canTransformToDefaultBlock =
365
- !! replacement?.length &&
366
- replacement.every( ( block ) =>
367
- canInsertBlockType( block.name, _clientId )
368
- );
369
-
370
367
  if (
371
- isFirstBlockContentUnmodified &&
372
- canTransformToDefaultBlock
373
- ) {
374
- // Step 1: If the block is empty and can be transformed to the default block type.
375
- replaceBlocks(
376
- firstClientId,
377
- replacement,
378
- changeSelection
379
- );
380
- } else if (
381
- isFirstBlockContentUnmodified &&
382
- firstBlock.name === defaultBlockName
383
- ) {
384
- // Step 2: If the block is empty and is already the default block type.
385
- removeBlock( firstClientId );
386
- const nextBlockClientId =
387
- getNextBlockClientId( clientId );
388
- if ( nextBlockClientId ) {
389
- selectBlock( nextBlockClientId );
390
- }
391
- } else if (
392
368
  canInsertBlockType(
393
- firstBlock.name,
369
+ getBlockName( firstClientId ),
394
370
  targetRootClientId
395
371
  )
396
372
  ) {
397
- // Step 3: If the block can be moved up.
398
373
  moveBlocksToPosition(
399
374
  [ firstClientId ],
400
375
  _clientId,
@@ -402,17 +377,21 @@ const applyWithDispatch = withDispatch( ( dispatch, ownProps, registry ) => {
402
377
  getBlockIndex( _clientId )
403
378
  );
404
379
  } else {
405
- const canLiftAndTransformToDefaultBlock =
406
- !! replacement?.length &&
380
+ const replacement = switchToBlockType(
381
+ getBlock( firstClientId ),
382
+ getDefaultBlockName()
383
+ );
384
+
385
+ if (
386
+ replacement &&
387
+ replacement.length &&
407
388
  replacement.every( ( block ) =>
408
389
  canInsertBlockType(
409
390
  block.name,
410
391
  targetRootClientId
411
392
  )
412
- );
413
-
414
- if ( canLiftAndTransformToDefaultBlock ) {
415
- // Step 4: If the block can be transformed to the default block type and moved up.
393
+ )
394
+ ) {
416
395
  insertBlocks(
417
396
  replacement,
418
397
  getBlockIndex( _clientId ),
@@ -421,7 +400,6 @@ const applyWithDispatch = withDispatch( ( dispatch, ownProps, registry ) => {
421
400
  );
422
401
  removeBlock( firstClientId, false );
423
402
  } else {
424
- // Step 5: Continue the default behavior.
425
403
  switchToDefaultOrRemove();
426
404
  }
427
405
  }
@@ -433,6 +411,8 @@ const applyWithDispatch = withDispatch( ( dispatch, ownProps, registry ) => {
433
411
  removeBlock( _clientId, false );
434
412
  }
435
413
  } );
414
+ } else {
415
+ switchToDefaultOrRemove();
436
416
  }
437
417
  }
438
418
 
@@ -18,7 +18,6 @@ import { BlockPatternsList } from '@wordpress/block-editor';
18
18
  const MyBlockPatternsList = () => (
19
19
  <BlockPatternsList
20
20
  blockPatterns={ shownBlockPatterns }
21
- shownPatterns={ shownBlockPatterns }
22
21
  onClickPattern={ onSelectBlockPattern }
23
22
  />
24
23
  );
@@ -33,13 +32,6 @@ An array of block patterns that can be shown in the block patterns list.
33
32
  - Type: `Array`
34
33
  - Required: Yes
35
34
 
36
- #### shownPatterns
37
-
38
- An array of shown block patterns objects.
39
-
40
- - Type: `Array`
41
- - Required: Yes
42
-
43
35
  #### onClickPattern
44
36
 
45
37
  The performed event after a click on a block pattern. In most cases, the pattern is inserted in the block editor.
@@ -69,6 +61,14 @@ The aria label for the block patterns list.
69
61
  - Required: No
70
62
  - Default: `Block Patterns`
71
63
 
64
+ #### showTitlesAsTooltip
65
+
66
+ Whether to render the title of each pattern as a tooltip. User-defined patterns always show their visual title regardless of this prop.
67
+
68
+ - Type: `boolean`
69
+ - Required: No
70
+ - Default: `false`
71
+
72
72
  ## Related components
73
73
 
74
74
  Block Editor components are components that can be used to compose the UI of your block editor. Thus, they can only be used under a [`BlockEditorProvider`](https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/provider/README.md) in the components tree.