@wordpress/block-library 7.3.0 → 7.4.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 (310) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/archives/edit.js +1 -1
  3. package/build/archives/edit.js.map +1 -1
  4. package/build/audio/edit.js +2 -2
  5. package/build/audio/edit.js.map +1 -1
  6. package/build/audio/edit.native.js +1 -1
  7. package/build/audio/edit.native.js.map +1 -1
  8. package/build/categories/edit.js +8 -3
  9. package/build/categories/edit.js.map +1 -1
  10. package/build/categories/index.js +4 -0
  11. package/build/categories/index.js.map +1 -1
  12. package/build/column/index.js +10 -0
  13. package/build/column/index.js.map +1 -1
  14. package/build/comment-template/edit.js +3 -1
  15. package/build/comment-template/edit.js.map +1 -1
  16. package/build/comment-template/hooks.js +14 -4
  17. package/build/comment-template/hooks.js.map +1 -1
  18. package/build/comments-pagination/edit.js +18 -1
  19. package/build/comments-pagination/edit.js.map +1 -1
  20. package/build/comments-query-loop/edit.js +1 -1
  21. package/build/comments-query-loop/edit.js.map +1 -1
  22. package/build/comments-title/edit.js +149 -0
  23. package/build/comments-title/edit.js.map +1 -0
  24. package/build/comments-title/index.js +101 -0
  25. package/build/comments-title/index.js.map +1 -0
  26. package/build/cover/transforms.js +33 -32
  27. package/build/cover/transforms.js.map +1 -1
  28. package/build/embed/edit.js +12 -18
  29. package/build/embed/edit.js.map +1 -1
  30. package/build/embed/edit.native.js +1 -7
  31. package/build/embed/edit.native.js.map +1 -1
  32. package/build/embed/util.js +29 -4
  33. package/build/embed/util.js.map +1 -1
  34. package/build/file/inspector.js +2 -4
  35. package/build/file/inspector.js.map +1 -1
  36. package/build/gallery/edit.js +1 -1
  37. package/build/gallery/edit.js.map +1 -1
  38. package/build/gallery/v1/edit.js +1 -1
  39. package/build/gallery/v1/edit.js.map +1 -1
  40. package/build/html/edit.js +2 -2
  41. package/build/html/edit.js.map +1 -1
  42. package/build/image/edit.js +4 -6
  43. package/build/image/edit.js.map +1 -1
  44. package/build/image/edit.native.js +1 -1
  45. package/build/image/edit.native.js.map +1 -1
  46. package/build/image/image.js +1 -1
  47. package/build/image/image.js.map +1 -1
  48. package/build/index.js +5 -3
  49. package/build/index.js.map +1 -1
  50. package/build/index.native.js +14 -3
  51. package/build/index.native.js.map +1 -1
  52. package/build/latest-comments/edit.js +1 -1
  53. package/build/latest-comments/edit.js.map +1 -1
  54. package/build/list/index.js +13 -2
  55. package/build/list/index.js.map +1 -1
  56. package/build/loginout/edit.js +1 -1
  57. package/build/loginout/edit.js.map +1 -1
  58. package/build/media-text/edit.js +1 -2
  59. package/build/media-text/edit.js.map +1 -1
  60. package/build/media-text/edit.native.js +1 -1
  61. package/build/media-text/edit.native.js.map +1 -1
  62. package/build/navigation/edit/index.js +17 -1
  63. package/build/navigation/edit/index.js.map +1 -1
  64. package/build/navigation/edit/navigation-menu-selector.js +7 -2
  65. package/build/navigation/edit/navigation-menu-selector.js.map +1 -1
  66. package/build/navigation/edit/unsaved-inner-blocks.js +5 -4
  67. package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  68. package/build/navigation/index.js +1 -1
  69. package/build/navigation/view-modal.js +37 -0
  70. package/build/navigation/view-modal.js.map +1 -0
  71. package/build/navigation/view.js +1 -34
  72. package/build/navigation/view.js.map +1 -1
  73. package/build/paragraph/edit.native.js +6 -2
  74. package/build/paragraph/edit.native.js.map +1 -1
  75. package/build/post-author/edit.js +1 -1
  76. package/build/post-author/edit.js.map +1 -1
  77. package/build/post-comments/index.js +4 -3
  78. package/build/post-comments/index.js.map +1 -1
  79. package/build/post-excerpt/edit.js +1 -1
  80. package/build/post-excerpt/edit.js.map +1 -1
  81. package/build/post-featured-image/edit.js +19 -7
  82. package/build/post-featured-image/edit.js.map +1 -1
  83. package/build/query/edit/index.js +84 -22
  84. package/build/query/edit/index.js.map +1 -1
  85. package/build/query/edit/query-placeholder.js +7 -14
  86. package/build/query/edit/query-placeholder.js.map +1 -1
  87. package/build/query/edit/query-toolbar.js +6 -1
  88. package/build/query/edit/query-toolbar.js.map +1 -1
  89. package/build/quote/index.js +19 -2
  90. package/build/quote/index.js.map +1 -1
  91. package/build/quote/v2/edit.js +11 -3
  92. package/build/quote/v2/edit.js.map +1 -1
  93. package/build/rss/edit.js +1 -1
  94. package/build/rss/edit.js.map +1 -1
  95. package/build/search/edit.js +11 -9
  96. package/build/search/edit.js.map +1 -1
  97. package/build/spacer/constants.js +9 -0
  98. package/build/spacer/constants.js.map +1 -0
  99. package/build/spacer/controls.js +3 -3
  100. package/build/spacer/controls.js.map +1 -1
  101. package/build/spacer/controls.native.js +2 -2
  102. package/build/spacer/controls.native.js.map +1 -1
  103. package/build/spacer/edit.js +5 -6
  104. package/build/spacer/edit.js.map +1 -1
  105. package/build/table/edit.js +8 -2
  106. package/build/table/edit.js.map +1 -1
  107. package/build/tag-cloud/edit.js +1 -1
  108. package/build/tag-cloud/edit.js.map +1 -1
  109. package/build/video/edit.js +1 -1
  110. package/build/video/edit.js.map +1 -1
  111. package/build/video/edit.native.js +1 -1
  112. package/build/video/edit.native.js.map +1 -1
  113. package/build-module/archives/edit.js +1 -1
  114. package/build-module/archives/edit.js.map +1 -1
  115. package/build-module/audio/edit.js +2 -2
  116. package/build-module/audio/edit.js.map +1 -1
  117. package/build-module/audio/edit.native.js +1 -1
  118. package/build-module/audio/edit.native.js.map +1 -1
  119. package/build-module/categories/edit.js +8 -3
  120. package/build-module/categories/edit.js.map +1 -1
  121. package/build-module/categories/index.js +4 -0
  122. package/build-module/categories/index.js.map +1 -1
  123. package/build-module/column/index.js +10 -0
  124. package/build-module/column/index.js.map +1 -1
  125. package/build-module/comment-template/edit.js +3 -1
  126. package/build-module/comment-template/edit.js.map +1 -1
  127. package/build-module/comment-template/hooks.js +14 -4
  128. package/build-module/comment-template/hooks.js.map +1 -1
  129. package/build-module/comments-pagination/edit.js +19 -2
  130. package/build-module/comments-pagination/edit.js.map +1 -1
  131. package/build-module/comments-query-loop/edit.js +1 -1
  132. package/build-module/comments-query-loop/edit.js.map +1 -1
  133. package/build-module/comments-title/edit.js +133 -0
  134. package/build-module/comments-title/edit.js.map +1 -0
  135. package/build-module/comments-title/index.js +88 -0
  136. package/build-module/comments-title/index.js.map +1 -0
  137. package/build-module/cover/transforms.js +33 -32
  138. package/build-module/cover/transforms.js.map +1 -1
  139. package/build-module/embed/edit.js +13 -19
  140. package/build-module/embed/edit.js.map +1 -1
  141. package/build-module/embed/edit.native.js +2 -8
  142. package/build-module/embed/edit.native.js.map +1 -1
  143. package/build-module/embed/util.js +25 -3
  144. package/build-module/embed/util.js.map +1 -1
  145. package/build-module/file/inspector.js +2 -4
  146. package/build-module/file/inspector.js.map +1 -1
  147. package/build-module/gallery/edit.js +1 -1
  148. package/build-module/gallery/edit.js.map +1 -1
  149. package/build-module/gallery/v1/edit.js +1 -1
  150. package/build-module/gallery/v1/edit.js.map +1 -1
  151. package/build-module/html/edit.js +2 -2
  152. package/build-module/html/edit.js.map +1 -1
  153. package/build-module/image/edit.js +4 -6
  154. package/build-module/image/edit.js.map +1 -1
  155. package/build-module/image/edit.native.js +1 -1
  156. package/build-module/image/edit.native.js.map +1 -1
  157. package/build-module/image/image.js +1 -1
  158. package/build-module/image/image.js.map +1 -1
  159. package/build-module/index.js +4 -3
  160. package/build-module/index.js.map +1 -1
  161. package/build-module/index.native.js +14 -3
  162. package/build-module/index.native.js.map +1 -1
  163. package/build-module/latest-comments/edit.js +1 -1
  164. package/build-module/latest-comments/edit.js.map +1 -1
  165. package/build-module/list/index.js +9 -3
  166. package/build-module/list/index.js.map +1 -1
  167. package/build-module/loginout/edit.js +1 -1
  168. package/build-module/loginout/edit.js.map +1 -1
  169. package/build-module/media-text/edit.js +1 -2
  170. package/build-module/media-text/edit.js.map +1 -1
  171. package/build-module/media-text/edit.native.js +1 -1
  172. package/build-module/media-text/edit.native.js.map +1 -1
  173. package/build-module/navigation/edit/index.js +17 -1
  174. package/build-module/navigation/edit/index.js.map +1 -1
  175. package/build-module/navigation/edit/navigation-menu-selector.js +6 -2
  176. package/build-module/navigation/edit/navigation-menu-selector.js.map +1 -1
  177. package/build-module/navigation/edit/unsaved-inner-blocks.js +5 -4
  178. package/build-module/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  179. package/build-module/navigation/index.js +1 -1
  180. package/build-module/navigation/view-modal.js +32 -0
  181. package/build-module/navigation/view-modal.js.map +1 -0
  182. package/build-module/navigation/view.js +1 -30
  183. package/build-module/navigation/view.js.map +1 -1
  184. package/build-module/paragraph/edit.native.js +6 -2
  185. package/build-module/paragraph/edit.native.js.map +1 -1
  186. package/build-module/post-author/edit.js +1 -1
  187. package/build-module/post-author/edit.js.map +1 -1
  188. package/build-module/post-comments/index.js +4 -3
  189. package/build-module/post-comments/index.js.map +1 -1
  190. package/build-module/post-excerpt/edit.js +1 -1
  191. package/build-module/post-excerpt/edit.js.map +1 -1
  192. package/build-module/post-featured-image/edit.js +19 -7
  193. package/build-module/post-featured-image/edit.js.map +1 -1
  194. package/build-module/query/edit/index.js +87 -26
  195. package/build-module/query/edit/index.js.map +1 -1
  196. package/build-module/query/edit/query-placeholder.js +8 -15
  197. package/build-module/query/edit/query-placeholder.js.map +1 -1
  198. package/build-module/query/edit/query-toolbar.js +6 -1
  199. package/build-module/query/edit/query-toolbar.js.map +1 -1
  200. package/build-module/quote/index.js +10 -4
  201. package/build-module/quote/index.js.map +1 -1
  202. package/build-module/quote/v2/edit.js +10 -3
  203. package/build-module/quote/v2/edit.js.map +1 -1
  204. package/build-module/rss/edit.js +1 -1
  205. package/build-module/rss/edit.js.map +1 -1
  206. package/build-module/search/edit.js +11 -9
  207. package/build-module/search/edit.js.map +1 -1
  208. package/build-module/spacer/constants.js +2 -0
  209. package/build-module/spacer/constants.js.map +1 -0
  210. package/build-module/spacer/controls.js +2 -2
  211. package/build-module/spacer/controls.js.map +1 -1
  212. package/build-module/spacer/controls.native.js +1 -1
  213. package/build-module/spacer/controls.native.js.map +1 -1
  214. package/build-module/spacer/edit.js +1 -1
  215. package/build-module/spacer/edit.js.map +1 -1
  216. package/build-module/table/edit.js +9 -3
  217. package/build-module/table/edit.js.map +1 -1
  218. package/build-module/tag-cloud/edit.js +1 -1
  219. package/build-module/tag-cloud/edit.js.map +1 -1
  220. package/build-module/video/edit.js +1 -1
  221. package/build-module/video/edit.js.map +1 -1
  222. package/build-module/video/edit.native.js +1 -1
  223. package/build-module/video/edit.native.js.map +1 -1
  224. package/build-style/comments-title/editor-rtl.css +79 -0
  225. package/build-style/comments-title/editor.css +79 -0
  226. package/build-style/common-rtl.css +32 -0
  227. package/build-style/common.css +32 -0
  228. package/build-style/editor-rtl.css +51 -0
  229. package/build-style/editor.css +51 -0
  230. package/build-style/post-comments-form/style-rtl.css +9 -0
  231. package/build-style/post-comments-form/style.css +9 -0
  232. package/build-style/query/editor-rtl.css +39 -0
  233. package/build-style/query/editor.css +39 -0
  234. package/build-style/style-rtl.css +79 -0
  235. package/build-style/style.css +79 -0
  236. package/build-style/table/editor-rtl.css +8 -0
  237. package/build-style/table/editor.css +8 -0
  238. package/build-style/table/style-rtl.css +38 -0
  239. package/build-style/table/style.css +38 -0
  240. package/package.json +28 -28
  241. package/src/archives/edit.js +1 -1
  242. package/src/audio/edit.js +2 -2
  243. package/src/audio/edit.native.js +1 -1
  244. package/src/categories/block.json +4 -0
  245. package/src/categories/edit.js +8 -2
  246. package/src/categories/index.php +1 -0
  247. package/src/column/block.json +10 -0
  248. package/src/comment-template/edit.js +5 -2
  249. package/src/comment-template/hooks.js +15 -2
  250. package/src/comment-template/index.php +23 -2
  251. package/src/comments-pagination/edit.js +23 -0
  252. package/src/comments-query-loop/edit.js +1 -0
  253. package/src/comments-title/block.json +70 -0
  254. package/src/comments-title/edit.js +197 -0
  255. package/src/comments-title/editor.scss +4 -0
  256. package/src/comments-title/index.js +18 -0
  257. package/src/comments-title/index.php +68 -0
  258. package/src/common.scss +24 -1
  259. package/src/cover/transforms.js +51 -28
  260. package/src/editor.scss +1 -0
  261. package/src/embed/edit.js +19 -24
  262. package/src/embed/edit.native.js +9 -14
  263. package/src/embed/util.js +34 -2
  264. package/src/file/inspector.js +1 -3
  265. package/src/gallery/edit.js +1 -1
  266. package/src/gallery/v1/edit.js +1 -1
  267. package/src/html/edit.js +2 -2
  268. package/src/image/edit.js +2 -4
  269. package/src/image/edit.native.js +1 -1
  270. package/src/image/image.js +1 -1
  271. package/src/index.js +7 -1
  272. package/src/index.native.js +12 -2
  273. package/src/latest-comments/edit.js +1 -1
  274. package/src/list/index.js +7 -3
  275. package/src/loginout/edit.js +1 -1
  276. package/src/media-text/edit.js +1 -2
  277. package/src/media-text/edit.native.js +1 -1
  278. package/src/navigation/block.json +1 -1
  279. package/src/navigation/edit/index.js +24 -0
  280. package/src/navigation/edit/navigation-menu-selector.js +15 -9
  281. package/src/navigation/edit/unsaved-inner-blocks.js +5 -4
  282. package/src/navigation/index.php +5 -0
  283. package/src/navigation/view-modal.js +36 -0
  284. package/src/navigation/view.js +0 -35
  285. package/src/paragraph/edit.native.js +13 -1
  286. package/src/post-author/edit.js +1 -1
  287. package/src/post-comments/block.json +4 -3
  288. package/src/post-comments-form/index.php +12 -4
  289. package/src/post-comments-form/style.scss +11 -0
  290. package/src/post-excerpt/edit.js +1 -1
  291. package/src/post-featured-image/edit.js +24 -12
  292. package/src/query/edit/index.js +125 -26
  293. package/src/query/edit/query-placeholder.js +3 -13
  294. package/src/query/edit/query-toolbar.js +6 -0
  295. package/src/query/editor.scss +38 -0
  296. package/src/quote/index.js +8 -4
  297. package/src/quote/v2/edit.js +3 -0
  298. package/src/rss/edit.js +1 -1
  299. package/src/search/edit.js +13 -7
  300. package/src/search/index.php +84 -33
  301. package/src/spacer/constants.js +1 -0
  302. package/src/spacer/controls.js +2 -2
  303. package/src/spacer/controls.native.js +1 -1
  304. package/src/spacer/edit.js +1 -2
  305. package/src/table/edit.js +11 -2
  306. package/src/table/editor.scss +13 -0
  307. package/src/table/style.scss +52 -0
  308. package/src/tag-cloud/edit.js +1 -1
  309. package/src/video/edit.js +1 -1
  310. package/src/video/edit.native.js +1 -1
@@ -2,9 +2,9 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { useSelect, useDispatch } from '@wordpress/data';
5
- import { cloneBlock } from '@wordpress/blocks';
5
+ import { store as blocksStore, cloneBlock } from '@wordpress/blocks';
6
6
  import { useInstanceId } from '@wordpress/compose';
7
- import { useEffect } from '@wordpress/element';
7
+ import { useState, useEffect } from '@wordpress/element';
8
8
  import {
9
9
  BlockControls,
10
10
  InspectorControls,
@@ -12,9 +12,15 @@ import {
12
12
  useSetting,
13
13
  store as blockEditorStore,
14
14
  useInnerBlocksProps,
15
+ __experimentalGetMatchingVariation as getMatchingVariation,
15
16
  __experimentalBlockPatternSetup as BlockPatternSetup,
16
17
  } from '@wordpress/block-editor';
17
- import { SelectControl } from '@wordpress/components';
18
+ import {
19
+ Button,
20
+ SelectControl,
21
+ Placeholder,
22
+ Modal,
23
+ } from '@wordpress/components';
18
24
  import { __ } from '@wordpress/i18n';
19
25
 
20
26
  /**
@@ -27,7 +33,11 @@ import { DEFAULTS_POSTS_PER_PAGE } from '../constants';
27
33
  import { getFirstQueryClientIdFromBlocks } from '../utils';
28
34
 
29
35
  const TEMPLATE = [ [ 'core/post-template' ] ];
30
- export function QueryContent( { attributes, setAttributes } ) {
36
+ export function QueryContent( {
37
+ attributes,
38
+ setAttributes,
39
+ openPatternSelectionModal,
40
+ } ) {
31
41
  const {
32
42
  queryId,
33
43
  query,
@@ -102,6 +112,7 @@ export function QueryContent( { attributes, setAttributes } ) {
102
112
  attributes={ attributes }
103
113
  setQuery={ updateQuery }
104
114
  setDisplayLayout={ updateDisplayLayout }
115
+ openPatternSelectionModal={ openPatternSelectionModal }
105
116
  />
106
117
  </BlockControls>
107
118
  <InspectorControls __experimentalGroup="advanced">
@@ -124,43 +135,131 @@ export function QueryContent( { attributes, setAttributes } ) {
124
135
  );
125
136
  }
126
137
 
127
- function QueryPatternSetup( props ) {
128
- const { clientId, name: blockName } = props;
138
+ function QueryPatternSetup( {
139
+ attributes,
140
+ clientId,
141
+ name,
142
+ openPatternSelectionModal,
143
+ setAttributes,
144
+ } ) {
145
+ const [ isStartingBlank, setIsStartingBlank ] = useState( false );
129
146
  const blockProps = useBlockProps();
130
- const { replaceBlock, selectBlock } = useDispatch( blockEditorStore );
131
- const onBlockPatternSelect = ( blocks ) => {
132
- const clonedBlocks = blocks.map( ( block ) => cloneBlock( block ) );
133
- const firstQueryClientId = getFirstQueryClientIdFromBlocks(
134
- clonedBlocks
147
+
148
+ const { blockType, allVariations, hasPatterns } = useSelect(
149
+ ( select ) => {
150
+ const { getBlockVariations, getBlockType } = select( blocksStore );
151
+ const {
152
+ getBlockRootClientId,
153
+ __experimentalGetPatternsByBlockTypes,
154
+ } = select( blockEditorStore );
155
+ const rootClientId = getBlockRootClientId( clientId );
156
+
157
+ return {
158
+ blockType: getBlockType( name ),
159
+ allVariations: getBlockVariations( name ),
160
+ hasPatterns: !! __experimentalGetPatternsByBlockTypes(
161
+ name,
162
+ rootClientId
163
+ ).length,
164
+ };
165
+ },
166
+ [ name, clientId ]
167
+ );
168
+
169
+ const matchingVariation = getMatchingVariation( attributes, allVariations );
170
+ const icon = matchingVariation?.icon || blockType?.icon?.src;
171
+ const label = matchingVariation?.title || blockType?.title;
172
+ if ( isStartingBlank ) {
173
+ return (
174
+ <QueryPlaceholder
175
+ clientId={ clientId }
176
+ name={ name }
177
+ setAttributes={ setAttributes }
178
+ icon={ icon }
179
+ label={ label }
180
+ />
135
181
  );
136
- replaceBlock( clientId, clonedBlocks );
137
- if ( firstQueryClientId ) {
138
- selectBlock( firstQueryClientId );
139
- }
140
- };
141
- // `startBlankComponent` is what to render when clicking `Start blank`
142
- // or if no matched patterns are found.
182
+ }
143
183
  return (
144
184
  <div { ...blockProps }>
145
- <BlockPatternSetup
146
- blockName={ blockName }
147
- clientId={ clientId }
148
- startBlankComponent={ <QueryPlaceholder { ...props } /> }
149
- onBlockPatternSelect={ onBlockPatternSelect }
150
- />
185
+ <Placeholder
186
+ icon={ icon }
187
+ label={ label }
188
+ instructions={ __(
189
+ 'Choose a pattern for the query loop or start blank.'
190
+ ) }
191
+ >
192
+ { !! hasPatterns && (
193
+ <Button
194
+ variant="primary"
195
+ onClick={ openPatternSelectionModal }
196
+ >
197
+ { __( 'Choose' ) }
198
+ </Button>
199
+ ) }
200
+
201
+ <Button
202
+ variant="secondary"
203
+ onClick={ () => {
204
+ setIsStartingBlank( true );
205
+ } }
206
+ >
207
+ { __( 'Start blank' ) }
208
+ </Button>
209
+ </Placeholder>
151
210
  </div>
152
211
  );
153
212
  }
154
213
 
155
214
  const QueryEdit = ( props ) => {
156
- const { clientId } = props;
215
+ const { clientId, name } = props;
216
+ const [
217
+ isPatternSelectionModalOpen,
218
+ setIsPatternSelectionModalOpen,
219
+ ] = useState( false );
220
+ const { replaceBlock, selectBlock } = useDispatch( blockEditorStore );
157
221
  const hasInnerBlocks = useSelect(
158
222
  ( select ) =>
159
223
  !! select( blockEditorStore ).getBlocks( clientId ).length,
160
224
  [ clientId ]
161
225
  );
162
226
  const Component = hasInnerBlocks ? QueryContent : QueryPatternSetup;
163
- return <Component { ...props } />;
227
+ const onBlockPatternSelect = ( blocks ) => {
228
+ const clonedBlocks = blocks.map( ( block ) => cloneBlock( block ) );
229
+ const firstQueryClientId = getFirstQueryClientIdFromBlocks(
230
+ clonedBlocks
231
+ );
232
+ replaceBlock( clientId, clonedBlocks );
233
+ if ( firstQueryClientId ) {
234
+ selectBlock( firstQueryClientId );
235
+ }
236
+ };
237
+ return (
238
+ <>
239
+ <Component
240
+ { ...props }
241
+ openPatternSelectionModal={ () =>
242
+ setIsPatternSelectionModalOpen( true )
243
+ }
244
+ />
245
+ { isPatternSelectionModalOpen && (
246
+ <Modal
247
+ className="block-editor-query-pattern__selection-modal"
248
+ title={ __( 'Choose a pattern' ) }
249
+ closeLabel={ __( 'Cancel' ) }
250
+ onRequestClose={ () =>
251
+ setIsPatternSelectionModalOpen( false )
252
+ }
253
+ >
254
+ <BlockPatternSetup
255
+ blockName={ name }
256
+ clientId={ clientId }
257
+ onBlockPatternSelect={ onBlockPatternSelect }
258
+ />
259
+ </Modal>
260
+ ) }
261
+ </>
262
+ );
164
263
  };
165
264
 
166
265
  export default QueryEdit;
@@ -5,7 +5,6 @@ import { useSelect, useDispatch } from '@wordpress/data';
5
5
  import {
6
6
  useBlockProps,
7
7
  __experimentalBlockVariationPicker,
8
- __experimentalGetMatchingVariation as getMatchingVariation,
9
8
  store as blockEditorStore,
10
9
  } from '@wordpress/block-editor';
11
10
  import {
@@ -13,13 +12,8 @@ import {
13
12
  store as blocksStore,
14
13
  } from '@wordpress/blocks';
15
14
 
16
- const QueryPlaceholder = ( { clientId, name, attributes, setAttributes } ) => {
17
- const {
18
- blockType,
19
- defaultVariation,
20
- scopeVariations,
21
- allVariations,
22
- } = useSelect(
15
+ function QueryPlaceholder( { clientId, name, setAttributes, icon, label } ) {
16
+ const { defaultVariation, scopeVariations } = useSelect(
23
17
  ( select ) => {
24
18
  const {
25
19
  getBlockVariations,
@@ -31,16 +25,12 @@ const QueryPlaceholder = ( { clientId, name, attributes, setAttributes } ) => {
31
25
  blockType: getBlockType( name ),
32
26
  defaultVariation: getDefaultBlockVariation( name, 'block' ),
33
27
  scopeVariations: getBlockVariations( name, 'block' ),
34
- allVariations: getBlockVariations( name ),
35
28
  };
36
29
  },
37
30
  [ name ]
38
31
  );
39
32
  const { replaceInnerBlocks } = useDispatch( blockEditorStore );
40
33
  const blockProps = useBlockProps();
41
- const matchingVariation = getMatchingVariation( attributes, allVariations );
42
- const icon = matchingVariation?.icon || blockType?.icon?.src;
43
- const label = matchingVariation?.title || blockType?.title;
44
34
  return (
45
35
  <div { ...blockProps }>
46
36
  <__experimentalBlockVariationPicker
@@ -64,6 +54,6 @@ const QueryPlaceholder = ( { clientId, name, attributes, setAttributes } ) => {
64
54
  />
65
55
  </div>
66
56
  );
67
- };
57
+ }
68
58
 
69
59
  export default QueryPlaceholder;
@@ -16,6 +16,7 @@ export default function QueryToolbar( {
16
16
  attributes: { query, displayLayout },
17
17
  setQuery,
18
18
  setDisplayLayout,
19
+ openPatternSelectionModal,
19
20
  } ) {
20
21
  const maxPageInputId = useInstanceId(
21
22
  QueryToolbar,
@@ -128,6 +129,11 @@ export default function QueryToolbar( {
128
129
  />
129
130
  </ToolbarGroup>
130
131
  ) }
132
+ <ToolbarGroup className="wp-block-template-part__block-control-group">
133
+ <ToolbarButton onClick={ openPatternSelectionModal }>
134
+ { __( 'Replace' ) }
135
+ </ToolbarButton>
136
+ </ToolbarGroup>
131
137
  <ToolbarGroup controls={ displayLayoutControls } />
132
138
  </>
133
139
  );
@@ -5,3 +5,41 @@
5
5
  .wp-block-query__create-new-link {
6
6
  padding: 0 $grid-unit-20 $grid-unit-20 56px;
7
7
  }
8
+
9
+ .block-library-query__pattern-selection-content .block-editor-block-patterns-list {
10
+ display: grid;
11
+ grid-template-columns: 1fr 1fr 1fr;
12
+ grid-gap: $grid-unit-10;
13
+
14
+ .block-editor-block-patterns-list__list-item {
15
+ margin-bottom: 0;
16
+ .block-editor-block-preview__container {
17
+ max-height: 250px;
18
+ }
19
+ }
20
+ }
21
+
22
+ .block-editor-query-pattern__selection-modal .components-modal__content {
23
+ overflow: hidden;
24
+ padding: 0;
25
+ &::before {
26
+ margin-bottom: 0;
27
+ }
28
+ }
29
+
30
+ .block-editor-query-pattern__selection-modal {
31
+ // To keep modal dimensions consistent as subsections are navigated, width
32
+ // and height are used instead of max-(width/height).
33
+ @include break-small() {
34
+ width: calc(100% - #{ $grid-unit-20 * 2 });
35
+ height: calc(100% - #{ $header-height * 2 });
36
+ }
37
+ @include break-medium() {
38
+ width: $break-medium - $grid-unit-20 * 2;
39
+ }
40
+ @include break-large() {
41
+ height: 80%;
42
+ width: 80%;
43
+ max-height: none;
44
+ }
45
+ }
@@ -16,7 +16,7 @@ import settingsV2 from './v2';
16
16
 
17
17
  const { name } = metadata;
18
18
 
19
- export { metadata, name };
19
+ export { metadata, name, settingsV2 };
20
20
 
21
21
  export const settingsV1 = {
22
22
  icon,
@@ -53,6 +53,10 @@ export const settingsV1 = {
53
53
  deprecated,
54
54
  };
55
55
 
56
- export const settings = window?.__experimentalEnableQuoteBlockV2
57
- ? settingsV2
58
- : settingsV1;
56
+ let settings = settingsV1;
57
+ if ( process.env.IS_GUTENBERG_PLUGIN ) {
58
+ settings = window?.__experimentalEnableQuoteBlockV2
59
+ ? settingsV2
60
+ : settingsV1;
61
+ }
62
+ export { settings };
@@ -74,6 +74,7 @@ export default function QuoteEdit( {
74
74
  insertBlocksAfter,
75
75
  clientId,
76
76
  className,
77
+ style,
77
78
  } ) {
78
79
  const { citation, align } = attributes;
79
80
 
@@ -88,6 +89,7 @@ export default function QuoteEdit( {
88
89
  className: classNames( className, {
89
90
  [ `has-text-align-${ align }` ]: align,
90
91
  } ),
92
+ ...( ! isWebPlatform && { style } ),
91
93
  } );
92
94
  const innerBlocksProps = useInnerBlocksProps( blockProps, {
93
95
  template: TEMPLATE,
@@ -128,6 +130,7 @@ export default function QuoteEdit( {
128
130
  __unstableOnSplitAtEnd={ () =>
129
131
  insertBlocksAfter( createBlock( 'core/paragraph' ) )
130
132
  }
133
+ { ...( ! isWebPlatform ? { textAlign: align } : {} ) }
131
134
  />
132
135
  ) }
133
136
  </BlockQuotation>
package/src/rss/edit.js CHANGED
@@ -109,7 +109,7 @@ export default function RSSEdit( { attributes, setAttributes } ) {
109
109
  <ToolbarGroup controls={ toolbarControls } />
110
110
  </BlockControls>
111
111
  <InspectorControls>
112
- <PanelBody title={ __( 'RSS settings' ) }>
112
+ <PanelBody title={ __( 'Settings' ) }>
113
113
  <RangeControl
114
114
  label={ __( 'Number of items' ) }
115
115
  value={ itemsToShow }
@@ -103,8 +103,6 @@ export default function SearchEdit( {
103
103
  } );
104
104
  }, [ insertedInNavigationBlock ] );
105
105
  const borderRadius = style?.border?.radius;
106
- const borderColor = style?.border?.color;
107
- const borderWidth = style?.border?.width;
108
106
  const borderProps = useBorderProps( attributes );
109
107
 
110
108
  // Check for old deprecated numerical border radius. Done as a separate
@@ -392,10 +390,18 @@ export default function SearchEdit( {
392
390
  radius ? `calc(${ radius } + ${ DEFAULT_INNER_PADDING })` : undefined;
393
391
 
394
392
  const getWrapperStyles = () => {
395
- const styles = {
396
- borderColor,
397
- borderWidth: isButtonPositionInside ? borderWidth : undefined,
398
- };
393
+ const styles = isButtonPositionInside
394
+ ? borderProps.style
395
+ : {
396
+ borderRadius: borderProps.style?.borderRadius,
397
+ borderTopLeftRadius: borderProps.style?.borderTopLeftRadius,
398
+ borderTopRightRadius:
399
+ borderProps.style?.borderTopRightRadius,
400
+ borderBottomLeftRadius:
401
+ borderProps.style?.borderBottomLeftRadius,
402
+ borderBottomRightRadius:
403
+ borderProps.style?.borderBottomRightRadius,
404
+ };
399
405
 
400
406
  const isNonZeroBorderRadius =
401
407
  borderRadius !== undefined && parseInt( borderRadius, 10 ) !== 0;
@@ -417,11 +423,11 @@ export default function SearchEdit( {
417
423
  } = borderRadius;
418
424
 
419
425
  return {
426
+ ...styles,
420
427
  borderTopLeftRadius: padBorderRadius( topLeft ),
421
428
  borderTopRightRadius: padBorderRadius( topRight ),
422
429
  borderBottomLeftRadius: padBorderRadius( bottomLeft ),
423
430
  borderBottomRightRadius: padBorderRadius( bottomRight ),
424
- ...styles,
425
431
  };
426
432
  }
427
433
 
@@ -171,6 +171,75 @@ function classnames_for_block_core_search( $attributes ) {
171
171
  return implode( ' ', $classnames );
172
172
  }
173
173
 
174
+ /**
175
+ * This generates a CSS rule for the given border property and side if provided.
176
+ * Based on whether the Search block is configured to display the button inside
177
+ * or not, the generated rule is injected into the appropriate collection of
178
+ * styles for later application in the block's markup.
179
+ *
180
+ * @param array $attributes The block attributes.
181
+ * @param string $property Border property to generate rule for e.g. width or color.
182
+ * @param string $side Optional side border. The dictates the value retrieved and final CSS property.
183
+ * @param array $wrapper_styles Current collection of wrapper styles.
184
+ * @param array $button_styles Current collection of button styles.
185
+ * @param array $input_styles Current collection of input styles.
186
+ *
187
+ * @return void
188
+ */
189
+ function apply_block_core_search_border_style( $attributes, $property, $side, &$wrapper_styles, &$button_styles, &$input_styles ) {
190
+ $is_button_inside = 'button-inside' === _wp_array_get( $attributes, array( 'buttonPosition' ), false );
191
+
192
+ $path = array( 'style', 'border', $property );
193
+
194
+ if ( $side ) {
195
+ array_splice( $path, 2, 0, $side );
196
+ }
197
+
198
+ $value = _wp_array_get( $attributes, $path, false );
199
+
200
+ if ( empty( $value ) ) {
201
+ return;
202
+ }
203
+
204
+ if ( 'color' === $property && $side ) {
205
+ $has_color_preset = strpos( $value, 'var:preset|color|' ) !== false;
206
+ if ( $has_color_preset ) {
207
+ $named_color_value = substr( $value, strrpos( $value, '|' ) + 1 );
208
+ $value = sprintf( 'var(--wp--preset--color--%s)', $named_color_value );
209
+ }
210
+ }
211
+
212
+ $property_suffix = $side ? sprintf( '%s-%s', $side, $property ) : $property;
213
+
214
+ if ( $is_button_inside ) {
215
+ $wrapper_styles[] = sprintf( 'border-%s: %s;', $property_suffix, esc_attr( $value ) );
216
+ } else {
217
+ $button_styles[] = sprintf( 'border-%s: %s;', $property_suffix, esc_attr( $value ) );
218
+ $input_styles[] = sprintf( 'border-%s: %s;', $property_suffix, esc_attr( $value ) );
219
+ }
220
+ }
221
+
222
+ /**
223
+ * This adds CSS rules for a given border property e.g. width or color. It
224
+ * injects rules into the provided wrapper, button and input style arrays for
225
+ * uniform "flat" borders or those with individual sides configured.
226
+ *
227
+ * @param array $attributes The block attributes.
228
+ * @param string $property Border property to generate rule for e.g. width or color.
229
+ * @param array $wrapper_styles Current collection of wrapper styles.
230
+ * @param array $button_styles Current collection of button styles.
231
+ * @param array $input_styles Current collection of input styles.
232
+ *
233
+ * @return void
234
+ */
235
+ function apply_block_core_search_border_styles( $attributes, $property, &$wrapper_styles, &$button_styles, &$input_styles ) {
236
+ apply_block_core_search_border_style( $attributes, $property, null, $wrapper_styles, $button_styles, $input_styles );
237
+ apply_block_core_search_border_style( $attributes, $property, 'top', $wrapper_styles, $button_styles, $input_styles );
238
+ apply_block_core_search_border_style( $attributes, $property, 'right', $wrapper_styles, $button_styles, $input_styles );
239
+ apply_block_core_search_border_style( $attributes, $property, 'bottom', $wrapper_styles, $button_styles, $input_styles );
240
+ apply_block_core_search_border_style( $attributes, $property, 'left', $wrapper_styles, $button_styles, $input_styles );
241
+ }
242
+
174
243
  /**
175
244
  * Builds an array of inline styles for the search block.
176
245
  *
@@ -201,19 +270,10 @@ function styles_for_block_core_search( $attributes ) {
201
270
  );
202
271
  }
203
272
 
204
- // Add border width styles.
205
- $has_border_width = ! empty( $attributes['style']['border']['width'] );
206
-
207
- if ( $has_border_width ) {
208
- $border_width = $attributes['style']['border']['width'];
209
-
210
- if ( $is_button_inside ) {
211
- $wrapper_styles[] = sprintf( 'border-width: %s;', esc_attr( $border_width ) );
212
- } else {
213
- $button_styles[] = sprintf( 'border-width: %s;', esc_attr( $border_width ) );
214
- $input_styles[] = sprintf( 'border-width: %s;', esc_attr( $border_width ) );
215
- }
216
- }
273
+ // Add border width and color styles.
274
+ apply_block_core_search_border_styles( $attributes, 'width', $wrapper_styles, $button_styles, $input_styles );
275
+ apply_block_core_search_border_styles( $attributes, 'color', $wrapper_styles, $button_styles, $input_styles );
276
+ apply_block_core_search_border_styles( $attributes, 'style', $wrapper_styles, $button_styles, $input_styles );
217
277
 
218
278
  // Add border radius styles.
219
279
  $has_border_radius = ! empty( $attributes['style']['border']['radius'] );
@@ -269,21 +329,6 @@ function styles_for_block_core_search( $attributes ) {
269
329
  }
270
330
  }
271
331
 
272
- // Add border color styles.
273
- $has_border_color = ! empty( $attributes['style']['border']['color'] );
274
-
275
- if ( $has_border_color ) {
276
- $border_color = $attributes['style']['border']['color'];
277
-
278
- // Apply wrapper border color if button placed inside.
279
- if ( $is_button_inside ) {
280
- $wrapper_styles[] = sprintf( 'border-color: %s;', esc_attr( $border_color ) );
281
- } else {
282
- $button_styles[] = sprintf( 'border-color: %s;', esc_attr( $border_color ) );
283
- $input_styles[] = sprintf( 'border-color: %s;', esc_attr( $border_color ) );
284
- }
285
- }
286
-
287
332
  // Add color styles.
288
333
  $has_text_color = ! empty( $attributes['style']['color']['text'] );
289
334
  if ( $has_text_color ) {
@@ -315,13 +360,19 @@ function styles_for_block_core_search( $attributes ) {
315
360
  * @return string The border color classnames to be applied to the block elements.
316
361
  */
317
362
  function get_border_color_classes_for_block_core_search( $attributes ) {
363
+ $border_color_classes = array();
318
364
  $has_custom_border_color = ! empty( $attributes['style']['border']['color'] );
319
- $border_color_classes = ! empty( $attributes['borderColor'] ) ? sprintf( 'has-border-color has-%s-border-color', $attributes['borderColor'] ) : '';
320
- // If there's a border color style and no `borderColor` text string, we still want to add the generic `has-border-color` class name to the element.
321
- if ( $has_custom_border_color && empty( $attributes['borderColor'] ) ) {
322
- $border_color_classes = 'has-border-color';
365
+ $has_named_border_color = ! empty( $attributes['borderColor'] );
366
+
367
+ if ( $has_custom_border_color || $has_named_border_color ) {
368
+ $border_color_classes[] = 'has-border-color';
369
+ }
370
+
371
+ if ( $has_named_border_color ) {
372
+ $border_color_classes[] = sprintf( 'has-%s-border-color', esc_attr( $attributes['borderColor'] ) );
323
373
  }
324
- return $border_color_classes;
374
+
375
+ return implode( ' ', $border_color_classes );
325
376
  }
326
377
 
327
378
  /**
@@ -0,0 +1 @@
1
+ export const MIN_SPACER_SIZE = 0;
@@ -15,7 +15,7 @@ import { useInstanceId } from '@wordpress/compose';
15
15
  /**
16
16
  * Internal dependencies
17
17
  */
18
- import { MIN_SPACER_SIZE } from './edit';
18
+ import { MIN_SPACER_SIZE } from './constants';
19
19
 
20
20
  function DimensionInput( { label, onChange, isResizing, value = '' } ) {
21
21
  const inputId = useInstanceId( UnitControl, 'block-spacer-height-input' );
@@ -75,7 +75,7 @@ export default function SpacerControls( {
75
75
  } ) {
76
76
  return (
77
77
  <InspectorControls>
78
- <PanelBody title={ __( 'Spacer settings' ) }>
78
+ <PanelBody title={ __( 'Settings' ) }>
79
79
  { orientation === 'horizontal' && (
80
80
  <DimensionInput
81
81
  label={ __( 'Width' ) }
@@ -14,7 +14,7 @@ import { __ } from '@wordpress/i18n';
14
14
  /**
15
15
  * Internal dependencies
16
16
  */
17
- import { MIN_SPACER_SIZE } from './edit.js';
17
+ import { MIN_SPACER_SIZE } from './constants';
18
18
  import styles from './style.scss';
19
19
 
20
20
  const DEFAULT_VALUES = { px: 100, em: 10, rem: 10, vw: 10, vh: 25 };
@@ -15,8 +15,7 @@ import { View } from '@wordpress/primitives';
15
15
  * Internal dependencies
16
16
  */
17
17
  import SpacerControls from './controls';
18
-
19
- export const MIN_SPACER_SIZE = 0;
18
+ import { MIN_SPACER_SIZE } from './constants';
20
19
 
21
20
  const ResizableSpacer = ( {
22
21
  orientation,
package/src/table/edit.js CHANGED
@@ -25,6 +25,7 @@ import {
25
25
  TextControl,
26
26
  ToggleControl,
27
27
  ToolbarDropdownMenu,
28
+ __experimentalHasSplitBorders as hasSplitBorders,
28
29
  } from '@wordpress/components';
29
30
  import {
30
31
  alignLeft,
@@ -451,7 +452,7 @@ function TableEdit( {
451
452
  { ! isEmpty && (
452
453
  <InspectorControls>
453
454
  <PanelBody
454
- title={ __( 'Table settings' ) }
455
+ title={ __( 'Settings' ) }
455
456
  className="blocks-table-settings"
456
457
  >
457
458
  <ToggleControl
@@ -477,7 +478,15 @@ function TableEdit( {
477
478
  className={ classnames(
478
479
  colorProps.className,
479
480
  borderProps.className,
480
- { 'has-fixed-layout': hasFixedLayout }
481
+ {
482
+ 'has-fixed-layout': hasFixedLayout,
483
+ // This is required in the editor only to overcome
484
+ // the fact the editor rewrites individual border
485
+ // widths into a shorthand format.
486
+ 'has-individual-borders': hasSplitBorders(
487
+ attributes?.style?.border
488
+ ),
489
+ }
481
490
  ) }
482
491
  style={ { ...colorProps.style, ...borderProps.style } }
483
492
  >
@@ -43,6 +43,19 @@
43
43
  figcaption {
44
44
  @include caption-style-theme();
45
45
  }
46
+
47
+ // This is only required in the editor to overcome the fact the editor
48
+ // rewrites border width styles into shorthand.
49
+ table.has-individual-borders {
50
+ > *,
51
+ tr,
52
+ th,
53
+ td {
54
+ border-width: $border-width;
55
+ border-style: solid;
56
+ border-color: currentColor;
57
+ }
58
+ }
46
59
  }
47
60
 
48
61
  .blocks-table__placeholder-form.blocks-table__placeholder-form {