@wordpress/block-editor 15.2.1-next.f34ab90e9.0 → 15.3.1-next.836ecdcae.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 (120) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/block-actions/index.js +3 -1
  3. package/build/components/block-actions/index.js.map +1 -1
  4. package/build/components/block-context/index.js +1 -0
  5. package/build/components/block-context/index.js.map +1 -1
  6. package/build/components/block-edit/context.js +1 -0
  7. package/build/components/block-edit/context.js.map +1 -1
  8. package/build/components/block-list/index.js +1 -0
  9. package/build/components/block-list/index.js.map +1 -1
  10. package/build/components/block-list/layout.js +1 -0
  11. package/build/components/block-list/layout.js.map +1 -1
  12. package/build/components/block-list/private-block-context.js +1 -0
  13. package/build/components/block-list/private-block-context.js.map +1 -1
  14. package/build/components/block-popover/inbetween.js +1 -2
  15. package/build/components/block-popover/inbetween.js.map +1 -1
  16. package/build/components/block-toolbar/block-name-context.js +1 -0
  17. package/build/components/block-toolbar/block-name-context.js.map +1 -1
  18. package/build/components/block-tools/insertion-point.js +1 -0
  19. package/build/components/block-tools/insertion-point.js.map +1 -1
  20. package/build/components/block-tools/use-show-block-tools.js +1 -1
  21. package/build/components/block-tools/use-show-block-tools.js.map +1 -1
  22. package/build/components/global-styles/context.js +1 -0
  23. package/build/components/global-styles/context.js.map +1 -1
  24. package/build/components/image-editor/context.js +1 -0
  25. package/build/components/image-editor/context.js.map +1 -1
  26. package/build/components/inserter/hooks/use-insertion-point.js +1 -1
  27. package/build/components/inserter/hooks/use-insertion-point.js.map +1 -1
  28. package/build/components/inserter/index.js +1 -3
  29. package/build/components/inserter/index.js.map +1 -1
  30. package/build/components/inserter-listbox/context.js +1 -0
  31. package/build/components/inserter-listbox/context.js.map +1 -1
  32. package/build/components/inserter-listbox/index.js +11 -2
  33. package/build/components/inserter-listbox/index.js.map +1 -1
  34. package/build/components/list-view/appender.js +13 -3
  35. package/build/components/list-view/appender.js.map +1 -1
  36. package/build/components/list-view/context.js +1 -0
  37. package/build/components/list-view/context.js.map +1 -1
  38. package/build/components/provider/block-refs-provider.js +1 -0
  39. package/build/components/provider/block-refs-provider.js.map +1 -1
  40. package/build/components/recursion-provider/index.js +1 -0
  41. package/build/components/recursion-provider/index.js.map +1 -1
  42. package/build/components/rich-text/index.js +2 -0
  43. package/build/components/rich-text/index.js.map +1 -1
  44. package/build/store/private-selectors.js +25 -0
  45. package/build/store/private-selectors.js.map +1 -1
  46. package/build/store/selectors.js +25 -5
  47. package/build/store/selectors.js.map +1 -1
  48. package/build-module/components/block-actions/index.js +3 -1
  49. package/build-module/components/block-actions/index.js.map +1 -1
  50. package/build-module/components/block-context/index.js +1 -0
  51. package/build-module/components/block-context/index.js.map +1 -1
  52. package/build-module/components/block-edit/context.js +1 -0
  53. package/build-module/components/block-edit/context.js.map +1 -1
  54. package/build-module/components/block-list/index.js +1 -0
  55. package/build-module/components/block-list/index.js.map +1 -1
  56. package/build-module/components/block-list/layout.js +1 -0
  57. package/build-module/components/block-list/layout.js.map +1 -1
  58. package/build-module/components/block-list/private-block-context.js +1 -0
  59. package/build-module/components/block-list/private-block-context.js.map +1 -1
  60. package/build-module/components/block-popover/inbetween.js +1 -2
  61. package/build-module/components/block-popover/inbetween.js.map +1 -1
  62. package/build-module/components/block-toolbar/block-name-context.js +1 -0
  63. package/build-module/components/block-toolbar/block-name-context.js.map +1 -1
  64. package/build-module/components/block-tools/insertion-point.js +1 -0
  65. package/build-module/components/block-tools/insertion-point.js.map +1 -1
  66. package/build-module/components/block-tools/use-show-block-tools.js +1 -1
  67. package/build-module/components/block-tools/use-show-block-tools.js.map +1 -1
  68. package/build-module/components/global-styles/context.js +1 -0
  69. package/build-module/components/global-styles/context.js.map +1 -1
  70. package/build-module/components/image-editor/context.js +1 -0
  71. package/build-module/components/image-editor/context.js.map +1 -1
  72. package/build-module/components/inserter/hooks/use-insertion-point.js +1 -1
  73. package/build-module/components/inserter/hooks/use-insertion-point.js.map +1 -1
  74. package/build-module/components/inserter/index.js +1 -3
  75. package/build-module/components/inserter/index.js.map +1 -1
  76. package/build-module/components/inserter-listbox/context.js +1 -0
  77. package/build-module/components/inserter-listbox/context.js.map +1 -1
  78. package/build-module/components/inserter-listbox/index.js +11 -2
  79. package/build-module/components/inserter-listbox/index.js.map +1 -1
  80. package/build-module/components/list-view/appender.js +13 -3
  81. package/build-module/components/list-view/appender.js.map +1 -1
  82. package/build-module/components/list-view/context.js +1 -0
  83. package/build-module/components/list-view/context.js.map +1 -1
  84. package/build-module/components/provider/block-refs-provider.js +1 -0
  85. package/build-module/components/provider/block-refs-provider.js.map +1 -1
  86. package/build-module/components/recursion-provider/index.js +1 -0
  87. package/build-module/components/recursion-provider/index.js.map +1 -1
  88. package/build-module/components/rich-text/index.js +2 -0
  89. package/build-module/components/rich-text/index.js.map +1 -1
  90. package/build-module/store/private-selectors.js +24 -0
  91. package/build-module/store/private-selectors.js.map +1 -1
  92. package/build-module/store/selectors.js +26 -7
  93. package/build-module/store/selectors.js.map +1 -1
  94. package/build-types/components/block-context/index.d.ts.map +1 -1
  95. package/package.json +34 -34
  96. package/src/components/block-actions/index.js +6 -1
  97. package/src/components/block-context/index.js +1 -0
  98. package/src/components/block-draggable/test/helpers.native.js +8 -8
  99. package/src/components/block-edit/context.js +2 -0
  100. package/src/components/block-list/index.js +2 -0
  101. package/src/components/block-list/layout.js +1 -0
  102. package/src/components/block-list/private-block-context.js +1 -0
  103. package/src/components/block-popover/inbetween.js +1 -8
  104. package/src/components/block-toolbar/block-name-context.js +1 -0
  105. package/src/components/block-tools/insertion-point.js +1 -0
  106. package/src/components/block-tools/use-show-block-tools.js +1 -1
  107. package/src/components/global-styles/context.js +1 -0
  108. package/src/components/image-editor/context.js +1 -0
  109. package/src/components/inserter/hooks/use-insertion-point.js +1 -1
  110. package/src/components/inserter/index.js +1 -3
  111. package/src/components/inserter-listbox/context.js +1 -0
  112. package/src/components/inserter-listbox/index.js +10 -1
  113. package/src/components/list-view/appender.js +13 -6
  114. package/src/components/list-view/context.js +1 -0
  115. package/src/components/provider/block-refs-provider.js +1 -0
  116. package/src/components/recursion-provider/index.js +1 -0
  117. package/src/components/rich-text/index.js +3 -0
  118. package/src/store/private-selectors.js +29 -0
  119. package/src/store/selectors.js +42 -6
  120. package/tsconfig.tsbuildinfo +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/block-context/index.js"],"names":[],"mappings":"AAkBA;;;;;;GAMG;AACH,0DAFW,yBAAyB,+BAUnC;;wBA5Ba,OAAO,OAAO,EAAE,SAAS;;;;;;WAKzB,MAAM,CAAC,MAAM,EAAC,GAAC,CAAC;;;;cAEhB,SAAS;;AAPvB,qDAAqD;AAErD;;;;;;GAMG;AAEH,wDAAwD;AACxD,uBADW,OAAO,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAC,GAAC,CAAC,CAAC,CAChB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/block-context/index.js"],"names":[],"mappings":"AAmBA;;;;;;GAMG;AACH,0DAFW,yBAAyB,+BAUnC;;wBA7Ba,OAAO,OAAO,EAAE,SAAS;;;;;;WAKzB,MAAM,CAAC,MAAM,EAAC,GAAC,CAAC;;;;cAEhB,SAAS;;AAPvB,qDAAqD;AAErD;;;;;;GAMG;AAEH,wDAAwD;AACxD,uBADW,OAAO,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAC,GAAC,CAAC,CAAC,CAChB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/block-editor",
3
- "version": "15.2.1-next.f34ab90e9.0",
3
+ "version": "15.3.1-next.836ecdcae.0",
4
4
  "description": "Generic block editor.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -37,38 +37,38 @@
37
37
  "@emotion/react": "^11.7.1",
38
38
  "@emotion/styled": "^11.6.0",
39
39
  "@react-spring/web": "^9.4.5",
40
- "@wordpress/a11y": "^4.29.1-next.f34ab90e9.0",
41
- "@wordpress/api-fetch": "^7.29.1-next.f34ab90e9.0",
42
- "@wordpress/blob": "^4.29.1-next.f34ab90e9.0",
43
- "@wordpress/block-serialization-default-parser": "^5.29.1-next.f34ab90e9.0",
44
- "@wordpress/blocks": "^15.2.1-next.f34ab90e9.0",
45
- "@wordpress/commands": "^1.29.1-next.f34ab90e9.0",
46
- "@wordpress/components": "^30.2.1-next.f34ab90e9.0",
47
- "@wordpress/compose": "^7.29.1-next.f34ab90e9.0",
48
- "@wordpress/data": "^10.29.1-next.f34ab90e9.0",
49
- "@wordpress/date": "^5.29.1-next.f34ab90e9.0",
50
- "@wordpress/deprecated": "^4.29.1-next.f34ab90e9.0",
51
- "@wordpress/dom": "^4.29.1-next.f34ab90e9.0",
52
- "@wordpress/element": "^6.29.1-next.f34ab90e9.0",
53
- "@wordpress/escape-html": "^3.29.1-next.f34ab90e9.0",
54
- "@wordpress/hooks": "^4.29.1-next.f34ab90e9.0",
55
- "@wordpress/html-entities": "^4.29.1-next.f34ab90e9.0",
56
- "@wordpress/i18n": "^6.2.1-next.f34ab90e9.0",
57
- "@wordpress/icons": "^10.29.1-next.f34ab90e9.0",
58
- "@wordpress/is-shallow-equal": "^5.29.1-next.f34ab90e9.0",
59
- "@wordpress/keyboard-shortcuts": "^5.29.1-next.f34ab90e9.0",
60
- "@wordpress/keycodes": "^4.29.1-next.f34ab90e9.0",
61
- "@wordpress/notices": "^5.29.1-next.f34ab90e9.0",
62
- "@wordpress/preferences": "^4.29.1-next.f34ab90e9.0",
63
- "@wordpress/priority-queue": "^3.29.1-next.f34ab90e9.0",
64
- "@wordpress/private-apis": "^1.29.1-next.f34ab90e9.0",
65
- "@wordpress/rich-text": "^7.29.1-next.f34ab90e9.0",
66
- "@wordpress/style-engine": "^2.29.1-next.f34ab90e9.0",
67
- "@wordpress/token-list": "^3.29.1-next.f34ab90e9.0",
68
- "@wordpress/upload-media": "^0.14.1-next.f34ab90e9.0",
69
- "@wordpress/url": "^4.29.1-next.f34ab90e9.0",
70
- "@wordpress/warning": "^3.29.1-next.f34ab90e9.0",
71
- "@wordpress/wordcount": "^4.29.1-next.f34ab90e9.0",
40
+ "@wordpress/a11y": "^4.30.1-next.836ecdcae.0",
41
+ "@wordpress/api-fetch": "^7.30.1-next.836ecdcae.0",
42
+ "@wordpress/blob": "^4.30.1-next.836ecdcae.0",
43
+ "@wordpress/block-serialization-default-parser": "^5.30.1-next.836ecdcae.0",
44
+ "@wordpress/blocks": "^15.3.1-next.836ecdcae.0",
45
+ "@wordpress/commands": "^1.30.1-next.836ecdcae.0",
46
+ "@wordpress/components": "^30.3.2-next.836ecdcae.0",
47
+ "@wordpress/compose": "^7.30.1-next.836ecdcae.0",
48
+ "@wordpress/data": "^10.30.1-next.836ecdcae.0",
49
+ "@wordpress/date": "^5.30.1-next.836ecdcae.0",
50
+ "@wordpress/deprecated": "^4.30.1-next.836ecdcae.0",
51
+ "@wordpress/dom": "^4.30.1-next.836ecdcae.0",
52
+ "@wordpress/element": "^6.30.1-next.836ecdcae.0",
53
+ "@wordpress/escape-html": "^3.30.1-next.836ecdcae.0",
54
+ "@wordpress/hooks": "^4.30.1-next.836ecdcae.0",
55
+ "@wordpress/html-entities": "^4.30.1-next.836ecdcae.0",
56
+ "@wordpress/i18n": "^6.3.1-next.836ecdcae.0",
57
+ "@wordpress/icons": "^10.30.1-next.836ecdcae.0",
58
+ "@wordpress/is-shallow-equal": "^5.30.1-next.836ecdcae.0",
59
+ "@wordpress/keyboard-shortcuts": "^5.30.1-next.836ecdcae.0",
60
+ "@wordpress/keycodes": "^4.30.1-next.836ecdcae.0",
61
+ "@wordpress/notices": "^5.30.1-next.836ecdcae.0",
62
+ "@wordpress/preferences": "^4.30.1-next.836ecdcae.0",
63
+ "@wordpress/priority-queue": "^3.30.1-next.836ecdcae.0",
64
+ "@wordpress/private-apis": "^1.30.1-next.836ecdcae.0",
65
+ "@wordpress/rich-text": "^7.30.1-next.836ecdcae.0",
66
+ "@wordpress/style-engine": "^2.30.1-next.836ecdcae.0",
67
+ "@wordpress/token-list": "^3.30.1-next.836ecdcae.0",
68
+ "@wordpress/upload-media": "^0.15.1-next.836ecdcae.0",
69
+ "@wordpress/url": "^4.30.1-next.836ecdcae.0",
70
+ "@wordpress/warning": "^3.30.1-next.836ecdcae.0",
71
+ "@wordpress/wordcount": "^4.30.1-next.836ecdcae.0",
72
72
  "change-case": "^4.1.2",
73
73
  "clsx": "^2.1.1",
74
74
  "colord": "^2.7.0",
@@ -91,5 +91,5 @@
91
91
  "publishConfig": {
92
92
  "access": "public"
93
93
  },
94
- "gitHead": "91f58004986ec6faf118825f925ac7873d171986"
94
+ "gitHead": "3e60b4c1e78d7b27acbf1d7dd172bbd64358a0f2"
95
95
  }
@@ -43,7 +43,12 @@ export default function BlockActions( {
43
43
 
44
44
  return {
45
45
  canRemove: canRemoveBlocks( clientIds ),
46
- canInsertBlock: canInsertDefaultBlock || !! directInsertBlock,
46
+ canInsertBlock: blocks.every( ( block ) => {
47
+ return (
48
+ ( canInsertDefaultBlock || !! directInsertBlock ) &&
49
+ canInsertBlockType( block.name, rootClientId )
50
+ );
51
+ } ),
47
52
  canCopyStyles: blocks.every( ( block ) => {
48
53
  return (
49
54
  !! block &&
@@ -15,6 +15,7 @@ import { createContext, useContext, useMemo } from '@wordpress/element';
15
15
 
16
16
  /** @type {import('react').Context<Record<string,*>>} */
17
17
  const Context = createContext( {} );
18
+ Context.displayName = 'BlockContext';
18
19
 
19
20
  /**
20
21
  * Component which merges passed value with current consumed block context.
@@ -108,11 +108,11 @@ export const initializeWithBlocksLayouts = async ( blocks ) => {
108
108
  /**
109
109
  * Fires long-press gesture event on a block.
110
110
  *
111
- * @param {import('react-test-renderer').ReactTestInstance} block Block test instance.
112
- * @param {string} testID Id for querying the draggable trigger element.
113
- * @param {Object} [options] Configuration options for the gesture event.
114
- * @param {boolean} [options.failed] Determines if the gesture should fail.
115
- * @param {number} [options.triggerIndex] In case there are multiple draggable triggers, this specifies the index to use.
111
+ * @param {ReturnType<import('@testing-library/react-native').RenderAPI['getByTestId']>} block Block test instance.
112
+ * @param {string} testID Id for querying the draggable trigger element.
113
+ * @param {Object} [options] Configuration options for the gesture event.
114
+ * @param {boolean} [options.failed] Determines if the gesture should fail.
115
+ * @param {number} [options.triggerIndex] In case there are multiple draggable triggers, this specifies the index to use.
116
116
  */
117
117
  export const fireLongPress = (
118
118
  block,
@@ -140,8 +140,8 @@ export const fireLongPress = (
140
140
  /**
141
141
  * Fires pan gesture event on a BlockDraggable component.
142
142
  *
143
- * @param {import('react-test-renderer').ReactTestInstance} blockDraggable BlockDraggable test instance.
144
- * @param {Object} [touchEvents] Array of touch events to dispatch on the pan gesture.
143
+ * @param {ReturnType<import('@testing-library/react-native').RenderAPI['getByTestId']>} blockDraggable BlockDraggable test instance.
144
+ * @param {Object} [touchEvents] Array of touch events to dispatch on the pan gesture.
145
145
  */
146
146
  export const firePanGesture = (
147
147
  blockDraggable,
@@ -169,7 +169,7 @@ export const firePanGesture = (
169
169
  *
170
170
  * @param {import('@testing-library/react-native').RenderAPI} screen The Testing Library screen.
171
171
  *
172
- * @return {import('react-test-renderer').ReactTestInstance} Draggable chip test instance.
172
+ * @return {ReturnType<import('@testing-library/react-native').RenderAPI['getByTestId']>} Draggable chip test instance.
173
173
  */
174
174
  export const getDraggableChip = ( { getByTestId } ) => {
175
175
  let draggableChip;
@@ -15,6 +15,8 @@ export const DEFAULT_BLOCK_EDIT_CONTEXT = {
15
15
  };
16
16
 
17
17
  const Context = createContext( DEFAULT_BLOCK_EDIT_CONTEXT );
18
+ Context.displayName = 'BlockEditContext';
19
+
18
20
  const { Provider } = Context;
19
21
 
20
22
  export { Provider as BlockEditContextProvider };
@@ -40,6 +40,8 @@ import { ZoomOutSeparator } from './zoom-out-separator';
40
40
  import { unlock } from '../../lock-unlock';
41
41
 
42
42
  export const IntersectionObserver = createContext();
43
+ IntersectionObserver.displayName = 'IntersectionObserverContext';
44
+
43
45
  const pendingBlockVisibilityUpdatesPerRegistry = new WeakMap();
44
46
 
45
47
  function Root( { className, ...settings } ) {
@@ -12,6 +12,7 @@ import { useSettings } from '../use-settings';
12
12
  export const defaultLayout = { type: 'default' };
13
13
 
14
14
  const Layout = createContext( defaultLayout );
15
+ Layout.displayName = 'BlockLayoutContext';
15
16
 
16
17
  /**
17
18
  * Allows to define the layout.
@@ -4,3 +4,4 @@
4
4
  import { createContext } from '@wordpress/element';
5
5
 
6
6
  export const PrivateBlockContext = createContext( {} );
7
+ PrivateBlockContext.displayName = 'PrivateBlockContext';
@@ -7,12 +7,7 @@ import clsx from 'clsx';
7
7
  * WordPress dependencies
8
8
  */
9
9
  import { useSelect } from '@wordpress/data';
10
- import {
11
- useMemo,
12
- createContext,
13
- useReducer,
14
- useLayoutEffect,
15
- } from '@wordpress/element';
10
+ import { useMemo, useReducer, useLayoutEffect } from '@wordpress/element';
16
11
  import { Popover } from '@wordpress/components';
17
12
  import { isRTL } from '@wordpress/i18n';
18
13
 
@@ -25,8 +20,6 @@ import usePopoverScroll from './use-popover-scroll';
25
20
 
26
21
  const MAX_POPOVER_RECOMPUTE_COUNTER = Number.MAX_SAFE_INTEGER;
27
22
 
28
- export const InsertionPointOpenRef = createContext();
29
-
30
23
  function BlockPopoverInbetween( {
31
24
  previousClientId,
32
25
  nextClientId,
@@ -4,5 +4,6 @@
4
4
  import { createContext } from '@wordpress/element';
5
5
 
6
6
  const __unstableBlockNameContext = createContext( '' );
7
+ __unstableBlockNameContext.displayName = '__unstableBlockNameContext';
7
8
 
8
9
  export default __unstableBlockNameContext;
@@ -21,6 +21,7 @@ import BlockDropZonePopover from '../block-popover/drop-zone';
21
21
  import { unlock } from '../../lock-unlock';
22
22
 
23
23
  export const InsertionPointOpenRef = createContext();
24
+ InsertionPointOpenRef.displayName = 'InsertionPointOpenRefContext';
24
25
 
25
26
  function InbetweenInsertionPointPopover( {
26
27
  __unstablePopoverSlot,
@@ -36,7 +36,7 @@ export function useShowBlockTools() {
36
36
  const hasSelectedBlock = !! clientId && !! block;
37
37
  const isEmptyDefaultBlock =
38
38
  hasSelectedBlock &&
39
- isUnmodifiedDefaultBlock( block ) &&
39
+ isUnmodifiedDefaultBlock( block, 'content' ) &&
40
40
  getBlockMode( clientId ) !== 'html';
41
41
  const _showEmptyBlockSideInserter =
42
42
  clientId &&
@@ -13,3 +13,4 @@ export const DEFAULT_GLOBAL_STYLES_CONTEXT = {
13
13
  export const GlobalStylesContext = createContext(
14
14
  DEFAULT_GLOBAL_STYLES_CONTEXT
15
15
  );
16
+ GlobalStylesContext.displayName = 'GlobalStylesContext';
@@ -10,6 +10,7 @@ import useSaveImage from './use-save-image';
10
10
  import useTransformImage from './use-transform-image';
11
11
 
12
12
  const ImageEditingContext = createContext( {} );
13
+ ImageEditingContext.displayName = 'ImageEditingContext';
13
14
 
14
15
  export const useImageEditingContext = () => useContext( ImageEditingContext );
15
16
 
@@ -151,7 +151,7 @@ function useInsertionPoint( {
151
151
  if (
152
152
  ! isAppender &&
153
153
  selectedBlock &&
154
- isUnmodifiedDefaultBlock( selectedBlock )
154
+ isUnmodifiedDefaultBlock( selectedBlock, 'content' )
155
155
  ) {
156
156
  replaceBlocks(
157
157
  selectedBlock.clientId,
@@ -386,9 +386,7 @@ export default compose( [
386
386
  );
387
387
 
388
388
  if ( onSelectOrClose ) {
389
- onSelectOrClose( {
390
- clientId: blockToInsert?.clientId,
391
- } );
389
+ onSelectOrClose( blockToInsert );
392
390
  }
393
391
 
394
392
  const message = sprintf(
@@ -4,5 +4,6 @@
4
4
  import { createContext } from '@wordpress/element';
5
5
 
6
6
  const InserterListboxContext = createContext();
7
+ InserterListboxContext.displayName = 'InserterListboxContext';
7
8
 
8
9
  export default InserterListboxContext;
@@ -2,6 +2,7 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { Composite } from '@wordpress/components';
5
+ import { Fragment } from '@wordpress/element';
5
6
 
6
7
  /**
7
8
  * Internal dependencies
@@ -11,9 +12,17 @@ export { default as InserterListboxGroup } from './group';
11
12
  export { default as InserterListboxRow } from './row';
12
13
  export { default as InserterListboxItem } from './item';
13
14
 
15
+ function InserterListBoxWrapper( { key, children } ) {
16
+ return <Fragment key={ key }>{ children }</Fragment>;
17
+ }
18
+
14
19
  function InserterListbox( { children } ) {
15
20
  return (
16
- <Composite focusShift focusWrap="horizontal" render={ <></> }>
21
+ <Composite
22
+ focusShift
23
+ focusWrap="horizontal"
24
+ render={ InserterListBoxWrapper }
25
+ >
17
26
  { children }
18
27
  </Composite>
19
28
  );
@@ -22,13 +22,20 @@ export const Appender = forwardRef(
22
22
  const { insertedBlock, setInsertedBlock } = useListViewContext();
23
23
 
24
24
  const instanceId = useInstanceId( Appender );
25
- const hideInserter = useSelect(
25
+ const { directInsert, hideInserter } = useSelect(
26
26
  ( select ) => {
27
- const { getTemplateLock, isZoomOut } = unlock(
28
- select( blockEditorStore )
29
- );
27
+ const { getBlockListSettings, getTemplateLock, isZoomOut } =
28
+ unlock( select( blockEditorStore ) );
30
29
 
31
- return !! getTemplateLock( clientId ) || isZoomOut();
30
+ const settings = getBlockListSettings( clientId );
31
+ const directInsertValue = settings?.directInsert || false;
32
+ const hideInserterValue =
33
+ !! getTemplateLock( clientId ) || isZoomOut();
34
+
35
+ return {
36
+ directInsert: directInsertValue,
37
+ hideInserter: hideInserterValue,
38
+ };
32
39
  },
33
40
  [ clientId ]
34
41
  );
@@ -79,7 +86,7 @@ export const Appender = forwardRef(
79
86
  position="bottom right"
80
87
  isAppender
81
88
  selectBlockOnInsert={ false }
82
- shouldDirectInsert={ false }
89
+ shouldDirectInsert={ directInsert }
83
90
  __experimentalIsQuick
84
91
  { ...props }
85
92
  toggleProps={ { 'aria-describedby': descriptionId } }
@@ -4,5 +4,6 @@
4
4
  import { createContext, useContext } from '@wordpress/element';
5
5
 
6
6
  export const ListViewContext = createContext( {} );
7
+ ListViewContext.displayName = 'ListViewContext';
7
8
 
8
9
  export const useListViewContext = () => useContext( ListViewContext );
@@ -5,6 +5,7 @@ import { createContext, useMemo } from '@wordpress/element';
5
5
  import { observableMap } from '@wordpress/compose';
6
6
 
7
7
  export const BlockRefs = createContext( { refsMap: observableMap() } );
8
+ BlockRefs.displayName = 'BlockRefsContext';
8
9
 
9
10
  export function BlockRefsProvider( { children } ) {
10
11
  const value = useMemo( () => ( { refsMap: observableMap() } ), [] );
@@ -10,6 +10,7 @@ import deprecated from '@wordpress/deprecated';
10
10
  import { useBlockEditContext } from '../block-edit/context';
11
11
 
12
12
  const RenderedRefsContext = createContext( {} );
13
+ RenderedRefsContext.displayName = 'RenderedRefsContext';
13
14
 
14
15
  /**
15
16
  * Immutably adds an unique identifier to a set scoped for a given block type.
@@ -43,7 +43,10 @@ import { canBindBlock } from '../../utils/block-bindings';
43
43
  import BlockContext from '../block-context';
44
44
 
45
45
  export const keyboardShortcutContext = createContext();
46
+ keyboardShortcutContext.displayName = 'keyboardShortcutContext';
47
+
46
48
  export const inputEventContext = createContext();
49
+ inputEventContext.displayName = 'inputEventContext';
47
50
 
48
51
  const instanceIdKey = Symbol( 'instanceId' );
49
52
 
@@ -2,6 +2,7 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { createSelector, createRegistrySelector } from '@wordpress/data';
5
+ import { privateApis as blocksPrivateApis } from '@wordpress/blocks';
5
6
 
6
7
  /**
7
8
  * Internal dependencies
@@ -33,6 +34,8 @@ import {
33
34
  sectionRootClientIdKey,
34
35
  } from './private-keys';
35
36
 
37
+ const { isContentBlock } = unlock( blocksPrivateApis );
38
+
36
39
  export { getBlockSettings } from './get-block-settings';
37
40
 
38
41
  /**
@@ -81,6 +84,32 @@ export const isBlockSubtreeDisabled = ( state, clientId ) => {
81
84
  return getBlockOrder( state, clientId ).every( isChildSubtreeDisabled );
82
85
  };
83
86
 
87
+ /**
88
+ * Determines if a container (clientId) allows insertion of blocks, considering contentOnly mode restrictions.
89
+ *
90
+ * @param {Object} state Editor state.
91
+ * @param {string} blockName The block name to insert.
92
+ * @param {string} rootClientId The client ID of the root container block.
93
+ * @return {boolean} Whether the container allows insertion.
94
+ */
95
+ export function isContainerInsertableToInWriteMode(
96
+ state,
97
+ blockName,
98
+ rootClientId
99
+ ) {
100
+ const isBlockContentBlock = isContentBlock( blockName );
101
+ const rootBlockName = getBlockName( state, rootClientId );
102
+ const isContainerContentBlock = isContentBlock( rootBlockName );
103
+ const isRootBlockMain = getSectionRootClientId( state ) === rootClientId;
104
+
105
+ // In write mode, containers shouldn't be inserted into unless:
106
+ // 1. they are a section root;
107
+ // 2. they are a content block and the block to be inserted is also content.
108
+ return (
109
+ isRootBlockMain || ( isContainerContentBlock && isBlockContentBlock )
110
+ );
111
+ }
112
+
84
113
  function getEnabledClientIdsTreeUnmemoized( state, rootClientId ) {
85
114
  const blockOrder = getBlockOrder( state, rootClientId );
86
115
  const result = [];
@@ -9,6 +9,7 @@ import {
9
9
  getPossibleBlockTransformations,
10
10
  switchToBlockType,
11
11
  store as blocksStore,
12
+ privateApis as blocksPrivateApis,
12
13
  } from '@wordpress/blocks';
13
14
  import { Platform } from '@wordpress/element';
14
15
  import { applyFilters } from '@wordpress/hooks';
@@ -42,8 +43,11 @@ import {
42
43
  isSectionBlock,
43
44
  getParentSectionBlock,
44
45
  isZoomOut,
46
+ isContainerInsertableToInWriteMode,
45
47
  } from './private-selectors';
46
48
 
49
+ const { isContentBlock } = unlock( blocksPrivateApis );
50
+
47
51
  /**
48
52
  * A block selection object.
49
53
  *
@@ -1682,13 +1686,16 @@ const canInsertBlockTypeUnmemoized = (
1682
1686
  if ( isLocked ) {
1683
1687
  return false;
1684
1688
  }
1685
-
1686
- const _isSectionBlock = !! isSectionBlock( state, rootClientId );
1687
- if ( _isSectionBlock ) {
1689
+ const isContentRoleBlock = isContentBlock( blockName );
1690
+ const isParentSectionBlock = !! isSectionBlock( state, rootClientId );
1691
+ // It shouldn't be possible to insert inside a section block unless in
1692
+ // some cases when the block is a content block.
1693
+ if ( isParentSectionBlock && ! isContentRoleBlock ) {
1688
1694
  return false;
1689
1695
  }
1690
1696
 
1691
- if ( getBlockEditingMode( state, rootClientId ?? '' ) === 'disabled' ) {
1697
+ const blockEditingMode = getBlockEditingMode( state, rootClientId ?? '' );
1698
+ if ( blockEditingMode === 'disabled' ) {
1692
1699
  return false;
1693
1700
  }
1694
1701
 
@@ -1700,11 +1707,22 @@ const canInsertBlockTypeUnmemoized = (
1700
1707
  return false;
1701
1708
  }
1702
1709
 
1710
+ // In write mode, check if this container allows insertion.
1711
+ if (
1712
+ blockEditingMode === 'contentOnly' &&
1713
+ isNavigationMode( state ) &&
1714
+ ! isContainerInsertableToInWriteMode( state, blockName, rootClientId )
1715
+ ) {
1716
+ return false;
1717
+ }
1718
+
1703
1719
  const parentName = getBlockName( state, rootClientId );
1720
+
1704
1721
  const parentBlockType = getBlockType( parentName );
1705
1722
 
1706
1723
  // Look at the `blockType.allowedBlocks` field to determine whether this is an allowed child block.
1707
1724
  const parentAllowedChildBlocks = parentBlockType?.allowedBlocks;
1725
+
1708
1726
  let hasParentAllowedBlock = checkAllowList(
1709
1727
  parentAllowedChildBlocks,
1710
1728
  blockName
@@ -1842,11 +1860,29 @@ export function canRemoveBlock( state, clientId ) {
1842
1860
  }
1843
1861
 
1844
1862
  const isBlockWithinSection = !! getParentSectionBlock( state, clientId );
1845
- if ( isBlockWithinSection ) {
1863
+ const isContentRoleBlock = isContentBlock(
1864
+ getBlockName( state, clientId )
1865
+ );
1866
+ if ( isBlockWithinSection && ! isContentRoleBlock ) {
1846
1867
  return false;
1847
1868
  }
1848
1869
 
1849
- return getBlockEditingMode( state, rootClientId ) !== 'disabled';
1870
+ const blockEditingMode = getBlockEditingMode( state, rootClientId );
1871
+
1872
+ // Check if the parent container allows insertion/removal in write mode
1873
+ if (
1874
+ blockEditingMode === 'contentOnly' &&
1875
+ isNavigationMode( state ) &&
1876
+ ! isContainerInsertableToInWriteMode(
1877
+ state,
1878
+ getBlockName( state, rootClientId ),
1879
+ rootClientId
1880
+ )
1881
+ ) {
1882
+ return false;
1883
+ }
1884
+
1885
+ return blockEditingMode !== 'disabled';
1850
1886
  }
1851
1887
 
1852
1888
  /**