@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.
- package/CHANGELOG.md +2 -0
- package/build/components/block-actions/index.js +3 -1
- package/build/components/block-actions/index.js.map +1 -1
- package/build/components/block-context/index.js +1 -0
- package/build/components/block-context/index.js.map +1 -1
- package/build/components/block-edit/context.js +1 -0
- package/build/components/block-edit/context.js.map +1 -1
- package/build/components/block-list/index.js +1 -0
- package/build/components/block-list/index.js.map +1 -1
- package/build/components/block-list/layout.js +1 -0
- package/build/components/block-list/layout.js.map +1 -1
- package/build/components/block-list/private-block-context.js +1 -0
- package/build/components/block-list/private-block-context.js.map +1 -1
- package/build/components/block-popover/inbetween.js +1 -2
- package/build/components/block-popover/inbetween.js.map +1 -1
- package/build/components/block-toolbar/block-name-context.js +1 -0
- package/build/components/block-toolbar/block-name-context.js.map +1 -1
- package/build/components/block-tools/insertion-point.js +1 -0
- package/build/components/block-tools/insertion-point.js.map +1 -1
- package/build/components/block-tools/use-show-block-tools.js +1 -1
- package/build/components/block-tools/use-show-block-tools.js.map +1 -1
- package/build/components/global-styles/context.js +1 -0
- package/build/components/global-styles/context.js.map +1 -1
- package/build/components/image-editor/context.js +1 -0
- package/build/components/image-editor/context.js.map +1 -1
- package/build/components/inserter/hooks/use-insertion-point.js +1 -1
- package/build/components/inserter/hooks/use-insertion-point.js.map +1 -1
- package/build/components/inserter/index.js +1 -3
- package/build/components/inserter/index.js.map +1 -1
- package/build/components/inserter-listbox/context.js +1 -0
- package/build/components/inserter-listbox/context.js.map +1 -1
- package/build/components/inserter-listbox/index.js +11 -2
- package/build/components/inserter-listbox/index.js.map +1 -1
- package/build/components/list-view/appender.js +13 -3
- package/build/components/list-view/appender.js.map +1 -1
- package/build/components/list-view/context.js +1 -0
- package/build/components/list-view/context.js.map +1 -1
- package/build/components/provider/block-refs-provider.js +1 -0
- package/build/components/provider/block-refs-provider.js.map +1 -1
- package/build/components/recursion-provider/index.js +1 -0
- package/build/components/recursion-provider/index.js.map +1 -1
- package/build/components/rich-text/index.js +2 -0
- package/build/components/rich-text/index.js.map +1 -1
- package/build/store/private-selectors.js +25 -0
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/selectors.js +25 -5
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/block-actions/index.js +3 -1
- package/build-module/components/block-actions/index.js.map +1 -1
- package/build-module/components/block-context/index.js +1 -0
- package/build-module/components/block-context/index.js.map +1 -1
- package/build-module/components/block-edit/context.js +1 -0
- package/build-module/components/block-edit/context.js.map +1 -1
- package/build-module/components/block-list/index.js +1 -0
- package/build-module/components/block-list/index.js.map +1 -1
- package/build-module/components/block-list/layout.js +1 -0
- package/build-module/components/block-list/layout.js.map +1 -1
- package/build-module/components/block-list/private-block-context.js +1 -0
- package/build-module/components/block-list/private-block-context.js.map +1 -1
- package/build-module/components/block-popover/inbetween.js +1 -2
- package/build-module/components/block-popover/inbetween.js.map +1 -1
- package/build-module/components/block-toolbar/block-name-context.js +1 -0
- package/build-module/components/block-toolbar/block-name-context.js.map +1 -1
- package/build-module/components/block-tools/insertion-point.js +1 -0
- package/build-module/components/block-tools/insertion-point.js.map +1 -1
- package/build-module/components/block-tools/use-show-block-tools.js +1 -1
- package/build-module/components/block-tools/use-show-block-tools.js.map +1 -1
- package/build-module/components/global-styles/context.js +1 -0
- package/build-module/components/global-styles/context.js.map +1 -1
- package/build-module/components/image-editor/context.js +1 -0
- package/build-module/components/image-editor/context.js.map +1 -1
- package/build-module/components/inserter/hooks/use-insertion-point.js +1 -1
- package/build-module/components/inserter/hooks/use-insertion-point.js.map +1 -1
- package/build-module/components/inserter/index.js +1 -3
- package/build-module/components/inserter/index.js.map +1 -1
- package/build-module/components/inserter-listbox/context.js +1 -0
- package/build-module/components/inserter-listbox/context.js.map +1 -1
- package/build-module/components/inserter-listbox/index.js +11 -2
- package/build-module/components/inserter-listbox/index.js.map +1 -1
- package/build-module/components/list-view/appender.js +13 -3
- package/build-module/components/list-view/appender.js.map +1 -1
- package/build-module/components/list-view/context.js +1 -0
- package/build-module/components/list-view/context.js.map +1 -1
- package/build-module/components/provider/block-refs-provider.js +1 -0
- package/build-module/components/provider/block-refs-provider.js.map +1 -1
- package/build-module/components/recursion-provider/index.js +1 -0
- package/build-module/components/recursion-provider/index.js.map +1 -1
- package/build-module/components/rich-text/index.js +2 -0
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/store/private-selectors.js +24 -0
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/selectors.js +26 -7
- package/build-module/store/selectors.js.map +1 -1
- package/build-types/components/block-context/index.d.ts.map +1 -1
- package/package.json +34 -34
- package/src/components/block-actions/index.js +6 -1
- package/src/components/block-context/index.js +1 -0
- package/src/components/block-draggable/test/helpers.native.js +8 -8
- package/src/components/block-edit/context.js +2 -0
- package/src/components/block-list/index.js +2 -0
- package/src/components/block-list/layout.js +1 -0
- package/src/components/block-list/private-block-context.js +1 -0
- package/src/components/block-popover/inbetween.js +1 -8
- package/src/components/block-toolbar/block-name-context.js +1 -0
- package/src/components/block-tools/insertion-point.js +1 -0
- package/src/components/block-tools/use-show-block-tools.js +1 -1
- package/src/components/global-styles/context.js +1 -0
- package/src/components/image-editor/context.js +1 -0
- package/src/components/inserter/hooks/use-insertion-point.js +1 -1
- package/src/components/inserter/index.js +1 -3
- package/src/components/inserter-listbox/context.js +1 -0
- package/src/components/inserter-listbox/index.js +10 -1
- package/src/components/list-view/appender.js +13 -6
- package/src/components/list-view/context.js +1 -0
- package/src/components/provider/block-refs-provider.js +1 -0
- package/src/components/recursion-provider/index.js +1 -0
- package/src/components/rich-text/index.js +3 -0
- package/src/store/private-selectors.js +29 -0
- package/src/store/selectors.js +42 -6
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/block-context/index.js"],"names":[],"mappings":"
|
|
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.
|
|
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.
|
|
41
|
-
"@wordpress/api-fetch": "^7.
|
|
42
|
-
"@wordpress/blob": "^4.
|
|
43
|
-
"@wordpress/block-serialization-default-parser": "^5.
|
|
44
|
-
"@wordpress/blocks": "^15.
|
|
45
|
-
"@wordpress/commands": "^1.
|
|
46
|
-
"@wordpress/components": "^30.2
|
|
47
|
-
"@wordpress/compose": "^7.
|
|
48
|
-
"@wordpress/data": "^10.
|
|
49
|
-
"@wordpress/date": "^5.
|
|
50
|
-
"@wordpress/deprecated": "^4.
|
|
51
|
-
"@wordpress/dom": "^4.
|
|
52
|
-
"@wordpress/element": "^6.
|
|
53
|
-
"@wordpress/escape-html": "^3.
|
|
54
|
-
"@wordpress/hooks": "^4.
|
|
55
|
-
"@wordpress/html-entities": "^4.
|
|
56
|
-
"@wordpress/i18n": "^6.
|
|
57
|
-
"@wordpress/icons": "^10.
|
|
58
|
-
"@wordpress/is-shallow-equal": "^5.
|
|
59
|
-
"@wordpress/keyboard-shortcuts": "^5.
|
|
60
|
-
"@wordpress/keycodes": "^4.
|
|
61
|
-
"@wordpress/notices": "^5.
|
|
62
|
-
"@wordpress/preferences": "^4.
|
|
63
|
-
"@wordpress/priority-queue": "^3.
|
|
64
|
-
"@wordpress/private-apis": "^1.
|
|
65
|
-
"@wordpress/rich-text": "^7.
|
|
66
|
-
"@wordpress/style-engine": "^2.
|
|
67
|
-
"@wordpress/token-list": "^3.
|
|
68
|
-
"@wordpress/upload-media": "^0.
|
|
69
|
-
"@wordpress/url": "^4.
|
|
70
|
-
"@wordpress/warning": "^3.
|
|
71
|
-
"@wordpress/wordcount": "^4.
|
|
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": "
|
|
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:
|
|
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-
|
|
112
|
-
* @param {string}
|
|
113
|
-
* @param {Object}
|
|
114
|
-
* @param {boolean}
|
|
115
|
-
* @param {number}
|
|
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-
|
|
144
|
-
* @param {Object}
|
|
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-
|
|
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;
|
|
@@ -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 } ) {
|
|
@@ -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,
|
|
@@ -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 &&
|
|
@@ -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
|
|
|
@@ -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
|
|
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 } =
|
|
28
|
-
select( blockEditorStore )
|
|
29
|
-
);
|
|
27
|
+
const { getBlockListSettings, getTemplateLock, isZoomOut } =
|
|
28
|
+
unlock( select( blockEditorStore ) );
|
|
30
29
|
|
|
31
|
-
|
|
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={
|
|
89
|
+
shouldDirectInsert={ directInsert }
|
|
83
90
|
__experimentalIsQuick
|
|
84
91
|
{ ...props }
|
|
85
92
|
toggleProps={ { 'aria-describedby': descriptionId } }
|
|
@@ -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 = [];
|
package/src/store/selectors.js
CHANGED
|
@@ -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
|
|
1687
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1863
|
+
const isContentRoleBlock = isContentBlock(
|
|
1864
|
+
getBlockName( state, clientId )
|
|
1865
|
+
);
|
|
1866
|
+
if ( isBlockWithinSection && ! isContentRoleBlock ) {
|
|
1846
1867
|
return false;
|
|
1847
1868
|
}
|
|
1848
1869
|
|
|
1849
|
-
|
|
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
|
/**
|