@wordpress/block-library 7.17.0 → 7.18.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 (233) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/audio/edit.js +44 -4
  3. package/build/audio/edit.js.map +1 -1
  4. package/build/button/edit.js +1 -1
  5. package/build/button/edit.js.map +1 -1
  6. package/build/buttons/edit.native.js +1 -1
  7. package/build/buttons/edit.native.js.map +1 -1
  8. package/build/comment-template/index.js +6 -2
  9. package/build/comment-template/index.js.map +1 -1
  10. package/build/cover/edit/inspector-controls.js +3 -7
  11. package/build/cover/edit/inspector-controls.js.map +1 -1
  12. package/build/embed/deprecated.js +43 -4
  13. package/build/embed/deprecated.js.map +1 -1
  14. package/build/file/deprecated.js +108 -4
  15. package/build/file/deprecated.js.map +1 -1
  16. package/build/file/transforms.js +3 -9
  17. package/build/file/transforms.js.map +1 -1
  18. package/build/gallery/deprecated.js +148 -23
  19. package/build/gallery/deprecated.js.map +1 -1
  20. package/build/gallery/gallery.js +3 -2
  21. package/build/gallery/gallery.js.map +1 -1
  22. package/build/gallery/use-image-sizes.js +2 -1
  23. package/build/gallery/use-image-sizes.js.map +1 -1
  24. package/build/gallery/v1/edit.js +2 -1
  25. package/build/gallery/v1/edit.js.map +1 -1
  26. package/build/group/edit.js +7 -3
  27. package/build/group/edit.js.map +1 -1
  28. package/build/image/edit.native.js +1 -1
  29. package/build/image/edit.native.js.map +1 -1
  30. package/build/image/image.js +6 -9
  31. package/build/image/image.js.map +1 -1
  32. package/build/latest-posts/edit.js +1 -1
  33. package/build/latest-posts/edit.js.map +1 -1
  34. package/build/list/utils.js +4 -8
  35. package/build/list/utils.js.map +1 -1
  36. package/build/list-item/hooks/use-outdent-list-item.js +5 -7
  37. package/build/list-item/hooks/use-outdent-list-item.js.map +1 -1
  38. package/build/navigation/edit/index.js +12 -11
  39. package/build/navigation/edit/index.js.map +1 -1
  40. package/build/navigation/edit/unsaved-inner-blocks.js +3 -1
  41. package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  42. package/build/navigation-link/edit.js +4 -2
  43. package/build/navigation-link/edit.js.map +1 -1
  44. package/build/navigation-submenu/edit.js +4 -4
  45. package/build/navigation-submenu/edit.js.map +1 -1
  46. package/build/page-list/edit.js +29 -10
  47. package/build/page-list/edit.js.map +1 -1
  48. package/build/post-comments-count/index.js +4 -0
  49. package/build/post-comments-count/index.js.map +1 -1
  50. package/build/post-comments-form/index.js +4 -0
  51. package/build/post-comments-form/index.js.map +1 -1
  52. package/build/post-comments-link/index.js +4 -0
  53. package/build/post-comments-link/index.js.map +1 -1
  54. package/build/post-content/edit.js +14 -6
  55. package/build/post-content/edit.js.map +1 -1
  56. package/build/pullquote/deprecated.js +6 -6
  57. package/build/pullquote/deprecated.js.map +1 -1
  58. package/build/search/edit.js +1 -3
  59. package/build/search/edit.js.map +1 -1
  60. package/build/site-logo/edit.js +1 -1
  61. package/build/site-logo/edit.js.map +1 -1
  62. package/build/site-tagline/edit.js +21 -9
  63. package/build/site-tagline/edit.js.map +1 -1
  64. package/build/site-title/edit/index.js +20 -8
  65. package/build/site-title/edit/index.js.map +1 -1
  66. package/build/social-link/edit.js +11 -2
  67. package/build/social-link/edit.js.map +1 -1
  68. package/build/social-link/index.js +3 -0
  69. package/build/social-link/index.js.map +1 -1
  70. package/build/spacer/controls.js +3 -7
  71. package/build/spacer/controls.js.map +1 -1
  72. package/build/table/deprecated.js +282 -27
  73. package/build/table/deprecated.js.map +1 -1
  74. package/build/table/state.js +1 -1
  75. package/build/table/state.js.map +1 -1
  76. package/build/utils/clean-empty-object.js +5 -4
  77. package/build/utils/clean-empty-object.js.map +1 -1
  78. package/build/video/deprecated.js +159 -0
  79. package/build/video/deprecated.js.map +1 -0
  80. package/build/video/edit.js +41 -5
  81. package/build/video/edit.js.map +1 -1
  82. package/build/video/index.js +3 -0
  83. package/build/video/index.js.map +1 -1
  84. package/build/video/tracks-editor.js +3 -28
  85. package/build/video/tracks-editor.js.map +1 -1
  86. package/build-module/audio/edit.js +46 -7
  87. package/build-module/audio/edit.js.map +1 -1
  88. package/build-module/button/edit.js +1 -1
  89. package/build-module/button/edit.js.map +1 -1
  90. package/build-module/buttons/edit.native.js +1 -1
  91. package/build-module/buttons/edit.native.js.map +1 -1
  92. package/build-module/comment-template/index.js +6 -2
  93. package/build-module/comment-template/index.js.map +1 -1
  94. package/build-module/cover/edit/inspector-controls.js +4 -8
  95. package/build-module/cover/edit/inspector-controls.js.map +1 -1
  96. package/build-module/embed/deprecated.js +44 -5
  97. package/build-module/embed/deprecated.js.map +1 -1
  98. package/build-module/file/deprecated.js +108 -4
  99. package/build-module/file/deprecated.js.map +1 -1
  100. package/build-module/file/transforms.js +3 -8
  101. package/build-module/file/transforms.js.map +1 -1
  102. package/build-module/gallery/deprecated.js +147 -25
  103. package/build-module/gallery/deprecated.js.map +1 -1
  104. package/build-module/gallery/gallery.js +3 -2
  105. package/build-module/gallery/gallery.js.map +1 -1
  106. package/build-module/gallery/use-image-sizes.js +3 -2
  107. package/build-module/gallery/use-image-sizes.js.map +1 -1
  108. package/build-module/gallery/v1/edit.js +3 -2
  109. package/build-module/gallery/v1/edit.js.map +1 -1
  110. package/build-module/group/edit.js +7 -3
  111. package/build-module/group/edit.js.map +1 -1
  112. package/build-module/image/edit.native.js +1 -1
  113. package/build-module/image/edit.native.js.map +1 -1
  114. package/build-module/image/image.js +8 -11
  115. package/build-module/image/image.js.map +1 -1
  116. package/build-module/latest-posts/edit.js +2 -2
  117. package/build-module/latest-posts/edit.js.map +1 -1
  118. package/build-module/list/utils.js +5 -9
  119. package/build-module/list/utils.js.map +1 -1
  120. package/build-module/list-item/hooks/use-outdent-list-item.js +5 -6
  121. package/build-module/list-item/hooks/use-outdent-list-item.js.map +1 -1
  122. package/build-module/navigation/edit/index.js +12 -11
  123. package/build-module/navigation/edit/index.js.map +1 -1
  124. package/build-module/navigation/edit/unsaved-inner-blocks.js +3 -1
  125. package/build-module/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  126. package/build-module/navigation-link/edit.js +4 -3
  127. package/build-module/navigation-link/edit.js.map +1 -1
  128. package/build-module/navigation-submenu/edit.js +4 -4
  129. package/build-module/navigation-submenu/edit.js.map +1 -1
  130. package/build-module/page-list/edit.js +29 -10
  131. package/build-module/page-list/edit.js.map +1 -1
  132. package/build-module/post-comments-count/index.js +4 -0
  133. package/build-module/post-comments-count/index.js.map +1 -1
  134. package/build-module/post-comments-form/index.js +4 -0
  135. package/build-module/post-comments-form/index.js.map +1 -1
  136. package/build-module/post-comments-link/index.js +4 -0
  137. package/build-module/post-comments-link/index.js.map +1 -1
  138. package/build-module/post-content/edit.js +14 -6
  139. package/build-module/post-content/edit.js.map +1 -1
  140. package/build-module/pullquote/deprecated.js +7 -7
  141. package/build-module/pullquote/deprecated.js.map +1 -1
  142. package/build-module/search/edit.js +1 -3
  143. package/build-module/search/edit.js.map +1 -1
  144. package/build-module/site-logo/edit.js +2 -2
  145. package/build-module/site-logo/edit.js.map +1 -1
  146. package/build-module/site-tagline/edit.js +23 -11
  147. package/build-module/site-tagline/edit.js.map +1 -1
  148. package/build-module/site-title/edit/index.js +22 -10
  149. package/build-module/site-title/edit/index.js.map +1 -1
  150. package/build-module/social-link/edit.js +11 -2
  151. package/build-module/social-link/edit.js.map +1 -1
  152. package/build-module/social-link/index.js +3 -0
  153. package/build-module/social-link/index.js.map +1 -1
  154. package/build-module/spacer/controls.js +4 -8
  155. package/build-module/spacer/controls.js.map +1 -1
  156. package/build-module/table/deprecated.js +282 -27
  157. package/build-module/table/deprecated.js.map +1 -1
  158. package/build-module/table/state.js +1 -1
  159. package/build-module/table/state.js.map +1 -1
  160. package/build-module/utils/clean-empty-object.js +5 -5
  161. package/build-module/utils/clean-empty-object.js.map +1 -1
  162. package/build-module/video/deprecated.js +147 -0
  163. package/build-module/video/deprecated.js.map +1 -0
  164. package/build-module/video/edit.js +45 -9
  165. package/build-module/video/edit.js.map +1 -1
  166. package/build-module/video/index.js +2 -0
  167. package/build-module/video/index.js.map +1 -1
  168. package/build-module/video/tracks-editor.js +4 -29
  169. package/build-module/video/tracks-editor.js.map +1 -1
  170. package/build-style/button/style-rtl.css +1 -0
  171. package/build-style/button/style.css +1 -0
  172. package/build-style/comment-template/style-rtl.css +1 -0
  173. package/build-style/comment-template/style.css +1 -0
  174. package/build-style/editor-rtl.css +4 -4
  175. package/build-style/editor.css +4 -4
  176. package/build-style/navigation/editor-rtl.css +4 -4
  177. package/build-style/navigation/editor.css +4 -4
  178. package/build-style/navigation/style-rtl.css +3 -1
  179. package/build-style/navigation/style.css +3 -1
  180. package/build-style/post-comments-form/style-rtl.css +3 -0
  181. package/build-style/post-comments-form/style.css +3 -0
  182. package/build-style/style-rtl.css +8 -1
  183. package/build-style/style.css +8 -1
  184. package/package.json +29 -28
  185. package/src/audio/edit.js +79 -24
  186. package/src/button/edit.js +1 -1
  187. package/src/button/style.scss +2 -0
  188. package/src/buttons/edit.native.js +1 -1
  189. package/src/comment-template/block.json +6 -2
  190. package/src/comment-template/style.scss +2 -0
  191. package/src/cover/edit/inspector-controls.js +11 -13
  192. package/src/embed/deprecated.js +53 -26
  193. package/src/file/deprecated.js +130 -2
  194. package/src/file/transforms.js +3 -8
  195. package/src/gallery/deprecated.js +129 -4
  196. package/src/gallery/gallery.js +2 -0
  197. package/src/gallery/index.php +19 -10
  198. package/src/gallery/use-image-sizes.js +3 -2
  199. package/src/gallery/v1/edit.js +3 -2
  200. package/src/group/edit.js +10 -2
  201. package/src/image/edit.native.js +1 -1
  202. package/src/image/image.js +22 -10
  203. package/src/latest-posts/edit.js +2 -2
  204. package/src/list/utils.js +3 -11
  205. package/src/list-item/hooks/use-outdent-list-item.js +3 -6
  206. package/src/navigation/edit/index.js +13 -15
  207. package/src/navigation/edit/unsaved-inner-blocks.js +9 -2
  208. package/src/navigation/editor.scss +4 -4
  209. package/src/navigation/style.scss +3 -1
  210. package/src/navigation-link/edit.js +5 -4
  211. package/src/navigation-submenu/edit.js +7 -5
  212. package/src/page-list/edit.js +36 -22
  213. package/src/post-comments-count/block.json +4 -0
  214. package/src/post-comments-form/block.json +4 -0
  215. package/src/post-comments-form/style.scss +3 -0
  216. package/src/post-comments-link/block.json +4 -0
  217. package/src/post-content/edit.js +8 -4
  218. package/src/pullquote/deprecated.js +7 -7
  219. package/src/search/edit.js +1 -1
  220. package/src/site-logo/edit.js +2 -2
  221. package/src/site-tagline/edit.js +25 -18
  222. package/src/site-title/edit/index.js +26 -12
  223. package/src/social-link/block.json +3 -0
  224. package/src/social-link/edit.js +8 -1
  225. package/src/social-link/index.php +11 -7
  226. package/src/spacer/controls.js +10 -12
  227. package/src/table/deprecated.js +587 -348
  228. package/src/table/state.js +1 -1
  229. package/src/utils/clean-empty-object.js +5 -6
  230. package/src/video/deprecated.js +57 -0
  231. package/src/video/edit.js +71 -23
  232. package/src/video/index.js +2 -0
  233. package/src/video/tracks-editor.js +12 -28
@@ -261,10 +261,6 @@ $color-control-label-height: 20px;
261
261
  }
262
262
  }
263
263
 
264
- .wp-block-navigation-placeholder .components-spinner {
265
- margin-top: 0;
266
- }
267
-
268
264
  // Unselected state.
269
265
  .wp-block-navigation-placeholder__preview {
270
266
  display: flex;
@@ -567,6 +563,10 @@ body.editor-styles-wrapper
567
563
  padding: $grid-unit-10 $grid-unit-15;
568
564
  }
569
565
 
566
+ .wp-block-navigation .wp-block-navigation__uncontrolled-inner-blocks-loading-indicator {
567
+ margin-top: 0;
568
+ }
569
+
570
570
  @keyframes fadeouthalf {
571
571
  0% {
572
572
  opacity: 1;
@@ -359,7 +359,9 @@ button.wp-block-navigation-item__content {
359
359
 
360
360
  // Provide a default padding for submenus who should always have some, regardless of the top level menu items.
361
361
  :where(.wp-block-navigation .wp-block-navigation__submenu-container .wp-block-navigation-item a:not(.wp-element-button)),
362
- :where(.wp-block-navigation .wp-block-navigation__submenu-container .wp-block-navigation-submenu a:not(.wp-element-button)) {
362
+ :where(.wp-block-navigation .wp-block-navigation__submenu-container .wp-block-navigation-submenu a:not(.wp-element-button)),
363
+ :where(.wp-block-navigation .wp-block-navigation__submenu-container .wp-block-navigation-submenu button.wp-block-navigation-item__content),
364
+ :where(.wp-block-navigation .wp-block-navigation__submenu-container .wp-block-pages-list__item button.wp-block-navigation-item__content) {
363
365
  padding: 0.5em 1em;
364
366
  }
365
367
 
@@ -2,7 +2,8 @@
2
2
  * External dependencies
3
3
  */
4
4
  import classnames from 'classnames';
5
- import { escape, unescape } from 'lodash';
5
+ import escapeHtml from 'escape-html';
6
+ import { unescape } from 'lodash';
6
7
 
7
8
  /**
8
9
  * WordPress dependencies
@@ -262,8 +263,8 @@ export const updateNavigationLinkBlockAttributes = (
262
263
  // - https://github.com/WordPress/gutenberg/pull/41063
263
264
  // - https://github.com/WordPress/gutenberg/pull/18617.
264
265
  const label = useNewLabel
265
- ? escape( newLabel )
266
- : originalLabel || escape( newUrlWithoutHttp );
266
+ ? escapeHtml( newLabel )
267
+ : originalLabel || escapeHtml( newUrlWithoutHttp );
267
268
 
268
269
  // In https://github.com/WordPress/gutenberg/pull/24670 we decided to use "tag" in favor of "post_tag"
269
270
  const type = newType === 'post_tag' ? 'tag' : newType.replace( '-', '_' );
@@ -846,7 +847,7 @@ export default function NavigationLinkEdit( {
846
847
  ) }
847
848
  { isLinkOpen && (
848
849
  <Popover
849
- position="bottom center"
850
+ placement="bottom"
850
851
  onClose={ () => setIsLinkOpen( false ) }
851
852
  anchor={ popoverAnchor }
852
853
  shift
@@ -2,7 +2,7 @@
2
2
  * External dependencies
3
3
  */
4
4
  import classnames from 'classnames';
5
- import { escape, without } from 'lodash';
5
+ import escapeHtml from 'escape-html';
6
6
 
7
7
  /**
8
8
  * WordPress dependencies
@@ -248,8 +248,8 @@ export const updateNavigationLinkBlockAttributes = (
248
248
  normalizedTitle !== normalizedURL &&
249
249
  originalLabel !== title;
250
250
  const label = escapeTitle
251
- ? escape( title )
252
- : originalLabel || escape( normalizedURL );
251
+ ? escapeHtml( title )
252
+ : originalLabel || escapeHtml( normalizedURL );
253
253
 
254
254
  // In https://github.com/WordPress/gutenberg/pull/24670 we decided to use "tag" in favor of "post_tag"
255
255
  const type = newType === 'post_tag' ? 'tag' : newType.replace( '-', '_' );
@@ -486,7 +486,9 @@ export default function NavigationSubmenuEdit( {
486
486
  const innerBlocksColors = getColors( context, true );
487
487
 
488
488
  const allowedBlocks = isAtMaxNesting
489
- ? without( ALLOWED_BLOCKS, 'core/navigation-submenu' )
489
+ ? ALLOWED_BLOCKS.filter(
490
+ ( blockName ) => blockName !== 'core/navigation-submenu'
491
+ )
490
492
  : ALLOWED_BLOCKS;
491
493
 
492
494
  const innerBlocksProps = useInnerBlocksProps(
@@ -631,7 +633,7 @@ export default function NavigationSubmenuEdit( {
631
633
  }
632
634
  { ! openSubmenusOnClick && isLinkOpen && (
633
635
  <Popover
634
- position="bottom center"
636
+ placement="bottom"
635
637
  onClose={ () => setIsLinkOpen( false ) }
636
638
  anchor={ popoverAnchor }
637
639
  shift
@@ -52,50 +52,64 @@ export default function PageListEdit( { context, clientId } ) {
52
52
  style: { ...context.style?.color },
53
53
  } );
54
54
 
55
- return (
56
- <>
57
- { allowConvertToLinks && (
58
- <BlockControls group="other">
59
- <ToolbarButton title={ __( 'Edit' ) } onClick={ openModal }>
60
- { __( 'Edit' ) }
61
- </ToolbarButton>
62
- </BlockControls>
63
- ) }
64
- { allowConvertToLinks && isOpen && (
65
- <ConvertToLinksModal
66
- onClose={ closeModal }
67
- clientId={ clientId }
68
- />
69
- ) }
70
- { ! hasResolvedPages && (
55
+ const getBlockContent = () => {
56
+ if ( ! hasResolvedPages ) {
57
+ return (
71
58
  <div { ...blockProps }>
72
59
  <Spinner />
73
60
  </div>
74
- ) }
61
+ );
62
+ }
75
63
 
76
- { hasResolvedPages && totalPages === null && (
64
+ if ( totalPages === null ) {
65
+ return (
77
66
  <div { ...blockProps }>
78
67
  <Notice status={ 'warning' } isDismissible={ false }>
79
68
  { __( 'Page List: Cannot retrieve Pages.' ) }
80
69
  </Notice>
81
70
  </div>
82
- ) }
71
+ );
72
+ }
83
73
 
84
- { totalPages === 0 && (
74
+ if ( totalPages === 0 ) {
75
+ return (
85
76
  <div { ...blockProps }>
86
77
  <Notice status={ 'info' } isDismissible={ false }>
87
78
  { __( 'Page List: Cannot retrieve Pages.' ) }
88
79
  </Notice>
89
80
  </div>
90
- ) }
91
- { totalPages > 0 && (
81
+ );
82
+ }
83
+
84
+ if ( totalPages > 0 ) {
85
+ return (
92
86
  <ul { ...blockProps }>
93
87
  <PageItems
94
88
  context={ context }
95
89
  pagesByParentId={ pagesByParentId }
96
90
  />
97
91
  </ul>
92
+ );
93
+ }
94
+ };
95
+
96
+ return (
97
+ <>
98
+ { allowConvertToLinks && (
99
+ <BlockControls group="other">
100
+ <ToolbarButton title={ __( 'Edit' ) } onClick={ openModal }>
101
+ { __( 'Edit' ) }
102
+ </ToolbarButton>
103
+ </BlockControls>
98
104
  ) }
105
+ { allowConvertToLinks && isOpen && (
106
+ <ConvertToLinksModal
107
+ onClose={ closeModal }
108
+ clientId={ clientId }
109
+ />
110
+ ) }
111
+
112
+ { getBlockContent() }
99
113
  </>
100
114
  );
101
115
  }
@@ -22,6 +22,10 @@
22
22
  "text": true
23
23
  }
24
24
  },
25
+ "spacing": {
26
+ "margin": true,
27
+ "padding": true
28
+ },
25
29
  "typography": {
26
30
  "fontSize": true,
27
31
  "lineHeight": true,
@@ -22,6 +22,10 @@
22
22
  "text": true
23
23
  }
24
24
  },
25
+ "spacing": {
26
+ "margin": true,
27
+ "padding": true
28
+ },
25
29
  "typography": {
26
30
  "fontSize": true,
27
31
  "lineHeight": true,
@@ -1,4 +1,7 @@
1
1
  .wp-block-post-comments-form {
2
+ // This block has customizable padding, border-box makes that more predictable.
3
+ box-sizing: border-box;
4
+
2
5
  &[style*="font-weight"] :where(.comment-reply-title) {
3
6
  font-weight: inherit;
4
7
  }
@@ -23,6 +23,10 @@
23
23
  "link": true
24
24
  }
25
25
  },
26
+ "spacing": {
27
+ "margin": true,
28
+ "padding": true
29
+ },
26
30
  "typography": {
27
31
  "fontSize": true,
28
32
  "lineHeight": true,
@@ -84,8 +84,8 @@ function Content( props ) {
84
84
  );
85
85
  }
86
86
 
87
- function Placeholder() {
88
- const blockProps = useBlockProps();
87
+ function Placeholder( { layoutClassNames } ) {
88
+ const blockProps = useBlockProps( { className: layoutClassNames } );
89
89
  return (
90
90
  <div { ...blockProps }>
91
91
  <p>
@@ -118,7 +118,11 @@ function RecursionError() {
118
118
  );
119
119
  }
120
120
 
121
- export default function PostContentEdit( { context, attributes } ) {
121
+ export default function PostContentEdit( {
122
+ context,
123
+ attributes,
124
+ __unstableLayoutClassNames: layoutClassNames,
125
+ } ) {
122
126
  const { postId: contextPostId, postType: contextPostType } = context;
123
127
  const { layout = {} } = attributes;
124
128
  const hasAlreadyRendered = useHasRecursion( contextPostId );
@@ -132,7 +136,7 @@ export default function PostContentEdit( { context, attributes } ) {
132
136
  { contextPostId && contextPostType ? (
133
137
  <Content context={ context } layout={ layout } />
134
138
  ) : (
135
- <Placeholder />
139
+ <Placeholder layoutClassNames={ layoutClassNames } />
136
140
  ) }
137
141
  </RecursionProvider>
138
142
  );
@@ -2,7 +2,7 @@
2
2
  * External dependencies
3
3
  */
4
4
  import classnames from 'classnames';
5
- import { get, includes } from 'lodash';
5
+ import { get } from 'lodash';
6
6
 
7
7
  /**
8
8
  * WordPress dependencies
@@ -140,7 +140,7 @@ const v4 = {
140
140
  className,
141
141
  } = attributes;
142
142
 
143
- const isSolidColorStyle = includes( className, SOLID_COLOR_CLASS );
143
+ const isSolidColorStyle = className?.includes( SOLID_COLOR_CLASS );
144
144
 
145
145
  let figureClasses, figureStyles;
146
146
 
@@ -206,7 +206,7 @@ const v4 = {
206
206
  customTextColor,
207
207
  ...attributes
208
208
  } ) {
209
- const isSolidColorStyle = includes( className, SOLID_COLOR_CLASS );
209
+ const isSolidColorStyle = className?.includes( SOLID_COLOR_CLASS );
210
210
  let style;
211
211
 
212
212
  if ( customMainColor ) {
@@ -270,7 +270,7 @@ const v3 = {
270
270
  figureStyle,
271
271
  } = attributes;
272
272
 
273
- const isSolidColorStyle = includes( className, SOLID_COLOR_CLASS );
273
+ const isSolidColorStyle = className?.includes( SOLID_COLOR_CLASS );
274
274
 
275
275
  let figureClasses, figureStyles;
276
276
 
@@ -345,7 +345,7 @@ const v3 = {
345
345
  customTextColor,
346
346
  ...attributes
347
347
  } ) {
348
- const isSolidColorStyle = includes( className, SOLID_COLOR_CLASS );
348
+ const isSolidColorStyle = className?.includes( SOLID_COLOR_CLASS );
349
349
  let style;
350
350
 
351
351
  if ( customMainColor ) {
@@ -416,7 +416,7 @@ const v2 = {
416
416
  citation,
417
417
  className,
418
418
  } = attributes;
419
- const isSolidColorStyle = includes( className, SOLID_COLOR_CLASS );
419
+ const isSolidColorStyle = className?.includes( SOLID_COLOR_CLASS );
420
420
 
421
421
  let figureClass, figureStyles;
422
422
  // Is solid color style
@@ -484,7 +484,7 @@ const v2 = {
484
484
  customTextColor,
485
485
  ...attributes
486
486
  } ) {
487
- const isSolidColorStyle = includes( className, SOLID_COLOR_CLASS );
487
+ const isSolidColorStyle = className?.includes( SOLID_COLOR_CLASS );
488
488
  let style = {};
489
489
 
490
490
  if ( customMainColor ) {
@@ -363,7 +363,7 @@ export default function SearchEdit( {
363
363
  widthUnit: newUnit,
364
364
  } );
365
365
  } }
366
- style={ { maxWidth: 80 } }
366
+ __unstableInputWidth={ '80px' }
367
367
  value={ `${ width }${ widthUnit }` }
368
368
  units={ units }
369
369
  />
@@ -2,7 +2,7 @@
2
2
  * External dependencies
3
3
  */
4
4
  import classnames from 'classnames';
5
- import { includes, pick } from 'lodash';
5
+ import { pick } from 'lodash';
6
6
 
7
7
  /**
8
8
  * WordPress dependencies
@@ -71,7 +71,7 @@ const SiteLogo = ( {
71
71
  } ) => {
72
72
  const clientWidth = useClientWidth( containerRef, [ align ] );
73
73
  const isLargeViewport = useViewportMatch( 'medium' );
74
- const isWideAligned = includes( [ 'wide', 'full' ], align );
74
+ const isWideAligned = [ 'wide', 'full' ].includes( align );
75
75
  const isResizable = ! isWideAligned && isLargeViewport;
76
76
  const [ { naturalWidth, naturalHeight }, setNaturalSize ] = useState( {} );
77
77
  const [ isEditingImage, setIsEditingImage ] = useState( false );
@@ -6,8 +6,8 @@ import classnames from 'classnames';
6
6
  /**
7
7
  * WordPress dependencies
8
8
  */
9
- import { useSelect } from '@wordpress/data';
10
- import { useEntityProp, store as coreStore } from '@wordpress/core-data';
9
+ import { useDispatch, useSelect } from '@wordpress/data';
10
+ import { store as coreStore } from '@wordpress/core-data';
11
11
  import {
12
12
  AlignmentControl,
13
13
  useBlockProps,
@@ -23,34 +23,43 @@ export default function SiteTaglineEdit( {
23
23
  insertBlocksAfter,
24
24
  } ) {
25
25
  const { textAlign } = attributes;
26
- const [ siteTagline, setSiteTagline ] = useEntityProp(
27
- 'root',
28
- 'site',
29
- 'description'
30
- );
31
- const { canUserEdit, readOnlySiteTagLine } = useSelect( ( select ) => {
32
- const { canUser, getEntityRecord } = select( coreStore );
33
- const siteData = getEntityRecord( 'root', '__unstableBase' );
26
+ const { canUserEdit, tagline } = useSelect( ( select ) => {
27
+ const { canUser, getEntityRecord, getEditedEntityRecord } =
28
+ select( coreStore );
29
+ const canEdit = canUser( 'update', 'settings' );
30
+ const settings = canEdit ? getEditedEntityRecord( 'root', 'site' ) : {};
31
+ const readOnlySettings = getEntityRecord( 'root', '__unstableBase' );
32
+
34
33
  return {
35
34
  canUserEdit: canUser( 'update', 'settings' ),
36
- readOnlySiteTagLine: siteData?.description,
35
+ tagline: canEdit
36
+ ? settings?.description
37
+ : readOnlySettings?.description,
37
38
  };
38
39
  }, [] );
40
+
41
+ const { editEntityRecord } = useDispatch( coreStore );
42
+
43
+ function setTagline( newTagline ) {
44
+ editEntityRecord( 'root', 'site', undefined, {
45
+ description: newTagline,
46
+ } );
47
+ }
48
+
39
49
  const blockProps = useBlockProps( {
40
50
  className: classnames( {
41
51
  [ `has-text-align-${ textAlign }` ]: textAlign,
42
- 'wp-block-site-tagline__placeholder':
43
- ! canUserEdit && ! readOnlySiteTagLine,
52
+ 'wp-block-site-tagline__placeholder': ! canUserEdit && ! tagline,
44
53
  } ),
45
54
  } );
46
55
  const siteTaglineContent = canUserEdit ? (
47
56
  <RichText
48
57
  allowedFormats={ [] }
49
- onChange={ setSiteTagline }
58
+ onChange={ setTagline }
50
59
  aria-label={ __( 'Site tagline text' ) }
51
60
  placeholder={ __( 'Write site tagline…' ) }
52
61
  tagName="p"
53
- value={ siteTagline }
62
+ value={ tagline }
54
63
  disableLineBreaks
55
64
  __unstableOnSplitAtEnd={ () =>
56
65
  insertBlocksAfter( createBlock( getDefaultBlockName() ) )
@@ -58,9 +67,7 @@ export default function SiteTaglineEdit( {
58
67
  { ...blockProps }
59
68
  />
60
69
  ) : (
61
- <p { ...blockProps }>
62
- { readOnlySiteTagLine || __( 'Site Tagline placeholder' ) }
63
- </p>
70
+ <p { ...blockProps }>{ tagline || __( 'Site Tagline placeholder' ) }</p>
64
71
  );
65
72
  return (
66
73
  <>
@@ -6,8 +6,8 @@ import classnames from 'classnames';
6
6
  /**
7
7
  * WordPress dependencies
8
8
  */
9
- import { useSelect } from '@wordpress/data';
10
- import { useEntityProp, store as coreStore } from '@wordpress/core-data';
9
+ import { useDispatch, useSelect } from '@wordpress/data';
10
+ import { store as coreStore } from '@wordpress/core-data';
11
11
  import { __ } from '@wordpress/i18n';
12
12
  import {
13
13
  RichText,
@@ -31,21 +31,31 @@ export default function SiteTitleEdit( {
31
31
  insertBlocksAfter,
32
32
  } ) {
33
33
  const { level, textAlign, isLink, linkTarget } = attributes;
34
- const [ title, setTitle ] = useEntityProp( 'root', 'site', 'title' );
35
- const { canUserEdit, readOnlyTitle } = useSelect( ( select ) => {
36
- const { canUser, getEntityRecord } = select( coreStore );
37
- const siteData = getEntityRecord( 'root', '__unstableBase' );
34
+ const { canUserEdit, title } = useSelect( ( select ) => {
35
+ const { canUser, getEntityRecord, getEditedEntityRecord } =
36
+ select( coreStore );
37
+ const canEdit = canUser( 'update', 'settings' );
38
+ const settings = canEdit ? getEditedEntityRecord( 'root', 'site' ) : {};
39
+ const readOnlySettings = getEntityRecord( 'root', '__unstableBase' );
40
+
38
41
  return {
39
- canUserEdit: canUser( 'update', 'settings' ),
40
- readOnlyTitle: decodeEntities( siteData?.name ),
42
+ canUserEdit: canEdit,
43
+ title: canEdit ? settings?.title : readOnlySettings?.name,
41
44
  };
42
45
  }, [] );
46
+ const { editEntityRecord } = useDispatch( coreStore );
47
+
48
+ function setTitle( newTitle ) {
49
+ editEntityRecord( 'root', 'site', undefined, {
50
+ title: newTitle,
51
+ } );
52
+ }
53
+
43
54
  const TagName = level === 0 ? 'p' : `h${ level }`;
44
55
  const blockProps = useBlockProps( {
45
56
  className: classnames( {
46
57
  [ `has-text-align-${ textAlign }` ]: textAlign,
47
- 'wp-block-site-title__placeholder':
48
- ! canUserEdit && ! readOnlyTitle,
58
+ 'wp-block-site-title__placeholder': ! canUserEdit && ! title,
49
59
  } ),
50
60
  } );
51
61
  const siteTitleContent = canUserEdit ? (
@@ -71,10 +81,14 @@ export default function SiteTitleEdit( {
71
81
  href="#site-title-pseudo-link"
72
82
  onClick={ ( event ) => event.preventDefault() }
73
83
  >
74
- { readOnlyTitle || __( 'Site Title placeholder' ) }
84
+ { decodeEntities( title ) ||
85
+ __( 'Site Title placeholder' ) }
75
86
  </a>
76
87
  ) : (
77
- <span>{ title || readOnlyTitle }</span>
88
+ <span>
89
+ { decodeEntities( title ) ||
90
+ __( 'Site Title placeholder' ) }
91
+ </span>
78
92
  ) }
79
93
  </TagName>
80
94
  );
@@ -16,6 +16,9 @@
16
16
  },
17
17
  "label": {
18
18
  "type": "string"
19
+ },
20
+ "rel": {
21
+ "type": "string"
19
22
  }
20
23
  },
21
24
  "usesContext": [
@@ -66,7 +66,7 @@ const SocialLinkEdit = ( {
66
66
  isSelected,
67
67
  setAttributes,
68
68
  } ) => {
69
- const { url, service, label } = attributes;
69
+ const { url, service, label, rel } = attributes;
70
70
  const { showLabels, iconColorValue, iconBackgroundColorValue } = context;
71
71
  const [ showURLPopover, setPopover ] = useState( false );
72
72
  const classes = classNames( 'wp-social-link', 'wp-social-link-' + service, {
@@ -113,6 +113,13 @@ const SocialLinkEdit = ( {
113
113
  </PanelRow>
114
114
  </PanelBody>
115
115
  </InspectorControls>
116
+ <InspectorControls __experimentalGroup="advanced">
117
+ <TextControl
118
+ label={ __( 'Link rel' ) }
119
+ value={ rel || '' }
120
+ onChange={ ( value ) => setAttributes( { rel: value } ) }
121
+ />
122
+ </InspectorControls>
116
123
  <li { ...blockProps }>
117
124
  <Button
118
125
  className="wp-block-social-link-anchor"
@@ -20,6 +20,7 @@ function render_block_core_social_link( $attributes, $content, $block ) {
20
20
  $service = ( isset( $attributes['service'] ) ) ? $attributes['service'] : 'Icon';
21
21
  $url = ( isset( $attributes['url'] ) ) ? $attributes['url'] : false;
22
22
  $label = ( isset( $attributes['label'] ) ) ? $attributes['label'] : block_core_social_link_get_name( $service );
23
+ $rel = ( isset( $attributes['rel'] ) ) ? $attributes['rel'] : '';
23
24
  $show_labels = array_key_exists( 'showLabels', $block->context ) ? $block->context['showLabels'] : false;
24
25
 
25
26
  // Don't render a link if there is no URL set.
@@ -43,11 +44,6 @@ function render_block_core_social_link( $attributes, $content, $block ) {
43
44
  $url = 'https://' . $url;
44
45
  }
45
46
 
46
- $rel_target_attributes = '';
47
- if ( $open_in_new_tab ) {
48
- $rel_target_attributes = 'rel="noopener nofollow" target="_blank"';
49
- }
50
-
51
47
  $icon = block_core_social_link_get_icon( $service );
52
48
  $wrapper_attributes = get_block_wrapper_attributes(
53
49
  array(
@@ -57,13 +53,21 @@ function render_block_core_social_link( $attributes, $content, $block ) {
57
53
  );
58
54
 
59
55
  $link = '<li ' . $wrapper_attributes . '>';
60
- $link .= '<a href="' . esc_url( $url ) . '" ' . $rel_target_attributes . ' class="wp-block-social-link-anchor">';
56
+ $link .= '<a href="' . esc_url( $url ) . '" class="wp-block-social-link-anchor">';
61
57
  $link .= $icon;
62
58
  $link .= '<span class="wp-block-social-link-label' . ( $show_labels ? '' : ' screen-reader-text' ) . '">';
63
59
  $link .= esc_html( $label );
64
60
  $link .= '</span></a></li>';
65
61
 
66
- return $link;
62
+ $w = new WP_HTML_Tag_Processor( $link );
63
+ $w->next_tag( 'a' );
64
+ if ( $open_in_new_tab ) {
65
+ $w->set_attribute( 'rel', esc_attr( $rel ) . ' noopener nofollow' );
66
+ $w->set_attribute( 'target', '_blank' );
67
+ } elseif ( '' !== $rel ) {
68
+ $w->set_attribute( 'rel', esc_attr( $rel ) );
69
+ }
70
+ return $w;
67
71
  }
68
72
 
69
73
  /**
@@ -4,7 +4,6 @@
4
4
  import { __ } from '@wordpress/i18n';
5
5
  import { InspectorControls, useSetting } from '@wordpress/block-editor';
6
6
  import {
7
- BaseControl,
8
7
  PanelBody,
9
8
  __experimentalUseCustomUnits as useCustomUnits,
10
9
  __experimentalUnitControl as UnitControl,
@@ -51,17 +50,16 @@ function DimensionInput( { label, onChange, isResizing, value = '' } ) {
51
50
  ].join( '' );
52
51
 
53
52
  return (
54
- <BaseControl label={ label } id={ inputId }>
55
- <UnitControl
56
- id={ inputId }
57
- isResetValueOnUnitChange
58
- min={ MIN_SPACER_SIZE }
59
- onChange={ handleOnChange }
60
- style={ { maxWidth: 80 } }
61
- value={ computedValue }
62
- units={ units }
63
- />
64
- </BaseControl>
53
+ <UnitControl
54
+ label={ label }
55
+ id={ inputId }
56
+ isResetValueOnUnitChange
57
+ min={ MIN_SPACER_SIZE }
58
+ onChange={ handleOnChange }
59
+ __unstableInputWidth={ '80px' }
60
+ value={ computedValue }
61
+ units={ units }
62
+ />
65
63
  );
66
64
  }
67
65