@wordpress/block-library 9.41.1-next.v.202603161435.0 → 9.43.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 (109) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/build/form-input/edit.cjs +36 -29
  3. package/build/form-input/edit.cjs.map +2 -2
  4. package/build/form-input/variations.cjs +10 -0
  5. package/build/form-input/variations.cjs.map +2 -2
  6. package/build/group/block.json +3 -1
  7. package/build/html/modal.cjs +151 -229
  8. package/build/html/modal.cjs.map +2 -2
  9. package/build/image/image.cjs +13 -4
  10. package/build/image/image.cjs.map +2 -2
  11. package/build/latest-comments/deprecated.cjs +33 -0
  12. package/build/latest-comments/deprecated.cjs.map +2 -2
  13. package/build/list-item/block.json +1 -0
  14. package/build/navigation/edit/index.cjs +123 -119
  15. package/build/navigation/edit/index.cjs.map +3 -3
  16. package/build/navigation/edit/navigation-menu-selector.cjs +2 -1
  17. package/build/navigation/edit/navigation-menu-selector.cjs.map +2 -2
  18. package/build/post-date/block.json +1 -3
  19. package/build/post-date/deprecated.cjs +82 -6
  20. package/build/post-date/deprecated.cjs.map +3 -3
  21. package/build/post-date/edit.cjs +49 -62
  22. package/build/post-date/edit.cjs.map +3 -3
  23. package/build/site-logo/edit.cjs +19 -13
  24. package/build/site-logo/edit.cjs.map +3 -3
  25. package/build/site-tagline/deprecated.cjs +2 -1
  26. package/build/site-tagline/deprecated.cjs.map +2 -2
  27. package/build/site-title/index.cjs +5 -1
  28. package/build/site-title/index.cjs.map +2 -2
  29. package/build/tab/save.cjs +2 -4
  30. package/build/tab/save.cjs.map +2 -2
  31. package/build/tabs/save.cjs +2 -4
  32. package/build/tabs/save.cjs.map +2 -2
  33. package/build/utils/media-control.cjs +1 -1
  34. package/build/utils/media-control.cjs.map +2 -2
  35. package/build-module/form-input/edit.mjs +36 -29
  36. package/build-module/form-input/edit.mjs.map +2 -2
  37. package/build-module/form-input/variations.mjs +10 -0
  38. package/build-module/form-input/variations.mjs.map +2 -2
  39. package/build-module/group/block.json +3 -1
  40. package/build-module/html/modal.mjs +151 -229
  41. package/build-module/html/modal.mjs.map +2 -2
  42. package/build-module/image/image.mjs +13 -4
  43. package/build-module/image/image.mjs.map +2 -2
  44. package/build-module/latest-comments/deprecated.mjs +33 -0
  45. package/build-module/latest-comments/deprecated.mjs.map +2 -2
  46. package/build-module/list-item/block.json +1 -0
  47. package/build-module/navigation/edit/index.mjs +123 -119
  48. package/build-module/navigation/edit/index.mjs.map +2 -2
  49. package/build-module/navigation/edit/navigation-menu-selector.mjs +2 -1
  50. package/build-module/navigation/edit/navigation-menu-selector.mjs.map +2 -2
  51. package/build-module/post-date/block.json +1 -3
  52. package/build-module/post-date/deprecated.mjs +82 -6
  53. package/build-module/post-date/deprecated.mjs.map +2 -2
  54. package/build-module/post-date/edit.mjs +49 -63
  55. package/build-module/post-date/edit.mjs.map +2 -2
  56. package/build-module/site-logo/edit.mjs +21 -14
  57. package/build-module/site-logo/edit.mjs.map +2 -2
  58. package/build-module/site-tagline/deprecated.mjs +2 -1
  59. package/build-module/site-tagline/deprecated.mjs.map +2 -2
  60. package/build-module/site-title/index.mjs +5 -1
  61. package/build-module/site-title/index.mjs.map +2 -2
  62. package/build-module/tab/save.mjs +2 -4
  63. package/build-module/tab/save.mjs.map +2 -2
  64. package/build-module/tabs/save.mjs +2 -4
  65. package/build-module/tabs/save.mjs.map +2 -2
  66. package/build-module/utils/media-control.mjs +1 -1
  67. package/build-module/utils/media-control.mjs.map +2 -2
  68. package/build-style/editor-rtl.css +15 -5
  69. package/build-style/editor.css +15 -5
  70. package/build-style/form-input/editor-rtl.css +6 -5
  71. package/build-style/form-input/editor.css +6 -5
  72. package/build-style/icon/editor-rtl.css +5 -0
  73. package/build-style/icon/editor.css +5 -0
  74. package/build-style/image/editor-rtl.css +4 -0
  75. package/build-style/image/editor.css +4 -0
  76. package/build-style/navigation/style-rtl.css +4 -1
  77. package/build-style/navigation/style.css +4 -1
  78. package/build-style/style-rtl.css +4 -1
  79. package/build-style/style.css +4 -1
  80. package/package.json +38 -38
  81. package/src/form-input/edit.js +19 -15
  82. package/src/form-input/editor.scss +6 -6
  83. package/src/form-input/variations.js +10 -0
  84. package/src/group/block.json +3 -1
  85. package/src/home-link/index.php +14 -33
  86. package/src/html/modal.js +6 -77
  87. package/src/icon/editor.scss +5 -0
  88. package/src/image/editor.scss +5 -0
  89. package/src/image/image.js +18 -3
  90. package/src/latest-comments/deprecated.js +33 -0
  91. package/src/list-item/block.json +1 -0
  92. package/src/loginout/index.php +13 -0
  93. package/src/navigation/edit/index.js +134 -130
  94. package/src/navigation/edit/navigation-menu-selector.js +2 -1
  95. package/src/navigation/index.php +24 -6
  96. package/src/navigation/style.scss +5 -3
  97. package/src/navigation-link/index.php +10 -38
  98. package/src/navigation-link/shared/build-css-font-sizes.php +43 -0
  99. package/src/navigation-submenu/index.php +10 -38
  100. package/src/page-list/index.php +14 -41
  101. package/src/post-date/block.json +1 -3
  102. package/src/post-date/deprecated.js +86 -6
  103. package/src/post-date/edit.js +65 -82
  104. package/src/site-logo/edit.js +24 -13
  105. package/src/site-tagline/deprecated.js +1 -0
  106. package/src/site-title/index.js +5 -1
  107. package/src/tab/save.js +2 -6
  108. package/src/tabs/save.js +2 -6
  109. package/src/utils/media-control.js +3 -1
@@ -7,6 +7,84 @@ import clsx from 'clsx';
7
7
  * Internal dependencies
8
8
  */
9
9
  import migrateFontFamily from '../utils/migrate-font-family';
10
+ import migrateTextAlign from '../utils/migrate-text-align';
11
+
12
+ const v4 = {
13
+ attributes: {
14
+ datetime: {
15
+ type: 'string',
16
+ role: 'content',
17
+ },
18
+ textAlign: {
19
+ type: 'string',
20
+ },
21
+ format: {
22
+ type: 'string',
23
+ },
24
+ isLink: {
25
+ type: 'boolean',
26
+ default: false,
27
+ role: 'content',
28
+ },
29
+ },
30
+ supports: {
31
+ anchor: true,
32
+ html: false,
33
+ color: {
34
+ gradients: true,
35
+ link: true,
36
+ __experimentalDefaultControls: {
37
+ background: true,
38
+ text: true,
39
+ link: true,
40
+ },
41
+ },
42
+ spacing: {
43
+ margin: true,
44
+ padding: true,
45
+ },
46
+ typography: {
47
+ fontSize: true,
48
+ lineHeight: true,
49
+ __experimentalFontFamily: true,
50
+ __experimentalFontWeight: true,
51
+ __experimentalFontStyle: true,
52
+ __experimentalTextTransform: true,
53
+ __experimentalTextDecoration: true,
54
+ __experimentalLetterSpacing: true,
55
+ __experimentalDefaultControls: {
56
+ fontSize: true,
57
+ },
58
+ },
59
+ interactivity: {
60
+ clientNavigation: true,
61
+ },
62
+ __experimentalBorder: {
63
+ radius: true,
64
+ color: true,
65
+ width: true,
66
+ style: true,
67
+ __experimentalDefaultControls: {
68
+ radius: true,
69
+ color: true,
70
+ width: true,
71
+ style: true,
72
+ },
73
+ },
74
+ },
75
+ save() {
76
+ return null;
77
+ },
78
+ migrate: migrateTextAlign,
79
+ isEligible( attributes ) {
80
+ return (
81
+ !! attributes.textAlign ||
82
+ !! attributes.className?.match(
83
+ /\bhas-text-align-(left|center|right)\b/
84
+ )
85
+ );
86
+ },
87
+ };
10
88
 
11
89
  const v3 = {
12
90
  attributes: {
@@ -87,7 +165,7 @@ const v3 = {
87
165
  ...otherAttributes
88
166
  } ) {
89
167
  // Change the block bindings source argument name from "key" to "field".
90
- return {
168
+ return migrateTextAlign( {
91
169
  metadata: {
92
170
  bindings: {
93
171
  datetime: {
@@ -99,7 +177,7 @@ const v3 = {
99
177
  ...otherMetadata,
100
178
  },
101
179
  ...otherAttributes,
102
- };
180
+ } );
103
181
  },
104
182
  isEligible( attributes ) {
105
183
  return (
@@ -184,7 +262,7 @@ const v2 = {
184
262
  );
185
263
  }
186
264
 
187
- return {
265
+ return migrateTextAlign( {
188
266
  ...otherAttributes,
189
267
  className,
190
268
  metadata: {
@@ -196,7 +274,7 @@ const v2 = {
196
274
  },
197
275
  },
198
276
  },
199
- };
277
+ } );
200
278
  }
201
279
  },
202
280
  isEligible( attributes ) {
@@ -240,7 +318,9 @@ const v1 = {
240
318
  save() {
241
319
  return null;
242
320
  },
243
- migrate: migrateFontFamily,
321
+ migrate( attributes ) {
322
+ return migrateTextAlign( migrateFontFamily( attributes ) );
323
+ },
244
324
  isEligible( { style } ) {
245
325
  return style?.typography?.fontFamily;
246
326
  },
@@ -254,4 +334,4 @@ const v1 = {
254
334
  *
255
335
  * See block-deprecation.md
256
336
  */
257
- export default [ v3, v2, v1 ];
337
+ export default [ v4, v3, v2, v1 ];
@@ -1,8 +1,3 @@
1
- /**
2
- * External dependencies
3
- */
4
- import clsx from 'clsx';
5
-
6
1
  /**
7
2
  * WordPress dependencies
8
3
  */
@@ -14,7 +9,6 @@ import {
14
9
  getSettings as getDateSettings,
15
10
  } from '@wordpress/date';
16
11
  import {
17
- AlignmentControl,
18
12
  BlockControls,
19
13
  InspectorControls,
20
14
  store as blockEditorStore,
@@ -41,19 +35,18 @@ import { store as blocksStore } from '@wordpress/blocks';
41
35
  * Internal dependencies
42
36
  */
43
37
  import { useToolsPanelDropdownMenuProps } from '../utils/hooks';
38
+ import useDeprecatedTextAlign from '../utils/deprecated-text-align-attributes';
44
39
 
45
- export default function PostDateEdit( {
46
- attributes,
47
- context: { postType: postTypeSlug, queryId },
48
- setAttributes,
49
- name,
50
- } ) {
51
- const { datetime, textAlign, format, isLink } = attributes;
52
- const blockProps = useBlockProps( {
53
- className: clsx( {
54
- [ `has-text-align-${ textAlign }` ]: textAlign,
55
- } ),
56
- } );
40
+ export default function PostDateEdit( props ) {
41
+ const {
42
+ attributes,
43
+ context: { postType: postTypeSlug, queryId },
44
+ setAttributes,
45
+ name,
46
+ } = props;
47
+ useDeprecatedTextAlign( props );
48
+ const { datetime, format, isLink } = attributes;
49
+ const blockProps = useBlockProps();
57
50
  const dropdownMenuProps = useToolsPanelDropdownMenuProps();
58
51
 
59
52
  // Use internal state instead of a ref to make sure that the component
@@ -126,71 +119,61 @@ export default function PostDateEdit( {
126
119
  }
127
120
  return (
128
121
  <>
129
- { ( blockEditingMode === 'default' ||
130
- ! isDescendentOfQueryLoop ) && (
131
- <BlockControls group="block">
132
- <AlignmentControl
133
- value={ textAlign }
134
- onChange={ ( nextAlign ) => {
135
- setAttributes( { textAlign: nextAlign } );
136
- } }
137
- />
138
-
139
- { activeBlockVariationName !== 'post-date-modified' &&
140
- ( ! isDescendentOfQueryLoop ||
141
- ! activeBlockVariationName ) && (
142
- <ToolbarGroup>
143
- <Dropdown
144
- popoverProps={ popoverProps }
145
- renderContent={ ( { onClose } ) => (
146
- <PublishDateTimePicker
147
- title={
148
- activeBlockVariationName ===
149
- 'post-date'
150
- ? __( 'Publish Date' )
151
- : __( 'Date' )
152
- }
153
- currentDate={ datetime }
154
- onChange={ ( newDatetime ) =>
155
- setAttributes( {
156
- datetime: newDatetime,
157
- } )
158
- }
159
- is12Hour={ is12HourFormat(
160
- siteTimeFormat
161
- ) }
162
- onClose={ onClose }
163
- dateOrder={
164
- /* translators: Order of day, month, and year. Available formats are 'dmy', 'mdy', and 'ymd'. */
165
- _x( 'dmy', 'date order' )
166
- }
122
+ { ( blockEditingMode === 'default' || ! isDescendentOfQueryLoop ) &&
123
+ activeBlockVariationName !== 'post-date-modified' &&
124
+ ( ! isDescendentOfQueryLoop || ! activeBlockVariationName ) && (
125
+ <BlockControls group="block">
126
+ <ToolbarGroup>
127
+ <Dropdown
128
+ popoverProps={ popoverProps }
129
+ renderContent={ ( { onClose } ) => (
130
+ <PublishDateTimePicker
131
+ title={
132
+ activeBlockVariationName ===
133
+ 'post-date'
134
+ ? __( 'Publish Date' )
135
+ : __( 'Date' )
136
+ }
137
+ currentDate={ datetime }
138
+ onChange={ ( newDatetime ) =>
139
+ setAttributes( {
140
+ datetime: newDatetime,
141
+ } )
142
+ }
143
+ is12Hour={ is12HourFormat(
144
+ siteTimeFormat
145
+ ) }
146
+ onClose={ onClose }
147
+ dateOrder={
148
+ /* translators: Order of day, month, and year. Available formats are 'dmy', 'mdy', and 'ymd'. */
149
+ _x( 'dmy', 'date order' )
150
+ }
151
+ />
152
+ ) }
153
+ renderToggle={ ( { isOpen, onToggle } ) => {
154
+ const openOnArrowDown = ( event ) => {
155
+ if (
156
+ ! isOpen &&
157
+ event.keyCode === DOWN
158
+ ) {
159
+ event.preventDefault();
160
+ onToggle();
161
+ }
162
+ };
163
+ return (
164
+ <ToolbarButton
165
+ aria-expanded={ isOpen }
166
+ icon={ pencil }
167
+ title={ __( 'Change Date' ) }
168
+ onClick={ onToggle }
169
+ onKeyDown={ openOnArrowDown }
167
170
  />
168
- ) }
169
- renderToggle={ ( { isOpen, onToggle } ) => {
170
- const openOnArrowDown = ( event ) => {
171
- if (
172
- ! isOpen &&
173
- event.keyCode === DOWN
174
- ) {
175
- event.preventDefault();
176
- onToggle();
177
- }
178
- };
179
- return (
180
- <ToolbarButton
181
- aria-expanded={ isOpen }
182
- icon={ pencil }
183
- title={ __( 'Change Date' ) }
184
- onClick={ onToggle }
185
- onKeyDown={ openOnArrowDown }
186
- />
187
- );
188
- } }
189
- />
190
- </ToolbarGroup>
191
- ) }
192
- </BlockControls>
193
- ) }
171
+ );
172
+ } }
173
+ />
174
+ </ToolbarGroup>
175
+ </BlockControls>
176
+ ) }
194
177
 
195
178
  <InspectorControls>
196
179
  <ToolsPanel
@@ -35,6 +35,7 @@ import {
35
35
  store as blockEditorStore,
36
36
  __experimentalImageEditor as ImageEditor,
37
37
  useBlockEditingMode,
38
+ privateApis as blockEditorPrivateApis,
38
39
  } from '@wordpress/block-editor';
39
40
  import { useSelect, useDispatch } from '@wordpress/data';
40
41
  import { store as coreStore } from '@wordpress/core-data';
@@ -46,9 +47,11 @@ import { store as noticesStore } from '@wordpress/notices';
46
47
  */
47
48
  import { MIN_SIZE } from '../image/constants';
48
49
  import { MediaControl, MediaControlPreview } from '../utils/media-control';
50
+ import { unlock } from '../lock-unlock';
49
51
  import { useToolsPanelDropdownMenuProps } from '../utils/hooks';
50
52
 
51
53
  const ALLOWED_MEDIA_TYPES = [ 'image' ];
54
+ const { mediaEditKey } = unlock( blockEditorPrivateApis );
52
55
 
53
56
  const SiteLogo = ( {
54
57
  alt,
@@ -75,18 +78,22 @@ const SiteLogo = ( {
75
78
  const blockEditingMode = useBlockEditingMode();
76
79
  const isContentOnlyMode = blockEditingMode === 'contentOnly';
77
80
 
78
- const { imageEditing, maxWidth, title } = useSelect( ( select ) => {
79
- const settings = select( blockEditorStore ).getSettings();
80
- const siteEntities = select( coreStore ).getEntityRecord(
81
- 'root',
82
- '__unstableBase'
83
- );
84
- return {
85
- title: siteEntities?.name,
86
- imageEditing: settings.imageEditing,
87
- maxWidth: settings.maxWidth,
88
- };
89
- }, [] );
81
+ const { imageEditing, maxWidth, title, editMediaEntity } = useSelect(
82
+ ( select ) => {
83
+ const settings = select( blockEditorStore ).getSettings();
84
+ const siteEntities = select( coreStore ).getEntityRecord(
85
+ 'root',
86
+ '__unstableBase'
87
+ );
88
+ return {
89
+ title: siteEntities?.name,
90
+ imageEditing: settings.imageEditing,
91
+ maxWidth: settings.maxWidth,
92
+ editMediaEntity: settings?.[ mediaEditKey ],
93
+ };
94
+ },
95
+ []
96
+ );
90
97
 
91
98
  useEffect( () => {
92
99
  // Turn the `Use as site icon` toggle off if it is on but the logo and icon have
@@ -200,7 +207,11 @@ const SiteLogo = ( {
200
207
  /* eslint-enable no-lonely-if */
201
208
 
202
209
  const canEditImage =
203
- logoId && naturalWidth && naturalHeight && imageEditing;
210
+ logoId &&
211
+ naturalWidth &&
212
+ naturalHeight &&
213
+ imageEditing &&
214
+ !! editMediaEntity;
204
215
 
205
216
  // Hide crop and dimensions editing in write mode
206
217
  const shouldShowCropAndDimensions = ! isContentOnlyMode;
@@ -11,6 +11,7 @@ const v2 = {
11
11
  },
12
12
  level: {
13
13
  type: 'number',
14
+ default: 0,
14
15
  },
15
16
  levelOptions: {
16
17
  type: 'array',
@@ -20,7 +20,11 @@ export const settings = {
20
20
  example: {
21
21
  viewportWidth: 350,
22
22
  attributes: {
23
- textAlign: 'center',
23
+ style: {
24
+ typography: {
25
+ textAlign: 'center',
26
+ },
27
+ },
24
28
  },
25
29
  },
26
30
  edit,
package/src/tab/save.js CHANGED
@@ -3,15 +3,11 @@
3
3
  */
4
4
  import { useBlockProps, useInnerBlocksProps } from '@wordpress/block-editor';
5
5
 
6
- export default function save( { attributes } ) {
7
- const { anchor } = attributes;
8
-
9
- const tabPanelId = anchor;
10
-
6
+ export default function save() {
11
7
  const blockProps = useBlockProps.save( {
12
8
  role: 'tabpanel',
13
9
  } );
14
10
  const innerBlocksProps = useInnerBlocksProps.save( blockProps );
15
11
 
16
- return <section { ...innerBlocksProps } id={ tabPanelId } />;
12
+ return <section { ...innerBlocksProps } />;
17
13
  }
package/src/tabs/save.js CHANGED
@@ -3,13 +3,9 @@
3
3
  */
4
4
  import { useBlockProps, useInnerBlocksProps } from '@wordpress/block-editor';
5
5
 
6
- export default function save( { attributes } ) {
7
- const { anchor } = attributes;
8
-
9
- const tabsId = anchor;
10
-
6
+ export default function save() {
11
7
  const blockProps = useBlockProps.save();
12
8
  const innerBlocksProps = useInnerBlocksProps.save( blockProps );
13
9
 
14
- return <div { ...innerBlocksProps } id={ tabsId } />;
10
+ return <div { ...innerBlocksProps } />;
15
11
  }
@@ -140,7 +140,9 @@ export function MediaControl( {
140
140
  filename={ filename }
141
141
  className="block-library-utils__media-control__inspector-media-replace-title"
142
142
  label={
143
- mediaUrl ? getFilename( filename ) : emptyLabel
143
+ mediaUrl
144
+ ? getFilename( filename ) || emptyLabel
145
+ : emptyLabel
144
146
  }
145
147
  />
146
148
  }