@wordpress/block-library 7.3.2 → 7.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (266) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/archives/edit.js +1 -1
  3. package/build/archives/edit.js.map +1 -1
  4. package/build/audio/edit.js +1 -1
  5. package/build/audio/edit.js.map +1 -1
  6. package/build/audio/edit.native.js +1 -1
  7. package/build/audio/edit.native.js.map +1 -1
  8. package/build/categories/edit.js +8 -3
  9. package/build/categories/edit.js.map +1 -1
  10. package/build/categories/index.js +4 -0
  11. package/build/categories/index.js.map +1 -1
  12. package/build/column/index.js +10 -0
  13. package/build/column/index.js.map +1 -1
  14. package/build/comment-template/hooks.js +11 -3
  15. package/build/comment-template/hooks.js.map +1 -1
  16. package/build/comments-pagination/edit.js +18 -1
  17. package/build/comments-pagination/edit.js.map +1 -1
  18. package/build/comments-query-loop/edit.js +1 -1
  19. package/build/comments-query-loop/edit.js.map +1 -1
  20. package/build/comments-title/edit.js +149 -0
  21. package/build/comments-title/edit.js.map +1 -0
  22. package/build/comments-title/index.js +101 -0
  23. package/build/comments-title/index.js.map +1 -0
  24. package/build/embed/edit.js +12 -18
  25. package/build/embed/edit.js.map +1 -1
  26. package/build/embed/edit.native.js +1 -7
  27. package/build/embed/edit.native.js.map +1 -1
  28. package/build/embed/util.js +29 -4
  29. package/build/embed/util.js.map +1 -1
  30. package/build/file/inspector.js +2 -4
  31. package/build/file/inspector.js.map +1 -1
  32. package/build/gallery/edit.js +1 -1
  33. package/build/gallery/edit.js.map +1 -1
  34. package/build/gallery/v1/edit.js +1 -1
  35. package/build/gallery/v1/edit.js.map +1 -1
  36. package/build/html/edit.js +2 -2
  37. package/build/html/edit.js.map +1 -1
  38. package/build/image/edit.js +4 -6
  39. package/build/image/edit.js.map +1 -1
  40. package/build/image/edit.native.js +1 -1
  41. package/build/image/edit.native.js.map +1 -1
  42. package/build/image/image.js +1 -1
  43. package/build/image/image.js.map +1 -1
  44. package/build/index.js +3 -1
  45. package/build/index.js.map +1 -1
  46. package/build/index.native.js +14 -3
  47. package/build/index.native.js.map +1 -1
  48. package/build/latest-comments/edit.js +1 -1
  49. package/build/latest-comments/edit.js.map +1 -1
  50. package/build/loginout/edit.js +1 -1
  51. package/build/loginout/edit.js.map +1 -1
  52. package/build/media-text/edit.js +1 -2
  53. package/build/media-text/edit.js.map +1 -1
  54. package/build/media-text/edit.native.js +1 -1
  55. package/build/media-text/edit.native.js.map +1 -1
  56. package/build/navigation/edit/index.js +17 -1
  57. package/build/navigation/edit/index.js.map +1 -1
  58. package/build/navigation/edit/navigation-menu-selector.js +7 -2
  59. package/build/navigation/edit/navigation-menu-selector.js.map +1 -1
  60. package/build/navigation/edit/unsaved-inner-blocks.js +5 -4
  61. package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  62. package/build/navigation/index.js +1 -1
  63. package/build/navigation/view-modal.js +37 -0
  64. package/build/navigation/view-modal.js.map +1 -0
  65. package/build/navigation/view.js +1 -34
  66. package/build/navigation/view.js.map +1 -1
  67. package/build/paragraph/edit.native.js +6 -2
  68. package/build/paragraph/edit.native.js.map +1 -1
  69. package/build/post-author/edit.js +1 -1
  70. package/build/post-author/edit.js.map +1 -1
  71. package/build/post-excerpt/edit.js +1 -1
  72. package/build/post-excerpt/edit.js.map +1 -1
  73. package/build/quote/index.js +6 -0
  74. package/build/quote/index.js.map +1 -1
  75. package/build/quote/v2/edit.js +11 -3
  76. package/build/quote/v2/edit.js.map +1 -1
  77. package/build/rss/edit.js +1 -1
  78. package/build/rss/edit.js.map +1 -1
  79. package/build/search/edit.js +11 -9
  80. package/build/search/edit.js.map +1 -1
  81. package/build/spacer/constants.js +9 -0
  82. package/build/spacer/constants.js.map +1 -0
  83. package/build/spacer/controls.js +3 -3
  84. package/build/spacer/controls.js.map +1 -1
  85. package/build/spacer/controls.native.js +2 -2
  86. package/build/spacer/controls.native.js.map +1 -1
  87. package/build/spacer/edit.js +5 -6
  88. package/build/spacer/edit.js.map +1 -1
  89. package/build/table/edit.js +8 -2
  90. package/build/table/edit.js.map +1 -1
  91. package/build/tag-cloud/edit.js +1 -1
  92. package/build/tag-cloud/edit.js.map +1 -1
  93. package/build/video/edit.js +1 -1
  94. package/build/video/edit.js.map +1 -1
  95. package/build/video/edit.native.js +1 -1
  96. package/build/video/edit.native.js.map +1 -1
  97. package/build-module/archives/edit.js +1 -1
  98. package/build-module/archives/edit.js.map +1 -1
  99. package/build-module/audio/edit.js +1 -1
  100. package/build-module/audio/edit.js.map +1 -1
  101. package/build-module/audio/edit.native.js +1 -1
  102. package/build-module/audio/edit.native.js.map +1 -1
  103. package/build-module/categories/edit.js +8 -3
  104. package/build-module/categories/edit.js.map +1 -1
  105. package/build-module/categories/index.js +4 -0
  106. package/build-module/categories/index.js.map +1 -1
  107. package/build-module/column/index.js +10 -0
  108. package/build-module/column/index.js.map +1 -1
  109. package/build-module/comment-template/hooks.js +11 -3
  110. package/build-module/comment-template/hooks.js.map +1 -1
  111. package/build-module/comments-pagination/edit.js +19 -2
  112. package/build-module/comments-pagination/edit.js.map +1 -1
  113. package/build-module/comments-query-loop/edit.js +1 -1
  114. package/build-module/comments-query-loop/edit.js.map +1 -1
  115. package/build-module/comments-title/edit.js +133 -0
  116. package/build-module/comments-title/edit.js.map +1 -0
  117. package/build-module/comments-title/index.js +88 -0
  118. package/build-module/comments-title/index.js.map +1 -0
  119. package/build-module/embed/edit.js +13 -19
  120. package/build-module/embed/edit.js.map +1 -1
  121. package/build-module/embed/edit.native.js +2 -8
  122. package/build-module/embed/edit.native.js.map +1 -1
  123. package/build-module/embed/util.js +25 -3
  124. package/build-module/embed/util.js.map +1 -1
  125. package/build-module/file/inspector.js +2 -4
  126. package/build-module/file/inspector.js.map +1 -1
  127. package/build-module/gallery/edit.js +1 -1
  128. package/build-module/gallery/edit.js.map +1 -1
  129. package/build-module/gallery/v1/edit.js +1 -1
  130. package/build-module/gallery/v1/edit.js.map +1 -1
  131. package/build-module/html/edit.js +2 -2
  132. package/build-module/html/edit.js.map +1 -1
  133. package/build-module/image/edit.js +4 -6
  134. package/build-module/image/edit.js.map +1 -1
  135. package/build-module/image/edit.native.js +1 -1
  136. package/build-module/image/edit.native.js.map +1 -1
  137. package/build-module/image/image.js +1 -1
  138. package/build-module/image/image.js.map +1 -1
  139. package/build-module/index.js +2 -1
  140. package/build-module/index.js.map +1 -1
  141. package/build-module/index.native.js +14 -3
  142. package/build-module/index.native.js.map +1 -1
  143. package/build-module/latest-comments/edit.js +1 -1
  144. package/build-module/latest-comments/edit.js.map +1 -1
  145. package/build-module/loginout/edit.js +1 -1
  146. package/build-module/loginout/edit.js.map +1 -1
  147. package/build-module/media-text/edit.js +1 -2
  148. package/build-module/media-text/edit.js.map +1 -1
  149. package/build-module/media-text/edit.native.js +1 -1
  150. package/build-module/media-text/edit.native.js.map +1 -1
  151. package/build-module/navigation/edit/index.js +17 -1
  152. package/build-module/navigation/edit/index.js.map +1 -1
  153. package/build-module/navigation/edit/navigation-menu-selector.js +6 -2
  154. package/build-module/navigation/edit/navigation-menu-selector.js.map +1 -1
  155. package/build-module/navigation/edit/unsaved-inner-blocks.js +5 -4
  156. package/build-module/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  157. package/build-module/navigation/index.js +1 -1
  158. package/build-module/navigation/view-modal.js +32 -0
  159. package/build-module/navigation/view-modal.js.map +1 -0
  160. package/build-module/navigation/view.js +1 -30
  161. package/build-module/navigation/view.js.map +1 -1
  162. package/build-module/paragraph/edit.native.js +6 -2
  163. package/build-module/paragraph/edit.native.js.map +1 -1
  164. package/build-module/post-author/edit.js +1 -1
  165. package/build-module/post-author/edit.js.map +1 -1
  166. package/build-module/post-excerpt/edit.js +1 -1
  167. package/build-module/post-excerpt/edit.js.map +1 -1
  168. package/build-module/quote/index.js +1 -1
  169. package/build-module/quote/index.js.map +1 -1
  170. package/build-module/quote/v2/edit.js +10 -3
  171. package/build-module/quote/v2/edit.js.map +1 -1
  172. package/build-module/rss/edit.js +1 -1
  173. package/build-module/rss/edit.js.map +1 -1
  174. package/build-module/search/edit.js +11 -9
  175. package/build-module/search/edit.js.map +1 -1
  176. package/build-module/spacer/constants.js +2 -0
  177. package/build-module/spacer/constants.js.map +1 -0
  178. package/build-module/spacer/controls.js +2 -2
  179. package/build-module/spacer/controls.js.map +1 -1
  180. package/build-module/spacer/controls.native.js +1 -1
  181. package/build-module/spacer/controls.native.js.map +1 -1
  182. package/build-module/spacer/edit.js +1 -1
  183. package/build-module/spacer/edit.js.map +1 -1
  184. package/build-module/table/edit.js +9 -3
  185. package/build-module/table/edit.js.map +1 -1
  186. package/build-module/tag-cloud/edit.js +1 -1
  187. package/build-module/tag-cloud/edit.js.map +1 -1
  188. package/build-module/video/edit.js +1 -1
  189. package/build-module/video/edit.js.map +1 -1
  190. package/build-module/video/edit.native.js +1 -1
  191. package/build-module/video/edit.native.js.map +1 -1
  192. package/build-style/comments-title/editor-rtl.css +79 -0
  193. package/build-style/comments-title/editor.css +79 -0
  194. package/build-style/common-rtl.css +32 -0
  195. package/build-style/common.css +32 -0
  196. package/build-style/editor-rtl.css +12 -0
  197. package/build-style/editor.css +12 -0
  198. package/build-style/post-comments-form/style-rtl.css +9 -0
  199. package/build-style/post-comments-form/style.css +9 -0
  200. package/build-style/style-rtl.css +79 -0
  201. package/build-style/style.css +79 -0
  202. package/build-style/table/editor-rtl.css +8 -0
  203. package/build-style/table/editor.css +8 -0
  204. package/build-style/table/style-rtl.css +38 -0
  205. package/build-style/table/style.css +38 -0
  206. package/package.json +28 -28
  207. package/src/archives/edit.js +1 -1
  208. package/src/audio/edit.js +1 -1
  209. package/src/audio/edit.native.js +1 -1
  210. package/src/categories/block.json +4 -0
  211. package/src/categories/edit.js +8 -2
  212. package/src/categories/index.php +1 -0
  213. package/src/column/block.json +10 -0
  214. package/src/comment-template/hooks.js +13 -1
  215. package/src/comment-template/index.php +13 -4
  216. package/src/comments-pagination/edit.js +23 -0
  217. package/src/comments-query-loop/edit.js +1 -0
  218. package/src/comments-title/block.json +70 -0
  219. package/src/comments-title/edit.js +197 -0
  220. package/src/comments-title/editor.scss +4 -0
  221. package/src/comments-title/index.js +18 -0
  222. package/src/comments-title/index.php +68 -0
  223. package/src/common.scss +24 -1
  224. package/src/editor.scss +1 -0
  225. package/src/embed/edit.js +19 -24
  226. package/src/embed/edit.native.js +9 -14
  227. package/src/embed/util.js +34 -2
  228. package/src/file/inspector.js +1 -3
  229. package/src/gallery/edit.js +1 -1
  230. package/src/gallery/v1/edit.js +1 -1
  231. package/src/html/edit.js +2 -2
  232. package/src/image/edit.js +2 -4
  233. package/src/image/edit.native.js +1 -1
  234. package/src/image/image.js +1 -1
  235. package/src/index.js +3 -0
  236. package/src/index.native.js +12 -2
  237. package/src/latest-comments/edit.js +1 -1
  238. package/src/loginout/edit.js +1 -1
  239. package/src/media-text/edit.js +1 -2
  240. package/src/media-text/edit.native.js +1 -1
  241. package/src/navigation/block.json +1 -1
  242. package/src/navigation/edit/index.js +24 -0
  243. package/src/navigation/edit/navigation-menu-selector.js +15 -9
  244. package/src/navigation/edit/unsaved-inner-blocks.js +5 -4
  245. package/src/navigation/index.php +5 -0
  246. package/src/navigation/view-modal.js +36 -0
  247. package/src/navigation/view.js +0 -35
  248. package/src/paragraph/edit.native.js +13 -1
  249. package/src/post-author/edit.js +1 -1
  250. package/src/post-comments-form/style.scss +11 -0
  251. package/src/post-excerpt/edit.js +1 -1
  252. package/src/quote/index.js +1 -1
  253. package/src/quote/v2/edit.js +3 -0
  254. package/src/rss/edit.js +1 -1
  255. package/src/search/edit.js +13 -7
  256. package/src/search/index.php +84 -33
  257. package/src/spacer/constants.js +1 -0
  258. package/src/spacer/controls.js +2 -2
  259. package/src/spacer/controls.native.js +1 -1
  260. package/src/spacer/edit.js +1 -2
  261. package/src/table/edit.js +11 -2
  262. package/src/table/editor.scss +13 -0
  263. package/src/table/style.scss +52 -0
  264. package/src/tag-cloud/edit.js +1 -1
  265. package/src/video/edit.js +1 -1
  266. package/src/video/edit.native.js +1 -1
package/src/common.scss CHANGED
@@ -116,11 +116,34 @@
116
116
  html :where(.has-border-color) {
117
117
  border-style: solid;
118
118
  }
119
+ html :where([style*="border-top-color"]) {
120
+ border-top-style: solid;
121
+ }
122
+ html :where([style*="border-right-color"]) {
123
+ border-right-style: solid;
124
+ }
125
+ html :where([style*="border-bottom-color"]) {
126
+ border-bottom-style: solid;
127
+ }
128
+ html :where([style*="border-left-color"]) {
129
+ border-left-style: solid;
130
+ }
119
131
 
120
132
  html :where([style*="border-width"]) {
121
133
  border-style: solid;
122
134
  }
123
-
135
+ html :where([style*="border-top-width"]) {
136
+ border-top-style: solid;
137
+ }
138
+ html :where([style*="border-right-width"]) {
139
+ border-right-style: solid;
140
+ }
141
+ html :where([style*="border-bottom-width"]) {
142
+ border-bottom-style: solid;
143
+ }
144
+ html :where([style*="border-left-width"]) {
145
+ border-left-style: solid;
146
+ }
124
147
 
125
148
  /**
126
149
  * Provide baseline responsiveness for images.
package/src/editor.scss CHANGED
@@ -10,6 +10,7 @@
10
10
  @import "./comments-query-loop/editor.scss";
11
11
  @import "./comments-pagination/editor.scss";
12
12
  @import "./comments-pagination-numbers/editor.scss";
13
+ @import "./comments-title/editor.scss";
13
14
  @import "./cover/editor.scss";
14
15
  @import "./embed/editor.scss";
15
16
  @import "./file/editor.scss";
package/src/embed/edit.js CHANGED
@@ -5,8 +5,8 @@ import {
5
5
  createUpgradedEmbedBlock,
6
6
  getClassNames,
7
7
  fallback,
8
- getAttributesFromPreview,
9
8
  getEmbedInfoByProvider,
9
+ getMergedAttributesWithPreview,
10
10
  } from './util';
11
11
  import EmbedControls from './embed-controls';
12
12
  import { embedContentIcon } from './icons';
@@ -99,21 +99,19 @@ const EmbedEdit = ( props ) => {
99
99
  );
100
100
 
101
101
  /**
102
- * @return {Object} Attributes derived from the preview, merged with the current attributes.
102
+ * Returns the attributes derived from the preview, merged with the current attributes.
103
+ *
104
+ * @param {boolean} ignorePreviousClassName Determines if the previous className attribute should be ignored when merging.
105
+ * @return {Object} Merged attributes.
103
106
  */
104
- const getMergedAttributes = () => {
105
- const { allowResponsive, className } = attributes;
106
- return {
107
- ...attributes,
108
- ...getAttributesFromPreview(
109
- preview,
110
- title,
111
- className,
112
- responsive,
113
- allowResponsive
114
- ),
115
- };
116
- };
107
+ const getMergedAttributes = ( ignorePreviousClassName = false ) =>
108
+ getMergedAttributesWithPreview(
109
+ attributes,
110
+ preview,
111
+ title,
112
+ responsive,
113
+ ignorePreviousClassName
114
+ );
117
115
 
118
116
  const toggleResponsive = () => {
119
117
  const { allowResponsive, className } = attributes;
@@ -145,15 +143,12 @@ const EmbedEdit = ( props ) => {
145
143
  // Handle incoming preview.
146
144
  useEffect( () => {
147
145
  if ( preview && ! isEditingURL ) {
148
- // Even though we set attributes that get derived from the preview,
149
- // we don't access them directly because for the initial render,
150
- // the `setAttributes` call will not have taken effect. If we're
151
- // rendering responsive content, setting the responsive classes
152
- // after the preview has been rendered can result in unwanted
153
- // clipping or scrollbars. The `getAttributesFromPreview` function
154
- // that `getMergedAttributes` uses is memoized so that we're not
155
- // calculating them on every render.
156
- setAttributes( getMergedAttributes() );
146
+ // When obtaining an incoming preview, we set the attributes derived from
147
+ // the preview data. In this case when getting the merged attributes,
148
+ // we ignore the previous classname because it might not match the expected
149
+ // classes by the new preview.
150
+ setAttributes( getMergedAttributes( true ) );
151
+
157
152
  if ( onReplace ) {
158
153
  const upgradedBlock = createUpgradedEmbedBlock(
159
154
  props,
@@ -5,8 +5,8 @@ import {
5
5
  createUpgradedEmbedBlock,
6
6
  getClassNames,
7
7
  fallback,
8
- getAttributesFromPreview,
9
8
  getEmbedInfoByProvider,
9
+ getMergedAttributesWithPreview,
10
10
  } from './util';
11
11
  import EmbedControls from './embed-controls';
12
12
  import { embedContentIcon } from './icons';
@@ -130,19 +130,14 @@ const EmbedEdit = ( props ) => {
130
130
  * @param {boolean} ignorePreviousClassName Determines if the previous className attribute should be ignored when merging.
131
131
  * @return {Object} Merged attributes.
132
132
  */
133
- const getMergedAttributes = ( ignorePreviousClassName = false ) => {
134
- const { allowResponsive, className } = attributes;
135
- return {
136
- ...attributes,
137
- ...getAttributesFromPreview(
138
- preview,
139
- title,
140
- ignorePreviousClassName ? undefined : className,
141
- responsive,
142
- allowResponsive
143
- ),
144
- };
145
- };
133
+ const getMergedAttributes = ( ignorePreviousClassName = false ) =>
134
+ getMergedAttributesWithPreview(
135
+ attributes,
136
+ preview,
137
+ title,
138
+ responsive,
139
+ ignorePreviousClassName
140
+ );
146
141
 
147
142
  const toggleResponsive = () => {
148
143
  const { allowResponsive, className } = attributes;
package/src/embed/util.js CHANGED
@@ -66,9 +66,11 @@ export const isFromWordPress = ( html ) =>
66
66
  html && html.includes( 'class="wp-embedded-content"' );
67
67
 
68
68
  export const getPhotoHtml = ( photo ) => {
69
+ // If full image url not found use thumbnail.
70
+ const imageUrl = photo.url || photo.thumbnail_url;
71
+
69
72
  // 100% width for the preview so it fits nicely into the document, some "thumbnails" are
70
- // actually the full size photo. If thumbnails not found, use full image.
71
- const imageUrl = photo.thumbnail_url || photo.url;
73
+ // actually the full size photo.
72
74
  const photoPreview = (
73
75
  <p>
74
76
  <img src={ imageUrl } alt={ photo.title } width="100%" />
@@ -290,3 +292,33 @@ export const getAttributesFromPreview = memoize(
290
292
  return attributes;
291
293
  }
292
294
  );
295
+
296
+ /**
297
+ * Returns the attributes derived from the preview, merged with the current attributes.
298
+ *
299
+ * @param {Object} currentAttributes The current attributes of the block.
300
+ * @param {Object} preview The preview data.
301
+ * @param {string} title The block's title, e.g. Twitter.
302
+ * @param {boolean} isResponsive Boolean indicating if the block supports responsive content.
303
+ * @param {boolean} ignorePreviousClassName Determines if the previous className attribute should be ignored when merging.
304
+ * @return {Object} Merged attributes.
305
+ */
306
+ export const getMergedAttributesWithPreview = (
307
+ currentAttributes,
308
+ preview,
309
+ title,
310
+ isResponsive,
311
+ ignorePreviousClassName = false
312
+ ) => {
313
+ const { allowResponsive, className } = currentAttributes;
314
+ return {
315
+ ...currentAttributes,
316
+ ...getAttributesFromPreview(
317
+ preview,
318
+ title,
319
+ ignorePreviousClassName ? undefined : className,
320
+ isResponsive,
321
+ allowResponsive
322
+ ),
323
+ };
324
+ };
@@ -68,7 +68,7 @@ export default function FileBlockInspector( {
68
68
  ) }
69
69
  </PanelBody>
70
70
  ) }
71
- <PanelBody title={ __( 'Text link settings' ) }>
71
+ <PanelBody title={ __( 'Settings' ) }>
72
72
  <SelectControl
73
73
  label={ __( 'Link to' ) }
74
74
  value={ textLinkHref }
@@ -80,8 +80,6 @@ export default function FileBlockInspector( {
80
80
  checked={ openInNewWindow }
81
81
  onChange={ changeOpenInNewWindow }
82
82
  />
83
- </PanelBody>
84
- <PanelBody title={ __( 'Download button settings' ) }>
85
83
  <ToggleControl
86
84
  label={ __( 'Show download button' ) }
87
85
  checked={ showDownloadButton }
@@ -478,7 +478,7 @@ function GalleryEdit( props ) {
478
478
  return (
479
479
  <>
480
480
  <InspectorControls>
481
- <PanelBody title={ __( 'Gallery settings' ) }>
481
+ <PanelBody title={ __( 'Settings' ) }>
482
482
  { images.length > 1 && (
483
483
  <RangeControl
484
484
  label={ __( 'Columns' ) }
@@ -420,7 +420,7 @@ function GalleryEdit( props ) {
420
420
  return (
421
421
  <>
422
422
  <InspectorControls>
423
- <PanelBody title={ __( 'Gallery settings' ) }>
423
+ <PanelBody title={ __( 'Settings' ) }>
424
424
  { images.length > 1 && (
425
425
  <RangeControl
426
426
  label={ __( 'Columns' ) }
package/src/html/edit.js CHANGED
@@ -59,14 +59,14 @@ export default function HTMLEdit( { attributes, setAttributes, isSelected } ) {
59
59
  isPressed={ ! isPreview }
60
60
  onClick={ switchToHTML }
61
61
  >
62
- <span>HTML</span>
62
+ HTML
63
63
  </ToolbarButton>
64
64
  <ToolbarButton
65
65
  className="components-tab-button"
66
66
  isPressed={ isPreview }
67
67
  onClick={ switchToPreview }
68
68
  >
69
- <span>{ __( 'Preview' ) }</span>
69
+ { __( 'Preview' ) }
70
70
  </ToolbarButton>
71
71
  </ToolbarGroup>
72
72
  </BlockControls>
package/src/image/edit.js CHANGED
@@ -22,8 +22,6 @@ import { useEffect, useRef, useState } from '@wordpress/element';
22
22
  import { __ } from '@wordpress/i18n';
23
23
  import { image as icon } from '@wordpress/icons';
24
24
 
25
- /* global wp */
26
-
27
25
  /**
28
26
  * Internal dependencies
29
27
  */
@@ -97,7 +95,7 @@ function hasDefaultSize( image, defaultSize ) {
97
95
  * @return {boolean} Whether the image has been destroyed.
98
96
  */
99
97
  export function isMediaDestroyed( id ) {
100
- const attachment = wp?.media?.attachment( id ) || {};
98
+ const attachment = window?.wp?.media?.attachment( id ) || {};
101
99
  return attachment.destroyed;
102
100
  }
103
101
 
@@ -232,7 +230,7 @@ export function ImageEdit( {
232
230
  // The constants used in Gutenberg do not match WP options so a little more complicated than ideal.
233
231
  // TODO: fix this in a follow up PR, requires updating media-text and ui component.
234
232
  switch (
235
- wp?.media?.view?.settings?.defaultProps?.link ||
233
+ window?.wp?.media?.view?.settings?.defaultProps?.link ||
236
234
  LINK_DESTINATION_NONE
237
235
  ) {
238
236
  case 'file':
@@ -670,7 +670,7 @@ export class ImageEdit extends Component {
670
670
 
671
671
  const getInspectorControls = () => (
672
672
  <InspectorControls>
673
- <PanelBody title={ __( 'Image settings' ) } />
673
+ <PanelBody title={ __( 'Settings' ) } />
674
674
  <PanelBody style={ styles.panelBody }>
675
675
  <BlockStyles clientId={ clientId } url={ url } />
676
676
  </PanelBody>
@@ -370,7 +370,7 @@ export default function Image( {
370
370
  </BlockControls>
371
371
  ) }
372
372
  <InspectorControls>
373
- <PanelBody title={ __( 'Image settings' ) }>
373
+ <PanelBody title={ __( 'Settings' ) }>
374
374
  { ! multiImageSelection && (
375
375
  <TextareaControl
376
376
  label={ __( 'Alt text (alternative text)' ) }
package/src/index.js CHANGED
@@ -35,6 +35,7 @@ import * as commentsQueryLoop from './comments-query-loop';
35
35
  import * as commentsPagination from './comments-pagination';
36
36
  import * as commentsPaginationNext from './comments-pagination-next';
37
37
  import * as commentsPaginationNumbers from './comments-pagination-numbers';
38
+ import * as commentsTitle from './comments-title';
38
39
  import * as cover from './cover';
39
40
  import * as embed from './embed';
40
41
  import * as file from './file';
@@ -212,11 +213,13 @@ export const __experimentalGetCoreBlocks = () => [
212
213
  commentEditLink,
213
214
  commentReplyLink,
214
215
  commentTemplate,
216
+ commentsTitle,
215
217
  commentsQueryLoop,
216
218
  commentsPagination,
217
219
  commentsPaginationNext,
218
220
  commentsPaginationNumbers,
219
221
  commentsPaginationPrevious,
222
+
220
223
  postComments,
221
224
  homeLink,
222
225
  logInOut,
@@ -179,6 +179,14 @@ const devOnly = ( block ) => ( !! __DEV__ ? block : null );
179
179
  const iOSOnly = ( block ) =>
180
180
  Platform.OS === 'ios' ? block : devOnly( block );
181
181
 
182
+ // To be removed once Quote V2 is released on the web editor.
183
+ function quoteCheck( quoteBlock, blocksFlags ) {
184
+ if ( blocksFlags?.__experimentalEnableQuoteBlockV2 ) {
185
+ quoteBlock.settings = quoteBlock?.settingsV2;
186
+ }
187
+ return quoteBlock;
188
+ }
189
+
182
190
  // Hide the Classic block and SocialLink block
183
191
  addFilter(
184
192
  'blocks.registerBlockType',
@@ -230,8 +238,10 @@ addFilter(
230
238
  *
231
239
  * registerCoreBlocks();
232
240
  * ```
241
+ * @param {Object} [blocksFlags] Experimental flags
242
+ *
233
243
  */
234
- export const registerCoreBlocks = () => {
244
+ export const registerCoreBlocks = ( blocksFlags ) => {
235
245
  // When adding new blocks to this list please also consider updating /src/block-support/supported-blocks.json in the Gutenberg-Mobile repo
236
246
  [
237
247
  paragraph,
@@ -244,7 +254,7 @@ export const registerCoreBlocks = () => {
244
254
  nextpage,
245
255
  separator,
246
256
  list,
247
- quote,
257
+ quoteCheck( quote, blocksFlags ),
248
258
  mediaText,
249
259
  preformatted,
250
260
  gallery,
@@ -35,7 +35,7 @@ export default function LatestComments( { attributes, setAttributes } ) {
35
35
  return (
36
36
  <div { ...useBlockProps() }>
37
37
  <InspectorControls>
38
- <PanelBody title={ __( 'Latest comments settings' ) }>
38
+ <PanelBody title={ __( 'Settings' ) }>
39
39
  <ToggleControl
40
40
  label={ __( 'Display avatar' ) }
41
41
  checked={ displayAvatar }
@@ -11,7 +11,7 @@ export default function LoginOutEdit( { attributes, setAttributes } ) {
11
11
  return (
12
12
  <>
13
13
  <InspectorControls>
14
- <PanelBody title={ __( 'Login/out settings' ) }>
14
+ <PanelBody title={ __( 'Settings' ) }>
15
15
  <ToggleControl
16
16
  label={ __( 'Display login as form' ) }
17
17
  checked={ displayLoginAsForm }
@@ -46,7 +46,6 @@ const TEMPLATE = [
46
46
  [
47
47
  'core/paragraph',
48
48
  {
49
- fontSize: 'large',
50
49
  placeholder: _x( 'Content…', 'content placeholder' ),
51
50
  },
52
51
  ],
@@ -238,7 +237,7 @@ function MediaTextEdit( { attributes, isSelected, setAttributes } ) {
238
237
  };
239
238
 
240
239
  const mediaTextGeneralSettings = (
241
- <PanelBody title={ __( 'Media & Text settings' ) }>
240
+ <PanelBody title={ __( 'Settings' ) }>
242
241
  <ToggleControl
243
242
  label={ __( 'Stack on mobile' ) }
244
243
  checked={ isStackedOnMobile }
@@ -186,7 +186,7 @@ class MediaTextEdit extends Component {
186
186
 
187
187
  return (
188
188
  <InspectorControls>
189
- <PanelBody title={ __( 'Media & Text settings' ) }>
189
+ <PanelBody title={ __( 'Settings' ) }>
190
190
  <ToggleControl
191
191
  label={ __( 'Crop image to fill entire column' ) }
192
192
  checked={ imageFill }
@@ -117,7 +117,7 @@
117
117
  }
118
118
  }
119
119
  },
120
- "viewScript": "file:./view.min.js",
120
+ "viewScript": [ "file:./view.min.js", "file:./view-modal.min.js" ],
121
121
  "editorStyle": "wp-block-navigation-editor",
122
122
  "style": "wp-block-navigation"
123
123
  }
@@ -523,6 +523,11 @@ function Navigation( {
523
523
  ref,
524
524
  ] );
525
525
 
526
+ const navigationSelectorRef = useRef();
527
+ const [
528
+ shouldFocusNavigationSelector,
529
+ setShouldFocusNavigationSelector,
530
+ ] = useState( false );
526
531
  const handleSelectNavigation = useCallback(
527
532
  ( navPostOrClassicMenu ) => {
528
533
  if ( ! navPostOrClassicMenu ) {
@@ -538,10 +543,28 @@ function Navigation( {
538
543
  } else {
539
544
  handleUpdateMenu( navPostOrClassicMenu.id );
540
545
  }
546
+ setShouldFocusNavigationSelector( true );
541
547
  },
542
548
  [ convert, handleUpdateMenu ]
543
549
  );
544
550
 
551
+ // Focus support after menu selection.
552
+ useEffect( () => {
553
+ if (
554
+ isDraftNavigationMenu ||
555
+ ! isEntityAvailable ||
556
+ ! shouldFocusNavigationSelector
557
+ ) {
558
+ return;
559
+ }
560
+ navigationSelectorRef?.current?.focus();
561
+ setShouldFocusNavigationSelector( false );
562
+ }, [
563
+ isDraftNavigationMenu,
564
+ isEntityAvailable,
565
+ shouldFocusNavigationSelector,
566
+ ] );
567
+
545
568
  const resetToEmptyBlock = useCallback( () => {
546
569
  registry.batch( () => {
547
570
  if ( navigationArea ) {
@@ -663,6 +686,7 @@ function Navigation( {
663
686
  { ! isDraftNavigationMenu && isEntityAvailable && (
664
687
  <ToolbarGroup className="wp-block-navigation__toolbar-menu-selector">
665
688
  <NavigationMenuSelector
689
+ ref={ navigationSelectorRef }
666
690
  currentMenuId={ ref }
667
691
  clientId={ clientId }
668
692
  onSelect={ handleSelectNavigation }
@@ -10,7 +10,7 @@ import {
10
10
  import { __, sprintf } from '@wordpress/i18n';
11
11
  import { decodeEntities } from '@wordpress/html-entities';
12
12
  import { addQueryArgs } from '@wordpress/url';
13
- import { useCallback, useMemo } from '@wordpress/element';
13
+ import { forwardRef, useCallback, useMemo } from '@wordpress/element';
14
14
 
15
15
  /**
16
16
  * Internal dependencies
@@ -18,14 +18,17 @@ import { useCallback, useMemo } from '@wordpress/element';
18
18
  import useNavigationMenu from '../use-navigation-menu';
19
19
  import useNavigationEntities from '../use-navigation-entities';
20
20
 
21
- export default function NavigationMenuSelector( {
22
- currentMenuId,
23
- onSelect,
24
- onCreateNew,
25
- showManageActions = false,
26
- actionLabel,
27
- toggleProps = {},
28
- } ) {
21
+ function NavigationMenuSelector(
22
+ {
23
+ currentMenuId,
24
+ onSelect,
25
+ onCreateNew,
26
+ showManageActions = false,
27
+ actionLabel,
28
+ toggleProps = {},
29
+ },
30
+ forwardedRef
31
+ ) {
29
32
  /* translators: %s: The name of a menu. */
30
33
  const createActionLabel = __( "Create from '%s'" );
31
34
 
@@ -92,6 +95,7 @@ export default function NavigationMenuSelector( {
92
95
 
93
96
  return (
94
97
  <ToolbarDropdownMenu
98
+ ref={ forwardedRef }
95
99
  label={ __( 'Select Menu' ) }
96
100
  text={ __( 'Select Menu' ) }
97
101
  icon={ null }
@@ -152,3 +156,5 @@ export default function NavigationMenuSelector( {
152
156
  </ToolbarDropdownMenu>
153
157
  );
154
158
  }
159
+
160
+ export default forwardRef( NavigationMenuSelector );
@@ -123,7 +123,7 @@ export default function UnsavedInnerBlocks( {
123
123
  );
124
124
 
125
125
  // Automatically save the uncontrolled blocks.
126
- useEffect( async () => {
126
+ useEffect( () => {
127
127
  // The block will be disabled when used in a BlockPreview.
128
128
  // In this case avoid automatic creation of a wp_navigation post.
129
129
  // Otherwise the user will be spammed with lots of menus!
@@ -150,9 +150,10 @@ export default function UnsavedInnerBlocks( {
150
150
  }
151
151
 
152
152
  savingLock.current = true;
153
- const menu = await createNavigationMenu( null, blocks );
154
- onSave( menu );
155
- savingLock.current = false;
153
+ createNavigationMenu( null, blocks ).then( ( menu ) => {
154
+ onSave( menu );
155
+ savingLock.current = false;
156
+ } );
156
157
  }, [
157
158
  isDisabled,
158
159
  isSaving,
@@ -396,6 +396,11 @@ function render_block_core_navigation( $attributes, $content, $block ) {
396
396
  wp_enqueue_script( 'wp-block-navigation-view' );
397
397
  }
398
398
 
399
+ $should_load_modal_view_script = isset( $attributes['overlayMenu'] ) && 'never' !== $attributes['overlayMenu'];
400
+ if ( $should_load_modal_view_script ) {
401
+ wp_enqueue_script( 'wp-block-navigation-view-modal' );
402
+ }
403
+
399
404
  $inner_blocks = $block->inner_blocks;
400
405
 
401
406
  // Ensure that blocks saved with the legacy ref attribute name (navigationMenuId) continue to render.
@@ -0,0 +1,36 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import MicroModal from 'micromodal';
5
+
6
+ // Responsive navigation toggle.
7
+ function navigationToggleModal( modal ) {
8
+ const dialogContainer = modal.querySelector(
9
+ `.wp-block-navigation__responsive-dialog`
10
+ );
11
+
12
+ const isHidden = 'true' === modal.getAttribute( 'aria-hidden' );
13
+
14
+ modal.classList.toggle( 'has-modal-open', ! isHidden );
15
+ dialogContainer.toggleAttribute( 'aria-modal', ! isHidden );
16
+
17
+ if ( isHidden ) {
18
+ dialogContainer.removeAttribute( 'role' );
19
+ dialogContainer.removeAttribute( 'aria-modal' );
20
+ } else {
21
+ dialogContainer.setAttribute( 'role', 'dialog' );
22
+ dialogContainer.setAttribute( 'aria-modal', 'true' );
23
+ }
24
+
25
+ // Add a class to indicate the modal is open.
26
+ const htmlElement = document.documentElement;
27
+ htmlElement.classList.toggle( 'has-modal-open' );
28
+ }
29
+
30
+ window.addEventListener( 'load', () => {
31
+ MicroModal.init( {
32
+ onShow: navigationToggleModal,
33
+ onClose: navigationToggleModal,
34
+ openClass: 'is-menu-open',
35
+ } );
36
+ } );
@@ -1,32 +1,3 @@
1
- /**
2
- * External dependencies
3
- */
4
- import MicroModal from 'micromodal';
5
-
6
- // Responsive navigation toggle.
7
- function navigationToggleModal( modal ) {
8
- const dialogContainer = modal.querySelector(
9
- `.wp-block-navigation__responsive-dialog`
10
- );
11
-
12
- const isHidden = 'true' === modal.getAttribute( 'aria-hidden' );
13
-
14
- modal.classList.toggle( 'has-modal-open', ! isHidden );
15
- dialogContainer.toggleAttribute( 'aria-modal', ! isHidden );
16
-
17
- if ( isHidden ) {
18
- dialogContainer.removeAttribute( 'role' );
19
- dialogContainer.removeAttribute( 'aria-modal' );
20
- } else {
21
- dialogContainer.setAttribute( 'role', 'dialog' );
22
- dialogContainer.setAttribute( 'aria-modal', 'true' );
23
- }
24
-
25
- // Add a class to indicate the modal is open.
26
- const htmlElement = document.documentElement;
27
- htmlElement.classList.toggle( 'has-modal-open' );
28
- }
29
-
30
1
  // Open on click functionality.
31
2
  function closeSubmenus( element ) {
32
3
  element
@@ -65,12 +36,6 @@ function toggleSubmenuOnClick( event ) {
65
36
  // Necessary for some themes such as TT1 Blocks, where
66
37
  // scripts could be loaded before the body.
67
38
  window.addEventListener( 'load', () => {
68
- MicroModal.init( {
69
- onShow: navigationToggleModal,
70
- onClose: navigationToggleModal,
71
- openClass: 'is-menu-open',
72
- } );
73
-
74
39
  const submenuButtons = document.querySelectorAll(
75
40
  '.wp-block-navigation-submenu__toggle'
76
41
  );