@wordpress/block-editor 15.10.1-next.v.0 → 15.11.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-edit/context.cjs +5 -0
- package/build/components/block-edit/context.cjs.map +2 -2
- package/build/components/block-edit/index.cjs +3 -0
- package/build/components/block-edit/index.cjs.map +2 -2
- package/build/components/block-inspector/index.cjs +2 -9
- package/build/components/block-inspector/index.cjs.map +2 -2
- package/build/components/block-list/block.cjs +3 -0
- package/build/components/block-list/block.cjs.map +2 -2
- package/build/components/button-block-appender/index.cjs +23 -19
- package/build/components/button-block-appender/index.cjs.map +2 -2
- package/build/components/font-sizes/font-size-picker.cjs +2 -1
- package/build/components/font-sizes/font-size-picker.cjs.map +2 -2
- package/build/components/inspector-controls/fill.cjs +4 -25
- package/build/components/inspector-controls/fill.cjs.map +2 -2
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.cjs +6 -6
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.cjs.map +2 -2
- package/build/hooks/block-fields/index.cjs +52 -86
- package/build/hooks/block-fields/index.cjs.map +3 -3
- package/build/hooks/block-fields/link/index.cjs +2 -11
- package/build/hooks/block-fields/link/index.cjs.map +2 -2
- package/build/hooks/block-fields/media/index.cjs +9 -14
- package/build/hooks/block-fields/media/index.cjs.map +2 -2
- package/build/hooks/index.cjs +2 -1
- package/build/hooks/index.cjs.map +3 -3
- package/build/hooks/list-view.cjs +27 -10
- package/build/hooks/list-view.cjs.map +2 -2
- package/build/hooks/utils.cjs +3 -2
- package/build/hooks/utils.cjs.map +2 -2
- package/build/store/selectors.cjs +7 -1
- package/build/store/selectors.cjs.map +2 -2
- package/build-module/components/block-edit/context.mjs +4 -0
- package/build-module/components/block-edit/context.mjs.map +2 -2
- package/build-module/components/block-edit/index.mjs +4 -0
- package/build-module/components/block-edit/index.mjs.map +2 -2
- package/build-module/components/block-inspector/index.mjs +2 -9
- package/build-module/components/block-inspector/index.mjs.map +2 -2
- package/build-module/components/block-list/block.mjs +3 -0
- package/build-module/components/block-list/block.mjs.map +2 -2
- package/build-module/components/button-block-appender/index.mjs +23 -19
- package/build-module/components/button-block-appender/index.mjs.map +2 -2
- package/build-module/components/font-sizes/font-size-picker.mjs +2 -1
- package/build-module/components/font-sizes/font-size-picker.mjs.map +2 -2
- package/build-module/components/inspector-controls/fill.mjs +6 -22
- package/build-module/components/inspector-controls/fill.mjs.map +2 -2
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.mjs +6 -6
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.mjs.map +2 -2
- package/build-module/hooks/block-fields/index.mjs +45 -87
- package/build-module/hooks/block-fields/index.mjs.map +2 -2
- package/build-module/hooks/block-fields/link/index.mjs +2 -11
- package/build-module/hooks/block-fields/link/index.mjs.map +2 -2
- package/build-module/hooks/block-fields/media/index.mjs +9 -14
- package/build-module/hooks/block-fields/media/index.mjs.map +2 -2
- package/build-module/hooks/index.mjs +2 -1
- package/build-module/hooks/index.mjs.map +2 -2
- package/build-module/hooks/list-view.mjs +27 -10
- package/build-module/hooks/list-view.mjs.map +2 -2
- package/build-module/hooks/utils.mjs +5 -3
- package/build-module/hooks/utils.mjs.map +2 -2
- package/build-module/store/selectors.mjs +7 -1
- package/build-module/store/selectors.mjs.map +2 -2
- package/package.json +39 -39
- package/src/components/block-edit/context.js +3 -0
- package/src/components/block-edit/index.js +6 -0
- package/src/components/block-inspector/index.js +2 -6
- package/src/components/block-list/block.js +3 -0
- package/src/components/block-list/block.native.js +5 -0
- package/src/components/block-patterns-list/stories/index.story.jsx +1 -1
- package/src/components/button-block-appender/index.js +2 -2
- package/src/components/font-sizes/font-size-picker.js +1 -0
- package/src/components/inspector-controls/fill.js +10 -20
- package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +11 -8
- package/src/hooks/block-fields/index.js +66 -111
- package/src/hooks/block-fields/link/index.js +2 -14
- package/src/hooks/block-fields/media/index.js +9 -21
- package/src/hooks/index.js +2 -1
- package/src/hooks/list-view.js +40 -10
- package/src/hooks/utils.js +4 -0
- package/src/store/selectors.js +14 -6
- /package/src/components/block-icon/stories/{index.story.js → index.story.ts} +0 -0
- /package/src/components/contrast-checker/stories/{index.story.js → index.story.ts} +0 -0
|
@@ -25,8 +25,7 @@ import { getMediaSelectKey } from '../../../store/private-keys';
|
|
|
25
25
|
import { store as blockEditorStore } from '../../../store';
|
|
26
26
|
|
|
27
27
|
function MediaThumbnail( { data, field, attachment, config } ) {
|
|
28
|
-
const {
|
|
29
|
-
const { allowedTypes = [], multiple = false } = fieldDef.args || {};
|
|
28
|
+
const { allowedTypes = [], multiple = false } = config || {};
|
|
30
29
|
|
|
31
30
|
if ( multiple ) {
|
|
32
31
|
return 'todo multiple';
|
|
@@ -85,12 +84,11 @@ export default function Media( { data, field, onChange, config = {} } ) {
|
|
|
85
84
|
isControl: true,
|
|
86
85
|
} );
|
|
87
86
|
const value = field.getValue( { item: data } );
|
|
88
|
-
const {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
fieldDef?.mapping && 'featuredImage' in fieldDef.mapping;
|
|
87
|
+
const {
|
|
88
|
+
allowedTypes = [],
|
|
89
|
+
multiple = false,
|
|
90
|
+
useFeaturedImage = false,
|
|
91
|
+
} = config;
|
|
94
92
|
|
|
95
93
|
const id = value?.id;
|
|
96
94
|
const url = value?.url;
|
|
@@ -140,23 +138,14 @@ export default function Media( { data, field, onChange, config = {} } ) {
|
|
|
140
138
|
multiple={ multiple }
|
|
141
139
|
popoverProps={ popoverProps }
|
|
142
140
|
onReset={ () => {
|
|
143
|
-
// Build reset value dynamically based on mapping
|
|
144
|
-
const resetValue = {};
|
|
145
|
-
|
|
146
|
-
if ( fieldDef?.mapping ) {
|
|
147
|
-
Object.keys( fieldDef.mapping ).forEach( ( key ) => {
|
|
148
|
-
resetValue[ key ] = undefined;
|
|
149
|
-
} );
|
|
150
|
-
}
|
|
151
|
-
|
|
152
141
|
onChange(
|
|
153
142
|
field.setValue( {
|
|
154
143
|
item: data,
|
|
155
|
-
value:
|
|
144
|
+
value: {},
|
|
156
145
|
} )
|
|
157
146
|
);
|
|
158
147
|
} }
|
|
159
|
-
{ ...(
|
|
148
|
+
{ ...( useFeaturedImage && {
|
|
160
149
|
useFeaturedImage: !! value?.featuredImage,
|
|
161
150
|
onToggleFeaturedImage: () => {
|
|
162
151
|
onChange(
|
|
@@ -171,14 +160,13 @@ export default function Media( { data, field, onChange, config = {} } ) {
|
|
|
171
160
|
} ) }
|
|
172
161
|
onSelect={ ( selectedMedia ) => {
|
|
173
162
|
if ( selectedMedia.id && selectedMedia.url ) {
|
|
174
|
-
// Build new value dynamically based on what's in the mapping
|
|
175
163
|
const newValue = {
|
|
176
164
|
...selectedMedia,
|
|
177
165
|
mediaType: selectedMedia.media_type,
|
|
178
166
|
};
|
|
179
167
|
|
|
180
168
|
// Turn off featured image when manually selecting media
|
|
181
|
-
if (
|
|
169
|
+
if ( useFeaturedImage ) {
|
|
182
170
|
newValue.featuredImage = false;
|
|
183
171
|
}
|
|
184
172
|
|
package/src/hooks/index.js
CHANGED
|
@@ -14,7 +14,7 @@ import './lock';
|
|
|
14
14
|
import allowedBlocks from './allowed-blocks';
|
|
15
15
|
import anchor from './anchor';
|
|
16
16
|
import ariaLabel from './aria-label';
|
|
17
|
-
import './block-fields';
|
|
17
|
+
import blockFields from './block-fields';
|
|
18
18
|
import customClassName from './custom-class-name';
|
|
19
19
|
import './generated-class-name';
|
|
20
20
|
import style from './style';
|
|
@@ -56,6 +56,7 @@ createBlockEditFilter(
|
|
|
56
56
|
blockBindingsPanel,
|
|
57
57
|
childLayout,
|
|
58
58
|
allowedBlocks,
|
|
59
|
+
blockFields,
|
|
59
60
|
listView,
|
|
60
61
|
autoInspectorControls,
|
|
61
62
|
].filter( Boolean )
|
package/src/hooks/list-view.js
CHANGED
|
@@ -5,13 +5,15 @@ import { __ } from '@wordpress/i18n';
|
|
|
5
5
|
import { PanelBody } from '@wordpress/components';
|
|
6
6
|
import { useSelect } from '@wordpress/data';
|
|
7
7
|
import { store as blocksStore, hasBlockSupport } from '@wordpress/blocks';
|
|
8
|
+
import { useContext } from '@wordpress/element';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Internal dependencies
|
|
11
12
|
*/
|
|
12
|
-
import InspectorControls from '../components/inspector-controls';
|
|
13
13
|
import { store as blockEditorStore } from '../store';
|
|
14
14
|
import { PrivateListView } from '../components/list-view';
|
|
15
|
+
import InspectorControls from '../components/inspector-controls/fill';
|
|
16
|
+
import { PrivateBlockContext } from '../components/block-list/private-block-context';
|
|
15
17
|
|
|
16
18
|
export const LIST_VIEW_SUPPORT_KEY = 'listView';
|
|
17
19
|
|
|
@@ -34,23 +36,50 @@ export function hasListViewSupport( nameOrType ) {
|
|
|
34
36
|
* @return {Element|null} List view inspector controls or null.
|
|
35
37
|
*/
|
|
36
38
|
export function ListViewPanel( { clientId, name } ) {
|
|
39
|
+
const { isSelectionWithinCurrentSection } =
|
|
40
|
+
useContext( PrivateBlockContext );
|
|
37
41
|
const isEnabled = hasListViewSupport( name );
|
|
38
|
-
const { hasChildren, blockTitle } = useSelect(
|
|
39
|
-
( select ) =>
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
const { hasChildren, blockTitle, isNestedListView } = useSelect(
|
|
43
|
+
( select ) => {
|
|
44
|
+
const { getBlockCount, getBlockParents, getBlockName } =
|
|
45
|
+
select( blockEditorStore );
|
|
46
|
+
|
|
47
|
+
// When the ListView is shown in a section, avoid showing List Views
|
|
48
|
+
// for both parent and child blocks that have support. In this situation
|
|
49
|
+
// the parent will show the child anyway in its List.
|
|
50
|
+
// Search parents to see if there's one that also has support, and if so
|
|
51
|
+
// skip rendering.
|
|
52
|
+
// This matches closely the logic in the `BlockCard` component.
|
|
53
|
+
let _isNestedListView = false;
|
|
54
|
+
if ( isSelectionWithinCurrentSection ) {
|
|
55
|
+
const parents = getBlockParents( clientId, true );
|
|
56
|
+
_isNestedListView = parents.find( ( parentId ) => {
|
|
57
|
+
const parentName = getBlockName( parentId );
|
|
58
|
+
return (
|
|
59
|
+
parentName === 'core/navigation' ||
|
|
60
|
+
hasBlockSupport( parentName, 'listView' )
|
|
61
|
+
);
|
|
62
|
+
} );
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return {
|
|
66
|
+
hasChildren: !! getBlockCount( clientId ),
|
|
67
|
+
blockTitle: select( blocksStore ).getBlockType( name )?.title,
|
|
68
|
+
isNestedListView: _isNestedListView,
|
|
69
|
+
};
|
|
70
|
+
},
|
|
71
|
+
[ clientId, name, isSelectionWithinCurrentSection ]
|
|
45
72
|
);
|
|
46
73
|
|
|
47
|
-
if ( ! isEnabled ) {
|
|
74
|
+
if ( ! isEnabled || isNestedListView ) {
|
|
48
75
|
return null;
|
|
49
76
|
}
|
|
50
77
|
|
|
78
|
+
const showBlockTitle = isSelectionWithinCurrentSection;
|
|
79
|
+
|
|
51
80
|
return (
|
|
52
81
|
<InspectorControls group="list">
|
|
53
|
-
<PanelBody title={
|
|
82
|
+
<PanelBody title={ showBlockTitle ? blockTitle : undefined }>
|
|
54
83
|
{ ! hasChildren && (
|
|
55
84
|
<p className="block-editor-block-inspector__no-blocks">
|
|
56
85
|
{ __( 'No items yet.' ) }
|
|
@@ -74,4 +103,5 @@ export default {
|
|
|
74
103
|
edit: ListViewPanel,
|
|
75
104
|
hasSupport: hasListViewSupport,
|
|
76
105
|
attributeKeys: [],
|
|
106
|
+
supportsPatternEditing: true,
|
|
77
107
|
};
|
package/src/hooks/utils.js
CHANGED
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
useBlockEditContext,
|
|
20
20
|
mayDisplayControlsKey,
|
|
21
21
|
mayDisplayParentControlsKey,
|
|
22
|
+
mayDisplayPatternEditingControlsKey,
|
|
22
23
|
} from '../components/block-edit/context';
|
|
23
24
|
import { useSettings } from '../components';
|
|
24
25
|
import { useSettingsForBlockElement } from '../components/global-styles/hooks';
|
|
@@ -534,8 +535,11 @@ export function createBlockEditFilter( features ) {
|
|
|
534
535
|
hasSupport,
|
|
535
536
|
attributeKeys = [],
|
|
536
537
|
shareWithChildBlocks,
|
|
538
|
+
supportsPatternEditing,
|
|
537
539
|
} = feature;
|
|
538
540
|
const shouldDisplayControls =
|
|
541
|
+
( supportsPatternEditing &&
|
|
542
|
+
context[ mayDisplayPatternEditingControlsKey ] ) ||
|
|
539
543
|
context[ mayDisplayControlsKey ] ||
|
|
540
544
|
( context[ mayDisplayParentControlsKey ] &&
|
|
541
545
|
shareWithChildBlocks );
|
package/src/store/selectors.js
CHANGED
|
@@ -2279,13 +2279,21 @@ export const getInserterItems = createRegistrySelector( ( select ) =>
|
|
|
2279
2279
|
)
|
|
2280
2280
|
);
|
|
2281
2281
|
} else {
|
|
2282
|
+
const { getClosestAllowedInsertionPoint } = unlock(
|
|
2283
|
+
select( STORE_NAME )
|
|
2284
|
+
);
|
|
2282
2285
|
blockTypeInserterItems = blockTypeInserterItems
|
|
2283
|
-
.filter(
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2286
|
+
.filter(
|
|
2287
|
+
( blockType ) =>
|
|
2288
|
+
isBlockVisibleInTheInserter(
|
|
2289
|
+
state,
|
|
2290
|
+
blockType,
|
|
2291
|
+
rootClientId
|
|
2292
|
+
) &&
|
|
2293
|
+
getClosestAllowedInsertionPoint(
|
|
2294
|
+
blockType.name,
|
|
2295
|
+
rootClientId
|
|
2296
|
+
) !== null
|
|
2289
2297
|
)
|
|
2290
2298
|
.map( ( blockType ) => ( {
|
|
2291
2299
|
...blockType,
|
|
File without changes
|
|
File without changes
|