@wordpress/block-library 8.33.0 → 8.34.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 (259) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/block/edit.js +15 -8
  3. package/build/block/edit.js.map +1 -1
  4. package/build/block-keyboard-shortcuts/index.js +95 -0
  5. package/build/block-keyboard-shortcuts/index.js.map +1 -0
  6. package/build/column/edit.js +28 -19
  7. package/build/column/edit.js.map +1 -1
  8. package/build/column/edit.native.js +3 -1
  9. package/build/column/edit.native.js.map +1 -1
  10. package/build/columns/edit.js +69 -53
  11. package/build/columns/edit.js.map +1 -1
  12. package/build/columns/variations.js +18 -28
  13. package/build/columns/variations.js.map +1 -1
  14. package/build/comment-template/util.js +3 -1
  15. package/build/comment-template/util.js.map +1 -1
  16. package/build/cover/shared.js +3 -1
  17. package/build/cover/shared.js.map +1 -1
  18. package/build/embed/embed-placeholder.js +8 -3
  19. package/build/embed/embed-placeholder.js.map +1 -1
  20. package/build/embed/util.js +3 -1
  21. package/build/embed/util.js.map +1 -1
  22. package/build/embed/variations.js +3 -1
  23. package/build/embed/variations.js.map +1 -1
  24. package/build/embed/wp-embed-preview.js +6 -2
  25. package/build/embed/wp-embed-preview.js.map +1 -1
  26. package/build/group/index.js +0 -8
  27. package/build/group/index.js.map +1 -1
  28. package/build/group/placeholder.js +18 -19
  29. package/build/group/placeholder.js.map +1 -1
  30. package/build/image/image.js +3 -1
  31. package/build/image/image.js.map +1 -1
  32. package/build/image/view.js +3 -1
  33. package/build/image/view.js.map +1 -1
  34. package/build/index.js +9 -1
  35. package/build/index.js.map +1 -1
  36. package/build/list-item/hooks/use-merge.js +12 -4
  37. package/build/list-item/hooks/use-merge.js.map +1 -1
  38. package/build/list-item/hooks/use-outdent-list-item.js +15 -5
  39. package/build/list-item/hooks/use-outdent-list-item.js.map +1 -1
  40. package/build/navigation/edit/are-blocks-dirty.js +9 -3
  41. package/build/navigation/edit/are-blocks-dirty.js.map +1 -1
  42. package/build/navigation/edit/deleted-navigation-warning.js +1 -1
  43. package/build/navigation/edit/deleted-navigation-warning.js.map +1 -1
  44. package/build/navigation/edit/menu-inspector-controls.js +3 -1
  45. package/build/navigation/edit/menu-inspector-controls.js.map +1 -1
  46. package/build/navigation/edit/navigation-menu-selector.js +1 -1
  47. package/build/navigation/edit/navigation-menu-selector.js.map +1 -1
  48. package/build/navigation/index.js +0 -9
  49. package/build/navigation/index.js.map +1 -1
  50. package/build/navigation/view.js +3 -1
  51. package/build/navigation/view.js.map +1 -1
  52. package/build/navigation-link/edit.js +94 -85
  53. package/build/navigation-link/edit.js.map +1 -1
  54. package/build/navigation-link/link-ui.js +2 -7
  55. package/build/navigation-link/link-ui.js.map +1 -1
  56. package/build/paragraph/index.js +0 -1
  57. package/build/paragraph/index.js.map +1 -1
  58. package/build/paragraph/transforms.js +0 -1
  59. package/build/paragraph/transforms.js.map +1 -1
  60. package/build/post-excerpt/edit.js +3 -1
  61. package/build/post-excerpt/edit.js.map +1 -1
  62. package/build/post-featured-image/dimension-controls.js +3 -1
  63. package/build/post-featured-image/dimension-controls.js.map +1 -1
  64. package/build/post-navigation-link/variations.js +3 -1
  65. package/build/post-navigation-link/variations.js.map +1 -1
  66. package/build/post-template/edit.js +18 -8
  67. package/build/post-template/edit.js.map +1 -1
  68. package/build/post-terms/edit.js +3 -1
  69. package/build/post-terms/edit.js.map +1 -1
  70. package/build/private-apis.js +21 -0
  71. package/build/private-apis.js.map +1 -0
  72. package/build/query/edit/enhanced-pagination-modal.js +1 -1
  73. package/build/query/edit/enhanced-pagination-modal.js.map +1 -1
  74. package/build/query/edit/inspector-controls/author-control.js +6 -2
  75. package/build/query/edit/inspector-controls/author-control.js.map +1 -1
  76. package/build/query/edit/inspector-controls/create-new-post-link.js +3 -1
  77. package/build/query/edit/inspector-controls/create-new-post-link.js.map +1 -1
  78. package/build/query/edit/inspector-controls/enhanced-pagination-control.js +6 -3
  79. package/build/query/edit/inspector-controls/enhanced-pagination-control.js.map +1 -1
  80. package/build/query/edit/inspector-controls/parent-control.js +18 -6
  81. package/build/query/edit/inspector-controls/parent-control.js.map +1 -1
  82. package/build/query/edit/inspector-controls/taxonomy-controls.js +9 -3
  83. package/build/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
  84. package/build/query/utils.js +3 -1
  85. package/build/query/utils.js.map +1 -1
  86. package/build/query-title/variations.js +3 -1
  87. package/build/query-title/variations.js.map +1 -1
  88. package/build/social-link/edit.js +1 -1
  89. package/build/social-link/edit.js.map +1 -1
  90. package/build/social-link/variations.js +3 -1
  91. package/build/social-link/variations.js.map +1 -1
  92. package/build/template-part/variations.js +6 -2
  93. package/build/template-part/variations.js.map +1 -1
  94. package/build-module/block/edit.js +15 -8
  95. package/build-module/block/edit.js.map +1 -1
  96. package/build-module/block-keyboard-shortcuts/index.js +88 -0
  97. package/build-module/block-keyboard-shortcuts/index.js.map +1 -0
  98. package/build-module/column/edit.js +28 -19
  99. package/build-module/column/edit.js.map +1 -1
  100. package/build-module/column/edit.native.js +3 -1
  101. package/build-module/column/edit.native.js.map +1 -1
  102. package/build-module/columns/edit.js +69 -53
  103. package/build-module/columns/edit.js.map +1 -1
  104. package/build-module/columns/variations.js +18 -28
  105. package/build-module/columns/variations.js.map +1 -1
  106. package/build-module/comment-template/util.js +3 -1
  107. package/build-module/comment-template/util.js.map +1 -1
  108. package/build-module/cover/shared.js +3 -1
  109. package/build-module/cover/shared.js.map +1 -1
  110. package/build-module/embed/embed-placeholder.js +9 -4
  111. package/build-module/embed/embed-placeholder.js.map +1 -1
  112. package/build-module/embed/util.js +3 -1
  113. package/build-module/embed/util.js.map +1 -1
  114. package/build-module/embed/variations.js +3 -1
  115. package/build-module/embed/variations.js.map +1 -1
  116. package/build-module/embed/wp-embed-preview.js +6 -2
  117. package/build-module/embed/wp-embed-preview.js.map +1 -1
  118. package/build-module/group/index.js +0 -8
  119. package/build-module/group/index.js.map +1 -1
  120. package/build-module/group/placeholder.js +18 -19
  121. package/build-module/group/placeholder.js.map +1 -1
  122. package/build-module/image/image.js +3 -1
  123. package/build-module/image/image.js.map +1 -1
  124. package/build-module/image/view.js +3 -1
  125. package/build-module/image/view.js.map +1 -1
  126. package/build-module/index.js +1 -0
  127. package/build-module/index.js.map +1 -1
  128. package/build-module/list-item/hooks/use-merge.js +12 -4
  129. package/build-module/list-item/hooks/use-merge.js.map +1 -1
  130. package/build-module/list-item/hooks/use-outdent-list-item.js +15 -5
  131. package/build-module/list-item/hooks/use-outdent-list-item.js.map +1 -1
  132. package/build-module/navigation/edit/are-blocks-dirty.js +9 -3
  133. package/build-module/navigation/edit/are-blocks-dirty.js.map +1 -1
  134. package/build-module/navigation/edit/deleted-navigation-warning.js +1 -1
  135. package/build-module/navigation/edit/deleted-navigation-warning.js.map +1 -1
  136. package/build-module/navigation/edit/menu-inspector-controls.js +3 -1
  137. package/build-module/navigation/edit/menu-inspector-controls.js.map +1 -1
  138. package/build-module/navigation/edit/navigation-menu-selector.js +1 -1
  139. package/build-module/navigation/edit/navigation-menu-selector.js.map +1 -1
  140. package/build-module/navigation/index.js +0 -9
  141. package/build-module/navigation/index.js.map +1 -1
  142. package/build-module/navigation/view.js +3 -1
  143. package/build-module/navigation/view.js.map +1 -1
  144. package/build-module/navigation-link/edit.js +94 -85
  145. package/build-module/navigation-link/edit.js.map +1 -1
  146. package/build-module/navigation-link/link-ui.js +3 -8
  147. package/build-module/navigation-link/link-ui.js.map +1 -1
  148. package/build-module/paragraph/index.js +0 -1
  149. package/build-module/paragraph/index.js.map +1 -1
  150. package/build-module/paragraph/transforms.js +0 -1
  151. package/build-module/paragraph/transforms.js.map +1 -1
  152. package/build-module/post-excerpt/edit.js +3 -1
  153. package/build-module/post-excerpt/edit.js.map +1 -1
  154. package/build-module/post-featured-image/dimension-controls.js +3 -1
  155. package/build-module/post-featured-image/dimension-controls.js.map +1 -1
  156. package/build-module/post-navigation-link/variations.js +3 -1
  157. package/build-module/post-navigation-link/variations.js.map +1 -1
  158. package/build-module/post-template/edit.js +18 -8
  159. package/build-module/post-template/edit.js.map +1 -1
  160. package/build-module/post-terms/edit.js +3 -1
  161. package/build-module/post-terms/edit.js.map +1 -1
  162. package/build-module/private-apis.js +14 -0
  163. package/build-module/private-apis.js.map +1 -0
  164. package/build-module/query/edit/enhanced-pagination-modal.js +1 -1
  165. package/build-module/query/edit/enhanced-pagination-modal.js.map +1 -1
  166. package/build-module/query/edit/inspector-controls/author-control.js +6 -2
  167. package/build-module/query/edit/inspector-controls/author-control.js.map +1 -1
  168. package/build-module/query/edit/inspector-controls/create-new-post-link.js +3 -1
  169. package/build-module/query/edit/inspector-controls/create-new-post-link.js.map +1 -1
  170. package/build-module/query/edit/inspector-controls/enhanced-pagination-control.js +6 -3
  171. package/build-module/query/edit/inspector-controls/enhanced-pagination-control.js.map +1 -1
  172. package/build-module/query/edit/inspector-controls/parent-control.js +18 -6
  173. package/build-module/query/edit/inspector-controls/parent-control.js.map +1 -1
  174. package/build-module/query/edit/inspector-controls/taxonomy-controls.js +9 -3
  175. package/build-module/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
  176. package/build-module/query/utils.js +3 -1
  177. package/build-module/query/utils.js.map +1 -1
  178. package/build-module/query-title/variations.js +3 -1
  179. package/build-module/query-title/variations.js.map +1 -1
  180. package/build-module/social-link/edit.js +1 -1
  181. package/build-module/social-link/edit.js.map +1 -1
  182. package/build-module/social-link/variations.js +3 -1
  183. package/build-module/social-link/variations.js.map +1 -1
  184. package/build-module/template-part/variations.js +6 -2
  185. package/build-module/template-part/variations.js.map +1 -1
  186. package/build-style/editor-rtl.css +15 -49
  187. package/build-style/editor.css +15 -49
  188. package/build-style/embed/editor-rtl.css +0 -3
  189. package/build-style/embed/editor.css +0 -3
  190. package/build-style/group/editor-rtl.css +0 -44
  191. package/build-style/group/editor.css +0 -44
  192. package/build-style/group/style-rtl.css +4 -0
  193. package/build-style/group/style.css +4 -0
  194. package/build-style/navigation-link/style-rtl.css +0 -8
  195. package/build-style/navigation-link/style.css +0 -8
  196. package/build-style/post-featured-image/editor-rtl.css +1 -0
  197. package/build-style/post-featured-image/editor.css +1 -0
  198. package/build-style/site-logo/editor-rtl.css +1 -0
  199. package/build-style/site-logo/editor.css +1 -0
  200. package/build-style/social-link/editor-rtl.css +13 -2
  201. package/build-style/social-link/editor.css +13 -2
  202. package/build-style/style-rtl.css +4 -8
  203. package/build-style/style.css +4 -8
  204. package/package.json +35 -34
  205. package/src/block/edit.js +19 -12
  206. package/src/block-keyboard-shortcuts/index.js +113 -0
  207. package/src/column/edit.js +26 -20
  208. package/src/column/edit.native.js +3 -1
  209. package/src/columns/edit.js +93 -83
  210. package/src/columns/variations.js +12 -34
  211. package/src/comment-template/util.js +3 -1
  212. package/src/cover/shared.js +3 -1
  213. package/src/embed/editor.scss +0 -2
  214. package/src/embed/embed-placeholder.js +21 -9
  215. package/src/embed/util.js +3 -1
  216. package/src/embed/variations.js +3 -1
  217. package/src/embed/wp-embed-preview.js +6 -2
  218. package/src/gallery/test/helpers.native.js +3 -3
  219. package/src/group/editor.scss +0 -47
  220. package/src/group/index.js +0 -8
  221. package/src/group/placeholder.js +18 -18
  222. package/src/group/style.scss +5 -0
  223. package/src/image/image.js +3 -1
  224. package/src/image/view.js +3 -1
  225. package/src/index.js +2 -0
  226. package/src/list-item/hooks/use-merge.js +12 -4
  227. package/src/list-item/hooks/use-outdent-list-item.js +15 -5
  228. package/src/navigation/block.json +0 -9
  229. package/src/navigation/edit/are-blocks-dirty.js +8 -3
  230. package/src/navigation/edit/deleted-navigation-warning.js +1 -1
  231. package/src/navigation/edit/menu-inspector-controls.js +3 -1
  232. package/src/navigation/edit/navigation-menu-selector.js +1 -1
  233. package/src/navigation/edit/test/navigation-menu-selector.js +5 -5
  234. package/src/navigation/view.js +3 -1
  235. package/src/navigation-link/edit.js +91 -91
  236. package/src/navigation-link/link-ui.js +74 -89
  237. package/src/navigation-link/style.scss +0 -12
  238. package/src/paragraph/block.json +0 -1
  239. package/src/post-excerpt/edit.js +3 -1
  240. package/src/post-featured-image/dimension-controls.js +3 -1
  241. package/src/post-featured-image/editor.scss +1 -0
  242. package/src/post-navigation-link/variations.js +3 -1
  243. package/src/post-template/edit.js +9 -4
  244. package/src/post-terms/edit.js +3 -1
  245. package/src/private-apis.js +13 -0
  246. package/src/query/edit/enhanced-pagination-modal.js +5 -1
  247. package/src/query/edit/inspector-controls/author-control.js +6 -2
  248. package/src/query/edit/inspector-controls/create-new-post-link.js +3 -1
  249. package/src/query/edit/inspector-controls/enhanced-pagination-control.js +13 -3
  250. package/src/query/edit/inspector-controls/parent-control.js +18 -6
  251. package/src/query/edit/inspector-controls/taxonomy-controls.js +9 -3
  252. package/src/query/index.php +1 -1
  253. package/src/query/utils.js +3 -1
  254. package/src/query-title/variations.js +3 -1
  255. package/src/site-logo/editor.scss +1 -0
  256. package/src/social-link/edit.js +2 -2
  257. package/src/social-link/editor.scss +25 -11
  258. package/src/social-link/variations.js +3 -1
  259. package/src/template-part/variations.js +6 -2
package/src/block/edit.js CHANGED
@@ -92,7 +92,9 @@ const useInferredLayout = ( blocks, parentLayout ) => {
92
92
 
93
93
  function hasOverridableBlocks( blocks ) {
94
94
  return blocks.some( ( block ) => {
95
- if ( isOverridableBlock( block ) ) return true;
95
+ if ( isOverridableBlock( block ) ) {
96
+ return true;
97
+ }
96
98
  return hasOverridableBlocks( block.innerBlocks );
97
99
  } );
98
100
  }
@@ -159,7 +161,9 @@ function getContentValuesFromInnerBlocks( blocks, defaultValues, legacyIdMap ) {
159
161
  /** @type {Record<string, { values: Record<string, unknown>}>} */
160
162
  const content = {};
161
163
  for ( const block of blocks ) {
162
- if ( block.name === patternBlockName ) continue;
164
+ if ( block.name === patternBlockName ) {
165
+ continue;
166
+ }
163
167
  if ( block.innerBlocks.length ) {
164
168
  Object.assign(
165
169
  content,
@@ -261,8 +265,9 @@ function ReusableBlockEdit( {
261
265
  );
262
266
  const isMissing = hasResolved && ! record;
263
267
 
264
- // The initial value of the `content` attribute.
265
- const initialContent = useRef( content );
268
+ // The value of the `content` attribute, stored in a `ref` to avoid triggering the effect
269
+ // that runs `applyInitialContentValuesToInnerBlocks` unnecessarily.
270
+ const contentRef = useRef( content );
266
271
 
267
272
  // The default content values from the original pattern for overridable attributes.
268
273
  // Set by the `applyInitialContentValuesToInnerBlocks` function.
@@ -349,7 +354,7 @@ function ReusableBlockEdit( {
349
354
  // Build a map of clientIds to the old nano id system to provide back compat.
350
355
  legacyIdMap.current = getLegacyIdMap(
351
356
  initialBlocks,
352
- initialContent.current
357
+ contentRef.current
353
358
  );
354
359
  defaultContent.current = {};
355
360
  const originalEditingMode = getBlockEditingMode( patternClientId );
@@ -360,7 +365,7 @@ function ReusableBlockEdit( {
360
365
  const blocks = hasPatternOverridesSource
361
366
  ? applyInitialContentValuesToInnerBlocks(
362
367
  initialBlocks,
363
- initialContent.current,
368
+ contentRef.current,
364
369
  defaultContent.current,
365
370
  legacyIdMap.current
366
371
  )
@@ -397,7 +402,7 @@ function ReusableBlockEdit( {
397
402
  } );
398
403
 
399
404
  const innerBlocksProps = useInnerBlocksProps( blockProps, {
400
- templateLock: 'all',
405
+ templateLock: 'contentOnly',
401
406
  layout,
402
407
  renderAppender: innerBlocks?.length
403
408
  ? undefined
@@ -417,13 +422,15 @@ function ReusableBlockEdit( {
417
422
  if ( blocks !== prevBlocks ) {
418
423
  prevBlocks = blocks;
419
424
  syncDerivedUpdates( () => {
425
+ const updatedContent = getContentValuesFromInnerBlocks(
426
+ blocks,
427
+ defaultContent.current,
428
+ legacyIdMap.current
429
+ );
420
430
  setAttributes( {
421
- content: getContentValuesFromInnerBlocks(
422
- blocks,
423
- defaultContent.current,
424
- legacyIdMap.current
425
- ),
431
+ content: updatedContent,
426
432
  } );
433
+ contentRef.current = updatedContent;
427
434
  } );
428
435
  }
429
436
  }, blockEditorStore );
@@ -0,0 +1,113 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useEffect } from '@wordpress/element';
5
+ import { useSelect, useDispatch } from '@wordpress/data';
6
+ import {
7
+ useShortcut,
8
+ store as keyboardShortcutsStore,
9
+ } from '@wordpress/keyboard-shortcuts';
10
+ import { __ } from '@wordpress/i18n';
11
+ import { createBlock } from '@wordpress/blocks';
12
+ import { store as blockEditorStore } from '@wordpress/block-editor';
13
+
14
+ function BlockKeyboardShortcuts() {
15
+ const { registerShortcut } = useDispatch( keyboardShortcutsStore );
16
+ const { replaceBlocks } = useDispatch( blockEditorStore );
17
+ const { getBlockName, getSelectedBlockClientId, getBlockAttributes } =
18
+ useSelect( blockEditorStore );
19
+
20
+ const handleTransformHeadingAndParagraph = ( event, level ) => {
21
+ event.preventDefault();
22
+
23
+ const currentClientId = getSelectedBlockClientId();
24
+ if ( currentClientId === null ) {
25
+ return;
26
+ }
27
+
28
+ const blockName = getBlockName( currentClientId );
29
+ const isParagraph = blockName === 'core/paragraph';
30
+ const isHeading = blockName === 'core/heading';
31
+
32
+ if ( ! isParagraph && ! isHeading ) {
33
+ return;
34
+ }
35
+
36
+ const destinationBlockName =
37
+ level === 0 ? 'core/paragraph' : 'core/heading';
38
+
39
+ const attributes = getBlockAttributes( currentClientId );
40
+
41
+ // Avoid unnecessary block transform when attempting to transform to
42
+ // the same block type and/or same level.
43
+ if (
44
+ ( isParagraph && level === 0 ) ||
45
+ ( isHeading && attributes.level === level )
46
+ ) {
47
+ return;
48
+ }
49
+
50
+ const textAlign =
51
+ blockName === 'core/paragraph' ? 'align' : 'textAlign';
52
+ const destinationTextAlign =
53
+ destinationBlockName === 'core/paragraph' ? 'align' : 'textAlign';
54
+
55
+ replaceBlocks(
56
+ currentClientId,
57
+ createBlock( destinationBlockName, {
58
+ level,
59
+ content: attributes.content,
60
+ ...{ [ destinationTextAlign ]: attributes[ textAlign ] },
61
+ } )
62
+ );
63
+ };
64
+
65
+ useEffect( () => {
66
+ registerShortcut( {
67
+ name: 'core/block-editor/transform-heading-to-paragraph',
68
+ category: 'block-library',
69
+ description: __( 'Transform heading to paragraph.' ),
70
+ keyCombination: {
71
+ modifier: 'access',
72
+ character: '0',
73
+ },
74
+ aliases: [
75
+ {
76
+ modifier: 'access',
77
+ character: '7',
78
+ },
79
+ ],
80
+ } );
81
+
82
+ [ 1, 2, 3, 4, 5, 6 ].forEach( ( level ) => {
83
+ registerShortcut( {
84
+ name: `core/block-editor/transform-paragraph-to-heading-${ level }`,
85
+ category: 'block-library',
86
+ description: __( 'Transform paragraph to heading.' ),
87
+ keyCombination: {
88
+ modifier: 'access',
89
+ character: `${ level }`,
90
+ },
91
+ } );
92
+ } );
93
+ }, [] );
94
+
95
+ useShortcut(
96
+ 'core/block-editor/transform-heading-to-paragraph',
97
+ ( event ) => handleTransformHeadingAndParagraph( event, 0 )
98
+ );
99
+
100
+ [ 1, 2, 3, 4, 5, 6 ].forEach( ( level ) => {
101
+ //the loop is based off on a constant therefore
102
+ //the hook will execute the same way every time
103
+ //eslint-disable-next-line react-hooks/rules-of-hooks
104
+ useShortcut(
105
+ `core/block-editor/transform-paragraph-to-heading-${ level }`,
106
+ ( event ) => handleTransformHeadingAndParagraph( event, level )
107
+ );
108
+ } );
109
+
110
+ return null;
111
+ }
112
+
113
+ export default BlockKeyboardShortcuts;
@@ -24,6 +24,28 @@ import {
24
24
  import { useSelect, useDispatch } from '@wordpress/data';
25
25
  import { sprintf, __ } from '@wordpress/i18n';
26
26
 
27
+ function ColumnInspectorControls( { width, setAttributes } ) {
28
+ const [ availableUnits ] = useSettings( 'spacing.units' );
29
+ const units = useCustomUnits( {
30
+ availableUnits: availableUnits || [ '%', 'px', 'em', 'rem', 'vw' ],
31
+ } );
32
+ return (
33
+ <PanelBody title={ __( 'Settings' ) }>
34
+ <UnitControl
35
+ label={ __( 'Width' ) }
36
+ labelPosition="edge"
37
+ __unstableInputWidth="80px"
38
+ value={ width || '' }
39
+ onChange={ ( nextWidth ) => {
40
+ nextWidth = 0 > parseFloat( nextWidth ) ? '0' : nextWidth;
41
+ setAttributes( { width: nextWidth } );
42
+ } }
43
+ units={ units }
44
+ />
45
+ </PanelBody>
46
+ );
47
+ }
48
+
27
49
  function ColumnEdit( {
28
50
  attributes: { verticalAlignment, width, templateLock, allowedBlocks },
29
51
  setAttributes,
@@ -32,12 +54,6 @@ function ColumnEdit( {
32
54
  const classes = classnames( 'block-core-columns', {
33
55
  [ `is-vertically-aligned-${ verticalAlignment }` ]: verticalAlignment,
34
56
  } );
35
-
36
- const [ availableUnits ] = useSettings( 'spacing.units' );
37
- const units = useCustomUnits( {
38
- availableUnits: availableUnits || [ '%', 'px', 'em', 'rem', 'vw' ],
39
- } );
40
-
41
57
  const { columnsIds, hasChildBlocks, rootClientId } = useSelect(
42
58
  ( select ) => {
43
59
  const { getBlockOrder, getBlockRootClientId } =
@@ -103,20 +119,10 @@ function ColumnEdit( {
103
119
  />
104
120
  </BlockControls>
105
121
  <InspectorControls>
106
- <PanelBody title={ __( 'Settings' ) }>
107
- <UnitControl
108
- label={ __( 'Width' ) }
109
- labelPosition="edge"
110
- __unstableInputWidth="80px"
111
- value={ width || '' }
112
- onChange={ ( nextWidth ) => {
113
- nextWidth =
114
- 0 > parseFloat( nextWidth ) ? '0' : nextWidth;
115
- setAttributes( { width: nextWidth } );
116
- } }
117
- units={ units }
118
- />
119
- </PanelBody>
122
+ <ColumnInspectorControls
123
+ width={ width }
124
+ setAttributes={ setAttributes }
125
+ />
120
126
  </InspectorControls>
121
127
  <div { ...innerBlocksProps } />
122
128
  </>
@@ -220,7 +220,9 @@ function ColumnEditWrapper( props ) {
220
220
  const { verticalAlignment } = props.attributes;
221
221
 
222
222
  const getVerticalAlignmentRemap = ( alignment ) => {
223
- if ( ! alignment ) return styles.flexBase;
223
+ if ( ! alignment ) {
224
+ return styles.flexBase;
225
+ }
224
226
  return {
225
227
  ...styles.flexBase,
226
228
  ...styles[ `is-vertically-aligned-${ alignment }` ],
@@ -44,8 +44,11 @@ const DEFAULT_BLOCK = {
44
44
  name: 'core/column',
45
45
  };
46
46
 
47
- function ColumnsEditContainer( { attributes, setAttributes, clientId } ) {
48
- const { isStackedOnMobile, verticalAlignment, templateLock } = attributes;
47
+ function ColumnInspectorControls( {
48
+ clientId,
49
+ setAttributes,
50
+ isStackedOnMobile,
51
+ } ) {
49
52
  const { count, canInsertColumnBlock, minCount } = useSelect(
50
53
  ( select ) => {
51
54
  const {
@@ -79,47 +82,8 @@ function ColumnsEditContainer( { attributes, setAttributes, clientId } ) {
79
82
  },
80
83
  [ clientId ]
81
84
  );
82
-
83
- const registry = useRegistry();
84
- const { getBlocks, getBlockOrder } = useSelect( blockEditorStore );
85
- const { updateBlockAttributes, replaceInnerBlocks } =
86
- useDispatch( blockEditorStore );
87
-
88
- const classes = classnames( {
89
- [ `are-vertically-aligned-${ verticalAlignment }` ]: verticalAlignment,
90
- [ `is-not-stacked-on-mobile` ]: ! isStackedOnMobile,
91
- } );
92
-
93
- const blockProps = useBlockProps( {
94
- className: classes,
95
- } );
96
- const innerBlocksProps = useInnerBlocksProps( blockProps, {
97
- defaultBlock: DEFAULT_BLOCK,
98
- directInsert: true,
99
- orientation: 'horizontal',
100
- renderAppender: false,
101
- templateLock,
102
- } );
103
-
104
- /**
105
- * Update all child Column blocks with a new vertical alignment setting
106
- * based on whatever alignment is passed in. This allows change to parent
107
- * to overide anything set on a individual column basis.
108
- *
109
- * @param {string} newVerticalAlignment The vertical alignment setting.
110
- */
111
- function updateAlignment( newVerticalAlignment ) {
112
- const innerBlockClientIds = getBlockOrder( clientId );
113
-
114
- // Update own and child Column block vertical alignments.
115
- // This is a single action; the batching prevents creating multiple history records.
116
- registry.batch( () => {
117
- setAttributes( { verticalAlignment: newVerticalAlignment } );
118
- updateBlockAttributes( innerBlockClientIds, {
119
- verticalAlignment: newVerticalAlignment,
120
- } );
121
- } );
122
- }
85
+ const { getBlocks } = useSelect( blockEditorStore );
86
+ const { replaceInnerBlocks } = useDispatch( blockEditorStore );
123
87
 
124
88
  /**
125
89
  * Updates the column count, including necessary revisions to child Column
@@ -184,6 +148,86 @@ function ColumnsEditContainer( { attributes, setAttributes, clientId } ) {
184
148
  replaceInnerBlocks( clientId, innerBlocks );
185
149
  }
186
150
 
151
+ return (
152
+ <PanelBody title={ __( 'Settings' ) }>
153
+ { canInsertColumnBlock && (
154
+ <>
155
+ <RangeControl
156
+ __nextHasNoMarginBottom
157
+ __next40pxDefaultSize
158
+ label={ __( 'Columns' ) }
159
+ value={ count }
160
+ onChange={ ( value ) =>
161
+ updateColumns( count, Math.max( minCount, value ) )
162
+ }
163
+ min={ Math.max( 1, minCount ) }
164
+ max={ Math.max( 6, count ) }
165
+ />
166
+ { count > 6 && (
167
+ <Notice status="warning" isDismissible={ false }>
168
+ { __(
169
+ 'This column count exceeds the recommended amount and may cause visual breakage.'
170
+ ) }
171
+ </Notice>
172
+ ) }
173
+ </>
174
+ ) }
175
+ <ToggleControl
176
+ __nextHasNoMarginBottom
177
+ label={ __( 'Stack on mobile' ) }
178
+ checked={ isStackedOnMobile }
179
+ onChange={ () =>
180
+ setAttributes( {
181
+ isStackedOnMobile: ! isStackedOnMobile,
182
+ } )
183
+ }
184
+ />
185
+ </PanelBody>
186
+ );
187
+ }
188
+
189
+ function ColumnsEditContainer( { attributes, setAttributes, clientId } ) {
190
+ const { isStackedOnMobile, verticalAlignment, templateLock } = attributes;
191
+ const registry = useRegistry();
192
+ const { getBlockOrder } = useSelect( blockEditorStore );
193
+ const { updateBlockAttributes } = useDispatch( blockEditorStore );
194
+
195
+ const classes = classnames( {
196
+ [ `are-vertically-aligned-${ verticalAlignment }` ]: verticalAlignment,
197
+ [ `is-not-stacked-on-mobile` ]: ! isStackedOnMobile,
198
+ } );
199
+
200
+ const blockProps = useBlockProps( {
201
+ className: classes,
202
+ } );
203
+ const innerBlocksProps = useInnerBlocksProps( blockProps, {
204
+ defaultBlock: DEFAULT_BLOCK,
205
+ directInsert: true,
206
+ orientation: 'horizontal',
207
+ renderAppender: false,
208
+ templateLock,
209
+ } );
210
+
211
+ /**
212
+ * Update all child Column blocks with a new vertical alignment setting
213
+ * based on whatever alignment is passed in. This allows change to parent
214
+ * to overide anything set on a individual column basis.
215
+ *
216
+ * @param {string} newVerticalAlignment The vertical alignment setting.
217
+ */
218
+ function updateAlignment( newVerticalAlignment ) {
219
+ const innerBlockClientIds = getBlockOrder( clientId );
220
+
221
+ // Update own and child Column block vertical alignments.
222
+ // This is a single action; the batching prevents creating multiple history records.
223
+ registry.batch( () => {
224
+ setAttributes( { verticalAlignment: newVerticalAlignment } );
225
+ updateBlockAttributes( innerBlockClientIds, {
226
+ verticalAlignment: newVerticalAlignment,
227
+ } );
228
+ } );
229
+ }
230
+
187
231
  return (
188
232
  <>
189
233
  <BlockControls>
@@ -193,46 +237,11 @@ function ColumnsEditContainer( { attributes, setAttributes, clientId } ) {
193
237
  />
194
238
  </BlockControls>
195
239
  <InspectorControls>
196
- <PanelBody title={ __( 'Settings' ) }>
197
- { canInsertColumnBlock && (
198
- <>
199
- <RangeControl
200
- __nextHasNoMarginBottom
201
- __next40pxDefaultSize
202
- label={ __( 'Columns' ) }
203
- value={ count }
204
- onChange={ ( value ) =>
205
- updateColumns(
206
- count,
207
- Math.max( minCount, value )
208
- )
209
- }
210
- min={ Math.max( 1, minCount ) }
211
- max={ Math.max( 6, count ) }
212
- />
213
- { count > 6 && (
214
- <Notice
215
- status="warning"
216
- isDismissible={ false }
217
- >
218
- { __(
219
- 'This column count exceeds the recommended amount and may cause visual breakage.'
220
- ) }
221
- </Notice>
222
- ) }
223
- </>
224
- ) }
225
- <ToggleControl
226
- __nextHasNoMarginBottom
227
- label={ __( 'Stack on mobile' ) }
228
- checked={ isStackedOnMobile }
229
- onChange={ () =>
230
- setAttributes( {
231
- isStackedOnMobile: ! isStackedOnMobile,
232
- } )
233
- }
234
- />
235
- </PanelBody>
240
+ <ColumnInspectorControls
241
+ clientId={ clientId }
242
+ setAttributes={ setAttributes }
243
+ isStackedOnMobile={ isStackedOnMobile }
244
+ />
236
245
  </InspectorControls>
237
246
  <div { ...innerBlocksProps } />
238
247
  </>
@@ -265,6 +274,7 @@ function Placeholder( { clientId, name, setAttributes } ) {
265
274
  icon={ blockType?.icon?.src }
266
275
  label={ blockType?.title }
267
276
  variations={ variations }
277
+ instructions={ __( 'Divide into columns. Select a layout:' ) }
268
278
  onSelect={ ( nextVariation = defaultVariation ) => {
269
279
  if ( nextVariation.attributes ) {
270
280
  setAttributes( nextVariation.attributes );
@@ -18,16 +18,12 @@ const variations = [
18
18
  description: __( 'One column' ),
19
19
  icon: (
20
20
  <SVG
21
+ xmlns="http://www.w3.org/2000/svg"
21
22
  width="48"
22
23
  height="48"
23
24
  viewBox="0 0 48 48"
24
- xmlns="http://www.w3.org/2000/svg"
25
25
  >
26
- <Path
27
- fillRule="evenodd"
28
- clipRule="evenodd"
29
- d="m39.0625 14h-30.0625v20.0938h30.0625zm-30.0625-2c-1.10457 0-2 .8954-2 2v20.0938c0 1.1045.89543 2 2 2h30.0625c1.1046 0 2-.8955 2-2v-20.0938c0-1.1046-.8954-2-2-2z"
30
- />
26
+ <Path d="M0 10a2 2 0 0 1 2-2h44a2 2 0 0 1 2 2v28a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V10Z" />
31
27
  </SVG>
32
28
  ),
33
29
  innerBlocks: [ [ 'core/column' ] ],
@@ -39,16 +35,12 @@ const variations = [
39
35
  description: __( 'Two columns; equal split' ),
40
36
  icon: (
41
37
  <SVG
38
+ xmlns="http://www.w3.org/2000/svg"
42
39
  width="48"
43
40
  height="48"
44
41
  viewBox="0 0 48 48"
45
- xmlns="http://www.w3.org/2000/svg"
46
42
  >
47
- <Path
48
- fillRule="evenodd"
49
- clipRule="evenodd"
50
- d="M39 12C40.1046 12 41 12.8954 41 14V34C41 35.1046 40.1046 36 39 36H9C7.89543 36 7 35.1046 7 34V14C7 12.8954 7.89543 12 9 12H39ZM39 34V14H25V34H39ZM23 34H9V14H23V34Z"
51
- />
43
+ <Path d="M0 10a2 2 0 0 1 2-2h19a2 2 0 0 1 2 2v28a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V10Zm25 0a2 2 0 0 1 2-2h19a2 2 0 0 1 2 2v28a2 2 0 0 1-2 2H27a2 2 0 0 1-2-2V10Z" />
52
44
  </SVG>
53
45
  ),
54
46
  isDefault: true,
@@ -61,16 +53,12 @@ const variations = [
61
53
  description: __( 'Two columns; one-third, two-thirds split' ),
62
54
  icon: (
63
55
  <SVG
56
+ xmlns="http://www.w3.org/2000/svg"
64
57
  width="48"
65
58
  height="48"
66
59
  viewBox="0 0 48 48"
67
- xmlns="http://www.w3.org/2000/svg"
68
60
  >
69
- <Path
70
- fillRule="evenodd"
71
- clipRule="evenodd"
72
- d="M39 12C40.1046 12 41 12.8954 41 14V34C41 35.1046 40.1046 36 39 36H9C7.89543 36 7 35.1046 7 34V14C7 12.8954 7.89543 12 9 12H39ZM39 34V14H20V34H39ZM18 34H9V14H18V34Z"
73
- />
61
+ <Path d="M0 10a2 2 0 0 1 2-2h11a2 2 0 0 1 2 2v28a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V10Zm17 0a2 2 0 0 1 2-2h27a2 2 0 0 1 2 2v28a2 2 0 0 1-2 2H19a2 2 0 0 1-2-2V10Z" />
74
62
  </SVG>
75
63
  ),
76
64
  innerBlocks: [
@@ -85,16 +73,12 @@ const variations = [
85
73
  description: __( 'Two columns; two-thirds, one-third split' ),
86
74
  icon: (
87
75
  <SVG
76
+ xmlns="http://www.w3.org/2000/svg"
88
77
  width="48"
89
78
  height="48"
90
79
  viewBox="0 0 48 48"
91
- xmlns="http://www.w3.org/2000/svg"
92
80
  >
93
- <Path
94
- fillRule="evenodd"
95
- clipRule="evenodd"
96
- d="M39 12C40.1046 12 41 12.8954 41 14V34C41 35.1046 40.1046 36 39 36H9C7.89543 36 7 35.1046 7 34V14C7 12.8954 7.89543 12 9 12H39ZM39 34V14H30V34H39ZM28 34H9V14H28V34Z"
97
- />
81
+ <Path d="M0 10a2 2 0 0 1 2-2h27a2 2 0 0 1 2 2v28a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V10Zm33 0a2 2 0 0 1 2-2h11a2 2 0 0 1 2 2v28a2 2 0 0 1-2 2H35a2 2 0 0 1-2-2V10Z" />
98
82
  </SVG>
99
83
  ),
100
84
  innerBlocks: [
@@ -109,15 +93,12 @@ const variations = [
109
93
  description: __( 'Three columns; equal split' ),
110
94
  icon: (
111
95
  <SVG
96
+ xmlns="http://www.w3.org/2000/svg"
112
97
  width="48"
113
98
  height="48"
114
99
  viewBox="0 0 48 48"
115
- xmlns="http://www.w3.org/2000/svg"
116
100
  >
117
- <Path
118
- fillRule="evenodd"
119
- d="M41 14a2 2 0 0 0-2-2H9a2 2 0 0 0-2 2v20a2 2 0 0 0 2 2h30a2 2 0 0 0 2-2V14zM28.5 34h-9V14h9v20zm2 0V14H39v20h-8.5zm-13 0H9V14h8.5v20z"
120
- />
101
+ <Path d="M0 10a2 2 0 0 1 2-2h10.531c1.105 0 1.969.895 1.969 2v28c0 1.105-.864 2-1.969 2H2a2 2 0 0 1-2-2V10Zm16.5 0c0-1.105.864-2 1.969-2H29.53c1.105 0 1.969.895 1.969 2v28c0 1.105-.864 2-1.969 2H18.47c-1.105 0-1.969-.895-1.969-2V10Zm17 0c0-1.105.864-2 1.969-2H46a2 2 0 0 1 2 2v28a2 2 0 0 1-2 2H35.469c-1.105 0-1.969-.895-1.969-2V10Z" />
121
102
  </SVG>
122
103
  ),
123
104
  innerBlocks: [
@@ -133,15 +114,12 @@ const variations = [
133
114
  description: __( 'Three columns; wide center column' ),
134
115
  icon: (
135
116
  <SVG
117
+ xmlns="http://www.w3.org/2000/svg"
136
118
  width="48"
137
119
  height="48"
138
120
  viewBox="0 0 48 48"
139
- xmlns="http://www.w3.org/2000/svg"
140
121
  >
141
- <Path
142
- fillRule="evenodd"
143
- d="M41 14a2 2 0 0 0-2-2H9a2 2 0 0 0-2 2v20a2 2 0 0 0 2 2h30a2 2 0 0 0 2-2V14zM31 34H17V14h14v20zm2 0V14h6v20h-6zm-18 0H9V14h6v20z"
144
- />
122
+ <Path d="M0 10a2 2 0 0 1 2-2h7.531c1.105 0 1.969.895 1.969 2v28c0 1.105-.864 2-1.969 2H2a2 2 0 0 1-2-2V10Zm13.5 0c0-1.105.864-2 1.969-2H32.53c1.105 0 1.969.895 1.969 2v28c0 1.105-.864 2-1.969 2H15.47c-1.105 0-1.969-.895-1.969-2V10Zm23 0c0-1.105.864-2 1.969-2H46a2 2 0 0 1 2 2v28a2 2 0 0 1-2 2h-7.531c-1.105 0-1.969-.895-1.969-2V10Z" />
145
123
  </SVG>
146
124
  ),
147
125
  innerBlocks: [
@@ -30,7 +30,9 @@
30
30
  export const convertToTree = ( data ) => {
31
31
  const table = {};
32
32
 
33
- if ( ! data ) return [];
33
+ if ( ! data ) {
34
+ return [];
35
+ }
34
36
 
35
37
  // First create a hash table of { [id]: { ...comment, children: [] }}
36
38
  data.forEach( ( item ) => {
@@ -103,7 +103,9 @@ export function getPositionClassName( contentPosition ) {
103
103
  /*
104
104
  * Only render a className if the contentPosition is not center (the default).
105
105
  */
106
- if ( isContentPositionCenter( contentPosition ) ) return '';
106
+ if ( isContentPositionCenter( contentPosition ) ) {
107
+ return '';
108
+ }
107
109
 
108
110
  return POSITION_CLASSNAMES[ contentPosition ];
109
111
  }
@@ -19,8 +19,6 @@
19
19
  }
20
20
 
21
21
  .wp-block-embed__learn-more {
22
- margin-top: 1em;
23
-
24
22
  @at-root .wp-block-post-content & {
25
23
  a {
26
24
  color: var(--wp-admin-theme-color);
@@ -2,7 +2,13 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { __, _x } from '@wordpress/i18n';
5
- import { Button, Placeholder, ExternalLink } from '@wordpress/components';
5
+ import {
6
+ Button,
7
+ Placeholder,
8
+ ExternalLink,
9
+ __experimentalHStack as HStack,
10
+ __experimentalVStack as VStack,
11
+ } from '@wordpress/components';
6
12
  import { BlockIcon } from '@wordpress/block-editor';
7
13
 
8
14
  const EmbedPlaceholder = ( {
@@ -47,17 +53,23 @@ const EmbedPlaceholder = ( {
47
53
  </ExternalLink>
48
54
  </div>
49
55
  { cannotEmbed && (
50
- <div className="components-placeholder__error">
56
+ <VStack spacing={ 3 } className="components-placeholder__error">
51
57
  <div className="components-placeholder__instructions">
52
58
  { __( 'Sorry, this content could not be embedded.' ) }
53
59
  </div>
54
- <Button variant="secondary" onClick={ tryAgain }>
55
- { _x( 'Try again', 'button label' ) }
56
- </Button>{ ' ' }
57
- <Button variant="secondary" onClick={ fallback }>
58
- { _x( 'Convert to link', 'button label' ) }
59
- </Button>
60
- </div>
60
+ <HStack
61
+ expanded={ false }
62
+ spacing={ 3 }
63
+ justify="flex-start"
64
+ >
65
+ <Button variant="secondary" onClick={ tryAgain }>
66
+ { _x( 'Try again', 'button label' ) }
67
+ </Button>{ ' ' }
68
+ <Button variant="secondary" onClick={ fallback }>
69
+ { _x( 'Convert to link', 'button label' ) }
70
+ </Button>
71
+ </HStack>
72
+ </VStack>
61
73
  ) }
62
74
  </Placeholder>
63
75
  );
package/src/embed/util.js CHANGED
@@ -97,7 +97,9 @@ export const createUpgradedEmbedBlock = (
97
97
  const { preview, attributes = {} } = props;
98
98
  const { url, providerNameSlug, type, ...restAttributes } = attributes;
99
99
 
100
- if ( ! url || ! getBlockType( DEFAULT_EMBED_BLOCK ) ) return;
100
+ if ( ! url || ! getBlockType( DEFAULT_EMBED_BLOCK ) ) {
101
+ return;
102
+ }
101
103
 
102
104
  const matchedBlock = findMoreSuitableBlock( url );
103
105