@wordpress/block-editor 15.12.0 → 15.12.1-next.v.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 (36) hide show
  1. package/build/components/block-inspector/index.cjs +9 -9
  2. package/build/components/block-inspector/index.cjs.map +3 -3
  3. package/build/components/inspector-controls/last-item.cjs +41 -0
  4. package/build/components/inspector-controls/last-item.cjs.map +7 -0
  5. package/build/components/inspector-controls-tabs/styles-tab.cjs +3 -3
  6. package/build/components/inspector-controls-tabs/styles-tab.cjs.map +2 -2
  7. package/build/hooks/anchor.cjs +1 -1
  8. package/build/hooks/anchor.cjs.map +1 -1
  9. package/build/hooks/grid-visualizer.cjs +42 -5
  10. package/build/hooks/grid-visualizer.cjs.map +3 -3
  11. package/build/hooks/layout-child.cjs +41 -5
  12. package/build/hooks/layout-child.cjs.map +3 -3
  13. package/build/private-apis.cjs +2 -0
  14. package/build/private-apis.cjs.map +3 -3
  15. package/build-module/components/block-inspector/index.mjs +10 -9
  16. package/build-module/components/block-inspector/index.mjs.map +2 -2
  17. package/build-module/components/inspector-controls/last-item.mjs +23 -0
  18. package/build-module/components/inspector-controls/last-item.mjs.map +7 -0
  19. package/build-module/components/inspector-controls-tabs/styles-tab.mjs +3 -3
  20. package/build-module/components/inspector-controls-tabs/styles-tab.mjs.map +2 -2
  21. package/build-module/hooks/anchor.mjs +1 -1
  22. package/build-module/hooks/anchor.mjs.map +1 -1
  23. package/build-module/hooks/grid-visualizer.mjs +20 -5
  24. package/build-module/hooks/grid-visualizer.mjs.map +2 -2
  25. package/build-module/hooks/layout-child.mjs +31 -5
  26. package/build-module/hooks/layout-child.mjs.map +2 -2
  27. package/build-module/private-apis.mjs +2 -0
  28. package/build-module/private-apis.mjs.map +2 -2
  29. package/package.json +39 -39
  30. package/src/components/block-inspector/index.js +19 -17
  31. package/src/components/inspector-controls/last-item.js +29 -0
  32. package/src/components/inspector-controls-tabs/styles-tab.js +3 -3
  33. package/src/hooks/anchor.js +1 -1
  34. package/src/hooks/grid-visualizer.js +23 -4
  35. package/src/hooks/layout-child.js +39 -3
  36. package/src/private-apis.js +2 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/block-editor",
3
- "version": "15.12.0",
3
+ "version": "15.12.1-next.v.0+5aba098fc",
4
4
  "description": "Generic block editor.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -61,43 +61,43 @@
61
61
  ],
62
62
  "dependencies": {
63
63
  "@react-spring/web": "^9.4.5",
64
- "@wordpress/a11y": "^4.39.0",
65
- "@wordpress/api-fetch": "^7.39.0",
66
- "@wordpress/base-styles": "^6.15.0",
67
- "@wordpress/blob": "^4.39.0",
68
- "@wordpress/block-serialization-default-parser": "^5.39.0",
69
- "@wordpress/blocks": "^15.12.0",
70
- "@wordpress/commands": "^1.39.0",
71
- "@wordpress/components": "^32.1.0",
72
- "@wordpress/compose": "^7.39.0",
73
- "@wordpress/data": "^10.39.0",
74
- "@wordpress/dataviews": "^11.3.0",
75
- "@wordpress/date": "^5.39.0",
76
- "@wordpress/deprecated": "^4.39.0",
77
- "@wordpress/dom": "^4.39.0",
78
- "@wordpress/element": "^6.39.0",
79
- "@wordpress/escape-html": "^3.39.0",
80
- "@wordpress/global-styles-engine": "^1.6.0",
81
- "@wordpress/hooks": "^4.39.0",
82
- "@wordpress/html-entities": "^4.39.0",
83
- "@wordpress/i18n": "^6.12.0",
84
- "@wordpress/icons": "^11.6.0",
85
- "@wordpress/image-cropper": "^1.3.0",
86
- "@wordpress/interactivity": "^6.39.0",
87
- "@wordpress/is-shallow-equal": "^5.39.0",
88
- "@wordpress/keyboard-shortcuts": "^5.39.0",
89
- "@wordpress/keycodes": "^4.39.0",
90
- "@wordpress/notices": "^5.39.0",
91
- "@wordpress/preferences": "^4.39.0",
92
- "@wordpress/priority-queue": "^3.39.0",
93
- "@wordpress/private-apis": "^1.39.0",
94
- "@wordpress/rich-text": "^7.39.0",
95
- "@wordpress/style-engine": "^2.39.0",
96
- "@wordpress/token-list": "^3.39.0",
97
- "@wordpress/upload-media": "^0.24.0",
98
- "@wordpress/url": "^4.39.0",
99
- "@wordpress/warning": "^3.39.0",
100
- "@wordpress/wordcount": "^4.39.0",
64
+ "@wordpress/a11y": "^4.39.1-next.v.0+5aba098fc",
65
+ "@wordpress/api-fetch": "^7.39.1-next.v.0+5aba098fc",
66
+ "@wordpress/base-styles": "^6.15.1-next.v.0+5aba098fc",
67
+ "@wordpress/blob": "^4.39.1-next.v.0+5aba098fc",
68
+ "@wordpress/block-serialization-default-parser": "^5.39.1-next.v.0+5aba098fc",
69
+ "@wordpress/blocks": "^15.12.1-next.v.0+5aba098fc",
70
+ "@wordpress/commands": "^1.39.1-next.v.0+5aba098fc",
71
+ "@wordpress/components": "^32.1.1-next.v.0+5aba098fc",
72
+ "@wordpress/compose": "^7.39.1-next.v.0+5aba098fc",
73
+ "@wordpress/data": "^10.39.1-next.v.0+5aba098fc",
74
+ "@wordpress/dataviews": "^11.4.1-next.v.0+5aba098fc",
75
+ "@wordpress/date": "^5.39.1-next.v.0+5aba098fc",
76
+ "@wordpress/deprecated": "^4.39.1-next.v.0+5aba098fc",
77
+ "@wordpress/dom": "^4.39.1-next.v.0+5aba098fc",
78
+ "@wordpress/element": "^6.39.1-next.v.0+5aba098fc",
79
+ "@wordpress/escape-html": "^3.39.1-next.v.0+5aba098fc",
80
+ "@wordpress/global-styles-engine": "^1.6.1-next.v.0+5aba098fc",
81
+ "@wordpress/hooks": "^4.39.1-next.v.0+5aba098fc",
82
+ "@wordpress/html-entities": "^4.39.1-next.v.0+5aba098fc",
83
+ "@wordpress/i18n": "^6.12.1-next.v.0+5aba098fc",
84
+ "@wordpress/icons": "^11.6.1-next.v.0+5aba098fc",
85
+ "@wordpress/image-cropper": "^1.3.1-next.v.0+5aba098fc",
86
+ "@wordpress/interactivity": "^6.39.1-next.v.0+5aba098fc",
87
+ "@wordpress/is-shallow-equal": "^5.39.1-next.v.0+5aba098fc",
88
+ "@wordpress/keyboard-shortcuts": "^5.39.1-next.v.0+5aba098fc",
89
+ "@wordpress/keycodes": "^4.39.1-next.v.0+5aba098fc",
90
+ "@wordpress/notices": "^5.39.1-next.v.0+5aba098fc",
91
+ "@wordpress/preferences": "^4.39.1-next.v.0+5aba098fc",
92
+ "@wordpress/priority-queue": "^3.39.1-next.v.0+5aba098fc",
93
+ "@wordpress/private-apis": "^1.39.1-next.v.0+5aba098fc",
94
+ "@wordpress/rich-text": "^7.39.1-next.v.0+5aba098fc",
95
+ "@wordpress/style-engine": "^2.39.1-next.v.0+5aba098fc",
96
+ "@wordpress/token-list": "^3.39.1-next.v.0+5aba098fc",
97
+ "@wordpress/upload-media": "^0.24.1-next.v.0+5aba098fc",
98
+ "@wordpress/url": "^4.39.1-next.v.0+5aba098fc",
99
+ "@wordpress/warning": "^3.39.1-next.v.0+5aba098fc",
100
+ "@wordpress/wordcount": "^4.39.1-next.v.0+5aba098fc",
101
101
  "change-case": "^4.1.2",
102
102
  "clsx": "^2.1.1",
103
103
  "colord": "^2.7.0",
@@ -124,5 +124,5 @@
124
124
  "publishConfig": {
125
125
  "access": "public"
126
126
  },
127
- "gitHead": "eee1cfb1472f11183e40fb77465a5f13145df7ad"
127
+ "gitHead": "d730f9e00f5462d1b9d2660632850f5f43ccff44"
128
128
  }
@@ -5,6 +5,7 @@ import { __ } from '@wordpress/i18n';
5
5
  import {
6
6
  getBlockType,
7
7
  getUnregisteredTypeHandlerName,
8
+ hasBlockSupport,
8
9
  store as blocksStore,
9
10
  } from '@wordpress/blocks';
10
11
  import { __unstableMotion as motion } from '@wordpress/components';
@@ -24,6 +25,7 @@ import BlockStyles from '../block-styles';
24
25
  import { default as InspectorControls } from '../inspector-controls';
25
26
  import { default as InspectorControlsTabs } from '../inspector-controls-tabs';
26
27
  import useInspectorControlsTabs from '../inspector-controls-tabs/use-inspector-controls-tabs';
28
+ import InspectorControlsLastItem from '../inspector-controls/last-item';
27
29
  import AdvancedControls from '../inspector-controls-tabs/advanced-controls-panel';
28
30
  import PositionControls from '../inspector-controls-tabs/position-controls-panel';
29
31
  import useBlockInspectorAnimationSettings from './useBlockInspectorAnimationSettings';
@@ -145,30 +147,29 @@ function BlockInspector() {
145
147
  renderedBlockClientId
146
148
  );
147
149
 
148
- // Temporary workaround for issue #71991
149
- // Exclude Navigation block children from Content sidebar until proper
150
- // drill-down experience is implemented (see #65699)
151
- // This prevents a poor UX where all Nav block sub-items are shown
152
- // when the parent block is in contentOnly mode.
153
- // Build a Set of all navigation block descendants for efficient lookup
154
- const navigationDescendants = new Set();
150
+ // Exclude items from the content tab that are already present in the
151
+ // List View tab.
152
+ const listViewDescendants = new Set();
155
153
  descendants.forEach( ( clientId ) => {
156
- if ( getBlockName( clientId ) === 'core/navigation' ) {
157
- const navChildren = getClientIdsOfDescendants( clientId );
158
- navChildren.forEach( ( childId ) =>
159
- navigationDescendants.add( childId )
154
+ const blockName = getBlockName( clientId );
155
+ // Navigation block doesn't have List View block support, but
156
+ // it does have a custom implementation that is shown within
157
+ // patterns, so it's included in this condition.
158
+ if (
159
+ blockName === 'core/navigation' ||
160
+ hasBlockSupport( blockName, 'listView' )
161
+ ) {
162
+ const listViewChildren =
163
+ getClientIdsOfDescendants( clientId );
164
+ listViewChildren.forEach( ( childId ) =>
165
+ listViewDescendants.add( childId )
160
166
  );
161
167
  }
162
168
  } );
163
169
 
164
170
  return descendants.filter( ( current ) => {
165
- // Exclude navigation block children
166
- if ( navigationDescendants.has( current ) ) {
167
- return false;
168
- }
169
-
170
171
  return (
171
- getBlockName( current ) !== 'core/list-item' &&
172
+ ! listViewDescendants.has( current ) &&
172
173
  getBlockEditingMode( current ) === 'contentOnly'
173
174
  );
174
175
  } );
@@ -369,6 +370,7 @@ const BlockInspectorSingleBlock = ( {
369
370
  ) }
370
371
  </>
371
372
  ) }
373
+ <InspectorControlsLastItem.Slot />
372
374
  <SkipToSelectedBlock key="back" />
373
375
  </div>
374
376
  );
@@ -0,0 +1,29 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { createSlotFill } from '@wordpress/components';
5
+
6
+ /**
7
+ * Internal dependencies
8
+ */
9
+ import {
10
+ useBlockEditContext,
11
+ mayDisplayControlsKey,
12
+ } from '../block-edit/context';
13
+
14
+ const { Fill, Slot } = createSlotFill( Symbol( 'InspectorControlsLastItem' ) );
15
+
16
+ const InspectorControlsLastItem = ( props ) => {
17
+ const context = useBlockEditContext();
18
+ if ( ! context[ mayDisplayControlsKey ] ) {
19
+ return null;
20
+ }
21
+ return <Fill { ...props } />;
22
+ };
23
+ InspectorControlsLastItem.Slot = function InspectorControlsLastItemSlot(
24
+ props
25
+ ) {
26
+ return <Slot { ...props } />;
27
+ };
28
+
29
+ export default InspectorControlsLastItem;
@@ -23,14 +23,14 @@ function SectionBlockColorControls( {
23
23
  const settings = useBlockSettings( blockName );
24
24
  const { updateBlockAttributes } = useDispatch( blockEditorStore );
25
25
 
26
- const { hasButton, hasHeading } = useSelect(
26
+ const { hasButtons, hasHeading } = useSelect(
27
27
  ( select ) => {
28
28
  const blockNames =
29
29
  select( blockEditorStore ).getBlockNamesByClientId(
30
30
  contentClientIds
31
31
  );
32
32
  return {
33
- hasButton: blockNames.includes( 'core/button' ),
33
+ hasButtons: blockNames.includes( 'core/buttons' ),
34
34
  hasHeading: blockNames.includes( 'core/heading' ),
35
35
  };
36
36
  },
@@ -52,7 +52,7 @@ function SectionBlockColorControls( {
52
52
  defaultControls={ {
53
53
  text: true,
54
54
  background: true,
55
- button: hasButton,
55
+ button: hasButtons,
56
56
  heading: hasHeading,
57
57
  } }
58
58
  />
@@ -64,7 +64,7 @@ function BlockEditAnchorControlPure( { anchor, setAttributes } ) {
64
64
  help={
65
65
  <>
66
66
  { __(
67
- 'Enter a word or two without spaces to make a unique web address just for this block, called an “anchor”. Then, you’ll be able to link directly to this section of your page.'
67
+ 'Enter a word or two—without spaces—to make a unique web address just for this block, called an “anchor”. Then, you’ll be able to link directly to this section of your page.'
68
68
  ) }
69
69
  { isWeb && (
70
70
  <>
@@ -10,19 +10,24 @@ import { useSelect } from '@wordpress/data';
10
10
  */
11
11
  import { GridVisualizer, useGridLayoutSync } from '../components/grid';
12
12
  import { store as blockEditorStore } from '../store';
13
+ import useBlockVisibility from '../components/block-visibility/use-block-visibility';
14
+ import { deviceTypeKey } from '../store/private-keys';
15
+ import { BLOCK_VISIBILITY_VIEWPORTS } from '../components/block-visibility/constants';
13
16
 
14
17
  function GridLayoutSync( props ) {
15
18
  useGridLayoutSync( props );
16
19
  }
17
20
 
18
21
  function GridTools( { clientId, layout } ) {
19
- const isVisible = useSelect(
22
+ const { isVisible, blockVisibility, deviceType } = useSelect(
20
23
  ( select ) => {
21
24
  const {
22
25
  isBlockSelected,
23
26
  isDraggingBlocks,
24
27
  getTemplateLock,
25
28
  getBlockEditingMode,
29
+ getBlockAttributes,
30
+ getSettings,
26
31
  } = select( blockEditorStore );
27
32
 
28
33
  // These calls are purposely ordered from least expensive to most expensive.
@@ -32,18 +37,32 @@ function GridTools( { clientId, layout } ) {
32
37
  getTemplateLock( clientId ) ||
33
38
  getBlockEditingMode( clientId ) !== 'default'
34
39
  ) {
35
- return false;
40
+ return { isVisible: false };
36
41
  }
37
42
 
38
- return true;
43
+ const attributes = getBlockAttributes( clientId );
44
+ const settings = getSettings();
45
+
46
+ return {
47
+ isVisible: true,
48
+ blockVisibility: attributes?.metadata?.blockVisibility,
49
+ deviceType:
50
+ settings?.[ deviceTypeKey ]?.toLowerCase() ||
51
+ BLOCK_VISIBILITY_VIEWPORTS.desktop.value,
52
+ };
39
53
  },
40
54
  [ clientId ]
41
55
  );
42
56
 
57
+ const { isBlockCurrentlyHidden } = useBlockVisibility( {
58
+ blockVisibility,
59
+ deviceType,
60
+ } );
61
+
43
62
  return (
44
63
  <>
45
64
  <GridLayoutSync clientId={ clientId } />
46
- { isVisible && (
65
+ { isVisible && ! isBlockCurrentlyHidden && (
47
66
  <GridVisualizer clientId={ clientId } parentLayout={ layout } />
48
67
  ) }
49
68
  </>
@@ -16,6 +16,9 @@ import {
16
16
  GridItemResizer,
17
17
  GridItemMovers,
18
18
  } from '../components/grid';
19
+ import useBlockVisibility from '../components/block-visibility/use-block-visibility';
20
+ import { deviceTypeKey } from '../store/private-keys';
21
+ import { BLOCK_VISIBILITY_VIEWPORTS } from '../components/block-visibility/constants';
19
22
 
20
23
  // Used for generating the instance ID
21
24
  const LAYOUT_CHILD_BLOCK_PROPS_REFERENCE = {};
@@ -199,12 +202,20 @@ function GridTools( {
199
202
  isManualPlacement,
200
203
  parentLayout,
201
204
  } ) {
202
- const { rootClientId, isVisible } = useSelect(
205
+ const {
206
+ rootClientId,
207
+ isVisible,
208
+ parentBlockVisibility,
209
+ blockBlockVisibility,
210
+ deviceType,
211
+ } = useSelect(
203
212
  ( select ) => {
204
213
  const {
205
214
  getBlockRootClientId,
206
215
  getBlockEditingMode,
207
216
  getTemplateLock,
217
+ getBlockAttributes,
218
+ getSettings,
208
219
  } = select( blockEditorStore );
209
220
 
210
221
  const _rootClientId = getBlockRootClientId( clientId );
@@ -219,21 +230,46 @@ function GridTools( {
219
230
  };
220
231
  }
221
232
 
233
+ const parentAttributes = getBlockAttributes( _rootClientId );
234
+ const blockAttributes = getBlockAttributes( clientId );
235
+ const settings = getSettings();
236
+
222
237
  return {
223
238
  rootClientId: _rootClientId,
224
239
  isVisible: true,
240
+ parentBlockVisibility:
241
+ parentAttributes?.metadata?.blockVisibility,
242
+ blockBlockVisibility:
243
+ blockAttributes?.metadata?.blockVisibility,
244
+ deviceType:
245
+ settings?.[ deviceTypeKey ]?.toLowerCase() ||
246
+ BLOCK_VISIBILITY_VIEWPORTS.desktop.value,
225
247
  };
226
248
  },
227
249
  [ clientId ]
228
250
  );
229
251
 
252
+ const { isBlockCurrentlyHidden: isParentBlockCurrentlyHidden } =
253
+ useBlockVisibility( {
254
+ blockVisibility: parentBlockVisibility,
255
+ deviceType,
256
+ } );
257
+
258
+ const { isBlockCurrentlyHidden: isBlockItselfCurrentlyHidden } =
259
+ useBlockVisibility( {
260
+ blockVisibility: blockBlockVisibility,
261
+ deviceType,
262
+ } );
263
+
230
264
  // Use useState() instead of useRef() so that GridItemResizer updates when ref is set.
231
265
  const [ resizerBounds, setResizerBounds ] = useState();
232
266
 
233
- if ( ! isVisible ) {
267
+ if ( ! isVisible || isParentBlockCurrentlyHidden ) {
234
268
  return null;
235
269
  }
236
270
 
271
+ const showResizer = allowSizingOnChildren && ! isBlockItselfCurrentlyHidden;
272
+
237
273
  function updateLayout( layout ) {
238
274
  setAttributes( {
239
275
  style: {
@@ -253,7 +289,7 @@ function GridTools( {
253
289
  contentRef={ setResizerBounds }
254
290
  parentLayout={ parentLayout }
255
291
  />
256
- { allowSizingOnChildren && (
292
+ { showResizer && (
257
293
  <GridItemResizer
258
294
  clientId={ clientId }
259
295
  // Don't allow resizing beyond the grid visualizer.
@@ -13,6 +13,7 @@ import {
13
13
  normalizeString,
14
14
  } from './components/inserter/search-items';
15
15
  import { PrivateListView } from './components/list-view';
16
+ import InspectorControlsLastItem from './components/inspector-controls/last-item';
16
17
  import { useHasBlockToolbar } from './components/block-toolbar/use-has-block-toolbar';
17
18
  import { cleanEmptyObject } from './hooks/utils';
18
19
  import BlockQuickNavigation from './components/block-quick-navigation';
@@ -79,6 +80,7 @@ lock( privateApis, {
79
80
  normalizeString,
80
81
  PrivateListView,
81
82
  ResizableBoxPopover,
83
+ InspectorControlsLastItem,
82
84
  useHasBlockToolbar,
83
85
  cleanEmptyObject,
84
86
  BlockQuickNavigation,