@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
@@ -42,8 +42,7 @@ function BlockPattern({
42
42
  pattern,
43
43
  onClick,
44
44
  onHover,
45
- showTitle = true,
46
- showTooltip,
45
+ showTitlesAsTooltip,
47
46
  category
48
47
  }) {
49
48
  const [isDragging, setIsDragging] = useState(false);
@@ -53,6 +52,7 @@ function BlockPattern({
53
52
  } = pattern;
54
53
  const instanceId = useInstanceId(BlockPattern);
55
54
  const descriptionId = `block-editor-block-patterns-list__item-description-${instanceId}`;
55
+ const isUserPattern = pattern.type === INSERTER_PATTERN_TYPES.user;
56
56
 
57
57
  // When we have a selected category and the pattern is draggable, we need to update the
58
58
  // pattern's categories in metadata to only contain the selected category, and pass this to
@@ -95,7 +95,7 @@ function BlockPattern({
95
95
  }
96
96
  },
97
97
  children: /*#__PURE__*/_jsx(WithToolTip, {
98
- showTooltip: showTooltip && !pattern.type !== INSERTER_PATTERN_TYPES.user,
98
+ showTooltip: showTitlesAsTooltip && !isUserPattern,
99
99
  title: pattern.title,
100
100
  children: /*#__PURE__*/_jsxs(Composite.Item, {
101
101
  render: /*#__PURE__*/_jsx("div", {
@@ -118,19 +118,22 @@ function BlockPattern({
118
118
  onHover?.(pattern);
119
119
  },
120
120
  onMouseLeave: () => onHover?.(null),
121
- children: [/*#__PURE__*/_jsx(BlockPreview, {
122
- blocks: blocks,
123
- viewportWidth: viewportWidth
124
- }), showTitle && /*#__PURE__*/_jsxs(HStack, {
121
+ children: [/*#__PURE__*/_jsx(BlockPreview.Async, {
122
+ placeholder: /*#__PURE__*/_jsx(BlockPatternPlaceholder, {}),
123
+ children: /*#__PURE__*/_jsx(BlockPreview, {
124
+ blocks: blocks,
125
+ viewportWidth: viewportWidth
126
+ })
127
+ }), (!showTitlesAsTooltip || isUserPattern) && /*#__PURE__*/_jsxs(HStack, {
125
128
  className: "block-editor-patterns__pattern-details",
126
129
  spacing: 2,
127
- children: [pattern.type === INSERTER_PATTERN_TYPES.user && !pattern.syncStatus && /*#__PURE__*/_jsx("div", {
130
+ children: [isUserPattern && !pattern.syncStatus && /*#__PURE__*/_jsx("div", {
128
131
  className: "block-editor-patterns__pattern-icon-wrapper",
129
132
  children: /*#__PURE__*/_jsx(Icon, {
130
133
  className: "block-editor-patterns__pattern-icon",
131
134
  icon: symbol
132
135
  })
133
- }), (!showTooltip || pattern.type === INSERTER_PATTERN_TYPES.user) && /*#__PURE__*/_jsx("div", {
136
+ }), /*#__PURE__*/_jsx("div", {
134
137
  className: "block-editor-block-patterns-list__item-title",
135
138
  children: pattern.title
136
139
  })]
@@ -151,13 +154,11 @@ function BlockPatternPlaceholder() {
151
154
  function BlockPatternsList({
152
155
  isDraggable,
153
156
  blockPatterns,
154
- shownPatterns,
155
157
  onHover,
156
158
  onClickPattern,
157
159
  orientation,
158
160
  label = __('Block patterns'),
159
161
  category,
160
- showTitle = true,
161
162
  showTitlesAsTooltip,
162
163
  pagingProps
163
164
  }, ref) {
@@ -166,9 +167,9 @@ function BlockPatternsList({
166
167
  // Reset the active composite item whenever the available patterns change,
167
168
  // to make sure that Composite widget can receive focus correctly when its
168
169
  // composite items change. The first composite item will receive focus.
169
- const firstCompositeItemId = blockPatterns.find(pattern => shownPatterns.includes(pattern))?.name;
170
+ const firstCompositeItemId = blockPatterns[0]?.name;
170
171
  setActiveCompositeId(firstCompositeItemId);
171
- }, [shownPatterns, blockPatterns]);
172
+ }, [blockPatterns]);
172
173
  return /*#__PURE__*/_jsxs(Composite, {
173
174
  orientation: orientation,
174
175
  activeId: activeCompositeId,
@@ -177,19 +178,15 @@ function BlockPatternsList({
177
178
  className: "block-editor-block-patterns-list",
178
179
  "aria-label": label,
179
180
  ref: ref,
180
- children: [blockPatterns.map(pattern => {
181
- const isShown = shownPatterns.includes(pattern);
182
- return isShown ? /*#__PURE__*/_jsx(BlockPattern, {
183
- id: pattern.name,
184
- pattern: pattern,
185
- onClick: onClickPattern,
186
- onHover: onHover,
187
- isDraggable: isDraggable,
188
- showTitle: showTitle,
189
- showTooltip: showTitlesAsTooltip,
190
- category: category
191
- }, pattern.name) : /*#__PURE__*/_jsx(BlockPatternPlaceholder, {}, pattern.name);
192
- }), pagingProps && /*#__PURE__*/_jsx(BlockPatternsPaging, {
181
+ children: [blockPatterns.map(pattern => /*#__PURE__*/_jsx(BlockPattern, {
182
+ id: pattern.name,
183
+ pattern: pattern,
184
+ onClick: onClickPattern,
185
+ onHover: onHover,
186
+ isDraggable: isDraggable,
187
+ showTitlesAsTooltip: showTitlesAsTooltip,
188
+ category: category
189
+ }, pattern.name)), pagingProps && /*#__PURE__*/_jsx(BlockPatternsPaging, {
193
190
  ...pagingProps
194
191
  })]
195
192
  });
@@ -1 +1 @@
1
- {"version":3,"names":["clsx","cloneBlock","useEffect","useState","forwardRef","useMemo","Composite","VisuallyHidden","Tooltip","__experimentalHStack","HStack","useInstanceId","__","Icon","symbol","BlockPreview","InserterDraggableBlocks","BlockPatternsPaging","INSERTER_PATTERN_TYPES","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","WithToolTip","showTooltip","title","children","text","BlockPattern","id","isDraggable","pattern","onClick","onHover","showTitle","category","isDragging","setIsDragging","blocks","viewportWidth","instanceId","descriptionId","patternBlocks","map","block","clonedBlock","attributes","metadata","categories","includes","isEnabled","draggable","onDragStart","onDragEnd","className","event","type","user","Item","render","role","description","undefined","syncStatus","onMouseEnter","onMouseLeave","spacing","icon","BlockPatternPlaceholder","BlockPatternsList","blockPatterns","shownPatterns","onClickPattern","orientation","label","showTitlesAsTooltip","pagingProps","ref","activeCompositeId","setActiveCompositeId","firstCompositeItemId","find","name","activeId","setActiveId","isShown"],"sources":["@wordpress/block-editor/src/components/block-patterns-list/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { cloneBlock } from '@wordpress/blocks';\nimport { useEffect, useState, forwardRef, useMemo } from '@wordpress/element';\nimport {\n\tComposite,\n\tVisuallyHidden,\n\tTooltip,\n\t__experimentalHStack as HStack,\n} from '@wordpress/components';\nimport { useInstanceId } from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\nimport { Icon, symbol } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport BlockPreview from '../block-preview';\nimport InserterDraggableBlocks from '../inserter-draggable-blocks';\nimport BlockPatternsPaging from '../block-patterns-paging';\nimport { INSERTER_PATTERN_TYPES } from '../inserter/block-patterns-tab/utils';\n\nconst WithToolTip = ( { showTooltip, title, children } ) => {\n\tif ( showTooltip ) {\n\t\treturn <Tooltip text={ title }>{ children }</Tooltip>;\n\t}\n\treturn <>{ children }</>;\n};\n\nfunction BlockPattern( {\n\tid,\n\tisDraggable,\n\tpattern,\n\tonClick,\n\tonHover,\n\tshowTitle = true,\n\tshowTooltip,\n\tcategory,\n} ) {\n\tconst [ isDragging, setIsDragging ] = useState( false );\n\tconst { blocks, viewportWidth } = pattern;\n\tconst instanceId = useInstanceId( BlockPattern );\n\tconst descriptionId = `block-editor-block-patterns-list__item-description-${ instanceId }`;\n\n\t// When we have a selected category and the pattern is draggable, we need to update the\n\t// pattern's categories in metadata to only contain the selected category, and pass this to\n\t// InserterDraggableBlocks component. We do that because we use this information for pattern\n\t// shuffling and it makes more sense to show only the ones from the initially selected category during insertion.\n\tconst patternBlocks = useMemo( () => {\n\t\tif ( ! category || ! isDraggable ) {\n\t\t\treturn blocks;\n\t\t}\n\t\treturn ( blocks ?? [] ).map( ( block ) => {\n\t\t\tconst clonedBlock = cloneBlock( block );\n\t\t\tif (\n\t\t\t\tclonedBlock.attributes.metadata?.categories?.includes(\n\t\t\t\t\tcategory\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tclonedBlock.attributes.metadata.categories = [ category ];\n\t\t\t}\n\t\t\treturn clonedBlock;\n\t\t} );\n\t}, [ blocks, isDraggable, category ] );\n\n\treturn (\n\t\t<InserterDraggableBlocks\n\t\t\tisEnabled={ isDraggable }\n\t\t\tblocks={ patternBlocks }\n\t\t\tpattern={ pattern }\n\t\t>\n\t\t\t{ ( { draggable, onDragStart, onDragEnd } ) => (\n\t\t\t\t<div\n\t\t\t\t\tclassName=\"block-editor-block-patterns-list__list-item\"\n\t\t\t\t\tdraggable={ draggable }\n\t\t\t\t\tonDragStart={ ( event ) => {\n\t\t\t\t\t\tsetIsDragging( true );\n\t\t\t\t\t\tif ( onDragStart ) {\n\t\t\t\t\t\t\tonHover?.( null );\n\t\t\t\t\t\t\tonDragStart( event );\n\t\t\t\t\t\t}\n\t\t\t\t\t} }\n\t\t\t\t\tonDragEnd={ ( event ) => {\n\t\t\t\t\t\tsetIsDragging( false );\n\t\t\t\t\t\tif ( onDragEnd ) {\n\t\t\t\t\t\t\tonDragEnd( event );\n\t\t\t\t\t\t}\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t<WithToolTip\n\t\t\t\t\t\tshowTooltip={\n\t\t\t\t\t\t\tshowTooltip &&\n\t\t\t\t\t\t\t! pattern.type !== INSERTER_PATTERN_TYPES.user\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttitle={ pattern.title }\n\t\t\t\t\t>\n\t\t\t\t\t\t<Composite.Item\n\t\t\t\t\t\t\trender={\n\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\trole=\"option\"\n\t\t\t\t\t\t\t\t\taria-label={ pattern.title }\n\t\t\t\t\t\t\t\t\taria-describedby={\n\t\t\t\t\t\t\t\t\t\tpattern.description\n\t\t\t\t\t\t\t\t\t\t\t? descriptionId\n\t\t\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t\t\t\t'block-editor-block-patterns-list__item',\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t'block-editor-block-patterns-list__list-item-synced':\n\t\t\t\t\t\t\t\t\t\t\t\tpattern.type ===\n\t\t\t\t\t\t\t\t\t\t\t\t\tINSERTER_PATTERN_TYPES.user &&\n\t\t\t\t\t\t\t\t\t\t\t\t! pattern.syncStatus,\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tid={ id }\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tonClick( pattern, blocks );\n\t\t\t\t\t\t\t\tonHover?.( null );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tonMouseEnter={ () => {\n\t\t\t\t\t\t\t\tif ( isDragging ) {\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tonHover?.( pattern );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tonMouseLeave={ () => onHover?.( null ) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<BlockPreview\n\t\t\t\t\t\t\t\tblocks={ blocks }\n\t\t\t\t\t\t\t\tviewportWidth={ viewportWidth }\n\t\t\t\t\t\t\t/>\n\n\t\t\t\t\t\t\t{ showTitle && (\n\t\t\t\t\t\t\t\t<HStack\n\t\t\t\t\t\t\t\t\tclassName=\"block-editor-patterns__pattern-details\"\n\t\t\t\t\t\t\t\t\tspacing={ 2 }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ pattern.type ===\n\t\t\t\t\t\t\t\t\t\tINSERTER_PATTERN_TYPES.user &&\n\t\t\t\t\t\t\t\t\t\t! pattern.syncStatus && (\n\t\t\t\t\t\t\t\t\t\t\t<div className=\"block-editor-patterns__pattern-icon-wrapper\">\n\t\t\t\t\t\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\t\t\t\t\t\tclassName=\"block-editor-patterns__pattern-icon\"\n\t\t\t\t\t\t\t\t\t\t\t\t\ticon={ symbol }\n\t\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t{ ( ! showTooltip ||\n\t\t\t\t\t\t\t\t\t\tpattern.type ===\n\t\t\t\t\t\t\t\t\t\t\tINSERTER_PATTERN_TYPES.user ) && (\n\t\t\t\t\t\t\t\t\t\t<div className=\"block-editor-block-patterns-list__item-title\">\n\t\t\t\t\t\t\t\t\t\t\t{ pattern.title }\n\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</HStack>\n\t\t\t\t\t\t\t) }\n\n\t\t\t\t\t\t\t{ !! pattern.description && (\n\t\t\t\t\t\t\t\t<VisuallyHidden id={ descriptionId }>\n\t\t\t\t\t\t\t\t\t{ pattern.description }\n\t\t\t\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</Composite.Item>\n\t\t\t\t\t</WithToolTip>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t</InserterDraggableBlocks>\n\t);\n}\n\nfunction BlockPatternPlaceholder() {\n\treturn (\n\t\t<div className=\"block-editor-block-patterns-list__item is-placeholder\" />\n\t);\n}\n\nfunction BlockPatternsList(\n\t{\n\t\tisDraggable,\n\t\tblockPatterns,\n\t\tshownPatterns,\n\t\tonHover,\n\t\tonClickPattern,\n\t\torientation,\n\t\tlabel = __( 'Block patterns' ),\n\t\tcategory,\n\t\tshowTitle = true,\n\t\tshowTitlesAsTooltip,\n\t\tpagingProps,\n\t},\n\tref\n) {\n\tconst [ activeCompositeId, setActiveCompositeId ] = useState( undefined );\n\n\tuseEffect( () => {\n\t\t// Reset the active composite item whenever the available patterns change,\n\t\t// to make sure that Composite widget can receive focus correctly when its\n\t\t// composite items change. The first composite item will receive focus.\n\t\tconst firstCompositeItemId = blockPatterns.find( ( pattern ) =>\n\t\t\tshownPatterns.includes( pattern )\n\t\t)?.name;\n\t\tsetActiveCompositeId( firstCompositeItemId );\n\t}, [ shownPatterns, blockPatterns ] );\n\n\treturn (\n\t\t<Composite\n\t\t\torientation={ orientation }\n\t\t\tactiveId={ activeCompositeId }\n\t\t\tsetActiveId={ setActiveCompositeId }\n\t\t\trole=\"listbox\"\n\t\t\tclassName=\"block-editor-block-patterns-list\"\n\t\t\taria-label={ label }\n\t\t\tref={ ref }\n\t\t>\n\t\t\t{ blockPatterns.map( ( pattern ) => {\n\t\t\t\tconst isShown = shownPatterns.includes( pattern );\n\t\t\t\treturn isShown ? (\n\t\t\t\t\t<BlockPattern\n\t\t\t\t\t\tkey={ pattern.name }\n\t\t\t\t\t\tid={ pattern.name }\n\t\t\t\t\t\tpattern={ pattern }\n\t\t\t\t\t\tonClick={ onClickPattern }\n\t\t\t\t\t\tonHover={ onHover }\n\t\t\t\t\t\tisDraggable={ isDraggable }\n\t\t\t\t\t\tshowTitle={ showTitle }\n\t\t\t\t\t\tshowTooltip={ showTitlesAsTooltip }\n\t\t\t\t\t\tcategory={ category }\n\t\t\t\t\t/>\n\t\t\t\t) : (\n\t\t\t\t\t<BlockPatternPlaceholder key={ pattern.name } />\n\t\t\t\t);\n\t\t\t} ) }\n\t\t\t{ pagingProps && <BlockPatternsPaging { ...pagingProps } /> }\n\t\t</Composite>\n\t);\n}\n\nexport default forwardRef( BlockPatternsList );\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SAASC,UAAU,QAAQ,mBAAmB;AAC9C,SAASC,SAAS,EAAEC,QAAQ,EAAEC,UAAU,EAAEC,OAAO,QAAQ,oBAAoB;AAC7E,SACCC,SAAS,EACTC,cAAc,EACdC,OAAO,EACPC,oBAAoB,IAAIC,MAAM,QACxB,uBAAuB;AAC9B,SAASC,aAAa,QAAQ,oBAAoB;AAClD,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,IAAI,EAAEC,MAAM,QAAQ,kB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CAACmD,IAAM;QACnBnD,OAAO,EAAGA,OAAS;QACnBC,OAAO,EAAGwC,cAAgB;QAC1BvC,OAAO,EAAGA,OAAS;QACnBH,WAAW,EAAGA,WAAa;QAC3BI,SAAS,EAAGA,SAAW;QACvBV,WAAW,EAAGmD,mBAAqB;QACnCxC,QAAQ,EAAGA;MAAU,GARfJ,OAAO,CAACmD,IASd,CAAC,gBAEFhE,IAAA,CAACkD,uBAAuB,MAAOrC,OAAO,CAACmD,IAAQ,CAC/C;IACF,CAAE,CAAC,EACDN,WAAW,iBAAI1D,IAAA,CAACH,mBAAmB;MAAA,GAAM6D;IAAW,CAAI,CAAC;EAAA,CACjD,CAAC;AAEd;AAEA,eAAe1E,UAAU,CAAEmE,iBAAkB,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["clsx","cloneBlock","useEffect","useState","forwardRef","useMemo","Composite","VisuallyHidden","Tooltip","__experimentalHStack","HStack","useInstanceId","__","Icon","symbol","BlockPreview","InserterDraggableBlocks","BlockPatternsPaging","INSERTER_PATTERN_TYPES","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","WithToolTip","showTooltip","title","children","text","BlockPattern","id","isDraggable","pattern","onClick","onHover","showTitlesAsTooltip","category","isDragging","setIsDragging","blocks","viewportWidth","instanceId","descriptionId","isUserPattern","type","user","patternBlocks","map","block","clonedBlock","attributes","metadata","categories","includes","isEnabled","draggable","onDragStart","onDragEnd","className","event","Item","render","role","description","undefined","syncStatus","onMouseEnter","onMouseLeave","Async","placeholder","BlockPatternPlaceholder","spacing","icon","BlockPatternsList","blockPatterns","onClickPattern","orientation","label","pagingProps","ref","activeCompositeId","setActiveCompositeId","firstCompositeItemId","name","activeId","setActiveId"],"sources":["@wordpress/block-editor/src/components/block-patterns-list/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { cloneBlock } from '@wordpress/blocks';\nimport { useEffect, useState, forwardRef, useMemo } from '@wordpress/element';\nimport {\n\tComposite,\n\tVisuallyHidden,\n\tTooltip,\n\t__experimentalHStack as HStack,\n} from '@wordpress/components';\nimport { useInstanceId } from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\nimport { Icon, symbol } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport BlockPreview from '../block-preview';\nimport InserterDraggableBlocks from '../inserter-draggable-blocks';\nimport BlockPatternsPaging from '../block-patterns-paging';\nimport { INSERTER_PATTERN_TYPES } from '../inserter/block-patterns-tab/utils';\n\nconst WithToolTip = ( { showTooltip, title, children } ) => {\n\tif ( showTooltip ) {\n\t\treturn <Tooltip text={ title }>{ children }</Tooltip>;\n\t}\n\treturn <>{ children }</>;\n};\n\nfunction BlockPattern( {\n\tid,\n\tisDraggable,\n\tpattern,\n\tonClick,\n\tonHover,\n\tshowTitlesAsTooltip,\n\tcategory,\n} ) {\n\tconst [ isDragging, setIsDragging ] = useState( false );\n\tconst { blocks, viewportWidth } = pattern;\n\tconst instanceId = useInstanceId( BlockPattern );\n\tconst descriptionId = `block-editor-block-patterns-list__item-description-${ instanceId }`;\n\tconst isUserPattern = pattern.type === INSERTER_PATTERN_TYPES.user;\n\n\t// When we have a selected category and the pattern is draggable, we need to update the\n\t// pattern's categories in metadata to only contain the selected category, and pass this to\n\t// InserterDraggableBlocks component. We do that because we use this information for pattern\n\t// shuffling and it makes more sense to show only the ones from the initially selected category during insertion.\n\tconst patternBlocks = useMemo( () => {\n\t\tif ( ! category || ! isDraggable ) {\n\t\t\treturn blocks;\n\t\t}\n\t\treturn ( blocks ?? [] ).map( ( block ) => {\n\t\t\tconst clonedBlock = cloneBlock( block );\n\t\t\tif (\n\t\t\t\tclonedBlock.attributes.metadata?.categories?.includes(\n\t\t\t\t\tcategory\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tclonedBlock.attributes.metadata.categories = [ category ];\n\t\t\t}\n\t\t\treturn clonedBlock;\n\t\t} );\n\t}, [ blocks, isDraggable, category ] );\n\n\treturn (\n\t\t<InserterDraggableBlocks\n\t\t\tisEnabled={ isDraggable }\n\t\t\tblocks={ patternBlocks }\n\t\t\tpattern={ pattern }\n\t\t>\n\t\t\t{ ( { draggable, onDragStart, onDragEnd } ) => (\n\t\t\t\t<div\n\t\t\t\t\tclassName=\"block-editor-block-patterns-list__list-item\"\n\t\t\t\t\tdraggable={ draggable }\n\t\t\t\t\tonDragStart={ ( event ) => {\n\t\t\t\t\t\tsetIsDragging( true );\n\t\t\t\t\t\tif ( onDragStart ) {\n\t\t\t\t\t\t\tonHover?.( null );\n\t\t\t\t\t\t\tonDragStart( event );\n\t\t\t\t\t\t}\n\t\t\t\t\t} }\n\t\t\t\t\tonDragEnd={ ( event ) => {\n\t\t\t\t\t\tsetIsDragging( false );\n\t\t\t\t\t\tif ( onDragEnd ) {\n\t\t\t\t\t\t\tonDragEnd( event );\n\t\t\t\t\t\t}\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t<WithToolTip\n\t\t\t\t\t\tshowTooltip={ showTitlesAsTooltip && ! isUserPattern }\n\t\t\t\t\t\ttitle={ pattern.title }\n\t\t\t\t\t>\n\t\t\t\t\t\t<Composite.Item\n\t\t\t\t\t\t\trender={\n\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\trole=\"option\"\n\t\t\t\t\t\t\t\t\taria-label={ pattern.title }\n\t\t\t\t\t\t\t\t\taria-describedby={\n\t\t\t\t\t\t\t\t\t\tpattern.description\n\t\t\t\t\t\t\t\t\t\t\t? descriptionId\n\t\t\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t\t\t\t'block-editor-block-patterns-list__item',\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t'block-editor-block-patterns-list__list-item-synced':\n\t\t\t\t\t\t\t\t\t\t\t\tpattern.type ===\n\t\t\t\t\t\t\t\t\t\t\t\t\tINSERTER_PATTERN_TYPES.user &&\n\t\t\t\t\t\t\t\t\t\t\t\t! pattern.syncStatus,\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tid={ id }\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tonClick( pattern, blocks );\n\t\t\t\t\t\t\t\tonHover?.( null );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tonMouseEnter={ () => {\n\t\t\t\t\t\t\t\tif ( isDragging ) {\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tonHover?.( pattern );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tonMouseLeave={ () => onHover?.( null ) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<BlockPreview.Async\n\t\t\t\t\t\t\t\tplaceholder={ <BlockPatternPlaceholder /> }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<BlockPreview\n\t\t\t\t\t\t\t\t\tblocks={ blocks }\n\t\t\t\t\t\t\t\t\tviewportWidth={ viewportWidth }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</BlockPreview.Async>\n\t\t\t\t\t\t\t{ ( ! showTitlesAsTooltip || isUserPattern ) && (\n\t\t\t\t\t\t\t\t<HStack\n\t\t\t\t\t\t\t\t\tclassName=\"block-editor-patterns__pattern-details\"\n\t\t\t\t\t\t\t\t\tspacing={ 2 }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ isUserPattern && ! pattern.syncStatus && (\n\t\t\t\t\t\t\t\t\t\t<div className=\"block-editor-patterns__pattern-icon-wrapper\">\n\t\t\t\t\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\t\t\t\t\tclassName=\"block-editor-patterns__pattern-icon\"\n\t\t\t\t\t\t\t\t\t\t\t\ticon={ symbol }\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t<div className=\"block-editor-block-patterns-list__item-title\">\n\t\t\t\t\t\t\t\t\t\t{ pattern.title }\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t</HStack>\n\t\t\t\t\t\t\t) }\n\n\t\t\t\t\t\t\t{ !! pattern.description && (\n\t\t\t\t\t\t\t\t<VisuallyHidden id={ descriptionId }>\n\t\t\t\t\t\t\t\t\t{ pattern.description }\n\t\t\t\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</Composite.Item>\n\t\t\t\t\t</WithToolTip>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t</InserterDraggableBlocks>\n\t);\n}\n\nfunction BlockPatternPlaceholder() {\n\treturn (\n\t\t<div className=\"block-editor-block-patterns-list__item is-placeholder\" />\n\t);\n}\n\nfunction BlockPatternsList(\n\t{\n\t\tisDraggable,\n\t\tblockPatterns,\n\t\tonHover,\n\t\tonClickPattern,\n\t\torientation,\n\t\tlabel = __( 'Block patterns' ),\n\t\tcategory,\n\t\tshowTitlesAsTooltip,\n\t\tpagingProps,\n\t},\n\tref\n) {\n\tconst [ activeCompositeId, setActiveCompositeId ] = useState( undefined );\n\n\tuseEffect( () => {\n\t\t// Reset the active composite item whenever the available patterns change,\n\t\t// to make sure that Composite widget can receive focus correctly when its\n\t\t// composite items change. The first composite item will receive focus.\n\t\tconst firstCompositeItemId = blockPatterns[ 0 ]?.name;\n\t\tsetActiveCompositeId( firstCompositeItemId );\n\t}, [ blockPatterns ] );\n\n\treturn (\n\t\t<Composite\n\t\t\torientation={ orientation }\n\t\t\tactiveId={ activeCompositeId }\n\t\t\tsetActiveId={ setActiveCompositeId }\n\t\t\trole=\"listbox\"\n\t\t\tclassName=\"block-editor-block-patterns-list\"\n\t\t\taria-label={ label }\n\t\t\tref={ ref }\n\t\t>\n\t\t\t{ blockPatterns.map( ( pattern ) => (\n\t\t\t\t<BlockPattern\n\t\t\t\t\tkey={ pattern.name }\n\t\t\t\t\tid={ pattern.name }\n\t\t\t\t\tpattern={ pattern }\n\t\t\t\t\tonClick={ onClickPattern }\n\t\t\t\t\tonHover={ onHover }\n\t\t\t\t\tisDraggable={ isDraggable }\n\t\t\t\t\tshowTitlesAsTooltip={ showTitlesAsTooltip }\n\t\t\t\t\tcategory={ category }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t\t{ pagingProps && <BlockPatternsPaging { ...pagingProps } /> }\n\t\t</Composite>\n\t);\n}\n\nexport default forwardRef( BlockPatternsList );\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SAASC,UAAU,QAAQ,mBAAmB;AAC9C,SAASC,SAAS,EAAEC,QAAQ,EAAEC,UAAU,EAAEC,OAAO,QAAQ,oBAAoB;AAC7E,SACCC,SAAS,EACTC,cAAc,EACdC,OAAO,EACPC,oBAAoB,IAAIC,MAAM,QACxB,uBAAuB;AAC9B,SAASC,aAAa,QAAQ,oBAAoB;AAClD,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,IAAI,EAAEC,MAAM,QAAQ,kBAAkB;;AAE/C;AACA;AACA;AACA,OAAOC,YAAY,MAAM,kBAAkB;AAC3C,OAAOC,uBAAuB,MAAM,8BAA8B;AAClE,OAAOC,mBAAmB,MAAM,0BAA0B;AAC1D,SAASC,sBAAsB,QAAQ,sCAAsC;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,QAAA,IAAAC,SAAA,EAAAC,IAAA,IAAAC,KAAA;AAE9E,MAAMC,WAAW,GAAGA,CAAE;EAAEC,WAAW;EAAEC,KAAK;EAAEC;AAAS,CAAC,KAAM;EAC3D,IAAKF,WAAW,EAAG;IAClB,oBAAON,IAAA,CAACZ,OAAO;MAACqB,IAAI,EAAGF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EACRD,mBAAmB;EACnB2C;AACD,CAAC,EACDC,GAAG,EACF;EACD,MAAM,CAAEC,iBAAiB,EAAEC,oBAAoB,CAAE,GAAG/E,QAAQ,CAAE8D,SAAU,CAAC;EAEzE/D,SAAS,CAAE,MAAM;IAChB;IACA;IACA;IACA,MAAMiF,oBAAoB,GAAGR,aAAa,CAAE,CAAC,CAAE,EAAES,IAAI;IACrDF,oBAAoB,CAAEC,oBAAqB,CAAC;EAC7C,CAAC,EAAE,CAAER,aAAa,CAAG,CAAC;EAEtB,oBACCnD,KAAA,CAAClB,SAAS;IACTuE,WAAW,EAAGA,WAAa;IAC3BQ,QAAQ,EAAGJ,iBAAmB;IAC9BK,WAAW,EAAGJ,oBAAsB;IACpCnB,IAAI,EAAC,SAAS;IACdJ,SAAS,EAAC,kCAAkC;IAC5C,cAAamB,KAAO;IACpBE,GAAG,EAAGA,GAAK;IAAApD,QAAA,GAET+C,aAAa,CAAC3B,GAAG,CAAIf,OAAO,iBAC7Bb,IAAA,CAACU,YAAY;MAEZC,EAAE,EAAGE,OAAO,CAACmD,IAAM;MACnBnD,OAAO,EAAGA,OAAS;MACnBC,OAAO,EAAG0C,cAAgB;MAC1BzC,OAAO,EAAGA,OAAS;MACnBH,WAAW,EAAGA,WAAa;MAC3BI,mBAAmB,EAAGA,mBAAqB;MAC3CC,QAAQ,EAAGA;IAAU,GAPfJ,OAAO,CAACmD,IAQd,CACA,CAAC,EACDL,WAAW,iBAAI3D,IAAA,CAACH,mBAAmB;MAAA,GAAM8D;IAAW,CAAI,CAAC;EAAA,CACjD,CAAC;AAEd;AAEA,eAAe3E,UAAU,CAAEsE,iBAAkB,CAAC","ignoreList":[]}
@@ -15,7 +15,7 @@ import { forwardRef, useMemo, useReducer, useLayoutEffect } from '@wordpress/ele
15
15
  */
16
16
  import { useBlockElement } from '../block-list/use-block-props/use-block-refs';
17
17
  import usePopoverScroll from './use-popover-scroll';
18
- import { rectUnion, getVisibleElementBounds } from '../../utils/dom';
18
+ import { rectUnion, getElementBounds } from '../../utils/dom';
19
19
  import { jsx as _jsx } from "react/jsx-runtime";
20
20
  const MAX_POPOVER_RECOMPUTE_COUNTER = Number.MAX_SAFE_INTEGER;
21
21
  function BlockPopover({
@@ -63,7 +63,7 @@ function BlockPopover({
63
63
  }
64
64
  return {
65
65
  getBoundingClientRect() {
66
- return lastSelectedElement ? rectUnion(getVisibleElementBounds(selectedElement), getVisibleElementBounds(lastSelectedElement)) : getVisibleElementBounds(selectedElement);
66
+ return lastSelectedElement ? rectUnion(getElementBounds(selectedElement), getElementBounds(lastSelectedElement)) : getElementBounds(selectedElement);
67
67
  },
68
68
  contextElement: selectedElement
69
69
  };
@@ -1 +1 @@
1
- {"version":3,"names":["clsx","useMergeRefs","Popover","forwardRef","useMemo","useReducer","useLayoutEffect","useBlockElement","usePopoverScroll","rectUnion","getVisibleElementBounds","jsx","_jsx","MAX_POPOVER_RECOMPUTE_COUNTER","Number","MAX_SAFE_INTEGER","BlockPopover","clientId","bottomClientId","children","__unstablePopoverSlot","__unstableContentRef","shift","props","ref","selectedElement","lastSelectedElement","mergedRefs","popoverDimensionsRecomputeCounter","forceRecomputePopoverDimensions","s","observer","window","MutationObserver","observe","attributes","disconnect","popoverAnchor","undefined","getBoundingClientRect","contextElement","animate","focusOnMount","anchor","__unstableSlotName","inline","placement","resize","flip","className","variant","PrivateBlockPopover","PublicBlockPopover"],"sources":["@wordpress/block-editor/src/components/block-popover/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useMergeRefs } from '@wordpress/compose';\nimport { Popover } from '@wordpress/components';\nimport {\n\tforwardRef,\n\tuseMemo,\n\tuseReducer,\n\tuseLayoutEffect,\n} from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { useBlockElement } from '../block-list/use-block-props/use-block-refs';\nimport usePopoverScroll from './use-popover-scroll';\nimport { rectUnion, getVisibleElementBounds } from '../../utils/dom';\n\nconst MAX_POPOVER_RECOMPUTE_COUNTER = Number.MAX_SAFE_INTEGER;\n\nfunction BlockPopover(\n\t{\n\t\tclientId,\n\t\tbottomClientId,\n\t\tchildren,\n\t\t__unstablePopoverSlot,\n\t\t__unstableContentRef,\n\t\tshift = true,\n\t\t...props\n\t},\n\tref\n) {\n\tconst selectedElement = useBlockElement( clientId );\n\tconst lastSelectedElement = useBlockElement( bottomClientId ?? clientId );\n\tconst mergedRefs = useMergeRefs( [\n\t\tref,\n\t\tusePopoverScroll( __unstableContentRef ),\n\t] );\n\n\tconst [\n\t\tpopoverDimensionsRecomputeCounter,\n\t\tforceRecomputePopoverDimensions,\n\t] = useReducer(\n\t\t// Module is there to make sure that the counter doesn't overflow.\n\t\t( s ) => ( s + 1 ) % MAX_POPOVER_RECOMPUTE_COUNTER,\n\t\t0\n\t);\n\n\t// When blocks are moved up/down, they are animated to their new position by\n\t// updating the `transform` property manually (i.e. without using CSS\n\t// transitions or animations). The animation, which can also scroll the block\n\t// editor, can sometimes cause the position of the Popover to get out of sync.\n\t// A MutationObserver is therefore used to make sure that changes to the\n\t// selectedElement's attribute (i.e. `transform`) can be tracked and used to\n\t// trigger the Popover to rerender.\n\tuseLayoutEffect( () => {\n\t\tif ( ! selectedElement ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst observer = new window.MutationObserver(\n\t\t\tforceRecomputePopoverDimensions\n\t\t);\n\t\tobserver.observe( selectedElement, { attributes: true } );\n\n\t\treturn () => {\n\t\t\tobserver.disconnect();\n\t\t};\n\t}, [ selectedElement ] );\n\n\tconst popoverAnchor = useMemo( () => {\n\t\tif (\n\t\t\t// popoverDimensionsRecomputeCounter is by definition always equal or greater\n\t\t\t// than 0. This check is only there to satisfy the correctness of the\n\t\t\t// exhaustive-deps rule for the `useMemo` hook.\n\t\t\tpopoverDimensionsRecomputeCounter < 0 ||\n\t\t\t! selectedElement ||\n\t\t\t( bottomClientId && ! lastSelectedElement )\n\t\t) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn {\n\t\t\tgetBoundingClientRect() {\n\t\t\t\treturn lastSelectedElement\n\t\t\t\t\t? rectUnion(\n\t\t\t\t\t\t\tgetVisibleElementBounds( selectedElement ),\n\t\t\t\t\t\t\tgetVisibleElementBounds( lastSelectedElement )\n\t\t\t\t\t )\n\t\t\t\t\t: getVisibleElementBounds( selectedElement );\n\t\t\t},\n\t\t\tcontextElement: selectedElement,\n\t\t};\n\t}, [\n\t\tpopoverDimensionsRecomputeCounter,\n\t\tselectedElement,\n\t\tbottomClientId,\n\t\tlastSelectedElement,\n\t] );\n\n\tif ( ! selectedElement || ( bottomClientId && ! lastSelectedElement ) ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Popover\n\t\t\tref={ mergedRefs }\n\t\t\tanimate={ false }\n\t\t\tfocusOnMount={ false }\n\t\t\tanchor={ popoverAnchor }\n\t\t\t// Render in the old slot if needed for backward compatibility,\n\t\t\t// otherwise render in place (not in the default popover slot).\n\t\t\t__unstableSlotName={ __unstablePopoverSlot }\n\t\t\tinline={ ! __unstablePopoverSlot }\n\t\t\tplacement=\"top-start\"\n\t\t\tresize={ false }\n\t\t\tflip={ false }\n\t\t\tshift={ shift }\n\t\t\t{ ...props }\n\t\t\tclassName={ clsx( 'block-editor-block-popover', props.className ) }\n\t\t\tvariant=\"unstyled\"\n\t\t>\n\t\t\t{ children }\n\t\t</Popover>\n\t);\n}\n\nexport const PrivateBlockPopover = forwardRef( BlockPopover );\n\nconst PublicBlockPopover = (\n\t{ clientId, bottomClientId, children, ...props },\n\tref\n) => (\n\t<PrivateBlockPopover\n\t\t{ ...props }\n\t\tbottomClientId={ bottomClientId }\n\t\tclientId={ clientId }\n\t\t__unstableContentRef={ undefined }\n\t\t__unstablePopoverSlot={ undefined }\n\t\tref={ ref }\n\t>\n\t\t{ children }\n\t</PrivateBlockPopover>\n);\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-popover/README.md\n */\nexport default forwardRef(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AMgC,mBAAmB,GAAGhD,UAAU,CAAEa,YAAa,CAAC;AAE7D,MAAMoC,kBAAkB,GAAGA,CAC1B;EAAEnC,QAAQ;EAAEC,cAAc;EAAEC,QAAQ;EAAE,GAAGI;AAAM,CAAC,EAChDC,GAAG,kBAEHZ,IAAA,CAACuC,mBAAmB;EAAA,GACd5B,KAAK;EACVL,cAAc,EAAGA,cAAgB;EACjCD,QAAQ,EAAGA,QAAU;EACrBI,oBAAoB,EAAGiB,SAAW;EAClClB,qBAAqB,EAAGkB,SAAW;EACnCd,GAAG,EAAGA,GAAK;EAAAL,QAAA,EAETA;AAAQ,CACU,CACrB;;AAED;AACA;AACA;AACA,eAAehB,UAAU,CAAEiD,kBAAmB,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["clsx","useMergeRefs","Popover","forwardRef","useMemo","useReducer","useLayoutEffect","useBlockElement","usePopoverScroll","rectUnion","getElementBounds","jsx","_jsx","MAX_POPOVER_RECOMPUTE_COUNTER","Number","MAX_SAFE_INTEGER","BlockPopover","clientId","bottomClientId","children","__unstablePopoverSlot","__unstableContentRef","shift","props","ref","selectedElement","lastSelectedElement","mergedRefs","popoverDimensionsRecomputeCounter","forceRecomputePopoverDimensions","s","observer","window","MutationObserver","observe","attributes","disconnect","popoverAnchor","undefined","getBoundingClientRect","contextElement","animate","focusOnMount","anchor","__unstableSlotName","inline","placement","resize","flip","className","variant","PrivateBlockPopover","PublicBlockPopover"],"sources":["@wordpress/block-editor/src/components/block-popover/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useMergeRefs } from '@wordpress/compose';\nimport { Popover } from '@wordpress/components';\nimport {\n\tforwardRef,\n\tuseMemo,\n\tuseReducer,\n\tuseLayoutEffect,\n} from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { useBlockElement } from '../block-list/use-block-props/use-block-refs';\nimport usePopoverScroll from './use-popover-scroll';\nimport { rectUnion, getElementBounds } from '../../utils/dom';\n\nconst MAX_POPOVER_RECOMPUTE_COUNTER = Number.MAX_SAFE_INTEGER;\n\nfunction BlockPopover(\n\t{\n\t\tclientId,\n\t\tbottomClientId,\n\t\tchildren,\n\t\t__unstablePopoverSlot,\n\t\t__unstableContentRef,\n\t\tshift = true,\n\t\t...props\n\t},\n\tref\n) {\n\tconst selectedElement = useBlockElement( clientId );\n\tconst lastSelectedElement = useBlockElement( bottomClientId ?? clientId );\n\tconst mergedRefs = useMergeRefs( [\n\t\tref,\n\t\tusePopoverScroll( __unstableContentRef ),\n\t] );\n\n\tconst [\n\t\tpopoverDimensionsRecomputeCounter,\n\t\tforceRecomputePopoverDimensions,\n\t] = useReducer(\n\t\t// Module is there to make sure that the counter doesn't overflow.\n\t\t( s ) => ( s + 1 ) % MAX_POPOVER_RECOMPUTE_COUNTER,\n\t\t0\n\t);\n\n\t// When blocks are moved up/down, they are animated to their new position by\n\t// updating the `transform` property manually (i.e. without using CSS\n\t// transitions or animations). The animation, which can also scroll the block\n\t// editor, can sometimes cause the position of the Popover to get out of sync.\n\t// A MutationObserver is therefore used to make sure that changes to the\n\t// selectedElement's attribute (i.e. `transform`) can be tracked and used to\n\t// trigger the Popover to rerender.\n\tuseLayoutEffect( () => {\n\t\tif ( ! selectedElement ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst observer = new window.MutationObserver(\n\t\t\tforceRecomputePopoverDimensions\n\t\t);\n\t\tobserver.observe( selectedElement, { attributes: true } );\n\n\t\treturn () => {\n\t\t\tobserver.disconnect();\n\t\t};\n\t}, [ selectedElement ] );\n\n\tconst popoverAnchor = useMemo( () => {\n\t\tif (\n\t\t\t// popoverDimensionsRecomputeCounter is by definition always equal or greater\n\t\t\t// than 0. This check is only there to satisfy the correctness of the\n\t\t\t// exhaustive-deps rule for the `useMemo` hook.\n\t\t\tpopoverDimensionsRecomputeCounter < 0 ||\n\t\t\t! selectedElement ||\n\t\t\t( bottomClientId && ! lastSelectedElement )\n\t\t) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn {\n\t\t\tgetBoundingClientRect() {\n\t\t\t\treturn lastSelectedElement\n\t\t\t\t\t? rectUnion(\n\t\t\t\t\t\t\tgetElementBounds( selectedElement ),\n\t\t\t\t\t\t\tgetElementBounds( lastSelectedElement )\n\t\t\t\t\t )\n\t\t\t\t\t: getElementBounds( selectedElement );\n\t\t\t},\n\t\t\tcontextElement: selectedElement,\n\t\t};\n\t}, [\n\t\tpopoverDimensionsRecomputeCounter,\n\t\tselectedElement,\n\t\tbottomClientId,\n\t\tlastSelectedElement,\n\t] );\n\n\tif ( ! selectedElement || ( bottomClientId && ! lastSelectedElement ) ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Popover\n\t\t\tref={ mergedRefs }\n\t\t\tanimate={ false }\n\t\t\tfocusOnMount={ false }\n\t\t\tanchor={ popoverAnchor }\n\t\t\t// Render in the old slot if needed for backward compatibility,\n\t\t\t// otherwise render in place (not in the default popover slot).\n\t\t\t__unstableSlotName={ __unstablePopoverSlot }\n\t\t\tinline={ ! __unstablePopoverSlot }\n\t\t\tplacement=\"top-start\"\n\t\t\tresize={ false }\n\t\t\tflip={ false }\n\t\t\tshift={ shift }\n\t\t\t{ ...props }\n\t\t\tclassName={ clsx( 'block-editor-block-popover', props.className ) }\n\t\t\tvariant=\"unstyled\"\n\t\t>\n\t\t\t{ children }\n\t\t</Popover>\n\t);\n}\n\nexport const PrivateBlockPopover = forwardRef( BlockPopover );\n\nconst PublicBlockPopover = (\n\t{ clientId, bottomClientId, children, ...props },\n\tref\n) => (\n\t<PrivateBlockPopover\n\t\t{ ...props }\n\t\tbottomClientId={ bottomClientId }\n\t\tclientId={ clientId }\n\t\t__unstableContentRef={ undefined }\n\t\t__unstablePopoverSlot={ undefined }\n\t\tref={ ref }\n\t>\n\t\t{ children }\n\t</PrivateBlockPopover>\n);\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-popover/README.md\n */\nex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AO,MAAMgC,mBAAmB,GAAGhD,UAAU,CAAEa,YAAa,CAAC;AAE7D,MAAMoC,kBAAkB,GAAGA,CAC1B;EAAEnC,QAAQ;EAAEC,cAAc;EAAEC,QAAQ;EAAE,GAAGI;AAAM,CAAC,EAChDC,GAAG,kBAEHZ,IAAA,CAACuC,mBAAmB;EAAA,GACd5B,KAAK;EACVL,cAAc,EAAGA,cAAgB;EACjCD,QAAQ,EAAGA,QAAU;EACrBI,oBAAoB,EAAGiB,SAAW;EAClClB,qBAAqB,EAAGkB,SAAW;EACnCd,GAAG,EAAGA,GAAK;EAAAL,QAAA,EAETA;AAAQ,CACU,CACrB;;AAED;AACA;AACA;AACA,eAAehB,UAAU,CAAEiD,kBAAmB,CAAC","ignoreList":[]}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useEffect, useState, flushSync } from '@wordpress/element';
5
+ import { createQueue } from '@wordpress/priority-queue';
6
+ const blockPreviewQueue = createQueue();
7
+
8
+ /**
9
+ * Renders a component at the next idle time.
10
+ * @param {*} props
11
+ */
12
+ export function Async({
13
+ children,
14
+ placeholder
15
+ }) {
16
+ const [shouldRender, setShouldRender] = useState(false);
17
+
18
+ // In the future, we could try to use startTransition here, but currently
19
+ // react will batch all transitions, which means all previews will be
20
+ // rendered at the same time.
21
+ // https://react.dev/reference/react/startTransition#caveats
22
+ // > If there are multiple ongoing Transitions, React currently batches them
23
+ // > together. This is a limitation that will likely be removed in a future
24
+ // > release.
25
+
26
+ useEffect(() => {
27
+ const context = {};
28
+ blockPreviewQueue.add(context, () => {
29
+ // Synchronously run all renders so it consumes timeRemaining.
30
+ // See https://github.com/WordPress/gutenberg/pull/48238
31
+ flushSync(() => {
32
+ setShouldRender(true);
33
+ });
34
+ });
35
+ return () => {
36
+ blockPreviewQueue.cancel(context);
37
+ };
38
+ }, []);
39
+ if (!shouldRender) {
40
+ return placeholder;
41
+ }
42
+ return children;
43
+ }
44
+ //# sourceMappingURL=async.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useEffect","useState","flushSync","createQueue","blockPreviewQueue","Async","children","placeholder","shouldRender","setShouldRender","context","add","cancel"],"sources":["@wordpress/block-editor/src/components/block-preview/async.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useState, flushSync } from '@wordpress/element';\nimport { createQueue } from '@wordpress/priority-queue';\n\nconst blockPreviewQueue = createQueue();\n\n/**\n * Renders a component at the next idle time.\n * @param {*} props\n */\nexport function Async( { children, placeholder } ) {\n\tconst [ shouldRender, setShouldRender ] = useState( false );\n\n\t// In the future, we could try to use startTransition here, but currently\n\t// react will batch all transitions, which means all previews will be\n\t// rendered at the same time.\n\t// https://react.dev/reference/react/startTransition#caveats\n\t// > If there are multiple ongoing Transitions, React currently batches them\n\t// > together. This is a limitation that will likely be removed in a future\n\t// > release.\n\n\tuseEffect( () => {\n\t\tconst context = {};\n\t\tblockPreviewQueue.add( context, () => {\n\t\t\t// Synchronously run all renders so it consumes timeRemaining.\n\t\t\t// See https://github.com/WordPress/gutenberg/pull/48238\n\t\t\tflushSync( () => {\n\t\t\t\tsetShouldRender( true );\n\t\t\t} );\n\t\t} );\n\t\treturn () => {\n\t\t\tblockPreviewQueue.cancel( context );\n\t\t};\n\t}, [] );\n\n\tif ( ! shouldRender ) {\n\t\treturn placeholder;\n\t}\n\n\treturn children;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,QAAQ,EAAEC,SAAS,QAAQ,oBAAoB;AACnE,SAASC,WAAW,QAAQ,2BAA2B;AAEvD,MAAMC,iBAAiB,GAAGD,WAAW,CAAC,CAAC;;AAEvC;AACA;AACA;AACA;AACA,OAAO,SAASE,KAAKA,CAAE;EAAEC,QAAQ;EAAEC;AAAY,CAAC,EAAG;EAClD,MAAM,CAAEC,YAAY,EAAEC,eAAe,CAAE,GAAGR,QAAQ,CAAE,KAAM,CAAC;;EAE3D;EACA;EACA;EACA;EACA;EACA;EACA;;EAEAD,SAAS,CAAE,MAAM;IAChB,MAAMU,OAAO,GAAG,CAAC,CAAC;IAClBN,iBAAiB,CAACO,GAAG,CAAED,OAAO,EAAE,MAAM;MACrC;MACA;MACAR,SAAS,CAAE,MAAM;QAChBO,eAAe,CAAE,IAAK,CAAC;MACxB,CAAE,CAAC;IACJ,CAAE,CAAC;IACH,OAAO,MAAM;MACZL,iBAAiB,CAACQ,MAAM,CAAEF,OAAQ,CAAC;IACpC,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EAEP,IAAK,CAAEF,YAAY,EAAG;IACrB,OAAOD,WAAW;EACnB;EAEA,OAAOD,QAAQ;AAChB","ignoreList":[]}
@@ -19,6 +19,7 @@ import AutoHeightBlockPreview from './auto';
19
19
  import EditorStyles from '../editor-styles';
20
20
  import { store as blockEditorStore } from '../../store';
21
21
  import { BlockListItems } from '../block-list';
22
+ import { Async } from './async';
22
23
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
23
24
  const EMPTY_ADDITIONAL_STYLES = [];
24
25
  export function BlockPreview({
@@ -69,6 +70,8 @@ export function BlockPreview({
69
70
  })
70
71
  });
71
72
  }
73
+ const MemoizedBlockPreview = memo(BlockPreview);
74
+ MemoizedBlockPreview.Async = Async;
72
75
 
73
76
  /**
74
77
  * BlockPreview renders a preview of a block or array of blocks.
@@ -81,7 +84,7 @@ export function BlockPreview({
81
84
  *
82
85
  * @return {Component} The component to be rendered.
83
86
  */
84
- export default memo(BlockPreview);
87
+ export default MemoizedBlockPreview;
85
88
 
86
89
  /**
87
90
  * This hook is used to lightly mark an element as a block preview wrapper
@@ -1 +1 @@
1
- {"version":3,"names":["clsx","useDisabled","useMergeRefs","useSelect","memo","useMemo","deprecated","ExperimentalBlockEditorProvider","AutoHeightBlockPreview","EditorStyles","store","blockEditorStore","BlockListItems","jsx","_jsx","jsxs","_jsxs","EMPTY_ADDITIONAL_STYLES","BlockPreview","blocks","viewportWidth","minHeight","additionalStyles","__experimentalMinHeight","__experimentalPadding","since","version","alternative","css","originalSettings","select","getSettings","settings","focusMode","isPreviewMode","renderedBlocks","Array","isArray","length","value","children","useBlockPreview","props","layout","styles","undefined","disabledRef","ref","renderAppender","className"],"sources":["@wordpress/block-editor/src/components/block-preview/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useDisabled, useMergeRefs } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport { memo, useMemo } from '@wordpress/element';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport { ExperimentalBlockEditorProvider } from '../provider';\nimport AutoHeightBlockPreview from './auto';\nimport EditorStyles from '../editor-styles';\nimport { store as blockEditorStore } from '../../store';\nimport { BlockListItems } from '../block-list';\n\nconst EMPTY_ADDITIONAL_STYLES = [];\n\nexport function BlockPreview( {\n\tblocks,\n\tviewportWidth = 1200,\n\tminHeight,\n\tadditionalStyles = EMPTY_ADDITIONAL_STYLES,\n\t// Deprecated props:\n\t__experimentalMinHeight,\n\t__experimentalPadding,\n} ) {\n\tif ( __experimentalMinHeight ) {\n\t\tminHeight = __experimentalMinHeight;\n\t\tdeprecated( 'The __experimentalMinHeight prop', {\n\t\t\tsince: '6.2',\n\t\t\tversion: '6.4',\n\t\t\talternative: 'minHeight',\n\t\t} );\n\t}\n\tif ( __experimentalPadding ) {\n\t\tadditionalStyles = [\n\t\t\t...additionalStyles,\n\t\t\t{ css: `body { padding: ${ __experimentalPadding }px; }` },\n\t\t];\n\t\tdeprecated( 'The __experimentalPadding prop of BlockPreview', {\n\t\t\tsince: '6.2',\n\t\t\tversion: '6.4',\n\t\t\talternative: 'additionalStyles',\n\t\t} );\n\t}\n\n\tconst originalSettings = useSelect(\n\t\t( select ) => select( blockEditorStore ).getSettings(),\n\t\t[]\n\t);\n\tconst settings = useMemo(\n\t\t() => ( {\n\t\t\t...originalSettings,\n\t\t\tfocusMode: false, // Disable \"Spotlight mode\".\n\t\t\tisPreviewMode: true,\n\t\t} ),\n\t\t[ originalSettings ]\n\t);\n\tconst renderedBlocks = useMemo(\n\t\t() => ( Array.isArray( blocks ) ? blocks : [ blocks ] ),\n\t\t[ blocks ]\n\t);\n\n\tif ( ! blocks || blocks.length === 0 ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<ExperimentalBlockEditorProvider\n\t\t\tvalue={ renderedBlocks }\n\t\t\tsettings={ settings }\n\t\t>\n\t\t\t<AutoHeightBlockPreview\n\t\t\t\tviewportWidth={ viewportWidth }\n\t\t\t\tminHeight={ minHeight }\n\t\t\t\tadditionalStyles={ additionalStyles }\n\t\t\t/>\n\t\t</ExperimentalBlockEditorProvider>\n\t);\n}\n\n/**\n * BlockPreview renders a preview of a block or array of blocks.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-preview/README.md\n *\n * @param {Object} preview options for how the preview should be shown\n * @param {Array|Object} preview.blocks A block instance (object) or an array of blocks to be previewed.\n * @param {number} preview.viewportWidth Width of the preview container in pixels. Controls at what size the blocks will be rendered inside the preview. Default: 700.\n *\n * @return {Component} The component to be rendered.\n */\nexport default memo( BlockPreview );\n\n/**\n * This hook is used to lightly mark an element as a block preview wrapper\n * element. Call this hook and pass the returned props to the element to mark as\n * a block preview wrapper, automatically rendering inner blocks as children. If\n * you define a ref for the element, it is important to pass the ref to this\n * hook, which the hook in turn will pass to the component through the props it\n * returns. Optionally, you can also pass any other props through this hook, and\n * they will be merged and returned.\n *\n * @param {Object} options Preview options.\n * @param {WPBlock[]} options.blocks Block objects.\n * @param {Object} options.props Optional. Props to pass to the element. Must contain\n * the ref if one is defined.\n * @param {Object} options.layout Layout settings to be used in the preview.\n */\nexport function useBlockPreview( { blocks, props = {}, layout } ) {\n\tconst originalSettings = useSelect(\n\t\t( select ) => select( blockEditorStore ).getSettings(),\n\t\t[]\n\t);\n\tconst settings = useMemo(\n\t\t() => ( {\n\t\t\t...originalSettings,\n\t\t\tstyles: undefined, // Clear styles included by the parent settings, as they are already output by the parent's EditorStyles.\n\t\t\tfocusMode: false, // Disable \"Spotlight mode\".\n\t\t\tisPreviewMode: true,\n\t\t} ),\n\t\t[ originalSettings ]\n\t);\n\tconst disabledRef = useDisabled();\n\tconst ref = useMergeRefs( [ props.ref, disabledRef ] );\n\tconst renderedBlocks = useMemo(\n\t\t() => ( Array.isArray( blocks ) ? blocks : [ blocks ] ),\n\t\t[ blocks ]\n\t);\n\n\tconst children = (\n\t\t<ExperimentalBlockEditorProvider\n\t\t\tvalue={ renderedBlocks }\n\t\t\tsettings={ settings }\n\t\t>\n\t\t\t<EditorStyles />\n\t\t\t<BlockListItems renderAppender={ false } layout={ layout } />\n\t\t</ExperimentalBlockEditorProvider>\n\t);\n\n\treturn {\n\t\t...props,\n\t\tref,\n\t\tclassName: clsx(\n\t\t\tprops.className,\n\t\t\t'block-editor-block-preview__live-content',\n\t\t\t'components-disabled'\n\t\t),\n\t\tchildren: blocks?.length ? children : null,\n\t};\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SAASC,WAAW,EAAEC,YAAY,QAAQ,oBAAoB;AAC9D,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,IAAI,EAAEC,OAAO,QAAQ,oBAAoB;AAClD,OAAOC,UAAU,MAAM,uBAAuB;;AAE9C;AACA;AACA;AACA,SAASC,+BAA+B,QAAQ,aAAa;AAC7D,OAAOC,sBAAsB,MAAM,QAAQ;AAC3C,OAAOC,YAAY,MAAM,kBAAkB;AAC3C,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,aAAa;AACvD,SAASC,cAAc,QAAQ,eAAe;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAE/C,MAAMC,uBAAuB,GAAG,EAAE;AAElC,OAAO,SAASC,YAAYA,CAAE;EAC7BC,MAAM;EACNC,aAAa,GAAG,IAAI;EACpBC,SA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AAE,CAAC;EAAA,CAC7B,CACjC;EAED,OAAO;IACN,GAAGD,KAAK;IACRK,GAAG;IACHE,SAAS,EAAEjD,IAAI,CACd0C,KAAK,CAACO,SAAS,EACf,0CAA0C,EAC1C,qBACD,CAAC;IACDT,QAAQ,EAAErB,MAAM,EAAEmB,MAAM,GAAGE,QAAQ,GAAG;EACvC,CAAC;AACF","ignoreList":[]}
1
+ {"version":3,"names":["clsx","useDisabled","useMergeRefs","useSelect","memo","useMemo","deprecated","ExperimentalBlockEditorProvider","AutoHeightBlockPreview","EditorStyles","store","blockEditorStore","BlockListItems","Async","jsx","_jsx","jsxs","_jsxs","EMPTY_ADDITIONAL_STYLES","BlockPreview","blocks","viewportWidth","minHeight","additionalStyles","__experimentalMinHeight","__experimentalPadding","since","version","alternative","css","originalSettings","select","getSettings","settings","focusMode","isPreviewMode","renderedBlocks","Array","isArray","length","value","children","MemoizedBlockPreview","useBlockPreview","props","layout","styles","undefined","disabledRef","ref","renderAppender","className"],"sources":["@wordpress/block-editor/src/components/block-preview/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useDisabled, useMergeRefs } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport { memo, useMemo } from '@wordpress/element';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport { ExperimentalBlockEditorProvider } from '../provider';\nimport AutoHeightBlockPreview from './auto';\nimport EditorStyles from '../editor-styles';\nimport { store as blockEditorStore } from '../../store';\nimport { BlockListItems } from '../block-list';\nimport { Async } from './async';\n\nconst EMPTY_ADDITIONAL_STYLES = [];\n\nexport function BlockPreview( {\n\tblocks,\n\tviewportWidth = 1200,\n\tminHeight,\n\tadditionalStyles = EMPTY_ADDITIONAL_STYLES,\n\t// Deprecated props:\n\t__experimentalMinHeight,\n\t__experimentalPadding,\n} ) {\n\tif ( __experimentalMinHeight ) {\n\t\tminHeight = __experimentalMinHeight;\n\t\tdeprecated( 'The __experimentalMinHeight prop', {\n\t\t\tsince: '6.2',\n\t\t\tversion: '6.4',\n\t\t\talternative: 'minHeight',\n\t\t} );\n\t}\n\tif ( __experimentalPadding ) {\n\t\tadditionalStyles = [\n\t\t\t...additionalStyles,\n\t\t\t{ css: `body { padding: ${ __experimentalPadding }px; }` },\n\t\t];\n\t\tdeprecated( 'The __experimentalPadding prop of BlockPreview', {\n\t\t\tsince: '6.2',\n\t\t\tversion: '6.4',\n\t\t\talternative: 'additionalStyles',\n\t\t} );\n\t}\n\n\tconst originalSettings = useSelect(\n\t\t( select ) => select( blockEditorStore ).getSettings(),\n\t\t[]\n\t);\n\tconst settings = useMemo(\n\t\t() => ( {\n\t\t\t...originalSettings,\n\t\t\tfocusMode: false, // Disable \"Spotlight mode\".\n\t\t\tisPreviewMode: true,\n\t\t} ),\n\t\t[ originalSettings ]\n\t);\n\tconst renderedBlocks = useMemo(\n\t\t() => ( Array.isArray( blocks ) ? blocks : [ blocks ] ),\n\t\t[ blocks ]\n\t);\n\n\tif ( ! blocks || blocks.length === 0 ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<ExperimentalBlockEditorProvider\n\t\t\tvalue={ renderedBlocks }\n\t\t\tsettings={ settings }\n\t\t>\n\t\t\t<AutoHeightBlockPreview\n\t\t\t\tviewportWidth={ viewportWidth }\n\t\t\t\tminHeight={ minHeight }\n\t\t\t\tadditionalStyles={ additionalStyles }\n\t\t\t/>\n\t\t</ExperimentalBlockEditorProvider>\n\t);\n}\n\nconst MemoizedBlockPreview = memo( BlockPreview );\n\nMemoizedBlockPreview.Async = Async;\n\n/**\n * BlockPreview renders a preview of a block or array of blocks.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-preview/README.md\n *\n * @param {Object} preview options for how the preview should be shown\n * @param {Array|Object} preview.blocks A block instance (object) or an array of blocks to be previewed.\n * @param {number} preview.viewportWidth Width of the preview container in pixels. Controls at what size the blocks will be rendered inside the preview. Default: 700.\n *\n * @return {Component} The component to be rendered.\n */\nexport default MemoizedBlockPreview;\n\n/**\n * This hook is used to lightly mark an element as a block preview wrapper\n * element. Call this hook and pass the returned props to the element to mark as\n * a block preview wrapper, automatically rendering inner blocks as children. If\n * you define a ref for the element, it is important to pass the ref to this\n * hook, which the hook in turn will pass to the component through the props it\n * returns. Optionally, you can also pass any other props through this hook, and\n * they will be merged and returned.\n *\n * @param {Object} options Preview options.\n * @param {WPBlock[]} options.blocks Block objects.\n * @param {Object} options.props Optional. Props to pass to the element. Must contain\n * the ref if one is defined.\n * @param {Object} options.layout Layout settings to be used in the preview.\n */\nexport function useBlockPreview( { blocks, props = {}, layout } ) {\n\tconst originalSettings = useSelect(\n\t\t( select ) => select( blockEditorStore ).getSettings(),\n\t\t[]\n\t);\n\tconst settings = useMemo(\n\t\t() => ( {\n\t\t\t...originalSettings,\n\t\t\tstyles: undefined, // Clear styles included by the parent settings, as they are already output by the parent's EditorStyles.\n\t\t\tfocusMode: false, // Disable \"Spotlight mode\".\n\t\t\tisPreviewMode: true,\n\t\t} ),\n\t\t[ originalSettings ]\n\t);\n\tconst disabledRef = useDisabled();\n\tconst ref = useMergeRefs( [ props.ref, disabledRef ] );\n\tconst renderedBlocks = useMemo(\n\t\t() => ( Array.isArray( blocks ) ? blocks : [ blocks ] ),\n\t\t[ blocks ]\n\t);\n\n\tconst children = (\n\t\t<ExperimentalBlockEditorProvider\n\t\t\tvalue={ renderedBlocks }\n\t\t\tsettings={ settings }\n\t\t>\n\t\t\t<EditorStyles />\n\t\t\t<BlockListItems renderAppender={ false } layout={ layout } />\n\t\t</ExperimentalBlockEditorProvider>\n\t);\n\n\treturn {\n\t\t...props,\n\t\tref,\n\t\tclassName: clsx(\n\t\t\tprops.className,\n\t\t\t'block-editor-block-preview__live-content',\n\t\t\t'components-disabled'\n\t\t),\n\t\tchildren: blocks?.length ? children : null,\n\t};\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,M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yB,gBAAgB;IACnBgB,MAAM,EAAEC,SAAS;IAAE;IACnBb,SAAS,EAAE,KAAK;IAAE;IAClBC,aAAa,EAAE;EAChB,CAAC,CAAE,EACH,CAAEL,gBAAgB,CACnB,CAAC;EACD,MAAMkB,WAAW,GAAG/C,WAAW,CAAC,CAAC;EACjC,MAAMgD,GAAG,GAAG/C,YAAY,CAAE,CAAE0C,KAAK,CAACK,GAAG,EAAED,WAAW,CAAG,CAAC;EACtD,MAAMZ,cAAc,GAAG/B,OAAO,CAC7B,MAAQgC,KAAK,CAACC,OAAO,CAAElB,MAAO,CAAC,GAAGA,MAAM,GAAG,CAAEA,MAAM,CAAI,EACvD,CAAEA,MAAM,CACT,CAAC;EAED,MAAMqB,QAAQ,gBACbxB,KAAA,CAACV,+BAA+B;IAC/BiC,KAAK,EAAGJ,cAAgB;IACxBH,QAAQ,EAAGA,QAAU;IAAAQ,QAAA,gBAErB1B,IAAA,CAACN,YAAY,IAAE,CAAC,eAChBM,IAAA,CAACH,cAAc;MAACsC,cAAc,EAAG,KAAO;MAACL,MAAM,EAAGA;IAAQ,CAAE,CAAC;EAAA,CAC7B,CACjC;EAED,OAAO;IACN,GAAGD,KAAK;IACRK,GAAG;IACHE,SAAS,EAAEnD,IAAI,CACd4C,KAAK,CAACO,SAAS,EACf,0CAA0C,EAC1C,qBACD,CAAC;IACDV,QAAQ,EAAErB,MAAM,EAAEmB,MAAM,GAAGE,QAAQ,GAAG;EACvC,CAAC;AACF","ignoreList":[]}
@@ -5,7 +5,6 @@ import { ToolbarButton, ToolbarGroup, Dropdown, __experimentalDropdownContentWra
5
5
  import { __ } from '@wordpress/i18n';
6
6
  import { cloneBlock } from '@wordpress/blocks';
7
7
  import { useMemo } from '@wordpress/element';
8
- import { useAsyncList } from '@wordpress/compose';
9
8
  import { useSelect, useDispatch } from '@wordpress/data';
10
9
 
11
10
  /**
@@ -70,7 +69,6 @@ export default function ChangeDesign({
70
69
  );
71
70
  }).slice(0, MAX_PATTERNS_TO_SHOW);
72
71
  }, [categories, currentPatternName, patterns]);
73
- const currentShownPatterns = useAsyncList(sameCategoryPatternsWithSingleWrapper);
74
72
  if (sameCategoryPatternsWithSingleWrapper.length < 2) {
75
73
  return null;
76
74
  }
@@ -103,10 +101,9 @@ export default function ChangeDesign({
103
101
  className: "block-editor-block-toolbar-change-design-content-wrapper",
104
102
  paddingSize: "none",
105
103
  children: /*#__PURE__*/_jsx(BlockPatternsList, {
106
- shownPatterns: currentShownPatterns,
107
104
  blockPatterns: sameCategoryPatternsWithSingleWrapper,
108
105
  onClickPattern: onClickPattern,
109
- showTitle: false
106
+ showTitlesAsTooltip: true
110
107
  })
111
108
  })
112
109
  });
@@ -1 +1 @@
1
- {"version":3,"names":["ToolbarButton","ToolbarGroup","Dropdown","__experimentalDropdownContentWrapper","DropdownContentWrapper","__","cloneBlock","useMemo","useAsyncList","useSelect","useDispatch","store","blockEditorStore","BlockPatternsList","jsx","_jsx","EMPTY_ARRAY","MAX_PATTERNS_TO_SHOW","POPOVER_PROPS","placement","ChangeDesign","clientId","categories","currentPatternName","patterns","select","getBlockAttributes","getBlockRootClientId","__experimentalGetAllowedPatterns","attributes","_categories","metadata","rootBlock","_patterns","length","patternName","replaceBlocks","sameCategoryPatternsWithSingleWrapper","filter","pattern","isCorePattern","source","startsWith","blocks","name","some","category","includes","syncStatus","id","slice","currentShownPatterns","onClickPattern","_pattern$blocks","newBlocks","map","block","popoverProps","renderToggle","onToggle","isOpen","children","onClick","renderContent","className","paddingSize","shownPatterns","blockPatterns","showTitle"],"sources":["@wordpress/block-editor/src/components/block-toolbar/change-design.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tToolbarButton,\n\tToolbarGroup,\n\tDropdown,\n\t__experimentalDropdownContentWrapper as DropdownContentWrapper,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { cloneBlock } from '@wordpress/blocks';\nimport { useMemo } from '@wordpress/element';\nimport { useAsyncList } from '@wordpress/compose';\nimport { useSelect, useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport BlockPatternsList from '../block-patterns-list';\n\nconst EMPTY_ARRAY = [];\nconst MAX_PATTERNS_TO_SHOW = 6;\nconst POPOVER_PROPS = {\n\tplacement: 'bottom-start',\n};\n\nexport default function ChangeDesign( { clientId } ) {\n\tconst { categories, currentPatternName, patterns } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockAttributes,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\t__experimentalGetAllowedPatterns,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst attributes = getBlockAttributes( clientId );\n\t\t\tconst _categories = attributes?.metadata?.categories || EMPTY_ARRAY;\n\t\t\tconst rootBlock = getBlockRootClientId( clientId );\n\n\t\t\t// Calling `__experimentalGetAllowedPatterns` is expensive.\n\t\t\t// Checking if the block can be changed prevents unnecessary selector calls.\n\t\t\t// See: https://github.com/WordPress/gutenberg/pull/64736.\n\t\t\tconst _patterns =\n\t\t\t\t_categories.length > 0\n\t\t\t\t\t? __experimentalGetAllowedPatterns( rootBlock )\n\t\t\t\t\t: EMPTY_ARRAY;\n\t\t\treturn {\n\t\t\t\tcategories: _categories,\n\t\t\t\tcurrentPatternName: attributes?.metadata?.patternName,\n\t\t\t\tpatterns: _patterns,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst { replaceBlocks } = useDispatch( blockEditorStore );\n\tconst sameCategoryPatternsWithSingleWrapper = useMemo( () => {\n\t\tif ( categories.length === 0 || ! patterns || patterns.length === 0 ) {\n\t\t\treturn EMPTY_ARRAY;\n\t\t}\n\t\treturn patterns\n\t\t\t.filter( ( pattern ) => {\n\t\t\t\tconst isCorePattern =\n\t\t\t\t\tpattern.source === 'core' ||\n\t\t\t\t\t( pattern.source?.startsWith( 'pattern-directory' ) &&\n\t\t\t\t\t\tpattern.source !== 'pattern-directory/theme' );\n\t\t\t\treturn (\n\t\t\t\t\t// Check if the pattern has only one top level block,\n\t\t\t\t\t// otherwise we may switch to a pattern that doesn't have replacement suggestions.\n\t\t\t\t\tpattern.blocks.length === 1 &&\n\t\t\t\t\t// We exclude the core patterns and pattern directory patterns that are not theme patterns.\n\t\t\t\t\t! isCorePattern &&\n\t\t\t\t\t// Exclude current pattern.\n\t\t\t\t\tcurrentPatternName !== pattern.name &&\n\t\t\t\t\tpattern.categories?.some( ( category ) => {\n\t\t\t\t\t\treturn categories.includes( category );\n\t\t\t\t\t} ) &&\n\t\t\t\t\t// Check if the pattern is not a synced pattern.\n\t\t\t\t\t( pattern.syncStatus === 'unsynced' || ! pattern.id )\n\t\t\t\t);\n\t\t\t} )\n\t\t\t.slice( 0, MAX_PATTERNS_TO_SHOW );\n\t}, [ categories, currentPatternName, patterns ] );\n\n\tconst currentShownPatterns = useAsyncList(\n\t\tsameCategoryPatternsWithSingleWrapper\n\t);\n\n\tif ( sameCategoryPatternsWithSingleWrapper.length < 2 ) {\n\t\treturn null;\n\t}\n\n\tconst onClickPattern = ( pattern ) => {\n\t\tconst newBlocks = ( pattern.blocks ?? [] ).map( ( block ) => {\n\t\t\treturn cloneBlock( block );\n\t\t} );\n\t\tnewBlocks[ 0 ].attributes.metadata = {\n\t\t\t...newBlocks[ 0 ].attributes.metadata,\n\t\t\tcategories,\n\t\t};\n\t\treplaceBlocks( clientId, newBlocks );\n\t};\n\n\treturn (\n\t\t<Dropdown\n\t\t\tpopoverProps={ POPOVER_PROPS }\n\t\t\trenderToggle={ ( { onToggle, isOpen } ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\t\tonClick={ () => onToggle( ! isOpen ) }\n\t\t\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Change design' ) }\n\t\t\t\t\t\t</ToolbarButton>\n\t\t\t\t\t</ToolbarGroup>\n\t\t\t\t);\n\t\t\t} }\n\t\t\trenderContent={ () => (\n\t\t\t\t<DropdownContentWrapper\n\t\t\t\t\tclassName=\"block-editor-block-toolbar-change-design-content-wrapper\"\n\t\t\t\t\tpaddingSize=\"none\"\n\t\t\t\t>\n\t\t\t\t\t<BlockPatternsList\n\t\t\t\t\t\tshownPatterns={ currentShownPatterns }\n\t\t\t\t\t\tblockPatterns={ sameCategoryPatternsWithSingleWrapper }\n\t\t\t\t\t\tonClickPattern={ onClickPattern }\n\t\t\t\t\t\tshowTitle={ false }\n\t\t\t\t\t/>\n\t\t\t\t</DropdownContentWrapper>\n\t\t\t) }\n\t\t/>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,aAAa,EACbC,YAAY,EACZC,QAAQ,EACRC,oCAAoC,IAAIC,sBAAsB,QACxD,uBAAuB;AAC9B,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,UAAU,QAAQ,mBAAmB;AAC9C,SAASC,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,YAAY,QAAQ,oBAAoB;AACjD,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;;AAExD;AACA;AACA;AACA,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,aAAa;AACvD,OAAOC,iBAAiB,MAAM,wBAAwB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAEvD,MAAMC,WAAW,GAAG,EAAE;AACtB,MAAMC,oBAAoB,GAAG,CAAC;AAC9B,MAAMC,aAAa,GAAG;EACrBC,SAAS,EAAE;AACZ,CAAC;AAED,eAAe,SAASC,YAAYA,CAAE;EAAEC;AAAS,CAAC,EAAG;EACpD,MAAM;IAAEC,UAAU;IAAEC,kBAAkB;IAAEC;EAAS,CAAC,GAAGf,SAAS,CAC3DgB,MAAM,IAAM;IACb,MAAM;MACLC,kBAAkB;MAClBC,oBAAoB;MACpBC;IACD,CAAC,GAAGH,MAAM,CAAEb,gBAAiB,CAAC;IAC9B,MAAMiB,UAAU,GAAGH,k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MAAAJ,QAAA,eAElB9C,IAAA,CAACF,iBAAiB;QACjBqD,aAAa,EAAGf,oBAAsB;QACtCgB,aAAa,EAAG9B,qCAAuC;QACvDe,cAAc,EAAGA,cAAgB;QACjCgB,SAAS,EAAG;MAAO,CACnB;IAAC,CACqB;EACtB,CACH,CAAC;AAEJ","ignoreList":[]}
1
+ {"version":3,"names":["ToolbarButton","ToolbarGroup","Dropdown","__experimentalDropdownContentWrapper","DropdownContentWrapper","__","cloneBlock","useMemo","useSelect","useDispatch","store","blockEditorStore","BlockPatternsList","jsx","_jsx","EMPTY_ARRAY","MAX_PATTERNS_TO_SHOW","POPOVER_PROPS","placement","ChangeDesign","clientId","categories","currentPatternName","patterns","select","getBlockAttributes","getBlockRootClientId","__experimentalGetAllowedPatterns","attributes","_categories","metadata","rootBlock","_patterns","length","patternName","replaceBlocks","sameCategoryPatternsWithSingleWrapper","filter","pattern","isCorePattern","source","startsWith","blocks","name","some","category","includes","syncStatus","id","slice","onClickPattern","_pattern$blocks","newBlocks","map","block","popoverProps","renderToggle","onToggle","isOpen","children","onClick","renderContent","className","paddingSize","blockPatterns","showTitlesAsTooltip"],"sources":["@wordpress/block-editor/src/components/block-toolbar/change-design.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tToolbarButton,\n\tToolbarGroup,\n\tDropdown,\n\t__experimentalDropdownContentWrapper as DropdownContentWrapper,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { cloneBlock } from '@wordpress/blocks';\nimport { useMemo } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport BlockPatternsList from '../block-patterns-list';\n\nconst EMPTY_ARRAY = [];\nconst MAX_PATTERNS_TO_SHOW = 6;\nconst POPOVER_PROPS = {\n\tplacement: 'bottom-start',\n};\n\nexport default function ChangeDesign( { clientId } ) {\n\tconst { categories, currentPatternName, patterns } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockAttributes,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\t__experimentalGetAllowedPatterns,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst attributes = getBlockAttributes( clientId );\n\t\t\tconst _categories = attributes?.metadata?.categories || EMPTY_ARRAY;\n\t\t\tconst rootBlock = getBlockRootClientId( clientId );\n\n\t\t\t// Calling `__experimentalGetAllowedPatterns` is expensive.\n\t\t\t// Checking if the block can be changed prevents unnecessary selector calls.\n\t\t\t// See: https://github.com/WordPress/gutenberg/pull/64736.\n\t\t\tconst _patterns =\n\t\t\t\t_categories.length > 0\n\t\t\t\t\t? __experimentalGetAllowedPatterns( rootBlock )\n\t\t\t\t\t: EMPTY_ARRAY;\n\t\t\treturn {\n\t\t\t\tcategories: _categories,\n\t\t\t\tcurrentPatternName: attributes?.metadata?.patternName,\n\t\t\t\tpatterns: _patterns,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst { replaceBlocks } = useDispatch( blockEditorStore );\n\tconst sameCategoryPatternsWithSingleWrapper = useMemo( () => {\n\t\tif ( categories.length === 0 || ! patterns || patterns.length === 0 ) {\n\t\t\treturn EMPTY_ARRAY;\n\t\t}\n\t\treturn patterns\n\t\t\t.filter( ( pattern ) => {\n\t\t\t\tconst isCorePattern =\n\t\t\t\t\tpattern.source === 'core' ||\n\t\t\t\t\t( pattern.source?.startsWith( 'pattern-directory' ) &&\n\t\t\t\t\t\tpattern.source !== 'pattern-directory/theme' );\n\t\t\t\treturn (\n\t\t\t\t\t// Check if the pattern has only one top level block,\n\t\t\t\t\t// otherwise we may switch to a pattern that doesn't have replacement suggestions.\n\t\t\t\t\tpattern.blocks.length === 1 &&\n\t\t\t\t\t// We exclude the core patterns and pattern directory patterns that are not theme patterns.\n\t\t\t\t\t! isCorePattern &&\n\t\t\t\t\t// Exclude current pattern.\n\t\t\t\t\tcurrentPatternName !== pattern.name &&\n\t\t\t\t\tpattern.categories?.some( ( category ) => {\n\t\t\t\t\t\treturn categories.includes( category );\n\t\t\t\t\t} ) &&\n\t\t\t\t\t// Check if the pattern is not a synced pattern.\n\t\t\t\t\t( pattern.syncStatus === 'unsynced' || ! pattern.id )\n\t\t\t\t);\n\t\t\t} )\n\t\t\t.slice( 0, MAX_PATTERNS_TO_SHOW );\n\t}, [ categories, currentPatternName, patterns ] );\n\n\tif ( sameCategoryPatternsWithSingleWrapper.length < 2 ) {\n\t\treturn null;\n\t}\n\n\tconst onClickPattern = ( pattern ) => {\n\t\tconst newBlocks = ( pattern.blocks ?? [] ).map( ( block ) => {\n\t\t\treturn cloneBlock( block );\n\t\t} );\n\t\tnewBlocks[ 0 ].attributes.metadata = {\n\t\t\t...newBlocks[ 0 ].attributes.metadata,\n\t\t\tcategories,\n\t\t};\n\t\treplaceBlocks( clientId, newBlocks );\n\t};\n\n\treturn (\n\t\t<Dropdown\n\t\t\tpopoverProps={ POPOVER_PROPS }\n\t\t\trenderToggle={ ( { onToggle, isOpen } ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\t\tonClick={ () => onToggle( ! isOpen ) }\n\t\t\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Change design' ) }\n\t\t\t\t\t\t</ToolbarButton>\n\t\t\t\t\t</ToolbarGroup>\n\t\t\t\t);\n\t\t\t} }\n\t\t\trenderContent={ () => (\n\t\t\t\t<DropdownContentWrapper\n\t\t\t\t\tclassName=\"block-editor-block-toolbar-change-design-content-wrapper\"\n\t\t\t\t\tpaddingSize=\"none\"\n\t\t\t\t>\n\t\t\t\t\t<BlockPatternsList\n\t\t\t\t\t\tblockPatterns={ sameCategoryPatternsWithSingleWrapper }\n\t\t\t\t\t\tonClickPattern={ onClickPattern }\n\t\t\t\t\t\tshowTitlesAsTooltip\n\t\t\t\t\t/>\n\t\t\t\t</DropdownContentWrapper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G,CAAIC,KAAK,IAAM;MAC5D,OAAOhD,UAAU,CAAEgD,KAAM,CAAC;IAC3B,CAAE,CAAC;IACHF,SAAS,CAAE,CAAC,CAAE,CAACxB,UAAU,CAACE,QAAQ,GAAG;MACpC,GAAGsB,SAAS,CAAE,CAAC,CAAE,CAACxB,UAAU,CAACE,QAAQ;MACrCT;IACD,CAAC;IACDc,aAAa,CAAEf,QAAQ,EAAEgC,SAAU,CAAC;EACrC,CAAC;EAED,oBACCtC,IAAA,CAACZ,QAAQ;IACRqD,YAAY,EAAGtC,aAAe;IAC9BuC,YAAY,EAAGA,CAAE;MAAEC,QAAQ;MAAEC;IAAO,CAAC,KAAM;MAC1C,oBACC5C,IAAA,CAACb,YAAY;QAAA0D,QAAA,eACZ7C,IAAA,CAACd,aAAa;UACb4D,OAAO,EAAGA,CAAA,KAAMH,QAAQ,CAAE,CAAEC,MAAO,CAAG;UACtC,iBAAgBA,MAAQ;UAAAC,QAAA,EAEtBtD,EAAE,CAAE,eAAgB;QAAC,CACT;MAAC,CACH,CAAC;IAEjB,CAAG;IACHwD,aAAa,EAAGA,CAAA,kBACf/C,IAAA,CAACV,sBAAsB;MACtB0D,SAAS,EAAC,0DAA0D;MACpEC,WAAW,EAAC,MAAM;MAAAJ,QAAA,eAElB7C,IAAA,CAACF,iBAAiB;QACjBoD,aAAa,EAAG5B,qCAAuC;QACvDc,cAAc,EAAGA,cAAgB;QACjCe,mBAAmB;MAAA,CACnB;IAAC,CACqB;EACtB,CACH,CAAC;AAEJ","ignoreList":[]}
@@ -8,7 +8,7 @@ import { __unstableUseShortcutEventMatch as useShortcutEventMatch } from '@wordp
8
8
  import { useRef } from '@wordpress/element';
9
9
  import { switchToBlockType, store as blocksStore } from '@wordpress/blocks';
10
10
  import { speak } from '@wordpress/a11y';
11
- import { __ } from '@wordpress/i18n';
11
+ import { __, sprintf, _n } from '@wordpress/i18n';
12
12
 
13
13
  /**
14
14
  * Internal dependencies
@@ -91,19 +91,22 @@ export default function BlockTools({
91
91
  if (event.defaultPrevented) {
92
92
  return;
93
93
  }
94
- if (isMatch('core/block-editor/move-up', event)) {
94
+ if (isMatch('core/block-editor/move-up', event) || isMatch('core/block-editor/move-down', event)) {
95
95
  const clientIds = getSelectedBlockClientIds();
96
96
  if (clientIds.length) {
97
97
  event.preventDefault();
98
98
  const rootClientId = getBlockRootClientId(clientIds[0]);
99
- moveBlocksUp(clientIds, rootClientId);
100
- }
101
- } else if (isMatch('core/block-editor/move-down', event)) {
102
- const clientIds = getSelectedBlockClientIds();
103
- if (clientIds.length) {
104
- event.preventDefault();
105
- const rootClientId = getBlockRootClientId(clientIds[0]);
106
- moveBlocksDown(clientIds, rootClientId);
99
+ const direction = isMatch('core/block-editor/move-up', event) ? 'up' : 'down';
100
+ if (direction === 'up') {
101
+ moveBlocksUp(clientIds, rootClientId);
102
+ } else {
103
+ moveBlocksDown(clientIds, rootClientId);
104
+ }
105
+ const blockLength = Array.isArray(clientIds) ? clientIds.length : 1;
106
+ const message = sprintf(
107
+ // translators: %d: the name of the block that has been moved
108
+ _n('%d block moved.', '%d blocks moved.', clientIds.length), blockLength);
109
+ speak(message);
107
110
  }
108
111
  } else if (isMatch('core/block-editor/duplicate', event)) {
109
112
  const clientIds = getSelectedBlockClientIds();
@@ -1 +1 @@
1
- {"version":3,"names":["useSelect","useDispatch","isTextField","Popover","__unstableUseShortcutEventMatch","useShortcutEventMatch","useRef","switchToBlockType","store","blocksStore","speak","__","EmptyBlockInserter","InsertionPointOpenRef","default","InsertionPoint","BlockToolbarPopover","blockEditorStore","usePopoverScroll","ZoomOutModeInserters","useShowBlockTools","unlock","jsx","_jsx","jsxs","_jsxs","selector","select","getSelectedBlockClientId","getFirstMultiSelectedBlockClientId","getSettings","isTyping","isDragging","isZoomOut","clientId","hasFixedToolbar","isZoomOutMode","BlockTools","children","__unstableContentRef","props","isMatch","getBlocksByClientId","getSelectedBlockClientIds","getBlockRootClientId","isGroupable","getGroupingBlockName","showEmptyBlockSideInserter","showBlockToolbarPopover","duplicateBlocks","removeBlocks","replaceBlocks","insertAfterBlock","insertBeforeBlock","selectBlock","moveBlocksUp","moveBlocksDown","expandBlock","onKeyDown","event","defaultPrevented","clientIds","length","preventDefault","rootClientId","target","closest","contentWindow","document","activeElement","blocks","groupingBlockName","newBlocks","blockToolbarRef","blockToolbarAfterRef","Provider","value","Slot","name","ref"],"sources":["@wordpress/block-editor/src/components/block-tools/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { isTextField } from '@wordpress/dom';\nimport { Popover } from '@wordpress/components';\nimport { __unstableUseShortcutEventMatch as useShortcutEventMatch } from '@wordpress/keyboard-shortcuts';\nimport { useRef } from '@wordpress/element';\nimport { switchToBlockType, store as blocksStore } from '@wordpress/blocks';\nimport { speak } from '@wordpress/a11y';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport EmptyBlockInserter from './empty-block-inserter';\nimport {\n\tInsertionPointOpenRef,\n\tdefault as InsertionPoint,\n} from './insertion-point';\nimport BlockToolbarPopover from './block-toolbar-popover';\nimport { store as blockEditorStore } from '../../store';\nimport usePopoverScroll from '../block-popover/use-popover-scroll';\nimport ZoomOutModeInserters from './zoom-out-mode-inserters';\nimport { useShowBlockTools } from './use-show-block-tools';\nimport { unlock } from '../../lock-unlock';\n\nfunction selector( select ) {\n\tconst {\n\t\tgetSelectedBlockClientId,\n\t\tgetFirstMultiSelectedBlockClientId,\n\t\tgetSettings,\n\t\tisTyping,\n\t\tisDragging,\n\t\tisZoomOut,\n\t} = unlock( select( blockEditorStore ) );\n\n\tconst clientId =\n\t\tgetSelectedBlockClientId() || getFirstMultiSelectedBlockClientId();\n\n\treturn {\n\t\tclientId,\n\t\thasFixedToolbar: getSettings().hasFixedToolbar,\n\t\tisTyping: isTyping(),\n\t\tisZoomOutMode: isZoomOut(),\n\t\tisDragging: isDragging(),\n\t};\n}\n\n/**\n * Renders block tools (the block toolbar, select/navigation mode toolbar, the\n * insertion point and a slot for the inline rich text toolbar). Must be wrapped\n * around the block content and editor styles wrapper or iframe.\n *\n * @param {Object} $0 Props.\n * @param {Object} $0.children The block content and style container.\n * @param {Object} $0.__unstableContentRef Ref holding the content scroll container.\n */\nexport default function BlockTools( {\n\tchildren,\n\t__unstableContentRef,\n\t...props\n} ) {\n\tconst { clientId, hasFixedToolbar, isTyping, isZoomOutMode, isDragging } =\n\t\tuseSelect( selector, [] );\n\n\tconst isMatch = useShortcutEventMatch();\n\tconst {\n\t\tgetBlocksByClientId,\n\t\tgetSelectedBlockClientIds,\n\t\tgetBlockRootClientId,\n\t\tisGroupable,\n\t} = useSelect( blockEditorStore );\n\tconst { getGroupingBlockName } = useSelect( blocksStore );\n\tconst { showEmptyBlockSideInserter, showBlockToolbarPopover } =\n\t\tuseShowBlockTools();\n\n\tconst {\n\t\tduplicateBlocks,\n\t\tremoveBlocks,\n\t\treplaceBlocks,\n\t\tinsertAfterBlock,\n\t\tinsertBeforeBlock,\n\t\tselectBlock,\n\t\tmoveBlocksUp,\n\t\tmoveBlocksDown,\n\t\texpandBlock,\n\t} = unlock( useDispatch( blockEditorStore ) );\n\n\tfunction onKeyDown( event ) {\n\t\tif ( event.defaultPrevented ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( isMatch( 'core/block-editor/move-up', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst rootClientId = getBlockRootClientId( clientIds[ 0 ] );\n\t\t\t\tmoveBlocksUp( clientIds, rootClientId );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/move-down', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst rootClientId = getBlockRootClientId( clientIds[ 0 ] );\n\t\t\t\tmoveBlocksDown( clientIds, rootClientId );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/duplicate', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tduplicateBlocks( clientIds );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/remove', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tremoveBlocks( clientIds );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/insert-after', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tinsertAfterBlock( clientIds[ clientIds.length - 1 ] );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/insert-before', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tinsertBeforeBlock( clientIds[ 0 ] );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/unselect', event ) ) {\n\t\t\tif ( event.target.closest( '[role=toolbar]' ) ) {\n\t\t\t\t// This shouldn't be necessary, but we have a combination of a few things all combining to create a situation where:\n\t\t\t\t// - Because the block toolbar uses createPortal to populate the block toolbar fills, we can't rely on the React event bubbling to hit the onKeyDown listener for the block toolbar\n\t\t\t\t// - Since we can't use the React tree, we use the DOM tree which _should_ handle the event bubbling correctly from a `createPortal` element.\n\t\t\t\t// - This bubbles via the React tree, which hits this `unselect` escape keypress before the block toolbar DOM event listener has access to it.\n\t\t\t\t// An alternative would be to remove the addEventListener on the navigableToolbar and use this event to handle it directly right here. That feels hacky too though.\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length > 1 ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\t// If there is more than one block selected, select the first\n\t\t\t\t// block so that focus is directed back to the beginning of the selection.\n\t\t\t\t// In effect, to the user this feels like deselecting the multi-selection.\n\t\t\t\tselectBlock( clientIds[ 0 ] );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/collapse-list-view', event ) ) {\n\t\t\t// If focus is currently within a text field, such as a rich text block or other editable field,\n\t\t\t// skip collapsing the list view, and allow the keyboard shortcut to be handled by the text field.\n\t\t\t// This condition checks for both the active element and the active element within an iframed editor.\n\t\t\tif (\n\t\t\t\tisTextField( event.target ) ||\n\t\t\t\tisTextField(\n\t\t\t\t\tevent.target?.contentWindow?.document?.activeElement\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tevent.preventDefault();\n\t\t\texpandBlock( clientId );\n\t\t} else if ( isMatch( 'core/block-editor/group', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length > 1 && isGroupable( clientIds ) ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst blocks = getBlocksByClientId( clientIds );\n\t\t\t\tconst groupingBlockName = getGroupingBlockName();\n\t\t\t\tconst newBlocks = switchToBlockType(\n\t\t\t\t\tblocks,\n\t\t\t\t\tgroupingBlockName\n\t\t\t\t);\n\t\t\t\treplaceBlocks( clientIds, newBlocks );\n\t\t\t\tspeak( __( 'Selected blocks are grouped.' ) );\n\t\t\t}\n\t\t}\n\t}\n\tconst blockToolbarRef = usePopoverScroll( __unstableContentRef );\n\tconst blockToolbarAfterRef = usePopoverScroll( __unstableContentRef );\n\n\treturn (\n\t\t// eslint-disable-next-line jsx-a11y/no-static-element-interactions\n\t\t<div { ...props } onKeyDown={ onKeyDown }>\n\t\t\t<InsertionPointOpenRef.Provider value={ useRef( false ) }>\n\t\t\t\t{ ! isTyping && ! isZoomOutMode && (\n\t\t\t\t\t<InsertionPoint\n\t\t\t\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\n\t\t\t\t{ showEmptyBlockSideInserter && (\n\t\t\t\t\t<EmptyBlockInserter\n\t\t\t\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\n\t\t\t\t{ showBlockToolbarPopover && (\n\t\t\t\t\t<BlockToolbarPopover\n\t\t\t\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\tisTyping={ isTyping }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\n\t\t\t\t{ /* Used for the inline rich text toolbar. Until this toolbar is combined into BlockToolbar, someone implementing their own BlockToolbar will also need to use this to see the image caption toolbar. */ }\n\t\t\t\t{ ! isZoomOutMode && ! hasFixedToolbar && (\n\t\t\t\t\t<Popover.Slot\n\t\t\t\t\t\tname=\"block-toolbar\"\n\t\t\t\t\t\tref={ blockToolbarRef }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ children }\n\t\t\t\t{ /* Used for inline rich text popovers. */ }\n\t\t\t\t<Popover.Slot\n\t\t\t\t\tname=\"__unstable-block-tools-after\"\n\t\t\t\t\tref={ blockToolbarAfterRef }\n\t\t\t\t/>\n\t\t\t\t{ isZoomOutMode && ! isDragging && (\n\t\t\t\t\t<ZoomOutModeInserters\n\t\t\t\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</InsertionPointOpenRef.Provider>\n\t\t</div>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,WAAW,QAAQ,gBAAgB;AAC5C,SAASC,OAAO,QAAQ,uBAAuB;AAC/C,SAASC,+BAA+B,IAAIC,qBAAqB,QAAQ,+BAA+B;AACxG,SAASC,MAAM,QAAQ,oBAAoB;AAC3C,SAASC,iBAAiB,EAAEC,KAAK,IAAIC,WAA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A,eACxCb,KAAA,CAACZ,qBAAqB,CAAC8D,QAAQ;QAACC,KAAK,EAAGtE,MAAM,CAAE,KAAM,CAAG;QAAAgC,QAAA,GACtD,CAAEP,QAAQ,IAAI,CAAEK,aAAa,iBAC9Bb,IAAA,CAACR,cAAc;UACdwB,oBAAoB,EAAGA;QAAsB,CAC7C,CACD,EAECQ,0BAA0B,iBAC3BxB,IAAA,CAACX,kBAAkB;UAClB2B,oBAAoB,EAAGA,oBAAsB;UAC7CL,QAAQ,EAAGA;QAAU,CACrB,CACD,EAECc,uBAAuB,iBACxBzB,IAAA,CAACP,mBAAmB;UACnBuB,oBAAoB,EAAGA,oBAAsB;UAC7CL,QAAQ,EAAGA,QAAU;UACrBH,QAAQ,EAAGA;QAAU,CACrB,CACD,EAGC,CAAEK,aAAa,IAAI,CAAED,eAAe,iBACrCZ,IAAA,CAACpB,OAAO,CAAC0E,IAAI;UACZC,IAAI,EAAC,eAAe;UACpBC,GAAG,EAAGN;QAAiB,CACvB,CACD,EACCnC,QAAQ,eAEVf,IAAA,CAACpB,OAAO,CAAC0E,IAAI;UACZC,IAAI,EAAC,8BAA8B;UACnCC,GAAG,EAAGL;QAAsB,CAC5B,CAAC,EACAtC,aAAa,IAAI,CAAEJ,UAAU,iBAC9BT,IAAA,CAACJ,oBAAoB;UACpBoB,oBAAoB,EAAGA;QAAsB,CAC7C,CACD;MAAA,CAC8B;IAAC,CAC7B;EAAC;AAER","ignoreList":[]}
1
+ {"version":3,"names":["useSelect","useDispatch","isTextField","Popover","__unstableUseShortcutEventMatch","useShortcutEventMatch","useRef","switchToBlockType","store","blocksStore","speak","__","sprintf","_n","EmptyBlockInserter","InsertionPointOpenRef","default","InsertionPoint","BlockToolbarPopover","blockEditorStore","usePopoverScroll","ZoomOutModeInserters","useShowBlockTools","unlock","jsx","_jsx","jsxs","_jsxs","selector","select","getSelectedBlockClientId","getFirstMultiSelectedBlockClientId","getSettings","isTyping","isDragging","isZoomOut","clientId","hasFixedToolbar","isZoomOutMode","BlockTools","children","__unstableContentRef","props","isMatch","getBlocksByClientId","getSelectedBlockClientIds","getBlockRootClientId","isGroupable","getGroupingBlockName","showEmptyBlockSideInserter","showBlockToolbarPopover","duplicateBlocks","removeBlocks","replaceBlocks","insertAfterBlock","insertBeforeBlock","selectBlock","moveBlocksUp","moveBlocksDown","expandBlock","onKeyDown","event","defaultPrevented","clientIds","length","preventDefault","rootClientId","direction","blockLength","Array","isArray","message","target","closest","contentWindow","document","activeElement","blocks","groupingBlockName","newBlocks","blockToolbarRef","blockToolbarAfterRef","Provider","value","Slot","name","ref"],"sources":["@wordpress/block-editor/src/components/block-tools/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { isTextField } from '@wordpress/dom';\nimport { Popover } from '@wordpress/components';\nimport { __unstableUseShortcutEventMatch as useShortcutEventMatch } from '@wordpress/keyboard-shortcuts';\nimport { useRef } from '@wordpress/element';\nimport { switchToBlockType, store as blocksStore } from '@wordpress/blocks';\nimport { speak } from '@wordpress/a11y';\nimport { __, sprintf, _n } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport EmptyBlockInserter from './empty-block-inserter';\nimport {\n\tInsertionPointOpenRef,\n\tdefault as InsertionPoint,\n} from './insertion-point';\nimport BlockToolbarPopover from './block-toolbar-popover';\nimport { store as blockEditorStore } from '../../store';\nimport usePopoverScroll from '../block-popover/use-popover-scroll';\nimport ZoomOutModeInserters from './zoom-out-mode-inserters';\nimport { useShowBlockTools } from './use-show-block-tools';\nimport { unlock } from '../../lock-unlock';\n\nfunction selector( select ) {\n\tconst {\n\t\tgetSelectedBlockClientId,\n\t\tgetFirstMultiSelectedBlockClientId,\n\t\tgetSettings,\n\t\tisTyping,\n\t\tisDragging,\n\t\tisZoomOut,\n\t} = unlock( select( blockEditorStore ) );\n\n\tconst clientId =\n\t\tgetSelectedBlockClientId() || getFirstMultiSelectedBlockClientId();\n\n\treturn {\n\t\tclientId,\n\t\thasFixedToolbar: getSettings().hasFixedToolbar,\n\t\tisTyping: isTyping(),\n\t\tisZoomOutMode: isZoomOut(),\n\t\tisDragging: isDragging(),\n\t};\n}\n\n/**\n * Renders block tools (the block toolbar, select/navigation mode toolbar, the\n * insertion point and a slot for the inline rich text toolbar). Must be wrapped\n * around the block content and editor styles wrapper or iframe.\n *\n * @param {Object} $0 Props.\n * @param {Object} $0.children The block content and style container.\n * @param {Object} $0.__unstableContentRef Ref holding the content scroll container.\n */\nexport default function BlockTools( {\n\tchildren,\n\t__unstableContentRef,\n\t...props\n} ) {\n\tconst { clientId, hasFixedToolbar, isTyping, isZoomOutMode, isDragging } =\n\t\tuseSelect( selector, [] );\n\n\tconst isMatch = useShortcutEventMatch();\n\tconst {\n\t\tgetBlocksByClientId,\n\t\tgetSelectedBlockClientIds,\n\t\tgetBlockRootClientId,\n\t\tisGroupable,\n\t} = useSelect( blockEditorStore );\n\tconst { getGroupingBlockName } = useSelect( blocksStore );\n\tconst { showEmptyBlockSideInserter, showBlockToolbarPopover } =\n\t\tuseShowBlockTools();\n\n\tconst {\n\t\tduplicateBlocks,\n\t\tremoveBlocks,\n\t\treplaceBlocks,\n\t\tinsertAfterBlock,\n\t\tinsertBeforeBlock,\n\t\tselectBlock,\n\t\tmoveBlocksUp,\n\t\tmoveBlocksDown,\n\t\texpandBlock,\n\t} = unlock( useDispatch( blockEditorStore ) );\n\n\tfunction onKeyDown( event ) {\n\t\tif ( event.defaultPrevented ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (\n\t\t\tisMatch( 'core/block-editor/move-up', event ) ||\n\t\t\tisMatch( 'core/block-editor/move-down', event )\n\t\t) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst rootClientId = getBlockRootClientId( clientIds[ 0 ] );\n\t\t\t\tconst direction = isMatch( 'core/block-editor/move-up', event )\n\t\t\t\t\t? 'up'\n\t\t\t\t\t: 'down';\n\t\t\t\tif ( direction === 'up' ) {\n\t\t\t\t\tmoveBlocksUp( clientIds, rootClientId );\n\t\t\t\t} else {\n\t\t\t\t\tmoveBlocksDown( clientIds, rootClientId );\n\t\t\t\t}\n\t\t\t\tconst blockLength = Array.isArray( clientIds )\n\t\t\t\t\t? clientIds.length\n\t\t\t\t\t: 1;\n\t\t\t\tconst message = sprintf(\n\t\t\t\t\t// translators: %d: the name of the block that has been moved\n\t\t\t\t\t_n(\n\t\t\t\t\t\t'%d block moved.',\n\t\t\t\t\t\t'%d blocks moved.',\n\t\t\t\t\t\tclientIds.length\n\t\t\t\t\t),\n\t\t\t\t\tblockLength\n\t\t\t\t);\n\t\t\t\tspeak( message );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/duplicate', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tduplicateBlocks( clientIds );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/remove', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tremoveBlocks( clientIds );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/insert-after', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tinsertAfterBlock( clientIds[ clientIds.length - 1 ] );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/insert-before', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tinsertBeforeBlock( clientIds[ 0 ] );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/unselect', event ) ) {\n\t\t\tif ( event.target.closest( '[role=toolbar]' ) ) {\n\t\t\t\t// This shouldn't be necessary, but we have a combination of a few things all combining to create a situation where:\n\t\t\t\t// - Because the block toolbar uses createPortal to populate the block toolbar fills, we can't rely on the React event bubbling to hit the onKeyDown listener for the block toolbar\n\t\t\t\t// - Since we can't use the React tree, we use the DOM tree which _should_ handle the event bubbling correctly from a `createPortal` element.\n\t\t\t\t// - This bubbles via the React tree, which hits this `unselect` escape keypress before the block toolbar DOM event listener has access to it.\n\t\t\t\t// An alternative would be to remove the addEventListener on the navigableToolbar and use this event to handle it directly right here. That feels hacky too though.\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length > 1 ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\t// If there is more than one block selected, select the first\n\t\t\t\t// block so that focus is directed back to the beginning of the selection.\n\t\t\t\t// In effect, to the user this feels like deselecting the multi-selection.\n\t\t\t\tselectBlock( clientIds[ 0 ] );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/collapse-list-view', event ) ) {\n\t\t\t// If focus is currently within a text field, such as a rich text block or other editable field,\n\t\t\t// skip collapsing the list view, and allow the keyboard shortcut to be handled by the text field.\n\t\t\t// This condition checks for both the active element and the active element within an iframed editor.\n\t\t\tif (\n\t\t\t\tisTextField( event.target ) ||\n\t\t\t\tisTextField(\n\t\t\t\t\tevent.target?.contentWindow?.document?.activeElement\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tevent.preventDefault();\n\t\t\texpandBlock( clientId );\n\t\t} else if ( isMatch( 'core/block-editor/group', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length > 1 && isGroupable( clientIds ) ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst blocks = getBlocksByClientId( clientIds );\n\t\t\t\tconst groupingBlockName = getGroupingBlockName();\n\t\t\t\tconst newBlocks = switchToBlockType(\n\t\t\t\t\tblocks,\n\t\t\t\t\tgroupingBlockName\n\t\t\t\t);\n\t\t\t\treplaceBlocks( clientIds, newBlocks );\n\t\t\t\tspeak( __( 'Selected blocks are grouped.' ) );\n\t\t\t}\n\t\t}\n\t}\n\tconst blockToolbarRef = usePopoverScroll( __unstableContentRef );\n\tconst blockToolbarAfterRef = usePopoverScroll( __unstableContentRef );\n\n\treturn (\n\t\t// eslint-disable-next-line jsx-a11y/no-static-element-interactions\n\t\t<div { ...props } onKeyDown={ onKeyDown }>\n\t\t\t<InsertionPointOpenRef.Provider value={ useRef( false ) }>\n\t\t\t\t{ ! isTyping && ! isZoomOutMode && (\n\t\t\t\t\t<InsertionPoint\n\t\t\t\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\n\t\t\t\t{ showEmptyBlockSideInserter && (\n\t\t\t\t\t<EmptyBlockInserter\n\t\t\t\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\n\t\t\t\t{ showBlockToolbarPopover && (\n\t\t\t\t\t<BlockToolbarPopover\n\t\t\t\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\tisTyping={ isTyping }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\n\t\t\t\t{ /* Used for the inline rich text toolbar. Until this toolbar is combined into BlockToolbar, someone implementing their own BlockToolbar will also need to use this to see the image caption toolbar. */ }\n\t\t\t\t{ ! isZoomOutMode && ! hasFixedToolbar && (\n\t\t\t\t\t<Popover.Slot\n\t\t\t\t\t\tname=\"block-toolbar\"\n\t\t\t\t\t\tref={ blockToolbarRef }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ children }\n\t\t\t\t{ /* Used for inline rich text popovers. */ }\n\t\t\t\t<Popover.Slot\n\t\t\t\t\tname=\"__unstable-block-tools-after\"\n\t\t\t\t\tref={ blockToolbarAfterRef }\n\t\t\t\t/>\n\t\t\t\t{ isZoomOutMode && ! isDragging && (\n\t\t\t\t\t<ZoomOutModeInserters\n\t\t\t\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</InsertionPointOpenRef.Provider>\n\t\t</div>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,WAAW,QAAQ,gBAAgB;AAC5C,SAASC,OAAO,QAAQ,uBAAuB;AAC/C,SAASC,+BAA+B,IAAIC,qBAAqB,QAAQ,+BAA+B;AACxG,SAASC,MAAM,QAAQ,oBAAoB;AAC3C,SAASC,iBAAiB,EAAEC,KAAK,IAAIC,WAAW,QAAQ,mBAAmB;AAC3E,SAASC,KAAK,QAAQ,iBAAiB;AACvC,SAASC,EAAE,EAAEC,OAAO,EAAEC,EAAE,QAAQ,iBAAiB;;AAEjD;AACA;AACA;AACA,OAAOC,kBAAkB,MAAM,wBAAwB;AACvD,SACCC,qBAAqB,EACrBC,OAAO,IAAIC,cAAc,QACnB,mBAAmB;AAC1B,OAAOC,mBAAmB,MAAM,yBAAyB;AACzD,SAASV,KAAK,IAAIW,gBAAgB,QAAQ,aAAa;AACvD,OAAOC,gBAAgB,MAAM,qCAAqC;AAClE,OAAOC,oBAAoB,MAAM,2BAA2B;AAC5D,SAASC,iBAAiB,QAAQ,wBAAwB;AAC1D,SAASC,MAAM,QAAQ,mBAAmB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAE3C,SAASC,QAAQA,CAAEC,MAAM,EAAG;EAC3B,MAAM;IACLC,wBAAwB;IACxBC,kCAAkC;IAClCC,WAAW;IACXC,QAAQ;IACRC,UAAU;IACVC;EACD,CAAC,GAAGZ,MAAM,CAAEM,MAAM,CAAEV,gBAAiB,CAAE,CAAC;EAExC,MAAMiB,QAAQ,GACbN,wBAAwB,CAAC,CAAC,IAAIC,kCAAkC,CA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C,IAAI,EAAC,eAAe;UACpBC,GAAG,EAAGN;QAAiB,CACvB,CACD,EACCxC,QAAQ,eAEVf,IAAA,CAACtB,OAAO,CAACiF,IAAI;UACZC,IAAI,EAAC,8BAA8B;UACnCC,GAAG,EAAGL;QAAsB,CAC5B,CAAC,EACA3C,aAAa,IAAI,CAAEJ,UAAU,iBAC9BT,IAAA,CAACJ,oBAAoB;UACpBoB,oBAAoB,EAAGA;QAAsB,CAC7C,CACD;MAAA,CAC8B;IAAC,CAC7B;EAAC;AAER","ignoreList":[]}
@@ -12,7 +12,7 @@ import { useCallback, useLayoutEffect, useMemo, useState } from '@wordpress/elem
12
12
  import { store as blockEditorStore } from '../../store';
13
13
  import { useBlockElement } from '../block-list/use-block-props/use-block-refs';
14
14
  import { hasStickyOrFixedPositionValue } from '../../hooks/position';
15
- import { getVisibleElementBounds } from '../../utils/dom';
15
+ import { getElementBounds } from '../../utils/dom';
16
16
  const COMMON_PROPS = {
17
17
  placement: 'top-start'
18
18
  };
@@ -55,7 +55,7 @@ function getProps(contentElement, selectedBlockElement, scrollContainer, toolbar
55
55
 
56
56
  // Get how far the content area has been scrolled.
57
57
  const scrollTop = scrollContainer?.scrollTop || 0;
58
- const blockRect = getVisibleElementBounds(selectedBlockElement);
58
+ const blockRect = getElementBounds(selectedBlockElement);
59
59
  const contentRect = contentElement.getBoundingClientRect();
60
60
 
61
61
  // Get the vertical position of top of the visible content area.