@wordpress/block-library 8.24.1 → 8.25.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 (327) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/audio/edit.js +7 -52
  3. package/build/audio/edit.js.map +1 -1
  4. package/build/audio/edit.native.js +1 -1
  5. package/build/audio/edit.native.js.map +1 -1
  6. package/build/audio/index.js +2 -2
  7. package/build/block/edit.js +102 -11
  8. package/build/block/edit.js.map +1 -1
  9. package/build/block/index.js +3 -2
  10. package/build/block/index.js.map +1 -1
  11. package/build/block/v1/edit.js +116 -0
  12. package/build/block/v1/edit.js.map +1 -0
  13. package/build/block/{edit.native.js → v1/edit.native.js} +2 -2
  14. package/build/block/v1/edit.native.js.map +1 -0
  15. package/build/button/index.js +2 -2
  16. package/build/button/save.js +1 -1
  17. package/build/button/save.js.map +1 -1
  18. package/build/code/edit.native.js +13 -14
  19. package/build/code/edit.native.js.map +1 -1
  20. package/build/code/index.js +2 -2
  21. package/build/code/save.js +6 -2
  22. package/build/code/save.js.map +1 -1
  23. package/build/details/index.js +2 -2
  24. package/build/embed/deprecated.js +2 -2
  25. package/build/embed/embed-preview.native.js +1 -1
  26. package/build/embed/embed-preview.native.js.map +1 -1
  27. package/build/embed/icons.js +1 -1
  28. package/build/embed/icons.js.map +1 -1
  29. package/build/embed/index.js +2 -2
  30. package/build/embed/transforms.js +2 -2
  31. package/build/embed/util.js +2 -2
  32. package/build/file/edit.js +1 -1
  33. package/build/file/edit.js.map +1 -1
  34. package/build/file/edit.native.js +1 -1
  35. package/build/file/edit.native.js.map +1 -1
  36. package/build/file/index.js +4 -4
  37. package/build/file/save.js +4 -1
  38. package/build/file/save.js.map +1 -1
  39. package/build/form-input/deprecated.js +147 -0
  40. package/build/form-input/deprecated.js.map +1 -0
  41. package/build/form-input/edit.js +1 -1
  42. package/build/form-input/edit.js.map +1 -1
  43. package/build/form-input/index.js +4 -2
  44. package/build/form-input/index.js.map +1 -1
  45. package/build/form-input/save.js +7 -9
  46. package/build/form-input/save.js.map +1 -1
  47. package/build/gallery/edit.js +2 -41
  48. package/build/gallery/edit.js.map +1 -1
  49. package/build/gallery/gallery.js +18 -24
  50. package/build/gallery/gallery.js.map +1 -1
  51. package/build/gallery/gallery.native.js +1 -1
  52. package/build/gallery/gallery.native.js.map +1 -1
  53. package/build/gallery/index.js +4 -4
  54. package/build/gallery/v1/gallery.native.js +1 -1
  55. package/build/gallery/v1/gallery.native.js.map +1 -1
  56. package/build/group/edit.js +6 -1
  57. package/build/group/edit.js.map +1 -1
  58. package/build/heading/index.js +3 -6
  59. package/build/heading/index.js.map +1 -1
  60. package/build/image/edit.native.js +1 -1
  61. package/build/image/edit.native.js.map +1 -1
  62. package/build/image/image.js +14 -51
  63. package/build/image/image.js.map +1 -1
  64. package/build/image/index.js +2 -2
  65. package/build/image/save.js +3 -1
  66. package/build/image/save.js.map +1 -1
  67. package/build/list-item/index.js +10 -3
  68. package/build/list-item/index.js.map +1 -1
  69. package/build/navigation/edit/index.js +1 -1
  70. package/build/navigation/edit/index.js.map +1 -1
  71. package/build/page-list/convert-to-links-modal.js +2 -2
  72. package/build/page-list/convert-to-links-modal.js.map +1 -1
  73. package/build/paragraph/edit.js +54 -32
  74. package/build/paragraph/edit.js.map +1 -1
  75. package/build/paragraph/index.js +2 -3
  76. package/build/paragraph/index.js.map +1 -1
  77. package/build/paragraph/transforms.js +2 -3
  78. package/build/paragraph/transforms.js.map +1 -1
  79. package/build/post-title/index.js +1 -3
  80. package/build/post-title/index.js.map +1 -1
  81. package/build/preformatted/index.js +2 -3
  82. package/build/preformatted/index.js.map +1 -1
  83. package/build/pullquote/index.js +5 -7
  84. package/build/pullquote/index.js.map +1 -1
  85. package/build/query/edit/inspector-controls/taxonomy-controls.js +2 -0
  86. package/build/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
  87. package/build/query-title/index.js +1 -3
  88. package/build/query-title/index.js.map +1 -1
  89. package/build/quote/index.js +3 -5
  90. package/build/quote/index.js.map +1 -1
  91. package/build/quote/transforms.js +7 -6
  92. package/build/quote/transforms.js.map +1 -1
  93. package/build/site-title/index.js +1 -5
  94. package/build/site-title/index.js.map +1 -1
  95. package/build/social-link/icons/gravatar.js +22 -0
  96. package/build/social-link/icons/gravatar.js.map +1 -0
  97. package/build/social-link/icons/index.js +11 -0
  98. package/build/social-link/icons/index.js.map +1 -1
  99. package/build/social-link/variations.js +7 -0
  100. package/build/social-link/variations.js.map +1 -1
  101. package/build/table/edit.js +3 -1
  102. package/build/table/edit.js.map +1 -1
  103. package/build/table/index.js +9 -10
  104. package/build/table/index.js.map +1 -1
  105. package/build/table-of-contents/edit.js +2 -2
  106. package/build/table-of-contents/edit.js.map +1 -1
  107. package/build/table-of-contents/index.js +5 -2
  108. package/build/table-of-contents/index.js.map +1 -1
  109. package/build/utils/caption.js +90 -0
  110. package/build/utils/caption.js.map +1 -0
  111. package/build/utils/remove-anchor-tag.js +2 -1
  112. package/build/utils/remove-anchor-tag.js.map +1 -1
  113. package/build/verse/index.js +3 -5
  114. package/build/verse/index.js.map +1 -1
  115. package/build/video/deprecated.js +2 -2
  116. package/build/video/edit.js +8 -52
  117. package/build/video/edit.js.map +1 -1
  118. package/build/video/edit.native.js +1 -1
  119. package/build/video/edit.native.js.map +1 -1
  120. package/build/video/index.js +2 -2
  121. package/build-module/audio/edit.js +11 -56
  122. package/build-module/audio/edit.js.map +1 -1
  123. package/build-module/audio/edit.native.js +2 -2
  124. package/build-module/audio/edit.native.js.map +1 -1
  125. package/build-module/audio/index.js +2 -2
  126. package/build-module/block/edit.js +104 -13
  127. package/build-module/block/edit.js.map +1 -1
  128. package/build-module/block/index.js +3 -2
  129. package/build-module/block/index.js.map +1 -1
  130. package/build-module/block/v1/edit.js +108 -0
  131. package/build-module/block/v1/edit.js.map +1 -0
  132. package/build-module/block/{edit.native.js → v1/edit.native.js} +2 -2
  133. package/build-module/block/v1/edit.native.js.map +1 -0
  134. package/build-module/button/index.js +2 -2
  135. package/build-module/button/save.js +1 -1
  136. package/build-module/button/save.js.map +1 -1
  137. package/build-module/code/edit.native.js +14 -16
  138. package/build-module/code/edit.native.js.map +1 -1
  139. package/build-module/code/index.js +2 -2
  140. package/build-module/code/save.js +6 -2
  141. package/build-module/code/save.js.map +1 -1
  142. package/build-module/details/index.js +2 -2
  143. package/build-module/embed/deprecated.js +2 -2
  144. package/build-module/embed/embed-preview.native.js +2 -2
  145. package/build-module/embed/embed-preview.native.js.map +1 -1
  146. package/build-module/embed/icons.js +1 -1
  147. package/build-module/embed/icons.js.map +1 -1
  148. package/build-module/embed/index.js +2 -2
  149. package/build-module/embed/transforms.js +2 -2
  150. package/build-module/embed/util.js +2 -2
  151. package/build-module/file/edit.js +1 -1
  152. package/build-module/file/edit.js.map +1 -1
  153. package/build-module/file/edit.native.js +1 -1
  154. package/build-module/file/edit.native.js.map +1 -1
  155. package/build-module/file/index.js +4 -4
  156. package/build-module/file/save.js +4 -1
  157. package/build-module/file/save.js.map +1 -1
  158. package/build-module/form-input/deprecated.js +138 -0
  159. package/build-module/form-input/deprecated.js.map +1 -0
  160. package/build-module/form-input/edit.js +1 -1
  161. package/build-module/form-input/edit.js.map +1 -1
  162. package/build-module/form-input/index.js +4 -2
  163. package/build-module/form-input/index.js.map +1 -1
  164. package/build-module/form-input/save.js +8 -10
  165. package/build-module/form-input/save.js.map +1 -1
  166. package/build-module/gallery/edit.js +5 -44
  167. package/build-module/gallery/edit.js.map +1 -1
  168. package/build-module/gallery/gallery.js +17 -21
  169. package/build-module/gallery/gallery.js.map +1 -1
  170. package/build-module/gallery/gallery.native.js +2 -2
  171. package/build-module/gallery/gallery.native.js.map +1 -1
  172. package/build-module/gallery/index.js +4 -4
  173. package/build-module/gallery/v1/gallery.native.js +2 -2
  174. package/build-module/gallery/v1/gallery.native.js.map +1 -1
  175. package/build-module/group/edit.js +6 -1
  176. package/build-module/group/edit.js.map +1 -1
  177. package/build-module/heading/index.js +3 -6
  178. package/build-module/heading/index.js.map +1 -1
  179. package/build-module/image/edit.native.js +2 -2
  180. package/build-module/image/edit.native.js.map +1 -1
  181. package/build-module/image/image.js +19 -56
  182. package/build-module/image/image.js.map +1 -1
  183. package/build-module/image/index.js +2 -2
  184. package/build-module/image/save.js +3 -1
  185. package/build-module/image/save.js.map +1 -1
  186. package/build-module/list-item/index.js +10 -3
  187. package/build-module/list-item/index.js.map +1 -1
  188. package/build-module/navigation/edit/index.js +2 -2
  189. package/build-module/navigation/edit/index.js.map +1 -1
  190. package/build-module/page-list/convert-to-links-modal.js +2 -2
  191. package/build-module/page-list/convert-to-links-modal.js.map +1 -1
  192. package/build-module/paragraph/edit.js +54 -32
  193. package/build-module/paragraph/edit.js.map +1 -1
  194. package/build-module/paragraph/index.js +2 -3
  195. package/build-module/paragraph/index.js.map +1 -1
  196. package/build-module/paragraph/transforms.js +2 -3
  197. package/build-module/paragraph/transforms.js.map +1 -1
  198. package/build-module/post-title/index.js +1 -3
  199. package/build-module/post-title/index.js.map +1 -1
  200. package/build-module/preformatted/index.js +2 -3
  201. package/build-module/preformatted/index.js.map +1 -1
  202. package/build-module/pullquote/index.js +5 -7
  203. package/build-module/pullquote/index.js.map +1 -1
  204. package/build-module/query/edit/inspector-controls/taxonomy-controls.js +2 -0
  205. package/build-module/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
  206. package/build-module/query-title/index.js +1 -3
  207. package/build-module/query-title/index.js.map +1 -1
  208. package/build-module/quote/index.js +3 -5
  209. package/build-module/quote/index.js.map +1 -1
  210. package/build-module/quote/transforms.js +7 -6
  211. package/build-module/quote/transforms.js.map +1 -1
  212. package/build-module/site-title/index.js +1 -5
  213. package/build-module/site-title/index.js.map +1 -1
  214. package/build-module/social-link/icons/gravatar.js +14 -0
  215. package/build-module/social-link/icons/gravatar.js.map +1 -0
  216. package/build-module/social-link/icons/index.js +1 -0
  217. package/build-module/social-link/icons/index.js.map +1 -1
  218. package/build-module/social-link/variations.js +8 -1
  219. package/build-module/social-link/variations.js.map +1 -1
  220. package/build-module/table/edit.js +3 -1
  221. package/build-module/table/edit.js.map +1 -1
  222. package/build-module/table/index.js +9 -10
  223. package/build-module/table/index.js.map +1 -1
  224. package/build-module/table-of-contents/edit.js +1 -1
  225. package/build-module/table-of-contents/edit.js.map +1 -1
  226. package/build-module/table-of-contents/index.js +5 -1
  227. package/build-module/table-of-contents/index.js.map +1 -1
  228. package/build-module/utils/caption.js +82 -0
  229. package/build-module/utils/caption.js.map +1 -0
  230. package/build-module/utils/remove-anchor-tag.js +2 -1
  231. package/build-module/utils/remove-anchor-tag.js.map +1 -1
  232. package/build-module/verse/index.js +3 -5
  233. package/build-module/verse/index.js.map +1 -1
  234. package/build-module/video/deprecated.js +2 -2
  235. package/build-module/video/edit.js +13 -57
  236. package/build-module/video/edit.js.map +1 -1
  237. package/build-module/video/edit.native.js +2 -2
  238. package/build-module/video/edit.native.js.map +1 -1
  239. package/build-module/video/index.js +2 -2
  240. package/build-style/editor-rtl.css +1 -11
  241. package/build-style/editor.css +1 -11
  242. package/build-style/social-links/style-rtl.css +14 -2
  243. package/build-style/social-links/style.css +14 -2
  244. package/build-style/style-rtl.css +14 -2
  245. package/build-style/style.css +14 -2
  246. package/build-style/table/editor-rtl.css +1 -11
  247. package/build-style/table/editor.css +1 -11
  248. package/package.json +32 -32
  249. package/src/audio/block.json +2 -2
  250. package/src/audio/edit.js +11 -74
  251. package/src/audio/edit.native.js +2 -1
  252. package/src/block/edit.js +143 -16
  253. package/src/block/index.js +3 -2
  254. package/src/block/index.php +48 -0
  255. package/src/block/v1/edit.js +163 -0
  256. package/src/block/{edit.native.js → v1/edit.native.js} +2 -2
  257. package/src/button/block.json +2 -2
  258. package/src/button/save.js +1 -1
  259. package/src/code/block.json +2 -2
  260. package/src/code/edit.native.js +11 -13
  261. package/src/code/save.js +4 -1
  262. package/src/code/test/edit.native.js +2 -2
  263. package/src/cover/test/edit.native.js +7 -1
  264. package/src/details/block.json +2 -2
  265. package/src/embed/block.json +2 -2
  266. package/src/embed/embed-preview.native.js +2 -1
  267. package/src/embed/icons.js +1 -1
  268. package/src/file/block.json +4 -4
  269. package/src/file/edit.js +1 -1
  270. package/src/file/edit.native.js +1 -1
  271. package/src/file/save.js +5 -1
  272. package/src/form-input/block.json +2 -2
  273. package/src/form-input/deprecated.js +142 -0
  274. package/src/form-input/edit.js +1 -1
  275. package/src/form-input/index.js +2 -0
  276. package/src/form-input/save.js +27 -24
  277. package/src/gallery/block.json +4 -4
  278. package/src/gallery/edit.js +4 -59
  279. package/src/gallery/gallery.js +19 -36
  280. package/src/gallery/gallery.native.js +6 -2
  281. package/src/gallery/v1/gallery.native.js +2 -1
  282. package/src/group/edit.js +4 -1
  283. package/src/heading/block.json +3 -6
  284. package/src/image/block.json +2 -2
  285. package/src/image/edit.native.js +2 -3
  286. package/src/image/image.js +24 -93
  287. package/src/image/save.js +3 -1
  288. package/src/list-item/block.json +10 -3
  289. package/src/navigation/edit/index.js +7 -2
  290. package/src/navigation/index.php +1 -1
  291. package/src/navigation-link/test/__snapshots__/hooks.js.snap +6 -3
  292. package/src/page-list/convert-to-links-modal.js +2 -2
  293. package/src/paragraph/block.json +2 -3
  294. package/src/paragraph/edit.js +53 -40
  295. package/src/post-title/block.json +1 -3
  296. package/src/preformatted/block.json +2 -3
  297. package/src/pullquote/block.json +5 -7
  298. package/src/query/edit/inspector-controls/taxonomy-controls.js +2 -0
  299. package/src/query-title/block.json +1 -3
  300. package/src/quote/block.json +3 -5
  301. package/src/quote/transforms.js +12 -11
  302. package/src/site-title/block.json +1 -5
  303. package/src/social-link/icons/gravatar.js +10 -0
  304. package/src/social-link/icons/index.js +1 -0
  305. package/src/social-link/index.php +4 -0
  306. package/src/social-link/socials-with-bg.scss +5 -0
  307. package/src/social-link/socials-without-bg.scss +4 -0
  308. package/src/social-link/variations.js +7 -0
  309. package/src/social-links/style.scss +14 -8
  310. package/src/table/block.json +9 -10
  311. package/src/table/edit.js +3 -1
  312. package/src/table/editor.scss +1 -14
  313. package/src/table-of-contents/edit.js +1 -1
  314. package/src/table-of-contents/index.js +5 -1
  315. package/src/utils/caption.js +108 -0
  316. package/src/utils/remove-anchor-tag.js +2 -1
  317. package/src/verse/block.json +3 -5
  318. package/src/video/block.json +2 -2
  319. package/src/video/edit.js +12 -74
  320. package/src/video/edit.native.js +2 -1
  321. package/build/block/edit.native.js.map +0 -1
  322. package/build/table-of-contents/icon.js +0 -22
  323. package/build/table-of-contents/icon.js.map +0 -1
  324. package/build-module/block/edit.native.js.map +0 -1
  325. package/build-module/table-of-contents/icon.js +0 -15
  326. package/build-module/table-of-contents/icon.js.map +0 -1
  327. package/src/table-of-contents/icon.js +0 -18
@@ -6,16 +6,15 @@ import classnames from 'classnames';
6
6
  /**
7
7
  * WordPress dependencies
8
8
  */
9
- import {
10
- RichText,
11
- __experimentalGetElementClassName,
12
- } from '@wordpress/block-editor';
13
9
  import { __ } from '@wordpress/i18n';
14
- import { createBlock, getDefaultBlockName } from '@wordpress/blocks';
15
10
  import { View } from '@wordpress/primitives';
16
- import { forwardRef } from '@wordpress/element';
17
11
 
18
- export const Gallery = ( props, captionRef ) => {
12
+ /**
13
+ * Internal dependencies
14
+ */
15
+ import { Caption } from '../utils/caption';
16
+
17
+ export default function Gallery( props ) {
19
18
  const {
20
19
  attributes,
21
20
  isSelected,
@@ -24,10 +23,10 @@ export const Gallery = ( props, captionRef ) => {
24
23
  insertBlocksAfter,
25
24
  blockProps,
26
25
  __unstableLayoutClassNames: layoutClassNames,
27
- showCaption,
26
+ isContentLocked,
28
27
  } = props;
29
28
 
30
- const { align, columns, caption, imageCrop } = attributes;
29
+ const { align, columns, imageCrop } = attributes;
31
30
 
32
31
  return (
33
32
  <figure
@@ -50,32 +49,16 @@ export const Gallery = ( props, captionRef ) => {
50
49
  { mediaPlaceholder }
51
50
  </View>
52
51
  ) }
53
- { showCaption &&
54
- ( ! RichText.isEmpty( caption ) || isSelected ) && (
55
- <RichText
56
- identifier="caption"
57
- aria-label={ __( 'Gallery caption text' ) }
58
- placeholder={ __( 'Write gallery caption…' ) }
59
- value={ caption }
60
- className={ classnames(
61
- 'blocks-gallery-caption',
62
- __experimentalGetElementClassName( 'caption' )
63
- ) }
64
- ref={ captionRef }
65
- tagName="figcaption"
66
- onChange={ ( value ) =>
67
- setAttributes( { caption: value } )
68
- }
69
- inlineToolbar
70
- __unstableOnSplitAtEnd={ () =>
71
- insertBlocksAfter(
72
- createBlock( getDefaultBlockName() )
73
- )
74
- }
75
- />
76
- ) }
52
+ <Caption
53
+ attributes={ attributes }
54
+ setAttributes={ setAttributes }
55
+ isSelected={ isSelected }
56
+ insertBlocksAfter={ insertBlocksAfter }
57
+ showToolbarButton={ ! isContentLocked }
58
+ className="blocks-gallery-caption"
59
+ label={ __( 'Gallery caption text' ) }
60
+ placeholder={ __( 'Add gallery caption' ) }
61
+ />
77
62
  </figure>
78
63
  );
79
- };
80
-
81
- export default forwardRef( Gallery );
64
+ }
@@ -13,7 +13,11 @@ import styles from './gallery-styles.scss';
13
13
  * WordPress dependencies
14
14
  */
15
15
  import { __, sprintf } from '@wordpress/i18n';
16
- import { BlockCaption, useInnerBlocksProps } from '@wordpress/block-editor';
16
+ import {
17
+ BlockCaption,
18
+ RichText,
19
+ useInnerBlocksProps,
20
+ } from '@wordpress/block-editor';
17
21
  import { useState, useEffect } from '@wordpress/element';
18
22
  import { mediaUploadSync } from '@wordpress/react-native-bridge';
19
23
  import { WIDE_ALIGNMENTS } from '@wordpress/components';
@@ -99,7 +103,7 @@ export const Gallery = ( props ) => {
99
103
  isSelected={ isCaptionSelected }
100
104
  accessible={ true }
101
105
  accessibilityLabelCreator={ ( caption ) =>
102
- ! caption
106
+ RichText.isEmpty( caption )
103
107
  ? /* translators: accessibility text. Empty gallery caption. */
104
108
 
105
109
  'Gallery caption. Empty'
@@ -17,6 +17,7 @@ import Tiles from './tiles';
17
17
  import { __, sprintf } from '@wordpress/i18n';
18
18
  import {
19
19
  BlockCaption,
20
+ RichText,
20
21
  store as blockEditorStore,
21
22
  } from '@wordpress/block-editor';
22
23
  import { useState, useEffect } from '@wordpress/element';
@@ -141,7 +142,7 @@ export const Gallery = ( props ) => {
141
142
  isSelected={ isCaptionSelected }
142
143
  accessible={ true }
143
144
  accessibilityLabelCreator={ ( caption ) =>
144
- ! caption
145
+ RichText.isEmpty( caption )
145
146
  ? /* translators: accessibility text. Empty gallery caption. */
146
147
  'Gallery caption. Empty'
147
148
  : sprintf(
package/src/group/edit.js CHANGED
@@ -10,6 +10,7 @@ import {
10
10
  store as blockEditorStore,
11
11
  } from '@wordpress/block-editor';
12
12
  import { SelectControl } from '@wordpress/components';
13
+ import { useRef } from '@wordpress/element';
13
14
  import { __ } from '@wordpress/i18n';
14
15
  import { View } from '@wordpress/primitives';
15
16
 
@@ -97,7 +98,8 @@ function GroupEdit( { attributes, name, setAttributes, clientId } ) {
97
98
  themeSupportsLayout || type === 'flex' || type === 'grid';
98
99
 
99
100
  // Hooks.
100
- const blockProps = useBlockProps();
101
+ const ref = useRef();
102
+ const blockProps = useBlockProps( { ref } );
101
103
 
102
104
  const [ showPlaceholder, setShowPlaceholder ] = useShouldShowPlaceHolder( {
103
105
  attributes,
@@ -124,6 +126,7 @@ function GroupEdit( { attributes, name, setAttributes, clientId } ) {
124
126
  ? blockProps
125
127
  : { className: 'wp-block-group__inner-container' },
126
128
  {
129
+ dropZoneElement: ref.current,
127
130
  templateLock,
128
131
  allowedBlocks,
129
132
  renderAppender,
@@ -12,10 +12,9 @@
12
12
  "type": "string"
13
13
  },
14
14
  "content": {
15
- "type": "string",
16
- "source": "html",
15
+ "type": "rich-text",
16
+ "source": "rich-text",
17
17
  "selector": "h1,h2,h3,h4,h5,h6",
18
- "default": "",
19
18
  "__experimentalRole": "content"
20
19
  },
21
20
  "level": {
@@ -57,9 +56,7 @@
57
56
  "__experimentalTextDecoration": true,
58
57
  "__experimentalWritingMode": true,
59
58
  "__experimentalDefaultControls": {
60
- "fontSize": true,
61
- "fontAppearance": true,
62
- "textTransform": true
59
+ "fontSize": true
63
60
  }
64
61
  },
65
62
  "__unstablePasteTextInline": true,
@@ -25,8 +25,8 @@
25
25
  "__experimentalRole": "content"
26
26
  },
27
27
  "caption": {
28
- "type": "string",
29
- "source": "html",
28
+ "type": "rich-text",
29
+ "source": "rich-text",
30
30
  "selector": "figcaption",
31
31
  "__experimentalRole": "content"
32
32
  },
@@ -47,6 +47,7 @@ import {
47
47
  BlockStyles,
48
48
  store as blockEditorStore,
49
49
  blockSettingsScreens,
50
+ RichText,
50
51
  } from '@wordpress/block-editor';
51
52
  import { __, _x, sprintf } from '@wordpress/i18n';
52
53
  import { getProtocol, hasQueryArg, isURL } from '@wordpress/url';
@@ -329,9 +330,7 @@ export class ImageEdit extends Component {
329
330
 
330
331
  accessibilityLabelCreator( caption ) {
331
332
  // Checks if caption is empty.
332
- return ( typeof caption === 'string' && caption.trim().length === 0 ) ||
333
- caption === undefined ||
334
- caption === null
333
+ return RichText.isEmpty( caption )
335
334
  ? /* translators: accessibility text. Empty image caption. */
336
335
  'Image caption. Empty'
337
336
  : sprintf(
@@ -15,41 +15,24 @@ import {
15
15
  __experimentalToolsPanelItem as ToolsPanelItem,
16
16
  __experimentalUseCustomUnits as useCustomUnits,
17
17
  } from '@wordpress/components';
18
- import { useViewportMatch, usePrevious } from '@wordpress/compose';
18
+ import { useViewportMatch } from '@wordpress/compose';
19
19
  import { useSelect, useDispatch } from '@wordpress/data';
20
20
  import {
21
21
  BlockControls,
22
22
  InspectorControls,
23
- RichText,
24
23
  __experimentalImageURLInputUI as ImageURLInputUI,
25
24
  MediaReplaceFlow,
26
25
  store as blockEditorStore,
27
26
  useSettings,
28
27
  __experimentalImageEditor as ImageEditor,
29
- __experimentalGetElementClassName,
30
28
  __experimentalUseBorderProps as useBorderProps,
31
29
  privateApis as blockEditorPrivateApis,
32
30
  } from '@wordpress/block-editor';
33
- import {
34
- useEffect,
35
- useMemo,
36
- useState,
37
- useRef,
38
- useCallback,
39
- } from '@wordpress/element';
31
+ import { useEffect, useMemo, useState, useRef } from '@wordpress/element';
40
32
  import { __, _x, sprintf, isRTL } from '@wordpress/i18n';
41
33
  import { getFilename } from '@wordpress/url';
42
- import {
43
- createBlock,
44
- getDefaultBlockName,
45
- switchToBlockType,
46
- } from '@wordpress/blocks';
47
- import {
48
- crop,
49
- overlayText,
50
- upload,
51
- caption as captionIcon,
52
- } from '@wordpress/icons';
34
+ import { switchToBlockType } from '@wordpress/blocks';
35
+ import { crop, overlayText, upload } from '@wordpress/icons';
53
36
  import { store as noticesStore } from '@wordpress/notices';
54
37
  import { store as coreStore } from '@wordpress/core-data';
55
38
 
@@ -60,6 +43,7 @@ import { unlock } from '../lock-unlock';
60
43
  import { createUpgradedEmbedBlock } from '../embed/util';
61
44
  import useClientWidth from './use-client-width';
62
45
  import { isExternalImage } from './edit';
46
+ import { Caption } from '../utils/caption';
63
47
 
64
48
  /**
65
49
  * Module constants
@@ -125,7 +109,6 @@ export default function Image( {
125
109
  const {
126
110
  url = '',
127
111
  alt,
128
- caption,
129
112
  align,
130
113
  id,
131
114
  href,
@@ -147,8 +130,6 @@ export default function Image( {
147
130
  const numericHeight = height ? parseInt( height, 10 ) : undefined;
148
131
 
149
132
  const imageRef = useRef();
150
- const prevCaption = usePrevious( caption );
151
- const [ showCaption, setShowCaption ] = useState( !! caption );
152
133
  const { allowResize = true } = context;
153
134
  const { getBlock } = useSelect( blockEditorStore );
154
135
 
@@ -247,24 +228,6 @@ export default function Image( {
247
228
  .catch( () => {} );
248
229
  }, [ id, url, isSelected, externalBlob, canUploadMedia ] );
249
230
 
250
- // We need to show the caption when changes come from
251
- // history navigation(undo/redo).
252
- useEffect( () => {
253
- if ( caption && ! prevCaption ) {
254
- setShowCaption( true );
255
- }
256
- }, [ caption, prevCaption ] );
257
-
258
- // Focus the caption when we click to add one.
259
- const captionRef = useCallback(
260
- ( node ) => {
261
- if ( node && ! caption ) {
262
- node.focus();
263
- }
264
- },
265
- [ caption ]
266
- );
267
-
268
231
  // Get naturalWidth and naturalHeight from image ref, and fall back to loaded natural
269
232
  // width and height. This resolves an issue in Safari where the loaded natural
270
233
  // width and height is otherwise lost when switching between alignments.
@@ -355,11 +318,8 @@ export default function Image( {
355
318
  useEffect( () => {
356
319
  if ( ! isSelected ) {
357
320
  setIsEditingImage( false );
358
- if ( ! caption ) {
359
- setShowCaption( false );
360
- }
361
321
  }
362
- }, [ isSelected, caption ] );
322
+ }, [ isSelected ] );
363
323
 
364
324
  const canEditImage = id && naturalWidth && naturalHeight && imageEditing;
365
325
  const allowCrop = ! multiImageSelection && canEditImage && ! isEditingImage;
@@ -420,6 +380,7 @@ export default function Image( {
420
380
 
421
381
  const resetAll = () => {
422
382
  setAttributes( {
383
+ alt: undefined,
423
384
  width: undefined,
424
385
  height: undefined,
425
386
  scale: undefined,
@@ -439,23 +400,6 @@ export default function Image( {
439
400
  const controls = (
440
401
  <>
441
402
  <BlockControls group="block">
442
- { hasNonContentControls && (
443
- <ToolbarButton
444
- onClick={ () => {
445
- setShowCaption( ! showCaption );
446
- if ( showCaption && caption ) {
447
- setAttributes( { caption: undefined } );
448
- }
449
- } }
450
- icon={ captionIcon }
451
- isPressed={ showCaption }
452
- label={
453
- showCaption
454
- ? __( 'Remove caption' )
455
- : __( 'Add caption' )
456
- }
457
- />
458
- ) }
459
403
  { ! multiImageSelection && ! isEditingImage && (
460
404
  <ImageURLInputUI
461
405
  url={ href || '' }
@@ -513,14 +457,14 @@ export default function Image( {
513
457
  <ToolsPanelItem
514
458
  label={ __( 'Alternative text' ) }
515
459
  isShownByDefault={ true }
516
- hasValue={ () => alt !== '' }
460
+ hasValue={ () => !! alt }
517
461
  onDeselect={ () =>
518
462
  setAttributes( { alt: undefined } )
519
463
  }
520
464
  >
521
465
  <TextareaControl
522
466
  label={ __( 'Alternative text' ) }
523
- value={ alt }
467
+ value={ alt || '' }
524
468
  onChange={ updateAlt }
525
469
  help={
526
470
  <>
@@ -538,11 +482,13 @@ export default function Image( {
538
482
  </ToolsPanelItem>
539
483
  ) }
540
484
  { isResizable && dimensionsControl }
541
- <ResolutionTool
542
- value={ sizeSlug }
543
- onChange={ updateImage }
544
- options={ imageSizeOptions }
545
- />
485
+ { !! imageSizeOptions.length && (
486
+ <ResolutionTool
487
+ value={ sizeSlug }
488
+ onChange={ updateImage }
489
+ options={ imageSizeOptions }
490
+ />
491
+ ) }
546
492
  { showLightboxToggle && (
547
493
  <ToolsPanelItem
548
494
  hasValue={ () => !! lightbox }
@@ -793,29 +739,14 @@ export default function Image( {
793
739
  which causes duplicated image upload. */ }
794
740
  { ! temporaryURL && controls }
795
741
  { img }
796
- { showCaption &&
797
- ( ! RichText.isEmpty( caption ) || isSelected ) && (
798
- <RichText
799
- identifier="caption"
800
- className={ __experimentalGetElementClassName(
801
- 'caption'
802
- ) }
803
- ref={ captionRef }
804
- tagName="figcaption"
805
- aria-label={ __( 'Image caption text' ) }
806
- placeholder={ __( 'Add caption' ) }
807
- value={ caption }
808
- onChange={ ( value ) =>
809
- setAttributes( { caption: value } )
810
- }
811
- inlineToolbar
812
- __unstableOnSplitAtEnd={ () =>
813
- insertBlocksAfter(
814
- createBlock( getDefaultBlockName() )
815
- )
816
- }
817
- />
818
- ) }
742
+ <Caption
743
+ attributes={ attributes }
744
+ setAttributes={ setAttributes }
745
+ isSelected={ isSelected }
746
+ insertBlocksAfter={ insertBlocksAfter }
747
+ label={ __( 'Image caption text' ) }
748
+ showToolbarButton={ hasNonContentControls }
749
+ />
819
750
  </>
820
751
  );
821
752
  }
package/src/image/save.js CHANGED
@@ -36,7 +36,9 @@ export default function save( { attributes } ) {
36
36
  const borderProps = getBorderClassesAndStyles( attributes );
37
37
 
38
38
  const classes = classnames( {
39
- [ `align${ align }` ]: align,
39
+ // All other align classes are handled by block supports.
40
+ // `{ align: 'none' }` is unique to transforms for the image block.
41
+ alignnone: 'none' === align,
40
42
  [ `size-${ sizeSlug }` ]: sizeSlug,
41
43
  'is-resized': width || height,
42
44
  'has-custom-border':
@@ -12,16 +12,23 @@
12
12
  "type": "string"
13
13
  },
14
14
  "content": {
15
- "type": "string",
16
- "source": "html",
15
+ "type": "rich-text",
16
+ "source": "rich-text",
17
17
  "selector": "li",
18
- "default": "",
19
18
  "__experimentalRole": "content"
20
19
  }
21
20
  },
22
21
  "supports": {
23
22
  "className": false,
24
23
  "__experimentalSelector": "li",
24
+ "spacing": {
25
+ "margin": true,
26
+ "padding": true,
27
+ "__experimentalDefaultControls": {
28
+ "margin": false,
29
+ "padding": false
30
+ }
31
+ },
25
32
  "typography": {
26
33
  "fontSize": true,
27
34
  "lineHeight": true,
@@ -24,7 +24,6 @@ import {
24
24
  getColorClassName,
25
25
  Warning,
26
26
  __experimentalColorGradientSettingsDropdown as ColorGradientSettingsDropdown,
27
- __experimentalUseBlockOverlayActive as useBlockOverlayActive,
28
27
  __experimentalUseMultipleOriginColorsAndGradients as useMultipleOriginColorsAndGradients,
29
28
  useBlockEditingMode,
30
29
  } from '@wordpress/block-editor';
@@ -290,7 +289,13 @@ function Navigation( {
290
289
 
291
290
  const textDecoration = attributes.style?.typography?.textDecoration;
292
291
 
293
- const hasBlockOverlay = useBlockOverlayActive( clientId );
292
+ const hasBlockOverlay = useSelect(
293
+ ( select ) =>
294
+ select( blockEditorStore ).__unstableHasActiveBlockOverlayActive(
295
+ clientId
296
+ ),
297
+ [ clientId ]
298
+ );
294
299
  const isResponsive = 'never' !== overlayMenu;
295
300
  const blockProps = useBlockProps( {
296
301
  ref: navRef,
@@ -75,7 +75,7 @@ if ( defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ) {
75
75
  function block_core_navigation_get_inner_blocks_from_unstable_location( $attributes ) {
76
76
  $menu_items = block_core_navigation_get_menu_items_at_location( $attributes['__unstableLocation'] );
77
77
  if ( empty( $menu_items ) ) {
78
- return '';
78
+ return new WP_Block_List( array(), $attributes );
79
79
  }
80
80
 
81
81
  $menu_items_by_parent_id = block_core_navigation_sort_menu_items_by_parent_id( $menu_items );
@@ -30,7 +30,7 @@ exports[`hooks enhanceNavigationLinkVariations enhances variations with icon and
30
30
  xmlns="http://www.w3.org/2000/svg"
31
31
  >
32
32
  <Path
33
- d="M18 4H6c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm.5 14c0 .3-.2.5-.5.5H6c-.3 0-.5-.2-.5-.5V6c0-.3.2-.5.5-.5h12c.3 0 .5.2.5.5v12zM7 11h2V9H7v2zm0 4h2v-2H7v2zm3-4h7V9h-7v2zm0 4h7v-2h-7v2z"
33
+ d="M18 5.5H6a.5.5 0 0 0-.5.5v12a.5.5 0 0 0 .5.5h12a.5.5 0 0 0 .5-.5V6a.5.5 0 0 0-.5-.5ZM6 4h12a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2Zm1 5h1.5v1.5H7V9Zm1.5 4.5H7V15h1.5v-1.5ZM10 9h7v1.5h-7V9Zm7 4.5h-7V15h7v-1.5Z"
34
34
  />
35
35
  </SVG>,
36
36
  "isActive": [Function],
@@ -47,7 +47,10 @@ exports[`hooks enhanceNavigationLinkVariations enhances variations with icon and
47
47
  xmlns="http://www.w3.org/2000/svg"
48
48
  >
49
49
  <Path
50
- d="M7 5.5h10a.5.5 0 01.5.5v12a.5.5 0 01-.5.5H7a.5.5 0 01-.5-.5V6a.5.5 0 01.5-.5zM17 4H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V6a2 2 0 00-2-2zm-1 3.75H8v1.5h8v-1.5zM8 11h8v1.5H8V11zm6 3.25H8v1.5h6v-1.5z"
50
+ d="M15.5 7.5h-7V9h7V7.5Zm-7 3.5h7v1.5h-7V11Zm7 3.5h-7V16h7v-1.5Z"
51
+ />
52
+ <Path
53
+ d="M17 4H7a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2ZM7 5.5h10a.5.5 0 0 1 .5.5v12a.5.5 0 0 1-.5.5H7a.5.5 0 0 1-.5-.5V6a.5.5 0 0 1 .5-.5Z"
51
54
  />
52
55
  </SVG>,
53
56
  "isActive": [Function],
@@ -83,7 +86,7 @@ exports[`hooks enhanceNavigationLinkVariations enhances variations with icon and
83
86
  xmlns="http://www.w3.org/2000/svg"
84
87
  >
85
88
  <Path
86
- d="M20.1 11.2l-6.7-6.7c-.1-.1-.3-.2-.5-.2H5c-.4-.1-.8.3-.8.7v7.8c0 .2.1.4.2.5l6.7 6.7c.2.2.5.4.7.5s.6.2.9.2c.3 0 .6-.1.9-.2.3-.1.5-.3.8-.5l5.6-5.6c.4-.4.7-1 .7-1.6.1-.6-.2-1.2-.6-1.6zM19 13.4L13.4 19c-.1.1-.2.1-.3.2-.2.1-.4.1-.6 0-.1 0-.2-.1-.3-.2l-6.5-6.5V5.8h6.8l6.5 6.5c.2.2.2.4.2.6 0 .1 0 .3-.2.5zM9 8c-.6 0-1 .4-1 1s.4 1 1 1 1-.4 1-1-.4-1-1-1z"
89
+ d="M4.75 4a.75.75 0 0 0-.75.75v7.826c0 .2.08.39.22.53l6.72 6.716a2.313 2.313 0 0 0 3.276-.001l5.61-5.611-.531-.53.532.528a2.315 2.315 0 0 0 0-3.264L13.104 4.22a.75.75 0 0 0-.53-.22H4.75ZM19 12.576a.815.815 0 0 1-.236.574l-5.61 5.611a.814.814 0 0 1-1.153 0L5.5 12.264V5.5h6.763l6.5 6.502a.816.816 0 0 1 .237.574ZM8.75 9.75a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z"
87
90
  />
88
91
  </SVG>,
89
92
  "isActive": [Function],
@@ -5,7 +5,7 @@ import { Button, Modal } from '@wordpress/components';
5
5
  import { __ } from '@wordpress/i18n';
6
6
 
7
7
  export const convertDescription = __(
8
- 'This page list is synced with the published pages on your site. Detach the page list to add, delete, or reorder pages yourself.'
8
+ "This navigation menu displays your website's pages. Editing it will enable you to add, delete, or reorder pages. However, new pages will no longer be added automatically."
9
9
  );
10
10
 
11
11
  export function ConvertToLinksModal( { onClick, onClose, disabled } ) {
@@ -30,7 +30,7 @@ export function ConvertToLinksModal( { onClick, onClose, disabled } ) {
30
30
  disabled={ disabled }
31
31
  onClick={ onClick }
32
32
  >
33
- { __( 'Detach' ) }
33
+ { __( 'Edit' ) }
34
34
  </Button>
35
35
  </div>
36
36
  </Modal>
@@ -13,10 +13,9 @@
13
13
  "type": "string"
14
14
  },
15
15
  "content": {
16
- "type": "string",
17
- "source": "html",
16
+ "type": "rich-text",
17
+ "source": "rich-text",
18
18
  "selector": "p",
19
- "default": "",
20
19
  "__experimentalRole": "content"
21
20
  },
22
21
  "dropCap": {