@wordpress/block-library 9.37.2-next.ba3aee3a2.0 → 9.38.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 (238) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/build/audio/index.cjs +16 -8
  3. package/build/audio/index.cjs.map +2 -2
  4. package/build/block-keyboard-shortcuts/index.cjs +2 -4
  5. package/build/block-keyboard-shortcuts/index.cjs.map +2 -2
  6. package/build/button/index.cjs +17 -8
  7. package/build/button/index.cjs.map +2 -2
  8. package/build/code/index.cjs +3 -1
  9. package/build/code/index.cjs.map +2 -2
  10. package/build/comments-title/edit.cjs +10 -6
  11. package/build/comments-title/edit.cjs.map +2 -2
  12. package/build/cover/index.cjs +20 -10
  13. package/build/cover/index.cjs.map +2 -2
  14. package/build/details/index.cjs +3 -1
  15. package/build/details/index.cjs.map +2 -2
  16. package/build/file/index.cjs +19 -9
  17. package/build/file/index.cjs.map +2 -2
  18. package/build/heading/block.json +1 -3
  19. package/build/heading/deprecated.cjs +101 -5
  20. package/build/heading/deprecated.cjs.map +3 -3
  21. package/build/heading/edit.cjs +20 -41
  22. package/build/heading/edit.cjs.map +3 -3
  23. package/build/heading/index.cjs +3 -1
  24. package/build/heading/index.cjs.map +2 -2
  25. package/build/heading/save.cjs +2 -16
  26. package/build/heading/save.cjs.map +3 -3
  27. package/build/heading/transforms.cjs +16 -3
  28. package/build/heading/transforms.cjs.map +2 -2
  29. package/build/image/image.cjs +3 -3
  30. package/build/image/image.cjs.map +2 -2
  31. package/build/image/index.cjs +33 -17
  32. package/build/image/index.cjs.map +2 -2
  33. package/build/list-item/index.cjs +3 -1
  34. package/build/list-item/index.cjs.map +2 -2
  35. package/build/media-text/index.cjs +30 -15
  36. package/build/media-text/index.cjs.map +2 -2
  37. package/build/more/block.json +1 -0
  38. package/build/more/index.cjs +3 -1
  39. package/build/more/index.cjs.map +2 -2
  40. package/build/navigation/edit/index.cjs +7 -6
  41. package/build/navigation/edit/index.cjs.map +2 -2
  42. package/build/navigation/edit/responsive-wrapper.cjs +7 -4
  43. package/build/navigation/edit/responsive-wrapper.cjs.map +2 -2
  44. package/build/navigation/edit/use-create-overlay.cjs +2 -0
  45. package/build/navigation/edit/use-create-overlay.cjs.map +2 -2
  46. package/build/navigation-link/edit.cjs +8 -58
  47. package/build/navigation-link/edit.cjs.map +3 -3
  48. package/build/navigation-link/index.cjs +13 -8
  49. package/build/navigation-link/index.cjs.map +2 -2
  50. package/build/navigation-link/shared/index.cjs +11 -2
  51. package/build/navigation-link/shared/index.cjs.map +2 -2
  52. package/build/navigation-link/shared/invalid-draft-display.cjs +82 -0
  53. package/build/navigation-link/shared/invalid-draft-display.cjs.map +7 -0
  54. package/build/navigation-link/shared/use-enable-link-status-validation.cjs +50 -0
  55. package/build/navigation-link/shared/use-enable-link-status-validation.cjs.map +7 -0
  56. package/build/navigation-link/shared/use-is-invalid-link.cjs +64 -0
  57. package/build/navigation-link/shared/use-is-invalid-link.cjs.map +7 -0
  58. package/build/navigation-overlay-close/block.json +1 -4
  59. package/build/navigation-overlay-close/index.cjs +3 -25
  60. package/build/navigation-overlay-close/index.cjs.map +3 -3
  61. package/build/navigation-submenu/edit.cjs +36 -18
  62. package/build/navigation-submenu/edit.cjs.map +2 -2
  63. package/build/navigation-submenu/index.cjs +15 -8
  64. package/build/navigation-submenu/index.cjs.map +2 -2
  65. package/build/nextpage/block.json +1 -0
  66. package/build/paragraph/index.cjs +3 -1
  67. package/build/paragraph/index.cjs.map +2 -2
  68. package/build/paragraph/transforms.cjs +14 -3
  69. package/build/paragraph/transforms.cjs.map +3 -3
  70. package/build/preformatted/index.cjs +3 -1
  71. package/build/preformatted/index.cjs.map +2 -2
  72. package/build/pullquote/index.cjs +7 -3
  73. package/build/pullquote/index.cjs.map +2 -2
  74. package/build/search/index.cjs +10 -5
  75. package/build/search/index.cjs.map +2 -2
  76. package/build/social-link/index.cjs +13 -7
  77. package/build/social-link/index.cjs.map +2 -2
  78. package/build/table-of-contents/hooks.cjs +1 -1
  79. package/build/table-of-contents/hooks.cjs.map +1 -1
  80. package/build/template-part/edit/utils/get-template-part-icon.cjs.map +1 -1
  81. package/build/utils/is-within-overlay.cjs +52 -0
  82. package/build/utils/is-within-overlay.cjs.map +7 -0
  83. package/build/verse/index.cjs +3 -1
  84. package/build/verse/index.cjs.map +2 -2
  85. package/build/video/index.cjs +20 -10
  86. package/build/video/index.cjs.map +2 -2
  87. package/build-module/audio/index.mjs +16 -8
  88. package/build-module/audio/index.mjs.map +2 -2
  89. package/build-module/block-keyboard-shortcuts/index.mjs +2 -4
  90. package/build-module/block-keyboard-shortcuts/index.mjs.map +2 -2
  91. package/build-module/button/index.mjs +17 -8
  92. package/build-module/button/index.mjs.map +2 -2
  93. package/build-module/code/index.mjs +3 -1
  94. package/build-module/code/index.mjs.map +2 -2
  95. package/build-module/comments-title/edit.mjs +10 -6
  96. package/build-module/comments-title/edit.mjs.map +2 -2
  97. package/build-module/cover/index.mjs +20 -10
  98. package/build-module/cover/index.mjs.map +2 -2
  99. package/build-module/details/index.mjs +3 -1
  100. package/build-module/details/index.mjs.map +2 -2
  101. package/build-module/file/index.mjs +19 -9
  102. package/build-module/file/index.mjs.map +2 -2
  103. package/build-module/heading/block.json +1 -3
  104. package/build-module/heading/deprecated.mjs +101 -5
  105. package/build-module/heading/deprecated.mjs.map +2 -2
  106. package/build-module/heading/edit.mjs +22 -46
  107. package/build-module/heading/edit.mjs.map +2 -2
  108. package/build-module/heading/index.mjs +3 -1
  109. package/build-module/heading/index.mjs.map +2 -2
  110. package/build-module/heading/save.mjs +2 -6
  111. package/build-module/heading/save.mjs.map +2 -2
  112. package/build-module/heading/transforms.mjs +16 -3
  113. package/build-module/heading/transforms.mjs.map +2 -2
  114. package/build-module/image/image.mjs +3 -3
  115. package/build-module/image/image.mjs.map +2 -2
  116. package/build-module/image/index.mjs +33 -17
  117. package/build-module/image/index.mjs.map +2 -2
  118. package/build-module/list-item/index.mjs +3 -1
  119. package/build-module/list-item/index.mjs.map +2 -2
  120. package/build-module/media-text/index.mjs +30 -15
  121. package/build-module/media-text/index.mjs.map +2 -2
  122. package/build-module/more/block.json +1 -0
  123. package/build-module/more/index.mjs +3 -1
  124. package/build-module/more/index.mjs.map +2 -2
  125. package/build-module/navigation/edit/index.mjs +7 -6
  126. package/build-module/navigation/edit/index.mjs.map +2 -2
  127. package/build-module/navigation/edit/responsive-wrapper.mjs +7 -4
  128. package/build-module/navigation/edit/responsive-wrapper.mjs.map +2 -2
  129. package/build-module/navigation/edit/use-create-overlay.mjs +2 -0
  130. package/build-module/navigation/edit/use-create-overlay.mjs.map +2 -2
  131. package/build-module/navigation-link/edit.mjs +12 -60
  132. package/build-module/navigation-link/edit.mjs.map +2 -2
  133. package/build-module/navigation-link/index.mjs +13 -8
  134. package/build-module/navigation-link/index.mjs.map +2 -2
  135. package/build-module/navigation-link/shared/index.mjs +7 -1
  136. package/build-module/navigation-link/shared/index.mjs.map +2 -2
  137. package/build-module/navigation-link/shared/invalid-draft-display.mjs +47 -0
  138. package/build-module/navigation-link/shared/invalid-draft-display.mjs.map +7 -0
  139. package/build-module/navigation-link/shared/use-enable-link-status-validation.mjs +25 -0
  140. package/build-module/navigation-link/shared/use-enable-link-status-validation.mjs.map +7 -0
  141. package/build-module/navigation-link/shared/use-is-invalid-link.mjs +39 -0
  142. package/build-module/navigation-link/shared/use-is-invalid-link.mjs.map +7 -0
  143. package/build-module/navigation-overlay-close/block.json +1 -4
  144. package/build-module/navigation-overlay-close/index.mjs +3 -25
  145. package/build-module/navigation-overlay-close/index.mjs.map +2 -2
  146. package/build-module/navigation-submenu/edit.mjs +40 -19
  147. package/build-module/navigation-submenu/edit.mjs.map +2 -2
  148. package/build-module/navigation-submenu/index.mjs +15 -8
  149. package/build-module/navigation-submenu/index.mjs.map +2 -2
  150. package/build-module/nextpage/block.json +1 -0
  151. package/build-module/paragraph/index.mjs +3 -1
  152. package/build-module/paragraph/index.mjs.map +2 -2
  153. package/build-module/paragraph/transforms.mjs +2 -1
  154. package/build-module/paragraph/transforms.mjs.map +2 -2
  155. package/build-module/preformatted/index.mjs +3 -1
  156. package/build-module/preformatted/index.mjs.map +2 -2
  157. package/build-module/pullquote/index.mjs +7 -3
  158. package/build-module/pullquote/index.mjs.map +2 -2
  159. package/build-module/search/index.mjs +10 -5
  160. package/build-module/search/index.mjs.map +2 -2
  161. package/build-module/social-link/index.mjs +13 -7
  162. package/build-module/social-link/index.mjs.map +2 -2
  163. package/build-module/table-of-contents/hooks.mjs +1 -1
  164. package/build-module/table-of-contents/hooks.mjs.map +1 -1
  165. package/build-module/template-part/edit/utils/get-template-part-icon.mjs.map +1 -1
  166. package/build-module/utils/is-within-overlay.mjs +27 -0
  167. package/build-module/utils/is-within-overlay.mjs.map +7 -0
  168. package/build-module/verse/index.mjs +3 -1
  169. package/build-module/verse/index.mjs.map +2 -2
  170. package/build-module/video/index.mjs +20 -10
  171. package/build-module/video/index.mjs.map +2 -2
  172. package/build-style/navigation/style-rtl.css +1 -16
  173. package/build-style/navigation/style.css +1 -16
  174. package/build-style/style-rtl.css +1 -16
  175. package/build-style/style.css +1 -16
  176. package/package.json +37 -38
  177. package/src/audio/index.js +13 -7
  178. package/src/block-keyboard-shortcuts/index.js +4 -7
  179. package/src/breadcrumbs/index.php +6 -3
  180. package/src/button/index.js +15 -8
  181. package/src/code/index.js +2 -1
  182. package/src/comments-title/edit.js +10 -7
  183. package/src/comments-title/index.php +7 -8
  184. package/src/cover/index.js +17 -8
  185. package/src/details/index.js +2 -1
  186. package/src/file/index.js +15 -8
  187. package/src/heading/block.json +1 -3
  188. package/src/heading/deprecated.js +118 -5
  189. package/src/heading/edit.js +6 -32
  190. package/src/heading/edit.native.js +17 -2
  191. package/src/heading/index.js +2 -1
  192. package/src/heading/save.js +2 -11
  193. package/src/heading/transforms.js +16 -3
  194. package/src/image/image.js +38 -40
  195. package/src/image/index.js +29 -16
  196. package/src/list-item/index.js +2 -1
  197. package/src/media-text/index.js +27 -14
  198. package/src/more/block.json +1 -0
  199. package/src/more/index.js +2 -1
  200. package/src/navigation/edit/index.js +9 -4
  201. package/src/navigation/edit/responsive-wrapper.js +15 -8
  202. package/src/navigation/edit/test/use-create-overlay.js +12 -0
  203. package/src/navigation/edit/use-create-overlay.js +2 -0
  204. package/src/navigation/index.php +74 -24
  205. package/src/navigation/style.scss +2 -18
  206. package/src/navigation-link/edit.js +11 -97
  207. package/src/navigation-link/index.js +13 -8
  208. package/src/navigation-link/index.php +17 -29
  209. package/src/navigation-link/shared/helpers.php +46 -0
  210. package/src/navigation-link/shared/index.js +3 -0
  211. package/src/navigation-link/shared/invalid-draft-display.js +63 -0
  212. package/src/navigation-link/shared/test/use-enable-link-status-validation.test.js +127 -0
  213. package/src/navigation-link/shared/use-enable-link-status-validation.js +40 -0
  214. package/src/navigation-link/shared/use-is-invalid-link.js +72 -0
  215. package/src/navigation-overlay-close/block.json +1 -4
  216. package/src/navigation-overlay-close/index.js +2 -37
  217. package/src/navigation-overlay-close/index.php +37 -1
  218. package/src/navigation-submenu/edit.js +49 -24
  219. package/src/navigation-submenu/index.js +13 -8
  220. package/src/navigation-submenu/index.php +25 -18
  221. package/src/nextpage/block.json +1 -0
  222. package/src/paragraph/index.js +2 -1
  223. package/src/paragraph/transforms.js +3 -1
  224. package/src/preformatted/index.js +2 -1
  225. package/src/pullquote/index.js +5 -3
  226. package/src/query-title/index.php +2 -2
  227. package/src/search/index.js +7 -5
  228. package/src/social-link/index.js +12 -7
  229. package/src/table-of-contents/hooks.js +1 -1
  230. package/src/template-part/edit/utils/get-template-part-icon.js +1 -1
  231. package/src/utils/is-within-overlay.js +54 -0
  232. package/src/verse/index.js +2 -1
  233. package/src/video/index.js +17 -9
  234. package/build/navigation-overlay-close/save.cjs +0 -67
  235. package/build/navigation-overlay-close/save.cjs.map +0 -7
  236. package/build-module/navigation-overlay-close/save.mjs +0 -46
  237. package/build-module/navigation-overlay-close/save.mjs.map +0 -7
  238. package/src/navigation-overlay-close/save.js +0 -44
@@ -12,6 +12,11 @@ import {
12
12
  useBlockProps,
13
13
  } from '@wordpress/block-editor';
14
14
 
15
+ /**
16
+ * Internal dependencies
17
+ */
18
+ import migrateTextAlignAttributeToBlockSupport from '../utils/migrate-text-align';
19
+
15
20
  const blockSupports = {
16
21
  className: false,
17
22
  anchor: true,
@@ -75,7 +80,9 @@ const v1 = {
75
80
  },
76
81
  },
77
82
  migrate: ( attributes ) =>
78
- migrateCustomColors( migrateTextAlign( attributes ) ),
83
+ migrateTextAlignAttributeToBlockSupport(
84
+ migrateCustomColors( migrateTextAlign( attributes ) )
85
+ ),
79
86
  save( { attributes } ) {
80
87
  const { align, level, content, textColor, customTextColor } =
81
88
  attributes;
@@ -111,7 +118,9 @@ const v2 = {
111
118
  },
112
119
  },
113
120
  migrate: ( attributes ) =>
114
- migrateCustomColors( migrateTextAlign( attributes ) ),
121
+ migrateTextAlignAttributeToBlockSupport(
122
+ migrateCustomColors( migrateTextAlign( attributes ) )
123
+ ),
115
124
  save( { attributes } ) {
116
125
  const { align, content, customTextColor, level, textColor } =
117
126
  attributes;
@@ -149,7 +158,9 @@ const v3 = {
149
158
  },
150
159
  },
151
160
  migrate: ( attributes ) =>
152
- migrateCustomColors( migrateTextAlign( attributes ) ),
161
+ migrateTextAlignAttributeToBlockSupport(
162
+ migrateCustomColors( migrateTextAlign( attributes ) )
163
+ ),
153
164
  save( { attributes } ) {
154
165
  const { align, content, customTextColor, level, textColor } =
155
166
  attributes;
@@ -195,7 +206,10 @@ const v4 = {
195
206
  },
196
207
  attributes: blockAttributes,
197
208
  isEligible: ( { align } ) => TEXT_ALIGN_OPTIONS.includes( align ),
198
- migrate: migrateTextAlign,
209
+ migrate: ( attributes ) =>
210
+ migrateTextAlignAttributeToBlockSupport(
211
+ migrateCustomColors( migrateTextAlign( attributes ) )
212
+ ),
199
213
  save( { attributes } ) {
200
214
  const { align, content, level } = attributes;
201
215
  const TagName = 'h' + level;
@@ -283,8 +297,107 @@ const v5 = {
283
297
  </TagName>
284
298
  );
285
299
  },
300
+ migrate: ( attributes ) =>
301
+ migrateTextAlignAttributeToBlockSupport(
302
+ migrateCustomColors( migrateTextAlign( attributes ) )
303
+ ),
304
+ };
305
+
306
+ const v6 = {
307
+ supports: {
308
+ align: [ 'wide', 'full' ],
309
+ anchor: true,
310
+ className: true,
311
+ splitting: true,
312
+ __experimentalBorder: {
313
+ color: true,
314
+ radius: true,
315
+ style: true,
316
+ width: true,
317
+ },
318
+ color: {
319
+ gradients: true,
320
+ link: true,
321
+ __experimentalDefaultControls: {
322
+ background: true,
323
+ text: true,
324
+ },
325
+ },
326
+ spacing: {
327
+ margin: true,
328
+ padding: true,
329
+ },
330
+ typography: {
331
+ fontSize: true,
332
+ lineHeight: true,
333
+ __experimentalFontFamily: true,
334
+ __experimentalFontStyle: true,
335
+ __experimentalFontWeight: true,
336
+ __experimentalLetterSpacing: true,
337
+ __experimentalTextTransform: true,
338
+ __experimentalTextDecoration: true,
339
+ __experimentalWritingMode: true,
340
+ fitText: true,
341
+ __experimentalDefaultControls: {
342
+ fontSize: true,
343
+ },
344
+ },
345
+ __unstablePasteTextInline: true,
346
+ __experimentalSlashInserter: true,
347
+ interactivity: {
348
+ clientNavigation: true,
349
+ },
350
+ },
351
+ attributes: {
352
+ textAlign: {
353
+ type: 'string',
354
+ },
355
+ content: {
356
+ type: 'string',
357
+ source: 'html',
358
+ selector: 'h1,h2,h3,h4,h5,h6',
359
+ default: '',
360
+ role: 'content',
361
+ },
362
+ level: {
363
+ type: 'number',
364
+ default: 2,
365
+ },
366
+ levelOptions: {
367
+ type: 'array',
368
+ },
369
+ placeholder: {
370
+ type: 'string',
371
+ },
372
+ },
373
+ save( { attributes } ) {
374
+ const { textAlign, content, level } = attributes;
375
+ const TagName = 'h' + level;
376
+
377
+ const className = clsx( {
378
+ [ `has-text-align-${ textAlign }` ]: textAlign,
379
+ } );
380
+
381
+ return (
382
+ <TagName { ...useBlockProps.save( { className } ) }>
383
+ <RichText.Content value={ content } />
384
+ </TagName>
385
+ );
386
+ },
387
+ migrate: ( attributes ) =>
388
+ migrateTextAlignAttributeToBlockSupport(
389
+ migrateCustomColors( migrateTextAlign( attributes ) )
390
+ ),
391
+ isEligible( attributes ) {
392
+ return (
393
+ !! attributes.textAlign ||
394
+ !! attributes.className?.match(
395
+ /\bhas-text-align-(left|center|right)\b/
396
+ )
397
+ );
398
+ },
286
399
  };
287
400
 
288
- const deprecated = [ v5, v4, v3, v2, v1 ];
401
+ const deprecated = [ v6, v5, v4, v3, v2, v1 ];
289
402
 
290
403
  export default deprecated;
@@ -1,8 +1,3 @@
1
- /**
2
- * External dependencies
3
- */
4
- import clsx from 'clsx';
5
-
6
1
  /**
7
2
  * WordPress dependencies
8
3
  */
@@ -10,36 +5,26 @@ import { __ } from '@wordpress/i18n';
10
5
  import { useEffect, Platform } from '@wordpress/element';
11
6
  import { useDispatch, useSelect } from '@wordpress/data';
12
7
  import {
13
- AlignmentControl,
14
- BlockControls,
15
8
  RichText,
16
9
  useBlockProps,
17
10
  store as blockEditorStore,
18
- useBlockEditingMode,
19
11
  } from '@wordpress/block-editor';
20
12
 
21
13
  /**
22
14
  * Internal dependencies
23
15
  */
24
16
  import { generateAnchor, setAnchor } from './autogenerate-anchors';
17
+ import useDeprecatedTextAlign from '../utils/deprecated-text-align-attributes';
25
18
 
26
- function HeadingEdit( {
27
- attributes,
28
- setAttributes,
29
- mergeBlocks,
30
- onReplace,
31
- style,
32
- clientId,
33
- } ) {
34
- const { textAlign, content, level, placeholder, anchor } = attributes;
19
+ function HeadingEdit( props ) {
20
+ const { attributes, setAttributes, mergeBlocks, onReplace, clientId } =
21
+ props;
22
+ useDeprecatedTextAlign( props );
23
+ const { style, content, level, placeholder, anchor } = attributes;
35
24
  const tagName = 'h' + level;
36
25
  const blockProps = useBlockProps( {
37
- className: clsx( {
38
- [ `has-text-align-${ textAlign }` ]: textAlign,
39
- } ),
40
26
  style,
41
27
  } );
42
- const blockEditingMode = useBlockEditingMode();
43
28
 
44
29
  const { canGenerateAnchors } = useSelect( ( select ) => {
45
30
  const { getGlobalBlockCount, getSettings } = select( blockEditorStore );
@@ -90,16 +75,6 @@ function HeadingEdit( {
90
75
 
91
76
  return (
92
77
  <>
93
- { blockEditingMode === 'default' && (
94
- <BlockControls group="block">
95
- <AlignmentControl
96
- value={ textAlign }
97
- onChange={ ( nextAlign ) => {
98
- setAttributes( { textAlign: nextAlign } );
99
- } }
100
- />
101
- </BlockControls>
102
- ) }
103
78
  <RichText
104
79
  identifier="content"
105
80
  tagName={ tagName }
@@ -109,7 +84,6 @@ function HeadingEdit( {
109
84
  onReplace={ onReplace }
110
85
  onRemove={ () => onReplace( [] ) }
111
86
  placeholder={ placeholder || __( 'Heading' ) }
112
- textAlign={ textAlign }
113
87
  { ...( Platform.isNative && { deleteEnter: true } ) } // setup RichText on native mobile to delete the "Enter" key as it's handled by the JS/RN side
114
88
  { ...blockProps }
115
89
  />
@@ -32,7 +32,14 @@ function HeadingEdit( {
32
32
  style,
33
33
  clientId,
34
34
  } ) {
35
- const { textAlign, content, level, placeholder, anchor } = attributes;
35
+ const {
36
+ content,
37
+ level,
38
+ placeholder,
39
+ anchor,
40
+ style: attributesStyle,
41
+ } = attributes;
42
+ const textAlign = attributesStyle?.typography?.textAlign;
36
43
  const tagName = 'h' + level;
37
44
  const blockProps = useBlockProps( {
38
45
  className: clsx( {
@@ -100,7 +107,15 @@ function HeadingEdit( {
100
107
  <AlignmentControl
101
108
  value={ textAlign }
102
109
  onChange={ ( nextAlign ) => {
103
- setAttributes( { textAlign: nextAlign } );
110
+ setAttributes( {
111
+ style: {
112
+ ...attributesStyle,
113
+ typography: {
114
+ ...attributesStyle?.typography,
115
+ textAlign: nextAlign,
116
+ },
117
+ },
118
+ } );
104
119
  } }
105
120
  />
106
121
  </BlockControls>
@@ -82,7 +82,8 @@ if ( window.__experimentalContentOnlyInspectorFields ) {
82
82
  {
83
83
  id: 'content',
84
84
  label: __( 'Content' ),
85
- type: 'richtext',
85
+ type: 'text',
86
+ Edit: 'rich-text', // TODO: replace with custom component
86
87
  },
87
88
  ];
88
89
  settings[ formKey ] = {
@@ -1,23 +1,14 @@
1
- /**
2
- * External dependencies
3
- */
4
- import clsx from 'clsx';
5
-
6
1
  /**
7
2
  * WordPress dependencies
8
3
  */
9
4
  import { RichText, useBlockProps } from '@wordpress/block-editor';
10
5
 
11
6
  export default function save( { attributes } ) {
12
- const { textAlign, content, level } = attributes;
7
+ const { content, level } = attributes;
13
8
  const TagName = 'h' + level;
14
9
 
15
- const className = clsx( {
16
- [ `has-text-align-${ textAlign }` ]: textAlign,
17
- } );
18
-
19
10
  return (
20
- <TagName { ...useBlockProps.save( { className } ) }>
11
+ <TagName { ...useBlockProps.save() }>
21
12
  <RichText.Content value={ content } />
22
13
  </TagName>
23
14
  );
@@ -29,7 +29,13 @@ const transforms = {
29
29
  ),
30
30
  content,
31
31
  anchor,
32
- textAlign,
32
+ ...( textAlign && {
33
+ style: {
34
+ typography: {
35
+ textAlign,
36
+ },
37
+ },
38
+ } ),
33
39
  } );
34
40
  } ),
35
41
  },
@@ -64,7 +70,13 @@ const transforms = {
64
70
  textAlign === 'center' ||
65
71
  textAlign === 'right'
66
72
  ) {
67
- attributes.align = textAlign;
73
+ attributes.style = {
74
+ ...attributes.style,
75
+ typography: {
76
+ ...attributes.style?.typography,
77
+ textAlign,
78
+ },
79
+ };
68
80
  }
69
81
 
70
82
  return createBlock( 'core/heading', attributes );
@@ -93,7 +105,8 @@ const transforms = {
93
105
  blocks: [ 'core/paragraph' ],
94
106
  transform: ( attributes ) =>
95
107
  attributes.map( ( _attributes ) => {
96
- const { content, textAlign } = _attributes;
108
+ const { content, style } = _attributes;
109
+ const textAlign = style?.typography?.textAlign;
97
110
  return createBlock( 'core/paragraph', {
98
111
  ...getTransformedAttributes(
99
112
  _attributes,
@@ -788,14 +788,14 @@ export default function Image( {
788
788
  />
789
789
  </BlockControls>
790
790
  ) }
791
- { ! hasDataFormBlockFields && (
791
+ { ! hasDataFormBlockFields && isSingleSelected && (
792
792
  <InspectorControls group="content">
793
793
  <ToolsPanel
794
794
  label={ __( 'Media' ) }
795
795
  resetAll={ () => onSelectImage( undefined ) }
796
796
  dropdownMenuProps={ dropdownMenuProps }
797
797
  >
798
- { isSingleSelected && ! lockUrlControls && (
798
+ { ! lockUrlControls && (
799
799
  <ToolsPanelItem
800
800
  label={ __( 'Image' ) }
801
801
  hasValue={ () => !! url }
@@ -822,47 +822,45 @@ export default function Image( {
822
822
  />
823
823
  </ToolsPanelItem>
824
824
  ) }
825
- { isSingleSelected && (
826
- <ToolsPanelItem
825
+ <ToolsPanelItem
826
+ label={ __( 'Alternative text' ) }
827
+ isShownByDefault
828
+ hasValue={ () => !! alt }
829
+ onDeselect={ () =>
830
+ setAttributes( { alt: undefined } )
831
+ }
832
+ >
833
+ <TextareaControl
827
834
  label={ __( 'Alternative text' ) }
828
- isShownByDefault
829
- hasValue={ () => !! alt }
830
- onDeselect={ () =>
831
- setAttributes( { alt: undefined } )
832
- }
833
- >
834
- <TextareaControl
835
- label={ __( 'Alternative text' ) }
836
- value={ alt || '' }
837
- onChange={ updateAlt }
838
- readOnly={ lockAltControls }
839
- help={
840
- lockAltControls ? (
841
- <>{ lockAltControlsMessage }</>
842
- ) : (
843
- <>
844
- <ExternalLink
845
- href={
846
- // translators: Localized tutorial, if one exists. W3C Web Accessibility Initiative link has list of existing translations.
847
- __(
848
- 'https://www.w3.org/WAI/tutorials/images/decision-tree/'
849
- )
850
- }
851
- >
852
- { __(
853
- 'Describe the purpose of the image.'
854
- ) }
855
- </ExternalLink>
856
- <br />
835
+ value={ alt || '' }
836
+ onChange={ updateAlt }
837
+ readOnly={ lockAltControls }
838
+ help={
839
+ lockAltControls ? (
840
+ <>{ lockAltControlsMessage }</>
841
+ ) : (
842
+ <>
843
+ <ExternalLink
844
+ href={
845
+ // translators: Localized tutorial, if one exists. W3C Web Accessibility Initiative link has list of existing translations.
846
+ __(
847
+ 'https://www.w3.org/WAI/tutorials/images/decision-tree/'
848
+ )
849
+ }
850
+ >
857
851
  { __(
858
- 'Leave empty if decorative.'
852
+ 'Describe the purpose of the image.'
859
853
  ) }
860
- </>
861
- )
862
- }
863
- />
864
- </ToolsPanelItem>
865
- ) }
854
+ </ExternalLink>
855
+ <br />
856
+ { __(
857
+ 'Leave empty if decorative.'
858
+ ) }
859
+ </>
860
+ )
861
+ }
862
+ />
863
+ </ToolsPanelItem>
866
864
  </ToolsPanel>
867
865
  </InspectorControls>
868
866
  ) }
@@ -72,32 +72,45 @@ if ( window.__experimentalContentOnlyInspectorFields ) {
72
72
  id: 'image',
73
73
  label: __( 'Image' ),
74
74
  type: 'media',
75
- mapping: {
76
- id: 'id',
77
- url: 'url',
78
- caption: 'caption',
79
- alt: 'alt',
80
- },
81
- args: {
75
+ Edit: {
76
+ control: 'media', // TODO: replace with custom component
82
77
  allowedTypes: [ 'image' ],
83
78
  multiple: false,
84
79
  },
80
+ getValue: ( { item } ) => ( {
81
+ id: item.id,
82
+ url: item.url,
83
+ alt: item.alt,
84
+ caption: item.caption,
85
+ } ),
86
+ setValue: ( { value } ) => ( {
87
+ id: value.id,
88
+ url: value.url,
89
+ alt: value.alt,
90
+ caption: value.caption,
91
+ } ),
85
92
  },
86
93
  {
87
94
  id: 'link',
88
95
  label: __( 'Link' ),
89
- type: 'link',
90
- mapping: {
91
- url: 'href',
92
- rel: 'rel',
93
- linkTarget: 'linkTarget',
94
- destination: 'linkDestination',
95
- },
96
+ type: 'url',
97
+ Edit: 'link', // TODO: replace with custom component
98
+ getValue: ( { item } ) => ( {
99
+ url: item.href,
100
+ rel: item.rel,
101
+ linkTarget: item.linkTarget,
102
+ } ),
103
+ setValue: ( { value } ) => ( {
104
+ href: value.url,
105
+ rel: value.rel,
106
+ linkTarget: value.linkTarget,
107
+ } ),
96
108
  },
97
109
  {
98
110
  id: 'caption',
99
111
  label: __( 'Caption' ),
100
- type: 'richtext',
112
+ type: 'text',
113
+ Edit: 'rich-text', // TODO: replace with custom component
101
114
  },
102
115
  {
103
116
  id: 'alt',
@@ -106,7 +119,7 @@ if ( window.__experimentalContentOnlyInspectorFields ) {
106
119
  },
107
120
  ];
108
121
  settings[ formKey ] = {
109
- fields: [ 'image' ],
122
+ fields: [ 'image', 'link', 'caption', 'alt' ],
110
123
  };
111
124
  }
112
125
 
@@ -41,7 +41,8 @@ if ( window.__experimentalContentOnlyInspectorFields ) {
41
41
  {
42
42
  id: 'content',
43
43
  label: __( 'Content' ),
44
- type: 'richtext',
44
+ type: 'text',
45
+ Edit: 'rich-text', // TODO: replace with custom component
45
46
  },
46
47
  ];
47
48
  settings[ formKey ] = {
@@ -60,30 +60,43 @@ if ( window.__experimentalContentOnlyInspectorFields ) {
60
60
  id: 'media',
61
61
  label: __( 'Media' ),
62
62
  type: 'media',
63
- mapping: {
64
- id: 'mediaId',
65
- type: 'mediaType',
66
- url: 'mediaUrl',
67
- link: 'mediaLink',
68
- },
69
- args: {
63
+ Edit: {
64
+ control: 'media', // TODO: replace with custom component
70
65
  allowedTypes: [ 'image', 'video' ],
71
66
  multiple: false,
72
67
  },
68
+ getValue: ( { item } ) => ( {
69
+ id: item.mediaId,
70
+ url: item.mediaUrl,
71
+ mediaType: item.mediaType,
72
+ link: item.mediaLink,
73
+ } ),
74
+ setValue: ( { value } ) => ( {
75
+ mediaId: value.id,
76
+ mediaUrl: value.url,
77
+ mediaType: value.mediaType,
78
+ mediaLink: value.link,
79
+ } ),
73
80
  },
74
81
  {
75
82
  id: 'link',
76
83
  label: __( 'Link' ),
77
- type: 'link',
78
- mapping: {
79
- url: 'href',
80
- rel: 'rel',
81
- linkTarget: 'linkTarget',
82
- },
84
+ type: 'url',
85
+ Edit: 'link', // TODO: replace with custom component
86
+ getValue: ( { item } ) => ( {
87
+ url: item.href,
88
+ rel: item.rel,
89
+ linkTarget: item.linkTarget,
90
+ } ),
91
+ setValue: ( { value } ) => ( {
92
+ href: value.url,
93
+ rel: value.rel,
94
+ linkTarget: value.linkTarget,
95
+ } ),
83
96
  },
84
97
  ];
85
98
  settings[ formKey ] = {
86
- fields: [ 'media' ],
99
+ fields: [ 'media', 'link' ],
87
100
  };
88
101
  }
89
102
 
@@ -23,6 +23,7 @@
23
23
  "className": false,
24
24
  "html": false,
25
25
  "multiple": false,
26
+ "visibility": false,
26
27
  "interactivity": {
27
28
  "clientNavigation": true
28
29
  }
package/src/more/index.js CHANGED
@@ -45,7 +45,8 @@ if ( window.__experimentalContentOnlyInspectorFields ) {
45
45
  {
46
46
  id: 'customText',
47
47
  label: __( 'Content' ),
48
- type: 'richtext',
48
+ type: 'text',
49
+ Edit: 'rich-text', // TODO: replace with custom component
49
50
  },
50
51
  ];
51
52
  settings[ formKey ] = {
@@ -130,6 +130,7 @@ function ColorTools( {
130
130
  setOverlayBackgroundColor,
131
131
  clientId,
132
132
  navRef,
133
+ hasCustomOverlay,
133
134
  } ) {
134
135
  const [ detectedBackgroundColor, setDetectedBackgroundColor ] = useState();
135
136
  const [ detectedColor, setDetectedColor ] = useState();
@@ -201,7 +202,9 @@ function ColorTools( {
201
202
  },
202
203
  {
203
204
  colorValue: overlayTextColor.color,
204
- label: __( 'Submenu & overlay text' ),
205
+ label: hasCustomOverlay
206
+ ? __( 'Submenu text' )
207
+ : __( 'Submenu & overlay text' ),
205
208
  onColorChange: setOverlayTextColor,
206
209
  resetAllFilter: () => setOverlayTextColor(),
207
210
  clearable: true,
@@ -209,7 +212,9 @@ function ColorTools( {
209
212
  },
210
213
  {
211
214
  colorValue: overlayBackgroundColor.color,
212
- label: __( 'Submenu & overlay background' ),
215
+ label: hasCustomOverlay
216
+ ? __( 'Submenu background' )
217
+ : __( 'Submenu & overlay background' ),
213
218
  onColorChange: setOverlayBackgroundColor,
214
219
  resetAllFilter: () => setOverlayBackgroundColor(),
215
220
  clearable: true,
@@ -254,7 +259,6 @@ function Navigation( {
254
259
 
255
260
  // These props are used by the navigation editor to override specific
256
261
  // navigation block settings.
257
- hasSubmenuIndicatorSetting = true,
258
262
  customPlaceholder: CustomPlaceholder = null,
259
263
  __unstableLayoutClassNames: layoutClassNames,
260
264
  } ) {
@@ -655,7 +659,7 @@ function Navigation( {
655
659
  const stylingInspectorControls = (
656
660
  <>
657
661
  <InspectorControls>
658
- { hasSubmenuIndicatorSetting && (
662
+ { ( ! isOverlayExperimentEnabled || hasSubmenus ) && (
659
663
  <ToolsPanel
660
664
  label={ __( 'Display' ) }
661
665
  resetAll={ () => {
@@ -819,6 +823,7 @@ function Navigation( {
819
823
  setOverlayBackgroundColor={ setOverlayBackgroundColor }
820
824
  clientId={ clientId }
821
825
  navRef={ navRef }
826
+ hasCustomOverlay={ !! overlay }
822
827
  />
823
828
  </InspectorControls>
824
829
  </>