@wordpress/block-library 7.0.0 → 7.0.2

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 (230) hide show
  1. package/README.md +16 -0
  2. package/build/button/edit.native.js +2 -2
  3. package/build/button/edit.native.js.map +1 -1
  4. package/build/columns/index.js +12 -0
  5. package/build/columns/index.js.map +1 -1
  6. package/build/comment-author-avatar/edit.js +17 -4
  7. package/build/comment-author-avatar/edit.js.map +1 -1
  8. package/build/comment-template/edit.js +94 -36
  9. package/build/comment-template/edit.js.map +1 -1
  10. package/build/comment-template/hooks.js +175 -0
  11. package/build/comment-template/hooks.js.map +1 -0
  12. package/build/comment-template/index.js +1 -1
  13. package/build/comment-template/util.js.map +1 -1
  14. package/build/comments-pagination-next/index.js +1 -1
  15. package/build/comments-pagination-numbers/index.js +1 -1
  16. package/build/comments-query-loop/edit/comments-inspector-controls.js +20 -9
  17. package/build/comments-query-loop/edit/comments-inspector-controls.js.map +1 -1
  18. package/build/comments-query-loop/edit.js +1 -19
  19. package/build/comments-query-loop/edit.js.map +1 -1
  20. package/build/comments-query-loop/index.js +5 -0
  21. package/build/comments-query-loop/index.js.map +1 -1
  22. package/build/cover/edit.js +21 -22
  23. package/build/cover/edit.js.map +1 -1
  24. package/build/cover/edit.native.js +7 -5
  25. package/build/cover/edit.native.js.map +1 -1
  26. package/build/cover/overlay-color-settings.native.js +4 -3
  27. package/build/cover/overlay-color-settings.native.js.map +1 -1
  28. package/build/cover/transforms.js +4 -2
  29. package/build/cover/transforms.js.map +1 -1
  30. package/build/group/index.js +1 -0
  31. package/build/group/index.js.map +1 -1
  32. package/build/heading/edit.js +14 -2
  33. package/build/heading/edit.js.map +1 -1
  34. package/build/image/deprecated.js +89 -5
  35. package/build/image/deprecated.js.map +1 -1
  36. package/build/image/save.js +0 -7
  37. package/build/image/save.js.map +1 -1
  38. package/build/latest-posts/edit.js +1 -0
  39. package/build/latest-posts/edit.js.map +1 -1
  40. package/build/navigation/edit/index.js +17 -15
  41. package/build/navigation/edit/index.js.map +1 -1
  42. package/build/navigation/edit/navigation-menu-selector.js +44 -27
  43. package/build/navigation/edit/navigation-menu-selector.js.map +1 -1
  44. package/build/navigation/edit/placeholder/index.js +8 -22
  45. package/build/navigation/edit/placeholder/index.js.map +1 -1
  46. package/build/navigation/use-navigation-menu.js +6 -6
  47. package/build/navigation/use-navigation-menu.js.map +1 -1
  48. package/build/navigation-submenu/edit.js +41 -9
  49. package/build/navigation-submenu/edit.js.map +1 -1
  50. package/build/page-list/edit.js +11 -17
  51. package/build/page-list/edit.js.map +1 -1
  52. package/build/social-links/deprecated.js +1 -62
  53. package/build/social-links/deprecated.js.map +1 -1
  54. package/build/template-part/edit/index.js +36 -64
  55. package/build/template-part/edit/index.js.map +1 -1
  56. package/build/template-part/edit/placeholder.js +64 -0
  57. package/build/template-part/edit/placeholder.js.map +1 -0
  58. package/build/template-part/edit/selection-modal.js +103 -0
  59. package/build/template-part/edit/selection-modal.js.map +1 -0
  60. package/build/template-part/edit/title-modal.js +54 -0
  61. package/build/template-part/edit/title-modal.js.map +1 -0
  62. package/build/template-part/edit/utils/hooks.js +156 -0
  63. package/build/template-part/edit/utils/hooks.js.map +1 -0
  64. package/build/template-part/index.js +3 -1
  65. package/build/template-part/index.js.map +1 -1
  66. package/build-module/button/edit.native.js +4 -4
  67. package/build-module/button/edit.native.js.map +1 -1
  68. package/build-module/columns/index.js +12 -0
  69. package/build-module/columns/index.js.map +1 -1
  70. package/build-module/comment-author-avatar/edit.js +18 -6
  71. package/build-module/comment-author-avatar/edit.js.map +1 -1
  72. package/build-module/comment-template/edit.js +95 -37
  73. package/build-module/comment-template/edit.js.map +1 -1
  74. package/build-module/comment-template/hooks.js +156 -0
  75. package/build-module/comment-template/hooks.js.map +1 -0
  76. package/build-module/comment-template/index.js +1 -1
  77. package/build-module/comment-template/util.js.map +1 -1
  78. package/build-module/comments-pagination-next/index.js +1 -1
  79. package/build-module/comments-pagination-numbers/index.js +1 -1
  80. package/build-module/comments-query-loop/edit/comments-inspector-controls.js +20 -9
  81. package/build-module/comments-query-loop/edit/comments-inspector-controls.js.map +1 -1
  82. package/build-module/comments-query-loop/edit.js +2 -19
  83. package/build-module/comments-query-loop/edit.js.map +1 -1
  84. package/build-module/comments-query-loop/index.js +5 -0
  85. package/build-module/comments-query-loop/index.js.map +1 -1
  86. package/build-module/cover/edit.js +23 -24
  87. package/build-module/cover/edit.js.map +1 -1
  88. package/build-module/cover/edit.native.js +10 -8
  89. package/build-module/cover/edit.native.js.map +1 -1
  90. package/build-module/cover/overlay-color-settings.native.js +4 -4
  91. package/build-module/cover/overlay-color-settings.native.js.map +1 -1
  92. package/build-module/cover/transforms.js +4 -2
  93. package/build-module/cover/transforms.js.map +1 -1
  94. package/build-module/group/index.js +1 -0
  95. package/build-module/group/index.js.map +1 -1
  96. package/build-module/heading/edit.js +15 -3
  97. package/build-module/heading/edit.js.map +1 -1
  98. package/build-module/image/deprecated.js +90 -7
  99. package/build-module/image/deprecated.js.map +1 -1
  100. package/build-module/image/save.js +0 -7
  101. package/build-module/image/save.js.map +1 -1
  102. package/build-module/latest-posts/edit.js +1 -0
  103. package/build-module/latest-posts/edit.js.map +1 -1
  104. package/build-module/navigation/edit/index.js +17 -15
  105. package/build-module/navigation/edit/index.js.map +1 -1
  106. package/build-module/navigation/edit/navigation-menu-selector.js +45 -27
  107. package/build-module/navigation/edit/navigation-menu-selector.js.map +1 -1
  108. package/build-module/navigation/edit/placeholder/index.js +8 -21
  109. package/build-module/navigation/edit/placeholder/index.js.map +1 -1
  110. package/build-module/navigation/use-navigation-menu.js +6 -6
  111. package/build-module/navigation/use-navigation-menu.js.map +1 -1
  112. package/build-module/navigation-submenu/edit.js +41 -10
  113. package/build-module/navigation-submenu/edit.js.map +1 -1
  114. package/build-module/page-list/edit.js +12 -18
  115. package/build-module/page-list/edit.js.map +1 -1
  116. package/build-module/social-links/deprecated.js +1 -62
  117. package/build-module/social-links/deprecated.js.map +1 -1
  118. package/build-module/template-part/edit/index.js +37 -65
  119. package/build-module/template-part/edit/index.js.map +1 -1
  120. package/build-module/template-part/edit/placeholder.js +52 -0
  121. package/build-module/template-part/edit/placeholder.js.map +1 -0
  122. package/build-module/template-part/edit/selection-modal.js +89 -0
  123. package/build-module/template-part/edit/selection-modal.js.map +1 -0
  124. package/build-module/template-part/edit/title-modal.js +46 -0
  125. package/build-module/template-part/edit/title-modal.js.map +1 -0
  126. package/build-module/template-part/edit/utils/hooks.js +135 -0
  127. package/build-module/template-part/edit/utils/hooks.js.map +1 -0
  128. package/build-module/template-part/index.js +2 -1
  129. package/build-module/template-part/index.js.map +1 -1
  130. package/build-style/comment-author-avatar/editor-rtl.css +83 -0
  131. package/build-style/comment-author-avatar/editor.css +83 -0
  132. package/build-style/cover/style-rtl.css +4 -0
  133. package/build-style/cover/style.css +4 -0
  134. package/build-style/editor-rtl.css +27 -81
  135. package/build-style/editor.css +27 -81
  136. package/build-style/image/editor-rtl.css +0 -16
  137. package/build-style/image/editor.css +0 -16
  138. package/build-style/image/style-rtl.css +2 -0
  139. package/build-style/image/style.css +2 -0
  140. package/build-style/navigation/style-rtl.css +14 -3
  141. package/build-style/navigation/style.css +14 -3
  142. package/build-style/page-list/editor-rtl.css +0 -9
  143. package/build-style/page-list/editor.css +0 -9
  144. package/build-style/style-rtl.css +20 -3
  145. package/build-style/style.css +20 -3
  146. package/build-style/template-part/editor-rtl.css +19 -56
  147. package/build-style/template-part/editor.css +19 -56
  148. package/package.json +15 -15
  149. package/src/archives/index.php +1 -1
  150. package/src/button/edit.native.js +3 -3
  151. package/src/columns/block.json +12 -0
  152. package/src/comment-author-avatar/edit.js +13 -8
  153. package/src/comment-author-avatar/editor.scss +7 -0
  154. package/src/comment-template/block.json +7 -1
  155. package/src/comment-template/edit.js +102 -40
  156. package/src/comment-template/hooks.js +151 -0
  157. package/src/comment-template/index.php +8 -0
  158. package/src/comment-template/util.js +1 -0
  159. package/src/comments-pagination-next/block.json +8 -1
  160. package/src/comments-pagination-next/index.php +6 -8
  161. package/src/comments-pagination-numbers/block.json +7 -1
  162. package/src/comments-pagination-numbers/index.php +3 -10
  163. package/src/comments-query-loop/block.json +5 -0
  164. package/src/comments-query-loop/edit/comments-inspector-controls.js +22 -4
  165. package/src/comments-query-loop/edit.js +1 -16
  166. package/src/cover/edit.js +15 -28
  167. package/src/cover/edit.native.js +15 -7
  168. package/src/cover/overlay-color-settings.native.js +3 -4
  169. package/src/cover/style.scss +4 -0
  170. package/src/cover/transforms.js +2 -0
  171. package/src/editor.scss +1 -0
  172. package/src/gallery/index.php +1 -8
  173. package/src/group/block.json +1 -0
  174. package/src/heading/edit.js +18 -5
  175. package/src/home-link/index.php +1 -19
  176. package/src/image/deprecated.js +105 -1
  177. package/src/image/editor.scss +0 -18
  178. package/src/image/save.js +0 -8
  179. package/src/image/style.scss +3 -0
  180. package/src/image/test/edit.native.js +0 -10
  181. package/src/latest-posts/edit.js +1 -0
  182. package/src/latest-posts/index.php +1 -1
  183. package/src/navigation/edit/index.js +25 -26
  184. package/src/navigation/edit/navigation-menu-selector.js +73 -28
  185. package/src/navigation/edit/placeholder/index.js +8 -32
  186. package/src/navigation/index.php +4 -4
  187. package/src/navigation/style.scss +22 -3
  188. package/src/navigation/use-navigation-menu.js +6 -6
  189. package/src/navigation-link/index.php +3 -22
  190. package/src/navigation-submenu/edit.js +50 -12
  191. package/src/navigation-submenu/index.php +3 -21
  192. package/src/page-list/edit.js +21 -25
  193. package/src/page-list/editor.scss +0 -10
  194. package/src/page-list/index.php +4 -4
  195. package/src/post-navigation-link/index.php +3 -3
  196. package/src/search/index.php +6 -3
  197. package/src/site-logo/index.php +1 -1
  198. package/src/social-links/deprecated.js +0 -59
  199. package/src/template-part/edit/index.js +61 -71
  200. package/src/template-part/edit/placeholder.js +78 -0
  201. package/src/template-part/edit/selection-modal.js +115 -0
  202. package/src/template-part/edit/title-modal.js +59 -0
  203. package/src/template-part/edit/utils/hooks.js +158 -0
  204. package/src/template-part/editor.scss +16 -74
  205. package/src/template-part/index.js +4 -1
  206. package/build/navigation/edit/existing-menus-options.js +0 -62
  207. package/build/navigation/edit/existing-menus-options.js.map +0 -1
  208. package/build/template-part/edit/placeholder/index.js +0 -141
  209. package/build/template-part/edit/placeholder/index.js.map +0 -1
  210. package/build/template-part/edit/placeholder/patterns-setup.js +0 -100
  211. package/build/template-part/edit/placeholder/patterns-setup.js.map +0 -1
  212. package/build/template-part/edit/selection/index.js +0 -45
  213. package/build/template-part/edit/selection/index.js.map +0 -1
  214. package/build/template-part/edit/selection/template-part-previews.js +0 -317
  215. package/build/template-part/edit/selection/template-part-previews.js.map +0 -1
  216. package/build-module/navigation/edit/existing-menus-options.js +0 -53
  217. package/build-module/navigation/edit/existing-menus-options.js.map +0 -1
  218. package/build-module/template-part/edit/placeholder/index.js +0 -124
  219. package/build-module/template-part/edit/placeholder/index.js.map +0 -1
  220. package/build-module/template-part/edit/placeholder/patterns-setup.js +0 -91
  221. package/build-module/template-part/edit/placeholder/patterns-setup.js.map +0 -1
  222. package/build-module/template-part/edit/selection/index.js +0 -35
  223. package/build-module/template-part/edit/selection/index.js.map +0 -1
  224. package/build-module/template-part/edit/selection/template-part-previews.js +0 -298
  225. package/build-module/template-part/edit/selection/template-part-previews.js.map +0 -1
  226. package/src/navigation/edit/existing-menus-options.js +0 -70
  227. package/src/template-part/edit/placeholder/index.js +0 -172
  228. package/src/template-part/edit/placeholder/patterns-setup.js +0 -124
  229. package/src/template-part/edit/selection/index.js +0 -37
  230. package/src/template-part/edit/selection/template-part-previews.js +0 -372
package/src/cover/edit.js CHANGED
@@ -27,7 +27,7 @@ import {
27
27
  __experimentalBoxControl as BoxControl,
28
28
  __experimentalToolsPanelItem as ToolsPanelItem,
29
29
  } from '@wordpress/components';
30
- import { compose, withInstanceId, useInstanceId } from '@wordpress/compose';
30
+ import { compose, useInstanceId } from '@wordpress/compose';
31
31
  import {
32
32
  BlockControls,
33
33
  BlockIcon,
@@ -47,7 +47,7 @@ import {
47
47
  store as blockEditorStore,
48
48
  } from '@wordpress/block-editor';
49
49
  import { __ } from '@wordpress/i18n';
50
- import { withDispatch, useSelect } from '@wordpress/data';
50
+ import { useSelect, useDispatch } from '@wordpress/data';
51
51
  import { cover as icon } from '@wordpress/icons';
52
52
  import { isBlobURL } from '@wordpress/blob';
53
53
 
@@ -310,7 +310,6 @@ function CoverEdit( {
310
310
  setAttributes,
311
311
  setOverlayColor,
312
312
  toggleSelection,
313
- markNextChangeAsNotPersistent,
314
313
  } ) {
315
314
  const {
316
315
  contentPosition,
@@ -329,6 +328,9 @@ function CoverEdit( {
329
328
  allowedBlocks,
330
329
  templateLock,
331
330
  } = attributes;
331
+ const { __unstableMarkNextChangeAsNotPersistent } = useDispatch(
332
+ blockEditorStore
333
+ );
332
334
  const {
333
335
  gradientClass,
334
336
  gradientValue,
@@ -393,15 +395,13 @@ function CoverEdit( {
393
395
 
394
396
  useEffect( () => {
395
397
  // This side-effect should not create an undo level.
396
- markNextChangeAsNotPersistent();
398
+ __unstableMarkNextChangeAsNotPersistent();
397
399
  setAttributes( { isDark: isCoverDark } );
398
400
  }, [ isCoverDark ] );
399
401
 
400
402
  const isImageBackground = IMAGE_BACKGROUND_TYPE === backgroundType;
401
403
  const isVideoBackground = VIDEO_BACKGROUND_TYPE === backgroundType;
402
404
 
403
- const [ temporaryMinHeight, setTemporaryMinHeight ] = useState( null );
404
-
405
405
  const minHeightWithUnit = minHeightUnit
406
406
  ? `${ minHeight }${ minHeightUnit }`
407
407
  : minHeight;
@@ -412,7 +412,7 @@ function CoverEdit( {
412
412
  ...( isImageBackground && ! isImgElement
413
413
  ? backgroundImageStyles( url )
414
414
  : undefined ),
415
- minHeight: temporaryMinHeight || minHeightWithUnit || undefined,
415
+ minHeight: minHeightWithUnit || undefined,
416
416
  };
417
417
 
418
418
  const bgStyle = { backgroundColor: overlayColor.color };
@@ -593,7 +593,7 @@ function CoverEdit( {
593
593
  panelId={ clientId }
594
594
  >
595
595
  <CoverHeightInput
596
- value={ temporaryMinHeight || minHeight }
596
+ value={ minHeight }
597
597
  unit={ minHeightUnit }
598
598
  onChange={ ( newMinHeight ) =>
599
599
  setAttributes( { minHeight: newMinHeight } )
@@ -646,10 +646,7 @@ function CoverEdit( {
646
646
  onSelectMedia={ onSelectMedia }
647
647
  noticeOperations={ noticeOperations }
648
648
  style={ {
649
- minHeight:
650
- temporaryMinHeight ||
651
- minHeightWithUnit ||
652
- undefined,
649
+ minHeight: minHeightWithUnit || undefined,
653
650
  } }
654
651
  >
655
652
  <div className="wp-block-cover__placeholder-background-options">
@@ -667,11 +664,12 @@ function CoverEdit( {
667
664
  setAttributes( { minHeightUnit: 'px' } );
668
665
  toggleSelection( false );
669
666
  } }
670
- onResize={ setTemporaryMinHeight }
667
+ onResize={ ( value ) => {
668
+ setAttributes( { minHeight: value } );
669
+ } }
671
670
  onResizeStop={ ( newMinHeight ) => {
672
671
  toggleSelection( true );
673
672
  setAttributes( { minHeight: newMinHeight } );
674
- setTemporaryMinHeight( null );
675
673
  } }
676
674
  showHandle={ isSelected }
677
675
  />
@@ -714,11 +712,12 @@ function CoverEdit( {
714
712
  setAttributes( { minHeightUnit: 'px' } );
715
713
  toggleSelection( false );
716
714
  } }
717
- onResize={ setTemporaryMinHeight }
715
+ onResize={ ( value ) => {
716
+ setAttributes( { minHeight: value } );
717
+ } }
718
718
  onResizeStop={ ( newMinHeight ) => {
719
719
  toggleSelection( true );
720
720
  setAttributes( { minHeight: newMinHeight } );
721
- setTemporaryMinHeight( null );
722
721
  } }
723
722
  showHandle={ isSelected }
724
723
  />
@@ -777,18 +776,6 @@ function CoverEdit( {
777
776
  }
778
777
 
779
778
  export default compose( [
780
- withDispatch( ( dispatch ) => {
781
- const {
782
- toggleSelection,
783
- __unstableMarkNextChangeAsNotPersistent,
784
- } = dispatch( blockEditorStore );
785
-
786
- return {
787
- toggleSelection,
788
- markNextChangeAsNotPersistent: __unstableMarkNextChangeAsNotPersistent,
789
- };
790
- } ),
791
779
  withColors( { overlayColor: 'background-color' } ),
792
780
  withNotices,
793
- withInstanceId,
794
781
  ] )( CoverEdit );
@@ -31,6 +31,7 @@ import {
31
31
  ColorPicker,
32
32
  BottomSheetConsumer,
33
33
  useConvertUnitToMobile,
34
+ useMobileGlobalStylesColors,
34
35
  } from '@wordpress/components';
35
36
  import {
36
37
  BlockControls,
@@ -43,12 +44,17 @@ import {
43
44
  getColorObjectByColorValue,
44
45
  getColorObjectByAttributeValues,
45
46
  getGradientValueBySlug,
46
- useSetting,
47
47
  store as blockEditorStore,
48
48
  } from '@wordpress/block-editor';
49
49
  import { compose, withPreferredColorScheme } from '@wordpress/compose';
50
50
  import { withSelect, withDispatch } from '@wordpress/data';
51
- import { useEffect, useState, useRef, useCallback } from '@wordpress/element';
51
+ import {
52
+ useEffect,
53
+ useState,
54
+ useRef,
55
+ useCallback,
56
+ useMemo,
57
+ } from '@wordpress/element';
52
58
  import { cover as icon, replace, image, warning } from '@wordpress/icons';
53
59
  import { getProtocol } from '@wordpress/url';
54
60
  import { store as editPostStore } from '@wordpress/edit-post';
@@ -142,11 +148,13 @@ const Cover = ( {
142
148
  const isImage = backgroundType === MEDIA_TYPE_IMAGE;
143
149
 
144
150
  const THEME_COLORS_COUNT = 4;
145
- const colorsDefault = useSetting( 'color.palette' ) || [];
146
- const coverDefaultPalette = {
147
- colors: colorsDefault.slice( 0, THEME_COLORS_COUNT ),
148
- };
149
- const gradients = useSetting( 'color.gradients' ) || [];
151
+ const colorsDefault = useMobileGlobalStylesColors();
152
+ const coverDefaultPalette = useMemo( () => {
153
+ return {
154
+ colors: colorsDefault.slice( 0, THEME_COLORS_COUNT ),
155
+ };
156
+ }, [ colorsDefault ] );
157
+ const gradients = useMobileGlobalStylesColors( 'gradients' );
150
158
  const gradientValue =
151
159
  customGradient || getGradientValueBySlug( gradients, gradient );
152
160
  const overlayColorValue = getColorObjectByAttributeValues(
@@ -12,9 +12,9 @@ import {
12
12
  getGradientValueBySlug,
13
13
  getGradientSlugByValue,
14
14
  __experimentalPanelColorGradientSettings as PanelColorGradientSettings,
15
- useSetting,
16
15
  } from '@wordpress/block-editor';
17
16
  import { useMemo } from '@wordpress/element';
17
+ import { useMobileGlobalStylesColors } from '@wordpress/components';
18
18
 
19
19
  function OverlayColorSettings( {
20
20
  overlayColor,
@@ -23,9 +23,8 @@ function OverlayColorSettings( {
23
23
  customGradient,
24
24
  setAttributes,
25
25
  } ) {
26
- const EMPTY_ARRAY = [];
27
- const colors = useSetting( 'color.palette' ) || EMPTY_ARRAY;
28
- const gradients = useSetting( 'color.gradients' ) || EMPTY_ARRAY;
26
+ const colors = useMobileGlobalStylesColors();
27
+ const gradients = useMobileGlobalStylesColors( 'gradients' );
29
28
 
30
29
  const gradientValue =
31
30
  customGradient || getGradientValueBySlug( gradients, gradient );
@@ -50,6 +50,10 @@
50
50
  background-color: $black;
51
51
  }
52
52
 
53
+ .has-background-dim.has-background-gradient {
54
+ background-color: transparent;
55
+ }
56
+
53
57
  // the first selector is required for old Cover markup
54
58
  &.has-background-dim::before,
55
59
  .has-background-dim::before {
@@ -33,6 +33,7 @@ const transforms = {
33
33
  createBlock( 'core/paragraph', {
34
34
  content: caption,
35
35
  fontSize: 'large',
36
+ align: 'center',
36
37
  } ),
37
38
  ]
38
39
  ),
@@ -55,6 +56,7 @@ const transforms = {
55
56
  createBlock( 'core/paragraph', {
56
57
  content: caption,
57
58
  fontSize: 'large',
59
+ align: 'center',
58
60
  } ),
59
61
  ]
60
62
  ),
package/src/editor.scss CHANGED
@@ -5,6 +5,7 @@
5
5
  @import "./buttons/editor.scss";
6
6
  @import "./categories/editor.scss";
7
7
  @import "./columns/editor.scss";
8
+ @import "./comment-author-avatar/editor.scss";
8
9
  @import "./comments-query-loop/editor.scss";
9
10
  @import "./comments-pagination/editor.scss";
10
11
  @import "./comments-pagination-numbers/editor.scss";
@@ -34,17 +34,10 @@ add_filter( 'render_block_data', 'block_core_gallery_data_id_backcompatibility'
34
34
 
35
35
  /**
36
36
  * Registers the `core/gallery` block on server.
37
- * This render callback needs to be here
38
- * so that the gallery styles are loaded in block-based themes.
39
37
  */
40
38
  function register_block_core_gallery() {
41
39
  register_block_type_from_metadata(
42
- __DIR__ . '/gallery',
43
- array(
44
- 'render_callback' => function ( $attributes, $content ) {
45
- return $content;
46
- },
47
- )
40
+ __DIR__ . '/gallery'
48
41
  );
49
42
  }
50
43
 
@@ -30,6 +30,7 @@
30
30
  }
31
31
  },
32
32
  "spacing": {
33
+ "margin": [ "top", "bottom" ],
33
34
  "padding": true,
34
35
  "blockGap": true,
35
36
  "__experimentalDefaultControls": {
@@ -8,7 +8,7 @@ import classnames from 'classnames';
8
8
  */
9
9
  import { __ } from '@wordpress/i18n';
10
10
  import { useEffect, Platform } from '@wordpress/element';
11
- import { useDispatch } from '@wordpress/data';
11
+ import { useDispatch, useSelect } from '@wordpress/data';
12
12
  import { createBlock, getDefaultBlockName } from '@wordpress/blocks';
13
13
  import {
14
14
  AlignmentControl,
@@ -41,6 +41,14 @@ function HeadingEdit( {
41
41
  style,
42
42
  } );
43
43
 
44
+ const { canGenerateAnchors } = useSelect( ( select ) => {
45
+ const settings = select( blockEditorStore ).getSettings();
46
+
47
+ return {
48
+ canGenerateAnchors: !! settings.__experimentalGenerateAnchors,
49
+ };
50
+ }, [] );
51
+
44
52
  const { __unstableMarkNextChangeAsNotPersistent } = useDispatch(
45
53
  blockEditorStore
46
54
  );
@@ -48,6 +56,10 @@ function HeadingEdit( {
48
56
  // Initially set anchor for headings that have content but no anchor set.
49
57
  // This is used when transforming a block to heading, or for legacy anchors.
50
58
  useEffect( () => {
59
+ if ( ! canGenerateAnchors ) {
60
+ return;
61
+ }
62
+
51
63
  if ( ! anchor && content ) {
52
64
  // This side-effect should not create an undo level.
53
65
  __unstableMarkNextChangeAsNotPersistent();
@@ -59,14 +71,15 @@ function HeadingEdit( {
59
71
 
60
72
  // Remove anchor map when block unmounts.
61
73
  return () => setAnchor( clientId, null );
62
- }, [ content, anchor ] );
74
+ }, [ anchor, content, clientId, canGenerateAnchors ] );
63
75
 
64
76
  const onContentChange = ( value ) => {
65
77
  const newAttrs = { content: value };
66
78
  if (
67
- ! anchor ||
68
- ! value ||
69
- generateAnchor( clientId, content ) === anchor
79
+ canGenerateAnchors &&
80
+ ( ! anchor ||
81
+ ! value ||
82
+ generateAnchor( clientId, content ) === anchor )
70
83
  ) {
71
84
  newAttrs.anchor = generateAnchor( clientId, value );
72
85
  }
@@ -138,25 +138,7 @@ function render_block_core_home_link( $attributes, $content, $block ) {
138
138
  $html .= '>';
139
139
 
140
140
  if ( isset( $attributes['label'] ) ) {
141
- $html .= wp_kses(
142
- $attributes['label'],
143
- array(
144
- 'code' => array(),
145
- 'em' => array(),
146
- 'img' => array(
147
- 'scale' => array(),
148
- 'class' => array(),
149
- 'style' => array(),
150
- 'src' => array(),
151
- 'alt' => array(),
152
- ),
153
- 's' => array(),
154
- 'span' => array(
155
- 'style' => array(),
156
- ),
157
- 'strong' => array(),
158
- )
159
- );
141
+ $html .= wp_kses_post( $attributes['label'] );
160
142
  }
161
143
 
162
144
  $html .= '</a></li>';
@@ -2,11 +2,12 @@
2
2
  * External dependencies
3
3
  */
4
4
  import classnames from 'classnames';
5
+ import { isEmpty } from 'lodash';
5
6
 
6
7
  /**
7
8
  * WordPress dependencies
8
9
  */
9
- import { RichText } from '@wordpress/block-editor';
10
+ import { RichText, useBlockProps } from '@wordpress/block-editor';
10
11
 
11
12
  const blockAttributes = {
12
13
  align: {
@@ -68,7 +69,110 @@ const blockAttributes = {
68
69
  },
69
70
  };
70
71
 
72
+ const blockSupports = {
73
+ anchor: true,
74
+ color: {
75
+ __experimentalDuotone: 'img',
76
+ text: false,
77
+ background: false,
78
+ },
79
+ __experimentalBorder: {
80
+ radius: true,
81
+ __experimentalDefaultControls: {
82
+ radius: true,
83
+ },
84
+ },
85
+ };
86
+
71
87
  const deprecated = [
88
+ {
89
+ attributes: {
90
+ ...blockAttributes,
91
+ title: {
92
+ type: 'string',
93
+ source: 'attribute',
94
+ selector: 'img',
95
+ attribute: 'title',
96
+ },
97
+ sizeSlug: {
98
+ type: 'string',
99
+ },
100
+ },
101
+ supports: blockSupports,
102
+ save( { attributes } ) {
103
+ const {
104
+ url,
105
+ alt,
106
+ caption,
107
+ align,
108
+ href,
109
+ rel,
110
+ linkClass,
111
+ width,
112
+ height,
113
+ id,
114
+ linkTarget,
115
+ sizeSlug,
116
+ title,
117
+ } = attributes;
118
+
119
+ const newRel = isEmpty( rel ) ? undefined : rel;
120
+
121
+ const classes = classnames( {
122
+ [ `align${ align }` ]: align,
123
+ [ `size-${ sizeSlug }` ]: sizeSlug,
124
+ 'is-resized': width || height,
125
+ } );
126
+
127
+ const image = (
128
+ <img
129
+ src={ url }
130
+ alt={ alt }
131
+ className={ id ? `wp-image-${ id }` : null }
132
+ width={ width }
133
+ height={ height }
134
+ title={ title }
135
+ />
136
+ );
137
+
138
+ const figure = (
139
+ <>
140
+ { href ? (
141
+ <a
142
+ className={ linkClass }
143
+ href={ href }
144
+ target={ linkTarget }
145
+ rel={ newRel }
146
+ >
147
+ { image }
148
+ </a>
149
+ ) : (
150
+ image
151
+ ) }
152
+ { ! RichText.isEmpty( caption ) && (
153
+ <RichText.Content
154
+ tagName="figcaption"
155
+ value={ caption }
156
+ />
157
+ ) }
158
+ </>
159
+ );
160
+
161
+ if ( 'left' === align || 'right' === align || 'center' === align ) {
162
+ return (
163
+ <div { ...useBlockProps.save() }>
164
+ <figure className={ classes }>{ figure }</figure>
165
+ </div>
166
+ );
167
+ }
168
+
169
+ return (
170
+ <figure { ...useBlockProps.save( { className: classes } ) }>
171
+ { figure }
172
+ </figure>
173
+ );
174
+ },
175
+ },
72
176
  {
73
177
  attributes: blockAttributes,
74
178
  save( { attributes } ) {
@@ -70,24 +70,6 @@ figure.wp-block-image:not(.wp-block) {
70
70
  }
71
71
  }
72
72
 
73
- *:not([data-align]) {
74
- > .wp-block-image {
75
- display: grid;
76
- grid-template-columns: [image] minmax(0, max-content) [placeholder] auto;
77
- .components-placeholder {
78
- grid-column: placeholder;
79
- }
80
- > div:not(.components-placeholder) {
81
- grid-column: image;
82
- }
83
- > figcaption {
84
- grid-column: image;
85
- display: table-caption;
86
- caption-side: bottom;
87
- }
88
- }
89
- }
90
-
91
73
  .wp-block[data-align="left"] > .wp-block-image {
92
74
  margin-right: 1em;
93
75
  margin-left: 0;
package/src/image/save.js CHANGED
@@ -65,14 +65,6 @@ export default function save( { attributes } ) {
65
65
  </>
66
66
  );
67
67
 
68
- if ( 'left' === align || 'right' === align || 'center' === align ) {
69
- return (
70
- <div { ...useBlockProps.save() }>
71
- <figure className={ classes }>{ figure }</figure>
72
- </div>
73
- );
74
- }
75
-
76
68
  return (
77
69
  <figure { ...useBlockProps.save( { className: classes } ) }>
78
70
  { figure }
@@ -22,6 +22,9 @@
22
22
  width: 100%;
23
23
  }
24
24
 
25
+ &.alignleft,
26
+ &.alignright,
27
+ &.aligncenter,
25
28
  .alignleft,
26
29
  .alignright,
27
30
  .aligncenter {
@@ -15,7 +15,6 @@ import Clipboard from '@react-native-clipboard/clipboard';
15
15
  * WordPress dependencies
16
16
  */
17
17
  import { getBlockTypes, unregisterBlockType } from '@wordpress/blocks';
18
- import { apiFetch } from '@wordpress/data-controls';
19
18
  import {
20
19
  setFeaturedImage,
21
20
  sendMediaUpload,
@@ -40,14 +39,6 @@ sendMediaUpload.mockImplementation( ( payload ) => {
40
39
  uploadCallBack( payload );
41
40
  } );
42
41
 
43
- jest.mock( '@wordpress/data-controls', () => {
44
- const dataControls = jest.requireActual( '@wordpress/data-controls' );
45
- return {
46
- ...dataControls,
47
- apiFetch: jest.fn(),
48
- };
49
- } );
50
-
51
42
  /**
52
43
  * Immediately invoke delayed functions. A better alternative would be using
53
44
  * fake timers and test the delay itself. However, fake timers does not work
@@ -59,7 +50,6 @@ jest.mock( 'lodash', () => {
59
50
  } );
60
51
 
61
52
  const apiFetchPromise = Promise.resolve( {} );
62
- apiFetch.mockImplementation( () => apiFetchPromise );
63
53
 
64
54
  const clipboardPromise = Promise.resolve( '' );
65
55
  Clipboard.getString.mockImplementation( () => clipboardPromise );
@@ -480,6 +480,7 @@ export default function LatestPostsEdit( { attributes, setAttributes } ) {
480
480
  <div className={ imageClasses }>
481
481
  { addLinkToFeaturedImage ? (
482
482
  <a
483
+ className="wp-block-latest-posts__post-title"
483
484
  href={ post.link }
484
485
  rel="noreferrer noopener"
485
486
  >
@@ -105,7 +105,7 @@ function render_block_core_latest_posts( $attributes ) {
105
105
  }
106
106
 
107
107
  $list_items_markup .= sprintf(
108
- '<a href="%1$s">%2$s</a>',
108
+ '<a class="wp-block-latest-posts__post-title" href="%1$s">%2$s</a>',
109
109
  esc_url( $post_link ),
110
110
  $title
111
111
  );
@@ -223,12 +223,12 @@ function Navigation( {
223
223
  hasResolvedNavigationMenus,
224
224
  navigationMenus,
225
225
  navigationMenu,
226
- canUserUpdateNavigationEntity,
227
- hasResolvedCanUserUpdateNavigationEntity,
228
- canUserDeleteNavigationEntity,
229
- hasResolvedCanUserDeleteNavigationEntity,
230
- canUserCreateNavigation,
231
- hasResolvedCanUserCreateNavigation,
226
+ canUserUpdateNavigationMenu,
227
+ hasResolvedCanUserUpdateNavigationMenu,
228
+ canUserDeleteNavigationMenu,
229
+ hasResolvedCanUserDeleteNavigationMenu,
230
+ canUserCreateNavigationMenu,
231
+ hasResolvedCanUserCreateNavigationMenu,
232
232
  } = useNavigationMenu( ref );
233
233
 
234
234
  const navRef = useRef();
@@ -361,16 +361,16 @@ function Navigation( {
361
361
 
362
362
  if ( isSelected || isInnerBlockSelected ) {
363
363
  if (
364
- hasResolvedCanUserUpdateNavigationEntity &&
365
- ! canUserUpdateNavigationEntity
364
+ hasResolvedCanUserUpdateNavigationMenu &&
365
+ ! canUserUpdateNavigationMenu
366
366
  ) {
367
367
  showCantEditNotice();
368
368
  }
369
369
 
370
370
  if (
371
371
  ! ref &&
372
- hasResolvedCanUserCreateNavigation &&
373
- ! canUserCreateNavigation
372
+ hasResolvedCanUserCreateNavigationMenu &&
373
+ ! canUserCreateNavigationMenu
374
374
  ) {
375
375
  showCantCreateNotice();
376
376
  }
@@ -378,10 +378,10 @@ function Navigation( {
378
378
  }, [
379
379
  isSelected,
380
380
  isInnerBlockSelected,
381
- canUserUpdateNavigationEntity,
382
- hasResolvedCanUserUpdateNavigationEntity,
383
- canUserCreateNavigation,
384
- hasResolvedCanUserCreateNavigation,
381
+ canUserUpdateNavigationMenu,
382
+ hasResolvedCanUserUpdateNavigationMenu,
383
+ canUserCreateNavigationMenu,
384
+ hasResolvedCanUserCreateNavigationMenu,
385
385
  ref,
386
386
  ] );
387
387
 
@@ -496,12 +496,9 @@ function Navigation( {
496
496
  onClose();
497
497
  } }
498
498
  onCreateNew={ startWithEmptyMenu }
499
- canUserCreateNavigation={
500
- canUserCreateNavigation
501
- }
502
- canUserSwitchNavigation={
503
- canSwitchNavigationMenu
504
- }
499
+ /* translators: %s: The name of a menu. */
500
+ actionLabel={ __( "Switch to '%s'" ) }
501
+ showManageActions
505
502
  />
506
503
  ) }
507
504
  </ToolbarDropdownMenu>
@@ -648,12 +645,12 @@ function Navigation( {
648
645
  </InspectorControls>
649
646
  { isEntityAvailable && (
650
647
  <InspectorControls __experimentalGroup="advanced">
651
- { hasResolvedCanUserUpdateNavigationEntity &&
652
- canUserUpdateNavigationEntity && (
648
+ { hasResolvedCanUserUpdateNavigationMenu &&
649
+ canUserUpdateNavigationMenu && (
653
650
  <NavigationMenuNameControl />
654
651
  ) }
655
- { hasResolvedCanUserDeleteNavigationEntity &&
656
- canUserDeleteNavigationEntity && (
652
+ { hasResolvedCanUserDeleteNavigationMenu &&
653
+ canUserDeleteNavigationMenu && (
657
654
  <NavigationMenuDeleteControl
658
655
  onDelete={ startWithEmptyMenu }
659
656
  />
@@ -675,10 +672,12 @@ function Navigation( {
675
672
  hasResolvedNavigationMenus
676
673
  }
677
674
  clientId={ clientId }
678
- canUserCreateNavigation={ canUserCreateNavigation }
675
+ canUserCreateNavigationMenu={
676
+ canUserCreateNavigationMenu
677
+ }
679
678
  />
680
679
  ) }
681
- { ! hasResolvedCanUserCreateNavigation ||
680
+ { ! hasResolvedCanUserCreateNavigationMenu ||
682
681
  ( ! isEntityAvailable && ! isPlaceholderShown && (
683
682
  <PlaceholderPreview isLoading />
684
683
  ) ) }