@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,7 +6,7 @@ import { View } from 'react-native';
6
6
  /**
7
7
  * WordPress dependencies
8
8
  */
9
- import { PlainText } from '@wordpress/block-editor';
9
+ import { RichText } from '@wordpress/block-editor';
10
10
  import { __ } from '@wordpress/i18n';
11
11
  import { usePreferredColorSchemeStyle } from '@wordpress/compose';
12
12
  import { createBlock, getDefaultBlockName } from '@wordpress/blocks';
@@ -20,14 +20,11 @@ import { createBlock, getDefaultBlockName } from '@wordpress/blocks';
20
20
  */
21
21
  import styles from './theme.scss';
22
22
 
23
- // Note: styling is applied directly to the (nested) PlainText component. Web-side components
24
- // apply it to the container 'div' but we don't have a proper proposal for cascading styling yet.
25
23
  export function CodeEdit( props ) {
26
24
  const {
27
25
  attributes,
28
26
  setAttributes,
29
- onFocus,
30
- onBlur,
27
+ onRemove,
31
28
  style,
32
29
  insertBlocksAfter,
33
30
  mergeBlocks,
@@ -37,30 +34,31 @@ export function CodeEdit( props ) {
37
34
  styles.blockCode,
38
35
  styles.blockCodeDark
39
36
  ),
40
- ...( style?.fontSize && { fontSize: style.fontSize } ),
41
37
  };
42
38
 
39
+ const textStyle = style?.fontSize ? { fontSize: style.fontSize } : {};
40
+
43
41
  const placeholderStyle = usePreferredColorSchemeStyle(
44
42
  styles.placeholder,
45
43
  styles.placeholderDark
46
44
  );
47
45
 
48
46
  return (
49
- <View>
50
- <PlainText
47
+ <View style={ codeStyle }>
48
+ <RichText
49
+ tagName="pre"
51
50
  value={ attributes.content }
52
51
  identifier="content"
53
- style={ codeStyle }
54
- multiline={ true }
52
+ style={ textStyle }
55
53
  underlineColorAndroid="transparent"
56
54
  onChange={ ( content ) => setAttributes( { content } ) }
57
55
  onMerge={ mergeBlocks }
56
+ onRemove={ onRemove }
58
57
  placeholder={ __( 'Write code…' ) }
59
58
  aria-label={ __( 'Code' ) }
60
- isSelected={ props.isSelected }
61
- onFocus={ onFocus }
62
- onBlur={ onBlur }
63
59
  placeholderTextColor={ placeholderStyle.color }
60
+ preserveWhiteSpace
61
+ __unstablePastePlainText
64
62
  __unstableOnSplitAtDoubleLineEnd={ () =>
65
63
  insertBlocksAfter( createBlock( getDefaultBlockName() ) )
66
64
  }
package/src/code/save.js CHANGED
@@ -13,7 +13,10 @@ export default function save( { attributes } ) {
13
13
  <pre { ...useBlockProps.save() }>
14
14
  <RichText.Content
15
15
  tagName="code"
16
- value={ escape( attributes.content ) }
16
+ // To do: `escape` encodes characters in shortcodes and URLs to
17
+ // prevent embedding in PHP. Ideally checks for the code block,
18
+ // or pre/code tags, should be made on the PHP side?
19
+ value={ escape( attributes.content.toString() ) }
17
20
  />
18
21
  </pre>
19
22
  );
@@ -49,7 +49,7 @@ describe( 'Code', () => {
49
49
  const screen = await initializeEditor( {
50
50
  initialHtml,
51
51
  } );
52
- const { getByDisplayValue } = screen;
52
+ const { findByPlaceholderText } = screen;
53
53
 
54
54
  // Get block
55
55
  const codeBlock = await getBlock( screen, 'Code' );
@@ -57,7 +57,7 @@ describe( 'Code', () => {
57
57
  fireEvent.press( codeBlock );
58
58
 
59
59
  // Get initial text
60
- const codeBlockText = getByDisplayValue( 'Sample text' );
60
+ const codeBlockText = await findByPlaceholderText( 'Write code…' );
61
61
  expect( codeBlockText ).toBeVisible();
62
62
 
63
63
  expect( getEditorHtml() ).toMatchSnapshot();
@@ -80,7 +80,13 @@ const MEDIA_OPTIONS = [
80
80
  // Simplified tree to render Cover edit within slot.
81
81
  const CoverEdit = ( props ) => (
82
82
  <SlotFillProvider>
83
- <BlockEdit isSelected name={ cover.name } clientId={ 0 } { ...props } />
83
+ <BlockEdit
84
+ isSelected
85
+ mayDisplayControls
86
+ name={ cover.name }
87
+ clientId={ 0 }
88
+ { ...props }
89
+ />
84
90
  <BottomSheetSettings isVisible />
85
91
  </SlotFillProvider>
86
92
  );
@@ -13,8 +13,8 @@
13
13
  "default": false
14
14
  },
15
15
  "summary": {
16
- "type": "string",
17
- "source": "html",
16
+ "type": "rich-text",
17
+ "source": "rich-text",
18
18
  "selector": "summary"
19
19
  }
20
20
  },
@@ -12,8 +12,8 @@
12
12
  "__experimentalRole": "content"
13
13
  },
14
14
  "caption": {
15
- "type": "string",
16
- "source": "html",
15
+ "type": "rich-text",
16
+ "source": "rich-text",
17
17
  "selector": "figcaption",
18
18
  "__experimentalRole": "content"
19
19
  },
@@ -10,6 +10,7 @@ import classnames from 'classnames/dedupe';
10
10
  import { View } from '@wordpress/primitives';
11
11
  import {
12
12
  BlockCaption,
13
+ RichText,
13
14
  store as blockEditorStore,
14
15
  } from '@wordpress/block-editor';
15
16
  import { __, sprintf } from '@wordpress/i18n';
@@ -51,7 +52,7 @@ const EmbedPreview = ( {
51
52
  styles[ `embed-preview__sandbox--align-${ align }` ];
52
53
 
53
54
  function accessibilityLabelCreator( caption ) {
54
- return ! caption
55
+ return RichText.isEmpty( caption )
55
56
  ? /* translators: accessibility text. Empty Embed caption. */
56
57
  __( 'Embed caption. Empty' )
57
58
  : sprintf(
@@ -137,7 +137,7 @@ export const embedAnimotoIcon = (
137
137
  export const embedDailymotionIcon = (
138
138
  <SVG viewBox="0 0 24 24">
139
139
  <Path
140
- d="m12.1479 18.5957c-2.4949 0-4.28131-1.7558-4.28131-4.0658 0-2.2176 1.78641-4.0965 4.09651-4.0965 2.2793 0 4.0349 1.7864 4.0349 4.1581 0 2.2794-1.7556 4.0042-3.8501 4.0042zm8.3521-18.5957-4.5329 1v7c-1.1088-1.41691-2.8028-1.8787-4.8049-1.8787-2.09443 0-3.97329.76993-5.5133 2.27917-1.72483 1.66323-2.6489 3.78863-2.6489 6.16033 0 2.5873.98562 4.8049 2.89526 6.499 1.44763 1.2936 3.17251 1.9402 5.17454 1.9402 1.9713 0 3.4498-.5236 4.8973-1.9402v1.9402h4.5329c0-7.6359 0-15.3641 0-23z"
140
+ d="M11.903 16.568c-1.82 0-3.124-1.281-3.124-2.967a2.987 2.987 0 0 1 2.989-2.989c1.663 0 2.944 1.304 2.944 3.034 0 1.663-1.281 2.922-2.81 2.922ZM17.997 3l-3.308.73v5.107c-.809-1.034-2.045-1.37-3.505-1.37-1.529 0-2.9.561-4.023 1.662-1.259 1.214-1.933 2.764-1.933 4.495 0 1.888.72 3.506 2.113 4.742 1.056.944 2.314 1.415 3.775 1.415 1.438 0 2.517-.382 3.573-1.415v1.415h3.308V3Z"
141
141
  fill="#333436"
142
142
  />
143
143
  </SVG>
@@ -21,8 +21,8 @@
21
21
  "attribute": "id"
22
22
  },
23
23
  "fileName": {
24
- "type": "string",
25
- "source": "html",
24
+ "type": "rich-text",
25
+ "source": "rich-text",
26
26
  "selector": "a:not([download])"
27
27
  },
28
28
  "textLinkHref": {
@@ -42,8 +42,8 @@
42
42
  "default": true
43
43
  },
44
44
  "downloadButtonText": {
45
- "type": "string",
46
- "source": "html",
45
+ "type": "rich-text",
46
+ "source": "rich-text",
47
47
  "selector": "a[download]"
48
48
  },
49
49
  "displayPreview": {
package/src/file/edit.js CHANGED
@@ -102,7 +102,7 @@ function FileEdit( { attributes, isSelected, setAttributes, clientId } ) {
102
102
  revokeBlobURL( href );
103
103
  }
104
104
 
105
- if ( downloadButtonText === undefined ) {
105
+ if ( RichText.isEmpty( downloadButtonText ) ) {
106
106
  setAttributes( {
107
107
  downloadButtonText: _x( 'Download', 'button label' ),
108
108
  } );
@@ -97,7 +97,7 @@ export class FileEdit extends Component {
97
97
  const { attributes, setAttributes } = this.props;
98
98
  const { downloadButtonText } = attributes;
99
99
 
100
- if ( downloadButtonText === undefined || downloadButtonText === '' ) {
100
+ if ( RichText.isEmpty( downloadButtonText ) ) {
101
101
  setAttributes( {
102
102
  downloadButtonText: _x( 'Download', 'button label' ),
103
103
  } );
package/src/file/save.js CHANGED
@@ -25,7 +25,11 @@ export default function save( { attributes } ) {
25
25
  previewHeight,
26
26
  } = attributes;
27
27
 
28
- const pdfEmbedLabel = RichText.isEmpty( fileName ) ? 'PDF embed' : fileName;
28
+ const pdfEmbedLabel = RichText.isEmpty( fileName )
29
+ ? 'PDF embed'
30
+ : // To do: use toPlainText, but we need ensure it's RichTextData. See
31
+ // https://github.com/WordPress/gutenberg/pull/56710.
32
+ fileName.toString();
29
33
 
30
34
  const hasFilename = ! RichText.isEmpty( fileName );
31
35
 
@@ -19,10 +19,10 @@
19
19
  "type": "string"
20
20
  },
21
21
  "label": {
22
- "type": "string",
22
+ "type": "rich-text",
23
23
  "default": "Label",
24
24
  "selector": ".wp-block-form-input__label-content",
25
- "source": "html",
25
+ "source": "rich-text",
26
26
  "__experimentalRole": "content"
27
27
  },
28
28
  "inlineLabel": {
@@ -0,0 +1,142 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import classNames from 'classnames';
5
+ import removeAccents from 'remove-accents';
6
+
7
+ /**
8
+ * WordPress dependencies
9
+ */
10
+ import {
11
+ RichText,
12
+ __experimentalGetBorderClassesAndStyles as getBorderClassesAndStyles,
13
+ __experimentalGetColorClassesAndStyles as getColorClassesAndStyles,
14
+ } from '@wordpress/block-editor';
15
+ import { __unstableStripHTML as stripHTML } from '@wordpress/dom';
16
+
17
+ const getNameFromLabelV1 = ( content ) => {
18
+ return (
19
+ removeAccents( stripHTML( content ) )
20
+ // Convert anything that's not a letter or number to a hyphen.
21
+ .replace( /[^\p{L}\p{N}]+/gu, '-' )
22
+ // Convert to lowercase
23
+ .toLowerCase()
24
+ // Remove any remaining leading or trailing hyphens.
25
+ .replace( /(^-+)|(-+$)/g, '' )
26
+ );
27
+ };
28
+
29
+ // Version without wrapper div in saved markup
30
+ // See: https://github.com/WordPress/gutenberg/pull/56507
31
+ const v1 = {
32
+ attributes: {
33
+ type: {
34
+ type: 'string',
35
+ default: 'text',
36
+ },
37
+ name: {
38
+ type: 'string',
39
+ },
40
+ label: {
41
+ type: 'string',
42
+ default: 'Label',
43
+ selector: '.wp-block-form-input__label-content',
44
+ source: 'html',
45
+ __experimentalRole: 'content',
46
+ },
47
+ inlineLabel: {
48
+ type: 'boolean',
49
+ default: false,
50
+ },
51
+ required: {
52
+ type: 'boolean',
53
+ default: false,
54
+ selector: '.wp-block-form-input__input',
55
+ source: 'attribute',
56
+ attribute: 'required',
57
+ },
58
+ placeholder: {
59
+ type: 'string',
60
+ selector: '.wp-block-form-input__input',
61
+ source: 'attribute',
62
+ attribute: 'placeholder',
63
+ __experimentalRole: 'content',
64
+ },
65
+ value: {
66
+ type: 'string',
67
+ default: '',
68
+ selector: 'input',
69
+ source: 'attribute',
70
+ attribute: 'value',
71
+ },
72
+ visibilityPermissions: {
73
+ type: 'string',
74
+ default: 'all',
75
+ },
76
+ },
77
+ supports: {
78
+ className: false,
79
+ anchor: true,
80
+ reusable: false,
81
+ spacing: {
82
+ margin: [ 'top', 'bottom' ],
83
+ },
84
+ __experimentalBorder: {
85
+ radius: true,
86
+ __experimentalSkipSerialization: true,
87
+ __experimentalDefaultControls: {
88
+ radius: true,
89
+ },
90
+ },
91
+ },
92
+ save( { attributes } ) {
93
+ const { type, name, label, inlineLabel, required, placeholder, value } =
94
+ attributes;
95
+
96
+ const borderProps = getBorderClassesAndStyles( attributes );
97
+ const colorProps = getColorClassesAndStyles( attributes );
98
+
99
+ const inputStyle = {
100
+ ...borderProps.style,
101
+ ...colorProps.style,
102
+ };
103
+
104
+ const inputClasses = classNames(
105
+ 'wp-block-form-input__input',
106
+ colorProps.className,
107
+ borderProps.className
108
+ );
109
+ const TagName = type === 'textarea' ? 'textarea' : 'input';
110
+
111
+ if ( 'hidden' === type ) {
112
+ return <input type={ type } name={ name } value={ value } />;
113
+ }
114
+
115
+ /* eslint-disable jsx-a11y/label-has-associated-control */
116
+ return (
117
+ <label
118
+ className={ classNames( 'wp-block-form-input__label', {
119
+ 'is-label-inline': inlineLabel,
120
+ } ) }
121
+ >
122
+ <span className="wp-block-form-input__label-content">
123
+ <RichText.Content value={ label } />
124
+ </span>
125
+ <TagName
126
+ className={ inputClasses }
127
+ type={ 'textarea' === type ? undefined : type }
128
+ name={ name || getNameFromLabelV1( label ) }
129
+ required={ required }
130
+ aria-required={ required }
131
+ placeholder={ placeholder || undefined }
132
+ style={ inputStyle }
133
+ />
134
+ </label>
135
+ );
136
+ /* eslint-enable jsx-a11y/label-has-associated-control */
137
+ },
138
+ };
139
+
140
+ const deprecated = [ v1 ];
141
+
142
+ export default deprecated;
@@ -59,7 +59,7 @@ function InputFieldBlock( { attributes, setAttributes, className } ) {
59
59
  </PanelBody>
60
60
  </InspectorControls>
61
61
  ) }
62
- <InspectorControls __experimentalGroup="advanced">
62
+ <InspectorControls group="advanced">
63
63
  <TextControl
64
64
  autoComplete="off"
65
65
  label={ __( 'Name' ) }
@@ -2,6 +2,7 @@
2
2
  * Internal dependencies
3
3
  */
4
4
  import initBlock from '../utils/init-block';
5
+ import deprecated from './deprecated';
5
6
  import edit from './edit';
6
7
  import metadata from './block.json';
7
8
  import save from './save';
@@ -12,6 +13,7 @@ const { name } = metadata;
12
13
  export { metadata, name };
13
14
 
14
15
  export const settings = {
16
+ deprecated,
15
17
  edit,
16
18
  save,
17
19
  variations,
@@ -9,9 +9,11 @@ import removeAccents from 'remove-accents';
9
9
  */
10
10
  import {
11
11
  RichText,
12
+ useBlockProps,
12
13
  __experimentalGetBorderClassesAndStyles as getBorderClassesAndStyles,
13
14
  __experimentalGetColorClassesAndStyles as getColorClassesAndStyles,
14
15
  } from '@wordpress/block-editor';
16
+ import { __unstableStripHTML as stripHTML } from '@wordpress/dom';
15
17
 
16
18
  /**
17
19
  * Get the name attribute from a content string.
@@ -21,11 +23,8 @@ import {
21
23
  * @return {string} Returns the slug.
22
24
  */
23
25
  const getNameFromLabel = ( content ) => {
24
- const dummyElement = document.createElement( 'div' );
25
- dummyElement.innerHTML = content;
26
- // Get the slug.
27
26
  return (
28
- removeAccents( dummyElement.innerText )
27
+ removeAccents( stripHTML( content ) )
29
28
  // Convert anything that's not a letter or number to a hyphen.
30
29
  .replace( /[^\p{L}\p{N}]+/gu, '-' )
31
30
  // Convert to lowercase
@@ -54,30 +53,34 @@ export default function save( { attributes } ) {
54
53
  );
55
54
  const TagName = type === 'textarea' ? 'textarea' : 'input';
56
55
 
56
+ const blockProps = useBlockProps.save();
57
+
57
58
  if ( 'hidden' === type ) {
58
59
  return <input type={ type } name={ name } value={ value } />;
59
60
  }
60
61
 
61
- /* eslint-disable jsx-a11y/label-has-associated-control */
62
62
  return (
63
- <label
64
- className={ classNames( 'wp-block-form-input__label', {
65
- 'is-label-inline': inlineLabel,
66
- } ) }
67
- >
68
- <span className="wp-block-form-input__label-content">
69
- <RichText.Content value={ label } />
70
- </span>
71
- <TagName
72
- className={ inputClasses }
73
- type={ 'textarea' === type ? undefined : type }
74
- name={ name || getNameFromLabel( label ) }
75
- required={ required }
76
- aria-required={ required }
77
- placeholder={ placeholder || undefined }
78
- style={ inputStyle }
79
- />
80
- </label>
63
+ <div { ...blockProps }>
64
+ { /* eslint-disable jsx-a11y/label-has-associated-control */ }
65
+ <label
66
+ className={ classNames( 'wp-block-form-input__label', {
67
+ 'is-label-inline': inlineLabel,
68
+ } ) }
69
+ >
70
+ <span className="wp-block-form-input__label-content">
71
+ <RichText.Content value={ label } />
72
+ </span>
73
+ <TagName
74
+ className={ inputClasses }
75
+ type={ 'textarea' === type ? undefined : type }
76
+ name={ name || getNameFromLabel( label ) }
77
+ required={ required }
78
+ aria-required={ required }
79
+ placeholder={ placeholder || undefined }
80
+ style={ inputStyle }
81
+ />
82
+ </label>
83
+ { /* eslint-enable jsx-a11y/label-has-associated-control */ }
84
+ </div>
81
85
  );
82
- /* eslint-enable jsx-a11y/label-has-associated-control */
83
86
  }
@@ -46,8 +46,8 @@
46
46
  "attribute": "data-id"
47
47
  },
48
48
  "caption": {
49
- "type": "string",
50
- "source": "html",
49
+ "type": "rich-text",
50
+ "source": "rich-text",
51
51
  "selector": ".blocks-gallery-item__caption"
52
52
  }
53
53
  }
@@ -72,8 +72,8 @@
72
72
  "maximum": 8
73
73
  },
74
74
  "caption": {
75
- "type": "string",
76
- "source": "html",
75
+ "type": "rich-text",
76
+ "source": "rich-text",
77
77
  "selector": ".blocks-gallery-caption"
78
78
  },
79
79
  "imageCrop": {
@@ -6,7 +6,7 @@ import classnames from 'classnames';
6
6
  /**
7
7
  * WordPress dependencies
8
8
  */
9
- import { compose, usePrevious } from '@wordpress/compose';
9
+ import { compose } from '@wordpress/compose';
10
10
  import {
11
11
  BaseControl,
12
12
  PanelBody,
@@ -14,7 +14,6 @@ import {
14
14
  ToggleControl,
15
15
  RangeControl,
16
16
  Spinner,
17
- ToolbarButton,
18
17
  } from '@wordpress/components';
19
18
  import {
20
19
  store as blockEditorStore,
@@ -25,13 +24,7 @@ import {
25
24
  BlockControls,
26
25
  MediaReplaceFlow,
27
26
  } from '@wordpress/block-editor';
28
- import {
29
- Platform,
30
- useCallback,
31
- useEffect,
32
- useState,
33
- useMemo,
34
- } from '@wordpress/element';
27
+ import { Platform, useEffect, useMemo } from '@wordpress/element';
35
28
  import { __, _x, sprintf } from '@wordpress/i18n';
36
29
  import { useSelect, useDispatch } from '@wordpress/data';
37
30
  import { withViewportMatch } from '@wordpress/viewport';
@@ -39,7 +32,6 @@ import { View } from '@wordpress/primitives';
39
32
  import { createBlock } from '@wordpress/blocks';
40
33
  import { createBlobURL } from '@wordpress/blob';
41
34
  import { store as noticesStore } from '@wordpress/notices';
42
- import { caption as captionIcon } from '@wordpress/icons';
43
35
 
44
36
  /**
45
37
  * Internal dependencies
@@ -94,34 +86,7 @@ function GalleryEdit( props ) {
94
86
  onFocus,
95
87
  } = props;
96
88
 
97
- const { columns, imageCrop, linkTarget, linkTo, sizeSlug, caption } =
98
- attributes;
99
- const [ showCaption, setShowCaption ] = useState( !! caption );
100
- const prevCaption = usePrevious( caption );
101
-
102
- // We need to show the caption when changes come from
103
- // history navigation(undo/redo).
104
- useEffect( () => {
105
- if ( caption && ! prevCaption ) {
106
- setShowCaption( true );
107
- }
108
- }, [ caption, prevCaption ] );
109
-
110
- useEffect( () => {
111
- if ( ! isSelected && ! caption ) {
112
- setShowCaption( false );
113
- }
114
- }, [ isSelected, caption ] );
115
-
116
- // Focus the caption when we click to add one.
117
- const captionRef = useCallback(
118
- ( node ) => {
119
- if ( node && ! caption ) {
120
- node.focus();
121
- }
122
- },
123
- [ caption ]
124
- );
89
+ const { columns, imageCrop, linkTarget, linkTo, sizeSlug } = attributes;
125
90
 
126
91
  const {
127
92
  __unstableMarkNextChangeAsNotPersistent,
@@ -620,25 +585,6 @@ function GalleryEdit( props ) {
620
585
  </InspectorControls>
621
586
  { Platform.isWeb && (
622
587
  <>
623
- <BlockControls group="block">
624
- { ! isContentLocked && (
625
- <ToolbarButton
626
- onClick={ () => {
627
- setShowCaption( ! showCaption );
628
- if ( showCaption && caption ) {
629
- setAttributes( { caption: undefined } );
630
- }
631
- } }
632
- icon={ captionIcon }
633
- isPressed={ showCaption }
634
- label={
635
- showCaption
636
- ? __( 'Remove caption' )
637
- : __( 'Add caption' )
638
- }
639
- />
640
- ) }
641
- </BlockControls>
642
588
  <BlockControls group="other">
643
589
  <MediaReplaceFlow
644
590
  allowedTypes={ ALLOWED_MEDIA_TYPES }
@@ -661,8 +607,7 @@ function GalleryEdit( props ) {
661
607
  ) }
662
608
  <Gallery
663
609
  { ...props }
664
- showCaption={ showCaption }
665
- ref={ Platform.isWeb ? captionRef : undefined }
610
+ isContentLocked={ isContentLocked }
666
611
  images={ images }
667
612
  mediaPlaceholder={
668
613
  ! hasImages || Platform.isNative