@wordpress/block-library 9.19.1 → 9.20.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 (67) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/archives/edit.js +2 -2
  3. package/build/archives/edit.js.map +1 -1
  4. package/build/audio/edit.js +66 -33
  5. package/build/audio/edit.js.map +1 -1
  6. package/build/avatar/index.js +8 -3
  7. package/build/avatar/index.js.map +1 -1
  8. package/build/button/edit.js +43 -16
  9. package/build/button/edit.js.map +1 -1
  10. package/build/comment-template/hooks.js +6 -0
  11. package/build/comment-template/hooks.js.map +1 -1
  12. package/build/cover/index.js +8 -1
  13. package/build/cover/index.js.map +1 -1
  14. package/build/image/constants.js +2 -1
  15. package/build/image/constants.js.map +1 -1
  16. package/build/image/image.js +85 -72
  17. package/build/image/image.js.map +1 -1
  18. package/build/post-author/index.js +8 -1
  19. package/build/post-author/index.js.map +1 -1
  20. package/build/site-logo/index.js +8 -1
  21. package/build/site-logo/index.js.map +1 -1
  22. package/build/social-links/index.js +1 -0
  23. package/build/social-links/index.js.map +1 -1
  24. package/build/table-of-contents/hooks.js +6 -3
  25. package/build/table-of-contents/hooks.js.map +1 -1
  26. package/build-module/archives/edit.js +2 -2
  27. package/build-module/archives/edit.js.map +1 -1
  28. package/build-module/audio/edit.js +68 -35
  29. package/build-module/audio/edit.js.map +1 -1
  30. package/build-module/avatar/index.js +8 -3
  31. package/build-module/avatar/index.js.map +1 -1
  32. package/build-module/button/edit.js +44 -17
  33. package/build-module/button/edit.js.map +1 -1
  34. package/build-module/comment-template/hooks.js +6 -0
  35. package/build-module/comment-template/hooks.js.map +1 -1
  36. package/build-module/cover/index.js +8 -1
  37. package/build-module/cover/index.js.map +1 -1
  38. package/build-module/image/constants.js +1 -0
  39. package/build-module/image/constants.js.map +1 -1
  40. package/build-module/image/image.js +88 -75
  41. package/build-module/image/image.js.map +1 -1
  42. package/build-module/post-author/index.js +8 -1
  43. package/build-module/post-author/index.js.map +1 -1
  44. package/build-module/site-logo/index.js +8 -1
  45. package/build-module/site-logo/index.js.map +1 -1
  46. package/build-module/social-links/index.js +1 -0
  47. package/build-module/social-links/index.js.map +1 -1
  48. package/build-module/table-of-contents/hooks.js +6 -3
  49. package/build-module/table-of-contents/hooks.js.map +1 -1
  50. package/build-style/editor-rtl.css +0 -9
  51. package/build-style/editor.css +0 -9
  52. package/build-style/image/editor-rtl.css +0 -9
  53. package/build-style/image/editor.css +0 -9
  54. package/package.json +35 -35
  55. package/src/archives/edit.js +2 -2
  56. package/src/audio/edit.js +84 -33
  57. package/src/avatar/block.json +8 -3
  58. package/src/button/edit.js +69 -24
  59. package/src/comment-template/hooks.js +14 -6
  60. package/src/cover/block.json +8 -1
  61. package/src/image/constants.js +1 -0
  62. package/src/image/editor.scss +0 -13
  63. package/src/image/image.js +115 -122
  64. package/src/post-author/block.json +8 -1
  65. package/src/site-logo/block.json +8 -1
  66. package/src/social-links/block.json +1 -0
  67. package/src/table-of-contents/hooks.js +5 -2
@@ -134,15 +134,6 @@ figure.wp-block-image:not(.wp-block) {
134
134
  opacity: 0.1;
135
135
  }
136
136
 
137
- .wp-block-image .components-resizable-box__container {
138
- display: table;
139
- }
140
- .wp-block-image .components-resizable-box__container img {
141
- display: block;
142
- width: inherit;
143
- height: inherit;
144
- }
145
-
146
137
  .block-editor-block-list__block[data-type="core/image"] .block-editor-block-toolbar .block-editor-url-input__button-modal {
147
138
  position: absolute;
148
139
  left: 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/block-library",
3
- "version": "9.19.1",
3
+ "version": "9.20.0",
4
4
  "description": "Block library for the WordPress editor.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -41,39 +41,39 @@
41
41
  ],
42
42
  "dependencies": {
43
43
  "@babel/runtime": "7.25.7",
44
- "@wordpress/a11y": "^4.19.1",
45
- "@wordpress/api-fetch": "^7.19.1",
46
- "@wordpress/autop": "^4.19.1",
47
- "@wordpress/blob": "^4.19.1",
48
- "@wordpress/block-editor": "^14.14.1",
49
- "@wordpress/blocks": "^14.8.1",
50
- "@wordpress/components": "^29.5.1",
51
- "@wordpress/compose": "^7.19.1",
52
- "@wordpress/core-data": "^7.19.1",
53
- "@wordpress/data": "^10.19.1",
54
- "@wordpress/date": "^5.19.1",
55
- "@wordpress/deprecated": "^4.19.1",
56
- "@wordpress/dom": "^4.19.1",
57
- "@wordpress/element": "^6.19.1",
58
- "@wordpress/escape-html": "^3.19.1",
59
- "@wordpress/hooks": "^4.19.1",
60
- "@wordpress/html-entities": "^4.19.1",
61
- "@wordpress/i18n": "^5.19.1",
62
- "@wordpress/icons": "^10.19.1",
63
- "@wordpress/interactivity": "^6.19.1",
64
- "@wordpress/interactivity-router": "^2.19.1",
65
- "@wordpress/keyboard-shortcuts": "^5.19.1",
66
- "@wordpress/keycodes": "^4.19.1",
67
- "@wordpress/notices": "^5.19.1",
68
- "@wordpress/patterns": "^2.19.1",
69
- "@wordpress/primitives": "^4.19.1",
70
- "@wordpress/private-apis": "^1.19.1",
71
- "@wordpress/reusable-blocks": "^5.19.1",
72
- "@wordpress/rich-text": "^7.19.1",
73
- "@wordpress/server-side-render": "^5.19.1",
74
- "@wordpress/url": "^4.19.1",
75
- "@wordpress/viewport": "^6.19.1",
76
- "@wordpress/wordcount": "^4.19.1",
44
+ "@wordpress/a11y": "^4.20.0",
45
+ "@wordpress/api-fetch": "^7.20.0",
46
+ "@wordpress/autop": "^4.20.0",
47
+ "@wordpress/blob": "^4.20.0",
48
+ "@wordpress/block-editor": "^14.15.0",
49
+ "@wordpress/blocks": "^14.9.0",
50
+ "@wordpress/components": "^29.6.0",
51
+ "@wordpress/compose": "^7.20.0",
52
+ "@wordpress/core-data": "^7.20.0",
53
+ "@wordpress/data": "^10.20.0",
54
+ "@wordpress/date": "^5.20.0",
55
+ "@wordpress/deprecated": "^4.20.0",
56
+ "@wordpress/dom": "^4.20.0",
57
+ "@wordpress/element": "^6.20.0",
58
+ "@wordpress/escape-html": "^3.20.0",
59
+ "@wordpress/hooks": "^4.20.0",
60
+ "@wordpress/html-entities": "^4.20.0",
61
+ "@wordpress/i18n": "^5.20.0",
62
+ "@wordpress/icons": "^10.20.0",
63
+ "@wordpress/interactivity": "^6.20.0",
64
+ "@wordpress/interactivity-router": "^2.20.0",
65
+ "@wordpress/keyboard-shortcuts": "^5.20.0",
66
+ "@wordpress/keycodes": "^4.20.0",
67
+ "@wordpress/notices": "^5.20.0",
68
+ "@wordpress/patterns": "^2.20.0",
69
+ "@wordpress/primitives": "^4.20.0",
70
+ "@wordpress/private-apis": "^1.20.0",
71
+ "@wordpress/reusable-blocks": "^5.20.0",
72
+ "@wordpress/rich-text": "^7.20.0",
73
+ "@wordpress/server-side-render": "^5.20.0",
74
+ "@wordpress/url": "^4.20.0",
75
+ "@wordpress/viewport": "^6.20.0",
76
+ "@wordpress/wordcount": "^4.20.0",
77
77
  "change-case": "^4.1.2",
78
78
  "clsx": "^2.1.1",
79
79
  "colord": "^2.7.0",
@@ -91,5 +91,5 @@
91
91
  "publishConfig": {
92
92
  "access": "public"
93
93
  },
94
- "gitHead": "6f49fee89f840761f7fedf662713cbd4a71723e9"
94
+ "gitHead": "72476970386146d450c375e5c71a96dda7c9aaa8"
95
95
  }
@@ -30,7 +30,7 @@ export default function ArchivesEdit( { attributes, setAttributes } ) {
30
30
  resetAll={ () => {
31
31
  setAttributes( {
32
32
  displayAsDropdown: false,
33
- showLabel: false,
33
+ showLabel: true,
34
34
  showPostCounts: false,
35
35
  type: 'monthly',
36
36
  } );
@@ -63,7 +63,7 @@ export default function ArchivesEdit( { attributes, setAttributes } ) {
63
63
  isShownByDefault
64
64
  hasValue={ () => ! showLabel }
65
65
  onDeselect={ () =>
66
- setAttributes( { showLabel: false } )
66
+ setAttributes( { showLabel: true } )
67
67
  }
68
68
  >
69
69
  <ToggleControl
package/src/audio/edit.js CHANGED
@@ -9,10 +9,11 @@ import clsx from 'clsx';
9
9
  import { isBlobURL } from '@wordpress/blob';
10
10
  import {
11
11
  Disabled,
12
- PanelBody,
13
12
  SelectControl,
14
13
  Spinner,
15
14
  ToggleControl,
15
+ __experimentalToolsPanel as ToolsPanel,
16
+ __experimentalToolsPanelItem as ToolsPanelItem,
16
17
  } from '@wordpress/components';
17
18
  import {
18
19
  BlockControls,
@@ -32,7 +33,10 @@ import { useState } from '@wordpress/element';
32
33
  * Internal dependencies
33
34
  */
34
35
  import { createUpgradedEmbedBlock } from '../embed/util';
35
- import { useUploadMediaFromBlobURL } from '../utils/hooks';
36
+ import {
37
+ useUploadMediaFromBlobURL,
38
+ useToolsPanelDropdownMenuProps,
39
+ } from '../utils/hooks';
36
40
  import { Caption } from '../utils/caption';
37
41
 
38
42
  const ALLOWED_MEDIA_TYPES = [ 'audio' ];
@@ -126,6 +130,7 @@ function AudioEdit( {
126
130
  const blockProps = useBlockProps( {
127
131
  className: classes,
128
132
  } );
133
+ const dropdownMenuProps = useToolsPanelDropdownMenuProps();
129
134
 
130
135
  if ( ! src && ! temporaryURL ) {
131
136
  return (
@@ -160,42 +165,88 @@ function AudioEdit( {
160
165
  </BlockControls>
161
166
  ) }
162
167
  <InspectorControls>
163
- <PanelBody title={ __( 'Settings' ) }>
164
- <ToggleControl
165
- __nextHasNoMarginBottom
168
+ <ToolsPanel
169
+ label={ __( 'Settings' ) }
170
+ resetAll={ () => {
171
+ setAttributes( {
172
+ autoplay: false,
173
+ loop: false,
174
+ preload: undefined,
175
+ } );
176
+ } }
177
+ dropdownMenuProps={ dropdownMenuProps }
178
+ >
179
+ <ToolsPanelItem
166
180
  label={ __( 'Autoplay' ) }
167
- onChange={ toggleAttribute( 'autoplay' ) }
168
- checked={ autoplay }
169
- help={ getAutoplayHelp }
170
- />
171
- <ToggleControl
172
- __nextHasNoMarginBottom
181
+ isShownByDefault
182
+ hasValue={ () => !! autoplay }
183
+ onDeselect={ () =>
184
+ setAttributes( {
185
+ autoplay: false,
186
+ } )
187
+ }
188
+ >
189
+ <ToggleControl
190
+ __nextHasNoMarginBottom
191
+ label={ __( 'Autoplay' ) }
192
+ onChange={ toggleAttribute( 'autoplay' ) }
193
+ checked={ !! autoplay }
194
+ help={ getAutoplayHelp }
195
+ />
196
+ </ToolsPanelItem>
197
+ <ToolsPanelItem
173
198
  label={ __( 'Loop' ) }
174
- onChange={ toggleAttribute( 'loop' ) }
175
- checked={ loop }
176
- />
177
- <SelectControl
178
- __next40pxDefaultSize
179
- __nextHasNoMarginBottom
180
- label={ _x( 'Preload', 'noun; Audio block parameter' ) }
181
- value={ preload || '' }
182
- // `undefined` is required for the preload attribute to be unset.
183
- onChange={ ( value ) =>
199
+ isShownByDefault
200
+ hasValue={ () => !! loop }
201
+ onDeselect={ () =>
184
202
  setAttributes( {
185
- preload: value || undefined,
203
+ loop: false,
186
204
  } )
187
205
  }
188
- options={ [
189
- { value: '', label: __( 'Browser default' ) },
190
- { value: 'auto', label: __( 'Auto' ) },
191
- { value: 'metadata', label: __( 'Metadata' ) },
192
- {
193
- value: 'none',
194
- label: _x( 'None', 'Preload value' ),
195
- },
196
- ] }
197
- />
198
- </PanelBody>
206
+ >
207
+ <ToggleControl
208
+ __nextHasNoMarginBottom
209
+ label={ __( 'Loop' ) }
210
+ onChange={ toggleAttribute( 'loop' ) }
211
+ checked={ !! loop }
212
+ />
213
+ </ToolsPanelItem>
214
+ <ToolsPanelItem
215
+ label={ __( 'Preload' ) }
216
+ isShownByDefault
217
+ hasValue={ () => !! preload }
218
+ onDeselect={ () =>
219
+ setAttributes( {
220
+ preload: undefined,
221
+ } )
222
+ }
223
+ >
224
+ <SelectControl
225
+ __next40pxDefaultSize
226
+ __nextHasNoMarginBottom
227
+ label={ _x(
228
+ 'Preload',
229
+ 'noun; Audio block parameter'
230
+ ) }
231
+ value={ preload || '' }
232
+ // `undefined` is required for the preload attribute to be unset.
233
+ onChange={ ( value ) =>
234
+ setAttributes( {
235
+ preload: value || undefined,
236
+ } )
237
+ }
238
+ options={ [
239
+ { value: '', label: __( 'Browser default' ) },
240
+ { value: 'auto', label: __( 'Auto' ) },
241
+ { value: 'metadata', label: __( 'Metadata' ) },
242
+ {
243
+ value: 'none',
244
+ label: _x( 'None', 'Preload value' ),
245
+ },
246
+ ] }
247
+ />
248
+ </ToolsPanelItem>
249
+ </ToolsPanel>
199
250
  </InspectorControls>
200
251
  <figure { ...blockProps }>
201
252
  { /*
@@ -48,15 +48,20 @@
48
48
  },
49
49
  "color": {
50
50
  "text": false,
51
- "background": false,
52
- "__experimentalDuotone": "img"
51
+ "background": false
52
+ },
53
+ "filter": {
54
+ "duotone": true
53
55
  },
54
56
  "interactivity": {
55
57
  "clientNavigation": true
56
58
  }
57
59
  },
58
60
  "selectors": {
59
- "border": ".wp-block-avatar img"
61
+ "border": ".wp-block-avatar img",
62
+ "filter": {
63
+ "duotone": ".wp-block-avatar img"
64
+ }
60
65
  },
61
66
  "editorStyle": "wp-block-avatar-editor",
62
67
  "style": "wp-block-avatar"
@@ -15,7 +15,13 @@ import { useToolsPanelDropdownMenuProps } from '../utils/hooks';
15
15
  * WordPress dependencies
16
16
  */
17
17
  import { __, sprintf } from '@wordpress/i18n';
18
- import { useEffect, useState, useRef, useMemo } from '@wordpress/element';
18
+ import {
19
+ useEffect,
20
+ useState,
21
+ useRef,
22
+ useMemo,
23
+ createInterpolateElement,
24
+ } from '@wordpress/element';
19
25
  import {
20
26
  TextControl,
21
27
  ToolbarButton,
@@ -219,6 +225,63 @@ function ButtonEdit( props ) {
219
225
  const nofollow = !! rel?.includes( NOFOLLOW_REL );
220
226
  const isLinkTag = 'a' === TagName;
221
227
 
228
+ const {
229
+ createPageEntity,
230
+ userCanCreatePages,
231
+ lockUrlControls = false,
232
+ } = useSelect(
233
+ ( select ) => {
234
+ if ( ! isSelected ) {
235
+ return {};
236
+ }
237
+
238
+ const _settings = select( blockEditorStore ).getSettings();
239
+
240
+ const blockBindingsSource = getBlockBindingsSource(
241
+ metadata?.bindings?.url?.source
242
+ );
243
+
244
+ return {
245
+ createPageEntity: _settings.__experimentalCreatePageEntity,
246
+ userCanCreatePages: _settings.__experimentalUserCanCreatePages,
247
+ lockUrlControls:
248
+ !! metadata?.bindings?.url &&
249
+ ! blockBindingsSource?.canUserEditValue?.( {
250
+ select,
251
+ context,
252
+ args: metadata?.bindings?.url?.args,
253
+ } ),
254
+ };
255
+ },
256
+ [ context, isSelected, metadata?.bindings?.url ]
257
+ );
258
+
259
+ async function handleCreate( pageTitle ) {
260
+ const page = await createPageEntity( {
261
+ title: pageTitle,
262
+ status: 'draft',
263
+ } );
264
+
265
+ return {
266
+ id: page.id,
267
+ type: page.type,
268
+ title: page.title.rendered,
269
+ url: page.link,
270
+ kind: 'post-type',
271
+ };
272
+ }
273
+
274
+ function createButtonText( searchTerm ) {
275
+ return createInterpolateElement(
276
+ sprintf(
277
+ /* translators: %s: search term. */
278
+ __( 'Create page: <mark>%s</mark>' ),
279
+ searchTerm
280
+ ),
281
+ { mark: <mark /> }
282
+ );
283
+ }
284
+
222
285
  function startEditing( event ) {
223
286
  event.preventDefault();
224
287
  setIsEditingURL( true );
@@ -249,29 +312,6 @@ function ButtonEdit( props ) {
249
312
  const useEnterRef = useEnter( { content: text, clientId } );
250
313
  const mergedRef = useMergeRefs( [ useEnterRef, richTextRef ] );
251
314
 
252
- const { lockUrlControls = false } = useSelect(
253
- ( select ) => {
254
- if ( ! isSelected ) {
255
- return {};
256
- }
257
-
258
- const blockBindingsSource = getBlockBindingsSource(
259
- metadata?.bindings?.url?.source
260
- );
261
-
262
- return {
263
- lockUrlControls:
264
- !! metadata?.bindings?.url &&
265
- ! blockBindingsSource?.canUserEditValue?.( {
266
- select,
267
- context,
268
- args: metadata?.bindings?.url?.args,
269
- } ),
270
- };
271
- },
272
- [ context, isSelected, metadata?.bindings?.url ]
273
- );
274
-
275
315
  const [ fluidTypographySettings, layout ] = useSettings(
276
316
  'typography.fluid',
277
317
  'layout'
@@ -400,6 +440,11 @@ function ButtonEdit( props ) {
400
440
  } }
401
441
  forceIsEditingLink={ isEditingURL }
402
442
  settings={ LINK_SETTINGS }
443
+ createSuggestion={
444
+ createPageEntity && handleCreate
445
+ }
446
+ withCreateSuggestion={ userCanCreatePages }
447
+ createSuggestionButtonText={ createButtonText }
403
448
  />
404
449
  </Popover>
405
450
  ) }
@@ -107,13 +107,21 @@ const useDefaultPageIndex = ( { defaultPage, postId, perPage, queryArgs } ) => {
107
107
  } ),
108
108
  method: 'HEAD',
109
109
  parse: false,
110
- } ).then( ( res ) => {
111
- const pages = parseInt( res.headers.get( 'X-WP-TotalPages' ) );
112
- setDefaultPages( {
113
- ...defaultPages,
114
- [ key ]: pages <= 1 ? 1 : pages, // If there are 0 pages, it means that there are no comments, but there is no 0th page.
110
+ } )
111
+ .then( ( res ) => {
112
+ const pages = parseInt( res.headers.get( 'X-WP-TotalPages' ) );
113
+ setDefaultPages( {
114
+ ...defaultPages,
115
+ [ key ]: pages <= 1 ? 1 : pages, // If there are 0 pages, it means that there are no comments, but there is no 0th page.
116
+ } );
117
+ } )
118
+ .catch( () => {
119
+ // There's no 0th page, but we can't know the number of pages, fallback to 1.
120
+ setDefaultPages( {
121
+ ...defaultPages,
122
+ [ key ]: 1,
123
+ } );
115
124
  } );
116
- } );
117
125
  }, [ defaultPage, postId, perPage, setDefaultPages ] );
118
126
 
119
127
  // The oldest one is always the first one.
@@ -111,7 +111,6 @@
111
111
  }
112
112
  },
113
113
  "color": {
114
- "__experimentalDuotone": "> .wp-block-cover__image-background, > .wp-block-cover__video-background",
115
114
  "heading": true,
116
115
  "text": true,
117
116
  "background": false,
@@ -139,6 +138,14 @@
139
138
  },
140
139
  "interactivity": {
141
140
  "clientNavigation": true
141
+ },
142
+ "filter": {
143
+ "duotone": true
144
+ }
145
+ },
146
+ "selectors": {
147
+ "filter": {
148
+ "duotone": ".wp-block-cover > .wp-block-cover__image-background, .wp-block-cover > .wp-block-cover__video-background"
142
149
  }
143
150
  },
144
151
  "editorStyle": "wp-block-cover-editor",
@@ -6,3 +6,4 @@ export const LINK_DESTINATION_CUSTOM = 'custom';
6
6
  export const NEW_TAB_REL = [ 'noreferrer', 'noopener' ];
7
7
  export const ALLOWED_MEDIA_TYPES = [ 'image' ];
8
8
  export const MEDIA_ID_NO_FEATURED_IMAGE_SET = 0;
9
+ export const SIZED_LAYOUTS = [ 'flex', 'grid' ];
@@ -48,19 +48,6 @@ figure.wp-block-image:not(.wp-block) {
48
48
  }
49
49
  }
50
50
 
51
- // This is necessary for the editor resize handles to accurately work on a non-floated, non-resized, small image.
52
- .wp-block-image .components-resizable-box__container {
53
- // Using "display: table" because:
54
- // - it visually hides empty white space in between elements
55
- // - it allows the element to be as wide as its contents (instead of 100% width, as it would be with `display: block`)
56
- display: table;
57
- img {
58
- display: block;
59
- width: inherit;
60
- height: inherit;
61
- }
62
- }
63
-
64
51
  .block-editor-block-list__block[data-type="core/image"] .block-editor-block-toolbar .block-editor-url-input__button-modal {
65
52
  position: absolute;
66
53
  left: 0;